@jant/core 0.7.1 → 0.8.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/assets/prepare.js +3 -3
- package/bin/commands/db/export.js +115 -2
- package/bin/commands/deploy.js +11 -3
- package/bin/commands/{search-reindex.js → search/reindex.js} +5 -5
- package/bin/commands/site/export.js +48 -36
- package/bin/commands/site/import.js +3074 -2
- package/bin/commands/site/snapshot/import.js +2 -0
- package/bin/commands/telegram/register-webhooks.js +48 -23
- package/bin/jant.js +16 -11
- package/bin/lib/command-registry.js +120 -0
- package/bin/lib/migration-artifacts.js +19 -0
- package/bin/lib/renamed-arguments.js +56 -0
- package/bin/lib/site-snapshot.js +83 -1
- package/dist/{app-ZcaI1kPN.js → app-CFsmRVJN.js} +7916 -499
- package/dist/client/.vite/manifest.json +3 -3
- package/dist/client/_assets/{client-DAhoqPdr.css → client-BCumu1-D.css} +1 -1
- package/dist/client/_assets/{client-knSEyUJO.js → client-DTLBOHqD.js} +1 -1
- package/dist/client/_assets/{client-auth-CAMfTrKW.js → client-auth-D6Ix6SmE.js} +1 -1
- package/dist/index.js +2 -3
- package/dist/node.js +2 -3
- package/dist/url-CKlGzvdN.js +428 -0
- package/package.json +1 -5
- package/src/__tests__/cli-commands.test.ts +144 -0
- package/src/__tests__/config-docs.test.ts +148 -0
- package/src/__tests__/export-import-roundtrip.test.ts +1 -1
- package/src/__tests__/feed-docs.test.ts +36 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/README.md +89 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/41q27/0x4nv/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/41q27/_index.md +41 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/41q27/faqyt/index.md +28 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/41q27/the-potting-mix-guide-i-keep-rereading/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/_index.md +4 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/a-night-heron-field-guide-for-my-walk-folder/_index.md +27 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/a-quiet-saturday-after-a-busy-week/_index.md +32 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/archive/_index.md +7 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/are-na-is-the-only-bookmark-pile-i-still-revisit/_index.md +27 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/bought-too-many-lemons-again/_index.md +34 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/city-walks/_index.md +11 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/collections/_index.md +4 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/current-tea-rotation/_index.md +31 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/derek-sivers-still-writes-the-kind-of-internet-i-want-more-of/_index.md +27 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/desk-but-better/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/e0kcg/_index.md +19 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/featured/_index.md +7 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/from-basho/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/from-epictetus/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/from-marcus-aurelius/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/from-seneca/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/from-thoreau/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/gkbvv/2cl6d/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/gkbvv/3zqv7/index.md +28 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/gkbvv/5oxsv/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/gkbvv/_index.md +36 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/home-cooking/_index.md +11 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/k5vh8/_index.md +29 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/k5vh8/a-reading-log-idea-i-might-steal/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/k5vh8/a83qu/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/k5vh8/from-seneca-5hibo/index.md +19 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/mynoise-for-rainy-afternoons/_index.md +27 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/nts-archives-are-good-cleaning-music/_index.md +27 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/qgfcu/_index.md +29 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/qgfcu/c91j0/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/qgfcu/qyucy/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/qgfcu/wsgck/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/rain-makes-my-neighborhood-look-better/_index.md +43 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/reading-notes/_index.md +11 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/serious-eats-on-tomato-and-egg-soup/_index.md +27 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/te812/_index.md +41 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/te812/cxiu6/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/te812/t77ms/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/te812/the-soup-trick-i-always-forget/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/telk3/_index.md +27 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/telk3/from-thoreau-pawt2/index.md +17 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/the-five-minute-reset-is-still-the-best-habit-i-have/_index.md +32 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/the-hallway-light-took-12-minutes-and-3-months/_index.md +29 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/the-recurse-center-manual-is-weirdly-calming/_index.md +27 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/tiny-projects/_index.md +11 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/useful-links/_index.md +11 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/weekend-notes/_index.md +11 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/content/what-i-actually-use-my-notebook-for/_index.md +49 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/data/jant.toml +119 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/hugo.toml +43 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/static/media/021801c20ab3-med_01kn8jw26cenf98vc7k0ppz5k8.webp +0 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/static/media/0f868ce9ac84-med_01kn8jtx8qenf98tm9ahxr48sw.webp +0 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/static/media/50c2ad911bad-med_01kn8jvb16enf98txp7p0pf5ge.webp +0 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/static/media/7a91f0960491-med_01kn8jvq58enf98v538w5vsqp4.webp +0 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/static/media/8714116d3c8e-med_01kn8jve5nenf98tzap11gpxzr.webp +0 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/static/media/8a0b4277443f-med_01kn8jv0jdenf98tp6qr9zgjjc.webp +0 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/static/media/a7d1c8a1afd9-med_01kn8jv452enf98trbkwrvhvgd.webp +0 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/static/media/e25570b405f5-med_01kn8jvsaeenf98v6ct4gjzppc.webp +0 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/static/media/e89ea4eabf01-med_01kn8jtq3penf98tfq4gzmh9g9.png +0 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/themes/jant/static/apple-touch-icon.png +0 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/themes/jant/static/custom.css +0 -0
- package/src/__tests__/fixtures/releases/0.7.0/site-export/themes/jant/static/favicon.ico +0 -0
- package/src/__tests__/fixtures/releases/0.7.0/snapshot/db.sql +218 -0
- package/src/__tests__/fixtures/releases/0.7.0/snapshot/meta.json +9 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/README.md +89 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/41q27/0x4nv/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/41q27/_index.md +41 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/41q27/faqyt/index.md +28 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/41q27/the-potting-mix-guide-i-keep-rereading/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/_index.md +4 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/a-night-heron-field-guide-for-my-walk-folder/_index.md +27 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/a-quiet-saturday-after-a-busy-week/_index.md +32 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/archive/_index.md +7 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/are-na-is-the-only-bookmark-pile-i-still-revisit/_index.md +27 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/bought-too-many-lemons-again/_index.md +34 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/city-walks/_index.md +11 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/collections/_index.md +4 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/current-tea-rotation/_index.md +31 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/derek-sivers-still-writes-the-kind-of-internet-i-want-more-of/_index.md +27 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/desk-but-better/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/e0kcg/_index.md +19 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/featured/_index.md +7 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/from-basho/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/from-epictetus/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/from-marcus-aurelius/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/from-seneca/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/from-thoreau/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/gkbvv/2cl6d/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/gkbvv/3zqv7/index.md +28 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/gkbvv/5oxsv/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/gkbvv/_index.md +36 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/home-cooking/_index.md +11 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/k5vh8/_index.md +29 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/k5vh8/a-reading-log-idea-i-might-steal/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/k5vh8/a83qu/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/k5vh8/from-seneca-5hibo/index.md +19 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/mynoise-for-rainy-afternoons/_index.md +27 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/nts-archives-are-good-cleaning-music/_index.md +27 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/qgfcu/_index.md +29 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/qgfcu/c91j0/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/qgfcu/qyucy/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/qgfcu/wsgck/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/rain-makes-my-neighborhood-look-better/_index.md +43 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/reading-notes/_index.md +11 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/serious-eats-on-tomato-and-egg-soup/_index.md +27 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/te812/_index.md +41 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/te812/cxiu6/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/te812/t77ms/index.md +16 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/te812/the-soup-trick-i-always-forget/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/telk3/_index.md +27 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/telk3/from-thoreau-pawt2/index.md +17 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/the-five-minute-reset-is-still-the-best-habit-i-have/_index.md +32 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/the-hallway-light-took-12-minutes-and-3-months/_index.md +29 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/the-recurse-center-manual-is-weirdly-calming/_index.md +27 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/tiny-projects/_index.md +11 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/useful-links/_index.md +11 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/weekend-notes/_index.md +11 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/content/what-i-actually-use-my-notebook-for/_index.md +49 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/data/jant.toml +119 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/hugo.toml +43 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/static/media/021801c20ab3-med_01kn8jw26cenf98vc7k0ppz5k8.webp +0 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/static/media/0f868ce9ac84-med_01kn8jtx8qenf98tm9ahxr48sw.webp +0 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/static/media/50c2ad911bad-med_01kn8jvb16enf98txp7p0pf5ge.webp +0 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/static/media/7a91f0960491-med_01kn8jvq58enf98v538w5vsqp4.webp +0 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/static/media/8714116d3c8e-med_01kn8jve5nenf98tzap11gpxzr.webp +0 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/static/media/8a0b4277443f-med_01kn8jv0jdenf98tp6qr9zgjjc.webp +0 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/static/media/a7d1c8a1afd9-med_01kn8jv452enf98trbkwrvhvgd.webp +0 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/static/media/e25570b405f5-med_01kn8jvsaeenf98v6ct4gjzppc.webp +0 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/static/media/e89ea4eabf01-med_01kn8jtq3penf98tfq4gzmh9g9.png +0 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/themes/jant/static/apple-touch-icon.png +0 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/themes/jant/static/custom.css +0 -0
- package/src/__tests__/fixtures/releases/0.7.1/site-export/themes/jant/static/favicon.ico +0 -0
- package/src/__tests__/fixtures/releases/0.7.1/snapshot/db.sql +322 -0
- package/src/__tests__/fixtures/releases/0.7.1/snapshot/meta.json +9 -0
- package/src/__tests__/helpers/site-export-import.ts +97 -0
- package/src/__tests__/import-site-command.test.ts +27 -1
- package/src/__tests__/release-fixtures.test.ts +132 -0
- package/src/__tests__/site-export-canonical-import.test.ts +11 -47
- package/src/__tests__/theme-docs.test.ts +109 -0
- package/src/app.tsx +1 -5
- package/src/db/rehearsal-fixtures/pg-demo-current.json +55 -0
- package/src/db/rehearsal-fixtures/pg-demo-current.sql +431 -0
- package/src/i18n/locales/public/en.po +0 -2
- package/src/i18n/locales/public/zh-Hans.po +0 -2
- package/src/i18n/locales/public/zh-Hant.po +0 -2
- package/src/index.ts +6 -77
- package/src/lib/__tests__/view.test.ts +0 -46
- package/src/lib/feed.ts +0 -6
- package/src/lib/view.ts +0 -27
- package/src/node/__tests__/cli-export.test.ts +2 -2
- package/src/node/__tests__/cli-site-snapshot.test.ts +6 -0
- package/src/node/__tests__/cli-site-token-env.test.ts +4 -1
- package/src/node/__tests__/cli-snapshot-meta.test.ts +64 -0
- package/src/routes/api/internal/search-reindex.ts +1 -1
- package/src/services/__tests__/media.test.ts +0 -271
- package/src/services/export.ts +13 -5
- package/src/services/media.ts +1 -219
- package/src/styles/ui.css +0 -118
- package/bin/commands/export.js +0 -120
- package/bin/commands/import-site.js +0 -3034
- package/bin/commands/migrate-text-attachments.js +0 -181
- package/dist/github-sync-Gw4orAHk.js +0 -8398
- package/src/client/multipart-upload.ts +0 -206
- package/src/routes/api/__tests__/upload-multipart.test.ts +0 -739
- package/src/routes/api/internal/text-attachments.ts +0 -60
- package/src/routes/api/upload-multipart.ts +0 -366
|
@@ -2566,8 +2566,6 @@ msgid "This site publishes Atom feeds. Copy one of these addresses into a feed r
|
|
|
2566
2566
|
msgstr "This site publishes Atom feeds. Copy one of these addresses into a feed reader."
|
|
2567
2567
|
|
|
2568
2568
|
#. @context: Error shown when a hosted upload would exceed the shared account media limit
|
|
2569
|
-
#. @context: Error shown when a hosted upload would exceed the shared account media limit
|
|
2570
|
-
#: src/routes/api/upload-multipart.ts
|
|
2571
2569
|
#: src/routes/api/upload.ts
|
|
2572
2570
|
msgid "This upload would exceed your shared hosted media limit. Remove files or upgrade storage to continue."
|
|
2573
2571
|
msgstr "This upload would exceed your shared hosted media limit. Remove files or upgrade storage to continue."
|
|
@@ -2563,8 +2563,6 @@ msgid "This site publishes Atom feeds. Copy one of these addresses into a feed r
|
|
|
2563
2563
|
msgstr ""
|
|
2564
2564
|
|
|
2565
2565
|
#. @context: Error shown when a hosted upload would exceed the shared account media limit
|
|
2566
|
-
#. @context: Error shown when a hosted upload would exceed the shared account media limit
|
|
2567
|
-
#: src/routes/api/upload-multipart.ts
|
|
2568
2566
|
#: src/routes/api/upload.ts
|
|
2569
2567
|
msgid "This upload would exceed your shared hosted media limit. Remove files or upgrade storage to continue."
|
|
2570
2568
|
msgstr ""
|
|
@@ -2563,8 +2563,6 @@ msgid "This site publishes Atom feeds. Copy one of these addresses into a feed r
|
|
|
2563
2563
|
msgstr ""
|
|
2564
2564
|
|
|
2565
2565
|
#. @context: Error shown when a hosted upload would exceed the shared account media limit
|
|
2566
|
-
#. @context: Error shown when a hosted upload would exceed the shared account media limit
|
|
2567
|
-
#: src/routes/api/upload-multipart.ts
|
|
2568
2566
|
#: src/routes/api/upload.ts
|
|
2569
2567
|
msgid "This upload would exceed your shared hosted media limit. Remove files or upgrade storage to continue."
|
|
2570
2568
|
msgstr ""
|
package/src/index.ts
CHANGED
|
@@ -1,84 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Jant - A microblog system
|
|
3
3
|
*
|
|
4
|
+
* The public JavaScript API is `createApp`. A site's entry point is
|
|
5
|
+
* `export default createApp();`, and every setting comes from the
|
|
6
|
+
* environment. Everything else under `src/` is internal and can change in
|
|
7
|
+
* any release; see `docs/compatibility.md`.
|
|
8
|
+
*
|
|
4
9
|
* @packageDocumentation
|
|
5
10
|
*/
|
|
6
11
|
|
|
7
|
-
// Main app factory
|
|
8
12
|
export { createApp } from "./app.js";
|
|
9
|
-
export type { App
|
|
10
|
-
|
|
11
|
-
// Types
|
|
12
|
-
export type {
|
|
13
|
-
Format,
|
|
14
|
-
Status,
|
|
15
|
-
SortOrder,
|
|
16
|
-
NavItemType,
|
|
17
|
-
Bindings,
|
|
18
|
-
Post,
|
|
19
|
-
Media,
|
|
20
|
-
MediaAttachment,
|
|
21
|
-
PostWithMedia,
|
|
22
|
-
Collection,
|
|
23
|
-
NavItem,
|
|
24
|
-
CustomUrl,
|
|
25
|
-
Setting,
|
|
26
|
-
CreatePost,
|
|
27
|
-
UpdatePost,
|
|
28
|
-
PostAttachmentInput,
|
|
29
|
-
TextAttachmentContent,
|
|
30
|
-
CreateNavItem,
|
|
31
|
-
UpdateNavItem,
|
|
32
|
-
CreateCollection,
|
|
33
|
-
UpdateCollection,
|
|
34
|
-
AppConfig,
|
|
35
|
-
TextAttachmentContentFormat,
|
|
36
|
-
// View Model types
|
|
37
|
-
PostView,
|
|
38
|
-
MediaView,
|
|
39
|
-
NavItemView,
|
|
40
|
-
SearchResultView,
|
|
41
|
-
TimelineItemView,
|
|
42
|
-
ArchiveGroup,
|
|
43
|
-
// Page props
|
|
44
|
-
ArchiveFilters,
|
|
45
|
-
// Feed types
|
|
46
|
-
FeedData,
|
|
47
|
-
// Search
|
|
48
|
-
SearchResult,
|
|
49
|
-
} from "./types.js";
|
|
50
|
-
|
|
51
|
-
export type { ColorTheme } from "./ui/color-themes.js";
|
|
52
|
-
|
|
53
|
-
export {
|
|
54
|
-
FORMATS,
|
|
55
|
-
STATUSES,
|
|
56
|
-
SORT_ORDERS,
|
|
57
|
-
NAV_ITEM_TYPES,
|
|
58
|
-
MAX_MEDIA_ATTACHMENTS,
|
|
59
|
-
MAX_PINNED_POSTS,
|
|
60
|
-
TEXT_ATTACHMENT_CONTENT_FORMATS,
|
|
61
|
-
MEDIA_KINDS,
|
|
62
|
-
} from "./types.js";
|
|
63
|
-
|
|
64
|
-
// Utilities
|
|
65
|
-
export * as time from "./lib/time.js";
|
|
66
|
-
export * as url from "./lib/url.js";
|
|
67
|
-
export * as markdown from "./lib/markdown.js";
|
|
68
|
-
|
|
69
|
-
// View Model conversion utilities
|
|
70
|
-
export {
|
|
71
|
-
createMediaContext,
|
|
72
|
-
toPostView,
|
|
73
|
-
toPostViews,
|
|
74
|
-
toMediaView,
|
|
75
|
-
toNavItemView,
|
|
76
|
-
toNavItemViews,
|
|
77
|
-
toSearchResultView,
|
|
78
|
-
toArchiveGroups,
|
|
79
|
-
toArchiveGroupsWithMedia,
|
|
80
|
-
} from "./lib/view.js";
|
|
81
|
-
export type { MediaContext } from "./lib/view.js";
|
|
82
|
-
|
|
83
|
-
// Default feed renderers (for custom feed implementations)
|
|
84
|
-
export { defaultFeedRenderer } from "./lib/feed.js";
|
|
13
|
+
export type { App } from "./app.js";
|
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
toNavItemView,
|
|
11
11
|
toNavItemViews,
|
|
12
12
|
toSearchResultView,
|
|
13
|
-
toArchiveGroups,
|
|
14
13
|
} from "../view.js";
|
|
15
14
|
import type { MediaContext } from "../view.js";
|
|
16
15
|
import type {
|
|
@@ -984,48 +983,3 @@ describe("toSearchResultView", () => {
|
|
|
984
983
|
expect(view.post.permalink).toBe("/my-link");
|
|
985
984
|
});
|
|
986
985
|
});
|
|
987
|
-
|
|
988
|
-
// =============================================================================
|
|
989
|
-
// toArchiveGroups
|
|
990
|
-
// =============================================================================
|
|
991
|
-
|
|
992
|
-
describe("toArchiveGroups", () => {
|
|
993
|
-
it("converts grouped map to ArchiveGroup array", () => {
|
|
994
|
-
const grouped = new Map<string, Post[]>();
|
|
995
|
-
grouped.set("2024-02", [
|
|
996
|
-
makePost({ id: UUID_1, publishedAt: 1706745600 }),
|
|
997
|
-
makePost({ id: UUID_2, publishedAt: 1706832000 }),
|
|
998
|
-
]);
|
|
999
|
-
grouped.set("2024-01", [makePost({ id: UUID_3, publishedAt: 1704067200 })]);
|
|
1000
|
-
|
|
1001
|
-
const groups = toArchiveGroups(grouped, EMPTY_CTX);
|
|
1002
|
-
expect(groups).toHaveLength(2);
|
|
1003
|
-
|
|
1004
|
-
expect(groups[0]).toHaveProperty("year", "2024");
|
|
1005
|
-
expect(groups[0]).toHaveProperty("month", "02");
|
|
1006
|
-
expect(groups[0]).toHaveProperty("label", "February 2024");
|
|
1007
|
-
expect(groups[0]).toHaveProperty("posts");
|
|
1008
|
-
expect(groups[0]?.posts).toHaveLength(2);
|
|
1009
|
-
|
|
1010
|
-
expect(groups[1]).toHaveProperty("year", "2024");
|
|
1011
|
-
expect(groups[1]).toHaveProperty("month", "01");
|
|
1012
|
-
expect(groups[1]).toHaveProperty("label", "January 2024");
|
|
1013
|
-
expect(groups[1]?.posts).toHaveLength(1);
|
|
1014
|
-
});
|
|
1015
|
-
|
|
1016
|
-
it("converts posts to PostView within groups", () => {
|
|
1017
|
-
const grouped = new Map<string, Post[]>();
|
|
1018
|
-
grouped.set("2024-02", [makePost({ id: UUID_1 })]);
|
|
1019
|
-
|
|
1020
|
-
const groups = toArchiveGroups(grouped, EMPTY_CTX);
|
|
1021
|
-
const post = groups[0]?.posts[0];
|
|
1022
|
-
expect(post).toBeDefined();
|
|
1023
|
-
expect(post?.permalink).toBeDefined();
|
|
1024
|
-
expect(post?.publishedAtFormatted).toBeDefined();
|
|
1025
|
-
});
|
|
1026
|
-
|
|
1027
|
-
it("handles empty map", () => {
|
|
1028
|
-
const groups = toArchiveGroups(new Map(), EMPTY_CTX);
|
|
1029
|
-
expect(groups).toHaveLength(0);
|
|
1030
|
-
});
|
|
1031
|
-
});
|
package/src/lib/feed.ts
CHANGED
|
@@ -2,12 +2,6 @@
|
|
|
2
2
|
* Default Feed Renderers
|
|
3
3
|
*
|
|
4
4
|
* Atom and Sitemap XML generators.
|
|
5
|
-
* Theme authors can import these to extend/wrap the defaults:
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```typescript
|
|
9
|
-
* import { defaultFeedRenderer } from "@jant/core/lib/feed";
|
|
10
|
-
* ```
|
|
11
5
|
*/
|
|
12
6
|
|
|
13
7
|
import type {
|
package/src/lib/view.ts
CHANGED
|
@@ -724,35 +724,8 @@ export function toSearchResultViews(
|
|
|
724
724
|
// Archive Group Conversions
|
|
725
725
|
// =============================================================================
|
|
726
726
|
|
|
727
|
-
/**
|
|
728
|
-
* Converts a grouped post map to typed ArchiveGroup[].
|
|
729
|
-
*/
|
|
730
|
-
export function toArchiveGroups(
|
|
731
|
-
grouped: Map<string, Post[]>,
|
|
732
|
-
ctx: MediaContext,
|
|
733
|
-
aliasMap?: Map<string, string>,
|
|
734
|
-
): ArchiveGroup[] {
|
|
735
|
-
const groups: ArchiveGroup[] = [];
|
|
736
|
-
for (const [yearMonth, posts] of grouped) {
|
|
737
|
-
const [year, month] = yearMonth.split("-");
|
|
738
|
-
if (!year || !month) continue;
|
|
739
|
-
|
|
740
|
-
const label = formatYearMonthLabel(yearMonth);
|
|
741
|
-
if (!label) continue;
|
|
742
|
-
|
|
743
|
-
groups.push({
|
|
744
|
-
year,
|
|
745
|
-
month,
|
|
746
|
-
label,
|
|
747
|
-
posts: toPostViewsFromPosts(posts, ctx, undefined, aliasMap),
|
|
748
|
-
});
|
|
749
|
-
}
|
|
750
|
-
return groups;
|
|
751
|
-
}
|
|
752
|
-
|
|
753
727
|
/**
|
|
754
728
|
* Converts a grouped PostWithMedia map to typed ArchiveGroup[].
|
|
755
|
-
* Unlike toArchiveGroups, this preserves media attachments on each post.
|
|
756
729
|
*
|
|
757
730
|
* @param grouped - Map of "YYYY-MM" keys to PostWithMedia arrays
|
|
758
731
|
* @param ctx - Media context for URL computation
|
|
@@ -3,11 +3,11 @@ import { tmpdir } from "node:os";
|
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import Database from "better-sqlite3";
|
|
5
5
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
6
|
-
import { run } from "../../../bin/commands/export.js";
|
|
6
|
+
import { run } from "../../../bin/commands/db/export.js";
|
|
7
7
|
import { migrate } from "../runtime.js";
|
|
8
8
|
import type { Bindings } from "../../types.js";
|
|
9
9
|
|
|
10
|
-
describe("jant export", () => {
|
|
10
|
+
describe("jant db export", () => {
|
|
11
11
|
const tempDirs: string[] = [];
|
|
12
12
|
const originalEnv = process.env.DATABASE_URL;
|
|
13
13
|
const siteId = "sit_01jpyz1h3v4m7s2k8r5c9t0qbd";
|
|
@@ -4,6 +4,10 @@ import { tmpdir } from "node:os";
|
|
|
4
4
|
import { join } from "node:path";
|
|
5
5
|
import Database from "better-sqlite3";
|
|
6
6
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
7
|
+
import {
|
|
8
|
+
listInstalledSchemaTags,
|
|
9
|
+
readInstalledJantVersion,
|
|
10
|
+
} from "../../../bin/lib/site-snapshot.js";
|
|
7
11
|
import { createLocalDriver } from "../../lib/storage.js";
|
|
8
12
|
import { migrate } from "../runtime.js";
|
|
9
13
|
import type { Bindings } from "../../types.js";
|
|
@@ -244,6 +248,8 @@ describe("jant site snapshot export/import", () => {
|
|
|
244
248
|
format: "jant-site-snapshot",
|
|
245
249
|
version: 2,
|
|
246
250
|
dialect: "sqlite",
|
|
251
|
+
jant: readInstalledJantVersion(),
|
|
252
|
+
schema: listInstalledSchemaTags("sqlite").at(-1),
|
|
247
253
|
site: { id: SNAPSHOT_SITE_ID, key: SNAPSHOT_SITE_KEY },
|
|
248
254
|
});
|
|
249
255
|
expect(existsSync(join(snapshotPath, "storage-manifest.json"))).toBe(false);
|
|
@@ -2,7 +2,7 @@ import { mkdtemp, readFile, rm } from "node:fs/promises";
|
|
|
2
2
|
import { tmpdir } from "node:os";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
5
|
-
import { run as runImportSite } from "../../../bin/commands/import
|
|
5
|
+
import { run as runImportSite } from "../../../bin/commands/site/import.js";
|
|
6
6
|
import { run as runSiteExport } from "../../../bin/commands/site/export.js";
|
|
7
7
|
import {
|
|
8
8
|
CLI_API_TOKEN_ENV_VAR,
|
|
@@ -65,6 +65,7 @@ describe("site CLI token env", () => {
|
|
|
65
65
|
vi.spyOn(console, "log").mockImplementation(() => {});
|
|
66
66
|
|
|
67
67
|
await runSiteExport([
|
|
68
|
+
"--url",
|
|
68
69
|
"https://example.com",
|
|
69
70
|
"--output",
|
|
70
71
|
outputPath,
|
|
@@ -94,6 +95,7 @@ describe("site CLI token env", () => {
|
|
|
94
95
|
|
|
95
96
|
await expect(
|
|
96
97
|
runImportSite([
|
|
98
|
+
"--url",
|
|
97
99
|
"https://example.com",
|
|
98
100
|
"--path",
|
|
99
101
|
"/definitely-missing-jant-import-source",
|
|
@@ -119,6 +121,7 @@ describe("site CLI token env", () => {
|
|
|
119
121
|
|
|
120
122
|
await expect(
|
|
121
123
|
runImportSite([
|
|
124
|
+
"--url",
|
|
122
125
|
"https://example.com",
|
|
123
126
|
"--path",
|
|
124
127
|
"/definitely-missing-jant-import-source",
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
2
3
|
import {
|
|
3
4
|
assertSnapshotDialectMatches,
|
|
4
5
|
assertSnapshotMeta,
|
|
6
|
+
assertSnapshotSchemaInstalled,
|
|
7
|
+
listInstalledSchemaTags,
|
|
5
8
|
buildMediaProviderSql,
|
|
6
9
|
buildSnapshotMeta,
|
|
7
10
|
getSnapshotDialect,
|
|
@@ -32,6 +35,67 @@ describe("buildSnapshotMeta", () => {
|
|
|
32
35
|
});
|
|
33
36
|
});
|
|
34
37
|
|
|
38
|
+
describe("snapshot schema", () => {
|
|
39
|
+
const packageVersion = JSON.parse(
|
|
40
|
+
readFileSync(new URL("../../../package.json", import.meta.url), "utf8"),
|
|
41
|
+
).version;
|
|
42
|
+
|
|
43
|
+
it("records the writing version and its last migration per dialect", () => {
|
|
44
|
+
for (const dialect of ["sqlite", "pg"] as const) {
|
|
45
|
+
const meta = buildSnapshotMeta(SITE, { dialect });
|
|
46
|
+
expect(meta.jant).toBe(packageVersion);
|
|
47
|
+
expect(meta.schema).toBe(listInstalledSchemaTags(dialect).at(-1));
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("accepts a snapshot whose schema the installed package ships", () => {
|
|
52
|
+
const meta = buildSnapshotMeta(SITE, { dialect: "pg" });
|
|
53
|
+
expect(() => assertSnapshotSchemaInstalled(meta)).not.toThrow();
|
|
54
|
+
const older = {
|
|
55
|
+
...meta,
|
|
56
|
+
schema: listInstalledSchemaTags("pg")[0],
|
|
57
|
+
};
|
|
58
|
+
expect(() => assertSnapshotSchemaInstalled(older)).not.toThrow();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("accepts a snapshot from before the schema was recorded", () => {
|
|
62
|
+
const {
|
|
63
|
+
schema: _schema,
|
|
64
|
+
jant: _jant,
|
|
65
|
+
...legacy
|
|
66
|
+
} = buildSnapshotMeta(SITE, { dialect: "sqlite" });
|
|
67
|
+
expect(() => assertSnapshotSchemaInstalled(legacy)).not.toThrow();
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it("refuses a snapshot from a newer schema, naming the fix", () => {
|
|
71
|
+
const meta = {
|
|
72
|
+
...buildSnapshotMeta(SITE, { dialect: "sqlite" }),
|
|
73
|
+
jant: "9.0.0",
|
|
74
|
+
schema: "9999_later_change",
|
|
75
|
+
};
|
|
76
|
+
expect(() => assertSnapshotSchemaInstalled(meta)).toThrow(
|
|
77
|
+
/Jant 9\.0\.0.*9999_later_change.*Upgrade @jant\/core/,
|
|
78
|
+
);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it("checks a snapshot against its own dialect's migrations", () => {
|
|
82
|
+
const sqliteTag = listInstalledSchemaTags("sqlite").at(-1);
|
|
83
|
+
const pgTags = listInstalledSchemaTags("pg");
|
|
84
|
+
expect(pgTags).not.toContain(sqliteTag);
|
|
85
|
+
const meta = {
|
|
86
|
+
...buildSnapshotMeta(SITE, { dialect: "pg" }),
|
|
87
|
+
schema: sqliteTag,
|
|
88
|
+
};
|
|
89
|
+
expect(() => assertSnapshotSchemaInstalled(meta)).toThrow();
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it("rejects a non-string jant or schema field", () => {
|
|
93
|
+
expect(() =>
|
|
94
|
+
assertSnapshotMeta({ ...buildSnapshotMeta(SITE), schema: 34 }),
|
|
95
|
+
).toThrow(/schema must be a string/);
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
|
|
35
99
|
describe("assertSnapshotMeta", () => {
|
|
36
100
|
it("accepts a known dialect", () => {
|
|
37
101
|
expect(() =>
|
|
@@ -20,7 +20,7 @@ export const internalSearchReindexRoutes = new Hono<Env>();
|
|
|
20
20
|
* `body_text` changes.
|
|
21
21
|
*
|
|
22
22
|
* Idempotent. Callers loop with the returned `nextCursor` until `done: true`.
|
|
23
|
-
* Used by the `jant search
|
|
23
|
+
* Used by the `jant search reindex` CLI to backfill search indexes for
|
|
24
24
|
* existing posts after changes to the text extraction logic (e.g. including
|
|
25
25
|
* link mark hrefs so inline URLs become searchable).
|
|
26
26
|
*/
|
|
@@ -573,277 +573,6 @@ describe("MediaService", () => {
|
|
|
573
573
|
});
|
|
574
574
|
});
|
|
575
575
|
|
|
576
|
-
describe("migrateLegacyTextAttachments", () => {
|
|
577
|
-
/**
|
|
578
|
-
* Seed a row representing the envelope-era format (single JSON blob with
|
|
579
|
-
* `{ json, html }`), bypassing the current service APIs.
|
|
580
|
-
*/
|
|
581
|
-
async function seedEnvelopeRow(
|
|
582
|
-
storage: ReturnType<typeof createMockStorage>,
|
|
583
|
-
key: string,
|
|
584
|
-
envelope: { json: unknown; html: string },
|
|
585
|
-
) {
|
|
586
|
-
const bytes = new TextEncoder().encode(JSON.stringify(envelope));
|
|
587
|
-
await storage.put(key, bytes, { contentType: "text/x-tiptap+json" });
|
|
588
|
-
return mediaService.create({
|
|
589
|
-
filename: key.split("/").pop() ?? "attached-text.md",
|
|
590
|
-
originalName: "attached-text.md",
|
|
591
|
-
mimeType: "text/x-tiptap+json",
|
|
592
|
-
size: bytes.byteLength,
|
|
593
|
-
storageKey: key,
|
|
594
|
-
provider: "local",
|
|
595
|
-
mediaKind: "text",
|
|
596
|
-
summary: "Legacy envelope",
|
|
597
|
-
chars: 10,
|
|
598
|
-
});
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
/**
|
|
602
|
-
* Seed a row representing the split-era format (`.html` primary object
|
|
603
|
-
* with a `.json` sibling at the swapped suffix), bypassing current APIs.
|
|
604
|
-
*/
|
|
605
|
-
async function seedSplitRow(
|
|
606
|
-
storage: ReturnType<typeof createMockStorage>,
|
|
607
|
-
htmlKey: string,
|
|
608
|
-
json: unknown,
|
|
609
|
-
html: string,
|
|
610
|
-
) {
|
|
611
|
-
const jsonKey = htmlKey.replace(/\.html$/, ".json");
|
|
612
|
-
const htmlBytes = new TextEncoder().encode(html);
|
|
613
|
-
const jsonBytes = new TextEncoder().encode(JSON.stringify(json));
|
|
614
|
-
await storage.put(jsonKey, jsonBytes, {
|
|
615
|
-
contentType: "application/json",
|
|
616
|
-
});
|
|
617
|
-
await storage.put(htmlKey, htmlBytes, {
|
|
618
|
-
contentType: "text/html; charset=utf-8",
|
|
619
|
-
});
|
|
620
|
-
return mediaService.create({
|
|
621
|
-
filename: htmlKey.split("/").pop() ?? "attached-text.html",
|
|
622
|
-
originalName: "attached-text.html",
|
|
623
|
-
mimeType: "text/html; charset=utf-8",
|
|
624
|
-
size: htmlBytes.byteLength,
|
|
625
|
-
storageKey: htmlKey,
|
|
626
|
-
provider: "local",
|
|
627
|
-
mediaKind: "text",
|
|
628
|
-
summary: "Legacy split",
|
|
629
|
-
chars: 10,
|
|
630
|
-
});
|
|
631
|
-
}
|
|
632
|
-
|
|
633
|
-
it("converts an envelope row into a single .md file", async () => {
|
|
634
|
-
const storage = createMockStorage();
|
|
635
|
-
// Real legacy envelopes were named `attached-text.md` — so their
|
|
636
|
-
// storageKey already ends in `.md`. Migration overwrites the same
|
|
637
|
-
// key with markdown bytes rather than writing a new file; this is
|
|
638
|
-
// fine because the DB row still points at the same key and the old
|
|
639
|
-
// envelope contents are gone.
|
|
640
|
-
const legacyKey = "media/legacy-env.md";
|
|
641
|
-
const envelope = {
|
|
642
|
-
json: {
|
|
643
|
-
type: "doc",
|
|
644
|
-
content: [
|
|
645
|
-
{
|
|
646
|
-
type: "paragraph",
|
|
647
|
-
content: [{ type: "text", text: "Hello" }],
|
|
648
|
-
},
|
|
649
|
-
],
|
|
650
|
-
},
|
|
651
|
-
html: "<p>Hello</p>",
|
|
652
|
-
};
|
|
653
|
-
const row = await seedEnvelopeRow(storage, legacyKey, envelope);
|
|
654
|
-
|
|
655
|
-
const result = await mediaService.migrateLegacyTextAttachments({
|
|
656
|
-
storage,
|
|
657
|
-
storageDriver: "local",
|
|
658
|
-
});
|
|
659
|
-
|
|
660
|
-
expect(result).toEqual({
|
|
661
|
-
migrated: 1,
|
|
662
|
-
failed: 0,
|
|
663
|
-
remaining: 0,
|
|
664
|
-
errors: [],
|
|
665
|
-
});
|
|
666
|
-
|
|
667
|
-
// Exactly one storage object — the same key, now with markdown bytes
|
|
668
|
-
// and markdown metadata. The old envelope JSON is gone (overwritten).
|
|
669
|
-
expect(storage.files.size).toBe(1);
|
|
670
|
-
const file = storage.files.get(legacyKey)!;
|
|
671
|
-
expect(file.contentType).toBe("text/markdown; charset=utf-8");
|
|
672
|
-
expect(file.cacheControl).toBe("public, max-age=31536000, immutable");
|
|
673
|
-
expect(file.contentDisposition).toBe("inline");
|
|
674
|
-
const mdText = new TextDecoder().decode(file.body);
|
|
675
|
-
expect(mdText).toContain("Hello");
|
|
676
|
-
// Sanity check: no trace of the envelope JSON structure.
|
|
677
|
-
expect(mdText.trim().startsWith("{")).toBe(false);
|
|
678
|
-
|
|
679
|
-
const updated = await mediaService.getById(row.id);
|
|
680
|
-
expect(updated?.storageKey).toBe(legacyKey);
|
|
681
|
-
expect(updated?.mimeType).toBe("text/markdown; charset=utf-8");
|
|
682
|
-
expect(updated?.originalName).toBe("attached-text.md");
|
|
683
|
-
expect(updated?.size).toBe(file.body.byteLength);
|
|
684
|
-
expect(updated?.filename).toBe("legacy-env.md");
|
|
685
|
-
});
|
|
686
|
-
|
|
687
|
-
it("converts a split (.html + .json) row into a single .md file", async () => {
|
|
688
|
-
const storage = createMockStorage();
|
|
689
|
-
const htmlKey = "media/legacy-split.html";
|
|
690
|
-
const jsonKey = "media/legacy-split.json";
|
|
691
|
-
const row = await seedSplitRow(
|
|
692
|
-
storage,
|
|
693
|
-
htmlKey,
|
|
694
|
-
{
|
|
695
|
-
type: "doc",
|
|
696
|
-
content: [
|
|
697
|
-
{
|
|
698
|
-
type: "paragraph",
|
|
699
|
-
content: [{ type: "text", text: "split world" }],
|
|
700
|
-
},
|
|
701
|
-
],
|
|
702
|
-
},
|
|
703
|
-
"<p>split world</p>",
|
|
704
|
-
);
|
|
705
|
-
|
|
706
|
-
const result = await mediaService.migrateLegacyTextAttachments({
|
|
707
|
-
storage,
|
|
708
|
-
storageDriver: "local",
|
|
709
|
-
});
|
|
710
|
-
|
|
711
|
-
expect(result.migrated).toBe(1);
|
|
712
|
-
expect(result.failed).toBe(0);
|
|
713
|
-
expect(result.remaining).toBe(0);
|
|
714
|
-
|
|
715
|
-
// Both old siblings gone; single .md written.
|
|
716
|
-
expect(storage.files.has(htmlKey)).toBe(false);
|
|
717
|
-
expect(storage.files.has(jsonKey)).toBe(false);
|
|
718
|
-
const mdKey = "media/legacy-split.md";
|
|
719
|
-
expect(storage.files.has(mdKey)).toBe(true);
|
|
720
|
-
|
|
721
|
-
const file = storage.files.get(mdKey)!;
|
|
722
|
-
const mdText = new TextDecoder().decode(file.body);
|
|
723
|
-
expect(mdText).toContain("split world");
|
|
724
|
-
|
|
725
|
-
const updated = await mediaService.getById(row.id);
|
|
726
|
-
expect(updated?.storageKey).toBe(mdKey);
|
|
727
|
-
expect(updated?.mimeType).toBe("text/markdown; charset=utf-8");
|
|
728
|
-
});
|
|
729
|
-
|
|
730
|
-
it("is idempotent: current markdown rows are skipped", async () => {
|
|
731
|
-
const storage = createMockStorage();
|
|
732
|
-
await seedEnvelopeRow(storage, "media/legacy-idemp.md", {
|
|
733
|
-
json: {
|
|
734
|
-
type: "doc",
|
|
735
|
-
content: [
|
|
736
|
-
{
|
|
737
|
-
type: "paragraph",
|
|
738
|
-
content: [{ type: "text", text: "hello" }],
|
|
739
|
-
},
|
|
740
|
-
],
|
|
741
|
-
},
|
|
742
|
-
html: "<p>hello</p>",
|
|
743
|
-
});
|
|
744
|
-
|
|
745
|
-
const first = await mediaService.migrateLegacyTextAttachments({
|
|
746
|
-
storage,
|
|
747
|
-
storageDriver: "local",
|
|
748
|
-
});
|
|
749
|
-
expect(first.migrated).toBe(1);
|
|
750
|
-
|
|
751
|
-
const second = await mediaService.migrateLegacyTextAttachments({
|
|
752
|
-
storage,
|
|
753
|
-
storageDriver: "local",
|
|
754
|
-
});
|
|
755
|
-
expect(second).toEqual({
|
|
756
|
-
migrated: 0,
|
|
757
|
-
failed: 0,
|
|
758
|
-
remaining: 0,
|
|
759
|
-
errors: [],
|
|
760
|
-
});
|
|
761
|
-
});
|
|
762
|
-
|
|
763
|
-
it("respects the batch limit and reports remaining count accurately", async () => {
|
|
764
|
-
const storage = createMockStorage();
|
|
765
|
-
for (let i = 0; i < 3; i += 1) {
|
|
766
|
-
await seedEnvelopeRow(storage, `media/legacy-batch-${i}.md`, {
|
|
767
|
-
json: {
|
|
768
|
-
type: "doc",
|
|
769
|
-
content: [
|
|
770
|
-
{
|
|
771
|
-
type: "paragraph",
|
|
772
|
-
content: [{ type: "text", text: `batch ${i}` }],
|
|
773
|
-
},
|
|
774
|
-
],
|
|
775
|
-
},
|
|
776
|
-
html: `<p>batch ${i}</p>`,
|
|
777
|
-
});
|
|
778
|
-
}
|
|
779
|
-
|
|
780
|
-
const first = await mediaService.migrateLegacyTextAttachments({
|
|
781
|
-
storage,
|
|
782
|
-
storageDriver: "local",
|
|
783
|
-
limit: 2,
|
|
784
|
-
});
|
|
785
|
-
expect(first.migrated).toBe(2);
|
|
786
|
-
expect(first.remaining).toBeGreaterThan(0);
|
|
787
|
-
|
|
788
|
-
const second = await mediaService.migrateLegacyTextAttachments({
|
|
789
|
-
storage,
|
|
790
|
-
storageDriver: "local",
|
|
791
|
-
limit: 2,
|
|
792
|
-
});
|
|
793
|
-
expect(second.migrated).toBe(1);
|
|
794
|
-
expect(second.remaining).toBe(0);
|
|
795
|
-
});
|
|
796
|
-
|
|
797
|
-
it("continues processing the batch when one record fails", async () => {
|
|
798
|
-
const storage = createMockStorage();
|
|
799
|
-
await seedEnvelopeRow(storage, "media/legacy-good.md", {
|
|
800
|
-
json: {
|
|
801
|
-
type: "doc",
|
|
802
|
-
content: [
|
|
803
|
-
{
|
|
804
|
-
type: "paragraph",
|
|
805
|
-
content: [{ type: "text", text: "good" }],
|
|
806
|
-
},
|
|
807
|
-
],
|
|
808
|
-
},
|
|
809
|
-
html: "<p>good</p>",
|
|
810
|
-
});
|
|
811
|
-
// Broken envelope — missing json field.
|
|
812
|
-
const brokenKey = "media/legacy-broken.md";
|
|
813
|
-
const brokenBytes = new TextEncoder().encode(
|
|
814
|
-
JSON.stringify({ html: "<p>broken</p>" }),
|
|
815
|
-
);
|
|
816
|
-
await storage.put(brokenKey, brokenBytes, {
|
|
817
|
-
contentType: "text/x-tiptap+json",
|
|
818
|
-
});
|
|
819
|
-
const brokenRow = await mediaService.create({
|
|
820
|
-
filename: "legacy-broken.md",
|
|
821
|
-
originalName: "attached-text.md",
|
|
822
|
-
mimeType: "text/x-tiptap+json",
|
|
823
|
-
size: brokenBytes.byteLength,
|
|
824
|
-
storageKey: brokenKey,
|
|
825
|
-
provider: "local",
|
|
826
|
-
mediaKind: "text",
|
|
827
|
-
summary: "Broken",
|
|
828
|
-
chars: 1,
|
|
829
|
-
});
|
|
830
|
-
|
|
831
|
-
const result = await mediaService.migrateLegacyTextAttachments({
|
|
832
|
-
storage,
|
|
833
|
-
storageDriver: "local",
|
|
834
|
-
});
|
|
835
|
-
|
|
836
|
-
expect(result.migrated).toBe(1);
|
|
837
|
-
expect(result.failed).toBe(1);
|
|
838
|
-
expect(result.errors).toHaveLength(1);
|
|
839
|
-
expect(result.errors[0].mediaId).toBe(brokenRow.id);
|
|
840
|
-
|
|
841
|
-
// Broken record is untouched and still flagged as legacy for later retry.
|
|
842
|
-
const stillBroken = await mediaService.getById(brokenRow.id);
|
|
843
|
-
expect(stillBroken?.mimeType).toBe("text/x-tiptap+json");
|
|
844
|
-
});
|
|
845
|
-
});
|
|
846
|
-
|
|
847
576
|
describe("getById", () => {
|
|
848
577
|
it("returns media by ID", async () => {
|
|
849
578
|
const created = await mediaService.create(sampleMedia);
|