From dbef6ba84724b1651db5c0d92fa726cabd809fce Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Wed, 11 Nov 2026 07:09:36 -0500 Subject: [PATCH 01/41] fix: Explain local storage permission errors with the process uid (#14525) * fix: Explain local storage permission errors with the process uid * fix: Check execute permission on local storage directory --- plugins/storage/server/api/files.ts | 2 +- plugins/storage/server/index.ts | 38 ++++++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/plugins/storage/server/api/files.ts b/plugins/storage/server/api/files.ts index 5b52f02534..810da4ca08 100644 --- a/plugins/storage/server/api/files.ts +++ b/plugins/storage/server/api/files.ts @@ -83,7 +83,7 @@ router.post( await attachment.destroy(); if (err instanceof Error && err.message.includes("permission denied")) { throw Error( - `Permission denied writing to "${key}". Check the host machine file system permissions.` + `Permission denied writing to "${key}". Check that uid ${process.getuid?.() ?? "unknown"} can write to the storage directory on the host machine.` ); } throw err; diff --git a/plugins/storage/server/index.ts b/plugins/storage/server/index.ts index d5a9f20321..a2bf4e9198 100644 --- a/plugins/storage/server/index.ts +++ b/plugins/storage/server/index.ts @@ -1,4 +1,10 @@ -import { existsSync, mkdirSync } from "node:fs"; +import { + accessSync, + constants, + existsSync, + mkdirSync, + statSync, +} from "node:fs"; import { toError } from "@shared/utils/error"; import env from "@server/env"; import Logger from "@server/logging/Logger"; @@ -16,6 +22,7 @@ if (env.FILE_STORAGE === "local") { mkdirSync(rootDir, { recursive: true }); Logger.debug("utils", `Created ${rootDir} for local storage`); } + checkWritable(rootDir); } catch (err) { Logger.fatal( `Failed to create directory for local file storage at ${env.FILE_STORAGE_LOCAL_ROOT_DIR}`, @@ -41,3 +48,32 @@ if (enabled) { }, ]); } + +/** + * Logs an error that explains how to fix the permissions when the process + * cannot write to or enter the local file storage directory. + * + * @param rootDir the local file storage directory. + */ +function checkWritable(rootDir: string) { + try { + accessSync(rootDir, constants.W_OK | constants.X_OK); + } catch (err) { + if (process.getuid === undefined || process.getgid === undefined) { + Logger.error( + `Local file storage directory ${rootDir} is not writable`, + toError(err) + ); + return; + } + + const uid = process.getuid(); + const gid = process.getgid(); + const owner = statSync(rootDir); + + Logger.error( + `Local file storage directory ${rootDir} is not writable. Outline runs as uid ${uid} and gid ${gid}, but the directory is owned by uid ${owner.uid} and gid ${owner.gid}. Run "chown -R ${uid}:${gid}" on the directory on the host, or run the container as the directory owner with user: "${owner.uid}:${owner.gid}".`, + toError(err) + ); + } +} From f480f96089f93c89ce922d852eabb9882567ea02 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Wed, 11 Nov 2026 07:51:33 -0500 Subject: [PATCH 02/41] fix: Consistent document filtering in trash list (#14527) * fix: Apply draft visibility to trash list * fix: Include group memberships in draft visibility --- server/routes/api/documents/documents.test.ts | 85 +++++++++++++++++++ server/routes/api/documents/documents.ts | 32 ++----- 2 files changed, 94 insertions(+), 23 deletions(-) diff --git a/server/routes/api/documents/documents.test.ts b/server/routes/api/documents/documents.test.ts index 927f981cf0..41bf25ba2f 100644 --- a/server/routes/api/documents/documents.test.ts +++ b/server/routes/api/documents/documents.test.ts @@ -4995,6 +4995,91 @@ describe("#documents.deleted", () => { expect(monthBody.data.length).toEqual(1); }); + it("should not return deleted drafts created by other collection members", async () => { + const user = await buildUser(); + const other = await buildUser({ teamId: user.teamId }); + const collection = await buildCollection({ teamId: user.teamId }); + const ownDraft = await buildDraftDocument({ + userId: user.id, + teamId: user.teamId, + collectionId: collection.id, + }); + const otherDraft = await buildDraftDocument({ + userId: other.id, + teamId: user.teamId, + collectionId: collection.id, + }); + const otherDocument = await buildDocument({ + userId: other.id, + teamId: user.teamId, + collectionId: collection.id, + }); + await withAPIContext(user, (ctx) => ownDraft.destroyWithCtx(ctx)); + await withAPIContext(other, (ctx) => otherDraft.destroyWithCtx(ctx)); + await withAPIContext(other, (ctx) => otherDocument.destroyWithCtx(ctx)); + + const res = await server.post("/api/documents.deleted", user); + const body = await res.json(); + const ids = body.data.map((d: { id: string }) => d.id); + expect(res.status).toEqual(200); + expect(ids).toHaveLength(2); + expect(ids).toContain(ownDraft.id); + expect(ids).toContain(otherDocument.id); + expect(ids).not.toContain(otherDraft.id); + }); + + it("should return deleted drafts the user has a direct membership on", async () => { + const user = await buildUser(); + const other = await buildUser({ teamId: user.teamId }); + const collection = await buildCollection({ teamId: user.teamId }); + const sharedDraft = await buildDraftDocument({ + userId: other.id, + teamId: user.teamId, + collectionId: collection.id, + }); + await UserMembership.create({ + createdById: other.id, + documentId: sharedDraft.id, + userId: user.id, + permission: DocumentPermission.ReadWrite, + }); + await withAPIContext(other, (ctx) => sharedDraft.destroyWithCtx(ctx)); + + const res = await server.post("/api/documents.deleted", user); + const body = await res.json(); + expect(res.status).toEqual(200); + expect(body.data.length).toEqual(1); + expect(body.data[0].id).toEqual(sharedDraft.id); + }); + + it("should return deleted drafts shared with a group of the user", async () => { + const user = await buildUser(); + const other = await buildUser({ teamId: user.teamId }); + const group = await buildGroup({ teamId: user.teamId }); + await group.$add("user", user, { + through: { createdById: other.id }, + }); + const collection = await buildCollection({ teamId: user.teamId }); + const sharedDraft = await buildDraftDocument({ + userId: other.id, + teamId: user.teamId, + collectionId: collection.id, + }); + await GroupMembership.create({ + groupId: group.id, + documentId: sharedDraft.id, + permission: DocumentPermission.ReadWrite, + createdById: other.id, + }); + await withAPIContext(other, (ctx) => sharedDraft.destroyWithCtx(ctx)); + + const res = await server.post("/api/documents.deleted", user); + const body = await res.json(); + expect(res.status).toEqual(200); + expect(body.data.length).toEqual(1); + expect(body.data[0].id).toEqual(sharedDraft.id); + }); + it("should require member", async () => { const viewer = await buildViewer(); const res = await server.post("/api/documents.deleted", viewer); diff --git a/server/routes/api/documents/documents.ts b/server/routes/api/documents/documents.ts index cbcdace6e3..824ac889fd 100644 --- a/server/routes/api/documents/documents.ts +++ b/server/routes/api/documents/documents.ts @@ -163,30 +163,10 @@ async function expandDocumentIdLeaves( return expandDocumentIdInFilter(filter, expandedIds); } -/** - * Fetch the ids of documents the user has a direct membership on. Used to - * express draft visibility without referencing the (separately-loaded) - * memberships association, which would otherwise break the COUNT query. - * - * @param user the user to fetch membership document ids for. - * @returns the list of document ids. - */ -async function directMembershipDocumentIds(user: User): Promise { - const memberships = await UserMembership.findAll({ - attributes: ["documentId"], - where: { - userId: user.id, - documentId: { [Op.ne]: null }, - }, - }); - return memberships.map((m) => m.documentId as string); -} - /** * Build the visibility clauses for drafts: a draft is only ever visible to its - * creator or to a user with a direct membership on it. Both the filter-derived - * and legacy statusFilter draft paths route through this so the invariant lives - * in one place. + * creator or to a user with a user or group membership on it. List endpoints + * that can return drafts route through this so the invariant lives in one place. * * @param user the user the drafts must be visible to. * @returns an array of OR-able Sequelize conditions. @@ -194,7 +174,7 @@ async function directMembershipDocumentIds(user: User): Promise { async function draftVisibilityClauses(user: User): Promise { return [ { createdById: user.id }, - { id: await directMembershipDocumentIds(user) }, + { id: await Document.membershipDocumentIds(user.id) }, ]; } @@ -572,6 +552,12 @@ router.post( }, ], }, + { + [Op.or]: [ + { publishedAt: { [Op.ne]: null } }, + ...(await draftVisibilityClauses(user)), + ], + }, ], }; From aa454033ecf272afabcc5c0c9a5619a891df4646 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Wed, 11 Nov 2026 08:09:35 -0500 Subject: [PATCH 03/41] fix: Keep callouts and rules nested when serialized to Markdown (#14528) * fix: Keep notices and rules nested in lists and quotes when serialized to Markdown * fix: Keep the blank line above notices and rules, written per line --- server/commands/documentUpdater.test.ts | 51 +++++++++++++++ shared/editor/lib/markdown/serializer.test.ts | 64 +++++++++++++++---- shared/editor/nodes/HorizontalRule.tsx | 4 +- shared/editor/nodes/Notice.tsx | 4 +- 4 files changed, 110 insertions(+), 13 deletions(-) diff --git a/server/commands/documentUpdater.test.ts b/server/commands/documentUpdater.test.ts index cb74596c16..b87175a6b9 100644 --- a/server/commands/documentUpdater.test.ts +++ b/server/commands/documentUpdater.test.ts @@ -743,6 +743,57 @@ describe("documentUpdater", () => { }); }); + it("should keep a notice nested in its list item when patching another item", async () => { + const user = await buildUser(); + let document = await buildDocument({ + teamId: user.teamId, + text: "1. Alpha one.\n2. Bravo two:\n\n :::info\n A note inside item two.\n :::\n3. Charlie three.", + }); + + document = await withAPIContext(user, (ctx) => + documentUpdater(ctx, { + text: "Amber", + findText: "Alpha", + document, + editMode: TextEditMode.Patch, + }) + ); + + expect(document.content).toMatchObject({ + type: "doc", + content: [ + { + type: "ordered_list", + content: [ + listItem("Amber one."), + { + type: "list_item", + content: [ + { + type: "paragraph", + content: [{ type: "text", text: "Bravo two:" }], + }, + { + type: "container_notice", + content: [ + { + type: "paragraph", + content: [ + { type: "text", text: "A note inside item two." }, + ], + }, + ], + }, + ], + }, + listItem("Charlie three."), + ], + }, + { type: "paragraph" }, + ], + }); + }); + it("should append new blocks after a table when patching the last row", async () => { const user = await buildUser(); let document = await buildDocument({ diff --git a/shared/editor/lib/markdown/serializer.test.ts b/shared/editor/lib/markdown/serializer.test.ts index 149fb6bbc4..1848a2f720 100644 --- a/shared/editor/lib/markdown/serializer.test.ts +++ b/shared/editor/lib/markdown/serializer.test.ts @@ -2,6 +2,18 @@ import { Node } from "prosemirror-model"; import { parser, schema, serializer } from "../../../test/editor"; import { MarkdownSerializerState } from "./serializer"; +/** + * Serializes a document to markdown and parses the output again. + * + * @param input - the markdown to parse, or a document. + * @returns the document, the serialized output and the second parse. + */ +const roundTrip = (input: string | Node) => { + const doc = typeof input === "string" ? parser.parse(input) : input; + const output = serializer.serialize(doc); + return { doc, output, reparsed: parser.parse(output) }; +}; + describe("tables", () => { it("preserves line breaks and empty paragraphs in table cells", () => { const doc = Node.fromJSON(schema, { @@ -76,19 +88,18 @@ describe("code fences", () => { }, ], }); - const output = serializer.serialize(doc); + const { output, reparsed } = roundTrip(doc); expect(output.startsWith("````")).toBe(true); - expect(parser.parse(output)?.toJSON()).toEqual(doc.toJSON()); + expect(reparsed.toJSON()).toEqual(doc.toJSON()); }); it("round trips a code block followed by other content", () => { - const markdown = - "````\ntext with a\n``` fenced line\n````\n\nA paragraph after"; - const doc = parser.parse(markdown); - const output = serializer.serialize(doc); + const { doc, reparsed } = roundTrip( + "````\ntext with a\n``` fenced line\n````\n\nA paragraph after" + ); - expect(parser.parse(output)?.toJSON()).toEqual(doc?.toJSON()); + expect(reparsed.toJSON()).toEqual(doc.toJSON()); }); it("parses only the first token of the fence info string as language", () => { @@ -109,11 +120,10 @@ describe("code fences", () => { }, ], }); - const output = serializer.serialize(doc); - const infoLine = output.split("\n")[0]; + const { output, reparsed } = roundTrip(doc); - expect(infoLine).toBe("```not"); - expect(parser.parse(output)?.firstChild?.type.name).toBe("code_block"); + expect(output.split("\n")[0]).toBe("```not"); + expect(reparsed.firstChild?.type.name).toBe("code_block"); }); }); @@ -258,3 +268,35 @@ describe("expelEnclosingWhitespace", () => { expect(strong("a \nb")).toBe("x**a \nb**y"); }); }); + +describe("nested notices and rules", () => { + it.each([ + [ + "a notice after text in an ordered list item", + "1. Alpha one.\n2. Bravo two:\n\n :::info\n A note inside item two.\n :::\n3. Charlie three.", + ], + [ + "a notice as the first child of a bullet list item", + "* :::info\n A note.\n :::\n* Bravo item.", + ], + [ + "a notice in a nested bullet list item", + "* Alpha item.\n* Bravo item:\n * Inner item:\n\n :::info\n A deep note.\n :::\n* Charlie item.", + ], + [ + "a notice in a blockquote", + "> Alpha quoted.\n>\n> :::info\n> A note in the quote.\n> :::\n>\n> Omega quoted.", + ], + ["a rule in a bullet list item", "* Alpha item:\n\n ---\n* Bravo item."], + ["a rule in a blockquote", "> Alpha quoted.\n>\n> ***\n>\n> Omega quoted."], + ["a rule after a paragraph", "Alpha paragraph.\n\n___\n\nOmega paragraph."], + ["a rule after an empty paragraph", "Alpha.\n\n\\\n\n---\n\nOmega."], + [ + "a rule after an empty paragraph in a list item", + "* Alpha item:\n\n \\\n\n ---\n* Bravo item.", + ], + ])("round trips %s", (_name, markdown) => { + const { doc, reparsed } = roundTrip(markdown); + expect(reparsed.toJSON()).toEqual(doc.toJSON()); + }); +}); diff --git a/shared/editor/nodes/HorizontalRule.tsx b/shared/editor/nodes/HorizontalRule.tsx index 86862a6987..3b58388a58 100644 --- a/shared/editor/nodes/HorizontalRule.tsx +++ b/shared/editor/nodes/HorizontalRule.tsx @@ -100,7 +100,9 @@ export default class HorizontalRule extends Node { } toMarkdown(state: MarkdownSerializerState, node: ProsemirrorNode) { - state.write(`\n${node.attrs.markup}`); + // Separate writes, so that a list or quote delimiter also prefixes the opener. + state.write("\n"); + state.write(node.attrs.markup); state.closeBlock(node); } diff --git a/shared/editor/nodes/Notice.tsx b/shared/editor/nodes/Notice.tsx index ffa1e19cfd..6ea5dc54de 100644 --- a/shared/editor/nodes/Notice.tsx +++ b/shared/editor/nodes/Notice.tsx @@ -177,7 +177,9 @@ export default class Notice extends Node { } toMarkdown(state: MarkdownSerializerState, node: ProsemirrorNode) { - state.write("\n:::" + (node.attrs.style || "info") + "\n"); + // Separate writes, so that a list or quote delimiter also prefixes the opener. + state.write("\n"); + state.write(":::" + (node.attrs.style || "info") + "\n"); state.renderContent(node); state.ensureNewLine(); state.write(":::"); From 713a2b511db70a1fb587390753829f4a1e4c4585 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Wed, 11 Nov 2026 08:27:50 -0500 Subject: [PATCH 04/41] fix: Show nested shared documents under their shared parent in sidebar (#14526) * fix: Show nested shared documents under their shared parent in sidebar * fix: Select shared roots from ancestor grants, ignore stale cached trees * Revert ancestor walk in membership list queries --- app/models/Group.ts | 6 +- app/models/User.test.ts | 72 +++++++++++++++++ app/models/User.ts | 6 +- app/models/UserMembership.ts | 2 +- app/models/base/NavigableModel.ts | 54 +++++++++++++ .../groupMemberships/groupMemberships.test.ts | 47 +++++++++++ .../api/groupMemberships/groupMemberships.ts | 12 ++- .../userMemberships/userMemberships.test.ts | 80 +++++++++++++++++++ .../api/userMemberships/userMemberships.ts | 9 +++ 9 files changed, 284 insertions(+), 4 deletions(-) diff --git a/app/models/Group.ts b/app/models/Group.ts index c04637daf7..08151c5be3 100644 --- a/app/models/Group.ts +++ b/app/models/Group.ts @@ -1,6 +1,7 @@ import { computed, observable } from "mobx"; import type GroupMembership from "./GroupMembership"; import Model from "./base/Model"; +import NavigableModel from "./base/NavigableModel"; import Field from "./decorators/Field"; import { GroupPermission } from "@shared/types"; import type { Searchable } from "./interfaces/Searchable"; @@ -110,6 +111,7 @@ class Group extends Model implements Searchable { /** * Returns the direct memberships that this group has to documents. Documents that the current * user already has access to through a collection, archived, and trashed documents are not included. + * Documents nested under another shared document in the list are also not included. * * @returns A list of group memberships */ @@ -118,7 +120,7 @@ class Group extends Model implements Searchable { const { groupMemberships, groupUsers, documents, policies, auth } = this.store.rootStore; - return groupMemberships.orderedData + const memberships = groupMemberships.orderedData .filter((groupMembership) => groupUsers.orderedData.some( (groupUser) => @@ -136,6 +138,8 @@ class Group extends Model implements Searchable { : undefined; return !policy?.abilities?.readDocument && !!document?.isActive; }); + + return NavigableModel.filterRoots(memberships, documents); } } diff --git a/app/models/User.test.ts b/app/models/User.test.ts index c9278a7f58..9800ecafc8 100644 --- a/app/models/User.test.ts +++ b/app/models/User.test.ts @@ -194,4 +194,76 @@ describe("User model", () => { expect(user.initials).toBe("JG"); }); }); + + describe("documentMemberships", () => { + const user = new User({ id: "300", name: "Member" }, users); + + beforeEach(() => { + stores.documents.clear(); + stores.userMemberships.clear(); + }); + + const addDocument = (id: string, parentDocumentId?: string) => + stores.documents.add({ + id, + title: id, + parentDocumentId, + collectionId: "collection", + }); + + const addMembership = (id: string, documentId: string) => + stores.userMemberships.add({ + id, + userId: user.id, + documentId, + sourceId: null, + index: id, + }); + + it("should only include the highest shared document of a tree", () => { + addDocument("parent"); + addDocument("child", "parent"); + addDocument("grandchild", "child"); + addMembership("m1", "grandchild"); + addMembership("m2", "child"); + addMembership("m3", "parent"); + + expect(user.documentMemberships.map((m) => m.documentId)).toEqual([ + "parent", + ]); + }); + + it("should include a moved document that is still in a cached tree", () => { + addDocument("parent"); + addDocument("child"); + addMembership("m1", "child"); + const parent = addMembership("m2", "parent"); + parent.node = { + id: "parent", + title: "parent", + url: "/doc/parent", + children: [ + { id: "child", title: "child", url: "/doc/child", children: [] }, + ], + }; + + expect(user.documentMemberships.map((m) => m.documentId)).toEqual([ + "child", + "parent", + ]); + }); + + it("should include a document whose parent is not shared", () => { + addDocument("parent"); + addDocument("child", "parent"); + addDocument("other"); + addMembership("m1", "child"); + addMembership("m2", "other"); + + expect(user.documentMemberships.map((m) => m.documentId)).toEqual([ + "child", + "other", + ]); + }); + }); }); diff --git a/app/models/User.ts b/app/models/User.ts index acd9e00130..fbff30f53a 100644 --- a/app/models/User.ts +++ b/app/models/User.ts @@ -17,6 +17,7 @@ import { client } from "~/utils/ApiClient"; import type Document from "./Document"; import type Group from "./Group"; import type UserMembership from "./UserMembership"; +import NavigableModel from "./base/NavigableModel"; import ParanoidModel from "./base/ParanoidModel"; import Field from "./decorators/Field"; import Relation from "./decorators/Relation"; @@ -211,13 +212,14 @@ class User extends ParanoidModel implements Searchable { /** * Returns the direct memberships that this user has to documents. Documents that the * user already has access to through a collection, archived, and trashed documents are not included. + * Documents nested under another shared document in the list are also not included. * * @returns A list of user memberships */ @computed get documentMemberships(): UserMembership[] { const { userMemberships, documents, policies } = this.store.rootStore; - return userMemberships.orderedData + const memberships = userMemberships.orderedData .filter( (m) => m.userId === this.id && m.sourceId === null && m.documentId ) @@ -228,6 +230,8 @@ class User extends ParanoidModel implements Searchable { : undefined; return !policy?.abilities?.readDocument && !!document?.isActive; }); + + return NavigableModel.filterRoots(memberships, documents); } @computed diff --git a/app/models/UserMembership.ts b/app/models/UserMembership.ts index eab66c31d9..d43a2bbf32 100644 --- a/app/models/UserMembership.ts +++ b/app/models/UserMembership.ts @@ -29,7 +29,7 @@ class UserMembership extends NavigableModel { document?: Document; /** The source ID points to the root membership from which this inherits */ - sourceId?: string; + sourceId?: string | null; /** The source points to the root membership from which this inherits */ @Relation(() => UserMembership, { onDelete: "cascade" }) diff --git a/app/models/base/NavigableModel.ts b/app/models/base/NavigableModel.ts index a39b3bc1e0..06d4525408 100644 --- a/app/models/base/NavigableModel.ts +++ b/app/models/base/NavigableModel.ts @@ -3,8 +3,62 @@ import type { JSONObject, NavigationNode } from "@shared/types"; import { client } from "~/utils/ApiClient"; import Model from "./Model"; import type Document from "../Document"; +import type DocumentsStore from "~/stores/DocumentsStore"; export default abstract class NavigableModel extends Model { + /** + * Filters memberships to those whose document is not nested under the + * document of another membership in the list, so that each shared tree is + * shown once from its highest shared document. + * + * @param memberships the memberships to filter. + * @param documents the documents store used to find parent documents. + * @returns the memberships that are roots of a shared tree. + */ + static filterRoots( + memberships: T[], + documents: DocumentsStore + ): T[] { + if (memberships.length < 2) { + return memberships; + } + + const rootIds = new Set(memberships.map((m) => m.documentId)); + + return memberships.filter((membership) => { + const { documentId } = membership; + if (!documentId) { + return true; + } + + const visited = new Set([documentId]); + let document = documents.get(documentId); + while (document?.parentDocumentId) { + const { parentDocumentId } = document; + if (rootIds.has(parentDocumentId)) { + return false; + } + if (visited.has(parentDocumentId)) { + return true; + } + visited.add(parentDocumentId); + document = documents.get(parentDocumentId); + } + + // The parent chain is complete, so the loaded trees are not needed. + if (document) { + return true; + } + + // Parent documents may not be loaded, so also check the loaded trees. + return !memberships.some( + (other) => + other.documentId !== documentId && + other.childrenByDocumentId.has(documentId) + ); + }); + } + private isFetching = false; /** The document ID associated with this model. */ diff --git a/server/routes/api/groupMemberships/groupMemberships.test.ts b/server/routes/api/groupMemberships/groupMemberships.test.ts index bb630a9f49..5f69415ddc 100644 --- a/server/routes/api/groupMemberships/groupMemberships.test.ts +++ b/server/routes/api/groupMemberships/groupMemberships.test.ts @@ -63,6 +63,53 @@ describe("groupMemberships.list", () => { expect(body.policies).not.toBeFalsy(); }); + it("should not return documents nested under another shared document", async () => { + const user = await buildUser(); + const collection = await buildCollection({ + teamId: user.teamId, + createdById: user.id, + permission: null, + }); + const group = await buildGroup({ + teamId: user.teamId, + }); + const member = await buildUser({ + teamId: user.teamId, + }); + await GroupUser.create({ + groupId: group.id, + userId: member.id, + createdById: user.id, + }); + const parent = await buildDocument({ + collectionId: collection.id, + createdById: user.id, + teamId: user.teamId, + }); + const child = await buildDocument({ + collectionId: collection.id, + parentDocumentId: parent.id, + createdById: user.id, + teamId: user.teamId, + }); + + for (const document of [child, parent]) { + await server.post("/api/documents.add_group", user, { + body: { + id: document.id, + groupId: group.id, + }, + }); + } + + const res = await server.post("/api/groupMemberships.list", member); + const body = await res.json(); + expect(res.status).toEqual(200); + expect(body.pagination.total).toEqual(1); + expect(body.data.groupMemberships).toHaveLength(1); + expect(body.data.groupMemberships[0].documentId).toEqual(parent.id); + }); + it("should return total count in pagination", async () => { const user = await buildUser(); const collection = await buildCollection({ diff --git a/server/routes/api/groupMemberships/groupMemberships.ts b/server/routes/api/groupMemberships/groupMemberships.ts index fe988e01bf..4af2d90180 100644 --- a/server/routes/api/groupMemberships/groupMemberships.ts +++ b/server/routes/api/groupMemberships/groupMemberships.ts @@ -1,6 +1,6 @@ import Router from "@koa/router"; import { uniqBy } from "es-toolkit/compat"; -import { Op } from "sequelize"; +import { Op, Sequelize } from "sequelize"; import auth from "@server/middlewares/authentication"; import validate from "@server/middlewares/validate"; import { Document, GroupMembership, GroupUser } from "@server/models"; @@ -44,6 +44,16 @@ router.post( sourceId: { [Op.eq]: null, }, + + // Documents that inherit access from a shared ancestor are shown + // nested under that ancestor rather than as separate roots. + [Op.and]: Sequelize.literal(`NOT EXISTS ( + SELECT 1 FROM group_permissions AS sourced + WHERE sourced."documentId" = "group_permission"."documentId" + AND sourced."groupId" = "group_permission"."groupId" + AND sourced."sourceId" IS NOT NULL + AND sourced."deletedAt" IS NULL + )`), }, include: [ { diff --git a/server/routes/api/userMemberships/userMemberships.test.ts b/server/routes/api/userMemberships/userMemberships.test.ts index 9316a32469..e11e14140d 100644 --- a/server/routes/api/userMemberships/userMemberships.test.ts +++ b/server/routes/api/userMemberships/userMemberships.test.ts @@ -102,6 +102,86 @@ describe("#userMemberships.list", () => { expect(body.data.documents).toHaveLength(1); expect(body.data.documents[0].id).toEqual(documents[2].id); }); + + it("should not return documents nested under another shared document", async () => { + const user = await buildUser(); + const collection = await buildCollection({ + teamId: user.teamId, + createdById: user.id, + permission: null, + }); + const member = await buildUser({ + teamId: user.teamId, + }); + const parent = await buildDocument({ + collectionId: collection.id, + createdById: user.id, + teamId: user.teamId, + }); + const child = await buildDocument({ + collectionId: collection.id, + parentDocumentId: parent.id, + createdById: user.id, + teamId: user.teamId, + }); + const grandchild = await buildDocument({ + collectionId: collection.id, + parentDocumentId: child.id, + createdById: user.id, + teamId: user.teamId, + }); + + for (const document of [grandchild, child, parent]) { + await server.post("/api/documents.add_user", user, { + body: { + id: document.id, + userId: member.id, + }, + }); + } + + const res = await server.post("/api/userMemberships.list", member); + const body = await res.json(); + expect(res.status).toEqual(200); + expect(body.data.memberships).toHaveLength(1); + expect(body.data.memberships[0].documentId).toEqual(parent.id); + }); + + it("should return a nested document when its parent is not shared", async () => { + const user = await buildUser(); + const collection = await buildCollection({ + teamId: user.teamId, + createdById: user.id, + permission: null, + }); + const member = await buildUser({ + teamId: user.teamId, + }); + const parent = await buildDocument({ + collectionId: collection.id, + createdById: user.id, + teamId: user.teamId, + }); + const child = await buildDocument({ + collectionId: collection.id, + parentDocumentId: parent.id, + createdById: user.id, + teamId: user.teamId, + }); + + await server.post("/api/documents.add_user", user, { + body: { + id: child.id, + userId: member.id, + }, + }); + + const res = await server.post("/api/userMemberships.list", member); + const body = await res.json(); + expect(res.status).toEqual(200); + expect(body.data.memberships).toHaveLength(1); + expect(body.data.memberships[0].documentId).toEqual(child.id); + }); }); describe("#userMemberships.update", () => { diff --git a/server/routes/api/userMemberships/userMemberships.ts b/server/routes/api/userMemberships/userMemberships.ts index a41202c41c..bcbe96b939 100644 --- a/server/routes/api/userMemberships/userMemberships.ts +++ b/server/routes/api/userMemberships/userMemberships.ts @@ -33,6 +33,15 @@ router.post( sourceId: { [Op.eq]: null, }, + + // Documents that inherit access from a shared ancestor are shown + // nested under that ancestor rather than as separate roots. + [Op.and]: Sequelize.literal(`NOT EXISTS ( + SELECT 1 FROM user_permissions AS sourced + WHERE sourced."documentId" = "user_permission"."documentId" + AND sourced."userId" = "user_permission"."userId" + AND sourced."sourceId" IS NOT NULL + )`), }, include: [ { From 291ec67243a9eec3d0a8416fae0a03c9d3e61196 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Wed, 11 Nov 2026 15:48:02 -0500 Subject: [PATCH 05/41] fix: Record document title on documents.delete audit event (#14530) --- server/models/Document.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/server/models/Document.ts b/server/models/Document.ts index b3188a6c0b..943e42d7e1 100644 --- a/server/models/Document.ts +++ b/server/models/Document.ts @@ -1571,7 +1571,13 @@ class Document extends ArchivableModel< this.lastModifiedById = user.id; this.updatedBy = user; - await this.saveWithCtx(ctx, undefined, { name: "delete", ...eventOpts }); + // Deleted documents are excluded from the default scope, so the title + // cannot be read from the document association when listing this event. + await this.saveWithCtx(ctx, undefined, { + name: "delete", + data: { title: this.title }, + ...eventOpts, + }); }; getTimestamp = () => Math.round(new Date(this.updatedAt).getTime() / 1000); From 7589ce38dea7adb174987c5d2b9b8e106d585d9f Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Wed, 11 Nov 2026 19:18:37 -0500 Subject: [PATCH 06/41] fix: New doc input indent and Shared with me nested docs (#14531) * fix: Match nested new doc input to child document indent * fix: Allow creating nested docs from Shared with me rows --- .../Sidebar/components/DocumentRow.tsx | 7 +-- .../Sidebar/components/SharedWithMeLink.tsx | 54 ++++++++++++++++++- .../Sidebar/components/StarredLink.tsx | 1 - 3 files changed, 54 insertions(+), 8 deletions(-) diff --git a/app/components/Sidebar/components/DocumentRow.tsx b/app/components/Sidebar/components/DocumentRow.tsx index eda31ebb72..e446f3d803 100644 --- a/app/components/Sidebar/components/DocumentRow.tsx +++ b/app/components/Sidebar/components/DocumentRow.tsx @@ -15,7 +15,7 @@ import useBoolean from "~/hooks/useBoolean"; import { ActionContextProvider } from "~/hooks/useActionContext"; import DropToImport from "./DropToImport"; import Relative from "./Relative"; -import SidebarLink from "./SidebarLink"; +import SidebarLink, { childDepthFor } from "./SidebarLink"; import { StaticLink } from "./StaticLink"; import type { SidebarContextType } from "./SidebarContext"; import { useSidebarContext } from "./SidebarContext"; @@ -94,8 +94,6 @@ export type DocumentRowProps = { canCreateChild?: boolean; /** Submit handler for the inline new-child title input. */ onCreateChild?: (title: string) => Promise; - /** Depth of the inline new-child SidebarLink. Defaults to `depth + 1`. */ - newChildDepth?: number; /** Context menu action for the row. */ contextAction?: ActionWithChildren | ActionFactory; @@ -145,7 +143,6 @@ function DocumentRow({ menuOpen, canCreateChild, onCreateChild, - newChildDepth, contextAction, isActiveOverride, children, @@ -306,7 +303,7 @@ function DocumentRow({ {isAddingNewChild && onCreateChild && ( true} - depth={newChildDepth ?? depth + 1} + depth={childDepthFor(depth)} ellipsis={false} label={ { + if (!document) { + return; + } + const newDocument = await documents.create( + { + collectionId: document.collectionId ?? undefined, + parentDocumentId: document.id, + fullWidth: + document.fullWidth ?? + user.getPreference(UserPreference.FullWidthDocuments), + title: input, + data: ProsemirrorDataHelper.getEmpty(), + }, + { publish: true } + ); + if (newDocument.collectionId) { + collections + .get(newDocument.collectionId) + ?.addDocument(newDocument, document.id); + } + membership.addDocument(newDocument, document.id); + history.push({ + pathname: documentEditPath(newDocument), + state: { sidebarContext }, + }); + }, + [ + documents, + collections, + document, + membership, + sidebarContext, + user, + history, + ] + ); + const parentRef = React.useRef(null); const reparentableNode = React.useMemo( () => document?.asNavigationNode, @@ -236,6 +284,8 @@ function SharedWithMeLink({ membership, depth = 0 }: Props) { } menu={menu} menuOpen={menuOpen} + canCreateChild={can.createChildDocument} + onCreateChild={handleNewDoc} isActiveOverride={isActive} > @@ -243,7 +293,7 @@ function SharedWithMeLink({ membership, depth = 0 }: Props) { Date: Wed, 11 Nov 2026 23:31:46 -0500 Subject: [PATCH 07/41] feat: Filter menu items by typing (#14534) * feat: Filter menu items by typing Typing in an open context menu, dropdown menu or editor toolbar dropdown shows a filter row and filters the items. Focus stays on the menu items, so the arrow keys still navigate, and the menu keeps its position and width while filtering. * fix: Focus first menu item when Escape clears the filter * fix: Accept AltGr characters and emoji in the menu filter * refactor: Use isTextInput helper in menu filter * fix: Text cursor, select all and selection delete in the menu filter * Refactor to use real input * fix: Keep the focused menu item highlighted while filtering --- app/components/Menu/ContextMenu.tsx | 18 +- app/components/Menu/DropdownMenu.tsx | 20 +- app/components/Menu/MenuFilter.tsx | 330 ++++++++++++++++++ app/components/Menu/transformer.test.tsx | 50 +++ app/components/Menu/transformer.tsx | 61 +++- app/components/primitives/components/Menu.tsx | 4 +- app/editor/components/ToolbarMenu.tsx | 32 +- 7 files changed, 498 insertions(+), 17 deletions(-) create mode 100644 app/components/Menu/MenuFilter.tsx create mode 100644 app/components/Menu/transformer.test.tsx diff --git a/app/components/Menu/ContextMenu.tsx b/app/components/Menu/ContextMenu.tsx index e9f734b4be..8c209b8996 100644 --- a/app/components/Menu/ContextMenu.tsx +++ b/app/components/Menu/ContextMenu.tsx @@ -4,6 +4,7 @@ import useActionContext from "~/hooks/useActionContext"; import useMobile from "~/hooks/useMobile"; import type { ActionFactory, ActionVariant, ActionWithChildren } from "~/types"; import { preventDefault } from "~/utils/events"; +import { MenuFilter, MenuFilterEmpty, useMenuFilter } from "./MenuFilter"; import { toMenuItems } from "./transformer"; import { observer } from "mobx-react"; import { useComputed } from "~/hooks/useComputed"; @@ -31,6 +32,13 @@ export const ContextMenu = observer( const actionContext = useActionContext({ isMenu: true, }); + const { + query, + setQuery, + handleKeyDownCapture, + handleEscapeKeyDown, + reset: resetFilter, + } = useMenuFilter(); // Menu items are only built while the menu is open. const menuItems = useComputed(() => { @@ -54,12 +62,13 @@ export const ContextMenu = observer( (open: boolean) => { setOpen(open); if (open) { + resetFilter(); onOpen?.(); } else { onClose?.(); } }, - [onOpen, onClose] + [onOpen, onClose, resetFilter] ); const enablePointerEvents = React.useCallback(() => { @@ -86,7 +95,7 @@ export const ContextMenu = observer( return <>{children}; } - const content = open ? toMenuItems(menuItems) : null; + const content = open ? toMenuItems(menuItems, query) : null; return ( @@ -97,8 +106,11 @@ export const ContextMenu = observer( onAnimationStart={disablePointerEvents} onAnimationEnd={enablePointerEvents} onCloseAutoFocus={preventDefault} + onEscapeKeyDown={handleEscapeKeyDown} + onKeyDownCapture={handleKeyDownCapture} > - {content} + + {content ?? (query ? : null)} diff --git a/app/components/Menu/DropdownMenu.tsx b/app/components/Menu/DropdownMenu.tsx index 313e1629b0..9a5036c772 100644 --- a/app/components/Menu/DropdownMenu.tsx +++ b/app/components/Menu/DropdownMenu.tsx @@ -20,6 +20,7 @@ import type { MenuItem, MenuItemWithChildren, } from "~/types"; +import { MenuFilter, MenuFilterEmpty, useMenuFilter } from "./MenuFilter"; import { toMenuItems, toMobileMenuItems } from "./transformer"; import { observer } from "mobx-react"; import { useComputed } from "~/hooks/useComputed"; @@ -65,6 +66,13 @@ export const DropdownMenu = observer(function DropdownMenu({ const actionContext = useActionContext({ isMenu: true, }); + const { + query, + setQuery, + handleKeyDownCapture, + handleEscapeKeyDown, + reset: resetFilter, + } = useMenuFilter(); const menuItems = useComputed(() => { if (!open) { @@ -93,12 +101,13 @@ export const DropdownMenu = observer(function DropdownMenu({ (open: boolean) => { setOpen(open); if (open) { + resetFilter(); onOpen?.(); } else { onClose?.(); } }, - [onOpen, onClose] + [onOpen, onClose, resetFilter] ); const enablePointerEvents = React.useCallback(() => { @@ -130,7 +139,7 @@ export const DropdownMenu = observer(function DropdownMenu({ ); } - const content = toMenuItems(menuItems); + const content = toMenuItems(menuItems, query); return ( @@ -144,9 +153,12 @@ export const DropdownMenu = observer(function DropdownMenu({ onAnimationStart={disablePointerEvents} onAnimationEnd={enablePointerEvents} onCloseAutoFocus={preventDefault} + onEscapeKeyDown={handleEscapeKeyDown} + onKeyDownCapture={handleKeyDownCapture} > - {content} - {append} + + {content ?? (query ? : null)} + {query ? null : append} diff --git a/app/components/Menu/MenuFilter.tsx b/app/components/Menu/MenuFilter.tsx new file mode 100644 index 0000000000..6fae2db542 --- /dev/null +++ b/app/components/Menu/MenuFilter.tsx @@ -0,0 +1,330 @@ +import { VISUALLY_HIDDEN_STYLES } from "@radix-ui/react-visually-hidden"; +import * as React from "react"; +import { useTranslation } from "react-i18next"; +import styled from "styled-components"; +import { s } from "@shared/styles"; +import { breakpoint } from "@shared/styles/breakpoint"; +import isTextInput from "~/utils/isTextInput"; + +interface MenuFilterState { + /** The current filter query, or undefined when the filter is hidden. */ + query: string | undefined; + /** Sets the filter query. */ + setQuery: (query: string) => void; + /** Capture-phase keydown handler to attach to the menu content. */ + handleKeyDownCapture: (event: React.KeyboardEvent) => void; + /** Escape handler to attach to the menu content. */ + handleEscapeKeyDown: (event: KeyboardEvent) => void; + /** Hides the filter and clears the query. */ + reset: () => void; +} + +/** + * Lets the user filter a menu by typing. When a key that types text is pressed + * on a menu item, focus moves to the filter input, which then receives the + * text. + * + * @returns the filter query and the handlers to attach to the menu content. + */ +export function useMenuFilter(): MenuFilterState { + const [query, setQuery] = React.useState(); + const contentRef = React.useRef(null); + const highlightRef = React.useRef(null); + + const reset = React.useCallback(() => { + contentRef.current = null; + highlightRef.current = null; + setQuery(undefined); + }, []); + + const handleKeyDownCapture = React.useCallback( + (event: React.KeyboardEvent) => { + const { target, currentTarget } = event; + if ( + !(target instanceof HTMLElement) || + target.closest("[data-radix-menu-content]") !== currentTarget || + (isTextInput(target) && !target.matches('[role^="menuitem"]')) || + target.isContentEditable + ) { + return; + } + + const input = currentTarget.querySelector( + `[${INPUT_ATTRIBUTE}]` + ); + + // AltGr is reported as Ctrl+Alt on Windows, but it types a character. + const isShortcut = + (event.ctrlKey || event.metaKey || event.altKey) && + !event.getModifierState("AltGraph"); + if (!input || isShortcut) { + return; + } + + // Move up from the first item to the input while the filter is visible. + if ( + event.key === "ArrowUp" && + query !== undefined && + target === currentTarget.querySelector(ITEM_SELECTOR) + ) { + event.preventDefault(); + event.stopPropagation(); + highlightRef.current = highlightItem(currentTarget, target); + input.focus(); + return; + } + + const isText = + Array.from(event.key).length === 1 || + (event.key === "Backspace" && !!query); + if (!isText) { + return; + } + + // Space selects the focused item until there is a query to add it to. + if (event.key === " " && !query) { + return; + } + + // The default action is kept, so the browser types into the input. Radix + // typeahead, item selection and global shortcuts must not handle the key. + event.stopPropagation(); + contentRef.current = currentTarget; + if (target.matches(ITEM_SELECTOR)) { + highlightRef.current = target; + } + if (query === undefined) { + lockLayout(currentTarget); + } + input.focus(); + }, + [query] + ); + + const handleEscapeKeyDown = React.useCallback( + (event: KeyboardEvent) => { + if (query === undefined) { + return; + } + event.preventDefault(); + setQuery(undefined); + }, + [query] + ); + + // While the input has focus, highlight the item that had focus before, or + // the first match if it was filtered out. Otherwise move focus to the first + // item if the focused item was filtered out, or if the filter was hidden + // while it had focus. A passive effect runs after Radix removes unmounted + // items from its collection. + React.useEffect(() => { + const content = contentRef.current; + if (!content) { + return; + } + + const active = document.activeElement; + if (query !== undefined && active?.hasAttribute(INPUT_ATTRIBUTE)) { + highlightRef.current = highlightItem(content, highlightRef.current); + return; + } + if ( + active && + content.contains(active) && + active.getAttribute("role")?.startsWith("menuitem") + ) { + return; + } + + const first = content.querySelector(ITEM_SELECTOR); + (first ?? content).focus(); + }, [query]); + + return { query, setQuery, handleKeyDownCapture, handleEscapeKeyDown, reset }; +} + +interface Props { + /** The current filter query, or undefined when the filter is hidden. */ + query: string | undefined; + /** Called when the user changes the query. */ + onChange: (query: string) => void; +} + +/** + * Displays the filter input at the top of a menu. The input is always + * rendered, so that it can receive focus before the first character is typed, + * but it is only visible while there is a query. + */ +export function MenuFilter({ query, onChange }: Props) { + const { t } = useTranslation(); + const isActive = query !== undefined; + + const handleChange = React.useCallback( + (event: React.ChangeEvent) => { + onChange(event.target.value); + }, + [onChange] + ); + + const handleKeyDown = React.useCallback( + (event: React.KeyboardEvent) => { + // Radix typeahead must not handle keys typed into the input, but Tab + // must reach the menu so that focus stays in it. + if (event.key !== "Tab") { + event.stopPropagation(); + } + if (event.nativeEvent.isComposing) { + return; + } + + const content = event.currentTarget.closest("[data-radix-menu-content]"); + const items = content + ? Array.from(content.querySelectorAll(ITEM_SELECTOR)) + : []; + const highlighted = + content?.querySelector(`[${HIGHLIGHT_ATTRIBUTE}]`) ?? + items[0]; + + if (event.key === "ArrowDown") { + event.preventDefault(); + highlighted?.focus(); + } else if (event.key === "ArrowUp") { + event.preventDefault(); + items[items.length - 1]?.focus(); + } else if (event.key === "Enter") { + event.preventDefault(); + highlighted?.click(); + } + }, + [] + ); + + return ( + + + + ); +} + +/** + * Displays a message when no menu items match the filter query. + */ +export function MenuFilterEmpty() { + const { t } = useTranslation(); + return {t("No results")}; +} + +/** + * Records the current width and position of the menu. The filter row applies + * them, so that the menu does not move while the items are filtered. + */ +function lockLayout(content: HTMLElement) { + // The computed width is not changed by the scale of the open animation. + content.style.setProperty( + "--menu-filter-width", + getComputedStyle(content).width + ); + content.setAttribute(LOCKED_ATTRIBUTE, ""); + + const wrapper = content.closest( + "[data-radix-popper-content-wrapper]" + ); + if (wrapper?.style.transform) { + wrapper.style.setProperty( + "--menu-filter-transform", + wrapper.style.transform + ); + wrapper.setAttribute(LOCKED_ATTRIBUTE, ""); + } +} + +/** + * Marks the item that Enter selects while the filter input has focus. + * + * @param content the menu content. + * @param preferred the item to mark if it is still in the menu. + * @returns the marked item, or null if the menu has no items. + */ +function highlightItem(content: HTMLElement, preferred: HTMLElement | null) { + const item = + preferred?.isConnected && + content.contains(preferred) && + preferred.matches(ITEM_SELECTOR) + ? preferred + : content.querySelector(ITEM_SELECTOR); + + content + .querySelectorAll(`[${HIGHLIGHT_ATTRIBUTE}]`) + .forEach((element) => element.removeAttribute(HIGHLIGHT_ATTRIBUTE)); + item?.setAttribute(HIGHLIGHT_ATTRIBUTE, ""); + return item; +} + +const ITEM_SELECTOR = '[role^="menuitem"]:not([data-disabled])'; + +const HIGHLIGHT_ATTRIBUTE = "data-menu-filter-highlighted"; + +const LOCKED_ATTRIBUTE = "data-menu-filter-locked"; + +const INPUT_ATTRIBUTE = "data-menu-filter-input"; + +const Wrapper = styled.label` + position: sticky; + top: 0; + z-index: 1; + display: flex; + align-items: center; + min-height: 40px; + margin: -6px -6px 6px; + padding: 8px 18px; + cursor: text; + background: ${s("menuBackground")}; + border-bottom: 1px solid ${s("divider")}; + + // Keep the size and position that the menu had before filtering. This rule + // overrides the inline transform that Radix changes when the menu resizes. + [data-radix-menu-content][${LOCKED_ATTRIBUTE}]:has(&) { + width: var(--menu-filter-width); + } + + [data-radix-popper-content-wrapper][${LOCKED_ATTRIBUTE}]:has(&) { + transform: var(--menu-filter-transform) !important; + } +`; + +const Input = styled.input` + flex: 1; + min-width: 0; + margin: 0; + padding: 0; + border: 0; + outline: none; + background: none; + font: inherit; + font-size: 16px; + color: ${s("text")}; + + &::placeholder { + color: ${s("placeholder")}; + } + + ${breakpoint("tablet")` + font-size: 14px; + `} +`; + +const Empty = styled.div` + padding: 4px 12px; + font-size: 14px; + color: ${s("textTertiary")}; +`; diff --git a/app/components/Menu/transformer.test.tsx b/app/components/Menu/transformer.test.tsx new file mode 100644 index 0000000000..379aca1681 --- /dev/null +++ b/app/components/Menu/transformer.test.tsx @@ -0,0 +1,50 @@ +import type { ReactElement } from "react"; +import type { MenuItem } from "~/types"; +import { toMenuItems } from "./transformer"; + +const noop = () => undefined; + +const items: MenuItem[] = [ + { type: "button", title: "Team", onClick: noop }, + { type: "button", title: "Due date", onClick: noop }, + { type: "separator" }, + { + type: "submenu", + title: "Move to", + items: [ + { type: "button", title: "Engineering", onClick: noop }, + { type: "button", title: "Design", onClick: noop }, + ], + }, + { type: "button", title: "Hidden date", visible: false, onClick: noop }, +]; + +function render(query?: string) { + return (toMenuItems(items, query) ?? []).filter( + (element): element is ReactElement => !!element + ); +} + +describe("toMenuItems", () => { + it("returns all visible items without a query", () => { + expect(render().map((element) => element.key)).toEqual([ + "button-0", + "button-1", + "separator-2", + "submenu-3", + ]); + }); + + it("returns only matching items and keeps their keys", () => { + expect(render("DATE").map((element) => element.key)).toEqual(["button-1"]); + }); + + it("keeps a submenu when one of its items matches", () => { + const [submenu] = render("design"); + expect(submenu.key).toEqual("submenu-3"); + }); + + it("returns null when nothing matches", () => { + expect(toMenuItems(items, "zzz")).toBeNull(); + }); +}); diff --git a/app/components/Menu/transformer.tsx b/app/components/Menu/transformer.tsx index 2ac0c4bf97..2dadb495ae 100644 --- a/app/components/Menu/transformer.tsx +++ b/app/components/Menu/transformer.tsx @@ -14,11 +14,27 @@ import type { MenuItem } from "~/types"; import { MouseSafeArea } from "~/components/MouseSafeArea"; import { createRef } from "react"; -export function toMenuItems(items: MenuItem[]) { +/** + * Converts menu items to menu elements. + * + * @param items the menu items to convert. + * @param query an optional filter query, only matching items are returned. + * @returns the menu elements, or null if there are none. + */ +export function toMenuItems(items: MenuItem[], query?: string) { const filteredItems = filterMenuItems(items); const parentRef = createRef(); + const normalizedQuery = query?.toLocaleLowerCase(); - if (!filteredItems.length) { + // Keys use the index before the query is applied, so that the focused item + // keeps its element while the query changes. + const entries = filteredItems + .map((item, index) => ({ item, index })) + .filter( + ({ item }) => !normalizedQuery || matchesQuery(item, normalizedQuery) + ); + + if (!entries.length) { return null; } @@ -31,13 +47,19 @@ export function toMenuItems(items: MenuItem[]) { !!item.icon ); - return filteredItems.map((item, index) => { + return entries.map(({ item, index }) => { const icon = showIcon ? ( {"icon" in item ? item.icon : null} ) : undefined; + // Children are filtered too, unless the parent title itself matches. + const childQuery = + normalizedQuery && !titleMatches(item, normalizedQuery) + ? normalizedQuery + : undefined; + switch (item.type) { case "button": return ( @@ -85,7 +107,7 @@ export function toMenuItems(items: MenuItem[]) { ); case "submenu": { - const submenuItems = toMenuItems(item.items); + const submenuItems = toMenuItems(item.items, childQuery); if (!submenuItems?.length) { return null; @@ -116,7 +138,7 @@ export function toMenuItems(items: MenuItem[]) { } case "group": { - const groupItems = toMenuItems(item.items); + const groupItems = toMenuItems(item.items, childQuery); if (!groupItems?.length) { return null; @@ -287,6 +309,35 @@ export function toMobileMenuItems( }); } +function titleMatches(item: MenuItem, query: string): boolean { + return ( + "title" in item && + typeof item.title === "string" && + item.title.toLocaleLowerCase().includes(query) + ); +} + +function matchesQuery(item: MenuItem, query: string): boolean { + if (item.visible === false) { + return false; + } + + switch (item.type) { + case "button": + case "route": + case "link": + return titleMatches(item, query); + case "submenu": + case "group": + return ( + titleMatches(item, query) || + item.items.some((child) => matchesQuery(child, query)) + ); + default: + return false; + } +} + function filterMenuItems(items: MenuItem[]): MenuItem[] { return items .filter((item) => item.visible !== false) diff --git a/app/components/primitives/components/Menu.tsx b/app/components/primitives/components/Menu.tsx index eb41ac9314..82cc2b1a52 100644 --- a/app/components/primitives/components/Menu.tsx +++ b/app/components/primitives/components/Menu.tsx @@ -68,7 +68,9 @@ const BaseMenuItemCSS = css` ` &[data-highlighted], &[data-state="open"], - &:focus-visible { + &:focus-visible, + [data-radix-menu-content]:has([data-menu-filter-input]:focus) + &[data-menu-filter-highlighted] { color: ${props.theme.accentText}; background: ${props.$dangerous ? props.theme.danger : props.theme.accent}; outline-color: ${ diff --git a/app/editor/components/ToolbarMenu.tsx b/app/editor/components/ToolbarMenu.tsx index 48942118b1..fa67f235d0 100644 --- a/app/editor/components/ToolbarMenu.tsx +++ b/app/editor/components/ToolbarMenu.tsx @@ -16,6 +16,11 @@ import ToolbarButton from "./ToolbarButton"; import ToolbarSeparator from "./ToolbarSeparator"; import Tooltip from "./Tooltip"; import { toMenuItems } from "~/components/Menu/transformer"; +import { + MenuFilter, + MenuFilterEmpty, + useMenuFilter, +} from "~/components/Menu/MenuFilter"; import { MenuContent } from "~/components/primitives/Menu"; import { MenuProvider } from "~/components/primitives/Menu/MenuContext"; import { Menu, MenuTrigger } from "~/components/primitives/Menu"; @@ -44,10 +49,23 @@ function ToolbarDropdown(props: ToolbarDropdownProps) { const { item, shortcut, tooltip } = props; const { state } = view; const [isOpen, setIsOpen] = useState(false); + const { + query, + setQuery, + handleKeyDownCapture, + handleEscapeKeyDown, + reset: resetFilter, + } = useMenuFilter(); - const handleOpenChange = useCallback((open: boolean) => { - setIsOpen(open); - }, []); + const handleOpenChange = useCallback( + (open: boolean) => { + setIsOpen(open); + if (open) { + resetFilter(); + } + }, + [resetFilter] + ); const items: TMenuItem[] = useMemo(() => { if (!isOpen) { @@ -86,8 +104,14 @@ function ToolbarDropdown(props: ToolbarDropdownProps) { align="end" aria-label={item.tooltip || t("More options")} onCloseAutoFocus={handleCloseAutoFocus} + onEscapeKeyDown={handleEscapeKeyDown} + onKeyDownCapture={handleKeyDownCapture} > - {toMenuItems(items)} + + + {toMenuItems(items, query) ?? + (query ? : null)} + From f43d8bcba9555a26e42b4fa80add5166397ef10d Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Wed, 11 Nov 2026 23:35:11 -0500 Subject: [PATCH 08/41] fix: Use a redder warning color so notices are not brown (#14537) --- shared/styles/theme.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/styles/theme.ts b/shared/styles/theme.ts index a4b727c158..0005fe70a2 100644 --- a/shared/styles/theme.ts +++ b/shared/styles/theme.ts @@ -28,7 +28,7 @@ const defaultColors: Colors = { yellow: "#EDBA07", warmGrey: "hsl(212 31% 95% / 1)", danger: "#ed2651", - warning: "#f08a24", + warning: "#f05a28", success: "#3ad984", info: "#a0d3e8", brand: { From bf0dbc8545462e7910bde32c533593bb4826aef8 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Wed, 11 Nov 2026 23:37:48 -0500 Subject: [PATCH 09/41] fix: Show workspace logo as square in General settings (#14538) --- app/scenes/Settings/Details.tsx | 2 ++ app/scenes/Settings/components/ImageInput.tsx | 14 ++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/scenes/Settings/Details.tsx b/app/scenes/Settings/Details.tsx index bfb3d72f05..def9a44b09 100644 --- a/app/scenes/Settings/Details.tsx +++ b/app/scenes/Settings/Details.tsx @@ -13,6 +13,7 @@ import type { CustomTheme } from "@shared/types"; import { TOCPosition, TeamPreference, UserPreference } from "@shared/types"; import { getBaseDomain } from "@shared/utils/domains"; import { TeamValidation } from "@shared/validations"; +import { AvatarVariant } from "~/components/Avatar/Avatar"; import Button from "~/components/Button"; import ButtonLink from "~/components/ButtonLink"; import DefaultCollectionInputSelect from "~/components/DefaultCollectionInputSelect"; @@ -221,6 +222,7 @@ function Details() { onError={handleAvatarError} model={team} borderRadius={0} + variant={AvatarVariant.Square} /> - + @@ -64,11 +67,14 @@ const avatarStyles = ` height: ${AvatarSize.Upload}px; `; -const ImageBox = styled(Flex)` +const ImageBox = styled(Flex)<{ $variant: AvatarVariant }>` ${avatarStyles}; position: relative; font-size: 14px; - border-radius: 50%; + border-radius: ${(props) => + props.$variant === AvatarVariant.Round + ? "50%" + : `${AvatarSize.Upload / 8}px`}; box-shadow: 0 0 0 1px ${s("backgroundSecondary")}; background: ${s("background")}; overflow: hidden; From 3dbd552ae86c39efe4105c181cbf8542809364b4 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Wed, 11 Nov 2026 23:47:30 -0500 Subject: [PATCH 10/41] chore: Update Node.js to 26.13.1 (#14539) --- Dockerfile | 2 +- Dockerfile.base | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index f05c05a291..e704d2e430 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ ARG APP_PATH WORKDIR $APP_PATH # --- -FROM node:26.13.0-slim AS runner +FROM node:26.13.1-slim AS runner LABEL org.opencontainers.image.source="https://github.com/outline/outline" diff --git a/Dockerfile.base b/Dockerfile.base index 2ea5c1d12c..3267b7cd08 100644 --- a/Dockerfile.base +++ b/Dockerfile.base @@ -1,5 +1,5 @@ ARG APP_PATH=/opt/outline -FROM node:26.13.0 AS deps +FROM node:26.13.1 AS deps ARG APP_PATH WORKDIR $APP_PATH diff --git a/package.json b/package.json index 60b1e6f727..a01252a132 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "url": "https://github.com/sponsors/outline" }, "engines": { - "node": ">=22.23.4 <23 || >=24.22.1 <25 || >=26.12.1 <27" + "node": ">=22.23.5 <23 || >=24.22.3 <25 || >=26.13.1 <27" }, "repository": { "type": "git", From f8446a3c7859b90c30faa25e0129ac4b8a0de2bd Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Thu, 12 Nov 2026 09:48:13 -0500 Subject: [PATCH 11/41] fix: Tighten session token validation order (#14542) * fix: Tighten session token validation order * test: Rename signature test --- server/utils/jwt.test.ts | 40 ++++++++++++++++++++++++++++++++++++++-- server/utils/jwt.ts | 12 ++++++------ 2 files changed, 44 insertions(+), 8 deletions(-) diff --git a/server/utils/jwt.test.ts b/server/utils/jwt.test.ts index cbb452910a..15916c662c 100644 --- a/server/utils/jwt.test.ts +++ b/server/utils/jwt.test.ts @@ -1,8 +1,8 @@ import { subMinutes } from "date-fns"; import JWT from "jsonwebtoken"; import type { Context } from "koa"; -import { buildUser } from "@server/test/factories"; -import { getUserForEmailSigninToken } from "./jwt"; +import { buildAdmin, buildUser } from "@server/test/factories"; +import { getUserForEmailSigninToken, getUserForJWT } from "./jwt"; /** * Minimal Koa context stub exposing only the request IP. @@ -94,3 +94,39 @@ describe("getUserForEmailSigninToken", () => { ); }); }); + +describe("getUserForJWT", () => { + it("should return the user for a valid token", async () => { + const user = await buildUser(); + const token = user.getSessionToken(); + + const result = await getUserForJWT(token); + expect(result.user.id).toEqual(user.id); + }); + + it("should reject a token with a wrong signature for a suspended user", async () => { + const admin = await buildAdmin(); + const user = await buildUser({ + teamId: admin.teamId, + suspendedAt: new Date(), + suspendedById: admin.id, + }); + const token = JWT.sign({ id: user.id, type: "session" }, "wrong-secret"); + + await expect(getUserForJWT(token)).rejects.toThrow("Invalid token"); + }); + + it("should reject a valid token for a suspended user", async () => { + const admin = await buildAdmin(); + const user = await buildUser({ + teamId: admin.teamId, + suspendedAt: new Date(), + suspendedById: admin.id, + }); + const token = user.getSessionToken(); + + await expect(getUserForJWT(token)).rejects.toMatchObject({ + id: "user_suspended", + }); + }); +}); diff --git a/server/utils/jwt.ts b/server/utils/jwt.ts index ca608a2b11..190ee1745d 100644 --- a/server/utils/jwt.ts +++ b/server/utils/jwt.ts @@ -74,6 +74,12 @@ export async function getUserForJWT( throw AuthenticationError("Invalid token"); } + try { + JWT.verify(token, user.jwtSecret); + } catch (_err) { + throw AuthenticationError("Invalid token"); + } + if (user.isSuspended) { const suspendingAdmin = user.suspendedById ? await User.findByPk(user.suspendedById) @@ -95,12 +101,6 @@ export async function getUserForJWT( } } - try { - JWT.verify(token, user.jwtSecret); - } catch (_err) { - throw AuthenticationError("Invalid token"); - } - return { user, service: payload.service as string | undefined, From b3555dddfeac5b455b4e8e41a69f79f58d0be33b Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Thu, 12 Nov 2026 09:50:35 -0500 Subject: [PATCH 12/41] fix: Improve webhook delivery response handling (#14541) --- .../server/tasks/DeliverWebhookTask.test.ts | 61 +++++++++++++++++++ .../server/tasks/DeliverWebhookTask.ts | 7 ++- 2 files changed, 66 insertions(+), 2 deletions(-) diff --git a/plugins/webhooks/server/tasks/DeliverWebhookTask.test.ts b/plugins/webhooks/server/tasks/DeliverWebhookTask.test.ts index 1c95657913..0dc042a881 100644 --- a/plugins/webhooks/server/tasks/DeliverWebhookTask.test.ts +++ b/plugins/webhooks/server/tasks/DeliverWebhookTask.test.ts @@ -137,6 +137,67 @@ describe("DeliverWebhookTask", () => { expect(delivery.responseBody).toEqual("SUCCESS"); }); + it("should truncate stored response bodies", async () => { + const subscription = await buildWebhookSubscription({ + url: "http://example.com", + events: ["*"], + }); + const signedInUser = await buildUser({ teamId: subscription.teamId }); + captureWebhook( + "http://example.com", + () => new HttpResponse("a".repeat(5000), { status: 200 }) + ); + + await new DeliverWebhookTask().perform({ + subscriptionId: subscription.id, + event: { + name: "users.signin", + userId: signedInUser.id, + teamId: subscription.teamId, + actorId: signedInUser.id, + ip, + }, + }); + + const delivery = await WebhookDelivery.findOne({ + where: { webhookSubscriptionId: subscription.id }, + rejectOnEmpty: true, + }); + expect(delivery.status).toBe("success"); + expect(delivery.responseBody).toEqual("a".repeat(1024)); + }); + + it("should not read response bodies over the size limit", async () => { + const subscription = await buildWebhookSubscription({ + url: "http://example.com", + events: ["*"], + }); + const signedInUser = await buildUser({ teamId: subscription.teamId }); + captureWebhook( + "http://example.com", + () => new HttpResponse("a".repeat(128 * 1024), { status: 200 }) + ); + + await new DeliverWebhookTask().perform({ + subscriptionId: subscription.id, + event: { + name: "users.signin", + userId: signedInUser.id, + teamId: subscription.teamId, + actorId: signedInUser.id, + ip, + }, + }); + + const delivery = await WebhookDelivery.findOne({ + where: { webhookSubscriptionId: subscription.id }, + rejectOnEmpty: true, + }); + expect(delivery.status).toBe("success"); + expect(delivery.statusCode).toBe(200); + expect(delivery.responseBody).toEqual(""); + }); + it("should hit the subscription url with signature header", async () => { const subscription = await buildWebhookSubscription({ url: "http://example.com", diff --git a/plugins/webhooks/server/tasks/DeliverWebhookTask.ts b/plugins/webhooks/server/tasks/DeliverWebhookTask.ts index 007c32466c..f0d1674c92 100644 --- a/plugins/webhooks/server/tasks/DeliverWebhookTask.ts +++ b/plugins/webhooks/server/tasks/DeliverWebhookTask.ts @@ -795,9 +795,12 @@ export default class DeliverWebhookTask extends BaseTask { }); } - /** Maximum number of bytes to read from webhook response bodies. */ + /** Maximum number of bytes to store from webhook response bodies. */ private static readonly MAX_RESPONSE_BODY_SIZE = 1024; + /** Maximum number of bytes to read from webhook response bodies. */ + private static readonly MAX_RESPONSE_READ_SIZE = 64 * 1024; + private async sendWebhook({ event, subscription, @@ -838,6 +841,7 @@ export default class DeliverWebhookTask extends BaseTask { body: JSON.stringify(requestBody), redirect: "error", timeout: 5000, + size: DeliverWebhookTask.MAX_RESPONSE_READ_SIZE, }); status = response.ok ? "success" : "failed"; } catch (err) { @@ -858,7 +862,6 @@ export default class DeliverWebhookTask extends BaseTask { if (response) { try { - // TODO: Use stream to avoid buffering large responses in memory. const text = await response.text(); responseBody = text.slice(0, DeliverWebhookTask.MAX_RESPONSE_BODY_SIZE); } catch (err) { From a176a4074979ec10b6221f0ce084ec86e81311e6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 12 Nov 2026 16:28:50 +0000 Subject: [PATCH 13/41] chore(deps): bump the aws group with 6 updates (#14543) Bumps the aws group with 6 updates: | Package | From | To | | --- | --- | --- | | [@aws-sdk/client-s3](https://github.com/aws/aws-sdk-js-v3/tree/HEAD/clients/client-s3) | `3.1159.0` | `3.1162.0` | | [@aws-sdk/cloudfront-signer](https://github.com/aws/aws-sdk-js-v3/tree/HEAD/packages/cloudfront-signer) | `3.1157.0` | `3.1161.0` | | [@aws-sdk/lib-storage](https://github.com/aws/aws-sdk-js-v3/tree/HEAD/lib/lib-storage) | `3.1159.0` | `3.1162.0` | | [@aws-sdk/s3-presigned-post](https://github.com/aws/aws-sdk-js-v3/tree/HEAD/packages/s3-presigned-post) | `3.1159.0` | `3.1162.0` | | [@aws-sdk/s3-request-presigner](https://github.com/aws/aws-sdk-js-v3/tree/HEAD/packages/s3-request-presigner) | `3.1159.0` | `3.1162.0` | | [@aws-sdk/signature-v4-crt](https://github.com/aws/aws-sdk-js-v3/tree/HEAD/packages/signature-v4-crt) | `3.1159.0` | `3.1162.0` | Updates `@aws-sdk/client-s3` from 3.1159.0 to 3.1162.0 - [Release notes](https://github.com/aws/aws-sdk-js-v3/releases) - [Changelog](https://github.com/aws/aws-sdk-js-v3/blob/main/clients/client-s3/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-js-v3/commits/v3.1162.0/clients/client-s3) Updates `@aws-sdk/cloudfront-signer` from 3.1157.0 to 3.1161.0 - [Release notes](https://github.com/aws/aws-sdk-js-v3/releases) - [Changelog](https://github.com/aws/aws-sdk-js-v3/blob/main/packages/cloudfront-signer/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-js-v3/commits/v3.1161.0/packages/cloudfront-signer) Updates `@aws-sdk/lib-storage` from 3.1159.0 to 3.1162.0 - [Release notes](https://github.com/aws/aws-sdk-js-v3/releases) - [Changelog](https://github.com/aws/aws-sdk-js-v3/blob/main/lib/lib-storage/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-js-v3/commits/v3.1162.0/lib/lib-storage) Updates `@aws-sdk/s3-presigned-post` from 3.1159.0 to 3.1162.0 - [Release notes](https://github.com/aws/aws-sdk-js-v3/releases) - [Changelog](https://github.com/aws/aws-sdk-js-v3/blob/main/packages/s3-presigned-post/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-js-v3/commits/v3.1162.0/packages/s3-presigned-post) Updates `@aws-sdk/s3-request-presigner` from 3.1159.0 to 3.1162.0 - [Release notes](https://github.com/aws/aws-sdk-js-v3/releases) - [Changelog](https://github.com/aws/aws-sdk-js-v3/blob/main/packages/s3-request-presigner/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-js-v3/commits/v3.1162.0/packages/s3-request-presigner) Updates `@aws-sdk/signature-v4-crt` from 3.1159.0 to 3.1162.0 - [Release notes](https://github.com/aws/aws-sdk-js-v3/releases) - [Changelog](https://github.com/aws/aws-sdk-js-v3/blob/main/packages/signature-v4-crt/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-js-v3/commits/v3.1162.0/packages/signature-v4-crt) --- updated-dependencies: - dependency-name: "@aws-sdk/client-s3" dependency-version: 3.1162.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: aws - dependency-name: "@aws-sdk/cloudfront-signer" dependency-version: 3.1161.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: aws - dependency-name: "@aws-sdk/lib-storage" dependency-version: 3.1162.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: aws - dependency-name: "@aws-sdk/s3-presigned-post" dependency-version: 3.1162.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: aws - dependency-name: "@aws-sdk/s3-request-presigner" dependency-version: 3.1162.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: aws - dependency-name: "@aws-sdk/signature-v4-crt" dependency-version: 3.1162.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: aws ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 12 +-- yarn.lock | 296 +++++++++++++++++++++++++-------------------------- 2 files changed, 154 insertions(+), 154 deletions(-) diff --git a/package.json b/package.json index a01252a132..c8fa30f7e8 100644 --- a/package.json +++ b/package.json @@ -52,12 +52,12 @@ "> 0.25%, not dead" ], "dependencies": { - "@aws-sdk/client-s3": "^3.1159.0", - "@aws-sdk/cloudfront-signer": "^3.1157.0", - "@aws-sdk/lib-storage": "^3.1159.0", - "@aws-sdk/s3-presigned-post": "^3.1159.0", - "@aws-sdk/s3-request-presigner": "^3.1159.0", - "@aws-sdk/signature-v4-crt": "^3.1159.0", + "@aws-sdk/client-s3": "^3.1162.0", + "@aws-sdk/cloudfront-signer": "^3.1161.0", + "@aws-sdk/lib-storage": "^3.1162.0", + "@aws-sdk/s3-presigned-post": "^3.1162.0", + "@aws-sdk/s3-request-presigner": "^3.1162.0", + "@aws-sdk/signature-v4-crt": "^3.1162.0", "@benrbray/prosemirror-math": "^0.2.2", "@bull-board/api": "^6.21.3", "@bull-board/koa": "^6.21.3", diff --git a/yarn.lock b/yarn.lock index 61df2dc480..e763b35fb9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -43,51 +43,51 @@ __metadata: languageName: node linkType: hard -"@aws-sdk/checksums@npm:^3.1001.7": - version: 3.1002.1 - resolution: "@aws-sdk/checksums@npm:3.1002.1" +"@aws-sdk/checksums@npm:^3.1002.2": + version: 3.1002.3 + resolution: "@aws-sdk/checksums@npm:3.1002.3" dependencies: - "@aws-sdk/core": "npm:^3.979.1" + "@aws-sdk/core": "npm:^3.980.1" "@aws-sdk/types": "npm:^3.975.0" "@smithy/core": "npm:^3.38.0" "@smithy/types": "npm:^4.19.0" tslib: "npm:^2.6.2" - checksum: 10c0/723318277a52280d9390674494e48bd3e440e7b81682a11297197d9e08923f05b5cb8af9a4568f426f36053c694940d2bd24981774545b8e299a70d3688ba7f7 + checksum: 10c0/e6fef833446cca106538bbc7c9f20eef54b53e41781201688d1857289bbc3c0b7c453ea5698f83a26af022c345f82e58af1d6dc554e04af98a634d6c7ceb4dde languageName: node linkType: hard -"@aws-sdk/client-s3@npm:3.1159.0, @aws-sdk/client-s3@npm:^3.1159.0": - version: 3.1159.0 - resolution: "@aws-sdk/client-s3@npm:3.1159.0" +"@aws-sdk/client-s3@npm:3.1162.0, @aws-sdk/client-s3@npm:^3.1162.0": + version: 3.1162.0 + resolution: "@aws-sdk/client-s3@npm:3.1162.0" dependencies: - "@aws-sdk/checksums": "npm:^3.1001.7" - "@aws-sdk/core": "npm:^3.978.7" - "@aws-sdk/credential-provider-node": "npm:^3.972.90" - "@aws-sdk/middleware-sdk-s3": "npm:^3.972.83" - "@aws-sdk/signature-v4-multi-region": "npm:^3.996.50" + "@aws-sdk/checksums": "npm:^3.1002.2" + "@aws-sdk/core": "npm:^3.980.0" + "@aws-sdk/credential-provider-node": "npm:^3.972.93" + "@aws-sdk/middleware-sdk-s3": "npm:^3.972.86" + "@aws-sdk/signature-v4-multi-region": "npm:^3.996.51" "@aws-sdk/types": "npm:^3.975.0" - "@smithy/core": "npm:^3.37.0" + "@smithy/core": "npm:^3.38.0" "@smithy/fetch-http-handler": "npm:^5.8.0" - "@smithy/node-http-handler": "npm:^4.13.0" + "@smithy/node-http-handler": "npm:^4.14.0" "@smithy/types": "npm:^4.19.0" tslib: "npm:^2.6.2" - checksum: 10c0/3c972c3e528eb0abbc16411cd279094f6f025c755fe681bf1f017e942763ce04af07582e4374a60b39e2216aec1fac2f7cc0a9888071cd5e333ff380480cc1ba + checksum: 10c0/63d67b0a311cc9b66005ed2c0f1636ca813d8847d1ac21a855e5d3752123c3206f7a7b8831d38480349cbbf9147a053d605be779b59166241969c5eb96267a61 languageName: node linkType: hard -"@aws-sdk/cloudfront-signer@npm:^3.1157.0": - version: 3.1157.0 - resolution: "@aws-sdk/cloudfront-signer@npm:3.1157.0" +"@aws-sdk/cloudfront-signer@npm:^3.1161.0": + version: 3.1161.0 + resolution: "@aws-sdk/cloudfront-signer@npm:3.1161.0" dependencies: - "@smithy/core": "npm:^3.37.0" + "@smithy/core": "npm:^3.38.0" tslib: "npm:^2.6.2" - checksum: 10c0/6ce3bfc9fb0eb7ada3156251b08c7a4db70895f09de40688359e781f48dddf7322f18b844f679601e31c68086381a7b4d5273f7b30cc7652afe781484ded7ada + checksum: 10c0/0bf305a911d107324c198fff9ed5266471cf6a36387a7cc67d8cf9efac5c4454f37fe8331afbbcb27f5f29504f40145801d62c7a15177e0f4ca302cdfbfca8c4 languageName: node linkType: hard -"@aws-sdk/core@npm:^3.978.7, @aws-sdk/core@npm:^3.979.1": - version: 3.979.1 - resolution: "@aws-sdk/core@npm:3.979.1" +"@aws-sdk/core@npm:^3.980.0, @aws-sdk/core@npm:^3.980.1": + version: 3.980.1 + resolution: "@aws-sdk/core@npm:3.980.1" dependencies: "@aws-sdk/types": "npm:^3.975.0" "@aws-sdk/xml-builder": "npm:^3.972.42" @@ -97,180 +97,180 @@ __metadata: "@smithy/types": "npm:^4.19.0" bowser: "npm:^2.11.0" tslib: "npm:^2.6.2" - checksum: 10c0/f44ffe99a8aa440445447cf9a4a73d9939fbee38d42a105cce188b740798e2a8c2bc0acdb847d010feef63ca8380783dfb247944c650419a9f8fe69a579fcacc + checksum: 10c0/1bd2c77c1d492807f6d45cfac2aff8cb6d4f40cf72148c43eaa59d3c9d5fbb079b6539481d6e3ae7640fe433ae2da97409b69455d0b95503df0fa4fb47c9c1a3 languageName: node linkType: hard -"@aws-sdk/credential-provider-env@npm:^3.972.80": - version: 3.972.80 - resolution: "@aws-sdk/credential-provider-env@npm:3.972.80" +"@aws-sdk/credential-provider-env@npm:^3.972.82": + version: 3.972.82 + resolution: "@aws-sdk/credential-provider-env@npm:3.972.82" dependencies: - "@aws-sdk/core": "npm:^3.979.1" + "@aws-sdk/core": "npm:^3.980.1" "@aws-sdk/types": "npm:^3.975.0" "@smithy/core": "npm:^3.38.0" "@smithy/types": "npm:^4.19.0" tslib: "npm:^2.6.2" - checksum: 10c0/9a2448d4d7d4b0ef5dd6863f0efdc891a24fcaae6b92c9d7b650adb3ceb0ebf93bd481c9691ce5f4ccd258f0c941fa4d0c4babef629ca4bc5b77d6e4ea12bdcd + checksum: 10c0/0f1fff896c3fee90c7d3c2d4b87f53b72c82dee0ff23cf779b158020d8c1983ce418f73bd49521f2cc667448c122657cfcbd4d3ad9048ea88b656fa0f699c518 languageName: node linkType: hard -"@aws-sdk/credential-provider-http@npm:^3.972.82": - version: 3.972.82 - resolution: "@aws-sdk/credential-provider-http@npm:3.972.82" +"@aws-sdk/credential-provider-http@npm:^3.972.84": + version: 3.972.84 + resolution: "@aws-sdk/credential-provider-http@npm:3.972.84" dependencies: - "@aws-sdk/core": "npm:^3.979.1" + "@aws-sdk/core": "npm:^3.980.1" "@aws-sdk/types": "npm:^3.975.0" "@smithy/core": "npm:^3.38.0" "@smithy/fetch-http-handler": "npm:^5.8.0" "@smithy/node-http-handler": "npm:^4.14.0" "@smithy/types": "npm:^4.19.0" tslib: "npm:^2.6.2" - checksum: 10c0/8f335e42e9415c1f00b705d0778264d157accae051fb06e85c9d463865443cabadf10fd239d8f69b436d6f29a7fc8e347e264b1a42e0c708f557ac47938e257e + checksum: 10c0/556a952fc2aecb6e39564f1aa9bf35d1aea443eb9a7808c3f4861b0c6403ad5c13ea6067a49db027c9087225faccc78caa5288394e9fa6bf4fdca6ebebec46fb languageName: node linkType: hard -"@aws-sdk/credential-provider-ini@npm:^3.973.25": - version: 3.973.25 - resolution: "@aws-sdk/credential-provider-ini@npm:3.973.25" +"@aws-sdk/credential-provider-ini@npm:^3.973.27": + version: 3.973.27 + resolution: "@aws-sdk/credential-provider-ini@npm:3.973.27" dependencies: - "@aws-sdk/core": "npm:^3.979.1" - "@aws-sdk/credential-provider-env": "npm:^3.972.80" - "@aws-sdk/credential-provider-http": "npm:^3.972.82" - "@aws-sdk/credential-provider-login": "npm:^3.972.87" - "@aws-sdk/credential-provider-process": "npm:^3.972.80" - "@aws-sdk/credential-provider-sso": "npm:^3.973.24" - "@aws-sdk/credential-provider-web-identity": "npm:^3.972.86" - "@aws-sdk/nested-clients": "npm:^3.997.54" + "@aws-sdk/core": "npm:^3.980.1" + "@aws-sdk/credential-provider-env": "npm:^3.972.82" + "@aws-sdk/credential-provider-http": "npm:^3.972.84" + "@aws-sdk/credential-provider-login": "npm:^3.972.89" + "@aws-sdk/credential-provider-process": "npm:^3.972.82" + "@aws-sdk/credential-provider-sso": "npm:^3.973.26" + "@aws-sdk/credential-provider-web-identity": "npm:^3.972.88" + "@aws-sdk/nested-clients": "npm:^3.998.1" "@aws-sdk/types": "npm:^3.975.0" "@smithy/core": "npm:^3.38.0" "@smithy/credential-provider-imds": "npm:^4.5.2" "@smithy/types": "npm:^4.19.0" tslib: "npm:^2.6.2" - checksum: 10c0/9e703efbc4b0542dbcb6d23b914712dc40b8749c74cc1df2b03759220edce941a307c703c084cccdae4df9008d56ea25d3de4e0c2c66bab31bbf16643c68c23e + checksum: 10c0/55c49b6922ca8948964f0eb491ab6a62f78decbdbdfb38c2c0f6f0748674a3c616160d6563d5af367d119d0fab1de73c8b9dd930d5d1bb89b9777c1a67f7f435 languageName: node linkType: hard -"@aws-sdk/credential-provider-login@npm:^3.972.87": - version: 3.972.87 - resolution: "@aws-sdk/credential-provider-login@npm:3.972.87" +"@aws-sdk/credential-provider-login@npm:^3.972.89": + version: 3.972.89 + resolution: "@aws-sdk/credential-provider-login@npm:3.972.89" dependencies: - "@aws-sdk/core": "npm:^3.979.1" - "@aws-sdk/nested-clients": "npm:^3.997.54" + "@aws-sdk/core": "npm:^3.980.1" + "@aws-sdk/nested-clients": "npm:^3.998.1" "@aws-sdk/types": "npm:^3.975.0" "@smithy/core": "npm:^3.38.0" "@smithy/types": "npm:^4.19.0" tslib: "npm:^2.6.2" - checksum: 10c0/7b8bd91d41257b5fde4926e47628eed10e4f40a2234eafc3151fdd3da96810b38d1f054854a537a33c9a7f712906972eb14c5ce0f9a92f154120e46bd9a59028 + checksum: 10c0/1c34644fa39993c71c86bf3da513d0b8f665e8e3be817158d7569108427e2075f8beeab59d69a9581f352e3d72906fa5245e11164e7da19af9f9aa03531c02b5 languageName: node linkType: hard -"@aws-sdk/credential-provider-node@npm:^3.972.90": - version: 3.972.92 - resolution: "@aws-sdk/credential-provider-node@npm:3.972.92" +"@aws-sdk/credential-provider-node@npm:^3.972.93": + version: 3.972.94 + resolution: "@aws-sdk/credential-provider-node@npm:3.972.94" dependencies: - "@aws-sdk/credential-provider-env": "npm:^3.972.80" - "@aws-sdk/credential-provider-http": "npm:^3.972.82" - "@aws-sdk/credential-provider-ini": "npm:^3.973.25" - "@aws-sdk/credential-provider-process": "npm:^3.972.80" - "@aws-sdk/credential-provider-sso": "npm:^3.973.24" - "@aws-sdk/credential-provider-web-identity": "npm:^3.972.86" + "@aws-sdk/credential-provider-env": "npm:^3.972.82" + "@aws-sdk/credential-provider-http": "npm:^3.972.84" + "@aws-sdk/credential-provider-ini": "npm:^3.973.27" + "@aws-sdk/credential-provider-process": "npm:^3.972.82" + "@aws-sdk/credential-provider-sso": "npm:^3.973.26" + "@aws-sdk/credential-provider-web-identity": "npm:^3.972.88" "@aws-sdk/types": "npm:^3.975.0" "@smithy/core": "npm:^3.38.0" "@smithy/credential-provider-imds": "npm:^4.5.2" "@smithy/types": "npm:^4.19.0" tslib: "npm:^2.6.2" - checksum: 10c0/9a144dbe8c16690e53fe54e5d6ce63fad0882756deb5ab360a66c735e91ccfde9ebf4062f7e17205a1ec1c0871e04eaa5838be3e9fe7c47c8db009703c73f32e + checksum: 10c0/3fc97bfa65a69f9c12e2c63ac8a249d0fc9e614e7dfc6dfa56354e8bb0d58c65f8eae1e659ebac200092fb13d8bb13ee8d7149f11e99323a9cadd408d4e5e9b0 languageName: node linkType: hard -"@aws-sdk/credential-provider-process@npm:^3.972.80": - version: 3.972.80 - resolution: "@aws-sdk/credential-provider-process@npm:3.972.80" +"@aws-sdk/credential-provider-process@npm:^3.972.82": + version: 3.972.82 + resolution: "@aws-sdk/credential-provider-process@npm:3.972.82" dependencies: - "@aws-sdk/core": "npm:^3.979.1" + "@aws-sdk/core": "npm:^3.980.1" "@aws-sdk/types": "npm:^3.975.0" "@smithy/core": "npm:^3.38.0" "@smithy/types": "npm:^4.19.0" tslib: "npm:^2.6.2" - checksum: 10c0/113d17b374159505fcc2ff66eab03530c2b3b2eb2026d318734666f5b9950acc56b3fae9b8c1740e6be38e3134bcd676a06a02526a61421250b03b3fe16fe535 + checksum: 10c0/ea05707f0f5c78bb0d0c09fe1b755c4aedf0215e24898fcda9bc4ba24d708fc7ecd745f504aaf03645402f5e5674625fcac57280a44bd37524a0c22cd520ec27 languageName: node linkType: hard -"@aws-sdk/credential-provider-sso@npm:^3.973.24": - version: 3.973.24 - resolution: "@aws-sdk/credential-provider-sso@npm:3.973.24" +"@aws-sdk/credential-provider-sso@npm:^3.973.26": + version: 3.973.26 + resolution: "@aws-sdk/credential-provider-sso@npm:3.973.26" dependencies: - "@aws-sdk/core": "npm:^3.979.1" - "@aws-sdk/nested-clients": "npm:^3.997.54" - "@aws-sdk/token-providers": "npm:3.1161.0" + "@aws-sdk/core": "npm:^3.980.1" + "@aws-sdk/nested-clients": "npm:^3.998.1" + "@aws-sdk/token-providers": "npm:3.1164.0" "@aws-sdk/types": "npm:^3.975.0" "@smithy/core": "npm:^3.38.0" "@smithy/types": "npm:^4.19.0" tslib: "npm:^2.6.2" - checksum: 10c0/635d6d4e3d34264308522352b21433f0c562517a798ae79541b5113de7179549c1d4a6287b894d5160e9b58bafac4be325d60e16ba799f60b2475942df2c4c77 + checksum: 10c0/b67c6088f7a4912c6e57ce96bc2136500b2f57ffa32eeb3d06ccc8cf8789068d9df9a9fcb9bcf819c0168d3046fb84fa154caddcc43037b7164f2f642472758f languageName: node linkType: hard -"@aws-sdk/credential-provider-web-identity@npm:^3.972.86": +"@aws-sdk/credential-provider-web-identity@npm:^3.972.88": + version: 3.972.88 + resolution: "@aws-sdk/credential-provider-web-identity@npm:3.972.88" + dependencies: + "@aws-sdk/core": "npm:^3.980.1" + "@aws-sdk/nested-clients": "npm:^3.998.1" + "@aws-sdk/types": "npm:^3.975.0" + "@smithy/core": "npm:^3.38.0" + "@smithy/types": "npm:^4.19.0" + tslib: "npm:^2.6.2" + checksum: 10c0/198c3955ee469e666c2547e9a61b7fcdab9fde1c163f179f9d1aed8b42b906b8e2d25500e75a5e27951b09b5aa9f88854bf510f092d43d20472d1061c2bb1793 + languageName: node + linkType: hard + +"@aws-sdk/crt-loader@npm:^3.972.85": version: 3.972.86 - resolution: "@aws-sdk/credential-provider-web-identity@npm:3.972.86" + resolution: "@aws-sdk/crt-loader@npm:3.972.86" dependencies: - "@aws-sdk/core": "npm:^3.979.1" - "@aws-sdk/nested-clients": "npm:^3.997.54" - "@aws-sdk/types": "npm:^3.975.0" - "@smithy/core": "npm:^3.38.0" - "@smithy/types": "npm:^4.19.0" - tslib: "npm:^2.6.2" - checksum: 10c0/ccda6e70c7c40b47e63e930844c4631cf2ceb259e088d55cfdf33f1276c803605b068354cf76eefff55cc8c741a7d70a27158197eea4fbdb1eadc95b70a23bc8 - languageName: node - linkType: hard - -"@aws-sdk/crt-loader@npm:^3.972.82": - version: 3.972.84 - resolution: "@aws-sdk/crt-loader@npm:3.972.84" - dependencies: - "@aws-sdk/core": "npm:^3.979.1" + "@aws-sdk/core": "npm:^3.980.1" aws-crt: "npm:^1.31.0" tslib: "npm:^2.6.2" - checksum: 10c0/7fdb62596178d4f3b9ba80cb5baaf19f7387c38787cc84bd9d2f9e2b96530c64ff8b4c20e1a834397c17ec2dbb8e382e090402125195fc514e2dee879805c02e + checksum: 10c0/c7abdd35079a1e3ec371143daed6098ebd4b5d345554c51de8efb6c28ee14ac675e6f409a084096dffdb95b146b172e8c4f709bbface4d4a757878b08b2025c5 languageName: node linkType: hard -"@aws-sdk/lib-storage@npm:^3.1159.0": - version: 3.1159.0 - resolution: "@aws-sdk/lib-storage@npm:3.1159.0" +"@aws-sdk/lib-storage@npm:^3.1162.0": + version: 3.1162.0 + resolution: "@aws-sdk/lib-storage@npm:3.1162.0" dependencies: - "@smithy/core": "npm:^3.37.0" + "@smithy/core": "npm:^3.38.0" "@smithy/types": "npm:^4.19.0" buffer: "npm:5.6.0" events: "npm:3.3.0" stream-browserify: "npm:3.0.0" tslib: "npm:^2.6.2" peerDependencies: - "@aws-sdk/client-s3": ^3.1159.0 - checksum: 10c0/15bf017ad341ffa1fb63d4429005d6f095a181236898d40fcd5654fd7403e0e2101f0541575a44918afe9c736a3b12f58efa4b76f625a00080a28f4afc03905f + "@aws-sdk/client-s3": ^3.1162.0 + checksum: 10c0/e8ad819c6e3fb22dc27f7c9a40f449a31be182caf75561cc198d1343363e23d75845eed84b35e11b9fa6275532185e882275177c5ef90252375d55fc4de89ecc languageName: node linkType: hard -"@aws-sdk/middleware-sdk-s3@npm:^3.972.83": - version: 3.972.85 - resolution: "@aws-sdk/middleware-sdk-s3@npm:3.972.85" +"@aws-sdk/middleware-sdk-s3@npm:^3.972.86": + version: 3.972.87 + resolution: "@aws-sdk/middleware-sdk-s3@npm:3.972.87" dependencies: - "@aws-sdk/core": "npm:^3.979.1" + "@aws-sdk/core": "npm:^3.980.1" "@aws-sdk/signature-v4-multi-region": "npm:^3.996.51" "@aws-sdk/types": "npm:^3.975.0" "@smithy/core": "npm:^3.38.0" "@smithy/types": "npm:^4.19.0" tslib: "npm:^2.6.2" - checksum: 10c0/75048bb8453e6f5f501e05ae9687c4fed00692e7121c41aec06c21589821e9a0fc1f67592f9f74483b5c7254b60da79760859f71a85d8f4ce7cb3aa9b93f5848 + checksum: 10c0/c1d0ee377dce8480aac7b6b0c6a5b9e2188ab1800bffc9cb3a9fe314200c0eee21cb0769e62e559c20ec2e40ce31ac23966c2d199e31ea76d6160179563680dc languageName: node linkType: hard -"@aws-sdk/nested-clients@npm:^3.997.54": - version: 3.997.54 - resolution: "@aws-sdk/nested-clients@npm:3.997.54" +"@aws-sdk/nested-clients@npm:^3.998.1": + version: 3.998.1 + resolution: "@aws-sdk/nested-clients@npm:3.998.1" dependencies: - "@aws-sdk/core": "npm:^3.979.1" + "@aws-sdk/core": "npm:^3.980.1" "@aws-sdk/signature-v4-multi-region": "npm:^3.996.51" "@aws-sdk/types": "npm:^3.975.0" "@smithy/core": "npm:^3.38.0" @@ -278,55 +278,55 @@ __metadata: "@smithy/node-http-handler": "npm:^4.14.0" "@smithy/types": "npm:^4.19.0" tslib: "npm:^2.6.2" - checksum: 10c0/68ae3d1d1b9eef88fdf2dcaf66fe0dabe35086a7b6b57459d10a48a03cc1c5d4d3eb241df94cf3dc765ab636ce21135174439eb767243a3940d021c8c6115eb5 + checksum: 10c0/c0a170e6a1a0aabacb5fbc7d3de89c981cc578a7b24ddd17e32bdbee0690e092f07a14f2d8ca5948927fbc5fd315bcec684f18a431944e2ab6c28168ec06f37d languageName: node linkType: hard -"@aws-sdk/s3-presigned-post@npm:^3.1159.0": - version: 3.1159.0 - resolution: "@aws-sdk/s3-presigned-post@npm:3.1159.0" +"@aws-sdk/s3-presigned-post@npm:^3.1162.0": + version: 3.1162.0 + resolution: "@aws-sdk/s3-presigned-post@npm:3.1162.0" dependencies: - "@aws-sdk/client-s3": "npm:3.1159.0" - "@aws-sdk/core": "npm:^3.978.7" + "@aws-sdk/client-s3": "npm:3.1162.0" + "@aws-sdk/core": "npm:^3.980.0" "@aws-sdk/types": "npm:^3.975.0" - "@smithy/core": "npm:^3.37.0" - "@smithy/signature-v4": "npm:^5.7.4" + "@smithy/core": "npm:^3.38.0" + "@smithy/signature-v4": "npm:^5.7.5" "@smithy/types": "npm:^4.19.0" tslib: "npm:^2.6.2" - checksum: 10c0/3c86b166a1071441d123ded7a7fbf84d806d40fa65fac2368db261c185b15288c54f12f14ed3ff6998233dbdea6bc07502e7556e616feac91d0e26ae549b61ef + checksum: 10c0/93a0e171412c358b1f31aee61fea5de0317b2532e993cfad3c4b98f871e26a7decd212413acf929bfcc5ba76c5ec45b2ea27926d711bc9d569ef0311a9705963 languageName: node linkType: hard -"@aws-sdk/s3-request-presigner@npm:^3.1159.0": - version: 3.1159.0 - resolution: "@aws-sdk/s3-request-presigner@npm:3.1159.0" +"@aws-sdk/s3-request-presigner@npm:^3.1162.0": + version: 3.1162.0 + resolution: "@aws-sdk/s3-request-presigner@npm:3.1162.0" dependencies: - "@aws-sdk/core": "npm:^3.978.7" - "@aws-sdk/signature-v4-multi-region": "npm:^3.996.50" + "@aws-sdk/core": "npm:^3.980.0" + "@aws-sdk/signature-v4-multi-region": "npm:^3.996.51" "@aws-sdk/types": "npm:^3.975.0" - "@smithy/core": "npm:^3.37.0" + "@smithy/core": "npm:^3.38.0" "@smithy/types": "npm:^4.19.0" tslib: "npm:^2.6.2" - checksum: 10c0/9bc80b2c992d4c717bd22038679cf01aa2d880a54780bb9a3dd9de15c878eb59bcdb430b4f4f0ae27f6207aa1f9d8831164cf51ab1cfa7f8008b56afa1b2b90e + checksum: 10c0/54945677b34b266277c0e7f2c005636eb7d1cfd58afa01e12603b0769593b69d14803831470099335ab896697f6abaaa6e5a4ff9615ad5d64859e0c9ca77df43 languageName: node linkType: hard -"@aws-sdk/signature-v4-crt@npm:^3.1159.0": - version: 3.1159.0 - resolution: "@aws-sdk/signature-v4-crt@npm:3.1159.0" +"@aws-sdk/signature-v4-crt@npm:^3.1162.0": + version: 3.1162.0 + resolution: "@aws-sdk/signature-v4-crt@npm:3.1162.0" dependencies: - "@aws-sdk/crt-loader": "npm:^3.972.82" - "@aws-sdk/signature-v4-multi-region": "npm:^3.996.50" + "@aws-sdk/crt-loader": "npm:^3.972.85" + "@aws-sdk/signature-v4-multi-region": "npm:^3.996.51" "@aws-sdk/types": "npm:^3.975.0" - "@smithy/core": "npm:^3.37.0" - "@smithy/signature-v4": "npm:^5.7.4" + "@smithy/core": "npm:^3.38.0" + "@smithy/signature-v4": "npm:^5.7.5" "@smithy/types": "npm:^4.19.0" tslib: "npm:^2.6.2" - checksum: 10c0/21a4f532f9277359da64775a3142686bd9f85026057a14350aa0c519dd03eb50d41e214afc9fc2874c944ed52ba0d64a19221a0c369d390921fbeaa3e6e3f2ae + checksum: 10c0/39afc3574136d0543c83008417ea35a1eb8bdeb589dec4059119fbca2c5697301df5945a6aa4764692985222a0b9f149508002b6219ed2faf2f08670edc37f44 languageName: node linkType: hard -"@aws-sdk/signature-v4-multi-region@npm:^3.996.50, @aws-sdk/signature-v4-multi-region@npm:^3.996.51": +"@aws-sdk/signature-v4-multi-region@npm:^3.996.51": version: 3.996.51 resolution: "@aws-sdk/signature-v4-multi-region@npm:3.996.51" dependencies: @@ -338,17 +338,17 @@ __metadata: languageName: node linkType: hard -"@aws-sdk/token-providers@npm:3.1161.0": - version: 3.1161.0 - resolution: "@aws-sdk/token-providers@npm:3.1161.0" +"@aws-sdk/token-providers@npm:3.1164.0": + version: 3.1164.0 + resolution: "@aws-sdk/token-providers@npm:3.1164.0" dependencies: - "@aws-sdk/core": "npm:^3.979.1" - "@aws-sdk/nested-clients": "npm:^3.997.54" + "@aws-sdk/core": "npm:^3.980.1" + "@aws-sdk/nested-clients": "npm:^3.998.1" "@aws-sdk/types": "npm:^3.975.0" "@smithy/core": "npm:^3.38.0" "@smithy/types": "npm:^4.19.0" tslib: "npm:^2.6.2" - checksum: 10c0/ac80ff7462553f5066bc0c730163b8d9848ac1d5b297822971020642bd7915cca87cb3bf7639242360b09334c2efa83e56824d7dc4db1d4f67ffdb97f5c9bff4 + checksum: 10c0/f0ef3a36a0789533d72a721bfcc98c9cd01d612f456fcfc1751a4b37626022356b4e5f2ca9e97426ea337f4ac086972f1e02fe46d363ee947460ba858ba57818 languageName: node linkType: hard @@ -5752,7 +5752,7 @@ __metadata: languageName: node linkType: hard -"@smithy/core@npm:^3.33.2, @smithy/core@npm:^3.33.3, @smithy/core@npm:^3.37.0, @smithy/core@npm:^3.38.0, @smithy/core@npm:^3.38.1": +"@smithy/core@npm:^3.33.2, @smithy/core@npm:^3.33.3, @smithy/core@npm:^3.38.0, @smithy/core@npm:^3.38.1": version: 3.38.1 resolution: "@smithy/core@npm:3.38.1" dependencies: @@ -5784,7 +5784,7 @@ __metadata: languageName: node linkType: hard -"@smithy/node-http-handler@npm:^4.13.0, @smithy/node-http-handler@npm:^4.14.0": +"@smithy/node-http-handler@npm:^4.14.0": version: 4.14.1 resolution: "@smithy/node-http-handler@npm:4.14.1" dependencies: @@ -5795,7 +5795,7 @@ __metadata: languageName: node linkType: hard -"@smithy/signature-v4@npm:^5.7.4, @smithy/signature-v4@npm:^5.7.5": +"@smithy/signature-v4@npm:^5.7.5": version: 5.7.5 resolution: "@smithy/signature-v4@npm:5.7.5" dependencies: @@ -13996,12 +13996,12 @@ __metadata: version: 0.0.0-use.local resolution: "outline@workspace:." dependencies: - "@aws-sdk/client-s3": "npm:^3.1159.0" - "@aws-sdk/cloudfront-signer": "npm:^3.1157.0" - "@aws-sdk/lib-storage": "npm:^3.1159.0" - "@aws-sdk/s3-presigned-post": "npm:^3.1159.0" - "@aws-sdk/s3-request-presigner": "npm:^3.1159.0" - "@aws-sdk/signature-v4-crt": "npm:^3.1159.0" + "@aws-sdk/client-s3": "npm:^3.1162.0" + "@aws-sdk/cloudfront-signer": "npm:^3.1161.0" + "@aws-sdk/lib-storage": "npm:^3.1162.0" + "@aws-sdk/s3-presigned-post": "npm:^3.1162.0" + "@aws-sdk/s3-request-presigner": "npm:^3.1162.0" + "@aws-sdk/signature-v4-crt": "npm:^3.1162.0" "@benrbray/prosemirror-math": "npm:^0.2.2" "@bull-board/api": "npm:^6.21.3" "@bull-board/koa": "npm:^6.21.3" From 44c0831279da4334e1bdcc70ee4ceb132d94af63 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 12 Nov 2026 16:30:16 +0000 Subject: [PATCH 14/41] chore(deps): bump i18next-http-backend from 4.0.9 to 4.0.10 (#14544) Bumps [i18next-http-backend](https://github.com/i18next/i18next-http-backend) from 4.0.9 to 4.0.10. - [Changelog](https://github.com/i18next/i18next-http-backend/blob/master/CHANGELOG.md) - [Commits](https://github.com/i18next/i18next-http-backend/compare/v4.0.9...v4.0.10) --- updated-dependencies: - dependency-name: i18next-http-backend dependency-version: 4.0.10 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index c8fa30f7e8..269a75e09b 100644 --- a/package.json +++ b/package.json @@ -152,7 +152,7 @@ "https-proxy-agent": "^7.0.6", "i18next": "^22.5.1", "i18next-fs-backend": "^2.6.9", - "i18next-http-backend": "^4.0.9", + "i18next-http-backend": "^4.0.10", "invariant": "^2.2.4", "ioredis": "^5.11.1", "ipaddr.js": "^2.5.0", diff --git a/yarn.lock b/yarn.lock index e763b35fb9..089c6ffb40 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11182,10 +11182,10 @@ __metadata: languageName: node linkType: hard -"i18next-http-backend@npm:^4.0.9": - version: 4.0.9 - resolution: "i18next-http-backend@npm:4.0.9" - checksum: 10c0/5092b498e7d682a473ef60b38a6bfb69843d7c570be3b213696763b84b7c6a85036d5eff3685fb54652fb8b4ca249099d63b6461a9b99573ba5f9ff4496b5566 +"i18next-http-backend@npm:^4.0.10": + version: 4.0.10 + resolution: "i18next-http-backend@npm:4.0.10" + checksum: 10c0/9bf54abbbe2daa7d6f4b3c263625b897801d9ddb2fe203c663c22dfae99e4232f8da11fd75db66732e0ad33509c74edff85d0da5d7a90fa08cd41f80cfeeb566 languageName: node linkType: hard @@ -14150,7 +14150,7 @@ __metadata: husky: "npm:^9.1.7" i18next: "npm:^22.5.1" i18next-fs-backend: "npm:^2.6.9" - i18next-http-backend: "npm:^4.0.9" + i18next-http-backend: "npm:^4.0.10" i18next-parser: "npm:^9.4.0" invariant: "npm:^2.2.4" ioredis: "npm:^5.11.1" From 508491c1cd832bc82a5952fe8e3a46243b50e9f0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 12 Nov 2026 16:30:21 +0000 Subject: [PATCH 15/41] chore(deps): bump nodemailer from 10.1.7 to 10.3.1 (#14545) Bumps [nodemailer](https://github.com/nodemailer/nodemailer) from 10.1.7 to 10.3.1. - [Release notes](https://github.com/nodemailer/nodemailer/releases) - [Changelog](https://github.com/nodemailer/nodemailer/blob/master/CHANGELOG.md) - [Commits](https://github.com/nodemailer/nodemailer/compare/v10.1.7...v10.3.1) --- updated-dependencies: - dependency-name: nodemailer dependency-version: 10.3.1 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 269a75e09b..95d1ad1614 100644 --- a/package.json +++ b/package.json @@ -183,7 +183,7 @@ "mobx-utils": "^6.1.1", "natural-sort": "^1.0.0", "node-fetch": "2.7.0", - "nodemailer": "^10.0.9", + "nodemailer": "^10.3.1", "octokit": "^5.0.5", "outline-icons": "^4.6.0", "pako": "^3.0.2", diff --git a/yarn.lock b/yarn.lock index 089c6ffb40..fbcbd4ef75 100644 --- a/yarn.lock +++ b/yarn.lock @@ -13699,13 +13699,20 @@ __metadata: languageName: node linkType: hard -"nodemailer@npm:10.1.7, nodemailer@npm:^10.0.9": +"nodemailer@npm:10.1.7": version: 10.1.7 resolution: "nodemailer@npm:10.1.7" checksum: 10c0/1bac1f2fb7a60ffa889973cfd1e71da2bdecacd82eb263a612a587a0c06cec43a9a7452fcbd830c39c3a047ef99eb101cb5cf2c6a0a9523624c38f1ae7f01bcb languageName: node linkType: hard +"nodemailer@npm:^10.3.1": + version: 10.3.1 + resolution: "nodemailer@npm:10.3.1" + checksum: 10c0/a960ba9e7cb8f7135b828fb72bcdfd061bb914c6357578ed6613dd5303e8461710a1151210e95a92542461128e900038dd0794fc27bd74b297bd822013cfe8e8 + languageName: node + linkType: hard + "nopt@npm:^7.2.1": version: 7.2.1 resolution: "nopt@npm:7.2.1" @@ -14185,7 +14192,7 @@ __metadata: msw: "npm:^2.15.0" natural-sort: "npm:^1.0.0" node-fetch: "npm:2.7.0" - nodemailer: "npm:^10.0.9" + nodemailer: "npm:^10.3.1" octokit: "npm:^5.0.5" outline-icons: "npm:^4.6.0" oxfmt: "npm:0.73.0" From 4fb4f9d6ad86deb9b2840987d5b635f9dde9d212 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 12 Nov 2026 16:31:40 +0000 Subject: [PATCH 16/41] chore(deps): bump @tanstack/react-virtual from 3.14.23 to 3.14.26 (#14549) Bumps [@tanstack/react-virtual](https://github.com/TanStack/virtual/tree/HEAD/packages/react-virtual) from 3.14.23 to 3.14.26. - [Release notes](https://github.com/TanStack/virtual/releases) - [Changelog](https://github.com/TanStack/virtual/blob/main/packages/react-virtual/CHANGELOG.md) - [Commits](https://github.com/TanStack/virtual/commits/@tanstack/react-virtual@3.14.26/packages/react-virtual) --- updated-dependencies: - dependency-name: "@tanstack/react-virtual" dependency-version: 3.14.26 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 23 +++++++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 95d1ad1614..ba06643f50 100644 --- a/package.json +++ b/package.json @@ -113,7 +113,7 @@ "@simplewebauthn/server": "^13.3.3", "@socket.io/redis-adapter": "^8.3.0", "@tanstack/react-table": "^8.21.3", - "@tanstack/react-virtual": "^3.14.23", + "@tanstack/react-virtual": "^3.14.26", "@types/mailparser": "^3.9.0", "@vitejs/plugin-react": "^6.1.2", "async-sema": "^3.1.1", diff --git a/yarn.lock b/yarn.lock index fbcbd4ef75..64d4b73ae5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6044,7 +6044,19 @@ __metadata: languageName: node linkType: hard -"@tanstack/react-virtual@npm:^3.14.23, @tanstack/react-virtual@npm:^3.14.9": +"@tanstack/react-virtual@npm:^3.14.26": + version: 3.14.26 + resolution: "@tanstack/react-virtual@npm:3.14.26" + dependencies: + "@tanstack/virtual-core": "npm:3.19.11" + peerDependencies: + react: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 + react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 + checksum: 10c0/71291177ac4c4b067a40351d46c69af0d5fc9dfcc6cb328cb87717b29209501a7193e92e75e599273ee423fff6c55c88157bd238684846b0d926dfa73b5d6dac + languageName: node + linkType: hard + +"@tanstack/react-virtual@npm:^3.14.9": version: 3.14.23 resolution: "@tanstack/react-virtual@npm:3.14.23" dependencies: @@ -6063,6 +6075,13 @@ __metadata: languageName: node linkType: hard +"@tanstack/virtual-core@npm:3.19.11": + version: 3.19.11 + resolution: "@tanstack/virtual-core@npm:3.19.11" + checksum: 10c0/61558882fd09f64020104ecd94bacaa2a6ccbb0745247610ede7683d709cf8d134cc3f6d1ee2d22203cb881e531bc4a3bb92e4657c08edf923ab6d5c39a958ec + languageName: node + linkType: hard + "@tanstack/virtual-core@npm:3.19.8": version: 3.19.8 resolution: "@tanstack/virtual-core@npm:3.19.8" @@ -14068,7 +14087,7 @@ __metadata: "@swc/cli": "npm:^0.8.2" "@swc/core": "npm:^1.16.20" "@tanstack/react-table": "npm:^8.21.3" - "@tanstack/react-virtual": "npm:^3.14.23" + "@tanstack/react-virtual": "npm:^3.14.26" "@types/cookie": "npm:0.6.0" "@types/diff": "npm:^5.0.9" "@types/escape-html": "npm:^1.0.4" From e51d1916d7a46fe71b4c17f29b6b33d65a4e9031 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 12 Nov 2026 16:33:28 +0000 Subject: [PATCH 17/41] chore(deps-dev): bump fake-indexeddb from 6.2.6 to 6.2.8 (#14551) Bumps [fake-indexeddb](https://github.com/dumbmatter/fakeIndexedDB) from 6.2.6 to 6.2.8. - [Release notes](https://github.com/dumbmatter/fakeIndexedDB/releases) - [Changelog](https://github.com/dumbmatter/fakeIndexedDB/blob/master/CHANGELOG.md) - [Commits](https://github.com/dumbmatter/fakeIndexedDB/compare/v6.2.6...v6.2.8) --- updated-dependencies: - dependency-name: fake-indexeddb dependency-version: 6.2.8 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index ba06643f50..152ad6756c 100644 --- a/package.json +++ b/package.json @@ -321,7 +321,7 @@ "browserslist-to-esbuild": "^1.2.0", "concurrently": "^8.2.2", "discord-api-types": "^0.38.48", - "fake-indexeddb": "^6.2.6", + "fake-indexeddb": "^6.2.8", "husky": "^9.1.7", "i18next-parser": "^9.4.0", "ioredis-mock": "^8.13.1", diff --git a/yarn.lock b/yarn.lock index 64d4b73ae5..c0796d3fa1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9995,10 +9995,10 @@ __metadata: languageName: node linkType: hard -"fake-indexeddb@npm:^6.2.6": - version: 6.2.6 - resolution: "fake-indexeddb@npm:6.2.6" - checksum: 10c0/d55b3155548f08da1c9d7552314eed30fd1880c1f7643654c8b0c1fdf80591682d9f88e7a5c481113f48b994cb09820d61eee0dd8b966ca4f4497fce0eb748de +"fake-indexeddb@npm:^6.2.8": + version: 6.2.8 + resolution: "fake-indexeddb@npm:6.2.8" + checksum: 10c0/69a85018a3a714e81ae88d9294ab54ed73f83a23dd28b926d41dabf892a939dd029207e8f2dca1238ed5ebde75f1971a7a8ab14f773d5fad396923e117b6e8fe languageName: node linkType: hard @@ -14155,7 +14155,7 @@ __metadata: emoji-regex: "npm:^10.6.0" es-toolkit: "npm:^1.53.0" express-useragent: "npm:^1.0.15" - fake-indexeddb: "npm:^6.2.6" + fake-indexeddb: "npm:^6.2.8" fast-deep-equal: "npm:^3.1.3" fast-myers-diff: "npm:^3.2.0" fetch-retry: "npm:^5.0.6" From e69a2870aec80de56a14eb02f2d3b171f51b67e1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 12 Nov 2026 16:36:25 +0000 Subject: [PATCH 18/41] chore(deps-dev): bump @swc/core from 1.16.20 to 1.16.22 (#14553) Bumps [@swc/core](https://github.com/swc-project/swc/tree/HEAD/packages/core) from 1.16.20 to 1.16.22. - [Release notes](https://github.com/swc-project/swc/releases) - [Changelog](https://github.com/swc-project/swc/blob/main/CHANGELOG.md) - [Commits](https://github.com/swc-project/swc/commits/v1.16.22/packages/core) --- updated-dependencies: - dependency-name: "@swc/core" dependency-version: 1.16.22 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 106 +++++++++++++++++++++++++-------------------------- 2 files changed, 54 insertions(+), 54 deletions(-) diff --git a/package.json b/package.json index 152ad6756c..222a47bee7 100644 --- a/package.json +++ b/package.json @@ -272,7 +272,7 @@ "@faker-js/faker": "^10.6.0", "@relative-ci/agent": "^4.3.1", "@swc/cli": "^0.8.2", - "@swc/core": "^1.16.20", + "@swc/core": "^1.16.22", "@types/cookie": "0.6.0", "@types/diff": "^5.0.9", "@types/escape-html": "^1.0.4", diff --git a/yarn.lock b/yarn.lock index c0796d3fa1..80f5fad2d4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5880,106 +5880,106 @@ __metadata: languageName: node linkType: hard -"@swc/core-darwin-arm64@npm:1.16.20": - version: 1.16.20 - resolution: "@swc/core-darwin-arm64@npm:1.16.20" +"@swc/core-darwin-arm64@npm:1.16.22": + version: 1.16.22 + resolution: "@swc/core-darwin-arm64@npm:1.16.22" conditions: os=darwin & cpu=arm64 languageName: node linkType: hard -"@swc/core-darwin-x64@npm:1.16.20": - version: 1.16.20 - resolution: "@swc/core-darwin-x64@npm:1.16.20" +"@swc/core-darwin-x64@npm:1.16.22": + version: 1.16.22 + resolution: "@swc/core-darwin-x64@npm:1.16.22" conditions: os=darwin & cpu=x64 languageName: node linkType: hard -"@swc/core-linux-arm-gnueabihf@npm:1.16.20": - version: 1.16.20 - resolution: "@swc/core-linux-arm-gnueabihf@npm:1.16.20" +"@swc/core-linux-arm-gnueabihf@npm:1.16.22": + version: 1.16.22 + resolution: "@swc/core-linux-arm-gnueabihf@npm:1.16.22" conditions: os=linux & cpu=arm languageName: node linkType: hard -"@swc/core-linux-arm64-gnu@npm:1.16.20": - version: 1.16.20 - resolution: "@swc/core-linux-arm64-gnu@npm:1.16.20" +"@swc/core-linux-arm64-gnu@npm:1.16.22": + version: 1.16.22 + resolution: "@swc/core-linux-arm64-gnu@npm:1.16.22" conditions: os=linux & cpu=arm64 & libc=glibc languageName: node linkType: hard -"@swc/core-linux-arm64-musl@npm:1.16.20": - version: 1.16.20 - resolution: "@swc/core-linux-arm64-musl@npm:1.16.20" +"@swc/core-linux-arm64-musl@npm:1.16.22": + version: 1.16.22 + resolution: "@swc/core-linux-arm64-musl@npm:1.16.22" conditions: os=linux & cpu=arm64 & libc=musl languageName: node linkType: hard -"@swc/core-linux-ppc64-gnu@npm:1.16.20": - version: 1.16.20 - resolution: "@swc/core-linux-ppc64-gnu@npm:1.16.20" +"@swc/core-linux-ppc64-gnu@npm:1.16.22": + version: 1.16.22 + resolution: "@swc/core-linux-ppc64-gnu@npm:1.16.22" conditions: os=linux & cpu=ppc64 & libc=glibc languageName: node linkType: hard -"@swc/core-linux-s390x-gnu@npm:1.16.20": - version: 1.16.20 - resolution: "@swc/core-linux-s390x-gnu@npm:1.16.20" +"@swc/core-linux-s390x-gnu@npm:1.16.22": + version: 1.16.22 + resolution: "@swc/core-linux-s390x-gnu@npm:1.16.22" conditions: os=linux & cpu=s390x & libc=glibc languageName: node linkType: hard -"@swc/core-linux-x64-gnu@npm:1.16.20": - version: 1.16.20 - resolution: "@swc/core-linux-x64-gnu@npm:1.16.20" +"@swc/core-linux-x64-gnu@npm:1.16.22": + version: 1.16.22 + resolution: "@swc/core-linux-x64-gnu@npm:1.16.22" conditions: os=linux & cpu=x64 & libc=glibc languageName: node linkType: hard -"@swc/core-linux-x64-musl@npm:1.16.20": - version: 1.16.20 - resolution: "@swc/core-linux-x64-musl@npm:1.16.20" +"@swc/core-linux-x64-musl@npm:1.16.22": + version: 1.16.22 + resolution: "@swc/core-linux-x64-musl@npm:1.16.22" conditions: os=linux & cpu=x64 & libc=musl languageName: node linkType: hard -"@swc/core-win32-arm64-msvc@npm:1.16.20": - version: 1.16.20 - resolution: "@swc/core-win32-arm64-msvc@npm:1.16.20" +"@swc/core-win32-arm64-msvc@npm:1.16.22": + version: 1.16.22 + resolution: "@swc/core-win32-arm64-msvc@npm:1.16.22" conditions: os=win32 & cpu=arm64 languageName: node linkType: hard -"@swc/core-win32-ia32-msvc@npm:1.16.20": - version: 1.16.20 - resolution: "@swc/core-win32-ia32-msvc@npm:1.16.20" +"@swc/core-win32-ia32-msvc@npm:1.16.22": + version: 1.16.22 + resolution: "@swc/core-win32-ia32-msvc@npm:1.16.22" conditions: os=win32 & cpu=ia32 languageName: node linkType: hard -"@swc/core-win32-x64-msvc@npm:1.16.20": - version: 1.16.20 - resolution: "@swc/core-win32-x64-msvc@npm:1.16.20" +"@swc/core-win32-x64-msvc@npm:1.16.22": + version: 1.16.22 + resolution: "@swc/core-win32-x64-msvc@npm:1.16.22" conditions: os=win32 & cpu=x64 languageName: node linkType: hard -"@swc/core@npm:^1.16.20": - version: 1.16.20 - resolution: "@swc/core@npm:1.16.20" +"@swc/core@npm:^1.16.22": + version: 1.16.22 + resolution: "@swc/core@npm:1.16.22" dependencies: - "@swc/core-darwin-arm64": "npm:1.16.20" - "@swc/core-darwin-x64": "npm:1.16.20" - "@swc/core-linux-arm-gnueabihf": "npm:1.16.20" - "@swc/core-linux-arm64-gnu": "npm:1.16.20" - "@swc/core-linux-arm64-musl": "npm:1.16.20" - "@swc/core-linux-ppc64-gnu": "npm:1.16.20" - "@swc/core-linux-s390x-gnu": "npm:1.16.20" - "@swc/core-linux-x64-gnu": "npm:1.16.20" - "@swc/core-linux-x64-musl": "npm:1.16.20" - "@swc/core-win32-arm64-msvc": "npm:1.16.20" - "@swc/core-win32-ia32-msvc": "npm:1.16.20" - "@swc/core-win32-x64-msvc": "npm:1.16.20" + "@swc/core-darwin-arm64": "npm:1.16.22" + "@swc/core-darwin-x64": "npm:1.16.22" + "@swc/core-linux-arm-gnueabihf": "npm:1.16.22" + "@swc/core-linux-arm64-gnu": "npm:1.16.22" + "@swc/core-linux-arm64-musl": "npm:1.16.22" + "@swc/core-linux-ppc64-gnu": "npm:1.16.22" + "@swc/core-linux-s390x-gnu": "npm:1.16.22" + "@swc/core-linux-x64-gnu": "npm:1.16.22" + "@swc/core-linux-x64-musl": "npm:1.16.22" + "@swc/core-win32-arm64-msvc": "npm:1.16.22" + "@swc/core-win32-ia32-msvc": "npm:1.16.22" + "@swc/core-win32-x64-msvc": "npm:1.16.22" "@swc/counter": "npm:^0.1.3" "@swc/types": "npm:^0.1.28" peerDependencies: @@ -6012,7 +6012,7 @@ __metadata: peerDependenciesMeta: "@swc/helpers": optional: true - checksum: 10c0/1dae88a3c5c9c78ed463ad6b166943249f8af3705dc523d59545811dd02a738f69f31e399e8ea0e24f64ecb9b94ded57dc2e189618e544f4dbcaa430417cc813 + checksum: 10c0/1fecb6764b2b9ad3b5e5ce14fcc78ba8eb6226ef23e51df28f485f3ca207d9587732a61a4a4ec3c439e3fe80955128d9d4780f1976757b7d05f40d803f106781 languageName: node linkType: hard @@ -14085,7 +14085,7 @@ __metadata: "@simplewebauthn/server": "npm:^13.3.3" "@socket.io/redis-adapter": "npm:^8.3.0" "@swc/cli": "npm:^0.8.2" - "@swc/core": "npm:^1.16.20" + "@swc/core": "npm:^1.16.22" "@tanstack/react-table": "npm:^8.21.3" "@tanstack/react-virtual": "npm:^3.14.26" "@types/cookie": "npm:0.6.0" From 333cac83d4508fabad276f0ac1afa9c87d149b95 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 12 Nov 2026 16:40:01 +0000 Subject: [PATCH 19/41] chore(deps-dev): bump oxlint-tsgolint from 7.0.2005 to 7.0.2006 (#14554) Bumps [oxlint-tsgolint](https://github.com/oxc-project/tsgolint) from 7.0.2005 to 7.0.2006. - [Release notes](https://github.com/oxc-project/tsgolint/releases) - [Commits](https://github.com/oxc-project/tsgolint/compare/v7.0.2005...v7.0.2006) --- updated-dependencies: - dependency-name: oxlint-tsgolint dependency-version: 7.0.2006 dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 58 ++++++++++++++++++++++++++-------------------------- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/package.json b/package.json index 222a47bee7..58f071a40b 100644 --- a/package.json +++ b/package.json @@ -329,7 +329,7 @@ "msw": "^2.15.0", "oxfmt": "0.73.0", "oxlint": "1.90.0", - "oxlint-tsgolint": "7.0.2005", + "oxlint-tsgolint": "7.0.2006", "react-refresh": "^0.19.0", "rimraf": "^6.1.3", "rollup-plugin-webpack-stats": "^3.1.3", diff --git a/yarn.lock b/yarn.lock index 80f5fad2d4..e2dbb132a8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3867,44 +3867,44 @@ __metadata: languageName: node linkType: hard -"@oxlint-tsgolint/darwin-arm64@npm:7.0.2005": - version: 7.0.2005 - resolution: "@oxlint-tsgolint/darwin-arm64@npm:7.0.2005" +"@oxlint-tsgolint/darwin-arm64@npm:7.0.2006": + version: 7.0.2006 + resolution: "@oxlint-tsgolint/darwin-arm64@npm:7.0.2006" conditions: os=darwin & cpu=arm64 languageName: node linkType: hard -"@oxlint-tsgolint/darwin-x64@npm:7.0.2005": - version: 7.0.2005 - resolution: "@oxlint-tsgolint/darwin-x64@npm:7.0.2005" +"@oxlint-tsgolint/darwin-x64@npm:7.0.2006": + version: 7.0.2006 + resolution: "@oxlint-tsgolint/darwin-x64@npm:7.0.2006" conditions: os=darwin & cpu=x64 languageName: node linkType: hard -"@oxlint-tsgolint/linux-arm64@npm:7.0.2005": - version: 7.0.2005 - resolution: "@oxlint-tsgolint/linux-arm64@npm:7.0.2005" +"@oxlint-tsgolint/linux-arm64@npm:7.0.2006": + version: 7.0.2006 + resolution: "@oxlint-tsgolint/linux-arm64@npm:7.0.2006" conditions: os=linux & cpu=arm64 languageName: node linkType: hard -"@oxlint-tsgolint/linux-x64@npm:7.0.2005": - version: 7.0.2005 - resolution: "@oxlint-tsgolint/linux-x64@npm:7.0.2005" +"@oxlint-tsgolint/linux-x64@npm:7.0.2006": + version: 7.0.2006 + resolution: "@oxlint-tsgolint/linux-x64@npm:7.0.2006" conditions: os=linux & cpu=x64 languageName: node linkType: hard -"@oxlint-tsgolint/win32-arm64@npm:7.0.2005": - version: 7.0.2005 - resolution: "@oxlint-tsgolint/win32-arm64@npm:7.0.2005" +"@oxlint-tsgolint/win32-arm64@npm:7.0.2006": + version: 7.0.2006 + resolution: "@oxlint-tsgolint/win32-arm64@npm:7.0.2006" conditions: os=win32 & cpu=arm64 languageName: node linkType: hard -"@oxlint-tsgolint/win32-x64@npm:7.0.2005": - version: 7.0.2005 - resolution: "@oxlint-tsgolint/win32-x64@npm:7.0.2005" +"@oxlint-tsgolint/win32-x64@npm:7.0.2006": + version: 7.0.2006 + resolution: "@oxlint-tsgolint/win32-x64@npm:7.0.2006" conditions: os=win32 & cpu=x64 languageName: node linkType: hard @@ -14216,7 +14216,7 @@ __metadata: outline-icons: "npm:^4.6.0" oxfmt: "npm:0.73.0" oxlint: "npm:1.90.0" - oxlint-tsgolint: "npm:7.0.2005" + oxlint-tsgolint: "npm:7.0.2006" pako: "npm:^3.0.2" passport: "npm:^0.7.0" passport-google-oauth2: "npm:^0.2.0" @@ -14477,16 +14477,16 @@ __metadata: languageName: node linkType: hard -"oxlint-tsgolint@npm:7.0.2005": - version: 7.0.2005 - resolution: "oxlint-tsgolint@npm:7.0.2005" +"oxlint-tsgolint@npm:7.0.2006": + version: 7.0.2006 + resolution: "oxlint-tsgolint@npm:7.0.2006" dependencies: - "@oxlint-tsgolint/darwin-arm64": "npm:7.0.2005" - "@oxlint-tsgolint/darwin-x64": "npm:7.0.2005" - "@oxlint-tsgolint/linux-arm64": "npm:7.0.2005" - "@oxlint-tsgolint/linux-x64": "npm:7.0.2005" - "@oxlint-tsgolint/win32-arm64": "npm:7.0.2005" - "@oxlint-tsgolint/win32-x64": "npm:7.0.2005" + "@oxlint-tsgolint/darwin-arm64": "npm:7.0.2006" + "@oxlint-tsgolint/darwin-x64": "npm:7.0.2006" + "@oxlint-tsgolint/linux-arm64": "npm:7.0.2006" + "@oxlint-tsgolint/linux-x64": "npm:7.0.2006" + "@oxlint-tsgolint/win32-arm64": "npm:7.0.2006" + "@oxlint-tsgolint/win32-x64": "npm:7.0.2006" dependenciesMeta: "@oxlint-tsgolint/darwin-arm64": optional: true @@ -14502,7 +14502,7 @@ __metadata: optional: true bin: tsgolint: ./bin/tsgolint.js - checksum: 10c0/a4e3e61bf3b2307f0ca5e52f102507d9e3e8199a85d7442c47a4492a9e47152766efd455a65a15455d731827df2279089cbeb09347ab9109ac96b65d873582ce + checksum: 10c0/ee532b7ca42bc373b019eaa79bf899e925b86ad74d3fe4368528b950a397991e0ac78562d1a01b6fe5f6083d12588c18a69b9a0410ae240bf8cddf8e2e6c117f languageName: node linkType: hard From fbb78cd2b033943d418e8c28332e3bf254a5de4f Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Thu, 12 Nov 2026 18:45:47 -0500 Subject: [PATCH 20/41] chore: Tighten error reporting payloads (#14568) --- server/logging/sentry.ts | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/server/logging/sentry.ts b/server/logging/sentry.ts index 816b15069e..ec5f3e85bd 100644 --- a/server/logging/sentry.ts +++ b/server/logging/sentry.ts @@ -59,6 +59,10 @@ function loadSentry(dsn: string): typeof SentryNode { environment: env.ENVIRONMENT, release: env.RELEASE, maxBreadcrumbs: 0, + integrations: [ + // Request bodies can contain document content and credentials. + sentry.httpIntegration({ maxIncomingRequestBodySize: "none" }), + ], ignoreErrors: [ // These errors are expected in normal running of the application and // don't need to be reported. @@ -80,6 +84,8 @@ function loadSentry(dsn: string): typeof SentryNode { "Premature close", ], beforeSend(event) { + scrubRequest(event); + try { switch (event.level) { case "warning": @@ -97,3 +103,29 @@ function loadSentry(dsn: string): typeof SentryNode { }); return sentry; } + +const SensitiveHeaderPattern = + /auth|cookie|token|secret|key|session|signature/i; + +/** + * Removes the request body, cookies, and sensitive headers from an event. + * + * @param event the event to scrub in place. + */ +function scrubRequest(event: SentryNode.ErrorEvent) { + const { request } = event; + if (!request) { + return; + } + + delete request.data; + delete request.cookies; + + if (request.headers) { + request.headers = Object.fromEntries( + Object.entries(request.headers).filter( + ([name]) => !SensitiveHeaderPattern.test(name) + ) + ); + } +} From 64be91604f5cf5d376e2cfb3e8045d0755e33c39 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Thu, 12 Nov 2026 18:52:28 -0500 Subject: [PATCH 21/41] Adjust S3 upload policy fields (#14567) --- server/storage/files/S3Storage.test.ts | 21 +++++++++++++++++++++ server/storage/files/S3Storage.ts | 3 ++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/server/storage/files/S3Storage.test.ts b/server/storage/files/S3Storage.test.ts index f024a59645..1b6eacd19a 100644 --- a/server/storage/files/S3Storage.test.ts +++ b/server/storage/files/S3Storage.test.ts @@ -1,10 +1,31 @@ +import { createPresignedPost } from "@aws-sdk/s3-presigned-post"; import { vi } from "vitest"; import { Week, Day } from "@shared/utils/time"; +import { createContext } from "@server/context"; import Logger from "@server/logging/Logger"; import BaseStorage from "./BaseStorage"; import S3Storage from "./S3Storage"; describe("S3Storage", () => { + describe("getPresignedPost", () => { + it("requires an exact Content-Type match", async () => { + const storage = new S3Storage(); + await storage.getPresignedPost( + createContext({}), + "uploads/user/id/photo.png", + "private", + 1000, + "image/png" + ); + + const options = vi.mocked(createPresignedPost).mock.lastCall?.[1]; + expect(options?.Fields?.["Content-Type"]).toBe("image/png"); + expect(options?.Conditions).not.toContainEqual( + expect.arrayContaining(["$Content-Type"]) + ); + }); + }); + describe("getFileStream", () => { afterEach(() => { vi.restoreAllMocks(); diff --git a/server/storage/files/S3Storage.ts b/server/storage/files/S3Storage.ts index cd272e8c20..075cb30a48 100644 --- a/server/storage/files/S3Storage.ts +++ b/server/storage/files/S3Storage.ts @@ -34,10 +34,11 @@ export default class S3Storage extends BaseStorage { Key: key, Conditions: compact([ ["content-length-range", 0, maxUploadSize], - ["starts-with", "$Content-Type", contentType], ["starts-with", "$Cache-Control", ""], ]), + // Each field is signed as an exact-match condition. Fields: { + "Content-Type": contentType, "Content-Disposition": this.getContentDisposition( contentType, AttachmentHelper.parseKey(key).fileName From 7a90ee5887a4c2d923a36e0c2a79ece43aeb605a Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Thu, 12 Nov 2026 18:53:24 -0500 Subject: [PATCH 22/41] fix: Run MCP document updates in a transaction (#14562) --- server/mcp/tools/documents.ts | 45 ++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/server/mcp/tools/documents.ts b/server/mcp/tools/documents.ts index 0e17092dad..1feb16d42a 100644 --- a/server/mcp/tools/documents.ts +++ b/server/mcp/tools/documents.ts @@ -697,21 +697,26 @@ export function documentTools(server: McpServer, scopes: string[]) { const ctx = buildAPIContext(context); const { user } = ctx.state.auth; - const document = await Document.findByPk(input.id, { - userId: user.id, - includeState: true, - rejectOnEmpty: true, - }); + // Returns null when the update persisted nothing. + const updated = await sequelize.transaction(async (transaction) => { + ctx.state.transaction = transaction; + ctx.context.transaction = transaction; - let updated; - - if (input.publish === false) { - authorize(user, "unpublish", document); - - updated = await document.unpublishWithCtx(ctx, { - detach: false, + const document = await Document.findByPk(input.id, { + userId: user.id, + includeState: true, + rejectOnEmpty: true, + transaction, }); - } else { + + if (input.publish === false) { + authorize(user, "unpublish", document); + + return document.unpublishWithCtx(ctx, { + detach: false, + }); + } + authorize(user, "update", document); // The collection is only used when publishing a draft that has @@ -735,7 +740,7 @@ export function documentTools(server: McpServer, scopes: string[]) { const { revisionCount } = document; - updated = await documentUpdater(ctx, { + const result = await documentUpdater(ctx, { document, ...input, collectionId, @@ -746,11 +751,13 @@ export function documentTools(server: McpServer, scopes: string[]) { // the caller would read as a completed write — the request either // carried no recognized fields or values identical to the current // document. - if (updated.revisionCount === revisionCount) { - return error( - "The update resulted in no changes to the document. Ensure at least one field is provided and differs from the current document." - ); - } + return result.revisionCount === revisionCount ? null : result; + }); + + if (!updated) { + return error( + "The update resulted in no changes to the document. Ensure at least one field is provided and differs from the current document." + ); } // A patch only rewrites part of the document, so the resulting From f95761dddf1fbd696bffce215ca3361a4d6af001 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Thu, 12 Nov 2026 18:54:37 -0500 Subject: [PATCH 23/41] perf: Use FOR NO KEY UPDATE where locked rows are only updated (#14559) * perf: Use FOR NO KEY UPDATE where locked rows are only updated Rows that other tables reference by foreign key are now locked with FOR NO KEY UPDATE when the transaction only updates or soft-deletes them, so concurrent inserts that reference the row are not blocked. * test: Collaborative save does not wait for foreign key inserts --- plugins/github/server/GitHubIssueProvider.ts | 6 +-- plugins/gitlab/server/GitLabIssueProvider.ts | 10 ++--- .../server/api/webhookSubscriptions.ts | 4 +- server/collaboration/PersistenceExtension.ts | 2 +- .../documentCollaborativeUpdater.test.ts | 45 +++++++++++++++++++ .../commands/documentCollaborativeUpdater.ts | 2 +- server/commands/documentUpdater.ts | 2 +- server/mcp/tools/comments.ts | 2 +- server/models/Collection.ts | 2 +- server/models/Comment.ts | 2 +- server/models/GroupMembership.ts | 2 +- server/models/IntegrationAuthentication.ts | 2 +- server/models/Reaction.ts | 4 +- server/models/UserMembership.ts | 2 +- .../queues/processors/CollectionsProcessor.ts | 2 +- server/queues/processors/ImportsProcessor.ts | 2 +- server/queues/tasks/APIImportTask.ts | 2 +- server/queues/tasks/CacheIssueSourcesTask.ts | 5 ++- server/queues/tasks/CleanupDemotedUserTask.ts | 2 +- server/queues/tasks/InviteReminderTask.ts | 2 +- .../api/accessRequests/accessRequests.ts | 4 +- .../authenticationProviders.ts | 2 +- server/routes/api/comments/comments.ts | 14 +++--- server/routes/api/documents/documents.ts | 2 +- .../api/fileOperations/fileOperations.ts | 2 +- server/routes/api/groups/groups.ts | 6 +-- server/routes/api/imports/imports.ts | 4 +- .../routes/api/integrations/integrations.ts | 4 +- .../routes/api/notifications/notifications.ts | 2 +- .../routes/api/oauthClients/oauthClients.ts | 6 +-- server/routes/api/revisions/revisions.ts | 2 +- server/routes/api/teams/teams.ts | 2 +- .../api/userMemberships/userMemberships.ts | 2 +- server/routes/api/users/users.ts | 16 +++---- .../oauth/middlewares/registrationAuth.ts | 2 +- 35 files changed, 110 insertions(+), 62 deletions(-) diff --git a/plugins/github/server/GitHubIssueProvider.ts b/plugins/github/server/GitHubIssueProvider.ts index bc1f86d58f..77e4ab253e 100644 --- a/plugins/github/server/GitHubIssueProvider.ts +++ b/plugins/github/server/GitHubIssueProvider.ts @@ -131,7 +131,7 @@ export class GitHubIssueProvider extends BaseIssueProvider { required: true, }, transaction, - lock: transaction.LOCK.UPDATE, + lock: transaction.LOCK.NO_KEY_UPDATE, }); const authentication = integration.authentication; @@ -172,7 +172,7 @@ export class GitHubIssueProvider extends BaseIssueProvider { "settings.github.installation.id": installationId, }, transaction, - lock: transaction.LOCK.UPDATE, + lock: transaction.LOCK.NO_KEY_UPDATE, }); if (!integration) { @@ -241,7 +241,7 @@ export class GitHubIssueProvider extends BaseIssueProvider { "settings.github.installation.id": installationId, }, transaction, - lock: transaction.LOCK.UPDATE, + lock: transaction.LOCK.NO_KEY_UPDATE, }); if (!integration) { diff --git a/plugins/gitlab/server/GitLabIssueProvider.ts b/plugins/gitlab/server/GitLabIssueProvider.ts index f5225eb626..26464c8c01 100644 --- a/plugins/gitlab/server/GitLabIssueProvider.ts +++ b/plugins/gitlab/server/GitLabIssueProvider.ts @@ -142,7 +142,7 @@ export class GitLabIssueProvider extends BaseIssueProvider { const integration = (await Integration.findOne({ where, replacements: { jsonCondition }, - lock: transaction.LOCK.UPDATE, + lock: transaction.LOCK.NO_KEY_UPDATE, transaction, })) as Integration; @@ -213,7 +213,7 @@ export class GitLabIssueProvider extends BaseIssueProvider { const integrations = (await Integration.findAll({ where: whereCondition, replacements, - lock: transaction.LOCK.UPDATE, + lock: transaction.LOCK.NO_KEY_UPDATE, transaction, })) as Integration[]; @@ -257,7 +257,7 @@ export class GitLabIssueProvider extends BaseIssueProvider { replacements: { projectJson: JSON.stringify([{ id: String(payload.project_id) }]), }, - lock: transaction.LOCK.UPDATE, + lock: transaction.LOCK.NO_KEY_UPDATE, transaction, }); @@ -303,7 +303,7 @@ export class GitLabIssueProvider extends BaseIssueProvider { ...(teamId ? { teamId } : {}), "settings.gitlab.installation.account.id": payload.user_id, }, - lock: transaction.LOCK.UPDATE, + lock: transaction.LOCK.NO_KEY_UPDATE, transaction, })) as Integration; @@ -354,7 +354,7 @@ export class GitLabIssueProvider extends BaseIssueProvider { replacements: { projectJson: JSON.stringify([{ id: String(payload.project_id) }]), }, - lock: transaction.LOCK.UPDATE, + lock: transaction.LOCK.NO_KEY_UPDATE, transaction, }); diff --git a/plugins/webhooks/server/api/webhookSubscriptions.ts b/plugins/webhooks/server/api/webhookSubscriptions.ts index 699ecb5637..c97f25e800 100644 --- a/plugins/webhooks/server/api/webhookSubscriptions.ts +++ b/plugins/webhooks/server/api/webhookSubscriptions.ts @@ -121,7 +121,7 @@ router.post( const webhookSubscription = await WebhookSubscription.findByPk(id, { rejectOnEmpty: true, - lock: transaction.LOCK.UPDATE, + lock: transaction.LOCK.NO_KEY_UPDATE, transaction, }); @@ -152,7 +152,7 @@ router.post( const webhookSubscription = await WebhookSubscription.findByPk(id, { rejectOnEmpty: true, - lock: transaction.LOCK.UPDATE, + lock: transaction.LOCK.NO_KEY_UPDATE, transaction, }); diff --git a/server/collaboration/PersistenceExtension.ts b/server/collaboration/PersistenceExtension.ts index 7548e0544c..af8c8a9bd9 100644 --- a/server/collaboration/PersistenceExtension.ts +++ b/server/collaboration/PersistenceExtension.ts @@ -66,7 +66,7 @@ export default class PersistenceExtension implements Extension { const document = await Document.unscoped().findOne({ attributes: ["id", "state", "content", "text"], transaction, - lock: transaction.LOCK.UPDATE, + lock: transaction.LOCK.NO_KEY_UPDATE, rejectOnEmpty: true, where: { id: documentId, diff --git a/server/commands/documentCollaborativeUpdater.test.ts b/server/commands/documentCollaborativeUpdater.test.ts index 154aad7e96..368c40ba35 100644 --- a/server/commands/documentCollaborativeUpdater.test.ts +++ b/server/commands/documentCollaborativeUpdater.test.ts @@ -3,6 +3,7 @@ import { prosemirrorToYDoc } from "y-prosemirror"; import { schema } from "@server/editor"; import { createContext } from "@server/context"; import { Document, Event, Revision } from "@server/models"; +import { sequelize } from "@server/storage/database"; import { buildDocument, buildUser } from "@server/test/factories"; import documentCollaborativeUpdater from "./documentCollaborativeUpdater"; @@ -231,4 +232,48 @@ describe("documentCollaborativeUpdater", () => { ); ydoc.destroy(); }); + + it("does not wait for a concurrent foreign key insert on the document", async () => { + const user = await buildUser(); + const document = await buildDocument({ + teamId: user.teamId, + userId: user.id, + }); + const ydoc = buildYDoc([ + { + type: "paragraph", + content: [{ type: "text", text: "Saved while referenced" }], + }, + ]); + + // A foreign key check on insert takes FOR KEY SHARE on the parent row. + const other = await sequelize.transaction(); + try { + await sequelize.query( + `SELECT id FROM documents WHERE id = :id FOR KEY SHARE`, + { replacements: { id: document.id }, transaction: other } + ); + + const save = documentCollaborativeUpdater({ + documentId: document.id, + ydoc, + collaborators: { ids: [user.id] }, + isLastConnection: true, + clientVersion: null, + }).then(() => "saved"); + const timeout = new Promise((resolve) => + setTimeout(() => resolve("blocked"), 2000) + ); + + await expect(Promise.race([save, timeout])).resolves.toBe("saved"); + } finally { + await other.rollback(); + } + + await document.reload(); + expect(document.content?.content?.[0]?.content?.[0]?.text).toBe( + "Saved while referenced" + ); + ydoc.destroy(); + }); }); diff --git a/server/commands/documentCollaborativeUpdater.ts b/server/commands/documentCollaborativeUpdater.ts index f3122b8929..959b39e466 100644 --- a/server/commands/documentCollaborativeUpdater.ts +++ b/server/commands/documentCollaborativeUpdater.ts @@ -89,7 +89,7 @@ export default async function documentCollaborativeUpdater({ transaction, lock: { of: Document, - level: transaction.LOCK.UPDATE, + level: transaction.LOCK.NO_KEY_UPDATE, }, rejectOnEmpty: true, paranoid: false, diff --git a/server/commands/documentUpdater.ts b/server/commands/documentUpdater.ts index ba176a0590..1fb618a069 100644 --- a/server/commands/documentUpdater.ts +++ b/server/commands/documentUpdater.ts @@ -114,7 +114,7 @@ export default async function documentUpdater( ...(lastRevision !== undefined && { revisionCount: lastRevision }), }, transaction, - lock: transaction.LOCK.UPDATE, + lock: transaction.LOCK.NO_KEY_UPDATE, paranoid: false, }); diff --git a/server/mcp/tools/comments.ts b/server/mcp/tools/comments.ts index 2be394845a..0dea86d6d4 100644 --- a/server/mcp/tools/comments.ts +++ b/server/mcp/tools/comments.ts @@ -219,7 +219,7 @@ export function commentTools(server: McpServer, scopes: string[]) { where: { id: document.id }, attributes: ["id"], transaction, - lock: Transaction.LOCK.UPDATE, + lock: Transaction.LOCK.NO_KEY_UPDATE, }); // Reload under the lock, with the state needed for the mark. diff --git a/server/models/Collection.ts b/server/models/Collection.ts index 6eec80aa63..1625963389 100644 --- a/server/models/Collection.ts +++ b/server/models/Collection.ts @@ -984,7 +984,7 @@ class Collection extends ParanoidModel< attributes: ["id"], where: { id: this.id }, transaction, - lock: transaction.LOCK.UPDATE, + lock: transaction.LOCK.NO_KEY_UPDATE, rejectOnEmpty: true, }); } diff --git a/server/models/Comment.ts b/server/models/Comment.ts index c89b08eddb..4660393819 100644 --- a/server/models/Comment.ts +++ b/server/models/Comment.ts @@ -293,7 +293,7 @@ class Comment extends ParanoidModel< }, transaction: options.transaction, lock: options.transaction - ? { level: options.transaction.LOCK.UPDATE, of: this } + ? { level: options.transaction.LOCK.NO_KEY_UPDATE, of: this } : undefined, }); if (!parent) { diff --git a/server/models/GroupMembership.ts b/server/models/GroupMembership.ts index a519c0b813..df0d176bda 100644 --- a/server/models/GroupMembership.ts +++ b/server/models/GroupMembership.ts @@ -164,7 +164,7 @@ class GroupMembership extends ParanoidModel< return this.findOne({ ...options, where: collectionId ? { groupId, collectionId } : { groupId, documentId }, - lock: options.transaction.LOCK.UPDATE, + lock: options.transaction.LOCK.NO_KEY_UPDATE, }); } diff --git a/server/models/IntegrationAuthentication.ts b/server/models/IntegrationAuthentication.ts index 7b08ab4880..654661c6d1 100644 --- a/server/models/IntegrationAuthentication.ts +++ b/server/models/IntegrationAuthentication.ts @@ -117,7 +117,7 @@ class IntegrationAuthentication extends IdModel< this.constructor as typeof IntegrationAuthentication ).findByPk(this.id, { transaction, - lock: transaction.LOCK.UPDATE, + lock: transaction.LOCK.NO_KEY_UPDATE, rejectOnEmpty: true, }); diff --git a/server/models/Reaction.ts b/server/models/Reaction.ts index 3c0ade42de..f3ede25206 100644 --- a/server/models/Reaction.ts +++ b/server/models/Reaction.ts @@ -61,7 +61,7 @@ class Reaction extends IdModel< const lock = transaction ? { - level: transaction.LOCK.UPDATE, + level: transaction.LOCK.NO_KEY_UPDATE, of: Comment, } : undefined; @@ -112,7 +112,7 @@ class Reaction extends IdModel< const lock = transaction ? { - level: transaction.LOCK.UPDATE, + level: transaction.LOCK.NO_KEY_UPDATE, of: Comment, } : undefined; diff --git a/server/models/UserMembership.ts b/server/models/UserMembership.ts index 0678bfd87e..bde81a2beb 100644 --- a/server/models/UserMembership.ts +++ b/server/models/UserMembership.ts @@ -171,7 +171,7 @@ class UserMembership extends IdModel< return this.findOne({ ...options, where: collectionId ? { userId, collectionId } : { userId, documentId }, - lock: options.transaction.LOCK.UPDATE, + lock: options.transaction.LOCK.NO_KEY_UPDATE, }); } diff --git a/server/queues/processors/CollectionsProcessor.ts b/server/queues/processors/CollectionsProcessor.ts index 869a3a587b..75432730b2 100644 --- a/server/queues/processors/CollectionsProcessor.ts +++ b/server/queues/processors/CollectionsProcessor.ts @@ -22,7 +22,7 @@ export default class CollectionsProcessor extends BaseProcessor { await sequelize.transaction(async (transaction) => { const team = await Team.findByPk(event.teamId, { transaction, - lock: transaction.LOCK.UPDATE, + lock: transaction.LOCK.NO_KEY_UPDATE, }); if (team?.defaultCollectionId === event.collectionId) { diff --git a/server/queues/processors/ImportsProcessor.ts b/server/queues/processors/ImportsProcessor.ts index 285c939c67..cb914e1986 100644 --- a/server/queues/processors/ImportsProcessor.ts +++ b/server/queues/processors/ImportsProcessor.ts @@ -88,7 +88,7 @@ export default abstract class ImportsProcessor< rejectOnEmpty: true, paranoid: false, transaction, - lock: transaction.LOCK.UPDATE, + lock: transaction.LOCK.NO_KEY_UPDATE, }); if ( diff --git a/server/queues/tasks/APIImportTask.ts b/server/queues/tasks/APIImportTask.ts index 2e63fd460c..d289050f6c 100644 --- a/server/queues/tasks/APIImportTask.ts +++ b/server/queues/tasks/APIImportTask.ts @@ -150,7 +150,7 @@ export default abstract class APIImportTask< }, ], transaction, - lock: Transaction.LOCK.UPDATE, + lock: Transaction.LOCK.NO_KEY_UPDATE, } ); diff --git a/server/queues/tasks/CacheIssueSourcesTask.ts b/server/queues/tasks/CacheIssueSourcesTask.ts index bbd05375f1..90faad5d05 100644 --- a/server/queues/tasks/CacheIssueSourcesTask.ts +++ b/server/queues/tasks/CacheIssueSourcesTask.ts @@ -27,7 +27,10 @@ export default class CacheIssueSourcesTask extends BaseTask { const sources = await plugin.value.fetchSources(integration); await sequelize.transaction(async (transaction) => { - await integration.reload({ transaction, lock: transaction.LOCK.UPDATE }); + await integration.reload({ + transaction, + lock: transaction.LOCK.NO_KEY_UPDATE, + }); integration.issueSources = sources; await integration.save({ transaction }); }); diff --git a/server/queues/tasks/CleanupDemotedUserTask.ts b/server/queues/tasks/CleanupDemotedUserTask.ts index cb45ae25f8..be91d02026 100644 --- a/server/queues/tasks/CleanupDemotedUserTask.ts +++ b/server/queues/tasks/CleanupDemotedUserTask.ts @@ -32,7 +32,7 @@ export default class CleanupDemotedUserTask extends BaseTask { enabled: true, }, transaction, - lock: transaction.LOCK.UPDATE, + lock: transaction.LOCK.NO_KEY_UPDATE, }); await Promise.all( subscriptions.map((subscription) => diff --git a/server/queues/tasks/InviteReminderTask.ts b/server/queues/tasks/InviteReminderTask.ts index 4a84e95aae..aea9d454e9 100644 --- a/server/queues/tasks/InviteReminderTask.ts +++ b/server/queues/tasks/InviteReminderTask.ts @@ -24,7 +24,7 @@ export default class InviteReminderTask extends CronTask { await sequelize.transaction(async (transaction) => { const user = await User.scope("withTeam").findByPk(userId, { lock: { - level: transaction.LOCK.UPDATE, + level: transaction.LOCK.NO_KEY_UPDATE, of: User, }, transaction, diff --git a/server/routes/api/accessRequests/accessRequests.ts b/server/routes/api/accessRequests/accessRequests.ts index 4cac8af61a..3ab19d5d6b 100644 --- a/server/routes/api/accessRequests/accessRequests.ts +++ b/server/routes/api/accessRequests/accessRequests.ts @@ -99,7 +99,7 @@ router.post( const accessRequest = await AccessRequest.findByPk(id, { rejectOnEmpty: true, transaction, - lock: { level: transaction.LOCK.UPDATE, of: AccessRequest }, + lock: { level: transaction.LOCK.NO_KEY_UPDATE, of: AccessRequest }, }); const document = await Document.findByPk(accessRequest.documentId, { @@ -151,7 +151,7 @@ router.post( const accessRequest = await AccessRequest.findByPk(id, { rejectOnEmpty: true, transaction, - lock: { level: transaction.LOCK.UPDATE, of: AccessRequest }, + lock: { level: transaction.LOCK.NO_KEY_UPDATE, of: AccessRequest }, }); const document = await Document.findByPk(accessRequest.documentId, { diff --git a/server/routes/api/authenticationProviders/authenticationProviders.ts b/server/routes/api/authenticationProviders/authenticationProviders.ts index 63d0bcca83..34580ecff0 100644 --- a/server/routes/api/authenticationProviders/authenticationProviders.ts +++ b/server/routes/api/authenticationProviders/authenticationProviders.ts @@ -48,7 +48,7 @@ router.post( const authenticationProvider = await AuthenticationProvider.findByPk(id, { transaction, - lock: transaction.LOCK.UPDATE, + lock: transaction.LOCK.NO_KEY_UPDATE, }); authorize(user, "update", authenticationProvider); diff --git a/server/routes/api/comments/comments.ts b/server/routes/api/comments/comments.ts index 6cf475741f..84041db547 100644 --- a/server/routes/api/comments/comments.ts +++ b/server/routes/api/comments/comments.ts @@ -51,7 +51,7 @@ router.post( where: { id: documentId }, attributes: ["id"], transaction, - lock: transaction.LOCK.UPDATE, + lock: transaction.LOCK.NO_KEY_UPDATE, }); } @@ -230,7 +230,7 @@ router.post( transaction, rejectOnEmpty: true, lock: { - level: transaction.LOCK.UPDATE, + level: transaction.LOCK.NO_KEY_UPDATE, of: Comment, }, }); @@ -306,7 +306,7 @@ router.post( transaction, rejectOnEmpty: true, lock: { - level: transaction.LOCK.UPDATE, + level: transaction.LOCK.NO_KEY_UPDATE, of: Comment, }, }); @@ -340,7 +340,7 @@ router.post( transaction, rejectOnEmpty: true, lock: { - level: transaction.LOCK.UPDATE, + level: transaction.LOCK.NO_KEY_UPDATE, of: Comment, }, }); @@ -376,7 +376,7 @@ router.post( transaction, rejectOnEmpty: true, lock: { - level: transaction.LOCK.UPDATE, + level: transaction.LOCK.NO_KEY_UPDATE, of: Comment, }, }); @@ -413,7 +413,7 @@ router.post( transaction, rejectOnEmpty: true, lock: { - level: transaction.LOCK.UPDATE, + level: transaction.LOCK.NO_KEY_UPDATE, of: Comment, }, }); @@ -469,7 +469,7 @@ router.post( transaction, rejectOnEmpty: true, lock: { - level: transaction.LOCK.UPDATE, + level: transaction.LOCK.NO_KEY_UPDATE, of: Comment, }, }); diff --git a/server/routes/api/documents/documents.ts b/server/routes/api/documents/documents.ts index 824ac889fd..d4a17919f3 100644 --- a/server/routes/api/documents/documents.ts +++ b/server/routes/api/documents/documents.ts @@ -2118,7 +2118,7 @@ router.post( groupId, }, transaction, - lock: transaction.LOCK.UPDATE, + lock: transaction.LOCK.NO_KEY_UPDATE, rejectOnEmpty: true, }); diff --git a/server/routes/api/fileOperations/fileOperations.ts b/server/routes/api/fileOperations/fileOperations.ts index 60901391fb..a710c609c6 100644 --- a/server/routes/api/fileOperations/fileOperations.ts +++ b/server/routes/api/fileOperations/fileOperations.ts @@ -136,7 +136,7 @@ router.post( const fileOperation = await FileOperation.unscoped().findByPk(id, { rejectOnEmpty: true, transaction, - lock: transaction.LOCK.UPDATE, + lock: transaction.LOCK.NO_KEY_UPDATE, }); authorize(user, "delete", fileOperation); diff --git a/server/routes/api/groups/groups.ts b/server/routes/api/groups/groups.ts index 537bcfa89f..58ade1b0ba 100644 --- a/server/routes/api/groups/groups.ts +++ b/server/routes/api/groups/groups.ts @@ -286,7 +286,7 @@ router.post( externalGroupInclude, ], lock: { - level: transaction.LOCK.UPDATE, + level: transaction.LOCK.NO_KEY_UPDATE, of: Group, }, }); @@ -334,7 +334,7 @@ router.post( transaction, include: [externalGroupInclude], lock: { - level: transaction.LOCK.UPDATE, + level: transaction.LOCK.NO_KEY_UPDATE, of: Group, }, }); @@ -380,7 +380,7 @@ router.post( const groups = await Group.findAll({ where: { id: groupIds, teamId: user.teamId }, transaction, - lock: transaction.LOCK.UPDATE, + lock: transaction.LOCK.NO_KEY_UPDATE, }); // Each group is destroyed individually so that a delete event is diff --git a/server/routes/api/imports/imports.ts b/server/routes/api/imports/imports.ts index 809c5e8bbb..8ae9f774e9 100644 --- a/server/routes/api/imports/imports.ts +++ b/server/routes/api/imports/imports.ts @@ -209,7 +209,7 @@ router.post( const importModel = await Import.findByPk(id, { rejectOnEmpty: true, transaction, - lock: transaction.LOCK.UPDATE, + lock: transaction.LOCK.NO_KEY_UPDATE, }); authorize(user, "delete", importModel); @@ -234,7 +234,7 @@ router.post( let importModel = await Import.findByPk(id, { rejectOnEmpty: true, transaction, - lock: transaction.LOCK.UPDATE, + lock: transaction.LOCK.NO_KEY_UPDATE, }); authorize(user, "cancel", importModel); diff --git a/server/routes/api/integrations/integrations.ts b/server/routes/api/integrations/integrations.ts index c528327807..b31b0038a7 100644 --- a/server/routes/api/integrations/integrations.ts +++ b/server/routes/api/integrations/integrations.ts @@ -130,7 +130,7 @@ router.post( const integration = await Integration.findByPk(id, { transaction, - lock: transaction.LOCK.UPDATE, + lock: transaction.LOCK.NO_KEY_UPDATE, }); authorize(user, "update", integration); @@ -166,7 +166,7 @@ router.post( const integration = await Integration.findByPk(id, { rejectOnEmpty: true, transaction, - lock: transaction.LOCK.UPDATE, + lock: transaction.LOCK.NO_KEY_UPDATE, }); authorize(user, "delete", integration); diff --git a/server/routes/api/notifications/notifications.ts b/server/routes/api/notifications/notifications.ts index 811a1d1d1b..cbc7b2ae87 100644 --- a/server/routes/api/notifications/notifications.ts +++ b/server/routes/api/notifications/notifications.ts @@ -49,7 +49,7 @@ const unsubscribe = async (ctx: APIContext) => { const user = await User.scope("withTeam").findByPk(userId, { rejectOnEmpty: true, - lock: transaction.LOCK.UPDATE, + lock: transaction.LOCK.NO_KEY_UPDATE, transaction, }); diff --git a/server/routes/api/oauthClients/oauthClients.ts b/server/routes/api/oauthClients/oauthClients.ts index 0afd6c400f..1e78cf8aac 100644 --- a/server/routes/api/oauthClients/oauthClients.ts +++ b/server/routes/api/oauthClients/oauthClients.ts @@ -154,7 +154,7 @@ router.post( const oauthClient = await OAuthClient.findByPk(id, { transaction, - lock: transaction.LOCK.UPDATE, + lock: transaction.LOCK.NO_KEY_UPDATE, rejectOnEmpty: true, }); authorize(user, "update", oauthClient); @@ -183,7 +183,7 @@ router.post( const oauthClient = await OAuthClient.findByPk(id, { transaction, - lock: transaction.LOCK.UPDATE, + lock: transaction.LOCK.NO_KEY_UPDATE, rejectOnEmpty: true, }); authorize(user, "update", oauthClient); @@ -212,7 +212,7 @@ router.post( const oauthClient = await OAuthClient.findByPk(id, { transaction, - lock: transaction.LOCK.UPDATE, + lock: transaction.LOCK.NO_KEY_UPDATE, rejectOnEmpty: true, }); authorize(user, "delete", oauthClient); diff --git a/server/routes/api/revisions/revisions.ts b/server/routes/api/revisions/revisions.ts index 2db08d82dd..86b6912bb6 100644 --- a/server/routes/api/revisions/revisions.ts +++ b/server/routes/api/revisions/revisions.ts @@ -111,7 +111,7 @@ router.post( transaction, lock: { of: Revision, - level: transaction.LOCK.UPDATE, + level: transaction.LOCK.NO_KEY_UPDATE, }, }); const document = await Document.findByPk(revision.documentId, { diff --git a/server/routes/api/teams/teams.ts b/server/routes/api/teams/teams.ts index 2d2e7061c0..6746a617ff 100644 --- a/server/routes/api/teams/teams.ts +++ b/server/routes/api/teams/teams.ts @@ -24,7 +24,7 @@ const handleTeamUpdate = async (ctx: APIContext) => { const { user } = ctx.state.auth; const team = await Team.findByPk(user.teamId, { include: [{ model: TeamDomain, separate: true }], - lock: transaction.LOCK.UPDATE, + lock: transaction.LOCK.NO_KEY_UPDATE, transaction, }); authorize(user, "update", team); diff --git a/server/routes/api/userMemberships/userMemberships.ts b/server/routes/api/userMemberships/userMemberships.ts index bcbe96b939..9127ea0e64 100644 --- a/server/routes/api/userMemberships/userMemberships.ts +++ b/server/routes/api/userMemberships/userMemberships.ts @@ -97,7 +97,7 @@ router.post( const membership = await UserMembership.scope("withUser").findByPk(id, { transaction, lock: { - level: transaction.LOCK.UPDATE, + level: transaction.LOCK.NO_KEY_UPDATE, of: UserMembership, }, rejectOnEmpty: true, diff --git a/server/routes/api/users/users.ts b/server/routes/api/users/users.ts index 40129ca80d..ec5b1d8300 100644 --- a/server/routes/api/users/users.ts +++ b/server/routes/api/users/users.ts @@ -237,7 +237,7 @@ router.get( try { const res = await getDetailsForEmailUpdateToken(code as string, { transaction, - lock: transaction.LOCK.UPDATE, + lock: transaction.LOCK.NO_KEY_UPDATE, }); user = res.user; email = res.email; @@ -281,7 +281,7 @@ router.post( user = await User.findByPk(id, { rejectOnEmpty: true, transaction, - lock: transaction.LOCK.UPDATE, + lock: transaction.LOCK.NO_KEY_UPDATE, }); } authorize(actor, "update", user); @@ -382,13 +382,13 @@ async function updateRole(ctx: APIContext) { const user = await User.findByPk(userId, { transaction, - lock: transaction.LOCK.UPDATE, + lock: transaction.LOCK.NO_KEY_UPDATE, }); authorize(actor, "update", user); await Team.findByPk(user.teamId, { transaction, - lock: transaction.LOCK.UPDATE, + lock: transaction.LOCK.NO_KEY_UPDATE, }); let name; @@ -435,7 +435,7 @@ router.post( const user = await User.findByPk(userId, { rejectOnEmpty: true, transaction, - lock: transaction.LOCK.UPDATE, + lock: transaction.LOCK.NO_KEY_UPDATE, }); authorize(actor, "suspend", user); @@ -472,7 +472,7 @@ router.post( const user = await User.findByPk(userId, { rejectOnEmpty: true, transaction, - lock: transaction.LOCK.UPDATE, + lock: transaction.LOCK.NO_KEY_UPDATE, }); authorize(actor, "activate", user); @@ -539,7 +539,7 @@ router.post( const actor = auth.user; const user = await User.findByPk(id, { - lock: transaction.LOCK.UPDATE, + lock: transaction.LOCK.NO_KEY_UPDATE, transaction, }); authorize(actor, "resendInvite", user); @@ -618,7 +618,7 @@ router.post( user = await User.findByPk(id, { rejectOnEmpty: true, transaction, - lock: transaction.LOCK.UPDATE, + lock: transaction.LOCK.NO_KEY_UPDATE, }); } else { user = actor; diff --git a/server/routes/oauth/middlewares/registrationAuth.ts b/server/routes/oauth/middlewares/registrationAuth.ts index d64f30d5c9..3a766e4bfc 100644 --- a/server/routes/oauth/middlewares/registrationAuth.ts +++ b/server/routes/oauth/middlewares/registrationAuth.ts @@ -23,7 +23,7 @@ export default function registrationAuth() { const client = await OAuthClient.findByRegistrationAccessToken(token, { transaction: ctx.state.transaction, - lock: ctx.state.transaction?.LOCK.UPDATE, + lock: ctx.state.transaction?.LOCK.NO_KEY_UPDATE, }); if (!client) { throw AuthenticationError("Invalid registration access token"); From 72a72dc735f4f1a7b7e9c8be5d98af60a16a1e5c Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Thu, 12 Nov 2026 18:55:35 -0500 Subject: [PATCH 24/41] fix: Popularity score update blocks inserts that reference documents (#14558) * fix: Use FOR NO KEY UPDATE when locking documents for popularity scores * test: Cover popularity update with a key share lock held --- ...UpdateDocumentsPopularityScoreTask.test.ts | 30 +++++++++++++++++++ .../UpdateDocumentsPopularityScoreTask.ts | 3 +- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/server/queues/tasks/UpdateDocumentsPopularityScoreTask.test.ts b/server/queues/tasks/UpdateDocumentsPopularityScoreTask.test.ts index 31cac930ad..66380ca518 100644 --- a/server/queues/tasks/UpdateDocumentsPopularityScoreTask.test.ts +++ b/server/queues/tasks/UpdateDocumentsPopularityScoreTask.test.ts @@ -347,4 +347,34 @@ describe("UpdateDocumentsPopularityScoreTask", () => { expect(Number(updatedDraft?.popularityScore)).toEqual(0); expect(Number(updatedDeleted?.popularityScore)).toEqual(0); }); + + it("should update documents that hold a key share lock", async () => { + const team = await buildTeam(); + const document = await buildDocument({ + teamId: team.id, + publishedAt: new Date(), + }); + await DocumentInsight.create({ + documentId: document.id, + teamId: team.id, + date: dayStr(new Date()), + revisionCount: 1, + }); + + // Inserts into tables that reference documents take this lock. + const transaction = await sequelize.transaction(); + try { + await sequelize.query( + `SELECT id FROM documents WHERE id = :id FOR KEY SHARE`, + { replacements: { id: document.id }, transaction } + ); + + await task.perform(props); + } finally { + await transaction.rollback(); + } + + const updated = await Document.findByPk(document.id); + expect(Number(updated?.popularityScore)).toBeGreaterThan(0); + }); }); diff --git a/server/queues/tasks/UpdateDocumentsPopularityScoreTask.ts b/server/queues/tasks/UpdateDocumentsPopularityScoreTask.ts index d4f7aef286..fee8093e9e 100644 --- a/server/queues/tasks/UpdateDocumentsPopularityScoreTask.ts +++ b/server/queues/tasks/UpdateDocumentsPopularityScoreTask.ts @@ -418,10 +418,11 @@ export default class UpdateDocumentsPopularityScoreTask extends CronTask { // Update documents in a single batch to improve performance and reduce round-trips. // We use unnest with multiple arrays to ensure the IDs and scores stay aligned. // We also use SKIP LOCKED to avoid waiting on locked rows from other concurrent tasks. + // NO KEY UPDATE does not block the KEY SHARE locks taken by inserts that reference documents. await sequelize.query( ` WITH lockable AS ( - SELECT id FROM documents WHERE id = ANY(ARRAY[:ids]::uuid[]) FOR UPDATE SKIP LOCKED + SELECT id FROM documents WHERE id = ANY(ARRAY[:ids]::uuid[]) FOR NO KEY UPDATE SKIP LOCKED ) UPDATE documents AS d SET "popularityScore" = s.score From d066c98bdec1563da6caaf80810feab623d7bc71 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Thu, 12 Nov 2026 18:57:50 -0500 Subject: [PATCH 25/41] fix: Remove vestigial done flag from document updates (#14561) Creating a revision immediately when the user clicks Done raced the collaboration server's save debounce, producing a stale revision followed by a second one and duplicate Slack notifications. --- app/models/Document.ts | 1 - app/scenes/Document/hooks/useDocumentSave.ts | 5 ++++- server/commands/documentUpdater.ts | 23 +++----------------- server/routes/api/documents/schema.ts | 3 --- 4 files changed, 7 insertions(+), 25 deletions(-) diff --git a/app/models/Document.ts b/app/models/Document.ts index f15088771b..b6697be3a3 100644 --- a/app/models/Document.ts +++ b/app/models/Document.ts @@ -41,7 +41,6 @@ import type { Searchable } from "./interfaces/Searchable"; type SaveOptions = JSONObject & { publish?: boolean; - done?: boolean; autosave?: boolean; }; diff --git a/app/scenes/Document/hooks/useDocumentSave.ts b/app/scenes/Document/hooks/useDocumentSave.ts index 5181d4047c..ba30a17bf6 100644 --- a/app/scenes/Document/hooks/useDocumentSave.ts +++ b/app/scenes/Document/hooks/useDocumentSave.ts @@ -165,7 +165,10 @@ export function useDocumentSave({ setIsPublishing(!!options.publish); try { - const savedDocument = await document.save(undefined, options); + const savedDocument = await document.save(undefined, { + publish: options.publish, + autosave: options.autosave, + }); isEditorDirtyRef.current = false; setIsEditorDirty(false); diff --git a/server/commands/documentUpdater.ts b/server/commands/documentUpdater.ts index 1fb618a069..0436b0dea0 100644 --- a/server/commands/documentUpdater.ts +++ b/server/commands/documentUpdater.ts @@ -1,6 +1,6 @@ import type { DocumentPreferences, TextEditMode } from "@shared/types"; import { DocumentConflictError, ValidationError } from "@server/errors"; -import { Event, Document } from "@server/models"; +import { Document } from "@server/models"; import { DocumentHelper } from "@server/models/helpers/DocumentHelper"; import { TextHelper } from "@server/models/helpers/TextHelper"; import type { APIContext } from "@server/types"; @@ -16,8 +16,6 @@ type Props = { color?: string | null; /** The new text content */ text?: string; - /** Whether the editing session is complete */ - done?: boolean; /** The version of the client editor that was used */ editorVersion?: string; /** The ID of the template that was used */ @@ -68,7 +66,6 @@ export default async function documentUpdater( publish, collectionId, deprecatedReason, - done, }: Props ): Promise { const { user } = ctx.state.auth; @@ -138,31 +135,17 @@ export default async function documentUpdater( } const changed = document.changed(); - const eventData = done !== undefined ? { done } : undefined; const { collection } = document; - const event = { - name: "documents.update", - documentId: document.id, - collectionId: cId, - data: eventData, - }; - if (publish && cId) { if (!document.collectionId) { document.collectionId = cId; } - await document.publish(ctx, { collectionId: cId, data: eventData }); + await document.publish(ctx, { collectionId: cId }); } else if (changed) { document.lastModifiedById = user.id; document.updatedBy = user; - await document.saveWithCtx(ctx, undefined, { data: eventData }); - } else if (done) { - await Event.schedule({ - ...event, - actorId: user.id, - teamId: document.teamId, - }); + await document.saveWithCtx(ctx); } // Publishing can move the document to another collection, and the save diff --git a/server/routes/api/documents/schema.ts b/server/routes/api/documents/schema.ts index 4948645c95..149aa5415c 100644 --- a/server/routes/api/documents/schema.ts +++ b/server/routes/api/documents/schema.ts @@ -450,9 +450,6 @@ export const DocumentsUpdateSchema = BaseSchema.extend({ /** @deprecated Version of the API to be used, remove in a few releases */ apiVersion: z.number().optional(), - - /** Whether the editing session is complete */ - done: z.boolean().optional(), }), }) .refine( From e262f3bd1720d448689d6eaa189ec4bf9bb20314 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Thu, 12 Nov 2026 18:59:43 -0500 Subject: [PATCH 26/41] perf: Add partial createdAt index for stuck import task scan (#14565) --- ...-pending-created-at-index-to-import-tasks.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 server/migrations/20261112120000-add-pending-created-at-index-to-import-tasks.js diff --git a/server/migrations/20261112120000-add-pending-created-at-index-to-import-tasks.js b/server/migrations/20261112120000-add-pending-created-at-index-to-import-tasks.js new file mode 100644 index 0000000000..a3241f42fd --- /dev/null +++ b/server/migrations/20261112120000-add-pending-created-at-index-to-import-tasks.js @@ -0,0 +1,17 @@ +"use strict"; + +/** @type {import('sequelize-cli').Migration} */ +module.exports = { + async up(queryInterface) { + // Covers the scan for stuck import tasks, which pages by createdAt. + await queryInterface.sequelize.query( + `CREATE INDEX CONCURRENTLY IF NOT EXISTS "import_tasks_pending_created_at" ON "import_tasks" ("createdAt", "id") WHERE "state" IN ('created', 'in_progress');` + ); + }, + + async down(queryInterface) { + await queryInterface.sequelize.query( + 'DROP INDEX CONCURRENTLY IF EXISTS "import_tasks_pending_created_at";' + ); + }, +}; From ded311873900d039d46c93a6d640c4904c1fdef7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 12 Nov 2026 19:04:18 -0500 Subject: [PATCH 27/41] chore(deps): bump react-colorful from 5.8.0 to 5.8.1 (#14547) --- package.json | 2 +- yarn.lock | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 58f071a40b..36bfe75180 100644 --- a/package.json +++ b/package.json @@ -219,7 +219,7 @@ "rate-limiter-flexible": "^11.2.3", "react": "^19.3.0", "react-avatar-editor": "^15.1.0", - "react-colorful": "^5.8.0", + "react-colorful": "^5.8.1", "react-day-picker": "^8.10.2", "react-dom": "^19.3.0", "react-dropzone": "^20.1.4", diff --git a/yarn.lock b/yarn.lock index e2dbb132a8..6be63eb44e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -14250,7 +14250,7 @@ __metadata: rate-limiter-flexible: "npm:^11.2.3" react: "npm:^19.3.0" react-avatar-editor: "npm:^15.1.0" - react-colorful: "npm:^5.8.0" + react-colorful: "npm:^5.8.1" react-day-picker: "npm:^8.10.2" react-dom: "npm:^19.3.0" react-dropzone: "npm:^20.1.4" @@ -15649,13 +15649,13 @@ __metadata: languageName: node linkType: hard -"react-colorful@npm:^5.8.0": - version: 5.8.0 - resolution: "react-colorful@npm:5.8.0" +"react-colorful@npm:^5.8.1": + version: 5.8.1 + resolution: "react-colorful@npm:5.8.1" peerDependencies: react: ">=16.8.0" react-dom: ">=16.8.0" - checksum: 10c0/852ee03ad7751d748e2232ad3bd089de6620de6a06582ee26177377802104b259bf5630d205e875dba4406d601d0e00ddd0912bb0d763da2a053b51c7c57b3a4 + checksum: 10c0/cd1705cdb218f9f43d376f36306968aa304e0d8018dcff198c798c2c56bf4873ea918580a57a0cceaab62ba7621663234ffad35f3d4ebd9198e65f926f9ec8fe languageName: node linkType: hard From f04a300bed255884ac255e1cba0c9c03fee8f772 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Thu, 12 Nov 2026 19:05:44 -0500 Subject: [PATCH 28/41] perf: Add index for inherited group permission lookups (#14560) --- ...0000-add-group-permissions-sourced-index.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 server/migrations/20261112160000-add-group-permissions-sourced-index.js diff --git a/server/migrations/20261112160000-add-group-permissions-sourced-index.js b/server/migrations/20261112160000-add-group-permissions-sourced-index.js new file mode 100644 index 0000000000..82b8c6d201 --- /dev/null +++ b/server/migrations/20261112160000-add-group-permissions-sourced-index.js @@ -0,0 +1,18 @@ +"use strict"; + +/** @type {import('sequelize-cli').Migration} */ +module.exports = { + async up(queryInterface) { + // Covers lookups of inherited group permissions by document and group. + // Partial so it only indexes rows that are sourced from a parent. + await queryInterface.sequelize.query( + 'CREATE INDEX CONCURRENTLY IF NOT EXISTS "group_permissions_document_id_group_id_sourced" ON "group_permissions" ("documentId", "groupId") WHERE "sourceId" IS NOT NULL AND "deletedAt" IS NULL;' + ); + }, + + async down(queryInterface) { + await queryInterface.sequelize.query( + 'DROP INDEX CONCURRENTLY IF EXISTS "group_permissions_document_id_group_id_sourced";' + ); + }, +}; From ecb27a7132cec982a3d4efe5a163864e6de8c805 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Thu, 12 Nov 2026 19:06:15 -0500 Subject: [PATCH 29/41] fix: Scope import attachment queries to the importing team (#14557) --- server/queues/processors/ImportsProcessor.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/server/queues/processors/ImportsProcessor.ts b/server/queues/processors/ImportsProcessor.ts index cb914e1986..832f042298 100644 --- a/server/queues/processors/ImportsProcessor.ts +++ b/server/queues/processors/ImportsProcessor.ts @@ -606,9 +606,10 @@ export default abstract class ImportsProcessor< const rootNode = rootNodesByExternalId[externalId]; + // documentId is set for root pages too. const attachments = await Attachment.findAll({ attributes: ["id", "size"], - where: { documentId: externalId }, // This will be set for root pages too + where: { documentId: externalId, teamId: importModel.teamId }, transaction, }); @@ -690,7 +691,11 @@ export default abstract class ImportsProcessor< // Unset documentId for attachments in collection overview. await Attachment.update( { documentId: null }, - { where: { documentId: externalId }, silent: true, transaction } + { + where: { documentId: externalId, teamId: importModel.teamId }, + silent: true, + transaction, + } ); continue; @@ -832,7 +837,11 @@ export default abstract class ImportsProcessor< // Update document id for attachments in document content. await Attachment.update( { documentId: internalId }, - { where: { documentId: externalId }, silent: true, transaction } + { + where: { documentId: externalId, teamId: importModel.teamId }, + silent: true, + transaction, + } ); } } From 84cabed245628d7e9c1489e29f76d7bcdfef3b15 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Nov 2026 00:10:37 +0000 Subject: [PATCH 30/41] chore(deps): bump i18next-fs-backend from 2.6.9 to 2.6.10 (#14555) Bumps [i18next-fs-backend](https://github.com/i18next/i18next-fs-backend) from 2.6.9 to 2.6.10. - [Changelog](https://github.com/i18next/i18next-fs-backend/blob/master/CHANGELOG.md) - [Commits](https://github.com/i18next/i18next-fs-backend/compare/v2.6.9...v2.6.10) --- updated-dependencies: - dependency-name: i18next-fs-backend dependency-version: 2.6.10 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 36bfe75180..8a0093be84 100644 --- a/package.json +++ b/package.json @@ -151,7 +151,7 @@ "http-proxy-agent": "^7.0.2", "https-proxy-agent": "^7.0.6", "i18next": "^22.5.1", - "i18next-fs-backend": "^2.6.9", + "i18next-fs-backend": "^2.6.10", "i18next-http-backend": "^4.0.10", "invariant": "^2.2.4", "ioredis": "^5.11.1", diff --git a/yarn.lock b/yarn.lock index 6be63eb44e..6570c31876 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11194,10 +11194,10 @@ __metadata: languageName: node linkType: hard -"i18next-fs-backend@npm:^2.6.9": - version: 2.6.9 - resolution: "i18next-fs-backend@npm:2.6.9" - checksum: 10c0/881432a5fd1c75cd44db09968807d3d517dec2ac5312629b751f7d0974ec29f6d08018da78f69becb3b43f50d539cb43f4583dd32afcf80691ce90bd6e901b23 +"i18next-fs-backend@npm:^2.6.10": + version: 2.6.10 + resolution: "i18next-fs-backend@npm:2.6.10" + checksum: 10c0/39282b0730c8551cf7f43c0d1f52e9b3a83a30812b72fb80993d903c81a6aba11557ce26c0fc4d1fbe1ba76857e787d4c6d53cd08de1cc1d1c0d1cb9f66a8afc languageName: node linkType: hard @@ -14175,7 +14175,7 @@ __metadata: https-proxy-agent: "npm:^7.0.6" husky: "npm:^9.1.7" i18next: "npm:^22.5.1" - i18next-fs-backend: "npm:^2.6.9" + i18next-fs-backend: "npm:^2.6.10" i18next-http-backend: "npm:^4.0.10" i18next-parser: "npm:^9.4.0" invariant: "npm:^2.2.4" From 8b253e058a78146d517a1015debbc747d1e2c877 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 12 Nov 2026 20:47:11 -0500 Subject: [PATCH 31/41] chore(deps): bump react-window from 2.3.4 to 2.5.3 (#14552) Bumps [react-window](https://github.com/bvaughn/react-window) from 2.3.4 to 2.5.3. - [Release notes](https://github.com/bvaughn/react-window/releases) - [Changelog](https://github.com/bvaughn/react-window/blob/main/CHANGELOG.md) - [Commits](https://github.com/bvaughn/react-window/compare/2.3.4...2.5.3) --- updated-dependencies: - dependency-name: react-window dependency-version: 2.5.3 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 8a0093be84..fb6cd5aacf 100644 --- a/package.json +++ b/package.json @@ -230,7 +230,7 @@ "react-remove-scroll": "^2.7.2", "react-router-dom": "^5.3.4", "react-use-measure": "^2.1.7", - "react-window": "^2.3.4", + "react-window": "^2.5.3", "react-zoom-pan-pinch": "^3.7.0", "reflect-metadata": "^0.2.2", "refractor": "^5.0.0", diff --git a/yarn.lock b/yarn.lock index 6570c31876..a2e20b613e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -14262,7 +14262,7 @@ __metadata: react-remove-scroll: "npm:^2.7.2" react-router-dom: "npm:^5.3.4" react-use-measure: "npm:^2.1.7" - react-window: "npm:^2.3.4" + react-window: "npm:^2.5.3" react-zoom-pan-pinch: "npm:^3.7.0" reflect-metadata: "npm:^0.2.2" refractor: "npm:^5.0.0" @@ -15856,13 +15856,17 @@ __metadata: languageName: node linkType: hard -"react-window@npm:^2.3.4": - version: 2.3.4 - resolution: "react-window@npm:2.3.4" +"react-window@npm:^2.5.3": + version: 2.5.3 + resolution: "react-window@npm:2.5.3" peerDependencies: + "@types/react": ^18.2.6 || ^19.0.0 react: ^18.0.0 || ^19.0.0 react-dom: ^18.0.0 || ^19.0.0 - checksum: 10c0/6990fe8e2933c621407a5eaa5be928c1c414b19184c6f5054e5f2be510aa5f54a44d9addf76f64381919cde0839e788163a6dec3ef67824eb8ec0c5859c4fb60 + peerDependenciesMeta: + "@types/react": + optional: true + checksum: 10c0/f491036d005ba570b1abb904179d27bfd4b8faac59514f278f0552f7eb61404e96f2c41173a8e52f0b631d46f67984dfe666e8da1c07904cc86f05d3dbc5530e languageName: node linkType: hard From 631114129e7d9970b2f280744a6971d113ea2804 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Thu, 12 Nov 2026 21:48:14 -0500 Subject: [PATCH 32/41] perf: Lock only the target row in locked queries with joins (#14564) --- plugins/github/server/GitHubIssueProvider.ts | 2 +- .../server/api/webhookSubscriptions.ts | 4 ++-- server/queues/processors/ImportsProcessor.ts | 2 +- server/queues/tasks/APIImportTask.ts | 2 +- server/queues/tasks/CleanupDemotedUserTask.ts | 5 ++++- server/routes/api/imports/imports.ts | 4 ++-- .../routes/api/notifications/notifications.ts | 2 +- server/scripts/reset-encrypted-data.ts | 2 +- yarn.lock | 21 +------------------ 9 files changed, 14 insertions(+), 30 deletions(-) diff --git a/plugins/github/server/GitHubIssueProvider.ts b/plugins/github/server/GitHubIssueProvider.ts index 77e4ab253e..9a6b9209cf 100644 --- a/plugins/github/server/GitHubIssueProvider.ts +++ b/plugins/github/server/GitHubIssueProvider.ts @@ -131,7 +131,7 @@ export class GitHubIssueProvider extends BaseIssueProvider { required: true, }, transaction, - lock: transaction.LOCK.NO_KEY_UPDATE, + lock: { level: transaction.LOCK.NO_KEY_UPDATE, of: Integration }, }); const authentication = integration.authentication; diff --git a/plugins/webhooks/server/api/webhookSubscriptions.ts b/plugins/webhooks/server/api/webhookSubscriptions.ts index c97f25e800..9b8024fee9 100644 --- a/plugins/webhooks/server/api/webhookSubscriptions.ts +++ b/plugins/webhooks/server/api/webhookSubscriptions.ts @@ -121,7 +121,7 @@ router.post( const webhookSubscription = await WebhookSubscription.findByPk(id, { rejectOnEmpty: true, - lock: transaction.LOCK.NO_KEY_UPDATE, + lock: { level: transaction.LOCK.NO_KEY_UPDATE, of: WebhookSubscription }, transaction, }); @@ -152,7 +152,7 @@ router.post( const webhookSubscription = await WebhookSubscription.findByPk(id, { rejectOnEmpty: true, - lock: transaction.LOCK.NO_KEY_UPDATE, + lock: { level: transaction.LOCK.NO_KEY_UPDATE, of: WebhookSubscription }, transaction, }); diff --git a/server/queues/processors/ImportsProcessor.ts b/server/queues/processors/ImportsProcessor.ts index 832f042298..99626cbb70 100644 --- a/server/queues/processors/ImportsProcessor.ts +++ b/server/queues/processors/ImportsProcessor.ts @@ -88,7 +88,7 @@ export default abstract class ImportsProcessor< rejectOnEmpty: true, paranoid: false, transaction, - lock: transaction.LOCK.NO_KEY_UPDATE, + lock: { level: transaction.LOCK.NO_KEY_UPDATE, of: Import }, }); if ( diff --git a/server/queues/tasks/APIImportTask.ts b/server/queues/tasks/APIImportTask.ts index d289050f6c..aaa92fdfc2 100644 --- a/server/queues/tasks/APIImportTask.ts +++ b/server/queues/tasks/APIImportTask.ts @@ -150,7 +150,7 @@ export default abstract class APIImportTask< }, ], transaction, - lock: Transaction.LOCK.NO_KEY_UPDATE, + lock: { level: Transaction.LOCK.NO_KEY_UPDATE, of: ImportTask }, } ); diff --git a/server/queues/tasks/CleanupDemotedUserTask.ts b/server/queues/tasks/CleanupDemotedUserTask.ts index be91d02026..08e2b8be72 100644 --- a/server/queues/tasks/CleanupDemotedUserTask.ts +++ b/server/queues/tasks/CleanupDemotedUserTask.ts @@ -32,7 +32,10 @@ export default class CleanupDemotedUserTask extends BaseTask { enabled: true, }, transaction, - lock: transaction.LOCK.NO_KEY_UPDATE, + lock: { + level: transaction.LOCK.NO_KEY_UPDATE, + of: WebhookSubscription, + }, }); await Promise.all( subscriptions.map((subscription) => diff --git a/server/routes/api/imports/imports.ts b/server/routes/api/imports/imports.ts index 8ae9f774e9..0d674f6481 100644 --- a/server/routes/api/imports/imports.ts +++ b/server/routes/api/imports/imports.ts @@ -209,7 +209,7 @@ router.post( const importModel = await Import.findByPk(id, { rejectOnEmpty: true, transaction, - lock: transaction.LOCK.NO_KEY_UPDATE, + lock: { level: transaction.LOCK.NO_KEY_UPDATE, of: Import }, }); authorize(user, "delete", importModel); @@ -234,7 +234,7 @@ router.post( let importModel = await Import.findByPk(id, { rejectOnEmpty: true, transaction, - lock: transaction.LOCK.NO_KEY_UPDATE, + lock: { level: transaction.LOCK.NO_KEY_UPDATE, of: Import }, }); authorize(user, "cancel", importModel); diff --git a/server/routes/api/notifications/notifications.ts b/server/routes/api/notifications/notifications.ts index cbc7b2ae87..af56d48591 100644 --- a/server/routes/api/notifications/notifications.ts +++ b/server/routes/api/notifications/notifications.ts @@ -49,7 +49,7 @@ const unsubscribe = async (ctx: APIContext) => { const user = await User.scope("withTeam").findByPk(userId, { rejectOnEmpty: true, - lock: transaction.LOCK.NO_KEY_UPDATE, + lock: { level: transaction.LOCK.NO_KEY_UPDATE, of: User }, transaction, }); diff --git a/server/scripts/reset-encrypted-data.ts b/server/scripts/reset-encrypted-data.ts index 681ea1f3dc..21cd230108 100644 --- a/server/scripts/reset-encrypted-data.ts +++ b/server/scripts/reset-encrypted-data.ts @@ -56,7 +56,7 @@ export default async function main() { }); const webhooks = await WebhookSubscription.findAll({ - lock: Transaction.LOCK.UPDATE, + lock: { level: Transaction.LOCK.UPDATE, of: WebhookSubscription }, transaction, }); diff --git a/yarn.lock b/yarn.lock index a2e20b613e..b8690521c8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6044,7 +6044,7 @@ __metadata: languageName: node linkType: hard -"@tanstack/react-virtual@npm:^3.14.26": +"@tanstack/react-virtual@npm:^3.14.26, @tanstack/react-virtual@npm:^3.14.9": version: 3.14.26 resolution: "@tanstack/react-virtual@npm:3.14.26" dependencies: @@ -6056,18 +6056,6 @@ __metadata: languageName: node linkType: hard -"@tanstack/react-virtual@npm:^3.14.9": - version: 3.14.23 - resolution: "@tanstack/react-virtual@npm:3.14.23" - dependencies: - "@tanstack/virtual-core": "npm:3.19.8" - peerDependencies: - react: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 - react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 - checksum: 10c0/cd39e337ba5d450be5cade885dd0a043ef9149abd95331c533b588a626573af4a48b0d4e78d2bcf36b4ffa1267921dfae7203dec8aa8aa7f128014accd2e4ff5 - languageName: node - linkType: hard - "@tanstack/table-core@npm:8.21.3": version: 8.21.3 resolution: "@tanstack/table-core@npm:8.21.3" @@ -6082,13 +6070,6 @@ __metadata: languageName: node linkType: hard -"@tanstack/virtual-core@npm:3.19.8": - version: 3.19.8 - resolution: "@tanstack/virtual-core@npm:3.19.8" - checksum: 10c0/eac7a1edd843d8c0f1b07343a7804ac393fb152cb046581331c1c912b7dc518f484c5bca69cae2637739f447cffc86f779b3f4ca7b227872ed7cd5dc8fe5d28b - languageName: node - linkType: hard - "@tokenizer/inflate@npm:^0.4.1": version: 0.4.1 resolution: "@tokenizer/inflate@npm:0.4.1" From 38770745c88adc67460c97ee53afb908d4db9b8c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 12 Nov 2026 21:48:21 -0500 Subject: [PATCH 33/41] chore(deps): bump react from 19.3.0 to 19.3.1 (#14546) * chore(deps): bump react from 19.3.0 to 19.3.1 Bumps [react](https://github.com/react/react/tree/HEAD/packages/react) from 19.3.0 to 19.3.1. - [Release notes](https://github.com/react/react/releases) - [Changelog](https://github.com/react/react/blob/main/CHANGELOG.md) - [Commits](https://github.com/react/react/commits/v19.3.1/packages/react) --- updated-dependencies: - dependency-name: react dependency-version: 19.3.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * chore(deps): bump react-dom to 19.3.1 to match react --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Tom Moor --- package.json | 4 ++-- yarn.lock | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index fb6cd5aacf..bf512f5a78 100644 --- a/package.json +++ b/package.json @@ -217,11 +217,11 @@ "proxy-from-env": "^1.1.0", "query-string": "^9.5.0", "rate-limiter-flexible": "^11.2.3", - "react": "^19.3.0", + "react": "^19.3.1", "react-avatar-editor": "^15.1.0", "react-colorful": "^5.8.1", "react-day-picker": "^8.10.2", - "react-dom": "^19.3.0", + "react-dom": "^19.3.1", "react-dropzone": "^20.1.4", "react-hook-form": "^7.85.0", "react-i18next": "^12.3.1", diff --git a/yarn.lock b/yarn.lock index b8690521c8..2773b2649f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -14229,11 +14229,11 @@ __metadata: proxy-from-env: "npm:^1.1.0" query-string: "npm:^9.5.0" rate-limiter-flexible: "npm:^11.2.3" - react: "npm:^19.3.0" + react: "npm:^19.3.1" react-avatar-editor: "npm:^15.1.0" react-colorful: "npm:^5.8.1" react-day-picker: "npm:^8.10.2" - react-dom: "npm:^19.3.0" + react-dom: "npm:^19.3.1" react-dropzone: "npm:^20.1.4" react-hook-form: "npm:^7.85.0" react-i18next: "npm:^12.3.1" @@ -15650,14 +15650,14 @@ __metadata: languageName: node linkType: hard -"react-dom@npm:^19.3.0": - version: 19.3.0 - resolution: "react-dom@npm:19.3.0" +"react-dom@npm:^19.3.1": + version: 19.3.1 + resolution: "react-dom@npm:19.3.1" dependencies: scheduler: "npm:^0.28.0" peerDependencies: - react: ^19.3.0 - checksum: 10c0/c513044b724dd6bfe9500a9682d60973e7f8a48cffba00b6b16d3e910e27dcc459bf71bf0a5c33d7d62a3843ca30de1bd1e2098058aa4ed71f618a24b6061da5 + react: ^19.3.1 + checksum: 10c0/382700916313b2ebc46acee80642f300bb8601eac6a9e7fefade5b8b30e66b05bf3aaa56a3c964589fcd578d27b486e847470c2697d879264e766661ff49fac7 languageName: node linkType: hard @@ -15861,10 +15861,10 @@ __metadata: languageName: node linkType: hard -"react@npm:^19.3.0": - version: 19.3.0 - resolution: "react@npm:19.3.0" - checksum: 10c0/dd3099c3c43a7122bc01223bb26b0f8d5ba13cca569af6fb94a005fb54fa73223c9cb203bb226d40cfd49a82cbeef2e36ce84062a3a6d5b9fe8f4437694c7b52 +"react@npm:^19.3.1": + version: 19.3.1 + resolution: "react@npm:19.3.1" + checksum: 10c0/f0ed036d1223562c09c8347858ca712733ea6e27a30db709ee9c3f3f176d3e9e767afce735d59956addf3d030102e256bba82dea635fc1bdb0e01107e98fef10 languageName: node linkType: hard From 2276ee2ecbfbb173694916d4d7d1ad4b00235667 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Thu, 12 Nov 2026 21:51:48 -0500 Subject: [PATCH 34/41] Set lock_timeout on request transactions (#14563) * Set lock_timeout on request transactions Lock waits in API transactions now fail after 5s with a 503 instead of holding a pool connection until the statement timeout. * Map query timeouts to request_timeout in batch sub-requests --- server/commands/documentUpdater.ts | 2 +- server/routes/api/batch/batch.test.ts | 31 +++++++++++++++- .../routes/api/middlewares/apiErrorHandler.ts | 6 ++++ server/storage/database.test.ts | 18 ++++++++-- server/storage/database.ts | 35 +++++++++++-------- 5 files changed, 74 insertions(+), 18 deletions(-) diff --git a/server/commands/documentUpdater.ts b/server/commands/documentUpdater.ts index 0436b0dea0..a7d16f22ba 100644 --- a/server/commands/documentUpdater.ts +++ b/server/commands/documentUpdater.ts @@ -101,7 +101,7 @@ export default async function documentUpdater( // Serialize concurrent updates to the same document by taking a row-level // lock before writing. The wait is already bounded by the transaction's - // statement_timeout. When lastRevision is provided it becomes part of the + // lock_timeout. When lastRevision is provided it becomes part of the // predicate, so a document modified since that revision matches no row. if (transaction) { const locked = await Document.unscoped().findOne({ diff --git a/server/routes/api/batch/batch.test.ts b/server/routes/api/batch/batch.test.ts index 594f30da4e..c4d487afab 100644 --- a/server/routes/api/batch/batch.test.ts +++ b/server/routes/api/batch/batch.test.ts @@ -1,6 +1,7 @@ import { RateLimiterRes } from "rate-limiter-flexible"; +import { DatabaseError } from "sequelize"; import env from "@server/env"; -import { Collection } from "@server/models"; +import { Collection, Document as DocumentModel } from "@server/models"; import type { Document, User } from "@server/models"; import { buildAdmin, @@ -270,6 +271,34 @@ describe("#batch", () => { expect(body.data[0].error).toEqual("not_found"); }); + it("should return a request timeout when a sub-request waits too long for a lock", async () => { + const parent = Object.assign( + new Error("canceling statement due to lock timeout"), + { code: "55P03", sql: "" } + ); + vi.spyOn(DocumentModel, "findByPk").mockRejectedValueOnce( + new DatabaseError(parent) + ); + + const res = await server.post("/api/batch", user, { + body: { + requests: [ + { + method: "documents.update", + body: { id: documentOne.id, title: "Updated" }, + }, + ], + }, + }); + const body = await res.json(); + vi.restoreAllMocks(); + + expect(res.status).toEqual(200); + expect(body.data[0].ok).toBe(false); + expect(body.data[0].status).toEqual(503); + expect(body.data[0].error).toEqual("request_timeout"); + }); + it("should surface per-request validation errors", async () => { const res = await server.post("/api/batch", user, { body: { diff --git a/server/routes/api/middlewares/apiErrorHandler.ts b/server/routes/api/middlewares/apiErrorHandler.ts index 9b5499e9ce..f8b6ad1f6a 100644 --- a/server/routes/api/middlewares/apiErrorHandler.ts +++ b/server/routes/api/middlewares/apiErrorHandler.ts @@ -8,8 +8,10 @@ import { import { AuthorizationError, NotFoundError, + RequestTimeoutError, ValidationError, } from "@server/errors"; +import { isQueryCanceledError } from "@server/storage/database"; /** Postgres codes for a requested date the database cannot represent. */ const DATE_RANGE_ERROR_CODES = new Set(["22008", "22015"]); @@ -62,6 +64,10 @@ export default function apiErrorHandler() { ); } + if (isQueryCanceledError(err)) { + transformedErr = RequestTimeoutError(); + } + if ( (err instanceof Error && "code" in err && err.code === "ENOENT") || err instanceof SequelizeEmptyResultError || diff --git a/server/storage/database.test.ts b/server/storage/database.test.ts index eca8674e65..09ca4356c2 100644 --- a/server/storage/database.test.ts +++ b/server/storage/database.test.ts @@ -57,7 +57,8 @@ describe("applyStatementTimeoutToTransactions", () => { beforeAll(() => { instance = applyStatementTimeoutToTransactions( createDatabaseInstance(env.DATABASE_URL ?? "", {}), - 1234 + 1234, + 567 ); }); @@ -69,6 +70,12 @@ describe("applyStatementTimeoutToTransactions", () => { vi.restoreAllMocks(); }); + const showLockTimeout = (transaction?: Transaction) => + instance.query<{ lock_timeout: string }>("SHOW lock_timeout", { + type: QueryTypes.SELECT, + transaction, + }); + const showTimeout = (transaction?: Transaction) => instance.query<{ statement_timeout: string }>("SHOW statement_timeout", { type: QueryTypes.SELECT, @@ -82,12 +89,18 @@ describe("applyStatementTimeoutToTransactions", () => { expect(rows).toEqual([{ statement_timeout: "1234ms" }]); expect(spy.mock.calls.map(([sql]) => sql)).toEqual([ - "START TRANSACTION; SET LOCAL statement_timeout = 1234;", + "START TRANSACTION; SET LOCAL statement_timeout = 1234; SET LOCAL lock_timeout = 567;", "SHOW statement_timeout", "COMMIT;", ]); }); + it("should set the lock timeout in the transaction", async () => { + const rows = await instance.transaction(showLockTimeout); + + expect(rows).toEqual([{ lock_timeout: "567ms" }]); + }); + it("should not set the timeout again for a savepoint", async () => { const spy = vi.spyOn(instance, "query"); @@ -109,5 +122,6 @@ describe("applyStatementTimeoutToTransactions", () => { const rows = await showTimeout(); expect(rows).not.toEqual([{ statement_timeout: "1234ms" }]); + expect(await showLockTimeout()).not.toEqual([{ lock_timeout: "567ms" }]); }); }); diff --git a/server/storage/database.ts b/server/storage/database.ts index 25e3f7888a..05eb81e3b1 100644 --- a/server/storage/database.ts +++ b/server/storage/database.ts @@ -46,12 +46,15 @@ function getDatabaseConfig() { ); } -/** Postgres error code for `query_canceled`. */ -const QueryCanceledErrorCode = "57014"; +/** Postgres error codes for `query_canceled` and `lock_not_available`. */ +const QueryCanceledErrorCodes = ["57014", "55P03"]; /** Headroom between the statement timeout and the HTTP request timeout. */ const StatementTimeoutMargin = 500; +/** Maximum time a statement in a request transaction waits for a lock. */ +const LockTimeout = 5000; + /** Sequelize types the query generator as unknown; this narrows to the single * method used to begin a transaction. */ interface QueryGeneratorWithTransaction { @@ -91,8 +94,8 @@ const statementTimeout = : undefined; /** - * Whether an error was caused by Postgres canceling a query, most commonly - * because it exceeded the configured `statement_timeout`. + * Whether an error was caused by Postgres canceling a query because it + * exceeded the configured `statement_timeout` or `lock_timeout`. * * @param err the error to inspect. * @returns true if the query was canceled by the database. @@ -102,7 +105,8 @@ export function isQueryCanceledError(err: unknown): boolean { err instanceof DatabaseError && !!err.parent && "code" in err.parent && - err.parent.code === QueryCanceledErrorCode + typeof err.parent.code === "string" && + QueryCanceledErrorCodes.includes(err.parent.code) ); } @@ -200,7 +204,8 @@ export function createDatabaseInstance( if (statementTimeout) { instance = applyStatementTimeoutToTransactions( instance, - Number(statementTimeout) + Number(statementTimeout), + LockTimeout ); } @@ -331,19 +336,21 @@ export function createMigrationRunner( } /** - * Appends `SET LOCAL statement_timeout` to the statement that begins each - * transaction, so that both are sent in a single round trip. Using `SET LOCAL` - * scopes the value to the transaction, preventing it from leaking to other - * consumers (e.g. background workers) sharing the same underlying connection - * via pgbouncer's transaction pooling. + * Appends `SET LOCAL statement_timeout` and `lock_timeout` to the statement + * that begins each transaction, so that all are sent in a single round trip. + * Using `SET LOCAL` scopes the values to the transaction, preventing them from + * leaking to other consumers (e.g. background workers) sharing the same + * underlying connection via pgbouncer's transaction pooling. * * @param instance the Sequelize instance to modify. * @param timeoutMs the statement timeout in milliseconds. + * @param lockTimeoutMs the lock timeout in milliseconds. * @returns the modified Sequelize instance. */ export function applyStatementTimeoutToTransactions( instance: Sequelize, - timeoutMs: number + timeoutMs: number, + lockTimeoutMs: number ) { const queryGenerator = instance.getQueryInterface() .queryGenerator as QueryGeneratorWithTransaction; @@ -353,11 +360,11 @@ export function applyStatementTimeoutToTransactions( queryGenerator.startTransactionQuery = (transaction) => { const sql = origStartTransactionQuery(transaction); - // Savepoints inherit the value set when the outer transaction began. + // Savepoints inherit the values set when the outer transaction began. if (transaction.parent) { return sql; } - return `${sql} SET LOCAL statement_timeout = ${timeoutMs};`; + return `${sql} SET LOCAL statement_timeout = ${timeoutMs}; SET LOCAL lock_timeout = ${lockTimeoutMs};`; }; return instance; From 97055b2d805071e2e086ddeca3edd8098a38365e Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Thu, 12 Nov 2026 21:52:06 -0500 Subject: [PATCH 35/41] chore: Split server/routes/index.ts into focused routers (#14556) Move static assets, shares, embeds and the app catch-all into their own routers, and extract workspace redirect and render option logic so the index file only composes middleware in order. --- server/middlewares/appHeaders.ts | 31 ++++ server/routes/app.ts | 57 +++++-- server/routes/assets.ts | 103 ++++++++++++ server/routes/embeds.ts | 10 ++ server/routes/index.ts | 276 ++----------------------------- server/routes/shares.ts | 61 +++++++ server/routes/workspace.test.ts | 99 +++++++++++ server/routes/workspace.ts | 95 +++++++++++ 8 files changed, 457 insertions(+), 275 deletions(-) create mode 100644 server/middlewares/appHeaders.ts create mode 100644 server/routes/assets.ts create mode 100644 server/routes/shares.ts create mode 100644 server/routes/workspace.test.ts create mode 100644 server/routes/workspace.ts diff --git a/server/middlewares/appHeaders.ts b/server/middlewares/appHeaders.ts new file mode 100644 index 0000000000..4095359882 --- /dev/null +++ b/server/middlewares/appHeaders.ts @@ -0,0 +1,31 @@ +import type { Context, Next } from "koa"; +import env from "@server/env"; + +/** + * Middleware that sets the response headers that are needed when serving the + * web application. + * + * @returns the middleware function. + */ +export default function appHeaders() { + // Sentry needs this header to report all performance metrics, see: + // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Timing-Allow-Origin + const timingOrigins = [env.URL]; + + if (env.SENTRY_DSN) { + timingOrigins.push("https://sentry.io"); + } + + const timingAllowOrigin = timingOrigins.join(", "); + + return async function appHeadersMiddleware(ctx: Context, next: Next) { + ctx.set("Timing-Allow-Origin", timingAllowOrigin); + + // Allow the JS Self-Profiling API to be used for local performance work. + if (env.isDevelopment) { + ctx.set("Document-Policy", "js-profiling"); + } + + await next(); + }; +} diff --git a/server/routes/app.ts b/server/routes/app.ts index 8e6324a384..f07e251ae5 100644 --- a/server/routes/app.ts +++ b/server/routes/app.ts @@ -1,6 +1,7 @@ import fs from "node:fs"; import path from "node:path"; import util from "node:util"; +import Router from "@koa/router"; import type { Context, Next } from "koa"; import { escape } from "es-toolkit/compat"; import { isbot } from "isbot"; @@ -26,7 +27,28 @@ import { getTeamFromContext } from "@server/utils/passport"; import prefetchTags from "@server/utils/prefetchTags"; import readManifestFile from "@server/utils/readManifestFile"; import { RedisPrefixHelper } from "@server/utils/RedisPrefixHelper"; +import { isInvalidAppPath } from "@server/utils/url"; import { loadPublicShare } from "@server/commands/shareLoader"; +import { + getWorkspaceRedirectUrl, + getWorkspaceRenderOptions, +} from "./workspace"; + +/** Options used to render the app shell. */ +export interface AppRenderOptions { + title?: string; + description?: string; + content?: string; + canonical?: string; + shortcutIcon?: string; + image?: string; + siteName?: string; + rootShareId?: string; + isShare?: boolean; + markdownUrl?: string; + analytics?: Integration[]; + allowIndexing?: boolean; +} const readFile = util.promisify(fs.readFile); const entry = "app/index.tsx"; @@ -139,20 +161,7 @@ const readIndexFile = async (): Promise => { export const renderApp = async ( ctx: Context, next: Next, - options: { - title?: string; - description?: string; - content?: string; - canonical?: string; - shortcutIcon?: string; - image?: string; - siteName?: string; - rootShareId?: string; - isShare?: boolean; - markdownUrl?: string; - analytics?: Integration[]; - allowIndexing?: boolean; - } = {} + options: AppRenderOptions = {} ) => { const { title = env.APP_NAME, @@ -444,3 +453,23 @@ export const renderShare = async (ctx: Context, next: Next) => { markdownUrl: document || collection ? markdownUrl : undefined, }); }; + +const router = new Router(); + +router.get("{/*path}", async (ctx, next) => { + if (isInvalidAppPath(ctx.path)) { + ctx.status = 404; + return; + } + + const team = await getTeamFromContext(ctx); + const redirectUrl = await getWorkspaceRedirectUrl(ctx, team); + if (redirectUrl) { + ctx.redirect(redirectUrl); + return; + } + + return renderApp(ctx, next, await getWorkspaceRenderOptions(team)); +}); + +export default router; diff --git a/server/routes/assets.ts b/server/routes/assets.ts new file mode 100644 index 0000000000..26b2d8427d --- /dev/null +++ b/server/routes/assets.ts @@ -0,0 +1,103 @@ +import crypto from "node:crypto"; +import path from "node:path"; +import { formatRFC7231 } from "date-fns"; +import Router from "@koa/router"; +import { send } from "@koa/send"; +import { languages } from "@shared/i18n"; +import { Day } from "@shared/utils/time"; +import env from "@server/env"; +import { NotFoundError } from "@server/errors"; + +const router = new Router(); + +router.get( + ["/images/{*path}", "/email/{*path}", "/fonts/{*path}"], + async (ctx, next) => { + let sent; + + try { + sent = await send(ctx, ctx.path, { + root: path.resolve(__dirname, "../../../public"), + // 7 day expiry, these assets are mostly static but do not contain a hash + maxAge: Day.ms * 7, + setHeaders: (res) => { + res.setHeader("Access-Control-Allow-Origin", "*"); + }, + }); + } catch (err) { + if (!isNotFound(err)) { + throw err; + } + } + + if (!sent) { + await next(); + } + } +); + +if (env.isProduction) { + router.get("/static/{*path}", async (ctx) => { + try { + const pathname = ctx.path.substring(8); + if (!pathname) { + throw NotFoundError(); + } + + await send(ctx, pathname, { + root: path.join(__dirname, "../../app/"), + // Hashed static assets get 1 year expiry plus immutable flag + maxAge: Day.ms * 365, + immutable: true, + setHeaders: (res, filePath) => { + res.setHeader("Service-Worker-Allowed", "/"); + res.setHeader("Access-Control-Allow-Origin", "*"); + + // The service worker is not hashed and must always be revalidated + // so that browsers detect and install new versions. + if (path.basename(filePath) === "sw.js") { + res.setHeader("Cache-Control", "no-cache"); + } + }, + }); + } catch (err) { + // Serve a bad request instead of not found if the file doesn't exist, + // this prevents CDNs from caching the response and allows them to + // continue serving old file versions. + if (isNotFound(err)) { + ctx.status = 400; + return; + } + + throw err; + } + }); +} + +router.get("/locales/:lng.json", async (ctx) => { + const { lng } = ctx.params; + + if (!languages.includes(lng as (typeof languages)[number])) { + ctx.status = 404; + return; + } + + await send(ctx, path.join(lng, "translation.json"), { + setHeaders: (res, _, stats) => { + res.setHeader("Last-Modified", formatRFC7231(stats.mtime)); + res.setHeader("Cache-Control", `public, max-age=${7 * Day.seconds}`); + res.setHeader( + "ETag", + crypto.createHash("md5").update(stats.mtime.toISOString()).digest("hex") + ); + res.setHeader("Access-Control-Allow-Origin", "*"); + }, + root: path.join(__dirname, "../../shared/i18n/locales"), + }); +}); + +function isNotFound(err: unknown): boolean { + return err instanceof Error && "status" in err && err.status === 404; +} + +export default router; diff --git a/server/routes/embeds.ts b/server/routes/embeds.ts index 92943ead7f..598299a838 100644 --- a/server/routes/embeds.ts +++ b/server/routes/embeds.ts @@ -1,3 +1,4 @@ +import Router from "@koa/router"; import escape from "escape-html"; import type { Context, Next } from "koa"; import env from "@server/env"; @@ -224,3 +225,12 @@ ${resizeObserverScript(ctx)} return next(); }; + +const router = new Router(); + +router.get( + ["/embeds/gitlab", "/embeds/github", "/embeds/dropbox", "/embeds/pinterest"], + renderEmbed +); + +export default router; diff --git a/server/routes/index.ts b/server/routes/index.ts index d5cd833862..64dfcb836a 100644 --- a/server/routes/index.ts +++ b/server/routes/index.ts @@ -1,275 +1,29 @@ -import crypto from "node:crypto"; -import path from "node:path"; -import { formatRFC7231 } from "date-fns"; import Koa from "koa"; -import Router from "@koa/router"; -import { send } from "@koa/send"; -import { languages } from "@shared/i18n"; -import { TeamPreference } from "@shared/types"; -import { parseDomain } from "@shared/utils/domains"; -import { Day } from "@shared/utils/time"; import env from "@server/env"; -import { NotFoundError } from "@server/errors"; -import shareDomains from "@server/middlewares/shareDomains"; -import { Integration } from "@server/models"; -import { getSessionRedirectUrl } from "@server/utils/authentication"; -import { SessionsCookieHelper } from "@server/utils/SessionsCookieHelper"; -import { getTeamFromContext } from "@server/utils/passport"; -import { isInvalidAppPath } from "@server/utils/url"; -import apexRedirect from "../middlewares/apexRedirect"; -import { renderApp, renderShare } from "./app"; +import apexRedirect from "@server/middlewares/apexRedirect"; +import appHeaders from "@server/middlewares/appHeaders"; +import app from "./app"; +import assets from "./assets"; import discovery from "./discovery"; -import { renderEmbed } from "./embeds"; +import embeds from "./embeds"; import errors from "./errors"; +import shares from "./shares"; const koa = new Koa(); -const router = new Router(); - -// serve public assets -router.use( - ["/images/{*path}", "/email/{*path}", "/fonts/{*path}"], - async (ctx, next) => { - let done; - - if (ctx.method === "HEAD" || ctx.method === "GET") { - try { - done = await send(ctx, ctx.path, { - root: path.resolve(__dirname, "../../../public"), - // 7 day expiry, these assets are mostly static but do not contain a hash - maxAge: Day.ms * 7, - setHeaders: (res) => { - res.setHeader("Access-Control-Allow-Origin", "*"); - }, - }); - } catch (err) { - if (!(err instanceof Error && "status" in err && err.status === 404)) { - throw err; - } - } - } - - if (!done) { - await next(); - } - } -); - -router.use( - [ - "/share/:shareId", - "/share/:shareId/doc/:documentSlug", - "/share/:shareId/{*path}", - ], - (ctx) => { - const redirectPath = ctx.path.replace(/^\/share/, "/s"); - ctx.redirect(redirectPath + ctx.request.URL.search); - ctx.status = 301; - } -); - -if (env.isProduction) { - router.get("/static/{*path}", async (ctx) => { - try { - const pathname = ctx.path.substring(8); - if (!pathname) { - throw NotFoundError(); - } - - await send(ctx, pathname, { - root: path.join(__dirname, "../../app/"), - // Hashed static assets get 1 year expiry plus immutable flag - maxAge: Day.ms * 365, - immutable: true, - setHeaders: (res, filePath) => { - res.setHeader("Service-Worker-Allowed", "/"); - res.setHeader("Access-Control-Allow-Origin", "*"); - - // The service worker is not hashed and must always be revalidated - // so that browsers detect and install new versions. - if (path.basename(filePath) === "sw.js") { - res.setHeader("Cache-Control", "no-cache"); - } - }, - }); - } catch (err) { - if (err instanceof Error && "status" in err && err.status === 404) { - // Serve a bad request instead of not found if the file doesn't exist - // This prevents CDN's from caching the response, allowing them to continue - // serving old file versions - ctx.status = 400; - return; - } - - throw err; - } - }); -} - -router.get("/locales/:lng.json", async (ctx) => { - const { lng } = ctx.params; - - if (!languages.includes(lng as (typeof languages)[number])) { - ctx.status = 404; - return; - } - - await send(ctx, path.join(lng, "translation.json"), { - setHeaders: (res, _, stats) => { - res.setHeader("Last-Modified", formatRFC7231(stats.mtime)); - res.setHeader("Cache-Control", `public, max-age=${7 * Day.seconds}`); - res.setHeader( - "ETag", - crypto.createHash("md5").update(stats.mtime.toISOString()).digest("hex") - ); - res.setHeader("Access-Control-Allow-Origin", "*"); - }, - root: path.join(__dirname, "../../shared/i18n/locales"), - }); -}); - -router.use(discovery.routes()); - -router.get("/s/:shareId.:format", shareDomains(), renderShare); -router.get("/s/:shareId", shareDomains(), renderShare); -router.get( - "/s/:shareId/doc/:documentSlug.:format", - shareDomains(), - renderShare -); -router.get("/s/:shareId/doc/:documentSlug", shareDomains(), renderShare); -router.get("/s/:shareId/{*path}", shareDomains(), renderShare); - -router.get("/embeds/gitlab", renderEmbed); -router.get("/embeds/github", renderEmbed); -router.get("/embeds/dropbox", renderEmbed); -router.get("/embeds/pinterest", renderEmbed); - -router.use(shareDomains()); - -router.get("/doc/:documentSlug", async (ctx, next) => { - if (ctx.state?.rootShare) { - return renderShare(ctx, next); - } - return next(); -}); - -router.get("/sitemap.xml", async (ctx) => { - if (ctx.state?.rootShare) { - ctx.redirect(`/api/shares.sitemap?id=${ctx.state?.rootShare.id}`); - } else { - ctx.status = 404; - } -}); - -// Client routes that render without an authenticated session. -const publicAppPaths = [ - "/", - "/create", - "/logout", - "/desktop-redirect", - "/oauth/authorize", -]; - -function isPublicAppPath(path: string) { - return publicAppPaths.includes(path.replace(/\/+$/, "") || "/"); -} - -// catch all for application -router.get("{/*path}", async (ctx, next) => { - if (isInvalidAppPath(ctx.path)) { - ctx.status = 404; - return; - } - - if (ctx.state?.rootShare) { - // Only allow root path for root share domains, return 404 for other paths. - // Valid paths like /doc/:documentSlug and /sitemap.xml are handled above. - if (ctx.path !== "/") { - ctx.status = 404; - return; - } - return renderShare(ctx, next); - } - - const team = await getTeamFromContext(ctx); - - if (env.isCloudHosted) { - // Redirect to main domain if no team is found - if (!team || team.isSuspended) { - if (env.isProduction && ctx.hostname !== parseDomain(env.URL).host) { - ctx.redirect(env.URL); - return; - } - - if (!team) { - const teams = await SessionsCookieHelper.reconcile(ctx); - - // Links to app paths on the root domain, such as those in emails, are - // sent on to the workspace the browser is signed in to. - if (!isPublicAppPath(ctx.path)) { - const url = getSessionRedirectUrl(ctx, teams); - if (url) { - ctx.redirect(url); - return; - } - } - } - } - - // Redirect to the team's canonical url, taking into account custom domains - // and hosted subdomains, if the request arrived on a different host. - else if (team && !team.isTeamUrl(ctx.href)) { - const url = new URL(team.url); - url.pathname = ctx.path; - url.search = ctx.search; - ctx.redirect(url.toString()); - return; - } - } - - const analytics = await Integration.findAnalyticsIntegrationsForTeam( - team?.id - ); - - const publicBranding = - team?.getPreference(TeamPreference.PublicBranding) ?? false; - - return renderApp(ctx, next, { - title: publicBranding && team?.name ? team.name : undefined, - description: - publicBranding && team?.description ? team.description : undefined, - analytics, - shortcutIcon: - publicBranding && team?.avatarUrl - ? ((await team.publicAvatarUrl()) ?? undefined) - : undefined, - }); -}); - -// In order to report all possible performance metrics to Sentry this header -// must be provided when serving the application, see: -// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Timing-Allow-Origin -const timingOrigins = [env.URL]; - -if (env.SENTRY_DSN) { - timingOrigins.push("https://sentry.io"); -} - -koa.use(async (ctx, next) => { - ctx.set("Timing-Allow-Origin", timingOrigins.join(", ")); - - // Allow the JS Self-Profiling API to be used for local performance work. - if (env.isDevelopment) { - ctx.set("Document-Policy", "js-profiling"); - } - await next(); -}); +koa.use(appHeaders()); koa.use(apexRedirect()); + if (env.ENVIRONMENT === "test") { koa.use(errors.routes()); } -koa.use(router.routes()); +koa.use(assets.routes()); +koa.use(discovery.routes()); +koa.use(embeds.routes()); +koa.use(shares.routes()); + +// The app router has a catch-all route, so it must be last. +koa.use(app.routes()); export default koa; diff --git a/server/routes/shares.ts b/server/routes/shares.ts new file mode 100644 index 0000000000..573bf394a8 --- /dev/null +++ b/server/routes/shares.ts @@ -0,0 +1,61 @@ +import Router from "@koa/router"; +import shareDomains from "@server/middlewares/shareDomains"; +import { renderShare } from "./app"; + +const router = new Router(); + +// Legacy share urls. +router.get( + [ + "/share/:shareId", + "/share/:shareId/doc/:documentSlug", + "/share/:shareId/{*path}", + ], + (ctx) => { + const redirectPath = ctx.path.replace(/^\/share/, "/s"); + ctx.redirect(redirectPath + ctx.request.URL.search); + ctx.status = 301; + } +); + +router.use(shareDomains()); + +router.get( + [ + "/s/:shareId.:format", + "/s/:shareId", + "/s/:shareId/doc/:documentSlug.:format", + "/s/:shareId/doc/:documentSlug", + "/s/:shareId/{*path}", + ], + renderShare +); + +// Routes below are only served for a share on its own custom domain. +router.get("/doc/:documentSlug", (ctx, next) => { + if (ctx.state.rootShare) { + return renderShare(ctx, next); + } + return next(); +}); + +router.get("/sitemap.xml", (ctx) => { + if (ctx.state.rootShare) { + ctx.redirect(`/api/shares.sitemap?id=${ctx.state.rootShare.id}`); + } else { + ctx.status = 404; + } +}); + +router.get("{/*path}", (ctx, next) => { + if (!ctx.state.rootShare) { + return next(); + } + if (ctx.path !== "/") { + ctx.status = 404; + return; + } + return renderShare(ctx, next); +}); + +export default router; diff --git a/server/routes/workspace.test.ts b/server/routes/workspace.test.ts new file mode 100644 index 0000000000..0191afcfb7 --- /dev/null +++ b/server/routes/workspace.test.ts @@ -0,0 +1,99 @@ +import { randomUUID } from "node:crypto"; +import { IncomingMessage, ServerResponse } from "node:http"; +import { Socket } from "node:net"; +import Koa from "koa"; +import { TeamPreference } from "@shared/types"; +import { buildTeam } from "@server/test/factories"; +import { setSelfHosted } from "@server/test/support"; +import { + getWorkspaceRedirectUrl, + getWorkspaceRenderOptions, +} from "./workspace"; + +function buildContext(url: string) { + const { host, pathname, search } = new URL(url); + const req = new IncomingMessage(new Socket()); + req.method = "GET"; + req.url = pathname + search; + req.headers = { host }; + return new Koa().createContext(req, new ServerResponse(req)); +} + +describe("getWorkspaceRedirectUrl", () => { + it("should return undefined on the canonical host", async () => { + const subdomain = `canonical-${randomUUID()}`; + const team = await buildTeam({ subdomain }); + const ctx = buildContext(`https://${subdomain}.outline.dev/search`); + + expect(await getWorkspaceRedirectUrl(ctx, team)).toBeUndefined(); + }); + + it("should return the canonical url with the path and query", async () => { + const id = randomUUID(); + const team = await buildTeam({ + subdomain: `current-${id}`, + previousSubdomains: [`previous-${id}`], + }); + const ctx = buildContext( + `https://previous-${id}.outline.dev/search?query=hello` + ); + + expect(await getWorkspaceRedirectUrl(ctx, team)).toEqual( + `https://current-${id}.outline.dev/search?query=hello` + ); + }); + + it("should not redirect a suspended workspace to its canonical url", async () => { + const id = randomUUID(); + const team = await buildTeam({ + subdomain: `current-${id}`, + previousSubdomains: [`previous-${id}`], + suspendedAt: new Date(), + }); + const ctx = buildContext(`https://previous-${id}.outline.dev/search`); + + expect(await getWorkspaceRedirectUrl(ctx, team)).toBeUndefined(); + }); + + it("should return undefined without a workspace or sessions", async () => { + const ctx = buildContext("https://app.outline.dev/settings"); + + expect(await getWorkspaceRedirectUrl(ctx, undefined)).toBeUndefined(); + }); + + it("should return undefined when self hosted", async () => { + setSelfHosted(); + const team = await buildTeam({ subdomain: `self-${randomUUID()}` }); + const ctx = buildContext("https://other.example.com/search"); + + expect(await getWorkspaceRedirectUrl(ctx, team)).toBeUndefined(); + }); +}); + +describe("getWorkspaceRenderOptions", () => { + it("should return only analytics without public branding", async () => { + const team = await buildTeam({ description: "A description" }); + + expect(await getWorkspaceRenderOptions(team)).toEqual({ analytics: [] }); + }); + + it("should return only analytics without a workspace", async () => { + expect(await getWorkspaceRenderOptions(undefined)).toEqual({ + analytics: [], + }); + }); + + it("should return the workspace name and description with public branding", async () => { + const team = await buildTeam({ + description: "A description", + preferences: { [TeamPreference.PublicBranding]: true }, + }); + + expect(await getWorkspaceRenderOptions(team)).toEqual({ + analytics: [], + title: team.name, + description: "A description", + shortcutIcon: undefined, + }); + }); +}); diff --git a/server/routes/workspace.ts b/server/routes/workspace.ts new file mode 100644 index 0000000000..6e3f44ed7a --- /dev/null +++ b/server/routes/workspace.ts @@ -0,0 +1,95 @@ +import type { Context } from "koa"; +import { TeamPreference } from "@shared/types"; +import { parseDomain } from "@shared/utils/domains"; +import env from "@server/env"; +import { Integration, type Team } from "@server/models"; +import { getSessionRedirectUrl } from "@server/utils/authentication"; +import { SessionsCookieHelper } from "@server/utils/SessionsCookieHelper"; +import type { AppRenderOptions } from "./app"; + +/** + * Returns the URL to redirect an app request to when the request did not + * arrive on the canonical host of a usable workspace. When no workspace is + * found, the sessions cookie is reconciled. + * + * @param ctx the request context. + * @param team the workspace for the request host, if any. + * @returns the URL to redirect to, or undefined to render the app. + */ +export async function getWorkspaceRedirectUrl( + ctx: Context, + team: Team | null | undefined +): Promise { + if (!env.isCloudHosted) { + return; + } + + if (team && !team.isSuspended) { + if (team.isTeamUrl(ctx.href)) { + return; + } + + const url = new URL(team.url); + url.pathname = ctx.path; + url.search = ctx.search; + return url.toString(); + } + + if (env.isProduction && ctx.hostname !== parseDomain(env.URL).host) { + return env.URL; + } + + if (team) { + return; + } + + const teams = await SessionsCookieHelper.reconcile(ctx); + + // Links to app paths on the root domain, such as those in emails, are sent + // on to the workspace the browser is signed in to. + if (isPublicAppPath(ctx.path)) { + return; + } + + return getSessionRedirectUrl(ctx, teams); +} + +/** + * Returns the options used to render the app shell for a workspace. + * + * @param team the workspace for the request host, if any. + * @returns the render options. + */ +export async function getWorkspaceRenderOptions( + team: Team | null | undefined +): Promise { + const analytics = await Integration.findAnalyticsIntegrationsForTeam( + team?.id + ); + + if (!team?.getPreference(TeamPreference.PublicBranding)) { + return { analytics }; + } + + return { + analytics, + title: team.name || undefined, + description: team.description || undefined, + shortcutIcon: team.avatarUrl + ? ((await team.publicAvatarUrl()) ?? undefined) + : undefined, + }; +} + +// Client routes that render without an authenticated session. +const publicAppPaths = [ + "/", + "/create", + "/logout", + "/desktop-redirect", + "/oauth/authorize", +]; + +function isPublicAppPath(pathname: string) { + return publicAppPaths.includes(pathname.replace(/\/+$/, "") || "/"); +} From 77f2d88416a397e5132bfd7cc91af33d966dd098 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Thu, 12 Nov 2026 22:08:47 -0500 Subject: [PATCH 36/41] fix: Tighten passkey challenge handling (#14571) --- plugins/passkeys/server/auth/passkeys.test.ts | 69 +++++++++++++++++++ plugins/passkeys/server/auth/passkeys.ts | 13 ++-- 2 files changed, 73 insertions(+), 9 deletions(-) diff --git a/plugins/passkeys/server/auth/passkeys.test.ts b/plugins/passkeys/server/auth/passkeys.test.ts index d5dea1113f..5bf0fc249a 100644 --- a/plugins/passkeys/server/auth/passkeys.test.ts +++ b/plugins/passkeys/server/auth/passkeys.test.ts @@ -259,6 +259,38 @@ describe("#passkeys.verifyRegistration", () => { expect(body.message).toEqual("Invalid authentication type"); }); + it("should consume the challenge on a failed attempt", async () => { + const team = await buildTeam({ passkeysEnabled: true }); + const user = await buildUser({ teamId: team.id }); + + const options = await server.post( + "/auth/passkeys.generateRegistrationOptions", + user + ); + const { data } = await options.json(); + + const failed = await server.post( + "/auth/passkeys.verifyRegistration", + user, + { + body: buildNoneAttestationResponse( + isoBase64URL.fromBuffer(randomBytes(32)), + data.rp.id + ), + } + ); + expect(failed.status).toEqual(400); + + const res = await server.post("/auth/passkeys.verifyRegistration", user, { + body: buildNoneAttestationResponse(data.challenge, data.rp.id), + }); + const body = await res.json(); + expect(res.status).toEqual(400); + expect(body.message).toEqual( + "No registration challenge found or challenge expired" + ); + }); + it("should record the registration in the audit log", async () => { const planSpy = vi .spyOn(Team.prototype, "plan", "get") @@ -290,3 +322,40 @@ describe("#passkeys.verifyRegistration", () => { planSpy.mockRestore(); }); }); + +describe("#passkeys.verifyAuthentication", () => { + it("should consume the challenge on a failed attempt", async () => { + const options = await server.post( + "/auth/passkeys.generateAuthenticationOptions", + { body: {} } + ); + const { data } = await options.json(); + const body = { + challengeId: data.challengeId, + id: "unknown", + rawId: "unknown", + response: { + authenticatorData: "", + clientDataJSON: "", + signature: "", + }, + type: "public-key", + }; + + const failed = await server.post("/auth/passkeys.verifyAuthentication", { + body, + }); + const failedBody = await failed.json(); + expect(failed.status).toEqual(400); + expect(failedBody.message).toContain("Passkey not found"); + + const res = await server.post("/auth/passkeys.verifyAuthentication", { + body, + }); + const resBody = await res.json(); + expect(res.status).toEqual(400); + expect(resBody.message).toEqual( + "No authentication challenge found or challenge expired" + ); + }); +}); diff --git a/plugins/passkeys/server/auth/passkeys.ts b/plugins/passkeys/server/auth/passkeys.ts index af18d42291..e2717cf2d7 100644 --- a/plugins/passkeys/server/auth/passkeys.ts +++ b/plugins/passkeys/server/auth/passkeys.ts @@ -157,8 +157,8 @@ router.post( const body = ctx.input.body; authorize(user, "createUserPasskey", user.team); - // Retrieve challenge from Redis - const expectedChallenge = await Redis.defaultClient.get( + // Consume the challenge atomically so it can only be used once + const expectedChallenge = await Redis.defaultClient.getdel( getRegistrationChallengeKey(user.id) ); @@ -238,8 +238,6 @@ router.post( }); } - // Delete challenge from Redis - await Redis.defaultClient.del(getRegistrationChallengeKey(user.id)); ctx.body = { data: { verified: true } }; } else { throw ValidationError("Verification failed"); @@ -301,8 +299,8 @@ router.post( const body = ctx.input.body; const { challengeId, client = Client.Web } = body; - // Retrieve challenge from Redis - const expectedChallenge = await Redis.defaultClient.get( + // Consume the challenge atomically so it can only be used once + const expectedChallenge = await Redis.defaultClient.getdel( getAuthenticationChallengeKey(challengeId) ); @@ -371,9 +369,6 @@ router.post( passkey.lastActiveAt = new Date(); await passkey.save({ silent: true }); - // Delete challenge from Redis - await Redis.defaultClient.del(getAuthenticationChallengeKey(challengeId)); - // Use the signIn utility which handles all sign-in logic await signIn(ctx, "passkeys", { user, From ebe842b1f5410c828756ff0d71a4c00f0115e598 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Thu, 12 Nov 2026 22:10:31 -0500 Subject: [PATCH 37/41] fix: Sticky hover state on sidebar items on touch screens (#14570) --- app/components/Sidebar/components/Disclosure.tsx | 4 ++-- app/components/Sidebar/components/SidebarActions.tsx | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/components/Sidebar/components/Disclosure.tsx b/app/components/Sidebar/components/Disclosure.tsx index 0a2dad9004..60c457da46 100644 --- a/app/components/Sidebar/components/Disclosure.tsx +++ b/app/components/Sidebar/components/Disclosure.tsx @@ -2,7 +2,7 @@ import { CollapsedIcon } from "outline-icons"; import * as React from "react"; import { useTranslation } from "react-i18next"; import styled from "styled-components"; -import { extraArea, s } from "@shared/styles"; +import { extraArea, hover, s } from "@shared/styles"; import NudeButton from "~/components/NudeButton"; type Props = React.ComponentProps & { @@ -34,7 +34,7 @@ const Button = styled(NudeButton)` margin: 2px; ${extraArea(4)} - &:hover { + &:${hover} { color: ${s("text")}; background: ${s("sidebarControlHoverBackground")}; } diff --git a/app/components/Sidebar/components/SidebarActions.tsx b/app/components/Sidebar/components/SidebarActions.tsx index d4552ca886..571950b193 100644 --- a/app/components/Sidebar/components/SidebarActions.tsx +++ b/app/components/Sidebar/components/SidebarActions.tsx @@ -1,14 +1,15 @@ import styled, { css } from "styled-components"; import EventBoundary from "@shared/components/EventBoundary"; -import { s } from "@shared/styles"; +import { hover, s } from "@shared/styles"; import NudeButton from "~/components/NudeButton"; /** * Selector list matching a sidebar row that is hovered, pressed, or has one * of its menus open. Radix marks the open trigger with `data-state="open"`: - * the row itself for a context menu, a descendant button for a dropdown. + * the row itself for a context menu, a descendant button for a dropdown. On + * touch devices `:hover` sticks after a tap, so only `:active` is matched. */ -export const hoveredOrMenuOpen = `&:hover, &:active, &[data-state="open"], &:has([data-state="open"])`; +export const hoveredOrMenuOpen = `&:${hover}, &:active, &[data-state="open"], &:has([data-state="open"])`; /** * Trailing action buttons for a sidebar row. Hidden until the row reveals From 7a87534789c09bee45596c6be3e0e24d2daf169c Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Thu, 12 Nov 2026 22:11:39 -0500 Subject: [PATCH 38/41] chore: Replace Gitbeaker with a small GitLab API client (#14548) * chore: Replace Gitbeaker with a small GitLab API client * test: Cover GitLab token refresh --- package.json | 1 - plugins/gitlab/server/api/gitlab.ts | 2 +- plugins/gitlab/server/gitlab.test.ts | 238 ++++++++++++++ plugins/gitlab/server/gitlab.ts | 468 +++++++++++++++++---------- yarn.lock | 57 +--- 5 files changed, 531 insertions(+), 235 deletions(-) create mode 100644 plugins/gitlab/server/gitlab.test.ts diff --git a/package.json b/package.json index bf512f5a78..599ca31591 100644 --- a/package.json +++ b/package.json @@ -76,7 +76,6 @@ "@fortawesome/free-solid-svg-icons": "^7.3.1", "@fortawesome/react-fontawesome": "^3.5.0", "@getoutline/react-roving-tabindex": "^3.2.4", - "@gitbeaker/rest": "^43.8.0", "@hocuspocus/extension-redis": "1.1.3", "@hocuspocus/extension-throttle": "1.1.3", "@hocuspocus/provider": "1.1.3", diff --git a/plugins/gitlab/server/api/gitlab.ts b/plugins/gitlab/server/api/gitlab.ts index 79043a6fe2..bb36262043 100644 --- a/plugins/gitlab/server/api/gitlab.ts +++ b/plugins/gitlab/server/api/gitlab.ts @@ -269,7 +269,7 @@ router.get( account: { id: userInfo.id, name: userInfo.username, - avatarUrl: userInfo.avatar_url, + avatarUrl: userInfo.avatar_url ?? "", }, }, }, diff --git a/plugins/gitlab/server/gitlab.test.ts b/plugins/gitlab/server/gitlab.test.ts new file mode 100644 index 0000000000..d0dc83a937 --- /dev/null +++ b/plugins/gitlab/server/gitlab.test.ts @@ -0,0 +1,238 @@ +import { randomUUID } from "node:crypto"; +import { addHours, subHours } from "date-fns"; +import { http, HttpResponse } from "msw"; +import { IntegrationService, IntegrationType } from "@shared/types"; +import { Integration, IntegrationAuthentication } from "@server/models"; +import { buildUser } from "@server/test/factories"; +import { server } from "@server/test/msw"; +import { GitLab } from "./gitlab"; + +const author = { id: 7, username: "octo", avatar_url: "https://a.test/a.png" }; + +const buildBaseUrl = () => `https://${randomUUID()}.example.com`; + +async function buildGitLabIntegration({ + teamId, + userId, + url, + expiresAt = addHours(new Date(), 1), +}: { + teamId: string; + userId: string; + url: string; + expiresAt?: Date; +}) { + const authentication = await IntegrationAuthentication.create({ + service: IntegrationService.GitLab, + userId, + teamId, + clientId: "client-id", + clientSecret: "client-secret", + token: "token", + refreshToken: "refresh", + expiresAt, + }); + + const integration = await Integration.create({ + service: IntegrationService.GitLab, + type: IntegrationType.Embed, + userId, + teamId, + authenticationId: authentication.id, + settings: { gitlab: { url } }, + }); + return { integration, authentication }; +} + +describe("GitLab", () => { + describe("getIssue", () => { + it("should request the issue with an encoded project path", async () => { + const customUrl = buildBaseUrl(); + let requestUrl: URL | undefined; + let authorization: string | null = null; + server.use( + http.get( + `${customUrl}/api/v4/projects/:project/issues`, + ({ request }) => { + requestUrl = new URL(request.url); + authorization = request.headers.get("authorization"); + return HttpResponse.json([ + { + iid: 12, + title: "Fix it", + description: "Details", + web_url: `${customUrl}/group/repo/-/issues/12`, + state: "opened", + author, + labels: [{ name: "bug", color: "#ff0000" }], + created_at: "2026-01-01T00:00:00Z", + }, + ]); + } + ) + ); + + const issue = await GitLab.getIssue({ + accessToken: "token", + customUrl, + path: "group/repo", + id: 12, + }); + + expect(issue.title).toEqual("Fix it"); + expect(requestUrl?.pathname).toEqual( + "/api/v4/projects/group%2Frepo/issues" + ); + expect(requestUrl?.searchParams.get("iids[]")).toEqual("12"); + expect(authorization).toEqual("Bearer token"); + }); + }); + + describe("getProjects", () => { + it("should follow pagination", async () => { + const user = await buildUser(); + const pages: (string | null)[] = []; + server.use( + http.get("https://gitlab.com/api/v4/projects", ({ request }) => { + const page = new URL(request.url).searchParams.get("page"); + pages.push(page); + return HttpResponse.json( + [ + { + id: Number(page), + name: `project-${page}`, + namespace: { id: 1, full_path: "group" }, + }, + ], + { headers: { "x-next-page": page === "1" ? "2" : "" } } + ); + }) + ); + + const projects = await GitLab.getProjects({ + accessToken: "token", + teamId: user.teamId, + }); + + expect(pages).toEqual(["1", "2"]); + expect(projects.map((project) => project.name)).toEqual([ + "project-1", + "project-2", + ]); + }); + }); + + describe("unfurl", () => { + it("should refresh an expired token and use the new token", async () => { + const user = await buildUser(); + const customUrl = buildBaseUrl(); + const { authentication } = await buildGitLabIntegration({ + teamId: user.teamId, + userId: user.id, + url: customUrl, + expiresAt: subHours(new Date(), 1), + }); + let tokenRequest: Record | undefined; + let authorization: string | null = null; + server.use( + http.post(`${customUrl}/oauth/token`, async ({ request }) => { + tokenRequest = (await request.json()) as Record; + return HttpResponse.json({ + access_token: "new-token", + token_type: "Bearer", + expires_in: 7200, + refresh_token: "new-refresh", + scope: "read_api read_user", + created_at: 0, + }); + }), + http.get( + `${customUrl}/api/v4/projects/:project/merge_requests/5`, + ({ request }) => { + authorization = request.headers.get("authorization"); + return HttpResponse.json({ + iid: 5, + title: "Change", + web_url: `${customUrl}/group/repo/-/merge_requests/5`, + state: "opened", + author, + created_at: "2026-01-01T00:00:00Z", + }); + } + ) + ); + + const result = await GitLab.unfurl( + `${customUrl}/group/repo/-/merge_requests/5`, + user + ); + + expect(result).toMatchObject({ title: "Change" }); + expect(tokenRequest).toMatchObject({ + grant_type: "refresh_token", + refresh_token: "refresh", + client_id: "client-id", + client_secret: "client-secret", + }); + expect(authorization).toEqual("Bearer new-token"); + + await authentication.reload(); + expect(authentication.token).toEqual("new-token"); + expect(authentication.refreshToken).toEqual("new-refresh"); + }); + + it("should unfurl a project without progress when statistics fail", async () => { + const user = await buildUser(); + const customUrl = buildBaseUrl(); + await buildGitLabIntegration({ + teamId: user.teamId, + userId: user.id, + url: customUrl, + }); + server.use( + http.get(`${customUrl}/api/v4/projects/:project`, () => + HttpResponse.json({ + id: 1, + name: "repo", + web_url: `${customUrl}/group/repo`, + visibility: "public", + created_at: "2026-01-01T00:00:00Z", + }) + ), + http.get( + `${customUrl}/api/v4/projects/:project/issues_statistics`, + () => HttpResponse.json({}, { status: 500 }) + ) + ); + + const result = await GitLab.unfurl(`${customUrl}/group/repo`, user); + + expect(result).toMatchObject({ name: "repo", progress: undefined }); + }); + + it("should not return the response body of a failed request", async () => { + const user = await buildUser(); + const customUrl = buildBaseUrl(); + await buildGitLabIntegration({ + teamId: user.teamId, + userId: user.id, + url: customUrl, + }); + server.use( + http.get(`${customUrl}/api/v4/projects/:project/merge_requests/5`, () => + HttpResponse.json({ message: "secret" }, { status: 500 }) + ) + ); + + const result = await GitLab.unfurl( + `${customUrl}/group/repo/-/merge_requests/5`, + user + ); + + expect(result).toEqual({ + error: + "Error while requesting /projects/group%2Frepo/merge_requests/5 from GitLab; status: 500", + }); + }); + }); +}); diff --git a/plugins/gitlab/server/gitlab.ts b/plugins/gitlab/server/gitlab.ts index 63edcaac72..97e075408e 100644 --- a/plugins/gitlab/server/gitlab.ts +++ b/plugins/gitlab/server/gitlab.ts @@ -1,12 +1,3 @@ -import { Gitlab } from "@gitbeaker/rest"; -import type { - EpicSchema, - IssueSchemaWithExpandedLabels, - MergeRequestSchema, - ProjectSchema, - SimpleLabelSchema, - StatisticsSchema, -} from "@gitbeaker/rest"; import z from "zod"; import { type IntegrationType, @@ -14,6 +5,7 @@ import { UnfurlResourceType, } from "@shared/types"; import { toError, errToString } from "@shared/utils/error"; +import { Second } from "@shared/utils/time"; import Logger from "@server/logging/Logger"; import type { User } from "@server/models"; import { Integration, IntegrationAuthentication } from "@server/models"; @@ -22,8 +14,7 @@ import type { UnfurlProject, UnfurlSignature, } from "@server/types"; -import fetch from "@server/utils/fetch"; -import { validateUrlNotPrivate } from "@server/utils/url"; +import fetch, { type Headers } from "@server/utils/fetch"; import { GitLabUtils } from "../shared/GitLabUtils"; import env from "./env"; @@ -36,10 +27,97 @@ const AccessTokenResponseSchema = z.object({ created_at: z.number(), }); -export class GitLab { - private static clientSecret = env.GITLAB_CLIENT_SECRET; - private static clientId = env.GITLAB_CLIENT_ID; +const UserSchema = z.object({ + id: z.number(), + username: z.string(), + avatar_url: z.string().nullish(), +}); +const LabelSchema = z.object({ + name: z.string(), + color: z.string(), +}); + +const IssueSchema = z.object({ + iid: z.number(), + title: z.string(), + description: z.string().nullish(), + web_url: z.string(), + state: z.string(), + author: UserSchema.nullish(), + labels: z.array(LabelSchema), + created_at: z.string(), +}); + +// Epics are returned without label color details. +const EpicSchema = IssueSchema.extend({ + labels: z.array(z.string()), +}); + +const MergeRequestSchema = z.object({ + iid: z.number(), + title: z.string(), + description: z.string().nullish(), + web_url: z.string(), + state: z.string(), + author: UserSchema, + draft: z.boolean().nullish(), + merged_at: z.string().nullish(), + created_at: z.string(), +}); + +const NamespaceSchema = z.object({ + id: z.number(), + full_path: z.string(), +}); + +const SimpleProjectSchema = z.object({ + id: z.number(), + name: z.string(), + namespace: NamespaceSchema, +}); + +const ProjectSchema = z.object({ + id: z.number(), + name: z.string(), + description: z.string().nullish(), + web_url: z.string(), + avatar_url: z.string().nullish(), + visibility: z.string().nullish(), + owner: z + .object({ name: z.string(), avatar_url: z.string().nullish() }) + .nullish(), + topics: z.array(z.string()).nullish(), + created_at: z.string(), +}); + +const IssueStatisticsSchema = z.object({ + statistics: z.object({ + counts: z.object({ + opened: z.number(), + closed: z.number(), + }), + }), +}); + +type Issue = z.infer; +type Epic = z.infer; +type MergeRequest = z.infer; +type SimpleProject = z.infer; +type Project = z.infer; +type IssueStatistics = z.infer; + +interface RequestParams { + accessToken: string; + customUrl?: string; +} + +interface ResourceParams extends RequestParams { + path: string; + id: number; +} + +export class GitLab { /** * Fetches the custom GitLab URL for a team from the first matching * integration, falling back to the default. @@ -58,93 +136,90 @@ export class GitLab { return url || GitLabUtils.defaultGitlabUrl; } - /** - * Creates a Gitbeaker client instance. - * - * @param accessToken - The access token for authentication. - * @param customUrl - Optional custom GitLab URL from integration settings. - * @returns A configured Gitbeaker client. - */ - public static async createClient(accessToken: string, customUrl?: string) { - const host = customUrl || GitLabUtils.defaultGitlabUrl; - - // Validate the URL to prevent SSRF as GitLab instance does not use our - // fetch wrapper which has built-in SSRF protection. - await validateUrlNotPrivate(host); - - return new Gitlab({ - host, - oauthToken: accessToken, - }); - } - /** * Fetches an issue from a GitLab project. * - * @param accessToken - The access token for authentication. - * @param projectPath - The project path (owner/repo). - * @param issueIid - The issue IID (internal ID within the project). - * @param customUrl - Optional custom GitLab URL from integration settings. + * @param params.accessToken - The access token for authentication. + * @param params.customUrl - Optional custom GitLab URL from integration settings. + * @param params.path - The project path (owner/repo). + * @param params.id - The issue IID (internal ID within the project). * @returns The issue data. + * @throws If the issue does not exist. */ - public static async getIssue( - accessToken: string, - projectPath: string, - issueIid: number, - customUrl?: string - ) { - const client = await this.createClient(accessToken, customUrl); - - const issues = await client.Issues.all({ - projectId: projectPath, - iids: [issueIid], - withLabelsDetails: true, + public static async getIssue({ path, id, ...params }: ResourceParams) { + const { data } = await this.request({ + ...params, + path: `/projects/${encodeURIComponent(path)}/issues?iids[]=${id}&with_labels_details=true`, + schema: z.array(IssueSchema), }); - if (!issues || issues.length === 0) { - throw new Error(`Issue ${issueIid} not found in project ${projectPath}`); + if (data.length === 0) { + throw new Error(`Issue ${id} not found in project ${path}`); } - return issues[0]; + return data[0]; } /** * Fetches an epic from a GitLab group. * - * @param accessToken - The access token for authentication. - * @param groupPath - The full path of the group. - * @param epicIid - The epic IID (internal ID within the group). - * @param customUrl - Optional custom GitLab URL from integration settings. + * @param params.accessToken - The access token for authentication. + * @param params.customUrl - Optional custom GitLab URL from integration settings. + * @param params.path - The full path of the group. + * @param params.id - The epic IID (internal ID within the group). * @returns The epic data. */ - public static async getEpic( - accessToken: string, - groupPath: string, - epicIid: number, - customUrl?: string - ) { - const client = await this.createClient(accessToken, customUrl); - return client.Epics.show(groupPath, epicIid); + public static async getEpic({ path, id, ...params }: ResourceParams) { + const { data } = await this.request({ + ...params, + path: `/groups/${encodeURIComponent(path)}/epics/${id}`, + schema: EpicSchema, + }); + return data; } /** * Fetches a merge request from a GitLab project. * - * @param accessToken - The access token for authentication. - * @param projectPath - The project path (owner/repo). - * @param mrIid - The merge request IID (internal ID within the project). - * @param customUrl - Optional custom GitLab URL from integration settings. + * @param params.accessToken - The access token for authentication. + * @param params.customUrl - Optional custom GitLab URL from integration settings. + * @param params.path - The project path (owner/repo). + * @param params.id - The merge request IID (internal ID within the project). * @returns The merge request data. */ - public static async getMergeRequest( - accessToken: string, - projectPath: string, - mrIid: number, - customUrl?: string - ) { - const client = await this.createClient(accessToken, customUrl); - const mr = await client.MergeRequests.show(projectPath, mrIid); - return mr; + public static async getMergeRequest({ path, id, ...params }: ResourceParams) { + const { data } = await this.request({ + ...params, + path: `/projects/${encodeURIComponent(path)}/merge_requests/${id}`, + schema: MergeRequestSchema, + }); + return data; + } + + /** + * Fetches a GitLab project and its issue statistics. + * + * @param params.accessToken - The access token for authentication. + * @param params.customUrl - Optional custom GitLab URL from integration settings. + * @param params.path - The project path (owner/repo). + * @returns The project data and its issue statistics, if available. + */ + public static async getProject({ + path, + ...params + }: RequestParams & { path: string }) { + const projectPath = `/projects/${encodeURIComponent(path)}`; + const [project, issueStats] = await Promise.all([ + this.request({ ...params, path: projectPath, schema: ProjectSchema }), + // Statistics can be slow for projects with many issues, so they are optional. + this.request({ + ...params, + path: `${projectPath}/issues_statistics`, + schema: IssueStatisticsSchema, + }).catch(() => undefined), + ]); + + return { project: project.data, issueStats: issueStats?.data }; } /** @@ -154,26 +229,21 @@ export class GitLab { * @param params.customUrl - Optional custom GitLab URL. Falls back to default. * @returns User information including the resolved URL. */ - public static async getCurrentUser({ - accessToken, - customUrl, - }: { - accessToken: string; - customUrl?: string; - }) { - const url = customUrl || GitLabUtils.defaultGitlabUrl; - const client = await this.createClient(accessToken, url); - - const userData = await client.Users.showCurrentUser({ - showExpanded: false, + public static async getCurrentUser(params: RequestParams) { + const url = params.customUrl || GitLabUtils.defaultGitlabUrl; + const { data } = await this.request({ + ...params, + path: "/user", + schema: UserSchema, }); - return { ...userData, url }; + return { ...data, url }; } /** - * Fetches projects accessible to the user. + * Fetches projects that the user can maintain. * - * @param accessToken - Access token for authentication. + * @param params.accessToken - Access token for authentication. + * @param params.teamId - The team ID used to find the GitLab URL. * @returns Array of projects. */ public static async getProjects({ @@ -184,13 +254,22 @@ export class GitLab { teamId: string; }) { const customUrl = await this.getGitLabUrl(teamId); - const client = await this.createClient(accessToken, customUrl); + const projects: SimpleProject[] = []; + let page: string | null = "1"; + + for (let i = 0; i < this.maxPages && page; i++) { + const res: { data: SimpleProject[]; headers: Headers } = + await this.request({ + accessToken, + customUrl, + // At least Maintainer access to reduce the sheer volume of projects. + path: `/projects?simple=true&min_access_level=40&per_page=100&page=${page}`, + schema: z.array(SimpleProjectSchema), + }); + projects.push(...res.data); + page = res.headers.get("x-next-page"); + } - const projects = await client.Projects.all({ - simple: true, - perPage: 100, - minAccessLevel: 40, // At least Maintainer access to reduce the sheer volume of projects - }); return projects; } @@ -250,7 +329,7 @@ export class GitLab { try { const customUrl = matchedIntegration.settings?.gitlab?.url; const { authentication } = matchedIntegration; - const token = await authentication.refreshTokenIfNeeded( + const accessToken = await authentication.refreshTokenIfNeeded( async (refreshToken: string) => GitLab.refreshToken({ refreshToken, @@ -265,41 +344,41 @@ export class GitLab { resource.type === UnfurlResourceType.Issue && resource.scope === "group" ) { - const epic = await this.getEpic( - token, - resource.owner, - resource.id, - customUrl - ); + const epic = await this.getEpic({ + accessToken, + customUrl, + path: resource.owner, + id: resource.id, + }); return this.transformIssue(epic); } - const projectPath = `${resource.owner}/${resource.repo}`; + const path = `${resource.owner}/${resource.repo}`; if (resource.type === UnfurlResourceType.Issue) { - const issue = await this.getIssue( - token, - projectPath, - resource.id, - customUrl - ); + const issue = await this.getIssue({ + accessToken, + customUrl, + path, + id: resource.id, + }); return this.transformIssue(issue); } else if (resource.type === UnfurlResourceType.PR) { - const mr = await this.getMergeRequest( - token, - projectPath, - resource.id, - customUrl - ); + const mr = await this.getMergeRequest({ + accessToken, + customUrl, + path, + id: resource.id, + }); return this.transformMR(mr); } else if (resource.type === UnfurlResourceType.Project) { - const client = await this.createClient(token, customUrl); - const [project, issueStats] = await Promise.all([ - client.Projects.show(projectPath), - client.IssuesStatistics.all({ projectId: projectPath }), - ]); + const { project, issueStats } = await this.getProject({ + accessToken, + customUrl, + path, + }); return this.transformProject(project, issueStats); } @@ -321,7 +400,7 @@ export class GitLab { * @param params.clientSecret - Optional custom client secret (falls back to env var). * @returns The parsed access token response. */ - public static oauthAccess = async ({ + public static async oauthAccess({ code, customUrl, clientId, @@ -331,30 +410,61 @@ export class GitLab { customUrl?: string; clientId?: string; clientSecret?: string; - }) => { - const url = customUrl || GitLabUtils.defaultGitlabUrl; - const res = await fetch(GitLabUtils.getOauthUrl(url) + "/token", { - method: "POST", + }) { + return this.requestToken(customUrl, { + code: code ?? "", + client_id: clientId || this.clientId || "", + client_secret: clientSecret || this.clientSecret || "", + grant_type: "authorization_code", + redirect_uri: GitLabUtils.callbackUrl(), + }); + } + + /** The time to wait for a response from a GitLab instance. */ + private static timeout = 10 * Second.ms; + + /** The maximum number of pages to fetch from a paginated endpoint. */ + private static maxPages = 10; + + private static clientSecret = env.GITLAB_CLIENT_SECRET; + + private static clientId = env.GITLAB_CLIENT_ID; + + /** + * Makes an authenticated GET request to the GitLab API. + * + * @param params.accessToken - The access token for authentication. + * @param params.customUrl - Optional custom GitLab URL from integration settings. + * @param params.path - The API path, starting with a slash. + * @param params.schema - The schema to parse the response body with. + * @returns The parsed body and the response headers. + * @throws If the response status is not successful. + */ + private static async request({ + accessToken, + customUrl, + path, + schema, + }: RequestParams & { path: string; schema: T }) { + const baseUrl = customUrl || GitLabUtils.defaultGitlabUrl; + const res = await fetch(`${baseUrl}/api/v4${path}`, { + timeout: this.timeout, headers: { - "Content-Type": "application/json", + Accept: "application/json", + Authorization: `Bearer ${accessToken}`, }, - body: JSON.stringify({ - code, - client_id: clientId || this.clientId, - client_secret: clientSecret || this.clientSecret, - grant_type: "authorization_code", - redirect_uri: GitLabUtils.callbackUrl(), - }), }); - if (res.status !== 200) { + if (!res.ok) { throw new Error( - `Error while validating oauth code from GitLab; status: ${res.status}` + `Error while requesting ${path} from GitLab; status: ${res.status}` ); } - return AccessTokenResponseSchema.parse(await res.json()); - }; + // Read the body at once, a body left unread while awaiting other requests + // can be closed early. + return { data: schema.parse(await res.json()), headers: res.headers }; + } private static async refreshToken({ refreshToken, @@ -367,39 +477,40 @@ export class GitLab { clientId?: string; clientSecret?: string; }) { - const queryParams = new URLSearchParams({ - client_id: clientId || this.clientId!, - client_secret: clientSecret || this.clientSecret!, - grant_type: "refresh_token", + return this.requestToken(customUrl, { refresh_token: refreshToken, + client_id: clientId || this.clientId || "", + client_secret: clientSecret || this.clientSecret || "", + grant_type: "refresh_token", redirect_uri: GitLabUtils.callbackUrl(), }); + } + + private static async requestToken( + customUrl: string | undefined, + body: Record + ) { + const res = await fetch(`${GitLabUtils.getOauthUrl(customUrl)}/token`, { + method: "POST", + timeout: this.timeout, + headers: { + "Content-Type": "application/json", + Accept: "application/json", + }, + body: JSON.stringify(body), + }); - const res = await fetch( - `${GitLabUtils.getOauthUrl(customUrl)}/token?${queryParams.toString()}`, - { - method: "POST", - headers: { - "Content-Type": "application/x-www-form-urlencoded", - Accept: "application/json", - }, - } - ); - const resJson = await res.json(); if (res.status !== 200) { - Logger.error("failed to refresh access token from GitLab", resJson); throw new Error( - `Error while refreshing access token from GitLab; status: ${res.status}` + `Error while requesting access token from GitLab; status: ${res.status}` ); } - return AccessTokenResponseSchema.parse(resJson); + return AccessTokenResponseSchema.parse(await res.json()); } - private static transformIssue( - issue: IssueSchemaWithExpandedLabels | EpicSchema - ) { - const labels: (string | SimpleLabelSchema)[] = issue.labels; + private static transformIssue(issue: Issue | Epic) { + const labels: (string | z.infer)[] = issue.labels; return { type: UnfurlResourceType.Issue, @@ -411,7 +522,6 @@ export class GitLab { name: issue.author?.username ?? "", avatarUrl: issue.author?.avatar_url ?? "", }, - // Epics are returned without label color details. labels: labels.map((label) => typeof label === "string" ? { name: label, color: GitLabUtils.defaultLabelColor } @@ -425,8 +535,10 @@ export class GitLab { } satisfies UnfurlIssueOrPR; } - private static transformMR(mr: MergeRequestSchema) { + private static transformMR(mr: MergeRequest) { const mrState = mr.merged_at ? "merged" : mr.state; + const draft = !!mr.draft; + return { type: UnfurlResourceType.PR, url: mr.web_url, @@ -435,28 +547,30 @@ export class GitLab { description: GitLabUtils.sanitizeGitLabMarkdown(mr.description) ?? "", author: { name: mr.author.username, - avatarUrl: mr.author.avatar_url, + avatarUrl: mr.author.avatar_url ?? "", }, state: { name: mrState, - color: GitLabUtils.getColorForStatus(mrState, !!mr.draft), - draft: mr.draft, + color: GitLabUtils.getColorForStatus(mrState, draft), + draft, }, createdAt: mr.created_at, } satisfies UnfurlIssueOrPR; } private static transformProject( - project: ProjectSchema, - issueStats: StatisticsSchema + project: Project, + issueStats?: IssueStatistics ) { const visibility = project.visibility ?? "private"; - const owner = project.owner as - | { name: string; avatar_url?: string } - | undefined; - const { opened, closed } = issueStats.statistics.counts; - const total = opened + closed; - const progress = total > 0 ? closed / total : 0; + const { owner } = project; + const counts = issueStats?.statistics.counts; + let progress: number | undefined; + + if (counts) { + const total = counts.opened + counts.closed; + progress = total > 0 ? counts.closed / total : 0; + } return { type: UnfurlResourceType.Project, @@ -477,7 +591,7 @@ export class GitLab { name: visibility.charAt(0).toUpperCase() + visibility.slice(1), color: GitLabUtils.getColorForVisibility(visibility), }, - labels: (project.topics ?? []).map((topic: string) => ({ + labels: (project.topics ?? []).map((topic) => ({ name: topic, color: GitLabUtils.defaultLabelColor, })), diff --git a/yarn.lock b/yarn.lock index 2773b2649f..9d88d12bf2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2251,39 +2251,6 @@ __metadata: languageName: node linkType: hard -"@gitbeaker/core@npm:^43.8.0": - version: 43.8.0 - resolution: "@gitbeaker/core@npm:43.8.0" - dependencies: - "@gitbeaker/requester-utils": "npm:^43.8.0" - qs: "npm:^6.14.0" - xcase: "npm:^2.0.1" - checksum: 10c0/5913aea8ae89b30f37693093fe68a94fbe4ab2737e661ba6795b3d22463ffa63806076b392b938d4c662d691c0114facc022bcdde29297e7b6617b146c449ff6 - languageName: node - linkType: hard - -"@gitbeaker/requester-utils@npm:^43.8.0": - version: 43.8.0 - resolution: "@gitbeaker/requester-utils@npm:43.8.0" - dependencies: - picomatch-browser: "npm:^2.2.6" - qs: "npm:^6.14.0" - rate-limiter-flexible: "npm:^8.0.1" - xcase: "npm:^2.0.1" - checksum: 10c0/07fd5af56fa3b577009bac6fc59a9b54b3e188a8b412c926b253b21528fb46f8ab02dbeba5c032a9a77d169a69208550147a099c71681d5b9193c87224db8d19 - languageName: node - linkType: hard - -"@gitbeaker/rest@npm:^43.8.0": - version: 43.8.0 - resolution: "@gitbeaker/rest@npm:43.8.0" - dependencies: - "@gitbeaker/core": "npm:^43.8.0" - "@gitbeaker/requester-utils": "npm:^43.8.0" - checksum: 10c0/f3b25c6a67c25f9d5aac4674bacd36321c06bedd55e4fe859cba569e6c0121ac00d41838094ca7e19dc3158f59e57f8bae7d565b2e7d308904a3bbe234152b8b - languageName: node - linkType: hard - "@graphql-typed-document-node/core@npm:^3.2.0": version: 3.2.0 resolution: "@graphql-typed-document-node/core@npm:3.2.0" @@ -14028,7 +13995,6 @@ __metadata: "@fortawesome/free-solid-svg-icons": "npm:^7.3.1" "@fortawesome/react-fontawesome": "npm:^3.5.0" "@getoutline/react-roving-tabindex": "npm:^3.2.4" - "@gitbeaker/rest": "npm:^43.8.0" "@hocuspocus/extension-redis": "npm:1.1.3" "@hocuspocus/extension-throttle": "npm:1.1.3" "@hocuspocus/provider": "npm:1.1.3" @@ -15080,13 +15046,6 @@ __metadata: languageName: node linkType: hard -"picomatch-browser@npm:^2.2.6": - version: 2.2.6 - resolution: "picomatch-browser@npm:2.2.6" - checksum: 10c0/bf97d3e6f77dee776fe4cc7728037931b681c56e1fd964023ed797de341a0e32dcc1e90a5552cc74923cb97566464870a37be188b09e3db7279f9e9a9b12d977 - languageName: node - linkType: hard - "picomatch@npm:^2.0.4, picomatch@npm:^2.3.1": version: 2.3.2 resolution: "picomatch@npm:2.3.2" @@ -15555,7 +15514,7 @@ __metadata: languageName: node linkType: hard -"qs@npm:^6.14.0, qs@npm:^6.5.2": +"qs@npm:^6.5.2": version: 6.16.1 resolution: "qs@npm:6.16.1" dependencies: @@ -15601,13 +15560,6 @@ __metadata: languageName: node linkType: hard -"rate-limiter-flexible@npm:^8.0.1": - version: 8.3.0 - resolution: "rate-limiter-flexible@npm:8.3.0" - checksum: 10c0/30b0aad1128b5a5cff44b289c6083be6ee782389015c1a93f854b1f07a682e539fcd48a3b983c828271b8f8ade3c930055edc2cf376915a3300a0d572d911244 - languageName: node - linkType: hard - "raw-body@npm:^2.3.3": version: 2.5.3 resolution: "raw-body@npm:2.5.3" @@ -19415,13 +19367,6 @@ __metadata: languageName: node linkType: hard -"xcase@npm:^2.0.1": - version: 2.0.1 - resolution: "xcase@npm:2.0.1" - checksum: 10c0/11b8ae8f6734b29d442a5acf1dff3a896cabbf49e7ffa01472ff6fa687a6e6f6a25889d06c10a41950e7a90fe89239fa78d95eab0c5eb654ca75f0ccd71ba8ed - languageName: node - linkType: hard - "xml-name-validator@npm:^5.0.0": version: 5.0.0 resolution: "xml-name-validator@npm:5.0.0" From 306c0fcecfd3ea87a2acafebe026735ebad44519 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Thu, 12 Nov 2026 22:26:49 -0500 Subject: [PATCH 39/41] feat: Show the drag handle only when hovering the side of the editor (#14574) --- app/editor/extensions/DragHandle.ts | 2 +- app/editor/plugins/DragTarget.ts | 78 ++++++++++++++++++----------- 2 files changed, 49 insertions(+), 31 deletions(-) diff --git a/app/editor/extensions/DragHandle.ts b/app/editor/extensions/DragHandle.ts index 703530f153..62ba35274a 100644 --- a/app/editor/extensions/DragHandle.ts +++ b/app/editor/extensions/DragHandle.ts @@ -37,7 +37,7 @@ const hoverPluginKey = new PluginKey(HOVER_META_KEY); /** * Renders a floating drag handle to the left of block-level nodes when the - * user hovers within the editor, and lets the user drag the block to reorder + * user hovers near the side of the editor, and lets the user drag the block to reorder * it. The handle is a real, always-draggable DOM element rather than a CSS * pseudo on the block, which keeps drag-and-drop working uniformly across * node types regardless of whether the schema declares `draggable: true`. diff --git a/app/editor/plugins/DragTarget.ts b/app/editor/plugins/DragTarget.ts index 9ba2e6d499..95dd87febd 100644 --- a/app/editor/plugins/DragTarget.ts +++ b/app/editor/plugins/DragTarget.ts @@ -18,12 +18,13 @@ export interface ResolvedDragTarget { const LIST_TYPES = ["bullet_list", "ordered_list", "checkbox_list"]; -// Distance outside the content column in which the cursor still finds a block. -const GUTTER_HIT_WIDTH = 60; - // Inset from the content edges, so that posAtCoords lands inside the block. const CONTENT_INSET = 1; +// Fraction of the content width, from the handle side, in which hover shows +// the handle. +const HOVER_ZONE_RATIO = 0.25; + /** * A block in the editor that the drag handle can attach to. Holds the * position of the block in the document and the DOM element that the handle @@ -46,8 +47,9 @@ export class DragTarget { } /** - * Finds the block under the cursor, also when the cursor is in the gutter - * to the side of the content. + * Finds the block at the cursor's height when the cursor is on the side + * where the handle renders, either outside the content or in the first 25% + * of the content width. * * @param view - the editor view. * @param event - the mouse event. @@ -61,17 +63,20 @@ export class DragTarget { if (event.clientY < rect.top || event.clientY > rect.bottom) { return null; } + + // Ignore the cursor over other regions, such as the sidebar or a modal. + const region = view.dom.closest("[role='main']"); + if ( + region && + !(event.target instanceof Node && region.contains(event.target)) + ) { + return null; + } const style = window.getComputedStyle(view.dom); const paddingLeft = parseFloat(style.paddingLeft) || 0; const paddingRight = parseFloat(style.paddingRight) || 0; const contentLeft = rect.left + paddingLeft + CONTENT_INSET; const contentRight = rect.right - paddingRight - CONTENT_INSET; - if ( - event.clientX < contentLeft - GUTTER_HIT_WIDTH || - event.clientX > contentRight + GUTTER_HIT_WIDTH - ) { - return null; - } const projectedX = Math.max( contentLeft, Math.min(contentRight, event.clientX) @@ -80,27 +85,20 @@ export class DragTarget { // Mermaid diagrams hide their source code block and render an SVG widget // next to it — target the underlying code block but anchor the handle to // the visible diagram element. - const mermaid = this.mermaidFromEvent(view, event, projectedX); - if (mermaid) { - return mermaid; + const target = + this.mermaidFromEvent(view, event, projectedX) ?? + this.blockFromCoords(view, projectedX, event.clientY); + if (!target) { + return null; } - const coords = view.posAtCoords({ - left: projectedX, - top: event.clientY, - }); - if (!coords) { - return null; - } - const resolved = this.resolvePos(view.state, coords.pos); - if (!resolved) { - return null; - } - const dom = view.nodeDOM(resolved.pos); - if (!(dom instanceof HTMLElement)) { - return null; - } - return new DragTarget(resolved.pos, dom, resolved.kind); + // Only show the handle when the cursor is on the side it renders on. + const zoneWidth = (contentRight - contentLeft) * HOVER_ZONE_RATIO; + const isRTL = window.getComputedStyle(target.element).direction === "rtl"; + const inZone = isRTL + ? event.clientX >= contentRight - zoneWidth + : event.clientX <= contentLeft + zoneWidth; + return inZone ? target : null; } /** @@ -258,6 +256,26 @@ export class DragTarget { return found; } + private static blockFromCoords( + view: EditorView, + left: number, + top: number + ): DragTarget | null { + const coords = view.posAtCoords({ left, top }); + if (!coords) { + return null; + } + const resolved = this.resolvePos(view.state, coords.pos); + if (!resolved) { + return null; + } + const dom = view.nodeDOM(resolved.pos); + if (!(dom instanceof HTMLElement)) { + return null; + } + return new DragTarget(resolved.pos, dom, resolved.kind); + } + private static mermaidFromEvent( view: EditorView, event: MouseEvent, From e0895fc548c943fe810f492b2ae9fa12387942b3 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Thu, 12 Nov 2026 23:00:42 -0500 Subject: [PATCH 40/41] Refine authentication token handling (#14572) --- server/middlewares/authentication.test.ts | 49 ++++++--- server/middlewares/authentication.ts | 15 +-- server/routes/auth/index.test.ts | 25 +++++ server/routes/auth/index.ts | 116 +++++++++++----------- server/utils/jwt.ts | 4 +- 5 files changed, 124 insertions(+), 85 deletions(-) diff --git a/server/middlewares/authentication.test.ts b/server/middlewares/authentication.test.ts index a0c0eb4cb8..c52c1f3ff1 100644 --- a/server/middlewares/authentication.test.ts +++ b/server/middlewares/authentication.test.ts @@ -348,24 +348,47 @@ describe("Authentication middleware", () => { ); }); - it("should allow passing transfer token as a GET param", async () => { + it("should not accept transfer token as a GET param", async () => { const state = {} as DefaultState; const user = await buildUser(); const authMiddleware = auth(); - await authMiddleware( - buildMockContext({ - request: { - get: vi.fn(() => null), - query: { - token: user.getTransferToken(), + + await expect( + authMiddleware( + buildMockContext({ + request: { + get: vi.fn(() => null), + query: { + token: user.getTransferToken(), + }, }, - }, - state, - cache: {}, - }), - vi.fn() + state, + cache: {}, + }), + vi.fn() + ) + ).rejects.toThrow( + "Session token must be passed in the cookie or Authorization header" ); - expect(state.auth.user.id).toEqual(user.id); + }); + + it("should not accept transfer token in the Authorization header", async () => { + const state = {} as DefaultState; + const user = await buildUser(); + const authMiddleware = auth(); + + await expect( + authMiddleware( + buildMockContext({ + request: { + get: vi.fn(() => `Bearer ${user.getTransferToken()}`), + }, + state, + cache: {}, + }), + vi.fn() + ) + ).rejects.toThrow("Invalid token"); }); it("should return an error for suspended users", async () => { diff --git a/server/middlewares/authentication.ts b/server/middlewares/authentication.ts index 21f259f848..4d7e23e472 100644 --- a/server/middlewares/authentication.ts +++ b/server/middlewares/authentication.ts @@ -10,7 +10,7 @@ import tracer, { import { User, Team, ApiKey, OAuthAuthentication } from "@server/models"; import type { AppContext } from "@server/types"; import { AuthenticationType } from "@server/types"; -import { getJWTPayload, getUserForJWT } from "@server/utils/jwt"; +import { getUserForJWT } from "@server/utils/jwt"; import { AuthenticationError, AuthorizationError, @@ -274,16 +274,11 @@ async function validateAuthentication( await apiKey.updateActiveAt(); } else { // Session tokens are long-lived, so keep them out of transports that end up - // in browser history, referrers, and request logs. Short-lived single-use - // tokens such as transfer are still accepted from anywhere. + // in browser history, referrers, and request logs. if (transport !== "cookie" && transport !== "header") { - const payload = getJWTPayload(token); - - if (payload.type === "session") { - throw AuthenticationError( - "Session token must be passed in the cookie or Authorization header" - ); - } + throw AuthenticationError( + "Session token must be passed in the cookie or Authorization header" + ); } type = AuthenticationType.APP; diff --git a/server/routes/auth/index.test.ts b/server/routes/auth/index.test.ts index adade4cd10..67804cda76 100644 --- a/server/routes/auth/index.test.ts +++ b/server/routes/auth/index.test.ts @@ -82,6 +82,31 @@ describe("auth/redirect", () => { expect(res.status).toEqual(401); }); + + it("should not accept a transfer token twice", async () => { + const user = await buildUser(); + const token = user.getTransferToken(); + + const first = await server.get(`/auth/redirect?token=${token}`, { + redirect: "manual", + }); + expect(first.status).toEqual(302); + + const second = await server.get(`/auth/redirect?token=${token}`, { + redirect: "manual", + }); + expect(second.status).toEqual(401); + }); + + it("should not accept a transfer token on the API", async () => { + const user = await buildUser(); + const res = await server.post("/api/auth.info", { + headers: { + Authorization: `Bearer ${user.getTransferToken()}`, + }, + }); + expect(res.status).toEqual(401); + }); }); describe("auth provider routes", () => { diff --git a/server/routes/auth/index.ts b/server/routes/auth/index.ts index 089badbad3..5d7352a12a 100644 --- a/server/routes/auth/index.ts +++ b/server/routes/auth/index.ts @@ -8,11 +8,10 @@ import authMiddleware from "@server/middlewares/authentication"; import coalesceBody from "@server/middlewares/coaleseBody"; import { Collection, Team, View } from "@server/models"; import AuthenticationHelper from "@server/models/helpers/AuthenticationHelper"; -import type { AppState, AppContext, APIContext } from "@server/types"; -import { AuthenticationType } from "@server/types"; +import type { AppState, AppContext } from "@server/types"; import { verifyCSRFToken } from "@server/middlewares/csrf"; import { clearCSRFCookie } from "@server/utils/csrf"; -import { getJWTPayload } from "@server/utils/jwt"; +import { getUserForJWT } from "@server/utils/jwt"; const app = new Koa(); const router = new Router(); @@ -36,64 +35,61 @@ void (async () => { } })(); -router.get( - "/redirect", - authMiddleware({ type: AuthenticationType.APP }), - async (ctx: APIContext) => { - const { user, service } = ctx.state.auth; - - const payload = getJWTPayload(ctx.state.auth.token); - if (payload.type !== "transfer") { - throw AuthenticationError("Cannot extend token"); - } - - const expires = addMonths(new Date(), 3); - const jwtToken = user.getSessionToken(expires, service); - - // ensure that the lastActiveAt on user is updated to prevent replay requests - await user.updateActiveAt(ctx, true); - - ctx.cookies.set("accessToken", jwtToken, { - sameSite: "lax", - expires, - }); - clearCSRFCookie(ctx); - const [team, collection, view] = await Promise.all([ - Team.findByPk(user.teamId), - Collection.findFirstCollectionForUser(user), - View.findOne({ - where: { - userId: user.id, - }, - }), - ]); - - const defaultCollectionId = team?.defaultCollectionId; - - if (defaultCollectionId) { - const collection = await Collection.findOne({ - where: { - id: defaultCollectionId, - teamId: team.id, - ownerId: null, - }, - }); - - if (collection) { - ctx.redirect(`${team.url}${collection.path}`); - return; - } - } - - const hasViewedDocuments = !!view; - - ctx.redirect( - !hasViewedDocuments && collection - ? `${team?.url}${collection.path}/recent` - : `${team?.url}/home` - ); +router.get("/redirect", async (ctx: AppContext) => { + const { token } = ctx.request.query; + if (typeof token !== "string") { + throw AuthenticationError("Missing token"); } -); + + // Transfer tokens are only accepted here, to be exchanged for a session. + const { user, service } = await getUserForJWT(token, ["transfer"]); + + const expires = addMonths(new Date(), 3); + const jwtToken = user.getSessionToken(expires, service); + + // ensure that the lastActiveAt on user is updated to prevent replay requests + await user.updateActiveAt(ctx, true); + + ctx.cookies.set("accessToken", jwtToken, { + sameSite: "lax", + expires, + }); + clearCSRFCookie(ctx); + const [team, collection, view] = await Promise.all([ + Team.findByPk(user.teamId), + Collection.findFirstCollectionForUser(user), + View.findOne({ + where: { + userId: user.id, + }, + }), + ]); + + const defaultCollectionId = team?.defaultCollectionId; + + if (defaultCollectionId) { + const collection = await Collection.findOne({ + where: { + id: defaultCollectionId, + teamId: team.id, + ownerId: null, + }, + }); + + if (collection) { + ctx.redirect(`${team.url}${collection.path}`); + return; + } + } + + const hasViewedDocuments = !!view; + + ctx.redirect( + !hasViewedDocuments && collection + ? `${team?.url}${collection.path}/recent` + : `${team?.url}/home` + ); +}); app.use(bodyParser()); app.use(coalesceBody()); diff --git a/server/utils/jwt.ts b/server/utils/jwt.ts index 190ee1745d..18a9f95515 100644 --- a/server/utils/jwt.ts +++ b/server/utils/jwt.ts @@ -40,14 +40,14 @@ export function getJWTPayload(token: string) { * Retrieves the user associated with a JWT token, validating the token's type and expiration. * * @param token The JWT token to validate and extract the user from. - * @param allowedTypes An array of allowed token types (default: ["session", "transfer"]). The token's type must be included in this array to be considered valid. + * @param allowedTypes An array of allowed token types (default: ["session"]). The token's type must be included in this array to be considered valid. * @returns An object containing the user associated with the token, an optional service string if included in the token's payload, and the time the token expires at if it has one. * @throws AuthenticationError if the token is missing, invalid, expired, or if the token's type is not allowed. * @throws UserSuspendedError if the user associated with the token is suspended. */ export async function getUserForJWT( token: string, - allowedTypes = ["session", "transfer"] + allowedTypes = ["session"] ): Promise<{ user: User; service?: string; expiresAt?: Date }> { const payload = getJWTPayload(token); const expiresAt = payload.expiresAt ? new Date(payload.expiresAt) : undefined; From bcf282a2f67a7391ac311b66e7bf9ca9861c63ae Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Thu, 12 Nov 2026 23:01:55 -0500 Subject: [PATCH 41/41] feat: Auto-save settings and tidy settings layout (#14569) * feat: Auto-save General and Profile settings, add settings sections - Save General and Profile fields on change and remove the Save button - Add SettingsSection with consistent spacing and a tinted Danger block - Right-align setting controls and center switches in their row - Let descriptions use the full row width beside switches * fix: Avoid settings autosave overwrites and IME Enter saves - Send only the changed team preference so concurrent saves do not revert each other - Save separate editing as a single preference instead of the whole team - Treat a cleared color input as empty so the default is restored - Ignore Enter during IME composition * feat: Add change and remove icon buttons below image inputs - Replace the Remove button with edit and trash icon buttons with tooltips - Show an upload icon on the image hover overlay - Re-render ImageInput when the image changes so the remove action appears immediately * feat: Use footer buttons in the change profile picture dialog - Add Replace and Delete buttons beside Done in the admin avatar dialog - Add showActions and an open handle to ImageInput so dialogs can supply their own controls * fix: Style the danger section with an outer shadow instead of tinted text --- app/components/UserDialogs.tsx | 24 +- app/scenes/Settings/AI.tsx | 175 +++--- app/scenes/Settings/Authentication.tsx | 339 +++++----- app/scenes/Settings/Details.tsx | 588 ++++++++++-------- app/scenes/Settings/Embeds.tsx | 12 +- app/scenes/Settings/Preferences.tsx | 322 +++++----- app/scenes/Settings/Profile.tsx | 38 +- app/scenes/Settings/Security.tsx | 330 +++++----- app/scenes/Settings/components/ImageInput.tsx | 85 ++- .../Settings/components/ImageUpload.tsx | 15 +- app/scenes/Settings/components/SettingRow.tsx | 21 +- .../Settings/components/SettingsSection.tsx | 74 +++ shared/i18n/locales/en_US/translation.json | 2 + 13 files changed, 1146 insertions(+), 879 deletions(-) create mode 100644 app/scenes/Settings/components/SettingsSection.tsx diff --git a/app/components/UserDialogs.tsx b/app/components/UserDialogs.tsx index 7f37426a1e..c804cca53c 100644 --- a/app/components/UserDialogs.tsx +++ b/app/components/UserDialogs.tsx @@ -13,6 +13,7 @@ import Input from "~/components/Input"; import useCurrentUser from "~/hooks/useCurrentUser"; import useStores from "~/hooks/useStores"; import ImageInput from "~/scenes/Settings/components/ImageInput"; +import type { ImageUploadHandle } from "~/scenes/Settings/components/ImageUpload"; import { performBatch } from "~/actions/definitions/common"; import { client } from "~/utils/ApiClient"; import Text from "./Text"; @@ -183,6 +184,11 @@ export const UserChangeAvatarDialog = observer(function UserChangeAvatarDialog({ onSubmit, }: Props) { const { t } = useTranslation(); + const imageRef = React.useRef(null); + + const handleReplace = () => { + imageRef.current?.open(); + }; const handleAvatarChange = async (avatarUrl: string | null) => { try { @@ -205,15 +211,21 @@ export const UserChangeAvatarDialog = observer(function UserChangeAvatarDialog({ onSuccess={handleAvatarChange} onError={handleAvatarError} model={user} - showRemoveOption={false} + showActions={false} + ref={imageRef} /> - - {user.avatarUrl && ( - - )} + {user.avatarUrl && ( + + )} + diff --git a/app/scenes/Settings/AI.tsx b/app/scenes/Settings/AI.tsx index fa3261de67..6f6f61ef11 100644 --- a/app/scenes/Settings/AI.tsx +++ b/app/scenes/Settings/AI.tsx @@ -11,6 +11,7 @@ import Switch from "~/components/Switch"; import Text from "~/components/Text"; import useCurrentTeam from "~/hooks/useCurrentTeam"; import SettingRow from "./components/SettingRow"; +import { SettingsSection } from "./components/SettingsSection"; import Input from "~/components/Input"; import Tooltip from "~/components/Tooltip"; import CopyToClipboard from "~/components/CopyToClipboard"; @@ -56,102 +57,102 @@ function AI() { Control how AI features are used in the workspace. - {t("MCP server")} - - - {t( - "Let members connect AI assistants and other apps to this workspace. Connected apps can read and edit content with the same permissions as the member who connects them." - )} - - {team.getPreference(TeamPreference.MCP) && ( - <> - - - ), - }} - /> - - - - - - - - - - - - )} - - } - > - - - - {team.getPreference(TeamPreference.MCP) && ( + -
+ {t( - "Optional instructions that are sent to connected AI apps, for example how your workspace is organized or where to find important information." + "Let members connect AI assistants and other apps to this workspace. Connected apps can read and edit content with the same permissions as the member who connects them." )} -
- + + {team.getPreference(TeamPreference.MCP) && ( + <> + + + ), + }} + /> + + + + + + + + + + + + )} } - /> - )} + > + +
- {t("AI answers")} - +
+ {t( + "Optional instructions that are sent to connected AI apps, for example how your workspace is organized or where to find important information." + )} +
+ + + } + /> )} - border={false} - > - -
+
+ + + + + + ); } diff --git a/app/scenes/Settings/Authentication.tsx b/app/scenes/Settings/Authentication.tsx index cef6030c9d..71e701064c 100644 --- a/app/scenes/Settings/Authentication.tsx +++ b/app/scenes/Settings/Authentication.tsx @@ -21,6 +21,7 @@ import usePolicy from "~/hooks/usePolicy"; import useRequest from "~/hooks/useRequest"; import useStores from "~/hooks/useStores"; import SettingRow from "./components/SettingRow"; +import { SettingsSection } from "./components/SettingsSection"; import { setPostLoginPath } from "~/hooks/useLastVisitedPath"; import { getRedirectUrl, toRelative } from "~/utils/urls"; import { settingsPath } from "~/utils/routeHelpers"; @@ -193,188 +194,188 @@ function Authentication() { - {t("Sign in")} + + {authenticationProviders.orderedData.map((provider) => { + // Group sync can still be disabled after losing the entitlement. + const showGroupSync = + provider.isActive && + provider.groupSyncSupported && + (!!can.externalGroupSync || !!provider.settings?.groupSyncEnabled); - {authenticationProviders.orderedData.map((provider) => { - // Group sync can still be disabled after losing the entitlement. - const showGroupSync = - provider.isActive && - provider.groupSyncSupported && - (!!can.externalGroupSync || !!provider.settings?.groupSyncEnabled); - - return ( - - - {provider.displayName} - - } - name={provider.name} - description={ - provider.isConnected - ? t("Allow members to sign in with {{ authProvider }}", { - authProvider: provider.displayName, - }) - : t( - "Connect {{ authProvider }} to allow members to sign in", - { + return ( + + + {provider.displayName} + + } + name={provider.name} + description={ + provider.isConnected + ? t("Allow members to sign in with {{ authProvider }}", { authProvider: provider.displayName, - } - ) - } - border={!showGroupSync} - > - - {provider.isConnected ? ( - + }) + : t( + "Connect {{ authProvider }} to allow members to sign in", + { + authProvider: provider.displayName, + } + ) + } + border={!showGroupSync} + > + + {provider.isConnected ? ( + + + + {provider.providerId} + + + ) : ( - - {provider.providerId} - - - ) : ( - - )} - - - {showGroupSync && ( - - {provider.groupSyncRequiresSetup && - !provider.settings?.groupSyncEnabled ? ( - - ) : ( - - handleToggleGroupSync(provider, checked) - } - /> - )} - - )} - {showGroupSync && - provider.groupSyncUsesClaim && - provider.settings?.groupSyncEnabled && ( - + + {showGroupSync && ( + - ) => { - const value = ev.target.value.trim(); - if (value !== (provider.settings?.groupClaim ?? "")) { - void handleGroupClaimChange(provider, value); + {provider.groupSyncRequiresSetup && + !provider.settings?.groupSyncEnabled ? ( + + ) : ( + + handleToggleGroupSync(provider, checked) } - }} - /> + /> + )} )} - - ); - })} - - {t("Email")} - - } - name="guestSignin" - description={ - env.EMAIL_ENABLED - ? t("Allow members to sign in using their email address") - : t("The server must have SMTP configured to enable this setting") - } - border={false} - > - - + {showGroupSync && + provider.groupSyncUsesClaim && + provider.settings?.groupSyncEnabled && ( + + ) => { + const value = ev.target.value.trim(); + if (value !== (provider.settings?.groupClaim ?? "")) { + void handleGroupClaimChange(provider, value); + } + }} + /> + + )} + + ); + })} + + {t("Email")} + + } + name="guestSignin" + description={ + env.EMAIL_ENABLED + ? t("Allow members to sign in using their email address") + : t("The server must have SMTP configured to enable this setting") + } + > + + - - {t("Passkeys")} - - } - name="passkeysEnabled" - description={t("Allow members to sign in with a WebAuthn passkey")} - > - { - try { - await team.save({ passkeysEnabled: checked }); - toast.success(t("Settings saved")); - } catch (err) { - toast.error(errToString(err)); - } - }} - /> - + + {t("Passkeys")} + + } + name="passkeysEnabled" + description={t("Allow members to sign in with a WebAuthn passkey")} + > + { + try { + await team.save({ passkeysEnabled: checked }); + toast.success(t("Settings saved")); + } catch (err) { + toast.error(errToString(err)); + } + }} + /> + + - {t("Restrictions")} - + + + ); } diff --git a/app/scenes/Settings/Details.tsx b/app/scenes/Settings/Details.tsx index def9a44b09..544722edf0 100644 --- a/app/scenes/Settings/Details.tsx +++ b/app/scenes/Settings/Details.tsx @@ -1,15 +1,15 @@ import { isHexColor } from "class-validator"; -import { pickBy } from "es-toolkit/compat"; +import { debounce, pickBy } from "es-toolkit/compat"; import { observer } from "mobx-react"; import { TeamIcon } from "outline-icons"; -import { useRef, useState } from "react"; +import { useState } from "react"; import * as React from "react"; import { useTranslation, Trans } from "react-i18next"; import { toast } from "sonner"; import { ThemeProvider } from "styled-components"; import { errToString } from "@shared/utils/error"; import { buildDarkTheme, buildLightTheme } from "@shared/styles/theme"; -import type { CustomTheme } from "@shared/types"; +import type { CustomTheme, TeamPreferences } from "@shared/types"; import { TOCPosition, TeamPreference, UserPreference } from "@shared/types"; import { getBaseDomain } from "@shared/utils/domains"; import { TeamValidation } from "@shared/validations"; @@ -28,13 +28,18 @@ import useCurrentTeam from "~/hooks/useCurrentTeam"; import useCurrentUser from "~/hooks/useCurrentUser"; import usePolicy from "~/hooks/usePolicy"; import useStores from "~/hooks/useStores"; +import type Team from "~/models/Team"; import isCloudHosted from "~/utils/isCloudHosted"; import TeamDelete from "../TeamDelete"; -import { ActionRow } from "./components/ActionRow"; import ImageInput from "./components/ImageInput"; import SettingRow from "./components/SettingRow"; +import { SettingsSection } from "./components/SettingsSection"; import { ThemeColorInputs } from "./components/ThemeColorInputs"; +type TeamUpdate = Partial< + Pick +> & { preferences?: TeamPreferences }; + function Details() { const { dialogs, ui } = useStores(); const { t } = useTranslation(); @@ -42,7 +47,6 @@ function Details() { const user = useCurrentUser(); const can = usePolicy(team); - const form = useRef(null); const [accent, setAccent] = useState( team.preferences?.customTheme?.accent ); @@ -52,12 +56,6 @@ function Details() { const [name, setName] = useState(team.name); const [description, setDescription] = useState(team.description || ""); const [subdomain, setSubdomain] = useState(team.subdomain); - const [publicBranding, setPublicBranding] = useState( - team.preferences?.publicBranding - ); - const [defaultCollectionId, setDefaultCollectionId] = useState( - team.defaultCollectionId - ); const customTheme: Partial = React.useMemo( () => @@ -71,10 +69,6 @@ function Details() { [accent, accentText] ); - const [tocPosition, setTocPosition] = useState( - team.getPreference(TeamPreference.TocPosition) as TOCPosition - ); - const tocPositionOptions: Option[] = React.useMemo( () => [ @@ -92,47 +86,103 @@ function Details() { [t] ); - const handleTocPositionChange = React.useCallback((position: string) => { - setTocPosition(position as TOCPosition); - }, []); - - const handleSubmit = React.useCallback( - async (event?: React.SyntheticEvent) => { - if (event) { - event.preventDefault(); - } - - try { - await team.save({ - name, - description, - subdomain, - defaultCollectionId, - preferences: { - ...team.preferences, - publicBranding, - customTheme, - tocPosition, - }, - }); + const showSuccessMessage = React.useMemo( + () => + debounce(() => { toast.success(t("Settings saved")); + }, 250), + [t] + ); + + const saveData = React.useCallback( + async (data: TeamUpdate) => { + try { + await team.save(data); + showSuccessMessage(); + return true; } catch (err) { toast.error(errToString(err)); + return false; } }, - [ - tocPosition, - team, - name, - description, - subdomain, - defaultCollectionId, - publicBranding, - customTheme, - t, - ] + [team, showSuccessMessage] ); + const savePreference = React.useCallback( + (key: T, value: TeamPreferences[T]) => + saveData({ preferences: { [key]: value } }), + [saveData] + ); + + const saveTheme = React.useMemo( + () => + debounce((theme: Partial) => { + void savePreference(TeamPreference.CustomTheme, theme); + }, 500), + [savePreference] + ); + + // Save a pending theme change when the user leaves the page. + React.useEffect(() => () => saveTheme.flush(), [saveTheme]); + + const handleThemeChange = React.useCallback( + ( + nextAccent: string | null | undefined, + nextText: string | null | undefined + ) => { + // Wait until every entered color is complete or empty before saving. + const isReady = (value: string | null | undefined) => + !value || value === "#" || isHexColor(value); + if (!isReady(nextAccent) || !isReady(nextText)) { + return; + } + saveTheme( + pickBy({ accent: nextAccent, accentText: nextText }, isHexColor) + ); + }, + [saveTheme] + ); + + const handleAccentChange = React.useCallback( + (value: string) => { + setAccent(value); + handleThemeChange(value, accentText); + }, + [accentText, handleThemeChange] + ); + + const handleAccentTextChange = React.useCallback( + (value: string) => { + setAccentText(value); + handleThemeChange(accent, value); + }, + [accent, handleThemeChange] + ); + + const handleResetTheme = React.useCallback(() => { + setAccent(null); + setAccentText(null); + saveTheme.cancel(); + void savePreference(TeamPreference.CustomTheme, {}); + }, [saveTheme, savePreference]); + + const handleSubmit = React.useCallback((ev: React.FormEvent) => { + ev.preventDefault(); + }, []); + + const handleKeyDown = React.useCallback((ev: React.KeyboardEvent) => { + // Text fields save on blur, so Enter saves the focused field. + if ( + ev.key === "Enter" && + !ev.nativeEvent.isComposing && + ev.target instanceof HTMLInputElement && + ev.currentTarget.contains(ev.target) + ) { + ev.preventDefault(); + ev.target.blur(); + } + }, []); + const handleNameChange = React.useCallback( (ev: React.ChangeEvent) => { setName(ev.target.value); @@ -140,6 +190,31 @@ function Details() { [] ); + const handleNameBlur = React.useCallback(async () => { + if (name === team.name) { + return; + } + if (!name.trim() || !(await saveData({ name }))) { + setName(team.name); + } + }, [name, team, saveData]); + + const handleDescriptionChange = React.useCallback( + (ev: React.ChangeEvent) => { + setDescription(ev.target.value); + }, + [] + ); + + const handleDescriptionBlur = React.useCallback(async () => { + if (description === (team.description || "")) { + return; + } + if (!(await saveData({ description }))) { + setDescription(team.description || ""); + } + }, [description, team, saveData]); + const handleSubdomainChange = React.useCallback( (ev: React.ChangeEvent) => { setSubdomain(ev.target.value.toLowerCase()); @@ -147,6 +222,33 @@ function Details() { [] ); + const handleSubdomainBlur = React.useCallback(async () => { + if (subdomain === team.subdomain) { + return; + } + if (!(await saveData({ subdomain }))) { + setSubdomain(team.subdomain); + } + }, [subdomain, team, saveData]); + + const handlePublicBrandingChange = React.useCallback( + (checked: boolean) => + savePreference(TeamPreference.PublicBranding, checked), + [savePreference] + ); + + const handleTocPositionChange = React.useCallback( + (position: string) => + savePreference(TeamPreference.TocPosition, position as TOCPosition), + [savePreference] + ); + + const handleSelectCollection = React.useCallback( + (value: string) => + saveData({ defaultCollectionId: value === "home" ? null : value }), + [saveData] + ); + const handleAvatarChange = async (avatarUrl: string | null) => { await team.save({ avatarUrl }); toast.success(t("Logo updated")); @@ -166,28 +268,25 @@ function Details() { }); }; - const onSelectCollection = React.useCallback((value: string) => { - const selectedValue = value === "home" ? null : value; - setDefaultCollectionId(selectedValue); - }, []); - const handleSeamlessEditChange = React.useCallback( async (checked: boolean) => { - team.setPreference(TeamPreference.SeamlessEdit, !checked); - await team.save(); + if (!(await savePreference(TeamPreference.SeamlessEdit, !checked))) { + return; + } // Enabling separate editing also applies it to the current user. if (checked) { - user.setPreference(UserPreference.SeamlessEdit, false); - await user.save(); + try { + user.setPreference(UserPreference.SeamlessEdit, false); + await user.save(); + } catch (err) { + toast.error(errToString(err)); + } } - toast.success(t("Settings saved")); }, - [team, user, t] + [savePreference, user] ); - const isValid = form.current?.checkValidity(); - const newTheme = React.useMemo( () => ui.resolvedTheme === "light" @@ -207,207 +306,192 @@ function Details() { -
- {t("Appearance")} - - - - - - - - ) => { - setDescription(ev.target.value); - }} - maxLength={TeamValidation.maxDescriptionLength} - showCharacterCount - /> - - - {t("Customize the interface look and feel.")}{" "} - {accent && ( - <> - { - setAccent(null); - setAccentText(null); - }} - > + + + + + + + + + + + + + {t("Customize the interface look and feel.")}{" "} + {accent && ( + {t("Reset theme")} - + )} + + } + > + + + {(team.avatarUrl || team.description) && ( + - } - > - - - {(team.avatarUrl || team.description) && ( + > + + + )} + + + + + + + Your workspace will be accessible at{" "} + + {subdomain}.{getBaseDomain()} + + + ) : ( + t( + "Choose a subdomain to enable a login page just for your team." + ) + ) + } + > + + + + + + setPublicBranding(checked)} + id={TeamPreference.SeamlessEdit} + name={TeamPreference.SeamlessEdit} + checked={!team.getPreference(TeamPreference.SeamlessEdit)} + onChange={handleSeamlessEditChange} /> - )} - - - - - {t("Behavior")} - - - Your workspace will be accessible at{" "} - - {subdomain}.{getBaseDomain()} - - - ) : ( - t( - "Choose a subdomain to enable a login page just for your team." - ) - ) - } - > - - - - - - - - - - - - - - {can.delete && ( - <> -

 

- - {t("Danger")} - - - - - - - )} +
+ + {can.delete && ( + + + + + + + + )} ); diff --git a/app/scenes/Settings/Embeds.tsx b/app/scenes/Settings/Embeds.tsx index f12209ed56..5b51ef5ce9 100644 --- a/app/scenes/Settings/Embeds.tsx +++ b/app/scenes/Settings/Embeds.tsx @@ -12,6 +12,7 @@ import Text from "~/components/Text"; import useCurrentTeam from "~/hooks/useCurrentTeam"; import { IntegrationScene } from "./components/IntegrationScene"; import SettingRow from "./components/SettingRow"; +import { SettingsSection } from "./components/SettingsSection"; import { HStack } from "~/components/primitives/HStack"; /** List of embed providers available for configuration. */ @@ -99,15 +100,16 @@ function Embeds() {
{team.documentEmbeds && ( - <> - {t("Providers")} - + Enabled providers will appear in the editor slash menu and embed automatically when a compatible link is pasted. Existing embeds in documents will continue to display regardless of these settings. - + } + > ); })} - + )} ); diff --git a/app/scenes/Settings/Preferences.tsx b/app/scenes/Settings/Preferences.tsx index 1530a2f8b2..c79fab6405 100644 --- a/app/scenes/Settings/Preferences.tsx +++ b/app/scenes/Settings/Preferences.tsx @@ -24,6 +24,7 @@ import useStores from "~/hooks/useStores"; import UserDelete from "../UserDelete"; import { AutoLaunchSetting } from "./components/AutoLaunchSetting"; import SettingRow from "./components/SettingRow"; +import { SettingsSection } from "./components/SettingsSection"; function Preferences() { const { t } = useTranslation(); @@ -181,173 +182,172 @@ function Preferences() { Manage settings that affect your personal experience. - {t("Appearance")} - - - Choose the interface language. Community translations are accepted - through our{" "} - - translation portal - - . - - - } - > - + - - - - - - - - - - - - - - - - - - {t("Behavior")} - - + + Choose the interface language. Community translations are + accepted through our{" "} + + translation portal + + . + + } - onChange={handleSeamlessEditChange} - /> - - - + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + - - - - + + + + - + description={t( + "Choose how unread notifications are indicated on the app icon." + )} + > + + + {can.delete && ( - <> - {t("Danger")} + - + )} ); diff --git a/app/scenes/Settings/Profile.tsx b/app/scenes/Settings/Profile.tsx index 4ee6b30051..13d0303754 100644 --- a/app/scenes/Settings/Profile.tsx +++ b/app/scenes/Settings/Profile.tsx @@ -4,7 +4,6 @@ import * as React from "react"; import { Trans, useTranslation } from "react-i18next"; import { toast } from "sonner"; import { errToString } from "@shared/utils/error"; -import Button from "~/components/Button"; import Heading from "~/components/Heading"; import Input from "~/components/Input"; import Scene from "~/components/Scene"; @@ -20,17 +19,40 @@ import SettingRow from "./components/SettingRow"; const Profile = () => { const user = useCurrentUser(); const { dialogs } = useStores(); - const form = React.useRef(null); const [name, setName] = React.useState(user.name); const { t } = useTranslation(); - const handleSubmit = async (ev: React.SyntheticEvent) => { + const handleSubmit = (ev: React.FormEvent) => { ev.preventDefault(); + }; + + const handleKeyDown = (ev: React.KeyboardEvent) => { + // The name saves on blur, so Enter saves it. + if ( + ev.key === "Enter" && + !ev.nativeEvent.isComposing && + ev.target instanceof HTMLInputElement && + ev.currentTarget.contains(ev.target) + ) { + ev.preventDefault(); + ev.target.blur(); + } + }; + + const handleNameBlur = async () => { + if (name === user.name) { + return; + } + if (!name.trim()) { + setName(user.name); + return; + } try { await user.save({ name }); toast.success(t("Profile saved")); } catch (err) { + setName(user.name); toast.error(errToString(err)); } }; @@ -57,9 +79,6 @@ const Profile = () => { toast.error(error || t("Unable to upload new profile picture")); }; - const isValid = form.current?.checkValidity(); - const { isSaving } = user; - return ( }> {t("Profile")} @@ -67,7 +86,7 @@ const Profile = () => { Manage how you appear to other members of the workspace. -
+ { autoComplete="name" value={name} onChange={handleNameChange} + onBlur={handleNameBlur} maxLength={UserValidation.maxNameLength} showCharacterCount required @@ -109,10 +129,6 @@ const Profile = () => { /> )} - -
); diff --git a/app/scenes/Settings/Security.tsx b/app/scenes/Settings/Security.tsx index 5a7a5462be..bb7b092a42 100644 --- a/app/scenes/Settings/Security.tsx +++ b/app/scenes/Settings/Security.tsx @@ -21,6 +21,7 @@ import usePolicy from "~/hooks/usePolicy"; import useStores from "~/hooks/useStores"; import isCloudHosted from "~/utils/isCloudHosted"; import SettingRow from "./components/SettingRow"; +import { SettingsSection } from "./components/SettingsSection"; function Security() { const { dialogs } = useStores(); @@ -280,186 +281,189 @@ function Security() { - {t("Invites")} - - - - {isCloudHosted && ( + - )} - - {!data.inviteRequired && ( - - - - )} - - {t("Behavior")} - - - - {can.setDefaultShareExpiry && ( - - + + + )} + + {!data.inviteRequired && ( + + + + )} + + + + + + + {can.setDefaultShareExpiry && ( + + + + )} + + + + + + + + - )} - - - - - - - - - - - - - - - - - - - {isCloudHosted && ( - - )} + + + + + + + {isCloudHosted && ( + + + + )} + ); } diff --git a/app/scenes/Settings/components/ImageInput.tsx b/app/scenes/Settings/components/ImageInput.tsx index 7c51a44530..f17f02f383 100644 --- a/app/scenes/Settings/components/ImageInput.tsx +++ b/app/scenes/Settings/components/ImageInput.tsx @@ -1,13 +1,19 @@ -import { EditIcon } from "outline-icons"; +import { observer } from "mobx-react"; +import { EditIcon, ExportIcon, TrashIcon } from "outline-icons"; +import * as React from "react"; import { useTranslation } from "react-i18next"; import styled from "styled-components"; import { s } from "@shared/styles"; import type { IAvatar } from "~/components/Avatar"; import { Avatar, AvatarSize } from "~/components/Avatar"; import { AvatarVariant } from "~/components/Avatar/Avatar"; -import Button from "~/components/Button"; import Flex from "~/components/Flex"; -import type { Props as ImageUploadProps } from "./ImageUpload"; +import NudeButton from "~/components/NudeButton"; +import Tooltip from "~/components/Tooltip"; +import type { + ImageUploadHandle, + Props as ImageUploadProps, +} from "./ImageUpload"; import ImageUpload from "./ImageUpload"; type Props = ImageUploadProps & { @@ -15,29 +21,48 @@ type Props = ImageUploadProps & { model: IAvatar; /** Alt text for the avatar image. */ alt: string; - /** - * Whether to render the inline "Remove" button when the model has an - * existing avatar. Defaults to true. - */ - showRemoveOption?: boolean; /** The shape of the avatar preview. Defaults to round. */ variant?: AvatarVariant; + /** + * Whether to render the change and remove buttons below the image. Hide + * them when the parent provides its own controls. Defaults to true. + */ + showActions?: boolean; + /** Handle to open the file picker from the parent. */ + ref?: React.Ref; }; -export default function ImageInput({ +function ImageInput({ model, onSuccess, alt, - showRemoveOption = true, variant = AvatarVariant.Round, + showActions = true, + ref, ...rest }: Props) { const { t } = useTranslation(); + const uploadRef = React.useRef(null); + + React.useImperativeHandle( + ref, + () => ({ open: () => uploadRef.current?.open() }), + [] + ); + + const handleChange = React.useCallback(() => { + uploadRef.current?.open(); + }, []); + + const handleRemove = React.useCallback(() => { + void onSuccess(null); + }, [onSuccess]); return ( - + - + - {model.avatarUrl && showRemoveOption && ( - + {showActions && ( + + + + + + + {model.avatarUrl && ( + + + + + + )} + )} - + ); } +export default observer(ImageInput); + +const Wrapper = styled(Flex)` + width: fit-content; +`; + +const Actions = styled(Flex)` + color: ${s("textSecondary")}; + + button:hover, + button:focus-visible { + color: ${s("text")}; + } +`; + const avatarStyles = ` width: ${AvatarSize.Upload}px; height: ${AvatarSize.Upload}px; diff --git a/app/scenes/Settings/components/ImageUpload.tsx b/app/scenes/Settings/components/ImageUpload.tsx index bc5c1a76d9..b007bb5ec6 100644 --- a/app/scenes/Settings/components/ImageUpload.tsx +++ b/app/scenes/Settings/components/ImageUpload.tsx @@ -26,13 +26,20 @@ export type Props = { children?: React.ReactNode; }; -const ImageUpload: React.FC = ({ +/** Imperative handle exposed by ImageUpload. */ +export interface ImageUploadHandle { + /** Opens the file picker. */ + open: () => void; +} + +const ImageUpload = ({ onSuccess, onError, submitText, borderRadius, children, -}) => { + ref, +}: Props & { ref?: React.Ref }) => { const { dialogs } = useStores(); const { t } = useTranslation(); @@ -110,11 +117,13 @@ const ImageUpload: React.FC = ({ [t, dialogs, handleUpload, handleClose, onError, borderRadius, submitText] ); - const { getRootProps, getInputProps } = useDropzone({ + const { getRootProps, getInputProps, open } = useDropzone({ accept: avatarAccept, onDropAccepted, }); + React.useImperativeHandle(ref, () => ({ open }), [open]); + if (isCropping) { return null; // onDropAccepted would have opened a modal for cropping the image. } diff --git a/app/scenes/Settings/components/SettingRow.tsx b/app/scenes/Settings/components/SettingRow.tsx index bdb3921027..729f9be42c 100644 --- a/app/scenes/Settings/components/SettingRow.tsx +++ b/app/scenes/Settings/components/SettingRow.tsx @@ -28,6 +28,18 @@ const Row = styled(Flex)<{ $border?: boolean; $compact?: boolean }>` border-bottom: 0; } + /* Center switches, unless the text column also holds a field. */ + &:has(> :last-child > [role="switch"]):not( + :has(> :first-child :is(input, textarea)) + ) { + align-items: center; + } + + /* A switch column is only as wide as the switch. */ + &:has(> :last-child > [role="switch"]) > :last-child { + flex: 0 0 auto; + } + ${breakpoint("mobile", "tablet")` &:has([role="switch"]) { gap: 16px; @@ -73,11 +85,10 @@ const Column = styled.div` align-self: flex-end; } - ${breakpoint("tablet")` - > * { - align-self: initial; - } - `} + /* Text fields and selects fill the column. */ + > :has(input:not([type="file"]), textarea, [role="combobox"]) { + align-self: stretch; + } } ${breakpoint("tablet")` diff --git a/app/scenes/Settings/components/SettingsSection.tsx b/app/scenes/Settings/components/SettingsSection.tsx new file mode 100644 index 0000000000..586571f3a8 --- /dev/null +++ b/app/scenes/Settings/components/SettingsSection.tsx @@ -0,0 +1,74 @@ +import { transparentize } from "polished"; +import * as React from "react"; +import styled, { css } from "styled-components"; +import { breakpoint } from "@shared/styles/breakpoint"; +import Text from "~/components/Text"; + +interface Props { + /** The section heading. */ + title: React.ReactNode; + /** Optional text shown below the heading. */ + description?: React.ReactNode; + /** Whether the section holds destructive actions. */ + danger?: boolean; + /** The rows in the section, usually SettingRow components. */ + children: React.ReactNode; +} + +/** + * A titled group of setting rows on a settings screen. + * + * @param props the section props. + * @returns the section element. + */ +export function SettingsSection({ + title, + description, + danger, + children, +}: Props) { + const titleId = React.useId(); + + return ( +
+ {title} + {description && ( + + {description} + + )} + {children} +
+ ); +} + +const Section = styled.section` + margin-top: 32px; + + ${breakpoint("tablet")` + margin-top: 48px; + `} +`; + +const Title = styled.h2` + font-size: 20px; + font-weight: 600; + margin: 0; +`; + +const Description = styled(Text)` + margin: 4px 0 8px; +`; + +const Rows = styled.div<{ $danger?: boolean }>` + ${(props) => + props.$danger && + css` + /* Inset by the shadow width so the shadow aligns with the content. */ + margin: 24px 8px 8px; + padding: 0 16px; + border: 1px solid ${transparentize(0.6, props.theme.danger)}; + border-radius: 8px; + box-shadow: 0 0 0 8px ${transparentize(0.9, props.theme.danger)}; + `} +`; diff --git a/shared/i18n/locales/en_US/translation.json b/shared/i18n/locales/en_US/translation.json index c755118dbf..d28dc2fccb 100644 --- a/shared/i18n/locales/en_US/translation.json +++ b/shared/i18n/locales/en_US/translation.json @@ -1387,6 +1387,8 @@ "Synced <2>": "Synced <2>", "Date created": "Date created", "Crop image": "Crop image", + "Change image": "Change image", + "Remove image": "Remove image", "Your browser cannot read HEIC images – please convert the image to JPEG or PNG first": "Your browser cannot read HEIC images – please convert the image to JPEG or PNG first", "You can import a zip file that was previously exported from the JSON option in another instance. In {{ appName }}, open Export in the Settings sidebar and click on Export data.": "You can import a zip file that was previously exported from the JSON option in another instance. In {{ appName }}, open Export in the Settings sidebar and click on Export data.", "Drag and drop the zip file from the JSON export option in {{appName}}, or click to upload": "Drag and drop the zip file from the JSON export option in {{appName}}, or click to upload",