@jant/core 0.11.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/deploy.js +179 -0
- package/bin/lib/cloudflare-setup.js +499 -0
- package/bin/lib/d1-query.js +26 -1
- package/bin/lib/r2-query.js +2 -2
- package/dist/{app-jQI4OPRe.js → app-DSwsDBD0.js} +28623 -635
- package/dist/client/.vite/manifest.json +2 -2
- package/dist/client/_assets/{client-52vQhZAv.js → client-DPByjWoU.js} +1 -1
- package/dist/client/_assets/{client-auth-BDcCR6u1.js → client-auth-CPqPTX1B.js} +1 -1
- package/dist/index.js +1 -1
- package/dist/node.js +2 -2
- package/package.json +31 -31
- package/src/__tests__/bin/deploy.test.ts +163 -0
- package/src/__tests__/export-hugo-build.test.ts +5 -5
- package/src/__tests__/export-import-roundtrip.test.ts +1 -1
- package/src/__tests__/export-service.test.ts +2 -2
- 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/d1-round-trips.ts +213 -0
- package/src/__tests__/package-dependencies.test.ts +123 -0
- package/src/__tests__/public-page-round-trips.test.ts +203 -0
- package/src/__tests__/template-deploy-workflow.test.ts +33 -77
- package/src/__tests__/vite-config.test.ts +32 -0
- package/src/app.tsx +7 -1
- package/src/client/icons.ts +5 -6
- package/src/db/__tests__/d1-query.test.ts +29 -0
- package/src/db/__tests__/migration-rehearsal.test.ts +2 -2
- package/src/lib/__tests__/icons.test.ts +21 -10
- package/src/lib/api-posts.ts +4 -2
- package/src/lib/api-public-posts.ts +4 -2
- package/src/lib/constants.ts +20 -0
- package/src/lib/icons.ts +96 -34
- package/src/lib/post-display.ts +13 -9
- package/src/lib/timeline.ts +23 -21
- package/src/lib/view.ts +3 -2
- package/src/middleware/__tests__/onboarding.test.ts +5 -3
- package/src/middleware/__tests__/secure-headers.test.ts +40 -42
- package/src/middleware/config.ts +44 -2
- package/src/middleware/onboarding.ts +12 -3
- package/src/middleware/secure-headers.ts +25 -36
- package/src/node/__tests__/cli-deploy-setup.test.ts +373 -0
- package/src/node/__tests__/cli-deploy.test.ts +55 -0
- package/src/routes/feed/feed.ts +4 -2
- package/src/routes/pages/__tests__/post-page-round-trips.test.ts +10 -10
- package/src/routes/pages/archive.tsx +36 -17
- package/src/routes/pages/collection.tsx +72 -35
- package/src/routes/pages/page.tsx +46 -25
- package/src/routes/pages/search.tsx +3 -1
- package/src/services/__tests__/collection.test.ts +2 -4
- package/src/services/collection.ts +95 -71
- package/src/services/export.ts +2 -1
- package/src/services/post.ts +150 -205
- package/src/services/settings.ts +4 -8
- package/src/types/app-context.ts +5 -0
- package/src/ui/pages/ArchivePage.tsx +34 -34
- package/src/ui/pages/CollectionPage.tsx +1 -1
- package/src/ui/pages/SmartCollectionPage.tsx +2 -2
- package/src/ui/pages/SubscribePage.tsx +2 -4
- 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/custom-icons.ts +38 -7
- package/src/ui/shared/icon-collector.ts +7 -5
package/src/services/post.ts
CHANGED
|
@@ -1901,95 +1901,57 @@ export function createPostService(
|
|
|
1901
1901
|
}
|
|
1902
1902
|
|
|
1903
1903
|
/**
|
|
1904
|
-
*
|
|
1905
|
-
*
|
|
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).
|
|
1906
1907
|
*
|
|
1907
|
-
*
|
|
1908
|
-
*
|
|
1909
|
-
*
|
|
1910
|
-
* 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.
|
|
1911
1911
|
*
|
|
1912
|
-
*
|
|
1913
|
-
*
|
|
1914
|
-
*
|
|
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.
|
|
1915
1915
|
*/
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
}
|
|
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
|
+
};
|
|
1938
1937
|
|
|
1939
1938
|
/**
|
|
1940
|
-
*
|
|
1941
|
-
*
|
|
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.
|
|
1942
1943
|
*/
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
slugMap: Map<string, string>;
|
|
1947
|
-
visibilityMap: Map<string, Visibility>;
|
|
1948
|
-
}> {
|
|
1949
|
-
const { known, missingThreadIds } = seedThreadVisibility(rows);
|
|
1950
|
-
const [slugMap, fetched] = await Promise.all([
|
|
1951
|
-
resolvedPaths.getPostSlugMap(rows.map((row) => row.id)),
|
|
1952
|
-
missingThreadIds.length > 0
|
|
1953
|
-
? getThreadVisibilityMap(missingThreadIds)
|
|
1954
|
-
: Promise.resolve(new Map<string, Visibility>()),
|
|
1955
|
-
]);
|
|
1956
|
-
for (const [threadId, visibility] of fetched) {
|
|
1957
|
-
known.set(threadId, visibility);
|
|
1958
|
-
}
|
|
1959
|
-
return { slugMap, visibilityMap: known };
|
|
1960
|
-
}
|
|
1961
|
-
|
|
1962
|
-
async function hydratePost(
|
|
1963
|
-
row: typeof posts.$inferSelect | undefined,
|
|
1964
|
-
knownSlug?: string,
|
|
1965
|
-
): Promise<Post | null> {
|
|
1966
|
-
if (!row) return null;
|
|
1967
|
-
const { known, missingThreadIds } = seedThreadVisibility([row]);
|
|
1968
|
-
const [slug, fetched] = await Promise.all([
|
|
1969
|
-
knownSlug ?? resolvedPaths.getPostSlug(row.id),
|
|
1970
|
-
missingThreadIds.length > 0
|
|
1971
|
-
? getThreadVisibilityMap(missingThreadIds)
|
|
1972
|
-
: Promise.resolve(new Map<string, Visibility>()),
|
|
1973
|
-
]);
|
|
1974
|
-
if (!slug) return null;
|
|
1975
|
-
const visibility =
|
|
1976
|
-
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;
|
|
1977
1947
|
if (!visibility) return null;
|
|
1978
|
-
return toPost(row, slug, visibility);
|
|
1948
|
+
return toPost(row, row.slug, visibility);
|
|
1979
1949
|
}
|
|
1980
1950
|
|
|
1981
|
-
|
|
1982
|
-
rows: (typeof posts.$inferSelect)[],
|
|
1983
|
-
): Promise<Post[]> {
|
|
1984
|
-
if (rows.length === 0) return [];
|
|
1985
|
-
const { slugMap, visibilityMap } = await loadHydrationMaps(rows);
|
|
1951
|
+
function hydratePosts(rows: HydratedPostRow[]): Post[] {
|
|
1986
1952
|
return rows
|
|
1987
|
-
.map((row) =>
|
|
1988
|
-
|
|
1989
|
-
const visibility = visibilityMap.get(row.threadId) ?? row.visibility;
|
|
1990
|
-
return slug && visibility ? toPost(row, slug, visibility) : null;
|
|
1991
|
-
})
|
|
1992
|
-
.filter((row): row is Post => row !== null);
|
|
1953
|
+
.map((row) => hydratePost(row))
|
|
1954
|
+
.filter((post): post is Post => post !== null);
|
|
1993
1955
|
}
|
|
1994
1956
|
|
|
1995
1957
|
async function hydratePostsById(ids: string[]): Promise<Map<string, Post>> {
|
|
@@ -2002,7 +1964,7 @@ export function createPostService(
|
|
|
2002
1964
|
|
|
2003
1965
|
const rows = await batchQueryRows(uniqueIds, (chunk) =>
|
|
2004
1966
|
db
|
|
2005
|
-
.select()
|
|
1967
|
+
.select(hydratedPostColumns)
|
|
2006
1968
|
.from(posts)
|
|
2007
1969
|
.where(
|
|
2008
1970
|
and(
|
|
@@ -2013,36 +1975,13 @@ export function createPostService(
|
|
|
2013
1975
|
),
|
|
2014
1976
|
);
|
|
2015
1977
|
|
|
2016
|
-
for (const post of
|
|
1978
|
+
for (const post of hydratePosts(rows)) {
|
|
2017
1979
|
result.set(post.id, post);
|
|
2018
1980
|
}
|
|
2019
1981
|
|
|
2020
1982
|
return result;
|
|
2021
1983
|
}
|
|
2022
1984
|
|
|
2023
|
-
async function getThreadVisibilityMap(
|
|
2024
|
-
threadIds: string[],
|
|
2025
|
-
): Promise<Map<string, Visibility>> {
|
|
2026
|
-
const uniqueThreadIds = [...new Set(threadIds)];
|
|
2027
|
-
const result = new Map<string, Visibility>();
|
|
2028
|
-
if (uniqueThreadIds.length === 0) return result;
|
|
2029
|
-
|
|
2030
|
-
const rows = await batchQueryRows(uniqueThreadIds, (chunk) =>
|
|
2031
|
-
db
|
|
2032
|
-
.select({ id: posts.id, visibility: posts.visibility })
|
|
2033
|
-
.from(posts)
|
|
2034
|
-
.where(and(eq(posts.siteId, siteId), inArray(posts.id, chunk))),
|
|
2035
|
-
);
|
|
2036
|
-
|
|
2037
|
-
for (const row of rows) {
|
|
2038
|
-
if (row.visibility) {
|
|
2039
|
-
result.set(row.id, ensurePostVisibility(row.visibility, Error));
|
|
2040
|
-
}
|
|
2041
|
-
}
|
|
2042
|
-
|
|
2043
|
-
return result;
|
|
2044
|
-
}
|
|
2045
|
-
|
|
2046
1985
|
function buildThreadRootPageConditions(options?: ThreadRootPageOptions) {
|
|
2047
1986
|
const conditions: SQL[] = [
|
|
2048
1987
|
eq(posts.siteId, siteId),
|
|
@@ -2392,7 +2331,7 @@ export function createPostService(
|
|
|
2392
2331
|
return {
|
|
2393
2332
|
async getById(id) {
|
|
2394
2333
|
const result = await db
|
|
2395
|
-
.select()
|
|
2334
|
+
.select(hydratedPostColumns)
|
|
2396
2335
|
.from(posts)
|
|
2397
2336
|
.where(and(eq(posts.siteId, siteId), eq(posts.id, id)))
|
|
2398
2337
|
.limit(1);
|
|
@@ -2400,45 +2339,36 @@ export function createPostService(
|
|
|
2400
2339
|
},
|
|
2401
2340
|
|
|
2402
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.
|
|
2403
2346
|
const rows = await db
|
|
2404
|
-
.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
|
+
})
|
|
2405
2359
|
.from(posts)
|
|
2406
|
-
.leftJoin(
|
|
2407
|
-
pathRegistry,
|
|
2408
|
-
and(
|
|
2409
|
-
eq(pathRegistry.siteId, siteId),
|
|
2410
|
-
eq(pathRegistry.postId, posts.id),
|
|
2411
|
-
),
|
|
2412
|
-
)
|
|
2413
2360
|
.where(and(eq(posts.siteId, siteId), eq(posts.id, postId)))
|
|
2414
|
-
.
|
|
2361
|
+
.limit(1);
|
|
2415
2362
|
|
|
2416
2363
|
const row = rows[0];
|
|
2417
|
-
if (!row) return null;
|
|
2418
|
-
|
|
2419
|
-
let slug: string | null = null;
|
|
2420
|
-
let canonicalAlias: string | null = null;
|
|
2421
|
-
for (const { path } of rows) {
|
|
2422
|
-
if (!path) continue;
|
|
2423
|
-
if (path.kind === "slug") {
|
|
2424
|
-
slug = path.path;
|
|
2425
|
-
continue;
|
|
2426
|
-
}
|
|
2427
|
-
// Rows arrive oldest first, and the oldest alias is the post's
|
|
2428
|
-
// address, as feeds, the sitemap, and the export name it: a second
|
|
2429
|
-
// custom URL is another way in, not a new identity. Ties within a
|
|
2430
|
-
// second fall to the lower id, not to the storage engine's order.
|
|
2431
|
-
if (path.kind === "alias" && canonicalAlias === null) {
|
|
2432
|
-
canonicalAlias = `/${path.path}`;
|
|
2433
|
-
}
|
|
2434
|
-
}
|
|
2435
|
-
|
|
2436
2364
|
// A Post with no slug row has no address, which is what `hydratePost`
|
|
2437
2365
|
// says by returning null for it.
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2366
|
+
const post = hydratePost(row);
|
|
2367
|
+
if (!row || !post) return null;
|
|
2368
|
+
return {
|
|
2369
|
+
post,
|
|
2370
|
+
canonicalAlias: row.canonicalAlias ? `/${row.canonicalAlias}` : null,
|
|
2371
|
+
};
|
|
2442
2372
|
},
|
|
2443
2373
|
|
|
2444
2374
|
async getBySlug(slug) {
|
|
@@ -2447,13 +2377,11 @@ export function createPostService(
|
|
|
2447
2377
|
return null;
|
|
2448
2378
|
}
|
|
2449
2379
|
const result = await db
|
|
2450
|
-
.select()
|
|
2380
|
+
.select(hydratedPostColumns)
|
|
2451
2381
|
.from(posts)
|
|
2452
2382
|
.where(and(eq(posts.siteId, siteId), eq(posts.id, resolved.postId)))
|
|
2453
2383
|
.limit(1);
|
|
2454
|
-
|
|
2455
|
-
// back for it.
|
|
2456
|
-
return hydratePost(result[0], resolved.path);
|
|
2384
|
+
return hydratePost(result[0]);
|
|
2457
2385
|
},
|
|
2458
2386
|
|
|
2459
2387
|
async suggestSlug(input) {
|
|
@@ -2483,7 +2411,7 @@ export function createPostService(
|
|
|
2483
2411
|
const conditions = buildFilterConditions(filters);
|
|
2484
2412
|
|
|
2485
2413
|
let query = db
|
|
2486
|
-
.select()
|
|
2414
|
+
.select(hydratedPostColumns)
|
|
2487
2415
|
.from(posts)
|
|
2488
2416
|
.where(conditions.length > 0 ? and(...conditions) : undefined)
|
|
2489
2417
|
.orderBy(...listOrderBy(keys))
|
|
@@ -2512,7 +2440,7 @@ export function createPostService(
|
|
|
2512
2440
|
// One row past the page says whether another page exists, so the last
|
|
2513
2441
|
// page carries a null cursor rather than one that leads to an empty page.
|
|
2514
2442
|
const rows = await db
|
|
2515
|
-
.select({ post:
|
|
2443
|
+
.select({ post: hydratedPostColumns, sortKey: listSortKeyFields(keys) })
|
|
2516
2444
|
.from(posts)
|
|
2517
2445
|
.where(conditions.length > 0 ? and(...conditions) : undefined)
|
|
2518
2446
|
.orderBy(...listOrderBy(keys))
|
|
@@ -2532,7 +2460,7 @@ export function createPostService(
|
|
|
2532
2460
|
: null;
|
|
2533
2461
|
|
|
2534
2462
|
return {
|
|
2535
|
-
posts:
|
|
2463
|
+
posts: hydratePosts(pageRows.map((row) => row.post)),
|
|
2536
2464
|
nextCursor,
|
|
2537
2465
|
};
|
|
2538
2466
|
},
|
|
@@ -3603,9 +3531,10 @@ export function createPostService(
|
|
|
3603
3531
|
.returning();
|
|
3604
3532
|
if (needsThreadActivityRecalc) {
|
|
3605
3533
|
await recalculateThreadActivity(existing.threadId);
|
|
3606
|
-
return this.getById(id);
|
|
3607
3534
|
}
|
|
3608
|
-
|
|
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;
|
|
3609
3538
|
}
|
|
3610
3539
|
|
|
3611
3540
|
// Complex case: cascade + update + Thread collection sync atomically.
|
|
@@ -3837,9 +3766,8 @@ export function createPostService(
|
|
|
3837
3766
|
|
|
3838
3767
|
if (needsThreadActivityRecalc) {
|
|
3839
3768
|
await recalculateThreadActivity(existing.threadId);
|
|
3840
|
-
return this.getById(id);
|
|
3841
3769
|
}
|
|
3842
|
-
return
|
|
3770
|
+
return updateResult?.[0] ? this.getById(id) : null;
|
|
3843
3771
|
},
|
|
3844
3772
|
|
|
3845
3773
|
async updateWithAttachments(id, data, attachments, deps, summaryConfig) {
|
|
@@ -4069,7 +3997,7 @@ export function createPostService(
|
|
|
4069
3997
|
|
|
4070
3998
|
async getThread(rootId) {
|
|
4071
3999
|
const rows = await db
|
|
4072
|
-
.select()
|
|
4000
|
+
.select(hydratedPostColumns)
|
|
4073
4001
|
.from(posts)
|
|
4074
4002
|
.where(and(eq(posts.siteId, siteId), eq(posts.threadId, rootId)))
|
|
4075
4003
|
.orderBy(...threadOrder());
|
|
@@ -4094,7 +4022,7 @@ export function createPostService(
|
|
|
4094
4022
|
}
|
|
4095
4023
|
|
|
4096
4024
|
const rows = await db
|
|
4097
|
-
.select({ post:
|
|
4025
|
+
.select({ post: hydratedPostColumns, sortKey: listSortKeyFields(keys) })
|
|
4098
4026
|
.from(posts)
|
|
4099
4027
|
.where(and(...conditions))
|
|
4100
4028
|
.orderBy(...listOrderBy(keys))
|
|
@@ -4103,7 +4031,7 @@ export function createPostService(
|
|
|
4103
4031
|
const pageRows = rows.slice(0, limit);
|
|
4104
4032
|
const lastRow = pageRows[pageRows.length - 1];
|
|
4105
4033
|
return {
|
|
4106
|
-
posts:
|
|
4034
|
+
posts: hydratePosts(pageRows.map((row) => row.post)),
|
|
4107
4035
|
nextCursor:
|
|
4108
4036
|
rows.length > limit && lastRow
|
|
4109
4037
|
? encodePostListCursor(
|
|
@@ -4427,7 +4355,7 @@ export function createPostService(
|
|
|
4427
4355
|
}
|
|
4428
4356
|
|
|
4429
4357
|
const rows = await db
|
|
4430
|
-
.select()
|
|
4358
|
+
.select(hydratedPostColumns)
|
|
4431
4359
|
.from(posts)
|
|
4432
4360
|
.where(and(...conditions))
|
|
4433
4361
|
.orderBy(desc(posts.publishedAt))
|
|
@@ -4492,38 +4420,57 @@ export function createPostService(
|
|
|
4492
4420
|
const uniqueIds = [...new Set(postIds)].filter(Boolean);
|
|
4493
4421
|
if (uniqueIds.length === 0) return result;
|
|
4494
4422
|
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
),
|
|
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),
|
|
4504
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
|
+
]);
|
|
4505
4466
|
if (seedRows.length === 0) return result;
|
|
4506
4467
|
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
),
|
|
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(),
|
|
4513
4473
|
];
|
|
4514
|
-
const memberRows = await db
|
|
4515
|
-
.select()
|
|
4516
|
-
.from(posts)
|
|
4517
|
-
.where(
|
|
4518
|
-
and(
|
|
4519
|
-
eq(posts.siteId, siteId),
|
|
4520
|
-
inArray(posts.translationGroupId, groupIds),
|
|
4521
|
-
...(reader
|
|
4522
|
-
? buildReaderVisibilityConditions(posts, siteId, reader)
|
|
4523
|
-
: []),
|
|
4524
|
-
),
|
|
4525
|
-
);
|
|
4526
|
-
const members = await hydratePosts(memberRows);
|
|
4527
4474
|
const byGroup = new Map<string, Post[]>();
|
|
4528
4475
|
for (const member of members) {
|
|
4529
4476
|
const groupId = member.translationGroupId;
|
|
@@ -4722,14 +4669,14 @@ export function createPostService(
|
|
|
4722
4669
|
|
|
4723
4670
|
// A page of Threads can outgrow one statement's parameter budget — the
|
|
4724
4671
|
// API lists up to 100. Each Thread lands in one chunk, so every window
|
|
4725
|
-
// 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.
|
|
4726
4674
|
const contextRows = await batchQueryRows(
|
|
4727
4675
|
[...new Set(rootIds)],
|
|
4728
4676
|
(chunk) => {
|
|
4729
4677
|
const rankedReplies = db
|
|
4730
4678
|
.select({
|
|
4731
|
-
|
|
4732
|
-
threadId: posts.threadId,
|
|
4679
|
+
...hydratedPostColumns,
|
|
4733
4680
|
firstReplyRank: sql<number>`CAST(ROW_NUMBER() OVER (
|
|
4734
4681
|
PARTITION BY ${posts.threadId}
|
|
4735
4682
|
ORDER BY ${sql.join(threadOrder(), sql`, `)}
|
|
@@ -4754,13 +4701,7 @@ export function createPostService(
|
|
|
4754
4701
|
.as("ranked_replies");
|
|
4755
4702
|
|
|
4756
4703
|
return db
|
|
4757
|
-
.select(
|
|
4758
|
-
threadId: rankedReplies.threadId,
|
|
4759
|
-
id: rankedReplies.id,
|
|
4760
|
-
firstReplyRank: rankedReplies.firstReplyRank,
|
|
4761
|
-
latestReplyRank: rankedReplies.latestReplyRank,
|
|
4762
|
-
totalReplyCount: rankedReplies.totalReplyCount,
|
|
4763
|
-
})
|
|
4704
|
+
.select()
|
|
4764
4705
|
.from(rankedReplies)
|
|
4765
4706
|
.where(
|
|
4766
4707
|
or(
|
|
@@ -4774,9 +4715,16 @@ export function createPostService(
|
|
|
4774
4715
|
},
|
|
4775
4716
|
);
|
|
4776
4717
|
|
|
4777
|
-
const hydratedPosts =
|
|
4778
|
-
|
|
4779
|
-
|
|
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
|
+
}
|
|
4780
4728
|
|
|
4781
4729
|
const contextByThreadId = new Map<
|
|
4782
4730
|
string,
|
|
@@ -4941,7 +4889,7 @@ export function createPostService(
|
|
|
4941
4889
|
// The Posts shown: the Root, every Featured Post, and the last Post.
|
|
4942
4890
|
const rankedPosts = db
|
|
4943
4891
|
.select({
|
|
4944
|
-
...
|
|
4892
|
+
...hydratedPostColumns,
|
|
4945
4893
|
threadPosition: threadPosition(),
|
|
4946
4894
|
threadPostCount: threadPostCount(),
|
|
4947
4895
|
})
|
|
@@ -4967,6 +4915,7 @@ export function createPostService(
|
|
|
4967
4915
|
.select({
|
|
4968
4916
|
id: posts.id,
|
|
4969
4917
|
threadId: posts.threadId,
|
|
4918
|
+
slug: hydratedPostColumns.slug,
|
|
4970
4919
|
featuredAt: posts.featuredAt,
|
|
4971
4920
|
threadPosition: threadPosition(),
|
|
4972
4921
|
threadPostCount: threadPostCount(),
|
|
@@ -4986,6 +4935,7 @@ export function createPostService(
|
|
|
4986
4935
|
.select({
|
|
4987
4936
|
id: gapCandidates.id,
|
|
4988
4937
|
threadId: gapCandidates.threadId,
|
|
4938
|
+
slug: gapCandidates.slug,
|
|
4989
4939
|
previousPostId: gapCandidates.previousPostId,
|
|
4990
4940
|
})
|
|
4991
4941
|
.from(gapCandidates)
|
|
@@ -5006,17 +4956,13 @@ export function createPostService(
|
|
|
5006
4956
|
|
|
5007
4957
|
const [rows, gapRows] = await Promise.all([shownQuery, gapQuery]);
|
|
5008
4958
|
|
|
5009
|
-
const
|
|
4959
|
+
const hydratedById = new Map(
|
|
5010
4960
|
hydratePosts(
|
|
5011
4961
|
rows.map(
|
|
5012
4962
|
({ threadPosition: _position, threadPostCount: _count, ...row }) =>
|
|
5013
4963
|
row,
|
|
5014
4964
|
),
|
|
5015
|
-
),
|
|
5016
|
-
resolvedPaths.getPostSlugMap(gapRows.map((row) => row.id)),
|
|
5017
|
-
]);
|
|
5018
|
-
const hydratedById = new Map(
|
|
5019
|
-
hydratedPosts.map((post) => [post.id, post]),
|
|
4965
|
+
).map((post) => [post.id, post]),
|
|
5020
4966
|
);
|
|
5021
4967
|
|
|
5022
4968
|
for (const row of rows) {
|
|
@@ -5036,12 +4982,11 @@ export function createPostService(
|
|
|
5036
4982
|
}
|
|
5037
4983
|
|
|
5038
4984
|
for (const row of gapRows) {
|
|
5039
|
-
const slug = gapSlugs.get(row.id);
|
|
5040
4985
|
const thread = result.get(row.threadId);
|
|
5041
|
-
if (!slug || !thread || !row.previousPostId) continue;
|
|
4986
|
+
if (!row.slug || !thread || !row.previousPostId) continue;
|
|
5042
4987
|
thread.gapTargets.push({
|
|
5043
4988
|
id: row.id,
|
|
5044
|
-
slug,
|
|
4989
|
+
slug: row.slug,
|
|
5045
4990
|
afterPostId: row.previousPostId,
|
|
5046
4991
|
});
|
|
5047
4992
|
}
|
|
@@ -5272,13 +5217,13 @@ export function createPostService(
|
|
|
5272
5217
|
);
|
|
5273
5218
|
}
|
|
5274
5219
|
return db
|
|
5275
|
-
.select()
|
|
5220
|
+
.select(hydratedPostColumns)
|
|
5276
5221
|
.from(posts)
|
|
5277
5222
|
.where(and(...conditions))
|
|
5278
5223
|
.orderBy(posts.threadId, ...threadOrder());
|
|
5279
5224
|
});
|
|
5280
5225
|
|
|
5281
|
-
for (const post of
|
|
5226
|
+
for (const post of hydratePosts(rows)) {
|
|
5282
5227
|
const thread = result.get(post.threadId);
|
|
5283
5228
|
if (thread) {
|
|
5284
5229
|
thread.push(post);
|
package/src/services/settings.ts
CHANGED
|
@@ -15,6 +15,7 @@ import { now } from "../lib/time.js";
|
|
|
15
15
|
import {
|
|
16
16
|
SETTINGS_KEYS,
|
|
17
17
|
ONBOARDING_STATUS,
|
|
18
|
+
parseOnboardingStatus,
|
|
18
19
|
type OnboardingStatus,
|
|
19
20
|
type SettingsKey,
|
|
20
21
|
} from "../lib/constants.js";
|
|
@@ -368,14 +369,9 @@ export function createSettingsService(
|
|
|
368
369
|
},
|
|
369
370
|
|
|
370
371
|
async getOnboardingStatus() {
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
}
|
|
375
|
-
if (status === ONBOARDING_STATUS.PROVISIONED) {
|
|
376
|
-
return ONBOARDING_STATUS.PROVISIONED;
|
|
377
|
-
}
|
|
378
|
-
return ONBOARDING_STATUS.PENDING;
|
|
372
|
+
return parseOnboardingStatus(
|
|
373
|
+
await this.get(SETTINGS_KEYS.ONBOARDING_STATUS),
|
|
374
|
+
);
|
|
379
375
|
},
|
|
380
376
|
|
|
381
377
|
async isOnboardingComplete() {
|
package/src/types/app-context.ts
CHANGED
|
@@ -37,6 +37,11 @@ export interface AppVariables {
|
|
|
37
37
|
currentSiteDomain: SiteDomain | null;
|
|
38
38
|
appConfig: AppConfig;
|
|
39
39
|
allSettings: Record<string, string>;
|
|
40
|
+
/**
|
|
41
|
+
* The settings read in flight for this request, shared through
|
|
42
|
+
* `loadRequestSettings()` so the middleware that need them read once.
|
|
43
|
+
*/
|
|
44
|
+
settingsLoad?: Promise<Record<string, string>>;
|
|
40
45
|
themeStyle: string;
|
|
41
46
|
storage: StorageDriver | null;
|
|
42
47
|
publicRequestUrl: string;
|