texlite 0.19.2 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DESIGN.md +241 -7
- package/OPERATIONS.md +7 -4
- package/README.md +6 -1
- package/README.zh-CN.md +4 -1
- package/dist/client/assets/AdminUsers-BghRo_hC.js +1 -0
- package/dist/client/assets/AdminUsers-BghRo_hC.js.br +0 -0
- package/dist/client/assets/AdminUsers-BghRo_hC.js.gz +0 -0
- package/dist/client/assets/AgentIcon-DsoMeMA8.js +1 -0
- package/dist/client/assets/AgentIcon-DsoMeMA8.js.br +0 -0
- package/dist/client/assets/AgentIcon-DsoMeMA8.js.gz +0 -0
- package/dist/client/assets/AgentIcon-dCMgWJG-.css +1 -0
- package/dist/client/assets/AgentIcon-dCMgWJG-.css.br +0 -0
- package/dist/client/assets/AgentIcon-dCMgWJG-.css.gz +0 -0
- package/dist/client/assets/AgentManagement-rIYtm4Bo.js +1 -0
- package/dist/client/assets/AgentManagement-rIYtm4Bo.js.br +0 -0
- package/dist/client/assets/AgentManagement-rIYtm4Bo.js.gz +0 -0
- package/dist/client/assets/AgentTerminal-BEjiw51y.js +2 -0
- package/dist/client/assets/AgentTerminal-BEjiw51y.js.br +0 -0
- package/dist/client/assets/AgentTerminal-BEjiw51y.js.gz +0 -0
- package/dist/client/assets/{AgentTerminalSurface-C11baRxh.js → AgentTerminalSurface-B2rwONYs.js} +2 -2
- package/dist/client/assets/AgentTerminalSurface-B2rwONYs.js.br +0 -0
- package/dist/client/assets/AgentTerminalSurface-B2rwONYs.js.gz +0 -0
- package/dist/client/assets/AvatarSettingsDialog-DplRpiJJ.js +1 -0
- package/dist/client/assets/AvatarSettingsDialog-DplRpiJJ.js.br +0 -0
- package/dist/client/assets/AvatarSettingsDialog-DplRpiJJ.js.gz +0 -0
- package/dist/client/assets/CitationBibtexEditor-BnK6nZPi.js +1 -0
- package/dist/client/assets/CitationLibraryDialog-CZvJiTmT.js +3 -0
- package/dist/client/assets/CitationLibraryDialog-CZvJiTmT.js.br +0 -0
- package/dist/client/assets/CitationLibraryDialog-CZvJiTmT.js.gz +0 -0
- package/dist/client/assets/CitationNotesPreview-CiIzdjCa.js +36 -0
- package/dist/client/assets/CitationNotesPreview-CiIzdjCa.js.br +0 -0
- package/dist/client/assets/CitationNotesPreview-CiIzdjCa.js.gz +0 -0
- package/dist/client/assets/Dashboard-Dcl0Y_C3.js +5 -0
- package/dist/client/assets/Dashboard-Dcl0Y_C3.js.br +0 -0
- package/dist/client/assets/Dashboard-Dcl0Y_C3.js.gz +0 -0
- package/dist/client/assets/GitDialog-BeYvUCDv.js +3 -0
- package/dist/client/assets/GitDialog-BeYvUCDv.js.br +0 -0
- package/dist/client/assets/GitDialog-BeYvUCDv.js.gz +0 -0
- package/dist/client/assets/GitHubAccountDialog-BGKINOwJ.js +1 -0
- package/dist/client/assets/GitHubAccountDialog-BGKINOwJ.js.br +0 -0
- package/dist/client/assets/GitHubAccountDialog-BGKINOwJ.js.gz +0 -0
- package/dist/client/assets/GitHubIcon-CExJn0AV.js +1 -0
- package/dist/client/assets/HistoryDialog-B-C4Zaef.js +8 -0
- package/dist/client/assets/HistoryDialog-B-C4Zaef.js.br +0 -0
- package/dist/client/assets/HistoryDialog-B-C4Zaef.js.gz +0 -0
- package/dist/client/assets/InfoPopover-Dkz742vJ.js +1 -0
- package/dist/client/assets/LatexEditor-CohUJrGD.js +25 -0
- package/dist/client/assets/LatexEditor-CohUJrGD.js.br +0 -0
- package/dist/client/assets/LatexEditor-CohUJrGD.js.gz +0 -0
- package/dist/client/assets/PdfPreview-BvJxduy3.js +1 -0
- package/dist/client/assets/PdfPreview-BvJxduy3.js.br +0 -0
- package/dist/client/assets/PdfPreview-BvJxduy3.js.gz +0 -0
- package/dist/client/assets/ProjectIconPickerDialog-B9_XvdIC.js +1 -0
- package/dist/client/assets/ProjectIconPickerDialog-B9_XvdIC.js.br +0 -0
- package/dist/client/assets/ProjectIconPickerDialog-B9_XvdIC.js.gz +0 -0
- package/dist/client/assets/ProjectSettings-D8uH3PqQ.js +4 -0
- package/dist/client/assets/ProjectSettings-D8uH3PqQ.js.br +0 -0
- package/dist/client/assets/ProjectSettings-D8uH3PqQ.js.gz +0 -0
- package/dist/client/assets/ProjectWorkspace-BZj-CRZB.js +31 -0
- package/dist/client/assets/ProjectWorkspace-BZj-CRZB.js.br +0 -0
- package/dist/client/assets/ProjectWorkspace-BZj-CRZB.js.gz +0 -0
- package/dist/client/assets/QuickOpenDialog-B9bf5mnw.js +1 -0
- package/dist/client/assets/QuickOpenDialog-B9bf5mnw.js.br +0 -0
- package/dist/client/assets/QuickOpenDialog-B9bf5mnw.js.gz +0 -0
- package/dist/client/assets/ReadOnlySource-BZ7WYQO7.js +2 -0
- package/dist/client/assets/SaveButton-wiTpGLho.js +1 -0
- package/dist/client/assets/{SelectionHistoryDialog-cDxbuXmO.js → SelectionHistoryDialog-DYQb9hXp.js} +2 -2
- package/dist/client/assets/SelectionHistoryDialog-DYQb9hXp.js.br +0 -0
- package/dist/client/assets/SelectionHistoryDialog-DYQb9hXp.js.gz +0 -0
- package/dist/client/assets/SharedProjectPage-BOGGeyBG.css +1 -0
- package/dist/client/assets/SharedProjectPage-DJjR-D8d.js +2 -0
- package/dist/client/assets/SharedProjectPage-DJjR-D8d.js.br +0 -0
- package/dist/client/assets/SharedProjectPage-DJjR-D8d.js.gz +0 -0
- package/dist/client/assets/SystemMetricsDialog-BExTHWxg.js +1 -0
- package/dist/client/assets/SystemMetricsDialog-BExTHWxg.js.br +0 -0
- package/dist/client/assets/SystemMetricsDialog-BExTHWxg.js.gz +0 -0
- package/dist/client/assets/{TagColorSelect-D-zwdawC.js → TagColorSelect-CzPUDAny.js} +1 -1
- package/dist/client/assets/TagManagementDialog-BBOpD_62.js +1 -0
- package/dist/client/assets/TagManagementDialog-BBOpD_62.js.br +0 -0
- package/dist/client/assets/TagManagementDialog-BBOpD_62.js.gz +0 -0
- package/dist/client/assets/ThemeSwitcher-BTDUp7Wj.js +1 -0
- package/dist/client/assets/ThemeSwitcher-BTDUp7Wj.js.br +0 -0
- package/dist/client/assets/ThemeSwitcher-BTDUp7Wj.js.gz +0 -0
- package/dist/client/assets/WordCountDialog-CgDcnPdJ.js +1 -0
- package/dist/client/assets/WordCountDialog-CgDcnPdJ.js.br +0 -0
- package/dist/client/assets/WordCountDialog-CgDcnPdJ.js.gz +0 -0
- package/dist/client/assets/arrow-down-C_4f1E-E.js +1 -0
- package/dist/client/assets/check-Dw16EqG-.js +1 -0
- package/dist/client/assets/chevron-up-BHaMUEEA.js +1 -0
- package/dist/client/assets/{chktex-Dm6IIkcR.js → chktex-BeOSrdut.js} +1 -1
- package/dist/client/assets/circle-check-CunlnBPw.js +1 -0
- package/dist/client/assets/clipboard-CslquMx4.js +1 -0
- package/dist/client/assets/clock-3-DztJubz_.js +1 -0
- package/dist/client/assets/createLucideIcon-CDYIzuiB.js +1 -0
- package/dist/client/assets/createLucideIcon-CDYIzuiB.js.br +0 -0
- package/dist/client/assets/createLucideIcon-CDYIzuiB.js.gz +0 -0
- package/dist/client/assets/dist-B_WjsTVV.js +1 -0
- package/dist/client/assets/dist-B_WjsTVV.js.br +0 -0
- package/dist/client/assets/dist-B_WjsTVV.js.gz +0 -0
- package/dist/client/assets/dist-Bcdl4EAC.js +1 -0
- package/dist/client/assets/dist-Bcdl4EAC.js.br +0 -0
- package/dist/client/assets/dist-Bcdl4EAC.js.gz +0 -0
- package/dist/client/assets/dist-DdUqlCPw.js +1 -0
- package/dist/client/assets/dist-DdUqlCPw.js.br +0 -0
- package/dist/client/assets/dist-DdUqlCPw.js.gz +0 -0
- package/dist/client/assets/editor-JqCouYk8.js +14 -0
- package/dist/client/assets/editor-JqCouYk8.js.br +0 -0
- package/dist/client/assets/editor-JqCouYk8.js.gz +0 -0
- package/dist/client/assets/editor-languages-CRI2h3Fj.js +36 -0
- package/dist/client/assets/editor-languages-CRI2h3Fj.js.br +0 -0
- package/dist/client/assets/editor-languages-CRI2h3Fj.js.gz +0 -0
- package/dist/client/assets/editorThemeExtension-BNWs0sHh.js +1 -0
- package/dist/client/assets/editorThemeExtension-BNWs0sHh.js.br +0 -0
- package/dist/client/assets/editorThemeExtension-BNWs0sHh.js.gz +0 -0
- package/dist/client/assets/es2015-D2UDOM09.js +41 -0
- package/dist/client/assets/es2015-D2UDOM09.js.br +0 -0
- package/dist/client/assets/es2015-D2UDOM09.js.gz +0 -0
- package/dist/client/assets/eye-BnslGpqB.js +1 -0
- package/dist/client/assets/hard-drive-CXlummIE.js +1 -0
- package/dist/client/assets/i18n-Bv4wFb8D.js +13 -0
- package/dist/client/assets/i18n-Bv4wFb8D.js.br +0 -0
- package/dist/client/assets/i18n-Bv4wFb8D.js.gz +0 -0
- package/dist/client/assets/index-Bdb2ITID.js +2 -0
- package/dist/client/assets/index-Bdb2ITID.js.br +0 -0
- package/dist/client/assets/index-Bdb2ITID.js.gz +0 -0
- package/dist/client/assets/index-wqKiaXZr.css +1 -0
- package/dist/client/assets/index-wqKiaXZr.css.br +0 -0
- package/dist/client/assets/index-wqKiaXZr.css.gz +0 -0
- package/dist/client/assets/katex-CBRBI6nR.js +257 -0
- package/dist/client/assets/katex-CBRBI6nR.js.br +0 -0
- package/dist/client/assets/katex-CBRBI6nR.js.gz +0 -0
- package/dist/client/assets/katex-CvRo0776.css +1 -0
- package/dist/client/assets/katex-CvRo0776.css.br +0 -0
- package/dist/client/assets/{katex-DDK6mlKN.css.gz → katex-CvRo0776.css.gz} +0 -0
- package/dist/client/assets/library-big-B8e_Fiql.js +1 -0
- package/dist/client/assets/loader-circle-DKGyi5EK.js +1 -0
- package/dist/client/assets/lock-keyhole-aC_QjKDi.js +1 -0
- package/dist/client/assets/minimize-2-CkBmeGXp.js +1 -0
- package/dist/client/assets/minus-DrpwqY8Y.js +1 -0
- package/dist/client/assets/refresh-cw-IqExWG6S.js +1 -0
- package/dist/client/assets/relativeTime-DlKXhH_h.js +1 -0
- package/dist/client/assets/relativeTime-DlKXhH_h.js.br +0 -0
- package/dist/client/assets/relativeTime-DlKXhH_h.js.gz +0 -0
- package/dist/client/assets/search-DjOWqLig.js +1 -0
- package/dist/client/assets/sourceCursorStore-C7u-3Gbl.js +1 -0
- package/dist/client/assets/sourceCursorStore-C7u-3Gbl.js.br +0 -0
- package/dist/client/assets/sourceCursorStore-C7u-3Gbl.js.gz +0 -0
- package/dist/client/assets/{spellCheck-DiNvmZKv.js → spellCheck-P-fMO4iR.js} +1 -1
- package/dist/client/assets/spellCheck-P-fMO4iR.js.br +0 -0
- package/dist/client/assets/spellCheck-P-fMO4iR.js.gz +0 -0
- package/dist/client/assets/tags-GrE3ZIQN.js +1 -0
- package/dist/client/assets/terminal-DD9WJ56e.js +1 -0
- package/dist/client/assets/{textLanguageSupport-DIXngcZX.js → textLanguageSupport-BSIE7WPM.js} +1 -1
- package/dist/client/assets/textLanguages-DAJ1OXJA.js +78 -0
- package/dist/client/assets/textLanguages-DAJ1OXJA.js.br +0 -0
- package/dist/client/assets/textLanguages-DAJ1OXJA.js.gz +0 -0
- package/dist/client/assets/type-CKe1tHHo.js +1 -0
- package/dist/client/assets/useDeletionTransitions-TAZINdHX.js +1 -0
- package/dist/client/assets/useDeletionTransitions-TAZINdHX.js.br +0 -0
- package/dist/client/assets/useDeletionTransitions-TAZINdHX.js.gz +0 -0
- package/dist/client/assets/useTranslation-DwkoADSz.js +1 -0
- package/dist/client/assets/useTranslation-DwkoADSz.js.br +0 -0
- package/dist/client/assets/useTranslation-DwkoADSz.js.gz +0 -0
- package/dist/client/assets/user-plus-NNBQOWDP.js +1 -0
- package/dist/client/assets/{vimSupport-RdD-E-Eh.js → vimSupport-BwIAfLU0.js} +6 -6
- package/dist/client/assets/vimSupport-BwIAfLU0.js.br +0 -0
- package/dist/client/assets/vimSupport-BwIAfLU0.js.gz +0 -0
- package/dist/client/index.html +9 -4
- package/dist/server/app.js +7 -1
- package/dist/server/byteRange.js +19 -0
- package/dist/server/citationCollections.js +163 -0
- package/dist/server/citationFolderTransfer.js +74 -0
- package/dist/server/citationInput.js +34 -0
- package/dist/server/collaboration.js +47 -16
- package/dist/server/commentMentions.js +6 -1
- package/dist/server/commentSuggestions.js +143 -0
- package/dist/server/db.js +81 -0
- package/dist/server/i18n.js +9 -0
- package/dist/server/locales/zh-Hant.js +6 -0
- package/dist/server/projectPreview.js +133 -0
- package/dist/server/routes/citations.js +84 -55
- package/dist/server/routes/commentSuggestions.js +154 -0
- package/dist/server/routes/comments.js +17 -1
- package/dist/server/routes/compile.js +1 -19
- package/dist/server/routes/projectShared.js +3 -0
- package/dist/server/routes/projectViewLinks.js +238 -0
- package/dist/server/routes/projects.js +12 -3
- package/dist/server/viewLinkTokens.js +49 -0
- package/dist/server/viewLinks.js +25 -0
- package/dist/shared/citationCollections.js +29 -0
- package/dist/shared/citationContent.js +4 -0
- package/dist/shared/citationTransfer.js +7 -0
- package/dist/shared/comments.js +2 -1
- package/dist/shared/projectCatalog.js +1 -1
- package/dist/shared/projectViewLinks.js +20 -0
- package/dist/shared/suggestionMessages.js +41 -0
- package/dist/shared/updates.js +1 -1
- package/package.json +9 -1
- package/dist/client/assets/AdminUsers-D5vhK_Ae.js +0 -1
- package/dist/client/assets/AdminUsers-D5vhK_Ae.js.br +0 -0
- package/dist/client/assets/AdminUsers-D5vhK_Ae.js.gz +0 -0
- package/dist/client/assets/AgentIcon-C97W4Mt-.js +0 -1
- package/dist/client/assets/AgentIcon-C97W4Mt-.js.br +0 -0
- package/dist/client/assets/AgentIcon-C97W4Mt-.js.gz +0 -0
- package/dist/client/assets/AgentIcon-DxrC-zx_.css +0 -1
- package/dist/client/assets/AgentIcon-DxrC-zx_.css.br +0 -0
- package/dist/client/assets/AgentIcon-DxrC-zx_.css.gz +0 -0
- package/dist/client/assets/AgentManagement-D6I_GDL_.js +0 -1
- package/dist/client/assets/AgentManagement-D6I_GDL_.js.br +0 -0
- package/dist/client/assets/AgentManagement-D6I_GDL_.js.gz +0 -0
- package/dist/client/assets/AgentTerminal-fsHpIB_c.js +0 -2
- package/dist/client/assets/AgentTerminal-fsHpIB_c.js.br +0 -0
- package/dist/client/assets/AgentTerminal-fsHpIB_c.js.gz +0 -0
- package/dist/client/assets/AgentTerminalSurface-C11baRxh.js.br +0 -0
- package/dist/client/assets/AgentTerminalSurface-C11baRxh.js.gz +0 -0
- package/dist/client/assets/AvatarSettingsDialog-B80aSza0.js +0 -1
- package/dist/client/assets/AvatarSettingsDialog-B80aSza0.js.br +0 -0
- package/dist/client/assets/AvatarSettingsDialog-B80aSza0.js.gz +0 -0
- package/dist/client/assets/CitationLibraryDialog-DE7W81FW.js +0 -1
- package/dist/client/assets/CitationLibraryDialog-DE7W81FW.js.br +0 -0
- package/dist/client/assets/CitationLibraryDialog-DE7W81FW.js.gz +0 -0
- package/dist/client/assets/Dashboard-DAPwKNNH.js +0 -5
- package/dist/client/assets/Dashboard-DAPwKNNH.js.br +0 -0
- package/dist/client/assets/Dashboard-DAPwKNNH.js.gz +0 -0
- package/dist/client/assets/GitDialog-BzyA_IgU.js +0 -3
- package/dist/client/assets/GitDialog-BzyA_IgU.js.br +0 -0
- package/dist/client/assets/GitDialog-BzyA_IgU.js.gz +0 -0
- package/dist/client/assets/GitHubAccountDialog-tigrQQNz.js +0 -1
- package/dist/client/assets/GitHubAccountDialog-tigrQQNz.js.br +0 -0
- package/dist/client/assets/GitHubAccountDialog-tigrQQNz.js.gz +0 -0
- package/dist/client/assets/GitHubIcon-BqDow-CN.js +0 -1
- package/dist/client/assets/HistoryDialog-407q3Fe6.js +0 -8
- package/dist/client/assets/HistoryDialog-407q3Fe6.js.br +0 -0
- package/dist/client/assets/HistoryDialog-407q3Fe6.js.gz +0 -0
- package/dist/client/assets/LatexEditor-BYiVPD_b.js +0 -101
- package/dist/client/assets/LatexEditor-BYiVPD_b.js.br +0 -0
- package/dist/client/assets/LatexEditor-BYiVPD_b.js.gz +0 -0
- package/dist/client/assets/PdfPreview-Bbzop29j.js +0 -1
- package/dist/client/assets/PdfPreview-Bbzop29j.js.br +0 -0
- package/dist/client/assets/PdfPreview-Bbzop29j.js.gz +0 -0
- package/dist/client/assets/ProjectIconPickerDialog-CsT5Pj4j.js +0 -1
- package/dist/client/assets/ProjectIconPickerDialog-CsT5Pj4j.js.br +0 -0
- package/dist/client/assets/ProjectIconPickerDialog-CsT5Pj4j.js.gz +0 -0
- package/dist/client/assets/ProjectSettings-BfvAiyC6.js +0 -4
- package/dist/client/assets/ProjectSettings-BfvAiyC6.js.br +0 -0
- package/dist/client/assets/ProjectSettings-BfvAiyC6.js.gz +0 -0
- package/dist/client/assets/ProjectWorkspace-DHVcaXR0.js +0 -30
- package/dist/client/assets/ProjectWorkspace-DHVcaXR0.js.br +0 -0
- package/dist/client/assets/ProjectWorkspace-DHVcaXR0.js.gz +0 -0
- package/dist/client/assets/QuickOpenDialog-DKq9iNJ5.js +0 -1
- package/dist/client/assets/QuickOpenDialog-DKq9iNJ5.js.br +0 -0
- package/dist/client/assets/QuickOpenDialog-DKq9iNJ5.js.gz +0 -0
- package/dist/client/assets/SaveButton-C8W1DGzx.js +0 -1
- package/dist/client/assets/SelectionHistoryDialog-cDxbuXmO.js.br +0 -0
- package/dist/client/assets/SelectionHistoryDialog-cDxbuXmO.js.gz +0 -0
- package/dist/client/assets/SystemMetricsDialog-GZbYEHna.js +0 -1
- package/dist/client/assets/SystemMetricsDialog-GZbYEHna.js.br +0 -0
- package/dist/client/assets/SystemMetricsDialog-GZbYEHna.js.gz +0 -0
- package/dist/client/assets/TagManagementDialog-BN3tlXuW.js +0 -1
- package/dist/client/assets/TagManagementDialog-BN3tlXuW.js.br +0 -0
- package/dist/client/assets/TagManagementDialog-BN3tlXuW.js.gz +0 -0
- package/dist/client/assets/WordCountDialog-C4okQWS3.js +0 -1
- package/dist/client/assets/WordCountDialog-C4okQWS3.js.br +0 -0
- package/dist/client/assets/WordCountDialog-C4okQWS3.js.gz +0 -0
- package/dist/client/assets/arrow-down-BiIGj4-X.js +0 -1
- package/dist/client/assets/check-DfWHdQ1s.js +0 -1
- package/dist/client/assets/chevron-up-lyMKml7P.js +0 -1
- package/dist/client/assets/circle-check-DjXwnxuR.js +0 -1
- package/dist/client/assets/clock-3-D-XeFtkK.js +0 -1
- package/dist/client/assets/dist-ByqeNQqT.js +0 -1
- package/dist/client/assets/dist-ByqeNQqT.js.br +0 -0
- package/dist/client/assets/dist-ByqeNQqT.js.gz +0 -0
- package/dist/client/assets/dist-Dxkdrap6.js +0 -2
- package/dist/client/assets/dist-Dxkdrap6.js.br +0 -0
- package/dist/client/assets/dist-Dxkdrap6.js.gz +0 -0
- package/dist/client/assets/editor-languages-C6EDWlLD.js +0 -36
- package/dist/client/assets/editor-languages-C6EDWlLD.js.br +0 -0
- package/dist/client/assets/editor-languages-C6EDWlLD.js.gz +0 -0
- package/dist/client/assets/editor-oR9RlWUz.js +0 -14
- package/dist/client/assets/editor-oR9RlWUz.js.br +0 -0
- package/dist/client/assets/editor-oR9RlWUz.js.gz +0 -0
- package/dist/client/assets/eye-BvCLgqrq.js +0 -1
- package/dist/client/assets/hard-drive-Crh-l_oh.js +0 -1
- package/dist/client/assets/i18n-O9QnEo2t.js +0 -13
- package/dist/client/assets/i18n-O9QnEo2t.js.br +0 -0
- package/dist/client/assets/i18n-O9QnEo2t.js.gz +0 -0
- package/dist/client/assets/index-7d5TfVNx.css +0 -1
- package/dist/client/assets/index-7d5TfVNx.css.br +0 -0
- package/dist/client/assets/index-7d5TfVNx.css.gz +0 -0
- package/dist/client/assets/index-DFEpXxLs.js +0 -42
- package/dist/client/assets/index-DFEpXxLs.js.br +0 -0
- package/dist/client/assets/index-DFEpXxLs.js.gz +0 -0
- package/dist/client/assets/info-g1IBvVg6.js +0 -1
- package/dist/client/assets/katex-Bd0sKoun.js +0 -257
- package/dist/client/assets/katex-Bd0sKoun.js.br +0 -0
- package/dist/client/assets/katex-Bd0sKoun.js.gz +0 -0
- package/dist/client/assets/katex-DDK6mlKN.css +0 -1
- package/dist/client/assets/katex-DDK6mlKN.css.br +0 -0
- package/dist/client/assets/minimize-2-BHKmubQs.js +0 -1
- package/dist/client/assets/minus-BmWzkFwz.js +0 -1
- package/dist/client/assets/plus-CoYCCEFJ.js +0 -1
- package/dist/client/assets/refresh-cw-Di6Huxb4.js +0 -1
- package/dist/client/assets/relativeTime-CFNodf1I.js +0 -1
- package/dist/client/assets/relativeTime-CFNodf1I.js.br +0 -0
- package/dist/client/assets/relativeTime-CFNodf1I.js.gz +0 -0
- package/dist/client/assets/search-l36unLLS.js +0 -1
- package/dist/client/assets/spellCheck-DiNvmZKv.js.br +0 -0
- package/dist/client/assets/spellCheck-DiNvmZKv.js.gz +0 -0
- package/dist/client/assets/tags-yjr9KRc8.js +0 -1
- package/dist/client/assets/terminal-P09ZGT83.js +0 -1
- package/dist/client/assets/type-C7rzXWVU.js +0 -1
- package/dist/client/assets/user-plus-CqyV7OV4.js +0 -1
- package/dist/client/assets/vimSupport-RdD-E-Eh.js.br +0 -0
- package/dist/client/assets/vimSupport-RdD-E-Eh.js.gz +0 -0
|
@@ -2,6 +2,9 @@ import { randomUUID } from "node:crypto";
|
|
|
2
2
|
import { requireUser } from "../auth.js";
|
|
3
3
|
import { apiError, httpError, ValidationError } from "../http.js";
|
|
4
4
|
import { MAX_CITATION_BIBTEX_BYTES } from "../limits.js";
|
|
5
|
+
import { assertCitationCollectionCapacity, citationCollectionIds, citationCollectionsForEntries, filterCitationCollection, registerCitationCollectionRoutes } from "../citationCollections.js";
|
|
6
|
+
import { comparableCitationBibtex } from "../../shared/citationContent.js";
|
|
7
|
+
import { citationInput } from "../citationInput.js";
|
|
5
8
|
const tagColors = ["red", "orange", "yellow", "green", "blue", "purple", "gray"];
|
|
6
9
|
const now = () => new Date().toISOString();
|
|
7
10
|
function escapeLikePattern(value) {
|
|
@@ -13,16 +16,18 @@ function text(value, max = 200) {
|
|
|
13
16
|
}
|
|
14
17
|
return value.trim();
|
|
15
18
|
}
|
|
16
|
-
function citationJson(row, tags = []) {
|
|
19
|
+
function citationJson(row, tags = [], collectionIds = []) {
|
|
17
20
|
return {
|
|
18
21
|
id: row.id,
|
|
19
22
|
citationKey: row.citation_key,
|
|
20
23
|
entryType: row.entry_type,
|
|
21
24
|
bibtex: row.bibtex,
|
|
25
|
+
notes: row.notes,
|
|
22
26
|
title: row.title,
|
|
23
27
|
authors: row.authors,
|
|
24
28
|
year: row.year,
|
|
25
29
|
revision: row.revision,
|
|
30
|
+
collectionIds,
|
|
26
31
|
tags: tags.map((tag) => ({ id: tag.id, name: tag.name, color: tag.color, ownerId: tag.user_id })),
|
|
27
32
|
ownerId: row.user_id,
|
|
28
33
|
ownerUsername: row.owner_username ?? null,
|
|
@@ -31,6 +36,9 @@ function citationJson(row, tags = []) {
|
|
|
31
36
|
updatedAt: row.updated_at
|
|
32
37
|
};
|
|
33
38
|
}
|
|
39
|
+
function citationDetails(db, row) {
|
|
40
|
+
return citationJson(row, citationTagsForEntries(db, [row.id]).get(row.id), citationCollectionsForEntries(db, [row.id]).get(row.id));
|
|
41
|
+
}
|
|
34
42
|
function citationTagsForEntries(db, entryIds) {
|
|
35
43
|
const result = new Map(entryIds.map((entryId) => [entryId, []]));
|
|
36
44
|
if (!entryIds.length)
|
|
@@ -71,42 +79,10 @@ function citationExpectedRevision(value) {
|
|
|
71
79
|
}
|
|
72
80
|
return Number(value);
|
|
73
81
|
}
|
|
74
|
-
function citationNullableText(value, max) {
|
|
75
|
-
if (value === undefined || value === null || value === "")
|
|
76
|
-
return null;
|
|
77
|
-
if (typeof value !== "string" || value.length > max)
|
|
78
|
-
throw new ValidationError();
|
|
79
|
-
const trimmed = value.trim();
|
|
80
|
-
return trimmed || null;
|
|
81
|
-
}
|
|
82
|
-
function citationInput(value) {
|
|
83
|
-
if (typeof value !== "object" || value === null)
|
|
84
|
-
throw new ValidationError();
|
|
85
|
-
const body = value;
|
|
86
|
-
if (typeof body.bibtex !== "string" || !body.bibtex.trim()) {
|
|
87
|
-
throw new ValidationError();
|
|
88
|
-
}
|
|
89
|
-
if (Buffer.byteLength(body.bibtex, "utf8") > MAX_CITATION_BIBTEX_BYTES) {
|
|
90
|
-
throw httpError(413, "CITATION_TOO_LARGE");
|
|
91
|
-
}
|
|
92
|
-
if (typeof body.citationKey !== "string" || !body.citationKey.trim() || body.citationKey.length > 512) {
|
|
93
|
-
throw new ValidationError();
|
|
94
|
-
}
|
|
95
|
-
if (typeof body.entryType !== "string" || !body.entryType.trim() || body.entryType.length > 128) {
|
|
96
|
-
throw new ValidationError();
|
|
97
|
-
}
|
|
98
|
-
return {
|
|
99
|
-
bibtex: body.bibtex.trim(),
|
|
100
|
-
citationKey: body.citationKey.trim(),
|
|
101
|
-
entryType: body.entryType.trim(),
|
|
102
|
-
title: citationNullableText(body.title, 2048),
|
|
103
|
-
authors: citationNullableText(body.authors, 2048),
|
|
104
|
-
year: citationNullableText(body.year, 128)
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
82
|
/** Register the current user's private citation-library routes. */
|
|
108
83
|
export function registerCitationRoutes(app, context) {
|
|
109
84
|
const { db } = context;
|
|
85
|
+
registerCitationCollectionRoutes(app, db);
|
|
110
86
|
app.get("/api/citations", async (request, reply) => {
|
|
111
87
|
const user = requireUser(request, reply, db);
|
|
112
88
|
if (!user)
|
|
@@ -119,6 +95,7 @@ export function registerCitationRoutes(app, context) {
|
|
|
119
95
|
const pageSize = Math.min(200, Math.max(1, Number.isFinite(requestedPageSize) ? requestedPageSize : 60));
|
|
120
96
|
const where = ["entry.user_id = ?"];
|
|
121
97
|
const params = [user.id];
|
|
98
|
+
filterCitationCollection(db, user.id, typeof query.collection === "string" ? query.collection.trim() : "", where, params);
|
|
122
99
|
if (search) {
|
|
123
100
|
where.push(`(
|
|
124
101
|
citation_key LIKE ? ESCAPE '\\' OR entry_type LIKE ? ESCAPE '\\'
|
|
@@ -147,8 +124,9 @@ export function registerCitationRoutes(app, context) {
|
|
|
147
124
|
JOIN users owner ON owner.id = entry.user_id
|
|
148
125
|
WHERE ${where.join(" AND ")} ORDER BY entry.updated_at DESC, entry.citation_key COLLATE NOCASE LIMIT ? OFFSET ?`).all(...params);
|
|
149
126
|
const tags = citationTagsForEntries(db, rows.map((row) => row.id));
|
|
127
|
+
const collections = citationCollectionsForEntries(db, rows.map((row) => row.id));
|
|
150
128
|
return {
|
|
151
|
-
entries: rows.map((row) => citationJson(row, tags.get(row.id)
|
|
129
|
+
entries: rows.map((row) => citationJson(row, tags.get(row.id), collections.get(row.id))),
|
|
152
130
|
pagination: { page, pageSize, total, totalPages }
|
|
153
131
|
};
|
|
154
132
|
});
|
|
@@ -216,25 +194,48 @@ export function registerCitationRoutes(app, context) {
|
|
|
216
194
|
return;
|
|
217
195
|
return apiError(reply, 403, "CITATION_LIBRARY_PRIVATE");
|
|
218
196
|
});
|
|
219
|
-
app.post("/api/citations/lookup", async (request, reply) => {
|
|
197
|
+
app.post("/api/citations/lookup", { bodyLimit: MAX_CITATION_BIBTEX_BYTES * 8 }, async (request, reply) => {
|
|
220
198
|
const user = requireUser(request, reply, db);
|
|
221
199
|
if (!user)
|
|
222
200
|
return;
|
|
223
201
|
const body = request.body;
|
|
224
|
-
|
|
225
|
-
|
|
202
|
+
let contents = null;
|
|
203
|
+
let keyInput = body?.keys;
|
|
204
|
+
if (body?.entries !== undefined) {
|
|
205
|
+
if (body.keys !== undefined || !Array.isArray(body.entries) || body.entries.length > 5000)
|
|
206
|
+
throw new ValidationError();
|
|
207
|
+
contents = new Map();
|
|
208
|
+
let bytes = 0;
|
|
209
|
+
keyInput = body.entries.map((value) => {
|
|
210
|
+
if (typeof value !== "object" || !value)
|
|
211
|
+
throw new ValidationError();
|
|
212
|
+
const item = value;
|
|
213
|
+
if (typeof item.citationKey !== "string" || typeof item.bibtex !== "string" || !item.bibtex.trim())
|
|
214
|
+
throw new ValidationError();
|
|
215
|
+
bytes += Buffer.byteLength(item.bibtex, "utf8");
|
|
216
|
+
if (bytes > MAX_CITATION_BIBTEX_BYTES)
|
|
217
|
+
throw httpError(413, "CITATION_TOO_LARGE");
|
|
218
|
+
contents.set(item.citationKey.trim().toLowerCase(), comparableCitationBibtex(item.bibtex));
|
|
219
|
+
return item.citationKey;
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
if (!Array.isArray(keyInput) || keyInput.length > 5000
|
|
223
|
+
|| keyInput.some((key) => typeof key !== "string" || !key.trim() || key.length > 512)) {
|
|
226
224
|
throw new ValidationError();
|
|
227
225
|
}
|
|
228
|
-
const keys = [...new Map(
|
|
226
|
+
const keys = [...new Map(keyInput.map((key) => [key.trim().toLowerCase(), key.trim()])).values()];
|
|
229
227
|
const matches = [];
|
|
230
228
|
for (let offset = 0; offset < keys.length; offset += 500) {
|
|
231
229
|
const chunk = keys.slice(offset, offset + 500);
|
|
232
230
|
const placeholders = chunk.map(() => "?").join(", ");
|
|
233
|
-
|
|
231
|
+
const rows = db.prepare(`SELECT id, citation_key, revision${contents ? ", bibtex" : ""} FROM citation_library_entries
|
|
234
232
|
WHERE user_id = ? AND citation_key COLLATE NOCASE IN (${placeholders})`)
|
|
235
|
-
.
|
|
233
|
+
.iterate(user.id, ...chunk);
|
|
234
|
+
for (const row of rows)
|
|
235
|
+
matches.push({ id: row.id, citationKey: row.citation_key, revision: row.revision,
|
|
236
|
+
...(contents ? { sameContent: comparableCitationBibtex(row.bibtex) === contents.get(row.citation_key.toLowerCase()) } : {}) });
|
|
236
237
|
}
|
|
237
|
-
return { matches
|
|
238
|
+
return { matches };
|
|
238
239
|
});
|
|
239
240
|
app.post("/api/citations", async (request, reply) => {
|
|
240
241
|
const user = requireUser(request, reply, db);
|
|
@@ -243,6 +244,7 @@ export function registerCitationRoutes(app, context) {
|
|
|
243
244
|
const body = request.body;
|
|
244
245
|
const citation = citationInput(body);
|
|
245
246
|
const tagIds = citationTagIds(db, user.id, body?.tagIds);
|
|
247
|
+
const collectionIds = citationCollectionIds(db, user.id, body?.collectionIds);
|
|
246
248
|
const overwrite = body?.overwrite === true;
|
|
247
249
|
const existing = db.prepare("SELECT id, revision FROM citation_library_entries WHERE user_id = ? AND citation_key = ? COLLATE NOCASE")
|
|
248
250
|
.get(user.id, citation.citationKey);
|
|
@@ -255,30 +257,34 @@ export function registerCitationRoutes(app, context) {
|
|
|
255
257
|
const id = existing?.id ?? randomUUID();
|
|
256
258
|
const timestamp = now();
|
|
257
259
|
db.transaction(() => {
|
|
260
|
+
assertCitationCollectionCapacity(db, user.id, id, collectionIds ?? []);
|
|
258
261
|
if (existing) {
|
|
259
262
|
const result = db.prepare(`UPDATE citation_library_entries SET citation_key = ?, entry_type = ?, bibtex = ?,
|
|
260
|
-
title = ?, authors = ?, year = ?, revision = revision + 1, updated_at = ?
|
|
263
|
+
title = ?, authors = ?, year = ?, notes = COALESCE(?, notes), revision = revision + 1, updated_at = ?
|
|
261
264
|
WHERE id = ? AND user_id = ? AND revision = ?`)
|
|
262
|
-
.run(citation.citationKey, citation.entryType, citation.bibtex, citation.title, citation.authors, citation.year, timestamp, id, user.id, expectedRevision);
|
|
265
|
+
.run(citation.citationKey, citation.entryType, citation.bibtex, citation.title, citation.authors, citation.year, citation.notes ?? null, timestamp, id, user.id, expectedRevision);
|
|
263
266
|
if (!result.changes)
|
|
264
267
|
throw httpError(409, "CITATION_CONFLICT");
|
|
265
268
|
}
|
|
266
269
|
else {
|
|
267
270
|
db.prepare(`INSERT INTO citation_library_entries
|
|
268
|
-
(id, user_id, citation_key, entry_type, bibtex, title, authors, year, revision, created_at, updated_at)
|
|
269
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, 1, ?, ?)`)
|
|
270
|
-
.run(id, user.id, citation.citationKey, citation.entryType, citation.bibtex, citation.title, citation.authors, citation.year, timestamp, timestamp);
|
|
271
|
+
(id, user_id, citation_key, entry_type, bibtex, title, authors, year, notes, revision, created_at, updated_at)
|
|
272
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, 1, ?, ?)`)
|
|
273
|
+
.run(id, user.id, citation.citationKey, citation.entryType, citation.bibtex, citation.title, citation.authors, citation.year, citation.notes ?? "", timestamp, timestamp);
|
|
271
274
|
}
|
|
272
275
|
if (tagIds !== null) {
|
|
273
276
|
db.prepare("DELETE FROM citation_library_entry_tags WHERE entry_id = ?").run(id);
|
|
274
277
|
for (const tagId of tagIds)
|
|
275
278
|
db.prepare("INSERT INTO citation_library_entry_tags (entry_id, tag_id, created_at) VALUES (?, ?, ?)").run(id, tagId, timestamp);
|
|
276
279
|
}
|
|
280
|
+
// Saving from a project's .bib adds the chosen folder without removing
|
|
281
|
+
// other placements of an already-saved reference.
|
|
282
|
+
for (const collectionId of collectionIds ?? [])
|
|
283
|
+
db.prepare("INSERT OR IGNORE INTO citation_library_entry_collections (entry_id, collection_id) VALUES (?, ?)").run(id, collectionId);
|
|
277
284
|
})();
|
|
278
285
|
const row = db.prepare("SELECT * FROM citation_library_entries WHERE id = ? AND user_id = ?")
|
|
279
286
|
.get(id, user.id);
|
|
280
|
-
|
|
281
|
-
return reply.code(existing ? 200 : 201).send({ entry: citationJson(row, tags.get(id) ?? []), updated: Boolean(existing) });
|
|
287
|
+
return reply.code(existing ? 200 : 201).send({ entry: citationDetails(db, row), updated: Boolean(existing) });
|
|
282
288
|
});
|
|
283
289
|
app.patch("/api/citations/:citationId/tags", async (request, reply) => {
|
|
284
290
|
const user = requireUser(request, reply, db);
|
|
@@ -310,8 +316,32 @@ export function registerCitationRoutes(app, context) {
|
|
|
310
316
|
})();
|
|
311
317
|
const row = db.prepare("SELECT * FROM citation_library_entries WHERE id = ? AND user_id = ?")
|
|
312
318
|
.get(citationId, user.id);
|
|
313
|
-
|
|
314
|
-
|
|
319
|
+
return { entry: citationDetails(db, row) };
|
|
320
|
+
});
|
|
321
|
+
app.patch("/api/citations/:citationId/collections", async (request, reply) => {
|
|
322
|
+
const user = requireUser(request, reply, db);
|
|
323
|
+
if (!user)
|
|
324
|
+
return;
|
|
325
|
+
const { citationId } = request.params;
|
|
326
|
+
if (!db.prepare("SELECT id FROM citation_library_entries WHERE id = ? AND user_id = ?").get(citationId, user.id))
|
|
327
|
+
throw httpError(404, "CITATION_NOT_FOUND");
|
|
328
|
+
const body = request.body;
|
|
329
|
+
const collectionIds = citationCollectionIds(db, user.id, body?.collectionIds);
|
|
330
|
+
if (collectionIds === null)
|
|
331
|
+
throw new ValidationError();
|
|
332
|
+
const revision = citationExpectedRevision(body?.expectedRevision);
|
|
333
|
+
db.transaction(() => {
|
|
334
|
+
const result = db.prepare("UPDATE citation_library_entries SET revision = revision + 1, updated_at = ? WHERE id = ? AND user_id = ? AND revision = ?").run(now(), citationId, user.id, revision);
|
|
335
|
+
if (!result.changes)
|
|
336
|
+
throw httpError(409, "CITATION_CONFLICT");
|
|
337
|
+
assertCitationCollectionCapacity(db, user.id, citationId, collectionIds);
|
|
338
|
+
db.prepare("DELETE FROM citation_library_entry_collections WHERE entry_id = ?").run(citationId);
|
|
339
|
+
const insert = db.prepare("INSERT INTO citation_library_entry_collections (entry_id, collection_id) VALUES (?, ?)");
|
|
340
|
+
for (const id of collectionIds)
|
|
341
|
+
insert.run(citationId, id);
|
|
342
|
+
})();
|
|
343
|
+
const row = db.prepare("SELECT * FROM citation_library_entries WHERE id = ? AND user_id = ?").get(citationId, user.id);
|
|
344
|
+
return { entry: citationDetails(db, row) };
|
|
315
345
|
});
|
|
316
346
|
app.patch("/api/citations/:citationId", async (request, reply) => {
|
|
317
347
|
const user = requireUser(request, reply, db);
|
|
@@ -330,15 +360,14 @@ export function registerCitationRoutes(app, context) {
|
|
|
330
360
|
if (duplicate)
|
|
331
361
|
return apiError(reply, 409, "CITATION_KEY_EXISTS");
|
|
332
362
|
const result = db.prepare(`UPDATE citation_library_entries SET citation_key = ?, entry_type = ?, bibtex = ?,
|
|
333
|
-
title = ?, authors = ?, year = ?, revision = revision + 1, updated_at = ?
|
|
363
|
+
title = ?, authors = ?, year = ?, notes = COALESCE(?, notes), revision = revision + 1, updated_at = ?
|
|
334
364
|
WHERE id = ? AND user_id = ? AND revision = ?`)
|
|
335
|
-
.run(citation.citationKey, citation.entryType, citation.bibtex, citation.title, citation.authors, citation.year, now(), citationId, user.id, expectedRevision);
|
|
365
|
+
.run(citation.citationKey, citation.entryType, citation.bibtex, citation.title, citation.authors, citation.year, citation.notes ?? null, now(), citationId, user.id, expectedRevision);
|
|
336
366
|
if (!result.changes)
|
|
337
367
|
return apiError(reply, 409, "CITATION_CONFLICT");
|
|
338
368
|
const updated = db.prepare("SELECT * FROM citation_library_entries WHERE id = ? AND user_id = ?")
|
|
339
369
|
.get(citationId, user.id);
|
|
340
|
-
|
|
341
|
-
return { entry: citationJson(updated, tags.get(citationId) ?? []) };
|
|
370
|
+
return { entry: citationDetails(db, updated) };
|
|
342
371
|
});
|
|
343
372
|
app.delete("/api/citations/:citationId", async (request, reply) => {
|
|
344
373
|
const user = requireUser(request, reply, db);
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import { requireUser } from "../auth.js";
|
|
4
|
+
import { accessibleProject, canEdit } from "../projects.js";
|
|
5
|
+
import { apiError, httpError } from "../http.js";
|
|
6
|
+
import { resolveSourcePath } from "../files.js";
|
|
7
|
+
import { isCollaborativeTextFile } from "../collaboration.js";
|
|
8
|
+
import { attachSuggestion, clearSuggestionReview, requestSuggestionReview, suggestionReviewers, suggestionRow, validateSuggestionReplacement } from "../commentSuggestions.js";
|
|
9
|
+
import { commentsForFile, commentsSummaryForProject, now } from "./projectShared.js";
|
|
10
|
+
export function registerSuggestionRoutes(app, context) {
|
|
11
|
+
const { db, config, collaboration, projectMutations } = context;
|
|
12
|
+
const result = (projectId, commentId, filePath) => {
|
|
13
|
+
const comment = commentsForFile(db, config, projectId, filePath).find((item) => item.id === commentId);
|
|
14
|
+
collaboration.signalComments(projectId);
|
|
15
|
+
return { change: { kind: "suggestion", commentId, filePath, suggestion: comment.suggestion }, summary: commentsSummaryForProject(db, projectId) };
|
|
16
|
+
};
|
|
17
|
+
app.get("/api/projects/:id/suggestion-reviewers", async (request, reply) => {
|
|
18
|
+
const user = requireUser(request, reply, db);
|
|
19
|
+
if (!user)
|
|
20
|
+
return;
|
|
21
|
+
const { id } = request.params;
|
|
22
|
+
const project = accessibleProject(db, id, user);
|
|
23
|
+
if (!project)
|
|
24
|
+
return apiError(reply, 404, "PROJECT_NOT_FOUND");
|
|
25
|
+
const { commentId } = request.query;
|
|
26
|
+
let authorId = user.id;
|
|
27
|
+
if (commentId !== undefined) {
|
|
28
|
+
const comment = db.prepare("SELECT author_id FROM comments WHERE id = ? AND project_id = ?").get(commentId, id);
|
|
29
|
+
if (!comment)
|
|
30
|
+
return apiError(reply, 404, "COMMENT_NOT_FOUND");
|
|
31
|
+
authorId = comment.author_id;
|
|
32
|
+
}
|
|
33
|
+
return { users: suggestionReviewers(db, id, authorId), ownerId: project.owner_id };
|
|
34
|
+
});
|
|
35
|
+
app.post("/api/projects/:id/comments/:commentId/suggestion", async (request, reply) => {
|
|
36
|
+
const user = requireUser(request, reply, db);
|
|
37
|
+
if (!user)
|
|
38
|
+
return;
|
|
39
|
+
const { id, commentId } = request.params;
|
|
40
|
+
if (!request.body || typeof request.body !== "object" || Array.isArray(request.body))
|
|
41
|
+
return apiError(reply, 400, "REQUEST_INVALID");
|
|
42
|
+
const body = request.body;
|
|
43
|
+
return projectMutations.runWrite(id, () => {
|
|
44
|
+
const comment = db.prepare("SELECT * FROM comments WHERE id = ? AND project_id = ?").get(commentId, id);
|
|
45
|
+
if (!comment)
|
|
46
|
+
throw httpError(404, "COMMENT_NOT_FOUND");
|
|
47
|
+
if (comment.author_id !== user.id)
|
|
48
|
+
throw httpError(403, "COMMENT_EDIT_FORBIDDEN");
|
|
49
|
+
const absolute = resolveSourcePath(config, id, comment.file_path);
|
|
50
|
+
if (comment.resolved || comment.orphaned || !isCollaborativeTextFile(comment.file_path) || !fs.existsSync(absolute))
|
|
51
|
+
throw httpError(409, "SUGGESTION_SOURCE_CHANGED");
|
|
52
|
+
const source = fs.readFileSync(absolute, "utf8");
|
|
53
|
+
if (comment.orphaned || createHash("sha256").update(source, "utf8").digest("hex") !== body.sourceHash
|
|
54
|
+
|| source.slice(comment.start_offset, comment.end_offset) !== comment.selected_text)
|
|
55
|
+
throw httpError(409, "SUGGESTION_SOURCE_CHANGED");
|
|
56
|
+
db.transaction(() => attachSuggestion(db, id, commentId, user.id, comment.selected_text, body))();
|
|
57
|
+
return result(id, commentId, comment.file_path);
|
|
58
|
+
}, { preflight: () => { if (!accessibleProject(db, id, user))
|
|
59
|
+
throw httpError(404, "PROJECT_NOT_FOUND"); } });
|
|
60
|
+
});
|
|
61
|
+
app.post("/api/projects/:id/comments/:commentId/suggestion/review", async (request, reply) => {
|
|
62
|
+
const user = requireUser(request, reply, db);
|
|
63
|
+
if (!user)
|
|
64
|
+
return;
|
|
65
|
+
const { id, commentId } = request.params;
|
|
66
|
+
const { action, expectedReplacementText } = (request.body ?? {});
|
|
67
|
+
if (action !== "accept" && action !== "reject")
|
|
68
|
+
return apiError(reply, 400, "REQUEST_INVALID");
|
|
69
|
+
const validate = () => {
|
|
70
|
+
const project = accessibleProject(db, id, user);
|
|
71
|
+
const row = suggestionRow(db, id, commentId);
|
|
72
|
+
if (!project || !canEdit(project) || row?.reviewer_id !== user.id || !suggestionReviewers(db, id).some((candidate) => candidate.id === user.id)) {
|
|
73
|
+
throw httpError(403, "SUGGESTION_REVIEW_FORBIDDEN");
|
|
74
|
+
}
|
|
75
|
+
if (row.author_id === user.id)
|
|
76
|
+
throw httpError(403, "SUGGESTION_SELF_REVIEW");
|
|
77
|
+
// Bind the decision to the replacement actually displayed by the reviewer.
|
|
78
|
+
// Repeat inside the project write queue after room preparation and flushing.
|
|
79
|
+
if (typeof expectedReplacementText !== "string" || row.replacement_text !== expectedReplacementText)
|
|
80
|
+
throw httpError(409, "SUGGESTION_UPDATED");
|
|
81
|
+
return row;
|
|
82
|
+
};
|
|
83
|
+
validate();
|
|
84
|
+
if (action === "accept")
|
|
85
|
+
await collaboration.prepareSuggestionRoom(id);
|
|
86
|
+
return projectMutations.runWrite(id, () => {
|
|
87
|
+
const row = validate();
|
|
88
|
+
const expected = action === "accept" ? "accepted" : "rejected";
|
|
89
|
+
if (row.status === expected)
|
|
90
|
+
return result(id, commentId, row.file_path);
|
|
91
|
+
if (row.status !== "pending")
|
|
92
|
+
throw httpError(409, "SUGGESTION_DECIDED");
|
|
93
|
+
if (action === "accept") {
|
|
94
|
+
if (!fs.existsSync(resolveSourcePath(config, id, row.file_path)))
|
|
95
|
+
throw httpError(409, "SUGGESTION_SOURCE_CHANGED");
|
|
96
|
+
collaboration.applyCommentSuggestion(id, row.file_path, commentId, user.id);
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
if (row.apply_update)
|
|
100
|
+
throw httpError(409, "SUGGESTION_APPLYING");
|
|
101
|
+
db.transaction(() => {
|
|
102
|
+
const at = now();
|
|
103
|
+
db.prepare("UPDATE comment_suggestions SET status = 'rejected', decided_by = ?, decided_at = ? WHERE comment_id = ?").run(user.id, at, commentId);
|
|
104
|
+
clearSuggestionReview(db, commentId, at);
|
|
105
|
+
})();
|
|
106
|
+
}
|
|
107
|
+
return result(id, commentId, row.file_path);
|
|
108
|
+
}, { preflight: () => { validate(); } });
|
|
109
|
+
});
|
|
110
|
+
app.patch("/api/projects/:id/comments/:commentId/suggestion", async (request, reply) => {
|
|
111
|
+
const user = requireUser(request, reply, db);
|
|
112
|
+
if (!user)
|
|
113
|
+
return;
|
|
114
|
+
const { id, commentId } = request.params;
|
|
115
|
+
if (!request.body || typeof request.body !== "object" || Array.isArray(request.body))
|
|
116
|
+
return apiError(reply, 400, "REQUEST_INVALID");
|
|
117
|
+
const body = request.body;
|
|
118
|
+
// Assignment is fixed when a suggestion is created; this endpoint only edits its text.
|
|
119
|
+
if (body.reviewerId !== undefined || typeof body.expectedReplacementText !== "string")
|
|
120
|
+
return apiError(reply, 400, "REQUEST_INVALID");
|
|
121
|
+
const validate = () => {
|
|
122
|
+
if (!accessibleProject(db, id, user))
|
|
123
|
+
throw httpError(404, "PROJECT_NOT_FOUND");
|
|
124
|
+
const row = suggestionRow(db, id, commentId);
|
|
125
|
+
if (!row)
|
|
126
|
+
throw httpError(404, "COMMENT_NOT_FOUND");
|
|
127
|
+
if (row.author_id !== user.id)
|
|
128
|
+
throw httpError(403, "COMMENT_EDIT_FORBIDDEN");
|
|
129
|
+
if (row.status !== "pending")
|
|
130
|
+
throw httpError(409, "SUGGESTION_DECIDED");
|
|
131
|
+
if (row.apply_update)
|
|
132
|
+
throw httpError(409, "SUGGESTION_APPLYING");
|
|
133
|
+
return row;
|
|
134
|
+
};
|
|
135
|
+
return projectMutations.runWrite(id, () => {
|
|
136
|
+
const row = validate();
|
|
137
|
+
validateSuggestionReplacement(row.original_text, body.replacementText);
|
|
138
|
+
// A retried save with identical text is a no-op, not another review request.
|
|
139
|
+
if (row.replacement_text === body.replacementText)
|
|
140
|
+
return result(id, commentId, row.file_path);
|
|
141
|
+
if (row.replacement_text !== body.expectedReplacementText)
|
|
142
|
+
throw httpError(409, "SUGGESTION_UPDATED");
|
|
143
|
+
db.transaction(() => {
|
|
144
|
+
const at = now();
|
|
145
|
+
db.prepare("UPDATE comment_suggestions SET replacement_text = ? WHERE comment_id = ?").run(body.replacementText, commentId);
|
|
146
|
+
clearSuggestionReview(db, commentId, at);
|
|
147
|
+
if (row.reviewer_id && suggestionReviewers(db, id, row.author_id).some((candidate) => candidate.id === row.reviewer_id)) {
|
|
148
|
+
requestSuggestionReview(db, id, commentId, row.reviewer_id, user.id, at);
|
|
149
|
+
}
|
|
150
|
+
})();
|
|
151
|
+
return result(id, commentId, row.file_path);
|
|
152
|
+
}, { preflight: () => { validate(); } });
|
|
153
|
+
});
|
|
154
|
+
}
|
|
@@ -5,11 +5,17 @@ import { createSourceAnchor, offsetToLine } from "../anchors.js";
|
|
|
5
5
|
import { resolveSourcePath, safeRelativePath } from "../files.js";
|
|
6
6
|
import { apiError, httpError } from "../http.js";
|
|
7
7
|
import { accessibleProject } from "../projects.js";
|
|
8
|
+
import { isCollaborativeTextFile } from "../collaboration.js";
|
|
9
|
+
import { attachSuggestion, suggestionRow } from "../commentSuggestions.js";
|
|
10
|
+
import { registerSuggestionRoutes } from "./commentSuggestions.js";
|
|
11
|
+
import { defaultSuggestionComments } from "../../shared/suggestionMessages.js";
|
|
12
|
+
import { serverLocale } from "../i18n.js";
|
|
8
13
|
import { commentMentionForUser, createCommentMentions, listCommentMentions, markAllCommentMentionsRead, markCommentMentionRead, markCommentMentionsResolved, mentionableUsersForProject } from "../commentMentions.js";
|
|
9
14
|
import { commentsForFile, commentsForProject, commentsSummaryForProject, now, repliesForComment, text } from "./projectShared.js";
|
|
10
15
|
/** Register source-anchored comments and reply routes. */
|
|
11
16
|
export function registerCommentRoutes(app, context) {
|
|
12
17
|
const { config, db, collaboration, projectMutations } = context;
|
|
18
|
+
registerSuggestionRoutes(app, context);
|
|
13
19
|
app.get("/api/projects/:id/mention-candidates", async (request, reply) => {
|
|
14
20
|
const user = requireUser(request, reply, db);
|
|
15
21
|
if (!user)
|
|
@@ -132,9 +138,13 @@ export function registerCommentRoutes(app, context) {
|
|
|
132
138
|
return apiError(reply, 409, "COMMENT_SOURCE_CHANGED");
|
|
133
139
|
}
|
|
134
140
|
const anchor = createSourceAnchor(source, Number(body.startOffset), Number(body.endOffset));
|
|
141
|
+
if (body.suggestion !== undefined && (!isCollaborativeTextFile(filePath) || body.sourceHash === undefined
|
|
142
|
+
|| Number(body.startOffset) < 0 || Number(body.endOffset) > source.length || Number(body.endOffset) <= Number(body.startOffset)))
|
|
143
|
+
throw httpError(400, "SUGGESTION_INVALID");
|
|
135
144
|
const comment = {
|
|
136
145
|
id: randomUUID(), filePath,
|
|
137
|
-
content: text(body.content
|
|
146
|
+
content: text(body.suggestion !== undefined && (body.content === undefined || typeof body.content === "string" && !body.content.trim())
|
|
147
|
+
? defaultSuggestionComments[serverLocale(request.headers)] : body.content, 5000)
|
|
138
148
|
};
|
|
139
149
|
db.transaction(() => {
|
|
140
150
|
db.prepare(`INSERT INTO comments
|
|
@@ -146,6 +156,8 @@ export function registerCommentRoutes(app, context) {
|
|
|
146
156
|
projectId: id, commentId: comment.id, authorId: user.id,
|
|
147
157
|
content: comment.content, createdAt
|
|
148
158
|
});
|
|
159
|
+
if (body.suggestion !== undefined)
|
|
160
|
+
attachSuggestion(db, id, comment.id, user.id, anchor.selectedText, body.suggestion);
|
|
149
161
|
})();
|
|
150
162
|
const created = commentsForFile(db, config, id, filePath).find((item) => item.id === comment.id);
|
|
151
163
|
collaboration.signalComments(id);
|
|
@@ -205,6 +217,8 @@ export function registerCommentRoutes(app, context) {
|
|
|
205
217
|
changed = true;
|
|
206
218
|
}
|
|
207
219
|
if (typeof body.resolved === "boolean") {
|
|
220
|
+
if (body.resolved && suggestionRow(db, id, commentId)?.status === "pending")
|
|
221
|
+
return apiError(reply, 409, "SUGGESTION_PENDING");
|
|
208
222
|
changed = true;
|
|
209
223
|
}
|
|
210
224
|
if (!changed)
|
|
@@ -256,6 +270,8 @@ export function registerCommentRoutes(app, context) {
|
|
|
256
270
|
return apiError(reply, 404, "COMMENT_NOT_FOUND");
|
|
257
271
|
if (comment.author_id !== user.id)
|
|
258
272
|
return apiError(reply, 403, "COMMENT_DELETE_FORBIDDEN");
|
|
273
|
+
if (suggestionRow(db, id, commentId)?.apply_update)
|
|
274
|
+
return apiError(reply, 409, "SUGGESTION_APPLYING");
|
|
259
275
|
db.prepare("DELETE FROM comments WHERE id = ?").run(commentId);
|
|
260
276
|
collaboration.signalComments(id);
|
|
261
277
|
const result = { change: { kind: "deleted", commentId, filePath: comment.file_path }, summary: commentsSummaryForProject(db, id) };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
|
+
import { parseByteRange } from "../byteRange.js";
|
|
2
3
|
import path from "node:path";
|
|
3
4
|
import { randomUUID } from "node:crypto";
|
|
4
5
|
import { performance } from "node:perf_hooks";
|
|
@@ -787,22 +788,3 @@ function compileRequestGeneration(project, persistedRevision, sourceGeneration,
|
|
|
787
788
|
function pdfDownloadTimestamp(date = new Date()) {
|
|
788
789
|
return date.toISOString().slice(0, 19).replace("T", "-").replaceAll(":", "");
|
|
789
790
|
}
|
|
790
|
-
function parseByteRange(value, size) {
|
|
791
|
-
if (!value)
|
|
792
|
-
return null;
|
|
793
|
-
const match = /^bytes=(\d*)-(\d*)$/.exec(value.trim());
|
|
794
|
-
if (!match || (!match[1] && !match[2]) || size < 1)
|
|
795
|
-
return "invalid";
|
|
796
|
-
if (!match[1]) {
|
|
797
|
-
const suffixLength = Number(match[2]);
|
|
798
|
-
if (!Number.isSafeInteger(suffixLength) || suffixLength <= 0)
|
|
799
|
-
return "invalid";
|
|
800
|
-
return { start: Math.max(0, size - suffixLength), end: size - 1 };
|
|
801
|
-
}
|
|
802
|
-
const start = Number(match[1]);
|
|
803
|
-
const requestedEnd = match[2] ? Number(match[2]) : size - 1;
|
|
804
|
-
if (!Number.isSafeInteger(start) || !Number.isSafeInteger(requestedEnd) || start >= size || requestedEnd < start) {
|
|
805
|
-
return "invalid";
|
|
806
|
-
}
|
|
807
|
-
return { start, end: Math.min(requestedEnd, size - 1) };
|
|
808
|
-
}
|
|
@@ -7,6 +7,7 @@ import { httpError, ValidationError } from "../http.js";
|
|
|
7
7
|
import { accessibleProject, canEdit } from "../projects.js";
|
|
8
8
|
import { isTextContent } from "../../shared/fileTypes.js";
|
|
9
9
|
import { sortProjectCommentsBySource } from "../commentSourceOrder.js";
|
|
10
|
+
import { suggestionsForProject } from "../commentSuggestions.js";
|
|
10
11
|
export const now = () => new Date().toISOString();
|
|
11
12
|
export function escapeLikePattern(value) {
|
|
12
13
|
return value.replace(/[\\%_]/g, "\\$&");
|
|
@@ -253,7 +254,9 @@ function commentsForScope(db, config, projectId, filePath) {
|
|
|
253
254
|
});
|
|
254
255
|
replyMap.set(reply.comment_id, list);
|
|
255
256
|
}
|
|
257
|
+
const suggestions = suggestionsForProject(db, projectId, sourceByPath);
|
|
256
258
|
const comments = rows.map((comment) => ({
|
|
259
|
+
suggestion: suggestions.get(comment.id) ?? null,
|
|
257
260
|
id: comment.id,
|
|
258
261
|
filePath: comment.file_path,
|
|
259
262
|
authorId: comment.author_id,
|