@jant/core 0.10.0 → 0.12.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/deploy.js +179 -0
- 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/cloudflare-setup.js +499 -0
- package/bin/lib/d1-query.js +26 -1
- package/bin/lib/import-sources.js +151 -0
- package/bin/lib/node-env.js +14 -9
- package/bin/lib/r2-query.js +2 -2
- 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-DSwsDBD0.js} +38257 -9662
- 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-BaqmpPQ-.css +2 -0
- package/dist/client/_assets/client-DPByjWoU.js +296 -0
- package/dist/client/_assets/{client-auth-BpkkKTsV.js → client-auth-CPqPTX1B.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 +43 -48
- package/src/__tests__/api-docs.test.ts +168 -1
- package/src/__tests__/bin/deploy.test.ts +163 -0
- 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 +143 -8
- package/src/__tests__/export-import-roundtrip.test.ts +3 -2
- package/src/__tests__/export-service.test.ts +44 -15
- 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__/fixtures/releases/0.11.0/site-export/README.md +130 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/297kg/_index.md +14 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/2thjq/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/2u5e5/_index.md +33 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/41q27/0x4nv/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/41q27/_index.md +42 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/41q27/faqyt/index.md +28 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/41q27/the-potting-mix-guide-i-keep-rereading/index.md +20 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/5kayp/_index.md +23 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/5ynfs/_index.md +31 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/5ynfs/hu597/index.md +21 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/_index.md +5 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/a-night-heron-field-guide-for-my-walk-folder/_index.md +31 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/a-quiet-saturday-after-a-busy-week/_index.md +36 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/archive/_index.md +8 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/are-na-is-the-only-bookmark-pile-i-still-revisit/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/bought-too-many-lemons-again/_index.md +35 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/city-walks/_index.md +14 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/cleanshot-for-screenshots-ocr-and-screen-recording-on-the-mac/_index.md +33 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/cleanshotmac-shang-de-jie-tu-ocr-lu-ping-gong-ju/_index.md +32 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/co344/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/collections/_index.md +5 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/current-tea-rotation/_index.md +34 -0
- package/src/__tests__/fixtures/releases/0.11.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.11.0/site-export/content/desk-but-better/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/e0kcg/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/egi3c/_index.md +24 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/evf9j/_index.md +129 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/featured/_index.md +8 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/fixture-draft/_index.md +17 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/fixture-quotes/_index.md +13 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/fixture-text-attachment/_index.md +29 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/from-basho/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/from-epictetus/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/from-marcus-aurelius/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/from-seneca/_index.md +26 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/from-thoreau/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/gkbvv/2cl6d/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/gkbvv/3zqv7/index.md +28 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/gkbvv/5oxsv/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/gkbvv/_index.md +37 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/gwob9/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/home-cooking/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/hz729/_index.md +24 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/inaturalist-ai-zi-ran-she-qu/_index.md +42 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/j4v0q/_index.md +33 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/k278t/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/k4eee/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/k5vh8/_index.md +32 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/k5vh8/a-reading-log-idea-i-might-steal/index.md +20 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/k5vh8/a83qu/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/k5vh8/from-seneca-5hibo/index.md +21 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/kan-qi-lai-bi-jiao-ku-de-gong-si-men/_index.md +41 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/l2m7y/_index.md +29 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/lan-ya-yao-kong-qi-chuang-shang-yue-du-de-fan-ye-shen-qi/_index.md +52 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/mynoise-for-rainy-afternoons/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/n09le/_index.md +23 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/ni-fu-jin-de-wei-ji-bai-ke-tiao-mu/_index.md +40 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/nts-archives-are-good-cleaning-music/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/qgfcu/_index.md +32 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/qgfcu/c91j0/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/qgfcu/qyucy/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/qgfcu/wsgck/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/rain-makes-my-neighborhood-look-better/_index.md +44 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/reading-notes/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/s4r3e/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/serious-eats-on-tomato-and-egg-soup/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/te812/_index.md +42 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/te812/cxiu6/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/te812/t77ms/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/te812/the-soup-trick-i-always-forget/index.md +20 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/telk3/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/telk3/from-thoreau-pawt2/index.md +21 -0
- package/src/__tests__/fixtures/releases/0.11.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.11.0/site-export/content/the-hallway-light-took-12-minutes-and-3-months/_index.md +32 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/the-recurse-center-manual-is-weirdly-calming/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/tiny-projects/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/tong-wang-xing-fu-zhi-lu/_index.md +68 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/tou-ma-yan-jiang-ju-le-bu-chu-ti-yan/_index.md +62 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/useful-links/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/weekend-notes/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/content/what-i-actually-use-my-notebook-for/_index.md +50 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/data/jant.toml +155 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/hugo.toml +45 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/_redirects +30 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/3c46a9ea6fe0-med_01kn8jtq3penf98tfq4gzmh9g9.png +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01kn8jtx8qenf98tm9ahxr48sw.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01kn8jv0jdenf98tp6qr9zgjjc.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01kn8jv452enf98trbkwrvhvgd.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01kn8jvb16enf98txp7p0pf5ge.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01kn8jve5nenf98tzap11gpxzr.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01kn8jvq58enf98v538w5vsqp4.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01kn8jvsaeenf98v6ct4gjzppc.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01kn8jw26cenf98vc7k0ppz5k8.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m313q1hme4e8cmby77dn66yy.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m313q2w7e4e8cmc20036yh66.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m313q7d2e4e8cmdeqjmyafby.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m313q887e4e8cmdjssych7yh.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m3167jx2f6ct88pkz45j3ycp-poster.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m3167jx2f6ct88pkz45j3ycp.mp4 +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m3167mbdf6ct88pr4ga1b9kf-poster.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m3167mbdf6ct88pr4ga1b9kf.mp4 +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m3167nsvf6ct88q1anhz4svb-poster.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m3167nsvf6ct88q1anhz4svb.mp4 +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m3167qaxf6ct88qfndwzxx83-poster.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m3167qaxf6ct88qfndwzxx83.mp4 +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m3167sm0f6ct88qw5brtsgcw.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m3167tf8f6ct88r169s51j49.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m3167vaaf6ct88rbx5ztenwb.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m3167w51f6ct88rp19pybkw1.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m3167x0nf6ct88rzajb84tw3.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m3167xxbf6ct88s5t2300bjk.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m3167yq5f6ct88s9pjwt5fxg.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m3167zg4f6ct88sge8jp28ja.webp +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/static/media/med_01m50607a6e8h8gfpa8byqtt7h.md +3 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/themes/jant/static/apple-touch-icon.png +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/themes/jant/static/custom.css +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/themes/jant/static/favicon.ico +0 -0
- package/src/__tests__/fixtures/releases/0.11.0/site-export/wrangler.jsonc +24 -0
- package/src/__tests__/fixtures/releases/0.11.0/snapshot/db.sql +339 -0
- package/src/__tests__/fixtures/releases/0.11.0/snapshot/meta.json +11 -0
- package/src/__tests__/helpers/app.ts +6 -1
- package/src/__tests__/helpers/d1-round-trips.ts +213 -0
- 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__/package-dependencies.test.ts +123 -0
- package/src/__tests__/public-page-round-trips.test.ts +203 -0
- 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 +57 -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/__tests__/vite-config.test.ts +32 -0
- package/src/app.tsx +96 -67
- 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/icons.ts +5 -6
- 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/__tests__/d1-query.test.ts +29 -0
- package/src/db/__tests__/migration-rehearsal.test.ts +2 -2
- 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__/icons.test.ts +21 -10
- 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 +128 -24
- package/src/lib/api-public-posts.ts +31 -38
- 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 +26 -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/icons.ts +96 -34
- package/src/lib/navigation.ts +4 -1
- package/src/lib/post-display.ts +13 -9
- 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 +76 -31
- package/src/lib/url-fetch.ts +141 -40
- package/src/lib/url.ts +86 -1
- package/src/lib/view.ts +3 -2
- 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__/onboarding.test.ts +5 -3
- package/src/middleware/__tests__/public-content-access.test.ts +2 -42
- package/src/middleware/__tests__/secure-headers.test.ts +40 -42
- package/src/middleware/auth.ts +34 -3
- package/src/middleware/config.ts +44 -2
- 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/onboarding.ts +12 -3
- package/src/middleware/public-content-access.ts +3 -26
- package/src/middleware/secure-headers.ts +32 -37
- package/src/node/__tests__/cli-deploy-setup.test.ts +373 -0
- package/src/node/__tests__/cli-deploy.test.ts +55 -0
- 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 +130 -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 +44 -12
- 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 +69 -111
- package/src/routes/pages/brand.tsx +1 -0
- package/src/routes/pages/collection.tsx +86 -120
- 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 +113 -66
- package/src/routes/pages/search.tsx +8 -4
- 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 +11 -4
- 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 +141 -76
- 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 +70 -20
- 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 +460 -400
- package/src/services/search.ts +22 -3
- package/src/services/settings.ts +40 -11
- 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 +10 -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 +35 -35
- package/src/ui/pages/BrandPage.tsx +1 -1
- package/src/ui/pages/CollectionPage.tsx +1 -2
- 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 +4 -5
- package/src/ui/pages/SubscribePage.tsx +3 -5
- package/src/ui/pages/ThemeSamplePage.tsx +1 -1
- package/src/ui/shared/CollectionDirectory.tsx +2 -2
- package/src/ui/shared/CollectionsManager.tsx +1 -1
- package/src/ui/shared/CopyField.tsx +1 -1
- package/src/ui/shared/Icon.tsx +5 -5
- package/src/ui/shared/IconSprite.tsx +10 -11
- package/src/ui/shared/MediaGallery.tsx +1 -1
- package/src/ui/shared/custom-icons.ts +38 -7
- package/src/ui/shared/icon-collector.ts +7 -5
- 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
package/src/services/post.ts
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
type SQL,
|
|
14
14
|
type SQLWrapper,
|
|
15
15
|
isNull,
|
|
16
|
+
ne,
|
|
16
17
|
desc,
|
|
17
18
|
inArray,
|
|
18
19
|
notInArray,
|
|
@@ -37,17 +38,19 @@ import {
|
|
|
37
38
|
buildRootActivityExpr,
|
|
38
39
|
rootActivityColumns,
|
|
39
40
|
} from "../db/thread-activity.js";
|
|
40
|
-
import {
|
|
41
|
+
import {
|
|
42
|
+
buildReaderVisibilityConditions,
|
|
43
|
+
type ReaderVisibilityOptions,
|
|
44
|
+
} from "../db/post-visibility.js";
|
|
41
45
|
import { createEntityId } from "../lib/ids.js";
|
|
42
46
|
import {
|
|
43
47
|
decodePostListCursor,
|
|
44
48
|
encodePostListCursor,
|
|
45
|
-
|
|
46
|
-
MISSING_LEGACY_CURSOR_MESSAGE,
|
|
49
|
+
THREAD_POSTS_SORT_MODE,
|
|
47
50
|
type PostListCursorKeyKind,
|
|
48
51
|
type PostListCursorValue,
|
|
49
52
|
} from "../lib/post-list-cursor.js";
|
|
50
|
-
import { now } from "../lib/time.js";
|
|
53
|
+
import { calendarPeriodsIn, now, type CalendarPeriod } from "../lib/time.js";
|
|
51
54
|
import { trimTiptapBody } from "../lib/tiptap-render.js";
|
|
52
55
|
import {
|
|
53
56
|
POST_BODY_HTML_VERSION,
|
|
@@ -61,7 +64,6 @@ import {
|
|
|
61
64
|
THREAD_TRAILING_REPLIES,
|
|
62
65
|
} from "../lib/thread-fold.js";
|
|
63
66
|
import { markdownToTiptapJson } from "../lib/markdown-to-tiptap.js";
|
|
64
|
-
import { tiptapJsonToMarkdown } from "../lib/tiptap-to-markdown.js";
|
|
65
67
|
import { generatePostSlug } from "../lib/slug.js";
|
|
66
68
|
import { getSlugValidationIssue } from "../lib/slug-format.js";
|
|
67
69
|
import { isReservedPath } from "../lib/constants.js";
|
|
@@ -229,10 +231,7 @@ export interface PostFilters {
|
|
|
229
231
|
|
|
230
232
|
/** Where `PostService.listPage` starts, and how much it returns. */
|
|
231
233
|
export interface PostListPageOptions {
|
|
232
|
-
/**
|
|
233
|
-
* `nextCursor` from the previous page; omit for the first. A bare post ID,
|
|
234
|
-
* the format earlier releases returned, is still accepted.
|
|
235
|
-
*/
|
|
234
|
+
/** `nextCursor` from the previous page; omit for the first. */
|
|
236
235
|
cursor?: string;
|
|
237
236
|
/** Posts per page. */
|
|
238
237
|
limit: number;
|
|
@@ -311,12 +310,6 @@ interface ListSort {
|
|
|
311
310
|
pinned: boolean;
|
|
312
311
|
}
|
|
313
312
|
|
|
314
|
-
/**
|
|
315
|
-
* The sort mode a cursor into one Thread's Posts records. Distinct from every
|
|
316
|
-
* `list()` and collection mode, so a position in one never resumes another.
|
|
317
|
-
*/
|
|
318
|
-
const THREAD_POSTS_SORT_MODE = "thread";
|
|
319
|
-
|
|
320
313
|
/** One term of a paged ORDER BY: `list()`'s, a collection's, or a Thread's. */
|
|
321
314
|
interface ListSortKey {
|
|
322
315
|
/** Selectable as a column, so a page's cursor is read from SQL. */
|
|
@@ -336,6 +329,19 @@ export interface FeaturedThreadTimelinePost {
|
|
|
336
329
|
position: number;
|
|
337
330
|
}
|
|
338
331
|
|
|
332
|
+
/**
|
|
333
|
+
* Where one gap in a curated Featured Thread points: the first Post of the run
|
|
334
|
+
* it hides, as `lib/thread-fold.ts` has every gap do. Only its address is
|
|
335
|
+
* loaded, since nothing renders it.
|
|
336
|
+
*/
|
|
337
|
+
export interface FeaturedThreadGapTarget {
|
|
338
|
+
id: string;
|
|
339
|
+
/** Canonical slug from `path_registry`. */
|
|
340
|
+
slug: string;
|
|
341
|
+
/** The shown Post the hidden run starts right after. */
|
|
342
|
+
afterPostId: string;
|
|
343
|
+
}
|
|
344
|
+
|
|
339
345
|
/**
|
|
340
346
|
* Bounded projection for one curated Featured Thread.
|
|
341
347
|
*
|
|
@@ -346,15 +352,8 @@ export interface FeaturedThreadTimelinePost {
|
|
|
346
352
|
export interface FeaturedThreadTimelineData {
|
|
347
353
|
posts: FeaturedThreadTimelinePost[];
|
|
348
354
|
featuredPostIds: string[];
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
export interface PostBodyContent {
|
|
352
|
-
id: string;
|
|
353
|
-
type: "post";
|
|
354
|
-
format: Format;
|
|
355
|
-
contentFormat: "markdown";
|
|
356
|
-
content: string;
|
|
357
|
-
chars: number;
|
|
355
|
+
/** The first hidden Post of each run between two shown ones. */
|
|
356
|
+
gapTargets: FeaturedThreadGapTarget[];
|
|
358
357
|
}
|
|
359
358
|
|
|
360
359
|
/** Minimal projection used by the sitemap renderer. */
|
|
@@ -432,7 +431,6 @@ export interface PostService {
|
|
|
432
431
|
* ```
|
|
433
432
|
*/
|
|
434
433
|
getWithCanonicalAlias(postId: string): Promise<PostWithCanonicalAlias | null>;
|
|
435
|
-
getBodyContent(id: string): Promise<PostBodyContent | null>;
|
|
436
434
|
getBySlug(slug: string): Promise<Post | null>;
|
|
437
435
|
suggestSlug(input: {
|
|
438
436
|
title?: string;
|
|
@@ -459,8 +457,8 @@ export interface PostService {
|
|
|
459
457
|
* @param filters - What to list and in which order, as for {@link list}
|
|
460
458
|
* @param page - The previous page's `nextCursor`, and the page size
|
|
461
459
|
* @returns The page's Posts and the cursor after them, `null` on the last page
|
|
462
|
-
* @throws {ValidationError} When the cursor can't be read
|
|
463
|
-
* another sort mode
|
|
460
|
+
* @throws {ValidationError} When the cursor can't be read or was taken in
|
|
461
|
+
* another sort mode
|
|
464
462
|
* @example
|
|
465
463
|
* ```ts
|
|
466
464
|
* const first = await posts.listPage({ status: "published" }, { limit: 20 });
|
|
@@ -539,9 +537,13 @@ export interface PostService {
|
|
|
539
537
|
filters: readonly PostFilters[],
|
|
540
538
|
base: PostFilters,
|
|
541
539
|
): Promise<PostFilterAggregate[]>;
|
|
542
|
-
/**
|
|
540
|
+
/**
|
|
541
|
+
* Count posts grouped by year-month (YYYY-MM) on the `sortBy` time axis, as
|
|
542
|
+
* the site's wall clock in `timeZone` reads it.
|
|
543
|
+
*/
|
|
543
544
|
countByYearMonth(
|
|
544
|
-
filters
|
|
545
|
+
filters: PostFilters,
|
|
546
|
+
timeZone: string,
|
|
545
547
|
): Promise<{ yearMonth: string; count: number }[]>;
|
|
546
548
|
create(data: CreatePost, summaryConfig?: SummaryConfig): Promise<Post>;
|
|
547
549
|
createWithAttachments(
|
|
@@ -591,10 +593,28 @@ export interface PostService {
|
|
|
591
593
|
*/
|
|
592
594
|
delete(id: string, deps?: PostDeleteDeps): Promise<boolean>;
|
|
593
595
|
/**
|
|
594
|
-
*
|
|
595
|
-
*
|
|
596
|
+
* Replace a saved Thread draft with a new version of it.
|
|
597
|
+
*
|
|
598
|
+
* The old Thread is deleted first, which releases its paths for the new
|
|
599
|
+
* one. Its attachments are detached before that, since the new version
|
|
600
|
+
* sends back the ones it keeps by ID; once the new Thread is created, the
|
|
601
|
+
* ones it left out are deleted.
|
|
602
|
+
*
|
|
603
|
+
* @param id - The old Thread's root, or the one post to replace
|
|
604
|
+
* @param items - The new version, as `createThreadWithAttachments` takes it
|
|
605
|
+
* @param deps - Media/storage dependencies
|
|
606
|
+
* @param summaryConfig - Optional summary extraction config
|
|
607
|
+
* @returns Ordered list of created posts; posts[0] is the root
|
|
596
608
|
*/
|
|
597
|
-
|
|
609
|
+
replaceThreadDraft(
|
|
610
|
+
id: string,
|
|
611
|
+
items: Array<{
|
|
612
|
+
data: CreatePost;
|
|
613
|
+
attachments: PostAttachmentInput[] | undefined;
|
|
614
|
+
}>,
|
|
615
|
+
deps: PostAttachmentDeps,
|
|
616
|
+
summaryConfig?: SummaryConfig,
|
|
617
|
+
): Promise<Post[]>;
|
|
598
618
|
/**
|
|
599
619
|
* Every Post in a Thread, drafts included, in Thread order: the root first,
|
|
600
620
|
* then replies by creation time, then ID.
|
|
@@ -606,17 +626,15 @@ export interface PostService {
|
|
|
606
626
|
*
|
|
607
627
|
* Pages like {@link listPage}. A new reply joins the end of the Thread, so a
|
|
608
628
|
* walk that is still going when one is published reaches it rather than
|
|
609
|
-
* skipping it.
|
|
610
|
-
*
|
|
611
|
-
* it, which is how a reader opens the run a fold hides.
|
|
629
|
+
* skipping it. A fold's gap carries a cursor from
|
|
630
|
+
* `encodeThreadPostsCursorAfter`, which opens the run the fold hides.
|
|
612
631
|
*
|
|
613
632
|
* @param threadId - The Thread root's ID
|
|
614
633
|
* @param options - Which Posts to include; `status` defaults to `published`
|
|
615
|
-
* @param page - The previous page's `nextCursor
|
|
616
|
-
* size
|
|
634
|
+
* @param page - The previous page's `nextCursor`, and the page size
|
|
617
635
|
* @returns The page's Posts and the cursor after them, `null` on the last page
|
|
618
|
-
* @throws {ValidationError} When the cursor can't be read
|
|
619
|
-
* another order
|
|
636
|
+
* @throws {ValidationError} When the cursor can't be read or was taken in
|
|
637
|
+
* another order
|
|
620
638
|
* @example
|
|
621
639
|
* ```ts
|
|
622
640
|
* const first = await posts.listThreadPostsPage(root.id, {}, { limit: 100 });
|
|
@@ -698,13 +716,27 @@ export interface PostService {
|
|
|
698
716
|
/**
|
|
699
717
|
* List the Thread roots that are translations of the given Post, excluding
|
|
700
718
|
* the Post itself. Empty when it belongs to no translation group.
|
|
719
|
+
*
|
|
720
|
+
* @param postId - The Post whose translations to list
|
|
721
|
+
* @param reader - What the audience may see. Omit it for the author's view,
|
|
722
|
+
* which includes drafts and private translations.
|
|
701
723
|
*/
|
|
702
|
-
listTranslations(
|
|
724
|
+
listTranslations(
|
|
725
|
+
postId: string,
|
|
726
|
+
reader?: ReaderVisibilityOptions,
|
|
727
|
+
): Promise<Post[]>;
|
|
703
728
|
/**
|
|
704
729
|
* List translations for many Thread roots in one round trip, keyed by the
|
|
705
|
-
* root ID that was asked about. Roots with no group
|
|
730
|
+
* root ID that was asked about. Roots with no group, or none the audience
|
|
731
|
+
* may see, are omitted.
|
|
732
|
+
*
|
|
733
|
+
* @param postIds - Thread roots to look up
|
|
734
|
+
* @param reader - What the audience may see. Omit it for the author's view.
|
|
706
735
|
*/
|
|
707
|
-
getTranslationsMap(
|
|
736
|
+
getTranslationsMap(
|
|
737
|
+
postIds: string[],
|
|
738
|
+
reader?: ReaderVisibilityOptions,
|
|
739
|
+
): Promise<Map<string, Post[]>>;
|
|
708
740
|
/**
|
|
709
741
|
* Find published Thread roots this Post could be linked to as a translation.
|
|
710
742
|
*
|
|
@@ -826,8 +858,8 @@ export interface PostService {
|
|
|
826
858
|
* @param page - The previous page's `nextCursor`, and the page size
|
|
827
859
|
* @returns The page's Thread roots and the cursor after them, `null` on the
|
|
828
860
|
* last page
|
|
829
|
-
* @throws {ValidationError} When the cursor can't be read
|
|
830
|
-
* another order
|
|
861
|
+
* @throws {ValidationError} When the cursor can't be read or was taken in
|
|
862
|
+
* another order
|
|
831
863
|
* @example
|
|
832
864
|
* ```ts
|
|
833
865
|
* const first = await posts.listCollectionThreadRootPage(
|
|
@@ -860,8 +892,11 @@ export interface PostService {
|
|
|
860
892
|
rootIds: string[],
|
|
861
893
|
options?: Pick<PostFilters, "publishedBefore">,
|
|
862
894
|
): Promise<Map<string, Post[]>>;
|
|
863
|
-
/**
|
|
864
|
-
|
|
895
|
+
/**
|
|
896
|
+
* Get distinct years with posts, bucketed on the `sortBy` time axis as the
|
|
897
|
+
* site's wall clock in `timeZone` reads it.
|
|
898
|
+
*/
|
|
899
|
+
getDistinctYears(filters: PostFilters, timeZone: string): Promise<number[]>;
|
|
865
900
|
/**
|
|
866
901
|
* For each Thread ID, resolve the Post that currently ends the chain: the
|
|
867
902
|
* last in Thread order, so the root only while it has no replies.
|
|
@@ -1176,6 +1211,7 @@ export function createPostService(
|
|
|
1176
1211
|
* cursor. The one definition both read, so a page of a Thread and the
|
|
1177
1212
|
* Thread page itself cannot order its posts differently.
|
|
1178
1213
|
*/
|
|
1214
|
+
/** Thread order; `encodeThreadPostsCursorAfter` writes the same tuple. */
|
|
1179
1215
|
function threadSortKeys(): ListSortKey[] {
|
|
1180
1216
|
return [
|
|
1181
1217
|
{
|
|
@@ -1194,16 +1230,58 @@ export function createPostService(
|
|
|
1194
1230
|
];
|
|
1195
1231
|
}
|
|
1196
1232
|
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1233
|
+
/**
|
|
1234
|
+
* The calendar periods, on the site's wall clock, that the posts matching
|
|
1235
|
+
* `filters` fall in, with the time axis and condition that select them.
|
|
1236
|
+
* `null` when no post matches.
|
|
1237
|
+
*
|
|
1238
|
+
* Neither SQLite nor D1 knows IANA time zones, so the period boundaries are
|
|
1239
|
+
* worked out here from the earliest and latest matching post, and the query
|
|
1240
|
+
* sorts each row into one by comparing against them.
|
|
1241
|
+
*/
|
|
1242
|
+
async function calendarPeriodsOf(
|
|
1243
|
+
filters: PostFilters,
|
|
1244
|
+
unit: "year" | "month",
|
|
1245
|
+
timeZone: string,
|
|
1246
|
+
) {
|
|
1247
|
+
const axis = timeAxisColumn(filters);
|
|
1248
|
+
const where = and(...buildFilterConditions(filters), isNotNull(axis));
|
|
1249
|
+
const [span] = await db
|
|
1250
|
+
.select({
|
|
1251
|
+
from: sql<number | null>`min(${axis})`,
|
|
1252
|
+
to: sql<number | null>`max(${axis})`,
|
|
1253
|
+
})
|
|
1254
|
+
.from(posts)
|
|
1255
|
+
.where(where);
|
|
1256
|
+
if (span?.from == null || span.to == null) return null;
|
|
1257
|
+
const periods = calendarPeriodsIn(
|
|
1258
|
+
Number(span.from),
|
|
1259
|
+
Number(span.to),
|
|
1260
|
+
unit,
|
|
1261
|
+
timeZone,
|
|
1262
|
+
);
|
|
1263
|
+
return { expr: buildPeriodExpr(axis, periods), where };
|
|
1201
1264
|
}
|
|
1202
1265
|
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1266
|
+
/**
|
|
1267
|
+
* A column's period key: the latest of `periods` (oldest first, the first
|
|
1268
|
+
* beginning at or before every value) that begins at or before it. Every
|
|
1269
|
+
* branch reads the column, even with one period: Postgres refuses to group
|
|
1270
|
+
* or order by a bare constant. Boundaries and keys are generated digits,
|
|
1271
|
+
* written as literals because D1 takes at most 100 bound parameters and a
|
|
1272
|
+
* long archive has more month boundaries than that.
|
|
1273
|
+
*/
|
|
1274
|
+
function buildPeriodExpr(
|
|
1275
|
+
column: SQLWrapper,
|
|
1276
|
+
periods: readonly CalendarPeriod[],
|
|
1277
|
+
): SQL<string> {
|
|
1278
|
+
const branches = [...periods]
|
|
1279
|
+
.reverse()
|
|
1280
|
+
.map(
|
|
1281
|
+
(period) =>
|
|
1282
|
+
sql`WHEN ${column} >= ${sql.raw(String(period.start))} THEN ${sql.raw(`'${period.key}'`)}`,
|
|
1283
|
+
);
|
|
1284
|
+
return sql<string>`CASE ${sql.join(branches, sql` `)} END`;
|
|
1207
1285
|
}
|
|
1208
1286
|
|
|
1209
1287
|
/** Check if a slug is available (not used by posts or path_registry) */
|
|
@@ -1762,47 +1840,17 @@ export function createPostService(
|
|
|
1762
1840
|
|
|
1763
1841
|
/**
|
|
1764
1842
|
* The position a cursor names, as the tuple of sort-key values after which
|
|
1765
|
-
* the page starts.
|
|
1766
|
-
*
|
|
1767
|
-
* A bare post ID, the cursor earlier releases returned, is looked up — but
|
|
1768
|
-
* only among Posts the caller could have been shown: the request's status,
|
|
1769
|
-
* and nothing private when the request excludes it. A deleted Post, a draft,
|
|
1770
|
-
* and a private Post all get the same rejection, so the lookup can't be used
|
|
1771
|
-
* to learn whether a Post exists or when it was published. Its values come
|
|
1772
|
-
* from the same key expressions as the ORDER BY.
|
|
1843
|
+
* the page starts. The cursor must come from a list in the same order.
|
|
1773
1844
|
*/
|
|
1774
|
-
|
|
1845
|
+
function resolveListCursor(
|
|
1775
1846
|
cursor: string,
|
|
1776
1847
|
sort: ListSort,
|
|
1777
1848
|
keys: readonly ListSortKey[],
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
kinds: keys.map((key) => key.kind),
|
|
1784
|
-
});
|
|
1785
|
-
}
|
|
1786
|
-
|
|
1787
|
-
const rows = await db
|
|
1788
|
-
.select(listSortKeyFields(keys))
|
|
1789
|
-
.from(posts)
|
|
1790
|
-
.where(
|
|
1791
|
-
and(
|
|
1792
|
-
eq(posts.siteId, siteId),
|
|
1793
|
-
eq(posts.id, cursor),
|
|
1794
|
-
...buildReaderVisibilityConditions(posts, siteId, {
|
|
1795
|
-
status: filters.status,
|
|
1796
|
-
excludePrivate: filters.excludePrivate,
|
|
1797
|
-
}),
|
|
1798
|
-
),
|
|
1799
|
-
)
|
|
1800
|
-
.limit(1);
|
|
1801
|
-
const row = rows[0];
|
|
1802
|
-
if (!row) {
|
|
1803
|
-
throw new ValidationError(MISSING_LEGACY_CURSOR_MESSAGE);
|
|
1804
|
-
}
|
|
1805
|
-
return readListSortKeyValues(keys, row);
|
|
1849
|
+
): PostListCursorValue[] {
|
|
1850
|
+
return decodePostListCursor(cursor, {
|
|
1851
|
+
mode: listSortMode(sort),
|
|
1852
|
+
kinds: keys.map((key) => key.kind),
|
|
1853
|
+
});
|
|
1806
1854
|
}
|
|
1807
1855
|
|
|
1808
1856
|
function toPost(
|
|
@@ -1853,95 +1901,57 @@ export function createPostService(
|
|
|
1853
1901
|
}
|
|
1854
1902
|
|
|
1855
1903
|
/**
|
|
1856
|
-
*
|
|
1857
|
-
*
|
|
1904
|
+
* A post row together with what turning it into a {@link Post} takes from
|
|
1905
|
+
* other rows: its slug, from `path_registry`, and its Thread's visibility,
|
|
1906
|
+
* which a reply inherits from the root (a reply's own column is null).
|
|
1858
1907
|
*
|
|
1859
|
-
*
|
|
1860
|
-
*
|
|
1861
|
-
*
|
|
1862
|
-
* thread and the follow-up read never runs.
|
|
1908
|
+
* Both ride along as correlated subqueries, so reading posts is one
|
|
1909
|
+
* statement. On D1 each follow-up lookup was one more round trip on every
|
|
1910
|
+
* page that shows a post.
|
|
1863
1911
|
*
|
|
1864
|
-
*
|
|
1865
|
-
*
|
|
1866
|
-
*
|
|
1912
|
+
* The outer columns are written out rather than interpolated: Drizzle only
|
|
1913
|
+
* qualifies projection columns when the query has a join, so `${posts.id}`
|
|
1914
|
+
* would render as a bare "id" and bind to the subquery's own table.
|
|
1867
1915
|
*/
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
}
|
|
1916
|
+
const hydratedPostColumns = {
|
|
1917
|
+
...getTableColumns(posts),
|
|
1918
|
+
slug: sql<string | null>`(
|
|
1919
|
+
SELECT post_slug.path
|
|
1920
|
+
FROM path_registry AS post_slug
|
|
1921
|
+
WHERE post_slug.site_id = ${siteId}
|
|
1922
|
+
AND post_slug.post_id = "post"."id"
|
|
1923
|
+
AND post_slug.kind = 'slug'
|
|
1924
|
+
)`.as("post_slug"),
|
|
1925
|
+
threadVisibility: sql<string | null>`(
|
|
1926
|
+
SELECT thread_root.visibility
|
|
1927
|
+
FROM post AS thread_root
|
|
1928
|
+
WHERE thread_root.site_id = ${siteId}
|
|
1929
|
+
AND thread_root.id = "post"."thread_id"
|
|
1930
|
+
)`.as("thread_visibility"),
|
|
1931
|
+
};
|
|
1932
|
+
|
|
1933
|
+
type HydratedPostRow = typeof posts.$inferSelect & {
|
|
1934
|
+
slug: string | null;
|
|
1935
|
+
threadVisibility: string | null;
|
|
1936
|
+
};
|
|
1890
1937
|
|
|
1891
1938
|
/**
|
|
1892
|
-
*
|
|
1893
|
-
*
|
|
1939
|
+
* Turn a row read with {@link hydratedPostColumns} into a `Post`.
|
|
1940
|
+
*
|
|
1941
|
+
* Null for a row with no slug — a Post with no address — or with no
|
|
1942
|
+
* visibility on its Thread root.
|
|
1894
1943
|
*/
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
slugMap: Map<string, string>;
|
|
1899
|
-
visibilityMap: Map<string, Visibility>;
|
|
1900
|
-
}> {
|
|
1901
|
-
const { known, missingThreadIds } = seedThreadVisibility(rows);
|
|
1902
|
-
const [slugMap, fetched] = await Promise.all([
|
|
1903
|
-
resolvedPaths.getPostSlugMap(rows.map((row) => row.id)),
|
|
1904
|
-
missingThreadIds.length > 0
|
|
1905
|
-
? getThreadVisibilityMap(missingThreadIds)
|
|
1906
|
-
: Promise.resolve(new Map<string, Visibility>()),
|
|
1907
|
-
]);
|
|
1908
|
-
for (const [threadId, visibility] of fetched) {
|
|
1909
|
-
known.set(threadId, visibility);
|
|
1910
|
-
}
|
|
1911
|
-
return { slugMap, visibilityMap: known };
|
|
1912
|
-
}
|
|
1913
|
-
|
|
1914
|
-
async function hydratePost(
|
|
1915
|
-
row: typeof posts.$inferSelect | undefined,
|
|
1916
|
-
knownSlug?: string,
|
|
1917
|
-
): Promise<Post | null> {
|
|
1918
|
-
if (!row) return null;
|
|
1919
|
-
const { known, missingThreadIds } = seedThreadVisibility([row]);
|
|
1920
|
-
const [slug, fetched] = await Promise.all([
|
|
1921
|
-
knownSlug ?? resolvedPaths.getPostSlug(row.id),
|
|
1922
|
-
missingThreadIds.length > 0
|
|
1923
|
-
? getThreadVisibilityMap(missingThreadIds)
|
|
1924
|
-
: Promise.resolve(new Map<string, Visibility>()),
|
|
1925
|
-
]);
|
|
1926
|
-
if (!slug) return null;
|
|
1927
|
-
const visibility =
|
|
1928
|
-
known.get(row.threadId) ?? fetched.get(row.threadId) ?? row.visibility;
|
|
1944
|
+
function hydratePost(row: HydratedPostRow | undefined): Post | null {
|
|
1945
|
+
if (!row?.slug) return null;
|
|
1946
|
+
const visibility = row.threadVisibility ?? row.visibility;
|
|
1929
1947
|
if (!visibility) return null;
|
|
1930
|
-
return toPost(row, slug, visibility);
|
|
1948
|
+
return toPost(row, row.slug, visibility);
|
|
1931
1949
|
}
|
|
1932
1950
|
|
|
1933
|
-
|
|
1934
|
-
rows: (typeof posts.$inferSelect)[],
|
|
1935
|
-
): Promise<Post[]> {
|
|
1936
|
-
if (rows.length === 0) return [];
|
|
1937
|
-
const { slugMap, visibilityMap } = await loadHydrationMaps(rows);
|
|
1951
|
+
function hydratePosts(rows: HydratedPostRow[]): Post[] {
|
|
1938
1952
|
return rows
|
|
1939
|
-
.map((row) =>
|
|
1940
|
-
|
|
1941
|
-
const visibility = visibilityMap.get(row.threadId) ?? row.visibility;
|
|
1942
|
-
return slug && visibility ? toPost(row, slug, visibility) : null;
|
|
1943
|
-
})
|
|
1944
|
-
.filter((row): row is Post => row !== null);
|
|
1953
|
+
.map((row) => hydratePost(row))
|
|
1954
|
+
.filter((post): post is Post => post !== null);
|
|
1945
1955
|
}
|
|
1946
1956
|
|
|
1947
1957
|
async function hydratePostsById(ids: string[]): Promise<Map<string, Post>> {
|
|
@@ -1954,7 +1964,7 @@ export function createPostService(
|
|
|
1954
1964
|
|
|
1955
1965
|
const rows = await batchQueryRows(uniqueIds, (chunk) =>
|
|
1956
1966
|
db
|
|
1957
|
-
.select()
|
|
1967
|
+
.select(hydratedPostColumns)
|
|
1958
1968
|
.from(posts)
|
|
1959
1969
|
.where(
|
|
1960
1970
|
and(
|
|
@@ -1965,36 +1975,13 @@ export function createPostService(
|
|
|
1965
1975
|
),
|
|
1966
1976
|
);
|
|
1967
1977
|
|
|
1968
|
-
for (const post of
|
|
1978
|
+
for (const post of hydratePosts(rows)) {
|
|
1969
1979
|
result.set(post.id, post);
|
|
1970
1980
|
}
|
|
1971
1981
|
|
|
1972
1982
|
return result;
|
|
1973
1983
|
}
|
|
1974
1984
|
|
|
1975
|
-
async function getThreadVisibilityMap(
|
|
1976
|
-
threadIds: string[],
|
|
1977
|
-
): Promise<Map<string, Visibility>> {
|
|
1978
|
-
const uniqueThreadIds = [...new Set(threadIds)];
|
|
1979
|
-
const result = new Map<string, Visibility>();
|
|
1980
|
-
if (uniqueThreadIds.length === 0) return result;
|
|
1981
|
-
|
|
1982
|
-
const rows = await batchQueryRows(uniqueThreadIds, (chunk) =>
|
|
1983
|
-
db
|
|
1984
|
-
.select({ id: posts.id, visibility: posts.visibility })
|
|
1985
|
-
.from(posts)
|
|
1986
|
-
.where(and(eq(posts.siteId, siteId), inArray(posts.id, chunk))),
|
|
1987
|
-
);
|
|
1988
|
-
|
|
1989
|
-
for (const row of rows) {
|
|
1990
|
-
if (row.visibility) {
|
|
1991
|
-
result.set(row.id, ensurePostVisibility(row.visibility, Error));
|
|
1992
|
-
}
|
|
1993
|
-
}
|
|
1994
|
-
|
|
1995
|
-
return result;
|
|
1996
|
-
}
|
|
1997
|
-
|
|
1998
1985
|
function buildThreadRootPageConditions(options?: ThreadRootPageOptions) {
|
|
1999
1986
|
const conditions: SQL[] = [
|
|
2000
1987
|
eq(posts.siteId, siteId),
|
|
@@ -2188,33 +2175,15 @@ export function createPostService(
|
|
|
2188
2175
|
/**
|
|
2189
2176
|
* The position a collection cursor names, as the tuple of sort-key values
|
|
2190
2177
|
* after which the page starts.
|
|
2191
|
-
*
|
|
2192
|
-
* A bare root ID, the cursor earlier releases returned, is looked up in the
|
|
2193
|
-
* request's own `sortedThreads`, so only among Threads this request could
|
|
2194
|
-
* list. A Thread that is gone, private, a draft, or no longer in the
|
|
2195
|
-
* collection gets the same rejection as an ID that never existed.
|
|
2196
2178
|
*/
|
|
2197
|
-
|
|
2179
|
+
function resolveCollectionThreadCursor(
|
|
2198
2180
|
cursor: string,
|
|
2199
2181
|
sort: ReturnType<typeof buildCollectionThreadSort>,
|
|
2200
|
-
):
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
});
|
|
2206
|
-
}
|
|
2207
|
-
|
|
2208
|
-
const rows = await db
|
|
2209
|
-
.select(listSortKeyFields(sort.keys))
|
|
2210
|
-
.from(sort.sortedThreads)
|
|
2211
|
-
.where(eq(sort.sortedThreads.threadId, cursor))
|
|
2212
|
-
.limit(1);
|
|
2213
|
-
const row = rows[0];
|
|
2214
|
-
if (!row) {
|
|
2215
|
-
throw new ValidationError(MISSING_LEGACY_CURSOR_MESSAGE);
|
|
2216
|
-
}
|
|
2217
|
-
return readListSortKeyValues(sort.keys, row);
|
|
2182
|
+
): PostListCursorValue[] {
|
|
2183
|
+
return decodePostListCursor(cursor, {
|
|
2184
|
+
mode: sort.mode,
|
|
2185
|
+
kinds: sort.keys.map((key) => key.kind),
|
|
2186
|
+
});
|
|
2218
2187
|
}
|
|
2219
2188
|
|
|
2220
2189
|
function isMediaAttachmentInput(
|
|
@@ -2223,9 +2192,19 @@ export function createPostService(
|
|
|
2223
2192
|
return attachment.type === "media";
|
|
2224
2193
|
}
|
|
2225
2194
|
|
|
2195
|
+
/** IDs of the uploaded media that attachment inputs reference. */
|
|
2196
|
+
function referencedMediaIds(
|
|
2197
|
+
attachments: PostAttachmentInput[] | undefined,
|
|
2198
|
+
): string[] {
|
|
2199
|
+
return (attachments ?? [])
|
|
2200
|
+
.filter(isMediaAttachmentInput)
|
|
2201
|
+
.map((attachment) => attachment.mediaId);
|
|
2202
|
+
}
|
|
2203
|
+
|
|
2226
2204
|
async function createAttachmentMediaIds(
|
|
2227
2205
|
attachments: PostAttachmentInput[],
|
|
2228
2206
|
deps: PostAttachmentDeps,
|
|
2207
|
+
postId?: string,
|
|
2229
2208
|
) {
|
|
2230
2209
|
if (attachments.length > MAX_MEDIA_ATTACHMENTS) {
|
|
2231
2210
|
throw new ValidationError(
|
|
@@ -2235,11 +2214,7 @@ export function createPostService(
|
|
|
2235
2214
|
|
|
2236
2215
|
const orderedMediaIds: string[] = [];
|
|
2237
2216
|
const createdTextMediaIds: string[] = [];
|
|
2238
|
-
|
|
2239
|
-
.filter(isMediaAttachmentInput)
|
|
2240
|
-
.map((attachment) => attachment.mediaId);
|
|
2241
|
-
|
|
2242
|
-
await deps.media.validateIds(referencedMediaIds);
|
|
2217
|
+
await deps.media.validateIds(referencedMediaIds(attachments), postId);
|
|
2243
2218
|
|
|
2244
2219
|
try {
|
|
2245
2220
|
for (const attachment of attachments) {
|
|
@@ -2356,7 +2331,7 @@ export function createPostService(
|
|
|
2356
2331
|
return {
|
|
2357
2332
|
async getById(id) {
|
|
2358
2333
|
const result = await db
|
|
2359
|
-
.select()
|
|
2334
|
+
.select(hydratedPostColumns)
|
|
2360
2335
|
.from(posts)
|
|
2361
2336
|
.where(and(eq(posts.siteId, siteId), eq(posts.id, id)))
|
|
2362
2337
|
.limit(1);
|
|
@@ -2364,55 +2339,35 @@ export function createPostService(
|
|
|
2364
2339
|
},
|
|
2365
2340
|
|
|
2366
2341
|
async getWithCanonicalAlias(postId) {
|
|
2342
|
+
// The oldest alias is the post's address, as feeds, the sitemap, and
|
|
2343
|
+
// the export name it: a second custom URL is another way in, not a new
|
|
2344
|
+
// identity. Ties within a second fall to the lower id, not to the
|
|
2345
|
+
// storage engine's order.
|
|
2367
2346
|
const rows = await db
|
|
2368
|
-
.select({
|
|
2347
|
+
.select({
|
|
2348
|
+
...hydratedPostColumns,
|
|
2349
|
+
canonicalAlias: sql<string | null>`(
|
|
2350
|
+
SELECT post_alias.path
|
|
2351
|
+
FROM path_registry AS post_alias
|
|
2352
|
+
WHERE post_alias.site_id = ${siteId}
|
|
2353
|
+
AND post_alias.post_id = "post"."id"
|
|
2354
|
+
AND post_alias.kind = 'alias'
|
|
2355
|
+
ORDER BY post_alias.created_at, post_alias.id
|
|
2356
|
+
LIMIT 1
|
|
2357
|
+
)`.as("canonical_alias"),
|
|
2358
|
+
})
|
|
2369
2359
|
.from(posts)
|
|
2370
|
-
.leftJoin(
|
|
2371
|
-
pathRegistry,
|
|
2372
|
-
and(
|
|
2373
|
-
eq(pathRegistry.siteId, siteId),
|
|
2374
|
-
eq(pathRegistry.postId, posts.id),
|
|
2375
|
-
),
|
|
2376
|
-
)
|
|
2377
2360
|
.where(and(eq(posts.siteId, siteId), eq(posts.id, postId)))
|
|
2378
|
-
.
|
|
2361
|
+
.limit(1);
|
|
2379
2362
|
|
|
2380
2363
|
const row = rows[0];
|
|
2381
|
-
if (!row) return null;
|
|
2382
|
-
|
|
2383
|
-
let slug: string | null = null;
|
|
2384
|
-
let canonicalAlias: string | null = null;
|
|
2385
|
-
for (const { path } of rows) {
|
|
2386
|
-
if (!path) continue;
|
|
2387
|
-
if (path.kind === "slug") {
|
|
2388
|
-
slug = path.path;
|
|
2389
|
-
continue;
|
|
2390
|
-
}
|
|
2391
|
-
// Rows arrive oldest first, so the last `alias` seen is the newest —
|
|
2392
|
-
// the one a slug URL redirects to. Ties within a second fall to the
|
|
2393
|
-
// higher id rather than to whatever the storage engine returned first.
|
|
2394
|
-
if (path.kind === "alias") canonicalAlias = `/${path.path}`;
|
|
2395
|
-
}
|
|
2396
|
-
|
|
2397
2364
|
// A Post with no slug row has no address, which is what `hydratePost`
|
|
2398
2365
|
// says by returning null for it.
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
const post = await hydratePost(row.post, slug);
|
|
2402
|
-
return post ? { post, canonicalAlias } : null;
|
|
2403
|
-
},
|
|
2404
|
-
|
|
2405
|
-
async getBodyContent(id) {
|
|
2406
|
-
const post = await this.getById(id);
|
|
2407
|
-
if (!post) return null;
|
|
2408
|
-
|
|
2366
|
+
const post = hydratePost(row);
|
|
2367
|
+
if (!row || !post) return null;
|
|
2409
2368
|
return {
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
format: post.format,
|
|
2413
|
-
contentFormat: "markdown",
|
|
2414
|
-
content: post.body ? tiptapJsonToMarkdown(post.body) : "",
|
|
2415
|
-
chars: post.bodyText?.length ?? 0,
|
|
2369
|
+
post,
|
|
2370
|
+
canonicalAlias: row.canonicalAlias ? `/${row.canonicalAlias}` : null,
|
|
2416
2371
|
};
|
|
2417
2372
|
},
|
|
2418
2373
|
|
|
@@ -2422,13 +2377,11 @@ export function createPostService(
|
|
|
2422
2377
|
return null;
|
|
2423
2378
|
}
|
|
2424
2379
|
const result = await db
|
|
2425
|
-
.select()
|
|
2380
|
+
.select(hydratedPostColumns)
|
|
2426
2381
|
.from(posts)
|
|
2427
2382
|
.where(and(eq(posts.siteId, siteId), eq(posts.id, resolved.postId)))
|
|
2428
2383
|
.limit(1);
|
|
2429
|
-
|
|
2430
|
-
// back for it.
|
|
2431
|
-
return hydratePost(result[0], resolved.path);
|
|
2384
|
+
return hydratePost(result[0]);
|
|
2432
2385
|
},
|
|
2433
2386
|
|
|
2434
2387
|
async suggestSlug(input) {
|
|
@@ -2458,7 +2411,7 @@ export function createPostService(
|
|
|
2458
2411
|
const conditions = buildFilterConditions(filters);
|
|
2459
2412
|
|
|
2460
2413
|
let query = db
|
|
2461
|
-
.select()
|
|
2414
|
+
.select(hydratedPostColumns)
|
|
2462
2415
|
.from(posts)
|
|
2463
2416
|
.where(conditions.length > 0 ? and(...conditions) : undefined)
|
|
2464
2417
|
.orderBy(...listOrderBy(keys))
|
|
@@ -2480,17 +2433,14 @@ export function createPostService(
|
|
|
2480
2433
|
// `?cursor=` before it has one keeps working.
|
|
2481
2434
|
if (cursor) {
|
|
2482
2435
|
conditions.push(
|
|
2483
|
-
buildListKeysetCondition(
|
|
2484
|
-
keys,
|
|
2485
|
-
await resolveListCursor(cursor, sort, keys, filters),
|
|
2486
|
-
),
|
|
2436
|
+
buildListKeysetCondition(keys, resolveListCursor(cursor, sort, keys)),
|
|
2487
2437
|
);
|
|
2488
2438
|
}
|
|
2489
2439
|
|
|
2490
2440
|
// One row past the page says whether another page exists, so the last
|
|
2491
2441
|
// page carries a null cursor rather than one that leads to an empty page.
|
|
2492
2442
|
const rows = await db
|
|
2493
|
-
.select({ post:
|
|
2443
|
+
.select({ post: hydratedPostColumns, sortKey: listSortKeyFields(keys) })
|
|
2494
2444
|
.from(posts)
|
|
2495
2445
|
.where(conditions.length > 0 ? and(...conditions) : undefined)
|
|
2496
2446
|
.orderBy(...listOrderBy(keys))
|
|
@@ -2510,7 +2460,7 @@ export function createPostService(
|
|
|
2510
2460
|
: null;
|
|
2511
2461
|
|
|
2512
2462
|
return {
|
|
2513
|
-
posts:
|
|
2463
|
+
posts: hydratePosts(pageRows.map((row) => row.post)),
|
|
2514
2464
|
nextCursor,
|
|
2515
2465
|
};
|
|
2516
2466
|
},
|
|
@@ -2696,20 +2646,19 @@ export function createPostService(
|
|
|
2696
2646
|
return rows.length;
|
|
2697
2647
|
},
|
|
2698
2648
|
|
|
2699
|
-
async countByYearMonth(filters
|
|
2700
|
-
const
|
|
2701
|
-
|
|
2702
|
-
const publishedYearMonthExpr = buildYearMonthExpr(axis);
|
|
2649
|
+
async countByYearMonth(filters, timeZone) {
|
|
2650
|
+
const months = await calendarPeriodsOf(filters, "month", timeZone);
|
|
2651
|
+
if (!months) return [];
|
|
2703
2652
|
|
|
2704
2653
|
return db
|
|
2705
2654
|
.select({
|
|
2706
|
-
yearMonth:
|
|
2655
|
+
yearMonth: months.expr.as("year_month"),
|
|
2707
2656
|
count: sql<number>`CAST(count(*) AS INTEGER)`.as("count"),
|
|
2708
2657
|
})
|
|
2709
2658
|
.from(posts)
|
|
2710
|
-
.where(
|
|
2711
|
-
.groupBy(
|
|
2712
|
-
.orderBy(desc(
|
|
2659
|
+
.where(months.where)
|
|
2660
|
+
.groupBy(months.expr)
|
|
2661
|
+
.orderBy(desc(months.expr));
|
|
2713
2662
|
},
|
|
2714
2663
|
|
|
2715
2664
|
async create(data, summaryConfig) {
|
|
@@ -3325,8 +3274,23 @@ export function createPostService(
|
|
|
3325
3274
|
);
|
|
3326
3275
|
created.push(post);
|
|
3327
3276
|
} catch (error) {
|
|
3328
|
-
//
|
|
3277
|
+
// Roll back the posts created so far, in reverse order. Uploads they
|
|
3278
|
+
// reference by ID are detached first rather than deleted with them:
|
|
3279
|
+
// the composer keeps those in its local draft, and a retry attaches
|
|
3280
|
+
// them again.
|
|
3281
|
+
const uploadIds = new Set(
|
|
3282
|
+
items.flatMap((entry) => referencedMediaIds(entry.attachments)),
|
|
3283
|
+
);
|
|
3329
3284
|
for (const p of [...created].reverse()) {
|
|
3285
|
+
const attached = await deps.media.getByPostId(p.id).catch(() => []);
|
|
3286
|
+
await deps.media
|
|
3287
|
+
.attachToPost(
|
|
3288
|
+
p.id,
|
|
3289
|
+
attached
|
|
3290
|
+
.filter((item) => !uploadIds.has(item.id))
|
|
3291
|
+
.map((item) => item.id),
|
|
3292
|
+
)
|
|
3293
|
+
.catch(() => undefined);
|
|
3330
3294
|
await this.delete(p.id, {
|
|
3331
3295
|
media: deps.media,
|
|
3332
3296
|
storage: deps.storage,
|
|
@@ -3567,9 +3531,10 @@ export function createPostService(
|
|
|
3567
3531
|
.returning();
|
|
3568
3532
|
if (needsThreadActivityRecalc) {
|
|
3569
3533
|
await recalculateThreadActivity(existing.threadId);
|
|
3570
|
-
return this.getById(id);
|
|
3571
3534
|
}
|
|
3572
|
-
|
|
3535
|
+
// A row from RETURNING has no slug or Thread visibility with it, so
|
|
3536
|
+
// the post is read back whole.
|
|
3537
|
+
return result[0] ? this.getById(id) : null;
|
|
3573
3538
|
}
|
|
3574
3539
|
|
|
3575
3540
|
// Complex case: cascade + update + Thread collection sync atomically.
|
|
@@ -3801,9 +3766,8 @@ export function createPostService(
|
|
|
3801
3766
|
|
|
3802
3767
|
if (needsThreadActivityRecalc) {
|
|
3803
3768
|
await recalculateThreadActivity(existing.threadId);
|
|
3804
|
-
return this.getById(id);
|
|
3805
3769
|
}
|
|
3806
|
-
return
|
|
3770
|
+
return updateResult?.[0] ? this.getById(id) : null;
|
|
3807
3771
|
},
|
|
3808
3772
|
|
|
3809
3773
|
async updateWithAttachments(id, data, attachments, deps, summaryConfig) {
|
|
@@ -3857,7 +3821,7 @@ export function createPostService(
|
|
|
3857
3821
|
]),
|
|
3858
3822
|
);
|
|
3859
3823
|
const { orderedMediaIds, createdTextMediaIds } =
|
|
3860
|
-
await createAttachmentMediaIds(attachments, deps);
|
|
3824
|
+
await createAttachmentMediaIds(attachments, deps, id);
|
|
3861
3825
|
const post = await this.update(id, data, summaryConfig);
|
|
3862
3826
|
|
|
3863
3827
|
if (!post) {
|
|
@@ -3994,13 +3958,46 @@ export function createPostService(
|
|
|
3994
3958
|
return true;
|
|
3995
3959
|
},
|
|
3996
3960
|
|
|
3997
|
-
async
|
|
3998
|
-
|
|
3961
|
+
async replaceThreadDraft(id, items, deps, summaryConfig) {
|
|
3962
|
+
const existing = await this.getById(id);
|
|
3963
|
+
const oldPosts = !existing
|
|
3964
|
+
? []
|
|
3965
|
+
: isThreadReply(existing)
|
|
3966
|
+
? [existing]
|
|
3967
|
+
: await this.getThread(id);
|
|
3968
|
+
const oldMedia = [
|
|
3969
|
+
...(
|
|
3970
|
+
await deps.media.getByPostIds(oldPosts.map((post) => post.id))
|
|
3971
|
+
).values(),
|
|
3972
|
+
].flat();
|
|
3973
|
+
for (const post of oldPosts) {
|
|
3974
|
+
await deps.media.detachFromPost(post.id);
|
|
3975
|
+
}
|
|
3976
|
+
if (existing) {
|
|
3977
|
+
await this.delete(id, { media: deps.media, storage: deps.storage });
|
|
3978
|
+
}
|
|
3979
|
+
|
|
3980
|
+
const created = await this.createThreadWithAttachments(
|
|
3981
|
+
items,
|
|
3982
|
+
deps,
|
|
3983
|
+
summaryConfig,
|
|
3984
|
+
);
|
|
3985
|
+
|
|
3986
|
+
const kept = new Set(
|
|
3987
|
+
items.flatMap((item) => referencedMediaIds(item.attachments)),
|
|
3988
|
+
);
|
|
3989
|
+
await deps.media
|
|
3990
|
+
.deleteByIds(
|
|
3991
|
+
oldMedia.filter((item) => !kept.has(item.id)).map((item) => item.id),
|
|
3992
|
+
deps.storage,
|
|
3993
|
+
)
|
|
3994
|
+
.catch(() => undefined);
|
|
3995
|
+
return created;
|
|
3999
3996
|
},
|
|
4000
3997
|
|
|
4001
3998
|
async getThread(rootId) {
|
|
4002
3999
|
const rows = await db
|
|
4003
|
-
.select()
|
|
4000
|
+
.select(hydratedPostColumns)
|
|
4004
4001
|
.from(posts)
|
|
4005
4002
|
.where(and(eq(posts.siteId, siteId), eq(posts.threadId, rootId)))
|
|
4006
4003
|
.orderBy(...threadOrder());
|
|
@@ -4017,32 +4014,15 @@ export function createPostService(
|
|
|
4017
4014
|
];
|
|
4018
4015
|
|
|
4019
4016
|
if (cursor) {
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
// be used to learn anything about a Post elsewhere.
|
|
4025
|
-
const rows = await db
|
|
4026
|
-
.select(listSortKeyFields(keys))
|
|
4027
|
-
.from(posts)
|
|
4028
|
-
.where(and(...conditions, eq(posts.id, cursor)))
|
|
4029
|
-
.limit(1);
|
|
4030
|
-
const row = rows[0];
|
|
4031
|
-
if (!row) {
|
|
4032
|
-
throw new ValidationError(MISSING_LEGACY_CURSOR_MESSAGE);
|
|
4033
|
-
}
|
|
4034
|
-
values = readListSortKeyValues(keys, row);
|
|
4035
|
-
} else {
|
|
4036
|
-
values = decodePostListCursor(cursor, {
|
|
4037
|
-
mode: THREAD_POSTS_SORT_MODE,
|
|
4038
|
-
kinds: keys.map((key) => key.kind),
|
|
4039
|
-
});
|
|
4040
|
-
}
|
|
4017
|
+
const values = decodePostListCursor(cursor, {
|
|
4018
|
+
mode: THREAD_POSTS_SORT_MODE,
|
|
4019
|
+
kinds: keys.map((key) => key.kind),
|
|
4020
|
+
});
|
|
4041
4021
|
conditions.push(buildListKeysetCondition(keys, values));
|
|
4042
4022
|
}
|
|
4043
4023
|
|
|
4044
4024
|
const rows = await db
|
|
4045
|
-
.select({ post:
|
|
4025
|
+
.select({ post: hydratedPostColumns, sortKey: listSortKeyFields(keys) })
|
|
4046
4026
|
.from(posts)
|
|
4047
4027
|
.where(and(...conditions))
|
|
4048
4028
|
.orderBy(...listOrderBy(keys))
|
|
@@ -4051,7 +4031,7 @@ export function createPostService(
|
|
|
4051
4031
|
const pageRows = rows.slice(0, limit);
|
|
4052
4032
|
const lastRow = pageRows[pageRows.length - 1];
|
|
4053
4033
|
return {
|
|
4054
|
-
posts:
|
|
4034
|
+
posts: hydratePosts(pageRows.map((row) => row.post)),
|
|
4055
4035
|
nextCursor:
|
|
4056
4036
|
rows.length > limit && lastRow
|
|
4057
4037
|
? encodePostListCursor(
|
|
@@ -4317,8 +4297,8 @@ export function createPostService(
|
|
|
4317
4297
|
.map((row) => ({ language: row.language, count: Number(row.count) }));
|
|
4318
4298
|
},
|
|
4319
4299
|
|
|
4320
|
-
async listTranslations(postId) {
|
|
4321
|
-
const map = await this.getTranslationsMap([postId]);
|
|
4300
|
+
async listTranslations(postId, reader) {
|
|
4301
|
+
const map = await this.getTranslationsMap([postId], reader);
|
|
4322
4302
|
return map.get(postId) ?? [];
|
|
4323
4303
|
},
|
|
4324
4304
|
|
|
@@ -4375,7 +4355,7 @@ export function createPostService(
|
|
|
4375
4355
|
}
|
|
4376
4356
|
|
|
4377
4357
|
const rows = await db
|
|
4378
|
-
.select()
|
|
4358
|
+
.select(hydratedPostColumns)
|
|
4379
4359
|
.from(posts)
|
|
4380
4360
|
.where(and(...conditions))
|
|
4381
4361
|
.orderBy(desc(posts.publishedAt))
|
|
@@ -4435,40 +4415,62 @@ export function createPostService(
|
|
|
4435
4415
|
return { status: "ok", post: candidate };
|
|
4436
4416
|
},
|
|
4437
4417
|
|
|
4438
|
-
async getTranslationsMap(postIds) {
|
|
4418
|
+
async getTranslationsMap(postIds, reader) {
|
|
4439
4419
|
const result = new Map<string, Post[]>();
|
|
4440
4420
|
const uniqueIds = [...new Set(postIds)].filter(Boolean);
|
|
4441
4421
|
if (uniqueIds.length === 0) return result;
|
|
4442
4422
|
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
),
|
|
4423
|
+
// The members query finds the seeds' groups itself, through a
|
|
4424
|
+
// subquery, so it does not wait for the seeds to come back: both reads
|
|
4425
|
+
// go out together. The seeds are still read on their own, because the
|
|
4426
|
+
// reader's view may leave a seed out of the members, and its group is
|
|
4427
|
+
// what names its siblings. A sitemap shard asks about hundreds of
|
|
4428
|
+
// posts, past what one D1 statement may bind, hence the chunks.
|
|
4429
|
+
const seedConditions = (chunk: string[]) =>
|
|
4430
|
+
and(
|
|
4431
|
+
eq(posts.siteId, siteId),
|
|
4432
|
+
inArray(posts.id, chunk),
|
|
4433
|
+
isNotNull(posts.translationGroupId),
|
|
4452
4434
|
);
|
|
4435
|
+
const [seedRows, memberRows] = await Promise.all([
|
|
4436
|
+
batchQueryRows(uniqueIds, (chunk) =>
|
|
4437
|
+
db
|
|
4438
|
+
.select({
|
|
4439
|
+
id: posts.id,
|
|
4440
|
+
translationGroupId: posts.translationGroupId,
|
|
4441
|
+
})
|
|
4442
|
+
.from(posts)
|
|
4443
|
+
.where(seedConditions(chunk)),
|
|
4444
|
+
),
|
|
4445
|
+
batchQueryRows(uniqueIds, (chunk) =>
|
|
4446
|
+
db
|
|
4447
|
+
.select(hydratedPostColumns)
|
|
4448
|
+
.from(posts)
|
|
4449
|
+
.where(
|
|
4450
|
+
and(
|
|
4451
|
+
eq(posts.siteId, siteId),
|
|
4452
|
+
inArray(
|
|
4453
|
+
posts.translationGroupId,
|
|
4454
|
+
db
|
|
4455
|
+
.select({ groupId: posts.translationGroupId })
|
|
4456
|
+
.from(posts)
|
|
4457
|
+
.where(seedConditions(chunk)),
|
|
4458
|
+
),
|
|
4459
|
+
...(reader
|
|
4460
|
+
? buildReaderVisibilityConditions(posts, siteId, reader)
|
|
4461
|
+
: []),
|
|
4462
|
+
),
|
|
4463
|
+
),
|
|
4464
|
+
),
|
|
4465
|
+
]);
|
|
4453
4466
|
if (seedRows.length === 0) return result;
|
|
4454
4467
|
|
|
4455
|
-
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
),
|
|
4468
|
+
// Seeds of one group in two chunks bring its members back twice.
|
|
4469
|
+
const members = [
|
|
4470
|
+
...new Map(
|
|
4471
|
+
hydratePosts(memberRows).map((member) => [member.id, member]),
|
|
4472
|
+
).values(),
|
|
4461
4473
|
];
|
|
4462
|
-
const memberRows = await db
|
|
4463
|
-
.select()
|
|
4464
|
-
.from(posts)
|
|
4465
|
-
.where(
|
|
4466
|
-
and(
|
|
4467
|
-
eq(posts.siteId, siteId),
|
|
4468
|
-
inArray(posts.translationGroupId, groupIds),
|
|
4469
|
-
),
|
|
4470
|
-
);
|
|
4471
|
-
const members = await hydratePosts(memberRows);
|
|
4472
4474
|
const byGroup = new Map<string, Post[]>();
|
|
4473
4475
|
for (const member of members) {
|
|
4474
4476
|
const groupId = member.translationGroupId;
|
|
@@ -4667,14 +4669,14 @@ export function createPostService(
|
|
|
4667
4669
|
|
|
4668
4670
|
// A page of Threads can outgrow one statement's parameter budget — the
|
|
4669
4671
|
// API lists up to 100. Each Thread lands in one chunk, so every window
|
|
4670
|
-
// below still partitions over a whole Thread.
|
|
4672
|
+
// below still partitions over a whole Thread. The replies come back
|
|
4673
|
+
// whole, ranked and ready to hydrate, so the preview is one read.
|
|
4671
4674
|
const contextRows = await batchQueryRows(
|
|
4672
4675
|
[...new Set(rootIds)],
|
|
4673
4676
|
(chunk) => {
|
|
4674
4677
|
const rankedReplies = db
|
|
4675
4678
|
.select({
|
|
4676
|
-
|
|
4677
|
-
threadId: posts.threadId,
|
|
4679
|
+
...hydratedPostColumns,
|
|
4678
4680
|
firstReplyRank: sql<number>`CAST(ROW_NUMBER() OVER (
|
|
4679
4681
|
PARTITION BY ${posts.threadId}
|
|
4680
4682
|
ORDER BY ${sql.join(threadOrder(), sql`, `)}
|
|
@@ -4699,13 +4701,7 @@ export function createPostService(
|
|
|
4699
4701
|
.as("ranked_replies");
|
|
4700
4702
|
|
|
4701
4703
|
return db
|
|
4702
|
-
.select(
|
|
4703
|
-
threadId: rankedReplies.threadId,
|
|
4704
|
-
id: rankedReplies.id,
|
|
4705
|
-
firstReplyRank: rankedReplies.firstReplyRank,
|
|
4706
|
-
latestReplyRank: rankedReplies.latestReplyRank,
|
|
4707
|
-
totalReplyCount: rankedReplies.totalReplyCount,
|
|
4708
|
-
})
|
|
4704
|
+
.select()
|
|
4709
4705
|
.from(rankedReplies)
|
|
4710
4706
|
.where(
|
|
4711
4707
|
or(
|
|
@@ -4719,9 +4715,16 @@ export function createPostService(
|
|
|
4719
4715
|
},
|
|
4720
4716
|
);
|
|
4721
4717
|
|
|
4722
|
-
const hydratedPosts =
|
|
4723
|
-
|
|
4724
|
-
|
|
4718
|
+
const hydratedPosts = new Map<string, Post>();
|
|
4719
|
+
for (const {
|
|
4720
|
+
firstReplyRank: _first,
|
|
4721
|
+
latestReplyRank: _latest,
|
|
4722
|
+
totalReplyCount: _total,
|
|
4723
|
+
...row
|
|
4724
|
+
} of contextRows) {
|
|
4725
|
+
const post = hydratePost(row);
|
|
4726
|
+
if (post) hydratedPosts.set(post.id, post);
|
|
4727
|
+
}
|
|
4725
4728
|
|
|
4726
4729
|
const contextByThreadId = new Map<
|
|
4727
4730
|
string,
|
|
@@ -4865,33 +4868,35 @@ export function createPostService(
|
|
|
4865
4868
|
if (rootIds.length === 0) return result;
|
|
4866
4869
|
|
|
4867
4870
|
const uniqueRootIds = [...new Set(rootIds)];
|
|
4868
|
-
const
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4871
|
+
const inThreadOrder = () => sql`
|
|
4872
|
+
PARTITION BY ${posts.threadId}
|
|
4873
|
+
ORDER BY ${sql.join(threadOrder(), sql`, `)}
|
|
4874
|
+
`;
|
|
4875
|
+
const threadPosition = () =>
|
|
4876
|
+
sql<number>`CAST(
|
|
4877
|
+
row_number() OVER (${inThreadOrder()}) - 1 AS INTEGER
|
|
4878
|
+
)`.as("thread_position");
|
|
4879
|
+
const threadPostCount = () =>
|
|
4880
|
+
sql<number>`CAST(
|
|
4881
|
+
count(*) OVER (PARTITION BY ${posts.threadId}) AS INTEGER
|
|
4882
|
+
)`.as("thread_post_count");
|
|
4883
|
+
const inRequestedThreads = and(
|
|
4884
|
+
eq(posts.siteId, siteId),
|
|
4885
|
+
inArray(posts.threadId, uniqueRootIds),
|
|
4886
|
+
eq(posts.status, "published"),
|
|
4887
|
+
);
|
|
4877
4888
|
|
|
4889
|
+
// The Posts shown: the Root, every Featured Post, and the last Post.
|
|
4878
4890
|
const rankedPosts = db
|
|
4879
4891
|
.select({
|
|
4880
|
-
...
|
|
4881
|
-
threadPosition,
|
|
4882
|
-
threadPostCount,
|
|
4892
|
+
...hydratedPostColumns,
|
|
4893
|
+
threadPosition: threadPosition(),
|
|
4894
|
+
threadPostCount: threadPostCount(),
|
|
4883
4895
|
})
|
|
4884
4896
|
.from(posts)
|
|
4885
|
-
.where(
|
|
4886
|
-
and(
|
|
4887
|
-
eq(posts.siteId, siteId),
|
|
4888
|
-
inArray(posts.threadId, uniqueRootIds),
|
|
4889
|
-
eq(posts.status, "published"),
|
|
4890
|
-
),
|
|
4891
|
-
)
|
|
4897
|
+
.where(inRequestedThreads)
|
|
4892
4898
|
.as("ranked_featured_thread_post");
|
|
4893
|
-
|
|
4894
|
-
const rows = await db
|
|
4899
|
+
const shownQuery = db
|
|
4895
4900
|
.select()
|
|
4896
4901
|
.from(rankedPosts)
|
|
4897
4902
|
.where(
|
|
@@ -4903,14 +4908,61 @@ export function createPostService(
|
|
|
4903
4908
|
)
|
|
4904
4909
|
.orderBy(rankedPosts.threadId, sql`${rankedPosts.threadPosition}`);
|
|
4905
4910
|
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
|
|
4911
|
-
|
|
4911
|
+
// Where each gap points: the Post right after a shown one, when it is
|
|
4912
|
+
// hidden itself. Read beside the shown Posts rather than with them, and
|
|
4913
|
+
// only as far as its address, since nothing renders it.
|
|
4914
|
+
const gapCandidates = db
|
|
4915
|
+
.select({
|
|
4916
|
+
id: posts.id,
|
|
4917
|
+
threadId: posts.threadId,
|
|
4918
|
+
slug: hydratedPostColumns.slug,
|
|
4919
|
+
featuredAt: posts.featuredAt,
|
|
4920
|
+
threadPosition: threadPosition(),
|
|
4921
|
+
threadPostCount: threadPostCount(),
|
|
4922
|
+
previousPostId: sql<
|
|
4923
|
+
string | null
|
|
4924
|
+
>`LAG(${posts.id}) OVER (${inThreadOrder()})`.as("previous_post_id"),
|
|
4925
|
+
previousFeaturedAt: sql<
|
|
4926
|
+
number | null
|
|
4927
|
+
>`LAG(${posts.featuredAt}) OVER (${inThreadOrder()})`.as(
|
|
4928
|
+
"previous_featured_at",
|
|
4929
|
+
),
|
|
4930
|
+
})
|
|
4931
|
+
.from(posts)
|
|
4932
|
+
.where(inRequestedThreads)
|
|
4933
|
+
.as("featured_thread_gap_candidate");
|
|
4934
|
+
const gapQuery = db
|
|
4935
|
+
.select({
|
|
4936
|
+
id: gapCandidates.id,
|
|
4937
|
+
threadId: gapCandidates.threadId,
|
|
4938
|
+
slug: gapCandidates.slug,
|
|
4939
|
+
previousPostId: gapCandidates.previousPostId,
|
|
4940
|
+
})
|
|
4941
|
+
.from(gapCandidates)
|
|
4942
|
+
.where(
|
|
4943
|
+
and(
|
|
4944
|
+
// Hidden: not the Root, not Featured, not the last Post...
|
|
4945
|
+
ne(gapCandidates.id, gapCandidates.threadId),
|
|
4946
|
+
isNull(gapCandidates.featuredAt),
|
|
4947
|
+
sql`${gapCandidates.threadPosition} < ${gapCandidates.threadPostCount} - 1`,
|
|
4948
|
+
// ...right after a shown Post. Nothing follows the last one, so
|
|
4949
|
+
// that is the Root or a Featured Post.
|
|
4950
|
+
or(
|
|
4951
|
+
eq(gapCandidates.previousPostId, gapCandidates.threadId),
|
|
4952
|
+
isNotNull(gapCandidates.previousFeaturedAt),
|
|
4953
|
+
),
|
|
4954
|
+
),
|
|
4955
|
+
);
|
|
4956
|
+
|
|
4957
|
+
const [rows, gapRows] = await Promise.all([shownQuery, gapQuery]);
|
|
4958
|
+
|
|
4912
4959
|
const hydratedById = new Map(
|
|
4913
|
-
|
|
4960
|
+
hydratePosts(
|
|
4961
|
+
rows.map(
|
|
4962
|
+
({ threadPosition: _position, threadPostCount: _count, ...row }) =>
|
|
4963
|
+
row,
|
|
4964
|
+
),
|
|
4965
|
+
).map((post) => [post.id, post]),
|
|
4914
4966
|
);
|
|
4915
4967
|
|
|
4916
4968
|
for (const row of rows) {
|
|
@@ -4920,6 +4972,7 @@ export function createPostService(
|
|
|
4920
4972
|
const thread = result.get(row.threadId) ?? {
|
|
4921
4973
|
posts: [],
|
|
4922
4974
|
featuredPostIds: [],
|
|
4975
|
+
gapTargets: [],
|
|
4923
4976
|
};
|
|
4924
4977
|
thread.posts.push({ post, position: row.threadPosition });
|
|
4925
4978
|
if (row.featuredAt !== null) {
|
|
@@ -4928,6 +4981,16 @@ export function createPostService(
|
|
|
4928
4981
|
result.set(row.threadId, thread);
|
|
4929
4982
|
}
|
|
4930
4983
|
|
|
4984
|
+
for (const row of gapRows) {
|
|
4985
|
+
const thread = result.get(row.threadId);
|
|
4986
|
+
if (!row.slug || !thread || !row.previousPostId) continue;
|
|
4987
|
+
thread.gapTargets.push({
|
|
4988
|
+
id: row.id,
|
|
4989
|
+
slug: row.slug,
|
|
4990
|
+
afterPostId: row.previousPostId,
|
|
4991
|
+
});
|
|
4992
|
+
}
|
|
4993
|
+
|
|
4931
4994
|
return result;
|
|
4932
4995
|
},
|
|
4933
4996
|
|
|
@@ -5039,7 +5102,7 @@ export function createPostService(
|
|
|
5039
5102
|
const after = cursor
|
|
5040
5103
|
? buildListKeysetCondition(
|
|
5041
5104
|
keys,
|
|
5042
|
-
|
|
5105
|
+
resolveCollectionThreadCursor(cursor, sort),
|
|
5043
5106
|
)
|
|
5044
5107
|
: undefined;
|
|
5045
5108
|
|
|
@@ -5154,13 +5217,13 @@ export function createPostService(
|
|
|
5154
5217
|
);
|
|
5155
5218
|
}
|
|
5156
5219
|
return db
|
|
5157
|
-
.select()
|
|
5220
|
+
.select(hydratedPostColumns)
|
|
5158
5221
|
.from(posts)
|
|
5159
5222
|
.where(and(...conditions))
|
|
5160
5223
|
.orderBy(posts.threadId, ...threadOrder());
|
|
5161
5224
|
});
|
|
5162
5225
|
|
|
5163
|
-
for (const post of
|
|
5226
|
+
for (const post of hydratePosts(rows)) {
|
|
5164
5227
|
const thread = result.get(post.threadId);
|
|
5165
5228
|
if (thread) {
|
|
5166
5229
|
thread.push(post);
|
|
@@ -5200,19 +5263,16 @@ export function createPostService(
|
|
|
5200
5263
|
return result;
|
|
5201
5264
|
},
|
|
5202
5265
|
|
|
5203
|
-
async getDistinctYears(filters
|
|
5204
|
-
const
|
|
5205
|
-
|
|
5206
|
-
const publishedYearExpr = buildYearExpr(axis);
|
|
5266
|
+
async getDistinctYears(filters, timeZone) {
|
|
5267
|
+
const years = await calendarPeriodsOf(filters, "year", timeZone);
|
|
5268
|
+
if (!years) return [];
|
|
5207
5269
|
|
|
5208
5270
|
const rows = await db
|
|
5209
|
-
.select({
|
|
5210
|
-
year: publishedYearExpr.as("year"),
|
|
5211
|
-
})
|
|
5271
|
+
.select({ year: years.expr.as("year") })
|
|
5212
5272
|
.from(posts)
|
|
5213
|
-
.where(
|
|
5214
|
-
.groupBy(
|
|
5215
|
-
.orderBy(desc(
|
|
5273
|
+
.where(years.where)
|
|
5274
|
+
.groupBy(years.expr)
|
|
5275
|
+
.orderBy(desc(years.expr));
|
|
5216
5276
|
|
|
5217
5277
|
return rows.map((r) => parseInt(r.year, 10));
|
|
5218
5278
|
},
|