@jant/core 0.10.0 → 0.11.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/bin/commands/db/execute-file.js +1 -1
- package/bin/commands/db/export.js +1 -1
- package/bin/commands/migrate.js +4 -4
- package/bin/commands/posts/rebuild-html.js +1 -1
- package/bin/commands/reset-password.js +1 -1
- package/bin/commands/search/reindex.js +1 -1
- package/bin/commands/setup.js +4 -2
- package/bin/commands/site/export.js +3 -0
- package/bin/commands/site/import.js +178 -91
- package/bin/commands/site/pull-media.js +3 -2
- package/bin/commands/site/snapshot/export.js +3 -1
- package/bin/commands/site/snapshot/import.js +3 -2
- package/bin/commands/start.js +44 -0
- package/bin/commands/telegram/register-webhooks.js +1 -1
- package/bin/commands/uploads/cleanup.js +48 -9
- package/bin/jant.js +39 -4
- package/bin/lib/import-sources.js +151 -0
- package/bin/lib/node-env.js +14 -9
- package/bin/lib/runtime-target.js +1 -1
- package/bin/lib/site-pull-media.js +56 -4
- package/bin/lib/site-snapshot.js +39 -2
- package/bin/lib/sql-export.js +66 -10
- package/dist/{app-DIVtyB4m.js → app-jQI4OPRe.js} +5055 -4448
- package/dist/client/.vite/manifest.json +38 -38
- package/dist/client/_assets/chunks/{create-editor-B-m7X7S5.js → create-editor-5Y49x7h5.js} +2 -2
- package/dist/client/_assets/chunks/{footnote-rail-CmeoVtnU.js → footnote-rail-BJwswtVQ.js} +1 -1
- package/dist/client/_assets/chunks/{settings-paths-C-ZZBTau.js → settings-paths-h6RjIe3C.js} +2 -2
- package/dist/client/_assets/chunks/{slug-format-BcIsNKz-.js → slug-format-Dsi0e9Xn.js} +1 -1
- package/dist/client/_assets/chunks/{slugify-373citbs.js → slugify-DlHLyUHS.js} +1 -1
- package/dist/client/_assets/chunks/sortable-list-DYMcJrlS.js +2 -0
- package/dist/client/_assets/chunks/unsafe-svg-DxrzM_Gb.js +2 -0
- package/dist/client/_assets/client-52vQhZAv.js +296 -0
- package/dist/client/_assets/client-BaqmpPQ-.css +2 -0
- package/dist/client/_assets/{client-auth-BpkkKTsV.js → client-auth-BDcCR6u1.js} +2 -2
- package/dist/client/_assets/client-author-CGVvrNZ8.css +2 -0
- package/dist/client/_assets/{client-compose-C-DXzcFR.js → client-compose-CzEwT5qX.js} +4 -4
- package/dist/client/_assets/{client-manage-BfT7ht4M.js → client-manage-CF7x21L4.js} +37 -37
- package/dist/client/_assets/{client-settings-CGR_nZ78.js → client-settings-DIM44Zqh.js} +2 -2
- package/dist/{url-CKlGzvdN.js → constants-DEgyqWDl.js} +340 -1
- package/dist/index.d.ts +44 -0
- package/dist/index.js +33 -1
- package/dist/node.js +57 -13
- package/package.json +13 -18
- package/src/__tests__/api-docs.test.ts +168 -1
- package/src/__tests__/bin/import-sources.test.ts +85 -0
- package/src/__tests__/bin/uploads-cleanup.test.ts +66 -26
- package/src/__tests__/cli-commands.test.ts +40 -0
- package/src/__tests__/config-docs.test.ts +119 -16
- package/src/__tests__/custom-url-redirects.test.ts +108 -0
- package/src/__tests__/export-collection-custom-urls.test.ts +69 -0
- package/src/__tests__/export-docs.test.ts +113 -41
- package/src/__tests__/export-feed-ids.test.ts +1 -0
- package/src/__tests__/export-format-version.test.ts +88 -0
- package/src/__tests__/export-hugo-build.test.ts +139 -4
- package/src/__tests__/export-import-roundtrip.test.ts +2 -1
- package/src/__tests__/export-service.test.ts +42 -13
- package/src/__tests__/export-smart-collection.test.ts +1 -1
- package/src/__tests__/feed-docs.test.ts +287 -21
- package/src/__tests__/feed-reply-addresses.test.ts +100 -0
- package/src/__tests__/feeds-disabled.test.ts +98 -0
- package/src/__tests__/fixtures/export-format/1.json +76 -0
- package/src/__tests__/fixtures/export-format/2.json +80 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/README.md +130 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/2thjq/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/2u5e5/_index.md +35 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/41q27/0x4nv/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/41q27/_index.md +44 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/41q27/faqyt/index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/41q27/the-potting-mix-guide-i-keep-rereading/index.md +20 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/5kayp/_index.md +23 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/5ynfs/_index.md +31 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/5ynfs/hu597/index.md +21 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/_index.md +5 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/a-night-heron-field-guide-for-my-walk-folder/_index.md +31 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/a-quiet-saturday-after-a-busy-week/_index.md +36 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/archive/_index.md +8 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/are-na-is-the-only-bookmark-pile-i-still-revisit/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/bought-too-many-lemons-again/_index.md +37 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/city-walks/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/cleanshot-for-screenshots-ocr-and-screen-recording-on-the-mac/_index.md +33 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/cleanshotmac-shang-de-jie-tu-ocr-lu-ping-gong-ju/_index.md +32 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/co344/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/collections/_index.md +5 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/current-tea-rotation/_index.md +34 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/derek-sivers-still-writes-the-kind-of-internet-i-want-more-of/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/desk-but-better/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/e0kcg/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/egi3c/_index.md +24 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/evf9j/_index.md +152 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/featured/_index.md +8 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/from-basho/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/from-epictetus/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/from-marcus-aurelius/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/from-seneca/_index.md +26 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/from-thoreau/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/gkbvv/2cl6d/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/gkbvv/3zqv7/index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/gkbvv/5oxsv/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/gkbvv/_index.md +39 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/gwob9/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/home-cooking/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/hz729/_index.md +24 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/inaturalist-ai-zi-ran-she-qu/_index.md +44 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/j4v0q/_index.md +35 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/k278t/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/k4eee/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/k5vh8/_index.md +32 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/k5vh8/a-reading-log-idea-i-might-steal/index.md +20 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/k5vh8/a83qu/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/k5vh8/from-seneca-5hibo/index.md +21 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/kan-qi-lai-bi-jiao-ku-de-gong-si-men/_index.md +41 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/l2m7y/_index.md +29 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/lan-ya-yao-kong-qi-chuang-shang-yue-du-de-fan-ye-shen-qi/_index.md +57 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/mynoise-for-rainy-afternoons/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/n09le/_index.md +23 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/ni-fu-jin-de-wei-ji-bai-ke-tiao-mu/_index.md +42 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/nts-archives-are-good-cleaning-music/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/qgfcu/_index.md +32 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/qgfcu/c91j0/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/qgfcu/qyucy/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/qgfcu/wsgck/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/rain-makes-my-neighborhood-look-better/_index.md +46 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/reading-notes/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/s4r3e/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/serious-eats-on-tomato-and-egg-soup/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/te812/_index.md +44 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/te812/cxiu6/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/te812/t77ms/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/te812/the-soup-trick-i-always-forget/index.md +20 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/telk3/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/telk3/from-thoreau-pawt2/index.md +21 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/the-five-minute-reset-is-still-the-best-habit-i-have/_index.md +36 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/the-hallway-light-took-12-minutes-and-3-months/_index.md +32 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/the-recurse-center-manual-is-weirdly-calming/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/tiny-projects/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/tong-wang-xing-fu-zhi-lu/_index.md +68 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/tou-ma-yan-jiang-ju-le-bu-chu-ti-yan/_index.md +62 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/useful-links/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/weekend-notes/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/what-i-actually-use-my-notebook-for/_index.md +52 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/data/jant.toml +124 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/hugo.toml +45 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/_redirects +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/40bc6cd1f12e-med_01kn8jtq3penf98tfq4gzmh9g9.png +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jtx8qenf98tm9ahxr48sw.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jv0jdenf98tp6qr9zgjjc.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jv452enf98trbkwrvhvgd.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jvb16enf98txp7p0pf5ge.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jve5nenf98tzap11gpxzr.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jvq58enf98v538w5vsqp4.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jvsaeenf98v6ct4gjzppc.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jw26cenf98vc7k0ppz5k8.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m313q1hme4e8cmby77dn66yy.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m313q2w7e4e8cmc20036yh66.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m313q7d2e4e8cmdeqjmyafby.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m313q887e4e8cmdjssych7yh.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167jx2f6ct88pkz45j3ycp-poster.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167jx2f6ct88pkz45j3ycp.mp4 +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167mbdf6ct88pr4ga1b9kf-poster.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167mbdf6ct88pr4ga1b9kf.mp4 +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167nsvf6ct88q1anhz4svb-poster.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167nsvf6ct88q1anhz4svb.mp4 +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167qaxf6ct88qfndwzxx83-poster.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167qaxf6ct88qfndwzxx83.mp4 +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167sm0f6ct88qw5brtsgcw.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167tf8f6ct88r169s51j49.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167vaaf6ct88rbx5ztenwb.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167w51f6ct88rp19pybkw1.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167x0nf6ct88rzajb84tw3.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167xxbf6ct88s5t2300bjk.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167yq5f6ct88s9pjwt5fxg.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167zg4f6ct88sge8jp28ja.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/themes/jant/static/apple-touch-icon.png +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/themes/jant/static/custom.css +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/themes/jant/static/favicon.ico +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/wrangler.jsonc +24 -0
- package/src/__tests__/fixtures/releases/0.10.0/snapshot/db.sql +322 -0
- package/src/__tests__/fixtures/releases/0.10.0/snapshot/meta.json +11 -0
- package/src/__tests__/helpers/app.ts +6 -1
- package/src/__tests__/helpers/export-fixtures.ts +1 -0
- package/src/__tests__/import-refused-aliases.test.ts +98 -0
- package/src/__tests__/import-site-command.test.ts +73 -8
- package/src/__tests__/public-types.test.ts +64 -0
- package/src/__tests__/release-fixtures.test.ts +79 -24
- package/src/__tests__/release-version.test.ts +84 -0
- package/src/__tests__/site-pull-media.test.ts +48 -0
- package/src/__tests__/snapshot-tables.test.ts +37 -0
- package/src/__tests__/sql-export.test.ts +21 -1
- package/src/__tests__/stored-file-headers.test.ts +94 -0
- package/src/__tests__/template-deploy-workflow.test.ts +101 -0
- package/src/__tests__/theme-docs.test.ts +113 -24
- package/src/__tests__/toolchain-versions.test.ts +54 -0
- package/src/__tests__/trailing-slash-redirect.test.ts +61 -0
- package/src/__tests__/vite-config-graph.test.ts +98 -0
- package/src/app.tsx +89 -66
- package/src/client/__tests__/compose-bridge-image-upload.test.ts +1 -0
- package/src/client/__tests__/compose-bridge.test.ts +87 -0
- package/src/client/__tests__/compose-shortcuts.test.ts +4 -4
- package/src/client/__tests__/footnote-rail.test.ts +1 -1
- package/src/client/__tests__/lazy-entries.test.ts +1 -1
- package/src/client/__tests__/media-scroll-hint.test.ts +2 -2
- package/src/client/avatar-upload.ts +10 -10
- package/src/client/components/__tests__/jant-compose-dialog.test.ts +295 -4
- package/src/client/components/__tests__/jant-compose-editor.test.ts +34 -0
- package/src/client/components/__tests__/jant-settings-general.test.ts +0 -32
- package/src/client/components/compose-types.ts +14 -0
- package/src/client/components/jant-compose-dialog.ts +96 -41
- package/src/client/components/jant-compose-editor.ts +21 -4
- package/src/client/components/jant-config-editor.ts +4 -6
- package/src/client/components/jant-media-lightbox.ts +4 -4
- package/src/client/components/jant-settings-general.ts +0 -4
- package/src/client/components/nav-manager-types.ts +6 -5
- package/src/client/compose-bridge.ts +15 -4
- package/src/client/compose-launch.ts +4 -6
- package/src/client/compose-shortcuts.ts +1 -1
- package/src/client/footnote-rail.ts +1 -1
- package/src/client/lazy-entries.ts +1 -1
- package/src/client/media-scroll-hint.ts +2 -2
- package/src/client/tiptap/__tests__/markdown-clipboard.test.ts +55 -0
- package/src/client/tiptap/markdown-clipboard.ts +50 -2
- package/src/client/upload-session.ts +7 -6
- package/src/db/__tests__/backfill-external-redirects.test.ts +59 -0
- package/src/db/__tests__/backfill-featured-discover.test.ts +56 -0
- package/src/db/backfills/0007_restore_external_redirect_scheme.sql +20 -0
- package/src/db/backfills/0008_turn_off_featured_only_discover.sql +11 -0
- package/src/i18n/locales/public/en.po +46 -48
- package/src/i18n/locales/public/en.ts +1 -1
- package/src/i18n/locales/public/zh-Hans.po +45 -46
- package/src/i18n/locales/public/zh-Hans.ts +1 -1
- package/src/i18n/locales/public/zh-Hant.po +45 -46
- package/src/i18n/locales/public/zh-Hant.ts +1 -1
- package/src/i18n/locales/settings/en.po +15 -29
- package/src/i18n/locales/settings/en.ts +1 -1
- package/src/i18n/locales/settings/zh-Hans.po +15 -29
- package/src/i18n/locales/settings/zh-Hans.ts +1 -1
- package/src/i18n/locales/settings/zh-Hant.po +15 -29
- package/src/i18n/locales/settings/zh-Hant.ts +1 -1
- package/src/index.ts +43 -2
- package/src/lib/__tests__/api-settings.test.ts +3 -3
- package/src/lib/__tests__/constants.test.ts +10 -0
- package/src/lib/__tests__/discover.test.ts +8 -9
- package/src/lib/__tests__/env-values.test.ts +125 -0
- package/src/lib/__tests__/feed-path.test.ts +29 -0
- package/src/lib/__tests__/feed.test.ts +50 -22
- package/src/lib/__tests__/filter-dimensions.test.ts +22 -8
- package/src/lib/__tests__/post-list-cursor.test.ts +0 -10
- package/src/lib/__tests__/rate-limit.test.ts +22 -7
- package/src/lib/__tests__/resolve-config.test.ts +5 -3
- package/src/lib/__tests__/schemas.test.ts +72 -23
- package/src/lib/__tests__/slugify.test.ts +9 -0
- package/src/lib/__tests__/startup-config.test.ts +12 -0
- package/src/lib/__tests__/storage-s3.test.ts +214 -0
- package/src/lib/__tests__/theme.test.ts +20 -1
- package/src/lib/__tests__/time.test.ts +56 -0
- package/src/lib/__tests__/timeline.test.ts +46 -0
- package/src/lib/__tests__/url-fetch.test.ts +65 -1
- package/src/lib/__tests__/url.test.ts +60 -1
- package/src/lib/api-nav-items.ts +16 -20
- package/src/lib/api-post-input.ts +34 -1
- package/src/lib/api-posts.ts +125 -23
- package/src/lib/api-public-posts.ts +28 -37
- package/src/lib/api-search.ts +49 -2
- package/src/lib/api-settings.ts +159 -54
- package/src/lib/api-threads.ts +34 -11
- package/src/lib/constants.ts +6 -0
- package/src/lib/discover.ts +7 -23
- package/src/lib/env-values.ts +140 -0
- package/src/lib/env.ts +203 -12
- package/src/lib/feed-path.ts +8 -2
- package/src/lib/feed-policy.ts +110 -7
- package/src/lib/feed.ts +69 -25
- package/src/lib/filter-dimensions.ts +17 -10
- package/src/lib/github-sync-site-config.ts +1 -0
- package/src/lib/hugo-markdown.ts +5 -6
- package/src/lib/navigation.ts +4 -1
- package/src/lib/post-list-cursor.ts +33 -29
- package/src/lib/public-storage.ts +43 -0
- package/src/lib/rate-limit.ts +31 -16
- package/src/lib/render.tsx +5 -0
- package/src/lib/resolve-config.ts +16 -19
- package/src/lib/schemas.ts +248 -180
- package/src/lib/slugify.ts +6 -1
- package/src/lib/sse.ts +1 -1
- package/src/lib/startup-config.ts +20 -1
- package/src/lib/theme.ts +8 -5
- package/src/lib/thread-fold.ts +6 -0
- package/src/lib/thread-query.ts +19 -24
- package/src/lib/time.ts +137 -17
- package/src/lib/timeline.ts +56 -13
- package/src/lib/url-fetch.ts +141 -40
- package/src/lib/url.ts +86 -1
- package/src/middleware/__tests__/auth.test.ts +27 -0
- package/src/middleware/__tests__/cors.test.ts +54 -0
- package/src/middleware/__tests__/cross-origin.test.ts +149 -0
- package/src/middleware/__tests__/public-content-access.test.ts +2 -42
- package/src/middleware/auth.ts +34 -3
- package/src/middleware/cors.ts +4 -4
- package/src/middleware/cross-origin.ts +124 -0
- package/src/middleware/error-handler.ts +7 -0
- package/src/middleware/public-content-access.ts +3 -26
- package/src/middleware/secure-headers.ts +8 -2
- package/src/node/__tests__/cli-migrate.test.ts +2 -2
- package/src/node/__tests__/cli-runtime-target.test.ts +13 -2
- package/src/node/__tests__/cli-site-snapshot.test.ts +57 -0
- package/src/node/__tests__/cli-snapshot-meta.test.ts +11 -1
- package/src/node/__tests__/cli-sql-export.test.ts +25 -1
- package/src/node/__tests__/cli-start.test.ts +66 -0
- package/src/node/__tests__/request-handler.test.ts +37 -0
- package/src/node/__tests__/runtime.test.ts +56 -1
- package/src/node/request-handler.ts +58 -5
- package/src/node/runtime.ts +37 -11
- package/src/preset.css +3 -3
- package/src/routes/__tests__/compose.test.ts +84 -0
- package/src/routes/api/__tests__/collections.test.ts +68 -0
- package/src/routes/api/__tests__/mcp.test.ts +164 -9
- package/src/routes/api/__tests__/media.test.ts +9 -1
- package/src/routes/api/__tests__/nav-items.test.ts +27 -1
- package/src/routes/api/__tests__/posts.test.ts +269 -78
- package/src/routes/api/__tests__/search.test.ts +17 -4
- package/src/routes/api/__tests__/settings.test.ts +119 -85
- package/src/routes/api/__tests__/telegram.test.ts +11 -6
- package/src/routes/api/__tests__/threads.test.ts +11 -0
- package/src/routes/api/__tests__/upload-response.test.ts +48 -0
- package/src/routes/api/__tests__/uploads.test.ts +35 -2
- package/src/routes/api/collections.ts +3 -3
- package/src/routes/api/custom-urls.ts +2 -1
- package/src/routes/api/export.ts +1 -0
- package/src/routes/api/internal/__tests__/post-body-html.test.ts +19 -0
- package/src/routes/api/internal/__tests__/uploads.test.ts +2 -0
- package/src/routes/api/internal/sites.ts +16 -4
- package/src/routes/api/mcp.ts +1 -0
- package/src/routes/api/media.ts +7 -8
- package/src/routes/api/nav-items.ts +2 -1
- package/src/routes/api/posts.ts +18 -24
- package/src/routes/api/public/__tests__/posts.test.ts +15 -0
- package/src/routes/api/public/__tests__/threads-collections.test.ts +12 -45
- package/src/routes/api/public/__tests__/threads.test.ts +41 -9
- package/src/routes/api/public/posts.ts +2 -2
- package/src/routes/api/public/threads.ts +16 -26
- package/src/routes/api/search.ts +7 -41
- package/src/routes/api/settings.ts +32 -28
- package/src/routes/api/smart-collections.ts +6 -1
- package/src/routes/api/threads.ts +25 -26
- package/src/routes/api/upload.ts +6 -21
- package/src/routes/api/uploads.ts +14 -20
- package/src/routes/auth/__tests__/dev.test.ts +16 -13
- package/src/routes/auth/__tests__/hosted-sso.test.ts +51 -0
- package/src/routes/auth/__tests__/setup-auth.test.ts +2 -0
- package/src/routes/auth/__tests__/setup-discover.test.ts +2 -0
- package/src/routes/auth/__tests__/setup-flow.test.ts +32 -0
- package/src/routes/auth/__tests__/setup-rate-limit.test.ts +72 -0
- package/src/routes/auth/__tests__/setup-steps.test.ts +2 -0
- package/src/routes/auth/__tests__/signin.test.ts +167 -2
- package/src/routes/auth/dev.ts +4 -6
- package/src/routes/auth/hosted-sso.ts +9 -6
- package/src/routes/auth/setup.tsx +35 -5
- package/src/routes/auth/signin.tsx +96 -1
- package/src/routes/compose.tsx +47 -47
- package/src/routes/dash/__tests__/settings-avatar.test.ts +59 -4
- package/src/routes/dash/__tests__/settings-demo-locks.test.ts +147 -0
- package/src/routes/dash/custom-urls.tsx +2 -0
- package/src/routes/dash/settings.tsx +79 -32
- package/src/routes/feed/__tests__/feed.test.ts +93 -3
- package/src/routes/feed/__tests__/sitemap.test.ts +42 -0
- package/src/routes/feed/feed.ts +128 -175
- package/src/routes/feed/sitemap.ts +9 -7
- package/src/routes/pages/__tests__/archive-years.test.ts +45 -0
- package/src/routes/pages/__tests__/collection-routing.test.ts +40 -0
- package/src/routes/pages/__tests__/collections.test.ts +3 -0
- package/src/routes/pages/__tests__/language-routing.test.ts +31 -0
- package/src/routes/pages/__tests__/post-page-round-trips.test.ts +34 -2
- package/src/routes/pages/__tests__/search.test.ts +5 -2
- package/src/routes/pages/__tests__/thread-gap.test.ts +207 -0
- package/src/routes/pages/archive.tsx +33 -94
- package/src/routes/pages/brand.tsx +1 -0
- package/src/routes/pages/collection.tsx +13 -84
- package/src/routes/pages/collections.tsx +2 -0
- package/src/routes/pages/featured.tsx +7 -2
- package/src/routes/pages/home.tsx +1 -0
- package/src/routes/pages/latest.tsx +6 -2
- package/src/routes/pages/new.tsx +1 -0
- package/src/routes/pages/page.tsx +73 -47
- package/src/routes/pages/search.tsx +5 -3
- package/src/routes/pages/smart-collection.tsx +11 -70
- package/src/routes/pages/subscribe.tsx +1 -0
- package/src/routes/pages/theme-sample.tsx +1 -0
- package/src/runtime/__tests__/readiness.test.ts +16 -0
- package/src/runtime/cloudflare.ts +2 -3
- package/src/runtime/index.ts +3 -1
- package/src/runtime/node.ts +3 -5
- package/src/runtime/readiness.ts +5 -0
- package/src/services/__tests__/auth.test.ts +115 -0
- package/src/services/__tests__/collection.test.ts +9 -0
- package/src/services/__tests__/github-sync-webhook.test.ts +78 -0
- package/src/services/__tests__/hosted-handoff.test.ts +208 -1
- package/src/services/__tests__/media.test.ts +47 -27
- package/src/services/__tests__/navigation.test.ts +67 -15
- package/src/services/__tests__/post.test.ts +103 -56
- package/src/services/__tests__/search.test.ts +38 -0
- package/src/services/__tests__/settings.test.ts +2 -14
- package/src/services/__tests__/smart-collection.test.ts +2 -2
- package/src/services/__tests__/telegram-ingest.test.ts +113 -0
- package/src/services/__tests__/thread.test.ts +26 -11
- package/src/services/auth.ts +36 -4
- package/src/services/collection.ts +46 -5
- package/src/services/custom-url.ts +11 -4
- package/src/services/export-theme/assets/client-site.css +1 -1
- package/src/services/export-theme/assets/client-site.js +2 -2
- package/src/services/export-theme/layouts/_default/baseof.html +1 -1
- package/src/services/export-theme/layouts/collection/single.html +1 -1
- package/src/services/export-theme/layouts/partials/featured-thread.html +8 -1
- package/src/services/export-theme/layouts/partials/head.html +1 -1
- package/src/services/export-theme/layouts/partials/media-gallery.html +6 -3
- package/src/services/export-theme/layouts/smart_collection/list.html +1 -1
- package/src/services/export-theme/styles/main.css +3 -3
- package/src/services/export.ts +68 -19
- package/src/services/github-sync.ts +10 -10
- package/src/services/hosted-handoff.ts +106 -6
- package/src/services/index.ts +3 -1
- package/src/services/language.ts +33 -0
- package/src/services/mcp.ts +176 -438
- package/src/services/media.ts +69 -21
- package/src/services/navigation.ts +19 -4
- package/src/services/path.ts +45 -3
- package/src/services/post.ts +329 -214
- package/src/services/search.ts +22 -3
- package/src/services/settings.ts +36 -3
- package/src/services/site-admin.ts +1 -0
- package/src/services/smart-collection.ts +10 -3
- package/src/services/telegram.ts +23 -6
- package/src/services/thread.ts +11 -3
- package/src/services/upload-session.ts +14 -15
- package/src/styles/components.css +2 -2
- package/src/styles/site-media.css +2 -2
- package/src/styles/tokens.css +19 -22
- package/src/styles/ui-author.css +73 -94
- package/src/styles/ui.css +62 -62
- package/src/types/app-context.ts +5 -1
- package/src/types/bindings.ts +11 -0
- package/src/types/config.ts +4 -4
- package/src/types/constants.ts +20 -0
- package/src/types/props.ts +34 -8
- package/src/types/views.ts +28 -13
- package/src/ui/color-themes.ts +6 -5
- package/src/ui/dash/settings/GeneralContent.tsx +0 -22
- package/src/ui/dash/settings/__tests__/GeneralContent.test.tsx +0 -21
- package/src/ui/feed/CuratedThreadPreview.tsx +7 -2
- package/src/ui/feed/LinkCard.tsx +1 -2
- package/src/ui/feed/NoteCard.tsx +1 -2
- package/src/ui/feed/QuoteCard.tsx +2 -2
- package/src/ui/feed/ThreadPreview.tsx +6 -6
- package/src/ui/feed/TimelineFeed.tsx +1 -7
- package/src/ui/feed/__tests__/thread-preview.test.ts +123 -10
- package/src/ui/feed/__tests__/timeline-cards.test.ts +18 -1
- package/src/ui/layouts/BaseLayout.tsx +5 -0
- package/src/ui/pages/ArchivePage.tsx +1 -1
- package/src/ui/pages/BrandPage.tsx +1 -1
- package/src/ui/pages/CollectionPage.tsx +0 -1
- package/src/ui/pages/CollectionsPage.tsx +2 -2
- package/src/ui/pages/ComposePage.tsx +1 -1
- package/src/ui/pages/FeaturedPage.tsx +1 -1
- package/src/ui/pages/HomePage.tsx +1 -1
- package/src/ui/pages/PostPage.tsx +1 -1
- package/src/ui/pages/SearchPage.tsx +1 -1
- package/src/ui/pages/SmartCollectionPage.tsx +2 -3
- package/src/ui/pages/SubscribePage.tsx +1 -1
- package/src/ui/pages/ThemeSamplePage.tsx +1 -1
- package/src/ui/shared/MediaGallery.tsx +1 -1
- package/src/vendor/datastar.js +9 -1956
- package/src/vendor/datastar.js.map +4 -4
- package/dist/client/_assets/chunks/sortable-list-BJyd-LXE.js +0 -2
- package/dist/client/_assets/chunks/unsafe-svg-DU_DNMy5.js +0 -2
- package/dist/client/_assets/client-D4AT9Iqr.js +0 -295
- package/dist/client/_assets/client-DRuw7XCt.css +0 -2
- package/dist/client/_assets/client-author-DQ8R-8KR.css +0 -2
|
@@ -401,5 +401,89 @@ describe("Compose Routes", () => {
|
|
|
401
401
|
1000,
|
|
402
402
|
);
|
|
403
403
|
});
|
|
404
|
+
|
|
405
|
+
// Saving a re-edited thread draft replaces the old draft with a new
|
|
406
|
+
// thread. The composer sends the draft's own attachments back by ID, so
|
|
407
|
+
// replacing it must not delete them.
|
|
408
|
+
it("keeps the draft's attachments when a thread draft is saved again", async () => {
|
|
409
|
+
const storage = createMockStorage();
|
|
410
|
+
const { app, services } = createTestApp({
|
|
411
|
+
authenticated: true,
|
|
412
|
+
storage: storage as never,
|
|
413
|
+
});
|
|
414
|
+
app.route("/compose", composeRoutes);
|
|
415
|
+
const upload = async (name: string) => {
|
|
416
|
+
await storage.put(`media/${name}`, new Uint8Array([1, 2, 3]));
|
|
417
|
+
return services.media.create({
|
|
418
|
+
filename: name,
|
|
419
|
+
originalName: name,
|
|
420
|
+
mimeType: "image/jpeg",
|
|
421
|
+
size: 3,
|
|
422
|
+
storageKey: `media/${name}`,
|
|
423
|
+
width: 800,
|
|
424
|
+
height: 600,
|
|
425
|
+
});
|
|
426
|
+
};
|
|
427
|
+
const kept = await upload("kept.jpg");
|
|
428
|
+
const dropped = await upload("dropped.jpg");
|
|
429
|
+
const draftPosts = await services.posts.createThreadWithAttachments(
|
|
430
|
+
[
|
|
431
|
+
{
|
|
432
|
+
data: {
|
|
433
|
+
format: "note",
|
|
434
|
+
bodyMarkdown: "Draft root",
|
|
435
|
+
status: "draft",
|
|
436
|
+
},
|
|
437
|
+
attachments: [
|
|
438
|
+
{ type: "media", mediaId: kept.id },
|
|
439
|
+
{ type: "media", mediaId: dropped.id },
|
|
440
|
+
],
|
|
441
|
+
},
|
|
442
|
+
{
|
|
443
|
+
data: {
|
|
444
|
+
format: "note",
|
|
445
|
+
bodyMarkdown: "Draft reply",
|
|
446
|
+
status: "draft",
|
|
447
|
+
},
|
|
448
|
+
attachments: [],
|
|
449
|
+
},
|
|
450
|
+
],
|
|
451
|
+
{ media: services.media, storage, storageDriver: "r2" },
|
|
452
|
+
);
|
|
453
|
+
const draftRoot = draftPosts[0];
|
|
454
|
+
if (!draftRoot) throw new Error("expected a draft root");
|
|
455
|
+
|
|
456
|
+
const res = await app.request("/compose/thread", {
|
|
457
|
+
method: "POST",
|
|
458
|
+
headers: {
|
|
459
|
+
"Content-Type": "application/json",
|
|
460
|
+
Accept: "application/json",
|
|
461
|
+
},
|
|
462
|
+
body: JSON.stringify({
|
|
463
|
+
replaceThreadId: draftRoot.id,
|
|
464
|
+
posts: [
|
|
465
|
+
{
|
|
466
|
+
format: "note",
|
|
467
|
+
bodyMarkdown: "Draft root, edited",
|
|
468
|
+
status: "draft",
|
|
469
|
+
attachments: [{ type: "media", mediaId: kept.id }],
|
|
470
|
+
},
|
|
471
|
+
{ format: "note", bodyMarkdown: "Draft reply", status: "draft" },
|
|
472
|
+
],
|
|
473
|
+
}),
|
|
474
|
+
});
|
|
475
|
+
|
|
476
|
+
expect(res.status).toBe(200);
|
|
477
|
+
expect(await services.posts.getById(draftRoot.id)).toBeNull();
|
|
478
|
+
const [newRoot] = (await services.posts.list({ status: "draft" })).filter(
|
|
479
|
+
(post) => post.replyToId === null,
|
|
480
|
+
);
|
|
481
|
+
expect(newRoot?.bodyText).toBe("Draft root, edited");
|
|
482
|
+
expect((await services.media.getById(kept.id))?.postId).toBe(newRoot?.id);
|
|
483
|
+
expect(storage.files.has("media/kept.jpg")).toBe(true);
|
|
484
|
+
// The one the new version left out goes, as removing it on save does.
|
|
485
|
+
expect(await services.media.getById(dropped.id)).toBeNull();
|
|
486
|
+
expect(storage.files.has("media/dropped.jpg")).toBe(false);
|
|
487
|
+
});
|
|
404
488
|
});
|
|
405
489
|
});
|
|
@@ -477,6 +477,12 @@ describe("Collections API Routes", () => {
|
|
|
477
477
|
expect(res.status).toBe(200);
|
|
478
478
|
const body = await res.json();
|
|
479
479
|
expect(body.success).toBe(true);
|
|
480
|
+
|
|
481
|
+
const again = await app.request(
|
|
482
|
+
`/api/collections/directory-items/${item.id}`,
|
|
483
|
+
{ method: "DELETE" },
|
|
484
|
+
);
|
|
485
|
+
expect(again.status).toBe(404);
|
|
480
486
|
});
|
|
481
487
|
});
|
|
482
488
|
|
|
@@ -768,5 +774,67 @@ describe("Collections API Routes", () => {
|
|
|
768
774
|
new Set(),
|
|
769
775
|
);
|
|
770
776
|
});
|
|
777
|
+
|
|
778
|
+
it("refuses to pin a Thread that isn't in the collection", async () => {
|
|
779
|
+
const { app, services } = createTestApp({ authenticated: true });
|
|
780
|
+
app.route("/api/collections", collectionsApiRoutes);
|
|
781
|
+
|
|
782
|
+
const col = await services.collections.create({
|
|
783
|
+
slug: "tech",
|
|
784
|
+
title: "Tech",
|
|
785
|
+
});
|
|
786
|
+
const post = await services.posts.create({
|
|
787
|
+
format: "note",
|
|
788
|
+
bodyMarkdown: "outside",
|
|
789
|
+
});
|
|
790
|
+
|
|
791
|
+
const pinRes = await app.request(
|
|
792
|
+
`/api/collections/${col.id}/threads/${post.id}/pin`,
|
|
793
|
+
{ method: "PUT" },
|
|
794
|
+
);
|
|
795
|
+
expect(pinRes.status).toBe(409);
|
|
796
|
+
expect((await pinRes.json()).code).toBe("CONFLICT");
|
|
797
|
+
|
|
798
|
+
// Already in the state asked for.
|
|
799
|
+
const unpinRes = await app.request(
|
|
800
|
+
`/api/collections/${col.id}/threads/${post.id}/pin`,
|
|
801
|
+
{ method: "DELETE" },
|
|
802
|
+
);
|
|
803
|
+
expect(unpinRes.status).toBe(200);
|
|
804
|
+
});
|
|
805
|
+
});
|
|
806
|
+
|
|
807
|
+
describe("Thread membership of a collection that doesn't exist", () => {
|
|
808
|
+
it("answers 404 to add, remove, pin, and unpin", async () => {
|
|
809
|
+
const { app, services } = createTestApp({ authenticated: true });
|
|
810
|
+
app.route("/api/collections", collectionsApiRoutes);
|
|
811
|
+
|
|
812
|
+
const post = await services.posts.create({
|
|
813
|
+
format: "note",
|
|
814
|
+
bodyMarkdown: "test",
|
|
815
|
+
});
|
|
816
|
+
const missing = createEntityId("collection");
|
|
817
|
+
|
|
818
|
+
const requests: [string, string, string?][] = [
|
|
819
|
+
[
|
|
820
|
+
"POST",
|
|
821
|
+
`/api/collections/${missing}/threads`,
|
|
822
|
+
JSON.stringify({ threadId: post.id }),
|
|
823
|
+
],
|
|
824
|
+
["DELETE", `/api/collections/${missing}/threads/${post.id}`],
|
|
825
|
+
["PUT", `/api/collections/${missing}/threads/${post.id}/pin`],
|
|
826
|
+
["DELETE", `/api/collections/${missing}/threads/${post.id}/pin`],
|
|
827
|
+
];
|
|
828
|
+
for (const [method, path, body] of requests) {
|
|
829
|
+
const res = await app.request(path, {
|
|
830
|
+
method,
|
|
831
|
+
...(body
|
|
832
|
+
? { body, headers: { "Content-Type": "application/json" } }
|
|
833
|
+
: {}),
|
|
834
|
+
});
|
|
835
|
+
expect(res.status, `${method} ${path}`).toBe(404);
|
|
836
|
+
expect((await res.json()).error).toBe("Collection not found");
|
|
837
|
+
}
|
|
838
|
+
});
|
|
771
839
|
});
|
|
772
840
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { describe, expect, it, vi } from "vitest";
|
|
2
2
|
import { createTestApp } from "../../../__tests__/helpers/app.js";
|
|
3
|
+
import { postsApiRoutes } from "../posts.js";
|
|
3
4
|
import { createEntityId } from "../../../lib/ids.js";
|
|
4
5
|
import { handleMcpHttpRequest } from "../../../services/mcp.js";
|
|
5
6
|
import { mcpApiRoutes } from "../mcp.js";
|
|
@@ -100,6 +101,49 @@ async function postMcp(
|
|
|
100
101
|
}
|
|
101
102
|
|
|
102
103
|
describe("MCP API Routes", () => {
|
|
104
|
+
it("advertises each tool's input from the schema its handler reads", async () => {
|
|
105
|
+
const { app } = createTestApp({ authenticated: true });
|
|
106
|
+
app.route("/api/mcp", mcpApiRoutes);
|
|
107
|
+
|
|
108
|
+
const res = await postMcp(
|
|
109
|
+
app,
|
|
110
|
+
{ jsonrpc: "2.0", id: 1, method: "tools/list" },
|
|
111
|
+
{ "MCP-Protocol-Version": "2025-06-18" },
|
|
112
|
+
);
|
|
113
|
+
const { tools } = (await res.json()).result as {
|
|
114
|
+
tools: Array<{
|
|
115
|
+
name: string;
|
|
116
|
+
inputSchema: {
|
|
117
|
+
type: string;
|
|
118
|
+
properties?: Record<string, { enum?: string[] }>;
|
|
119
|
+
required?: string[];
|
|
120
|
+
};
|
|
121
|
+
}>;
|
|
122
|
+
};
|
|
123
|
+
const byName = new Map(tools.map((tool) => [tool.name, tool.inputSchema]));
|
|
124
|
+
|
|
125
|
+
for (const tool of tools) {
|
|
126
|
+
expect(tool.inputSchema.type, tool.name).toBe("object");
|
|
127
|
+
}
|
|
128
|
+
// These once went missing from the hand-written schemas while the
|
|
129
|
+
// handlers accepted them.
|
|
130
|
+
expect(
|
|
131
|
+
Object.keys(byName.get("jant_posts_create")?.properties ?? {}),
|
|
132
|
+
).toEqual(
|
|
133
|
+
expect.arrayContaining([
|
|
134
|
+
"language",
|
|
135
|
+
"translationOfId",
|
|
136
|
+
"pinnedAt",
|
|
137
|
+
"featuredAt",
|
|
138
|
+
"collectionEntries",
|
|
139
|
+
]),
|
|
140
|
+
);
|
|
141
|
+
expect(byName.get("jant_posts_update")?.required).toContain("id");
|
|
142
|
+
expect(
|
|
143
|
+
byName.get("jant_threads_list")?.properties?.visibility?.enum,
|
|
144
|
+
).toContain("any");
|
|
145
|
+
});
|
|
146
|
+
|
|
103
147
|
it("initializes the MCP endpoint", async () => {
|
|
104
148
|
const { app } = createTestApp({ authenticated: true });
|
|
105
149
|
app.route("/api/mcp", mcpApiRoutes);
|
|
@@ -152,6 +196,12 @@ describe("MCP API Routes", () => {
|
|
|
152
196
|
expect(toolNames).toContain("jant_collections_remove_thread");
|
|
153
197
|
expect(toolNames).toContain("jant_settings_update");
|
|
154
198
|
expect(toolNames).toContain("jant_posts_search");
|
|
199
|
+
|
|
200
|
+
// Deleting reads nothing back, so it takes only the post to delete.
|
|
201
|
+
const deleteTool = body.result.tools.find(
|
|
202
|
+
(tool: { name: string }) => tool.name === "jant_posts_delete",
|
|
203
|
+
);
|
|
204
|
+
expect(Object.keys(deleteTool.inputSchema.properties)).toEqual(["id"]);
|
|
155
205
|
});
|
|
156
206
|
|
|
157
207
|
it("manages collection membership at the thread root", async () => {
|
|
@@ -283,6 +333,7 @@ describe("MCP API Routes", () => {
|
|
|
283
333
|
expect(inCollection.threads[0].fold.gap).toEqual({
|
|
284
334
|
id: replies[2]?.id,
|
|
285
335
|
slug: replies[2]?.slug,
|
|
336
|
+
cursor: expect.any(String),
|
|
286
337
|
});
|
|
287
338
|
|
|
288
339
|
const thread = await call("jant_threads_get", { id: replies[4]?.id });
|
|
@@ -351,14 +402,11 @@ describe("MCP API Routes", () => {
|
|
|
351
402
|
}
|
|
352
403
|
expect(ids).toEqual(created.map((post) => post.id).reverse());
|
|
353
404
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
const unreadable = await listPosts({ cursor: "nope" });
|
|
360
|
-
expect(unreadable.isError).toBe(true);
|
|
361
|
-
expect(unreadable.structuredContent.error).toMatch(/cursor/);
|
|
405
|
+
for (const cursor of [created[2]?.id, "nope"]) {
|
|
406
|
+
const unreadable = await listPosts({ cursor });
|
|
407
|
+
expect(unreadable.isError).toBe(true);
|
|
408
|
+
expect(unreadable.structuredContent.error).toMatch(/cursor/);
|
|
409
|
+
}
|
|
362
410
|
});
|
|
363
411
|
|
|
364
412
|
it("creates posts through tools/call", async () => {
|
|
@@ -526,7 +574,9 @@ describe("MCP API Routes", () => {
|
|
|
526
574
|
width: 1200,
|
|
527
575
|
height: 800,
|
|
528
576
|
});
|
|
529
|
-
expect(await services.media.
|
|
577
|
+
expect((await services.media.listPage({ limit: 10 })).media).toHaveLength(
|
|
578
|
+
1,
|
|
579
|
+
);
|
|
530
580
|
});
|
|
531
581
|
|
|
532
582
|
it("returns text attachment content through tools/call", async () => {
|
|
@@ -683,6 +733,83 @@ describe("MCP post writes", () => {
|
|
|
683
733
|
);
|
|
684
734
|
}
|
|
685
735
|
|
|
736
|
+
it("answers with what the matching HTTP endpoint returns", async () => {
|
|
737
|
+
const { app, services } = createTestApp({ authenticated: true });
|
|
738
|
+
app.route("/api/mcp", mcpApiRoutes);
|
|
739
|
+
app.route("/api/posts", postsApiRoutes);
|
|
740
|
+
const collection = await services.collections.create({
|
|
741
|
+
title: "Ideas",
|
|
742
|
+
slug: "ideas",
|
|
743
|
+
});
|
|
744
|
+
const post = await services.posts.create({
|
|
745
|
+
format: "note",
|
|
746
|
+
bodyMarkdown: "hello",
|
|
747
|
+
collectionIds: [collection.id],
|
|
748
|
+
});
|
|
749
|
+
|
|
750
|
+
const viaMcp = await callTool(app, "/api/mcp", "jant_posts_get", {
|
|
751
|
+
id: post.id,
|
|
752
|
+
});
|
|
753
|
+
const viaHttp = await (await app.request(`/api/posts/${post.id}`)).json();
|
|
754
|
+
|
|
755
|
+
expect(viaMcp.result.structuredContent).toEqual(viaHttp);
|
|
756
|
+
expect(viaHttp).toMatchObject({
|
|
757
|
+
collectionIds: [collection.id],
|
|
758
|
+
threadPosition: 1,
|
|
759
|
+
});
|
|
760
|
+
});
|
|
761
|
+
|
|
762
|
+
it("reads bodies as Markdown where HTTP takes content=markdown", async () => {
|
|
763
|
+
const { app, services } = createTestApp({ authenticated: true });
|
|
764
|
+
app.route("/api/mcp", mcpApiRoutes);
|
|
765
|
+
app.route("/api/posts", postsApiRoutes);
|
|
766
|
+
const post = await services.posts.create({
|
|
767
|
+
format: "note",
|
|
768
|
+
bodyMarkdown: "Some **bold** text",
|
|
769
|
+
});
|
|
770
|
+
|
|
771
|
+
const viaMcp = await callTool(app, "/api/mcp", "jant_posts_get", {
|
|
772
|
+
id: post.id,
|
|
773
|
+
content: "markdown",
|
|
774
|
+
});
|
|
775
|
+
const viaHttp = await (
|
|
776
|
+
await app.request(`/api/posts/${post.id}?content=markdown`)
|
|
777
|
+
).json();
|
|
778
|
+
expect(viaMcp.result.structuredContent).toEqual(viaHttp);
|
|
779
|
+
expect(viaHttp.bodyMarkdown).toBe("Some **bold** text");
|
|
780
|
+
|
|
781
|
+
for (const [name, args] of [
|
|
782
|
+
["jant_posts_list", {}],
|
|
783
|
+
["jant_threads_list_posts", { id: post.id }],
|
|
784
|
+
] as const) {
|
|
785
|
+
const listed = (await callTool(app, "/api/mcp", name, {
|
|
786
|
+
...args,
|
|
787
|
+
content: "markdown",
|
|
788
|
+
})) as unknown as {
|
|
789
|
+
result: { structuredContent: { posts: { bodyMarkdown: string }[] } };
|
|
790
|
+
};
|
|
791
|
+
expect(listed.result.structuredContent.posts[0]?.bodyMarkdown, name).toBe(
|
|
792
|
+
"Some **bold** text",
|
|
793
|
+
);
|
|
794
|
+
}
|
|
795
|
+
for (const name of ["jant_threads_list", "jant_threads_get"]) {
|
|
796
|
+
const result = (await callTool(app, "/api/mcp", name, {
|
|
797
|
+
...(name === "jant_threads_get" ? { id: post.id } : {}),
|
|
798
|
+
content: "markdown",
|
|
799
|
+
})) as unknown as {
|
|
800
|
+
result: {
|
|
801
|
+
structuredContent: {
|
|
802
|
+
threads?: { root: { bodyMarkdown: string } }[];
|
|
803
|
+
root?: { bodyMarkdown: string };
|
|
804
|
+
};
|
|
805
|
+
};
|
|
806
|
+
};
|
|
807
|
+
const content = result.result.structuredContent;
|
|
808
|
+
const root = content.threads?.[0]?.root ?? content.root;
|
|
809
|
+
expect(root?.bodyMarkdown, name).toBe("Some **bold** text");
|
|
810
|
+
}
|
|
811
|
+
});
|
|
812
|
+
|
|
686
813
|
it("keeps every field POST and PUT /api/posts keep", async () => {
|
|
687
814
|
// The MCP tools once mapped the body themselves and dropped `language`,
|
|
688
815
|
// `translationOfId`, `pinnedAt`, and `featuredAt`.
|
|
@@ -724,6 +851,33 @@ describe("MCP post writes", () => {
|
|
|
724
851
|
expect((await services.posts.getById(stored!.id))?.language).toBe("ja");
|
|
725
852
|
});
|
|
726
853
|
|
|
854
|
+
it("refuses media attached to another post, as POST /api/posts does", async () => {
|
|
855
|
+
const { app, services } = createTestApp({ authenticated: true });
|
|
856
|
+
app.route("/api/mcp", mcpApiRoutes);
|
|
857
|
+
const original = await services.posts.create({
|
|
858
|
+
format: "note",
|
|
859
|
+
bodyMarkdown: "original",
|
|
860
|
+
});
|
|
861
|
+
const media = await services.media.create({
|
|
862
|
+
filename: "a.jpg",
|
|
863
|
+
originalName: "a.jpg",
|
|
864
|
+
mimeType: "image/jpeg",
|
|
865
|
+
size: 1024,
|
|
866
|
+
storageKey: "media/a.jpg",
|
|
867
|
+
});
|
|
868
|
+
await services.media.attachToPost(original.id, [media.id]);
|
|
869
|
+
|
|
870
|
+
const copy = await callTool(app, "/api/mcp", "jant_posts_create", {
|
|
871
|
+
format: "note",
|
|
872
|
+
bodyMarkdown: "A translation reusing the image",
|
|
873
|
+
attachments: [{ type: "media", mediaId: media.id }],
|
|
874
|
+
});
|
|
875
|
+
|
|
876
|
+
expect(copy.result.isError).toBe(true);
|
|
877
|
+
expect(copy.result.structuredContent).toMatchObject({ code: "CONFLICT" });
|
|
878
|
+
expect((await services.media.getById(media.id))?.postId).toBe(original.id);
|
|
879
|
+
});
|
|
880
|
+
|
|
727
881
|
it("runs the post-write hook after each post write, and only then", async () => {
|
|
728
882
|
// The HTTP routes start a GitHub sync after writing a post; MCP writes
|
|
729
883
|
// reach the same hook through the context.
|
|
@@ -737,6 +891,7 @@ describe("MCP post writes", () => {
|
|
|
737
891
|
},
|
|
738
892
|
{
|
|
739
893
|
appConfig: c.var.appConfig,
|
|
894
|
+
env: c.env,
|
|
740
895
|
services: c.var.services,
|
|
741
896
|
storage: c.var.storage,
|
|
742
897
|
afterPostWrite,
|
|
@@ -119,7 +119,7 @@ describe("Media API Routes", () => {
|
|
|
119
119
|
});
|
|
120
120
|
|
|
121
121
|
const res = await app.request(`/api/media/${media.id}`, {
|
|
122
|
-
method: "
|
|
122
|
+
method: "PUT",
|
|
123
123
|
headers: { "Content-Type": "application/json" },
|
|
124
124
|
body: JSON.stringify({ alt: " Cover image " }),
|
|
125
125
|
});
|
|
@@ -128,6 +128,14 @@ describe("Media API Routes", () => {
|
|
|
128
128
|
const body = await res.json();
|
|
129
129
|
expect(body.alt).toBe("Cover image");
|
|
130
130
|
expect((await services.media.getById(media.id))?.alt).toBe("Cover image");
|
|
131
|
+
|
|
132
|
+
const cleared = await app.request(`/api/media/${media.id}`, {
|
|
133
|
+
method: "PUT",
|
|
134
|
+
headers: { "Content-Type": "application/json" },
|
|
135
|
+
body: JSON.stringify({ alt: " " }),
|
|
136
|
+
});
|
|
137
|
+
expect(cleared.status).toBe(200);
|
|
138
|
+
expect((await cleared.json()).alt).toBeNull();
|
|
131
139
|
});
|
|
132
140
|
|
|
133
141
|
it("deletes a media item", async () => {
|
|
@@ -255,6 +255,14 @@ describe("Nav Items API Routes", () => {
|
|
|
255
255
|
expect(body.url).toBe("https://github.com");
|
|
256
256
|
expect(body.type).toBe("link");
|
|
257
257
|
expect(body.headerHtml).toBeUndefined();
|
|
258
|
+
// Every field is there; the ones a link has no use for are null.
|
|
259
|
+
expect(body).toMatchObject({
|
|
260
|
+
systemKey: null,
|
|
261
|
+
collectionId: null,
|
|
262
|
+
smartCollectionId: null,
|
|
263
|
+
postId: null,
|
|
264
|
+
targetTitle: null,
|
|
265
|
+
});
|
|
258
266
|
});
|
|
259
267
|
|
|
260
268
|
it("includes a site header fragment for navigation editor requests", async () => {
|
|
@@ -576,13 +584,31 @@ describe("Nav Items API Routes", () => {
|
|
|
576
584
|
headers: { "Content-Type": "application/json" },
|
|
577
585
|
body: JSON.stringify({
|
|
578
586
|
type: "collection",
|
|
579
|
-
collectionId: "
|
|
587
|
+
collectionId: createEntityId("collection"),
|
|
580
588
|
}),
|
|
581
589
|
});
|
|
582
590
|
|
|
583
591
|
expect(res.status).toBe(404);
|
|
584
592
|
});
|
|
585
593
|
|
|
594
|
+
it("returns 400 for an ID that isn't a collection ID", async () => {
|
|
595
|
+
const { app, services } = createTestApp({ authenticated: true });
|
|
596
|
+
app.route("/api/nav-items", navItemsApiRoutes);
|
|
597
|
+
const post = await services.posts.create({
|
|
598
|
+
format: "note",
|
|
599
|
+
bodyMarkdown: "not a collection",
|
|
600
|
+
});
|
|
601
|
+
|
|
602
|
+
for (const collectionId of ["col_nonexistent000000000000000", post.id]) {
|
|
603
|
+
const res = await app.request("/api/nav-items", {
|
|
604
|
+
method: "POST",
|
|
605
|
+
headers: { "Content-Type": "application/json" },
|
|
606
|
+
body: JSON.stringify({ type: "collection", collectionId }),
|
|
607
|
+
});
|
|
608
|
+
expect(res.status, collectionId).toBe(400);
|
|
609
|
+
}
|
|
610
|
+
});
|
|
611
|
+
|
|
586
612
|
it("returns 400 for duplicate collection nav items", async () => {
|
|
587
613
|
const { app, services } = createTestApp({ authenticated: true });
|
|
588
614
|
app.route("/api/nav-items", navItemsApiRoutes);
|