Skip to content

⭐️⭐️⭐️ 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.

feat: improve Docs navigation and collaborative editing (#386)

I'm Groot 🌳0ff436b1982e
diff --git a/apps/api/package.json b/apps/api/package.json
index 60b2f42f..0e044bb7 100644
--- a/apps/api/package.json
+++ b/apps/api/package.json
@@ -33,6 +33,7 @@
"@repo/db": "workspace:*",
"@repo/mailer": "workspace:*",
"@repo/net": "workspace:*",
+ "@tiptap/pm": "3.30.5",
"croner": "^10.0.1",
"decode-named-character-reference": "^1.3.0",
"drizzle-orm": "^0.45.2",
diff --git a/apps/api/src/modules/documents/__tests__/integration/collaboration.test.ts b/apps/api/src/modules/documents/__tests__/integration/collaboration.test.ts
new file mode 100644
index 00000000..4d7db305
--- /dev/null
+++ b/apps/api/src/modules/documents/__tests__/integration/collaboration.test.ts
@@ -0,0 +1,295 @@
+import { beforeEach, describe, expect, it } from 'bun:test';
+import { authedApi } from '#tests/helpers/app';
+import { signUpTestUser } from '#tests/helpers/auth';
+import { resetDb } from '#tests/helpers/db';
+
+const contentJson = {
+ type: 'doc',
+ content: [{ type: 'paragraph', content: [{ type: 'text', text: 'Hello world' }] }],
+};
+async function setup() {
+ const owner = await signUpTestUser();
+ const client = authedApi(owner.cookie);
+ await client.projects.post({ key: 'DOC', name: 'Documents' });
+ const routes = client.projects({ projectKey: 'DOC' }).documents;
+ const created = await routes.post({ title: 'Shared', content: 'Hello world', contentJson });
+ const doc = routes({ documentId: created.data!.id });
+ const opened = await doc.session.post({ version: created.data!.version, contentJson });
+ expect(opened.status).toBe(200);
+ return { client, doc, id: created.data!.id, session: opened.data! };
+}
+const insert = (from: number, text: string) => ({
+ stepType: 'replace',
+ from,
+ to: from,
+ slice: { content: [{ type: 'text', text }] },
+});
+
+describe('collaborative documents', () => {
+ beforeEach(resetDb);
+ it('accepts ordered changes, rejects stale writers, and exposes steps for rebasing', async () => {
+ const { doc, session } = await setup();
+ const first = await doc.steps.post({
+ epoch: session.epoch,
+ version: 0,
+ clientId: 'alice',
+ steps: [insert(1, 'A')],
+ content: 'AHello world',
+ });
+ expect(first.status).toBe(200);
+ expect(
+ (
+ await doc.steps.post({
+ epoch: session.epoch,
+ version: 0,
+ clientId: 'bob',
+ steps: [insert(1, 'B')],
+ content: 'BHello world',
+ })
+ ).status,
+ ).toBe(409);
+ const changes = await doc.steps.get({ query: { epoch: session.epoch, version: 0 } });
+ expect(changes.data).toMatchObject({
+ version: 1,
+ hasMore: false,
+ steps: [{ clientId: 'alice' }],
+ });
+ expect(
+ (
+ await doc.steps.post({
+ epoch: session.epoch,
+ version: 1,
+ clientId: 'bob',
+ steps: [insert(2, 'B')],
+ content: 'ABHello world',
+ })
+ ).status,
+ ).toBe(200);
+ expect((await doc.get()).data!.contentJson).toMatchObject({
+ content: [{ content: [{ text: 'ABHello world' }] }],
+ });
+ expect((await doc.revisions.get()).data!.length).toBeGreaterThan(1);
+ });
+ it('keeps a session across title changes but refuses replaced content and locked pages', async () => {
+ const { doc, session } = await setup();
+ let current = (await doc.get()).data!;
+ expect((await doc.patch({ version: current.version, title: 'Renamed' })).status).toBe(200);
+ expect(
+ (
+ await doc.steps.post({
+ epoch: session.epoch,
+ version: 0,
+ clientId: 'alice',
+ steps: [insert(1, 'A')],
+ content: 'AHello world',
+ })
+ ).status,
+ ).toBe(200);
+ current = (await doc.get()).data!;
+ await doc.lock.post({ version: current.version });
+ expect(
+ (
+ await doc.steps.post({
+ epoch: session.epoch,
+ version: 1,
+ clientId: 'alice',
+ steps: [insert(1, 'B')],
+ content: 'BAHello world',
+ })
+ ).status,
+ ).toBe(409);
+ });
+ it('reopens rich content with the exact attributes emitted by the editor', async () => {
+ const { doc } = await setup();
+ const paragraph = {
+ type: 'paragraph',
+ attrs: { blockId: 'paragraph', textAlign: null },
+ content: [
+ {
+ type: 'text',
+ text: 'Linked',
+ marks: [
+ {
+ type: 'link',
+ attrs: {
+ href: '/project/DOC',
+ target: '_blank',
+ rel: 'noopener noreferrer nofollow',
+ class: null,
+ title: null,
+ },
+ },
+ ],
+ },
+ ],
+ };
+ const rich = {
+ type: 'doc',
+ content: [
+ paragraph,
+ {
+ type: 'bulletList',
+ attrs: { blockId: 'bullet', tight: true },
+ content: [{ type: 'listItem', content: [paragraph] }],
+ },
+ {
+ type: 'orderedList',
+ attrs: { blockId: 'ordered', tight: true, start: 1, type: null },
+ content: [{ type: 'listItem', content: [paragraph] }],
+ },
+ {
+ type: 'image',
+ attrs: {
+ blockId: 'image',
+ src: 'https://example.com/image.png',
+ alt: null,
+ title: null,
+ width: null,
+ style: null,
+ },
+ },
+ {
+ type: 'table',
+ attrs: { blockId: 'table' },
+ content: [
+ {
+ type: 'tableRow',
+ content: [
+ {
+ type: 'tableCell',
+ attrs: { colspan: 1, rowspan: 1, colwidth: null, align: null },
+ content: [paragraph],
+ },
+ ],
+ },
+ ],
+ },
+ ],
+ };
+ const current = (await doc.get()).data!;
+ const replaced = await doc.patch({
+ version: current.version,
+ content: 'Linked',
+ contentJson: rich,
+ });
+ expect(replaced.status).toBe(200);
+ const first = await doc.session.post({ version: replaced.data!.version, contentJson: rich });
+ expect(first.status).toBe(200);
+ const second = await doc.session.post({
+ version: replaced.data!.version,
+ contentJson: first.data!.contentJson,
+ });
+ expect(second.status).toBe(200);
+ expect(second.data!.epoch).toBe(first.data!.epoch);
+ expect(
+ (
+ await doc.steps.post({
+ epoch: first.data!.epoch,
+ version: 0,
+ clientId: 'rich',
+ steps: [insert(1, 'A')],
+ content: 'ALinked',
+ })
+ ).status,
+ ).toBe(200);
+ });
+ it('invalidates active sessions on Markdown-only replacement', async () => {
+ const { doc, session } = await setup();
+ const current = (await doc.get()).data!;
+ expect((await doc.patch({ version: current.version, content: 'Replacement' })).status).toBe(
+ 200,
+ );
+ expect((await doc.get()).data!.contentJson).toBeNull();
+ expect((await doc.steps.get({ query: { epoch: session.epoch, version: 0 } })).status).toBe(409);
+ });
+ it('rejects invalid structures, links and out-of-bounds transformations', async () => {
+ const { doc, session } = await setup();
+ const invalid = [insert(99999, 'bad')];
+ expect(
+ (
+ await doc.steps.post({
+ epoch: session.epoch,
+ version: 0,
+ clientId: 'bad',
+ steps: invalid,
+ content: 'bad',
+ })
+ ).status,
+ ).toBe(400);
+ const link = {
+ stepType: 'addMark',
+ from: 1,
+ to: 4,
+ mark: { type: 'link', attrs: { href: 'javascript:alert(1)' } },
+ };
+ expect(
+ (
+ await doc.steps.post({
+ epoch: session.epoch,
+ version: 0,
+ clientId: 'bad',
+ steps: [link],
+ content: 'bad',
+ })
+ ).status,
+ ).toBe(400);
+ expect(
+ (await doc.steps.get({ query: { epoch: session.epoch, version: 0 } })).data!.version,
+ ).toBe(0);
+ });
+ it('anchors discussions, maps selections through edits and preserves removed quotations', async () => {
+ const { doc, session } = await setup();
+ const version = (await doc.get()).data!.version;
+ const comment = await doc.comments.post({
+ body: 'Please clarify',
+ quote: 'Hello',
+ from: 1,
+ to: 6,
+ version,
+ });
+ expect(comment.status).toBe(201);
+ expect(
+ (await doc.comments.post({ body: 'Invalid', quote: 'Other', from: 1, to: 6, version }))
+ .status,
+ ).toBe(409);
+ await doc.steps.post({
+ epoch: session.epoch,
+ version: 0,
+ clientId: 'alice',
+ steps: [insert(1, 'A')],
+ content: 'AHello world',
+ });
+ expect((await doc.comments.get()).data![0]).toMatchObject({ from: 2, to: 7, orphaned: false });
+ await doc.steps.post({
+ epoch: session.epoch,
+ version: 1,
+ clientId: 'alice',
+ steps: [{ stepType: 'replace', from: 2, to: 7 }],
+ content: 'A world',
+ });
+ expect((await doc.comments.get()).data![0]).toMatchObject({ quote: 'Hello', orphaned: true });
+ const reply = await doc.comments.post({ parentId: comment.data!.id, body: 'Agreed', version });
+ expect(reply.status).toBe(201);
+ expect(
+ (await doc.comments({ commentId: comment.data!.id }).patch({ resolved: true })).status,
+ ).toBe(200);
+ expect((await doc.comments.get()).data![0].resolvedAt).not.toBeNull();
+ });
+ it('refuses non-members and does not expose private document sessions or comments', async () => {
+ const { client, doc, id, session } = await setup();
+ const stranger = await signUpTestUser();
+ const outsider = authedApi(stranger.cookie);
+ const other = outsider.projects({ projectKey: 'DOC' }).documents({ documentId: id });
+ expect((await other.steps.get({ query: { epoch: session.epoch, version: 0 } })).status).toBe(
+ 403,
+ );
+ const invite = await client
+ .projects({ projectKey: 'DOC' })
+ .invites.post({ email: stranger.email, role: 'member' });
+ await outsider.invites({ token: invite.data!.token }).accept.post();
+ const current = (await doc.get()).data!;
+ await doc.access.post({ version: current.version, isPrivate: true });
+ expect((await other.comments.get()).status).toBe(404);
+ expect((await other.session.post({ version: current.version, contentJson })).status).toBe(404);
+ });
+});
diff --git a/apps/api/src/modules/documents/collaboration-routes.ts b/apps/api/src/modules/documents/collaboration-routes.ts
new file mode 100644
index 00000000..336010fe
--- /dev/null
+++ b/apps/api/src/modules/documents/collaboration-routes.ts
@@ -0,0 +1,112 @@
+import { Elysia, t } from 'elysia';
+import { authContext } from '#shared/auth-context';
+import { guards } from '#shared/guards';
+import { requireUser } from '#shared/access';
+import { commonErrors, errors } from '#shared/responses';
+import { openDocumentSession, getDocumentSteps, saveDocumentSteps } from './collaboration';
+import { addDocumentComment, listDocumentComments, updateDocumentComment } from './comments';
+import {
+ collaborationOpenBody,
+ collaborationQuery,
+ collaborationSaveBody,
+ collaborationSessionResponse,
+ collaborationStepsResponse,
+ documentParams,
+ DocumentResponse,
+ documentCommentParams,
+ documentCommentBody,
+ documentCommentUpdateBody,
+ documentCommentResponse,
+} from './model';
+
+export const documentCollaborationRoutes = new Elysia({
+ name: 'document-collaboration',
+ detail: { tags: ['Documents'] },
+})
+ .use(authContext)
+ .use(guards)
+ .post(
+ '/projects/:projectKey/documents/:documentId/session',
+ ({ project, params, user, body }) =>
+ openDocumentSession(project.id, params.documentId, requireUser(user).id, body),
+ {
+ permission: ['documents', 'edit'],
+ params: documentParams,
+ body: collaborationOpenBody,
+ response: { 200: collaborationSessionResponse, ...commonErrors, ...errors(409) },
+ detail: { summary: 'Join a collaborative document session' },
+ },
+ )
+ .get(
+ '/projects/:projectKey/documents/:documentId/steps',
+ ({ project, params, user, query }) =>
+ getDocumentSteps(
+ project.id,
+ params.documentId,
+ requireUser(user).id,
+ query.epoch,
+ query.version,
+ ),
+ {
+ permission: ['documents', 'read'],
+ params: documentParams,
+ query: collaborationQuery,
+ response: { 200: collaborationStepsResponse, ...commonErrors, ...errors(409) },
+ detail: { summary: 'Receive collaborative document changes' },
+ },
+ )
+ .post(
+ '/projects/:projectKey/documents/:documentId/steps',
+ ({ project, params, user, body }) =>
+ saveDocumentSteps(project.id, params.documentId, requireUser(user).id, body),
+ {
+ permission: ['documents', 'edit'],
+ params: documentParams,
+ body: collaborationSaveBody,
+ response: { 200: t.Nullable(DocumentResponse), ...commonErrors, ...errors(409) },
+ detail: { summary: 'Save and rebase collaborative document changes' },
+ },
+ )
+ .get(
+ '/projects/:projectKey/documents/:documentId/comments',
+ ({ project, params, user }) =>
+ listDocumentComments(project.id, params.documentId, requireUser(user).id),
+ {
+ permission: ['documents', 'read'],
+ params: documentParams,
+ response: { 200: t.Array(documentCommentResponse), ...commonErrors },
+ detail: { summary: 'Read document comment threads' },
+ },
+ )
+ .post(
+ '/projects/:projectKey/documents/:documentId/comments',
+ ({ project, params, user, body, set }) => {
+ set.status = 201;
+ return addDocumentComment(project.id, params.documentId, requireUser(user).id, body);
+ },
+ {
+ permission: ['documents', 'edit'],
+ params: documentParams,
+ body: documentCommentBody,
+ response: { 201: t.Object({ id: t.String() }), ...commonErrors, ...errors(409) },
+ detail: { summary: 'Comment on selected document text or reply' },
+ },
+ )
+ .patch(
+ '/projects/:projectKey/documents/:documentId/comments/:commentId',
+ ({ project, params, user, body }) =>
+ updateDocumentComment(
+ project.id,
+ params.documentId,
+ requireUser(user).id,
+ params.commentId,
+ body,
+ ),
+ {
+ permission: ['documents', 'edit'],
+ params: documentCommentParams,
+ body: documentCommentUpdateBody,
+ response: { 200: t.Object({ ok: t.Boolean() }), ...commonErrors },
+ detail: { summary: 'Edit a document comment or resolve a thread' },
+ },
+ );
diff --git a/apps/api/src/modules/documents/collaboration-schema.ts b/apps/api/src/modules/documents/collaboration-schema.ts
new file mode 100644
index 00000000..7ab371eb
--- /dev/null
+++ b/apps/api/src/modules/documents/collaboration-schema.ts
@@ -0,0 +1,84 @@
+import { Schema, type NodeSpec } from '@tiptap/pm/model';
+
+const blockId = { default: null };
+const block = { blockId };
+const aligned = { ...block, textAlign: { default: null } };
+const cell = {
+ colspan: { default: 1 },
+ rowspan: { default: 1 },
+ colwidth: { default: null },
+ align: { default: null },
+};
+const nodes: Record<string, NodeSpec> = {
+ doc: { content: 'block+' },
+ text: { group: 'inline' },
+ paragraph: { group: 'block', content: 'inline*', attrs: aligned },
+ heading: {
+ group: 'block',
+ content: 'inline*',
+ attrs: { ...aligned, level: { default: 1 } },
+ defining: true,
+ },
+ blockquote: { group: 'block', content: 'block+', attrs: block, defining: true },
+ bulletList: {
+ group: 'block list',
+ content: 'listItem+',
+ attrs: { ...block, tight: { default: true } },
+ },
+ orderedList: {
+ group: 'block list',
+ content: 'listItem+',
+ attrs: { ...block, tight: { default: true }, start: { default: 1 }, type: { default: null } },
+ },
+ listItem: { content: 'paragraph block*', defining: true },
+ taskList: { group: 'block list', content: 'taskItem+', attrs: block },
+ taskItem: { content: 'paragraph block*', defining: true, attrs: { checked: { default: false } } },
+ horizontalRule: { group: 'block', attrs: block },
+ hardBreak: { group: 'inline', inline: true, selectable: false },
+ codeBlock: {
+ group: 'block',
+ content: 'text*',
+ marks: '',
+ code: true,
+ defining: true,
+ attrs: { ...block, language: { default: null } },
+ },
+ image: {
+ group: 'block',
+ atom: true,
+ attrs: {
+ ...block,
+ src: { default: null },
+ alt: { default: null },
+ title: { default: null },
+ width: { default: null },
+ style: { default: null },
+ },
+ },
+ table: { group: 'block', content: 'tableRow+', isolating: true, attrs: block },
+ tableRow: { content: '(tableCell | tableHeader)*' },
+ tableCell: { content: 'block+', isolating: true, attrs: cell },
+ tableHeader: { content: 'block+', isolating: true, attrs: cell },
+};
+export const collaborationSchema = new Schema({
+ nodes,
+ marks: {
+ bold: {},
+ italic: {},
+ strike: {},
+ underline: {},
+ code: { excludes: '_' },
+ link: {
+ inclusive: false,
+ attrs: {
+ href: { default: null },
+ title: { default: null },
+ target: { default: '_blank' },
+ rel: { default: 'noopener noreferrer nofollow' },
+ class: { default: null },
+ },
+ },
+ textStyle: { attrs: { color: { default: null } } },
+ highlight: { attrs: { color: { default: null } } },
+ },
+});
diff --git a/apps/api/src/modules/documents/collaboration.ts b/apps/api/src/modules/documents/collaboration.ts
new file mode 100644
index 00000000..f5f0a74c
--- /dev/null
+++ b/apps/api/src/modules/documents/collaboration.ts
@@ -0,0 +1,245 @@
+import {
+ db,
+ documentCollaboration,
+ documentComment,
+ documentStep,
+ projectDocument,
+} from '@repo/db';
+import { and, asc, eq, gt, lte, or } from 'drizzle-orm';
+import { Step, Mapping } from '@tiptap/pm/transform';
+import { HttpError } from '#shared/lib';
+import { assertValidDocumentContentJson, getDocument } from './service';
+import { collaborationSchema } from './collaboration-schema';
+
+type Transaction = Parameters<Parameters<typeof db.transaction>[0]>[0];
+export async function lockVisibleDocument(
+ tx: Transaction,
+ projectId: number,
+ documentId: number,
+ userId: string,
+ editing = false,
+) {
+ const [document] = await tx
+ .select()
+ .from(projectDocument)
+ .where(
+ and(
+ eq(projectDocument.id, documentId),
+ eq(projectDocument.projectId, projectId),
+ or(eq(projectDocument.isPrivate, false), eq(projectDocument.ownerUserId, userId)),
+ ),
+ )
+ .for('update');
+ if (!document) throw new HttpError(404, 'Document not found');
+ if (editing && (document.isLocked || document.archivedAt))
+ throw new HttpError(409, 'This document is read-only');
+ return document;
+}
+
+export async function openDocumentSession(
+ projectId: number,
+ documentId: number,
+ userId: string,
+ input: { version: number; contentJson: Record<string, unknown> },
+) {
+ assertValidDocumentContentJson(input.contentJson);
+ return db.transaction(async (tx) => {
+ const document = await lockVisibleDocument(tx, projectId, documentId, userId, true);
+ const [existing] = await tx
+ .select()
+ .from(documentCollaboration)
+ .where(eq(documentCollaboration.documentId, documentId));
+ if (existing && JSON.stringify(existing.contentJson) === JSON.stringify(document.contentJson))
+ return existing;
+ if (!document.contentJson && document.version !== input.version)
+ throw new HttpError(409, 'Reload the document before joining');
+ const json = document.contentJson ?? input.contentJson;
+ assertValidDocumentContentJson(json);
+ let normalized: Record<string, unknown>;
+ try {
+ const node = collaborationSchema.nodeFromJSON(json);
+ node.check();
+ normalized = node.toJSON();
+ const ids = new Set<unknown>();
+ const addIds = (value: Record<string, unknown>) => {
+ if (
+ [
+ 'paragraph',
+ 'heading',
+ 'blockquote',
+ 'codeBlock',
+ 'bulletList',
+ 'orderedList',
+ 'taskList',
+ 'table',
+ 'horizontalRule',
+ 'image',
+ ].includes(String(value.type))
+ ) {
+ const attrs = (value.attrs ?? {}) as Record<string, unknown>;
+ const id = attrs.blockId && !ids.has(attrs.blockId) ? attrs.blockId : crypto.randomUUID();
+ ids.add(id);
+ value.attrs = { ...attrs, blockId: id };
+ }
+ if (Array.isArray(value.content)) value.content.forEach(addIds);
+ };
+ addIds(normalized);
+ } catch {
+ throw new HttpError(400, 'Invalid document structure');
+ }
+ await tx.delete(documentStep).where(eq(documentStep.documentId, documentId));
+ const [session] = await tx
+ .insert(documentCollaboration)
+ .values({ documentId, contentJson: normalized })
+ .onConflictDoUpdate({
+ target: documentCollaboration.documentId,
+ set: { epoch: crypto.randomUUID(), version: 0, contentJson: normalized },
+ })
+ .returning();
+ if (JSON.stringify(document.contentJson) !== JSON.stringify(normalized)) {
+ await tx
+ .update(projectDocument)
+ .set({
+ contentJson: normalized,
+ version: document.version + 1,
+ updatedByUserId: userId,
+ updatedAt: new Date(),
+ })
+ .where(eq(projectDocument.id, documentId));
+ }
+ return session!;
+ });
+}
+
+export async function getDocumentSteps(
+ projectId: number,
+ documentId: number,
+ userId: string,
+ epoch: string,
+ version: number,
+) {
+ return db.transaction(async (tx) => {
+ const document = await lockVisibleDocument(tx, projectId, documentId, userId);
+ const [session] = await tx
+ .select()
+ .from(documentCollaboration)
+ .where(eq(documentCollaboration.documentId, documentId));
+ if (
+ !session ||
+ session.epoch !== epoch ||
+ JSON.stringify(session.contentJson) !== JSON.stringify(document.contentJson)
+ )
+ throw new HttpError(409, 'The document was restored or replaced. Rejoin to continue.');
+ if (version > session.version) throw new HttpError(409, 'Invalid collaboration version');
+ const steps = await tx
+ .select({
+ version: documentStep.version,
+ step: documentStep.step,
+ clientId: documentStep.clientId,
+ })
+ .from(documentStep)
+ .where(and(eq(documentStep.documentId, documentId), gt(documentStep.version, version)))
+ .orderBy(asc(documentStep.version))
+ .limit(1000);
+ if (version < session.version && steps[0]?.version !== version + 1)
+ throw new HttpError(409, 'The collaboration history expired. Rejoin to continue.');
+ return {
+ epoch,
+ version: version + steps.length,
+ steps: steps.map(({ step, clientId }) => ({ step, clientId })),
+ hasMore: version + steps.length < session.version,
+ documentVersion: document.version,
+ };
+ });
+}
+
+export async function saveDocumentSteps(
+ projectId: number,
+ documentId: number,
+ userId: string,
+ input: {
+ epoch: string;
+ version: number;
+ clientId: string;
+ steps: Record<string, unknown>[];
+ content: string;
+ },
+) {
+ await db.transaction(async (tx) => {
+ const document = await lockVisibleDocument(tx, projectId, documentId, userId, true);
+ const [session] = await tx
+ .select()
+ .from(documentCollaboration)
+ .where(eq(documentCollaboration.documentId, documentId));
+ if (
+ !session ||
+ session.epoch !== input.epoch ||
+ JSON.stringify(session.contentJson) !== JSON.stringify(document.contentJson)
+ )
+ throw new HttpError(409, 'The document was restored or replaced');
+ if (session.version !== input.version)
+ throw new HttpError(409, 'Receive the latest changes before saving');
+ let node = collaborationSchema.nodeFromJSON(session.contentJson);
+ const mapping = new Mapping();
+ const accepted: Record<string, unknown>[] = [];
+ try {
+ for (const json of input.steps) {
+ const step = Step.fromJSON(collaborationSchema, json);
+ const result = step.apply(node);
+ if (result.failed || !result.doc) throw new Error('Invalid step');
+ node = result.doc;
+ mapping.appendMap(step.getMap());
+ accepted.push(step.toJSON());
+ }
+ node.check();
+ } catch {
+ throw new HttpError(400, 'Invalid document changes');
+ }
+ const contentJson: Record<string, unknown> = node.toJSON();
+ assertValidDocumentContentJson(contentJson);
+ await tx.insert(documentStep).values(
+ accepted.map((step, index) => ({
+ documentId,
+ version: input.version + index + 1,
+ clientId: input.clientId,
+ step,
+ })),
+ );
+ await tx
+ .update(documentCollaboration)
+ .set({ version: input.version + input.steps.length, contentJson })
+ .where(eq(documentCollaboration.documentId, documentId));
+ await tx
+ .update(projectDocument)
+ .set({
+ contentJson,
+ content: input.content,
+ version: document.version + 1,
+ updatedAt: new Date(),
+ updatedByUserId: userId,
+ })
+ .where(eq(projectDocument.id, documentId));
+ const retainedFrom = input.version + input.steps.length - 10_000;
+ if (retainedFrom > 0)
+ await tx
+ .delete(documentStep)
+ .where(
+ and(eq(documentStep.documentId, documentId), lte(documentStep.version, retainedFrom)),
+ );
+ const comments = await tx
+ .select()
+ .from(documentComment)
+ .where(eq(documentComment.documentId, documentId));
+ for (const comment of comments) {
+ if (comment.from === null || comment.to === null || comment.orphaned) continue;
+ const from = mapping.map(comment.from, 1);
+ const to = mapping.map(comment.to, -1);
+ if (from === comment.from && to === comment.to) continue;
+ await tx
+ .update(documentComment)
+ .set({ from: Math.min(from, to), to: Math.max(from, to), orphaned: from >= to })
+ .where(eq(documentComment.id, comment.id));
+ }
+ });
+ return getDocument(projectId, documentId, userId);
+}
diff --git a/apps/api/src/modules/documents/comments.ts b/apps/api/src/modules/documents/comments.ts
new file mode 100644
index 00000000..ba293579
--- /dev/null
+++ b/apps/api/src/modules/documents/comments.ts
@@ -0,0 +1,115 @@
+import { db, documentComment } from '@repo/db';
+import { user } from '@repo/db/schema';
+import { and, asc, eq } from 'drizzle-orm';
+import { HttpError } from '#shared/lib';
+import { collaborationSchema } from './collaboration-schema';
+import { lockVisibleDocument } from './collaboration';
+
+export async function listDocumentComments(projectId: number, documentId: number, userId: string) {
+ return db.transaction(async (tx) => {
+ const document = await lockVisibleDocument(tx, projectId, documentId, userId);
+ const rows = await tx
+ .select({ comment: documentComment, authorName: user.name })
+ .from(documentComment)
+ .leftJoin(user, eq(documentComment.authorId, user.id))
+ .where(eq(documentComment.documentId, documentId))
+ .orderBy(asc(documentComment.createdAt));
+ return rows.map(({ comment, authorName }) => ({
+ ...comment,
+ documentVersion: document.version,
+ authorName,
+ createdAt: comment.createdAt.toISOString(),
+ updatedAt: comment.updatedAt.toISOString(),
+ resolvedAt: comment.resolvedAt?.toISOString() ?? null,
+ }));
+ });
+}
+export async function addDocumentComment(
+ projectId: number,
+ documentId: number,
+ userId: string,
+ input: {
+ body: string;
+ parentId?: string;
+ quote?: string;
+ from?: number;
+ to?: number;
+ version: number;
+ },
+) {
+ return db.transaction(async (tx) => {
+ const document = await lockVisibleDocument(tx, projectId, documentId, userId);
+ if (document.archivedAt) throw new HttpError(409, 'Archived documents cannot be commented on');
+ if (!input.body.trim()) throw new HttpError(400, 'A comment cannot be empty');
+ if (input.parentId) {
+ const [parent] = await tx
+ .select()
+ .from(documentComment)
+ .where(
+ and(eq(documentComment.id, input.parentId), eq(documentComment.documentId, documentId)),
+ );
+ if (!parent || parent.parentId) throw new HttpError(404, 'Comment thread not found');
+ } else {
+ if (document.version !== input.version)
+ throw new HttpError(409, 'The selection changed. Select the text again.');
+ if (
+ input.from === undefined ||
+ input.to === undefined ||
+ input.from >= input.to ||
+ !input.quote?.trim()
+ )
+ throw new HttpError(400, 'Select text to comment on');
+ if (!document.contentJson) throw new HttpError(409, 'Save the document first');
+ const node = collaborationSchema.nodeFromJSON(document.contentJson);
+ if (
+ input.to > node.content.size ||
+ node.textBetween(input.from, input.to, '\n').slice(0, 2000) !== input.quote
+ )
+ throw new HttpError(409, 'The selected text changed');
+ }
+ const [comment] = await tx
+ .insert(documentComment)
+ .values({
+ documentId,
+ authorId: userId,
+ body: input.body.trim(),
+ parentId: input.parentId ?? null,
+ quote: input.parentId ? '' : input.quote,
+ from: input.parentId ? null : input.from,
+ to: input.parentId ? null : input.to,
+ })
+ .returning({ id: documentComment.id });
+ return comment!;
+ });
+}
+export async function updateDocumentComment(
+ projectId: number,
+ documentId: number,
+ userId: string,
+ commentId: string,
+ input: { body?: string; resolved?: boolean },
+) {
+ await db.transaction(async (tx) => {
+ await lockVisibleDocument(tx, projectId, documentId, userId);
+ const [comment] = await tx
+ .select()
+ .from(documentComment)
+ .where(and(eq(documentComment.id, commentId), eq(documentComment.documentId, documentId)));
+ if (!comment) throw new HttpError(404, 'Comment not found');
+ if (input.body !== undefined && comment.authorId !== userId)
+ throw new HttpError(403, 'Only the author can edit a comment');
+ if (input.body !== undefined && !input.body.trim())
+ throw new HttpError(400, 'A comment cannot be empty');
+ if (input.resolved !== undefined && comment.parentId)
+ throw new HttpError(400, 'Resolve the thread, not a reply');
+ await tx
+ .update(documentComment)
+ .set({
+ ...(input.body !== undefined ? { body: input.body.trim() } : {}),
+ ...(input.resolved !== undefined ? { resolvedAt: input.resolved ? new Date() : null } : {}),
+ updatedAt: new Date(),
+ })
+ .where(eq(documentComment.id, commentId));
+ });
+ return { ok: true };
+}
diff --git a/apps/api/src/modules/documents/index.ts b/apps/api/src/modules/documents/index.ts
index 0d65d616..0b60625f 100644
--- a/apps/api/src/modules/documents/index.ts
+++ b/apps/api/src/modules/documents/index.ts
@@ -1,3 +1,4 @@
+import { documentCollaborationRoutes } from './collaboration-routes';
import { Elysia, t } from 'elysia';
import { authContext } from '#shared/auth-context';
import { assertPermission, requireUser } from '#shared/access';
@@ -105,6 +106,7 @@ export const documentRoutes = new Elysia({
})
.use(authContext)
.use(guards)
+ .use(documentCollaborationRoutes)
.get(
'/projects/:projectKey/documents',
async ({ project, query, user }) =>
diff --git a/apps/api/src/modules/documents/model.ts b/apps/api/src/modules/documents/model.ts
index fd5205af..4ae8c753 100644
--- a/apps/api/src/modules/documents/model.ts
+++ b/apps/api/src/modules/documents/model.ts
@@ -211,3 +211,65 @@ export const DocumentAssetListResponse = t.Array(DocumentAssetResponse);
export const deleteDocumentQuery = t.Object({
version: t.Integer({ minimum: 1 }),
});
+
+export const collaborationOpenBody = t.Object({
+ version: t.Integer({ minimum: 1 }),
+ contentJson: t.Record(t.String(), t.Any()),
+});
+export const collaborationQuery = t.Object({
+ epoch: t.String({ format: 'uuid' }),
+ version: t.Numeric({ minimum: 0 }),
+});
+export const collaborationSaveBody = t.Object({
+ epoch: t.String({ format: 'uuid' }),
+ version: t.Integer({ minimum: 0 }),
+ clientId: t.String({ minLength: 1, maxLength: 64 }),
+ steps: t.Array(t.Record(t.String(), t.Any()), { minItems: 1, maxItems: 1000 }),
+ content: t.String({ maxLength: 250_000 }),
+});
+export const collaborationSessionResponse = t.Object({
+ documentId: t.Number(),
+ epoch: t.String(),
+ version: t.Number(),
+ contentJson: t.Record(t.String(), t.Any()),
+});
+export const collaborationStepsResponse = t.Object({
+ epoch: t.String(),
+ version: t.Number(),
+ documentVersion: t.Number(),
+ hasMore: t.Boolean(),
+ steps: t.Array(t.Object({ clientId: t.String(), step: t.Record(t.String(), t.Any()) })),
+});
+export const documentCommentParams = t.Object({
+ projectKey: t.String(),
+ documentId: t.Numeric(),
+ commentId: t.String({ format: 'uuid' }),
+});
+export const documentCommentBody = t.Object({
+ body: t.String({ minLength: 1, maxLength: 10_000 }),
+ parentId: t.Optional(t.String({ format: 'uuid' })),
+ quote: t.Optional(t.String({ maxLength: 2000 })),
+ from: t.Optional(t.Integer({ minimum: 0 })),
+ to: t.Optional(t.Integer({ minimum: 1 })),
+ version: t.Integer({ minimum: 1 }),
+});
+export const documentCommentUpdateBody = t.Object({
+ body: t.Optional(t.String({ minLength: 1, maxLength: 10_000 })),
+ resolved: t.Optional(t.Boolean()),
+});
+export const documentCommentResponse = t.Object({
+ documentVersion: t.Number(),
+ id: t.String(),
+ documentId: t.Number(),
+ parentId: t.Nullable(t.String()),
+ authorId: t.Nullable(t.String()),
+ authorName: t.Nullable(t.String()),
+ body: t.String(),
+ quote: t.String(),
+ from: t.Nullable(t.Number()),
+ to: t.Nullable(t.Number()),
+ orphaned: t.Boolean(),
+ resolvedAt: t.Nullable(t.String()),
+ createdAt: t.String(),
+ updatedAt: t.String(),
+});
diff --git a/apps/api/src/modules/documents/service.ts b/apps/api/src/modules/documents/service.ts
index 97fd1958..601633cd 100644
--- a/apps/api/src/modules/documents/service.ts
+++ b/apps/api/src/modules/documents/service.ts
@@ -1,13 +1,27 @@
import {
db,
documentAsset,
+ documentCollaboration,
+ documentComment,
project,
projectDocument,
projectDocumentPreference,
projectDocumentRevision,
projectMember,
} from '@repo/db';
-import { and, asc, desc, eq, ilike, inArray, isNotNull, isNull, or, sql } from 'drizzle-orm';
+import {
+ getTableColumns,
+ and,
+ asc,
+ desc,
+ eq,
+ ilike,
+ inArray,
+ isNotNull,
+ isNull,
+ or,
+ sql,
+} from 'drizzle-orm';
import { HttpError, iso } from '#shared/lib';
import {
assertAttachmentStorageCapacity,
@@ -242,8 +256,13 @@ export async function listDocuments(
or(ilike(projectDocument.title, `%${term}%`), ilike(projectDocument.content, `%${term}%`)),
);
}
+ const {
+ content: _content,
+ contentJson: _contentJson,
+ ...columns
+ } = getTableColumns(projectDocument);
const rows = await db
- .select()
+ .select(columns)
.from(projectDocument)
.where(and(...conditions))
.orderBy(asc(projectDocument.position), asc(projectDocument.id));
@@ -254,7 +273,7 @@ export async function listDocuments(
rows.map((row) => row.id),
);
return rows.map((row) => ({
- ...summaryOf(row, favorites.has(row.id)),
+ ...summaryOf({ ...row, content: '', contentJson: null }, favorites.has(row.id)),
parentId: row.parentId !== null && visibleIds.has(row.parentId) ? row.parentId : null,
}));
}
@@ -678,7 +697,12 @@ function assertAllowedAttributes(
allowed: readonly string[],
context: string,
): void {
- const allowedKeys = new Set(allowed);
+ const allowedKeys = new Set([...allowed, 'blockId']);
+ if (
+ attrs.blockId != null &&
+ (typeof attrs.blockId !== 'string' || !/^[A-Za-z0-9_-]{1,64}$/.test(attrs.blockId))
+ )
+ throw new HttpError(400, 'Invalid document block identifier.');
const unknown = Object.keys(attrs).find((key) => !allowedKeys.has(key));
if (unknown) throw new HttpError(400, `${context} contains an unsupported "${unknown}" attr.`);
}
@@ -999,7 +1023,11 @@ export async function updateDocument(
.set({
...(input.title !== undefined ? { title: input.title } : {}),
...(input.content !== undefined ? { content: input.content } : {}),
- ...(input.contentJson !== undefined ? { contentJson: input.contentJson } : {}),
+ ...(input.contentJson !== undefined
+ ? { contentJson: input.contentJson }
+ : input.content !== undefined
+ ? { contentJson: null }
+ : {}),
...(input.icon !== undefined ? { icon: input.icon } : {}),
...(input.metadata !== undefined ? { metadata: input.metadata } : {}),
...(input.fullWidth !== undefined ? { fullWidth: input.fullWidth } : {}),
@@ -1020,6 +1048,15 @@ export async function updateDocument(
if (!row) {
throw new HttpError(409, 'This document changed elsewhere. Reload it before continuing.');
}
+ if (input.content !== undefined || input.contentJson !== undefined) {
+ await tx
+ .delete(documentCollaboration)
+ .where(eq(documentCollaboration.documentId, documentId));
+ await tx
+ .update(documentComment)
+ .set({ orphaned: true })
+ .where(eq(documentComment.documentId, documentId));
+ }
if (movePlan) {
// Position normalization is implementation detail, not user-visible page
// history. The Docs sync trigger still fires so every client refetches the
@@ -1599,6 +1636,11 @@ export async function restoreDocumentRevision(
if (!row) {
throw new HttpError(409, 'This document changed elsewhere. Reload it before continuing.');
}
+ await tx.delete(documentCollaboration).where(eq(documentCollaboration.documentId, documentId));
+ await tx
+ .update(documentComment)
+ .set({ orphaned: true })
+ .where(eq(documentComment.documentId, documentId));
return mapDocumentForUser(tx, row, userId);
});
}
diff --git a/apps/web/messages/ar/common.json b/apps/web/messages/ar/common.json
index 74d5b661..bd2782ee 100644
--- a/apps/web/messages/ar/common.json
+++ b/apps/web/messages/ar/common.json
@@ -151,7 +151,7 @@
"initiatives": "المبادرات",
"cycles": "الدورات",
"dashboards": "لوحات المعلومات",
- "documents": "Docs",
+ "documents": "المستندات",
"notes": "الملاحظات",
"subtasks": "المهام الفرعية",
"checklists": "قوائم التحقّق (قائمة الحاجات اللي لازم تتراجع)",
diff --git a/apps/web/messages/ar/documents.json b/apps/web/messages/ar/documents.json
index cedb3d97..1b3d6984 100644
--- a/apps/web/messages/ar/documents.json
+++ b/apps/web/messages/ar/documents.json
@@ -1,5 +1,5 @@
{
- "title": "Docs",
+ "title": "المستندات",
"newDocument": "صفحة جديدة",
"favoritePages": "المفضلة",
"newSubpage": "إضافة صفحة تحت {title}",
@@ -7,7 +7,7 @@
"untitled": "بلا عنوان",
"titlePlaceholder": "بلا عنوان",
"contentPlaceholder": "ابدأ الكتابة أو اضغط / للأوامر…",
- "search": "البحث في Docs…",
+ "search": "البحث في المستندات…",
"sort": "ترتيب الصفحات",
"manualOrder": "ترتيب يدوي",
"nameOrder": "الاسم",
@@ -25,11 +25,11 @@
"month": "آخر 30 يومًا",
"clearFilters": "مسح عوامل التصفية",
"noResults": "لم يتم العثور على صفحات.",
- "noAccess": "ليس لديك حق الوصول إلى Docs المشروع.",
- "treeLabel": "Docs المشروع",
+ "noAccess": "ليس لديك حق الوصول إلى مستندات المشروع.",
+ "treeLabel": "مستندات المشروع",
"expand": "توسيع الصفحة",
"collapse": "طي الصفحة",
- "backToDocuments": "العودة إلى Docs",
+ "backToDocuments": "العودة إلى المستندات",
"documentActions": "إجراءات الصفحة",
"pageIcon": "أيقونة الصفحة",
"pageTitle": "عنوان الصفحة",
@@ -37,7 +37,7 @@
"saving": "جارٍ الحفظ…",
"saveFailed": "تعذر الحفظ",
"retrySave": "إعادة محاولة الحفظ",
- "loadFailed": "تعذر تحميل Docs",
+ "loadFailed": "تعذر تحميل المستندات",
"conflict": "توجد نسخة أحدث",
"reload": "إعادة التحميل",
"reviewConflict": "مراجعة",
@@ -145,9 +145,9 @@
"empty": "لا توجد عناصر عمل مرتبطة بعد.",
"loadFailed": "تعذر تحميل عناصر العمل المرتبطة. انقر لإعادة المحاولة.",
"remove": "إلغاء ربط {identifier}",
- "selectDocument": "ربط صفحة Docs",
- "searchDocuments": "البحث في Docs…",
- "loading": "جارٍ تحميل Docs…",
+ "selectDocument": "ربط مستند",
+ "searchDocuments": "البحث في المستندات…",
+ "loading": "جارٍ تحميل المستندات…",
"noDocuments": "لا توجد صفحات متاحة للربط."
},
"toolbar": {
@@ -188,6 +188,66 @@
"codeBlock": "كتلة كود",
"divider": "فاصل",
"undo": "تراجع",
- "redo": "إعادة"
+ "redo": "إعادة",
+ "editorLabel": "Document content"
+ },
+ "recentAndFavorites": "Recent and favorites",
+ "searching": "Searching documents…",
+ "blocks": {
+ "actions": "Block actions",
+ "up": "Move up",
+ "down": "Move down",
+ "duplicate": "Duplicate block or section",
+ "delete": "Delete block or section",
+ "copyLink": "Copy link to block",
+ "linkCopied": "Link copied",
+ "copyFailed": "Could not copy the link"
+ },
+ "sync": {
+ "connecting": "Connecting to the document…",
+ "offline": "Offline. Changes stay in this tab and will sync when you reconnect.",
+ "error": "Changes have not synced. Your draft is kept in this tab.",
+ "conflict": "The document was restored, replaced, or access changed. Keep your draft before rejoining.",
+ "retry": "Retry",
+ "recoveryConflict": "The server document was replaced. Your unsaved text is shown here. Export it before opening the current version.",
+ "exportRecovery": "Export my text",
+ "discardRecovery": "Open current version",
+ "discardConfirm": "Discard this unsaved copy and open the current server version? Export your text first if you need it."
+ },
+ "workItem": {
+ "create": "Create work item",
+ "description": "Create a linked work item from this selection.",
+ "title": "Title",
+ "status": "Status",
+ "source": "Source document",
+ "cancel": "Cancel",
+ "creating": "Creating…",
+ "failed": "Could not create the work item. Try again.",
+ "linkFailed": "The work item was created. Retry to finish linking it; another item will not be created.",
+ "retryLink": "Retry linking"
+ },
+ "selectionActions": "Selection actions",
+ "comments": {
+ "title": "Comments",
+ "add": "Comment",
+ "edit": "Edit comment",
+ "save": "Save",
+ "cancel": "Cancel",
+ "reply": "Reply",
+ "replyPlaceholder": "Write a reply…",
+ "send": "Send",
+ "resolve": "Resolve",
+ "reopen": "Reopen",
+ "textRemoved": "The selected text was removed",
+ "unknownAuthor": "Former member",
+ "close": "Close comments",
+ "placeholder": "Discuss this selection…",
+ "resolved": "Resolved",
+ "open": "Open",
+ "failed": "Could not save. The document may have changed; select the text again or retry.",
+ "loading": "Loading comments…",
+ "retry": "Retry",
+ "noResolved": "No resolved discussions.",
+ "empty": "Select text to start a discussion."
}
}
diff --git a/apps/web/messages/ar/issue.json b/apps/web/messages/ar/issue.json
index 0fda1ea8..1d72add3 100644
--- a/apps/web/messages/ar/issue.json
+++ b/apps/web/messages/ar/issue.json
@@ -387,9 +387,9 @@
}
},
"documents": {
- "title": "Docs",
- "add": "ربط صفحة Docs",
- "empty": "لا توجد صفحات Docs مرتبطة بعد.",
+ "title": "المستندات",
+ "add": "ربط مستند",
+ "empty": "لا توجد مستندات مرتبطة بعد.",
"loadFailed": "تعذر تحميل الصفحات المرتبطة. انقر لإعادة المحاولة.",
"remove": "إلغاء ربط {title}",
"untitled": "بلا عنوان"
diff --git a/apps/web/messages/ar/nav.json b/apps/web/messages/ar/nav.json
index 41c5ba53..8cb4ec76 100644
--- a/apps/web/messages/ar/nav.json
+++ b/apps/web/messages/ar/nav.json
@@ -6,7 +6,7 @@
"initiatives": "المبادرات (initiatives)",
"cycles": "الدورات (cycles)",
"notes": "الملاحظات",
- "documents": "Docs",
+ "documents": "المستندات",
"aiTeam": "فريق الذكاء الاصطناعي",
"aiAgents": "وكلاء الذكاء الاصطناعي",
"configuration": "التهيئة",
diff --git a/apps/web/messages/ar/newProject.json b/apps/web/messages/ar/newProject.json
index 6eac2862..f17b65e4 100644
--- a/apps/web/messages/ar/newProject.json
+++ b/apps/web/messages/ar/newProject.json
@@ -35,7 +35,7 @@
"customFields": "الحقول المخصّصة",
"views": "العروض",
"dashboards": "لوحات المعلومات",
- "documents": "Docs",
+ "documents": "المستندات",
"actions": "الإجراءات",
"configuration": "التهيئة",
"webhooks": "خطافات الويب (webhooks)",
diff --git a/apps/web/messages/ar/permissions.json b/apps/web/messages/ar/permissions.json
index 75b92a95..361374e5 100644
--- a/apps/web/messages/ar/permissions.json
+++ b/apps/web/messages/ar/permissions.json
@@ -6,7 +6,7 @@
"initiatives": "المبادرات (initiatives)",
"cycles": "الدورات (cycles)",
"dashboards": "لوحات المعلومات",
- "documents": "Docs",
+ "documents": "المستندات",
"views": "عروض عناصر العمل",
"members_invite": "الدعوات",
"members_manage": "الأعضاء",
@@ -34,7 +34,7 @@
"groups": {
"workItems": "عناصر العمل",
"dashboards": "لوحات المعلومات",
- "documents": "Docs",
+ "documents": "المستندات",
"notes": "الملاحظات",
"ai": "الذكاء الاصطناعي",
"configuration": "التهيئة",
diff --git a/apps/web/messages/ar/teams.json b/apps/web/messages/ar/teams.json
index 462f65f8..e855cb36 100644
--- a/apps/web/messages/ar/teams.json
+++ b/apps/web/messages/ar/teams.json
@@ -410,7 +410,7 @@
"issues": "المهام",
"initiatives": "المبادرات",
"cycles": "الدورات",
- "documents": "Docs",
+ "documents": "المستندات",
"notes": "لوحات الملاحظات",
"project": "المشروع"
},
diff --git a/apps/web/messages/en/documents.json b/apps/web/messages/en/documents.json
index 2d2462bc..818f8f95 100644
--- a/apps/web/messages/en/documents.json
+++ b/apps/web/messages/en/documents.json
@@ -188,6 +188,66 @@
"alignCenter": "Align center",
"alignRight": "Align right",
"undo": "Undo",
- "redo": "Redo"
+ "redo": "Redo",
+ "editorLabel": "Document content"
+ },
+ "recentAndFavorites": "Recent and favorites",
+ "searching": "Searching documents…",
+ "blocks": {
+ "actions": "Block actions",
+ "up": "Move up",
+ "down": "Move down",
+ "duplicate": "Duplicate block or section",
+ "delete": "Delete block or section",
+ "copyLink": "Copy link to block",
+ "linkCopied": "Link copied",
+ "copyFailed": "Could not copy the link"
+ },
+ "sync": {
+ "connecting": "Connecting to the document…",
+ "offline": "Offline. Changes stay in this tab and will sync when you reconnect.",
+ "error": "Changes have not synced. Your draft is kept in this tab.",
+ "conflict": "The document was restored, replaced, or access changed. Keep your draft before rejoining.",
+ "retry": "Retry",
+ "recoveryConflict": "The server document was replaced. Your unsaved text is shown here. Export it before opening the current version.",
+ "exportRecovery": "Export my text",
+ "discardRecovery": "Open current version",
+ "discardConfirm": "Discard this unsaved copy and open the current server version? Export your text first if you need it."
+ },
+ "workItem": {
+ "create": "Create work item",
+ "description": "Create a linked work item from this selection.",
+ "title": "Title",
+ "status": "Status",
+ "source": "Source document",
+ "cancel": "Cancel",
+ "creating": "Creating…",
+ "failed": "Could not create the work item. Try again.",
+ "linkFailed": "The work item was created. Retry to finish linking it; another item will not be created.",
+ "retryLink": "Retry linking"
+ },
+ "selectionActions": "Selection actions",
+ "comments": {
+ "title": "Comments",
+ "add": "Comment",
+ "edit": "Edit comment",
+ "save": "Save",
+ "cancel": "Cancel",
+ "reply": "Reply",
+ "replyPlaceholder": "Write a reply…",
+ "send": "Send",
+ "resolve": "Resolve",
+ "reopen": "Reopen",
+ "textRemoved": "The selected text was removed",
+ "unknownAuthor": "Former member",
+ "close": "Close comments",
+ "placeholder": "Discuss this selection…",
+ "resolved": "Resolved",
+ "open": "Open",
+ "failed": "Could not save. The document may have changed; select the text again or retry.",
+ "loading": "Loading comments…",
+ "retry": "Retry",
+ "noResolved": "No resolved discussions.",
+ "empty": "Select text to start a discussion."
}
}
diff --git a/apps/web/messages/es-ES/dashboards.json b/apps/web/messages/es-ES/dashboards.json
index fb59eea4..a0b3570f 100644
--- a/apps/web/messages/es-ES/dashboards.json
+++ b/apps/web/messages/es-ES/dashboards.json
@@ -136,6 +136,10 @@
"day": "Días",
"week": "Semanas"
},
+ "scope": {
+ "project": "Todo el proyecto",
+ "me": "Mi actividad"
+ },
"events": "{count, plural, one {# evento} other {# eventos}}",
"eventNoun": "{count, plural, one {evento} other {eventos}}",
"active": "{count} activos",
diff --git a/apps/web/messages/es-ES/documents.json b/apps/web/messages/es-ES/documents.json
index a0475c36..894180e5 100644
--- a/apps/web/messages/es-ES/documents.json
+++ b/apps/web/messages/es-ES/documents.json
@@ -188,6 +188,66 @@
"alignCenter": "Alinear al centro",
"alignRight": "Alinear a la derecha",
"undo": "Deshacer",
- "redo": "Rehacer"
+ "redo": "Rehacer",
+ "editorLabel": "Contenido del documento"
+ },
+ "recentAndFavorites": "Recientes y favoritos",
+ "searching": "Buscando documentos…",
+ "blocks": {
+ "actions": "Acciones del bloque",
+ "up": "Subir",
+ "down": "Bajar",
+ "duplicate": "Duplicar bloque o sección",
+ "delete": "Eliminar bloque o sección",
+ "copyLink": "Copiar enlace al bloque",
+ "linkCopied": "Enlace copiado",
+ "copyFailed": "No se pudo copiar el enlace"
+ },
+ "sync": {
+ "connecting": "Conectando con el documento…",
+ "offline": "Sin conexión. Los cambios se guardan en esta pestaña y se sincronizarán al reconectar.",
+ "error": "Los cambios no se han sincronizado. Tu borrador se conserva en esta pestaña.",
+ "conflict": "El documento se restauró, se reemplazó o cambió el acceso. Guarda tu borrador antes de volver a unirte.",
+ "retry": "Reintentar",
+ "recoveryConflict": "El documento del servidor fue reemplazado. Aquí se muestra tu texto sin guardar. Expórtalo antes de abrir la versión actual.",
+ "exportRecovery": "Exportar mi texto",
+ "discardRecovery": "Abrir la versión actual",
+ "discardConfirm": "¿Descartar esta copia sin guardar y abrir la versión actual del servidor? Exporta tu texto primero si lo necesitas."
+ },
+ "workItem": {
+ "create": "Crear elemento de trabajo",
+ "description": "Crea un elemento de trabajo vinculado a partir de esta selección.",
+ "title": "Título",
+ "status": "Estado",
+ "source": "Documento de origen",
+ "cancel": "Cancelar",
+ "creating": "Creando…",
+ "failed": "No se pudo crear el elemento de trabajo. Inténtalo de nuevo.",
+ "linkFailed": "El elemento de trabajo se creó. Reintenta para terminar de vincularlo; no se creará otro elemento.",
+ "retryLink": "Reintentar vinculación"
+ },
+ "selectionActions": "Acciones de la selección",
+ "comments": {
+ "title": "Comentarios",
+ "add": "Comentar",
+ "edit": "Editar comentario",
+ "save": "Guardar",
+ "cancel": "Cancelar",
+ "reply": "Responder",
+ "replyPlaceholder": "Escribe una respuesta…",
+ "send": "Enviar",
+ "resolve": "Resolver",
+ "reopen": "Reabrir",
+ "textRemoved": "El texto seleccionado se eliminó",
+ "unknownAuthor": "Antiguo miembro",
+ "close": "Cerrar comentarios",
+ "placeholder": "Comenta esta selección…",
+ "resolved": "Resueltos",
+ "open": "Abiertos",
+ "failed": "No se pudo guardar. Puede que el documento haya cambiado; selecciona el texto de nuevo o reintenta.",
+ "loading": "Cargando comentarios…",
+ "retry": "Reintentar",
+ "noResolved": "No hay discusiones resueltas.",
+ "empty": "Selecciona texto para iniciar una discusión."
}
}
diff --git a/apps/web/messages/es-ES/nav.json b/apps/web/messages/es-ES/nav.json
index 59328e1c..59234431 100644
--- a/apps/web/messages/es-ES/nav.json
+++ b/apps/web/messages/es-ES/nav.json
@@ -40,5 +40,34 @@
"automation": "Automatización"
},
"godModeOwnerOnly": "El modo dios está abierto solo al propietario de la instancia.",
- "project": "Proyecto"
+ "project": "Proyecto",
+ "projectPicker": {
+ "sortName": "Nombre del proyecto",
+ "noResults": "No hay proyectos que coincidan",
+ "sortCreated": "Creados recientemente",
+ "hideHidden": "Ocultar proyectos ocultos",
+ "resize": "Arrastra para cambiar el ancho del selector de proyectos",
+ "resetWidth": "Restablecer el ancho del selector de proyectos",
+ "activityHint": "Último cambio o comentario en un elemento de trabajo",
+ "search": "Buscar proyectos por nombre, clave o equipo…",
+ "sortActivity": "Actividad reciente",
+ "sort": "Ordenar proyectos",
+ "sortKey": "Clave del proyecto",
+ "showHidden": "Mostrar proyectos ocultos ({count})",
+ "starProject": "Destacar {name}",
+ "unstarProject": "Quitar {name} de destacados",
+ "hideProject": "Ocultar {name} de mis proyectos",
+ "showProject": "Mostrar {name} en mis proyectos",
+ "allHiddenTitle": "Todos los proyectos están ocultos",
+ "allHiddenDescription": "Los proyectos ocultos no aparecen en tu navegación de proyectos. Tu acceso, tus compañeros y los agentes no se ven afectados. Muestra un proyecto para volver a abrirlo.",
+ "hiddenProjects": "Proyectos ocultos ({count})",
+ "noHiddenResults": "Ningún proyecto oculto coincide con tu búsqueda",
+ "noVisibleProjects": "No hay proyectos en tu vista",
+ "projectActions": "Acciones para {name}",
+ "starAction": "Destacar proyecto",
+ "unstarAction": "Quitar de destacados",
+ "hideAction": "Ocultar de mi vista",
+ "restoreAction": "Restaurar a mi vista",
+ "starred": "Destacados"
+ }
}
diff --git a/apps/web/messages/fr/common.json b/apps/web/messages/fr/common.json
index 198b67d4..4f08824d 100644
--- a/apps/web/messages/fr/common.json
+++ b/apps/web/messages/fr/common.json
@@ -151,7 +151,7 @@
"initiatives": "Initiatives",
"cycles": "Cycles",
"dashboards": "Tableaux de bord",
- "documents": "Docs",
+ "documents": "Documents",
"notes": "Notes",
"subtasks": "Sous-tâches",
"checklists": "Checklists",
diff --git a/apps/web/messages/fr/documents.json b/apps/web/messages/fr/documents.json
index 1b8ee4ed..1f7f566c 100644
--- a/apps/web/messages/fr/documents.json
+++ b/apps/web/messages/fr/documents.json
@@ -1,5 +1,5 @@
{
- "title": "Docs",
+ "title": "Documents",
"newDocument": "Nouvelle page",
"favoritePages": "Favoris",
"publicPages": "Publiques",
@@ -10,7 +10,7 @@
"untitled": "Sans titre",
"titlePlaceholder": "Sans titre",
"contentPlaceholder": "Commencez à écrire ou appuyez sur / pour les commandes…",
- "search": "Rechercher dans Docs…",
+ "search": "Rechercher des documents…",
"sort": "Trier les pages",
"manualOrder": "Ordre manuel",
"nameOrder": "Nom",
@@ -28,11 +28,11 @@
"month": "30 derniers jours",
"clearFilters": "Effacer les filtres",
"noResults": "Aucune page trouvée.",
- "noAccess": "Vous n'avez pas accès aux Docs du projet.",
- "treeLabel": "Docs du projet",
+ "noAccess": "Vous n’avez pas accès aux documents du projet.",
+ "treeLabel": "Documents du projet",
"expand": "Développer la page",
"collapse": "Réduire la page",
- "backToDocuments": "Retour aux Docs",
+ "backToDocuments": "Retour aux documents",
"documentActions": "Actions de la page",
"pageIcon": "Icône de la page",
"changeIcon": "Modifier l'icône de la page",
@@ -50,7 +50,7 @@
"saving": "Enregistrement…",
"saveFailed": "Impossible d'enregistrer",
"retrySave": "Réessayer",
- "loadFailed": "Impossible de charger Docs",
+ "loadFailed": "Impossible de charger les documents",
"conflict": "Une version plus récente existe",
"reload": "Recharger",
"reviewConflict": "Examiner",
@@ -145,9 +145,9 @@
"empty": "Aucune tâche liée.",
"loadFailed": "Impossible de charger les tâches liées. Cliquez pour réessayer.",
"remove": "Dissocier {identifier}",
- "selectDocument": "Lier une page Docs",
- "searchDocuments": "Rechercher dans Docs…",
- "loading": "Chargement de Docs…",
+ "selectDocument": "Lier un document",
+ "searchDocuments": "Rechercher des documents…",
+ "loading": "Chargement des documents…",
"noDocuments": "Aucune page disponible à lier."
},
"toolbar": {
@@ -188,6 +188,66 @@
"alignCenter": "Centrer",
"alignRight": "Aligner à droite",
"undo": "Annuler",
- "redo": "Rétablir"
+ "redo": "Rétablir",
+ "editorLabel": "Document content"
+ },
+ "recentAndFavorites": "Recent and favorites",
+ "searching": "Searching documents…",
+ "blocks": {
+ "actions": "Block actions",
+ "up": "Move up",
+ "down": "Move down",
+ "duplicate": "Duplicate block or section",
+ "delete": "Delete block or section",
+ "copyLink": "Copy link to block",
+ "linkCopied": "Link copied",
+ "copyFailed": "Could not copy the link"
+ },
+ "sync": {
+ "connecting": "Connecting to the document…",
+ "offline": "Offline. Changes stay in this tab and will sync when you reconnect.",
+ "error": "Changes have not synced. Your draft is kept in this tab.",
+ "conflict": "The document was restored, replaced, or access changed. Keep your draft before rejoining.",
+ "retry": "Retry",
+ "recoveryConflict": "The server document was replaced. Your unsaved text is shown here. Export it before opening the current version.",
+ "exportRecovery": "Export my text",
+ "discardRecovery": "Open current version",
+ "discardConfirm": "Discard this unsaved copy and open the current server version? Export your text first if you need it."
+ },
+ "workItem": {
+ "create": "Create work item",
+ "description": "Create a linked work item from this selection.",
+ "title": "Title",
+ "status": "Status",
+ "source": "Source document",
+ "cancel": "Cancel",
+ "creating": "Creating…",
+ "failed": "Could not create the work item. Try again.",
+ "linkFailed": "The work item was created. Retry to finish linking it; another item will not be created.",
+ "retryLink": "Retry linking"
+ },
+ "selectionActions": "Selection actions",
+ "comments": {
+ "title": "Comments",
+ "add": "Comment",
+ "edit": "Edit comment",
+ "save": "Save",
+ "cancel": "Cancel",
+ "reply": "Reply",
+ "replyPlaceholder": "Write a reply…",
+ "send": "Send",
+ "resolve": "Resolve",
+ "reopen": "Reopen",
+ "textRemoved": "The selected text was removed",
+ "unknownAuthor": "Former member",
+ "close": "Close comments",
+ "placeholder": "Discuss this selection…",
+ "resolved": "Resolved",
+ "open": "Open",
+ "failed": "Could not save. The document may have changed; select the text again or retry.",
+ "loading": "Loading comments…",
+ "retry": "Retry",
+ "noResolved": "No resolved discussions.",
+ "empty": "Select text to start a discussion."
}
}
diff --git a/apps/web/messages/fr/initiatives.json b/apps/web/messages/fr/initiatives.json
index 144e085e..d3d255d2 100644
--- a/apps/web/messages/fr/initiatives.json
+++ b/apps/web/messages/fr/initiatives.json
@@ -156,7 +156,7 @@
"deleteFile": "Supprimer {name}"
},
"documents": {
- "title": "Docs",
+ "title": "Documents",
"add": "Lier un doc",
"empty": "Aucun doc lié.",
"loadFailed": "Impossible de charger les docs liés. Réessayer.",
diff --git a/apps/web/messages/fr/issue.json b/apps/web/messages/fr/issue.json
index 6e9749a9..8c8d9453 100644
--- a/apps/web/messages/fr/issue.json
+++ b/apps/web/messages/fr/issue.json
@@ -387,9 +387,9 @@
}
},
"documents": {
- "title": "Docs",
- "add": "Lier une page Docs",
- "empty": "Aucune page Docs liée.",
+ "title": "Documents",
+ "add": "Lier un document",
+ "empty": "Aucun document lié.",
"loadFailed": "Impossible de charger les pages liées. Cliquez pour réessayer.",
"remove": "Dissocier {title}",
"untitled": "Sans titre"
diff --git a/apps/web/messages/fr/nav.json b/apps/web/messages/fr/nav.json
index c247caf5..24732325 100644
--- a/apps/web/messages/fr/nav.json
+++ b/apps/web/messages/fr/nav.json
@@ -5,7 +5,7 @@
"allWorkItems": "Tous les tickets",
"initiatives": "Initiatives",
"cycles": "Cycles",
- "documents": "Docs",
+ "documents": "Documents",
"notes": "Notes",
"aiTeam": "Équipe IA",
"aiAgents": "Agents IA",
diff --git a/apps/web/messages/fr/newProject.json b/apps/web/messages/fr/newProject.json
index 824c4bb5..20d9744b 100644
--- a/apps/web/messages/fr/newProject.json
+++ b/apps/web/messages/fr/newProject.json
@@ -35,7 +35,7 @@
"customFields": "Champs personnalisés",
"views": "Vues",
"dashboards": "Tableaux de bord",
- "documents": "Docs",
+ "documents": "Documents",
"actions": "Actions",
"configuration": "Configuration",
"webhooks": "Webhooks",
diff --git a/apps/web/messages/fr/permissions.json b/apps/web/messages/fr/permissions.json
index b0de7ff3..5439c681 100644
--- a/apps/web/messages/fr/permissions.json
+++ b/apps/web/messages/fr/permissions.json
@@ -6,7 +6,7 @@
"initiatives": "Initiatives",
"cycles": "Cycles",
"dashboards": "Tableaux de bord",
- "documents": "Docs",
+ "documents": "Documents",
"views": "Vues de tickets",
"members_invite": "Invitations",
"members_manage": "Membres",
@@ -34,7 +34,7 @@
"groups": {
"workItems": "Tickets",
"dashboards": "Tableaux de bord",
- "documents": "Docs",
+ "documents": "Documents",
"notes": "Notes",
"ai": "IA",
"configuration": "Configuration",
diff --git a/apps/web/messages/fr/teams.json b/apps/web/messages/fr/teams.json
index 0e35db63..85babb04 100644
--- a/apps/web/messages/fr/teams.json
+++ b/apps/web/messages/fr/teams.json
@@ -410,7 +410,7 @@
"issues": "Tickets",
"initiatives": "Initiatives",
"cycles": "Cycles",
- "documents": "Docs",
+ "documents": "Documents",
"notes": "Tableaux de notes",
"project": "Projet"
},
diff --git a/apps/web/messages/id/documents.json b/apps/web/messages/id/documents.json
index 0cbc7934..bc7feb31 100644
--- a/apps/web/messages/id/documents.json
+++ b/apps/web/messages/id/documents.json
@@ -188,6 +188,66 @@
"alignCenter": "Rata tengah",
"alignRight": "Rata kanan",
"undo": "Urungkan",
- "redo": "Ulangi"
- }
+ "redo": "Ulangi",
+ "editorLabel": "Document content"
+ },
+ "blocks": {
+ "actions": "Block actions",
+ "up": "Move up",
+ "down": "Move down",
+ "duplicate": "Duplicate block or section",
+ "delete": "Delete block or section",
+ "copyLink": "Copy link to block",
+ "linkCopied": "Link copied",
+ "copyFailed": "Could not copy the link"
+ },
+ "sync": {
+ "connecting": "Connecting to the document…",
+ "offline": "Offline. Changes stay in this tab and will sync when you reconnect.",
+ "error": "Changes have not synced. Your draft is kept in this tab.",
+ "conflict": "The document was restored, replaced, or access changed. Keep your draft before rejoining.",
+ "retry": "Retry",
+ "recoveryConflict": "The server document was replaced. Your unsaved text is shown here. Export it before opening the current version.",
+ "exportRecovery": "Export my text",
+ "discardRecovery": "Open current version",
+ "discardConfirm": "Discard this unsaved copy and open the current server version? Export your text first if you need it."
+ },
+ "workItem": {
+ "create": "Create work item",
+ "description": "Create a linked work item from this selection.",
+ "title": "Title",
+ "status": "Status",
+ "source": "Source document",
+ "cancel": "Cancel",
+ "creating": "Creating…",
+ "failed": "Could not create the work item. Try again.",
+ "linkFailed": "The work item was created. Retry to finish linking it; another item will not be created.",
+ "retryLink": "Retry linking"
+ },
+ "comments": {
+ "title": "Comments",
+ "add": "Comment",
+ "edit": "Edit comment",
+ "save": "Save",
+ "cancel": "Cancel",
+ "reply": "Reply",
+ "replyPlaceholder": "Write a reply…",
+ "send": "Send",
+ "resolve": "Resolve",
+ "reopen": "Reopen",
+ "textRemoved": "The selected text was removed",
+ "unknownAuthor": "Former member",
+ "close": "Close comments",
+ "placeholder": "Discuss this selection…",
+ "resolved": "Resolved",
+ "open": "Open",
+ "failed": "Could not save. The document may have changed; select the text again or retry.",
+ "loading": "Loading comments…",
+ "retry": "Retry",
+ "noResolved": "No resolved discussions.",
+ "empty": "Select text to start a discussion."
+ },
+ "selectionActions": "Selection actions",
+ "recentAndFavorites": "Recent and favorites",
+ "searching": "Searching documents…"
}
diff --git a/apps/web/messages/pt-BR/common.json b/apps/web/messages/pt-BR/common.json
index 88de1346..061adbaf 100644
--- a/apps/web/messages/pt-BR/common.json
+++ b/apps/web/messages/pt-BR/common.json
@@ -151,7 +151,7 @@
"initiatives": "Iniciativas",
"cycles": "Ciclos",
"dashboards": "Dashboards",
- "documents": "Docs",
+ "documents": "Documentos",
"notes": "Notas",
"subtasks": "Subtarefas",
"checklists": "Checklists",
diff --git a/apps/web/messages/pt-BR/documents.json b/apps/web/messages/pt-BR/documents.json
index 1b2b9fc7..52abd29a 100644
--- a/apps/web/messages/pt-BR/documents.json
+++ b/apps/web/messages/pt-BR/documents.json
@@ -1,5 +1,5 @@
{
- "title": "Docs",
+ "title": "Documentos",
"newDocument": "Nova página",
"favoritePages": "Favoritas",
"publicPages": "Públicas",
@@ -10,7 +10,7 @@
"untitled": "Sem título",
"titlePlaceholder": "Sem título",
"contentPlaceholder": "Escreva algo, ou pressione / para comandos…",
- "search": "Buscar em Docs…",
+ "search": "Buscar documentos…",
"sort": "Ordenar páginas",
"manualOrder": "Ordem manual",
"nameOrder": "Nome",
@@ -28,11 +28,11 @@
"month": "Últimos 30 dias",
"clearFilters": "Limpar filtros",
"noResults": "Nenhuma página encontrada.",
- "noAccess": "Você não tem acesso aos Docs do projeto.",
- "treeLabel": "Docs do projeto",
+ "noAccess": "Você não tem acesso aos documentos do projeto.",
+ "treeLabel": "Documentos do projeto",
"expand": "Expandir página",
"collapse": "Recolher página",
- "backToDocuments": "Voltar aos Docs",
+ "backToDocuments": "Voltar aos documentos",
"documentActions": "Ações da página",
"pageIcon": "Ícone da página",
"changeIcon": "Alterar ícone da página",
@@ -50,7 +50,7 @@
"saving": "Salvando…",
"saveFailed": "Não foi possível salvar",
"retrySave": "Tentar salvar novamente",
- "loadFailed": "Não foi possível carregar os Docs",
+ "loadFailed": "Não foi possível carregar os documentos",
"conflict": "Existe uma versão mais nova",
"reload": "Recarregar",
"reviewConflict": "Revisar",
@@ -145,9 +145,9 @@
"empty": "Nenhum item de trabalho vinculado ainda.",
"loadFailed": "Não foi possível carregar os itens de trabalho vinculados. Clique para tentar novamente.",
"remove": "Desvincular {identifier}",
- "selectDocument": "Vincular uma página de Docs",
- "searchDocuments": "Buscar em Docs…",
- "loading": "Carregando Docs…",
+ "selectDocument": "Vincular um documento",
+ "searchDocuments": "Buscar documentos…",
+ "loading": "Carregando documentos…",
"noDocuments": "Nenhuma página disponível para vincular."
},
"toolbar": {
@@ -188,6 +188,66 @@
"alignCenter": "Centralizar",
"alignRight": "Alinhar à direita",
"undo": "Desfazer",
- "redo": "Refazer"
- }
+ "redo": "Refazer",
+ "editorLabel": "Document content"
+ },
+ "blocks": {
+ "actions": "Block actions",
+ "up": "Move up",
+ "down": "Move down",
+ "duplicate": "Duplicate block or section",
+ "delete": "Delete block or section",
+ "copyLink": "Copy link to block",
+ "linkCopied": "Link copied",
+ "copyFailed": "Could not copy the link"
+ },
+ "sync": {
+ "connecting": "Connecting to the document…",
+ "offline": "Offline. Changes stay in this tab and will sync when you reconnect.",
+ "error": "Changes have not synced. Your draft is kept in this tab.",
+ "conflict": "The document was restored, replaced, or access changed. Keep your draft before rejoining.",
+ "retry": "Retry",
+ "recoveryConflict": "The server document was replaced. Your unsaved text is shown here. Export it before opening the current version.",
+ "exportRecovery": "Export my text",
+ "discardRecovery": "Open current version",
+ "discardConfirm": "Discard this unsaved copy and open the current server version? Export your text first if you need it."
+ },
+ "workItem": {
+ "create": "Create work item",
+ "description": "Create a linked work item from this selection.",
+ "title": "Title",
+ "status": "Status",
+ "source": "Source document",
+ "cancel": "Cancel",
+ "creating": "Creating…",
+ "failed": "Could not create the work item. Try again.",
+ "linkFailed": "The work item was created. Retry to finish linking it; another item will not be created.",
+ "retryLink": "Retry linking"
+ },
+ "comments": {
+ "title": "Comments",
+ "add": "Comment",
+ "edit": "Edit comment",
+ "save": "Save",
+ "cancel": "Cancel",
+ "reply": "Reply",
+ "replyPlaceholder": "Write a reply…",
+ "send": "Send",
+ "resolve": "Resolve",
+ "reopen": "Reopen",
+ "textRemoved": "The selected text was removed",
+ "unknownAuthor": "Former member",
+ "close": "Close comments",
+ "placeholder": "Discuss this selection…",
+ "resolved": "Resolved",
+ "open": "Open",
+ "failed": "Could not save. The document may have changed; select the text again or retry.",
+ "loading": "Loading comments…",
+ "retry": "Retry",
+ "noResolved": "No resolved discussions.",
+ "empty": "Select text to start a discussion."
+ },
+ "selectionActions": "Selection actions",
+ "recentAndFavorites": "Recent and favorites",
+ "searching": "Searching documents…"
}
diff --git a/apps/web/messages/pt-BR/initiatives.json b/apps/web/messages/pt-BR/initiatives.json
index 6018f1cc..c79e5615 100644
--- a/apps/web/messages/pt-BR/initiatives.json
+++ b/apps/web/messages/pt-BR/initiatives.json
@@ -156,10 +156,10 @@
"deleteFile": "Excluir {name}"
},
"documents": {
- "title": "Docs",
+ "title": "Documentos",
"add": "Vincular um Doc",
"empty": "Nenhum Doc vinculado ainda.",
- "loadFailed": "Não foi possível carregar os Docs vinculados. Tente novamente.",
+ "loadFailed": "Não foi possível carregar os documentos vinculados. Tente novamente.",
"untitled": "Sem título",
"remove": "Desvincular {title}"
}
diff --git a/apps/web/messages/pt-BR/issue.json b/apps/web/messages/pt-BR/issue.json
index 43c7dd60..3cced5c8 100644
--- a/apps/web/messages/pt-BR/issue.json
+++ b/apps/web/messages/pt-BR/issue.json
@@ -387,10 +387,10 @@
}
},
"documents": {
- "title": "Docs",
- "add": "Vincular uma página de Docs",
+ "title": "Documentos",
+ "add": "Vincular um documento",
"empty": "Nenhum Doc vinculado ainda.",
- "loadFailed": "Não foi possível carregar os Docs vinculados. Clique para tentar novamente.",
+ "loadFailed": "Não foi possível carregar os documentos vinculados. Clique para tentar novamente.",
"remove": "Desvincular {title}",
"untitled": "Sem título"
},
diff --git a/apps/web/messages/pt-BR/nav.json b/apps/web/messages/pt-BR/nav.json
index 30a00b76..54d1367f 100644
--- a/apps/web/messages/pt-BR/nav.json
+++ b/apps/web/messages/pt-BR/nav.json
@@ -6,7 +6,7 @@
"initiatives": "Iniciativas",
"cycles": "Ciclos",
"notes": "Notas",
- "documents": "Docs",
+ "documents": "Documentos",
"aiTeam": "Time de IA",
"aiAgents": "Agentes de IA",
"configuration": "Configuração",
diff --git a/apps/web/messages/pt-BR/newProject.json b/apps/web/messages/pt-BR/newProject.json
index 0439205b..1882e7c5 100644
--- a/apps/web/messages/pt-BR/newProject.json
+++ b/apps/web/messages/pt-BR/newProject.json
@@ -35,7 +35,7 @@
"customFields": "Campos personalizados",
"views": "Visões",
"dashboards": "Dashboards",
- "documents": "Docs",
+ "documents": "Documentos",
"actions": "Ações",
"configuration": "Configuração",
"webhooks": "Webhooks",
diff --git a/apps/web/messages/pt-BR/permissions.json b/apps/web/messages/pt-BR/permissions.json
index c3847782..10ea4fc3 100644
--- a/apps/web/messages/pt-BR/permissions.json
+++ b/apps/web/messages/pt-BR/permissions.json
@@ -6,7 +6,7 @@
"initiatives": "Iniciativas",
"cycles": "Ciclos",
"dashboards": "Dashboards",
- "documents": "Docs",
+ "documents": "Documentos",
"views": "Visões de itens de trabalho",
"members_invite": "Convites",
"members_manage": "Membros",
@@ -34,7 +34,7 @@
"groups": {
"workItems": "Itens de trabalho",
"dashboards": "Dashboards",
- "documents": "Docs",
+ "documents": "Documentos",
"notes": "Notas",
"ai": "IA",
"configuration": "Configuração",
diff --git a/apps/web/messages/pt-BR/teams.json b/apps/web/messages/pt-BR/teams.json
index f2c8545b..447ceafc 100644
--- a/apps/web/messages/pt-BR/teams.json
+++ b/apps/web/messages/pt-BR/teams.json
@@ -410,7 +410,7 @@
"issues": "Issues",
"initiatives": "Iniciativas",
"cycles": "Ciclos",
- "documents": "Docs",
+ "documents": "Documentos",
"notes": "Quadros de notas",
"project": "Projeto"
},
diff --git a/apps/web/messages/ru/common.json b/apps/web/messages/ru/common.json
index 3f94cef9..c750ad7f 100644
--- a/apps/web/messages/ru/common.json
+++ b/apps/web/messages/ru/common.json
@@ -151,7 +151,7 @@
"initiatives": "Инициативы",
"cycles": "Циклы",
"dashboards": "Дашборды",
- "documents": "Docs",
+ "documents": "Документы",
"notes": "Заметки",
"subtasks": "Подзадачи",
"checklists": "Чек-листы",
diff --git a/apps/web/messages/ru/documents.json b/apps/web/messages/ru/documents.json
index f071b37f..3be455a3 100644
--- a/apps/web/messages/ru/documents.json
+++ b/apps/web/messages/ru/documents.json
@@ -1,5 +1,5 @@
{
- "title": "Docs",
+ "title": "Документы",
"newDocument": "Новая страница",
"favoritePages": "Избранное",
"newSubpage": "Добавить страницу в {title}",
@@ -7,7 +7,7 @@
"untitled": "Без названия",
"titlePlaceholder": "Без названия",
"contentPlaceholder": "Начните писать или нажмите / для команд…",
- "search": "Поиск в Docs…",
+ "search": "Поиск документов…",
"sort": "Сортировать страницы",
"manualOrder": "Вручную",
"nameOrder": "По названию",
@@ -25,11 +25,11 @@
"month": "За 30 дней",
"clearFilters": "Сбросить фильтры",
"noResults": "Страницы не найдены.",
- "noAccess": "У вас нет доступа к Docs проекта.",
- "treeLabel": "Docs проекта",
+ "noAccess": "У вас нет доступа к документам проекта.",
+ "treeLabel": "Документы проекта",
"expand": "Развернуть страницу",
"collapse": "Свернуть страницу",
- "backToDocuments": "Назад в Docs",
+ "backToDocuments": "Назад к документам",
"documentActions": "Действия со страницей",
"pageIcon": "Иконка страницы",
"pageTitle": "Название страницы",
@@ -37,7 +37,7 @@
"saving": "Сохраняем…",
"saveFailed": "Не удалось сохранить",
"retrySave": "Повторить сохранение",
- "loadFailed": "Не удалось загрузить Docs",
+ "loadFailed": "Не удалось загрузить документы",
"conflict": "Есть более новая версия",
"reload": "Обновить",
"reviewConflict": "Разобраться",
@@ -145,9 +145,9 @@
"empty": "Связанных задач пока нет.",
"loadFailed": "Не удалось загрузить связанные задачи. Нажмите, чтобы повторить.",
"remove": "Отвязать {identifier}",
- "selectDocument": "Связать страницу Docs",
- "searchDocuments": "Поиск в Docs…",
- "loading": "Загрузка Docs…",
+ "selectDocument": "Связать документ",
+ "searchDocuments": "Поиск документов…",
+ "loading": "Загрузка документов…",
"noDocuments": "Нет доступных страниц для связи."
},
"toolbar": {
@@ -188,6 +188,66 @@
"codeBlock": "Блок кода",
"divider": "Разделитель",
"undo": "Отменить",
- "redo": "Повторить"
+ "redo": "Повторить",
+ "editorLabel": "Текст документа"
+ },
+ "recentAndFavorites": "Недавние и избранные",
+ "searching": "Поиск документов…",
+ "blocks": {
+ "actions": "Действия с блоком",
+ "up": "Переместить выше",
+ "down": "Переместить ниже",
+ "duplicate": "Дублировать блок или раздел",
+ "delete": "Удалить блок или раздел",
+ "copyLink": "Копировать ссылку на блок",
+ "linkCopied": "Ссылка скопирована",
+ "copyFailed": "Не удалось скопировать ссылку"
+ },
+ "sync": {
+ "connecting": "Подключаемся к документу…",
+ "offline": "Нет связи. Изменения сохраняются в этой вкладке и отправятся после подключения.",
+ "error": "Изменения пока не отправлены. Черновик сохранён в этой вкладке.",
+ "conflict": "Документ восстановлен, заменён или доступ изменился. Сохраните свой черновик перед повторным подключением.",
+ "retry": "Повторить",
+ "recoveryConflict": "Документ на сервере заменён. Здесь показан ваш несохранённый текст. Скачайте его перед открытием текущей версии.",
+ "exportRecovery": "Скачать мой текст",
+ "discardRecovery": "Открыть текущую версию",
+ "discardConfirm": "Удалить несохранённую копию и открыть текущую версию с сервера? Сначала скачайте текст, если он нужен."
+ },
+ "workItem": {
+ "create": "Создать задачу",
+ "description": "Создайте связанную задачу из выделенного текста.",
+ "title": "Название",
+ "status": "Статус",
+ "source": "Исходный документ",
+ "cancel": "Отмена",
+ "creating": "Создаём…",
+ "failed": "Не удалось создать задачу. Попробуйте ещё раз.",
+ "linkFailed": "Задача создана. Повторите привязку — вторая задача не появится.",
+ "retryLink": "Повторить привязку"
+ },
+ "selectionActions": "Действия с выделением",
+ "comments": {
+ "title": "Комментарии",
+ "add": "Комментировать",
+ "edit": "Редактировать комментарий",
+ "save": "Сохранить",
+ "cancel": "Отмена",
+ "reply": "Ответить",
+ "replyPlaceholder": "Напишите ответ…",
+ "send": "Отправить",
+ "resolve": "Закрыть обсуждение",
+ "reopen": "Открыть снова",
+ "textRemoved": "Выделенный текст удалён",
+ "unknownAuthor": "Бывший участник",
+ "close": "Закрыть комментарии",
+ "placeholder": "Обсудите выделенный текст…",
+ "resolved": "Закрытые",
+ "open": "Открытые",
+ "failed": "Не удалось сохранить. Возможно, документ изменился — выделите текст снова или повторите попытку.",
+ "loading": "Загрузка комментариев…",
+ "retry": "Повторить",
+ "noResolved": "Закрытых обсуждений пока нет.",
+ "empty": "Выделите текст, чтобы начать обсуждение."
}
}
diff --git a/apps/web/messages/ru/issue.json b/apps/web/messages/ru/issue.json
index 609cff2b..8feea145 100644
--- a/apps/web/messages/ru/issue.json
+++ b/apps/web/messages/ru/issue.json
@@ -387,9 +387,9 @@
}
},
"documents": {
- "title": "Docs",
- "add": "Связать страницу Docs",
- "empty": "Связанных страниц Docs пока нет.",
+ "title": "Документы",
+ "add": "Связать документ",
+ "empty": "Связанных документов пока нет.",
"loadFailed": "Не удалось загрузить связанные страницы. Нажмите, чтобы повторить.",
"remove": "Отвязать {title}",
"untitled": "Без названия"
diff --git a/apps/web/messages/ru/nav.json b/apps/web/messages/ru/nav.json
index 20258790..5f01212f 100644
--- a/apps/web/messages/ru/nav.json
+++ b/apps/web/messages/ru/nav.json
@@ -6,7 +6,7 @@
"initiatives": "Инициативы",
"cycles": "Циклы",
"notes": "Заметки",
- "documents": "Docs",
+ "documents": "Документы",
"aiTeam": "AI-команда",
"aiAgents": "ИИ-агенты",
"configuration": "Конфигурация",
diff --git a/apps/web/messages/ru/newProject.json b/apps/web/messages/ru/newProject.json
index a9ebabf2..5d6acb8d 100644
--- a/apps/web/messages/ru/newProject.json
+++ b/apps/web/messages/ru/newProject.json
@@ -35,7 +35,7 @@
"customFields": "Пользовательские поля",
"views": "Представления",
"dashboards": "Дашборды",
- "documents": "Docs",
+ "documents": "Документы",
"actions": "Действия",
"configuration": "Конфигурация",
"webhooks": "Вебхуки",
diff --git a/apps/web/messages/ru/permissions.json b/apps/web/messages/ru/permissions.json
index f8eabac9..ad0a8cd9 100644
--- a/apps/web/messages/ru/permissions.json
+++ b/apps/web/messages/ru/permissions.json
@@ -6,7 +6,7 @@
"initiatives": "Инициативы",
"cycles": "Циклы",
"dashboards": "Дашборды",
- "documents": "Docs",
+ "documents": "Документы",
"views": "Представления задач",
"members_invite": "Приглашения",
"members_manage": "Участники",
@@ -34,7 +34,7 @@
"groups": {
"workItems": "Задачи",
"dashboards": "Дашборды",
- "documents": "Docs",
+ "documents": "Документы",
"notes": "Заметки",
"ai": "AI",
"configuration": "Настройки",
diff --git a/apps/web/messages/ru/settings.json b/apps/web/messages/ru/settings.json
index d8de9bf0..e273ff2a 100644
--- a/apps/web/messages/ru/settings.json
+++ b/apps/web/messages/ru/settings.json
@@ -114,7 +114,7 @@
"subtasks": "Задачи, разбитые на подзадачи под родительской.",
"checklists": "Списки шагов внутри задачи.",
"issueStats": "Сколько задача провела в каждом статусе.",
- "documents": "Общая документация проекта в Docs."
+ "documents": "Совместная работа с документами проекта."
},
"featureOn": "Раздел «{feature}» включён",
"featureOff": "Раздел «{feature}» выключен"
diff --git a/apps/web/messages/ru/teams.json b/apps/web/messages/ru/teams.json
index c949de8a..44666693 100644
--- a/apps/web/messages/ru/teams.json
+++ b/apps/web/messages/ru/teams.json
@@ -410,7 +410,7 @@
"issues": "Задачи",
"initiatives": "Инициативы",
"cycles": "Циклы",
- "documents": "Docs",
+ "documents": "Документы",
"notes": "Доски заметок",
"project": "Проект"
},
diff --git a/apps/web/messages/uk/common.json b/apps/web/messages/uk/common.json
index 6a9b0bfb..449097c1 100644
--- a/apps/web/messages/uk/common.json
+++ b/apps/web/messages/uk/common.json
@@ -151,7 +151,7 @@
"initiatives": "Ініціативи",
"cycles": "Цикли",
"dashboards": "Дашборди",
- "documents": "Docs",
+ "documents": "Документи",
"notes": "Нотатки",
"subtasks": "Підзадачі",
"checklists": "Чеклісти",
diff --git a/apps/web/messages/uk/documents.json b/apps/web/messages/uk/documents.json
index 16be4722..5449b65d 100644
--- a/apps/web/messages/uk/documents.json
+++ b/apps/web/messages/uk/documents.json
@@ -1,5 +1,5 @@
{
- "title": "Docs",
+ "title": "Документи",
"newDocument": "Нова сторінка",
"favoritePages": "Обрані",
"newSubpage": "Додати сторінку до {title}",
@@ -7,7 +7,7 @@
"untitled": "Без назви",
"titlePlaceholder": "Без назви",
"contentPlaceholder": "Почніть писати або натисніть / для команд…",
- "search": "Пошук у Docs…",
+ "search": "Пошук документів…",
"sort": "Сортувати сторінки",
"manualOrder": "Вручну",
"nameOrder": "За назвою",
@@ -25,11 +25,11 @@
"month": "За 30 днів",
"clearFilters": "Скинути фільтри",
"noResults": "Сторінок не знайдено.",
- "noAccess": "У вас немає доступу до Docs проєкту.",
- "treeLabel": "Docs проєкту",
+ "noAccess": "У вас немає доступу до документів проєкту.",
+ "treeLabel": "Документи проєкту",
"expand": "Розгорнути сторінку",
"collapse": "Згорнути сторінку",
- "backToDocuments": "Назад до Docs",
+ "backToDocuments": "Назад до документів",
"documentActions": "Дії зі сторінкою",
"pageIcon": "Іконка сторінки",
"pageTitle": "Назва сторінки",
@@ -37,7 +37,7 @@
"saving": "Зберігаємо…",
"saveFailed": "Не вдалося зберегти",
"retrySave": "Повторити збереження",
- "loadFailed": "Не вдалося завантажити Docs",
+ "loadFailed": "Не вдалося завантажити документи",
"conflict": "Існує новіша версія",
"reload": "Оновити",
"reviewConflict": "Переглянути",
@@ -145,9 +145,9 @@
"empty": "Пов’язаних задач ще немає.",
"loadFailed": "Не вдалося завантажити пов’язані задачі. Натисніть, щоб повторити.",
"remove": "Відв’язати {identifier}",
- "selectDocument": "Пов’язати сторінку Docs",
- "searchDocuments": "Пошук у Docs…",
- "loading": "Завантаження Docs…",
+ "selectDocument": "Пов’язати документ",
+ "searchDocuments": "Пошук документів…",
+ "loading": "Завантаження документів…",
"noDocuments": "Немає доступних сторінок для зв’язку."
},
"toolbar": {
@@ -188,6 +188,66 @@
"codeBlock": "Блок коду",
"divider": "Роздільник",
"undo": "Скасувати",
- "redo": "Повторити"
+ "redo": "Повторити",
+ "editorLabel": "Document content"
+ },
+ "recentAndFavorites": "Recent and favorites",
+ "searching": "Searching documents…",
+ "blocks": {
+ "actions": "Block actions",
+ "up": "Move up",
+ "down": "Move down",
+ "duplicate": "Duplicate block or section",
+ "delete": "Delete block or section",
+ "copyLink": "Copy link to block",
+ "linkCopied": "Link copied",
+ "copyFailed": "Could not copy the link"
+ },
+ "sync": {
+ "connecting": "Connecting to the document…",
+ "offline": "Offline. Changes stay in this tab and will sync when you reconnect.",
+ "error": "Changes have not synced. Your draft is kept in this tab.",
+ "conflict": "The document was restored, replaced, or access changed. Keep your draft before rejoining.",
+ "retry": "Retry",
+ "recoveryConflict": "The server document was replaced. Your unsaved text is shown here. Export it before opening the current version.",
+ "exportRecovery": "Export my text",
+ "discardRecovery": "Open current version",
+ "discardConfirm": "Discard this unsaved copy and open the current server version? Export your text first if you need it."
+ },
+ "workItem": {
+ "create": "Create work item",
+ "description": "Create a linked work item from this selection.",
+ "title": "Title",
+ "status": "Status",
+ "source": "Source document",
+ "cancel": "Cancel",
+ "creating": "Creating…",
+ "failed": "Could not create the work item. Try again.",
+ "linkFailed": "The work item was created. Retry to finish linking it; another item will not be created.",
+ "retryLink": "Retry linking"
+ },
+ "selectionActions": "Selection actions",
+ "comments": {
+ "title": "Comments",
+ "add": "Comment",
+ "edit": "Edit comment",
+ "save": "Save",
+ "cancel": "Cancel",
+ "reply": "Reply",
+ "replyPlaceholder": "Write a reply…",
+ "send": "Send",
+ "resolve": "Resolve",
+ "reopen": "Reopen",
+ "textRemoved": "The selected text was removed",
+ "unknownAuthor": "Former member",
+ "close": "Close comments",
+ "placeholder": "Discuss this selection…",
+ "resolved": "Resolved",
+ "open": "Open",
+ "failed": "Could not save. The document may have changed; select the text again or retry.",
+ "loading": "Loading comments…",
+ "retry": "Retry",
+ "noResolved": "No resolved discussions.",
+ "empty": "Select text to start a discussion."
}
}
diff --git a/apps/web/messages/uk/issue.json b/apps/web/messages/uk/issue.json
index 11131fd3..7323ed6d 100644
--- a/apps/web/messages/uk/issue.json
+++ b/apps/web/messages/uk/issue.json
@@ -387,9 +387,9 @@
}
},
"documents": {
- "title": "Docs",
- "add": "Пов’язати сторінку Docs",
- "empty": "Пов’язаних сторінок Docs ще немає.",
+ "title": "Документи",
+ "add": "Пов’язати документ",
+ "empty": "Пов’язаних документів ще немає.",
"loadFailed": "Не вдалося завантажити пов’язані сторінки. Натисніть, щоб повторити.",
"remove": "Відв’язати {title}",
"untitled": "Без назви"
diff --git a/apps/web/messages/uk/nav.json b/apps/web/messages/uk/nav.json
index 34c1fa00..286f5cbf 100644
--- a/apps/web/messages/uk/nav.json
+++ b/apps/web/messages/uk/nav.json
@@ -6,7 +6,7 @@
"initiatives": "Ініціативи",
"cycles": "Цикли",
"notes": "Нотатки",
- "documents": "Docs",
+ "documents": "Документи",
"aiTeam": "AI-команда",
"aiAgents": "ШІ-агенти",
"configuration": "Конфігурація",
diff --git a/apps/web/messages/uk/newProject.json b/apps/web/messages/uk/newProject.json
index 31b3df99..376004db 100644
--- a/apps/web/messages/uk/newProject.json
+++ b/apps/web/messages/uk/newProject.json
@@ -35,7 +35,7 @@
"customFields": "Власні поля",
"views": "Подання",
"dashboards": "Дашборди",
- "documents": "Docs",
+ "documents": "Документи",
"actions": "Дії",
"configuration": "Конфігурація",
"webhooks": "Вебхуки",
diff --git a/apps/web/messages/uk/permissions.json b/apps/web/messages/uk/permissions.json
index 07bcd3d2..655b3e3b 100644
--- a/apps/web/messages/uk/permissions.json
+++ b/apps/web/messages/uk/permissions.json
@@ -6,7 +6,7 @@
"initiatives": "Ініціативи",
"cycles": "Цикли",
"dashboards": "Дашборди",
- "documents": "Docs",
+ "documents": "Документи",
"views": "Подання задач",
"members_invite": "Запрошення",
"members_manage": "Учасники",
@@ -34,7 +34,7 @@
"groups": {
"workItems": "Задачі",
"dashboards": "Дашборди",
- "documents": "Docs",
+ "documents": "Документи",
"notes": "Нотатки",
"ai": "AI",
"configuration": "Налаштування",
diff --git a/apps/web/messages/uk/settings.json b/apps/web/messages/uk/settings.json
index 9947b9b8..9f0a57e3 100644
--- a/apps/web/messages/uk/settings.json
+++ b/apps/web/messages/uk/settings.json
@@ -114,7 +114,7 @@
"subtasks": "Задачі, розбиті на підзадачі під батьківською.",
"checklists": "Списки кроків усередині задачі.",
"issueStats": "Скільки часу задача пробула в кожному статусі.",
- "documents": "Спільна документація проєкту в Docs."
+ "documents": "Спільна робота з документами проєкту."
},
"featureOn": "Розділ «{feature}» увімкнено",
"featureOff": "Розділ «{feature}» вимкнено"
diff --git a/apps/web/messages/uk/teams.json b/apps/web/messages/uk/teams.json
index 2342167e..a54e16c4 100644
--- a/apps/web/messages/uk/teams.json
+++ b/apps/web/messages/uk/teams.json
@@ -410,7 +410,7 @@
"issues": "Задачі",
"initiatives": "Ініціативи",
"cycles": "Цикли",
- "documents": "Docs",
+ "documents": "Документи",
"notes": "Дошки нотаток",
"project": "Проєкт"
},
diff --git a/apps/web/messages/zh-CN/common.json b/apps/web/messages/zh-CN/common.json
index 0660efc5..f4644001 100644
--- a/apps/web/messages/zh-CN/common.json
+++ b/apps/web/messages/zh-CN/common.json
@@ -151,7 +151,7 @@
"initiatives": "计划",
"cycles": "周期",
"dashboards": "仪表盘",
- "documents": "Docs",
+ "documents": "文档",
"notes": "便签",
"subtasks": "子任务",
"checklists": "检查清单",
diff --git a/apps/web/messages/zh-CN/documents.json b/apps/web/messages/zh-CN/documents.json
index 9ce09976..219525ce 100644
--- a/apps/web/messages/zh-CN/documents.json
+++ b/apps/web/messages/zh-CN/documents.json
@@ -1,5 +1,5 @@
{
- "title": "Docs",
+ "title": "文档",
"newDocument": "新建页面",
"favoritePages": "收藏",
"newSubpage": "在 {title} 下添加页面",
@@ -7,7 +7,7 @@
"untitled": "无标题",
"titlePlaceholder": "无标题",
"contentPlaceholder": "开始输入,或按 / 打开命令…",
- "search": "搜索 Docs…",
+ "search": "搜索文档…",
"sort": "页面排序",
"manualOrder": "手动排序",
"nameOrder": "名称",
@@ -25,11 +25,11 @@
"month": "过去 30 天",
"clearFilters": "清除筛选",
"noResults": "未找到页面。",
- "noAccess": "你无权访问项目 Docs。",
- "treeLabel": "项目 Docs",
+ "noAccess": "你无权访问项目文档。",
+ "treeLabel": "项目文档",
"expand": "展开页面",
"collapse": "收起页面",
- "backToDocuments": "返回 Docs",
+ "backToDocuments": "返回文档",
"documentActions": "页面操作",
"pageIcon": "页面图标",
"pageTitle": "页面标题",
@@ -37,7 +37,7 @@
"saving": "正在保存…",
"saveFailed": "保存失败",
"retrySave": "重试保存",
- "loadFailed": "无法加载 Docs",
+ "loadFailed": "无法加载文档",
"conflict": "存在更新版本",
"reload": "重新加载",
"reviewConflict": "查看",
@@ -145,9 +145,9 @@
"empty": "暂无关联的工作项。",
"loadFailed": "无法加载关联的工作项。点击重试。",
"remove": "取消关联 {identifier}",
- "selectDocument": "关联 Docs 页面",
- "searchDocuments": "搜索 Docs…",
- "loading": "正在加载 Docs…",
+ "selectDocument": "关联文档",
+ "searchDocuments": "搜索文档…",
+ "loading": "正在加载文档…",
"noDocuments": "没有可关联的页面。"
},
"toolbar": {
@@ -188,6 +188,66 @@
"codeBlock": "代码块",
"divider": "分隔线",
"undo": "撤销",
- "redo": "重做"
+ "redo": "重做",
+ "editorLabel": "Document content"
+ },
+ "recentAndFavorites": "Recent and favorites",
+ "searching": "Searching documents…",
+ "blocks": {
+ "actions": "Block actions",
+ "up": "Move up",
+ "down": "Move down",
+ "duplicate": "Duplicate block or section",
+ "delete": "Delete block or section",
+ "copyLink": "Copy link to block",
+ "linkCopied": "Link copied",
+ "copyFailed": "Could not copy the link"
+ },
+ "sync": {
+ "connecting": "Connecting to the document…",
+ "offline": "Offline. Changes stay in this tab and will sync when you reconnect.",
+ "error": "Changes have not synced. Your draft is kept in this tab.",
+ "conflict": "The document was restored, replaced, or access changed. Keep your draft before rejoining.",
+ "retry": "Retry",
+ "recoveryConflict": "The server document was replaced. Your unsaved text is shown here. Export it before opening the current version.",
+ "exportRecovery": "Export my text",
+ "discardRecovery": "Open current version",
+ "discardConfirm": "Discard this unsaved copy and open the current server version? Export your text first if you need it."
+ },
+ "workItem": {
+ "create": "Create work item",
+ "description": "Create a linked work item from this selection.",
+ "title": "Title",
+ "status": "Status",
+ "source": "Source document",
+ "cancel": "Cancel",
+ "creating": "Creating…",
+ "failed": "Could not create the work item. Try again.",
+ "linkFailed": "The work item was created. Retry to finish linking it; another item will not be created.",
+ "retryLink": "Retry linking"
+ },
+ "selectionActions": "Selection actions",
+ "comments": {
+ "title": "Comments",
+ "add": "Comment",
+ "edit": "Edit comment",
+ "save": "Save",
+ "cancel": "Cancel",
+ "reply": "Reply",
+ "replyPlaceholder": "Write a reply…",
+ "send": "Send",
+ "resolve": "Resolve",
+ "reopen": "Reopen",
+ "textRemoved": "The selected text was removed",
+ "unknownAuthor": "Former member",
+ "close": "Close comments",
+ "placeholder": "Discuss this selection…",
+ "resolved": "Resolved",
+ "open": "Open",
+ "failed": "Could not save. The document may have changed; select the text again or retry.",
+ "loading": "Loading comments…",
+ "retry": "Retry",
+ "noResolved": "No resolved discussions.",
+ "empty": "Select text to start a discussion."
}
}
diff --git a/apps/web/messages/zh-CN/issue.json b/apps/web/messages/zh-CN/issue.json
index becc1bd8..7a1586d4 100644
--- a/apps/web/messages/zh-CN/issue.json
+++ b/apps/web/messages/zh-CN/issue.json
@@ -387,9 +387,9 @@
}
},
"documents": {
- "title": "Docs",
- "add": "关联 Docs 页面",
- "empty": "暂无关联的 Docs 页面。",
+ "title": "文档",
+ "add": "关联文档",
+ "empty": "暂无关联文档。",
"loadFailed": "无法加载关联页面。点击重试。",
"remove": "取消关联 {title}",
"untitled": "无标题"
diff --git a/apps/web/messages/zh-CN/nav.json b/apps/web/messages/zh-CN/nav.json
index a7b4ff75..b21d7dc5 100644
--- a/apps/web/messages/zh-CN/nav.json
+++ b/apps/web/messages/zh-CN/nav.json
@@ -6,7 +6,7 @@
"initiatives": "计划",
"cycles": "周期",
"notes": "便签",
- "documents": "Docs",
+ "documents": "文档",
"aiTeam": "AI 团队",
"aiAgents": "AI 代理",
"configuration": "配置",
diff --git a/apps/web/messages/zh-CN/newProject.json b/apps/web/messages/zh-CN/newProject.json
index 3fb377e3..6bf95743 100644
--- a/apps/web/messages/zh-CN/newProject.json
+++ b/apps/web/messages/zh-CN/newProject.json
@@ -35,7 +35,7 @@
"customFields": "自定义字段",
"views": "视图",
"dashboards": "仪表盘",
- "documents": "Docs",
+ "documents": "文档",
"actions": "操作",
"configuration": "配置",
"webhooks": "Webhook",
diff --git a/apps/web/messages/zh-CN/permissions.json b/apps/web/messages/zh-CN/permissions.json
index 78a3c161..536e8fec 100644
--- a/apps/web/messages/zh-CN/permissions.json
+++ b/apps/web/messages/zh-CN/permissions.json
@@ -6,7 +6,7 @@
"initiatives": "计划",
"cycles": "周期",
"dashboards": "仪表盘",
- "documents": "Docs",
+ "documents": "文档",
"views": "工作项视图",
"members_invite": "邀请",
"members_manage": "成员",
@@ -34,7 +34,7 @@
"groups": {
"workItems": "工作项",
"dashboards": "仪表盘",
- "documents": "Docs",
+ "documents": "文档",
"notes": "便签",
"ai": "AI",
"configuration": "配置",
diff --git a/apps/web/messages/zh-CN/settings.json b/apps/web/messages/zh-CN/settings.json
index 41d8329d..46f3e936 100644
--- a/apps/web/messages/zh-CN/settings.json
+++ b/apps/web/messages/zh-CN/settings.json
@@ -114,7 +114,7 @@
"subtasks": "将工作项拆分为父工作项下的子任务。",
"checklists": "在工作项中跟踪简单步骤。",
"issueStats": "统计工作项在各状态中停留的时间。",
- "documents": "在 Docs 中组织共享项目文档。"
+ "documents": "组织和共享项目文档。"
},
"featureOn": "已启用{feature}",
"featureOff": "已停用{feature}"
diff --git a/apps/web/messages/zh-CN/teams.json b/apps/web/messages/zh-CN/teams.json
index 5e7db01f..c854f5b0 100644
--- a/apps/web/messages/zh-CN/teams.json
+++ b/apps/web/messages/zh-CN/teams.json
@@ -410,7 +410,7 @@
"issues": "任务",
"initiatives": "举措",
"cycles": "周期",
- "documents": "Docs",
+ "documents": "文档",
"notes": "便签板",
"project": "项目"
},
diff --git a/apps/web/package.json b/apps/web/package.json
index 44c712bf..18f0c9a7 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -68,6 +68,7 @@
"next": "^16.3.4",
"next-intl": "^4.13.6",
"next-themes": "^0.4.6",
+ "prosemirror-collab": "^1.3.1",
"radix-ui": "^1.6.7",
"react": "^19.2.8",
"react-day-picker": "^10.0.1",
diff --git a/apps/web/src/app/globals.css b/apps/web/src/app/globals.css
index 9e78e82b..62741a63 100644
--- a/apps/web/src/app/globals.css
+++ b/apps/web/src/app/globals.css
@@ -751,3 +751,27 @@
background-position: -200% 0;
}
}
+
+.md-content [id^='block-']:target {
+ outline: 2px solid color-mix(in srgb, var(--primary) 35%, transparent);
+ outline-offset: 6px;
+ border-radius: 4px;
+ scroll-margin-top: 5rem;
+}
+.document-issue-link {
+ border-radius: 4px;
+ background: color-mix(in srgb, var(--primary) 8%, transparent);
+ padding: 1px 5px;
+ text-decoration: none;
+ font-size: 0.9em;
+ font-weight: 500;
+}
+
+.document-comment-mark {
+ background-color: color-mix(in oklch, var(--primary) 12%, transparent);
+ border-bottom: 2px solid color-mix(in oklch, var(--primary) 45%, transparent);
+ cursor: pointer;
+}
+.document-comment-mark:hover {
+ background-color: color-mix(in oklch, var(--primary) 22%, transparent);
+}
diff --git a/apps/web/src/components/common/editor/EditorSelectionMenu.tsx b/apps/web/src/components/common/editor/EditorSelectionMenu.tsx
index 71db6552..2753cc78 100644
--- a/apps/web/src/components/common/editor/EditorSelectionMenu.tsx
+++ b/apps/web/src/components/common/editor/EditorSelectionMenu.tsx
@@ -1,3 +1,4 @@
+import type { ReactNode } from 'react';
import { type Editor } from '@tiptap/react';
import { BubbleMenu } from '@tiptap/react/menus';
import {
@@ -77,8 +78,10 @@ const ITEMS: {
export default function EditorSelectionMenu({
editor,
placement = 'top',
+ children,
}: {
editor: Editor;
+ children?: ReactNode;
// Above the selection by default. A field with a label right over it passes
// "bottom" so the menu does not cover the label.
placement?: 'top' | 'bottom';
@@ -88,7 +91,7 @@ export default function EditorSelectionMenu({
<BubbleMenu
editor={editor}
options={{ placement }}
- className="flex items-center gap-0.5 rounded-md border bg-popover p-1 shadow-md"
+ className="flex max-w-[calc(100vw-2rem)] flex-wrap items-center gap-0.5 rounded-md border bg-popover p-1 shadow-md"
>
{ITEMS.map((item) => (
<EditorToolbarButton
@@ -99,6 +102,7 @@ export default function EditorSelectionMenu({
<item.icon />
</EditorToolbarButton>
))}
+ {children}
</BubbleMenu>
);
}
diff --git a/apps/web/src/components/common/editor/tiptap-markdown.d.ts b/apps/web/src/components/common/editor/tiptap-markdown.d.ts
index b5d7bcce..65c5333b 100644
--- a/apps/web/src/components/common/editor/tiptap-markdown.d.ts
+++ b/apps/web/src/components/common/editor/tiptap-markdown.d.ts
@@ -1,3 +1,4 @@
+import type { Node } from '@tiptap/pm/model';
import type { MarkdownStorage } from 'tiptap-markdown';
// tiptap-markdown ships its storage type but never augments tiptap's Storage
@@ -6,6 +7,6 @@ import type { MarkdownStorage } from 'tiptap-markdown';
// holder of the editor instance can read the markdown back.
declare module '@tiptap/core' {
interface Storage {
- markdown: MarkdownStorage;
+ markdown: MarkdownStorage & { serializer: { serialize(node: Node): string } };
}
}
diff --git a/apps/web/src/components/layout/CommandPalette.tsx b/apps/web/src/components/layout/CommandPalette.tsx
index 6abee9bb..6a5ef64b 100644
--- a/apps/web/src/components/layout/CommandPalette.tsx
+++ b/apps/web/src/components/layout/CommandPalette.tsx
@@ -4,6 +4,7 @@ import { useDebouncedValue } from '@/hooks/useDebouncedValue';
import { useIssueSearchQuery } from '@/services/issues.service';
import type { Command, CommandPage, CommandSection } from '@/utils/commands';
import { substringFilter } from '@/utils/commandFilter';
+import CommandPaletteDocuments from './CommandPaletteDocuments';
import CommandPaletteIssues from '@/components/layout/CommandPaletteIssues';
import CommandPaletteRow from '@/components/layout/CommandPaletteRow';
import {
@@ -112,6 +113,12 @@ export default function CommandPalette({
</Fragment>
))
)}
+ <CommandPaletteDocuments
+ projectKey={currentProjectKey}
+ query={debounced}
+ enabled={open && !page}
+ onClose={() => onOpenChange(false)}
+ />
{/* Issue results only appear while the user is typing, otherwise the
palette would list the entire project on open. */}
{!page && hasProject && searching && (hits.length > 0 || search.isFetching) && (
diff --git a/apps/web/src/components/layout/CommandPaletteDocuments.tsx b/apps/web/src/components/layout/CommandPaletteDocuments.tsx
new file mode 100644
index 00000000..9b8331a5
--- /dev/null
+++ b/apps/web/src/components/layout/CommandPaletteDocuments.tsx
@@ -0,0 +1,84 @@
+import { useRouter } from 'next/navigation';
+import { useQuery } from '@tanstack/react-query';
+import { FileText, LockKeyhole } from 'lucide-react';
+import { useTranslations } from 'next-intl';
+import { listDocuments } from '@/lib/api/endpoints/documents';
+import { qk } from '@/services/queryKeys';
+import { usePermissions } from '@/hooks/usePermissions';
+import { useProjectFeatures } from '@/hooks/useProjectFeatures';
+import { useRecentDocuments } from '@/hooks/useDocumentNavigation';
+import { documentPath } from '@/utils/paths';
+import { DOCUMENT_PREFIX } from '@/utils/commandFilter';
+import { CommandGroup, CommandItem, CommandSeparator } from '@/components/ui/command';
+
+export default function CommandPaletteDocuments({
+ projectKey,
+ query,
+ enabled,
+ onClose,
+}: {
+ projectKey: string | null;
+ query: string;
+ enabled: boolean;
+ onClose: () => void;
+}) {
+ const t = useTranslations('documents');
+ const router = useRouter();
+ const { can } = usePermissions();
+ const features = useProjectFeatures();
+ const recent = useRecentDocuments(projectKey);
+ const allowed = features.documents && can('documents', 'read');
+ const result = useQuery({
+ queryKey: qk.documents(projectKey ?? '', query),
+ queryFn: () => listDocuments(projectKey!, query || undefined),
+ enabled: enabled && allowed && projectKey !== null,
+ staleTime: 30_000,
+ });
+ if (!enabled || !allowed || !projectKey) return null;
+ const documents = result.data ?? [];
+ const hits = query
+ ? documents.slice(0, 12)
+ : documents
+ .filter((item) => recent.ids.includes(item.id) || item.isFavorite)
+ .sort((a, b) => {
+ const ai = recent.ids.indexOf(a.id);
+ const bi = recent.ids.indexOf(b.id);
+ return (ai < 0 ? 99 : ai) - (bi < 0 ? 99 : bi);
+ })
+ .slice(0, 8);
+ if (!hits.length && !result.isFetching && !result.isError) return null;
+ return (
+ <>
+ <CommandSeparator />
+ <CommandGroup heading={query ? t('title') : t('recentAndFavorites')}>
+ {result.isError && (
+ <CommandItem value={`${DOCUMENT_PREFIX}error`} onSelect={() => void result.refetch()}>
+ {t('loadFailed')}
+ </CommandItem>
+ )}
+ {!hits.length && result.isFetching && (
+ <CommandItem value={`${DOCUMENT_PREFIX}loading`} disabled>
+ {t('searching')}
+ </CommandItem>
+ )}
+ {hits.map((item, index) => (
+ <CommandItem
+ key={item.id}
+ value={`${DOCUMENT_PREFIX}${index}`}
+ onSelect={() => {
+ recent.visit(item.id);
+ onClose();
+ router.push(documentPath(projectKey, item.id));
+ }}
+ >
+ <FileText />
+ <span className="min-w-0 flex-1 truncate" dir="auto">
+ {item.title || t('untitled')}
+ </span>
+ {item.isPrivate && <LockKeyhole className="size-3 text-muted-foreground" />}
+ </CommandItem>
+ ))}
+ </CommandGroup>
+ </>
+ );
+}
diff --git a/apps/web/src/features/documents/DocumentsPage.tsx b/apps/web/src/features/documents/DocumentsPage.tsx
index 854f2c53..9bb434c3 100644
--- a/apps/web/src/features/documents/DocumentsPage.tsx
+++ b/apps/web/src/features/documents/DocumentsPage.tsx
@@ -1,6 +1,6 @@
'use client';
-import { useDeferredValue, useEffect, useState } from 'react';
+import { useEffect } from 'react';
import { useParams, useRouter } from 'next/navigation';
import { useShell } from '@/context/shellContext';
import { usePermissions } from '@/hooks/usePermissions';
@@ -23,8 +23,12 @@ import DocumentLoadingState from './components/DocumentLoadingState';
import DocumentsIndex from './components/DocumentsIndex';
import { documentBelongsToTab, type DocumentListTab } from './utils/documentList';
import { documentAncestors } from './utils/documentTree';
+import { useDebouncedValue } from '@/hooks/useDebouncedValue';
+import { useDocumentNavigation, useRecentDocuments } from '@/hooks/useDocumentNavigation';
import { useTranslations } from 'next-intl';
+const listDefaults: { search: string; tab: DocumentListTab } = { search: '', tab: 'public' };
+
export default function DocumentsPage() {
const { project } = useShell();
const params = useParams<{ projectKey: string; documentId?: string }>();
@@ -34,13 +38,37 @@ export default function DocumentsPage() {
const projectKey = params.projectKey;
const routeId = params.documentId ? Number(params.documentId) : null;
const documentId = routeId && Number.isFinite(routeId) ? routeId : null;
- const [search, setSearch] = useState('');
- const [listTab, setListTab] = useState<DocumentListTab>('public');
- const deferredSearch = useDeferredValue(search.trim());
+ const [navigation, setNavigation] = useDocumentNavigation(projectKey, 'list', listDefaults);
+ const search = typeof navigation.search === 'string' ? navigation.search : '';
+ const listTab = ['public', 'private', 'favorites', 'archived'].includes(navigation.tab)
+ ? navigation.tab
+ : 'public';
+ const setSearch = (search: string) => setNavigation((previous) => ({ ...previous, search }));
+ const setListTab = (tab: DocumentListTab) => setNavigation((previous) => ({ ...previous, tab }));
+ const deferredSearch = useDebouncedValue(search.trim(), 250);
+ const { visit } = useRecentDocuments(projectKey);
+ useEffect(() => {
+ if (documentId !== null) visit(documentId);
+ }, [documentId, visit]);
const allDocumentsQuery = useDocumentsQuery(projectKey);
- const allArchivedDocumentsQuery = useDocumentsQuery(projectKey, '', true);
- const activeDocumentsQuery = useDocumentsQuery(projectKey, deferredSearch);
- const archivedDocumentsQuery = useDocumentsQuery(projectKey, deferredSearch, true);
+ const allArchivedDocumentsQuery = useDocumentsQuery(
+ projectKey,
+ '',
+ true,
+ documentId !== null || listTab === 'archived',
+ );
+ const activeDocumentsQuery = useDocumentsQuery(
+ projectKey,
+ deferredSearch,
+ false,
+ documentId === null && listTab !== 'archived',
+ );
+ const archivedDocumentsQuery = useDocumentsQuery(
+ projectKey,
+ deferredSearch,
+ true,
+ documentId === null && listTab === 'archived',
+ );
const visibleDocumentsQuery =
listTab === 'archived' ? archivedDocumentsQuery : activeDocumentsQuery;
const filteredDocuments = (visibleDocumentsQuery.data ?? []).filter((document) =>
@@ -76,6 +104,7 @@ export default function DocumentsPage() {
qk.document(projectKey, documentId),
qk.documentRevisions(projectKey, documentId),
qk.documentAssets(projectKey, documentId),
+ qk.documentComments(projectKey, documentId),
qk.documentIssueLinks(projectKey, documentId),
]),
],
diff --git a/apps/web/src/features/documents/components/DocumentBlockMenu.tsx b/apps/web/src/features/documents/components/DocumentBlockMenu.tsx
new file mode 100644
index 00000000..6183f837
--- /dev/null
+++ b/apps/web/src/features/documents/components/DocumentBlockMenu.tsx
@@ -0,0 +1,98 @@
+import { useEffect, useState } from 'react';
+import type { Editor } from '@tiptap/react';
+import { ArrowDown, ArrowUp, Copy, GripVertical, Link2, Trash2 } from 'lucide-react';
+import { toast } from 'sonner';
+import { useTranslations } from 'next-intl';
+import { Button } from '@/components/ui/button';
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuSeparator,
+ DropdownMenuTrigger,
+} from '@/components/ui/dropdown-menu';
+import { changeDocumentBlock, documentBlockRange } from '../utils/documentBlocks';
+
+export default function DocumentBlockMenu({ editor }: { editor: Editor }) {
+ const t = useTranslations('documents.blocks');
+ const [position, setPosition] = useState(1);
+ const [top, setTop] = useState(0);
+ useEffect(() => {
+ const update = () => {
+ const position = editor.state.selection.from;
+ setPosition(position);
+ const range = documentBlockRange(editor, position);
+ const node = range && editor.view.nodeDOM(range.from);
+ const container = editor.view.dom.closest('[data-document-editor]');
+ if (node instanceof HTMLElement && container)
+ setTop(node.getBoundingClientRect().top - container.getBoundingClientRect().top);
+ };
+ editor.on('selectionUpdate', update);
+ const resize = new ResizeObserver(update);
+ resize.observe(editor.view.dom);
+ update();
+ return () => {
+ editor.off('selectionUpdate', update);
+ resize.disconnect();
+ };
+ }, [editor]);
+ const range = documentBlockRange(editor, position);
+ return (
+ <div className="absolute -start-7 z-20 print:hidden" style={{ top }}>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button
+ type="button"
+ variant="ghost"
+ size="icon-sm"
+ aria-label={t('actions')}
+ className="size-7 text-muted-foreground"
+ >
+ <GripVertical className="size-4" />
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="start">
+ {(['up', 'down', 'duplicate'] as const).map((action) => {
+ const Icon = action === 'up' ? ArrowUp : action === 'down' ? ArrowDown : Copy;
+ return (
+ <DropdownMenuItem
+ key={action}
+ onSelect={() => changeDocumentBlock(editor, position, action)}
+ disabled={
+ !range ||
+ (action === 'up' && range.from === 0) ||
+ (action === 'down' && range.to === editor.state.doc.content.size)
+ }
+ >
+ <Icon />
+ {t(action)}
+ </DropdownMenuItem>
+ );
+ })}
+ <DropdownMenuItem
+ disabled={!range?.node.attrs.blockId}
+ onSelect={() => {
+ const url = new URL(window.location.href);
+ url.hash = `block-${range?.node.attrs.blockId}`;
+ void navigator.clipboard
+ .writeText(url.toString())
+ .then(() => toast.success(t('linkCopied')))
+ .catch(() => toast.error(t('copyFailed')));
+ }}
+ >
+ <Link2 />
+ {t('copyLink')}
+ </DropdownMenuItem>
+ <DropdownMenuSeparator />
+ <DropdownMenuItem
+ variant="destructive"
+ onSelect={() => changeDocumentBlock(editor, position, 'delete')}
+ >
+ <Trash2 />
+ {t('delete')}
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </div>
+ );
+}
diff --git a/apps/web/src/features/documents/components/DocumentCommentThread.tsx b/apps/web/src/features/documents/components/DocumentCommentThread.tsx
new file mode 100644
index 00000000..88d3c3ab
--- /dev/null
+++ b/apps/web/src/features/documents/components/DocumentCommentThread.tsx
@@ -0,0 +1,140 @@
+import { useState } from 'react';
+import { Check, CornerDownRight, Pencil, RotateCcw } from 'lucide-react';
+import { useTranslations } from 'next-intl';
+import type { DocumentComment } from '@/lib/api/endpoints/documents';
+import { Button } from '@/components/ui/button';
+import { Textarea } from '@/components/ui/textarea';
+
+export default function DocumentCommentThread({
+ comment,
+ replies,
+ userId,
+ canComment,
+ busy,
+ onReply,
+ onUpdate,
+ onJump,
+}: {
+ comment: DocumentComment;
+ replies: DocumentComment[];
+ userId: string | null;
+ canComment: boolean;
+ busy: boolean;
+ onReply: (body: string) => Promise<void>;
+ onUpdate: (id: string, input: { body?: string; resolved?: boolean }) => Promise<void>;
+ onJump: () => void;
+}) {
+ const t = useTranslations('documents.comments');
+ const [reply, setReply] = useState('');
+ const [replying, setReplying] = useState(false);
+ const [edit, setEdit] = useState<{ id: string; body: string } | null>(null);
+ const items = [comment, ...replies];
+ return (
+ <article id={`document-comment-${comment.id}`} className="border-b px-4 py-4">
+ <button
+ type="button"
+ onClick={onJump}
+ disabled={comment.orphaned}
+ className="mb-3 block w-full border-s-2 border-primary/40 ps-3 text-start text-xs leading-5 text-muted-foreground hover:text-foreground"
+ >
+ <span className="line-clamp-3">{comment.quote}</span>
+ {comment.orphaned && <span className="mt-1 block italic">{t('textRemoved')}</span>}
+ </button>
+ {items.map((item) => (
+ <div key={item.id} className={item.parentId ? 'ms-3 mt-3 border-s ps-3' : ''}>
+ <div className="mb-1 flex items-center gap-2 text-xs">
+ <span className="min-w-0 flex-1 truncate font-medium">
+ {item.authorName ?? t('unknownAuthor')}
+ </span>
+ {canComment && item.authorId === userId && (
+ <Button
+ variant="ghost"
+ size="icon-sm"
+ aria-label={t('edit')}
+ onClick={() => setEdit({ id: item.id, body: item.body })}
+ >
+ <Pencil className="size-3" />
+ </Button>
+ )}
+ </div>
+ {edit?.id === item.id ? (
+ <form
+ onSubmit={(event) => {
+ event.preventDefault();
+ void onUpdate(item.id, { body: edit.body })
+ .then(() => setEdit(null))
+ .catch(() => undefined);
+ }}
+ className="space-y-2"
+ >
+ <Textarea
+ value={edit.body}
+ maxLength={10000}
+ onChange={(event) => setEdit({ id: item.id, body: event.target.value })}
+ aria-label={t('edit')}
+ />
+ <Button size="sm" disabled={busy || !edit.body.trim()}>
+ {t('save')}
+ </Button>
+ <Button type="button" size="sm" variant="ghost" onClick={() => setEdit(null)}>
+ {t('cancel')}
+ </Button>
+ </form>
+ ) : (
+ <p className="text-sm leading-6 break-words whitespace-pre-wrap" dir="auto">
+ {item.body}
+ </p>
+ )}
+ </div>
+ ))}
+ {canComment && (
+ <div className="mt-3 flex items-center gap-1">
+ <Button size="sm" variant="ghost" onClick={() => setReplying((value) => !value)}>
+ <CornerDownRight className="size-3.5" />
+ {t('reply')}
+ </Button>
+ <Button
+ size="sm"
+ variant="ghost"
+ disabled={busy}
+ onClick={() =>
+ void onUpdate(comment.id, { resolved: !comment.resolvedAt }).catch(() => undefined)
+ }
+ >
+ {comment.resolvedAt ? (
+ <RotateCcw className="size-3.5" />
+ ) : (
+ <Check className="size-3.5" />
+ )}
+ {comment.resolvedAt ? t('reopen') : t('resolve')}
+ </Button>
+ </div>
+ )}
+ {replying && (
+ <form
+ className="mt-2 space-y-2"
+ onSubmit={(event) => {
+ event.preventDefault();
+ void onReply(reply)
+ .then(() => {
+ setReply('');
+ setReplying(false);
+ })
+ .catch(() => undefined);
+ }}
+ >
+ <Textarea
+ value={reply}
+ onChange={(event) => setReply(event.target.value)}
+ maxLength={10000}
+ aria-label={t('reply')}
+ placeholder={t('replyPlaceholder')}
+ />
+ <Button size="sm" disabled={busy || !reply.trim()}>
+ {t('send')}
+ </Button>
+ </form>
+ )}
+ </article>
+ );
+}
diff --git a/apps/web/src/features/documents/components/DocumentCommentsPanel.tsx b/apps/web/src/features/documents/components/DocumentCommentsPanel.tsx
new file mode 100644
index 00000000..ff4de531
--- /dev/null
+++ b/apps/web/src/features/documents/components/DocumentCommentsPanel.tsx
@@ -0,0 +1,181 @@
+import { useState } from 'react';
+import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
+import type { Editor } from '@tiptap/react';
+import { MessageSquare, X } from 'lucide-react';
+import { useTranslations } from 'next-intl';
+import {
+ addDocumentComment,
+ listDocumentComments,
+ updateDocumentComment,
+} from '@/lib/api/endpoints/documents';
+import { qk } from '@/services/queryKeys';
+import { useSession } from '@/lib/auth-client';
+import { Button } from '@/components/ui/button';
+import { Textarea } from '@/components/ui/textarea';
+import DocumentCommentThread from './DocumentCommentThread';
+import type { DocumentSelection } from './DocumentSelectionActions';
+
+export default function DocumentCommentsPanel({
+ editor,
+ projectKey,
+ documentId,
+ version,
+ selection,
+ canComment,
+ onClose,
+ onCommented,
+}: {
+ editor: Editor | null;
+ projectKey: string;
+ documentId: number;
+ version: number;
+ selection: DocumentSelection | null;
+ canComment: boolean;
+ onClose: () => void;
+ onCommented: () => void;
+}) {
+ const t = useTranslations('documents.comments');
+ const { data: session } = useSession();
+ const qc = useQueryClient();
+ const [body, setBody] = useState('');
+ const [showResolved, setShowResolved] = useState(false);
+ const key = qk.documentComments(projectKey, documentId);
+ const query = useQuery({
+ queryKey: key,
+ queryFn: () => listDocumentComments(projectKey, documentId),
+ });
+ const create = useMutation({
+ meta: { suppressErrorToast: true },
+ mutationFn: (input: {
+ body: string;
+ parentId?: string;
+ quote?: string;
+ from?: number;
+ to?: number;
+ }) =>
+ addDocumentComment(projectKey, documentId, {
+ ...input,
+ version: input.parentId ? version : (selection?.version ?? version),
+ }),
+ onSuccess: () => qc.invalidateQueries({ queryKey: key }),
+ });
+ const update = useMutation({
+ meta: { suppressErrorToast: true },
+ mutationFn: ({ id, input }: { id: string; input: { body?: string; resolved?: boolean } }) =>
+ updateDocumentComment(projectKey, documentId, id, input),
+ onSuccess: () => qc.invalidateQueries({ queryKey: key }),
+ });
+ const comments = query.data ?? [];
+ const roots = comments.filter(
+ (item) => !item.parentId && Boolean(item.resolvedAt) === showResolved,
+ );
+ const busy = create.isPending || update.isPending;
+ return (
+ <aside
+ aria-label={t('title')}
+ className="absolute inset-y-0 end-0 z-30 flex w-[min(100%,360px)] flex-col border-s bg-background shadow-sm motion-safe:animate-in motion-safe:fade-in md:relative md:w-[340px] md:shrink-0 md:shadow-none"
+ >
+ <header className="flex h-12 shrink-0 items-center gap-2 border-b px-4">
+ <MessageSquare className="size-4" />
+ <h2 className="flex-1 text-sm font-medium">{t('title')}</h2>
+ <Button size="icon-sm" variant="ghost" aria-label={t('close')} onClick={onClose}>
+ <X className="size-4" />
+ </Button>
+ </header>
+ <div className="min-h-0 flex-1 overflow-y-auto">
+ {selection && canComment && (
+ <form
+ className="space-y-3 border-b p-4"
+ onSubmit={(event) => {
+ event.preventDefault();
+ void create
+ .mutateAsync({ ...selection, quote: selection.quote.slice(0, 2000), body })
+ .then(() => {
+ setBody('');
+ onCommented();
+ })
+ .catch(() => undefined);
+ }}
+ >
+ <blockquote className="line-clamp-3 border-s-2 border-primary/40 ps-3 text-xs leading-5 text-muted-foreground">
+ {selection.quote}
+ </blockquote>
+ <Textarea
+ autoFocus
+ aria-label={t('add')}
+ placeholder={t('placeholder')}
+ value={body}
+ maxLength={10000}
+ onChange={(event) => setBody(event.target.value)}
+ onKeyDown={(event) => {
+ if ((event.metaKey || event.ctrlKey) && event.key === 'Enter')
+ event.currentTarget.form?.requestSubmit();
+ }}
+ />
+ <Button size="sm" disabled={busy || !body.trim()}>
+ {t('send')}
+ </Button>
+ </form>
+ )}
+ <div className="flex gap-1 border-b px-3 py-2">
+ {[false, true].map((resolved) => (
+ <Button
+ key={String(resolved)}
+ size="sm"
+ variant={showResolved === resolved ? 'secondary' : 'ghost'}
+ onClick={() => setShowResolved(resolved)}
+ >
+ {resolved ? t('resolved') : t('open')}
+ </Button>
+ ))}
+ </div>
+ {(create.isError || update.isError) && (
+ <p role="alert" className="p-4 text-xs text-destructive">
+ {t('failed')}
+ </p>
+ )}
+ {query.isLoading ? (
+ <p className="p-4 text-xs text-muted-foreground">{t('loading')}</p>
+ ) : query.isError ? (
+ <Button variant="ghost" onClick={() => void query.refetch()}>
+ {t('retry')}
+ </Button>
+ ) : !roots.length ? (
+ <p className="px-6 py-12 text-center text-sm leading-6 text-muted-foreground">
+ {showResolved ? t('noResolved') : t('empty')}
+ </p>
+ ) : (
+ roots.map((comment) => (
+ <DocumentCommentThread
+ key={comment.id}
+ comment={comment}
+ replies={comments.filter((item) => item.parentId === comment.id)}
+ userId={session?.user.id ?? null}
+ canComment={canComment}
+ busy={busy}
+ onReply={async (body) => {
+ await create.mutateAsync({ body, parentId: comment.id });
+ }}
+ onUpdate={async (id, input) => {
+ await update.mutateAsync({ id, input });
+ }}
+ onJump={() => {
+ if (
+ editor &&
+ comment.from !== null &&
+ comment.to !== null &&
+ comment.to <= editor.state.doc.content.size
+ )
+ editor
+ .chain()
+ .setTextSelection({ from: comment.from, to: comment.to })
+ .scrollIntoView()
+ .run();
+ }}
+ />
+ ))
+ )}
+ </div>
+ </aside>
+ );
+}
diff --git a/apps/web/src/features/documents/components/DocumentCreateIssueDialog.tsx b/apps/web/src/features/documents/components/DocumentCreateIssueDialog.tsx
new file mode 100644
index 00000000..bf68c09f
--- /dev/null
+++ b/apps/web/src/features/documents/components/DocumentCreateIssueDialog.tsx
@@ -0,0 +1,148 @@
+import { useRef, useState } from 'react';
+import { useQueryClient } from '@tanstack/react-query';
+import type { Editor } from '@tiptap/react';
+import type { SelectionBookmark } from '@tiptap/pm/state';
+import { useTranslations } from 'next-intl';
+import { type Issue, createIssue } from '@/lib/api/endpoints/issues';
+import { listDocumentIssueLinks, linkDocumentIssue } from '@/lib/api/endpoints/documents';
+import { useShell } from '@/context/shellContext';
+import { qk } from '@/services/queryKeys';
+import { documentPath, issuePath } from '@/utils/paths';
+import { Button } from '@/components/ui/button';
+import { Input } from '@/components/ui/input';
+import {
+ Dialog,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+} from '@/components/ui/dialog';
+
+export default function DocumentCreateIssueDialog({
+ editor,
+ projectKey,
+ documentId,
+ quote,
+ bookmark,
+ onClose,
+}: {
+ editor: Editor;
+ projectKey: string;
+ documentId: number;
+ quote: string;
+ bookmark: { current: SelectionBookmark };
+ onClose: () => void;
+}) {
+ const t = useTranslations('documents.workItem');
+ const { project } = useShell();
+ const qc = useQueryClient();
+ const [title, setTitle] = useState(quote.slice(0, 255));
+ const [columnId, setColumnId] = useState(project?.columns[0]?.id ?? 0);
+ const [pending, setPending] = useState(false);
+ const [failure, setFailure] = useState(false);
+ const created = useRef<Issue | null>(null);
+ const create = async () => {
+ if (pending || !title.trim() || !columnId) return;
+ setPending(true);
+ setFailure(false);
+ try {
+ if (!created.current)
+ created.current = await createIssue(projectKey, {
+ title: title.trim(),
+ columnId,
+ description: `[${t('source')}](${new URL(documentPath(projectKey, documentId), window.location.origin).toString()})\n\n${quote}`,
+ });
+ const issue = created.current;
+ const links = await listDocumentIssueLinks(projectKey, documentId);
+ if (!links.some((link) => link.issueId === issue.id))
+ await linkDocumentIssue(projectKey, documentId, issue.id);
+ if (!editor.isDestroyed && editor.isEditable) {
+ const selection = bookmark.current.resolve(editor.state.doc);
+ const unchanged =
+ editor.state.doc.textBetween(selection.from, selection.to, '\n') === quote;
+ const from = unchanged ? selection.from : selection.to;
+ editor
+ .chain()
+ .focus()
+ .insertContentAt(
+ { from, to: selection.to },
+ {
+ type: 'text',
+ text: `${projectKey}-${issue.sequenceNumber}`,
+ marks: [
+ {
+ type: 'link',
+ attrs: {
+ href: issuePath(projectKey, issue.sequenceNumber),
+ class: 'document-issue-link',
+ },
+ },
+ ],
+ },
+ )
+ .run();
+ }
+ void qc.invalidateQueries({ queryKey: qk.documentIssueLinks(projectKey, documentId) });
+ void qc.invalidateQueries({ queryKey: qk.boardIssues(projectKey) });
+ onClose();
+ } catch {
+ setFailure(true);
+ } finally {
+ setPending(false);
+ }
+ };
+ return (
+ <Dialog
+ open
+ onOpenChange={(open) => {
+ if (!open && !pending) onClose();
+ }}
+ >
+ <DialogContent>
+ <DialogHeader>
+ <DialogTitle>{t('create')}</DialogTitle>
+ <DialogDescription>{t('description')}</DialogDescription>
+ </DialogHeader>
+ <label className="grid gap-2 text-sm">
+ {t('title')}
+ <Input
+ value={title}
+ maxLength={255}
+ onChange={(event) => setTitle(event.target.value)}
+ disabled={pending || created.current !== null}
+ autoFocus
+ />
+ </label>
+ <label className="grid gap-2 text-sm">
+ {t('status')}
+ <select
+ className="h-9 rounded-md border bg-background px-3"
+ value={columnId}
+ onChange={(event) => setColumnId(Number(event.target.value))}
+ disabled={pending || created.current !== null}
+ >
+ {project?.columns.map((column) => (
+ <option key={column.id} value={column.id}>
+ {column.name}
+ </option>
+ ))}
+ </select>
+ </label>
+ {failure && (
+ <p role="alert" className="text-sm text-destructive">
+ {created.current ? t('linkFailed') : t('failed')}
+ </p>
+ )}
+ <DialogFooter>
+ <Button variant="outline" onClick={onClose} disabled={pending}>
+ {t('cancel')}
+ </Button>
+ <Button onClick={() => void create()} disabled={pending || !title.trim() || !columnId}>
+ {pending ? t('creating') : created.current ? t('retryLink') : t('create')}
+ </Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+ );
+}
diff --git a/apps/web/src/features/documents/components/DocumentEditor.tsx b/apps/web/src/features/documents/components/DocumentEditor.tsx
index 6391b7d3..c7457b3d 100644
--- a/apps/web/src/features/documents/components/DocumentEditor.tsx
+++ b/apps/web/src/features/documents/components/DocumentEditor.tsx
@@ -6,6 +6,11 @@ import type { ProjectDocument, ProjectDocumentSummary } from '@/lib/api/endpoint
import { useRelativeTime } from '@/context/relativeTimeContext';
import { useSession } from '@/lib/auth-client';
import { useTranslations } from 'next-intl';
+import { useDocumentCommentMarks } from '../hooks/useDocumentCommentMarks';
+import { useDocumentCollaboration } from '../hooks/useDocumentCollaboration';
+import DocumentCommentsPanel from './DocumentCommentsPanel';
+import type { DocumentSelection } from './DocumentSelectionActions';
+import DocumentSyncBanner from './DocumentSyncBanner';
import { useDocumentDraft } from '../hooks/useDocumentDraft';
import { useDocumentActionGate } from '../hooks/useDocumentActionGate';
import { useDocumentEditorPreferences } from '../hooks/useDocumentEditorPreferences';
@@ -71,6 +76,8 @@ export default function DocumentEditor({
const [deleteOpen, setDeleteOpen] = useState(false);
const [discardOpen, setDiscardOpen] = useState(false);
const [historyOpen, setHistoryOpen] = useState(false);
+ const [commentsOpen, setCommentsOpen] = useState(false);
+ const [commentSelection, setCommentSelection] = useState<DocumentSelection | null>(null);
const [inspectorOpen, setInspectorOpen] = useState(false);
const documentAction = useDocumentActionGate();
const currentUserId = session?.user.id ?? null;
@@ -92,6 +99,7 @@ export default function DocumentEditor({
const setDocumentFavorite = useSetDocumentFavorite(projectKey);
const uploadDocumentAsset = useUploadDocumentAsset(projectKey, document.id);
const {
+ legacyDraft,
title,
content,
contentJson,
@@ -104,7 +112,31 @@ export default function DocumentEditor({
save,
replaceWith,
adoptServerDocument,
- } = useDocumentDraft({ projectKey, document, editable: editorEditable, userId: currentUserId });
+ } = useDocumentDraft({
+ projectKey,
+ document,
+ editable: editorEditable,
+ userId: currentUserId,
+ collaborative: editable,
+ });
+ const collaboration = useDocumentCollaboration({
+ editor,
+ projectKey,
+ document,
+ userId: currentUserId,
+ enabled: editable && !legacyDraft,
+ onSaved: adoptServerDocument,
+ });
+ useDocumentCommentMarks(
+ editor,
+ projectKey,
+ document.id,
+ () => {
+ setCommentsOpen(true);
+ setInspectorOpen(false);
+ },
+ editable ? collaboration.version : document.version,
+ );
const providerActionPending =
updateDocument.isPending ||
setDocumentAccess.isPending ||
@@ -113,7 +145,10 @@ export default function DocumentEditor({
restoreDocument.isPending ||
setDocumentFavorite.isPending;
const actionPending = documentAction.pending || providerActionPending;
- const busy = actionPending || saveState === 'saving';
+ const busy =
+ actionPending ||
+ saveState === 'saving' ||
+ (editable && (!collaboration.ready || collaboration.status === 'saving'));
useEffect(() => {
const element = titleRef.current;
@@ -129,9 +164,11 @@ export default function DocumentEditor({
const prepareVersion = async () => {
if (providerActionPending || saveState === 'conflict' || saveState === 'error') return null;
+ const synchronized = editable ? await collaboration.flush() : null;
+ if (editable && !synchronized) return null;
const updatedDraft = await save();
if (dirty && !updatedDraft) return null;
- return updatedDraft?.version ?? version;
+ return updatedDraft?.version ?? synchronized?.version ?? version;
};
const runVersioned = async (
@@ -166,9 +203,15 @@ export default function DocumentEditor({
document={document}
ancestors={ancestors}
title={title}
- content={content}
- richHtml={editor?.getHTML() ?? ''}
- saveState={saveState}
+ content={() => editor?.storage.markdown.getMarkdown() ?? content}
+ richHtml={() => editor?.getHTML() ?? ''}
+ saveState={
+ editable && collaboration.status !== 'saved'
+ ? ['connecting', 'saving'].includes(collaboration.status)
+ ? 'saving'
+ : 'error'
+ : saveState
+ }
dirty={dirty}
stickyToolbar={stickyToolbar}
canCreate={canCreate}
@@ -178,7 +221,10 @@ export default function DocumentEditor({
canDelete={canManageLifecycle}
busy={busy}
onBack={onBack}
- onRetrySave={() => void save()}
+ onRetrySave={() => {
+ collaboration.retry();
+ void save();
+ }}
onFullWidthChange={(fullWidth) => {
void runVersioned((baseVersion) =>
updateDocument.mutateAsync({
@@ -231,11 +277,40 @@ export default function DocumentEditor({
);
}}
onDelete={() => setDeleteOpen(true)}
+ commentsOpen={commentsOpen}
+ onCommentsOpen={() => {
+ setCommentsOpen((value) => !value);
+ setInspectorOpen(false);
+ }}
inspectorOpen={inspectorOpen}
- onInspectorOpenChange={setInspectorOpen}
+ onInspectorOpenChange={(open) => {
+ setInspectorOpen(open);
+ if (open) setCommentsOpen(false);
+ }}
onOpenHistory={() => setHistoryOpen(true)}
/>
+ {editable && !legacyDraft && (
+ <DocumentSyncBanner
+ state={collaboration.status}
+ onRetry={collaboration.retry}
+ recoveryConflict={collaboration.recoveryConflict}
+ onDiscardRecovery={collaboration.discardRecovery}
+ onExportRecovery={() => {
+ if (!editor) return;
+ const url = URL.createObjectURL(
+ new Blob([editor.storage.markdown.getMarkdown()], {
+ type: 'text/markdown;charset=utf-8',
+ }),
+ );
+ const link = window.document.createElement('a');
+ link.href = url;
+ link.download = `${title || 'document'}-recovery.md`;
+ link.click();
+ URL.revokeObjectURL(url);
+ }}
+ />
+ )}
{saveState === 'conflict' && (
<DocumentConflictBanner onReload={() => setDiscardOpen(true)} />
)}
@@ -248,7 +323,22 @@ export default function DocumentEditor({
editorRevision={editorRevision}
editor={editor}
titleRef={titleRef}
- editable={editorEditable}
+ editable={editorEditable && collaboration.ready}
+ collaborative
+ onComment={() => {
+ void collaboration.flush().then((saved) => {
+ if (!editor || !saved) return;
+ const { from, to } = editor.state.selection;
+ setCommentSelection({
+ from,
+ to,
+ quote: editor.state.doc.textBetween(from, to, '\n'),
+ version: saved.version,
+ });
+ setCommentsOpen(true);
+ setInspectorOpen(false);
+ });
+ }}
stickyToolbar={stickyToolbar}
updateLabel={updateLabel}
onEditorReady={setEditor}
@@ -263,11 +353,26 @@ export default function DocumentEditor({
);
}}
onContentChange={({ markdown, json }) => setContent(markdown, json)}
- onContentBlur={() => void save()}
+ onContentBlur={() => {
+ void collaboration.flush();
+ void save();
+ }}
onUploadImage={(file) => uploadDocumentAsset.mutateAsync(file)}
/>
</section>
+ {commentsOpen && (
+ <DocumentCommentsPanel
+ editor={editor}
+ projectKey={projectKey}
+ documentId={document.id}
+ version={version}
+ selection={commentSelection}
+ canComment={canEdit && document.archivedAt === null}
+ onClose={() => setCommentsOpen(false)}
+ onCommented={() => setCommentSelection(null)}
+ />
+ )}
<DocumentEditorInspector
open={inspectorOpen}
projectKey={projectKey}
diff --git a/apps/web/src/features/documents/components/DocumentEditorCanvas.tsx b/apps/web/src/features/documents/components/DocumentEditorCanvas.tsx
index 4dfebcd3..f6188cdd 100644
--- a/apps/web/src/features/documents/components/DocumentEditorCanvas.tsx
+++ b/apps/web/src/features/documents/components/DocumentEditorCanvas.tsx
@@ -7,6 +7,7 @@ import { cn } from '@/lib/utils';
import { useTranslations } from 'next-intl';
import DocumentMarkdownEditor, { insertDocumentImage } from './DocumentMarkdownEditor';
import DocumentPageTitle from './DocumentPageTitle';
+import { type DocumentSelection } from './DocumentSelectionActions';
import DocumentToolbar from './DocumentToolbar';
export function documentToolbarPosition(stickyToolbar: boolean) {
@@ -23,6 +24,8 @@ export default function DocumentEditorCanvas({
editor,
titleRef,
editable,
+ collaborative = false,
+ onComment,
stickyToolbar,
updateLabel,
onEditorReady,
@@ -42,6 +45,8 @@ export default function DocumentEditorCanvas({
editor: Editor | null;
titleRef: RefObject<HTMLTextAreaElement | null>;
editable: boolean;
+ collaborative?: boolean;
+ onComment?: (selection: DocumentSelection) => void;
stickyToolbar: boolean;
updateLabel: string;
onEditorReady: (editor: Editor | null) => void;
@@ -125,9 +130,13 @@ export default function DocumentEditorCanvas({
<DocumentMarkdownEditor
key={`${document.id}:${editorRevision}`}
+ projectKey={projectKey}
+ documentId={document.id}
+ onComment={onComment}
defaultValue={content}
defaultJson={contentJson}
editable={editable}
+ collaborative={collaborative}
placeholder={t('contentPlaceholder')}
className="min-h-[58vh] flex-1 text-[15px] leading-7 md:text-base md:leading-7"
onReady={onEditorReady}
diff --git a/apps/web/src/features/documents/components/DocumentEditorHeader.tsx b/apps/web/src/features/documents/components/DocumentEditorHeader.tsx
index 78130a8c..3835dc2a 100644
--- a/apps/web/src/features/documents/components/DocumentEditorHeader.tsx
+++ b/apps/web/src/features/documents/components/DocumentEditorHeader.tsx
@@ -1,4 +1,12 @@
-import { ArrowLeft, Check, CircleAlert, LoaderCircle, PanelRight, RefreshCw } from 'lucide-react';
+import {
+ ArrowLeft,
+ Check,
+ CircleAlert,
+ LoaderCircle,
+ PanelRight,
+ MessageSquare,
+ RefreshCw,
+} from 'lucide-react';
import { useTranslations } from 'next-intl';
import type { ProjectDocument, ProjectDocumentSummary } from '@/lib/api/endpoints/documents';
import { Button } from '@/components/ui/button';
@@ -39,6 +47,8 @@ export default function DocumentEditorHeader({
onArchive,
onRestore,
onDelete,
+ commentsOpen,
+ onCommentsOpen,
inspectorOpen,
onInspectorOpenChange,
onOpenHistory,
@@ -48,8 +58,8 @@ export default function DocumentEditorHeader({
document: ProjectDocument;
ancestors: ProjectDocumentSummary[];
title: string;
- content: string;
- richHtml: string;
+ content: () => string;
+ richHtml: () => string;
saveState: DocumentSaveState;
dirty: boolean;
stickyToolbar: boolean;
@@ -71,6 +81,8 @@ export default function DocumentEditorHeader({
onArchive: () => void;
onRestore: () => void;
onDelete: () => void;
+ commentsOpen: boolean;
+ onCommentsOpen: () => void;
inspectorOpen: boolean;
onInspectorOpenChange: (open: boolean) => void;
onOpenHistory: () => void;
@@ -151,6 +163,15 @@ export default function DocumentEditorHeader({
</Button>
)}
+ <Button
+ type="button"
+ size="icon-sm"
+ variant={commentsOpen ? 'secondary' : 'ghost'}
+ aria-label={t('comments.title')}
+ onClick={onCommentsOpen}
+ >
+ <MessageSquare className="size-4" />
+ </Button>
<DocumentFavoriteButton
favorite={document.isFavorite}
disabled={busy}
diff --git a/apps/web/src/features/documents/components/DocumentExportDialog.tsx b/apps/web/src/features/documents/components/DocumentExportDialog.tsx
index 8837871c..7f6848a9 100644
--- a/apps/web/src/features/documents/components/DocumentExportDialog.tsx
+++ b/apps/web/src/features/documents/components/DocumentExportDialog.tsx
@@ -37,8 +37,8 @@ export default function DocumentExportDialog({
projectKey: string;
documentId: number;
title: string;
- content: string;
- richHtml: string;
+ content: () => string;
+ richHtml: () => string;
onOpenChange: (open: boolean) => void;
}) {
const t = useTranslations('documents');
@@ -65,8 +65,8 @@ export default function DocumentExportDialog({
try {
const result = await createPortableDocumentExport({
title,
- content,
- richHtml,
+ content: content(),
+ richHtml: richHtml(),
format,
projectKey,
documentId,
diff --git a/apps/web/src/features/documents/components/DocumentMarkdownEditor.test.ts b/apps/web/src/features/documents/components/DocumentMarkdownEditor.test.ts
index a35a3737..8f0e9a0e 100644
--- a/apps/web/src/features/documents/components/DocumentMarkdownEditor.test.ts
+++ b/apps/web/src/features/documents/components/DocumentMarkdownEditor.test.ts
@@ -76,6 +76,8 @@ beforeEach(() => {
previousAnimationFrame = Object.getOwnPropertyDescriptor(globalThis, 'requestAnimationFrame');
previousNode = Object.getOwnPropertyDescriptor(globalThis, 'Node');
dom = new JSDOM('<!doctype html><div id="one"></div><div id="two"></div>');
+ dom.window.Range.prototype.getClientRects = () => [] as unknown as DOMRectList;
+ dom.window.Range.prototype.getBoundingClientRect = () => new dom.window.DOMRect();
Object.defineProperties(globalThis, {
window: { configurable: true, value: dom.window },
document: { configurable: true, value: dom.window.document },
@@ -360,22 +362,22 @@ describe('DocumentMarkdownEditor schema attrs', () => {
);
assert.deepEqual(attrsOf(editor.schema.nodes), {
doc: [],
- paragraph: ['textAlign'],
+ paragraph: ['blockId', 'textAlign'],
text: [],
- blockquote: [],
- bulletList: ['tight'],
- orderedList: ['start', 'tight', 'type'],
+ blockquote: ['blockId'],
+ bulletList: ['blockId', 'tight'],
+ orderedList: ['blockId', 'start', 'tight', 'type'],
listItem: [],
- heading: ['level', 'textAlign'],
- horizontalRule: [],
+ heading: ['blockId', 'level', 'textAlign'],
+ horizontalRule: ['blockId'],
hardBreak: [],
- codeBlock: ['language'],
- image: ['alt', 'src', 'style', 'title', 'width'],
- table: [],
+ codeBlock: ['blockId', 'language'],
+ image: ['alt', 'blockId', 'src', 'style', 'title', 'width'],
+ table: ['blockId'],
tableRow: [],
tableHeader: ['align', 'colspan', 'colwidth', 'rowspan'],
tableCell: ['align', 'colspan', 'colwidth', 'rowspan'],
- taskList: [],
+ taskList: ['blockId'],
taskItem: ['checked'],
});
assert.deepEqual(attrsOf(editor.schema.marks), {
@@ -391,3 +393,149 @@ describe('DocumentMarkdownEditor schema attrs', () => {
editor.destroy();
});
});
+
+describe('collaborative editor convergence', () => {
+ it('rebases simultaneous edits and undo without removing the other writer’s text', async () => {
+ const { Step } = await import('@tiptap/pm/transform');
+ const { collab, receiveTransaction, sendableSteps } = await import('prosemirror-collab');
+ const make = (id: string, selector: string) => {
+ const editor = new Editor({
+ element: document.querySelector(selector) as HTMLElement,
+ extensions: documentEditorExtensions({
+ placeholder: '',
+ codeBlockLabel: 'Code',
+ tableLabel: 'Table',
+ }),
+ content: {
+ type: 'doc',
+ content: [
+ {
+ type: 'paragraph',
+ attrs: { blockId: 'shared' },
+ content: [{ type: 'text', text: 'Hello' }],
+ },
+ ],
+ },
+ });
+ editor.registerPlugin(collab({ clientID: id }));
+ return editor;
+ };
+ const alice = make('alice', '#one'),
+ bob = make('bob', '#two');
+ alice.commands.insertContentAt(1, 'A');
+ bob.commands.insertContentAt(1, 'B');
+ const first = sendableSteps(alice.state)!;
+ for (const editor of [alice, bob])
+ editor.view.dispatch(
+ receiveTransaction(
+ editor.state,
+ first.steps.map((step) => Step.fromJSON(editor.schema, step.toJSON())),
+ first.steps.map(() => 'alice'),
+ ),
+ );
+ const second = sendableSteps(bob.state)!;
+ for (const editor of [alice, bob])
+ editor.view.dispatch(
+ receiveTransaction(
+ editor.state,
+ second.steps.map((step) => Step.fromJSON(editor.schema, step.toJSON())),
+ second.steps.map(() => 'bob'),
+ ),
+ );
+ assert.deepEqual(alice.getJSON(), bob.getJSON());
+ assert.ok(alice.getText().includes('A') && alice.getText().includes('B'));
+ alice.commands.undo();
+ const undo = sendableSteps(alice.state)!;
+ for (const editor of [alice, bob])
+ editor.view.dispatch(
+ receiveTransaction(
+ editor.state,
+ undo.steps.map((step) => Step.fromJSON(editor.schema, step.toJSON())),
+ undo.steps.map(() => 'alice'),
+ ),
+ );
+ assert.deepEqual(alice.getJSON(), bob.getJSON());
+ assert.equal(alice.getText(), 'BHello');
+ alice.destroy();
+ bob.destroy();
+ });
+
+ it('duplicates a whole section with distinct anchors', async () => {
+ const { changeDocumentBlock } = await import('../utils/documentBlocks');
+ const editor = new Editor({
+ element: document.querySelector('#one') as HTMLElement,
+ extensions: documentEditorExtensions({
+ placeholder: '',
+ codeBlockLabel: 'Code',
+ tableLabel: 'Table',
+ }),
+ content: '<h2>One</h2><p>First</p><h2>Two</h2><p>Second</p>',
+ });
+ assert.equal(changeDocumentBlock(editor, 1, 'duplicate'), true);
+ assert.equal(editor.getText(), 'One\n\nFirst\n\nOne\n\nFirst\n\nTwo\n\nSecond');
+ const ids: string[] = [];
+ editor.state.doc.forEach((node) => ids.push(node.attrs.blockId));
+ assert.equal(ids.length, new Set(ids).size);
+ assert.ok(ids.every(Boolean));
+ changeDocumentBlock(editor, 1, 'delete');
+ assert.equal(editor.getText(), 'One\n\nFirst\n\nTwo\n\nSecond');
+ changeDocumentBlock(editor, 1, 'down');
+ assert.equal(editor.getText(), 'Two\n\nSecond\n\nOne\n\nFirst');
+ changeDocumentBlock(editor, editor.state.selection.from, 'up');
+ assert.equal(editor.getText(), 'One\n\nFirst\n\nTwo\n\nSecond');
+ editor.destroy();
+ });
+});
+
+describe('collaborative block anchors', () => {
+ it('converges when both authors split the same paragraph', async () => {
+ const { Step } = await import('@tiptap/pm/transform');
+ const { collab, receiveTransaction, sendableSteps } = await import('prosemirror-collab');
+ const editors = ['one', 'two'].map((id) => {
+ const editor = new Editor({
+ element: document.querySelector(`#${id}`) as HTMLElement,
+ extensions: documentEditorExtensions({
+ placeholder: '',
+ codeBlockLabel: 'Code',
+ tableLabel: 'Table',
+ }),
+ content: {
+ type: 'doc',
+ content: [
+ {
+ type: 'paragraph',
+ attrs: { blockId: 'original' },
+ content: [{ type: 'text', text: 'Hello world' }],
+ },
+ ],
+ },
+ });
+ editor.registerPlugin(collab({ clientID: id }));
+ editor.commands.setTextSelection(6);
+ editor.commands.splitBlock();
+ return editor;
+ });
+ for (let round = 0; round < 10; round++) {
+ for (const [index, editor] of editors.entries()) {
+ const pending = sendableSteps(editor.state);
+ if (!pending) continue;
+ for (const recipient of editors)
+ recipient.view.dispatch(
+ receiveTransaction(
+ recipient.state,
+ pending.steps.map((step) => Step.fromJSON(recipient.schema, step.toJSON())),
+ pending.steps.map(() => (index ? 'two' : 'one')),
+ ),
+ );
+ }
+ }
+ assert.deepEqual(editors[0].getJSON(), editors[1].getJSON());
+ const ids: string[] = [];
+ editors[0].state.doc.forEach((node) => ids.push(node.attrs.blockId));
+ assert.ok(ids.every(Boolean));
+ assert.equal(ids.length, new Set(ids).size);
+ assert.equal(sendableSteps(editors[0].state), null);
+ assert.equal(sendableSteps(editors[1].state), null);
+ editors.forEach((editor) => editor.destroy());
+ });
+});
diff --git a/apps/web/src/features/documents/components/DocumentMarkdownEditor.tsx b/apps/web/src/features/documents/components/DocumentMarkdownEditor.tsx
index ce155f5b..28949600 100644
--- a/apps/web/src/features/documents/components/DocumentMarkdownEditor.tsx
+++ b/apps/web/src/features/documents/components/DocumentMarkdownEditor.tsx
@@ -25,6 +25,10 @@ import { openLinkOnModifierClick } from '@/components/common/editor/modifierClic
import { ResizableImage } from '@/components/common/editor/tiptap-image';
import { MarkdownTable } from '@/components/common/editor/tiptap-table';
import { pasteMarkdown } from '@/components/common/editor/pasteMarkdown';
+import { useDocumentAnchor } from '../hooks/useDocumentAnchor';
+import { DocumentBlockId } from '../extensions/documentBlockId';
+import DocumentBlockMenu from './DocumentBlockMenu';
+import DocumentSelectionActions, { type DocumentSelection } from './DocumentSelectionActions';
import { SlashCommand } from '@/lib/tiptap-slash-command';
const lowlight = createLowlight(common);
@@ -74,6 +78,7 @@ type EditorValue = { markdown: string; json: JSONContent };
export function documentEditorExtensions(labels: EditorLabels) {
return [
+ DocumentBlockId,
StarterKit.configure({
codeBlock: false,
link: false,
@@ -112,9 +117,13 @@ function editorValue(editor: Editor): EditorValue {
}
export default function DocumentMarkdownEditor({
+ projectKey,
+ documentId,
+ onComment,
defaultValue,
defaultJson,
editable,
+ collaborative = false,
placeholder,
className,
onReady,
@@ -123,9 +132,13 @@ export default function DocumentMarkdownEditor({
onPickImage,
onUploadImage,
}: {
+ projectKey?: string;
+ documentId?: number;
+ onComment?: (selection: DocumentSelection) => void;
defaultValue: string;
defaultJson: Record<string, unknown> | null;
editable: boolean;
+ collaborative?: boolean;
placeholder: string;
className?: string;
onReady: (editor: Editor | null) => void;
@@ -171,6 +184,9 @@ export default function DocumentMarkdownEditor({
return openLinkOnModifierClick(event, view.dom);
},
attributes: {
+ role: 'textbox',
+ 'aria-multiline': 'true',
+ 'aria-label': t('editorLabel'),
class: 'md-content flex-1 focus:outline-none selection:bg-primary/15',
},
handlePaste: (_view, event) => {
@@ -207,13 +223,17 @@ export default function DocumentMarkdownEditor({
onCreate: ({ editor: currentEditor }) => {
editorRef.current = currentEditor;
},
- onUpdate: ({ editor: currentEditor }) => onChange(editorValue(currentEditor)),
+ onUpdate: ({ editor: currentEditor }) => {
+ if (!collaborative) onChange(editorValue(currentEditor));
+ },
onBlur: ({ editor: currentEditor }) => onBlur(editorValue(currentEditor)),
onDestroy: () => {
editorRef.current = null;
},
});
+ useDocumentAnchor(editor);
+
useEffect(() => {
editorRef.current = editor;
onReady(editor);
@@ -227,8 +247,20 @@ export default function DocumentMarkdownEditor({
if (!editor) return null;
return (
- <div className={className} data-document-editor="">
- {editable && <EditorSelectionMenu editor={editor} />}
+ <div className={`relative ${className ?? ''}`} data-document-editor="">
+ {editable && <DocumentBlockMenu editor={editor} />}
+ {editable && (
+ <EditorSelectionMenu editor={editor}>
+ {projectKey && documentId && onComment && (
+ <DocumentSelectionActions
+ editor={editor}
+ projectKey={projectKey}
+ documentId={documentId}
+ onComment={onComment}
+ />
+ )}
+ </EditorSelectionMenu>
+ )}
{editable && <EditorTableMenu editor={editor} />}
<EditorContent editor={editor} className="flex min-h-full flex-col" />
<EditorLinkPreview editor={editor} />
diff --git a/apps/web/src/features/documents/components/DocumentOptionsMenu.tsx b/apps/web/src/features/documents/components/DocumentOptionsMenu.tsx
index c6a199c1..f4c58bd0 100644
--- a/apps/web/src/features/documents/components/DocumentOptionsMenu.tsx
+++ b/apps/web/src/features/documents/components/DocumentOptionsMenu.tsx
@@ -55,8 +55,8 @@ export default function DocumentOptionsMenu({
projectKey: string;
document: ProjectDocument;
title: string;
- content: string;
- richHtml: string;
+ content: () => string;
+ richHtml: () => string;
stickyToolbar: boolean;
canCreate: boolean;
canUpdate: boolean;
@@ -80,10 +80,10 @@ export default function DocumentOptionsMenu({
const copyMarkdown = useCallback(async () => {
try {
- await navigator.clipboard.writeText(content);
+ await navigator.clipboard.writeText(content());
} catch {
const input = window.document.createElement('textarea');
- input.value = content;
+ input.value = content();
input.style.position = 'fixed';
input.style.opacity = '0';
try {
diff --git a/apps/web/src/features/documents/components/DocumentSelectionActions.tsx b/apps/web/src/features/documents/components/DocumentSelectionActions.tsx
new file mode 100644
index 00000000..fd050f18
--- /dev/null
+++ b/apps/web/src/features/documents/components/DocumentSelectionActions.tsx
@@ -0,0 +1,91 @@
+import { useEffect, useRef, useState } from 'react';
+import type { Editor } from '@tiptap/react';
+import type { SelectionBookmark } from '@tiptap/pm/state';
+import { ListPlus, MessageSquarePlus } from 'lucide-react';
+import { useTranslations } from 'next-intl';
+import { usePermissions } from '@/hooks/usePermissions';
+import { Button } from '@/components/ui/button';
+import DocumentCreateIssueDialog from './DocumentCreateIssueDialog';
+
+export type DocumentSelection = { from: number; to: number; quote: string; version?: number };
+export default function DocumentSelectionActions({
+ editor,
+ projectKey,
+ documentId,
+ onComment,
+}: {
+ editor: Editor;
+ projectKey: string;
+ documentId: number;
+ onComment: (selection: DocumentSelection) => void;
+}) {
+ const t = useTranslations('documents');
+ const { can } = usePermissions();
+ const [selection, setSelection] = useState<DocumentSelection | null>(null);
+ const [creating, setCreating] = useState(false);
+ const bookmark = useRef<SelectionBookmark>(editor.state.selection.getBookmark());
+ useEffect(() => {
+ const update = () => {
+ if (creating) return;
+ const { from, to, empty } = editor.state.selection;
+ const quote = editor.state.doc.textBetween(from, to, '\n');
+ setSelection(!empty && quote.trim() ? { from, to, quote } : null);
+ bookmark.current = editor.state.selection.getBookmark();
+ };
+ const map = ({
+ transaction,
+ }: {
+ transaction: { mapping: Parameters<SelectionBookmark['map']>[0] };
+ }) => {
+ if (creating) bookmark.current = bookmark.current.map(transaction.mapping);
+ };
+ editor.on('selectionUpdate', update);
+ editor.on('transaction', map);
+ update();
+ return () => {
+ editor.off('selectionUpdate', update);
+ editor.off('transaction', map);
+ };
+ }, [creating, editor]);
+ if (!selection || !editor.isEditable) return null;
+ return (
+ <>
+ <div
+ className="ms-1 flex items-center gap-1 border-s ps-1 print:hidden"
+ role="toolbar"
+ aria-label={t('selectionActions')}
+ >
+ <Button
+ size="sm"
+ variant="ghost"
+ onMouseDown={(event) => event.preventDefault()}
+ onClick={() => onComment(selection)}
+ >
+ <MessageSquarePlus className="size-4" />
+ {t('comments.add')}
+ </Button>
+ {can('work_items', 'create') && can('work_items', 'edit') && (
+ <Button
+ size="sm"
+ variant="ghost"
+ onMouseDown={(event) => event.preventDefault()}
+ onClick={() => setCreating(true)}
+ >
+ <ListPlus className="size-4" />
+ {t('workItem.create')}
+ </Button>
+ )}
+ </div>
+ {creating && (
+ <DocumentCreateIssueDialog
+ editor={editor}
+ projectKey={projectKey}
+ documentId={documentId}
+ quote={selection.quote}
+ bookmark={bookmark}
+ onClose={() => setCreating(false)}
+ />
+ )}
+ </>
+ );
+}
diff --git a/apps/web/src/features/documents/components/DocumentSidePanel.tsx b/apps/web/src/features/documents/components/DocumentSidePanel.tsx
index a8dd6155..79a832de 100644
--- a/apps/web/src/features/documents/components/DocumentSidePanel.tsx
+++ b/apps/web/src/features/documents/components/DocumentSidePanel.tsx
@@ -73,9 +73,16 @@ export default function DocumentSidePanel({
useEffect(() => {
if (!editor) return;
- const refreshOutline = () => setOutlineRevision((value) => value + 1);
+ let timer: ReturnType<typeof setTimeout>;
+ const refreshOutline = ({ transaction }: { transaction: { docChanged: boolean } }) => {
+ if (transaction.docChanged) {
+ clearTimeout(timer);
+ timer = setTimeout(() => setOutlineRevision((value) => value + 1), 300);
+ }
+ };
editor.on('transaction', refreshOutline);
return () => {
+ clearTimeout(timer);
editor.off('transaction', refreshOutline);
};
}, [editor]);
diff --git a/apps/web/src/features/documents/components/DocumentSyncBanner.tsx b/apps/web/src/features/documents/components/DocumentSyncBanner.tsx
new file mode 100644
index 00000000..fa4d8a3d
--- /dev/null
+++ b/apps/web/src/features/documents/components/DocumentSyncBanner.tsx
@@ -0,0 +1,58 @@
+import { CloudOff, Download, Loader2, RefreshCw } from 'lucide-react';
+import { useTranslations } from 'next-intl';
+import { Button } from '@/components/ui/button';
+import type { DocumentSyncState } from '../hooks/useDocumentCollaboration';
+
+export default function DocumentSyncBanner({
+ state,
+ onRetry,
+ recoveryConflict,
+ onExportRecovery,
+ onDiscardRecovery,
+}: {
+ state: DocumentSyncState;
+ onRetry: () => void;
+ recoveryConflict: boolean;
+ onExportRecovery: () => void;
+ onDiscardRecovery: () => void;
+}) {
+ const t = useTranslations('documents.sync');
+ if (state === 'saved' || state === 'saving') return null;
+ return (
+ <div
+ role="status"
+ aria-live="polite"
+ className="flex items-center gap-2 border-b bg-muted/40 px-4 py-2 text-xs text-muted-foreground"
+ >
+ {state === 'connecting' ? (
+ <Loader2 className="size-3.5 animate-spin motion-reduce:animate-none" />
+ ) : (
+ <CloudOff className="size-3.5" />
+ )}
+ <span className="flex-1">{t(recoveryConflict ? 'recoveryConflict' : state)}</span>
+ {recoveryConflict && (
+ <>
+ <Button size="sm" variant="ghost" onClick={onExportRecovery}>
+ <Download className="size-3.5" />
+ {t('exportRecovery')}
+ </Button>
+ <Button
+ size="sm"
+ variant="ghost"
+ onClick={() => {
+ if (window.confirm(t('discardConfirm'))) onDiscardRecovery();
+ }}
+ >
+ {t('discardRecovery')}
+ </Button>
+ </>
+ )}
+ {!recoveryConflict && state !== 'connecting' && (
+ <Button type="button" size="sm" variant="ghost" onClick={onRetry}>
+ <RefreshCw className="size-3.5" />
+ {t('retry')}
+ </Button>
+ )}
+ </div>
+ );
+}
diff --git a/apps/web/src/features/documents/components/DocumentTree.tsx b/apps/web/src/features/documents/components/DocumentTree.tsx
index cf3b9c72..68e48fd6 100644
--- a/apps/web/src/features/documents/components/DocumentTree.tsx
+++ b/apps/web/src/features/documents/components/DocumentTree.tsx
@@ -1,6 +1,7 @@
'use client';
-import { useMemo, useState } from 'react';
+import { useMemo } from 'react';
+import { useDocumentNavigation } from '@/hooks/useDocumentNavigation';
import {
closestCenter,
DndContext,
@@ -24,6 +25,8 @@ import SortableDocumentRow from './SortableDocumentRow';
export type DocumentSort = 'position' | 'title' | 'created' | 'updated';
+const treeDefaults: { collapsed: number[] } = { collapsed: [] };
+
export default function DocumentTree({
projectKey,
documents,
@@ -59,7 +62,10 @@ export default function DocumentTree({
onFavoriteChange: (documentId: number, isFavorite: boolean) => void;
}) {
const t = useTranslations('documents');
- const [collapsed, setCollapsed] = useState<Set<number>>(new Set());
+ const [treeState, setTreeState] = useDocumentNavigation(projectKey, 'tree', treeDefaults);
+ const collapsed = useMemo(() => new Set(treeState.collapsed), [treeState.collapsed]);
+ const setCollapsed = (update: (previous: Set<number>) => Set<number>) =>
+ setTreeState((previous) => ({ collapsed: [...update(new Set(previous.collapsed))] }));
const sensors = useSensors(
useSensor(PointerSensor, { activationConstraint: { distance: 6 } }),
useSensor(KeyboardSensor, { coordinateGetter: sortableKeyboardCoordinates }),
diff --git a/apps/web/src/features/documents/components/DocumentsIndex.tsx b/apps/web/src/features/documents/components/DocumentsIndex.tsx
index 5321740f..4e4c8150 100644
--- a/apps/web/src/features/documents/components/DocumentsIndex.tsx
+++ b/apps/web/src/features/documents/components/DocumentsIndex.tsx
@@ -1,6 +1,7 @@
'use client';
-import { useState } from 'react';
+import { useEffect, useRef } from 'react';
+import { useDocumentNavigation } from '@/hooks/useDocumentNavigation';
import {
ArrowDown,
ArrowUp,
@@ -41,6 +42,14 @@ const SORTS = [
] as const satisfies readonly DocumentSort[];
export type { DocumentListTab } from '../utils/documentList';
+const defaults: {
+ sort: DocumentSort;
+ direction: 'asc' | 'desc';
+ creator: string | null;
+ range: 'all' | 'today' | 'week' | 'month';
+ scroll: number;
+} = { sort: 'position', direction: 'asc', creator: null, range: 'all', scroll: 0 };
+
export default function DocumentsIndex({
projectKey,
documents,
@@ -79,10 +88,33 @@ export default function DocumentsIndex({
const t = useTranslations('documents');
const move = useMoveDocument(projectKey);
const favorite = useSetDocumentFavorite(projectKey);
- const [sort, setSort] = useState<DocumentSort>('position');
- const [sortDirection, setSortDirection] = useState<'asc' | 'desc'>('asc');
- const [creatorId, setCreatorId] = useState<string | null>(null);
- const [createdRange, setCreatedRange] = useState<'all' | 'today' | 'week' | 'month'>('all');
+ const [preferences, setPreferences] = useDocumentNavigation(projectKey, 'index', defaults);
+ const sort = SORTS.includes(preferences.sort) ? preferences.sort : 'position';
+ const sortDirection = preferences.direction === 'desc' ? 'desc' : 'asc';
+ const creatorId = preferences.creator;
+ const createdRange = ['all', 'today', 'week', 'month'].includes(preferences.range)
+ ? preferences.range
+ : 'all';
+ const setSort = (sort: DocumentSort) => setPreferences((p) => ({ ...p, sort }));
+ const setSortDirection = (update: (value: 'asc' | 'desc') => 'asc' | 'desc') =>
+ setPreferences((p) => ({ ...p, direction: update(p.direction) }));
+ const setCreatorId = (creator: string | null) => setPreferences((p) => ({ ...p, creator }));
+ const setCreatedRange = (range: typeof defaults.range) =>
+ setPreferences((p) => ({ ...p, range }));
+ const scrollRef = useRef<HTMLDivElement>(null);
+ const restored = useRef(false);
+ const lastScroll = useRef(preferences.scroll);
+ useEffect(() => {
+ if (!loading && !restored.current && scrollRef.current) {
+ scrollRef.current.scrollTop = preferences.scroll;
+ lastScroll.current = preferences.scroll;
+ restored.current = true;
+ }
+ }, [loading, preferences.scroll]);
+ useEffect(
+ () => () => setPreferences((p) => ({ ...p, scroll: lastScroll.current })),
+ [setPreferences],
+ );
const creatorIds = Array.from(
new Set(
@@ -299,7 +331,13 @@ export default function DocumentsIndex({
</div>
</div>
- <div className="min-h-0 flex-1 overflow-y-auto px-4 pb-10 md:px-6">
+ <div
+ ref={scrollRef}
+ onScroll={(event) => {
+ lastScroll.current = event.currentTarget.scrollTop;
+ }}
+ className="min-h-0 flex-1 overflow-y-auto px-4 pb-10 md:px-6"
+ >
<div className="mx-auto w-full max-w-6xl">
{loading ? (
<div className="space-y-1 py-1" aria-hidden>
diff --git a/apps/web/src/features/documents/extensions/documentBlockId.ts b/apps/web/src/features/documents/extensions/documentBlockId.ts
new file mode 100644
index 00000000..8a65c7f9
--- /dev/null
+++ b/apps/web/src/features/documents/extensions/documentBlockId.ts
@@ -0,0 +1,72 @@
+import { Extension } from '@tiptap/core';
+import { ReplaceStep, ReplaceAroundStep } from '@tiptap/pm/transform';
+import { Plugin } from '@tiptap/pm/state';
+import { uuid } from '@/utils/uuid';
+
+export const DOCUMENT_BLOCK_TYPES = [
+ 'paragraph',
+ 'heading',
+ 'blockquote',
+ 'codeBlock',
+ 'bulletList',
+ 'orderedList',
+ 'taskList',
+ 'table',
+ 'horizontalRule',
+ 'image',
+];
+export const DocumentBlockId = Extension.create({
+ name: 'documentBlockId',
+ addGlobalAttributes() {
+ return [
+ {
+ types: DOCUMENT_BLOCK_TYPES,
+ attributes: {
+ blockId: {
+ default: null,
+ parseHTML: (element) => element.getAttribute('data-block-id'),
+ renderHTML: (attributes) =>
+ attributes.blockId
+ ? { 'data-block-id': attributes.blockId, id: `block-${attributes.blockId}` }
+ : {},
+ },
+ },
+ },
+ ];
+ },
+ addProseMirrorPlugins() {
+ return [
+ new Plugin({
+ appendTransaction: (transactions, _old, state) => {
+ if (!this.editor.isEditable) return null;
+ const structureChanged = transactions.some((tr) =>
+ tr.steps.some((step) => {
+ if (step instanceof ReplaceAroundStep) return true;
+ if (!(step instanceof ReplaceStep)) return false;
+ let hasBlocks = false;
+ step.slice.content.forEach((node) => {
+ if (!node.isText && !node.isInline) hasBlocks = true;
+ });
+ return hasBlocks;
+ }),
+ );
+ if (!structureChanged) return null;
+ const seen = new Set<string>();
+ const tr = state.tr;
+ state.doc.descendants((node, pos) => {
+ if (!DOCUMENT_BLOCK_TYPES.includes(node.type.name)) return;
+ const id = node.attrs.blockId as string | null;
+ if (id && !seen.has(id)) {
+ seen.add(id);
+ return;
+ }
+ const next = uuid();
+ seen.add(next);
+ tr.setNodeMarkup(pos, undefined, { ...node.attrs, blockId: next });
+ });
+ return tr.docChanged ? tr.setMeta('addToHistory', false) : null;
+ },
+ }),
+ ];
+ },
+});
diff --git a/apps/web/src/features/documents/hooks/useDocumentAnchor.ts b/apps/web/src/features/documents/hooks/useDocumentAnchor.ts
new file mode 100644
index 00000000..bd6ffb53
--- /dev/null
+++ b/apps/web/src/features/documents/hooks/useDocumentAnchor.ts
@@ -0,0 +1,48 @@
+import { useEffect } from 'react';
+import type { Editor } from '@tiptap/react';
+
+export function useDocumentAnchor(editor: Editor | null) {
+ useEffect(() => {
+ if (!editor) return;
+ let last: HTMLElement | null = null;
+ let lastId = '';
+ let frame = 0;
+ const jump = () => {
+ const id = window.location.hash.slice(1);
+ if (!/^block-[A-Za-z0-9_-]{1,64}$/.test(id)) return;
+ if (lastId === id && last?.isConnected) return;
+ let target = window.document.getElementById(id);
+ if (!target)
+ editor.state.doc.descendants((node, position) => {
+ if (target || node.attrs.blockId !== id.slice(6)) return;
+ const element = editor.view.nodeDOM(position);
+ if (element instanceof HTMLElement) target = element;
+ });
+ if (!target || !editor.view.dom.contains(target) || target === last) return;
+ target.scrollIntoView({
+ block: 'center',
+ behavior: window.matchMedia('(prefers-reduced-motion: reduce)').matches
+ ? 'instant'
+ : 'smooth',
+ });
+ last = target;
+ lastId = id;
+ };
+ const hash = () => {
+ last = null;
+ jump();
+ };
+ const schedule = () => {
+ cancelAnimationFrame(frame);
+ frame = requestAnimationFrame(jump);
+ };
+ editor.on('transaction', schedule);
+ window.addEventListener('hashchange', hash);
+ schedule();
+ return () => {
+ cancelAnimationFrame(frame);
+ editor.off('transaction', schedule);
+ window.removeEventListener('hashchange', hash);
+ };
+ }, [editor]);
+}
diff --git a/apps/web/src/features/documents/hooks/useDocumentCollaboration.ts b/apps/web/src/features/documents/hooks/useDocumentCollaboration.ts
new file mode 100644
index 00000000..aef41c6e
--- /dev/null
+++ b/apps/web/src/features/documents/hooks/useDocumentCollaboration.ts
@@ -0,0 +1,307 @@
+import { useCallback, useEffect, useRef, useState } from 'react';
+import { useQueryClient } from '@tanstack/react-query';
+import type { Editor } from '@tiptap/react';
+import { Step } from '@tiptap/pm/transform';
+import { history } from '@tiptap/pm/history';
+import { collab, getVersion, receiveTransaction, sendableSteps } from 'prosemirror-collab';
+import { ApiError } from '@/lib/api/core/client';
+import {
+ type ProjectDocument,
+ getDocument,
+ getDocumentChanges,
+ saveDocumentChanges,
+ openDocumentSession,
+} from '@/lib/api/endpoints/documents';
+import { qk } from '@/services/queryKeys';
+import { uuid } from '@/utils/uuid';
+import {
+ persistDocumentRecovery,
+ readDocumentRecovery,
+ type DocumentSessionState,
+} from '../utils/documentRecovery';
+
+export type DocumentSyncState =
+ 'connecting' | 'saved' | 'saving' | 'offline' | 'error' | 'conflict';
+
+export function useDocumentCollaboration({
+ editor,
+ projectKey,
+ document,
+ userId,
+ enabled,
+ onSaved,
+}: {
+ editor: Editor | null;
+ projectKey: string;
+ document: ProjectDocument;
+ userId: string | null;
+ enabled: boolean;
+ onSaved: (document: ProjectDocument) => void;
+}) {
+ const qc = useQueryClient();
+ const [status, setStatus] = useState<DocumentSyncState>('connecting');
+ const [ready, setReady] = useState(false);
+ const state = useRef<DocumentSessionState | null>(null);
+ const saving = useRef<Promise<ProjectDocument | null> | null>(null);
+ const latest = useRef({ document, onSaved });
+ latest.current = { document, onSaved };
+ const storageKey = `document-steps:${userId}:${projectKey}:${document.id}`;
+ const [attempt, setAttempt] = useState(0);
+ const [recoveryConflict, setRecoveryConflict] = useState(false);
+ const confirmedVersion = useRef(document.version);
+
+ const persist = useCallback(
+ () => persistDocumentRecovery(storageKey, state.current),
+ [storageKey],
+ );
+
+ const receive = useCallback(async () => {
+ if (!editor || editor.isDestroyed || !state.current) return;
+ const activeSession = state.current;
+ let more = true;
+ while (more) {
+ const result = await getDocumentChanges(
+ projectKey,
+ document.id,
+ state.current.epoch,
+ getVersion(editor.state),
+ );
+ if (editor.isDestroyed || state.current !== activeSession) return;
+ confirmedVersion.current = result.documentVersion;
+ const steps = result.steps.map((item) => Step.fromJSON(editor.schema, item.step));
+ for (const step of steps) {
+ const applied = step.apply(state.current.confirmed);
+ if (!applied.doc) throw new Error('Invalid remote document change');
+ state.current.confirmed = applied.doc;
+ }
+ if (steps.length)
+ editor.view.dispatch(
+ receiveTransaction(
+ editor.state,
+ steps,
+ result.steps.map((item) => item.clientId),
+ { mapSelectionBackward: true },
+ ),
+ );
+ state.current.snapshot = editor.state;
+ more = result.hasMore;
+ }
+ persist();
+ }, [document.id, editor, persist, projectKey]);
+
+ const flush = useCallback((): Promise<ProjectDocument | null> => {
+ if (saving.current) return saving.current;
+ if (!enabled || !editor || editor.isDestroyed || !state.current) return Promise.resolve(null);
+ const activeSession = state.current;
+ const operation = async () => {
+ persist();
+ if (!navigator.onLine) {
+ setStatus('offline');
+ return null;
+ }
+ setStatus('saving');
+ try {
+ let saved: ProjectDocument | null = null;
+ for (let retry = 0; retry < 5; retry++) {
+ await receive();
+ if (editor.isDestroyed || state.current !== activeSession) return null;
+ const pending = sendableSteps(editor.state);
+ if (!pending) {
+ saved ??= latest.current.document;
+ if (saved.version < confirmedVersion.current) {
+ saved = await getDocument(projectKey, document.id);
+ if (editor.isDestroyed || state.current !== activeSession) return null;
+ latest.current.onSaved(saved);
+ }
+ setStatus('saved');
+ return saved;
+ }
+ try {
+ const batch = pending.steps.slice(0, 1000);
+ let snapshot = editor.state.doc;
+ if (batch.length !== pending.steps.length) {
+ snapshot = activeSession.confirmed;
+ for (const step of batch) {
+ const applied = step.apply(snapshot);
+ if (!applied.doc) throw new Error('Invalid local document change');
+ snapshot = applied.doc;
+ }
+ }
+ saved = await saveDocumentChanges(projectKey, document.id, {
+ epoch: state.current.epoch,
+ version: pending.version,
+ clientId: state.current.clientId,
+ steps: batch.map((step) => step.toJSON()),
+ content: editor.storage.markdown.serializer.serialize(snapshot),
+ });
+ if (editor.isDestroyed || state.current !== activeSession) return null;
+ latest.current.onSaved(saved);
+ qc.setQueryData(qk.document(projectKey, document.id), saved);
+ } catch (error) {
+ if (!(error instanceof ApiError && error.status === 409)) throw error;
+ }
+ }
+ await receive();
+ if (editor.isDestroyed || state.current !== activeSession) return null;
+ setStatus(sendableSteps(editor.state) ? 'error' : 'saved');
+ return sendableSteps(editor.state) ? null : saved;
+ } catch (error) {
+ if (editor.isDestroyed || state.current !== activeSession) return null;
+ if (error instanceof ApiError && error.status === 409 && !sendableSteps(editor.state)) {
+ setReady(false);
+ setAttempt((value) => value + 1);
+ return null;
+ }
+ if (error instanceof ApiError && error.status === 409) {
+ setRecoveryConflict(true);
+ setReady(false);
+ }
+ setStatus(
+ !navigator.onLine
+ ? 'offline'
+ : error instanceof ApiError && [403, 404, 409].includes(error.status)
+ ? 'conflict'
+ : 'error',
+ );
+ return null;
+ } finally {
+ persist();
+ }
+ };
+ const pending = operation().finally(() => {
+ if (saving.current === pending) saving.current = null;
+ });
+ saving.current = pending;
+ return pending;
+ }, [document.id, editor, enabled, persist, projectKey, qc, receive]);
+
+ useEffect(() => {
+ if (!editor || !userId || !enabled) return;
+ let cancelled = false;
+ const start = async () => {
+ setStatus('connecting');
+ try {
+ const session = await openDocumentSession(
+ projectKey,
+ document.id,
+ latest.current.document.version,
+ editor.getJSON(),
+ );
+ if (cancelled || editor.isDestroyed) return;
+ const recovery = readDocumentRecovery(storageKey);
+ const canRecover = recovery?.epoch === session.epoch;
+ const base = editor.schema.nodeFromJSON(recovery ? recovery.base : session.contentJson);
+ base.check();
+ editor
+ .chain()
+ .setContent(base.toJSON(), { emitUpdate: false })
+ .setMeta('addToHistory', false)
+ .run();
+ editor.unregisterPlugin('history');
+ editor.registerPlugin(history());
+ if (recovery && !canRecover) {
+ const tr = editor.state.tr;
+ for (const json of recovery.steps) tr.step(Step.fromJSON(editor.schema, json));
+ editor.view.dispatch(tr);
+ setRecoveryConflict(true);
+ setStatus('conflict');
+ return;
+ }
+ const clientId = recovery?.clientId ?? uuid();
+ editor.registerPlugin(
+ collab({ version: recovery?.version ?? session.version, clientID: clientId }),
+ );
+ state.current = { epoch: session.epoch, clientId, confirmed: base, snapshot: editor.state };
+ if (recovery) {
+ const tr = editor.state.tr;
+ for (const json of recovery.steps) tr.step(Step.fromJSON(editor.schema, json));
+ editor.view.dispatch(tr);
+ state.current.snapshot = editor.state;
+ }
+ setRecoveryConflict(false);
+ setReady(true);
+ setStatus('saved');
+ } catch (error) {
+ console.error('[document-session]', error);
+ if (!cancelled) setStatus(navigator.onLine ? 'error' : 'offline');
+ }
+ };
+ void start();
+ return () => {
+ cancelled = true;
+ persist();
+ state.current = null;
+ saving.current = null;
+ setReady(false);
+ if (!editor.isDestroyed) editor.unregisterPlugin('collab');
+ };
+ }, [attempt, document.id, editor, enabled, persist, projectKey, storageKey, userId]);
+
+ useEffect(() => {
+ if (!editor || !ready) return;
+ let timer: ReturnType<typeof setTimeout> | undefined;
+ const changed = () => {
+ if (!state.current || editor.isDestroyed) return;
+ state.current.snapshot = editor.state;
+ if (!sendableSteps(editor.state)) return;
+ setStatus('saving');
+ clearTimeout(timer);
+ timer = setTimeout(() => {
+ persist();
+ void flush();
+ }, 350);
+ };
+ const beforeUnload = (event: BeforeUnloadEvent) => {
+ persist();
+ if (state.current && !editor.isDestroyed && sendableSteps(editor.state))
+ event.preventDefault();
+ };
+ const online = () => {
+ void flush();
+ };
+ const offline = () => setStatus('offline');
+ editor.on('transaction', changed);
+ window.addEventListener('online', online);
+ window.addEventListener('offline', offline);
+ window.addEventListener('pagehide', persist);
+ window.addEventListener('beforeunload', beforeUnload);
+ void flush();
+ return () => {
+ clearTimeout(timer);
+ persist();
+ editor.off('transaction', changed);
+ window.removeEventListener('online', online);
+ window.removeEventListener('offline', offline);
+ window.removeEventListener('pagehide', persist);
+ window.removeEventListener('beforeunload', beforeUnload);
+ };
+ }, [editor, flush, persist, ready]);
+
+ useEffect(() => {
+ if (ready) void flush();
+ }, [document.version, flush, ready]);
+ useEffect(() => {
+ if (ready || recoveryConflict) return;
+ const reconnect = () => setAttempt((value) => value + 1);
+ window.addEventListener('online', reconnect);
+ return () => window.removeEventListener('online', reconnect);
+ }, [ready, recoveryConflict]);
+ const discardRecovery = () => {
+ state.current = null;
+ window.sessionStorage.removeItem(storageKey);
+ setRecoveryConflict(false);
+ setAttempt((value) => value + 1);
+ };
+ return {
+ status,
+ version: confirmedVersion.current,
+ ready,
+ flush,
+ recoveryConflict,
+ discardRecovery,
+ retry: () => {
+ if (ready) void flush();
+ else setAttempt((value) => value + 1);
+ },
+ };
+}
diff --git a/apps/web/src/features/documents/hooks/useDocumentCommentMarks.ts b/apps/web/src/features/documents/hooks/useDocumentCommentMarks.ts
new file mode 100644
index 00000000..77a8a742
--- /dev/null
+++ b/apps/web/src/features/documents/hooks/useDocumentCommentMarks.ts
@@ -0,0 +1,89 @@
+import { useEffect, useRef } from 'react';
+import { useQuery } from '@tanstack/react-query';
+import type { Editor } from '@tiptap/react';
+import { Plugin, PluginKey } from '@tiptap/pm/state';
+import { Decoration, DecorationSet } from '@tiptap/pm/view';
+import { Mapping } from '@tiptap/pm/transform';
+import { sendableSteps } from 'prosemirror-collab';
+import { listDocumentComments } from '@/lib/api/endpoints/documents';
+import { qk } from '@/services/queryKeys';
+
+const commentMarks = new PluginKey<DecorationSet>('documentCommentMarks');
+export function useDocumentCommentMarks(
+ editor: Editor | null,
+ projectKey: string,
+ documentId: number,
+ onOpen: () => void,
+ version: number,
+) {
+ const open = useRef(onOpen);
+ open.current = onOpen;
+ const { data } = useQuery({
+ queryKey: qk.documentComments(projectKey, documentId),
+ queryFn: () => listDocumentComments(projectKey, documentId),
+ });
+ useEffect(() => {
+ if (!editor) return;
+ editor.registerPlugin(
+ new Plugin({
+ key: commentMarks,
+ state: {
+ init: () => DecorationSet.empty,
+ apply: (tr, previous) => tr.getMeta(commentMarks) ?? previous.map(tr.mapping, tr.doc),
+ },
+ props: {
+ decorations: (state) => commentMarks.getState(state),
+ handleClick: (_view, _pos, event) => {
+ if (!(event.target instanceof Element)) return false;
+ const id = event.target
+ .closest('[data-document-comment]')
+ ?.getAttribute('data-document-comment');
+ if (!id) return false;
+ open.current();
+ requestAnimationFrame(() =>
+ window.document
+ .getElementById(`document-comment-${id}`)
+ ?.scrollIntoView({ block: 'nearest' }),
+ );
+ return true;
+ },
+ },
+ }),
+ );
+ return () => {
+ if (!editor.isDestroyed) editor.unregisterPlugin(commentMarks);
+ };
+ }, [editor]);
+ useEffect(() => {
+ if (!editor || editor.isDestroyed || !data) return;
+ if (data.length && data[0].documentVersion !== version) return;
+ const mapping = new Mapping();
+ try {
+ sendableSteps(editor.state)?.steps.forEach((step) => mapping.appendMap(step.getMap()));
+ } catch {
+ /* Read-only editors have no collaboration plugin. */
+ }
+ const decorations = data.flatMap((comment) => {
+ if (
+ comment.parentId ||
+ comment.resolvedAt ||
+ comment.orphaned ||
+ comment.from === null ||
+ comment.to === null
+ )
+ return [];
+ const from = mapping.map(comment.from, 1),
+ to = mapping.map(comment.to, -1);
+ if (from >= to || from < 0 || to > editor.state.doc.content.size) return [];
+ return [
+ Decoration.inline(from, to, {
+ class: 'document-comment-mark',
+ 'data-document-comment': comment.id,
+ }),
+ ];
+ });
+ editor.view.dispatch(
+ editor.state.tr.setMeta(commentMarks, DecorationSet.create(editor.state.doc, decorations)),
+ );
+ }, [data, editor, version]);
+}
diff --git a/apps/web/src/features/documents/hooks/useDocumentDraft.test.tsx b/apps/web/src/features/documents/hooks/useDocumentDraft.test.tsx
index c25e874d..d2ba6941 100644
--- a/apps/web/src/features/documents/hooks/useDocumentDraft.test.tsx
+++ b/apps/web/src/features/documents/hooks/useDocumentDraft.test.tsx
@@ -60,12 +60,14 @@ function projectDocument(version: number, content: string): ProjectDocument {
function Probe({
document,
editable,
+ collaborative = false,
onController = (value) => {
controller = value;
},
}: {
document: ProjectDocument;
editable: boolean;
+ collaborative?: boolean;
onController?: (value: DocumentDraftController) => void;
}) {
const value = useDocumentDraft({
@@ -73,6 +75,7 @@ function Probe({
document,
editable,
userId: 'user-1',
+ collaborative,
});
onController(value);
return null;
@@ -83,18 +86,24 @@ function renderInto(
document: ProjectDocument,
editable: boolean,
onController?: (value: DocumentDraftController) => void,
+ collaborative = false,
) {
act(() =>
targetRoot.render(
<QueryClientProvider client={queryClient}>
- <Probe document={document} editable={editable} onController={onController} />
+ <Probe
+ document={document}
+ editable={editable}
+ collaborative={collaborative}
+ onController={onController}
+ />
</QueryClientProvider>,
),
);
}
-function render(document: ProjectDocument, editable = true) {
- renderInto(root, document, editable);
+function render(document: ProjectDocument, editable = true, collaborative = false) {
+ renderInto(root, document, editable, undefined, collaborative);
assert.ok(controller);
}
@@ -312,3 +321,36 @@ describe('useDocumentDraft', () => {
tabBElement.remove();
});
});
+
+describe('collaborative document titles and legacy drafts', () => {
+ it('rebases title changes over body-only updates and protects a competing title', () => {
+ render(projectDocument(1, 'Initial'), true, true);
+ act(() => controller!.setTitle('My title'));
+ act(() => controller!.adoptServerDocument(projectDocument(2, 'Remote body')));
+ assert.equal(controller!.version, 2);
+ assert.equal(controller!.saveState, 'saved');
+ act(() =>
+ controller!.adoptServerDocument({
+ ...projectDocument(3, 'Remote body'),
+ title: 'Other title',
+ }),
+ );
+ assert.equal(controller!.title, 'My title');
+ assert.equal(controller!.saveState, 'conflict');
+ act(() => controller!.adoptServerDocument(projectDocument(1, 'Stale body')));
+ assert.equal(controller!.version, 3);
+ });
+ it('preserves a body draft made before collaborative editing was enabled', () => {
+ window.localStorage.setItem(
+ 'itsaplan:document-draft:user-1:SEKTA:42',
+ JSON.stringify({ title: 'Runbook', content: 'Unsaved old editor text', baseVersion: 1 }),
+ );
+ render(projectDocument(1, 'Initial'), true, true);
+ assert.equal(controller!.legacyDraft, true);
+ assert.equal(controller!.content, 'Unsaved old editor text');
+ assert.equal(controller!.saveState, 'conflict');
+ act(() => controller!.replaceWith(projectDocument(2, 'Current')));
+ assert.equal(controller!.legacyDraft, false);
+ assert.equal(controller!.content, 'Current');
+ });
+});
diff --git a/apps/web/src/features/documents/hooks/useDocumentDraft.ts b/apps/web/src/features/documents/hooks/useDocumentDraft.ts
index 5c5969af..b345d406 100644
--- a/apps/web/src/features/documents/hooks/useDocumentDraft.ts
+++ b/apps/web/src/features/documents/hooks/useDocumentDraft.ts
@@ -14,6 +14,7 @@ interface StoredDocumentDraft {
contentJson?: Record<string, unknown> | null;
baseVersion: number;
writerId?: string;
+ collaborative?: boolean;
}
function draftStorageKey(projectKey: string, documentId: number, userId: string) {
@@ -80,16 +81,19 @@ export function useDocumentDraft({
document,
editable,
userId,
+ collaborative = false,
}: {
projectKey: string;
document: ProjectDocument;
editable: boolean;
userId: string | null;
+ collaborative?: boolean;
}) {
const { mutateAsync } = useUpdateDocument(projectKey);
const versionRef = useRef(document.version);
const savingRef = useRef(false);
const writerIdRef = useRef(uuid());
+ const [legacyDraft, setLegacyDraft] = useState(false);
const [version, setVersion] = useState(document.version);
const [title, setTitleState] = useState(document.title);
const [content, setContentState] = useState(document.content);
@@ -105,8 +109,8 @@ export function useDocumentDraft({
const [restoredStorageKey, setRestoredStorageKey] = useState<string | null>(null);
const dirty =
title !== saved.title ||
- content !== saved.content ||
- JSON.stringify(contentJson) !== saved.contentJson;
+ (!collaborative &&
+ (content !== saved.content || JSON.stringify(contentJson) !== saved.contentJson));
const storageKey = userId ? draftStorageKey(projectKey, document.id, userId) : null;
// Keep an on-device recovery copy. Unlike beforeunload, this also survives
@@ -130,10 +134,21 @@ export function useDocumentDraft({
setTitleState(local?.title ?? document.title);
setContentState(local?.content ?? document.content);
setContentJsonState(local ? (local.contentJson ?? null) : document.contentJson);
- setSaveState(local && local.baseVersion !== document.version ? 'conflict' : 'saved');
+ const legacy = Boolean(
+ collaborative &&
+ local &&
+ !local.collaborative &&
+ (local.content !== document.content ||
+ JSON.stringify(local.contentJson ?? null) !== JSON.stringify(document.contentJson)),
+ );
+ setLegacyDraft(legacy);
+ setSaveState(
+ legacy || (local && local.baseVersion !== document.version) ? 'conflict' : 'saved',
+ );
setEditorRevision((revision) => revision + 1);
setRestoredStorageKey(storageKey);
}, [
+ collaborative,
document.content,
document.contentJson,
document.title,
@@ -150,7 +165,11 @@ export function useDocumentDraft({
useEffect(() => {
if (document.version <= versionRef.current) return;
if (dirty || savingRef.current) {
- setSaveState('conflict');
+ if (collaborative && document.title === saved.title) {
+ versionRef.current = document.version;
+ setVersion(document.version);
+ setDraftBaseVersion(document.version);
+ } else setSaveState('conflict');
return;
}
versionRef.current = document.version;
@@ -165,8 +184,16 @@ export function useDocumentDraft({
contentJson: JSON.stringify(document.contentJson),
});
setSaveState('saved');
- setEditorRevision((revision) => revision + 1);
- }, [dirty, document.content, document.contentJson, document.title, document.version]);
+ if (!collaborative) setEditorRevision((revision) => revision + 1);
+ }, [
+ collaborative,
+ saved.title,
+ dirty,
+ document.content,
+ document.contentJson,
+ document.title,
+ document.version,
+ ]);
useEffect(() => {
if (!storageKey || restoredStorageKey !== storageKey) return;
@@ -180,6 +207,7 @@ export function useDocumentDraft({
contentJson,
baseVersion: draftBaseVersion,
writerId: writerIdRef.current,
+ collaborative: collaborative && !legacyDraft,
}),
);
} else {
@@ -188,7 +216,17 @@ export function useDocumentDraft({
} catch {
// A full or disabled storage must not prevent editing or autosave.
}
- }, [content, contentJson, dirty, draftBaseVersion, restoredStorageKey, storageKey, title]);
+ }, [
+ collaborative,
+ legacyDraft,
+ content,
+ contentJson,
+ dirty,
+ draftBaseVersion,
+ restoredStorageKey,
+ storageKey,
+ title,
+ ]);
const save = useCallback(async (): Promise<ProjectDocument | null> => {
if (!editable || !dirty || savingRef.current || saveState === 'conflict') return null;
@@ -203,8 +241,9 @@ export function useDocumentDraft({
patch: {
version: baseVersion,
title: snapshot.title,
- content: snapshot.content,
- contentJson: snapshot.contentJson,
+ ...(!collaborative
+ ? { content: snapshot.content, contentJson: snapshot.contentJson }
+ : {}),
},
});
versionRef.current = updated.version;
@@ -226,6 +265,7 @@ export function useDocumentDraft({
savingRef.current = false;
}
}, [
+ collaborative,
content,
contentJson,
dirty,
@@ -262,6 +302,7 @@ export function useDocumentDraft({
};
const replaceWith = (latest: ProjectDocument) => {
+ setLegacyDraft(false);
try {
removeOwnedStoredDraft(storageKey, writerIdRef.current);
} catch {
@@ -285,6 +326,18 @@ export function useDocumentDraft({
};
const adoptServerDocument = (latest: ProjectDocument) => {
+ if (latest.version < versionRef.current) return;
+ if (
+ collaborative &&
+ title !== saved.title &&
+ latest.title !== saved.title &&
+ latest.title !== title
+ )
+ setSaveState('conflict');
+ if (collaborative && (title === saved.title || latest.title === title)) {
+ setTitleState(latest.title);
+ setSaved((previous) => ({ ...previous, title: latest.title }));
+ }
const previousVersion = versionRef.current;
versionRef.current = latest.version;
setVersion(latest.version);
@@ -293,6 +346,7 @@ export function useDocumentDraft({
};
return {
+ legacyDraft,
title,
content,
contentJson,
diff --git a/apps/web/src/features/documents/services/documents.service.ts b/apps/web/src/features/documents/services/documents.service.ts
index 4566aa73..54f248b8 100644
--- a/apps/web/src/features/documents/services/documents.service.ts
+++ b/apps/web/src/features/documents/services/documents.service.ts
@@ -44,11 +44,17 @@ function invalidateLists(qc: ReturnType<typeof useQueryClient>, projectKey: stri
void qc.invalidateQueries({ queryKey: qk.documentListsForProject(projectKey) });
}
-export function useDocumentsQuery(projectKey: string | null, q = '', archived = false) {
+export function useDocumentsQuery(
+ projectKey: string | null,
+ q = '',
+ archived = false,
+ enabled = true,
+) {
return useQuery({
queryKey: qk.documents(projectKey ?? '', q, archived),
queryFn: () => listDocuments(projectKey!, q || undefined, archived),
- enabled: projectKey != null,
+ enabled: enabled && projectKey != null,
+ staleTime: 30_000,
});
}
@@ -361,10 +367,10 @@ export function useUpdateDocument(projectKey: string | null) {
(previous) =>
previous?.map((item) => (item.id === document.id ? summaryOf(document) : item)),
);
- // Search membership can change when either title or content changes. The
- // immediate replacement keeps visible summaries fresh; the refetch adds or
- // removes the page from every cached search result as needed.
- invalidateLists(qc, projectKey);
+ void qc.invalidateQueries({
+ queryKey: qk.documentListsForProject(projectKey),
+ predicate: (query) => Boolean(query.queryKey[4]),
+ });
},
});
}
diff --git a/apps/web/src/features/documents/utils/documentBlocks.ts b/apps/web/src/features/documents/utils/documentBlocks.ts
new file mode 100644
index 00000000..f3eeb485
--- /dev/null
+++ b/apps/web/src/features/documents/utils/documentBlocks.ts
@@ -0,0 +1,81 @@
+import type { Editor } from '@tiptap/react';
+import { Fragment, type Node as ProseMirrorNode } from '@tiptap/pm/model';
+import { TextSelection } from '@tiptap/pm/state';
+import { uuid } from '@/utils/uuid';
+
+export function documentBlockRange(editor: Editor, position: number) {
+ const doc = editor.state.doc;
+ const resolved = doc.resolve(Math.max(0, Math.min(position, doc.content.size)));
+ const from = resolved.depth ? resolved.before(1) : position;
+ const node = doc.nodeAt(from);
+ if (!node) return null;
+ let to = from + node.nodeSize;
+ if (node.type.name === 'heading') {
+ while (to < doc.content.size) {
+ const next = doc.nodeAt(to);
+ if (!next || (next.type.name === 'heading' && next.attrs.level <= node.attrs.level)) break;
+ to += next.nodeSize;
+ }
+ }
+ return { from, to, node };
+}
+function copyNode(node: ProseMirrorNode): ProseMirrorNode {
+ const children: ProseMirrorNode[] = [];
+ node.content.forEach((child) => children.push(copyNode(child)));
+ if (node.isText) return node;
+ return node.type.create(
+ node.attrs.blockId ? { ...node.attrs, blockId: uuid() } : node.attrs,
+ Fragment.fromArray(children),
+ node.marks,
+ );
+}
+export function changeDocumentBlock(
+ editor: Editor,
+ position: number,
+ action: 'duplicate' | 'delete' | 'up' | 'down',
+) {
+ if (!editor.isEditable) return false;
+ const range = documentBlockRange(editor, position);
+ if (!range) return false;
+ const { from, to } = range;
+ const doc = editor.state.doc;
+ const tr = editor.state.tr;
+ const content = doc.slice(from, to).content;
+ let target = from;
+ if (action === 'duplicate') {
+ const nodes: ProseMirrorNode[] = [];
+ content.forEach((node) => nodes.push(copyNode(node)));
+ tr.insert(to, Fragment.fromArray(nodes));
+ target = to;
+ } else if (action === 'delete') tr.delete(from, to);
+ else {
+ const adjacent = action === 'up' ? doc.resolve(from).nodeBefore : doc.nodeAt(to);
+ if (!adjacent) return false;
+ target = action === 'up' ? from - adjacent.nodeSize : from + adjacent.nodeSize;
+ if (range.node.type.name === 'heading') {
+ if (action === 'up') {
+ let previousHeading: number | null = null;
+ doc.forEach((node, offset) => {
+ if (
+ offset < from &&
+ node.type.name === 'heading' &&
+ node.attrs.level <= range.node.attrs.level
+ )
+ previousHeading = node.attrs.level === range.node.attrs.level ? offset : null;
+ });
+ if (previousHeading !== null) target = previousHeading;
+ } else if (
+ adjacent.type.name === 'heading' &&
+ adjacent.attrs.level === range.node.attrs.level
+ ) {
+ const nextSection = documentBlockRange(editor, to);
+ if (nextSection) target = from + nextSection.to - to;
+ }
+ }
+ tr.delete(from, to).insert(target, content);
+ }
+ tr.setSelection(TextSelection.near(tr.doc.resolve(Math.min(target + 1, tr.doc.content.size))));
+ editor.view.dispatch(tr.scrollIntoView());
+ editor.view.focus();
+ return true;
+}
diff --git a/apps/web/src/features/documents/utils/documentRecovery.ts b/apps/web/src/features/documents/utils/documentRecovery.ts
new file mode 100644
index 00000000..e0b657c4
--- /dev/null
+++ b/apps/web/src/features/documents/utils/documentRecovery.ts
@@ -0,0 +1,59 @@
+import type { Node } from '@tiptap/pm/model';
+import type { EditorState } from '@tiptap/pm/state';
+import { sendableSteps } from 'prosemirror-collab';
+
+export type DocumentRecovery = {
+ epoch: string;
+ version: number;
+ clientId: string;
+ base: Record<string, unknown>;
+ steps: Record<string, unknown>[];
+};
+export type DocumentSessionState = {
+ epoch: string;
+ clientId: string;
+ confirmed: Node;
+ snapshot: EditorState;
+};
+
+export function readDocumentRecovery(key: string): DocumentRecovery | null {
+ try {
+ const value = JSON.parse(window.sessionStorage.getItem(key) ?? 'null');
+ if (
+ !value ||
+ typeof value.epoch !== 'string' ||
+ typeof value.clientId !== 'string' ||
+ !Number.isSafeInteger(value.version) ||
+ value.version < 0 ||
+ !value.base ||
+ !Array.isArray(value.steps)
+ )
+ return null;
+ return value;
+ } catch {
+ return null;
+ }
+}
+
+export function persistDocumentRecovery(key: string, session: DocumentSessionState | null) {
+ if (!session) return;
+ try {
+ const pending = sendableSteps(session.snapshot);
+ if (!pending) {
+ window.sessionStorage.removeItem(key);
+ return;
+ }
+ window.sessionStorage.setItem(
+ key,
+ JSON.stringify({
+ epoch: session.epoch,
+ version: pending.version,
+ clientId: session.clientId,
+ base: session.confirmed.toJSON(),
+ steps: pending.steps.map((step) => step.toJSON()),
+ } satisfies DocumentRecovery),
+ );
+ } catch {
+ /* Browser storage can be disabled or full. */
+ }
+}
diff --git a/apps/web/src/hooks/useDocumentNavigation.ts b/apps/web/src/hooks/useDocumentNavigation.ts
new file mode 100644
index 00000000..ee6924bf
--- /dev/null
+++ b/apps/web/src/hooks/useDocumentNavigation.ts
@@ -0,0 +1,93 @@
+import { useCallback, useMemo, useSyncExternalStore } from 'react';
+import { useSession } from '@/lib/auth-client';
+
+const CHANGE_EVENT = 'document-navigation-change';
+const empty = () => '';
+const memory = new Map<string, string>();
+function subscribe(listener: () => void) {
+ window.addEventListener(CHANGE_EVENT, listener);
+ window.addEventListener('storage', listener);
+ return () => {
+ window.removeEventListener(CHANGE_EVENT, listener);
+ window.removeEventListener('storage', listener);
+ };
+}
+function read(key: string | null) {
+ if (!key || typeof window === 'undefined') return '';
+ try {
+ return window.sessionStorage.getItem(key) ?? memory.get(key) ?? '';
+ } catch {
+ return memory.get(key) ?? '';
+ }
+}
+function parse<T extends object>(raw: string, fallback: T): T {
+ try {
+ const value: unknown = JSON.parse(raw);
+ if (!value || typeof value !== 'object' || Array.isArray(value)) return fallback;
+ const result = { ...fallback };
+ for (const key of Object.keys(fallback) as Array<keyof T>) {
+ const item = (value as T)[key],
+ defaultValue = fallback[key];
+ if (Array.isArray(defaultValue)) {
+ if (Array.isArray(item))
+ result[key] = item.filter(
+ (entry) => typeof entry === 'number' && Number.isSafeInteger(entry),
+ ) as T[keyof T];
+ } else if (defaultValue === null) {
+ if (item === null || typeof item === 'string') result[key] = item;
+ } else if (
+ typeof item === typeof defaultValue &&
+ (typeof item !== 'number' || Number.isFinite(item))
+ )
+ result[key] = item;
+ }
+ return result;
+ } catch {
+ return fallback;
+ }
+}
+
+export function useDocumentNavigation<T extends object>(
+ projectKey: string | null,
+ section: string,
+ fallback: T,
+) {
+ const { data: session } = useSession();
+ const key =
+ session?.user.id && projectKey ? `docs-nav:${session.user.id}:${projectKey}:${section}` : null;
+ const getSnapshot = useCallback(() => read(key), [key]);
+ const raw = useSyncExternalStore(subscribe, getSnapshot, empty);
+ const value = useMemo(() => parse(raw, fallback), [raw, fallback]);
+ const setValue = useCallback(
+ (next: T | ((previous: T) => T)) => {
+ if (!key) return;
+ const resolved = typeof next === 'function' ? next(parse(read(key), fallback)) : next;
+ const serialized = JSON.stringify(resolved);
+ memory.set(key, serialized);
+ try {
+ window.sessionStorage.setItem(key, serialized);
+ } catch {
+ /* Session memory remains available. */
+ }
+ window.dispatchEvent(new Event(CHANGE_EVENT));
+ },
+ [key, fallback],
+ );
+ return [value, setValue] as const;
+}
+
+const recentDefault: { ids: number[] } = { ids: [] };
+export function useRecentDocuments(projectKey: string | null) {
+ const [recent, update] = useDocumentNavigation(projectKey, 'recent', recentDefault);
+ const visit = useCallback(
+ (id: number) =>
+ update((previous) => ({
+ ids: [
+ id,
+ ...(Array.isArray(previous.ids) ? previous.ids : []).filter((item) => item !== id),
+ ].slice(0, 12),
+ })),
+ [update],
+ );
+ return { ids: Array.isArray(recent.ids) ? recent.ids : [], visit };
+}
diff --git a/apps/web/src/hooks/useHistoryScrollRestoration.test.tsx b/apps/web/src/hooks/useHistoryScrollRestoration.test.tsx
index 62dc5b43..9079405d 100644
--- a/apps/web/src/hooks/useHistoryScrollRestoration.test.tsx
+++ b/apps/web/src/hooks/useHistoryScrollRestoration.test.tsx
@@ -187,6 +187,13 @@ afterEach(() => {
});
describe('useHistoryScrollRestoration', () => {
+ it('preserves the search and section anchor while recording scroll state', () => {
+ const path = `${parentPath}?view=doc#block-section`;
+ window.history.replaceState({}, '', path);
+ render(parentPath);
+ assert.equal(window.location.pathname + window.location.search + window.location.hash, path);
+ });
+
it('restores the parent position from its browser history entry', () => {
const container = render(parentPath);
container.scrollTop = 1800;
diff --git a/apps/web/src/hooks/useHistoryScrollRestoration.ts b/apps/web/src/hooks/useHistoryScrollRestoration.ts
index 7b811acc..e4ddf783 100644
--- a/apps/web/src/hooks/useHistoryScrollRestoration.ts
+++ b/apps/web/src/hooks/useHistoryScrollRestoration.ts
@@ -82,6 +82,7 @@ function replaceHistoryPosition(position: ScrollRestorationPosition) {
window.history.replaceState(
{ ...window.history.state, __itsaplanScrollRestoration: position },
'',
+ window.location.href,
);
}
diff --git a/apps/web/src/lib/api/endpoints/documents.ts b/apps/web/src/lib/api/endpoints/documents.ts
index 480dfb2a..1807f507 100644
--- a/apps/web/src/lib/api/endpoints/documents.ts
+++ b/apps/web/src/lib/api/endpoints/documents.ts
@@ -273,3 +273,96 @@ export const deleteDocumentAsset = (projectKey: string, documentId: number, publ
`/projects/${projectKey}/documents/${documentId}/assets/${encodeURIComponent(publicId)}`,
{ method: 'DELETE' },
);
+
+export interface DocumentSession {
+ documentId: number;
+ epoch: string;
+ version: number;
+ contentJson: Record<string, unknown>;
+}
+export interface DocumentChanges {
+ epoch: string;
+ version: number;
+ documentVersion: number;
+ hasMore: boolean;
+ steps: { clientId: string; step: Record<string, unknown> }[];
+}
+export interface DocumentComment {
+ documentVersion: number;
+ id: string;
+ documentId: number;
+ parentId: string | null;
+ authorId: string | null;
+ authorName: string | null;
+ body: string;
+ quote: string;
+ from: number | null;
+ to: number | null;
+ orphaned: boolean;
+ resolvedAt: string | null;
+ createdAt: string;
+ updatedAt: string;
+}
+
+export const openDocumentSession = (
+ projectKey: string,
+ documentId: number,
+ version: number,
+ contentJson: Record<string, unknown>,
+) =>
+ request<DocumentSession>(`/projects/${projectKey}/documents/${documentId}/session`, {
+ method: 'POST',
+ body: JSON.stringify({ version, contentJson }),
+ });
+export const getDocumentChanges = (
+ projectKey: string,
+ documentId: number,
+ epoch: string,
+ version: number,
+) =>
+ request<DocumentChanges>(
+ `/projects/${projectKey}/documents/${documentId}/steps?epoch=${encodeURIComponent(epoch)}&version=${version}`,
+ );
+export const saveDocumentChanges = (
+ projectKey: string,
+ documentId: number,
+ input: {
+ epoch: string;
+ version: number;
+ clientId: string;
+ steps: Record<string, unknown>[];
+ content: string;
+ },
+) =>
+ request<ProjectDocument>(`/projects/${projectKey}/documents/${documentId}/steps`, {
+ method: 'POST',
+ body: JSON.stringify(input),
+ });
+export const listDocumentComments = (projectKey: string, documentId: number) =>
+ request<DocumentComment[]>(`/projects/${projectKey}/documents/${documentId}/comments`);
+export const addDocumentComment = (
+ projectKey: string,
+ documentId: number,
+ input: {
+ body: string;
+ parentId?: string;
+ quote?: string;
+ from?: number;
+ to?: number;
+ version: number;
+ },
+) =>
+ request<{ id: string }>(`/projects/${projectKey}/documents/${documentId}/comments`, {
+ method: 'POST',
+ body: JSON.stringify(input),
+ });
+export const updateDocumentComment = (
+ projectKey: string,
+ documentId: number,
+ commentId: string,
+ input: { body?: string; resolved?: boolean },
+) =>
+ request<{ ok: boolean }>(
+ `/projects/${projectKey}/documents/${documentId}/comments/${commentId}`,
+ { method: 'PATCH', body: JSON.stringify(input) },
+ );
diff --git a/apps/web/src/services/queryKeys.ts b/apps/web/src/services/queryKeys.ts
index 7cd490e5..b8d70882 100644
--- a/apps/web/src/services/queryKeys.ts
+++ b/apps/web/src/services/queryKeys.ts
@@ -66,6 +66,8 @@ export const qk = {
['documents', projectKey, 'document', documentId] as const,
documentRevisions: (projectKey: string, documentId: number) =>
['documents', projectKey, 'document', documentId, 'revisions'] as const,
+ documentComments: (projectKey: string, documentId: number) =>
+ ['documents', projectKey, 'document', documentId, 'comments'] as const,
documentAssets: (projectKey: string, documentId: number) =>
['documents', projectKey, 'document', documentId, 'assets'] as const,
documentIssueLinks: (projectKey: string, documentId: number) =>
diff --git a/apps/web/src/utils/commandFilter.ts b/apps/web/src/utils/commandFilter.ts
index ef9d6dc2..7cc2212b 100644
--- a/apps/web/src/utils/commandFilter.ts
+++ b/apps/web/src/utils/commandFilter.ts
@@ -4,6 +4,7 @@
// applies to the static action items. cmdk trims an item's value, so the prefix
// cannot rely on surrounding whitespace to keep it apart from a command value; the
// colon does that instead, since a command id never contains one.
+export const DOCUMENT_PREFIX = 'document-hit:';
export const ISSUE_PREFIX = 'issue-hit:';
// Match/rank the static action items. cmdk's default scorer is a fuzzy
@@ -12,8 +13,8 @@ export const ISSUE_PREFIX = 'issue-hit:';
// tiebreak (< 1) favouring an earlier hit. Server-provided issue items are handled
// separately: they always show (score > 0), ordered by their list index.
export function substringFilter(value: string, search: string): number {
- if (value.startsWith(ISSUE_PREFIX)) {
- const index = Number(value.slice(ISSUE_PREFIX.length));
+ if (value.startsWith(ISSUE_PREFIX) || value.startsWith(DOCUMENT_PREFIX)) {
+ const index = Number(value.slice(value.indexOf(':') + 1)) || 0;
return 1 - index / 1e6;
}
// cmdk calls this at item registration with the current (on open: empty)
diff --git a/bun.lock b/bun.lock
index c8a0aad6..e92c7374 100644
--- a/bun.lock
+++ b/bun.lock
@@ -35,6 +35,7 @@
"@repo/db": "workspace:*",
"@repo/mailer": "workspace:*",
"@repo/net": "workspace:*",
+ "@tiptap/pm": "3.30.5",
"croner": "^10.0.1",
"decode-named-character-reference": "^1.3.0",
"drizzle-orm": "^0.45.2",
@@ -126,6 +127,7 @@
"next": "^16.3.4",
"next-intl": "^4.13.6",
"next-themes": "^0.4.6",
+ "prosemirror-collab": "^1.3.1",
"radix-ui": "^1.6.7",
"react": "^19.2.8",
"react-day-picker": "^10.0.1",
@@ -2446,6 +2448,8 @@
"prosemirror-changeset": ["[email protected]", "", { "dependencies": { "prosemirror-transform": "^1.0.0" } }, "sha512-96WBLhOaYhJ+kPhLg3uW359Tz6I/MfcrQfL4EGv4SrcqKEMC1gmoGrXHecPE8eOwTVCJ4IwgfzM8fFad25wNfw=="],
+ "prosemirror-collab": ["[email protected]", "", { "dependencies": { "prosemirror-state": "^1.0.0" } }, "sha512-4SnynYR9TTYaQVXd/ieUvsVV4PDMBzrq2xPUWutHivDuOshZXqQ5rGbZM84HEaXKbLdItse7weMGOUdDVcLKEQ=="],
+
"prosemirror-commands": ["[email protected]", "", { "dependencies": { "prosemirror-model": "^1.0.0", "prosemirror-state": "^1.0.0", "prosemirror-transform": "^1.10.2" } }, "sha512-rT7qZnQtx5c0/y/KlYaGvtG411S97UaL6gdp6RIZ23DLHanMYLyfGBV5DtSnZdthQql7W+lEVbpSfwtO8T+L2w=="],
"prosemirror-dropcursor": ["[email protected]", "", { "dependencies": { "prosemirror-state": "^1.0.0", "prosemirror-transform": "^1.1.0", "prosemirror-view": "^1.1.0" } }, "sha512-FoYbsJR8gK+DGlqhNoE29Loa38eIZPzQRIb1VMaDNBoo4OLP6vVof/jR8qFY/6XvUd6Dhug8MDCHl2a/h8RTfQ=="],
diff --git a/docker-compose.test.yml b/docker-compose.test.yml
index 69a200d5..e5253780 100644
--- a/docker-compose.test.yml
+++ b/docker-compose.test.yml
@@ -20,6 +20,18 @@ name: itsaplan-test
services:
postgres-test:
image: postgres:17-alpine
+ # Frequent TRUNCATEs retain relation files until a checkpoint; keep the
+ # disposable database below the small tmpfs limit of CI runners.
+ command:
+ [
+ 'postgres',
+ '-c',
+ 'checkpoint_timeout=30s',
+ '-c',
+ 'max_wal_size=128MB',
+ '-c',
+ 'min_wal_size=32MB',
+ ]
environment:
POSTGRES_USER: itsaplan
POSTGRES_PASSWORD: itsaplan
diff --git a/packages/db/drizzle/0129_round_morlocks.sql b/packages/db/drizzle/0129_round_morlocks.sql
new file mode 100644
index 00000000..ab0a0b8d
--- /dev/null
+++ b/packages/db/drizzle/0129_round_morlocks.sql
@@ -0,0 +1,39 @@
+CREATE TABLE "document_collaboration" (
+ "document_id" integer PRIMARY KEY NOT NULL,
+ "epoch" uuid DEFAULT gen_random_uuid() NOT NULL,
+ "version" integer DEFAULT 0 NOT NULL,
+ "content_json" jsonb NOT NULL
+);
+--> statement-breakpoint
+CREATE TABLE "document_comment" (
+ "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
+ "document_id" integer NOT NULL,
+ "parent_id" uuid,
+ "author_id" text,
+ "body" text NOT NULL,
+ "quote" text DEFAULT '' NOT NULL,
+ "selection_from" integer,
+ "selection_to" integer,
+ "orphaned" boolean DEFAULT false NOT NULL,
+ "resolved_at" timestamp with time zone,
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
+);
+--> statement-breakpoint
+CREATE TABLE "document_step" (
+ "document_id" integer NOT NULL,
+ "version" integer NOT NULL,
+ "client_id" text NOT NULL,
+ "step" jsonb NOT NULL,
+ CONSTRAINT "document_step_document_id_version_pk" PRIMARY KEY("document_id","version")
+);
+--> statement-breakpoint
+ALTER TABLE "document_collaboration" ADD CONSTRAINT "document_collaboration_document_id_project_document_id_fk" FOREIGN KEY ("document_id") REFERENCES "public"."project_document"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "document_comment" ADD CONSTRAINT "document_comment_document_id_project_document_id_fk" FOREIGN KEY ("document_id") REFERENCES "public"."project_document"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "document_comment" ADD CONSTRAINT "document_comment_parent_id_document_comment_id_fk" FOREIGN KEY ("parent_id") REFERENCES "public"."document_comment"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "document_comment" ADD CONSTRAINT "document_comment_author_id_user_id_fk" FOREIGN KEY ("author_id") REFERENCES "public"."user"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "document_step" ADD CONSTRAINT "document_step_document_id_project_document_id_fk" FOREIGN KEY ("document_id") REFERENCES "public"."project_document"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
+CREATE INDEX "document_comment_document_idx" ON "document_comment" USING btree ("document_id","created_at");
+--> statement-breakpoint
+CREATE TRIGGER document_comment_rev AFTER INSERT OR UPDATE OR DELETE ON document_comment
+FOR EACH ROW EXECUTE FUNCTION rev_document_child();
diff --git a/packages/db/drizzle/meta/0129_snapshot.json b/packages/db/drizzle/meta/0129_snapshot.json
new file mode 100644
index 00000000..24f797ea
--- /dev/null
+++ b/packages/db/drizzle/meta/0129_snapshot.json
@@ -0,0 +1,10594 @@
+{
+ "id": "b73ebb20-d26f-45bd-87b6-5e47f13a8c7c",
+ "prevId": "3a88d463-8dce-44f8-bc2e-5ba09b5e7cc0",
+ "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
+ },
+ "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_connection_idx": {
+ "name": "git_managed_repository_connection_idx",
+ "columns": [
+ {
+ "expression": "connection_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "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_connection_external_unique": {
+ "name": "git_managed_repository_connection_external_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "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
+ },
+ "project_id": {
+ "name": "project_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_project_idx": {
+ "name": "git_provider_connection_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "git_provider_connection_project_id_project_id_fk": {
+ "name": "git_provider_connection_project_id_project_id_fk",
+ "tableFrom": "git_provider_connection",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "git_provider_connection_project_provider_url_account_unique": {
+ "name": "git_provider_connection_project_provider_url_account_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "project_id",
+ "provider",
+ "base_url",
+ "account_login"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "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_key_unique": {
+ "name": "project_key_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "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
+ },
+ "mcp_enabled": {
+ "name": "mcp_enabled",
+ "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": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "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 file
diff --git a/packages/db/drizzle/meta/_journal.json b/packages/db/drizzle/meta/_journal.json
index 599fc81b..881cbf3b 100644
--- a/packages/db/drizzle/meta/_journal.json
+++ b/packages/db/drizzle/meta/_journal.json
@@ -904,6 +904,13 @@
"when": 1788982170929,
"tag": "0128_slow_loa",
"breakpoints": true
+ },
+ {
+ "idx": 129,
+ "version": "7",
+ "when": 1789549970943,
+ "tag": "0129_round_morlocks",
+ "breakpoints": true
}
]
}
\ No newline at end of file
diff --git a/packages/db/src/schema/app.ts b/packages/db/src/schema/app.ts
index 8f8dfa4b..68ec7322 100644
--- a/packages/db/src/schema/app.ts
+++ b/packages/db/src/schema/app.ts
@@ -2210,3 +2210,48 @@ export const revision = pgTable(
// Backs both the project cleanup and the membership join the read does.
(t) => [index('revision_project_idx').on(t.projectId)],
);
+
+export const documentCollaboration = pgTable('document_collaboration', {
+ documentId: integer('document_id')
+ .primaryKey()
+ .references(() => projectDocument.id, { onDelete: 'cascade' }),
+ epoch: uuid('epoch').notNull().defaultRandom(),
+ version: integer('version').notNull().default(0),
+ contentJson: jsonb('content_json').$type<Record<string, unknown>>().notNull(),
+});
+
+export const documentStep = pgTable(
+ 'document_step',
+ {
+ documentId: integer('document_id')
+ .notNull()
+ .references(() => projectDocument.id, { onDelete: 'cascade' }),
+ version: integer('version').notNull(),
+ clientId: text('client_id').notNull(),
+ step: jsonb('step').$type<Record<string, unknown>>().notNull(),
+ },
+ (t) => [primaryKey({ columns: [t.documentId, t.version] })],
+);
+
+export const documentComment = pgTable(
+ 'document_comment',
+ {
+ id: uuid('id').primaryKey().defaultRandom(),
+ documentId: integer('document_id')
+ .notNull()
+ .references(() => projectDocument.id, { onDelete: 'cascade' }),
+ parentId: uuid('parent_id').references((): AnyPgColumn => documentComment.id, {
+ onDelete: 'cascade',
+ }),
+ authorId: text('author_id').references(() => user.id, { onDelete: 'set null' }),
+ body: text('body').notNull(),
+ quote: text('quote').notNull().default(''),
+ from: integer('selection_from'),
+ to: integer('selection_to'),
+ orphaned: boolean('orphaned').notNull().default(false),
+ resolvedAt: timestamp('resolved_at', { withTimezone: true }),
+ createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
+ updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),
+ },
+ (t) => [index('document_comment_document_idx').on(t.documentId, t.createdAt)],
+);