⭐️⭐️⭐️ 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
feat: per-team project keys and team-first URLs (#433)
Croff79e66756deba
diff --git a/apps/api/src/__tests__/helpers/auth.ts b/apps/api/src/__tests__/helpers/auth.tsindex 21154568..26f3a1d4 100644--- a/apps/api/src/__tests__/helpers/auth.ts+++ b/apps/api/src/__tests__/helpers/auth.ts@@ -1,4 +1,6 @@import { auth } from '@repo/auth';+import { db } from '@repo/db';+import { insertOwnedTeam } from '#modules/teams/service';export interface TestUser {// The session cookie header to pass to authenticated requests, e.g.@@ -18,11 +20,14 @@ let counter = 0;// we read the Set-Cookie off the response. Each call uses a unique email so// tests do not collide. Pass this cookie to authenticated requests.//+// Sign-up creates no team. Most tests need one to create projects in, so the user is+// given a team named after its username, without a slug, unless `team` is false.+//// Note: the very first user created in a fresh database becomes the "god" role// (better-auth create hook). resetDb() clears users between tests, so whichever// user a test creates first is "god" — keep that in mind for role-sensitive tests.export async function signUpTestUser(- overrides: { email?: string; password?: string; name?: string } = {},+ overrides: { email?: string; password?: string; name?: string; team?: boolean } = {},): Promise<TestUser> {counter += 1;const email = overrides.email ?? `test-user-${counter}@example.com`;@@ -49,6 +54,9 @@ export async function signUpTestUser(if (!userId) throw new Error(`signUpTestUser: no user id returned for ${email}`);const username = body.user?.username;if (!username) throw new Error(`signUpTestUser: no username returned for ${email}`);+ if (overrides.team !== false) {+ await db.transaction((tx) => insertOwnedTeam(tx, username, userId));+ }return { cookie, userId, email, username };}diff --git a/apps/api/src/app.ts b/apps/api/src/app.tsindex 3edac086..6401133b 100644--- a/apps/api/src/app.ts+++ b/apps/api/src/app.ts@@ -33,7 +33,7 @@ const apiDescription = `REST API for projects, work items, AI agents, Git integr1. Create a personal API key in [Account settings](${appUrl}/account/api-keys). The key is shown once and carries the same permissions as its owner.2. Send it in the \`x-api-key\` header. Never put a key in a URL, issue, comment, or source file.-3. Use the project key from the URL in routes containing \`{projectKey}\`. This page is opened from a project, but the API document is instance-wide.+3. In routes containing \`{projectKey}\`, name the project by its \`ref\`, \`<team>.<KEY>\` (e.g. \`acme.MKT\`). A bare key also works while only one of your teams has a project with it. This page is opened from a project, but the API document is instance-wide.\`\`\`shcurl "${apiUrl}/projects" \\diff --git a/apps/api/src/mcp/__tests__/integration/mcp-teams.test.ts b/apps/api/src/mcp/__tests__/integration/mcp-teams.test.tsindex 33731ece..7d183e92 100644--- a/apps/api/src/mcp/__tests__/integration/mcp-teams.test.ts+++ b/apps/api/src/mcp/__tests__/integration/mcp-teams.test.ts@@ -103,7 +103,7 @@ describe('MCP team resolution', () => {it('asks a person in more than one team to name the team', async () => {const { owner, asOwner, agentKey } = await setup();- await asOwner.teams.post({ name: 'Second Team' });+ await asOwner.teams.post({ name: 'Second Team', slug: 'second-team' });const personKey = (await auth.api.createApiKey({ body: { userId: owner.userId, name: 'mcp' } })).key;@@ -121,7 +121,7 @@ describe('MCP team resolution', () => {it('lists the teams of the caller', async () => {const { owner, asOwner } = await setup();- await asOwner.teams.post({ name: 'Second Team' });+ await asOwner.teams.post({ name: 'Second Team', slug: 'second-team' });const personKey = (await auth.api.createApiKey({ body: { userId: owner.userId, name: 'mcp' } })).key;diff --git a/apps/api/src/mcp/__tests__/integration/structured-results.test.ts b/apps/api/src/mcp/__tests__/integration/structured-results.test.tsindex 7e81cca6..2eff8728 100644--- a/apps/api/src/mcp/__tests__/integration/structured-results.test.ts+++ b/apps/api/src/mcp/__tests__/integration/structured-results.test.ts@@ -119,7 +119,7 @@ describe('MCP structured results through the SDK client', () => {it('returns the same error envelope for missing team arguments and unknown tools', async () => {const user = await signUpTestUser();- await authedApi(user.cookie).teams.post({ name: 'Another team' });+ await authedApi(user.cookie).teams.post({ name: 'Another team', slug: 'another-team' });const client = await connect(user.userId);await client.listTools();const missing = await callTool(client, { name: 'list_ai_agents' });diff --git a/apps/api/src/mcp/instructions.ts b/apps/api/src/mcp/instructions.tsindex fad0c24c..d504a9ea 100644--- a/apps/api/src/mcp/instructions.ts+++ b/apps/api/src/mcp/instructions.ts@@ -17,6 +17,10 @@ get_issue_by_number directly with those two values — do not call list_projectsget_project first, the key needs no resolving. Most issue tools take the issue'sinternal numeric id, which comes back in that result.+A project key is unique within its team, not across teams. If a bare key is+refused because several of your teams use it, pass the project's ref instead,+"<team>.KEY" — the ref field that list_projects returns.+When you have no identifier, start with list_projects to find the project, thenget_project to resolve its ids. Every id another tool takes — columnId, typeId,labelIds, assigneeUserId, custom field ids, member user ids — comes fromdiff --git a/apps/api/src/modules/agents/core/__tests__/integration/ai-agents.test.ts b/apps/api/src/modules/agents/core/__tests__/integration/ai-agents.test.tsindex 96552828..d8ba7162 100644--- a/apps/api/src/modules/agents/core/__tests__/integration/ai-agents.test.ts+++ b/apps/api/src/modules/agents/core/__tests__/integration/ai-agents.test.ts@@ -157,7 +157,7 @@ describe('ai agents', () => {it("rejects another team's model credential with 400", async () => {const { asOwner } = await setup();- const otherTeam = await asOwner.teams.post({ name: 'Engineering' });+ const otherTeam = await asOwner.teams.post({ name: 'Engineering', slug: 'engineering' });await asOwner.teams({ teamId: otherTeam.data!.id }).projects.post({key: 'ENG',name: 'Engineering',diff --git a/apps/api/src/modules/agents/core/__tests__/integration/route-tools.test.ts b/apps/api/src/modules/agents/core/__tests__/integration/route-tools.test.tsindex cfb32272..942a3212 100644--- a/apps/api/src/modules/agents/core/__tests__/integration/route-tools.test.ts+++ b/apps/api/src/modules/agents/core/__tests__/integration/route-tools.test.ts@@ -4,7 +4,7 @@ import { eq } from 'drizzle-orm';import { authedApi, type Api } from '#tests/helpers/app';import { signUpTestUser } from '#tests/helpers/auth';import { resetDb } from '#tests/helpers/db';-import { getProjectByKey } from '#modules/projects/service';+import { getProjectByRef } from '#modules/projects/service';import { getAgentById, getInternalAgentApiKey } from '../../service';import { actionCatalog, buildRouteTools } from '../../runtime/tools/route-tools';import { AGENT_ACTIONS, ALWAYS_ON_ACTIONS } from '../../runtime/tools/catalog';@@ -46,7 +46,7 @@ async function toolsFor(asOwner: Api, tools: string[], roleId?: number) {if (roleId !== undefined) {await setAgentProjectRole(asOwner, 'MKT', created.data!.agent.userId, roleId);}- const project = await getProjectByKey('MKT');+ const project = await getProjectByRef('MKT', '');if (!project) throw new Error('Test project was not created');const agent = await getAgentById(agentId, project.id);if (!agent) throw new Error('Test agent was not found');@@ -190,7 +190,7 @@ describe('internal agent route tools', () => {kind: 'internal',});const agentId = created.data?.agent.id;- const project = await getProjectByKey('MKT');+ const project = await getProjectByRef('MKT', '');if (agentId === undefined || !project) throw new Error('Test agent was not created');// An agent from before the key existed: no stored secret, and no place in thediff --git a/apps/api/src/modules/agents/core/model.ts b/apps/api/src/modules/agents/core/model.tsindex 543a4366..feb63818 100644--- a/apps/api/src/modules/agents/core/model.ts+++ b/apps/api/src/modules/agents/core/model.ts@@ -107,9 +107,12 @@ const configFields = {export const AiAgentResponse = t.Object({id: t.Number(),teamId: t.Number(),- projects: t.Array(t.Object({ id: t.Number(), key: t.String(), name: t.String() }), {- description: 'The projects of the team the agent works in.',- }),+ projects: t.Array(+ t.Object({ id: t.Number(), key: t.String(), ref: t.String(), name: t.String() }),+ {+ description: 'The projects of the team the agent works in.',+ },+ ),userId: t.String(),name: t.String(),username: t.String(),diff --git a/apps/api/src/modules/agents/core/runtime/tools/route-tools.ts b/apps/api/src/modules/agents/core/runtime/tools/route-tools.tsindex 830d5849..793f870f 100644--- a/apps/api/src/modules/agents/core/runtime/tools/route-tools.ts+++ b/apps/api/src/modules/agents/core/runtime/tools/route-tools.ts@@ -110,7 +110,7 @@ function buildOne(execute: async (input) => {const args: Record<string, unknown> = { ...input };for (const name of hidden) delete args[name];- if (bindsProject) args.projectKey = project.key;+ if (bindsProject) args.projectKey = project.ref;const { text, isError } = await dispatchTool(getMcpApp(),route,diff --git a/apps/api/src/modules/agents/core/service.ts b/apps/api/src/modules/agents/core/service.tsindex 7d802af5..7d74e2f8 100644--- a/apps/api/src/modules/agents/core/service.ts+++ b/apps/api/src/modules/agents/core/service.ts@@ -6,6 +6,7 @@ import {project,projectColumn,projectMember,+ team,teamMember,agentSkillLink,agentToolLink,@@ -23,6 +24,7 @@ import { normalizeToolKeys, ALWAYS_ON_ACTIONS } from './runtime/tools/catalog';import { deleteThreadsWhere } from './runtime/memory';import { listAgentMemberFieldIds } from '#modules/custom-fields/service';import { runsTeam, type TeamStanding } from '#modules/teams/service';+import { projectRefSql } from '#modules/teams/ref';import { getDefaultRoleId } from '#modules/roles/service';import { deleteAccount } from '#shared/account-deletion';@@ -68,6 +70,7 @@ export interface FieldTriggerRead extends FieldTrigger {export interface AgentProject {id: number;key: string;+ ref: string;name: string;}@@ -191,7 +194,7 @@ const agentColumns = {// of another team cannot happen (the attach route refuses it) and is not listed.projects: sql<AgentProject[]- >`(select coalesce(json_agg(json_build_object('id', p.id, 'key', p.key, 'name', p.name) order by p.key), '[]'::json) from ${projectMember} pm join ${project} p on p.id = pm.project_id where pm.user_id = ${aiAgent.userId} and p.team_id = ${aiAgent.teamId})`,+ >`(select coalesce(json_agg(json_build_object('id', ${project.id}, 'key', ${project.key}, 'ref', ${projectRefSql}, 'name', ${project.name}) order by ${project.key}), '[]'::json) from ${projectMember} join ${project} on ${project.id} = ${projectMember.projectId} join ${team} on ${team.id} = ${project.teamId} where ${projectMember.userId} = ${aiAgent.userId} and ${project.teamId} = ${aiAgent.teamId})`,userId: aiAgent.userId,name: user.name,username: aiAgent.username,diff --git a/apps/api/src/modules/agents/skills/__tests__/integration/agent-skills.test.ts b/apps/api/src/modules/agents/skills/__tests__/integration/agent-skills.test.tsindex dca4eb0b..988f5bb5 100644--- a/apps/api/src/modules/agents/skills/__tests__/integration/agent-skills.test.ts+++ b/apps/api/src/modules/agents/skills/__tests__/integration/agent-skills.test.ts@@ -229,7 +229,7 @@ describe('agent skills', () => {it('ignores a skill of another team when enabling skills on an agent', async () => {const { asOwner, teamId } = await setup();const mine = await skills(asOwner, teamId).post({ source: 'inline', markdown: SKILL_MD });- const otherTeam = await asOwner.teams.post({ name: 'Design' });+ const otherTeam = await asOwner.teams.post({ name: 'Design', slug: 'design' });const theirs = await skills(asOwner, otherTeam.data!.id).post({source: 'inline',markdown: SKILL_MD,diff --git a/apps/api/src/modules/agents/tools/__tests__/integration/agent-tools.test.ts b/apps/api/src/modules/agents/tools/__tests__/integration/agent-tools.test.tsindex 8af58606..3711f4a8 100644--- a/apps/api/src/modules/agents/tools/__tests__/integration/agent-tools.test.ts+++ b/apps/api/src/modules/agents/tools/__tests__/integration/agent-tools.test.ts@@ -182,7 +182,7 @@ describe('agent tools', () => {toolKey: 'jina_reader',credentialId: await jinaCredential(asOwner),});- const otherTeam = await asOwner.teams.post({ name: 'Design' });+ const otherTeam = await asOwner.teams.post({ name: 'Design', slug: 'design' });await asOwner.teams({ teamId: otherTeam.data!.id }).projects.post({ key: 'DSG', name: 'Design' });diff --git a/apps/api/src/modules/documents/__tests__/integration/assets.test.ts b/apps/api/src/modules/documents/__tests__/integration/assets.test.tsindex 8c6478c7..90f95468 100644--- a/apps/api/src/modules/documents/__tests__/integration/assets.test.ts+++ b/apps/api/src/modules/documents/__tests__/integration/assets.test.ts@@ -9,8 +9,8 @@ type Client = ReturnType<typeof authedApi>;async function setupProject() {const owner = await signUpTestUser();const asOwner = authedApi(owner.cookie);- await asOwner.projects.post({ key: 'MKT', name: 'Marketing' });- return { asOwner, owner };+ const project = (await asOwner.projects.post({ key: 'MKT', name: 'Marketing' })).data!;+ return { asOwner, owner, project };}async function addMember(owner: Client, roleId?: number) {@@ -43,7 +43,7 @@ describe('document assets', () => {beforeEach(resetDb);it('uploads, lists, securely downloads, and deletes an asset', async () => {- const { asOwner } = await setupProject();+ const { asOwner, project } = await setupProject();const page = (await documents(asOwner).post({ title: 'Guide' })).data!;const uploaded = await upload(asOwner, page.id, '../unsafe.svg', 'image/svg+xml');expect(uploaded.status).toBe(201);@@ -53,7 +53,7 @@ describe('document assets', () => {sizeBytes: 11,});expect(uploaded.data!.url).toBe(- `/projects/MKT/documents/${page.id}/assets/${uploaded.data!.id}/raw`,+ `/projects/${project.teamId}.MKT/documents/${page.id}/assets/${uploaded.data!.id}/raw`,);expect(uploaded.data).not.toHaveProperty('s3Key');diff --git a/apps/api/src/modules/documents/index.ts b/apps/api/src/modules/documents/index.tsindex 0b60625f..71f12f55 100644--- a/apps/api/src/modules/documents/index.ts+++ b/apps/api/src/modules/documents/index.ts@@ -73,6 +73,7 @@ import {transferDocumentOwnership,updateDocument,type DocumentAssetRow,+ documentAssetPath,} from './service';import {addDocumentInitiativeLink,@@ -84,7 +85,11 @@ import {removeDocumentIssueLink,} from './links';-function documentAssetDto(projectKey: string, documentId: number, asset: DocumentAssetRow) {+function documentAssetDto(+ project: { teamId: number; key: string },+ documentId: number,+ asset: DocumentAssetRow,+) {return {id: asset.publicId,filename: asset.filename,@@ -92,7 +97,7 @@ function documentAssetDto(projectKey: string, documentId: number, asset: DocumensizeBytes: asset.sizeBytes,uploadedByUserId: asset.uploadedByUserId,createdAt: asset.createdAt,- url: `/projects/${encodeURIComponent(projectKey)}/documents/${documentId}/assets/${asset.publicId}/raw`,+ url: documentAssetPath(project, documentId, asset.publicId),};}@@ -322,7 +327,7 @@ export const documentRoutes = new Elysia({async ({ project, params, user }) => {const assets = await listDocumentAssets(project.id, params.documentId, requireUser(user).id);if (!assets) throw new HttpError(404, 'Document not found');- return assets.map((asset) => documentAssetDto(project.key, params.documentId, asset));+ return assets.map((asset) => documentAssetDto(project, params.documentId, asset));},{permission: ['documents', 'read'],@@ -362,7 +367,7 @@ export const documentRoutes = new Elysia({});if (!asset) throw new HttpError(404, 'Document not found');set.status = 201;- return documentAssetDto(project.key, params.documentId, asset);+ return documentAssetDto(project, params.documentId, asset);} catch (error) {await deleteAttachmentObject(key);throw error;diff --git a/apps/api/src/modules/documents/service.ts b/apps/api/src/modules/documents/service.tsindex 601633cd..9f368441 100644--- a/apps/api/src/modules/documents/service.ts+++ b/apps/api/src/modules/documents/service.ts@@ -158,10 +158,21 @@ function mapAsset(row: typeof documentAsset.$inferSelect): DocumentAssetRow {return { ...row, createdAt: iso(row.createdAt) };}+// The URL of a document asset. It is stored in the document body, so it names the+// team by its id: a slug can change later, the id cannot.+export function documentAssetPath(+ project: { teamId: number; key: string },+ documentId: number,+ publicId: string,+): string {+ const ref = encodeURIComponent(`${project.teamId}.${project.key}`);+ return `/projects/${ref}/documents/${documentId}/assets/${publicId}/raw`;+}+export function replaceAssetReferences<T>(value: T,sourceDocumentId: number,- targetProjectKey: string,+ targetProject: { teamId: number; key: string },targetDocumentId: number,publicIds: Map<string, string>,): T {@@ -174,7 +185,7 @@ export function replaceAssetReferences<T>((match, mediaPrefix: string | undefined, publicId: string) => {const targetPublicId = publicIds.get(publicId.toLowerCase());return targetPublicId- ? `${mediaPrefix ?? ''}/projects/${encodeURIComponent(targetProjectKey)}/documents/${targetDocumentId}/assets/${targetPublicId}/raw`+ ? `${mediaPrefix ?? ''}${documentAssetPath(targetProject, targetDocumentId, targetPublicId)}`: match;},);@@ -182,20 +193,14 @@ export function replaceAssetReferences<T>(}if (Array.isArray(value)) {return value.map((item) =>- replaceAssetReferences(item, sourceDocumentId, targetProjectKey, targetDocumentId, publicIds),+ replaceAssetReferences(item, sourceDocumentId, targetProject, targetDocumentId, publicIds),) as T;}if (value && typeof value === 'object') {return Object.fromEntries(Object.entries(value).map(([key, item]) => [key,- replaceAssetReferences(- item,- sourceDocumentId,- targetProjectKey,- targetDocumentId,- publicIds,- ),+ replaceAssetReferences(item, sourceDocumentId, targetProject, targetDocumentId, publicIds),]),) as T;}@@ -1432,7 +1437,7 @@ export async function duplicateDocument(input: {await assertAttachmentFileAllowed(asset.sizeBytes, asset.contentType);}const [projectRow] = await tx- .select({ key: project.key })+ .select({ teamId: project.teamId, key: project.key }).from(project).where(eq(project.id, input.projectId));const publicIds = new Map<string, string>();@@ -1457,17 +1462,11 @@ export async function duplicateDocument(input: {const [rewritten] = await tx.update(projectDocument).set({- content: replaceAssetReferences(- row.content,- source.id,- projectRow.key,- row.id,- publicIds,- ),+ content: replaceAssetReferences(row.content, source.id, projectRow, row.id, publicIds),contentJson: replaceAssetReferences(row.contentJson,source.id,- projectRow.key,+ projectRow,row.id,publicIds,),diff --git a/apps/api/src/modules/git/handler.ts b/apps/api/src/modules/git/handler.tsindex 8d081dbf..08f43146 100644--- a/apps/api/src/modules/git/handler.ts+++ b/apps/api/src/modules/git/handler.ts@@ -20,6 +20,7 @@ import {import type { GitEvent, GitProviderKey, PullRequestEvent } from './providers';import { columnStateTypes, firstCompletedColumnId, type GitSettings } from './service';import { postPullRequestLinkback } from './connections-service';+import { issueWebPath } from '#modules/teams/ref';// Stores normalized repository events and applies pull request automation:// - a pull request merged into the repository's default branch moves the issues@@ -56,7 +57,7 @@ async function resolveIssues(}export async function handleGitEvent(- project: { id: number; key: string },+ project: { id: number; key: string; teamRef: string },settings: GitSettings,providerKey: GitProviderKey,providerLabel: string,@@ -133,7 +134,7 @@ export async function handleGitEvent(.map((item) => {const identifier = `${projectKey}-${item.sequenceNumber}`;return appUrl- ? `- [${identifier}](${appUrl}/project/${project.key}/issue/${item.sequenceNumber})`+ ? `- [${identifier}](${appUrl}${issueWebPath(project.teamRef, project.key, item.sequenceNumber)})`: `- ${identifier}`;});try {diff --git a/apps/api/src/modules/god/__tests__/integration/god-teams.test.ts b/apps/api/src/modules/god/__tests__/integration/god-teams.test.tsindex 4ceccc38..ccd2d5b9 100644--- a/apps/api/src/modules/god/__tests__/integration/god-teams.test.ts+++ b/apps/api/src/modules/god/__tests__/integration/god-teams.test.ts@@ -9,7 +9,7 @@ import { addUser, createAgentUser, setup, type Actor } from '../helpers';const PAGE = { page: 1, pageSize: 50 };-// Every account is given a team at registration, so the actor's own team is its first.+// signUpTestUser gives every account a team, so the actor's own team is its first.async function ownTeamId(actor: Actor): Promise<number> {const teams = await actor.api.teams.get();return teams.data![0]!.id;@@ -35,7 +35,7 @@ describe('god teams', () => {it('lists every team on the instance, including ones the owner is not in', async () => {const { god } = await setup();const alice = await addUser({ email: '[email protected]' });- await alice.api.teams.post({ name: 'Alice Only' });+ await alice.api.teams.post({ name: 'Alice Only', slug: 'alice-only' });const res = await god.api.god.teams.get({ query: PAGE });@@ -87,8 +87,8 @@ describe('god teams', () => {it('matches the search term against the name', async () => {const { god } = await setup();- await god.api.teams.post({ name: 'Marketing' });- await god.api.teams.post({ name: 'Engineering' });+ await god.api.teams.post({ name: 'Marketing', slug: 'marketing' });+ await god.api.teams.post({ name: 'Engineering', slug: 'engineering' });const match = await god.api.god.teams.get({ query: { ...PAGE, search: 'market' } });const noMatch = await god.api.god.teams.get({ query: { ...PAGE, search: 'nothing' } });@@ -101,13 +101,13 @@ describe('god teams', () => {it('pages with limit and offset while the total stays the full match count', async () => {const { god } = await setup();- await god.api.teams.post({ name: 'One' });- await god.api.teams.post({ name: 'Two' });+ await god.api.teams.post({ name: 'One', slug: 'one' });+ await god.api.teams.post({ name: 'Two', slug: 'two' });const first = await god.api.god.teams.get({ query: { page: 1, pageSize: 2 } });const second = await god.api.god.teams.get({ query: { page: 2, pageSize: 2 } });- // The two created teams plus the one the god account registered with.+ // The two created teams plus the one signUpTestUser gave the god account.expect(first.data?.items).toHaveLength(2);expect(second.data?.items).toHaveLength(1);expect(first.data?.total).toBe(3);diff --git a/apps/api/src/modules/imports/__tests__/integration/imports.test.ts b/apps/api/src/modules/imports/__tests__/integration/imports.test.tsindex 1a048aaa..2c9d08be 100644--- a/apps/api/src/modules/imports/__tests__/integration/imports.test.ts+++ b/apps/api/src/modules/imports/__tests__/integration/imports.test.ts@@ -3,7 +3,7 @@ import ExcelJS from 'exceljs';import { authedApi } from '#tests/helpers/app';import { signUpTestUser } from '#tests/helpers/auth';import { resetDb } from '#tests/helpers/db';-import { getProjectByKey } from '#modules/projects/service';+import { getProjectByRef } from '#modules/projects/service';import { createMappedImport } from '../../service';// The import flow: the file is uploaded through the chat-attachments route, an@@ -35,7 +35,7 @@ async function uploadWorkbook(}async function mapImport(attachmentId: string, mapping: Record<string, string>) {- const project = await getProjectByKey('MKT');+ const project = await getProjectByRef('MKT', '');if (!project) throw new Error('Test project was not created');return createMappedImport(project.id, attachmentId, mapping);}@@ -147,7 +147,7 @@ describe('imports', () => {const { asOwner } = await setup();await asOwner.projects.post({ key: 'OPS', name: 'Ops' });const uploaded = await uploadWorkbook(asOwner, [['Task'], ['Only']]);- const ops = await getProjectByKey('OPS');+ const ops = await getProjectByRef('OPS', '');if (!ops) throw new Error('Test project was not created');await expect(createMappedImport(ops.id, uploaded.data!.id, { title: 'Task' })).rejects.toThrow('Attachment not found',diff --git a/apps/api/src/modules/invites/__tests__/integration/invites.test.ts b/apps/api/src/modules/invites/__tests__/integration/invites.test.tsindex 9cea6567..4f4b9cf5 100644--- a/apps/api/src/modules/invites/__tests__/integration/invites.test.ts+++ b/apps/api/src/modules/invites/__tests__/integration/invites.test.ts@@ -33,7 +33,7 @@ async function configureEmail(owner: ReturnType<typeof authedApi>) {expect(result.status).toBe(200);}-// The id of the team the caller owns — every account is given one at registration.+// The id of the team the caller owns — signUpTestUser gives every account one.async function ownTeamId(api: ReturnType<typeof authedApi>): Promise<number> {const teams = await api.teams.get();return teams.data!.find((one) => one.role === 'owner')!.id;diff --git a/apps/api/src/modules/invites/model.ts b/apps/api/src/modules/invites/model.tsindex ce8732a0..e4df7e0a 100644--- a/apps/api/src/modules/invites/model.ts+++ b/apps/api/src/modules/invites/model.ts@@ -56,6 +56,7 @@ export const InviteRowListResponse = t.Array(InviteRowResponse);export const InviteViewResponse = t.Object({token: t.String(),teamName: t.String(),+ teamRef: t.String(),projectKey: t.Nullable(t.String()),projectName: t.Nullable(t.String()),email: t.String(),@@ -70,6 +71,7 @@ export const InviteViewResponse = t.Object({export const AcceptInviteResponse = t.Object({teamName: t.String(),+ teamRef: t.String(),projectKey: t.Nullable(t.String()),projectName: t.Nullable(t.String()),role: t.Nullable(projectRole),diff --git a/apps/api/src/modules/invites/service.ts b/apps/api/src/modules/invites/service.tsindex 7a95e654..d0ce92c7 100644--- a/apps/api/src/modules/invites/service.ts+++ b/apps/api/src/modules/invites/service.ts@@ -1,6 +1,7 @@import { db, teamInvite, teamMember, projectMember, teamRole, team, project, user } from '@repo/db';import { and, desc, eq, inArray, sql } from 'drizzle-orm';import { HttpError, iso, pgErrorCode } from '#shared/lib';+import { teamRef } from '#modules/teams/ref';import { getMembership, type MemberRole } from '#modules/members/service';import {assertTeamSeatFree,@@ -54,10 +55,12 @@ export interface InviteRow {}// Row shown to the invitee opening the link, with enough context to decide. Never-// exposes the internal team or project id.+// exposes the internal project id; the team is named by its ref, which the project's+// own URLs carry.export interface InviteView {token: string;teamName: string;+ teamRef: string;projectKey: string | null;projectName: string | null;email: string;@@ -76,6 +79,7 @@ export interface InviteView {// Where an invitee landed once the invite was accepted.export interface AcceptedInvite {teamName: string;+ teamRef: string;projectKey: string | null;projectName: string | null;role: MemberRole | null;@@ -285,7 +289,9 @@ export async function getInviteByToken(token: string): Promise<InviteView | nullconst rows = await db.select({token: teamInvite.token,+ teamId: team.id,teamName: team.name,+ teamSlug: team.slug,projectKey: project.key,projectName: project.name,email: teamInvite.email,@@ -307,6 +313,7 @@ export async function getInviteByToken(token: string): Promise<InviteView | nullreturn {token: r.token,teamName: r.teamName,+ teamRef: teamRef({ id: r.teamId, slug: r.teamSlug }),projectKey: r.projectKey,projectName: r.projectName,email: r.email,@@ -415,7 +422,7 @@ export async function acceptInvite(.where(eq(teamInvite.id, invite.id));const [joinedTeam] = await tx- .select({ name: team.name })+ .select({ id: team.id, name: team.name, slug: team.slug }).from(team).where(eq(team.id, invite.teamId));const [joinedProject] = invite.projectId@@ -426,6 +433,7 @@ export async function acceptInvite(: [];return {teamName: joinedTeam.name,+ teamRef: teamRef(joinedTeam),projectKey: joinedProject?.key ?? null,projectName: joinedProject?.name ?? null,role: invite.projectRole as MemberRole | null,diff --git a/apps/api/src/modules/issues/index.ts b/apps/api/src/modules/issues/index.tsindex d9b5107c..7a3724f6 100644--- a/apps/api/src/modules/issues/index.ts+++ b/apps/api/src/modules/issues/index.ts@@ -473,7 +473,7 @@ export const issueRoutes = new Elysia({ name: 'issues', detail: { tags: ['Issues)// Reads an issue by its project-scoped sequence number (the human number in a- // URL like /project/MKT/issue/42), with its custom field values. Backs the+ // URL like /acme/issue/MKT-42), with its custom field values. Backs the// identifier-based issue page. Same read permission as the by-id read..get('/projects/:projectKey/issues/:sequenceNumber',diff --git a/apps/api/src/modules/issues/service.ts b/apps/api/src/modules/issues/service.tsindex 7d536f9b..9597edf5 100644--- a/apps/api/src/modules/issues/service.ts+++ b/apps/api/src/modules/issues/service.ts@@ -90,7 +90,7 @@ export interface IssueRow {id: number;projectId: number;// Project-scoped sequence number (the "42" in "MKT-42"). Used to address the- // issue by its human number in URLs (/project/MKT/issue/42).+ // issue by its human number in URLs (/acme/issue/MKT-42).sequenceNumber: number;identifier: string;typeId: number | null;@@ -655,7 +655,7 @@ export async function getIssues(ids: number[]): Promise<IssueRow[]> {}// Loads an issue by its project-scoped sequence number (the human number in a URL-// like /project/MKT/issue/42). Returns null if the project has no issue with that+// like /acme/issue/MKT-42). Returns null if the project has no issue with that// number. Archived issues resolve too, so a link to one still opens.export async function getIssueBySequence(projectId: number,diff --git a/apps/api/src/modules/notifications/outbound.ts b/apps/api/src/modules/notifications/outbound.tsindex be0665c6..c34704d9 100644--- a/apps/api/src/modules/notifications/outbound.ts+++ b/apps/api/src/modules/notifications/outbound.ts@@ -4,6 +4,7 @@ import {issue,issueActivity,project,+ team,user,emailSource,getProjectEmailConfig,@@ -14,6 +15,7 @@ import { readRedactedSettings } from '#modules/notification-settings/service';import { getPreferencesForUsers } from '#modules/notification-preferences/service';import { getTelegramChatIds, hasUsableInstanceBot } from '#modules/telegram/service';import { escapeHtml } from '#shared/lib';+import { issueWebPath, teamRef } from '#modules/teams/ref';import type { NotificationType, NewNotificationRow } from './service';// Outbound notification delivery: turns the inbox notification rows produced by an@@ -43,9 +45,9 @@ function issueRef(projectKey: string, seq: number): string {// The public URL of an issue, or undefined when the web origin is not configured// (then messages carry no link rather than a localhost fallback).-function issueUrl(projectKey: string, seq: number): string | undefined {+function issueUrl(teamRef: string, projectKey: string, seq: number): string | undefined {const base = process.env.APP_URL;- return base ? `${base}/project/${projectKey}/issue/${seq}` : undefined;+ return base ? `${base}${issueWebPath(teamRef, projectKey, seq)}` : undefined;}interface StateChange {@@ -140,8 +142,9 @@ export async function enqueueOutbound(const projectId = notifications[0].projectId;const [projectRow] = await db- .select({ key: project.key, name: project.name, teamId: project.teamId })+ .select({ key: project.key, name: project.name, teamId: project.teamId, teamSlug: team.slug }).from(project)+ .innerJoin(team, eq(team.id, project.teamId)).where(eq(project.id, projectId));if (!projectRow) return;@@ -172,7 +175,11 @@ export async function enqueueOutbound(if (!issueRow) return;const ref = issueRef(projectRow.key, issueRow.seq);- const url = issueUrl(projectRow.key, issueRow.seq);+ const url = issueUrl(+ teamRef({ id: projectRow.teamId, slug: projectRow.teamSlug }),+ projectRow.key,+ issueRow.seq,+ );const actor = actorName ?? 'Someone';// One issue event, so every 'state_changed' row points at the same activity row.const statusActivityId =diff --git a/apps/api/src/modules/projects/__tests__/integration/discovery.test.ts b/apps/api/src/modules/projects/__tests__/integration/discovery.test.tsindex cea08f87..e5980b0a 100644--- a/apps/api/src/modules/projects/__tests__/integration/discovery.test.ts+++ b/apps/api/src/modules/projects/__tests__/integration/discovery.test.ts@@ -136,7 +136,7 @@ describe('project discovery', () => {it('combines team and search filters without revealing projects to a non-member', async () => {const { api } = await setup();const first = (await api.projects.post({ key: 'ONE', name: 'Shared name' })).data!;- const team = (await api.teams.post({ name: 'Second team' })).data!;+ const team = (await api.teams.post({ name: 'Second team', slug: 'second-team' })).data!;const second = await api.teams({ teamId: team.id }).projects.post({key: 'TWO',name: 'Shared name',@@ -166,7 +166,7 @@ describe('project discovery', () => {const { user, api } = await setup();const on = (await api.projects.post({ key: 'ON', name: 'Visible project' })).data!;const off = (await api.projects.post({ key: 'OFF', name: 'Visible disabled project' })).data!;- const secondTeam = (await api.teams.post({ name: 'Closed team' })).data!;+ const secondTeam = (await api.teams.post({ name: 'Closed team', slug: 'closed-team' })).data!;await api.teams({ teamId: secondTeam.id }).projects.post({ key: 'TEAMOFF', name: 'Visible team' });diff --git a/apps/api/src/modules/projects/__tests__/integration/project-ref.test.ts b/apps/api/src/modules/projects/__tests__/integration/project-ref.test.tsnew file mode 100644index 00000000..8c779381--- /dev/null+++ b/apps/api/src/modules/projects/__tests__/integration/project-ref.test.ts@@ -0,0 +1,111 @@+import { describe, it, expect, beforeEach } from 'bun:test';+import { authedApi } from '#tests/helpers/app';+import { signUpTestUser } from '#tests/helpers/auth';+import { resetDb } from '#tests/helpers/db';+import { addProjectMember } from '#tests/helpers/members';++// A project key is unique within its team. Routes name a project by its ref,+// "<teamRef>.<key>", or by the bare key while only one of the caller's teams has it.++async function signUpClient() {+ const user = await signUpTestUser();+ return { user, api: authedApi(user.cookie) };+}++// An owner with two teams, each holding a project keyed MKT.+async function twoTeamsWithMkt() {+ const owner = await signUpClient();+ const first = (await owner.api.teams.get()).data![0];+ const second = (await owner.api.teams.post({ name: 'Second', slug: 'second' })).data!;+ const a = (await owner.api.projects.post({ key: 'MKT', name: 'First marketing' })).data!;+ const b = (+ await owner.api.teams({ teamId: second.id }).projects.post({+ key: 'MKT',+ name: 'Second marketing',+ })+ ).data!;+ return { owner, first, second, a, b };+}++describe('project ref', () => {+ beforeEach(async () => {+ await resetDb();+ });++ it('lets two teams use the same key, and refuses it twice in one team', async () => {+ const { owner, second, a, b } = await twoTeamsWithMkt();+ expect(a.teamId).not.toBe(b.teamId);++ const dup = await owner.api.teams({ teamId: second.id }).projects.post({+ key: 'MKT',+ name: 'Again',+ });+ expect(dup.status).toBe(409);+ });++ it('carries the ref on the project', async () => {+ const { a } = await twoTeamsWithMkt();+ expect(a).toMatchObject({ teamRef: String(a.teamId), ref: `${a.teamId}.MKT` });+ });++ it("carries the ref on the team's project lists", async () => {+ const { owner, second } = await twoTeamsWithMkt();+ await owner.api.teams({ teamId: second.id }).patch({ slug: 'acme' });++ const page = await owner.api.teams({ teamId: second.id }).projects.get({ query: {} });+ expect(page.data?.items[0]).toMatchObject({ key: 'MKT', ref: 'acme.MKT' });+ const options = await owner.api.teams({ teamId: second.id }).projects.options.get();+ expect(options.data?.[0]).toMatchObject({ key: 'MKT', ref: 'acme.MKT' });+ });++ it('resolves a ref by team id and by team slug', async () => {+ const { owner, second, b } = await twoTeamsWithMkt();++ const byId = await owner.api.projects({ projectKey: `${second.id}.MKT` }).get();+ expect(byId.data?.project.id).toBe(b.id);++ await owner.api.teams({ teamId: second.id }).patch({ slug: 'acme' });+ const bySlug = await owner.api.projects({ projectKey: 'acme.MKT' }).get();+ expect(bySlug.data?.project).toMatchObject({ id: b.id, teamRef: 'acme', ref: 'acme.MKT' });+ expect((await owner.api.projects({ projectKey: `${second.id}.MKT` }).get()).status).toBe(200);+ });++ it('answers 404 for a ref whose team has no such project', async () => {+ const { owner, second } = await twoTeamsWithMkt();++ expect((await owner.api.projects({ projectKey: `${second.id}.OPS` }).get()).status).toBe(404);+ expect((await owner.api.projects({ projectKey: 'nope.MKT' }).get()).status).toBe(404);+ });++ it('refuses a bare key that names a project in several of the caller’s teams', async () => {+ const { owner } = await twoTeamsWithMkt();++ const res = await owner.api.projects({ projectKey: 'MKT' }).get();+ expect(res.status).toBe(409);+ });++ it('resolves a bare key to the one project among the caller’s teams', async () => {+ const { owner, b } = await twoTeamsWithMkt();+ const member = await addProjectMember(owner.api, `${b.teamId}.MKT`);++ const res = await member.projects({ projectKey: 'MKT' }).get();+ expect(res.status).toBe(200);+ expect(res.data?.project.id).toBe(b.id);+ });++ it('resolves a bare key while the instance has one project with it', async () => {+ const owner = await signUpClient();+ await owner.api.projects.post({ key: 'OPS', name: 'Ops' });++ expect((await owner.api.projects({ projectKey: 'OPS' }).get()).status).toBe(200);+ });++ it('rejects a key outside the allowed form', async () => {+ const { api } = await signUpClient();++ for (const key of ['mkt', '1MKT', 'MK-T', 'M.KT', 'ABCDEFGHIJK']) {+ expect((await api.projects.post({ key, name: 'Marketing' })).status).toBe(400);+ }+ expect((await api.projects.post({ key: 'ABCDEFGHIJ', name: 'Marketing' })).status).toBe(201);+ });+});diff --git a/apps/api/src/modules/projects/__tests__/integration/projects.test.ts b/apps/api/src/modules/projects/__tests__/integration/projects.test.tsindex c410a571..984e3e48 100644--- a/apps/api/src/modules/projects/__tests__/integration/projects.test.ts+++ b/apps/api/src/modules/projects/__tests__/integration/projects.test.ts@@ -579,7 +579,7 @@ describe('projects', () => {const { api } = await signUpClient();await api.projects.post({ key: 'SRC', name: 'Source' });await createAgent(api, 'SRC', { name: 'Ext', username: 'ext', kind: 'external' });- const target = (await api.teams.post({ name: 'Other Team' })).data!;+ const target = (await api.teams.post({ name: 'Other Team', slug: 'other-team' })).data!;const sourceId = await projectIdOf(api, 'SRC');await apidiff --git a/apps/api/src/modules/projects/copy.ts b/apps/api/src/modules/projects/copy.tsindex 0094aace..3d3ed3c5 100644--- a/apps/api/src/modules/projects/copy.ts+++ b/apps/api/src/modules/projects/copy.ts@@ -288,6 +288,7 @@ export async function copyProject(const proj = await mapProject({...row,teamName: ownerTeam.name,+ teamSlug: ownerTeam.slug,teamMcpEnabled: ownerTeam.mcpEnabled,});await tx.insert(projectMember).values({ projectId: proj.id, userId: ownerId, role: 'owner' });@@ -549,14 +550,14 @@ export async function copyProject(content: replaceAssetReferences(source.content,source.id,- input.key,+ proj,targetDocumentId,publicIds,),contentJson: replaceAssetReferences(source.contentJson,source.id,- input.key,+ proj,targetDocumentId,publicIds,),diff --git a/apps/api/src/modules/projects/index.ts b/apps/api/src/modules/projects/index.tsindex 28e80867..d11643ba 100644--- a/apps/api/src/modules/projects/index.ts+++ b/apps/api/src/modules/projects/index.ts@@ -88,7 +88,7 @@ export const projectRoutes = new Elysia({ name: 'projects', detail: { tags: ['Prdetail: {summary: 'Create a project',description:- 'Create a project you own. `key` is the unique, immutable prefix for issue ids ' ++ 'Create a project you own. `key` is the immutable prefix for issue ids, unique within the team ' +"(e.g. 'MKT' -> 'MKT-1'). Seeds the default columns and the issue types of the " +'chosen `preset`.',...mcpTool('create_project'),diff --git a/apps/api/src/modules/projects/model.ts b/apps/api/src/modules/projects/model.tsindex 5e5bc12b..b87f6240 100644--- a/apps/api/src/modules/projects/model.ts+++ b/apps/api/src/modules/projects/model.ts@@ -14,7 +14,10 @@ import { COPY_INCLUDE_KEYS } from './copy';export const PROJECT_DESCRIPTION_LIMIT = 2000;const projectBody = t.Object({- key: t.String({ minLength: 1 }),+ key: t.String({+ pattern: '^[A-Z][A-Z0-9]{0,9}$',+ description: 'Upper-case letters and digits, starting with a letter, up to 10 characters.',+ }),name: t.String({ minLength: 1 }),description: t.Optional(t.String({ maxLength: PROJECT_DESCRIPTION_LIMIT })),});@@ -95,7 +98,11 @@ export const ProjectResponse = t.Object({id: t.Number(),teamId: t.Number(),teamName: t.String(),+ teamRef: t.String({ description: "The team's slug, or its id while it has none." }),key: t.String(),+ ref: t.String({+ description: "'<teamRef>.<key>': how routes containing {projectKey} name this project.",+ }),name: t.String(),description: t.String(),mcpEnabled: t.Boolean(),diff --git a/apps/api/src/modules/projects/service.ts b/apps/api/src/modules/projects/service.tsindex 4cefedb7..ec6e03e8 100644--- a/apps/api/src/modules/projects/service.ts+++ b/apps/api/src/modules/projects/service.ts@@ -44,6 +44,7 @@ import { deleteThreadsWhere } from '#modules/agents/core/runtime/memory';import { getProjectDefaults } from '#modules/settings/service';import { getDefaultRoleId } from '#modules/roles/service';import { dropUnusedTeamMembership } from '#modules/scim/reconcile';+import { projectRef, teamRef } from '#modules/teams/ref';import { deleteObjects } from '@repo/storage';import { lockAttachmentStorage } from '#modules/attachments/storage';@@ -56,7 +57,11 @@ export interface ProjectRow {id: number;teamId: number;teamName: string;+ // The team's segment in web URLs: its slug, or its id while it has none.+ teamRef: string;key: string;+ // How a URL names the project: "<teamRef>.<key>". See getProjectByRef.+ ref: string;name: string;description: string;mcpEnabled: boolean;@@ -107,11 +112,16 @@ export interface ProjectListItem extends ProjectRow {permissions?: Permissions;}-type ProjectWithTeam = typeof project.$inferSelect & { teamName: string; teamMcpEnabled: boolean };+type ProjectWithTeam = typeof project.$inferSelect & {+ teamName: string;+ teamSlug: string | null;+ teamMcpEnabled: boolean;+};const projectWithTeam = {...getTableColumns(project),teamName: team.name,+ teamSlug: team.slug,teamMcpEnabled: team.mcpEnabled,};@@ -126,7 +136,9 @@ export async function mapProject(row: ProjectWithTeam): Promise<ProjectRow> {id: row.id,teamId: row.teamId,teamName: row.teamName,+ teamRef: teamRef({ id: row.teamId, slug: row.teamSlug }),key: row.key,+ ref: projectRef({ id: row.teamId, slug: row.teamSlug }, row.key),name: row.name,description: row.description,mcpEnabled: row.mcpEnabled,@@ -235,13 +247,54 @@ export async function listProjects();}-export async function getProjectByKey(key: string): Promise<ProjectRow | null> {+// Resolves the project a URL names. The full form is "<teamRef>.<key>", where the+// team is its slug or its id; a slug starts with a letter, so the two never collide.+// A bare key is what every URL carried while keys were unique on the instance: it+// still names a project as long as only one project with that key is in the+// caller's teams, and is refused with 409 once there are several.+export async function getProjectByRef(ref: string, userId: string): Promise<ProjectRow | null> {+ const dot = ref.indexOf('.');+ if (dot >= 0) {+ const teamPart = ref.slice(0, dot);+ const byTeam = /^\d{1,9}$/.test(teamPart)+ ? eq(team.id, Number(teamPart))+ : eq(team.slug, teamPart);+ const [row] = await db+ .select(projectWithTeam)+ .from(project)+ .innerJoin(team, eq(team.id, project.teamId))+ .where(and(byTeam, eq(project.key, ref.slice(dot + 1))));+ return row ? mapProject(row) : null;+ }+const rows = await db.select(projectWithTeam).from(project).innerJoin(team, eq(team.id, project.teamId))- .where(eq(project.key, key));- return rows[0] ? mapProject(rows[0]) : null;+ .where(eq(project.key, ref));+ if (rows.length <= 1) return rows[0] ? mapProject(rows[0]) : null;++ const teamIds = await db+ .select({ teamId: teamMember.teamId })+ .from(teamMember)+ .where(+ and(+ eq(teamMember.userId, userId),+ inArray(+ teamMember.teamId,+ rows.map((r) => r.teamId),+ ),+ ),+ );+ const mine = rows.filter((r) => teamIds.some((m) => m.teamId === r.teamId));+ if (mine.length === 0) return null;+ if (mine.length > 1) {+ throw new HttpError(+ 409,+ `Several of your teams have a project '${ref}'. Name it with its team, as '<team>.${ref}'.`,+ );+ }+ return mapProject(mine[0]);}export async function getProjectById(id: number): Promise<ProjectRow | null> {@@ -273,6 +326,7 @@ export async function targetTeam(userId: string, teamId?: number): Promise<Targe.select({id: team.id,name: team.name,+ slug: team.slug,mcpEnabled: team.mcpEnabled,defaultAgentIds: team.defaultAgentIds,})@@ -286,17 +340,18 @@ export async function targetTeam(userId: string, teamId?: number): Promise<Targeexport interface TargetTeam {id: number;name: string;+ slug: string | null;mcpEnabled: boolean;defaultAgentIds: number[];}-// The team the caller owns. Every account is given one when it is created, so a-// caller without one is a broken account rather than a state the UI can reach.+// The first team the caller owns. An account has none until it creates one.async function ownedTeam(userId: string): Promise<TargetTeam> {const [row] = await db.select({id: team.id,name: team.name,+ slug: team.slug,mcpEnabled: team.mcpEnabled,defaultAgentIds: team.defaultAgentIds,})@@ -455,7 +510,12 @@ export async function createProject(await tx.insert(projectSetting).values({ projectId: row.id, key: AUTO_ARCHIVE_KEY, value: DEFAULT_AUTO_ARCHIVE });- return mapProject({ ...row, teamName: ownerTeam.name, teamMcpEnabled: ownerTeam.mcpEnabled });+ return mapProject({+ ...row,+ teamName: ownerTeam.name,+ teamSlug: ownerTeam.slug,+ teamMcpEnabled: ownerTeam.mcpEnabled,+ });});}diff --git a/apps/api/src/modules/roles/__tests__/integration/roles.test.ts b/apps/api/src/modules/roles/__tests__/integration/roles.test.tsindex da5a0f32..155589d7 100644--- a/apps/api/src/modules/roles/__tests__/integration/roles.test.ts+++ b/apps/api/src/modules/roles/__tests__/integration/roles.test.ts@@ -16,7 +16,7 @@ import { createAgent, setAgentProjectRole } from '#tests/helpers/agents';type Actor = { user: TestUser; api: ReturnType<typeof authedApi>; teamId: number };// Creates a project MKT owned by a fresh user and returns a Treaty client acting as-// that owner, with the team the account was registered with. The first user in a+// that owner, with the team signUpTestUser gave the account. The first user in a// reset DB is "god"; the owner still reaches the project only through its// project_member row, so this is a plain owner.async function setupOwner(projectKey = 'MKT'): Promise<Actor> {diff --git a/apps/api/src/modules/scim/__tests__/integration/scim-reconcile.test.ts b/apps/api/src/modules/scim/__tests__/integration/scim-reconcile.test.tsindex 11a0a697..6007163d 100644--- a/apps/api/src/modules/scim/__tests__/integration/scim-reconcile.test.ts+++ b/apps/api/src/modules/scim/__tests__/integration/scim-reconcile.test.ts@@ -350,7 +350,7 @@ describe('SCIM group reconciliation', () => {it('refuses a role that belongs to another team', async () => {const setup = await setupScim();const marketing = await createProject(setup.god, 'Marketing', 'MKT');- const otherTeam = await setup.god.api.teams.post({ name: 'Design' });+ const otherTeam = await setup.god.api.teams.post({ name: 'Design', slug: 'design' });await setup.god.api.teams({ teamId: otherTeam.data!.id }).projects.post({key: 'DSN',name: 'Design',diff --git a/apps/api/src/modules/settings/whats-new.ts b/apps/api/src/modules/settings/whats-new.tsindex 0b45ba43..e1b734d8 100644--- a/apps/api/src/modules/settings/whats-new.ts+++ b/apps/api/src/modules/settings/whats-new.ts@@ -9,8 +9,8 @@ import { getAppVersion, releasesSince, type Release } from './updates';//// The dump and the data report are administration: they name the projects, roles and// agents of the whole instance, so only its owner reads them. Team ownership is not-// the line to draw here — every account is given a team of its own at registration,-// which would make that everyone.+// the line to draw here — nearly every account owns a team of its own, which would make+// that everyone.const MIGRATION_REPORT_KEY = 'migration.teams';// The migration is matched by name, not by its number: a merge from main renumbers thediff --git a/apps/api/src/modules/teams/__tests__/integration/teams.test.ts b/apps/api/src/modules/teams/__tests__/integration/teams.test.tsindex 19b43d04..08c42093 100644--- a/apps/api/src/modules/teams/__tests__/integration/teams.test.ts+++ b/apps/api/src/modules/teams/__tests__/integration/teams.test.ts@@ -131,7 +131,15 @@ describe('teams', () => {});describe('list', () => {- it('lists the team the account was registered with', async () => {+ it('gives a new account no team, so it has nowhere to create a project', async () => {+ const user = await signUpTestUser({ team: false });+ const api = authedApi(user.cookie);++ expect((await api.teams.get()).data).toEqual([]);+ expect((await api.projects.post({ key: 'MKT', name: 'Marketing' })).status).toBe(400);+ });++ it('lists the team the account owns', async () => {const { user, api } = await signUpClient();const list = await api.teams.get();@@ -157,7 +165,7 @@ describe('teams', () => {it("lists only the caller's own teams", async () => {const { api } = await signUpClient();const other = await signUpClient();- await other.api.teams.post({ name: 'Design' });+ await other.api.teams.post({ name: 'Design', slug: 'design' });const list = await api.teams.get();expect(list.data?.map((t) => t.name)).not.toContain('Design');@@ -173,7 +181,7 @@ describe('teams', () => {it('creates a team with the caller as its owner', async () => {const { api } = await signUpClient();- const created = await api.teams.post({ name: 'Design' });+ const created = await api.teams.post({ name: 'Design', slug: 'design' });expect(created.status).toBe(201);expect(created.data).toMatchObject({ name: 'Design', role: 'owner' });@@ -185,36 +193,54 @@ describe('teams', () => {it('trims the name', async () => {const { api } = await signUpClient();- const created = await api.teams.post({ name: ' Design ' });+ const created = await api.teams.post({ name: ' Design ', slug: 'design' });expect(created.data).toMatchObject({ name: 'Design' });});it('rejects an empty or blank name', async () => {const { api } = await signUpClient();- expect((await api.teams.post({ name: '' })).status).toBe(400);- expect((await api.teams.post({ name: ' ' })).status).toBe(400);+ expect((await api.teams.post({ name: '', slug: 'team' })).status).toBe(400);+ expect((await api.teams.post({ name: ' ', slug: 'team' })).status).toBe(400);});it('rejects a name longer than 60 characters', async () => {const { api } = await signUpClient();- expect((await api.teams.post({ name: 'a'.repeat(60) })).status).toBe(201);- expect((await api.teams.post({ name: 'a'.repeat(61) })).status).toBe(400);+ expect((await api.teams.post({ name: 'a'.repeat(60), slug: 'long' })).status).toBe(201);+ expect((await api.teams.post({ name: 'a'.repeat(61), slug: 'longer' })).status).toBe(400);});it('refuses one more team than the limits allow', async () => {const { api } = await signUpClient();- // The account already owns the team it was registered with.+ // The account already owns the team signUpTestUser gave it.setLimits({ maxTeams: 1 });- const created = await api.teams.post({ name: 'Design' });+ const created = await api.teams.post({ name: 'Design', slug: 'design' });expect(created.status).toBe(409);expect(await api.teams.get().then((list) => list.data)).toHaveLength(1);});+ it('creates the team under the slug it is given', async () => {+ const { api } = await signUpClient();++ const created = await api.teams.post({ name: 'Design', slug: 'design' });+ expect(created.status).toBe(201);+ expect(created.data).toMatchObject({ slug: 'design', ref: 'design' });+ });++ it('refuses a slug that is malformed, reserved or taken', async () => {+ const { api } = await signUpClient();+ await api.teams.post({ name: 'Design', slug: 'design' });++ expect((await api.teams.post({ name: 'Bad', slug: 'Bad Slug' })).status).toBe(400);+ expect((await api.teams.post({ name: 'Settings', slug: 'settings' })).status).toBe(400);+ expect((await api.teams.post({ name: 'Design 2', slug: 'design' })).status).toBe(409);+ expect(await api.teams.get().then((list) => list.data)).toHaveLength(2);+ });+it('rejects a request without a session', async () => {- const created = await anonApi.teams.post({ name: 'Design' });+ const created = await anonApi.teams.post({ name: 'Design', slug: 'design' });expect(created.status).toBe(401);});});@@ -568,7 +594,7 @@ describe('teams', () => {});describe('team projects', () => {- // The team the account was registered with, which owns the projects it creates.+ // The team signUpTestUser gave the account, which owns the projects it creates.async function ownTeamId(api: Api): Promise<number> {return (await api.teams.get()).data![0].id;}@@ -832,7 +858,7 @@ describe('teams', () => {it('hides a team with MCP off from an MCP list_teams call', async () => {const { api } = await signUpClient();const teamId = (await api.teams.get()).data![0].id;- const second = (await api.teams.post({ name: 'Growth' })).data!;+ const second = (await api.teams.post({ name: 'Growth', slug: 'growth' })).data!;await api.teams({ teamId }).mcp.patch({ enabled: false });expect((await api.teams.get()).data?.map((t) => t.id).sort()).toEqual(@@ -846,6 +872,7 @@ describe('teams', () => {it('renames a team the caller owns', async () => {const { api } = await signUpClient();const teamId = (await api.teams.get()).data![0].id;+ await api.teams({ teamId }).patch({ slug: 'growth' });const renamed = await api.teams({ teamId }).patch({ name: ' Growth ' });expect(renamed.status).toBe(200);@@ -872,6 +899,66 @@ describe('teams', () => {});});+ describe('slug', () => {+ it('answers with the team id as its ref until a slug is set', async () => {+ const { api } = await signUpClient();+ const teamId = (await api.teams.get()).data![0].id;+ expect((await api.teams.get()).data?.[0]).toMatchObject({ slug: null, ref: String(teamId) });++ const set = await api.teams({ teamId }).patch({ slug: 'acme' });+ expect(set.status).toBe(200);+ expect(set.data).toMatchObject({ slug: 'acme', ref: 'acme' });++ const cleared = await api.teams({ teamId }).patch({ slug: null as never });+ expect(cleared.status).toBe(400);+ });++ it('refuses a rename until the team has a slug', async () => {+ const { api } = await signUpClient();+ const teamId = (await api.teams.get()).data![0].id;++ expect((await api.teams({ teamId }).patch({ name: 'Growth' })).status).toBe(400);+ const res = await api.teams({ teamId }).patch({ name: 'Growth', slug: 'growth' });+ expect(res.status).toBe(200);+ expect(res.data).toMatchObject({ name: 'Growth', slug: 'growth' });+ });++ it('keeps the name when only the slug changes', async () => {+ const { user, api } = await signUpClient();+ const teamId = (await api.teams.get()).data![0].id;++ const res = await api.teams({ teamId }).patch({ slug: 'acme' });+ expect(res.data).toMatchObject({ name: user.username, slug: 'acme' });+ });++ it('rejects a slug outside the allowed form', async () => {+ const { api } = await signUpClient();+ const teamId = (await api.teams.get()).data![0].id;++ for (const slug of ['a', '42', '1acme', 'Acme', 'ac.me', 'acme-', 'a'.repeat(41)]) {+ expect((await api.teams({ teamId }).patch({ slug })).status).toBe(400);+ }+ expect((await api.teams({ teamId }).patch({ slug: 'a'.repeat(40) })).status).toBe(200);+ });++ it('rejects a slug the web app uses as a path', async () => {+ const { api } = await signUpClient();+ const teamId = (await api.teams.get()).data![0].id;++ expect((await api.teams({ teamId }).patch({ slug: 'account' })).status).toBe(400);+ });++ it('rejects a slug another team uses with 409', async () => {+ const { api } = await signUpClient();+ const other = await signUpClient();+ const teamId = (await api.teams.get()).data![0].id;+ const otherTeamId = (await other.api.teams.get()).data![0].id;+ await other.api.teams({ teamId: otherTeamId }).patch({ slug: 'acme' });++ expect((await api.teams({ teamId }).patch({ slug: 'acme' })).status).toBe(409);+ });+ });+describe('member rank', () => {it('promotes a member to manager', async () => {const owner = await signUpClient();diff --git a/apps/api/src/modules/teams/index.ts b/apps/api/src/modules/teams/index.tsindex 7483c6ee..d4f577d5 100644--- a/apps/api/src/modules/teams/index.ts+++ b/apps/api/src/modules/teams/index.ts@@ -49,7 +49,7 @@ import {listTeamProjects,listTeams,removeTeamMember,- renameTeam,+ updateTeam,setTeamMcp,getTeamProjectDefaults,setTeamProjectDefaults,@@ -64,7 +64,7 @@ async function requireTeamProject(teamId: number, projectId: number): Promise<vo}// The teams the session user belongs to. A team owns projects and its own member-// list; every account is given one at registration and may create more, becoming+// list; an account creates its own after registration, and may create more, becoming// their owner.export const teamRoutes = new Elysia({ name: 'teams', detail: { tags: ['Teams'] } }).use(authContext)@@ -273,11 +273,11 @@ export const teamRoutes = new Elysia({ name: 'teams', detail: { tags: ['Teams']const name = body.name.trim();if (!name) throw new HttpError(400, 'Team name is required');set.status = 201;- return createTeam(name, requireUser(user).id);+ return createTeam(name, body.slug, requireUser(user).id);},{body: createTeamBody,- response: { 201: TeamResponse, ...errors(400, 401) },+ response: { 201: TeamResponse, ...errors(400, 401, 409) },detail: {summary: 'Create a team',description: 'Create a team and become its owner.',@@ -289,17 +289,17 @@ export const teamRoutes = new Elysia({ name: 'teams', detail: { tags: ['Teams']'/teams/:teamId',async ({ body, membership }) => {const name = body.name?.trim();- if (!name) throw new HttpError(400, 'Team name is required');- return renameTeam(membership.teamId, name, membership.userId);+ if (name === '') throw new HttpError(400, 'Team name is required');+ return updateTeam(membership.teamId, { name, slug: body.slug }, membership.userId);},{teamOwner: true,params: teamParams,body: updateTeamBody,- response: { 200: TeamResponse, ...errors(400, 401, 403, 404) },+ response: { 200: TeamResponse, ...errors(400, 401, 403, 404, 409) },detail: {- summary: 'Rename a team',- description: 'Rename a team you own.',+ summary: 'Update a team',+ description: 'Rename a team you own, or set the slug its web URLs use.',},},)diff --git a/apps/api/src/modules/teams/model.ts b/apps/api/src/modules/teams/model.tsindex 90944f59..aaac942d 100644--- a/apps/api/src/modules/teams/model.ts+++ b/apps/api/src/modules/teams/model.ts@@ -2,6 +2,7 @@ import { t } from 'elysia';import { pageQueryFields, pageResponse } from '#shared/pagination';import { PermissionMatrixSchema } from '#shared/permissions';import { StatsDto } from '#modules/analytics/model';+import { TEAM_SLUG_PATTERN } from './ref';// Both member lists here take the filters and the window the project member list// defines, so a reader learns one query and it holds everywhere.@@ -17,16 +18,26 @@ export const setTeamMemberRoleBody = t.Object({role: t.Union([t.Literal('owner'), t.Literal('manager'), t.Literal('member')]),});-export const createTeamBody = t.Object({- name: t.String({ minLength: 1, maxLength: 60 }),+const teamName = t.String({ minLength: 1, maxLength: 60 });++const teamSlug = t.String({+ pattern: TEAM_SLUG_PATTERN,+ description:+ "The team's segment in web URLs: lower-case letters, digits and hyphens, " ++ 'starting with a letter, 2 to 40 characters.',});-export const updateTeamBody = t.Partial(createTeamBody);+export const createTeamBody = t.Object({ name: teamName, slug: teamSlug });++// A team made before slugs were required has none, and takes no change until one is set.+export const updateTeamBody = t.Partial(t.Object({ name: teamName, slug: teamSlug }));// A team DTO (TeamRow from the service).export const TeamResponse = t.Object({id: t.Number(),name: t.String(),+ slug: t.Nullable(t.String()),+ ref: t.String({ description: 'How web URLs name the team: its slug, or its id without one.' }),mcpEnabled: t.Boolean({description:'Whether the team is reachable over MCP. Off closes its own resources and every ' +@@ -102,6 +113,7 @@ export const TeamProjectPageResponse = pageResponse(t.Object({id: t.Number(),key: t.String(),+ ref: t.String({ description: "'<teamRef>.<key>': how routes name the project." }),name: t.String(),description: t.String(),mcpEnabled: t.Boolean({ description: "Whether the team's MCP reach covers this project." }),@@ -125,6 +137,7 @@ export const TeamProjectOptionListResponse = t.Array(t.Object({id: t.Number(),key: t.String(),+ ref: t.String({ description: "'<teamRef>.<key>': how routes name the project." }),name: t.String(),mcpEnabled: t.Boolean(),}),diff --git a/apps/api/src/modules/teams/ref.ts b/apps/api/src/modules/teams/ref.tsnew file mode 100644index 00000000..c7e63d07--- /dev/null+++ b/apps/api/src/modules/teams/ref.ts@@ -0,0 +1,47 @@+import { project, team } from '@repo/db';+import { sql } from 'drizzle-orm';++// How URLs name a team and a project. A team is its slug, or its id while it has+// none; a project is "<teamRef>.<key>". The web app puts the team first in its paths+// (/acme/MKT), so a slug must not be one of its own top-level segments.++export const TEAM_SLUG_PATTERN = '^[a-z][a-z0-9-]{0,38}[a-z0-9]$';++const RESERVED_SLUGS = new Set([+ 'account',+ 'api',+ 'docs',+ 'forgot-password',+ 'god',+ 'invite',+ 'issue',+ 'login',+ 'media',+ 'oauth',+ 'project',+ 'protected-media',+ 'register',+ 'reset-password',+ 'settings',+ 'share',+]);++export function isReservedSlug(slug: string): boolean {+ return RESERVED_SLUGS.has(slug);+}++export function teamRef(team: { id: number; slug: string | null }): string {+ return team.slug ?? String(team.id);+}++export function projectRef(team: { id: number; slug: string | null }, key: string): string {+ return `${teamRef(team)}.${key}`;+}++// projectRef as a column, for a query that joins team to project.+export const projectRefSql = sql<string>`coalesce(${team.slug}, ${team.id}::text) || '.' || ${project.key}`;++// The web page of an issue, e.g. "/acme/issue/MKT-42".+export function issueWebPath(teamRef: string, key: string, seq: number): string {+ return `/${teamRef}/issue/${key}-${seq}`;+}diff --git a/apps/api/src/modules/teams/service.ts b/apps/api/src/modules/teams/service.tsindex 46835b7d..62514f55 100644--- a/apps/api/src/modules/teams/service.ts+++ b/apps/api/src/modules/teams/service.ts@@ -15,7 +15,8 @@ import {user,} from '@repo/db';import { and, desc, eq, ilike, inArray, isNull, or, sql } from 'drizzle-orm';-import { HttpError, iso } from '#shared/lib';+import { HttpError, iso, pgErrorCode } from '#shared/lib';+import { isReservedSlug, projectRefSql, teamRef } from './ref';import { getLimits } from '#shared/limits';import { defaultMemberPermissions, fullPermissions, type Permissions } from '#shared/permissions';import {@@ -48,6 +49,9 @@ export function runsTeam(standing: TeamStanding | null): boolean {export interface TeamRow {id: number;name: string;+ slug: string | null;+ // How web URLs name the team: the slug, or the id while it has none.+ ref: string;// Whether the team is reachable over MCP at all. Off closes its own resources and// every project it owns, whichever projects it covers.mcpEnabled: boolean;@@ -94,6 +98,7 @@ export interface TeamMemberRow {export interface TeamProjectRow {id: number;key: string;+ ref: string;name: string;description: string;// Whether the team's MCP reach covers this project. Only counts while the team's@@ -115,6 +120,7 @@ export interface TeamProjectPage {export interface TeamProjectOption {id: number;key: string;+ ref: string;name: string;mcpEnabled: boolean;}@@ -192,6 +198,7 @@ async function loadTeamRows(userId: string, teamId?: number): Promise<TeamRow[]>.select({id: team.id,name: team.name,+ slug: team.slug,mcpEnabled: team.mcpEnabled,role: teamMember.role,source: teamMember.source,@@ -280,6 +287,8 @@ async function loadTeamRows(userId: string, teamId?: number): Promise<TeamRow[]>return {id: row.id,name: row.name,+ slug: row.slug,+ ref: teamRef(row),mcpEnabled: row.mcpEnabled,role: standing,source: row.source as MemberSource,@@ -527,6 +536,7 @@ export async function listTeamProjects(.select({id: project.id,key: project.key,+ ref: projectRefSql,name: project.name,description: project.description,mcpEnabled: project.mcpEnabled,@@ -535,9 +545,10 @@ export async function listTeamProjects(isMember: sql<boolean>`bool_or(${projectMember.userId} = ${userId})`,}).from(project)+ .innerJoin(team, eq(team.id, project.teamId)).leftJoin(projectMember, eq(projectMember.projectId, project.id)).where(where)- .groupBy(project.id)+ .groupBy(project.id, team.id).orderBy(project.key).limit(options.limit).offset(options.offset),@@ -580,6 +591,7 @@ export async function listTeamProjects(items: projects.map((p) => ({id: p.id,key: p.key,+ ref: p.ref,name: p.name,description: p.description,mcpEnabled: p.mcpEnabled,@@ -603,10 +615,12 @@ export async function listTeamProjectOptions(.select({id: project.id,key: project.key,+ ref: projectRefSql,name: project.name,mcpEnabled: project.mcpEnabled,}).from(project)+ .innerJoin(team, eq(team.id, project.teamId)).where(visibleTeamProjects(teamId, userId, standing)).orderBy(project.key);}@@ -701,11 +715,14 @@ export async function listTeamProjectMembers(type Transaction = Parameters<Parameters<typeof db.transaction>[0]>[0];-// Writes a team owned by one account, with the default role its projects assign. Every-// account owns one; the sign-up hook in @repo/auth writes the same rows inline, since-// it runs inside better-auth rather than through this module.-export async function insertOwnedTeam(tx: Transaction, name: string, ownerId: string) {- const [row] = await tx.insert(team).values({ name }).returning();+// Writes a team owned by one account, with the default role its projects assign.+export async function insertOwnedTeam(+ tx: Transaction,+ name: string,+ ownerId: string,+ slug: string | null = null,+) {+ const [row] = await tx.insert(team).values({ name, slug }).returning();const [membership] = await tx.insert(teamMember).values({ teamId: row.id, userId: ownerId, role: 'owner' })@@ -748,37 +765,71 @@ export async function assertTeamSeatFree(teamId: number): Promise<void> {}}-// The team an account gets at sign-up is written by the hook in @repo/auth, which does-// not come through here — the ceiling applies to the teams created on top of that one.-export async function createTeam(name: string, ownerId: string): Promise<TeamRow> {+export async function createTeam(name: string, slug: string, ownerId: string): Promise<TeamRow> {const { maxTeams } = await getLimits({ ownerUserId: ownerId });if (maxTeams > 0 && (await countOwnedTeams(ownerId)) >= maxTeams) {throw new HttpError(409, `You already own ${maxTeams} teams`);}- return db.transaction(async (tx) => {- const { team: row, membership } = await insertOwnedTeam(tx, name, ownerId);- return {- id: row.id,- name: row.name,- mcpEnabled: row.mcpEnabled,- role: 'owner',- source: 'invite',- joinedAt: iso(membership.createdAt),- projectCount: 0,- memberCount: 1,- ownerCount: 1,- roleCount: 1,- integrationCount: 0,- agentCount: 0,- skillCount: 0,- toolCount: 0,- createdAt: iso(row.createdAt),- };- });+ assertSlugAllowed(slug);+ return withSlugConflict(() =>+ db.transaction(async (tx) => {+ const { team: row, membership } = await insertOwnedTeam(tx, name, ownerId, slug);+ return {+ id: row.id,+ name: row.name,+ slug: row.slug,+ ref: teamRef(row),+ mcpEnabled: row.mcpEnabled,+ role: 'owner',+ source: 'invite',+ joinedAt: iso(membership.createdAt),+ projectCount: 0,+ memberCount: 1,+ ownerCount: 1,+ roleCount: 1,+ integrationCount: 0,+ agentCount: 0,+ skillCount: 0,+ toolCount: 0,+ createdAt: iso(row.createdAt),+ };+ }),+ );}-export async function renameTeam(teamId: number, name: string, userId: string): Promise<TeamRow> {- await db.update(team).set({ name }).where(eq(team.id, teamId));+function assertSlugAllowed(slug: string | undefined): void {+ if (slug && isReservedSlug(slug)) {+ throw new HttpError(400, `'${slug}' is reserved and cannot be a team slug`);+ }+}++// slug is the only unique column of team, so a unique violation names it.+async function withSlugConflict<T>(write: () => Promise<T>): Promise<T> {+ try {+ return await write();+ } catch (err) {+ if (pgErrorCode(err) === '23505')+ throw new HttpError(409, 'Another team already uses this slug');+ throw err;+ }+}++export async function updateTeam(+ teamId: number,+ changes: { name?: string; slug?: string },+ userId: string,+): Promise<TeamRow> {+ assertSlugAllowed(changes.slug);+ if (changes.slug === undefined) {+ const [current] = await db.select({ slug: team.slug }).from(team).where(eq(team.id, teamId));+ if (current?.slug === null) {+ throw new HttpError(400, "Set the team's slug before changing it");+ }+ }+ // Drizzle skips undefined values, and throws when none are left to set.+ if (changes.name !== undefined || changes.slug !== undefined) {+ await withSlugConflict(() => db.update(team).set(changes).where(eq(team.id, teamId)));+ }const [row] = await loadTeamRows(userId, teamId);return row;}diff --git a/apps/api/src/shared/access.ts b/apps/api/src/shared/access.tsindex f7ff580a..1c22c524 100644--- a/apps/api/src/shared/access.ts+++ b/apps/api/src/shared/access.ts@@ -1,7 +1,7 @@import { HttpError } from './lib';import {getProjectById,- getProjectByKey,+ getProjectByRef,projectFeatures,type ProjectRow,} from '#modules/projects/service';@@ -39,9 +39,10 @@ export function requireGod(user: AuthUser | undefined | null): AuthUser {return current;}-// Resolves the :projectKey path param, throwing 404 for an unknown project.-async function requireProject(projectKey: string): Promise<ProjectRow> {- const project = await getProjectByKey(projectKey);+// Resolves the :projectKey path param (see getProjectByRef), throwing 404 for an+// unknown project.+async function requireProject(projectKey: string, userId: string): Promise<ProjectRow> {+ const project = await getProjectByRef(projectKey, userId);if (!project) throw new HttpError(404, `Project '${projectKey}' not found`);return project;}@@ -54,7 +55,7 @@ export async function requireProjectAccess(user: AuthUser | undefined | null,): Promise<ProjectRow> {const current = requireUser(user);- const project = await requireProject(projectKey);+ const project = await requireProject(projectKey, current.id);const role = await getMembership(project.id, current.id);if (!role) throw new HttpError(403, 'You do not have access to this project');return project;@@ -69,7 +70,7 @@ export async function requireProjectOwner(user: AuthUser | undefined | null,): Promise<ProjectRow> {const current = requireUser(user);- const project = await requireProject(projectKey);+ const project = await requireProject(projectKey, current.id);const role = await getMembership(project.id, current.id);if (!role) throw new HttpError(403, 'You do not have access to this project');if (role !== 'owner') throw new HttpError(403, 'Only a project owner can do this');@@ -85,8 +86,9 @@ export async function requireProjectAdmin(projectKey: string,user: AuthUser | undefined | null,): Promise<ProjectRow> {- const project = await requireProject(projectKey);- await assertProjectAdmin(project, user);+ const current = requireUser(user);+ const project = await requireProject(projectKey, current.id);+ await assertProjectAdmin(project, current);return project;}@@ -115,7 +117,7 @@ export async function requireTeamRunsProject(user: AuthUser | undefined | null,): Promise<ProjectRow> {const current = requireUser(user);- const project = await requireProject(projectKey);+ const project = await requireProject(projectKey, current.id);if (!runsTeam(await getTeamMembership(project.teamId, current.id)))throw new HttpError(403, 'Only a team owner or manager can do this');return project;@@ -132,7 +134,7 @@ export async function requireMemberAdmin(action: PermissionAction,): Promise<ProjectRow> {const current = requireUser(user);- const project = await requireProject(projectKey);+ const project = await requireProject(projectKey, current.id);const standing = await getTeamMembership(project.teamId, current.id);if (runsTeam(standing)) return project;await assertPermission(project.id, current, resource, action);@@ -246,7 +248,7 @@ export async function requireProjectPermission(action: PermissionAction,): Promise<ProjectRow> {const current = requireUser(user);- const project = await requireProject(projectKey);+ const project = await requireProject(projectKey, current.id);await assertPermission(project.id, current, resource, action);return project;}diff --git a/apps/api/src/shared/permissions.ts b/apps/api/src/shared/permissions.tsindex 56032a9f..2b06e2b1 100644--- a/apps/api/src/shared/permissions.ts+++ b/apps/api/src/shared/permissions.ts@@ -1,8 +1,7 @@import { t } from 'elysia';// The permission model lives in @repo/db, next to the team_role table whose-// `permissions` column holds the matrix, so the sign-up hook in @repo/auth can seed-// a new team's default role with it. This module adds the API-side pieces.+// `permissions` column holds the matrix. This module adds the API-side pieces.export {PERMISSION_RESOURCES,PERMISSION_ACTIONS,diff --git a/apps/web/messages/ar/shell.json b/apps/web/messages/ar/shell.jsonindex bf94b0ab..b53076f7 100644--- a/apps/web/messages/ar/shell.json+++ b/apps/web/messages/ar/shell.json@@ -2,6 +2,10 @@"noProjectAccess": "مالكش صلاحية تدخل المشروع ده.","projectUnavailable": "هذا المشروع غير متاح.","noProjects": "مفيش مشاريع لسه، اعمل واحد وابدأ.",+ "noTeamsTitle": "لا يوجد فريق بعد",+ "noTeamsHint": "أنشئ فريقك. ستكون فيه مشاريعه وأعضاؤه ووكلاؤه.",+ "noProjectAccessHint": "اطلب من مالك الفريق أو مديره إضافتك إلى مشروع، أو أنشئ فريقك الخاص.",+ "createTeam": "إنشاء فريق","noProjectsTitle": "لا توجد مشاريع بعد","noProjectsHint": "اعمل أول مشروع ليك وابدأ تخطّط مهامك على لوحة.","createProject": "إنشاء مشروع"diff --git a/apps/web/messages/ar/teams.json b/apps/web/messages/ar/teams.jsonindex 1c0342fe..f8d6ef2a 100644--- a/apps/web/messages/ar/teams.json+++ b/apps/web/messages/ar/teams.json@@ -2,6 +2,9 @@"create": {"title": "فريق جديد","namePlaceholder": "اسم الفريق",+ "slug": "URL",+ "slugHint": "تبدأ روابط مشاريع الفريق به، مثل /acme.",+ "slugInvalid": "استخدم من 2 إلى 40 حرفًا لاتينيًا صغيرًا أو رقمًا أو شرطة، على أن يبدأ بحرف.","hint": "ستكون مالك هذا الفريق.","submit": "إنشاء فريق"},@@ -50,11 +53,14 @@"info": {"team": "الفريق","teamHint": "الاسم الذي تُجمَع تحته مشاريع الفريق.",+ "slug": "URL",+ "slugHint": "مطلوب لحفظ التغييرات. أحرف لاتينية صغيرة وأرقام وشرطات.",+ "slugInvalid": "استخدم من 2 إلى 40 حرفًا لاتينيًا صغيرًا أو رقمًا أو شرطة، على أن يبدأ بحرف.","role": "دورك","created": "أُنشئ","leads": "المالكون والمديرون","leadsHint": "الأشخاص الذين يمكنهم إدارة هذا الفريق ومشاريعه.",- "saved": "تم حفظ اسم الفريق",+ "saved": "تم حفظ الفريق","leaveHint": "تحتفظ بالمشاريع التي أنت عضو فيها. للانضمام مجددًا يجب أن يضيفك أحد المالكين."},"columns": {diff --git a/apps/web/messages/en/shell.json b/apps/web/messages/en/shell.jsonindex 15b43723..94faafb0 100644--- a/apps/web/messages/en/shell.json+++ b/apps/web/messages/en/shell.json@@ -2,6 +2,10 @@"noProjectAccess": "You do not have access to this project.","projectUnavailable": "This project is not available.","noProjects": "No projects yet, create one to get started.",+ "noTeamsTitle": "No team yet",+ "noTeamsHint": "Create your team. Its projects, members and agents are kept in it.",+ "noProjectAccessHint": "Ask a team owner or manager to add you to a project, or create your own team.",+ "createTeam": "Create team","noProjectsTitle": "No projects yet","noProjectsHint": "Create your first project to start planning issues on a board.","createProject": "Create project"diff --git a/apps/web/messages/en/teams.json b/apps/web/messages/en/teams.jsonindex daeb94fc..286770c8 100644--- a/apps/web/messages/en/teams.json+++ b/apps/web/messages/en/teams.json@@ -2,6 +2,9 @@"create": {"title": "New team","namePlaceholder": "Team name",+ "slug": "URL",+ "slugHint": "Links to the team's projects start with it, e.g. /acme.",+ "slugInvalid": "Use 2–40 lowercase letters, numbers or hyphens, starting with a letter.","hint": "You'll be the owner of this team.","submit": "Create team"},@@ -50,11 +53,14 @@"info": {"team": "Team","teamHint": "The name the team's projects are grouped under.",+ "slug": "URL",+ "slugHint": "Required to save changes. Lowercase letters, numbers and hyphens.",+ "slugInvalid": "Use 2–40 lowercase letters, numbers or hyphens, starting with a letter.","role": "Your role","created": "Created","leads": "Owners and managers","leadsHint": "People who can manage this team and its projects.",- "saved": "Team name saved",+ "saved": "Team saved","leaveHint": "You keep the projects you are a member of. To join again an owner has to add you back."},"columns": {diff --git a/apps/web/messages/es-ES/shell.json b/apps/web/messages/es-ES/shell.jsonindex d096273e..0cc203b0 100644--- a/apps/web/messages/es-ES/shell.json+++ b/apps/web/messages/es-ES/shell.json@@ -2,6 +2,10 @@"noProjectAccess": "No tienes acceso a este proyecto.","projectUnavailable": "Este proyecto no está disponible.","noProjects": "Todavía no hay proyectos, crea uno para empezar.",+ "noTeamsTitle": "Aún no hay equipo",+ "noTeamsHint": "Crea tu equipo. En él estarán sus proyectos, miembros y agentes.",+ "noProjectAccessHint": "Pide al propietario o a un administrador del equipo que te añada a un proyecto, o crea tu propio equipo.",+ "createTeam": "Crear equipo","noProjectsTitle": "Todavía no hay proyectos","noProjectsHint": "Crea tu primer proyecto para empezar a planificar tickets en un tablero.","createProject": "Crear proyecto"diff --git a/apps/web/messages/es-ES/teams.json b/apps/web/messages/es-ES/teams.jsonindex d8d1050b..5c9678d8 100644--- a/apps/web/messages/es-ES/teams.json+++ b/apps/web/messages/es-ES/teams.json@@ -2,6 +2,9 @@"create": {"title": "Nuevo equipo","namePlaceholder": "Nombre del equipo",+ "slug": "URL",+ "slugHint": "Los enlaces a los proyectos del equipo empiezan por él, p. ej. /acme.",+ "slugInvalid": "Usa de 2 a 40 letras minúsculas, números o guiones, empezando por una letra.","hint": "Serás el propietario de este equipo.","submit": "Crear equipo"},@@ -50,11 +53,14 @@"info": {"team": "Equipo","teamHint": "El nombre bajo el que se agrupan los proyectos del equipo.",+ "slug": "URL",+ "slugHint": "Obligatoria para guardar los cambios. Letras minúsculas, números y guiones.",+ "slugInvalid": "Usa de 2 a 40 letras minúsculas, números o guiones, empezando por una letra.","role": "Tu rol","created": "Creada","leads": "Propietarios y administradores","leadsHint": "Personas que pueden gestionar este equipo y sus proyectos.",- "saved": "El nombre del equipo se ha guardado",+ "saved": "Equipo guardado","leaveHint": "Conservas los proyectos de los que eres miembro. Para volver a unirte, un propietario tiene que añadirte de vuelta."},"columns": {diff --git a/apps/web/messages/fr/shell.json b/apps/web/messages/fr/shell.jsonindex 27730132..15595136 100644--- a/apps/web/messages/fr/shell.json+++ b/apps/web/messages/fr/shell.json@@ -2,6 +2,10 @@"noProjectAccess": "Vous n'avez pas accès à ce projet.","projectUnavailable": "Ce projet n'est pas disponible.","noProjects": "Aucun projet pour l'instant, créez-en un pour démarrer.",+ "noTeamsTitle": "Pas encore d'équipe",+ "noTeamsHint": "Créez votre équipe. Elle contiendra ses projets, ses membres et ses agents.",+ "noProjectAccessHint": "Demandez au propriétaire ou à un gestionnaire de l'équipe de vous ajouter à un projet, ou créez votre propre équipe.",+ "createTeam": "Créer une équipe","noProjectsTitle": "Aucun projet pour l'instant","noProjectsHint": "Créez votre premier projet pour commencer à organiser vos tickets sur un tableau.","createProject": "Créer un projet"diff --git a/apps/web/messages/fr/teams.json b/apps/web/messages/fr/teams.jsonindex a07039a4..4249f60f 100644--- a/apps/web/messages/fr/teams.json+++ b/apps/web/messages/fr/teams.json@@ -2,6 +2,9 @@"create": {"title": "Nouvelle équipe","namePlaceholder": "Nom de l'équipe",+ "slug": "URL",+ "slugHint": "Les liens vers les projets de l'équipe commencent par lui, par ex. /acme.",+ "slugInvalid": "Utilisez 2 à 40 lettres minuscules, chiffres ou tirets, en commençant par une lettre.","hint": "Vous serez le propriétaire de cette équipe.","submit": "Créer l'équipe"},@@ -50,11 +53,14 @@"info": {"team": "Équipe","teamHint": "Le nom sous lequel les projets de l'équipe sont regroupés.",+ "slug": "URL",+ "slugHint": "Obligatoire pour enregistrer les modifications. Lettres minuscules, chiffres et tirets.",+ "slugInvalid": "Utilisez 2 à 40 lettres minuscules, chiffres ou tirets, en commençant par une lettre.","role": "Votre rôle","created": "Créé le","leads": "Propriétaires et responsables","leadsHint": "Les personnes qui peuvent gérer cette équipe et ses projets.",- "saved": "Nom de l'équipe enregistré",+ "saved": "Équipe enregistrée","leaveHint": "Vous conservez les projets dont vous êtes membre. Pour revenir, un propriétaire doit vous ajouter à nouveau."},"columns": {diff --git a/apps/web/messages/id/shell.json b/apps/web/messages/id/shell.jsonindex 36f91fc1..996a0e7a 100644--- a/apps/web/messages/id/shell.json+++ b/apps/web/messages/id/shell.json@@ -2,6 +2,10 @@"noProjectAccess": "Anda tidak memiliki akses ke proyek ini.","projectUnavailable": "Proyek ini tidak tersedia.","noProjects": "Belum ada proyek. Buat proyek untuk memulai.",+ "noTeamsTitle": "Belum ada tim",+ "noTeamsHint": "Buat tim Anda. Proyek, anggota, dan agennya disimpan di dalamnya.",+ "noProjectAccessHint": "Minta pemilik atau manajer tim untuk menambahkan Anda ke proyek, atau buat tim Anda sendiri.",+ "createTeam": "Buat tim","noProjectsTitle": "Belum ada proyek","noProjectsHint": "Buat proyek pertama Anda untuk mulai merencanakan issue di papan.","createProject": "Buat proyek"diff --git a/apps/web/messages/id/teams.json b/apps/web/messages/id/teams.jsonindex 6108f8a8..4fb012d8 100644--- a/apps/web/messages/id/teams.json+++ b/apps/web/messages/id/teams.json@@ -2,6 +2,9 @@"create": {"title": "Tim baru","namePlaceholder": "Nama tim",+ "slug": "URL",+ "slugHint": "Tautan ke proyek tim diawali dengannya, misalnya /acme.",+ "slugInvalid": "Gunakan 2–40 huruf kecil, angka, atau tanda hubung, diawali huruf.","hint": "Anda akan menjadi pemilik tim ini.","submit": "Buat tim"},@@ -50,11 +53,14 @@"info": {"team": "Tim","teamHint": "Nama tim tempat proyek dikelompokkan.",+ "slug": "URL",+ "slugHint": "Wajib untuk menyimpan perubahan. Huruf kecil, angka, dan tanda hubung.",+ "slugInvalid": "Gunakan 2–40 huruf kecil, angka, atau tanda hubung, diawali huruf.","role": "Peran Anda","created": "Dibuat","leads": "Pemilik dan manajer","leadsHint": "Orang yang dapat mengelola tim ini beserta proyeknya.",- "saved": "Nama tim disimpan",+ "saved": "Tim disimpan","leaveHint": "Anda tetap menjadi anggota proyek yang Anda ikuti. Untuk bergabung kembali, pemilik harus menambahkan Anda lagi."},"columns": {diff --git a/apps/web/messages/pt-BR/shell.json b/apps/web/messages/pt-BR/shell.jsonindex 15846533..32e18d60 100644--- a/apps/web/messages/pt-BR/shell.json+++ b/apps/web/messages/pt-BR/shell.json@@ -2,6 +2,10 @@"noProjectAccess": "Você não tem acesso a este projeto.","projectUnavailable": "Este projeto não está disponível.","noProjects": "Nenhum projeto ainda. Crie um para começar.",+ "noTeamsTitle": "Ainda não há equipe",+ "noTeamsHint": "Crie sua equipe. Nela ficarão os projetos, os membros e os agentes.",+ "noProjectAccessHint": "Peça ao proprietário ou a um gerente da equipe para adicionar você a um projeto, ou crie sua própria equipe.",+ "createTeam": "Criar equipe","noProjectsTitle": "Nenhum projeto ainda","noProjectsHint": "Crie seu primeiro projeto para começar a planejar issues em um quadro.","createProject": "Criar projeto"diff --git a/apps/web/messages/pt-BR/teams.json b/apps/web/messages/pt-BR/teams.jsonindex 4d1e6b46..9142493c 100644--- a/apps/web/messages/pt-BR/teams.json+++ b/apps/web/messages/pt-BR/teams.json@@ -2,6 +2,9 @@"create": {"title": "Novo time","namePlaceholder": "Nome do time",+ "slug": "URL",+ "slugHint": "Os links para os projetos da equipe começam com ele, por exemplo /acme.",+ "slugInvalid": "Use de 2 a 40 letras minúsculas, números ou hifens, começando com uma letra.","hint": "Você será o dono deste time.","submit": "Criar time"},@@ -50,11 +53,14 @@"info": {"team": "Time","teamHint": "O nome sob o qual os projetos do time são agrupados.",+ "slug": "URL",+ "slugHint": "Obrigatória para salvar as alterações. Letras minúsculas, números e hifens.",+ "slugInvalid": "Use de 2 a 40 letras minúsculas, números ou hifens, começando com uma letra.","role": "Sua função","created": "Criado","leads": "Donos e gerentes","leadsHint": "Pessoas que podem gerenciar este time e seus projetos.",- "saved": "Nome do time salvo",+ "saved": "Equipe salva","leaveHint": "Você mantém os projetos de que é membro. Para entrar de novo, um dono precisa readicioná-lo."},"columns": {diff --git a/apps/web/messages/ru/shell.json b/apps/web/messages/ru/shell.jsonindex 18166bda..8f656c69 100644--- a/apps/web/messages/ru/shell.json+++ b/apps/web/messages/ru/shell.json@@ -2,6 +2,10 @@"noProjectAccess": "У вас нет доступа к этому проекту.","projectUnavailable": "Этот проект недоступен.","noProjects": "Проектов пока нет — создайте первый, чтобы начать.",+ "noTeamsTitle": "Команды пока нет",+ "noTeamsHint": "Создайте свою команду. В ней будут её проекты, участники и агенты.",+ "noProjectAccessHint": "Попросите владельца или менеджера команды добавить вас в проект или создайте свою команду.",+ "createTeam": "Создать команду","noProjectsTitle": "Проектов пока нет","noProjectsHint": "Создайте первый проект, чтобы планировать задачи на доске.","createProject": "Создать проект"diff --git a/apps/web/messages/ru/teams.json b/apps/web/messages/ru/teams.jsonindex c37a07f7..f223f7ae 100644--- a/apps/web/messages/ru/teams.json+++ b/apps/web/messages/ru/teams.json@@ -2,6 +2,9 @@"create": {"title": "Новая команда","namePlaceholder": "Название команды",+ "slug": "URL",+ "slugHint": "С него начинаются ссылки на проекты команды, например /acme.",+ "slugInvalid": "Используйте 2–40 строчных латинских букв, цифр или дефисов, первой должна быть буква.","hint": "Вы станете владельцем этой команды.","submit": "Создать команду"},@@ -50,11 +53,14 @@"info": {"team": "Команда","teamHint": "Название, под которым сгруппированы проекты команды.",+ "slug": "URL",+ "slugHint": "Нужен, чтобы сохранить изменения. Строчные латинские буквы, цифры и дефисы.",+ "slugInvalid": "Используйте 2–40 строчных латинских букв, цифр или дефисов, первой должна быть буква.","role": "Ваша роль","created": "Создана","leads": "Владельцы и менеджеры","leadsHint": "Люди, которые могут управлять этой командой и её проектами.",- "saved": "Название команды сохранено",+ "saved": "Команда сохранена","leaveHint": "Проекты, в которых вы участвуете, остаются у вас. Чтобы вернуться, владелец должен добавить вас снова."},"columns": {diff --git a/apps/web/messages/uk/shell.json b/apps/web/messages/uk/shell.jsonindex 19eb6686..d2a43b69 100644--- a/apps/web/messages/uk/shell.json+++ b/apps/web/messages/uk/shell.json@@ -2,6 +2,10 @@"noProjectAccess": "У вас немає доступу до цього проєкту.","projectUnavailable": "Цей проєкт недоступний.","noProjects": "Проєктів ще немає — створіть перший, щоб почати.",+ "noTeamsTitle": "Команди поки немає",+ "noTeamsHint": "Створіть свою команду. У ній будуть її проєкти, учасники та агенти.",+ "noProjectAccessHint": "Попросіть власника або менеджера команди додати вас до проєкту або створіть свою команду.",+ "createTeam": "Створити команду","noProjectsTitle": "Проєктів ще немає","noProjectsHint": "Створіть перший проєкт, щоб планувати задачі на дошці.","createProject": "Створити проєкт"diff --git a/apps/web/messages/uk/teams.json b/apps/web/messages/uk/teams.jsonindex d7e120f9..f3d210e9 100644--- a/apps/web/messages/uk/teams.json+++ b/apps/web/messages/uk/teams.json@@ -2,6 +2,9 @@"create": {"title": "Нова команда","namePlaceholder": "Назва команди",+ "slug": "URL",+ "slugHint": "З нього починаються посилання на проєкти команди, наприклад /acme.",+ "slugInvalid": "Використайте 2–40 малих латинських літер, цифр або дефісів, першою має бути літера.","hint": "Ви станете власником цієї команди.","submit": "Створити команду"},@@ -50,11 +53,14 @@"info": {"team": "Команда","teamHint": "Назва, під якою згруповані проєкти команди.",+ "slug": "URL",+ "slugHint": "Потрібна, щоб зберегти зміни. Малі латинські літери, цифри та дефіси.",+ "slugInvalid": "Використайте 2–40 малих латинських літер, цифр або дефісів, першою має бути літера.","role": "Ваша роль","created": "Створена","leads": "Власники та менеджери","leadsHint": "Люди, які можуть керувати цією командою та її проєктами.",- "saved": "Назву команди збережено",+ "saved": "Команду збережено","leaveHint": "Проєкти, у яких ви берете участь, залишаються у вас. Щоб повернутися, власник має додати вас знову."},"columns": {diff --git a/apps/web/messages/zh-CN/shell.json b/apps/web/messages/zh-CN/shell.jsonindex 7ccc747f..268a3155 100644--- a/apps/web/messages/zh-CN/shell.json+++ b/apps/web/messages/zh-CN/shell.json@@ -2,6 +2,10 @@"noProjectAccess": "你无权访问此项目。","projectUnavailable": "此项目不可用。","noProjects": "暂无项目,请先新建一个项目。",+ "noTeamsTitle": "还没有团队",+ "noTeamsHint": "创建你的团队。团队的项目、成员和智能体都在其中。",+ "noProjectAccessHint": "请团队所有者或管理员将你添加到项目中,或创建你自己的团队。",+ "createTeam": "创建团队","noProjectsTitle": "暂无项目","noProjectsHint": "新建第一个项目,然后开始在看板中规划工作项。","createProject": "新建项目"diff --git a/apps/web/messages/zh-CN/teams.json b/apps/web/messages/zh-CN/teams.jsonindex 19cdd95b..89a0e013 100644--- a/apps/web/messages/zh-CN/teams.json+++ b/apps/web/messages/zh-CN/teams.json@@ -2,6 +2,9 @@"create": {"title": "新建团队","namePlaceholder": "团队名称",+ "slug": "URL",+ "slugHint": "团队项目的链接以它开头,例如 /acme。",+ "slugInvalid": "请使用 2–40 个小写字母、数字或连字符,并以字母开头。","hint": "你将成为该团队的所有者。","submit": "创建团队"},@@ -50,11 +53,14 @@"info": {"team": "团队","teamHint": "团队项目归属的名称。",+ "slug": "URL",+ "slugHint": "保存更改前必须填写。仅限小写字母、数字和连字符。",+ "slugInvalid": "请使用 2–40 个小写字母、数字或连字符,并以字母开头。","role": "你的角色","created": "创建于","leads": "所有者和管理员","leadsHint": "可以管理此团队及其项目的成员。",- "saved": "团队名称已保存",+ "saved": "团队已保存","leaveHint": "你仍保留你参与的项目。若要重新加入,需由所有者再次添加你。"},"columns": {diff --git a/apps/web/src/app/[identifier]/page.tsx b/apps/web/src/app/[identifier]/page.tsxdeleted file mode 100644index 8b61dc0b..00000000--- a/apps/web/src/app/[identifier]/page.tsx+++ /dev/null@@ -1,26 +0,0 @@-'use client';--import { useEffect } from 'react';-import { useParams, useRouter } from 'next/navigation';--// Short link for an issue by its identifier, e.g. /IAP-62. The identifier is-// "<projectKey>-<number>", so it maps straight to the canonical project-scoped URL-// without a lookup. A segment that is not an identifier falls back to the home page.-// Static top-level routes (login, project, ...) take precedence over this dynamic-// segment, so only otherwise-unmatched paths reach here.-export default function IssueShortLink() {- const router = useRouter();- const params = useParams();- const identifier = typeof params.identifier === 'string' ? params.identifier : '';-- useEffect(() => {- const match = /^(.+)-(\d+)$/.exec(identifier);- router.replace(match ? `/project/${match[1]}/issue/${match[2]}` : '/');- }, [identifier, router]);-- return (- <div className="flex h-svh items-center justify-center bg-background text-sm text-muted-foreground">- Loading…- </div>- );-}diff --git a/apps/web/src/app/[teamRef]/(shell)/[projectKey]/agents/chat/page.tsx b/apps/web/src/app/[teamRef]/(shell)/[projectKey]/agents/chat/page.tsxnew file mode 100644index 00000000..0507eb88--- /dev/null+++ b/apps/web/src/app/[teamRef]/(shell)/[projectKey]/agents/chat/page.tsx@@ -0,0 +1,14 @@+import { redirect } from 'next/navigation';+import { aiTeamPath, projectRefOf } from '@/utils/paths';+import { AI_TEAM_SECTIONS } from '@/utils/settingsSections';++// The chat is a panel now, so its old path has no page of its own and sends the+// viewer to the first AI Team section.+export default async function Page({+ params,+}: {+ params: Promise<{ teamRef: string; projectKey: string }>;+}) {+ const { teamRef, projectKey } = await params;+ redirect(aiTeamPath(projectRefOf(teamRef, projectKey), AI_TEAM_SECTIONS[0].slug));+}diff --git a/apps/web/src/app/project/[projectKey]/ai-agents/page.tsx b/apps/web/src/app/[teamRef]/(shell)/[projectKey]/agents/page.tsxsimilarity index 100%rename from apps/web/src/app/project/[projectKey]/ai-agents/page.tsxrename to apps/web/src/app/[teamRef]/(shell)/[projectKey]/agents/page.tsxdiff --git a/apps/web/src/app/project/[projectKey]/ai-team/schedules/page.tsx b/apps/web/src/app/[teamRef]/(shell)/[projectKey]/agents/schedules/page.tsxsimilarity index 100%rename from apps/web/src/app/project/[projectKey]/ai-team/schedules/page.tsxrename to apps/web/src/app/[teamRef]/(shell)/[projectKey]/agents/schedules/page.tsxdiff --git a/apps/web/src/app/project/[projectKey]/api/page.tsx b/apps/web/src/app/[teamRef]/(shell)/[projectKey]/api/page.tsxsimilarity index 100%rename from apps/web/src/app/project/[projectKey]/api/page.tsxrename to apps/web/src/app/[teamRef]/(shell)/[projectKey]/api/page.tsxdiff --git a/apps/web/src/app/[teamRef]/(shell)/[projectKey]/cycles/[cycle]/page.tsx b/apps/web/src/app/[teamRef]/(shell)/[projectKey]/cycles/[cycle]/page.tsxnew file mode 100644index 00000000..d6e2f0ae--- /dev/null+++ b/apps/web/src/app/[teamRef]/(shell)/[projectKey]/cycles/[cycle]/page.tsx@@ -0,0 +1,30 @@+import { notFound, redirect } from 'next/navigation';+import RequireFeature from '@/components/common/permissions/RequireFeature';+import CyclesPage from '@/features/cycles/CyclesPage';+import CycleDetailPage from '@/features/cycles/CycleDetailPage';+import { cyclesPath, isCyclesView, projectRefOf } from '@/utils/paths';++// One layout of the cycles list (the grouped table or the day track), or one cycle.+export default async function Page({+ params,+}: {+ params: Promise<{ teamRef: string; projectKey: string; cycle: string }>;+}) {+ const { teamRef, projectKey, cycle } = await params;+ if (isCyclesView(cycle)) {+ return (+ <RequireFeature feature="cycles">+ <CyclesPage view={cycle} />+ </RequireFeature>+ );+ }+ const id = Number(cycle);+ if (!Number.isInteger(id)) redirect(cyclesPath(projectRefOf(teamRef, projectKey)));+ if (id <= 0) notFound();++ return (+ <RequireFeature feature="cycles">+ <CycleDetailPage cycleId={id} />+ </RequireFeature>+ );+}diff --git a/apps/web/src/app/project/[projectKey]/cycles/page.tsx b/apps/web/src/app/[teamRef]/(shell)/[projectKey]/cycles/page.tsxsimilarity index 100%rename from apps/web/src/app/project/[projectKey]/cycles/page.tsxrename to apps/web/src/app/[teamRef]/(shell)/[projectKey]/cycles/page.tsxdiff --git a/apps/web/src/app/project/[projectKey]/dashboard/[dashboardId]/page.tsx b/apps/web/src/app/[teamRef]/(shell)/[projectKey]/dashboards/[dashboardId]/page.tsxsimilarity index 100%rename from apps/web/src/app/project/[projectKey]/dashboard/[dashboardId]/page.tsxrename to apps/web/src/app/[teamRef]/(shell)/[projectKey]/dashboards/[dashboardId]/page.tsxdiff --git a/apps/web/src/app/project/[projectKey]/dashboard/page.tsx b/apps/web/src/app/[teamRef]/(shell)/[projectKey]/dashboards/page.tsxsimilarity index 100%rename from apps/web/src/app/project/[projectKey]/dashboard/page.tsxrename to apps/web/src/app/[teamRef]/(shell)/[projectKey]/dashboards/page.tsxdiff --git a/apps/web/src/app/project/[projectKey]/docs/[documentId]/page.tsx b/apps/web/src/app/[teamRef]/(shell)/[projectKey]/docs/[documentId]/page.tsxsimilarity index 100%rename from apps/web/src/app/project/[projectKey]/docs/[documentId]/page.tsxrename to apps/web/src/app/[teamRef]/(shell)/[projectKey]/docs/[documentId]/page.tsxdiff --git a/apps/web/src/app/project/[projectKey]/docs/page.tsx b/apps/web/src/app/[teamRef]/(shell)/[projectKey]/docs/page.tsxsimilarity index 100%rename from apps/web/src/app/project/[projectKey]/docs/page.tsxrename to apps/web/src/app/[teamRef]/(shell)/[projectKey]/docs/page.tsxdiff --git a/apps/web/src/app/project/[projectKey]/inbox/page.tsx b/apps/web/src/app/[teamRef]/(shell)/[projectKey]/inbox/page.tsxsimilarity index 100%rename from apps/web/src/app/project/[projectKey]/inbox/page.tsxrename to apps/web/src/app/[teamRef]/(shell)/[projectKey]/inbox/page.tsxdiff --git a/apps/web/src/app/[teamRef]/(shell)/[projectKey]/initiatives/[initiative]/issues/page.tsx b/apps/web/src/app/[teamRef]/(shell)/[projectKey]/initiatives/[initiative]/issues/page.tsxnew file mode 100644index 00000000..7a714f2d--- /dev/null+++ b/apps/web/src/app/[teamRef]/(shell)/[projectKey]/initiatives/[initiative]/issues/page.tsx@@ -0,0 +1,14 @@+import { notFound } from 'next/navigation';+import RequireFeature from '@/components/common/permissions/RequireFeature';+import InitiativeDetailPage from '@/features/initiatives/InitiativeDetailPage';++export default async function Page({ params }: { params: Promise<{ initiative: string }> }) {+ const id = Number((await params).initiative);+ if (!Number.isInteger(id) || id <= 0) notFound();++ return (+ <RequireFeature feature="initiatives">+ <InitiativeDetailPage initiativeId={id} tab="issues" />+ </RequireFeature>+ );+}diff --git a/apps/web/src/app/[teamRef]/(shell)/[projectKey]/initiatives/[initiative]/page.tsx b/apps/web/src/app/[teamRef]/(shell)/[projectKey]/initiatives/[initiative]/page.tsxnew file mode 100644index 00000000..a7e8c0d5--- /dev/null+++ b/apps/web/src/app/[teamRef]/(shell)/[projectKey]/initiatives/[initiative]/page.tsx@@ -0,0 +1,30 @@+import { notFound, redirect } from 'next/navigation';+import RequireFeature from '@/components/common/permissions/RequireFeature';+import InitiativesPage from '@/features/initiatives/InitiativesPage';+import InitiativeDetailPage from '@/features/initiatives/InitiativeDetailPage';+import { initiativesPath, isInitiativesTab, projectRefOf } from '@/utils/paths';++// One status tab of the initiatives list ("All" included), or one initiative.+export default async function Page({+ params,+}: {+ params: Promise<{ teamRef: string; projectKey: string; initiative: string }>;+}) {+ const { teamRef, projectKey, initiative } = await params;+ if (isInitiativesTab(initiative)) {+ return (+ <RequireFeature feature="initiatives">+ <InitiativesPage tab={initiative} />+ </RequireFeature>+ );+ }+ const id = Number(initiative);+ if (!Number.isInteger(id)) redirect(initiativesPath(projectRefOf(teamRef, projectKey)));+ if (id <= 0) notFound();++ return (+ <RequireFeature feature="initiatives">+ <InitiativeDetailPage initiativeId={id} tab="overview" />+ </RequireFeature>+ );+}diff --git a/apps/web/src/app/[teamRef]/(shell)/[projectKey]/initiatives/[initiative]/progress/page.tsx b/apps/web/src/app/[teamRef]/(shell)/[projectKey]/initiatives/[initiative]/progress/page.tsxnew file mode 100644index 00000000..75bdb8c4--- /dev/null+++ b/apps/web/src/app/[teamRef]/(shell)/[projectKey]/initiatives/[initiative]/progress/page.tsx@@ -0,0 +1,14 @@+import { notFound } from 'next/navigation';+import RequireFeature from '@/components/common/permissions/RequireFeature';+import InitiativeDetailPage from '@/features/initiatives/InitiativeDetailPage';++export default async function Page({ params }: { params: Promise<{ initiative: string }> }) {+ const id = Number((await params).initiative);+ if (!Number.isInteger(id) || id <= 0) notFound();++ return (+ <RequireFeature feature="initiatives">+ <InitiativeDetailPage initiativeId={id} tab="progress" />+ </RequireFeature>+ );+}diff --git a/apps/web/src/app/project/[projectKey]/initiatives/page.tsx b/apps/web/src/app/[teamRef]/(shell)/[projectKey]/initiatives/page.tsxsimilarity index 100%rename from apps/web/src/app/project/[projectKey]/initiatives/page.tsxrename to apps/web/src/app/[teamRef]/(shell)/[projectKey]/initiatives/page.tsxdiff --git a/apps/web/src/app/project/[projectKey]/mcp/page.tsx b/apps/web/src/app/[teamRef]/(shell)/[projectKey]/mcp/page.tsxsimilarity index 100%rename from apps/web/src/app/project/[projectKey]/mcp/page.tsxrename to apps/web/src/app/[teamRef]/(shell)/[projectKey]/mcp/page.tsxdiff --git a/apps/web/src/app/project/[projectKey]/members/page.tsx b/apps/web/src/app/[teamRef]/(shell)/[projectKey]/members/page.tsxsimilarity index 100%rename from apps/web/src/app/project/[projectKey]/members/page.tsxrename to apps/web/src/app/[teamRef]/(shell)/[projectKey]/members/page.tsxdiff --git a/apps/web/src/app/project/[projectKey]/notes/[boardId]/page.tsx b/apps/web/src/app/[teamRef]/(shell)/[projectKey]/notes/[boardId]/page.tsxsimilarity index 100%rename from apps/web/src/app/project/[projectKey]/notes/[boardId]/page.tsxrename to apps/web/src/app/[teamRef]/(shell)/[projectKey]/notes/[boardId]/page.tsxdiff --git a/apps/web/src/app/project/[projectKey]/notes/page.tsx b/apps/web/src/app/[teamRef]/(shell)/[projectKey]/notes/page.tsxsimilarity index 100%rename from apps/web/src/app/project/[projectKey]/notes/page.tsxrename to apps/web/src/app/[teamRef]/(shell)/[projectKey]/notes/page.tsxdiff --git a/apps/web/src/app/project/[projectKey]/notifications/page.tsx b/apps/web/src/app/[teamRef]/(shell)/[projectKey]/notifications/page.tsxsimilarity index 100%rename from apps/web/src/app/project/[projectKey]/notifications/page.tsxrename to apps/web/src/app/[teamRef]/(shell)/[projectKey]/notifications/page.tsxdiff --git a/apps/web/src/app/project/[projectKey]/page.tsx b/apps/web/src/app/[teamRef]/(shell)/[projectKey]/page.tsxsimilarity index 100%rename from apps/web/src/app/project/[projectKey]/page.tsxrename to apps/web/src/app/[teamRef]/(shell)/[projectKey]/page.tsxdiff --git a/apps/web/src/app/project/[projectKey]/settings/actions/page.tsx b/apps/web/src/app/[teamRef]/(shell)/[projectKey]/settings/actions/page.tsxsimilarity index 100%rename from apps/web/src/app/project/[projectKey]/settings/actions/page.tsxrename to apps/web/src/app/[teamRef]/(shell)/[projectKey]/settings/actions/page.tsxdiff --git a/apps/web/src/app/project/[projectKey]/settings/configuration/page.tsx b/apps/web/src/app/[teamRef]/(shell)/[projectKey]/settings/configuration/page.tsxsimilarity index 100%rename from apps/web/src/app/project/[projectKey]/settings/configuration/page.tsxrename to apps/web/src/app/[teamRef]/(shell)/[projectKey]/settings/configuration/page.tsxdiff --git a/apps/web/src/app/project/[projectKey]/settings/custom-fields/page.tsx b/apps/web/src/app/[teamRef]/(shell)/[projectKey]/settings/custom-fields/page.tsxsimilarity index 100%rename from apps/web/src/app/project/[projectKey]/settings/custom-fields/page.tsxrename to apps/web/src/app/[teamRef]/(shell)/[projectKey]/settings/custom-fields/page.tsxdiff --git a/apps/web/src/app/project/[projectKey]/settings/general/page.tsx b/apps/web/src/app/[teamRef]/(shell)/[projectKey]/settings/general/page.tsxsimilarity index 100%rename from apps/web/src/app/project/[projectKey]/settings/general/page.tsxrename to apps/web/src/app/[teamRef]/(shell)/[projectKey]/settings/general/page.tsxdiff --git a/apps/web/src/app/project/[projectKey]/settings/git/page.tsx b/apps/web/src/app/[teamRef]/(shell)/[projectKey]/settings/git/page.tsxsimilarity index 100%rename from apps/web/src/app/project/[projectKey]/settings/git/page.tsxrename to apps/web/src/app/[teamRef]/(shell)/[projectKey]/settings/git/page.tsxdiff --git a/apps/web/src/app/project/[projectKey]/settings/import-export/page.tsx b/apps/web/src/app/[teamRef]/(shell)/[projectKey]/settings/import-export/page.tsxsimilarity index 100%rename from apps/web/src/app/project/[projectKey]/settings/import-export/page.tsxrename to apps/web/src/app/[teamRef]/(shell)/[projectKey]/settings/import-export/page.tsxdiff --git a/apps/web/src/app/project/[projectKey]/settings/issue-templates/page.tsx b/apps/web/src/app/[teamRef]/(shell)/[projectKey]/settings/issue-templates/page.tsxsimilarity index 100%rename from apps/web/src/app/project/[projectKey]/settings/issue-templates/page.tsxrename to apps/web/src/app/[teamRef]/(shell)/[projectKey]/settings/issue-templates/page.tsxdiff --git a/apps/web/src/app/project/[projectKey]/settings/issue-types/page.tsx b/apps/web/src/app/[teamRef]/(shell)/[projectKey]/settings/issue-types/page.tsxsimilarity index 100%rename from apps/web/src/app/project/[projectKey]/settings/issue-types/page.tsxrename to apps/web/src/app/[teamRef]/(shell)/[projectKey]/settings/issue-types/page.tsxdiff --git a/apps/web/src/app/project/[projectKey]/settings/labels/page.tsx b/apps/web/src/app/[teamRef]/(shell)/[projectKey]/settings/labels/page.tsxsimilarity index 100%rename from apps/web/src/app/project/[projectKey]/settings/labels/page.tsxrename to apps/web/src/app/[teamRef]/(shell)/[projectKey]/settings/labels/page.tsxdiff --git a/apps/web/src/app/project/[projectKey]/settings/states/page.tsx b/apps/web/src/app/[teamRef]/(shell)/[projectKey]/settings/states/page.tsxsimilarity index 100%rename from apps/web/src/app/project/[projectKey]/settings/states/page.tsxrename to apps/web/src/app/[teamRef]/(shell)/[projectKey]/settings/states/page.tsxdiff --git a/apps/web/src/app/project/[projectKey]/settings/webhooks/page.tsx b/apps/web/src/app/[teamRef]/(shell)/[projectKey]/settings/webhooks/page.tsxsimilarity index 100%rename from apps/web/src/app/project/[projectKey]/settings/webhooks/page.tsxrename to apps/web/src/app/[teamRef]/(shell)/[projectKey]/settings/webhooks/page.tsxdiff --git a/apps/web/src/app/project/[projectKey]/view/[viewId]/page.tsx b/apps/web/src/app/[teamRef]/(shell)/[projectKey]/view/[viewId]/page.tsxsimilarity index 100%rename from apps/web/src/app/project/[projectKey]/view/[viewId]/page.tsxrename to apps/web/src/app/[teamRef]/(shell)/[projectKey]/view/[viewId]/page.tsxdiff --git a/apps/web/src/app/project/[projectKey]/issue/[issueId]/page.tsx b/apps/web/src/app/[teamRef]/(shell)/issue/[identifier]/page.tsxsimilarity index 100%rename from apps/web/src/app/project/[projectKey]/issue/[issueId]/page.tsxrename to apps/web/src/app/[teamRef]/(shell)/issue/[identifier]/page.tsxdiff --git a/apps/web/src/app/project/[projectKey]/layout.tsx b/apps/web/src/app/[teamRef]/(shell)/layout.tsxsimilarity index 100%rename from apps/web/src/app/project/[projectKey]/layout.tsxrename to apps/web/src/app/[teamRef]/(shell)/layout.tsxdiff --git a/apps/web/src/app/project/[projectKey]/loading.tsx b/apps/web/src/app/[teamRef]/(shell)/loading.tsxsimilarity index 100%rename from apps/web/src/app/project/[projectKey]/loading.tsxrename to apps/web/src/app/[teamRef]/(shell)/loading.tsxdiff --git a/apps/web/src/app/[teamRef]/page.tsx b/apps/web/src/app/[teamRef]/page.tsxnew file mode 100644index 00000000..5d32f7e4--- /dev/null+++ b/apps/web/src/app/[teamRef]/page.tsx@@ -0,0 +1,30 @@+'use client';++import { useParams } from 'next/navigation';+import LegacyRedirect from '@/components/common/LegacyRedirect';+import { issuePath, parseIssueIdentifier, projectPath, teamPath } from '@/utils/paths';++// /acme opens the team's first project, or its settings when it has none it shows.+// /MKT-42 is the issue short link from before keys were unique per team: the slug+// is lower case and an identifier is not, so the two never meet.+export default function Page() {+ const { teamRef } = useParams<{ teamRef: string }>();+ const segment = decodeURIComponent(teamRef);+ const issue = /^[A-Z]/.test(segment) ? parseIssueIdentifier(segment) : null;++ return (+ <LegacyRedirect+ resolve={(projects) => {+ if (issue) {+ const matches = projects.filter((project) => project.key === issue.key);+ return matches.length === 1 ? issuePath(matches[0].ref, issue.sequenceNumber) : null;+ }+ const ofTeam = projects.filter(+ (project) => project.teamRef === segment || String(project.teamId) === segment,+ );+ const first = ofTeam.find((project) => !project.isHidden) ?? ofTeam[0];+ return first ? projectPath(first.ref) : teamPath(segment);+ }}+ />+ );+}diff --git a/apps/web/src/app/[teamRef]/settings/agent-skills/page.tsx b/apps/web/src/app/[teamRef]/settings/agent-skills/page.tsxnew file mode 100644index 00000000..5640a701--- /dev/null+++ b/apps/web/src/app/[teamRef]/settings/agent-skills/page.tsx@@ -0,0 +1,9 @@+'use client';++import TeamAgentSkillsSection from '@/features/teams/components/agent-skills/TeamAgentSkillsSection';+import { useRouteTeam } from '@/features/teams/hooks/useRouteTeam';++export default function Page() {+ const team = useRouteTeam();+ return team && <TeamAgentSkillsSection teamId={team.id} />;+}diff --git a/apps/web/src/app/[teamRef]/settings/agent-tools/page.tsx b/apps/web/src/app/[teamRef]/settings/agent-tools/page.tsxnew file mode 100644index 00000000..e0d9ebe1--- /dev/null+++ b/apps/web/src/app/[teamRef]/settings/agent-tools/page.tsx@@ -0,0 +1,9 @@+'use client';++import TeamAgentToolsSection from '@/features/teams/components/agent-tools/TeamAgentToolsSection';+import { useRouteTeam } from '@/features/teams/hooks/useRouteTeam';++export default function Page() {+ const team = useRouteTeam();+ return team && <TeamAgentToolsSection teamId={team.id} />;+}diff --git a/apps/web/src/app/[teamRef]/settings/ai-agents/page.tsx b/apps/web/src/app/[teamRef]/settings/ai-agents/page.tsxnew file mode 100644index 00000000..db775c64--- /dev/null+++ b/apps/web/src/app/[teamRef]/settings/ai-agents/page.tsx@@ -0,0 +1,9 @@+'use client';++import TeamAiAgentsSection from '@/features/teams/components/ai-agents/TeamAiAgentsSection';+import { useRouteTeam } from '@/features/teams/hooks/useRouteTeam';++export default function Page() {+ const team = useRouteTeam();+ return team && <TeamAiAgentsSection teamId={team.id} />;+}diff --git a/apps/web/src/app/[teamRef]/settings/git/page.tsx b/apps/web/src/app/[teamRef]/settings/git/page.tsxnew file mode 100644index 00000000..5e1b66ef--- /dev/null+++ b/apps/web/src/app/[teamRef]/settings/git/page.tsx@@ -0,0 +1,9 @@+'use client';++import TeamGitSection from '@/features/teams/components/integrations/TeamGitSection';+import { useRouteTeam } from '@/features/teams/hooks/useRouteTeam';++export default function Page() {+ const team = useRouteTeam();+ return team && <TeamGitSection teamId={team.id} />;+}diff --git a/apps/web/src/app/[teamRef]/settings/integrations/page.tsx b/apps/web/src/app/[teamRef]/settings/integrations/page.tsxnew file mode 100644index 00000000..58797234--- /dev/null+++ b/apps/web/src/app/[teamRef]/settings/integrations/page.tsx@@ -0,0 +1,9 @@+'use client';++import TeamIntegrationsSection from '@/features/teams/components/integrations/TeamIntegrationsSection';+import { useRouteTeam } from '@/features/teams/hooks/useRouteTeam';++export default function Page() {+ const team = useRouteTeam();+ return team && <TeamIntegrationsSection teamId={team.id} />;+}diff --git a/apps/web/src/app/[teamRef]/settings/layout.tsx b/apps/web/src/app/[teamRef]/settings/layout.tsxnew file mode 100644index 00000000..e905eb7b--- /dev/null+++ b/apps/web/src/app/[teamRef]/settings/layout.tsx@@ -0,0 +1,11 @@+import type { ReactNode } from 'react';+import ManageTeamsLayout from '@/features/teams/ManageTeamsLayout';+import TeamLayout from '@/features/teams/TeamLayout';++export default function Layout({ children }: { children: ReactNode }) {+ return (+ <ManageTeamsLayout>+ <TeamLayout>{children}</TeamLayout>+ </ManageTeamsLayout>+ );+}diff --git a/apps/web/src/app/account/teams/[teamId]/loading.tsx b/apps/web/src/app/[teamRef]/settings/loading.tsxsimilarity index 100%rename from apps/web/src/app/account/teams/[teamId]/loading.tsxrename to apps/web/src/app/[teamRef]/settings/loading.tsxdiff --git a/apps/web/src/app/[teamRef]/settings/mcp/page.tsx b/apps/web/src/app/[teamRef]/settings/mcp/page.tsxnew file mode 100644index 00000000..954c494d--- /dev/null+++ b/apps/web/src/app/[teamRef]/settings/mcp/page.tsx@@ -0,0 +1,9 @@+'use client';++import TeamMcpSection from '@/features/teams/components/mcp/TeamMcpSection';+import { useRouteTeam } from '@/features/teams/hooks/useRouteTeam';++export default function Page() {+ const team = useRouteTeam();+ return team && <TeamMcpSection teamId={team.id} />;+}diff --git a/apps/web/src/app/[teamRef]/settings/members/page.tsx b/apps/web/src/app/[teamRef]/settings/members/page.tsxnew file mode 100644index 00000000..11752bd1--- /dev/null+++ b/apps/web/src/app/[teamRef]/settings/members/page.tsx@@ -0,0 +1,9 @@+'use client';++import TeamMembersSection from '@/features/teams/components/members/TeamMembersSection';+import { useRouteTeam } from '@/features/teams/hooks/useRouteTeam';++export default function Page() {+ const team = useRouteTeam();+ return team && <TeamMembersSection teamId={team.id} />;+}diff --git a/apps/web/src/app/[teamRef]/settings/notifications/page.tsx b/apps/web/src/app/[teamRef]/settings/notifications/page.tsxnew file mode 100644index 00000000..0eda1cd7--- /dev/null+++ b/apps/web/src/app/[teamRef]/settings/notifications/page.tsx@@ -0,0 +1,9 @@+'use client';++import TeamNotificationsSection from '@/features/teams/components/notifications/TeamNotificationsSection';+import { useRouteTeam } from '@/features/teams/hooks/useRouteTeam';++export default function Page() {+ const team = useRouteTeam();+ return team && <TeamNotificationsSection teamId={team.id} />;+}diff --git a/apps/web/src/app/[teamRef]/settings/page.tsx b/apps/web/src/app/[teamRef]/settings/page.tsxnew file mode 100644index 00000000..c7949795--- /dev/null+++ b/apps/web/src/app/[teamRef]/settings/page.tsx@@ -0,0 +1,9 @@+'use client';++import TeamInfoSection from '@/features/teams/components/info/TeamInfoSection';+import { useRouteTeam } from '@/features/teams/hooks/useRouteTeam';++export default function Page() {+ const team = useRouteTeam();+ return team && <TeamInfoSection teamId={team.id} />;+}diff --git a/apps/web/src/app/[teamRef]/settings/projects/page.tsx b/apps/web/src/app/[teamRef]/settings/projects/page.tsxnew file mode 100644index 00000000..6b11e670--- /dev/null+++ b/apps/web/src/app/[teamRef]/settings/projects/page.tsx@@ -0,0 +1,9 @@+'use client';++import TeamProjectsSection from '@/features/teams/components/projects/TeamProjectsSection';+import { useRouteTeam } from '@/features/teams/hooks/useRouteTeam';++export default function Page() {+ const team = useRouteTeam();+ return team && <TeamProjectsSection teamId={team.id} />;+}diff --git a/apps/web/src/app/[teamRef]/settings/roles/page.tsx b/apps/web/src/app/[teamRef]/settings/roles/page.tsxnew file mode 100644index 00000000..e9838fed--- /dev/null+++ b/apps/web/src/app/[teamRef]/settings/roles/page.tsx@@ -0,0 +1,9 @@+'use client';++import TeamRolesSection from '@/features/teams/components/roles/TeamRolesSection';+import { useRouteTeam } from '@/features/teams/hooks/useRouteTeam';++export default function Page() {+ const team = useRouteTeam();+ return team && <TeamRolesSection teamId={team.id} />;+}diff --git a/apps/web/src/app/account/teams/[teamId]/[[...section]]/page.tsx b/apps/web/src/app/account/teams/[teamId]/[[...section]]/page.tsxnew file mode 100644index 00000000..93e9bb3a--- /dev/null+++ b/apps/web/src/app/account/teams/[teamId]/[[...section]]/page.tsx@@ -0,0 +1,12 @@+import { redirect } from 'next/navigation';++// The path team settings had before they moved under the team. The id is a valid+// team ref, and the settings page moves it on to the slug.+export default async function Page({+ params,+}: {+ params: Promise<{ teamId: string; section?: string[] }>;+}) {+ const { teamId, section = [] } = await params;+ redirect(['', teamId, 'settings', ...section].map(encodeURIComponent).join('/'));+}diff --git a/apps/web/src/app/account/teams/[teamId]/agent-skills/page.tsx b/apps/web/src/app/account/teams/[teamId]/agent-skills/page.tsxdeleted file mode 100644index c917d229..00000000--- a/apps/web/src/app/account/teams/[teamId]/agent-skills/page.tsx+++ /dev/null@@ -1,6 +0,0 @@-import TeamAgentSkillsSection from '@/features/teams/components/agent-skills/TeamAgentSkillsSection';--export default async function Page({ params }: { params: Promise<{ teamId: string }> }) {- const { teamId } = await params;- return <TeamAgentSkillsSection teamId={Number(teamId)} />;-}diff --git a/apps/web/src/app/account/teams/[teamId]/agent-tools/page.tsx b/apps/web/src/app/account/teams/[teamId]/agent-tools/page.tsxdeleted file mode 100644index 4987c94c..00000000--- a/apps/web/src/app/account/teams/[teamId]/agent-tools/page.tsx+++ /dev/null@@ -1,6 +0,0 @@-import TeamAgentToolsSection from '@/features/teams/components/agent-tools/TeamAgentToolsSection';--export default async function Page({ params }: { params: Promise<{ teamId: string }> }) {- const { teamId } = await params;- return <TeamAgentToolsSection teamId={Number(teamId)} />;-}diff --git a/apps/web/src/app/account/teams/[teamId]/ai-agents/page.tsx b/apps/web/src/app/account/teams/[teamId]/ai-agents/page.tsxdeleted file mode 100644index 3b078ba8..00000000--- a/apps/web/src/app/account/teams/[teamId]/ai-agents/page.tsx+++ /dev/null@@ -1,6 +0,0 @@-import TeamAiAgentsSection from '@/features/teams/components/ai-agents/TeamAiAgentsSection';--export default async function Page({ params }: { params: Promise<{ teamId: string }> }) {- const { teamId } = await params;- return <TeamAiAgentsSection teamId={Number(teamId)} />;-}diff --git a/apps/web/src/app/account/teams/[teamId]/git/page.tsx b/apps/web/src/app/account/teams/[teamId]/git/page.tsxdeleted file mode 100644index deb56ad9..00000000--- a/apps/web/src/app/account/teams/[teamId]/git/page.tsx+++ /dev/null@@ -1,6 +0,0 @@-import TeamGitSection from '@/features/teams/components/integrations/TeamGitSection';--export default async function Page({ params }: { params: Promise<{ teamId: string }> }) {- const { teamId } = await params;- return <TeamGitSection teamId={Number(teamId)} />;-}diff --git a/apps/web/src/app/account/teams/[teamId]/integrations/page.tsx b/apps/web/src/app/account/teams/[teamId]/integrations/page.tsxdeleted file mode 100644index b4f4a4ab..00000000--- a/apps/web/src/app/account/teams/[teamId]/integrations/page.tsx+++ /dev/null@@ -1,6 +0,0 @@-import TeamIntegrationsSection from '@/features/teams/components/integrations/TeamIntegrationsSection';--export default async function Page({ params }: { params: Promise<{ teamId: string }> }) {- const { teamId } = await params;- return <TeamIntegrationsSection teamId={Number(teamId)} />;-}diff --git a/apps/web/src/app/account/teams/[teamId]/layout.tsx b/apps/web/src/app/account/teams/[teamId]/layout.tsxdeleted file mode 100644index 85f75ed0..00000000--- a/apps/web/src/app/account/teams/[teamId]/layout.tsx+++ /dev/null@@ -1,17 +0,0 @@-import type { ReactNode } from 'react';-import { notFound } from 'next/navigation';-import TeamLayout from '@/features/teams/TeamLayout';--export default async function Layout({- params,- children,-}: {- params: Promise<{ teamId: string }>;- children: ReactNode;-}) {- const { teamId } = await params;- const id = Number(teamId);- if (!Number.isInteger(id)) notFound();-- return <TeamLayout teamId={id}>{children}</TeamLayout>;-}diff --git a/apps/web/src/app/account/teams/[teamId]/mcp/page.tsx b/apps/web/src/app/account/teams/[teamId]/mcp/page.tsxdeleted file mode 100644index 337f7693..00000000--- a/apps/web/src/app/account/teams/[teamId]/mcp/page.tsx+++ /dev/null@@ -1,6 +0,0 @@-import TeamMcpSection from '@/features/teams/components/mcp/TeamMcpSection';--export default async function Page({ params }: { params: Promise<{ teamId: string }> }) {- const { teamId } = await params;- return <TeamMcpSection teamId={Number(teamId)} />;-}diff --git a/apps/web/src/app/account/teams/[teamId]/members/page.tsx b/apps/web/src/app/account/teams/[teamId]/members/page.tsxdeleted file mode 100644index b00408b3..00000000--- a/apps/web/src/app/account/teams/[teamId]/members/page.tsx+++ /dev/null@@ -1,6 +0,0 @@-import TeamMembersSection from '@/features/teams/components/members/TeamMembersSection';--export default async function Page({ params }: { params: Promise<{ teamId: string }> }) {- const { teamId } = await params;- return <TeamMembersSection teamId={Number(teamId)} />;-}diff --git a/apps/web/src/app/account/teams/[teamId]/notifications/page.tsx b/apps/web/src/app/account/teams/[teamId]/notifications/page.tsxdeleted file mode 100644index 0a94330d..00000000--- a/apps/web/src/app/account/teams/[teamId]/notifications/page.tsx+++ /dev/null@@ -1,6 +0,0 @@-import TeamNotificationsSection from '@/features/teams/components/notifications/TeamNotificationsSection';--export default async function Page({ params }: { params: Promise<{ teamId: string }> }) {- const { teamId } = await params;- return <TeamNotificationsSection teamId={Number(teamId)} />;-}diff --git a/apps/web/src/app/account/teams/[teamId]/page.tsx b/apps/web/src/app/account/teams/[teamId]/page.tsxdeleted file mode 100644index 5ea9651f..00000000--- a/apps/web/src/app/account/teams/[teamId]/page.tsx+++ /dev/null@@ -1,6 +0,0 @@-import TeamInfoSection from '@/features/teams/components/info/TeamInfoSection';--export default async function Page({ params }: { params: Promise<{ teamId: string }> }) {- const { teamId } = await params;- return <TeamInfoSection teamId={Number(teamId)} />;-}diff --git a/apps/web/src/app/account/teams/[teamId]/projects/page.tsx b/apps/web/src/app/account/teams/[teamId]/projects/page.tsxdeleted file mode 100644index 113e6630..00000000--- a/apps/web/src/app/account/teams/[teamId]/projects/page.tsx+++ /dev/null@@ -1,6 +0,0 @@-import TeamProjectsSection from '@/features/teams/components/projects/TeamProjectsSection';--export default async function Page({ params }: { params: Promise<{ teamId: string }> }) {- const { teamId } = await params;- return <TeamProjectsSection teamId={Number(teamId)} />;-}diff --git a/apps/web/src/app/account/teams/[teamId]/roles/page.tsx b/apps/web/src/app/account/teams/[teamId]/roles/page.tsxdeleted file mode 100644index efaf0ec3..00000000--- a/apps/web/src/app/account/teams/[teamId]/roles/page.tsx+++ /dev/null@@ -1,6 +0,0 @@-import TeamRolesSection from '@/features/teams/components/roles/TeamRolesSection';--export default async function Page({ params }: { params: Promise<{ teamId: string }> }) {- const { teamId } = await params;- return <TeamRolesSection teamId={Number(teamId)} />;-}diff --git a/apps/web/src/app/issue/[issueId]/page.tsx b/apps/web/src/app/issue/[issueId]/page.tsxindex 30e8ce30..fd16f6d6 100644--- a/apps/web/src/app/issue/[issueId]/page.tsx+++ b/apps/web/src/app/issue/[issueId]/page.tsx@@ -1,28 +1,24 @@'use client';-import { useEffect } from 'react';-import { useParams, useRouter } from 'next/navigation';+import { useParams } from 'next/navigation';+import LegacyRedirect from '@/components/common/LegacyRedirect';import { useIssueQuery } from '@/services/issues.service';import { issuePath } from '@/utils/paths';-// A bare deep link /issue/:issueId has no project key in the URL. Resolve the-// issue's project (its identifier is "<projectKey>-<number>") and redirect to the-// project-scoped issue route so it opens inside the Shell layout.+// A bare deep link /issue/:issueId carries neither the team nor the key: the issue+// names its project by id, which the viewer's project list maps to its path.export default function IssueRedirect() {- const router = useRouter();- const params = useParams();- const id = Number(typeof params.issueId === 'string' ? params.issueId : NaN);+ const { issueId } = useParams<{ issueId: string }>();+ const id = Number(issueId);const { data, isLoading } = useIssueQuery(Number.isNaN(id) ? null : id);- useEffect(() => {- if (isLoading) return;- const projectKey = data ? data.identifier.replace(/-\d+$/, '') : null;- router.replace(projectKey && data ? issuePath(projectKey, data.sequenceNumber) : '/');- }, [data, isLoading, router]);-+ if (isLoading) return null;return (- <div className="flex h-svh items-center justify-center bg-background text-sm text-muted-foreground">- Loading…- </div>+ <LegacyRedirect+ resolve={(projects) => {+ const project = data && projects.find((p) => p.id === data.projectId);+ return project && issuePath(project.ref, data.sequenceNumber);+ }}+ />);}diff --git a/apps/web/src/app/page.tsx b/apps/web/src/app/page.tsxindex ce946fca..6fbe45c5 100644--- a/apps/web/src/app/page.tsx+++ b/apps/web/src/app/page.tsx@@ -3,30 +3,27 @@import { useEffect, useState } from 'react';import { useRouter } from 'next/navigation';import { useTranslations } from 'next-intl';-import { Plus, SquareKanban } from 'lucide-react';+import { SquareKanban, Users } from 'lucide-react';import { useProjectsQuery } from '@/services/projects.service';+import { useTeamsQuery } from '@/services/teams.service';import { useAccountPreferencesQuery } from '@/services/preferences.service';import { startPagePath, projectPath } from '@/utils/paths';import NewProjectModal from '@/components/layout/NewProjectModal';+import NewTeamModal from '@/features/teams/components/NewTeamModal';import ProjectSwitcherHiddenState from '@/components/layout/ProjectSwitcherHiddenState';-import { Button } from '@/components/ui/button';-import {- Empty,- EmptyContent,- EmptyDescription,- EmptyHeader,- EmptyMedia,- EmptyTitle,-} from '@/components/ui/empty';+import StartEmpty from '@/components/layout/StartEmpty';// The index route: reopen the last-used project if it still exists, otherwise the// first visible favorite or project, on the user's preferred start page. Waits for both// the project list and the preferences before deciding so it does not flash the-// wrong destination. With no projects at all, offers to create the first one.+// wrong destination. With no projects at all, an account that owns or manages a team+// is offered to create the first one there, and any other to create its own team — a+// plain member is also told who adds them to the team's projects.export default function Home() {const t = useTranslations('shell');const tCommon = useTranslations('common');const router = useRouter();+ const { data: teams } = useTeamsQuery();const { data: projects } = useProjectsQuery();const { data: prefs, isPending: prefsPending } = useAccountPreferencesQuery();const [creating, setCreating] = useState(false);@@ -36,7 +33,7 @@ export default function Home() {const visible = projects.filter((project) => !project.isHidden);if (visible.length === 0) return;const last = visible.find((p) => p.id === prefs?.lastProjectId);- const target = last?.key ?? visible.find((p) => p.isFavorite)?.key ?? visible[0]?.key;+ const target = last?.ref ?? visible.find((p) => p.isFavorite)?.ref ?? visible[0]?.ref;if (target) router.replace(startPagePath(target, prefs?.startPage ?? 'work-items'));}, [projects, prefs, prefsPending, router]);@@ -44,29 +41,36 @@ export default function Home() {return <ProjectSwitcherHiddenState projects={projects} />;}+ const managedTeam = teams?.find((one) => one.role !== 'member');++ if (teams && !managedTeam && projects?.length === 0) {+ return (+ <StartEmpty+ icon={<Users />}+ title={teams.length === 0 ? t('noTeamsTitle') : t('noProjectsTitle')}+ hint={teams.length === 0 ? t('noTeamsHint') : t('noProjectAccessHint')}+ action={t('createTeam')}+ onAction={() => setCreating(true)}+ >+ {creating && <NewTeamModal onClose={() => setCreating(false)} />}+ </StartEmpty>+ );+ }+// No projects yet: the Shell (which owns the New project modal) never mounts// without a project, so the empty state offers project creation directly.- if (projects && projects.length === 0) {+ if (managedTeam && projects?.length === 0) {return (- <div className="flex h-svh items-center justify-center p-6">- <Empty className="max-w-md">- <EmptyHeader>- <EmptyMedia variant="icon">- <SquareKanban />- </EmptyMedia>- <EmptyTitle>{t('noProjectsTitle')}</EmptyTitle>- <EmptyDescription>{t('noProjectsHint')}</EmptyDescription>- </EmptyHeader>- <EmptyContent>- <Button onClick={() => setCreating(true)}>- <Plus />- {t('createProject')}- </Button>- </EmptyContent>- </Empty>-+ <StartEmpty+ icon={<SquareKanban />}+ title={t('noProjectsTitle')}+ hint={t('noProjectsHint')}+ action={t('createProject')}+ onAction={() => setCreating(true)}+ >{creating && (<NewProjectModal+ teamId={managedTeam.id}onClose={() => setCreating(false)}onCreated={(key) => {setCreating(false);@@ -74,7 +78,7 @@ export default function Home() {}}/>)}- </div>+ </StartEmpty>);}diff --git a/apps/web/src/app/project/[projectKey]/[[...rest]]/page.tsx b/apps/web/src/app/project/[projectKey]/[[...rest]]/page.tsxnew file mode 100644index 00000000..ea2b06c8--- /dev/null+++ b/apps/web/src/app/project/[projectKey]/[[...rest]]/page.tsx@@ -0,0 +1,42 @@+'use client';++import { useParams } from 'next/navigation';+import LegacyRedirect from '@/components/common/LegacyRedirect';+import { issuePath, projectPath } from '@/utils/paths';++// The project paths from before keys were unique per team, /project/MKT/…, moved to+// /acme/MKT/…, with the segments renamed on the way.+function movedSegments(rest: string[]): string[] {+ const [first, ...after] = rest;+ switch (first) {+ case 'dashboard':+ return ['dashboards', ...after];+ case 'ai-agents':+ return ['agents'];+ case 'ai-team':+ return ['agents', ...after];+ case 'cycles':+ case 'initiatives':+ return after[0] === 'details' ? [first, ...after.slice(1)] : rest;+ default:+ return rest;+ }+}++export default function Page() {+ const { projectKey, rest = [] } = useParams<{ projectKey: string; rest?: string[] }>();+ const key = decodeURIComponent(projectKey);++ return (+ <LegacyRedirect+ resolve={(projects) => {+ const matches = projects.filter((project) => project.key === key);+ if (matches.length !== 1) return null;+ const { ref } = matches[0];+ if (rest[0] === 'issue' && /^\d+$/.test(rest[1] ?? ''))+ return issuePath(ref, Number(rest[1]));+ return [projectPath(ref), ...movedSegments(rest)].join('/');+ }}+ />+ );+}diff --git a/apps/web/src/app/project/[projectKey]/ai-team/chat/page.tsx b/apps/web/src/app/project/[projectKey]/ai-team/chat/page.tsxdeleted file mode 100644index c8dd9f75..00000000--- a/apps/web/src/app/project/[projectKey]/ai-team/chat/page.tsx+++ /dev/null@@ -1,10 +0,0 @@-import { redirect } from 'next/navigation';-import { aiTeamPath } from '@/utils/paths';-import { AI_TEAM_SECTIONS } from '@/utils/settingsSections';--// The chat is a panel now, so its old path has no page of its own and sends the-// viewer to the first AI Team section.-export default async function Page({ params }: { params: Promise<{ projectKey: string }> }) {- const { projectKey } = await params;- redirect(aiTeamPath(projectKey, AI_TEAM_SECTIONS[0].slug));-}diff --git a/apps/web/src/app/project/[projectKey]/cycles/[view]/page.tsx b/apps/web/src/app/project/[projectKey]/cycles/[view]/page.tsxdeleted file mode 100644index d72692ea..00000000--- a/apps/web/src/app/project/[projectKey]/cycles/[view]/page.tsx+++ /dev/null@@ -1,20 +0,0 @@-import { redirect } from 'next/navigation';-import RequireFeature from '@/components/common/permissions/RequireFeature';-import CyclesPage from '@/features/cycles/CyclesPage';-import { cyclesPath, isCyclesView } from '@/utils/paths';--// One layout of the cycles list: the grouped table or the day track.-export default async function Page({- params,-}: {- params: Promise<{ projectKey: string; view: string }>;-}) {- const { projectKey, view } = await params;- if (!isCyclesView(view)) redirect(cyclesPath(projectKey));-- return (- <RequireFeature feature="cycles">- <CyclesPage view={view} />- </RequireFeature>- );-}diff --git a/apps/web/src/app/project/[projectKey]/cycles/details/[cycleId]/page.tsx b/apps/web/src/app/project/[projectKey]/cycles/details/[cycleId]/page.tsxdeleted file mode 100644index edcbdf1e..00000000--- a/apps/web/src/app/project/[projectKey]/cycles/details/[cycleId]/page.tsx+++ /dev/null@@ -1,15 +0,0 @@-import { notFound } from 'next/navigation';-import RequireFeature from '@/components/common/permissions/RequireFeature';-import CycleDetailPage from '@/features/cycles/CycleDetailPage';--export default async function Page({ params }: { params: Promise<{ cycleId: string }> }) {- const { cycleId } = await params;- const id = Number(cycleId);- if (!Number.isInteger(id)) notFound();-- return (- <RequireFeature feature="cycles">- <CycleDetailPage cycleId={id} />- </RequireFeature>- );-}diff --git a/apps/web/src/app/project/[projectKey]/initiatives/[tab]/page.tsx b/apps/web/src/app/project/[projectKey]/initiatives/[tab]/page.tsxdeleted file mode 100644index 6f6d7007..00000000--- a/apps/web/src/app/project/[projectKey]/initiatives/[tab]/page.tsx+++ /dev/null@@ -1,20 +0,0 @@-import { redirect } from 'next/navigation';-import RequireFeature from '@/components/common/permissions/RequireFeature';-import InitiativesPage from '@/features/initiatives/InitiativesPage';-import { initiativesPath, isInitiativesTab } from '@/utils/paths';--// One status tab of the initiatives list, "All" included.-export default async function Page({- params,-}: {- params: Promise<{ projectKey: string; tab: string }>;-}) {- const { projectKey, tab } = await params;- if (!isInitiativesTab(tab)) redirect(initiativesPath(projectKey));-- return (- <RequireFeature feature="initiatives">- <InitiativesPage tab={tab} />- </RequireFeature>- );-}diff --git a/apps/web/src/app/project/[projectKey]/initiatives/details/[initiativeId]/issues/page.tsx b/apps/web/src/app/project/[projectKey]/initiatives/details/[initiativeId]/issues/page.tsxdeleted file mode 100644index 8c35c32a..00000000--- a/apps/web/src/app/project/[projectKey]/initiatives/details/[initiativeId]/issues/page.tsx+++ /dev/null@@ -1,10 +0,0 @@-import RequireFeature from '@/components/common/permissions/RequireFeature';-import InitiativeDetailPage from '@/features/initiatives/InitiativeDetailPage';--export default function Page() {- return (- <RequireFeature feature="initiatives">- <InitiativeDetailPage tab="issues" />- </RequireFeature>- );-}diff --git a/apps/web/src/app/project/[projectKey]/initiatives/details/[initiativeId]/page.tsx b/apps/web/src/app/project/[projectKey]/initiatives/details/[initiativeId]/page.tsxdeleted file mode 100644index e54a29a5..00000000--- a/apps/web/src/app/project/[projectKey]/initiatives/details/[initiativeId]/page.tsx+++ /dev/null@@ -1,10 +0,0 @@-import RequireFeature from '@/components/common/permissions/RequireFeature';-import InitiativeDetailPage from '@/features/initiatives/InitiativeDetailPage';--export default function Page() {- return (- <RequireFeature feature="initiatives">- <InitiativeDetailPage tab="overview" />- </RequireFeature>- );-}diff --git a/apps/web/src/app/project/[projectKey]/initiatives/details/[initiativeId]/progress/page.tsx b/apps/web/src/app/project/[projectKey]/initiatives/details/[initiativeId]/progress/page.tsxdeleted file mode 100644index 239bb110..00000000--- a/apps/web/src/app/project/[projectKey]/initiatives/details/[initiativeId]/progress/page.tsx+++ /dev/null@@ -1,10 +0,0 @@-import RequireFeature from '@/components/common/permissions/RequireFeature';-import InitiativeDetailPage from '@/features/initiatives/InitiativeDetailPage';--export default function Page() {- return (- <RequireFeature feature="initiatives">- <InitiativeDetailPage tab="progress" />- </RequireFeature>- );-}diff --git a/apps/web/src/components/common/LegacyRedirect.tsx b/apps/web/src/components/common/LegacyRedirect.tsxnew file mode 100644index 00000000..2d33c800--- /dev/null+++ b/apps/web/src/components/common/LegacyRedirect.tsx@@ -0,0 +1,31 @@+'use client';++import { useEffect } from 'react';+import { useRouter } from 'next/navigation';+import { useTranslations } from 'next-intl';+import type { Project } from '@/lib/api/endpoints/projects';+import { useProjectsQuery } from '@/services/projects.service';++// Sends a path from before project keys were unique per team (/project/MKT/…, /MKT-42,+// /issue/:id) to the one that replaced it. `resolve` finds the project among the+// viewer's own and builds the new path; a key two of their teams share, or one they+// do not reach, lands on the home page.+export default function LegacyRedirect({+ resolve,+}: {+ resolve: (projects: Project[]) => string | null | undefined;+}) {+ const t = useTranslations('common');+ const router = useRouter();+ const { data: projects } = useProjectsQuery();++ useEffect(() => {+ if (projects) router.replace(resolve(projects) ?? '/');+ }, [projects, resolve, router]);++ return (+ <div className="flex h-svh items-center justify-center bg-background text-sm text-muted-foreground">+ {t('loading')}+ </div>+ );+}diff --git a/apps/web/src/components/common/editor/IssueRefChip.tsx b/apps/web/src/components/common/editor/IssueRefChip.tsxindex a293a19c..23ba9d85 100644--- a/apps/web/src/components/common/editor/IssueRefChip.tsx+++ b/apps/web/src/components/common/editor/IssueRefChip.tsx@@ -1,18 +1,18 @@import { useRef } from 'react';-import { issuePath } from '@/utils/paths';+import { issuePath, splitProjectRef } from '@/utils/paths';import type { ResolvedLinkPreview } from './resolveLinkPreview';import { useLinkPreviewQuery } from './useLinkPreviewQuery';// The link an issue identifier is drawn as in read-only text: the state colour, the// identifier and the title, read through the same query as the hover card.export default function IssueRefChip({- projectKey,+ projectRef,sequence,}: {- projectKey: string;+ projectRef: string;sequence: number;}) {- const path = issuePath(projectKey, sequence);+ const path = issuePath(projectRef, sequence);const { data, isError } = useLinkPreviewQuery(new URL(path, window.location.origin).href);// The query hides an internal preview while it revalidates, which the hover card// starts on every open. The chip keeps what it showed until the answer is a failure.@@ -25,7 +25,7 @@ export default function IssueRefChip({{preview?.status && (<span className="issue-ref-dot" style={{ backgroundColor: preview.status.color }} />)}- <span className="issue-ref-id">{`${projectKey}-${sequence}`}</span>+ <span className="issue-ref-id">{`${splitProjectRef(projectRef).key}-${sequence}`}</span>{preview?.issueTitle && <span className="issue-ref-title">{preview.issueTitle}</span>}</a>);diff --git a/apps/web/src/components/common/editor/MarkdownEditor.tsx b/apps/web/src/components/common/editor/MarkdownEditor.tsxindex a3a764f9..f0a5660e 100644--- a/apps/web/src/components/common/editor/MarkdownEditor.tsx+++ b/apps/web/src/components/common/editor/MarkdownEditor.tsx@@ -121,6 +121,7 @@ export default function MarkdownEditor({};const editor = useEditor({+ immediatelyRender: false,editable,extensions: [// Replaces StarterKit's plain code block, keeping the node name codeBlock.@@ -142,7 +143,7 @@ export default function MarkdownEditor({}),// Paints KEY-123 as a link without writing the link into the markdown.IssueRef.configure({- keys: () => issueRefsRef.current.keys,+ refs: () => issueRefsRef.current.refs,open: (href) => openIssueRefRef.current(href),rich: () => issueRefsRef.current.resolve && (!editableRef.current || !focusedRef.current),}),@@ -225,12 +226,12 @@ export default function MarkdownEditor({// eslint-disable-next-line react-hooks/exhaustive-deps}, [editor]);- const issueRefKeyList = issueRefs.keys.join(',');+ const issueRefList = issueRefs.refs.join(',');useEffect(() => {// After the commit. The refresh mounts the chip, and doing it here calls flushSync.const frame = requestAnimationFrame(() => refreshDecorations(editor));return () => cancelAnimationFrame(frame);- }, [editor, issueRefKeyList, issueRefs.resolve, selfHandle, editable, focused]);+ }, [editor, issueRefList, issueRefs.resolve, selfHandle, editable, focused]);if (!editor) return null;diff --git a/apps/web/src/components/common/editor/internalLinkTarget.test.ts b/apps/web/src/components/common/editor/internalLinkTarget.test.tsindex c42bc6e6..d4b9c641 100644--- a/apps/web/src/components/common/editor/internalLinkTarget.test.ts+++ b/apps/web/src/components/common/editor/internalLinkTarget.test.ts@@ -18,6 +18,19 @@ describe('internal link targets', () => {assert.deepEqual(internalLinkTarget(new URL(path, 'https://planner.test')), expected);});+ it('recognizes the team-first routes and names the project by its ref', () => {+ const examples = [+ ['/acme/SYR', { kind: 'project', projectKey: 'acme.SYR' }],+ ['/acme/issue/SYR-13', { kind: 'issue', projectKey: 'acme.SYR', id: 13 }],+ ['/12/issue/SYR-13#details', { kind: 'issue', projectKey: '12.SYR', id: 13 }],+ ['/acme/SYR/notes/18', { kind: 'notes', projectKey: 'acme.SYR', id: 18 }],+ ['/acme/SYR/docs/9', { kind: 'document', projectKey: 'acme.SYR', id: 9 }],+ ['/acme/SYR/view/41', { kind: 'view', projectKey: 'acme.SYR', id: 41 }],+ ] as const;+ for (const [path, expected] of examples)+ assert.deepEqual(internalLinkTarget(new URL(path, 'https://planner.test')), expected);+ });+it('rejects unsupported, malformed and unsafe numeric routes', () => {for (const path of ['/account/profile',@@ -29,6 +42,11 @@ describe('internal link targets', () => {'/project/SYR%2Fother/notes/1','/project/%E0%A4%A','/project/SYR/issue/1/extra',+ '/account/teams',+ '/acme/settings/members',+ '/acme/issue/SYR-0',+ '/acme/issue/42',+ '/acme/SYR/settings/general',]) {assert.equal(internalLinkTarget(new URL(path, 'https://planner.test')), null, path);}diff --git a/apps/web/src/components/common/editor/internalLinkTarget.ts b/apps/web/src/components/common/editor/internalLinkTarget.tsindex bc4cc87b..60ce7ff1 100644--- a/apps/web/src/components/common/editor/internalLinkTarget.ts+++ b/apps/web/src/components/common/editor/internalLinkTarget.ts@@ -1,3 +1,5 @@+import { parseIssueIdentifier, projectRefOf } from '@/utils/paths';+export type InternalLinkTarget =| { kind: 'project'; projectKey: string }| { kind: 'issueId'; id: number }@@ -17,6 +19,8 @@ export function internalLinkTarget(url: URL): InternalLinkTarget | null {return null;}if (parts.some((part) => /[/\\?#\p{Cc}]/u.test(part))) return null;+ // The paths from before keys were per team — /KEY-42, /issue/:id, /project/KEY/…+ // — name the project by its bare key, which the API still resolves.if (parts.length === 1) {const match = /^(.+)-(\d+)$/.exec(parts[0]!);const id = positiveId(match?.[2]);@@ -26,13 +30,26 @@ export function internalLinkTarget(url: URL): InternalLinkTarget | null {const id = positiveId(parts[1]);return id ? { kind: 'issueId', id } : null;}- if (parts[0] !== 'project' || !parts[1]) return null;- const projectKey = parts[1];- if (parts.length === 2) return { kind: 'project', projectKey };- if (parts.length !== 4) return null;- const id = positiveId(parts[3]);+ if (parts[0] === 'project') return projectTarget(parts[1], parts.slice(2));++ const [teamRef, second, ...rest] = parts;+ if (!teamRef || !second) return null;+ if (second === 'issue' && rest.length === 1) {+ const issue = parseIssueIdentifier(rest[0]!);+ const id = positiveId(issue ? String(issue.sequenceNumber) : undefined);+ return issue && id ? { kind: 'issue', projectKey: projectRefOf(teamRef, issue.key), id } : null;+ }+ if (!/^[A-Z][A-Z0-9]*$/.test(second)) return null;+ return projectTarget(projectRefOf(teamRef, second), rest);+}++function projectTarget(projectKey: string | undefined, rest: string[]): InternalLinkTarget | null {+ if (!projectKey) return null;+ if (rest.length === 0) return { kind: 'project', projectKey };+ if (rest.length !== 2) return null;+ const id = positiveId(rest[1]);if (!id) return null;- switch (parts[2]) {+ switch (rest[0]) {case 'issue':return { kind: 'issue', projectKey, id };case 'notes':diff --git a/apps/web/src/components/common/editor/issueRefDecorations.test.ts b/apps/web/src/components/common/editor/issueRefDecorations.test.tsindex 87e7768a..74d00be2 100644--- a/apps/web/src/components/common/editor/issueRefDecorations.test.ts+++ b/apps/web/src/components/common/editor/issueRefDecorations.test.ts@@ -39,14 +39,14 @@ afterEach(() => {}});-function mount(content: string, keys: () => string[], open: (href: string) => void = () => {}) {+function mount(content: string, refs: () => string[], open: (href: string) => void = () => {}) {return new Editor({element: document.querySelector('div')!,editable: false,extensions: [StarterKit.configure(editorStarterKitOptions),Link.configure({ openOnClick: false, autolink: true }),- IssueRef.configure({ keys, open, rich: () => false }),+ IssueRef.configure({ refs, open, rich: () => false }),Markdown.configure({ html: true, linkify: true, breaks: true }),],content,@@ -58,20 +58,20 @@ const links = (editor: Editor) => [...editor.view.dom.querySelectorAll('a.issue-describe('issue identifiers in the editor', () => {it('links an identifier without changing the stored markdown', () => {const content = 'See MKT-42, mkt-7 and `MKT-9` in [MKT-3](https://example.com)';- const editor = mount(content, () => ['MKT']);+ const editor = mount(content, () => ['acme.MKT']);assert.deepEqual(links(editor).map((link) => [link.textContent, link.getAttribute('href')]),- [['MKT-42', '/project/MKT/issue/42']],+ [['MKT-42', '/acme/issue/MKT-42']],);assert.equal(editor.storage.markdown.getMarkdown(), content);editor.destroy();});it('links the keys that arrive after the editor was built', () => {- let keys: string[] = [];- const editor = mount('OPS-3 and MKT-42', () => keys);+ let refs: string[] = [];+ const editor = mount('OPS-3 and MKT-42', () => refs);assert.equal(links(editor).length, 0);- keys = ['MKT', 'OPS'];+ refs = ['acme.MKT', 'acme.OPS'];refreshDecorations(editor);assert.deepEqual(links(editor).map((link) => link.textContent),@@ -84,7 +84,7 @@ describe('issue identifiers in the editor', () => {const opened: string[] = [];const editor = mount('See MKT-42',- () => ['MKT'],+ () => ['acme.MKT'],(href) => opened.push(href),);const event = new dom.window.MouseEvent('click', { button: 0, cancelable: true });@@ -92,7 +92,7 @@ describe('issue identifiers in the editor', () => {const handled = editor.view.someProp('handleClick', (handle) => handle(editor.view, 5, event));assert.equal(handled, true);assert.equal(event.defaultPrevented, true);- assert.deepEqual(opened, ['/project/MKT/issue/42']);+ assert.deepEqual(opened, ['/acme/issue/MKT-42']);editor.destroy();});});diff --git a/apps/web/src/components/common/editor/issueRefDecorations.ts b/apps/web/src/components/common/editor/issueRefDecorations.tsindex 8e130b48..2eccf1c3 100644--- a/apps/web/src/components/common/editor/issueRefDecorations.ts+++ b/apps/web/src/components/common/editor/issueRefDecorations.ts@@ -3,13 +3,14 @@ import { ReactRenderer, type Editor as ReactEditor } from '@tiptap/react';import type { Node as ProseMirrorNode } from '@tiptap/pm/model';import { Plugin, PluginKey } from '@tiptap/pm/state';import { Decoration, DecorationSet } from '@tiptap/pm/view';-import { issuePath } from '@/utils/paths';+import { issuePath, splitProjectRef } from '@/utils/paths';import { splitIssueRefs } from './issueRef';import { REFRESH_DECORATIONS } from './refreshDecorations';import IssueRefChip from './IssueRefChip';type IssueRefOptions = {- keys: () => readonly string[];+ // Project refs of one team: an identifier names a project by its key within the team.+ refs: () => readonly string[];open: (href: string) => void;// Read-only text shows the issue's state and title. Editable text keeps the// identifier as typed, so the caret moves through characters that are all there.@@ -22,7 +23,7 @@ export const IssueRef = Extension.create<IssueRefOptions>({name: 'issueRef',addOptions() {- return { keys: () => [], open: () => undefined, rich: () => false };+ return { refs: () => [], open: () => undefined, rich: () => false };},addProseMirrorPlugins() {@@ -31,8 +32,9 @@ export const IssueRef = Extension.create<IssueRefOptions>({const renderers = new Map<Node, ReactRenderer>();function build(doc: ProseMirrorNode) {- const keys = options.keys();- if (keys.length === 0) return DecorationSet.empty;+ const refByKey = new Map(options.refs().map((ref) => [splitProjectRef(ref).key, ref]));+ if (refByKey.size === 0) return DecorationSet.empty;+ const keys = [...refByKey.keys()];const rich = options.rich();const decorations: Decoration[] = [];doc.descendants((node, pos) => {@@ -47,7 +49,8 @@ export const IssueRef = Extension.create<IssueRefOptions>({continue;}const to = from + part.key.length + 1 + String(part.sequence).length;- const href = issuePath(part.key, part.sequence);+ const projectRef = refByKey.get(part.key)!;+ const href = issuePath(projectRef, part.sequence);if (rich) {decorations.push(Decoration.inline(from, to, { class: 'issue-ref-source', 'aria-hidden': 'true' }),@@ -57,7 +60,7 @@ export const IssueRef = Extension.create<IssueRefOptions>({const renderer = new ReactRenderer(IssueRefChip, {editor,as: 'span',- props: { projectKey: part.key, sequence: part.sequence },+ props: { projectRef, sequence: part.sequence },});renderer.element.setAttribute('data-issue-ref', '');renderers.set(renderer.element, renderer);diff --git a/apps/web/src/components/common/editor/resolveLinkPreview.ts b/apps/web/src/components/common/editor/resolveLinkPreview.tsindex 7f616499..007d9c8f 100644--- a/apps/web/src/components/common/editor/resolveLinkPreview.ts+++ b/apps/web/src/components/common/editor/resolveLinkPreview.ts@@ -41,7 +41,8 @@ async function resolveInternalLinkPreview(target.kind === 'issue'? await getIssueBySeq(target.projectKey, target.id, signal): await getIssue(target.id, signal);- const projectKey = issue.identifier.replace(/-\d+$/, '');+ const projectKey =+ target.kind === 'issue' ? target.projectKey : issue.identifier.replace(/-\d+$/, '');const project = await loadProject(projectKey, signal);return {...empty,diff --git a/apps/web/src/components/common/permissions/RequireFeature.tsx b/apps/web/src/components/common/permissions/RequireFeature.tsxindex ae319c97..c176cdc5 100644--- a/apps/web/src/components/common/permissions/RequireFeature.tsx+++ b/apps/web/src/components/common/permissions/RequireFeature.tsx@@ -2,7 +2,7 @@import type { ReactNode } from 'react';import Link from 'next/link';-import { useParams } from 'next/navigation';+import { useShellRoute } from '@/hooks/useShellRoute';import type { ProjectFeatures } from '@/lib/api/endpoints/settings';import { settingsPath } from '@/utils/paths';import { usePermissions } from '@/hooks/usePermissions';@@ -27,7 +27,7 @@ export default function RequireFeature({const featureLabel = useFeatureLabel();const features = useProjectFeatures();const { isOwner } = usePermissions();- const params = useParams<{ projectKey: string }>();+ const { projectKey } = useShellRoute();if (features[feature]) return <>{children}</>;@@ -36,9 +36,9 @@ export default function RequireFeature({title={t('featureOffTitle', { feature: featureLabel(feature) })}description={t('featureOffHint')}>- {isOwner && params.projectKey && (+ {isOwner && projectKey && (<Button size="sm" asChild>- <Link href={settingsPath(params.projectKey, 'general')}>{t('openGeneralSettings')}</Link>+ <Link href={settingsPath(projectKey, 'general')}>{t('openGeneralSettings')}</Link></Button>)}</EmptyState>diff --git a/apps/web/src/components/layout/AppSidebar.tsx b/apps/web/src/components/layout/AppSidebar.tsxindex 1ba4c2ca..ee08da65 100644--- a/apps/web/src/components/layout/AppSidebar.tsx+++ b/apps/web/src/components/layout/AppSidebar.tsx@@ -42,7 +42,7 @@ export default function AppSidebar({const t = useTranslations('nav');const pathname = usePathname();const disabled = !currentProjectKey;- const projectId = projects.find((p) => p.key === currentProjectKey)?.id ?? null;+ const projectId = projects.find((p) => p.ref === currentProjectKey)?.id ?? null;const { data: session } = useSession();// The session store can already be filled by the time React hydrates, while thediff --git a/apps/web/src/components/layout/CommandLayer.tsx b/apps/web/src/components/layout/CommandLayer.tsxindex c80b3880..6dc46f86 100644--- a/apps/web/src/components/layout/CommandLayer.tsx+++ b/apps/web/src/components/layout/CommandLayer.tsx@@ -44,7 +44,7 @@ export default function CommandLayer({onNewIssue: () => void;onSelectAll: () => void;onNewInitiative: () => void;- onNewProject: () => void;+ onNewProject: (() => void) | null;onSelectProject: (key: string) => void;onOpenIssue: (sequenceNumber: number) => void;onIssueDeleted: () => void;diff --git a/apps/web/src/components/layout/FilterBar.tsx b/apps/web/src/components/layout/FilterBar.tsxindex c5857458..d8bff08f 100644--- a/apps/web/src/components/layout/FilterBar.tsx+++ b/apps/web/src/components/layout/FilterBar.tsx@@ -24,7 +24,7 @@ export default function FilterBar({customFields: CustomField[];}) {const t = useTranslations('filters');- const { fieldSpecs } = useFilterFields(project.project.key);+ const { fieldSpecs } = useFilterFields(project.project.ref);const [addOpen, setAddOpen] = useState(false);const specs = fieldSpecs(project, customFields);// The pills read a catalog that also carries the fields only the currentdiff --git a/apps/web/src/components/layout/NewProjectModal.tsx b/apps/web/src/components/layout/NewProjectModal.tsxindex 37f1ab8f..444c15fb 100644--- a/apps/web/src/components/layout/NewProjectModal.tsx+++ b/apps/web/src/components/layout/NewProjectModal.tsx@@ -14,8 +14,8 @@ import { allSelected, type CopyInclude } from '@/components/layout/CopyProjectOp// Creates a project, or — when `copyFrom` is set — copies that project's structure// (states, issue types, labels, custom fields) into a new project without its-// issues. `teamId` is the team the project belongs to; without one it goes to the-// team the caller owns. A copy is always made within the source project's team.+// issues. `teamId` is the team the project belongs to; a copy is always made within+// the source project's team.export default function NewProjectModal({onClose,onCreated,@@ -24,7 +24,7 @@ export default function NewProjectModal({}: {onClose: () => void;onCreated: (projectKey: string) => void;- teamId?: number;+ teamId: number;copyFrom?: { id: number; name: string; description: string };}) {const t = useTranslations('newProject');@@ -44,12 +44,9 @@ export default function NewProjectModal({const createProject = useCreateProject();// Names the team in the header, so the dialog says where the project lands.const teams = useTeamsQuery().data;- const team =- teamId != null- ? teams?.find((one) => one.id === teamId)- : teams?.filter((one) => one.role === 'owner').sort((a, b) => a.id - b.id)[0];- const defaults = useTeamProjectDefaultsQuery(copyFrom ? null : (team?.id ?? null)).data;- const agents = useAiAgentsQuery(copyFrom ? null : (team?.id ?? null)).data ?? [];+ const team = teams?.find((one) => one.id === teamId);+ const defaults = useTeamProjectDefaultsQuery(copyFrom ? null : teamId).data;+ const agents = useAiAgentsQuery(copyFrom ? null : teamId).data ?? [];const defaultAgentNames = agents.filter((agent) => defaults?.defaultAgentIds.includes(agent.id)).map((agent) => agent.name);@@ -74,7 +71,7 @@ export default function NewProjectModal({};createProject.mutate({ teamId, copyFromId: copyFrom?.id, input },- { onSuccess: (project) => onCreated(project.key) },+ { onSuccess: (project) => onCreated(project.ref) },);}diff --git a/apps/web/src/components/layout/ProjectSwitcher.test.tsx b/apps/web/src/components/layout/ProjectSwitcher.test.tsxindex 7086a373..ca1ffd1b 100644--- a/apps/web/src/components/layout/ProjectSwitcher.test.tsx+++ b/apps/web/src/components/layout/ProjectSwitcher.test.tsx@@ -40,7 +40,9 @@ const projects: Project[] = Array.from({ length: 20 }, (_, index) => ({id: index + 1,teamId: 1,teamName: 'Engineering',+ teamRef: 'eng',key: `P${String(index + 1).padStart(2, '0')}`,+ ref: `eng.P${String(index + 1).padStart(2, '0')}`,name: `Project ${index + 1}`,description: '',mcpEnabled: true,@@ -96,7 +98,7 @@ async function render(mobile = true) {<Sidebar><ProjectSwitcherprojects={projects}- currentProjectKey="P01"+ currentProjectKey="eng.P01"onSelectProject={(key) => selections.push(key)}/></Sidebar>@@ -144,7 +146,7 @@ beforeEach(async () => {replacedGlobals.map((name) => [name, Object.getOwnPropertyDescriptor(globalThis, name)]),);dom = new JSDOM('<!doctype html><div id="root"></div>', {- url: 'https://example.test/project/P01',+ url: 'https://example.test/eng/P01',pretendToBeVisual: true,});for (const name of replacedGlobals) {@@ -239,7 +241,7 @@ describe('ProjectSwitcher', () => {await render();assert.equal(document.activeElement, element('[data-slot="popover-content"]'));await click('[data-value="project-2"]');- assert.deepEqual(selections, ['P02']);+ assert.deepEqual(selections, ['eng.P02']);assert.equal(document.querySelector('[data-slot="popover-content"]'), null);});@@ -253,7 +255,7 @@ describe('ProjectSwitcher', () => {assert.equal(touch(input, 'touchmove', 140).defaultPrevented, false);await key(input, 'ArrowDown');await key(input, 'Enter');- assert.deepEqual(selections, ['P02']);+ assert.deepEqual(selections, ['eng.P02']);});it('restores picker focus and scrolling after closing nested project actions', async () => {diff --git a/apps/web/src/components/layout/ProjectSwitcher.tsx b/apps/web/src/components/layout/ProjectSwitcher.tsxindex 5efadcac..b5136f6a 100644--- a/apps/web/src/components/layout/ProjectSwitcher.tsx+++ b/apps/web/src/components/layout/ProjectSwitcher.tsx@@ -24,7 +24,7 @@ export default function ProjectSwitcher({const queryClient = useQueryClient();const { data: session } = useSession();const preferences = useProjectSwitcherPreferences(session?.user.id);- const current = projects.find((project) => project.key === currentProjectKey);+ const current = projects.find((project) => project.ref === currentProjectKey);const [open, setOpen] = useState(false);const [openTeams, setOpenTeams] = useState<Record<number, boolean>>({});diff --git a/apps/web/src/components/layout/ProjectSwitcherHiddenState.tsx b/apps/web/src/components/layout/ProjectSwitcherHiddenState.tsxindex c69bd295..b2768c15 100644--- a/apps/web/src/components/layout/ProjectSwitcherHiddenState.tsx+++ b/apps/web/src/components/layout/ProjectSwitcherHiddenState.tsx@@ -28,7 +28,7 @@ export default function ProjectSwitcherHiddenState({ projects }: { projects: ProclassName="h-auto min-h-9 w-full justify-start py-2 text-start whitespace-normal"disabled={update.isPending}onClick={() =>- update.mutate({ projectKey: project.key, patch: { isHidden: false } })+ update.mutate({ projectKey: project.ref, patch: { isHidden: false } })}><Eye />diff --git a/apps/web/src/components/layout/ProjectSwitcherList.tsx b/apps/web/src/components/layout/ProjectSwitcherList.tsxindex 15ad6cb7..973135b3 100644--- a/apps/web/src/components/layout/ProjectSwitcherList.tsx+++ b/apps/web/src/components/layout/ProjectSwitcherList.tsx@@ -67,7 +67,7 @@ export default function ProjectSwitcherList({<ProjectSwitcherTeamGroupkey={group.teamId}group={group}- currentProjectKey={current?.key ?? null}+ currentProjectKey={current?.ref ?? null}open={searching ||(openTeams[group.teamId] ??@@ -85,7 +85,7 @@ export default function ProjectSwitcherList({hiddenCount={hiddenCount}expanded={showHidden}onExpandedChange={onShowHiddenChange}- currentProjectKey={current?.key ?? null}+ currentProjectKey={current?.ref ?? null}onSelectProject={onSelectProject}/>)}diff --git a/apps/web/src/components/layout/ProjectSwitcherProjectActions.tsx b/apps/web/src/components/layout/ProjectSwitcherProjectActions.tsxindex b0d91ffd..29549da5 100644--- a/apps/web/src/components/layout/ProjectSwitcherProjectActions.tsx+++ b/apps/web/src/components/layout/ProjectSwitcherProjectActions.tsx@@ -56,7 +56,7 @@ export default function ProjectSwitcherProjectActions({ project }: { project: Pr{!project.isHidden && (<DropdownMenuItemonSelect={() =>- update.mutate({ projectKey: project.key, patch: { isFavorite: !project.isFavorite } })+ update.mutate({ projectKey: project.ref, patch: { isFavorite: !project.isFavorite } })}><Star className={project.isFavorite ? 'fill-current' : undefined} />@@ -65,7 +65,7 @@ export default function ProjectSwitcherProjectActions({ project }: { project: Pr)}<DropdownMenuItemonSelect={() =>- update.mutate({ projectKey: project.key, patch: { isHidden: !project.isHidden } })+ update.mutate({ projectKey: project.ref, patch: { isHidden: !project.isHidden } })}>{project.isHidden ? <ArchiveRestore /> : <Archive />}diff --git a/apps/web/src/components/layout/ProjectSwitcherProjectRow.tsx b/apps/web/src/components/layout/ProjectSwitcherProjectRow.tsxindex 0bbe3a60..de108d91 100644--- a/apps/web/src/components/layout/ProjectSwitcherProjectRow.tsx+++ b/apps/web/src/components/layout/ProjectSwitcherProjectRow.tsx@@ -21,7 +21,7 @@ export default function ProjectSwitcherProjectRow({<div className="flex items-center gap-0.5"><CommandItemvalue={`project-${project.id}`}- onSelect={() => onSelectProject(project.key)}+ onSelect={() => onSelectProject(project.ref)}className="min-w-0 flex-1 gap-2 p-2"><div className="min-w-0 flex-1 space-y-1">@@ -48,7 +48,7 @@ export default function ProjectSwitcherProjectRow({)}</span></div>- {project.key === currentProjectKey && <Check className="size-4 shrink-0" />}+ {project.ref === currentProjectKey && <Check className="size-4 shrink-0" />}</CommandItem><ProjectSwitcherProjectActions project={project} /></div>diff --git a/apps/web/src/components/layout/ProjectSwitcherTeamGroup.tsx b/apps/web/src/components/layout/ProjectSwitcherTeamGroup.tsxindex 02538313..cbc0eda4 100644--- a/apps/web/src/components/layout/ProjectSwitcherTeamGroup.tsx+++ b/apps/web/src/components/layout/ProjectSwitcherTeamGroup.tsx@@ -57,7 +57,7 @@ export default function ProjectSwitcherTeamGroup({)}{group.projects.map((project) => (<ProjectSwitcherProjectRow- key={project.key}+ key={project.ref}project={project}currentProjectKey={currentProjectKey}onSelectProject={onSelectProject}diff --git a/apps/web/src/components/layout/Shell.tsx b/apps/web/src/components/layout/Shell.tsxindex 096925d4..387b37e0 100644--- a/apps/web/src/components/layout/Shell.tsx+++ b/apps/web/src/components/layout/Shell.tsx@@ -4,6 +4,7 @@ import { useMemo, useState, type ReactNode } from 'react';import { useRouter } from 'next/navigation';import { useInitiativeOptionsQuery } from '@/services/initiatives.service';import { useIssueBySeqQuery } from '@/services/issues.service';+import { useTeamsQuery } from '@/services/teams.service';import { useAccountPreferences } from '@/services/preferences.service';import type { IssueOpenMode } from '@/lib/api/endpoints/userPreferences';import { useKeyboardShortcuts } from '@/hooks/useKeyboardShortcuts';@@ -28,7 +29,7 @@ import { ChatPanel } from '@/features/ai-chat/components/panel/ChatPanel';import { useChatPanel } from '@/features/ai-chat/hooks/useChatPanel';import { useTranslations } from 'next-intl';-// The layout for /project/:projectKey and its children (the work items view and the+// The layout for /:team/:projectKey and its children (the work items view and the// settings pages). It owns the project data, the view editor and the// project-level overlays, renders the sidebar + header chrome, and passes the// project state to the active child through React context (see lib/shellContext).@@ -56,7 +57,11 @@ export default function Shell({errorMsg,forbidden,} = useShellProject(projectKey, route.activeViewId);- const issueRefKeys = useMemo(() => projects.map((item) => item.key), [projects]);+ const teamId = project?.project.teamId;+ const issueRefs = useMemo(+ () => projects.filter((item) => item.teamId === teamId).map((item) => item.ref),+ [projects, teamId],+ );const initiativeOptions = useInitiativeOptionsQuery(projectKey).data ?? [];const { issueOpenMode, showChatByDefault } = useAccountPreferences();@@ -70,6 +75,11 @@ export default function Shell({const chatAvailable = !!projectKey && can('ai_agents', 'read');const canCreateInitiative = !!project?.project.initiativesEnabled && can('initiatives', 'create');const issueQuery = useIssueBySeqQuery(projectKey, routeIssueSeq);+ // A project is created in a team by its owner or manager: the current project's team+ // when the user ranks so there, otherwise the first team they do.+ const managedTeams = (useTeamsQuery().data ?? []).filter((one) => one.role !== 'member');+ const newProjectTeamId = (managedTeams.find((one) => one.id === teamId) ?? managedTeams[0])?.id;+ const openNewProject = newProjectTeamId != null ? () => overlays.setShowNewProject(true) : null;useProjectRouteSync({ projects, projectsLoaded, projectKey });@@ -108,7 +118,7 @@ export default function Shell({onChangeView: editor.changeView,onNewIssue: () => canCreateIssue && openNewIssue(),onNewInitiative: () => canCreateInitiative && overlays.setShowNewInitiative(true),- onNewProject: () => overlays.setShowNewProject(true),+ onNewProject: () => openNewProject?.(),onSettings: () => firstSettingsHref && router.push(firstSettingsHref),onToggleChat: chatPanel.toggle,});@@ -187,7 +197,7 @@ export default function Shell({projectsLoaded={projectsLoaded}projectCount={projects.length}>- <IssueRefsProvider keys={issueRefKeys}>{children}</IssueRefsProvider>+ <IssueRefsProvider refs={issueRefs}>{children}</IssueRefsProvider></ShellBody></div>@@ -221,15 +231,20 @@ export default function Shell({// board); the constant matches BOARD_SELECT_ALL_EVENT in useSelection.onSelectAll={() => window.dispatchEvent(new Event('board:select-all'))}onNewInitiative={() => overlays.setShowNewInitiative(true)}- onNewProject={() => overlays.setShowNewProject(true)}+ onNewProject={openNewProject}onSelectProject={(key) => router.push(projectPath(key))}onOpenIssue={(seq) => projectKey && router.push(issuePath(projectKey, seq))}onIssueDeleted={onIssueDeleted}onToggleChat={chatPanel.toggle}/>- <IssueRefsProvider keys={issueRefKeys}>- <ShellOverlays project={project} projectKey={projectKey} overlays={overlays} />+ <IssueRefsProvider refs={issueRefs}>+ <ShellOverlays+ project={project}+ projectKey={projectKey}+ newProjectTeamId={newProjectTeamId}+ overlays={overlays}+ /></IssueRefsProvider></SidebarProvider></ShellCtx.Provider>diff --git a/apps/web/src/components/layout/ShellHeaderTitle.tsx b/apps/web/src/components/layout/ShellHeaderTitle.tsxindex 7461073c..0f4d04dd 100644--- a/apps/web/src/components/layout/ShellHeaderTitle.tsx+++ b/apps/web/src/components/layout/ShellHeaderTitle.tsx@@ -24,17 +24,17 @@ export default function ShellHeaderTitle({const sectionText = useSettingsSectionText();// The label on the pages that are not an issue, initiative or cycle detail. An- // /ai-team route names its section.+ // /agents/:section route names its section.function pageLabel(): string {const { sub, section, aiTeamSection } = route;const known = (slug: string) => SETTINGS_SECTIONS.some((s) => s.slug === slug);if (section) return known(section) ? sectionText(section).label : t('projectSettings');if (sub === 'members') return t('members');- if (sub === 'dashboard') return t('dashboards');+ if (sub === 'dashboards') return t('dashboards');if (sub === 'initiatives') return t('initiatives');if (sub === 'cycles') return t('cycles');if (aiTeamSection) return known(aiTeamSection) ? sectionText(aiTeamSection).label : t('aiTeam');- if (sub === 'ai-agents') return t('aiAgents');+ if (sub === 'agents') return t('aiAgents');if (sub === 'api') return t('api');return projectName;}diff --git a/apps/web/src/components/layout/ShellOverlays.tsx b/apps/web/src/components/layout/ShellOverlays.tsxindex 21114ad4..604a26bf 100644--- a/apps/web/src/components/layout/ShellOverlays.tsx+++ b/apps/web/src/components/layout/ShellOverlays.tsx@@ -14,18 +14,21 @@ import IssueDetail from '@/features/issue/components/detail/IssueDetail';export default function ShellOverlays({project,projectKey,+ newProjectTeamId,overlays,}: {project: ProjectDetail | null;projectKey: string | null;+ newProjectTeamId: number | undefined;overlays: ReturnType<typeof useOverlays>;}) {const router = useRouter();return (<>- {overlays.showNewProject && (+ {newProjectTeamId != null && overlays.showNewProject && (<NewProjectModal+ teamId={newProjectTeamId}onClose={() => overlays.setShowNewProject(false)}onCreated={(key) => {overlays.setShowNewProject(false);diff --git a/apps/web/src/components/layout/SidebarAiTeamNav.tsx b/apps/web/src/components/layout/SidebarAiTeamNav.tsxindex 278fca47..64e0fdfe 100644--- a/apps/web/src/components/layout/SidebarAiTeamNav.tsx+++ b/apps/web/src/components/layout/SidebarAiTeamNav.tsx@@ -36,7 +36,7 @@ export default function SidebarAiTeamNav({ projectKey }: { projectKey: string |href={projectKey ? aiTeamPath(projectKey, s.slug) : '#'}icon={s.icon}label={sectionText(s.slug).label}- active={pathname.endsWith(`/ai-team/${s.slug}`)}+ active={pathname.endsWith(`/agents/${s.slug}`)}disabled={disabled}/>))}@@ -45,7 +45,7 @@ export default function SidebarAiTeamNav({ projectKey }: { projectKey: string |href={projectKey ? aiAgentsPath(projectKey) : '#'}icon={AI_AGENTS_SECTION.icon}label={sectionText(AI_AGENTS_SECTION.slug).label}- active={pathname.endsWith(`/${AI_AGENTS_SECTION.slug}`)}+ active={pathname.endsWith('/agents')}disabled={disabled}/>)}diff --git a/apps/web/src/components/layout/SidebarWorkNav.tsx b/apps/web/src/components/layout/SidebarWorkNav.tsxindex 005cee53..8cf1a339 100644--- a/apps/web/src/components/layout/SidebarWorkNav.tsx+++ b/apps/web/src/components/layout/SidebarWorkNav.tsx@@ -1,4 +1,5 @@import { usePathname } from 'next/navigation';+import { useShellRoute } from '@/hooks/useShellRoute';import { useTranslations } from 'next-intl';import {BookOpenText,@@ -39,6 +40,7 @@ export default function SidebarWorkNav({}) {const t = useTranslations('nav');const pathname = usePathname();+ const routeSub = useShellRoute().sub;const { can } = usePermissions();const features = useProjectFeatures();const disabled = !projectKey;@@ -52,7 +54,7 @@ export default function SidebarWorkNav({!!projectKey &&(pathname === projectPath(projectKey) ||pathname.startsWith(`${projectPath(projectKey)}/view`) ||- pathname.startsWith(`${projectPath(projectKey)}/issue`));+ routeSub === 'issue');// With favorites, Work items becomes a sub-list: the unfiltered board plus one// entry per favorite view.diff --git a/apps/web/src/components/layout/StartEmpty.tsx b/apps/web/src/components/layout/StartEmpty.tsxnew file mode 100644index 00000000..746bddf4--- /dev/null+++ b/apps/web/src/components/layout/StartEmpty.tsx@@ -0,0 +1,48 @@+import type { ReactNode } from 'react';+import { Plus } from 'lucide-react';+import { Button } from '@/components/ui/button';+import {+ Empty,+ EmptyContent,+ EmptyDescription,+ EmptyHeader,+ EmptyMedia,+ EmptyTitle,+} from '@/components/ui/empty';++// A full-screen empty state with one action, for the start page before the account+// has a team or a project.+export default function StartEmpty({+ icon,+ title,+ hint,+ action,+ onAction,+ children,+}: {+ icon: ReactNode;+ title: string;+ hint: string;+ action: string;+ onAction: () => void;+ children: ReactNode;+}) {+ return (+ <div className="flex h-svh items-center justify-center p-6">+ <Empty className="max-w-md">+ <EmptyHeader>+ <EmptyMedia variant="icon">{icon}</EmptyMedia>+ <EmptyTitle>{title}</EmptyTitle>+ <EmptyDescription>{hint}</EmptyDescription>+ </EmptyHeader>+ <EmptyContent>+ <Button onClick={onAction}>+ <Plus />+ {action}+ </Button>+ </EmptyContent>+ </Empty>+ {children}+ </div>+ );+}diff --git a/apps/web/src/components/layout/utils/projectSwitcher.test.ts b/apps/web/src/components/layout/utils/projectSwitcher.test.tsindex ef2791cd..59812e66 100644--- a/apps/web/src/components/layout/utils/projectSwitcher.test.ts+++ b/apps/web/src/components/layout/utils/projectSwitcher.test.ts@@ -9,7 +9,9 @@ function project(overrides: Partial<Project> = {}): Project {id: 1,teamId: 1,teamName: 'Engineering',+ teamRef: 'eng',key: 'API',+ ref: 'eng.API',name: 'API platform',description: '',mcpEnabled: true,@@ -35,6 +37,8 @@ function team(overrides: Partial<Team> = {}): Team {return {id: 1,name: 'Engineering',+ slug: 'eng',+ ref: 'eng',mcpEnabled: true,role: 'owner',source: 'invite',diff --git a/apps/web/src/context/issueRefs.tsx b/apps/web/src/context/issueRefs.tsxindex a7bb776d..3524ac9e 100644--- a/apps/web/src/context/issueRefs.tsx+++ b/apps/web/src/context/issueRefs.tsx@@ -2,23 +2,23 @@import { createContext, useContext, type ReactNode } from 'react';-// The project keys an issue identifier is linked for, and whether the link may read+// The projects (by ref) an issue identifier is linked for, and whether the link may read// the issue it names to show its state and title.-type IssueRefs = { keys: readonly string[]; resolve: boolean };+type IssueRefs = { refs: readonly string[]; resolve: boolean };-const IssueRefsContext = createContext<IssueRefs>({ keys: [], resolve: false });+const IssueRefsContext = createContext<IssueRefs>({ refs: [], resolve: false });export function IssueRefsProvider({- keys,+ refs,resolve = true,children,}: {- keys: readonly string[];+ refs: readonly string[];resolve?: boolean;children: ReactNode;}) {return (- <IssueRefsContext.Provider value={{ keys, resolve }}>{children}</IssueRefsContext.Provider>+ <IssueRefsContext.Provider value={{ refs, resolve }}>{children}</IssueRefsContext.Provider>);}diff --git a/apps/web/src/features/api-docs/ApiDocsPage.tsx b/apps/web/src/features/api-docs/ApiDocsPage.tsxindex 5b7334b0..4877ce8e 100644--- a/apps/web/src/features/api-docs/ApiDocsPage.tsx+++ b/apps/web/src/features/api-docs/ApiDocsPage.tsx@@ -11,7 +11,7 @@ const ScalarReference = dynamic(() => import('./components/ScalarReference'), {loading: () => <PageSkeleton rows={8} />,});-// Mounted at /project/:projectKey/api, but the spec it renders is instance-wide.+// Mounted at /:team/:projectKey/api, but the spec it renders is instance-wide.export default function ApiDocsPage() {const { resolvedTheme } = useTheme();return <ScalarReference dark={resolvedTheme !== 'light'} />;diff --git a/apps/web/src/features/cycles/CycleDetailPage.tsx b/apps/web/src/features/cycles/CycleDetailPage.tsxindex 7ac30fc2..00565142 100644--- a/apps/web/src/features/cycles/CycleDetailPage.tsx+++ b/apps/web/src/features/cycles/CycleDetailPage.tsx@@ -11,7 +11,7 @@ import CycleIssuesBoard from './components/detail/CycleIssuesBoard';export default function CycleDetailPage({ cycleId }: { cycleId: number }) {const t = useTranslations('cycles');const { project } = useShell();- const projectKey = project?.project.key ?? null;+ const projectKey = project?.project.ref ?? null;const query = useCycleQuery(cycleId);const cycle = query.data;diff --git a/apps/web/src/features/cycles/CyclesPage.tsx b/apps/web/src/features/cycles/CyclesPage.tsxindex e5255ecf..282d5ece 100644--- a/apps/web/src/features/cycles/CyclesPage.tsx+++ b/apps/web/src/features/cycles/CyclesPage.tsx@@ -27,7 +27,7 @@ export default function CyclesPage({ view }: { view: CyclesView }) {const router = useRouter();const [creating, setCreating] = useState(false);- const projectKey = project?.project.key ?? null;+ const projectKey = project?.project.ref ?? null;const query = usePlannedCyclesQuery(projectKey);const completed = useCompletedCycles(projectKey);diff --git a/apps/web/src/features/cycles/CyclesRedirect.tsx b/apps/web/src/features/cycles/CyclesRedirect.tsxindex 051625a5..a02e541b 100644--- a/apps/web/src/features/cycles/CyclesRedirect.tsx+++ b/apps/web/src/features/cycles/CyclesRedirect.tsx@@ -15,7 +15,7 @@ import { readCyclesView } from './utils/cyclesView';export default function CyclesRedirect() {const { project } = useShell();const router = useRouter();- const projectKey = project?.project.key ?? null;+ const projectKey = project?.project.ref ?? null;useEffect(() => {if (!projectKey) return;diff --git a/apps/web/src/features/cycles/components/detail/CycleIssuesBoard.tsx b/apps/web/src/features/cycles/components/detail/CycleIssuesBoard.tsxindex 37be479f..490f7352 100644--- a/apps/web/src/features/cycles/components/detail/CycleIssuesBoard.tsx+++ b/apps/web/src/features/cycles/components/detail/CycleIssuesBoard.tsx@@ -24,7 +24,7 @@ export default function CycleIssuesBoard({ cycle }: { cycle: Cycle }) {const { project, customFields, onOpenIssue, onAddIssue } = useShell();const cycleId = cycle.id;const board = useLocalBoardSettings(CYCLE_BOARD_STORE_KEY, cycleId);- const initiativeOptions = useInitiativeOptionsQuery(project?.project.key ?? null).data ?? [];+ const initiativeOptions = useInitiativeOptionsQuery(project?.project.ref ?? null).data ?? [];const viewProject = useMemo(() => {if (!project) return null;diff --git a/apps/web/src/features/dashboards/DashboardsPage.tsx b/apps/web/src/features/dashboards/DashboardsPage.tsxindex 4ac1b85a..d5874d61 100644--- a/apps/web/src/features/dashboards/DashboardsPage.tsx+++ b/apps/web/src/features/dashboards/DashboardsPage.tsx@@ -2,6 +2,7 @@import { useEffect, useState } from 'react';import { useParams, useRouter } from 'next/navigation';+import { useShellRoute } from '@/hooks/useShellRoute';import { useTranslations } from 'next-intl';import { useShell } from '@/context/shellContext';import { usePermissions } from '@/hooks/usePermissions';@@ -23,9 +24,9 @@ export default function DashboardsPage() {const tCommon = useTranslations('common');const { project } = useShell();const { can } = usePermissions();- const params = useParams<{ projectKey: string; dashboardId?: string }>();+ const params = useParams<{ dashboardId?: string }>();const router = useRouter();- const projectKey = params.projectKey;+ const projectKey = useShellRoute().projectKey ?? '';const { data: dashboards, isLoading, isFetching, isSuccess } = useDashboardsQuery(projectKey);const [editing, setEditing] = useState(false);diff --git a/apps/web/src/features/documents/DocumentsPage.tsx b/apps/web/src/features/documents/DocumentsPage.tsxindex 9bb434c3..054ef605 100644--- a/apps/web/src/features/documents/DocumentsPage.tsx+++ b/apps/web/src/features/documents/DocumentsPage.tsx@@ -2,6 +2,7 @@import { useEffect } from 'react';import { useParams, useRouter } from 'next/navigation';+import { useShellRoute } from '@/hooks/useShellRoute';import { useShell } from '@/context/shellContext';import { usePermissions } from '@/hooks/usePermissions';import { useLiveRefresh } from '@/hooks/useLiveRefresh';@@ -31,11 +32,11 @@ const listDefaults: { search: string; tab: DocumentListTab } = { search: '', tabexport default function DocumentsPage() {const { project } = useShell();- const params = useParams<{ projectKey: string; documentId?: string }>();+ const params = useParams<{ documentId?: string }>();const router = useRouter();const t = useTranslations('documents');const { can, isOwner } = usePermissions();- const projectKey = params.projectKey;+ const projectKey = useShellRoute().projectKey ?? '';const routeId = params.documentId ? Number(params.documentId) : null;const documentId = routeId && Number.isFinite(routeId) ? routeId : null;const [navigation, setNavigation] = useDocumentNavigation(projectKey, 'list', listDefaults);diff --git a/apps/web/src/features/documents/components/DocumentEditorHeader.tsx b/apps/web/src/features/documents/components/DocumentEditorHeader.tsxindex 3835dc2a..e7e9268f 100644--- a/apps/web/src/features/documents/components/DocumentEditorHeader.tsx+++ b/apps/web/src/features/documents/components/DocumentEditorHeader.tsx@@ -196,7 +196,6 @@ export default function DocumentEditorHeader({<PanelRight /></Button><DocumentOptionsMenu- projectKey={projectKey}document={document}title={title}content={content}diff --git a/apps/web/src/features/documents/components/DocumentExportDialog.tsx b/apps/web/src/features/documents/components/DocumentExportDialog.tsxindex 7f6848a9..827dde3e 100644--- a/apps/web/src/features/documents/components/DocumentExportDialog.tsx+++ b/apps/web/src/features/documents/components/DocumentExportDialog.tsx@@ -26,7 +26,6 @@ const formats = [export default function DocumentExportDialog({open,- projectKey,documentId,title,content,@@ -34,7 +33,6 @@ export default function DocumentExportDialog({onOpenChange,}: {open: boolean;- projectKey: string;documentId: number;title: string;content: () => string;@@ -68,7 +66,6 @@ export default function DocumentExportDialog({content: content(),richHtml: richHtml(),format,- projectKey,documentId,baseUrl: window.location.origin,});diff --git a/apps/web/src/features/documents/components/DocumentMarkdownEditor.tsx b/apps/web/src/features/documents/components/DocumentMarkdownEditor.tsxindex bf590983..741badd0 100644--- a/apps/web/src/features/documents/components/DocumentMarkdownEditor.tsx+++ b/apps/web/src/features/documents/components/DocumentMarkdownEditor.tsx@@ -168,6 +168,7 @@ export default function DocumentMarkdownEditor({openIssueRefRef.current = (href: string) => router.push(href);const editor = useEditor({+ immediatelyRender: false,editable,extensions: documentEditorExtensions({placeholder,@@ -192,7 +193,7 @@ export default function DocumentMarkdownEditor({image: onPickImage ? { label: t('uploadImage'), onPick: onPickImage } : undefined,}).concat(IssueRef.configure({- keys: () => issueRefsRef.current.keys,+ refs: () => issueRefsRef.current.refs,open: (href) => openIssueRefRef.current(href),rich: () => issueRefsRef.current.resolve && (!editableRef.current || !focusedRef.current),}),@@ -268,11 +269,11 @@ export default function DocumentMarkdownEditor({return () => onReady(null);}, [editor, onReady]);- const issueRefKeyList = issueRefs.keys.join(',');+ const issueRefList = issueRefs.refs.join(',');useEffect(() => {const frame = requestAnimationFrame(() => refreshDecorations(editor));return () => cancelAnimationFrame(frame);- }, [editor, issueRefKeyList, issueRefs.resolve, editable, focused]);+ }, [editor, issueRefList, issueRefs.resolve, editable, focused]);useLayoutEffect(() => {syncDocumentEditorEditable(editor, editable);diff --git a/apps/web/src/features/documents/components/DocumentOptionsMenu.tsx b/apps/web/src/features/documents/components/DocumentOptionsMenu.tsxindex f4c58bd0..73da4c17 100644--- a/apps/web/src/features/documents/components/DocumentOptionsMenu.tsx+++ b/apps/web/src/features/documents/components/DocumentOptionsMenu.tsx@@ -30,7 +30,6 @@ import { useTranslations } from 'next-intl';import DocumentExportDialog from './DocumentExportDialog';export default function DocumentOptionsMenu({- projectKey,document,title,content,@@ -52,7 +51,6 @@ export default function DocumentOptionsMenu({onDelete,onOpenHistory,}: {- projectKey: string;document: ProjectDocument;title: string;content: () => string;@@ -208,7 +206,6 @@ export default function DocumentOptionsMenu({<DocumentExportDialogopen={exportOpen}- projectKey={projectKey}documentId={document.id}title={title}content={content}diff --git a/apps/web/src/features/documents/utils/documentExport.test.ts b/apps/web/src/features/documents/utils/documentExport.test.tsindex ffe81ebd..aac6bd70 100644--- a/apps/web/src/features/documents/utils/documentExport.test.ts+++ b/apps/web/src/features/documents/utils/documentExport.test.ts@@ -67,7 +67,6 @@ describe('document export', () => {content: '',richHtml: `<p><img src="${protectedAsset}"><a href="${protectedAsset}">Download</a><img src="/protected-media/projects/SEKTA/documents/99/assets/123e4567-e89b-12d3-a456-426614174000/raw"><img src="https://evil.example${protectedAsset}"><a href="https://example.test/public.png">External</a></p>`,format: 'html',- projectKey: 'SEKTA',documentId: 42,baseUrl: 'https://plan.example.test',fetchImpl: async (input, init) => {@@ -95,13 +94,37 @@ describe('document export', () => {assert.match(html, /https:\/\/example\.test\/public\.png/);});+ it('inlines an asset whose URL names the project by its ref', async () => {+ const refAsset =+ '/protected-media/projects/12.SEKTA/documents/42/assets/123e4567-e89b-12d3-a456-426614174001/raw';+ const calls: string[] = [];+ await createPortableDocumentExport({+ title: 'Guide',+ content: '',+ richHtml: `<p><img src="${protectedAsset}"><img src="${refAsset}"></p>`,+ format: 'html',+ documentId: 42,+ baseUrl: 'https://plan.example.test',+ fetchImpl: async (input) => {+ calls.push(String(input));+ return new Response(new Uint8Array([137, 80, 78, 71]), {+ headers: { 'content-type': 'image/png' },+ });+ },+ });++ assert.deepEqual(calls, [+ `https://plan.example.test${protectedAsset}`,+ `https://plan.example.test${refAsset}`,+ ]);+ });+it('does not preserve active asset MIME types in portable HTML', async () => {const result = await createPortableDocumentExport({title: 'Guide',content: '',richHtml: `<a href="${protectedAsset}">Download diagram</a>`,format: 'html',- projectKey: 'SEKTA',documentId: 42,baseUrl: 'https://plan.example.test',fetchImpl: async () =>@@ -121,7 +144,6 @@ describe('document export', () => {title: 'Guide',content: `\n\n[Download](${protectedAsset})\n\n[External](https://example.test/public.pdf)`,format: 'markdown',- projectKey: 'SEKTA',documentId: 42,baseUrl: 'https://plan.example.test',fetchImpl: async () => {@@ -150,7 +172,6 @@ describe('document export', () => {title: 'Guide',content: '[External](https://example.test/public.pdf)',format: 'markdown',- projectKey: 'SEKTA',documentId: 42,baseUrl: 'https://plan.example.test',fetchImpl: async () => {@@ -180,7 +201,6 @@ describe('document export', () => {title: 'Guide',content,format: 'markdown',- projectKey: 'SEKTA',documentId: 42,baseUrl: 'https://plan.example.test',fetchImpl: async () => {@@ -199,7 +219,6 @@ describe('document export', () => {title: 'Guide',content: ``,format: 'markdown',- projectKey: 'SEKTA',documentId: 42,baseUrl: 'https://plan.example.test',fetchImpl: async () =>diff --git a/apps/web/src/features/documents/utils/documentExport.ts b/apps/web/src/features/documents/utils/documentExport.tsindex 94f7b570..35c51854 100644--- a/apps/web/src/features/documents/utils/documentExport.ts+++ b/apps/web/src/features/documents/utils/documentExport.ts@@ -9,7 +9,6 @@ export interface PortableDocumentExportInput {content: string;richHtml?: string;format: DocumentExportFormat;- projectKey: string;documentId: number;baseUrl: string;fetchImpl?: typeof fetch;@@ -98,7 +97,6 @@ export async function createPortableDocumentExport({content,richHtml,format,- projectKey,documentId,baseUrl,fetchImpl = fetch,@@ -106,7 +104,6 @@ export async function createPortableDocumentExport({const body = documentExportBody(title, content, format, richHtml);const assets = await fetchDocumentExportAssets({body,- projectKey,documentId,baseUrl,fetchImpl,@@ -156,13 +153,11 @@ export function documentExportArchiveFilename(title: string): string {async function fetchDocumentExportAssets({body,- projectKey,documentId,baseUrl,fetchImpl,}: {body: string;- projectKey: string;documentId: number;baseUrl: string;fetchImpl: typeof fetch;@@ -170,7 +165,7 @@ async function fetchDocumentExportAssets({const base = new URL(baseUrl);const referencesByUrl = new Map<string, { url: URL; references: Set<string> }>();for (const reference of extractExportReferences(body)) {- const url = protectedDocumentAssetUrl(reference, { projectKey, documentId, base });+ const url = protectedDocumentAssetUrl(reference, { documentId, base });if (!url) continue;const existing = referencesByUrl.get(url.href);if (existing) existing.references.add(reference);@@ -319,9 +314,12 @@ function extractExportReferences(body: string): Set<string> {return references;}+// An asset of this document. The project segment is not compared: the stored URL can+// name the project by its ref or, from before keys were per team, by the bare key,+// and the document id alone already pins the asset.function protectedDocumentAssetUrl(reference: string,- { projectKey, documentId, base }: { projectKey: string; documentId: number; base: URL },+ { documentId, base }: { documentId: number; base: URL },): URL | null {let url: URL;try {@@ -331,7 +329,7 @@ function protectedDocumentAssetUrl(}if (url.origin !== base.origin || url.search || url.hash) return null;const expected = new RegExp(- `^/protected-media/projects/${escapeRegExp(encodeURIComponent(projectKey))}/documents/${documentId}/assets/${PUBLIC_ID}/raw$`,+ `^/protected-media/projects/[^/]+/documents/${documentId}/assets/${PUBLIC_ID}/raw$`,'i',);return expected.test(url.pathname) ? url : null;@@ -424,7 +422,3 @@ function safeDecodeURIComponent(value: string): string {return value;}}--function escapeRegExp(value: string): string {- return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');-}diff --git a/apps/web/src/features/inbox/InboxPage.tsx b/apps/web/src/features/inbox/InboxPage.tsxindex 94221cc9..e749bfa4 100644--- a/apps/web/src/features/inbox/InboxPage.tsx+++ b/apps/web/src/features/inbox/InboxPage.tsx@@ -3,12 +3,12 @@import { useShell } from '@/context/shellContext';import InboxView from './components/InboxView';-// The per-project inbox (/project/:projectKey/inbox): a list of the session user's+// The per-project inbox (/:team/:projectKey/inbox): a list of the session user's// notifications for this project on the left, the selected issue on the right. On a// narrow screen only one of the two is on screen at a time.export default function InboxPage() {const { project } = useShell();if (!project) return null;// Keyed by project: the stored filters are read on mount.- return <InboxView key={project.project.key} project={project} />;+ return <InboxView key={project.project.ref} project={project} />;}diff --git a/apps/web/src/features/inbox/components/InboxDetail.tsx b/apps/web/src/features/inbox/components/InboxDetail.tsxindex ee736099..4142d462 100644--- a/apps/web/src/features/inbox/components/InboxDetail.tsx+++ b/apps/web/src/features/inbox/components/InboxDetail.tsx@@ -25,7 +25,7 @@ export default function InboxDetail({return (<div className="flex min-h-0 flex-1 flex-col"><InboxDetailHeader- projectKey={project.project.key}+ projectKey={project.project.ref}issueSeq={issueSeq}isMobile={isMobile}onBack={onBack}diff --git a/apps/web/src/features/inbox/components/InboxDetailHeader.test.tsx b/apps/web/src/features/inbox/components/InboxDetailHeader.test.tsxindex fcf0deb5..71709ed1 100644--- a/apps/web/src/features/inbox/components/InboxDetailHeader.test.tsx+++ b/apps/web/src/features/inbox/components/InboxDetailHeader.test.tsx@@ -20,7 +20,7 @@ let root: Root;let backCalls: number;let originalGlobalDescriptors: Map<string, PropertyDescriptor | undefined>;-function render({ projectKey = 'TEST', issueSeq = 42, isMobile = false } = {}) {+function render({ projectKey = 'acme.TEST', issueSeq = 42, isMobile = false } = {}) {act(() =>root.render(<NextIntlClientProvider locale="en" messages={{ inbox, issue }} timeZone="UTC">@@ -42,7 +42,7 @@ beforeEach(async () => {replacedGlobals.map((name) => [name, Object.getOwnPropertyDescriptor(globalThis, name)]),);dom = new JSDOM('<!doctype html><div id="root"></div>', {- url: 'https://example.test/project/TEST/inbox',+ url: 'https://example.test/acme/TEST/inbox',});Object.defineProperties(globalThis, {window: { configurable: true, value: dom.window },@@ -72,7 +72,7 @@ describe('InboxDetailHeader', () => {render();const link = document.querySelector('a');assert.ok(link);- assert.equal(link.getAttribute('href'), '/project/TEST/issue/42');+ assert.equal(link.getAttribute('href'), '/acme/issue/TEST-42');assert.equal(link.getAttribute('aria-label'), issue.openAsPage);assert.equal(link.getAttribute('title'), issue.openAsPage);assert.equal(link.tabIndex, 0);@@ -88,19 +88,19 @@ describe('InboxDetailHeader', () => {assert.equal(back.textContent, inbox.backToList);act(() => back.click());assert.equal(backCalls, 1);- assert.equal(document.querySelector('a')?.getAttribute('href'), '/project/TEST/issue/42');+ assert.equal(document.querySelector('a')?.getAttribute('href'), '/acme/issue/TEST-42');});it('updates the destination when another notification is selected', () => {render();render({ issueSeq: 73 });- assert.equal(document.querySelector('a')?.getAttribute('href'), '/project/TEST/issue/73');+ assert.equal(document.querySelector('a')?.getAttribute('href'), '/acme/issue/TEST-73');assert.ok(document.querySelector('#root')?.textContent?.includes('TEST-73'));assert.equal(backCalls, 0);});it('uses the canonical route builder for project keys', () => {- render({ projectKey: 'R&D', issueSeq: 9 });- assert.equal(document.querySelector('a')?.getAttribute('href'), '/project/R%26D/issue/9');+ render({ projectKey: '12.R&D', issueSeq: 9 });+ assert.equal(document.querySelector('a')?.getAttribute('href'), '/12/issue/R%26D-9');});});diff --git a/apps/web/src/features/inbox/components/InboxDetailHeader.tsx b/apps/web/src/features/inbox/components/InboxDetailHeader.tsxindex 256ee5a9..b391bfb5 100644--- a/apps/web/src/features/inbox/components/InboxDetailHeader.tsx+++ b/apps/web/src/features/inbox/components/InboxDetailHeader.tsx@@ -4,7 +4,7 @@ import Link from 'next/link';import { ChevronLeft, Maximize2 } from 'lucide-react';import { useTranslations } from 'next-intl';import { Button } from '@/components/ui/button';-import { issuePath } from '@/utils/paths';+import { issuePath, splitProjectRef } from '@/utils/paths';export default function InboxDetailHeader({projectKey,@@ -30,7 +30,7 @@ export default function InboxDetailHeader({</Button>)}<span className="min-w-0 flex-1 truncate text-xs text-muted-foreground">- {projectKey}-{issueSeq}+ {splitProjectRef(projectKey).key}-{issueSeq}</span><ButtonasChilddiff --git a/apps/web/src/features/inbox/components/InboxView.tsx b/apps/web/src/features/inbox/components/InboxView.tsxindex 1b679ccc..26c17c4c 100644--- a/apps/web/src/features/inbox/components/InboxView.tsx+++ b/apps/web/src/features/inbox/components/InboxView.tsx@@ -24,7 +24,7 @@ import {export default function InboxView({ project }: { project: ProjectDetail }) {const t = useTranslations('inbox');- const projectKey = project.project.key;+ const projectKey = project.project.ref;const projectId = project.project.id;const { filters, changeFilters } = useInboxFilters(projectKey);diff --git a/apps/web/src/features/initiatives/InitiativeDetailPage.tsx b/apps/web/src/features/initiatives/InitiativeDetailPage.tsxindex 7604b387..404d2b60 100644--- a/apps/web/src/features/initiatives/InitiativeDetailPage.tsx+++ b/apps/web/src/features/initiatives/InitiativeDetailPage.tsx@@ -1,6 +1,6 @@'use client';-import { useParams, useRouter } from 'next/navigation';+import { useRouter } from 'next/navigation';import { useTranslations } from 'next-intl';import { useShell } from '@/context/shellContext';import { useLiveRefresh } from '@/hooks/useLiveRefresh';@@ -19,32 +19,35 @@ import InitiativeProgress from './components/detail/InitiativeProgress';// it is going (Progress) and the work items board over its linked issues (Issues).// Each tab is its own route, so the open tab survives a reload; the route that// mounts this page passes it.-export default function InitiativeDetailPage({ tab = 'overview' }: { tab?: InitiativeTab }) {+export default function InitiativeDetailPage({+ initiativeId,+ tab = 'overview',+}: {+ initiativeId: number;+ tab?: InitiativeTab;+}) {const t = useTranslations('initiatives');const { project } = useShell();const router = useRouter();- const params = useParams();- const raw = Array.isArray(params.initiativeId) ? params.initiativeId[0] : params.initiativeId;- const initiativeId = raw ? Number(raw) : null;const query = useInitiativeQuery(initiativeId);- const projectKey = project?.project.key ?? '';+ const projectKey = project?.project.ref ?? '';// Refetch the initiative (progress/health), its files, its linked Docs, its feed// and the board issues when its linked issues or its own fields change.useLiveRefresh({- scope: initiativeId != null ? revScope.initiative(initiativeId) : null,+ scope: revScope.initiative(initiativeId),targets: [- qk.initiative(initiativeId ?? 0),- qk.initiativeAttachments(initiativeId ?? 0),- qk.initiativeDocumentLinks(projectKey, initiativeId ?? 0),- qk.initiativeFeed(initiativeId ?? 0),+ qk.initiative(initiativeId),+ qk.initiativeAttachments(initiativeId),+ qk.initiativeDocumentLinks(projectKey, initiativeId),+ qk.initiativeFeed(initiativeId),qk.boardIssues(projectKey),],enabled: !!projectKey,});- if (!project || initiativeId == null) return null;+ if (!project) return null;const initiative = query.data;diff --git a/apps/web/src/features/initiatives/InitiativesPage.tsx b/apps/web/src/features/initiatives/InitiativesPage.tsxindex 7f130202..7a087f53 100644--- a/apps/web/src/features/initiatives/InitiativesPage.tsx+++ b/apps/web/src/features/initiatives/InitiativesPage.tsx@@ -39,7 +39,7 @@ export default function InitiativesPage({ tab }: { tab: InitiativesTab }) {const { order, reorder } = useInitiativeTabOrder();const sensors = useStripSortSensors();- const projectKey = project?.project.key ?? null;+ const projectKey = project?.project.ref ?? null;const activeTab = INITIATIVE_TABS.find((item) => item.value === tab)!;const orderedTabs = order.map((value) => INITIATIVE_TABS.find((item) => item.value === value)!);@@ -65,7 +65,7 @@ export default function InitiativesPage({ tab }: { tab: InitiativesTab }) {const items = query.data?.items ?? [];const total = query.data?.total ?? 0;- const tabPath = initiativesTabPath(project.project.key, tab);+ const tabPath = initiativesTabPath(project.project.ref, tab);const pushQuery = (params: URLSearchParams) => {const search = params.toString();@@ -75,7 +75,7 @@ export default function InitiativesPage({ tab }: { tab: InitiativesTab }) {// A tab is its own route and carries no query, so switching one drops the page and// the sorting of the tab left behind.const changeTab = (next: InitiativesTab) => {- router.push(initiativesTabPath(project.project.key, next));+ router.push(initiativesTabPath(project.project.ref, next));};const changePage = (next: number) => {diff --git a/apps/web/src/features/initiatives/InitiativesRedirect.tsx b/apps/web/src/features/initiatives/InitiativesRedirect.tsxindex 2a800603..de4c5b44 100644--- a/apps/web/src/features/initiatives/InitiativesRedirect.tsx+++ b/apps/web/src/features/initiatives/InitiativesRedirect.tsx@@ -26,7 +26,7 @@ function firstTabWithInitiatives(counts: InitiativeCounts | undefined): Initiatiexport default function InitiativesRedirect() {const { project } = useShell();const router = useRouter();- const projectKey = project?.project.key ?? null;+ const projectKey = project?.project.ref ?? null;const { data: counts, isError } = useInitiativeCountsQuery(projectKey);useEffect(() => {diff --git a/apps/web/src/features/initiatives/components/detail/InitiativeHeader.tsx b/apps/web/src/features/initiatives/components/detail/InitiativeHeader.tsxindex 3fd05318..9702cfc0 100644--- a/apps/web/src/features/initiatives/components/detail/InitiativeHeader.tsx+++ b/apps/web/src/features/initiatives/components/detail/InitiativeHeader.tsx@@ -28,7 +28,7 @@ export default function InitiativeHeader({project: ProjectDetail;}) {const t = useTranslations('initiatives');- const update = useUpdateInitiative(project.project.key);+ const update = useUpdateInitiative(project.project.ref);const hasDescription = initiative.description.trim().length > 0;// The calendars grey out days that would put one date on the wrong side of the// other. Equal dates are allowed.@@ -118,7 +118,7 @@ export default function InitiativeHeader({<HealthBadge health={initiative.health} /></div><ProgressBar progress={initiative.progress} />- <InitiativeActions initiative={initiative} projectKey={project.project.key} />+ <InitiativeActions initiative={initiative} projectKey={project.project.ref} /></div></div>);diff --git a/apps/web/src/features/initiatives/components/detail/InitiativeIssuesBoard.tsx b/apps/web/src/features/initiatives/components/detail/InitiativeIssuesBoard.tsxindex ea924f34..9a93310b 100644--- a/apps/web/src/features/initiatives/components/detail/InitiativeIssuesBoard.tsx+++ b/apps/web/src/features/initiatives/components/detail/InitiativeIssuesBoard.tsx@@ -21,7 +21,7 @@ const INITIATIVE_BOARD_STORE_KEY = 'planner_initiative_board_settings';export default function InitiativeIssuesBoard({ initiativeId }: { initiativeId: number }) {const { project, customFields, onOpenIssue, onAddIssue } = useShell();const board = useLocalBoardSettings(INITIATIVE_BOARD_STORE_KEY, initiativeId);- const initiativeOptions = useInitiativeOptionsQuery(project?.project.key ?? null).data ?? [];+ const initiativeOptions = useInitiativeOptionsQuery(project?.project.ref ?? null).data ?? [];const viewProject = useMemo(() => {if (!project) return null;diff --git a/apps/web/src/features/initiatives/components/detail/InitiativeProgress.tsx b/apps/web/src/features/initiatives/components/detail/InitiativeProgress.tsxindex f4f2a764..2b8ae56c 100644--- a/apps/web/src/features/initiatives/components/detail/InitiativeProgress.tsx+++ b/apps/web/src/features/initiatives/components/detail/InitiativeProgress.tsx@@ -18,7 +18,7 @@ export default function InitiativeProgress({project: ProjectDetail;}) {const t = useTranslations('initiatives');- const projectKey = project.project.key;+ const projectKey = project.project.ref;return (<div className="flex w-full flex-col gap-10 px-8 py-8 lg:flex-row">diff --git a/apps/web/src/features/initiatives/components/list/InitiativesList.tsx b/apps/web/src/features/initiatives/components/list/InitiativesList.tsxindex 22111e16..63e23a65 100644--- a/apps/web/src/features/initiatives/components/list/InitiativesList.tsx+++ b/apps/web/src/features/initiatives/components/list/InitiativesList.tsx@@ -108,7 +108,7 @@ export default function InitiativesList({<InitiativeRowkey={it.id}initiative={it}- projectKey={project.project.key}+ projectKey={project.project.ref}owner={it.ownerUserId ? (ownerById.get(it.ownerUserId) ?? null) : null}/>))}diff --git a/apps/web/src/features/invite/components/InviteActions.tsx b/apps/web/src/features/invite/components/InviteActions.tsxindex 800037c6..29b6f5b2 100644--- a/apps/web/src/features/invite/components/InviteActions.tsx+++ b/apps/web/src/features/invite/components/InviteActions.tsx@@ -7,7 +7,7 @@ import { useQueryClient } from '@tanstack/react-query';import { useTranslations } from 'next-intl';import { acceptInvite, rejectInvite } from '@/lib/api/endpoints/invites';import { ApiError } from '@/lib/api/core/client';-import { projectPath } from '@/utils/paths';+import { projectPath, projectRefOf } from '@/utils/paths';import { Button } from '@/components/ui/button';import { FieldError } from '@/components/ui/field';import InviteNotice from './InviteNotice';@@ -37,7 +37,9 @@ export default function InviteActions({setBusy('accept');try {const result = await acceptInvite(token);- router.push(result.projectKey ? projectPath(result.projectKey) : '/');+ router.push(+ result.projectKey ? projectPath(projectRefOf(result.teamRef, result.projectKey)) : '/',+ );router.refresh();} catch (err) {if (err instanceof ApiError && err.code === 'ALREADY_PROJECT_MEMBER') setAlreadyMember(true);diff --git a/apps/web/src/features/invite/components/InviteAuthForm.tsx b/apps/web/src/features/invite/components/InviteAuthForm.tsxindex 11708e36..cea306a3 100644--- a/apps/web/src/features/invite/components/InviteAuthForm.tsx+++ b/apps/web/src/features/invite/components/InviteAuthForm.tsx@@ -3,7 +3,7 @@import { useState, type FormEvent } from 'react';import { useRouter } from 'next/navigation';import { useTranslations } from 'next-intl';-import { projectPath } from '@/utils/paths';+import { projectPath, projectRefOf } from '@/utils/paths';import { Button } from '@/components/ui/button';import { Field, FieldDescription, FieldError, FieldGroup, FieldLabel } from '@/components/ui/field';import { Input } from '@/components/ui/input';@@ -64,7 +64,9 @@ export default function InviteAuthForm({token,registerFailed: t('registerFailed'),});- router.push(result.projectKey ? projectPath(result.projectKey) : '/');+ router.push(+ result.projectKey ? projectPath(projectRefOf(result.teamRef, result.projectKey)) : '/',+ );router.refresh();} else {await signInForInvite({ email, password, signInFailed: t('signInFailed') });diff --git a/apps/web/src/features/invite/components/InviteStep.tsx b/apps/web/src/features/invite/components/InviteStep.tsxindex c4672de1..68922b69 100644--- a/apps/web/src/features/invite/components/InviteStep.tsx+++ b/apps/web/src/features/invite/components/InviteStep.tsx@@ -5,6 +5,7 @@ import { useRouter } from 'next/navigation';import { useTranslations } from 'next-intl';import type { InviteView } from '@/lib/api/endpoints/invites';import { signOut, useSession } from '@/lib/auth-client';+import { projectRefOf } from '@/utils/paths';import { Button } from '@/components/ui/button';import InviteActions from './InviteActions';import InviteAuthForm from './InviteAuthForm';@@ -44,7 +45,12 @@ export default function InviteStep({ token, invite }: { token: string; invite: Iconst sessionEmail = session.user.email;if (sessionEmail.toLowerCase() === invite.email.toLowerCase()) {- return <InviteActions token={token} projectKey={invite.projectKey} />;+ return (+ <InviteActions+ token={token}+ projectKey={invite.projectKey && projectRefOf(invite.teamRef, invite.projectKey)}+ />+ );}return (diff --git a/apps/web/src/features/issue/IssueViewPage.tsx b/apps/web/src/features/issue/IssueViewPage.tsxindex 56eacf32..4ff581e4 100644--- a/apps/web/src/features/issue/IssueViewPage.tsx+++ b/apps/web/src/features/issue/IssueViewPage.tsx@@ -1,35 +1,30 @@'use client';-import { useParams, useRouter } from 'next/navigation';+import { useRouter } from 'next/navigation';import { useShell } from '@/context/shellContext';import { issuePath, projectPath } from '@/utils/paths';import { useExitOnEscape } from '@/hooks/useExitOnEscape';+import { useShellRoute } from '@/hooks/useShellRoute';import { useHistoryScrollRestoration } from '@/hooks/useHistoryScrollRestoration';import { useIssueBySeqQuery } from '@/services/issues.service';import IssueDetailContent from './components/detail/IssueDetailContent';import IssueDetailSkeleton from './components/detail/IssueDetailSkeleton';import { useTranslations } from 'next-intl';-// The full-page issue view (/project/:projectKey/issue/:sequenceNumber), rendered-// inside the Shell layout. The URL carries the project-scoped number, resolved to-// the issue here; the project comes from the Shell. Escape returns to the work-// items view.+// The full-page issue view (/:team/issue/:identifier), rendered inside the Shell+// layout. The URL carries the issue identifier, resolved to the issue here; the+// project comes from the Shell. Escape returns to the work items view.export default function IssueViewPage() {const t = useTranslations('issue');const router = useRouter();- const params = useParams();const { project } = useShell();- const seq = Number(typeof params.issueId === 'string' ? params.issueId : NaN);+ const seq = useShellRoute().routeIssueSeq;- const exit = () => project && router.push(projectPath(project.project.key));+ const exit = () => project && router.push(projectPath(project.project.ref));useExitOnEscape(exit);- const issueQuery = useIssueBySeqQuery(- project?.project.key ?? null,- Number.isNaN(seq) ? null : seq,- );- const currentIssuePath =- project && !Number.isNaN(seq) ? issuePath(project.project.key, seq) : null;+ const issueQuery = useIssueBySeqQuery(project?.project.ref ?? null, seq);+ const currentIssuePath = project && seq != null ? issuePath(project.project.ref, seq) : null;const scrollRestorationProps = useHistoryScrollRestoration({ pathname: currentIssuePath });if (!project) return null;diff --git a/apps/web/src/features/issue/components/actions/ArchiveIssueDialog.tsx b/apps/web/src/features/issue/components/actions/ArchiveIssueDialog.tsxindex f5e71163..3430a009 100644--- a/apps/web/src/features/issue/components/actions/ArchiveIssueDialog.tsx+++ b/apps/web/src/features/issue/components/actions/ArchiveIssueDialog.tsx@@ -21,7 +21,7 @@ export default function ArchiveIssueDialog({onArchived?: () => void;}) {const t = useTranslations('issue.actions');- const archiveIssue = useArchiveIssue(project.project.key);+ const archiveIssue = useArchiveIssue(project.project.ref);const subtasks = subtaskCount(project.issues, [issue.id]);const [disposition, setDisposition] = useState<SubtaskDisposition | null>(null);@@ -41,7 +41,7 @@ export default function ArchiveIssueDialog({{t('archiveDescription', { issue: issue.identifier })}</p><SubtaskDisposalChoice- projectKey={project.project.key}+ projectKey={project.project.ref}action="archive"count={subtasks}removedIssueIds={[issue.id]}diff --git a/apps/web/src/features/issue/components/actions/IssueActions.tsx b/apps/web/src/features/issue/components/actions/IssueActions.tsxindex 9881e684..77c01df4 100644--- a/apps/web/src/features/issue/components/actions/IssueActions.tsx+++ b/apps/web/src/features/issue/components/actions/IssueActions.tsx@@ -64,7 +64,7 @@ export function DeleteIssueDialog({onDeleted?: () => void;}) {const t = useTranslations('issue.actions');- const deleteIssue = useDeleteIssue(project.project.key);+ const deleteIssue = useDeleteIssue(project.project.ref);// The board carries only active issues, so an archived issue's subtasks are not// countable from it. The detail read carries them, archived ones included; it is// already cached on the issue page and fetched once when the dialog opens@@ -90,7 +90,7 @@ export function DeleteIssueDialog({</p>{subtasks > 0 && (<SubtaskDisposalChoice- projectKey={project.project.key}+ projectKey={project.project.ref}action="delete"count={subtasks}removedIssueIds={[issue.id]}@@ -116,7 +116,7 @@ export function ApplyActionDialog({onClose: () => void;}) {const t = useTranslations('issue.actions');- const updateIssue = useUpdateIssue(project.project.key);+ const updateIssue = useUpdateIssue(project.project.ref);return (<ConfirmDialogtitle={action.name}diff --git a/apps/web/src/features/issue/components/actions/IssueActionsBar.tsx b/apps/web/src/features/issue/components/actions/IssueActionsBar.tsxindex d4a589ab..23880268 100644--- a/apps/web/src/features/issue/components/actions/IssueActionsBar.tsx+++ b/apps/web/src/features/issue/components/actions/IssueActionsBar.tsx@@ -53,9 +53,9 @@ export default function IssueActionsBar({const qc = useQueryClient();const canEdit = can('work_items', 'edit');const canDelete = can('work_items', 'delete');- const actionsQuery = useActionsQuery(project.project.key);+ const actionsQuery = useActionsQuery(project.project.ref);const { archive, dialog: archiveDialog } = useArchiveAction(project);- const restoreIssue = useRestoreIssue(project.project.key);+ const restoreIssue = useRestoreIssue(project.project.ref);const [confirmingDelete, setConfirmingDelete] = useState(false);const [confirmingAction, setConfirmingAction] = useState<ActionDef | null>(null);const [sharing, setSharing] = useState(false);diff --git a/apps/web/src/features/issue/components/actions/IssueContextMenu.tsx b/apps/web/src/features/issue/components/actions/IssueContextMenu.tsxindex 5d7a4d0f..f170f955 100644--- a/apps/web/src/features/issue/components/actions/IssueContextMenu.tsx+++ b/apps/web/src/features/issue/components/actions/IssueContextMenu.tsx@@ -85,10 +85,10 @@ export default function IssueContextMenu({const { data: session } = useSession();const canEdit = can('work_items', 'edit');const canDelete = can('work_items', 'delete');- const updateIssue = useUpdateIssue(project.project.key);+ const updateIssue = useUpdateIssue(project.project.ref);const { archive, dialog: archiveDialog } = useArchiveAction(project, onDeleted);- const restoreIssue = useRestoreIssue(project.project.key);- const actionsQuery = useActionsQuery(project.project.key);+ const restoreIssue = useRestoreIssue(project.project.ref);+ const actionsQuery = useActionsQuery(project.project.ref);const priorityLabel = usePriorityLabel();const presetLabel = useDueDatePresetLabel();const [open, setOpen] = useState(false);@@ -97,7 +97,7 @@ export default function IssueContextMenu({// Initiatives are not in the board scaffold, so they are fetched here — only// while this menu is open, as every card on the board mounts one.const initiativesQuery = useInitiativeOptionsQuery(- open && project.project.initiativesEnabled ? project.project.key : null,+ open && project.project.initiativesEnabled ? project.project.ref : null,);// No Shell (public share): render the card as-is, without the right-click menu.diff --git a/apps/web/src/features/issue/components/create/NewIssueModal.tsx b/apps/web/src/features/issue/components/create/NewIssueModal.tsxindex f1dbea18..3edf4078 100644--- a/apps/web/src/features/issue/components/create/NewIssueModal.tsx+++ b/apps/web/src/features/issue/components/create/NewIssueModal.tsx@@ -130,8 +130,8 @@ export default function NewIssueModal({const [applyCount, setApplyCount] = useState(0);const createIssue = useCreateIssue();- const updateIssue = useUpdateIssue(project.project.key);- const setFieldValueMutation = useSetFieldValue(project.project.key);+ const updateIssue = useUpdateIssue(project.project.ref);+ const setFieldValueMutation = useSetFieldValue(project.project.ref);const attachments = useNewIssueAttachments();// The description editor instance, so a file dropped or pasted anywhere on the@@ -242,7 +242,7 @@ export default function NewIssueModal({setError(null);try {const created = await createIssue.mutateAsync({- projectKey: project.project.key,+ projectKey: project.project.ref,input: {title: title.trim(),description: description.trim() || undefined,@@ -332,7 +332,7 @@ export default function NewIssueModal({/>)}- scope={project.project.key}+ scope={project.project.ref}onClose={onClose}// The template pill comes before the title in the DOM, so the title has to// claim the focus itself.@@ -415,14 +415,14 @@ export default function NewIssueModal({{project.project.initiativesEnabled && (<InitiativeSelect- projectKey={project.project.key}+ projectKey={project.project.ref}value={initiativeId}onChange={setInitiativeId}/>)}{project.project.cyclesEnabled && (- <CycleSelect projectKey={project.project.key} value={cycle} onChange={setCycle} />+ <CycleSelect projectKey={project.project.ref} value={cycle} onChange={setCycle} />)}{project.labels.length > 0 && (diff --git a/apps/web/src/features/issue/components/detail/IssueDetail.tsx b/apps/web/src/features/issue/components/detail/IssueDetail.tsxindex e0aa396e..bcd6be5c 100644--- a/apps/web/src/features/issue/components/detail/IssueDetail.tsx+++ b/apps/web/src/features/issue/components/detail/IssueDetail.tsx@@ -21,7 +21,7 @@ export default function IssueDetail({issueId: number;onClose: () => void;// Passed the issue's project-scoped number so the host can open the page URL- // (/project/KEY/issue/42); null while the issue is still loading.+ // (/acme/issue/MKT-42); null while the issue is still loading.onExpand: (sequenceNumber: number | null) => void;}) {const t = useTranslations('issue');diff --git a/apps/web/src/features/issue/components/detail/IssueDetailContent.tsx b/apps/web/src/features/issue/components/detail/IssueDetailContent.tsxindex a82aa3a8..dbdc8194 100644--- a/apps/web/src/features/issue/components/detail/IssueDetailContent.tsx+++ b/apps/web/src/features/issue/components/detail/IssueDetailContent.tsx@@ -200,7 +200,7 @@ export default function IssueDetailContent({{features.documents && (<IssueDocumentsPanel- projectKey={project.project.key}+ projectKey={project.project.ref}issueId={issue.id}canRead={canReadDocuments}canLink={canLinkDocuments}diff --git a/apps/web/src/features/issue/components/detail/IssueLinkDialog.tsx b/apps/web/src/features/issue/components/detail/IssueLinkDialog.tsxindex 86935b22..84ca7c2e 100644--- a/apps/web/src/features/issue/components/detail/IssueLinkDialog.tsx+++ b/apps/web/src/features/issue/components/detail/IssueLinkDialog.tsx@@ -51,7 +51,7 @@ export default function IssueLinkDialog({// One request per burst of keystrokes, as in the command palette.const debounced = useDebouncedValue(query, 250);- const search = useIssueSearchQuery(project.project.key, debounced, { enabled: true });+ const search = useIssueSearchQuery(project.project.ref, debounced, { enabled: true });const hits = (search.data ?? []).filter((h) => h.id !== issueId && !linkedIssueIds.has(h.id));const prompt = t('searchPrompt', { relation: phrase(relation) });@@ -59,7 +59,7 @@ export default function IssueLinkDialog({setError(null);try {await linkIssues.mutateAsync({- projectKey: project.project.key,+ projectKey: project.project.ref,issueId,otherIssueId: targetIssueId,kind: relation,diff --git a/apps/web/src/features/issue/components/detail/IssueLinksPanel.tsx b/apps/web/src/features/issue/components/detail/IssueLinksPanel.tsxindex 620d1412..0d4eed13 100644--- a/apps/web/src/features/issue/components/detail/IssueLinksPanel.tsx+++ b/apps/web/src/features/issue/components/detail/IssueLinksPanel.tsx@@ -96,7 +96,7 @@ export default function IssueLinksPanel({canEdit? () =>unlinkIssues.mutate({- projectKey: project.project.key,+ projectKey: project.project.ref,issueId: issue.id,otherIssueId: link.issue.id,linkId: link.id,@@ -140,7 +140,7 @@ export default function IssueLinksPanel({onClose={() => setCreating(null)}onCreated={(created) => {linkIssues.mutate({- projectKey: project.project.key,+ projectKey: project.project.ref,issueId: issue.id,otherIssueId: created.id,kind: creating,diff --git a/apps/web/src/features/issue/components/detail/IssueProperties.tsx b/apps/web/src/features/issue/components/detail/IssueProperties.tsxindex 68255b76..6bc9b64a 100644--- a/apps/web/src/features/issue/components/detail/IssueProperties.tsx+++ b/apps/web/src/features/issue/components/detail/IssueProperties.tsx@@ -177,7 +177,7 @@ export default function IssueProperties({</ReadOnlyPill>) : (<InitiativeSelect- projectKey={project.project.key}+ projectKey={project.project.ref}value={issue.initiative?.id ?? null}onChange={(id) => onPatch({ initiativeId: id })}/>@@ -199,7 +199,7 @@ export default function IssueProperties({) : (<div className="flex min-w-0 items-center gap-1.5"><CycleSelect- projectKey={project.project.key}+ projectKey={project.project.ref}value={issue.cycle}onChange={(cycle) => onPatch({ cycleId: cycle?.id ?? null })}/>diff --git a/apps/web/src/features/issue/components/detail/IssueRefRow.tsx b/apps/web/src/features/issue/components/detail/IssueRefRow.tsxindex 56ea14cf..f3553d35 100644--- a/apps/web/src/features/issue/components/detail/IssueRefRow.tsx+++ b/apps/web/src/features/issue/components/detail/IssueRefRow.tsx@@ -56,7 +56,7 @@ export default function IssueRefRow({<Link{...historyScrollRestorationLinkProps}{...historyScrollRestorationAnchorProps(scrollAnchorKey)}- href={issuePath(project.project.key, issue.sequenceNumber)}+ href={issuePath(project.project.ref, issue.sequenceNumber)}className={labelClass}>{label}diff --git a/apps/web/src/features/issue/components/detail/IssueSubtasksPanel.tsx b/apps/web/src/features/issue/components/detail/IssueSubtasksPanel.tsxindex 8e04c081..cc060a11 100644--- a/apps/web/src/features/issue/components/detail/IssueSubtasksPanel.tsx+++ b/apps/web/src/features/issue/components/detail/IssueSubtasksPanel.tsx@@ -56,7 +56,7 @@ export default function IssueSubtasksPanel({const detach = (subtaskId: number, parentId: number) =>setParent.mutate({- projectKey: project.project.key,+ projectKey: project.project.ref,issueId: subtaskId,parentId: null,previousParentId: parentId,@@ -134,7 +134,7 @@ export default function IssueSubtasksPanel({{attaching && (<IssuePickerDialog- projectKey={project.project.key}+ projectKey={project.project.ref}title={t('addExisting')}prompt={t('searchPrompt')}// The hierarchy is one level deep, so an issue that already hangs under@@ -142,7 +142,7 @@ export default function IssueSubtasksPanel({exclude={(hit) => hit.id === issue.id || hit.parentId !== null}onPick={(hit) => {setParent.mutate({- projectKey: project.project.key,+ projectKey: project.project.ref,issueId: hit.id,parentId: issue.id,});diff --git a/apps/web/src/features/issue/components/detail/IssueWorklogPanel.tsx b/apps/web/src/features/issue/components/detail/IssueWorklogPanel.tsxindex d2691cf8..a17dcc8b 100644--- a/apps/web/src/features/issue/components/detail/IssueWorklogPanel.tsx+++ b/apps/web/src/features/issue/components/detail/IssueWorklogPanel.tsx@@ -41,7 +41,7 @@ export default function IssueWorklogPanel({const [adding, setAdding] = useState(false);const [editingId, setEditingId] = useState<number | null>(null);- const projectKey = project.project.key;+ const projectKey = project.project.ref;const entries = useWorklogsQuery(issue.id).data ?? [];const createWorklog = useCreateWorklog();const updateWorklog = useUpdateWorklog();diff --git a/apps/web/src/features/issue/components/detail/ReadOnlyIssueDetail.tsx b/apps/web/src/features/issue/components/detail/ReadOnlyIssueDetail.tsxindex 9bbef545..02456b94 100644--- a/apps/web/src/features/issue/components/detail/ReadOnlyIssueDetail.tsx+++ b/apps/web/src/features/issue/components/detail/ReadOnlyIssueDetail.tsx@@ -60,7 +60,7 @@ export default function ReadOnlyIssueDetail({issue it names: the api answers that read with 401, and lib/api treats every401 as an ended session and sends the reader to the sign-in screen. */}{issue.description.trim() && (- <IssueRefsProvider keys={[scaffold.project.key]} resolve={false}>+ <IssueRefsProvider refs={[scaffold.project.ref]} resolve={false}><MarkdownEditor className="mt-4" defaultValue={issue.description} editable={false} /></IssueRefsProvider>)}diff --git a/apps/web/src/features/issue/hooks/useArchiveAction.tsx b/apps/web/src/features/issue/hooks/useArchiveAction.tsxindex 33931020..98e51831 100644--- a/apps/web/src/features/issue/hooks/useArchiveAction.tsx+++ b/apps/web/src/features/issue/hooks/useArchiveAction.tsx@@ -17,7 +17,7 @@ export function useArchiveAction(project: ProjectDetail | null,onArchived?: () => void,): { archive: (issue: Issue) => void; dialog: ReactNode } {- const archiveIssue = useArchiveIssue(project?.project.key ?? null);+ const archiveIssue = useArchiveIssue(project?.project.ref ?? null);const [confirming, setConfirming] = useState<Issue | null>(null);const archive = (issue: Issue) => {diff --git a/apps/web/src/features/issue/hooks/useIssueCommands.tsx b/apps/web/src/features/issue/hooks/useIssueCommands.tsxindex b58f0f52..203c72ae 100644--- a/apps/web/src/features/issue/hooks/useIssueCommands.tsx+++ b/apps/web/src/features/issue/hooks/useIssueCommands.tsx@@ -60,7 +60,7 @@ export function useIssueCommands(const presetLabel = useDueDatePresetLabel();const { onOpenIssue } = useShell();const { data: session } = useSession();- const projectKey = project?.project.key ?? null;+ const projectKey = project?.project.ref ?? null;const issueQuery = useIssueQuery(issueId);const issue = issueQuery.data ?? null;const updateIssue = useUpdateIssue(projectKey);diff --git a/apps/web/src/features/issue/hooks/useIssueDetail.ts b/apps/web/src/features/issue/hooks/useIssueDetail.tsindex a908f099..b32cfbd8 100644--- a/apps/web/src/features/issue/hooks/useIssueDetail.ts+++ b/apps/web/src/features/issue/hooks/useIssueDetail.ts@@ -45,8 +45,8 @@ export function useIssueDetail(// What the markdown editors' image picker offers.const imageAttachments = (attachmentsQuery.data ?? []).filter(isImage);- const updateIssue = useUpdateIssue(project.project.key);- const setFieldValue = useSetFieldValue(project.project.key);+ const updateIssue = useUpdateIssue(project.project.ref);+ const setFieldValue = useSetFieldValue(project.project.ref);const uploadAttachment = useUploadAttachment();const [descEditor, setDescEditor] = useState<Editor | null>(null);@@ -57,7 +57,7 @@ export function useIssueDetail(targets: [qk.issue(issueId),qk.feed(issueId),- qk.issueDocumentLinks(project.project.key, issueId),+ qk.issueDocumentLinks(project.project.ref, issueId),],});diff --git a/apps/web/src/features/issue/utils/issuePrompt.ts b/apps/web/src/features/issue/utils/issuePrompt.tsindex a4188dcf..44743dce 100644--- a/apps/web/src/features/issue/utils/issuePrompt.ts+++ b/apps/web/src/features/issue/utils/issuePrompt.ts@@ -53,7 +53,7 @@ export function buildIssuePrompt(const labels = issue.labelIds.map((id) => project.labels.find((l) => l.id === id)?.name).filter((name): name is string => Boolean(name));- const url = `${window.location.origin}${issuePath(project.project.key, issue.sequenceNumber)}`;+ const url = `${window.location.origin}${issuePath(project.project.ref, issue.sequenceNumber)}`;const branch = buildIssueBranchName(issue, user);diff --git a/apps/web/src/features/mcp/components/McpAccessNotice.tsx b/apps/web/src/features/mcp/components/McpAccessNotice.tsxindex 872482a2..55039a84 100644--- a/apps/web/src/features/mcp/components/McpAccessNotice.tsx+++ b/apps/web/src/features/mcp/components/McpAccessNotice.tsx@@ -32,7 +32,7 @@ export default function McpAccessNotice({if (canManage) {action = (<Link- href={teamSectionPath(teamId, 'mcp')}+ href={teamSectionPath(team?.ref ?? String(teamId), 'mcp')}className="inline-block text-sm font-medium underline underline-offset-4">{t('openTeamSettings')}diff --git a/apps/web/src/features/members/MembersPage.tsx b/apps/web/src/features/members/MembersPage.tsxindex 4db4d319..94b95e54 100644--- a/apps/web/src/features/members/MembersPage.tsx+++ b/apps/web/src/features/members/MembersPage.tsx@@ -11,7 +11,7 @@ import InvitesManager from './components/invites/InvitesManager';import MemberAddDialog from './components/members/MemberAddDialog';import MembersList from './components/members/MembersList';-// The Members page (/project/:projectKey/members): who has access to the project.+// The Members page (/:team/:projectKey/members): who has access to the project.// Pending invites sit above the members list; the header action opens the dialog// that adds someone from the team or invites them by email.export default function MembersPage() {@@ -41,12 +41,12 @@ export default function MembersPage() {)}>- <InvitesManager projectKey={project.project.key} />- <MembersList projectKey={project.project.key} teamId={project.project.teamId} />+ <InvitesManager projectKey={project.project.ref} />+ <MembersList projectKey={project.project.ref} teamId={project.project.teamId} />{adding && (<MemberAddDialog- projectKey={project.project.key}+ projectKey={project.project.ref}projectName={project.project.name}teamId={project.project.teamId}teamName={project.project.teamName}diff --git a/apps/web/src/features/notes/NotesPage.tsx b/apps/web/src/features/notes/NotesPage.tsxindex 509509b8..22a006aa 100644--- a/apps/web/src/features/notes/NotesPage.tsx+++ b/apps/web/src/features/notes/NotesPage.tsx@@ -2,6 +2,7 @@import { useEffect, useMemo } from 'react';import { useParams, useRouter } from 'next/navigation';+import { useShellRoute } from '@/hooks/useShellRoute';import { useTranslations } from 'next-intl';import { useQueryClient } from '@tanstack/react-query';import { ReactFlowProvider } from '@xyflow/react';@@ -34,10 +35,10 @@ const MAX_TABS = 5;// full canvas) and moves it to the front.export default function NotesPage() {const { project } = useShell();- const params = useParams<{ projectKey: string; boardId?: string }>();+ const params = useParams<{ boardId?: string }>();const router = useRouter();const qc = useQueryClient();- const projectKey = params.projectKey;+ const projectKey = useShellRoute().projectKey ?? '';const t = useTranslations('notes');const { can } = usePermissions();diff --git a/apps/web/src/features/notes/components/StickerEditor.tsx b/apps/web/src/features/notes/components/StickerEditor.tsxindex 8b5be294..bb217bf1 100644--- a/apps/web/src/features/notes/components/StickerEditor.tsx+++ b/apps/web/src/features/notes/components/StickerEditor.tsx@@ -20,6 +20,7 @@ export default function StickerEditor({const t = useTranslations('notes');const linkKeyboardHandlers = useMemo(createLinkKeyboardHandlers, []);const editor = useEditor({+ immediatelyRender: false,editable,extensions: stickerEditorExtensions(t('notePlaceholder')),content: value,diff --git a/apps/web/src/features/settings/NotificationPreferencesPage.tsx b/apps/web/src/features/settings/NotificationPreferencesPage.tsxindex 3aa20078..eedd77bd 100644--- a/apps/web/src/features/settings/NotificationPreferencesPage.tsx+++ b/apps/web/src/features/settings/NotificationPreferencesPage.tsx@@ -11,7 +11,7 @@ import { useNotificationPreferencesQuery } from './services/settings.service';import { useNotificationPreferencesForm } from './hooks/useNotificationPreferencesForm';import { useTranslations } from 'next-intl';-// The member's own notification preferences (/project/:projectKey/notifications).+// The member's own notification preferences (/:team/:projectKey/notifications).// A main-nav Configuration destination, open to any member: choose which issue events// you get and where (email, Telegram), plus your Telegram chat id. The delivery// providers are configured separately by the owner of the team that runs the project@@ -19,7 +19,7 @@ import { useTranslations } from 'next-intl';export default function NotificationPreferencesPage() {const { project } = useShell();if (!project) return null;- return <PreferencesPage projectKey={project.project.key} />;+ return <PreferencesPage projectKey={project.project.ref} />;}function Chrome({ actions, children }: { actions?: ReactNode; children: ReactNode }) {diff --git a/apps/web/src/features/settings/SettingsActionsPage.tsx b/apps/web/src/features/settings/SettingsActionsPage.tsxindex 7fcbadac..0955203f 100644--- a/apps/web/src/features/settings/SettingsActionsPage.tsx+++ b/apps/web/src/features/settings/SettingsActionsPage.tsx@@ -13,7 +13,7 @@ import SettingsActions from './components/actions/SettingsActions';const section = settingsSection('actions');-// The Actions settings page (/project/:projectKey/settings/actions). The actions+// The Actions settings page (/:team/:projectKey/settings/actions). The actions// section also needs the project's custom fields for the condition editor.export default function SettingsActionsPage() {const t = useTranslations('settings.actions');diff --git a/apps/web/src/features/settings/SettingsConfigurationPage.tsx b/apps/web/src/features/settings/SettingsConfigurationPage.tsxindex 2ebf61d4..8abe7c5d 100644--- a/apps/web/src/features/settings/SettingsConfigurationPage.tsx+++ b/apps/web/src/features/settings/SettingsConfigurationPage.tsx@@ -21,7 +21,7 @@ import { useSubtaskAutomationForm } from './hooks/useSubtaskAutomationForm';const section = settingsSection('configuration');-// The Configuration settings page (/project/:projectKey/settings/configuration).+// The Configuration settings page (/:team/:projectKey/settings/configuration).// Holds the subtask automations, the estimate kinds and the auto-archive// thresholds; the Save in the page header writes all of them.export default function SettingsConfigurationPage() {@@ -36,9 +36,9 @@ function ConfigurationPage({ project }: { project: ProjectDetail }) {const sectionText = useSettingsSectionText()(section.slug);const { can } = usePermissions();const features = useProjectFeatures();- const subtasks = useSubtaskAutomationForm(project.project.key);+ const subtasks = useSubtaskAutomationForm(project.project.ref);const estimates = useEstimatesForm(project.project);- const archive = useAutoArchiveForm(project.project.key);+ const archive = useAutoArchiveForm(project.project.ref);const saving = subtasks.saving || estimates.saving || archive.saving;const loaded = subtasks.loaded && archive.loaded;diff --git a/apps/web/src/features/settings/SettingsCustomFieldsPage.tsx b/apps/web/src/features/settings/SettingsCustomFieldsPage.tsxindex 96324064..01baf598 100644--- a/apps/web/src/features/settings/SettingsCustomFieldsPage.tsx+++ b/apps/web/src/features/settings/SettingsCustomFieldsPage.tsx@@ -11,7 +11,7 @@ import SettingsCustomFields from './components/custom-fields/SettingsCustomFieldconst section = settingsSection('custom-fields');-// The Custom fields settings page (/project/:projectKey/settings/custom-fields).+// The Custom fields settings page (/:team/:projectKey/settings/custom-fields).export default function SettingsCustomFieldsPage() {const sectionText = useSettingsSectionText()(section.slug);const { project } = useShell();@@ -22,7 +22,7 @@ export default function SettingsCustomFieldsPage() {description={sectionText.description}actions={<CustomFieldsToolbar- projectKey={project.project.key}+ projectKey={project.project.ref}resource={section.resource}fields={project.customFields}types={project.issueTypes}diff --git a/apps/web/src/features/settings/SettingsGeneralPage.tsx b/apps/web/src/features/settings/SettingsGeneralPage.tsxindex 6071f5b5..2562eec5 100644--- a/apps/web/src/features/settings/SettingsGeneralPage.tsx+++ b/apps/web/src/features/settings/SettingsGeneralPage.tsx@@ -16,7 +16,7 @@ import { useFeatureToggles } from './hooks/useFeatureToggles';const section = settingsSection('general');-// The General settings page (/project/:projectKey/settings/general). Edits the+// The General settings page (/:team/:projectKey/settings/general). Edits the// project name and description; the key is shown read-only. Save lives in the page// header.export default function SettingsGeneralPage() {diff --git a/apps/web/src/features/settings/SettingsGitPage.tsx b/apps/web/src/features/settings/SettingsGitPage.tsxindex 061a3cf9..0bf31c57 100644--- a/apps/web/src/features/settings/SettingsGitPage.tsx+++ b/apps/web/src/features/settings/SettingsGitPage.tsx@@ -10,7 +10,7 @@ import SettingsGit from './components/git/SettingsGit';const section = settingsSection('git');-// The repository integration page (/project/:projectKey/settings/git).+// The repository integration page (/:team/:projectKey/settings/git).export default function SettingsGitPage() {const sectionText = useSettingsSectionText()(section.slug);const { project } = useShell();diff --git a/apps/web/src/features/settings/SettingsImportExportPage.tsx b/apps/web/src/features/settings/SettingsImportExportPage.tsxindex b12b1c23..d9a8d215 100644--- a/apps/web/src/features/settings/SettingsImportExportPage.tsx+++ b/apps/web/src/features/settings/SettingsImportExportPage.tsx@@ -10,7 +10,7 @@ import SettingsImportExport from './components/import-export/SettingsImportExporconst section = settingsSection('import-export');-// The Plane import page (/project/:projectKey/settings/import-export).+// The Plane import page (/:team/:projectKey/settings/import-export).export default function SettingsImportExportPage() {const sectionText = useSettingsSectionText()(section.slug);const { project } = useShell();diff --git a/apps/web/src/features/settings/SettingsIssueTemplatesPage.tsx b/apps/web/src/features/settings/SettingsIssueTemplatesPage.tsxindex cdf46277..ff80e09e 100644--- a/apps/web/src/features/settings/SettingsIssueTemplatesPage.tsx+++ b/apps/web/src/features/settings/SettingsIssueTemplatesPage.tsx@@ -13,7 +13,7 @@ import SettingsIssueTemplates from './components/issue-templates/SettingsIssueTeconst section = settingsSection('issue-templates');-// The Issue templates settings page (/project/:projectKey/settings/issue-templates).+// The Issue templates settings page (/:team/:projectKey/settings/issue-templates).export default function SettingsIssueTemplatesPage() {const t = useTranslations('settings.issueTemplates');const sectionText = useSettingsSectionText()(section.slug);diff --git a/apps/web/src/features/settings/SettingsIssueTypesPage.tsx b/apps/web/src/features/settings/SettingsIssueTypesPage.tsxindex 711c6970..364f8864 100644--- a/apps/web/src/features/settings/SettingsIssueTypesPage.tsx+++ b/apps/web/src/features/settings/SettingsIssueTypesPage.tsx@@ -12,7 +12,7 @@ import SettingsIssueTypes from './components/issue-types/SettingsIssueTypes';const section = settingsSection('issue-types');-// The Issue types settings page (/project/:projectKey/settings/issue-types).+// The Issue types settings page (/:team/:projectKey/settings/issue-types).export default function SettingsIssueTypesPage() {const sectionText = useSettingsSectionText()(section.slug);const { project } = useShell();@@ -25,7 +25,7 @@ export default function SettingsIssueTypesPage() {description={sectionText.description}actions={<IssueTypesToolbar- projectKey={project.project.key}+ projectKey={project.project.ref}resource={section.resource}types={project.issueTypes}onAdd={() => setAdding(true)}diff --git a/apps/web/src/features/settings/SettingsLabelsPage.tsx b/apps/web/src/features/settings/SettingsLabelsPage.tsxindex f42c52dd..7178282e 100644--- a/apps/web/src/features/settings/SettingsLabelsPage.tsx+++ b/apps/web/src/features/settings/SettingsLabelsPage.tsx@@ -11,7 +11,7 @@ import SettingsLabels from './components/labels/SettingsLabels';const section = settingsSection('labels');-// The Labels settings page (/project/:projectKey/settings/labels).+// The Labels settings page (/:team/:projectKey/settings/labels).export default function SettingsLabelsPage() {const sectionText = useSettingsSectionText()(section.slug);const { project } = useShell();@@ -22,7 +22,7 @@ export default function SettingsLabelsPage() {description={sectionText.description}actions={<LabelsToolbar- projectKey={project.project.key}+ projectKey={project.project.ref}resource={section.resource}groups={project.labelGroups}labels={project.labels}diff --git a/apps/web/src/features/settings/SettingsSchedulesPage.tsx b/apps/web/src/features/settings/SettingsSchedulesPage.tsxindex 239055a9..c8bda990 100644--- a/apps/web/src/features/settings/SettingsSchedulesPage.tsx+++ b/apps/web/src/features/settings/SettingsSchedulesPage.tsx@@ -14,7 +14,7 @@ import { useTranslations } from 'next-intl';const section = settingsSection('schedules');-// The Schedules page (/project/:projectKey/ai-team/schedules), listed in the main+// The Schedules page (/:team/:projectKey/agents/schedules), listed in the main// sidebar's AI Team group.export default function SettingsSchedulesPage() {const t = useTranslations('settings.schedules');diff --git a/apps/web/src/features/settings/SettingsStatesPage.tsx b/apps/web/src/features/settings/SettingsStatesPage.tsxindex 2f0f7220..4979b40c 100644--- a/apps/web/src/features/settings/SettingsStatesPage.tsx+++ b/apps/web/src/features/settings/SettingsStatesPage.tsx@@ -11,7 +11,7 @@ import StatesToolbar from './components/states/StatesToolbar';const section = settingsSection('states');-// The States settings page (/project/:projectKey/settings/states).+// The States settings page (/:team/:projectKey/settings/states).export default function SettingsStatesPage() {const sectionText = useSettingsSectionText()(section.slug);const { project } = useShell();@@ -20,7 +20,7 @@ export default function SettingsStatesPage() {<SectionPageViewtitle={sectionText.label}description={sectionText.description}- actions={<StatesToolbar projectKey={project.project.key} columns={project.columns} />}+ actions={<StatesToolbar projectKey={project.project.ref} columns={project.columns} />}><SettingsResourceProvider resource={section.resource}><RequirePermission resource={section.resource} action="read">diff --git a/apps/web/src/features/settings/SettingsWebhooksPage.tsx b/apps/web/src/features/settings/SettingsWebhooksPage.tsxindex dc0222e7..9c23f04e 100644--- a/apps/web/src/features/settings/SettingsWebhooksPage.tsx+++ b/apps/web/src/features/settings/SettingsWebhooksPage.tsx@@ -13,7 +13,7 @@ import SettingsWebhooks from './components/webhooks/SettingsWebhooks';const section = settingsSection('webhooks');-// The Webhooks settings page (/project/:projectKey/settings/webhooks).+// The Webhooks settings page (/:team/:projectKey/settings/webhooks).export default function SettingsWebhooksPage() {const t = useTranslations('settings.webhooks');const sectionText = useSettingsSectionText()(section.slug);diff --git a/apps/web/src/features/settings/components/actions/SettingsActionRow.tsx b/apps/web/src/features/settings/components/actions/SettingsActionRow.tsxindex d03e43f3..daa86959 100644--- a/apps/web/src/features/settings/components/actions/SettingsActionRow.tsx+++ b/apps/web/src/features/settings/components/actions/SettingsActionRow.tsx@@ -29,7 +29,7 @@ export function SettingsActionRow({}) {const t = useTranslations('settings.actions');const can = useSettingsCan();- const { describeConditions } = useFilterFields(project.project.key);+ const { describeConditions } = useFilterFields(project.project.ref);const effectText = useEffectText();const conditions = describeConditions(action.condition, project, customFields);const effects = describeEffect(action.effect, project, effectText);diff --git a/apps/web/src/features/settings/components/actions/SettingsActions.tsx b/apps/web/src/features/settings/components/actions/SettingsActions.tsxindex c1b63a93..d013c5bd 100644--- a/apps/web/src/features/settings/components/actions/SettingsActions.tsx+++ b/apps/web/src/features/settings/components/actions/SettingsActions.tsx@@ -34,7 +34,7 @@ export default function SettingsActions({onNewHandled: () => void;}) {const t = useTranslations('settings.actions');- const projectKey = project.project.key;+ const projectKey = project.project.ref;const actionsQuery = useActionsQuery(projectKey);const actions = actionsQuery.data ?? [];const createAction = useCreateAction(projectKey);diff --git a/apps/web/src/features/settings/components/custom-fields/SettingsCustomFields.tsx b/apps/web/src/features/settings/components/custom-fields/SettingsCustomFields.tsxindex 5ff91657..b63cc48e 100644--- a/apps/web/src/features/settings/components/custom-fields/SettingsCustomFields.tsx+++ b/apps/web/src/features/settings/components/custom-fields/SettingsCustomFields.tsx@@ -21,7 +21,7 @@ import SettingsCustomFieldDialog, { type FieldFormValues } from './SettingsCustotype AddScope = 'global' | number;export default function SettingsCustomFields({ project }: { project: ProjectDetail }) {- const projectKey = project.project.key;+ const projectKey = project.project.ref;const [addingScope, setAddingScope] = useState<AddScope | null>(null);const [editing, setEditing] = useState<CustomField | null>(null);const [deleting, setDeleting] = useState<CustomField | null>(null);diff --git a/apps/web/src/features/settings/components/git/GitProviderConnections.tsx b/apps/web/src/features/settings/components/git/GitProviderConnections.tsxindex a5e50dd8..b01a04ae 100644--- a/apps/web/src/features/settings/components/git/GitProviderConnections.tsx+++ b/apps/web/src/features/settings/components/git/GitProviderConnections.tsx@@ -10,11 +10,11 @@ import GitProviderConnectionCard from './GitProviderConnectionCard';export default function GitProviderConnections({projectKey,- teamId,+ teamRef,canManageTeam,}: {projectKey: string;- teamId: number;+ teamRef: string;canManageTeam: boolean;}) {const t = useTranslations('settings.git');@@ -23,7 +23,7 @@ export default function GitProviderConnections({const empty = !connections.isPending && connections.data?.length === 0;const addButton = canManageTeam && (<Button asChild variant="ghost" size="sm">- <Link href={teamSectionPath(teamId, 'git')}>+ <Link href={teamSectionPath(teamRef, 'git')}><Plus className="size-3.5" />{tc('add')}</Link>diff --git a/apps/web/src/features/settings/components/git/SettingsGit.tsx b/apps/web/src/features/settings/components/git/SettingsGit.tsxindex ce0947b6..cb574268 100644--- a/apps/web/src/features/settings/components/git/SettingsGit.tsx+++ b/apps/web/src/features/settings/components/git/SettingsGit.tsx@@ -16,7 +16,7 @@ import SettingsSection from '@/components/common/page/SettingsSection';// immediately; there is no form-level save.export default function SettingsGit({ project }: { project: ProjectDetail }) {const t = useTranslations('settings.git');- const projectKey = project.project.key;+ const projectKey = project.project.ref;const settingsQuery = useGitSettingsQuery(projectKey);const updateSettings = useUpdateGitSettings(projectKey);@@ -43,7 +43,7 @@ export default function SettingsGit({ project }: { project: ProjectDetail }) {<GitConnectionCard projectKey={projectKey} settings={settings} /><GitProviderConnectionsprojectKey={projectKey}- teamId={project.project.teamId}+ teamRef={project.project.teamRef}canManageTeam={project.viewer.teamRole === 'owner' || project.viewer.teamRole === 'manager'}diff --git a/apps/web/src/features/settings/components/import-export/SettingsImportExport.tsx b/apps/web/src/features/settings/components/import-export/SettingsImportExport.tsxindex fc884895..ef77a7f2 100644--- a/apps/web/src/features/settings/components/import-export/SettingsImportExport.tsx+++ b/apps/web/src/features/settings/components/import-export/SettingsImportExport.tsx@@ -31,7 +31,7 @@ const SOURCES = [// requires; the export tab needs create too.export default function SettingsImportExport({ project }: { project: ProjectDetail }) {const t = useTranslations('settings.importExport');- const projectKey = project.project.key;+ const projectKey = project.project.ref;const { can } = usePermissions();const canCreate = can('import_export', 'create');const canEdit = can('import_export', 'edit');diff --git a/apps/web/src/features/settings/components/import-export/SettingsImportExportDownloadButton.tsx b/apps/web/src/features/settings/components/import-export/SettingsImportExportDownloadButton.tsxindex a08e20cc..2e5b36de 100644--- a/apps/web/src/features/settings/components/import-export/SettingsImportExportDownloadButton.tsx+++ b/apps/web/src/features/settings/components/import-export/SettingsImportExportDownloadButton.tsx@@ -6,6 +6,7 @@ import { toast } from 'sonner';import { Download, Loader2 } from 'lucide-react';import { Button } from '@/components/ui/button';import { exportProject } from '@/lib/api/endpoints/importExport';+import { splitProjectRef } from '@/utils/paths';// Downloads a self-contained JSON snapshot of the project's data. A plain read, not a// mutation, so it builds and triggers the file save itself rather than going through@@ -23,7 +24,7 @@ export default function SettingsImportExportDownloadButton({ projectKey }: { proconst url = URL.createObjectURL(blob);const anchor = document.createElement('a');anchor.href = url;- anchor.download = `${projectKey}-export.json`;+ anchor.download = `${splitProjectRef(projectKey).key}-export.json`;anchor.hidden = true;try {document.body.append(anchor);diff --git a/apps/web/src/features/settings/components/issue-templates/SettingsIssueTemplates.tsx b/apps/web/src/features/settings/components/issue-templates/SettingsIssueTemplates.tsxindex 2f4a54ef..1c02d56c 100644--- a/apps/web/src/features/settings/components/issue-templates/SettingsIssueTemplates.tsx+++ b/apps/web/src/features/settings/components/issue-templates/SettingsIssueTemplates.tsx@@ -24,7 +24,7 @@ export default function SettingsIssueTemplates({onNewHandled: () => void;}) {const t = useTranslations('settings.issueTemplates');- const projectKey = project.project.key;+ const projectKey = project.project.ref;const createTemplate = useCreateIssueTemplate(projectKey);const updateTemplate = useUpdateIssueTemplate(projectKey);const deleteTemplate = useDeleteIssueTemplate(projectKey);diff --git a/apps/web/src/features/settings/components/issue-types/SettingsIssueTypes.tsx b/apps/web/src/features/settings/components/issue-types/SettingsIssueTypes.tsxindex 8611fc6c..8a17f5f4 100644--- a/apps/web/src/features/settings/components/issue-types/SettingsIssueTypes.tsx+++ b/apps/web/src/features/settings/components/issue-types/SettingsIssueTypes.tsx@@ -46,9 +46,9 @@ export default function SettingsIssueTypes({const t = useTranslations('settings.issueTypes');const tCommon = useTranslations('common');const can = useSettingsCan();- const createIssueType = useCreateIssueType(project.project.key);- const updateIssueType = useUpdateIssueType(project.project.key);- const deleteIssueType = useDeleteIssueType(project.project.key);+ const createIssueType = useCreateIssueType(project.project.ref);+ const updateIssueType = useUpdateIssueType(project.project.ref);+ const deleteIssueType = useDeleteIssueType(project.project.ref);const types = project.issueTypes;const issueCount = (typeId: number) =>diff --git a/apps/web/src/features/settings/components/labels/SettingsLabels.tsx b/apps/web/src/features/settings/components/labels/SettingsLabels.tsxindex 7ac9a5fb..c9cd7df4 100644--- a/apps/web/src/features/settings/components/labels/SettingsLabels.tsx+++ b/apps/web/src/features/settings/components/labels/SettingsLabels.tsx@@ -30,7 +30,7 @@ import { SettingsLabelsAddMenu } from './SettingsLabelsAddMenu';// adds labels into that group; the "Add" action below the list adds a group or an// ungrouped label. Labels drag between groups and the root.export default function SettingsLabels({ project }: { project: ProjectDetail }) {- const projectKey = project.project.key;+ const projectKey = project.project.ref;const [collapsed, setCollapsed] = useState<Set<string>>(new Set());// The open label add/edit form, and the open group add/edit form. At most one is// set at a time (opening either closes the other).diff --git a/apps/web/src/features/settings/components/schedules/SettingsSchedules.tsx b/apps/web/src/features/settings/components/schedules/SettingsSchedules.tsxindex b14a7bca..e04be017 100644--- a/apps/web/src/features/settings/components/schedules/SettingsSchedules.tsx+++ b/apps/web/src/features/settings/components/schedules/SettingsSchedules.tsx@@ -34,7 +34,7 @@ export default function SettingsSchedules({onNewHandled: () => void;}) {const t = useTranslations('settings.schedules');- const projectKey = project.project.key;+ const projectKey = project.project.ref;const can = useSettingsCan();const paging = usePaging();const schedulesQuery = useAgentSchedules(projectKey, paging.params);diff --git a/apps/web/src/features/settings/components/states/SettingsDeleteStateDialog.tsx b/apps/web/src/features/settings/components/states/SettingsDeleteStateDialog.tsxindex 4897540d..8720d9c8 100644--- a/apps/web/src/features/settings/components/states/SettingsDeleteStateDialog.tsx+++ b/apps/web/src/features/settings/components/states/SettingsDeleteStateDialog.tsx@@ -30,7 +30,7 @@ export default function SettingsDeleteStateDialog({const otherColumns = project.columns.filter((c) => c.id !== column.id);const [action, setAction] = useState<'move' | 'delete'>(otherColumns.length ? 'move' : 'delete');const [targetColumnId, setTargetColumnId] = useState<number | undefined>(otherColumns[0]?.id);- const deleteColumn = useDeleteColumn(project.project.key);+ const deleteColumn = useDeleteColumn(project.project.ref);async function confirm() {const body =diff --git a/apps/web/src/features/settings/components/states/SettingsStates.tsx b/apps/web/src/features/settings/components/states/SettingsStates.tsxindex c7a95dbd..a91b11c1 100644--- a/apps/web/src/features/settings/components/states/SettingsStates.tsx+++ b/apps/web/src/features/settings/components/states/SettingsStates.tsx@@ -45,9 +45,9 @@ export default function SettingsStates({ project }: { project: ProjectDetail })const tStateType = useTranslations('display.stateTypes');const sensors = useDndSensors();const can = useSettingsCan();- const createColumn = useCreateColumn(project.project.key);- const updateColumn = useUpdateColumn(project.project.key);- const reorderColumns = useReorderColumns(project.project.key);+ const createColumn = useCreateColumn(project.project.ref);+ const updateColumn = useUpdateColumn(project.project.ref);+ const reorderColumns = useReorderColumns(project.project.ref);const issueCount = (columnId: number) =>project.issues.filter((t) => t.columnId === columnId).length;diff --git a/apps/web/src/features/settings/components/webhooks/SettingsWebhooks.tsx b/apps/web/src/features/settings/components/webhooks/SettingsWebhooks.tsxindex cdeec71c..497eacf5 100644--- a/apps/web/src/features/settings/components/webhooks/SettingsWebhooks.tsx+++ b/apps/web/src/features/settings/components/webhooks/SettingsWebhooks.tsx@@ -28,7 +28,7 @@ export default function SettingsWebhooks({onNewHandled: () => void;}) {const t = useTranslations('settings.webhooks');- const projectKey = project.project.key;+ const projectKey = project.project.ref;const webhooksQuery = useWebhooksQuery(projectKey);const webhooks = webhooksQuery.data ?? [];const createWebhook = useCreateWebhook(projectKey);diff --git a/apps/web/src/features/settings/hooks/useEstimatesForm.ts b/apps/web/src/features/settings/hooks/useEstimatesForm.tsindex e71f1c5b..a6a25b8c 100644--- a/apps/web/src/features/settings/hooks/useEstimatesForm.ts+++ b/apps/web/src/features/settings/hooks/useEstimatesForm.ts@@ -21,7 +21,7 @@ export interface EstimatesForm {export function useEstimatesForm(project: Project): EstimatesForm {const { can } = usePermissions();- const update = useUpdateEstimates(project.key);+ const update = useUpdateEstimates(project.ref);const [points, setPoints] = useState(project.pointsEstimateEnabled);const [time, setTime] = useState(project.timeEstimateEnabled);diff --git a/apps/web/src/features/settings/hooks/useFeatureToggles.ts b/apps/web/src/features/settings/hooks/useFeatureToggles.tsindex f74526a3..325d42cd 100644--- a/apps/web/src/features/settings/hooks/useFeatureToggles.ts+++ b/apps/web/src/features/settings/hooks/useFeatureToggles.ts@@ -26,7 +26,7 @@ export function useFeatureToggles(project: ProjectDetail): FeatureTogglesForm {const t = useTranslations('settings.general');const featureLabel = useFeatureLabel();const { isOwner } = usePermissions();- const update = useUpdateProjectFeatures(project.project.key);+ const update = useUpdateProjectFeatures(project.project.ref);async function toggle(feature: keyof ProjectFeatures, enabled: boolean) {await update.mutateAsync({ [feature]: enabled });diff --git a/apps/web/src/features/teams/ManageTeamsIndex.tsx b/apps/web/src/features/teams/ManageTeamsIndex.tsxindex 619a2112..777bc074 100644--- a/apps/web/src/features/teams/ManageTeamsIndex.tsx+++ b/apps/web/src/features/teams/ManageTeamsIndex.tsx@@ -15,7 +15,7 @@ export default function ManageTeamsIndex() {const first = data?.[0];useEffect(() => {- if (first) router.replace(teamPath(first.id));+ if (first) router.replace(teamPath(first.ref));}, [first, router]);return (diff --git a/apps/web/src/features/teams/ManageTeamsLayout.tsx b/apps/web/src/features/teams/ManageTeamsLayout.tsxindex d4c82024..ca5f3a66 100644--- a/apps/web/src/features/teams/ManageTeamsLayout.tsx+++ b/apps/web/src/features/teams/ManageTeamsLayout.tsx@@ -1,13 +1,14 @@'use client';import { useState, type ReactNode } from 'react';-import { useParams, useRouter } from 'next/navigation';+import { useRouter } from 'next/navigation';import { useTranslations } from 'next-intl';import { teamPath } from '@/utils/paths';import { useTeamsQuery } from '@/services/teams.service';import NewTeamModal from './components/NewTeamModal';import TeamsPageView from './components/TeamsPageView';import TeamsRail from './components/TeamsRail';+import { useRouteTeam } from './hooks/useRouteTeam';// The teams the account belongs to, as the rail every team route is opened from.// The list carries each team's counters, so the section rail beside it shows them@@ -16,11 +17,9 @@ export default function ManageTeamsLayout({ children }: { children: ReactNode })const t = useTranslations('teams.manage');const { data, isPending } = useTeamsQuery();const router = useRouter();- const params = useParams<{ teamId?: string }>();+ const activeId = useRouteTeam()?.id ?? null;const [creating, setCreating] = useState(false);- const activeId = params.teamId ? Number(params.teamId) : null;-return (<TeamsPageViewlabel={t('label')}@@ -38,7 +37,7 @@ export default function ManageTeamsLayout({ children }: { children: ReactNode }){creating && (<NewTeamModalonClose={() => setCreating(false)}- onCreated={(team) => router.push(teamPath(team.id))}+ onCreated={(team) => router.push(teamPath(team.ref))}/>)}</TeamsPageView>diff --git a/apps/web/src/features/teams/TeamLayout.tsx b/apps/web/src/features/teams/TeamLayout.tsxindex ba4018a1..3447230c 100644--- a/apps/web/src/features/teams/TeamLayout.tsx+++ b/apps/web/src/features/teams/TeamLayout.tsx@@ -1,28 +1,35 @@'use client';import { useEffect, type ReactNode } from 'react';-import { useRouter } from 'next/navigation';+import { usePathname, useRouter } from 'next/navigation';import { manageTeamsPath } from '@/utils/paths';import { useTeamsQuery } from '@/services/teams.service';import TeamsPageRail from './components/TeamsPageRail';import TeamSectionNav from './components/TeamSectionNav';+import { useRouteTeam } from './hooks/useRouteTeam';// One team, as the second rail of the page and the section open beside it. Each-// section is a route of its own and loads only what it shows. A team the account is-// no longer in falls back to the first one left.-export default function TeamLayout({ teamId, children }: { teamId: number; children: ReactNode }) {+// section is a route of its own and loads only what it shows. A path that names the+// team by its id moves to its slug, and a team the account is no longer in falls back+// to the first one left.+export default function TeamLayout({ children }: { children: ReactNode }) {const router = useRouter();+ const pathname = usePathname();const { data } = useTeamsQuery();- const team = data?.find((entry) => entry.id === teamId) ?? null;+ const team = useRouteTeam();useEffect(() => {if (data && !team) router.replace(manageTeamsPath());- }, [data, team, router]);+ const [, routed = '', ...rest] = pathname.split('/');+ if (team && decodeURIComponent(routed) !== team.ref) {+ router.replace(`/${encodeURIComponent(team.ref)}/${rest.join('/')}`);+ }+ }, [data, team, pathname, router]);return (<><TeamsPageRail className="lg:w-60">{team && <TeamSectionNav team={team} />}</TeamsPageRail>- <div className="flex min-w-0 flex-1 flex-col">{children}</div>+ <div className="flex min-w-0 flex-1 flex-col">{team && children}</div></>);}diff --git a/apps/web/src/features/teams/components/NewTeamModal.tsx b/apps/web/src/features/teams/components/NewTeamModal.tsxindex 5314d64b..2c7e524a 100644--- a/apps/web/src/features/teams/components/NewTeamModal.tsx+++ b/apps/web/src/features/teams/components/NewTeamModal.tsx@@ -5,11 +5,15 @@ import { Users } from 'lucide-react';import { useTranslations } from 'next-intl';import type { Team } from '@/lib/api/endpoints/teams';import { useCreateTeam } from '@/services/teams.service';+import { cn } from '@/lib/utils';import Modal from '@/components/common/overlay/Modal';import { Button } from '@/components/ui/button';+import { Input } from '@/components/ui/input';+import { Label } from '@/components/ui/label';+import { TEAM_SLUG_PATTERN, suggestTeamSlug } from '../utils/teamSlug';-// Creates a team with the current user as its owner. Name only: everything else a-// team carries (its members, its projects) is added afterwards. `onCreated` is where+// Creates a team with the current user as its owner. Name and URL slug only: everything+// else a team carries (its members, its projects) is added afterwards. `onCreated` is where// the caller takes it from there — the teams page opens the new team.export default function NewTeamModal({onClose,@@ -21,13 +25,29 @@ export default function NewTeamModal({const t = useTranslations('teams.create');const createTeam = useCreateTeam();const [name, setName] = useState('');+ const [slug, setSlug] = useState('');+ // The slug follows the name until the user edits it; clearing it resumes that.+ const [slugEdited, setSlugEdited] = useState(false);- const canSubmit = !createTeam.isPending && name.trim() !== '';+ const slugValid = TEAM_SLUG_PATTERN.test(slug);+ const slugError = slug !== '' && !slugValid;+ const canSubmit = !createTeam.isPending && name.trim() !== '' && slugValid;++ function changeName(value: string) {+ setName(value);+ if (!slugEdited) setSlug(suggestTeamSlug(value));+ }++ function changeSlug(value: string) {+ const next = value.toLowerCase().trim();+ setSlug(next);+ setSlugEdited(next !== '');+ }function submit() {if (!canSubmit) return;createTeam.mutate(- { name: name.trim() },+ { name: name.trim(), slug },{onSuccess: (team) => {onClose();@@ -49,7 +69,7 @@ export default function NewTeamModal({className="w-full bg-transparent text-lg font-semibold outline-none placeholder:text-muted-foreground"placeholder={t('namePlaceholder')}value={name}- onChange={(e) => setName(e.target.value)}+ onChange={(e) => changeName(e.target.value)}onKeyDown={(e) => {if (e.key === 'Enter' && !e.nativeEvent.isComposing) submit();}}@@ -57,6 +77,28 @@ export default function NewTeamModal({/></div>+ <div className="mt-4 space-y-1.5">+ <Label htmlFor="new-team-slug">{t('slug')}</Label>+ <Input+ id="new-team-slug"+ value={slug}+ placeholder="acme"+ dir="ltr"+ aria-invalid={slugError}+ aria-describedby="new-team-slug-hint"+ onChange={(e) => changeSlug(e.target.value)}+ onKeyDown={(e) => {+ if (e.key === 'Enter' && !e.nativeEvent.isComposing) submit();+ }}+ />+ <p+ id="new-team-slug-hint"+ className={cn('text-xs', slugError ? 'text-destructive' : 'text-muted-foreground')}+ >+ {slugError ? t('slugInvalid') : t('slugHint')}+ </p>+ </div>+<p className="mt-3 text-sm text-muted-foreground">{t('hint')}</p><div className="mt-4 flex items-center border-t pt-3">diff --git a/apps/web/src/features/teams/components/TeamSectionNav.tsx b/apps/web/src/features/teams/components/TeamSectionNav.tsxindex 361e9d59..cd98225a 100644--- a/apps/web/src/features/teams/components/TeamSectionNav.tsx+++ b/apps/web/src/features/teams/components/TeamSectionNav.tsx@@ -54,7 +54,7 @@ export default function TeamSectionNav({ team }: { team: Team }) {label,icon,badge: count === undefined ? undefined : String(count),- href: teamSectionPath(team.id, id),+ href: teamSectionPath(team.ref, id),};}diff --git a/apps/web/src/features/teams/components/TeamsRail.tsx b/apps/web/src/features/teams/components/TeamsRail.tsxindex dcebaeb0..1e446505 100644--- a/apps/web/src/features/teams/components/TeamsRail.tsx+++ b/apps/web/src/features/teams/components/TeamsRail.tsx@@ -58,7 +58,7 @@ export default function TeamsRail({return (<li key={team.id}><Link- href={teamPath(team.id)}+ href={teamPath(team.ref)}aria-current={active ? 'page' : undefined}className={cn('flex h-8 w-full items-center gap-2 rounded-md px-2 text-start text-sm transition-colors duration-150 outline-none focus-visible:ring-2 focus-visible:ring-ring/60',diff --git a/apps/web/src/features/teams/components/ai-agents/AgentSheetForm.tsx b/apps/web/src/features/teams/components/ai-agents/AgentSheetForm.tsxindex c6540e6f..91fb31cd 100644--- a/apps/web/src/features/teams/components/ai-agents/AgentSheetForm.tsx+++ b/apps/web/src/features/teams/components/ai-agents/AgentSheetForm.tsx@@ -233,7 +233,7 @@ export function AgentSheetForm({icon={Sparkles}title={t('noSkills')}hint={t('noSkillsHint')}- href={teamSectionPath(teamId, 'agent-skills')}+ href={teamSectionPath(team?.ref ?? String(teamId), 'agent-skills')}linkLabel={t('goToSkills')}/>) : (@@ -261,7 +261,7 @@ export function AgentSheetForm({icon={Wrench}title={t('noTools')}hint={t('noToolsHint')}- href={teamSectionPath(teamId, 'agent-tools')}+ href={teamSectionPath(team?.ref ?? String(teamId), 'agent-tools')}linkLabel={t('goToTools')}/>) : (diff --git a/apps/web/src/features/teams/components/ai-agents/AgentTriggersSection.tsx b/apps/web/src/features/teams/components/ai-agents/AgentTriggersSection.tsxindex 3d76813f..19a478cb 100644--- a/apps/web/src/features/teams/components/ai-agents/AgentTriggersSection.tsx+++ b/apps/web/src/features/teams/components/ai-agents/AgentTriggersSection.tsx@@ -41,8 +41,8 @@ export default function AgentTriggersSection({// in the cache, so opening the editor usually fetches only the rest.const scaffolds = useQueries({queries: attached.map((project) => ({- queryKey: qk.project(project.key),- queryFn: () => getProject(project.key),+ queryKey: qk.project(project.ref),+ queryFn: () => getProject(project.ref),})),});const memberFields: ProjectField[] = scaffolds.flatMap((scaffold, index) =>diff --git a/apps/web/src/features/teams/components/ai-agents/ProjectAiAgentsSection.tsx b/apps/web/src/features/teams/components/ai-agents/ProjectAiAgentsSection.tsxindex b9c07625..05f5619f 100644--- a/apps/web/src/features/teams/components/ai-agents/ProjectAiAgentsSection.tsx+++ b/apps/web/src/features/teams/components/ai-agents/ProjectAiAgentsSection.tsx@@ -12,7 +12,7 @@ import ProjectAiAgents from './ProjectAiAgents';const section = AI_AGENTS_SECTION;-// The AI agents page (/project/:projectKey/ai-agents), a top-level nav item. It lists+// The AI agents page (/:team/:projectKey/agents), a top-level nav item. It lists// the agents working in the project and nothing more: an agent belongs to the team, so// it is created, attached to projects and edited in the team section.export default function ProjectAiAgentsSection() {diff --git a/apps/web/src/features/teams/components/ai-agents/TeamAiAgentSheet.tsx b/apps/web/src/features/teams/components/ai-agents/TeamAiAgentSheet.tsxindex a1c921f1..4d8c589d 100644--- a/apps/web/src/features/teams/components/ai-agents/TeamAiAgentSheet.tsx+++ b/apps/web/src/features/teams/components/ai-agents/TeamAiAgentSheet.tsx@@ -70,7 +70,7 @@ function SheetBody({ initialAgent }: { initialAgent: AiAgent | null }) {const chatProject = agent?.projects[0] ?? null;// Held here so the transcript and thread survive re-renders. No agent yet during// create → id 0; the chat is only reachable once the agent exists.- const chat = useAgentChat(chatProject?.key ?? '', agent?.id ?? 0, agent?.kind === 'external');+ const chat = useAgentChat(chatProject?.ref ?? '', agent?.id ?? 0, agent?.kind === 'external');// The form and the test chat always sit side by side, so the sheet keeps its shape// from create through edit. There is nothing to chat in until the agent exists and@@ -121,7 +121,7 @@ function SheetBody({ initialAgent }: { initialAgent: AiAgent | null }) {{chatReady ? (<AgentChatPanelagent={agent}- projectKey={chatProject.key}+ projectKey={chatProject.ref}messages={chat.messages}status={chat.status}activeTool={chat.activeTool}diff --git a/apps/web/src/features/teams/components/info/TeamInfoSection.tsx b/apps/web/src/features/teams/components/info/TeamInfoSection.tsxindex cb671309..e711d0eb 100644--- a/apps/web/src/features/teams/components/info/TeamInfoSection.tsx+++ b/apps/web/src/features/teams/components/info/TeamInfoSection.tsx@@ -1,12 +1,15 @@'use client';import { useState } from 'react';+import { useRouter } from 'next/navigation';import { toast } from 'sonner';import { useTranslations } from 'next-intl';import { TeamBillingSection } from '@/cloud';import type { Team } from '@/lib/api/endpoints/teams';+import { cn } from '@/lib/utils';import { formatDate } from '@/utils/dates';-import { useRenameTeam, useTeam } from '@/services/teams.service';+import { teamPath } from '@/utils/paths';+import { useUpdateTeam, useTeam } from '@/services/teams.service';import SectionPageView from '@/components/common/page/SectionPageView';import SettingsCard from '@/components/common/page/SettingsCard';import SettingsSection from '@/components/common/page/SettingsSection';@@ -17,6 +20,7 @@ import { Input } from '@/components/ui/input';import { Label } from '@/components/ui/label';import TeamLeadsSection from './TeamLeadsSection';import TeamLeaveDialog from './TeamLeaveDialog';+import { TEAM_SLUG_PATTERN } from '../../utils/teamSlug';// Leaving is offered only where the API allows it: the last owner has nobody to hand// the team over to, and a membership a provisioned group granted ends at the identity@@ -26,29 +30,39 @@ function canLeave(team: Team): boolean {return !(team.source === 'scim' && team.role === 'member');}-// The team itself: the name its owner edits here, the caller's rank in it, and the-// way out of it. Everything it shows comes with the team list.+// The team itself: the name and the URL slug its owner edits here, the caller's rank+// in it, and the way out of it. Everything it shows comes with the team list.export default function TeamInfoSection({ teamId }: { teamId: number }) {const t = useTranslations('teams.info');const tSection = useTranslations('teams.sections.info');const tManage = useTranslations('teams.manage');const tCommon = useTranslations('common');const team = useTeam(teamId);- const renameTeam = useRenameTeam();+ const router = useRouter();+ const updateTeam = useUpdateTeam();const [draft, setDraft] = useState<string | null>(null);+ const [slugDraft, setSlugDraft] = useState<string | null>(null);const [leaving, setLeaving] = useState(false);if (!team) return <SectionPageSkeleton rows={3} />;const name = draft ?? team.name;+ const slug = slugDraft ?? team.slug ?? '';const isOwner = team.role === 'owner';const trimmed = name.trim();- const canSave = trimmed !== '' && trimmed !== team.name && !renameTeam.isPending;+ const slugValue = slug.trim();+ const slugValid = TEAM_SLUG_PATTERN.test(slugValue);+ const slugError = slugValue !== '' && !slugValid;+ const changed = trimmed !== team.name || slugValue !== team.slug;+ const canSave = trimmed !== '' && slugValid && changed && !updateTeam.isPending;async function save() {- await renameTeam.mutateAsync({ teamId, name: trimmed });+ const updated = await updateTeam.mutateAsync({ teamId, name: trimmed, slug: slugValue });setDraft(null);+ setSlugDraft(null);toast.success(t('saved'));+ // The path names the team by its old slug, which no longer finds it.+ if (updated.ref !== team?.ref) router.replace(teamPath(updated.ref));}return (@@ -67,15 +81,46 @@ export default function TeamInfoSection({ teamId }: { teamId: number }) {<SettingsSection title={t('team')} description={t('teamHint')}><SettingsCard className="space-y-4 p-4">{isOwner ? (- <div className="space-y-1.5">- <Label htmlFor="team-name">{tCommon('name')}</Label>- <Input id="team-name" value={name} onChange={(e) => setDraft(e.target.value)} />- </div>+ <>+ <div className="space-y-1.5">+ <Label htmlFor="team-name">{tCommon('name')}</Label>+ <Input id="team-name" value={name} onChange={(e) => setDraft(e.target.value)} />+ </div>+ <div className="space-y-1.5">+ <Label htmlFor="team-slug">{t('slug')}</Label>+ <Input+ id="team-slug"+ value={slug}+ placeholder="acme"+ dir="ltr"+ aria-invalid={slugError}+ aria-describedby="team-slug-hint"+ onChange={(e) => setSlugDraft(e.target.value.toLowerCase())}+ />+ <p+ id="team-slug-hint"+ className={cn(+ 'text-xs',+ slugError ? 'text-destructive' : 'text-muted-foreground',+ )}+ >+ {slugError ? t('slugInvalid') : t('slugHint')}+ </p>+ </div>+ </>) : (- <div className="flex items-center justify-between gap-4">- <Label>{tCommon('name')}</Label>- <span className="text-sm text-muted-foreground">{team.name}</span>- </div>+ <>+ <div className="flex items-center justify-between gap-4">+ <Label>{tCommon('name')}</Label>+ <span className="text-sm text-muted-foreground">{team.name}</span>+ </div>+ {team.slug && (+ <div className="flex items-center justify-between gap-4">+ <Label>{t('slug')}</Label>+ <span className="text-sm text-muted-foreground">{team.slug}</span>+ </div>+ )}+ </>)}<div className="flex items-center justify-between gap-4"><Label>{t('role')}</Label>diff --git a/apps/web/src/features/teams/components/members/TeamMembersSection.tsx b/apps/web/src/features/teams/components/members/TeamMembersSection.tsxindex d293de4d..171c4a27 100644--- a/apps/web/src/features/teams/components/members/TeamMembersSection.tsx+++ b/apps/web/src/features/teams/components/members/TeamMembersSection.tsx@@ -157,7 +157,8 @@ export default function TeamMembersSection({ teamId }: { teamId: number }) {onRemove={member.agentId == null ? setRemoving : undefined}onOpen={member.agentId != null- ? () => router.push(teamSectionPath(teamId, 'ai-agents'))+ ? () =>+ router.push(teamSectionPath(team?.ref ?? String(teamId), 'ai-agents')): undefined}/>diff --git a/apps/web/src/features/teams/components/projects/TeamProjectDeleteDialog.tsx b/apps/web/src/features/teams/components/projects/TeamProjectDeleteDialog.tsxindex 37c3ad12..7cf4aff8 100644--- a/apps/web/src/features/teams/components/projects/TeamProjectDeleteDialog.tsx+++ b/apps/web/src/features/teams/components/projects/TeamProjectDeleteDialog.tsx@@ -28,7 +28,7 @@ export default function TeamProjectDeleteDialog({confirmDisabled={!matches}onClose={onClose}onConfirm={async () => {- await deleteProject.mutateAsync({ teamId, projectId: project.id, projectKey: project.key });+ await deleteProject.mutateAsync({ teamId, projectId: project.id, projectKey: project.ref });onClose();}}>diff --git a/apps/web/src/features/teams/components/projects/TeamProjectEditModal.tsx b/apps/web/src/features/teams/components/projects/TeamProjectEditModal.tsxindex 1a469ff3..04f43b9e 100644--- a/apps/web/src/features/teams/components/projects/TeamProjectEditModal.tsx+++ b/apps/web/src/features/teams/components/projects/TeamProjectEditModal.tsx@@ -37,7 +37,7 @@ export default function TeamProjectEditModal({{teamId,projectId: project.id,- projectKey: project.key,+ projectKey: project.ref,patch: { name: name.trim(), description: description.trim() },},{ onSuccess: onClose },diff --git a/apps/web/src/features/teams/components/projects/TeamProjectLeaveDialog.tsx b/apps/web/src/features/teams/components/projects/TeamProjectLeaveDialog.tsxindex ca4e3186..e87216b9 100644--- a/apps/web/src/features/teams/components/projects/TeamProjectLeaveDialog.tsx+++ b/apps/web/src/features/teams/components/projects/TeamProjectLeaveDialog.tsx@@ -23,7 +23,7 @@ export default function TeamProjectLeaveDialog({confirmLabel={t('confirm')}onClose={onClose}onConfirm={async () => {- await leaveProject.mutateAsync({ projectKey: project.key, userId });+ await leaveProject.mutateAsync({ projectKey: project.ref, userId });onClose();}}>diff --git a/apps/web/src/features/teams/components/projects/TeamProjectPanel.tsx b/apps/web/src/features/teams/components/projects/TeamProjectPanel.tsxindex 57791a03..2ac4e921 100644--- a/apps/web/src/features/teams/components/projects/TeamProjectPanel.tsx+++ b/apps/web/src/features/teams/components/projects/TeamProjectPanel.tsx@@ -108,7 +108,7 @@ export default function TeamProjectPanel({<TeamProjectMembersteamId={teamId}projectId={project.id}- projectKey={project.key}+ projectKey={project.ref}ownerCount={project.owners.length}viewerId={session?.user.id}projectName={project.name}diff --git a/apps/web/src/features/teams/components/projects/TeamProjectsTable.tsx b/apps/web/src/features/teams/components/projects/TeamProjectsTable.tsxindex 07d28ae9..da04b9c9 100644--- a/apps/web/src/features/teams/components/projects/TeamProjectsTable.tsx+++ b/apps/web/src/features/teams/components/projects/TeamProjectsTable.tsx@@ -122,7 +122,7 @@ export default function TeamProjectsTable({title={t('panel.openProject')}onClick={(e) => e.stopPropagation()}>- <Link href={projectPath(project.key)}>+ <Link href={projectPath(project.ref)}><ArrowUpRight className="size-4" /></Link></Button>diff --git a/apps/web/src/features/teams/hooks/useRouteTeam.ts b/apps/web/src/features/teams/hooks/useRouteTeam.tsnew file mode 100644index 00000000..b2108202--- /dev/null+++ b/apps/web/src/features/teams/hooks/useRouteTeam.ts@@ -0,0 +1,13 @@+import { useParams } from 'next/navigation';+import type { Team } from '@/lib/api/endpoints/teams';+import { useTeamsQuery } from '@/services/teams.service';++// The team the path names (/:teamRef/settings), by its slug or by its id. Null while+// the list loads and for a team the account is not in.+export function useRouteTeam(): Team | null {+ const { teamRef } = useParams<{ teamRef?: string }>();+ const { data } = useTeamsQuery();+ if (!teamRef) return null;+ const ref = decodeURIComponent(teamRef);+ return data?.find((team) => team.ref === ref || String(team.id) === ref) ?? null;+}diff --git a/apps/web/src/features/teams/utils/teamSlug.test.ts b/apps/web/src/features/teams/utils/teamSlug.test.tsnew file mode 100644index 00000000..3fe4f623--- /dev/null+++ b/apps/web/src/features/teams/utils/teamSlug.test.ts@@ -0,0 +1,13 @@+import assert from 'node:assert/strict';+import { describe, it } from 'node:test';+import { TEAM_SLUG_PATTERN, suggestTeamSlug } from './teamSlug';++describe('suggestTeamSlug', () => {+ it('builds a valid slug from a name', () => {+ assert.equal(suggestTeamSlug('Acme Design'), 'acme-design');+ assert.equal(suggestTeamSlug(' 42 -- Ops! '), 'ops');+ assert.equal(suggestTeamSlug('Команда'), 'komanda');+ const long = suggestTeamSlug(`a${'-b'.repeat(30)}`);+ assert.ok(TEAM_SLUG_PATTERN.test(long), long);+ });+});diff --git a/apps/web/src/features/teams/utils/teamSlug.ts b/apps/web/src/features/teams/utils/teamSlug.tsnew file mode 100644index 00000000..36a4cd40--- /dev/null+++ b/apps/web/src/features/teams/utils/teamSlug.ts@@ -0,0 +1,16 @@+import { transliterate } from '@/utils/projectKey';++// Mirrors the API's rule for a slug.+export const TEAM_SLUG_PATTERN = /^[a-z][a-z0-9-]{0,38}[a-z0-9]$/;++// Suggests a slug from the team's name: transliterated, lowercased, every run of other+// characters turned into one dash, cut to start with a letter and to 40 characters+// (e.g. "Команда Ops 2" -> "komanda-ops-2").+export function suggestTeamSlug(name: string): string {+ return transliterate(name)+ .toLowerCase()+ .replace(/[^a-z0-9]+/g, '-')+ .replace(/^[^a-z]+/, '')+ .slice(0, 40)+ .replace(/-+$/, '');+}diff --git a/apps/web/src/features/whats-new/WhatsNew.tsx b/apps/web/src/features/whats-new/WhatsNew.tsxindex da5613b6..4da5c28c 100644--- a/apps/web/src/features/whats-new/WhatsNew.tsx+++ b/apps/web/src/features/whats-new/WhatsNew.tsx@@ -1,19 +1,20 @@'use client';-import { useMarkWhatsNewSeen, useWhatsNewQuery } from './services/whatsNew.service';-import WhatsNewOverlay from './components/WhatsNewOverlay';+import { useWhatsNewQuery } from './services/whatsNew.service';+import WhatsNewOnceOnboarded from './components/WhatsNewOnceOnboarded';// Shows the post-upgrade screen once per release, over whatever page the user// landed on. Mounted for every signed-in page; the query it reads is disabled// without a session, so the sign-in and invite screens ask for nothing.export default function WhatsNew() {const { data } = useWhatsNewQuery();- const markSeen = useMarkWhatsNewSeen();if (!data?.pending) return null;// Nothing to say: a build whose version is missing from the changelog and an// account that sees neither the backup nor the report.if (data.releases.length === 0 && !data.backup && !data.migration) return null;- return <WhatsNewOverlay data={data} onClose={() => markSeen.mutate()} />;+ // Mounted only here, so the project list is read only when the screen has+ // something to show.+ return <WhatsNewOnceOnboarded data={data} />;}diff --git a/apps/web/src/features/whats-new/components/WhatsNewOnceOnboarded.tsx b/apps/web/src/features/whats-new/components/WhatsNewOnceOnboarded.tsxnew file mode 100644index 00000000..91fa60a1--- /dev/null+++ b/apps/web/src/features/whats-new/components/WhatsNewOnceOnboarded.tsx@@ -0,0 +1,18 @@+'use client';++import { usePathname } from 'next/navigation';+import { useProjectsQuery } from '@/services/projects.service';+import type { WhatsNew } from '@/lib/api/endpoints/updates';+import { useMarkWhatsNewSeen } from '../services/whatsNew.service';+import WhatsNewOverlay from './WhatsNewOverlay';++// Waits until the account has a project, so the screen does not cover the first team+// and project being created or an invite being accepted.+export default function WhatsNewOnceOnboarded({ data }: { data: WhatsNew }) {+ const pathname = usePathname();+ const { data: projects } = useProjectsQuery();+ const markSeen = useMarkWhatsNewSeen();++ if (pathname.startsWith('/invite') || !projects?.length) return null;+ return <WhatsNewOverlay data={data} onClose={() => markSeen.mutate()} />;+}diff --git a/apps/web/src/features/work-items/WorkItemsPage.tsx b/apps/web/src/features/work-items/WorkItemsPage.tsxindex 754453fc..9b9ead46 100644--- a/apps/web/src/features/work-items/WorkItemsPage.tsx+++ b/apps/web/src/features/work-items/WorkItemsPage.tsx@@ -53,7 +53,7 @@ export default function WorkItemsPage() {// Live board: refetch the issues when anything on the board changes, so another// user's create/move/edit shows without a manual reload.- const projectKey = project?.project.key ?? '';+ const projectKey = project?.project.ref ?? '';useLiveRefresh({scope: project ? revScope.board(project.project.id) : null,targets: [qk.boardIssues(projectKey)],@@ -166,7 +166,7 @@ export default function WorkItemsPage() {<><ViewTabsviews={views}- projectKey={project.project.key}+ projectKey={project.project.ref}activeViewId={editor.activeViewId}onSelect={editor.selectView}onNewView={editor.beginNewView}diff --git a/apps/web/src/features/work-items/components/calendar/CalendarView.tsx b/apps/web/src/features/work-items/components/calendar/CalendarView.tsxindex 8ee1bd91..88012222 100644--- a/apps/web/src/features/work-items/components/calendar/CalendarView.tsx+++ b/apps/web/src/features/work-items/components/calendar/CalendarView.tsx@@ -33,8 +33,8 @@ export default function CalendarView({readOnly,}: WorkItemsViewProps) {const t = useTranslations('workItems.calendar');- const updateIssue = useUpdateIssue(project.project.key);- const setFieldValue = useSetFieldValue(project.project.key);+ const updateIssue = useUpdateIssue(project.project.ref);+ const setFieldValue = useSetFieldValue(project.project.ref);const [cursor, setCursor] = useState<Date>(() => startOfMonth(new Date()));const [activeId, setActiveId] = useState<number | null>(null);const sensors = useDndSensors(readOnly);diff --git a/apps/web/src/features/work-items/components/kanban/BulkActionBar.tsx b/apps/web/src/features/work-items/components/kanban/BulkActionBar.tsxindex 163ffb44..d6e4072a 100644--- a/apps/web/src/features/work-items/components/kanban/BulkActionBar.tsx+++ b/apps/web/src/features/work-items/components/kanban/BulkActionBar.tsx@@ -38,7 +38,7 @@ export function BulkActionBar({ project }: { project: ProjectDetail }) {// (open) ones only while selection is active, and only while the project shows the// Initiatives section (with none loaded the picker is left out).const initiativesKey =- selection.isSelecting && project.project.initiativesEnabled ? project.project.key : null;+ selection.isSelecting && project.project.initiativesEnabled ? project.project.ref : null;const { data } = useInitiativeOptionsQuery(initiativesKey);const initiatives = data ?? [];@@ -254,7 +254,7 @@ export function BulkActionBar({ project }: { project: ProjectDetail }) {{confirming && (<BulkRemovalDialog- projectKey={project.project.key}+ projectKey={project.project.ref}action={confirming}ids={ids}subtaskCount={subtasks}diff --git a/apps/web/src/features/work-items/hooks/useApplyAssign.ts b/apps/web/src/features/work-items/hooks/useApplyAssign.tsindex e3791593..3bd569aa 100644--- a/apps/web/src/features/work-items/hooks/useApplyAssign.ts+++ b/apps/web/src/features/work-items/hooks/useApplyAssign.ts@@ -9,8 +9,8 @@ import { useSetFieldValue, useUpdateIssue } from '@/services/issues.service';// left alone — rewriting the same value would log another activity entry and start// another run of an agent that reacts to the field.export function useApplyAssign(project: ProjectDetail) {- const updateIssue = useUpdateIssue(project.project.key);- const setFieldValue = useSetFieldValue(project.project.key);+ const updateIssue = useUpdateIssue(project.project.ref);+ const setFieldValue = useSetFieldValue(project.project.ref);return function applyAssign(issueId: number, assign: GroupAssign | null, position: number) {updateIssue.mutate({ id: issueId, patch: { ...assign?.patch, position } });diff --git a/apps/web/src/features/work-items/hooks/useBulkActions.ts b/apps/web/src/features/work-items/hooks/useBulkActions.tsindex 17765273..6e2c1cc7 100644--- a/apps/web/src/features/work-items/hooks/useBulkActions.ts+++ b/apps/web/src/features/work-items/hooks/useBulkActions.ts@@ -11,7 +11,7 @@ import {// endpoints. The bar calls these with the current id set; cache updates and// invalidation live in the mutations.export function useBulkActions(project: ProjectDetail) {- const key = project.project.key;+ const key = project.project.ref;const update = useBulkUpdateIssues(key);const addLabels = useBulkAddLabels(key);const archive = useBulkArchiveIssues(key);diff --git a/apps/web/src/features/work-items/hooks/useTimelineDrag.ts b/apps/web/src/features/work-items/hooks/useTimelineDrag.tsindex b724c98e..efb58e1b 100644--- a/apps/web/src/features/work-items/hooks/useTimelineDrag.ts+++ b/apps/web/src/features/work-items/hooks/useTimelineDrag.ts@@ -31,7 +31,7 @@ export function useTimelineDrag({dayW: number;onOpenIssue: (id: number) => void;}) {- const updateIssue = useUpdateIssue(project.project.key);+ const updateIssue = useUpdateIssue(project.project.ref);const [preview, setPreview] = useState<{ issueId: number; start: Date; end: Date } | null>(null);function beginDrag(e: React.PointerEvent, issue: Issue, mode: TimelineDragMode) {diff --git a/apps/web/src/hooks/useAppCommands.tsx b/apps/web/src/hooks/useAppCommands.tsxindex c60de5b9..da282013 100644--- a/apps/web/src/hooks/useAppCommands.tsx+++ b/apps/web/src/hooks/useAppCommands.tsx@@ -36,7 +36,8 @@ export function useAppCommands({onNewIssue: () => void;onSelectAll: () => void;onNewInitiative: () => void;- onNewProject: () => void;+ // null when the user manages no team, so has nowhere to create a project.+ onNewProject: (() => void) | null;onSelectProject: (key: string) => void;onToggleChat: () => void;}): {@@ -106,24 +107,26 @@ export function useAppCommands({run: onToggleChat,});}- generalItems.push({- id: 'general.new-project',- label: tPalette('newProject'),- icon: <SquarePlus />,- keywords: 'create add',- shortcut: hotkey('project.new') ?? undefined,- run: onNewProject,- });+ if (onNewProject) {+ generalItems.push({+ id: 'general.new-project',+ label: tPalette('newProject'),+ icon: <SquarePlus />,+ keywords: 'create add',+ shortcut: hotkey('project.new') ?? undefined,+ run: onNewProject,+ });+ }const projectItems: Command[] = projects.filter((p) => !p.isHidden).map((p) => ({- id: `project.switch.${p.key}`,+ id: `project.switch.${p.ref}`,label: p.name,icon: <LayoutGrid />,keywords: `switch project ${p.key}`,- checked: p.key === currentProjectKey,- run: () => onSelectProject(p.key),+ checked: p.ref === currentProjectKey,+ run: () => onSelectProject(p.ref),}));return {diff --git a/apps/web/src/hooks/useProjectRouteSync.ts b/apps/web/src/hooks/useProjectRouteSync.tsindex 338394b9..7501f4b8 100644--- a/apps/web/src/hooks/useProjectRouteSync.ts+++ b/apps/web/src/hooks/useProjectRouteSync.ts@@ -1,5 +1,5 @@import { useEffect, useRef } from 'react';-import { useRouter } from 'next/navigation';+import { usePathname, useRouter } from 'next/navigation';import type { Project } from '@/lib/api/endpoints/projects';import { projectPath } from '@/utils/paths';import {@@ -8,9 +8,10 @@ import {} from '@/services/preferences.service';// Keeps the routed project and the account in step: it redirects away from a-// project key that no longer exists, and stores the open project so the index-// route reopens it after the next sign-in, on any device. `projectsLoaded` tells-// an empty list apart from a list that has not arrived yet.+// project that no longer exists, moves a path that names the team by its id to the+// team's slug, and stores the open project so the index route reopens it after the+// next sign-in, on any device. `projectsLoaded` tells an empty list apart from a+// list that has not arrived yet.export function useProjectRouteSync({projects,projectsLoaded,@@ -21,24 +22,31 @@ export function useProjectRouteSync({projectKey: string | null;}) {const router = useRouter();+ const pathname = usePathname();const prefsQuery = useAccountPreferencesQuery();const { mutate: saveLastProject, isPending: savingPrefs } = useUpdateAccountPreferences();- // Redirect to a valid project if the routed key does not exist (a stale link or+ // Redirect to a valid project if the routed one does not exist (a stale link or// a deleted project), preferring the first.useEffect(() => {if (!projectsLoaded) return;- if (projectKey && projects.some((p) => p.key === projectKey)) return;- const first = projects.find((project) => !project.isHidden)?.key;+ if (projectKey && projects.some((p) => p.ref === projectKey)) return;+ const byTeamId = projects.find((p) => `${p.teamId}.${p.key}` === projectKey);+ if (byTeamId) {+ const rest = pathname.split('/').slice(2).join('/');+ router.replace(`/${encodeURIComponent(byTeamId.teamRef)}/${rest}`);+ return;+ }+ const first = projects.find((project) => !project.isHidden)?.ref;if (first) router.replace(projectPath(first));else if (projects.length > 0) router.replace('/');- }, [projectsLoaded, projects, projectKey, router]);+ }, [projectsLoaded, projects, projectKey, pathname, router]);// Written only when it differs from what is stored. A failed save rolls the// cache back, which would satisfy the condition again, so the attempted id is// kept and not retried.const savedLastProjectId = prefsQuery.data?.lastProjectId ?? null;- const openProjectId = projects.find((p) => p.key === projectKey)?.id ?? null;+ const openProjectId = projects.find((p) => p.ref === projectKey)?.id ?? null;const failedLastProjectId = useRef<number | null>(null);useEffect(() => {if (prefsQuery.data == null || openProjectId == null) return;diff --git a/apps/web/src/hooks/useShellRoute.ts b/apps/web/src/hooks/useShellRoute.tsindex c2f48817..409d6fad 100644--- a/apps/web/src/hooks/useShellRoute.ts+++ b/apps/web/src/hooks/useShellRoute.ts@@ -1,13 +1,15 @@import { useParams, usePathname } from 'next/navigation';+import { parseIssueIdentifier, projectRefOf } from '@/utils/paths';export type ShellRoute = {+ // The routed project's ref, "<teamRef>.<key>" — what the API takes as {projectKey}.projectKey: string | null;// The segment after the project key: 'view', 'settings', 'issue', 'members', …// null on the project root.sub: string | null;activeViewId: number | null;section: string | null;- // The /ai-team/:section segment, which the header names (see ShellHeaderTitle).+ // The /agents/:section segment, which the header names (see ShellHeaderTitle).aiTeamSection: string | null;// The project-scoped issue number from the URL, not the internal id.routeIssueSeq: number | null;@@ -17,31 +19,38 @@ export type ShellRoute = {onBoard: boolean;};+const numericSegment = (value: string | undefined) =>+ value && /^\d+$/.test(value) ? Number(value) : null;+// The parts of the current route the Shell renders from. The open view, settings// section and issue live in deeper segments than this layout, so they are read-// from the pathname rather than useParams.+// from the pathname rather than useParams. An issue is routed under its team+// (/acme/issue/MKT-42), so its project comes from the identifier.export function useShellRoute(): ShellRoute {- const params = useParams();+ const params = useParams<{ teamRef?: string; projectKey?: string; identifier?: string }>();const pathname = usePathname();+ const teamRef = params.teamRef ? decodeURIComponent(params.teamRef) : null;- const routeKey = params.projectKey;- const projectKey = (Array.isArray(routeKey) ? routeKey[0] : routeKey) ?? null;+ const issue = params.identifier+ ? parseIssueIdentifier(decodeURIComponent(params.identifier))+ : null;+ const key = issue?.key ?? (params.projectKey ? decodeURIComponent(params.projectKey) : null);+ const projectKey = teamRef && key ? projectRefOf(teamRef, key) : null;- const segs = pathname.split('/').filter(Boolean); // ['project', key, sub?, id?]- const sub = segs[2] ?? null;+ const segs = pathname.split('/').filter(Boolean); // [team, key, sub?, id?, tab?]+ const sub = issue ? 'issue' : (segs[2] ?? null);return {projectKey,sub,- activeViewId: sub === 'view' && segs[3] ? Number(segs[3]) : null,+ activeViewId: sub === 'view' ? numericSegment(segs[3]) : null,section: sub === 'settings' ? (segs[3] ?? null) : null,- aiTeamSection: sub === 'ai-team' ? (segs[3] ?? null) : null,- routeIssueSeq: sub === 'issue' && segs[3] ? Number(segs[3]) : null,- // /initiatives/details/:id — the segment right after 'initiatives' is a list tab.- routeInitiativeId:- sub === 'initiatives' && segs[3] === 'details' && segs[4] ? Number(segs[4]) : null,- // /cycles/details/:id — the segment right after 'cycles' is a list layout.- routeCycleId: sub === 'cycles' && segs[3] === 'details' && segs[4] ? Number(segs[4]) : null,+ aiTeamSection: sub === 'agents' ? (segs[3] ?? null) : null,+ routeIssueSeq: issue?.sequenceNumber ?? null,+ // The segment after 'initiatives' / 'cycles' is a list tab when it is a word+ // and a record when it is a number.+ routeInitiativeId: sub === 'initiatives' ? numericSegment(segs[3]) : null,+ routeCycleId: sub === 'cycles' ? numericSegment(segs[3]) : null,onBoard: sub == null || sub === 'view',};}diff --git a/apps/web/src/lib/api/endpoints/agents.ts b/apps/web/src/lib/api/endpoints/agents.tsindex a6acf5ad..940c42d0 100644--- a/apps/web/src/lib/api/endpoints/agents.ts+++ b/apps/web/src/lib/api/endpoints/agents.ts@@ -17,6 +17,7 @@ export interface AgentFieldTriggerRead extends AgentFieldTrigger {export interface AgentProject {id: number;key: string;+ ref: string;name: string;}diff --git a/apps/web/src/lib/api/endpoints/invites.ts b/apps/web/src/lib/api/endpoints/invites.tsindex fe8a83e7..ebaac3a5 100644--- a/apps/web/src/lib/api/endpoints/invites.ts+++ b/apps/web/src/lib/api/endpoints/invites.ts@@ -40,10 +40,11 @@ export interface InviteEmailResult {}// An invite as shown to the invitee opening the link: enough team and project-// context to decide, never the internal ids.+// context to decide, never the internal project id.export interface InviteView {token: string;teamName: string;+ teamRef: string;projectKey: string | null;projectName: string | null;email: string;@@ -61,6 +62,7 @@ export interface InviteView {// Where an invitee landed once the invite was accepted.export interface AcceptedInvite {teamName: string;+ teamRef: string;projectKey: string | null;projectName: string | null;role: MemberRole | null;diff --git a/apps/web/src/lib/api/endpoints/issues.ts b/apps/web/src/lib/api/endpoints/issues.tsindex ce7ace43..e4634020 100644--- a/apps/web/src/lib/api/endpoints/issues.ts+++ b/apps/web/src/lib/api/endpoints/issues.ts@@ -29,7 +29,7 @@ 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).+ // its human number in URLs (/acme/issue/MKT-42).sequenceNumber: number;identifier: string;typeId: number | null;diff --git a/apps/web/src/lib/api/endpoints/projects.ts b/apps/web/src/lib/api/endpoints/projects.tsindex b40340df..472cbe61 100644--- a/apps/web/src/lib/api/endpoints/projects.ts+++ b/apps/web/src/lib/api/endpoints/projects.ts@@ -15,7 +15,12 @@ export interface Project {id: number;teamId: number;teamName: string;+ // The team's slug, or its id while it has none.+ teamRef: string;key: string;+ // "<teamRef>.<key>": how the API and the app's paths name the project. The key+ // alone is unique only within the team.+ ref: string;name: string;description: string;// Whether the team's MCP reach covers this project, and whether the team is@@ -124,13 +129,6 @@ export const updateProjectPreferences = (projectKey: string, patch: ProjectPrefebody: JSON.stringify(patch),});-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) });diff --git a/apps/web/src/lib/api/endpoints/teams.ts b/apps/web/src/lib/api/endpoints/teams.tsindex 2d104561..7cea270b 100644--- a/apps/web/src/lib/api/endpoints/teams.ts+++ b/apps/web/src/lib/api/endpoints/teams.ts@@ -13,6 +13,10 @@ import {export interface Team {id: number;name: string;+ // The team's segment in the app's paths (/acme/MKT). Null until an owner sets one.+ slug: string | null;+ // The slug, or the id while there is none: what the paths carry.+ ref: 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;@@ -62,6 +66,8 @@ export interface TeamMember {export interface TeamProject {id: number;key: string;+ // "<teamRef>.<key>", see Project.ref.+ ref: string;name: string;description: string;// Whether the team's MCP reach covers this project. Only counts while the team's@@ -83,6 +89,7 @@ export interface TeamProjectListParams extends PageParams {export interface TeamProjectOption {id: number;key: string;+ ref: string;name: string;mcpEnabled: boolean;}@@ -199,10 +206,10 @@ export const listTeamProjectMembers = (`/teams/${teamId}/projects/${projectId}/members${memberListQuery(params)}`,);-export const createTeam = (input: { name: string }) =>+export const createTeam = (input: { name: string; slug: string }) =>request<Team>('/teams', { method: 'POST', body: JSON.stringify(input) });-export const renameTeam = (teamId: number, input: { name: string }) =>+export const updateTeam = (teamId: number, input: { name?: string; slug?: string }) =>request<Team>(`/teams/${teamId}`, { method: 'PATCH', body: JSON.stringify(input) });export const leaveTeam = (teamId: number) =>diff --git a/apps/web/src/services/projects.service.ts b/apps/web/src/services/projects.service.tsindex 9cc416a7..68215e30 100644--- a/apps/web/src/services/projects.service.ts+++ b/apps/web/src/services/projects.service.ts@@ -13,7 +13,6 @@ import {listProjects,getProject,getBoardIssues,- createProject,updateProject,updateProjectPreferences,} from '@/lib/api/endpoints/projects';@@ -31,7 +30,7 @@ export function useUpdateProjectPreferences() {onSuccess: (preferences, { projectKey }) => {qc.setQueryData<Project[]>(qk.projects, (projects) =>projects?.map((project) =>- project.key === projectKey ? { ...project, ...preferences } : project,+ project.ref === projectKey ? { ...project, ...preferences } : project,),);void qc.invalidateQueries({ queryKey: qk.projects });@@ -77,9 +76,8 @@ export function useInvalidateProject(projectKey: string | null) {};}-// Creates a project, in a given team or — without one — in the team the caller owns.-// `copyFromId` copies that project's structure instead of starting from a preset; the-// source belongs to the same team.+// Creates a project in a team. `copyFromId` copies that project's structure instead of+// starting from a preset; the source belongs to the same team.export function useCreateProject() {const qc = useQueryClient();return useMutation({@@ -88,7 +86,7 @@ export function useCreateProject() {copyFromId,input,}: {- teamId?: number;+ teamId: number;copyFromId?: number;input: {key: string;@@ -97,12 +95,10 @@ export function useCreateProject() {include?: Partial<Record<CopyProjectIncludeKey, boolean>>;preset?: string;};- }) => {- if (teamId == null) return createProject(input);- return copyFromId == null+ }) =>+ copyFromId == null? createTeamProject(teamId, input)- : copyTeamProject(teamId, copyFromId, input);- },+ : copyTeamProject(teamId, copyFromId, input),onSuccess: (project) => {// Add the new project to the cached list immediately so navigating to it// (onCreated → setProjectKey) sticks. Otherwise the list has not refetched@@ -134,7 +130,7 @@ export function useUpdateProject() {// spreading the whole object would wipe the caller's role in the list item.qc.setQueryData<Project[]>(qk.projects, (prev) =>prev?.map((p) =>- p.key === projectKey ? { ...p, name: updated.name, description: updated.description } : p,+ p.ref === projectKey ? { ...p, name: updated.name, description: updated.description } : p,),);void qc.invalidateQueries({ queryKey: qk.projects });@@ -161,7 +157,7 @@ export function useUpdateTeamProject() {onSuccess: (updated, { teamId, projectKey }) => {qc.setQueryData<Project[]>(qk.projects, (prev) =>prev?.map((p) =>- p.key === projectKey ? { ...p, name: updated.name, description: updated.description } : p,+ p.ref === projectKey ? { ...p, name: updated.name, description: updated.description } : p,),);void qc.invalidateQueries({ queryKey: qk.projects });@@ -175,7 +171,7 @@ export function useUpdateTeamProject() {// before the refetch resolves) and discards its now-dead per-project caches so it// cannot be reopened with stale data. Then refetches the list to reconcile.function forgetProject(qc: ReturnType<typeof useQueryClient>, projectKey: string) {- qc.setQueryData<Project[]>(qk.projects, (prev) => prev?.filter((p) => p.key !== projectKey));+ qc.setQueryData<Project[]>(qk.projects, (prev) => prev?.filter((p) => p.ref !== projectKey));qc.removeQueries({ queryKey: qk.project(projectKey) });qc.removeQueries({ queryKey: qk.boardIssues(projectKey) });qc.removeQueries({ queryKey: qk.views(projectKey) });diff --git a/apps/web/src/services/teams.service.ts b/apps/web/src/services/teams.service.tsindex 7ee66b12..1478a75b 100644--- a/apps/web/src/services/teams.service.ts+++ b/apps/web/src/services/teams.service.ts@@ -27,7 +27,7 @@ import {getTeamProjectDefaults,updateTeamProjectDefaults,createTeam,- renameTeam,+ updateTeam,setTeamMemberRole,removeTeamMember,leaveTeam,@@ -155,7 +155,7 @@ export function useUpdateTeamProjectDefaults(teamId: number) {export function useCreateTeam() {const qc = useQueryClient();return useMutation({- mutationFn: (input: { name: string }) => createTeam(input),+ mutationFn: (input: { name: string; slug: 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.@@ -165,15 +165,21 @@ export function useCreateTeam() {});}-export function useRenameTeam() {+export function useUpdateTeam() {const qc = useQueryClient();return useMutation({- mutationFn: (input: { teamId: number; name: string }) =>- renameTeam(input.teamId, { name: input.name }),+ mutationFn: (input: { teamId: number; name?: string; slug?: string }) =>+ updateTeam(input.teamId, { name: input.name, slug: input.slug }),onSuccess: (team) => {+ // The caller moves to the new slug right away; a list still holding the old one+ // would not find the team on that path.+ qc.setQueryData<Team[]>(qk.teams, (prev) =>+ prev?.map((entry) => (entry.id === team.id ? team : entry)),+ );void qc.invalidateQueries({ queryKey: qk.teams });void qc.invalidateQueries({ queryKey: qk.team(team.id) });- // The switcher groups projects by team name, so the project list carries it too.+ // The project list carries the team's name, which the switcher groups by, and+ // its ref, which every project path starts with.void qc.invalidateQueries({ queryKey: qk.projects });},});diff --git a/apps/web/src/utils/paths.ts b/apps/web/src/utils/paths.tsindex 00b06a43..4b5c8854 100644--- a/apps/web/src/utils/paths.ts+++ b/apps/web/src/utils/paths.ts@@ -1,14 +1,28 @@// 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.+// see the app/[teamRef] route tree.+//+// A project is addressed by its ref, "<teamRef>.<key>" (Project.ref), which is also+// what the API takes wherever a route names {projectKey}. The team's slug starts with+// a letter and carries no dot, so the first dot splits the two.import type { StartPage } from '@/lib/api/endpoints/userPreferences';-export const projectPath = (key: string) => `/project/${encodeURIComponent(key)}`;+export function splitProjectRef(ref: string): { teamRef: string; key: string } {+ const dot = ref.indexOf('.');+ return { teamRef: ref.slice(0, dot), key: ref.slice(dot + 1) };+}-export const viewPath = (key: string, viewId: number | null) =>- viewId != null ? `${projectPath(key)}/view/${viewId}` : projectPath(key);+export const projectRefOf = (teamRef: string, key: string) => `${teamRef}.${key}`;-export const dashboardsPath = (key: string) => `${projectPath(key)}/dashboard`;+export const projectPath = (ref: string) => {+ const { teamRef, key } = splitProjectRef(ref);+ return `/${encodeURIComponent(teamRef)}/${encodeURIComponent(key)}`;+};++export const viewPath = (ref: string, viewId: number | null) =>+ viewId != null ? `${projectPath(ref)}/view/${viewId}` : projectPath(ref);++export const dashboardsPath = (ref: string) => `${projectPath(ref)}/dashboards`;// Public read-only share pages (no auth). The token is the unguessable share key.export const shareIssuePath = (token: string) => `/share/issue/${token}`;@@ -18,45 +32,54 @@ export const shareViewPath = (token: string) => `/share/view/${token}`;export const shareUrl = (path: string) =>typeof window === 'undefined' ? path : `${window.location.origin}${path}`;-export const dashboardPath = (key: string, dashboardId: number) =>- `${dashboardsPath(key)}/${dashboardId}`;+export const dashboardPath = (ref: string, dashboardId: number) =>+ `${dashboardsPath(ref)}/${dashboardId}`;-export const notesPath = (key: string) => `${projectPath(key)}/notes`;+export const notesPath = (ref: string) => `${projectPath(ref)}/notes`;-export const notePath = (key: string, boardId: number) => `${notesPath(key)}/${boardId}`;+export const notePath = (ref: string, boardId: number) => `${notesPath(ref)}/${boardId}`;-export const documentsPath = (key: string) => `${projectPath(key)}/docs`;+export const documentsPath = (ref: string) => `${projectPath(ref)}/docs`;-export const documentPath = (key: string, documentId: number) =>- `${documentsPath(key)}/${documentId}`;+export const documentPath = (ref: string, documentId: number) =>+ `${documentsPath(ref)}/${documentId}`;-export const settingsPath = (key: string, section: string) =>- `${projectPath(key)}/settings/${section}`;+export const settingsPath = (ref: string, section: string) =>+ `${projectPath(ref)}/settings/${section}`;// The AI Team destinations listed in the main sidebar (see AI_TEAM_SECTIONS).-export const aiTeamPath = (key: string, section: string) =>- `${projectPath(key)}/ai-team/${section}`;+export const aiTeamPath = (ref: string, section: string) => `${projectPath(ref)}/agents/${section}`;-export const inboxPath = (key: string) => `${projectPath(key)}/inbox`;+export const inboxPath = (ref: string) => `${projectPath(ref)}/inbox`;// The member's own notification preferences (which events, by which channel, their// Telegram chat id). A main-nav Configuration destination, open to any member.-export const notificationsPath = (key: string) => `${projectPath(key)}/notifications`;+export const notificationsPath = (ref: string) => `${projectPath(ref)}/notifications`;-export const aiAgentsPath = (key: string) => `${projectPath(key)}/ai-agents`;+export const aiAgentsPath = (ref: string) => `${projectPath(ref)}/agents`;-export const mcpServerPath = (key: string) => `${projectPath(key)}/mcp`;+export const mcpServerPath = (ref: string) => `${projectPath(ref)}/mcp`;-export const apiDocsPath = (key: string) => `${projectPath(key)}/api`;+export const apiDocsPath = (ref: string) => `${projectPath(ref)}/api`;-export const membersPath = (key: string) => `${projectPath(key)}/members`;+export const membersPath = (ref: string) => `${projectPath(ref)}/members`;++// An issue is addressed by its identifier under its team, not under its project:+// /acme/issue/MKT-42.+export const issuePath = (ref: string, sequenceNumber: number) => {+ const { teamRef, key } = splitProjectRef(ref);+ return `/${encodeURIComponent(teamRef)}/issue/${encodeURIComponent(key)}-${sequenceNumber}`;+};-// Issues are addressed in the URL by their project-scoped number (the "42" in-// "MKT-42"), not the internal database id: /project/MKT/issue/42.-export const issuePath = (key: string, sequenceNumber: number) =>- `${projectPath(key)}/issue/${sequenceNumber}`;+// "MKT-42" -> { key: 'MKT', sequenceNumber: 42 }, or null for anything else.+export function parseIssueIdentifier(+ identifier: string,+): { key: string; sequenceNumber: number } | null {+ const match = /^([A-Za-z][A-Za-z0-9]*)-(\d+)$/.exec(identifier);+ return match ? { key: match[1], sequenceNumber: Number(match[2]) } : null;+}-export const initiativesPath = (key: string) => `${projectPath(key)}/initiatives`;+export const initiativesPath = (ref: string) => `${projectPath(ref)}/initiatives`;// Every status tab of the initiatives list is a route of its own, "All" included,// so a reload or a shared link reopens the tab the user was on. The list path@@ -69,23 +92,23 @@ export type InitiativesTab = (typeof INITIATIVES_TABS)[number];export const isInitiativesTab = (value: string): value is InitiativesTab =>(INITIATIVES_TABS as readonly string[]).includes(value);-export const initiativesTabPath = (key: string, tab: InitiativesTab) =>- `${initiativesPath(key)}/${tab}`;+export const initiativesTabPath = (ref: string, tab: InitiativesTab) =>+ `${initiativesPath(ref)}/${tab}`;-// The initiative detail tabs are routes of their own too. They sit under /details/-// so the tab segment of the list above stays unambiguous.+// The initiative detail tabs are routes of their own too. A list tab is a word and an+// initiative is a number, so both sit directly under /initiatives.export type InitiativeTab = 'overview' | 'progress' | 'issues';export const initiativePath = (- key: string,+ ref: string,initiativeId: number,tab: InitiativeTab = 'overview',) => {- const base = `${initiativesPath(key)}/details/${initiativeId}`;+ const base = `${initiativesPath(ref)}/${initiativeId}`;return tab === 'overview' ? base : `${base}/${tab}`;};-export const cyclesPath = (key: string) => `${projectPath(key)}/cycles`;+export const cyclesPath = (ref: string) => `${projectPath(ref)}/cycles`;// Each layout of the cycles list is a route of its own, so a reload or a shared// link reopens the one the user was on. The list path itself holds no layout: it@@ -97,30 +120,28 @@ export type CyclesView = (typeof CYCLES_VIEWS)[number];export const isCyclesView = (value: string): value is CyclesView =>(CYCLES_VIEWS as readonly string[]).includes(value);-export const cyclesViewPath = (key: string, view: CyclesView) => `${cyclesPath(key)}/${view}`;+export const cyclesViewPath = (ref: string, view: CyclesView) => `${cyclesPath(ref)}/${view}`;-// The cycle detail sits under /details/ so the layout segment of the list above-// stays unambiguous.-export const cyclePath = (key: string, cycleId: number) => `${cyclesPath(key)}/details/${cycleId}`;+// A layout is a word and a cycle is a number, so both sit directly under /cycles.+export const cyclePath = (ref: string, cycleId: number) => `${cyclesPath(ref)}/${cycleId}`;// Where the app root sends the user, from their start page preference. The section// opens in the project they were last in (see app/page.tsx).-export const startPagePath = (key: string, startPage: StartPage) => {+export const startPagePath = (ref: string, startPage: StartPage) => {switch (startPage) {case 'inbox':- return inboxPath(key);+ return inboxPath(ref);case 'dashboard':- return dashboardsPath(key);+ return dashboardsPath(ref);case 'initiatives':- return initiativesPath(key);+ return initiativesPath(ref);default:- return projectPath(key);+ return projectPath(ref);}};-// The standalone Manage teams page, reached from the project switcher. Lists the-// teams the user belongs to and opens one beside the list; with no team in the URL-// it redirects to the first of them.+// The standalone Manage teams page, reached from the project switcher. With no team+// in the URL it opens the first team's settings.export const manageTeamsPath = () => '/account/teams';// Every section of a team is a route of its own, so each loads only what it shows.@@ -138,10 +159,11 @@ export type TeamSection =| 'agent-tools'| 'notifications';-export const teamPath = (teamId: number) => `${manageTeamsPath()}/${teamId}`;+// A team's settings, under the team's ref (Team.ref): /acme/settings.+export const teamPath = (teamRef: string) => `/${encodeURIComponent(teamRef)}/settings`;-export const teamSectionPath = (teamId: number, section: TeamSection) =>- section === 'info' ? teamPath(teamId) : `${teamPath(teamId)}/${section}`;+export const teamSectionPath = (teamRef: string, section: TeamSection) =>+ section === 'info' ? teamPath(teamRef) : `${teamPath(teamRef)}/${section}`;// The invitee-facing link an owner shares. Points at this web app's public// /invite/:token page, which reads the token and shows the accept screen.diff --git a/apps/web/src/utils/projectKey.ts b/apps/web/src/utils/projectKey.tsindex 3c02361b..b3bb276d 100644--- a/apps/web/src/utils/projectKey.ts+++ b/apps/web/src/utils/projectKey.ts@@ -51,7 +51,7 @@ export function transliterate(input: string): string {// several words become their initials (e.g. "Marketing Team" → "MT"), a single// word becomes its first few letters (e.g. "Marketing" → "MARK"). Non-Latin// scripts are transliterated, only letters and digits are kept, and the result-// is uppercased.+// is uppercased and starts with a letter.export function suggestKey(name: string): string {const words = transliterate(name).toUpperCase()@@ -60,14 +60,15 @@ export function suggestKey(name: string): string {.filter(Boolean);if (words.length === 0) return '';const raw = words.length === 1 ? words[0].slice(0, 4) : words.map((w) => w[0]).join('');- return raw.slice(0, KEY_MAX_LENGTH);+ return raw.replace(/^\d+/, '').slice(0, KEY_MAX_LENGTH);}// Normalizes what the user typed into the key field: transliterated, uppercase,-// letters and digits only, capped at the maximum length.+// letters and digits only, starting with a letter, capped at the maximum length.export function normalizeKey(input: string): string {return transliterate(input).toUpperCase().replace(/[^A-Z0-9]/g, '')+ .replace(/^\d+/, '').slice(0, KEY_MAX_LENGTH);}diff --git a/apps/web/src/utils/settingsSections.ts b/apps/web/src/utils/settingsSections.tsindex cf859380..909a902d 100644--- a/apps/web/src/utils/settingsSections.ts+++ b/apps/web/src/utils/settingsSections.ts@@ -23,8 +23,8 @@ import type { PermissionAction, PermissionResource } from '@/lib/api/endpoints/rexport type SettingsGroup = 'general' | 'configuration' | 'automation' | 'ai' | 'ai-team';// The project settings sections, each mounted as its own page at-// /project/:projectKey/settings/:section, except the 'ai-team' group, which is-// mounted at /project/:projectKey/ai-team/:section. The slug is the route param; the tab+// /:team/:projectKey/settings/:section, except the 'ai-team' group, which is+// mounted at /:team/:projectKey/agents/:section. The slug is the route param; the tab// components live in features/settings/components and take { project }. `resource`// is the permission resource that gates the section: `viewAction` (read unless set)// to view it, and the create/edit/delete actions gate the controls inside. `group` places it in thediff --git a/packages/auth/src/index.ts b/packages/auth/src/index.tsindex 75b8cd50..5bc8e54e 100644--- a/packages/auth/src/index.ts+++ b/packages/auth/src/index.ts@@ -1,5 +1,5 @@import { randomInt } from 'node:crypto';-import { db, defaultMemberPermissions } from '@repo/db';+import { db } from '@repo/db';import { eq, sql, type SQL } from 'drizzle-orm';import { betterAuth } from 'better-auth';import { createAuthMiddleware, APIError } from 'better-auth/api';@@ -512,28 +512,6 @@ export const auth = betterAuth({},};},- // A project belongs to a team, so an account owns one from the moment it is- // created, named after the username the hook above settled on. The team is- // also where the roles its projects assign live, so it starts with the- // default one.- after: async (created) => {- const handle = typeof created.username === 'string' ? created.username : created.name;- await db.transaction(async (tx) => {- const [row] = await tx- .insert(schema.team)- .values({ name: handle })- .returning({ id: schema.team.id });- await tx- .insert(schema.teamMember)- .values({ teamId: row.id, userId: created.id, role: 'owner' });- await tx.insert(schema.teamRole).values({- teamId: row.id,- name: 'Member',- isDefault: true,- permissions: defaultMemberPermissions(),- });- });- },},},session: {diff --git a/packages/db/AGENTS.md b/packages/db/AGENTS.mdindex 67045254..0a7eefc7 100644--- a/packages/db/AGENTS.md+++ b/packages/db/AGENTS.md@@ -11,8 +11,7 @@ See root `AGENTS.md` for monorepo-wide rules.- `src/schema/app.ts` — hand-written application tables. Add domain tables here.- `src/schema/index.ts` — re-exports every table; `drizzle.config.ts` points at it.- `src/permissions.ts` — the permission matrix stored in `team_role.permissions`: the- resource/action catalog, the default member role, and the normalizer. It lives here- because the API and the sign-up hook in `@repo/auth` both write it.+ resource/action catalog, the default member role, and the normalizer.- `src/settings.ts` / `src/secrets.ts` — the two instance config stores: `app_setting`in plaintext jsonb, `app_secret` encrypted with `APP_ENCRYPTION_KEY`. Both are readby more than one app, which is why they are here.diff --git a/packages/db/drizzle/0134_team_scoped_project_key.sql b/packages/db/drizzle/0134_team_scoped_project_key.sqlnew file mode 100644index 00000000..8a1cb71a--- /dev/null+++ b/packages/db/drizzle/0134_team_scoped_project_key.sql@@ -0,0 +1,4 @@+ALTER TABLE "project" DROP CONSTRAINT "project_key_unique";--> statement-breakpoint+ALTER TABLE "team" ADD COLUMN "slug" text;--> statement-breakpoint+ALTER TABLE "project" ADD CONSTRAINT "project_team_key_uq" UNIQUE("team_id","key");--> statement-breakpoint+ALTER TABLE "team" ADD CONSTRAINT "team_slug_unique" UNIQUE("slug");\ No newline at end of filediff --git a/packages/db/drizzle/meta/0134_snapshot.json b/packages/db/drizzle/meta/0134_snapshot.jsonnew file mode 100644index 00000000..796040f0--- /dev/null+++ b/packages/db/drizzle/meta/0134_snapshot.json@@ -0,0 +1,10981 @@+{+ "id": "70e53828-5afe-403b-b2a8-3c164ec33826",+ "prevId": "9aa14090-7850-4056-88e9-c9ebb88ea6a0",+ "version": "7",+ "dialect": "postgresql",+ "tables": {+ "public.account": {+ "name": "account",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "account_id": {+ "name": "account_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "provider_id": {+ "name": "provider_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "access_token": {+ "name": "access_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "refresh_token": {+ "name": "refresh_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "id_token": {+ "name": "id_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "access_token_expires_at": {+ "name": "access_token_expires_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "refresh_token_expires_at": {+ "name": "refresh_token_expires_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "scope": {+ "name": "scope",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "password": {+ "name": "password",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "account_userId_idx": {+ "name": "account_userId_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "account_user_id_user_id_fk": {+ "name": "account_user_id_user_id_fk",+ "tableFrom": "account",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.apikey": {+ "name": "apikey",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "config_id": {+ "name": "config_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'default'"+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "start": {+ "name": "start",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "reference_id": {+ "name": "reference_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "prefix": {+ "name": "prefix",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "key": {+ "name": "key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "refill_interval": {+ "name": "refill_interval",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "refill_amount": {+ "name": "refill_amount",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "last_refill_at": {+ "name": "last_refill_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "enabled": {+ "name": "enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": true+ },+ "rate_limit_enabled": {+ "name": "rate_limit_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": true+ },+ "rate_limit_time_window": {+ "name": "rate_limit_time_window",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "default": 1000+ },+ "rate_limit_max": {+ "name": "rate_limit_max",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "default": 100+ },+ "request_count": {+ "name": "request_count",+ "type": "integer",+ "primaryKey": false,+ "notNull": false,+ "default": 0+ },+ "remaining": {+ "name": "remaining",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "last_request": {+ "name": "last_request",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ },+ "permissions": {+ "name": "permissions",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "apikey_configId_idx": {+ "name": "apikey_configId_idx",+ "columns": [+ {+ "expression": "config_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "apikey_referenceId_idx": {+ "name": "apikey_referenceId_idx",+ "columns": [+ {+ "expression": "reference_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "apikey_key_idx": {+ "name": "apikey_key_idx",+ "columns": [+ {+ "expression": "key",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.oauth_access_token": {+ "name": "oauth_access_token",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "access_token": {+ "name": "access_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "refresh_token": {+ "name": "refresh_token",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "access_token_expires_at": {+ "name": "access_token_expires_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "refresh_token_expires_at": {+ "name": "refresh_token_expires_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "scopes": {+ "name": "scopes",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "oauthAccessToken_clientId_idx": {+ "name": "oauthAccessToken_clientId_idx",+ "columns": [+ {+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "oauthAccessToken_userId_idx": {+ "name": "oauthAccessToken_userId_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "oauth_access_token_client_id_oauth_application_client_id_fk": {+ "name": "oauth_access_token_client_id_oauth_application_client_id_fk",+ "tableFrom": "oauth_access_token",+ "tableTo": "oauth_application",+ "columnsFrom": [+ "client_id"+ ],+ "columnsTo": [+ "client_id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "oauth_access_token_user_id_user_id_fk": {+ "name": "oauth_access_token_user_id_user_id_fk",+ "tableFrom": "oauth_access_token",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "oauth_access_token_access_token_unique": {+ "name": "oauth_access_token_access_token_unique",+ "nullsNotDistinct": false,+ "columns": [+ "access_token"+ ]+ },+ "oauth_access_token_refresh_token_unique": {+ "name": "oauth_access_token_refresh_token_unique",+ "nullsNotDistinct": false,+ "columns": [+ "refresh_token"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.oauth_application": {+ "name": "oauth_application",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "icon": {+ "name": "icon",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "client_secret": {+ "name": "client_secret",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "redirect_urls": {+ "name": "redirect_urls",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "disabled": {+ "name": "disabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "oauthApplication_userId_idx": {+ "name": "oauthApplication_userId_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "oauth_application_user_id_user_id_fk": {+ "name": "oauth_application_user_id_user_id_fk",+ "tableFrom": "oauth_application",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "oauth_application_client_id_unique": {+ "name": "oauth_application_client_id_unique",+ "nullsNotDistinct": false,+ "columns": [+ "client_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.oauth_consent": {+ "name": "oauth_consent",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "scopes": {+ "name": "scopes",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "consent_given": {+ "name": "consent_given",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "oauthConsent_clientId_idx": {+ "name": "oauthConsent_clientId_idx",+ "columns": [+ {+ "expression": "client_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "oauthConsent_userId_idx": {+ "name": "oauthConsent_userId_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "oauth_consent_client_id_oauth_application_client_id_fk": {+ "name": "oauth_consent_client_id_oauth_application_client_id_fk",+ "tableFrom": "oauth_consent",+ "tableTo": "oauth_application",+ "columnsFrom": [+ "client_id"+ ],+ "columnsTo": [+ "client_id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "oauth_consent_user_id_user_id_fk": {+ "name": "oauth_consent_user_id_user_id_fk",+ "tableFrom": "oauth_consent",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.passkey": {+ "name": "passkey",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "public_key": {+ "name": "public_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "credential_id": {+ "name": "credential_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "counter": {+ "name": "counter",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "device_type": {+ "name": "device_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "backed_up": {+ "name": "backed_up",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true+ },+ "transports": {+ "name": "transports",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": false+ },+ "aaguid": {+ "name": "aaguid",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "passkey_userId_idx": {+ "name": "passkey_userId_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "passkey_credentialID_idx": {+ "name": "passkey_credentialID_idx",+ "columns": [+ {+ "expression": "credential_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "passkey_user_id_user_id_fk": {+ "name": "passkey_user_id_user_id_fk",+ "tableFrom": "passkey",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.session": {+ "name": "session",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ },+ "token": {+ "name": "token",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ },+ "ip_address": {+ "name": "ip_address",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_agent": {+ "name": "user_agent",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "session_userId_idx": {+ "name": "session_userId_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "session_user_id_user_id_fk": {+ "name": "session_user_id_user_id_fk",+ "tableFrom": "session",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "session_token_unique": {+ "name": "session_token_unique",+ "nullsNotDistinct": false,+ "columns": [+ "token"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.user": {+ "name": "user",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "email": {+ "name": "email",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "email_verified": {+ "name": "email_verified",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "image": {+ "name": "image",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "username": {+ "name": "username",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "display_username": {+ "name": "display_username",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "default": "'user'"+ },+ "active": {+ "name": "active",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false,+ "default": true+ },+ "scim_external_id": {+ "name": "scim_external_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "user_email_unique": {+ "name": "user_email_unique",+ "nullsNotDistinct": false,+ "columns": [+ "email"+ ]+ },+ "user_username_unique": {+ "name": "user_username_unique",+ "nullsNotDistinct": false,+ "columns": [+ "username"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.verification": {+ "name": "verification",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "identifier": {+ "name": "identifier",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "value": {+ "name": "value",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "expires_at": {+ "name": "expires_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "verification_identifier_idx": {+ "name": "verification_identifier_idx",+ "columns": [+ {+ "expression": "identifier",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_chat_event": {+ "name": "agent_chat_event",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "bigserial",+ "primaryKey": true,+ "notNull": true+ },+ "message_id": {+ "name": "message_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "payload": {+ "name": "payload",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_chat_event_message_idx": {+ "name": "agent_chat_event_message_idx",+ "columns": [+ {+ "expression": "message_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_chat_event_message_id_agent_chat_message_id_fk": {+ "name": "agent_chat_event_message_id_agent_chat_message_id_fk",+ "tableFrom": "agent_chat_event",+ "tableTo": "agent_chat_message",+ "columnsFrom": [+ "message_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_chat_favorite": {+ "name": "agent_chat_favorite",+ "schema": "",+ "columns": {+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "thread_id": {+ "name": "thread_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {},+ "foreignKeys": {+ "agent_chat_favorite_user_id_user_id_fk": {+ "name": "agent_chat_favorite_user_id_user_id_fk",+ "tableFrom": "agent_chat_favorite",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_chat_favorite_agent_id_ai_agent_id_fk": {+ "name": "agent_chat_favorite_agent_id_ai_agent_id_fk",+ "tableFrom": "agent_chat_favorite",+ "tableTo": "ai_agent",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "agent_chat_favorite_user_id_thread_id_pk": {+ "name": "agent_chat_favorite_user_id_thread_id_pk",+ "columns": [+ "user_id",+ "thread_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_chat_message": {+ "name": "agent_chat_message",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "thread_id": {+ "name": "thread_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "attempts": {+ "name": "attempts",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "next_attempt_at": {+ "name": "next_attempt_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "last_error": {+ "name": "last_error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "started_at": {+ "name": "started_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "finished_at": {+ "name": "finished_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_chat_message_thread_idx": {+ "name": "agent_chat_message_thread_idx",+ "columns": [+ {+ "expression": "thread_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_chat_message_due_idx": {+ "name": "agent_chat_message_due_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "next_attempt_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"agent_chat_message\".\"status\" IN ('pending', 'streaming')",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_chat_message_thread_id_agent_chat_thread_id_fk": {+ "name": "agent_chat_message_thread_id_agent_chat_thread_id_fk",+ "tableFrom": "agent_chat_message",+ "tableTo": "agent_chat_thread",+ "columnsFrom": [+ "thread_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_chat_message_agent_id_ai_agent_id_fk": {+ "name": "agent_chat_message_agent_id_ai_agent_id_fk",+ "tableFrom": "agent_chat_message",+ "tableTo": "ai_agent",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "agent_chat_message_role_check": {+ "name": "agent_chat_message_role_check",+ "value": "\"agent_chat_message\".\"role\" IN ('user', 'assistant')"+ },+ "agent_chat_message_status_check": {+ "name": "agent_chat_message_status_check",+ "value": "\"agent_chat_message\".\"status\" IN ('pending', 'streaming', 'success', 'failed', 'canceled')"+ }+ },+ "isRLSEnabled": false+ },+ "public.agent_chat_thread": {+ "name": "agent_chat_thread",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "cli_session_id": {+ "name": "cli_session_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_chat_thread_agent_user_idx": {+ "name": "agent_chat_thread_agent_user_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "updated_at",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_chat_thread_agent_id_ai_agent_id_fk": {+ "name": "agent_chat_thread_agent_id_ai_agent_id_fk",+ "tableFrom": "agent_chat_thread",+ "tableTo": "ai_agent",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_chat_thread_user_id_user_id_fk": {+ "name": "agent_chat_thread_user_id_user_id_fk",+ "tableFrom": "agent_chat_thread",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_chat_usage": {+ "name": "agent_chat_usage",+ "schema": "",+ "columns": {+ "thread_id": {+ "name": "thread_id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "input_tokens": {+ "name": "input_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "output_tokens": {+ "name": "output_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_chat_usage_agent_idx": {+ "name": "agent_chat_usage_agent_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_chat_usage_agent_id_ai_agent_id_fk": {+ "name": "agent_chat_usage_agent_id_ai_agent_id_fk",+ "tableFrom": "agent_chat_usage",+ "tableTo": "ai_agent",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_field_trigger": {+ "name": "agent_field_trigger",+ "schema": "",+ "columns": {+ "agent_id": {+ "name": "agent_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "field_id": {+ "name": "field_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "delay_sec": {+ "name": "delay_sec",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 120+ }+ },+ "indexes": {+ "agent_field_trigger_field_idx": {+ "name": "agent_field_trigger_field_idx",+ "columns": [+ {+ "expression": "field_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_field_trigger_agent_id_ai_agent_id_fk": {+ "name": "agent_field_trigger_agent_id_ai_agent_id_fk",+ "tableFrom": "agent_field_trigger",+ "tableTo": "ai_agent",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_field_trigger_field_id_custom_field_id_fk": {+ "name": "agent_field_trigger_field_id_custom_field_id_fk",+ "tableFrom": "agent_field_trigger",+ "tableTo": "custom_field",+ "columnsFrom": [+ "field_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "agent_field_trigger_agent_id_field_id_pk": {+ "name": "agent_field_trigger_agent_id_field_id_pk",+ "columns": [+ "agent_id",+ "field_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "agent_field_trigger_delay_check": {+ "name": "agent_field_trigger_delay_check",+ "value": "\"agent_field_trigger\".\"delay_sec\" >= 0 AND \"agent_field_trigger\".\"delay_sec\" <= 86400"+ }+ },+ "isRLSEnabled": false+ },+ "public.agent_run": {+ "name": "agent_run",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "schedule_id": {+ "name": "schedule_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "trigger": {+ "name": "trigger",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'delegation'"+ },+ "scheduled_for": {+ "name": "scheduled_for",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "source_activity_id": {+ "name": "source_activity_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "prompt": {+ "name": "prompt",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "attempts": {+ "name": "attempts",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "next_attempt_at": {+ "name": "next_attempt_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "last_error": {+ "name": "last_error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "output": {+ "name": "output",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "input_tokens": {+ "name": "input_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "output_tokens": {+ "name": "output_tokens",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "started_at": {+ "name": "started_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "finished_at": {+ "name": "finished_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_run_schedule_fire_uq": {+ "name": "agent_run_schedule_fire_uq",+ "columns": [+ {+ "expression": "schedule_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "scheduled_for",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_run_due_idx": {+ "name": "agent_run_due_idx",+ "columns": [+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "next_attempt_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_run_schedule_idx": {+ "name": "agent_run_schedule_idx",+ "columns": [+ {+ "expression": "schedule_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_run_project_idx": {+ "name": "agent_run_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_run_agent_id_ai_agent_id_fk": {+ "name": "agent_run_agent_id_ai_agent_id_fk",+ "tableFrom": "agent_run",+ "tableTo": "ai_agent",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_run_project_id_project_id_fk": {+ "name": "agent_run_project_id_project_id_fk",+ "tableFrom": "agent_run",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_run_issue_id_issue_id_fk": {+ "name": "agent_run_issue_id_issue_id_fk",+ "tableFrom": "agent_run",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_run_schedule_id_agent_schedule_id_fk": {+ "name": "agent_run_schedule_id_agent_schedule_id_fk",+ "tableFrom": "agent_run",+ "tableTo": "agent_schedule",+ "columnsFrom": [+ "schedule_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_run_source_activity_id_issue_activity_id_fk": {+ "name": "agent_run_source_activity_id_issue_activity_id_fk",+ "tableFrom": "agent_run",+ "tableTo": "issue_activity",+ "columnsFrom": [+ "source_activity_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "agent_run_status_check": {+ "name": "agent_run_status_check",+ "value": "\"agent_run\".\"status\" IN ('pending', 'success', 'failed', 'canceled')"+ },+ "agent_run_trigger_check": {+ "name": "agent_run_trigger_check",+ "value": "\"agent_run\".\"trigger\" IN ('mention', 'delegation', 'field', 'schedule', 'manual')"+ }+ },+ "isRLSEnabled": false+ },+ "public.agent_schedule": {+ "name": "agent_schedule",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "agent_id": {+ "name": "agent_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "prompt": {+ "name": "prompt",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "cron": {+ "name": "cron",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "timezone": {+ "name": "timezone",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'active'"+ },+ "next_run_at": {+ "name": "next_run_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true+ },+ "last_run_at": {+ "name": "last_run_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_schedule_due_idx": {+ "name": "agent_schedule_due_idx",+ "columns": [+ {+ "expression": "status",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "next_run_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_schedule_agent_idx": {+ "name": "agent_schedule_agent_idx",+ "columns": [+ {+ "expression": "agent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_schedule_project_idx": {+ "name": "agent_schedule_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_schedule_agent_id_ai_agent_id_fk": {+ "name": "agent_schedule_agent_id_ai_agent_id_fk",+ "tableFrom": "agent_schedule",+ "tableTo": "ai_agent",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_schedule_project_id_project_id_fk": {+ "name": "agent_schedule_project_id_project_id_fk",+ "tableFrom": "agent_schedule",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "agent_schedule_project_id_agent_id_name_unique": {+ "name": "agent_schedule_project_id_agent_id_name_unique",+ "nullsNotDistinct": false,+ "columns": [+ "project_id",+ "agent_id",+ "name"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {+ "agent_schedule_status_check": {+ "name": "agent_schedule_status_check",+ "value": "\"agent_schedule\".\"status\" IN ('active', 'paused')"+ }+ },+ "isRLSEnabled": false+ },+ "public.agent_skill": {+ "name": "agent_skill",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "team_id": {+ "name": "team_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "source": {+ "name": "source",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "source_url": {+ "name": "source_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "s3_prefix": {+ "name": "s3_prefix",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "files": {+ "name": "files",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_skill_team_idx": {+ "name": "agent_skill_team_idx",+ "columns": [+ {+ "expression": "team_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_skill_team_id_team_id_fk": {+ "name": "agent_skill_team_id_team_id_fk",+ "tableFrom": "agent_skill",+ "tableTo": "team",+ "columnsFrom": [+ "team_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "agent_skill_team_id_name_unique": {+ "name": "agent_skill_team_id_name_unique",+ "nullsNotDistinct": false,+ "columns": [+ "team_id",+ "name"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {+ "agent_skill_source_check": {+ "name": "agent_skill_source_check",+ "value": "\"agent_skill\".\"source\" IN ('upload', 'inline', 'github')"+ }+ },+ "isRLSEnabled": false+ },+ "public.agent_skill_link": {+ "name": "agent_skill_link",+ "schema": "",+ "columns": {+ "agent_id": {+ "name": "agent_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "skill_id": {+ "name": "skill_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "agent_skill_link_skill_idx": {+ "name": "agent_skill_link_skill_idx",+ "columns": [+ {+ "expression": "skill_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_skill_link_agent_id_ai_agent_id_fk": {+ "name": "agent_skill_link_agent_id_ai_agent_id_fk",+ "tableFrom": "agent_skill_link",+ "tableTo": "ai_agent",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_skill_link_skill_id_agent_skill_id_fk": {+ "name": "agent_skill_link_skill_id_agent_skill_id_fk",+ "tableFrom": "agent_skill_link",+ "tableTo": "agent_skill",+ "columnsFrom": [+ "skill_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "agent_skill_link_agent_id_skill_id_pk": {+ "name": "agent_skill_link_agent_id_skill_id_pk",+ "columns": [+ "agent_id",+ "skill_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_tool": {+ "name": "agent_tool",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "team_id": {+ "name": "team_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "tool_key": {+ "name": "tool_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "credential_id": {+ "name": "credential_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "agent_tool_team_idx": {+ "name": "agent_tool_team_idx",+ "columns": [+ {+ "expression": "team_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "agent_tool_credential_idx": {+ "name": "agent_tool_credential_idx",+ "columns": [+ {+ "expression": "credential_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_tool_team_id_team_id_fk": {+ "name": "agent_tool_team_id_team_id_fk",+ "tableFrom": "agent_tool",+ "tableTo": "team",+ "columnsFrom": [+ "team_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_tool_credential_id_integration_credential_id_fk": {+ "name": "agent_tool_credential_id_integration_credential_id_fk",+ "tableFrom": "agent_tool",+ "tableTo": "integration_credential",+ "columnsFrom": [+ "credential_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "agent_tool_team_id_tool_key_credential_id_unique": {+ "name": "agent_tool_team_id_tool_key_credential_id_unique",+ "nullsNotDistinct": false,+ "columns": [+ "team_id",+ "tool_key",+ "credential_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.agent_tool_link": {+ "name": "agent_tool_link",+ "schema": "",+ "columns": {+ "agent_id": {+ "name": "agent_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "agent_tool_id": {+ "name": "agent_tool_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "agent_tool_link_tool_idx": {+ "name": "agent_tool_link_tool_idx",+ "columns": [+ {+ "expression": "agent_tool_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "agent_tool_link_agent_id_ai_agent_id_fk": {+ "name": "agent_tool_link_agent_id_ai_agent_id_fk",+ "tableFrom": "agent_tool_link",+ "tableTo": "ai_agent",+ "columnsFrom": [+ "agent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "agent_tool_link_agent_tool_id_agent_tool_id_fk": {+ "name": "agent_tool_link_agent_tool_id_agent_tool_id_fk",+ "tableFrom": "agent_tool_link",+ "tableTo": "agent_tool",+ "columnsFrom": [+ "agent_tool_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "agent_tool_link_agent_id_agent_tool_id_pk": {+ "name": "agent_tool_link_agent_id_agent_tool_id_pk",+ "columns": [+ "agent_id",+ "agent_tool_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.ai_agent": {+ "name": "ai_agent",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "team_id": {+ "name": "team_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "username": {+ "name": "username",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "model_credential_id": {+ "name": "model_credential_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "model": {+ "name": "model",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "instructions": {+ "name": "instructions",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "tools": {+ "name": "tools",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "temperature": {+ "name": "temperature",+ "type": "double precision",+ "primaryKey": false,+ "notNull": false+ },+ "max_steps": {+ "name": "max_steps",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "trigger_on_mention": {+ "name": "trigger_on_mention",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "trigger_on_assign": {+ "name": "trigger_on_assign",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "delegation_delay_sec": {+ "name": "delegation_delay_sec",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 120+ },+ "api_key_ciphertext": {+ "name": "api_key_ciphertext",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "api_key_iv": {+ "name": "api_key_iv",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "api_key_auth_tag": {+ "name": "api_key_auth_tag",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "memory_enabled": {+ "name": "memory_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "memory_last_messages": {+ "name": "memory_last_messages",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "owner_user_id": {+ "name": "owner_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "runner_scope": {+ "name": "runner_scope",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'team'"+ },+ "last_seen_at": {+ "name": "last_seen_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "ai_agent_team_username_uq": {+ "name": "ai_agent_team_username_uq",+ "columns": [+ {+ "expression": "team_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "lower(\"username\")",+ "asc": true,+ "isExpression": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "ai_agent_team_idx": {+ "name": "ai_agent_team_idx",+ "columns": [+ {+ "expression": "team_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "ai_agent_team_id_team_id_fk": {+ "name": "ai_agent_team_id_team_id_fk",+ "tableFrom": "ai_agent",+ "tableTo": "team",+ "columnsFrom": [+ "team_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "ai_agent_user_id_user_id_fk": {+ "name": "ai_agent_user_id_user_id_fk",+ "tableFrom": "ai_agent",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "ai_agent_model_credential_id_integration_credential_id_fk": {+ "name": "ai_agent_model_credential_id_integration_credential_id_fk",+ "tableFrom": "ai_agent",+ "tableTo": "integration_credential",+ "columnsFrom": [+ "model_credential_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "ai_agent_owner_user_id_user_id_fk": {+ "name": "ai_agent_owner_user_id_user_id_fk",+ "tableFrom": "ai_agent",+ "tableTo": "user",+ "columnsFrom": [+ "owner_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "ai_agent_user_id_unique": {+ "name": "ai_agent_user_id_unique",+ "nullsNotDistinct": false,+ "columns": [+ "user_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {+ "ai_agent_kind_check": {+ "name": "ai_agent_kind_check",+ "value": "\"ai_agent\".\"kind\" IN ('external', 'internal')"+ },+ "ai_agent_runner_scope_check": {+ "name": "ai_agent_runner_scope_check",+ "value": "\"ai_agent\".\"runner_scope\" IN ('owner', 'team')"+ },+ "ai_agent_delegation_delay_check": {+ "name": "ai_agent_delegation_delay_check",+ "value": "\"ai_agent\".\"delegation_delay_sec\" >= 0 AND \"ai_agent\".\"delegation_delay_sec\" <= 86400"+ }+ },+ "isRLSEnabled": false+ },+ "public.app_secret": {+ "name": "app_secret",+ "schema": "",+ "columns": {+ "key": {+ "name": "key",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "ciphertext": {+ "name": "ciphertext",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "iv": {+ "name": "iv",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "auth_tag": {+ "name": "auth_tag",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "redacted": {+ "name": "redacted",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.app_setting": {+ "name": "app_setting",+ "schema": "",+ "columns": {+ "key": {+ "name": "key",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "value": {+ "name": "value",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.chat_attachment": {+ "name": "chat_attachment",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "public_id": {+ "name": "public_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "uploaded_by_user_id": {+ "name": "uploaded_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "s3_key": {+ "name": "s3_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "filename": {+ "name": "filename",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "content_type": {+ "name": "content_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "size_bytes": {+ "name": "size_bytes",+ "type": "bigint",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "chat_attachment_project_idx": {+ "name": "chat_attachment_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "chat_attachment_project_id_project_id_fk": {+ "name": "chat_attachment_project_id_project_id_fk",+ "tableFrom": "chat_attachment",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "chat_attachment_uploaded_by_user_id_user_id_fk": {+ "name": "chat_attachment_uploaded_by_user_id_user_id_fk",+ "tableFrom": "chat_attachment",+ "tableTo": "user",+ "columnsFrom": [+ "uploaded_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "chat_attachment_public_id_unique": {+ "name": "chat_attachment_public_id_unique",+ "nullsNotDistinct": false,+ "columns": [+ "public_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.custom_field": {+ "name": "custom_field",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "issue_type_id": {+ "name": "issue_type_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "field_type": {+ "name": "field_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "member_scope": {+ "name": "member_scope",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "show_in_body": {+ "name": "show_in_body",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "position": {+ "name": "position",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "custom_field_project_id_project_id_fk": {+ "name": "custom_field_project_id_project_id_fk",+ "tableFrom": "custom_field",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "custom_field_issue_type_id_issue_type_id_fk": {+ "name": "custom_field_issue_type_id_issue_type_id_fk",+ "tableFrom": "custom_field",+ "tableTo": "issue_type",+ "columnsFrom": [+ "issue_type_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "custom_field_field_type_check": {+ "name": "custom_field_field_type_check",+ "value": "\"custom_field\".\"field_type\" IN ('text', 'markdown', 'url', 'number', 'boolean', 'date', 'datetime', 'datetime_range', 'select', 'multi_select', 'member')"+ },+ "custom_field_member_scope_check": {+ "name": "custom_field_member_scope_check",+ "value": "(\"custom_field\".\"field_type\" = 'member') = (\"custom_field\".\"member_scope\" IS NOT NULL) AND (\"custom_field\".\"member_scope\" IS NULL OR \"custom_field\".\"member_scope\" IN ('all', 'humans', 'agents'))"+ }+ },+ "isRLSEnabled": false+ },+ "public.custom_field_option": {+ "name": "custom_field_option",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "field_id": {+ "name": "field_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "value": {+ "name": "value",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "color": {+ "name": "color",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'#6b7280'"+ },+ "position": {+ "name": "position",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ }+ },+ "indexes": {},+ "foreignKeys": {+ "custom_field_option_field_id_custom_field_id_fk": {+ "name": "custom_field_option_field_id_custom_field_id_fk",+ "tableFrom": "custom_field_option",+ "tableTo": "custom_field",+ "columnsFrom": [+ "field_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "custom_field_option_field_id_value_unique": {+ "name": "custom_field_option_field_id_value_unique",+ "nullsNotDistinct": false,+ "columns": [+ "field_id",+ "value"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.cycle": {+ "name": "cycle",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "goal": {+ "name": "goal",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "start_date": {+ "name": "start_date",+ "type": "date",+ "primaryKey": false,+ "notNull": true+ },+ "end_date": {+ "name": "end_date",+ "type": "date",+ "primaryKey": false,+ "notNull": true+ },+ "completed_at": {+ "name": "completed_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "cycle_project_idx": {+ "name": "cycle_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "start_date",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "cycle_project_id_project_id_fk": {+ "name": "cycle_project_id_project_id_fk",+ "tableFrom": "cycle",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "cycle_dates_check": {+ "name": "cycle_dates_check",+ "value": "\"cycle\".\"end_date\" >= \"cycle\".\"start_date\""+ }+ },+ "isRLSEnabled": false+ },+ "public.document_asset": {+ "name": "document_asset",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "public_id": {+ "name": "public_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "document_id": {+ "name": "document_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "uploaded_by_user_id": {+ "name": "uploaded_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "s3_key": {+ "name": "s3_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "filename": {+ "name": "filename",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "content_type": {+ "name": "content_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "size_bytes": {+ "name": "size_bytes",+ "type": "bigint",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "document_asset_document_idx": {+ "name": "document_asset_document_idx",+ "columns": [+ {+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "document_asset_document_id_project_document_id_fk": {+ "name": "document_asset_document_id_project_document_id_fk",+ "tableFrom": "document_asset",+ "tableTo": "project_document",+ "columnsFrom": [+ "document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "document_asset_uploaded_by_user_id_user_id_fk": {+ "name": "document_asset_uploaded_by_user_id_user_id_fk",+ "tableFrom": "document_asset",+ "tableTo": "user",+ "columnsFrom": [+ "uploaded_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "document_asset_public_id_unique": {+ "name": "document_asset_public_id_unique",+ "nullsNotDistinct": false,+ "columns": [+ "public_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.document_collaboration": {+ "name": "document_collaboration",+ "schema": "",+ "columns": {+ "document_id": {+ "name": "document_id",+ "type": "integer",+ "primaryKey": true,+ "notNull": true+ },+ "epoch": {+ "name": "epoch",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "version": {+ "name": "version",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "content_json": {+ "name": "content_json",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {},+ "foreignKeys": {+ "document_collaboration_document_id_project_document_id_fk": {+ "name": "document_collaboration_document_id_project_document_id_fk",+ "tableFrom": "document_collaboration",+ "tableTo": "project_document",+ "columnsFrom": [+ "document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.document_comment": {+ "name": "document_comment",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "document_id": {+ "name": "document_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "parent_id": {+ "name": "parent_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "author_id": {+ "name": "author_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "body": {+ "name": "body",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "quote": {+ "name": "quote",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "selection_from": {+ "name": "selection_from",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "selection_to": {+ "name": "selection_to",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "orphaned": {+ "name": "orphaned",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "resolved_at": {+ "name": "resolved_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "document_comment_document_idx": {+ "name": "document_comment_document_idx",+ "columns": [+ {+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "document_comment_document_id_project_document_id_fk": {+ "name": "document_comment_document_id_project_document_id_fk",+ "tableFrom": "document_comment",+ "tableTo": "project_document",+ "columnsFrom": [+ "document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "document_comment_parent_id_document_comment_id_fk": {+ "name": "document_comment_parent_id_document_comment_id_fk",+ "tableFrom": "document_comment",+ "tableTo": "document_comment",+ "columnsFrom": [+ "parent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "document_comment_author_id_user_id_fk": {+ "name": "document_comment_author_id_user_id_fk",+ "tableFrom": "document_comment",+ "tableTo": "user",+ "columnsFrom": [+ "author_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.document_step": {+ "name": "document_step",+ "schema": "",+ "columns": {+ "document_id": {+ "name": "document_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "version": {+ "name": "version",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "client_id": {+ "name": "client_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "step": {+ "name": "step",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {},+ "foreignKeys": {+ "document_step_document_id_project_document_id_fk": {+ "name": "document_step_document_id_project_document_id_fk",+ "tableFrom": "document_step",+ "tableTo": "project_document",+ "columnsFrom": [+ "document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "document_step_document_id_version_pk": {+ "name": "document_step_document_id_version_pk",+ "columns": [+ "document_id",+ "version"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.git_managed_repository": {+ "name": "git_managed_repository",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "connection_id": {+ "name": "connection_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "external_id": {+ "name": "external_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "full_name": {+ "name": "full_name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "web_url": {+ "name": "web_url",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "webhook_external_id": {+ "name": "webhook_external_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'connected'"+ },+ "last_error": {+ "name": "last_error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "git_managed_repository_project_connection_idx": {+ "name": "git_managed_repository_project_connection_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "connection_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "git_managed_repository_project_id_project_id_fk": {+ "name": "git_managed_repository_project_id_project_id_fk",+ "tableFrom": "git_managed_repository",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "git_managed_repository_connection_id_git_provider_connection_id_fk": {+ "name": "git_managed_repository_connection_id_git_provider_connection_id_fk",+ "tableFrom": "git_managed_repository",+ "tableTo": "git_provider_connection",+ "columnsFrom": [+ "connection_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "git_managed_repository_project_connection_external_unique": {+ "name": "git_managed_repository_project_connection_external_unique",+ "nullsNotDistinct": false,+ "columns": [+ "project_id",+ "connection_id",+ "external_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.git_provider_connection": {+ "name": "git_provider_connection",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "team_id": {+ "name": "team_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "base_url": {+ "name": "base_url",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "account_login": {+ "name": "account_login",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "ciphertext": {+ "name": "ciphertext",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "iv": {+ "name": "iv",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "auth_tag": {+ "name": "auth_tag",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "git_provider_connection_team_idx": {+ "name": "git_provider_connection_team_idx",+ "columns": [+ {+ "expression": "team_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "git_provider_connection_team_id_team_id_fk": {+ "name": "git_provider_connection_team_id_team_id_fk",+ "tableFrom": "git_provider_connection",+ "tableTo": "team",+ "columnsFrom": [+ "team_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.import_job": {+ "name": "import_job",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "source": {+ "name": "source",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "phase": {+ "name": "phase",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'discover'"+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "config": {+ "name": "config",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "cursor": {+ "name": "cursor",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "credential_ciphertext": {+ "name": "credential_ciphertext",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "credential_iv": {+ "name": "credential_iv",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "credential_auth_tag": {+ "name": "credential_auth_tag",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "attempts": {+ "name": "attempts",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "next_attempt_at": {+ "name": "next_attempt_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "last_error": {+ "name": "last_error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "import_job_project_idx": {+ "name": "import_job_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "import_job_due_idx": {+ "name": "import_job_due_idx",+ "columns": [+ {+ "expression": "next_attempt_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"import_job\".\"status\" = 'pending'",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "import_job_project_id_project_id_fk": {+ "name": "import_job_project_id_project_id_fk",+ "tableFrom": "import_job",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "import_job_created_by_user_id_user_id_fk": {+ "name": "import_job_created_by_user_id_user_id_fk",+ "tableFrom": "import_job",+ "tableTo": "user",+ "columnsFrom": [+ "created_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "import_job_source_check": {+ "name": "import_job_source_check",+ "value": "\"import_job\".\"source\" IN ('plane')"+ },+ "import_job_phase_check": {+ "name": "import_job_phase_check",+ "value": "\"import_job\".\"phase\" IN ('discover', 'create', 'link', 'rewrite', 'attachments', 'done')"+ },+ "import_job_status_check": {+ "name": "import_job_status_check",+ "value": "\"import_job\".\"status\" IN ('pending', 'running', 'paused', 'completed', 'failed')"+ }+ },+ "isRLSEnabled": false+ },+ "public.import_record": {+ "name": "import_record",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "import_job_id": {+ "name": "import_job_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "source_entity_type": {+ "name": "source_entity_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "source_id": {+ "name": "source_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "source_display_id": {+ "name": "source_display_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "local_entity_type": {+ "name": "local_entity_type",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "local_id": {+ "name": "local_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "import_record_job_source_uq": {+ "name": "import_record_job_source_uq",+ "columns": [+ {+ "expression": "import_job_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "source_entity_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "source_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "import_record_job_local_idx": {+ "name": "import_record_job_local_idx",+ "columns": [+ {+ "expression": "import_job_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "local_entity_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "local_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "import_record_job_display_idx": {+ "name": "import_record_job_display_idx",+ "columns": [+ {+ "expression": "import_job_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "source_entity_type",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "source_display_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "import_record_import_job_id_import_job_id_fk": {+ "name": "import_record_import_job_id_import_job_id_fk",+ "tableFrom": "import_record",+ "tableTo": "import_job",+ "columnsFrom": [+ "import_job_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "import_record_source_entity_type_check": {+ "name": "import_record_source_entity_type_check",+ "value": "\"import_record\".\"source_entity_type\" IN ('issue', 'comment', 'label', 'state', 'cycle', 'attachment')"+ },+ "import_record_local_entity_type_check": {+ "name": "import_record_local_entity_type_check",+ "value": "\"import_record\".\"local_entity_type\" IS NULL OR \"import_record\".\"local_entity_type\" IN ('issue', 'comment', 'label', 'state', 'cycle', 'attachment')"+ }+ },+ "isRLSEnabled": false+ },+ "public.initiative": {+ "name": "initiative",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'planned'"+ },+ "owner_user_id": {+ "name": "owner_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "priority": {+ "name": "priority",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "start_date": {+ "name": "start_date",+ "type": "date",+ "primaryKey": false,+ "notNull": false+ },+ "target_date": {+ "name": "target_date",+ "type": "date",+ "primaryKey": false,+ "notNull": false+ },+ "position": {+ "name": "position",+ "type": "double precision",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "initiative_project_idx": {+ "name": "initiative_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "position",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "initiative_project_id_project_id_fk": {+ "name": "initiative_project_id_project_id_fk",+ "tableFrom": "initiative",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "initiative_owner_user_id_user_id_fk": {+ "name": "initiative_owner_user_id_user_id_fk",+ "tableFrom": "initiative",+ "tableTo": "user",+ "columnsFrom": [+ "owner_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "initiative_status_check": {+ "name": "initiative_status_check",+ "value": "\"initiative\".\"status\" IN ('proposed', 'planned', 'active', 'completed', 'canceled')"+ }+ },+ "isRLSEnabled": false+ },+ "public.initiative_attachment": {+ "name": "initiative_attachment",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "public_id": {+ "name": "public_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "initiative_id": {+ "name": "initiative_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "s3_key": {+ "name": "s3_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "filename": {+ "name": "filename",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "content_type": {+ "name": "content_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "size_bytes": {+ "name": "size_bytes",+ "type": "bigint",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "initiative_attachment_initiative_idx": {+ "name": "initiative_attachment_initiative_idx",+ "columns": [+ {+ "expression": "initiative_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "initiative_attachment_initiative_id_initiative_id_fk": {+ "name": "initiative_attachment_initiative_id_initiative_id_fk",+ "tableFrom": "initiative_attachment",+ "tableTo": "initiative",+ "columnsFrom": [+ "initiative_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "initiative_attachment_public_id_unique": {+ "name": "initiative_attachment_public_id_unique",+ "nullsNotDistinct": false,+ "columns": [+ "public_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.initiative_label": {+ "name": "initiative_label",+ "schema": "",+ "columns": {+ "initiative_id": {+ "name": "initiative_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "label_id": {+ "name": "label_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {},+ "foreignKeys": {+ "initiative_label_initiative_id_initiative_id_fk": {+ "name": "initiative_label_initiative_id_initiative_id_fk",+ "tableFrom": "initiative_label",+ "tableTo": "initiative",+ "columnsFrom": [+ "initiative_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "initiative_label_label_id_label_id_fk": {+ "name": "initiative_label_label_id_label_id_fk",+ "tableFrom": "initiative_label",+ "tableTo": "label",+ "columnsFrom": [+ "label_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "initiative_label_initiative_id_label_id_pk": {+ "name": "initiative_label_initiative_id_label_id_pk",+ "columns": [+ "initiative_id",+ "label_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.integration_credential": {+ "name": "integration_credential",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "team_id": {+ "name": "team_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "integration_key": {+ "name": "integration_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "label": {+ "name": "label",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "ciphertext": {+ "name": "ciphertext",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "iv": {+ "name": "iv",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "auth_tag": {+ "name": "auth_tag",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "redacted": {+ "name": "redacted",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "integration_credential_team_idx": {+ "name": "integration_credential_team_idx",+ "columns": [+ {+ "expression": "team_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "integration_credential_team_id_team_id_fk": {+ "name": "integration_credential_team_id_team_id_fk",+ "tableFrom": "integration_credential",+ "tableTo": "team",+ "columnsFrom": [+ "team_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue": {+ "name": "issue",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "sequence_number": {+ "name": "sequence_number",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "type_id": {+ "name": "type_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "initiative_id": {+ "name": "initiative_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "cycle_id": {+ "name": "cycle_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "column_id": {+ "name": "column_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "parent_id": {+ "name": "parent_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "assignee_user_id": {+ "name": "assignee_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "delegate_user_id": {+ "name": "delegate_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "priority": {+ "name": "priority",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "estimate_points": {+ "name": "estimate_points",+ "type": "numeric",+ "primaryKey": false,+ "notNull": false+ },+ "estimate_minutes": {+ "name": "estimate_minutes",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "start_date": {+ "name": "start_date",+ "type": "date",+ "primaryKey": false,+ "notNull": false+ },+ "due_date": {+ "name": "due_date",+ "type": "date",+ "primaryKey": false,+ "notNull": false+ },+ "position": {+ "name": "position",+ "type": "double precision",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "archived_at": {+ "name": "archived_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "share_token": {+ "name": "share_token",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "share_extended": {+ "name": "share_extended",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_project_active_idx": {+ "name": "issue_project_active_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "column_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"issue\".\"archived_at\" IS NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_project_title_idx": {+ "name": "issue_project_title_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "lower(btrim(\"title\"))",+ "asc": true,+ "isExpression": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_parent_idx": {+ "name": "issue_parent_idx",+ "columns": [+ {+ "expression": "parent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"issue\".\"parent_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_cycle_idx": {+ "name": "issue_cycle_idx",+ "columns": [+ {+ "expression": "cycle_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"issue\".\"cycle_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_project_id_project_id_fk": {+ "name": "issue_project_id_project_id_fk",+ "tableFrom": "issue",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_type_id_issue_type_id_fk": {+ "name": "issue_type_id_issue_type_id_fk",+ "tableFrom": "issue",+ "tableTo": "issue_type",+ "columnsFrom": [+ "type_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_initiative_id_initiative_id_fk": {+ "name": "issue_initiative_id_initiative_id_fk",+ "tableFrom": "issue",+ "tableTo": "initiative",+ "columnsFrom": [+ "initiative_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_cycle_id_cycle_id_fk": {+ "name": "issue_cycle_id_cycle_id_fk",+ "tableFrom": "issue",+ "tableTo": "cycle",+ "columnsFrom": [+ "cycle_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_column_id_project_column_id_fk": {+ "name": "issue_column_id_project_column_id_fk",+ "tableFrom": "issue",+ "tableTo": "project_column",+ "columnsFrom": [+ "column_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "no action",+ "onUpdate": "no action"+ },+ "issue_parent_id_issue_id_fk": {+ "name": "issue_parent_id_issue_id_fk",+ "tableFrom": "issue",+ "tableTo": "issue",+ "columnsFrom": [+ "parent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_assignee_user_id_user_id_fk": {+ "name": "issue_assignee_user_id_user_id_fk",+ "tableFrom": "issue",+ "tableTo": "user",+ "columnsFrom": [+ "assignee_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_delegate_user_id_user_id_fk": {+ "name": "issue_delegate_user_id_user_id_fk",+ "tableFrom": "issue",+ "tableTo": "user",+ "columnsFrom": [+ "delegate_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "issue_share_token_unique": {+ "name": "issue_share_token_unique",+ "nullsNotDistinct": false,+ "columns": [+ "share_token"+ ]+ },+ "issue_project_id_sequence_number_unique": {+ "name": "issue_project_id_sequence_number_unique",+ "nullsNotDistinct": false,+ "columns": [+ "project_id",+ "sequence_number"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {+ "issue_estimate_points_check": {+ "name": "issue_estimate_points_check",+ "value": "\"issue\".\"estimate_points\" >= 0"+ },+ "issue_estimate_minutes_check": {+ "name": "issue_estimate_minutes_check",+ "value": "\"issue\".\"estimate_minutes\" >= 0"+ }+ },+ "isRLSEnabled": false+ },+ "public.issue_activity": {+ "name": "issue_activity",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "initiative_id": {+ "name": "initiative_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "reply_to_id": {+ "name": "reply_to_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "actor_user_id": {+ "name": "actor_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "actor_name": {+ "name": "actor_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "body": {+ "name": "body",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "action": {+ "name": "action",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "payload": {+ "name": "payload",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "edited_at": {+ "name": "edited_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_activity_issue_idx": {+ "name": "issue_activity_issue_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ },+ {+ "expression": "id",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_activity_reply_idx": {+ "name": "issue_activity_reply_idx",+ "columns": [+ {+ "expression": "reply_to_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_activity_initiative_idx": {+ "name": "issue_activity_initiative_idx",+ "columns": [+ {+ "expression": "initiative_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ },+ {+ "expression": "id",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_activity_issue_id_issue_id_fk": {+ "name": "issue_activity_issue_id_issue_id_fk",+ "tableFrom": "issue_activity",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_activity_initiative_id_initiative_id_fk": {+ "name": "issue_activity_initiative_id_initiative_id_fk",+ "tableFrom": "issue_activity",+ "tableTo": "initiative",+ "columnsFrom": [+ "initiative_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_activity_reply_to_id_issue_activity_id_fk": {+ "name": "issue_activity_reply_to_id_issue_activity_id_fk",+ "tableFrom": "issue_activity",+ "tableTo": "issue_activity",+ "columnsFrom": [+ "reply_to_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_activity_actor_user_id_user_id_fk": {+ "name": "issue_activity_actor_user_id_user_id_fk",+ "tableFrom": "issue_activity",+ "tableTo": "user",+ "columnsFrom": [+ "actor_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "issue_activity_kind_check": {+ "name": "issue_activity_kind_check",+ "value": "\"issue_activity\".\"kind\" IN ('comment', 'activity')"+ },+ "issue_activity_owner_check": {+ "name": "issue_activity_owner_check",+ "value": "(\"issue_activity\".\"issue_id\" IS NOT NULL) <> (\"issue_activity\".\"initiative_id\" IS NOT NULL)"+ }+ },+ "isRLSEnabled": false+ },+ "public.issue_attachment": {+ "name": "issue_attachment",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "public_id": {+ "name": "public_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "s3_key": {+ "name": "s3_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "filename": {+ "name": "filename",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "content_type": {+ "name": "content_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "size_bytes": {+ "name": "size_bytes",+ "type": "bigint",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_attachment_issue_idx": {+ "name": "issue_attachment_issue_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_attachment_issue_id_issue_id_fk": {+ "name": "issue_attachment_issue_id_issue_id_fk",+ "tableFrom": "issue_attachment",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "issue_attachment_public_id_unique": {+ "name": "issue_attachment_public_id_unique",+ "nullsNotDistinct": false,+ "columns": [+ "public_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_checklist": {+ "name": "issue_checklist",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "position": {+ "name": "position",+ "type": "double precision",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_checklist_issue_idx": {+ "name": "issue_checklist_issue_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "position",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_checklist_issue_id_issue_id_fk": {+ "name": "issue_checklist_issue_id_issue_id_fk",+ "tableFrom": "issue_checklist",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_checklist_item": {+ "name": "issue_checklist_item",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "checklist_id": {+ "name": "checklist_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "done": {+ "name": "done",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "position": {+ "name": "position",+ "type": "double precision",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_checklist_item_checklist_idx": {+ "name": "issue_checklist_item_checklist_idx",+ "columns": [+ {+ "expression": "checklist_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "position",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_checklist_item_checklist_id_issue_checklist_id_fk": {+ "name": "issue_checklist_item_checklist_id_issue_checklist_id_fk",+ "tableFrom": "issue_checklist_item",+ "tableTo": "issue_checklist",+ "columnsFrom": [+ "checklist_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_cycle": {+ "name": "issue_cycle",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "cycle_id": {+ "name": "cycle_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "entered_at": {+ "name": "entered_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "left_at": {+ "name": "left_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "issue_cycle_issue_idx": {+ "name": "issue_cycle_issue_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "entered_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_cycle_cycle_idx": {+ "name": "issue_cycle_cycle_idx",+ "columns": [+ {+ "expression": "cycle_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_cycle_open_idx": {+ "name": "issue_cycle_open_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "cycle_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"issue_cycle\".\"left_at\" IS NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_cycle_issue_id_issue_id_fk": {+ "name": "issue_cycle_issue_id_issue_id_fk",+ "tableFrom": "issue_cycle",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_cycle_cycle_id_cycle_id_fk": {+ "name": "issue_cycle_cycle_id_cycle_id_fk",+ "tableFrom": "issue_cycle",+ "tableTo": "cycle",+ "columnsFrom": [+ "cycle_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_development_check": {+ "name": "issue_development_check",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "development_link_id": {+ "name": "development_link_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "external_id": {+ "name": "external_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "app_id": {+ "name": "app_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "url": {+ "name": "url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "head_sha": {+ "name": "head_sha",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_development_check_link_sha_idx": {+ "name": "issue_development_check_link_sha_idx",+ "columns": [+ {+ "expression": "development_link_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "head_sha",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_development_check_development_link_id_issue_development_link_id_fk": {+ "name": "issue_development_check_development_link_id_issue_development_link_id_fk",+ "tableFrom": "issue_development_check",+ "tableTo": "issue_development_link",+ "columnsFrom": [+ "development_link_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "issue_development_check_development_link_id_app_id_name_unique": {+ "name": "issue_development_check_development_link_id_app_id_name_unique",+ "nullsNotDistinct": false,+ "columns": [+ "development_link_id",+ "app_id",+ "name"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_development_link": {+ "name": "issue_development_link",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "provider": {+ "name": "provider",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "repository": {+ "name": "repository",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pull_request'"+ },+ "external_key": {+ "name": "external_key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "number": {+ "name": "number",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "url": {+ "name": "url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "state": {+ "name": "state",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "draft": {+ "name": "draft",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "source_branch": {+ "name": "source_branch",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "target_branch": {+ "name": "target_branch",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "head_sha": {+ "name": "head_sha",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "pipeline_status": {+ "name": "pipeline_status",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "pipeline_url": {+ "name": "pipeline_url",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_development_link_issue_idx": {+ "name": "issue_development_link_issue_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "updated_at",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_development_link_pr_idx": {+ "name": "issue_development_link_pr_idx",+ "columns": [+ {+ "expression": "provider",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "repository",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "number",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_development_link_sha_idx": {+ "name": "issue_development_link_sha_idx",+ "columns": [+ {+ "expression": "provider",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "repository",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "head_sha",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_development_link_issue_id_issue_id_fk": {+ "name": "issue_development_link_issue_id_issue_id_fk",+ "tableFrom": "issue_development_link",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "issue_development_link_issue_id_provider_repository_external_key_unique": {+ "name": "issue_development_link_issue_id_provider_repository_external_key_unique",+ "nullsNotDistinct": false,+ "columns": [+ "issue_id",+ "provider",+ "repository",+ "external_key"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_field_option": {+ "name": "issue_field_option",+ "schema": "",+ "columns": {+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "field_id": {+ "name": "field_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "option_id": {+ "name": "option_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {},+ "foreignKeys": {+ "issue_field_option_issue_id_issue_id_fk": {+ "name": "issue_field_option_issue_id_issue_id_fk",+ "tableFrom": "issue_field_option",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_field_option_field_id_custom_field_id_fk": {+ "name": "issue_field_option_field_id_custom_field_id_fk",+ "tableFrom": "issue_field_option",+ "tableTo": "custom_field",+ "columnsFrom": [+ "field_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_field_option_option_id_custom_field_option_id_fk": {+ "name": "issue_field_option_option_id_custom_field_option_id_fk",+ "tableFrom": "issue_field_option",+ "tableTo": "custom_field_option",+ "columnsFrom": [+ "option_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "issue_field_option_issue_id_field_id_option_id_pk": {+ "name": "issue_field_option_issue_id_field_id_option_id_pk",+ "columns": [+ "issue_id",+ "field_id",+ "option_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_field_value": {+ "name": "issue_field_value",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "field_id": {+ "name": "field_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "value_text": {+ "name": "value_text",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "value_number": {+ "name": "value_number",+ "type": "numeric",+ "primaryKey": false,+ "notNull": false+ },+ "value_bool": {+ "name": "value_bool",+ "type": "boolean",+ "primaryKey": false,+ "notNull": false+ },+ "value_date": {+ "name": "value_date",+ "type": "date",+ "primaryKey": false,+ "notNull": false+ },+ "value_datetime": {+ "name": "value_datetime",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "value_datetime_end": {+ "name": "value_datetime_end",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "value_user_id": {+ "name": "value_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {},+ "foreignKeys": {+ "issue_field_value_issue_id_issue_id_fk": {+ "name": "issue_field_value_issue_id_issue_id_fk",+ "tableFrom": "issue_field_value",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_field_value_field_id_custom_field_id_fk": {+ "name": "issue_field_value_field_id_custom_field_id_fk",+ "tableFrom": "issue_field_value",+ "tableTo": "custom_field",+ "columnsFrom": [+ "field_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_field_value_value_user_id_user_id_fk": {+ "name": "issue_field_value_value_user_id_user_id_fk",+ "tableFrom": "issue_field_value",+ "tableTo": "user",+ "columnsFrom": [+ "value_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "issue_field_value_issue_id_field_id_unique": {+ "name": "issue_field_value_issue_id_field_id_unique",+ "nullsNotDistinct": false,+ "columns": [+ "issue_id",+ "field_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_import": {+ "name": "issue_import",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "public_id": {+ "name": "public_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "attachment_id": {+ "name": "attachment_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'mapped'"+ },+ "mapping": {+ "name": "mapping",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "error_text": {+ "name": "error_text",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_import_project_idx": {+ "name": "issue_import_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_import_project_id_project_id_fk": {+ "name": "issue_import_project_id_project_id_fk",+ "tableFrom": "issue_import",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_import_attachment_id_chat_attachment_id_fk": {+ "name": "issue_import_attachment_id_chat_attachment_id_fk",+ "tableFrom": "issue_import",+ "tableTo": "chat_attachment",+ "columnsFrom": [+ "attachment_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "issue_import_public_id_unique": {+ "name": "issue_import_public_id_unique",+ "nullsNotDistinct": false,+ "columns": [+ "public_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_label": {+ "name": "issue_label",+ "schema": "",+ "columns": {+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "label_id": {+ "name": "label_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {},+ "foreignKeys": {+ "issue_label_issue_id_issue_id_fk": {+ "name": "issue_label_issue_id_issue_id_fk",+ "tableFrom": "issue_label",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_label_label_id_label_id_fk": {+ "name": "issue_label_label_id_label_id_fk",+ "tableFrom": "issue_label",+ "tableTo": "label",+ "columnsFrom": [+ "label_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "issue_label_issue_id_label_id_pk": {+ "name": "issue_label_issue_id_label_id_pk",+ "columns": [+ "issue_id",+ "label_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_link": {+ "name": "issue_link",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "source_issue_id": {+ "name": "source_issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "target_issue_id": {+ "name": "target_issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "kind": {+ "name": "kind",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_link_pair_kind_idx": {+ "name": "issue_link_pair_kind_idx",+ "columns": [+ {+ "expression": "least(\"source_issue_id\", \"target_issue_id\")",+ "asc": true,+ "isExpression": true,+ "nulls": "last"+ },+ {+ "expression": "greatest(\"source_issue_id\", \"target_issue_id\")",+ "asc": true,+ "isExpression": true,+ "nulls": "last"+ },+ {+ "expression": "kind",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_link_source_idx": {+ "name": "issue_link_source_idx",+ "columns": [+ {+ "expression": "source_issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_link_target_idx": {+ "name": "issue_link_target_idx",+ "columns": [+ {+ "expression": "target_issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_link_source_issue_id_issue_id_fk": {+ "name": "issue_link_source_issue_id_issue_id_fk",+ "tableFrom": "issue_link",+ "tableTo": "issue",+ "columnsFrom": [+ "source_issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_link_target_issue_id_issue_id_fk": {+ "name": "issue_link_target_issue_id_issue_id_fk",+ "tableFrom": "issue_link",+ "tableTo": "issue",+ "columnsFrom": [+ "target_issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "issue_link_kind_check": {+ "name": "issue_link_kind_check",+ "value": "\"issue_link\".\"kind\" IN ('blocks', 'relates', 'duplicates')"+ },+ "issue_link_self_check": {+ "name": "issue_link_self_check",+ "value": "\"issue_link\".\"source_issue_id\" <> \"issue_link\".\"target_issue_id\""+ }+ },+ "isRLSEnabled": false+ },+ "public.issue_status": {+ "name": "issue_status",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "column_id": {+ "name": "column_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "column_name": {+ "name": "column_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "state_type": {+ "name": "state_type",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "entered_at": {+ "name": "entered_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "left_at": {+ "name": "left_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "issue_status_issue_idx": {+ "name": "issue_status_issue_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "entered_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_status_column_idx": {+ "name": "issue_status_column_idx",+ "columns": [+ {+ "expression": "column_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"issue_status\".\"column_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "issue_status_open_idx": {+ "name": "issue_status_open_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"issue_status\".\"left_at\" IS NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_status_issue_id_issue_id_fk": {+ "name": "issue_status_issue_id_issue_id_fk",+ "tableFrom": "issue_status",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_status_column_id_project_column_id_fk": {+ "name": "issue_status_column_id_project_column_id_fk",+ "tableFrom": "issue_status",+ "tableTo": "project_column",+ "columnsFrom": [+ "column_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_template": {+ "name": "issue_template",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "title_template": {+ "name": "title_template",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "description_template": {+ "name": "description_template",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "type_id": {+ "name": "type_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "column_id": {+ "name": "column_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "priority": {+ "name": "priority",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "assignee_user_id": {+ "name": "assignee_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "issue_template_project_id_project_id_fk": {+ "name": "issue_template_project_id_project_id_fk",+ "tableFrom": "issue_template",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_template_type_id_issue_type_id_fk": {+ "name": "issue_template_type_id_issue_type_id_fk",+ "tableFrom": "issue_template",+ "tableTo": "issue_type",+ "columnsFrom": [+ "type_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_template_column_id_project_column_id_fk": {+ "name": "issue_template_column_id_project_column_id_fk",+ "tableFrom": "issue_template",+ "tableTo": "project_column",+ "columnsFrom": [+ "column_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "issue_template_assignee_user_id_user_id_fk": {+ "name": "issue_template_assignee_user_id_user_id_fk",+ "tableFrom": "issue_template",+ "tableTo": "user",+ "columnsFrom": [+ "assignee_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "issue_template_project_id_name_unique": {+ "name": "issue_template_project_id_name_unique",+ "nullsNotDistinct": false,+ "columns": [+ "project_id",+ "name"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_template_label": {+ "name": "issue_template_label",+ "schema": "",+ "columns": {+ "template_id": {+ "name": "template_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "label_id": {+ "name": "label_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {},+ "foreignKeys": {+ "issue_template_label_template_id_issue_template_id_fk": {+ "name": "issue_template_label_template_id_issue_template_id_fk",+ "tableFrom": "issue_template_label",+ "tableTo": "issue_template",+ "columnsFrom": [+ "template_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_template_label_label_id_label_id_fk": {+ "name": "issue_template_label_label_id_label_id_fk",+ "tableFrom": "issue_template_label",+ "tableTo": "label",+ "columnsFrom": [+ "label_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "issue_template_label_template_id_label_id_pk": {+ "name": "issue_template_label_template_id_label_id_pk",+ "columns": [+ "template_id",+ "label_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_type": {+ "name": "issue_type",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "icon": {+ "name": "icon",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "color": {+ "name": "color",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'#6b7280'"+ },+ "is_default": {+ "name": "is_default",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "position": {+ "name": "position",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "issue_type_project_id_project_id_fk": {+ "name": "issue_type_project_id_project_id_fk",+ "tableFrom": "issue_type",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "issue_type_project_id_name_unique": {+ "name": "issue_type_project_id_name_unique",+ "nullsNotDistinct": false,+ "columns": [+ "project_id",+ "name"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_watcher": {+ "name": "issue_watcher",+ "schema": "",+ "columns": {+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "subscribed": {+ "name": "subscribed",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "issue_watcher_issue_id_issue_id_fk": {+ "name": "issue_watcher_issue_id_issue_id_fk",+ "tableFrom": "issue_watcher",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_watcher_user_id_user_id_fk": {+ "name": "issue_watcher_user_id_user_id_fk",+ "tableFrom": "issue_watcher",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "issue_watcher_issue_id_user_id_pk": {+ "name": "issue_watcher_issue_id_user_id_pk",+ "columns": [+ "issue_id",+ "user_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.issue_worklog": {+ "name": "issue_worklog",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "minutes": {+ "name": "minutes",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "spent_on": {+ "name": "spent_on",+ "type": "date",+ "primaryKey": false,+ "notNull": true+ },+ "note": {+ "name": "note",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "issue_worklog_issue_idx": {+ "name": "issue_worklog_issue_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "spent_on",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "issue_worklog_issue_id_issue_id_fk": {+ "name": "issue_worklog_issue_id_issue_id_fk",+ "tableFrom": "issue_worklog",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "issue_worklog_user_id_user_id_fk": {+ "name": "issue_worklog_user_id_user_id_fk",+ "tableFrom": "issue_worklog",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "issue_worklog_minutes_check": {+ "name": "issue_worklog_minutes_check",+ "value": "\"issue_worklog\".\"minutes\" > 0"+ }+ },+ "isRLSEnabled": false+ },+ "public.label": {+ "name": "label",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "group_id": {+ "name": "group_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "color": {+ "name": "color",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'#6b7280'"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "label_project_id_project_id_fk": {+ "name": "label_project_id_project_id_fk",+ "tableFrom": "label",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "label_group_id_label_group_id_fk": {+ "name": "label_group_id_label_group_id_fk",+ "tableFrom": "label",+ "tableTo": "label_group",+ "columnsFrom": [+ "group_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "label_project_id_name_unique": {+ "name": "label_project_id_name_unique",+ "nullsNotDistinct": false,+ "columns": [+ "project_id",+ "name"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.label_group": {+ "name": "label_group",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "color": {+ "name": "color",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'#6b7280'"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "label_group_project_id_project_id_fk": {+ "name": "label_group_project_id_project_id_fk",+ "tableFrom": "label_group",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "label_group_project_id_name_unique": {+ "name": "label_group_project_id_name_unique",+ "nullsNotDistinct": false,+ "columns": [+ "project_id",+ "name"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.note_board": {+ "name": "note_board",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "owner_user_id": {+ "name": "owner_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "canvas": {+ "name": "canvas",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "note_board_project_idx": {+ "name": "note_board_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "updated_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "note_board_project_id_project_id_fk": {+ "name": "note_board_project_id_project_id_fk",+ "tableFrom": "note_board",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "note_board_owner_user_id_user_id_fk": {+ "name": "note_board_owner_user_id_user_id_fk",+ "tableFrom": "note_board",+ "tableTo": "user",+ "columnsFrom": [+ "owner_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "note_board_created_by_user_id_user_id_fk": {+ "name": "note_board_created_by_user_id_user_id_fk",+ "tableFrom": "note_board",+ "tableTo": "user",+ "columnsFrom": [+ "created_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.note_board_member": {+ "name": "note_board_member",+ "schema": "",+ "columns": {+ "board_id": {+ "name": "board_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "note_board_member_user_idx": {+ "name": "note_board_member_user_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "note_board_member_board_id_note_board_id_fk": {+ "name": "note_board_member_board_id_note_board_id_fk",+ "tableFrom": "note_board_member",+ "tableTo": "note_board",+ "columnsFrom": [+ "board_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "note_board_member_user_id_user_id_fk": {+ "name": "note_board_member_user_id_user_id_fk",+ "tableFrom": "note_board_member",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "note_board_member_board_id_user_id_pk": {+ "name": "note_board_member_board_id_user_id_pk",+ "columns": [+ "board_id",+ "user_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.notification": {+ "name": "notification",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "source_activity_id": {+ "name": "source_activity_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "actor_user_id": {+ "name": "actor_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "actor_name": {+ "name": "actor_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "read_at": {+ "name": "read_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "snoozed_until": {+ "name": "snoozed_until",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "notification_user_idx": {+ "name": "notification_user_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "created_at",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ },+ {+ "expression": "id",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "notification_user_unread_idx": {+ "name": "notification_user_unread_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "id",+ "isExpression": false,+ "asc": false,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"notification\".\"read_at\" IS NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "notification_user_id_user_id_fk": {+ "name": "notification_user_id_user_id_fk",+ "tableFrom": "notification",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "notification_project_id_project_id_fk": {+ "name": "notification_project_id_project_id_fk",+ "tableFrom": "notification",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "notification_issue_id_issue_id_fk": {+ "name": "notification_issue_id_issue_id_fk",+ "tableFrom": "notification",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "notification_source_activity_id_issue_activity_id_fk": {+ "name": "notification_source_activity_id_issue_activity_id_fk",+ "tableFrom": "notification",+ "tableTo": "issue_activity",+ "columnsFrom": [+ "source_activity_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "notification_actor_user_id_user_id_fk": {+ "name": "notification_actor_user_id_user_id_fk",+ "tableFrom": "notification",+ "tableTo": "user",+ "columnsFrom": [+ "actor_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "notification_type_check": {+ "name": "notification_type_check",+ "value": "\"notification\".\"type\" IN ('assigned', 'mentioned', 'commented', 'state_changed')"+ }+ },+ "isRLSEnabled": false+ },+ "public.notification_delivery": {+ "name": "notification_delivery",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "channel": {+ "name": "channel",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "recipient": {+ "name": "recipient",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "payload": {+ "name": "payload",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "attempts": {+ "name": "attempts",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "next_attempt_at": {+ "name": "next_attempt_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "last_error": {+ "name": "last_error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "notification_delivery_due_idx": {+ "name": "notification_delivery_due_idx",+ "columns": [+ {+ "expression": "next_attempt_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"notification_delivery\".\"status\" = 'pending'",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "notification_delivery_project_id_project_id_fk": {+ "name": "notification_delivery_project_id_project_id_fk",+ "tableFrom": "notification_delivery",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "notification_delivery_channel_check": {+ "name": "notification_delivery_channel_check",+ "value": "\"notification_delivery\".\"channel\" IN ('email', 'telegram')"+ }+ },+ "isRLSEnabled": false+ },+ "public.project": {+ "name": "project",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "team_id": {+ "name": "team_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "key": {+ "name": "key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "next_sequence": {+ "name": "next_sequence",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 1+ },+ "mcp_enabled": {+ "name": "mcp_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "initiatives_enabled": {+ "name": "initiatives_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "dashboards_enabled": {+ "name": "dashboards_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "documents_enabled": {+ "name": "documents_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "notes_enabled": {+ "name": "notes_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "cycles_enabled": {+ "name": "cycles_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "subtasks_enabled": {+ "name": "subtasks_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "checklists_enabled": {+ "name": "checklists_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "issue_stats_enabled": {+ "name": "issue_stats_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "points_estimate_enabled": {+ "name": "points_estimate_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "time_estimate_enabled": {+ "name": "time_estimate_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "time_logging_enabled": {+ "name": "time_logging_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "project_team_id_team_id_fk": {+ "name": "project_team_id_team_id_fk",+ "tableFrom": "project",+ "tableTo": "team",+ "columnsFrom": [+ "team_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "project_team_key_uq": {+ "name": "project_team_key_uq",+ "nullsNotDistinct": false,+ "columns": [+ "team_id",+ "key"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.project_action": {+ "name": "project_action",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "icon": {+ "name": "icon",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "condition": {+ "name": "condition",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "effect": {+ "name": "effect",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "position": {+ "name": "position",+ "type": "double precision",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "project_action_project_idx": {+ "name": "project_action_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "position",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_action_project_id_project_id_fk": {+ "name": "project_action_project_id_project_id_fk",+ "tableFrom": "project_action",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.project_column": {+ "name": "project_column",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "state_type": {+ "name": "state_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'unstarted'"+ },+ "color": {+ "name": "color",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'#6b7280'"+ },+ "position": {+ "name": "position",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "wip_limit": {+ "name": "wip_limit",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "wip_mode": {+ "name": "wip_mode",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'soft'"+ },+ "auto_assign_user_id": {+ "name": "auto_assign_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "project_column_project_id_project_id_fk": {+ "name": "project_column_project_id_project_id_fk",+ "tableFrom": "project_column",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_column_auto_assign_user_id_user_id_fk": {+ "name": "project_column_auto_assign_user_id_user_id_fk",+ "tableFrom": "project_column",+ "tableTo": "user",+ "columnsFrom": [+ "auto_assign_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "project_column_project_id_position_unique": {+ "name": "project_column_project_id_position_unique",+ "nullsNotDistinct": false,+ "columns": [+ "project_id",+ "position"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {+ "project_column_state_type_check": {+ "name": "project_column_state_type_check",+ "value": "\"project_column\".\"state_type\" IN ('backlog', 'unstarted', 'started', 'completed', 'canceled')"+ },+ "project_column_wip_mode_check": {+ "name": "project_column_wip_mode_check",+ "value": "\"project_column\".\"wip_mode\" IN ('soft', 'hard')"+ },+ "project_column_wip_limit_check": {+ "name": "project_column_wip_limit_check",+ "value": "\"project_column\".\"wip_limit\" IS NULL OR \"project_column\".\"wip_limit\" > 0"+ }+ },+ "isRLSEnabled": false+ },+ "public.project_dashboard": {+ "name": "project_dashboard",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "icon": {+ "name": "icon",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "layout": {+ "name": "layout",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "position": {+ "name": "position",+ "type": "double precision",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "project_dashboard_project_idx": {+ "name": "project_dashboard_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "position",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_dashboard_project_id_project_id_fk": {+ "name": "project_dashboard_project_id_project_id_fk",+ "tableFrom": "project_dashboard",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.project_document": {+ "name": "project_document",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "parent_id": {+ "name": "parent_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "content_json": {+ "name": "content_json",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "icon": {+ "name": "icon",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "full_width": {+ "name": "full_width",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "is_private": {+ "name": "is_private",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "is_locked": {+ "name": "is_locked",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "archived_at": {+ "name": "archived_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "archived_by_ancestor_id": {+ "name": "archived_by_ancestor_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "position": {+ "name": "position",+ "type": "double precision",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "version": {+ "name": "version",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 1+ },+ "owner_user_id": {+ "name": "owner_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "updated_by_user_id": {+ "name": "updated_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "project_document_project_tree_idx": {+ "name": "project_document_project_tree_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "parent_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "position",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_document_owner_idx": {+ "name": "project_document_owner_idx",+ "columns": [+ {+ "expression": "owner_user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "project_document_project_archive_idx": {+ "name": "project_document_project_archive_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "archived_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_document_project_id_project_id_fk": {+ "name": "project_document_project_id_project_id_fk",+ "tableFrom": "project_document",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_document_parent_id_project_document_id_fk": {+ "name": "project_document_parent_id_project_document_id_fk",+ "tableFrom": "project_document",+ "tableTo": "project_document",+ "columnsFrom": [+ "parent_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "project_document_archived_by_ancestor_id_project_document_id_fk": {+ "name": "project_document_archived_by_ancestor_id_project_document_id_fk",+ "tableFrom": "project_document",+ "tableTo": "project_document",+ "columnsFrom": [+ "archived_by_ancestor_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "project_document_owner_user_id_user_id_fk": {+ "name": "project_document_owner_user_id_user_id_fk",+ "tableFrom": "project_document",+ "tableTo": "user",+ "columnsFrom": [+ "owner_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "project_document_created_by_user_id_user_id_fk": {+ "name": "project_document_created_by_user_id_user_id_fk",+ "tableFrom": "project_document",+ "tableTo": "user",+ "columnsFrom": [+ "created_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "project_document_updated_by_user_id_user_id_fk": {+ "name": "project_document_updated_by_user_id_user_id_fk",+ "tableFrom": "project_document",+ "tableTo": "user",+ "columnsFrom": [+ "updated_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "project_document_version_check": {+ "name": "project_document_version_check",+ "value": "\"project_document\".\"version\" > 0"+ }+ },+ "isRLSEnabled": false+ },+ "public.project_document_initiative": {+ "name": "project_document_initiative",+ "schema": "",+ "columns": {+ "document_id": {+ "name": "document_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "initiative_id": {+ "name": "initiative_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "project_document_initiative_initiative_idx": {+ "name": "project_document_initiative_initiative_idx",+ "columns": [+ {+ "expression": "initiative_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_document_initiative_document_id_project_document_id_fk": {+ "name": "project_document_initiative_document_id_project_document_id_fk",+ "tableFrom": "project_document_initiative",+ "tableTo": "project_document",+ "columnsFrom": [+ "document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_document_initiative_initiative_id_initiative_id_fk": {+ "name": "project_document_initiative_initiative_id_initiative_id_fk",+ "tableFrom": "project_document_initiative",+ "tableTo": "initiative",+ "columnsFrom": [+ "initiative_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_document_initiative_created_by_user_id_user_id_fk": {+ "name": "project_document_initiative_created_by_user_id_user_id_fk",+ "tableFrom": "project_document_initiative",+ "tableTo": "user",+ "columnsFrom": [+ "created_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "project_document_initiative_document_id_initiative_id_pk": {+ "name": "project_document_initiative_document_id_initiative_id_pk",+ "columns": [+ "document_id",+ "initiative_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.project_document_issue": {+ "name": "project_document_issue",+ "schema": "",+ "columns": {+ "document_id": {+ "name": "document_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "issue_id": {+ "name": "issue_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "project_document_issue_issue_idx": {+ "name": "project_document_issue_issue_idx",+ "columns": [+ {+ "expression": "issue_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_document_issue_document_id_project_document_id_fk": {+ "name": "project_document_issue_document_id_project_document_id_fk",+ "tableFrom": "project_document_issue",+ "tableTo": "project_document",+ "columnsFrom": [+ "document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_document_issue_issue_id_issue_id_fk": {+ "name": "project_document_issue_issue_id_issue_id_fk",+ "tableFrom": "project_document_issue",+ "tableTo": "issue",+ "columnsFrom": [+ "issue_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_document_issue_created_by_user_id_user_id_fk": {+ "name": "project_document_issue_created_by_user_id_user_id_fk",+ "tableFrom": "project_document_issue",+ "tableTo": "user",+ "columnsFrom": [+ "created_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "project_document_issue_document_id_issue_id_pk": {+ "name": "project_document_issue_document_id_issue_id_pk",+ "columns": [+ "document_id",+ "issue_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.project_document_preference": {+ "name": "project_document_preference",+ "schema": "",+ "columns": {+ "document_id": {+ "name": "document_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "is_favorite": {+ "name": "is_favorite",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "project_document_preference_user_idx": {+ "name": "project_document_preference_user_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_document_preference_document_id_project_document_id_fk": {+ "name": "project_document_preference_document_id_project_document_id_fk",+ "tableFrom": "project_document_preference",+ "tableTo": "project_document",+ "columnsFrom": [+ "document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_document_preference_user_id_user_id_fk": {+ "name": "project_document_preference_user_id_user_id_fk",+ "tableFrom": "project_document_preference",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "project_document_preference_document_id_user_id_pk": {+ "name": "project_document_preference_document_id_user_id_pk",+ "columns": [+ "document_id",+ "user_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.project_document_revision": {+ "name": "project_document_revision",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "document_id": {+ "name": "document_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "version": {+ "name": "version",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "parent_id": {+ "name": "parent_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "content": {+ "name": "content",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "content_json": {+ "name": "content_json",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "icon": {+ "name": "icon",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "metadata": {+ "name": "metadata",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "full_width": {+ "name": "full_width",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "is_private": {+ "name": "is_private",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "is_locked": {+ "name": "is_locked",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "archived_at": {+ "name": "archived_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "position": {+ "name": "position",+ "type": "double precision",+ "primaryKey": false,+ "notNull": true+ },+ "owner_user_id": {+ "name": "owner_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_by_user_id": {+ "name": "created_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "project_document_revision_document_idx": {+ "name": "project_document_revision_document_idx",+ "columns": [+ {+ "expression": "document_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "version",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_document_revision_document_id_project_document_id_fk": {+ "name": "project_document_revision_document_id_project_document_id_fk",+ "tableFrom": "project_document_revision",+ "tableTo": "project_document",+ "columnsFrom": [+ "document_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_document_revision_owner_user_id_user_id_fk": {+ "name": "project_document_revision_owner_user_id_user_id_fk",+ "tableFrom": "project_document_revision",+ "tableTo": "user",+ "columnsFrom": [+ "owner_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "project_document_revision_created_by_user_id_user_id_fk": {+ "name": "project_document_revision_created_by_user_id_user_id_fk",+ "tableFrom": "project_document_revision",+ "tableTo": "user",+ "columnsFrom": [+ "created_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "project_document_revision_document_version_unique": {+ "name": "project_document_revision_document_version_unique",+ "nullsNotDistinct": false,+ "columns": [+ "document_id",+ "version"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.project_member": {+ "name": "project_member",+ "schema": "",+ "columns": {+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'member'"+ },+ "role_id": {+ "name": "role_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "description": {+ "name": "description",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "''"+ },+ "source": {+ "name": "source",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'invite'"+ },+ "is_favorite": {+ "name": "is_favorite",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "is_hidden": {+ "name": "is_hidden",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "project_member_user_idx": {+ "name": "project_member_user_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_member_project_id_project_id_fk": {+ "name": "project_member_project_id_project_id_fk",+ "tableFrom": "project_member",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_member_user_id_user_id_fk": {+ "name": "project_member_user_id_user_id_fk",+ "tableFrom": "project_member",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_member_role_id_team_role_id_fk": {+ "name": "project_member_role_id_team_role_id_fk",+ "tableFrom": "project_member",+ "tableTo": "team_role",+ "columnsFrom": [+ "role_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "project_member_project_id_user_id_pk": {+ "name": "project_member_project_id_user_id_pk",+ "columns": [+ "project_id",+ "user_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "project_member_role_check": {+ "name": "project_member_role_check",+ "value": "\"project_member\".\"role\" IN ('owner', 'member')"+ },+ "project_member_source_check": {+ "name": "project_member_source_check",+ "value": "\"project_member\".\"source\" IN ('invite', 'scim')"+ }+ },+ "isRLSEnabled": false+ },+ "public.project_setting": {+ "name": "project_setting",+ "schema": "",+ "columns": {+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "key": {+ "name": "key",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "value": {+ "name": "value",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "project_setting_project_id_project_id_fk": {+ "name": "project_setting_project_id_project_id_fk",+ "tableFrom": "project_setting",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "project_setting_project_id_key_pk": {+ "name": "project_setting_project_id_key_pk",+ "columns": [+ "project_id",+ "key"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.project_view": {+ "name": "project_view",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "icon": {+ "name": "icon",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "filters": {+ "name": "filters",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "display": {+ "name": "display",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "position": {+ "name": "position",+ "type": "double precision",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "share_token": {+ "name": "share_token",+ "type": "uuid",+ "primaryKey": false,+ "notNull": false+ },+ "share_extended": {+ "name": "share_extended",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "project_view_project_idx": {+ "name": "project_view_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "position",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "project_view_project_id_project_id_fk": {+ "name": "project_view_project_id_project_id_fk",+ "tableFrom": "project_view",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "project_view_share_token_unique": {+ "name": "project_view_share_token_unique",+ "nullsNotDistinct": false,+ "columns": [+ "share_token"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.project_view_favorite": {+ "name": "project_view_favorite",+ "schema": "",+ "columns": {+ "view_id": {+ "name": "view_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {},+ "foreignKeys": {+ "project_view_favorite_view_id_project_view_id_fk": {+ "name": "project_view_favorite_view_id_project_view_id_fk",+ "tableFrom": "project_view_favorite",+ "tableTo": "project_view",+ "columnsFrom": [+ "view_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "project_view_favorite_user_id_user_id_fk": {+ "name": "project_view_favorite_user_id_user_id_fk",+ "tableFrom": "project_view_favorite",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "project_view_favorite_view_id_user_id_pk": {+ "name": "project_view_favorite_view_id_user_id_pk",+ "columns": [+ "view_id",+ "user_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.revision": {+ "name": "revision",+ "schema": "",+ "columns": {+ "scope": {+ "name": "scope",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "rev": {+ "name": "rev",+ "type": "bigint",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ }+ },+ "indexes": {+ "revision_project_idx": {+ "name": "revision_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.team": {+ "name": "team",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "slug": {+ "name": "slug",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "mcp_enabled": {+ "name": "mcp_enabled",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "default_agent_ids": {+ "name": "default_agent_ids",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "team_slug_unique": {+ "name": "team_slug_unique",+ "nullsNotDistinct": false,+ "columns": [+ "slug"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.team_invite": {+ "name": "team_invite",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "token": {+ "name": "token",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "team_id": {+ "name": "team_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "email": {+ "name": "email",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "team_role": {+ "name": "team_role",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'member'"+ },+ "project_role": {+ "name": "project_role",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "role_id": {+ "name": "role_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "invited_by_user_id": {+ "name": "invited_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "accepted_by_user_id": {+ "name": "accepted_by_user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "responded_at": {+ "name": "responded_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ }+ },+ "indexes": {+ "team_invite_team_pending_uq": {+ "name": "team_invite_team_pending_uq",+ "columns": [+ {+ "expression": "team_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "email",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"team_invite\".\"status\" = 'pending' AND \"team_invite\".\"project_id\" IS NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "team_invite_project_pending_uq": {+ "name": "team_invite_project_pending_uq",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ },+ {+ "expression": "email",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"team_invite\".\"status\" = 'pending' AND \"team_invite\".\"project_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "team_invite_team_idx": {+ "name": "team_invite_team_idx",+ "columns": [+ {+ "expression": "team_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "team_invite_project_idx": {+ "name": "team_invite_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "team_invite_team_id_team_id_fk": {+ "name": "team_invite_team_id_team_id_fk",+ "tableFrom": "team_invite",+ "tableTo": "team",+ "columnsFrom": [+ "team_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "team_invite_project_id_project_id_fk": {+ "name": "team_invite_project_id_project_id_fk",+ "tableFrom": "team_invite",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "team_invite_role_id_team_role_id_fk": {+ "name": "team_invite_role_id_team_role_id_fk",+ "tableFrom": "team_invite",+ "tableTo": "team_role",+ "columnsFrom": [+ "role_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "team_invite_invited_by_user_id_user_id_fk": {+ "name": "team_invite_invited_by_user_id_user_id_fk",+ "tableFrom": "team_invite",+ "tableTo": "user",+ "columnsFrom": [+ "invited_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ },+ "team_invite_accepted_by_user_id_user_id_fk": {+ "name": "team_invite_accepted_by_user_id_user_id_fk",+ "tableFrom": "team_invite",+ "tableTo": "user",+ "columnsFrom": [+ "accepted_by_user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "team_invite_token_unique": {+ "name": "team_invite_token_unique",+ "nullsNotDistinct": false,+ "columns": [+ "token"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {+ "team_invite_team_role_check": {+ "name": "team_invite_team_role_check",+ "value": "\"team_invite\".\"team_role\" IN ('owner', 'manager', 'member')"+ },+ "team_invite_project_role_check": {+ "name": "team_invite_project_role_check",+ "value": "(\"team_invite\".\"project_id\" IS NULL AND \"team_invite\".\"project_role\" IS NULL)\n OR (\"team_invite\".\"project_id\" IS NOT NULL AND \"team_invite\".\"project_role\" IN ('owner', 'member'))"+ },+ "team_invite_status_check": {+ "name": "team_invite_status_check",+ "value": "\"team_invite\".\"status\" IN ('pending', 'accepted', 'rejected')"+ }+ },+ "isRLSEnabled": false+ },+ "public.team_member": {+ "name": "team_member",+ "schema": "",+ "columns": {+ "team_id": {+ "name": "team_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'member'"+ },+ "source": {+ "name": "source",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'invite'"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "team_member_user_idx": {+ "name": "team_member_user_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "team_member_team_id_team_id_fk": {+ "name": "team_member_team_id_team_id_fk",+ "tableFrom": "team_member",+ "tableTo": "team",+ "columnsFrom": [+ "team_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "team_member_user_id_user_id_fk": {+ "name": "team_member_user_id_user_id_fk",+ "tableFrom": "team_member",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "team_member_team_id_user_id_pk": {+ "name": "team_member_team_id_user_id_pk",+ "columns": [+ "team_id",+ "user_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "team_member_role_check": {+ "name": "team_member_role_check",+ "value": "\"team_member\".\"role\" IN ('owner', 'manager', 'member', 'agent')"+ },+ "team_member_source_check": {+ "name": "team_member_source_check",+ "value": "\"team_member\".\"source\" IN ('invite', 'scim')"+ }+ },+ "isRLSEnabled": false+ },+ "public.team_notification_setting": {+ "name": "team_notification_setting",+ "schema": "",+ "columns": {+ "team_id": {+ "name": "team_id",+ "type": "integer",+ "primaryKey": true,+ "notNull": true+ },+ "ciphertext": {+ "name": "ciphertext",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "iv": {+ "name": "iv",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "auth_tag": {+ "name": "auth_tag",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "redacted": {+ "name": "redacted",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "team_notification_setting_team_id_team_id_fk": {+ "name": "team_notification_setting_team_id_team_id_fk",+ "tableFrom": "team_notification_setting",+ "tableTo": "team",+ "columnsFrom": [+ "team_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.team_role": {+ "name": "team_role",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "team_id": {+ "name": "team_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "is_default": {+ "name": "is_default",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "permissions": {+ "name": "permissions",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "team_role_default_uq": {+ "name": "team_role_default_uq",+ "columns": [+ {+ "expression": "team_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"team_role\".\"is_default\"",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "team_role_team_idx": {+ "name": "team_role_team_idx",+ "columns": [+ {+ "expression": "team_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "team_role_team_id_team_id_fk": {+ "name": "team_role_team_id_team_id_fk",+ "tableFrom": "team_role",+ "tableTo": "team",+ "columnsFrom": [+ "team_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "team_role_team_id_name_unique": {+ "name": "team_role_team_id_name_unique",+ "nullsNotDistinct": false,+ "columns": [+ "team_id",+ "name"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.user_notification_preference": {+ "name": "user_notification_preference",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "email_events": {+ "name": "email_events",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "telegram_events": {+ "name": "telegram_events",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'{}'::jsonb"+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "user_notification_preference_user_id_user_id_fk": {+ "name": "user_notification_preference_user_id_user_id_fk",+ "tableFrom": "user_notification_preference",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "user_notification_preference_project_id_project_id_fk": {+ "name": "user_notification_preference_project_id_project_id_fk",+ "tableFrom": "user_notification_preference",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "user_notification_pref_user_project_unique": {+ "name": "user_notification_pref_user_project_unique",+ "nullsNotDistinct": false,+ "columns": [+ "user_id",+ "project_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.user_preference": {+ "name": "user_preference",+ "schema": "",+ "columns": {+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "timezone": {+ "name": "timezone",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'UTC'"+ },+ "locale": {+ "name": "locale",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'en'"+ },+ "theme": {+ "name": "theme",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'system'"+ },+ "issue_open_mode": {+ "name": "issue_open_mode",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'panel'"+ },+ "start_page": {+ "name": "start_page",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'work-items'"+ },+ "show_chat_by_default": {+ "name": "show_chat_by_default",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": false+ },+ "issue_stats_open": {+ "name": "issue_stats_open",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "issue_stats_view": {+ "name": "issue_stats_view",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'compact'"+ },+ "issue_activity_view": {+ "name": "issue_activity_view",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'flat'"+ },+ "auto_watch": {+ "name": "auto_watch",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "hotkeys": {+ "name": "hotkeys",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": false+ },+ "last_project_id": {+ "name": "last_project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "seen_version": {+ "name": "seen_version",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "user_preference_user_id_user_id_fk": {+ "name": "user_preference_user_id_user_id_fk",+ "tableFrom": "user_preference",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "user_preference_last_project_id_project_id_fk": {+ "name": "user_preference_last_project_id_project_id_fk",+ "tableFrom": "user_preference",+ "tableTo": "project",+ "columnsFrom": [+ "last_project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {+ "user_preference_theme_check": {+ "name": "user_preference_theme_check",+ "value": "\"user_preference\".\"theme\" IN ('light', 'dark', 'system')"+ },+ "user_preference_issue_open_mode_check": {+ "name": "user_preference_issue_open_mode_check",+ "value": "\"user_preference\".\"issue_open_mode\" IN ('panel', 'page')"+ },+ "user_preference_start_page_check": {+ "name": "user_preference_start_page_check",+ "value": "\"user_preference\".\"start_page\" IN ('inbox', 'dashboard', 'work-items', 'initiatives')"+ },+ "user_preference_issue_stats_view_check": {+ "name": "user_preference_issue_stats_view_check",+ "value": "\"user_preference\".\"issue_stats_view\" IN ('compact', 'timeline')"+ },+ "user_preference_issue_activity_view_check": {+ "name": "user_preference_issue_activity_view_check",+ "value": "\"user_preference\".\"issue_activity_view\" IN ('flat', 'grouped')"+ }+ },+ "isRLSEnabled": false+ },+ "public.user_telegram_account": {+ "name": "user_telegram_account",+ "schema": "",+ "columns": {+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": true,+ "notNull": true+ },+ "chat_id": {+ "name": "chat_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "username": {+ "name": "username",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "first_name": {+ "name": "first_name",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "link_code": {+ "name": "link_code",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "link_code_expires_at": {+ "name": "link_code_expires_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "linked_at": {+ "name": "linked_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "user_telegram_account_chat_id_unique": {+ "name": "user_telegram_account_chat_id_unique",+ "columns": [+ {+ "expression": "chat_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"user_telegram_account\".\"chat_id\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "user_telegram_account_link_code_unique": {+ "name": "user_telegram_account_link_code_unique",+ "columns": [+ {+ "expression": "link_code",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": true,+ "where": "\"user_telegram_account\".\"link_code\" IS NOT NULL",+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "user_telegram_account_user_id_user_id_fk": {+ "name": "user_telegram_account_user_id_user_id_fk",+ "tableFrom": "user_telegram_account",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.webhook": {+ "name": "webhook",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "url": {+ "name": "url",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "secret": {+ "name": "secret",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "events": {+ "name": "events",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true,+ "default": "'[]'::jsonb"+ },+ "is_active": {+ "name": "is_active",+ "type": "boolean",+ "primaryKey": false,+ "notNull": true,+ "default": true+ },+ "consecutive_failures": {+ "name": "consecutive_failures",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "webhook_project_idx": {+ "name": "webhook_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "webhook_project_id_project_id_fk": {+ "name": "webhook_project_id_project_id_fk",+ "tableFrom": "webhook",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.webhook_delivery": {+ "name": "webhook_delivery",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "webhook_id": {+ "name": "webhook_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "event_id": {+ "name": "event_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "event_type": {+ "name": "event_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "payload": {+ "name": "payload",+ "type": "jsonb",+ "primaryKey": false,+ "notNull": true+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'pending'"+ },+ "attempts": {+ "name": "attempts",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "default": 0+ },+ "next_attempt_at": {+ "name": "next_attempt_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "last_error": {+ "name": "last_error",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "response_status": {+ "name": "response_status",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "response_body": {+ "name": "response_body",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "webhook_delivery_due_idx": {+ "name": "webhook_delivery_due_idx",+ "columns": [+ {+ "expression": "next_attempt_at",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "where": "\"webhook_delivery\".\"status\" = 'pending'",+ "concurrently": false,+ "method": "btree",+ "with": {}+ },+ "webhook_delivery_webhook_idx": {+ "name": "webhook_delivery_webhook_idx",+ "columns": [+ {+ "expression": "webhook_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "webhook_delivery_webhook_id_webhook_id_fk": {+ "name": "webhook_delivery_webhook_id_webhook_id_fk",+ "tableFrom": "webhook_delivery",+ "tableTo": "webhook",+ "columnsFrom": [+ "webhook_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.scim_group": {+ "name": "scim_group",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "uuid",+ "primaryKey": true,+ "notNull": true,+ "default": "gen_random_uuid()"+ },+ "display_name": {+ "name": "display_name",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ },+ "external_id": {+ "name": "external_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "scim_group_display_name_unique": {+ "name": "scim_group_display_name_unique",+ "nullsNotDistinct": false,+ "columns": [+ "display_name"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ },+ "public.scim_group_mapping": {+ "name": "scim_group_mapping",+ "schema": "",+ "columns": {+ "id": {+ "name": "id",+ "type": "serial",+ "primaryKey": true,+ "notNull": true+ },+ "group_id": {+ "name": "group_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "project_id": {+ "name": "project_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": true+ },+ "role": {+ "name": "role",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "default": "'member'"+ },+ "role_id": {+ "name": "role_id",+ "type": "integer",+ "primaryKey": false,+ "notNull": false+ },+ "created_at": {+ "name": "created_at",+ "type": "timestamp with time zone",+ "primaryKey": false,+ "notNull": true,+ "default": "now()"+ }+ },+ "indexes": {+ "scim_group_mapping_project_idx": {+ "name": "scim_group_mapping_project_idx",+ "columns": [+ {+ "expression": "project_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "scim_group_mapping_group_id_scim_group_id_fk": {+ "name": "scim_group_mapping_group_id_scim_group_id_fk",+ "tableFrom": "scim_group_mapping",+ "tableTo": "scim_group",+ "columnsFrom": [+ "group_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "scim_group_mapping_project_id_project_id_fk": {+ "name": "scim_group_mapping_project_id_project_id_fk",+ "tableFrom": "scim_group_mapping",+ "tableTo": "project",+ "columnsFrom": [+ "project_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "scim_group_mapping_role_id_team_role_id_fk": {+ "name": "scim_group_mapping_role_id_team_role_id_fk",+ "tableFrom": "scim_group_mapping",+ "tableTo": "team_role",+ "columnsFrom": [+ "role_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {+ "scim_group_mapping_group_id_project_id_unique": {+ "name": "scim_group_mapping_group_id_project_id_unique",+ "nullsNotDistinct": false,+ "columns": [+ "group_id",+ "project_id"+ ]+ }+ },+ "policies": {},+ "checkConstraints": {+ "scim_group_mapping_role_check": {+ "name": "scim_group_mapping_role_check",+ "value": "\"scim_group_mapping\".\"role\" IN ('owner', 'member')"+ }+ },+ "isRLSEnabled": false+ },+ "public.scim_group_member": {+ "name": "scim_group_member",+ "schema": "",+ "columns": {+ "group_id": {+ "name": "group_id",+ "type": "uuid",+ "primaryKey": false,+ "notNull": true+ },+ "user_id": {+ "name": "user_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true+ }+ },+ "indexes": {+ "scim_group_member_user_idx": {+ "name": "scim_group_member_user_idx",+ "columns": [+ {+ "expression": "user_id",+ "isExpression": false,+ "asc": true,+ "nulls": "last"+ }+ ],+ "isUnique": false,+ "concurrently": false,+ "method": "btree",+ "with": {}+ }+ },+ "foreignKeys": {+ "scim_group_member_group_id_scim_group_id_fk": {+ "name": "scim_group_member_group_id_scim_group_id_fk",+ "tableFrom": "scim_group_member",+ "tableTo": "scim_group",+ "columnsFrom": [+ "group_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "scim_group_member_user_id_user_id_fk": {+ "name": "scim_group_member_user_id_user_id_fk",+ "tableFrom": "scim_group_member",+ "tableTo": "user",+ "columnsFrom": [+ "user_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {+ "scim_group_member_group_id_user_id_pk": {+ "name": "scim_group_member_group_id_user_id_pk",+ "columns": [+ "group_id",+ "user_id"+ ]+ }+ },+ "uniqueConstraints": {},+ "policies": {},+ "checkConstraints": {},+ "isRLSEnabled": false+ }+ },+ "enums": {},+ "schemas": {},+ "sequences": {},+ "roles": {},+ "policies": {},+ "views": {},+ "_meta": {+ "columns": {},+ "schemas": {},+ "tables": {}+ }+}\ No newline at end of filediff --git a/packages/db/drizzle/meta/_journal.json b/packages/db/drizzle/meta/_journal.jsonindex 0e0006bd..caf79ebb 100644--- a/packages/db/drizzle/meta/_journal.json+++ b/packages/db/drizzle/meta/_journal.json@@ -939,6 +939,13 @@"when": 1790324657744,"tag": "0133_repositories_permission","breakpoints": true+ },+ {+ "idx": 134,+ "version": "7",+ "when": 1790334902773,+ "tag": "0134_team_scoped_project_key",+ "breakpoints": true}]}\ No newline at end of filediff --git a/packages/db/src/permissions.ts b/packages/db/src/permissions.tsindex a007871a..1238c2c6 100644--- a/packages/db/src/permissions.ts+++ b/packages/db/src/permissions.ts@@ -1,8 +1,7 @@// Permission model for team roles. A role carries a matrix: for each resource the// create/edit/read/delete flags. The matrix is stored as jsonb on team_role and// enforced by the API (apps/api/src/shared/access.ts). Owners bypass the matrix-// entirely (full access). It lives here because both the API and the sign-up hook-// in @repo/auth, which seeds a new team's default role, write it.+// entirely (full access).export const PERMISSION_RESOURCES = ['work_items',diff --git a/packages/db/src/schema/app.ts b/packages/db/src/schema/app.tsindex a4555551..487e72cd 100644--- a/packages/db/src/schema/app.ts+++ b/packages/db/src/schema/app.ts@@ -49,12 +49,14 @@ export const appSecret = pgTable('app_secret', {updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),});-// A team owns projects and holds its own member list. Every account is given one at-// registration, named after its username, and every project belongs to exactly one-// team.+// A team owns projects and holds its own member list. Every project belongs to exactly+// one team.export const team = pgTable('team', {id: serial('id').primaryKey(),name: text('name').notNull(),+ // The team's segment in web URLs (/acme/MKT). Null until an owner sets one; the+ // team id stands in for it until then.+ slug: text('slug').unique(),// Whether the team is reachable through the MCP server at all. Off closes both the// team's own resources (agents, skills, tools, roles, integrations) and every// project it owns, whatever each project's own flag says.@@ -98,41 +100,45 @@ export const teamMember = pgTable(// issues. next_sequence is the atomic counter behind each issue's human// identifier (e.g. "MKT-42"): incrementing it under a row lock keeps concurrent// creates from colliding.-export const project = pgTable('project', {- id: serial('id').primaryKey(),- teamId: integer('team_id')- .notNull()- .references(() => team.id, { onDelete: 'cascade' }),- key: text('key').notNull().unique(),- name: text('name').notNull(),- description: text('description').notNull().default(''),- nextSequence: integer('next_sequence').notNull().default(1),- // Whether this project is in the team's MCP reach. Managed from the team's MCP- // settings, not from the project, and only counts while team.mcp_enabled is on.- // The starting value is the instance-wide project default set in god mode.- mcpEnabled: boolean('mcp_enabled').notNull().default(false),- // Optional sections of the app, toggled per project in Settings -> Features. All- // on by default. Turning one off only hides its UI; the rows it owns stay and- // come back with it.- initiativesEnabled: boolean('initiatives_enabled').notNull().default(true),- dashboardsEnabled: boolean('dashboards_enabled').notNull().default(true),- documentsEnabled: boolean('documents_enabled').notNull().default(true),- notesEnabled: boolean('notes_enabled').notNull().default(true),- cyclesEnabled: boolean('cycles_enabled').notNull().default(true),- subtasksEnabled: boolean('subtasks_enabled').notNull().default(true),- checklistsEnabled: boolean('checklists_enabled').notNull().default(true),- issueStatsEnabled: boolean('issue_stats_enabled').notNull().default(true),- // Which kinds of estimate the issues of this project carry, set in Settings ->- // Configuration. Both off by default; turning one off hides its UI and keeps the- // values, which show again when it is turned back on.- pointsEstimateEnabled: boolean('points_estimate_enabled').notNull().default(false),- timeEstimateEnabled: boolean('time_estimate_enabled').notNull().default(false),- // Whether members log the time they spend on the issues of this project, set in- // the same place. Independent of the time estimate: a team can log time without- // estimating first. Turning it off hides the entries and keeps them.- timeLoggingEnabled: boolean('time_logging_enabled').notNull().default(false),- createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),-});+export const project = pgTable(+ 'project',+ {+ id: serial('id').primaryKey(),+ teamId: integer('team_id')+ .notNull()+ .references(() => team.id, { onDelete: 'cascade' }),+ key: text('key').notNull(),+ name: text('name').notNull(),+ description: text('description').notNull().default(''),+ nextSequence: integer('next_sequence').notNull().default(1),+ // Whether this project is in the team's MCP reach. Managed from the team's MCP+ // settings, not from the project, and only counts while team.mcp_enabled is on.+ // The starting value is the instance-wide project default set in god mode.+ mcpEnabled: boolean('mcp_enabled').notNull().default(false),+ // Optional sections of the app, toggled per project in Settings -> Features. All+ // on by default. Turning one off only hides its UI; the rows it owns stay and+ // come back with it.+ initiativesEnabled: boolean('initiatives_enabled').notNull().default(true),+ dashboardsEnabled: boolean('dashboards_enabled').notNull().default(true),+ documentsEnabled: boolean('documents_enabled').notNull().default(true),+ notesEnabled: boolean('notes_enabled').notNull().default(true),+ cyclesEnabled: boolean('cycles_enabled').notNull().default(true),+ subtasksEnabled: boolean('subtasks_enabled').notNull().default(true),+ checklistsEnabled: boolean('checklists_enabled').notNull().default(true),+ issueStatsEnabled: boolean('issue_stats_enabled').notNull().default(true),+ // Which kinds of estimate the issues of this project carry, set in Settings ->+ // Configuration. Both off by default; turning one off hides its UI and keeps the+ // values, which show again when it is turned back on.+ pointsEstimateEnabled: boolean('points_estimate_enabled').notNull().default(false),+ timeEstimateEnabled: boolean('time_estimate_enabled').notNull().default(false),+ // Whether members log the time they spend on the issues of this project, set in+ // the same place. Independent of the time estimate: a team can log time without+ // estimating first. Turning it off hides the entries and keeps them.+ timeLoggingEnabled: boolean('time_logging_enabled').notNull().default(false),+ createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),+ },+ (t) => [unique('project_team_key_uq').on(t.teamId, t.key)],+);// Per-project key-value settings, mirroring app_setting but scoped to a project.// The value is a jsonb blob owned by whatever feature reads the key, so one table