@cossackframework/cms 0.0.0-stage → 0.9.1

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.
Files changed (427) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +147 -2
  3. package/agent-docs.json +259 -0
  4. package/app/README.md +78 -0
  5. package/app/cossack-recipe.json +43 -0
  6. package/app/src/auth-bot-check.ts +32 -0
  7. package/app/src/auth-bot-token.ts +11 -0
  8. package/app/src/auth-input.ts +35 -0
  9. package/app/src/auth-options.ts +18 -0
  10. package/app/src/auth-providers.ts +16 -0
  11. package/app/src/auth.ts +1082 -0
  12. package/app/src/brand.ts +68 -0
  13. package/app/src/cms/ai.ts +54 -0
  14. package/app/src/cms/analytics.ts +33 -0
  15. package/app/src/cms/block-errors.ts +55 -0
  16. package/app/src/cms/block-inserter.ts +111 -0
  17. package/app/src/cms/block-panel.ts +68 -0
  18. package/app/src/cms/block-rows.ts +44 -0
  19. package/app/src/cms/block-tree.ts +585 -0
  20. package/app/src/cms/blocks.css +708 -0
  21. package/app/src/cms/builder.ts +126 -0
  22. package/app/src/cms/cache.ts +44 -0
  23. package/app/src/cms/carousel.client.ts +52 -0
  24. package/app/src/cms/collab/presence.ts +69 -0
  25. package/app/src/cms/collab/rich-text-collab.client.ts +197 -0
  26. package/app/src/cms/collab/rich-text-notes.client.ts +138 -0
  27. package/app/src/cms/collab/room.ts +881 -0
  28. package/app/src/cms/compare.client.ts +47 -0
  29. package/app/src/cms/condition-control.ts +109 -0
  30. package/app/src/cms/content-api.ts +143 -0
  31. package/app/src/cms/content.ts +524 -0
  32. package/app/src/cms/countdown.client.ts +37 -0
  33. package/app/src/cms/editor-layout-editor.ts +260 -0
  34. package/app/src/cms/editor-layout-view.ts +37 -0
  35. package/app/src/cms/editor.ts +381 -0
  36. package/app/src/cms/entry.ts +26 -0
  37. package/app/src/cms/feeds.ts +145 -0
  38. package/app/src/cms/field-controls.ts +222 -0
  39. package/app/src/cms/field-group-editor.ts +105 -0
  40. package/app/src/cms/field-group-view.ts +211 -0
  41. package/app/src/cms/form-view.ts +203 -0
  42. package/app/src/cms/form.client.ts +203 -0
  43. package/app/src/cms/guards.ts +27 -0
  44. package/app/src/cms/handoff.ts +202 -0
  45. package/app/src/cms/headings.ts +51 -0
  46. package/app/src/cms/icons.ts +80 -0
  47. package/app/src/cms/import.client.ts +16 -0
  48. package/app/src/cms/index.ts +191 -0
  49. package/app/src/cms/lightbox.client.ts +109 -0
  50. package/app/src/cms/machine.ts +118 -0
  51. package/app/src/cms/maintenance.ts +97 -0
  52. package/app/src/cms/manage.ts +1236 -0
  53. package/app/src/cms/mcp-tools.ts +388 -0
  54. package/app/src/cms/mcp.ts +242 -0
  55. package/app/src/cms/media-chooser.ts +123 -0
  56. package/app/src/cms/media-usage.ts +57 -0
  57. package/app/src/cms/middleware.ts +199 -0
  58. package/app/src/cms/middlewares.ts +13 -0
  59. package/app/src/cms/network-ui.ts +36 -0
  60. package/app/src/cms/network-view.ts +38 -0
  61. package/app/src/cms/notes-announce.ts +65 -0
  62. package/app/src/cms/notes-rail.ts +207 -0
  63. package/app/src/cms/notification-rules.ts +66 -0
  64. package/app/src/cms/recovery.ts +82 -0
  65. package/app/src/cms/replace.ts +63 -0
  66. package/app/src/cms/reserved-paths.ts +19 -0
  67. package/app/src/cms/rich-text-field.ts +325 -0
  68. package/app/src/cms/rich-text-schema.ts +91 -0
  69. package/app/src/cms/rich-text.client.ts +255 -0
  70. package/app/src/cms/search.client.ts +116 -0
  71. package/app/src/cms/seo-head.ts +78 -0
  72. package/app/src/cms/seo.ts +241 -0
  73. package/app/src/cms/settings-draft.ts +218 -0
  74. package/app/src/cms/settings-file.ts +127 -0
  75. package/app/src/cms/settings-form.ts +180 -0
  76. package/app/src/cms/settings-languages.ts +125 -0
  77. package/app/src/cms/settings-nav.ts +102 -0
  78. package/app/src/cms/settings-network.ts +151 -0
  79. package/app/src/cms/settings-permalinks.ts +114 -0
  80. package/app/src/cms/settings-scroll.ts +10 -0
  81. package/app/src/cms/settings-search.ts +77 -0
  82. package/app/src/cms/settings-section.ts +38 -0
  83. package/app/src/cms/share.client.ts +27 -0
  84. package/app/src/cms/site-editing.ts +219 -0
  85. package/app/src/cms/site-editor.client.ts +1008 -0
  86. package/app/src/cms/site-editor.ts +99 -0
  87. package/app/src/cms/site-export.ts +60 -0
  88. package/app/src/cms/site-forms.ts +143 -0
  89. package/app/src/cms/site-import.ts +28 -0
  90. package/app/src/cms/site-session.ts +36 -0
  91. package/app/src/cms/site-taskbar.ts +77 -0
  92. package/app/src/cms/site-view.ts +1014 -0
  93. package/app/src/cms/site.ts +1322 -0
  94. package/app/src/cms/sitemaps.ts +131 -0
  95. package/app/src/cms/stat.client.ts +56 -0
  96. package/app/src/cms/style-controls.ts +252 -0
  97. package/app/src/cms/tabs.client.ts +36 -0
  98. package/app/src/cms/taskbar.ts +134 -0
  99. package/app/src/cms/term-icons.ts +10 -0
  100. package/app/src/cms/traffic.ts +26 -0
  101. package/app/src/cms/ui.ts +170 -0
  102. package/app/src/cms/updates.ts +124 -0
  103. package/app/src/cms/uploads.ts +26 -0
  104. package/app/src/cms/worker.ts +13 -0
  105. package/app/src/config/auth.ts +30 -0
  106. package/app/src/config/cms.ts +18 -0
  107. package/app/src/dashboard/access.ts +344 -0
  108. package/app/src/dashboard/agent-icons.ts +44 -0
  109. package/app/src/dashboard/app-passwords.ts +74 -0
  110. package/app/src/dashboard/avatar-field.ts +58 -0
  111. package/app/src/dashboard/bulk.ts +53 -0
  112. package/app/src/dashboard/head.ts +29 -0
  113. package/app/src/dashboard/icons.ts +15 -0
  114. package/app/src/dashboard/list-table.ts +120 -0
  115. package/app/src/dashboard/modules/roles.ts +15 -0
  116. package/app/src/dashboard/modules/sessions.ts +15 -0
  117. package/app/src/dashboard/modules/settings.ts +15 -0
  118. package/app/src/dashboard/modules/users.ts +18 -0
  119. package/app/src/dashboard/page.ts +67 -0
  120. package/app/src/dashboard/registry.ts +13 -0
  121. package/app/src/dashboard/session-list.ts +98 -0
  122. package/app/src/dashboard/tabs.ts +26 -0
  123. package/app/src/dashboard/time-ago.ts +16 -0
  124. package/app/src/dashboard/types.ts +40 -0
  125. package/app/src/dashboard/user-sections.ts +172 -0
  126. package/app/src/lib/permissions.ts +84 -0
  127. package/app/src/middlewares/auth.ts +117 -0
  128. package/app/src/pages/(site)/[...path]/index.ts +609 -0
  129. package/app/src/pages/(site)/feed/[...rest]/index.ts +13 -0
  130. package/app/src/pages/(site)/feed/index.ts +12 -0
  131. package/app/src/pages/(site)/index.ts +11 -0
  132. package/app/src/pages/(site)/indexnow/[file]/index.ts +18 -0
  133. package/app/src/pages/(site)/layout.ts +219 -0
  134. package/app/src/pages/(site)/llms.txt/index.ts +23 -0
  135. package/app/src/pages/(site)/manifest.webmanifest/index.ts +29 -0
  136. package/app/src/pages/(site)/media/[id]/[name]/index.ts +59 -0
  137. package/app/src/pages/(site)/preview/[collection]/[id]/index.ts +115 -0
  138. package/app/src/pages/(site)/robots.txt/index.ts +29 -0
  139. package/app/src/pages/(site)/search/index.ts +36 -0
  140. package/app/src/pages/(site)/sitemap.xml/index.ts +26 -0
  141. package/app/src/pages/(site)/sitemaps/[file]/index.ts +33 -0
  142. package/app/src/pages/api/auth/session.ts +48 -0
  143. package/app/src/pages/api/cms/appearance/areas/[name].ts +12 -0
  144. package/app/src/pages/api/cms/appearance/areas/index.ts +6 -0
  145. package/app/src/pages/api/cms/appearance/locations/[location].ts +6 -0
  146. package/app/src/pages/api/cms/appearance/locations/index.ts +6 -0
  147. package/app/src/pages/api/cms/appearance/menus/[id].ts +12 -0
  148. package/app/src/pages/api/cms/appearance/menus/index.ts +13 -0
  149. package/app/src/pages/api/cms/appearance/themes/[name]/activate.ts +6 -0
  150. package/app/src/pages/api/cms/appearance/themes/index.ts +6 -0
  151. package/app/src/pages/api/cms/cache/purge.ts +6 -0
  152. package/app/src/pages/api/cms/collections/index.ts +6 -0
  153. package/app/src/pages/api/cms/commands/[plugin]/[command].ts +26 -0
  154. package/app/src/pages/api/cms/comments/[id].ts +9 -0
  155. package/app/src/pages/api/cms/comments/index.ts +126 -0
  156. package/app/src/pages/api/cms/comments/queue.ts +6 -0
  157. package/app/src/pages/api/cms/content/[collection]/[entry]/autosave.ts +27 -0
  158. package/app/src/pages/api/cms/content/[collection]/[entry]/blocks/[block].ts +16 -0
  159. package/app/src/pages/api/cms/content/[collection]/[entry]/notes.ts +18 -0
  160. package/app/src/pages/api/cms/content/[collection]/[entry]/publish.ts +11 -0
  161. package/app/src/pages/api/cms/content/[collection]/[entry]/revisions/[revision]/index.ts +6 -0
  162. package/app/src/pages/api/cms/content/[collection]/[entry]/revisions/[revision]/restore.ts +6 -0
  163. package/app/src/pages/api/cms/content/[collection]/[entry]/revisions/index.ts +6 -0
  164. package/app/src/pages/api/cms/content/[collection]/[entry]/unpublish.ts +6 -0
  165. package/app/src/pages/api/cms/content/[collection]/[entry].ts +42 -0
  166. package/app/src/pages/api/cms/content/[collection]/index.ts +24 -0
  167. package/app/src/pages/api/cms/export/[collection].ts +37 -0
  168. package/app/src/pages/api/cms/forms/[slug]/index.ts +173 -0
  169. package/app/src/pages/api/cms/forms/[slug]/submissions/[submission]/files/[file].ts +25 -0
  170. package/app/src/pages/api/cms/forms/[slug]/submissions/export.ts +34 -0
  171. package/app/src/pages/api/cms/forms/[slug]/submissions/index.ts +24 -0
  172. package/app/src/pages/api/cms/import/[collection].ts +23 -0
  173. package/app/src/pages/api/cms/mcp.ts +29 -0
  174. package/app/src/pages/api/cms/me/index.ts +6 -0
  175. package/app/src/pages/api/cms/me/recent-blocks.ts +37 -0
  176. package/app/src/pages/api/cms/me/tokens/[id].ts +6 -0
  177. package/app/src/pages/api/cms/me/tokens/index.ts +13 -0
  178. package/app/src/pages/api/cms/media/[id].ts +6 -0
  179. package/app/src/pages/api/cms/media.ts +26 -0
  180. package/app/src/pages/api/cms/menus/[location].ts +14 -0
  181. package/app/src/pages/api/cms/network/sites/[id]/export.ts +15 -0
  182. package/app/src/pages/api/cms/network/sites/[id]/index.ts +9 -0
  183. package/app/src/pages/api/cms/network/sites/index.ts +14 -0
  184. package/app/src/pages/api/cms/notes/[id].ts +13 -0
  185. package/app/src/pages/api/cms/notes/index.ts +6 -0
  186. package/app/src/pages/api/cms/payments/webhook.ts +28 -0
  187. package/app/src/pages/api/cms/plugins/[name]/grant.ts +6 -0
  188. package/app/src/pages/api/cms/plugins/[name]/revoke.ts +6 -0
  189. package/app/src/pages/api/cms/plugins/index.ts +6 -0
  190. package/app/src/pages/api/cms/recovery.ts +29 -0
  191. package/app/src/pages/api/cms/redirects/index.ts +9 -0
  192. package/app/src/pages/api/cms/roles/index.ts +6 -0
  193. package/app/src/pages/api/cms/schema/[collection].ts +13 -0
  194. package/app/src/pages/api/cms/search.ts +16 -0
  195. package/app/src/pages/api/cms/settings/[group].ts +9 -0
  196. package/app/src/pages/api/cms/settings/index.ts +9 -0
  197. package/app/src/pages/api/cms/site-export.ts +34 -0
  198. package/app/src/pages/api/cms/taxonomies/index.ts +6 -0
  199. package/app/src/pages/api/cms/terms/[taxonomy]/[id].ts +12 -0
  200. package/app/src/pages/api/cms/terms/[taxonomy]/index.ts +9 -0
  201. package/app/src/pages/api/cms/uploads/[id]/complete.ts +15 -0
  202. package/app/src/pages/api/cms/uploads/[id]/index.ts +15 -0
  203. package/app/src/pages/api/cms/uploads/index.ts +26 -0
  204. package/app/src/pages/api/cms/users/[id]/index.ts +12 -0
  205. package/app/src/pages/api/cms/users/[id]/meta.ts +40 -0
  206. package/app/src/pages/api/cms/users/index.ts +12 -0
  207. package/app/src/pages/api/cms/webhooks/[id].ts +6 -0
  208. package/app/src/pages/api/cms/webhooks/index.ts +9 -0
  209. package/app/src/pages/auth/[provider]/callback.ts +11 -0
  210. package/app/src/pages/auth/[provider]/redirect.ts +9 -0
  211. package/app/src/pages/auth/forgot-password/index.ts +75 -0
  212. package/app/src/pages/auth/layout.ts +32 -0
  213. package/app/src/pages/auth/login/index.ts +198 -0
  214. package/app/src/pages/auth/magic/index.ts +68 -0
  215. package/app/src/pages/auth/register/index.ts +117 -0
  216. package/app/src/pages/auth/reset-password/index.ts +65 -0
  217. package/app/src/pages/auth/setup/index.ts +194 -0
  218. package/app/src/pages/auth/two-factor/index.ts +67 -0
  219. package/app/src/pages/auth/verify/index.ts +62 -0
  220. package/app/src/pages/dashboard/(cms)/appearance/customize/index.ts +263 -0
  221. package/app/src/pages/dashboard/(cms)/appearance/dashboard-menu/index.ts +241 -0
  222. package/app/src/pages/dashboard/(cms)/appearance/index.ts +89 -0
  223. package/app/src/pages/dashboard/(cms)/appearance/menus/[id]/index.ts +697 -0
  224. package/app/src/pages/dashboard/(cms)/appearance/menus/index.ts +145 -0
  225. package/app/src/pages/dashboard/(cms)/appearance/widgets/index.ts +279 -0
  226. package/app/src/pages/dashboard/(cms)/blocks/index.ts +84 -0
  227. package/app/src/pages/dashboard/(cms)/calendar/index.ts +92 -0
  228. package/app/src/pages/dashboard/(cms)/collections/[name]/index.ts +525 -0
  229. package/app/src/pages/dashboard/(cms)/collections/index.ts +72 -0
  230. package/app/src/pages/dashboard/(cms)/collections/new/index.ts +66 -0
  231. package/app/src/pages/dashboard/(cms)/comments/index.ts +237 -0
  232. package/app/src/pages/dashboard/(cms)/content/[collection]/[id]/index.ts +2382 -0
  233. package/app/src/pages/dashboard/(cms)/content/[collection]/[id]/revisions/index.ts +126 -0
  234. package/app/src/pages/dashboard/(cms)/content/[collection]/index.ts +693 -0
  235. package/app/src/pages/dashboard/(cms)/field-groups/[id]/index.ts +193 -0
  236. package/app/src/pages/dashboard/(cms)/field-groups/index.ts +65 -0
  237. package/app/src/pages/dashboard/(cms)/forms/[id]/submissions/[submission]/index.ts +279 -0
  238. package/app/src/pages/dashboard/(cms)/forms/[id]/submissions/index.ts +170 -0
  239. package/app/src/pages/dashboard/(cms)/forms/index.ts +171 -0
  240. package/app/src/pages/dashboard/(cms)/media/[id]/index.ts +317 -0
  241. package/app/src/pages/dashboard/(cms)/media/index.ts +156 -0
  242. package/app/src/pages/dashboard/(cms)/media/new/index.ts +9 -0
  243. package/app/src/pages/dashboard/(cms)/media/summary/index.ts +74 -0
  244. package/app/src/pages/dashboard/(cms)/my-sites/index.ts +63 -0
  245. package/app/src/pages/dashboard/(cms)/network/index.ts +53 -0
  246. package/app/src/pages/dashboard/(cms)/network/plugins/index.ts +110 -0
  247. package/app/src/pages/dashboard/(cms)/network/sites/[id]/index.ts +243 -0
  248. package/app/src/pages/dashboard/(cms)/network/sites/index.ts +186 -0
  249. package/app/src/pages/dashboard/(cms)/network/sites/new/index.ts +77 -0
  250. package/app/src/pages/dashboard/(cms)/network/themes/index.ts +82 -0
  251. package/app/src/pages/dashboard/(cms)/network/updates/index.ts +48 -0
  252. package/app/src/pages/dashboard/(cms)/network/users/[id]/index.ts +176 -0
  253. package/app/src/pages/dashboard/(cms)/network/users/index.ts +174 -0
  254. package/app/src/pages/dashboard/(cms)/network/users/new/index.ts +66 -0
  255. package/app/src/pages/dashboard/(cms)/plugins/index.ts +172 -0
  256. package/app/src/pages/dashboard/(cms)/profile/public/index.ts +105 -0
  257. package/app/src/pages/dashboard/(cms)/registrations/index.ts +70 -0
  258. package/app/src/pages/dashboard/(cms)/settings/index.ts +359 -0
  259. package/app/src/pages/dashboard/(cms)/settings/json/index.ts +202 -0
  260. package/app/src/pages/dashboard/(cms)/settings/layout.ts +67 -0
  261. package/app/src/pages/dashboard/(cms)/taxonomies/[name]/index.ts +85 -0
  262. package/app/src/pages/dashboard/(cms)/taxonomies/index.ts +98 -0
  263. package/app/src/pages/dashboard/(cms)/terms/[taxonomy]/[id]/index.ts +244 -0
  264. package/app/src/pages/dashboard/(cms)/terms/[taxonomy]/index.ts +148 -0
  265. package/app/src/pages/dashboard/(cms)/tools/activity/index.ts +94 -0
  266. package/app/src/pages/dashboard/(cms)/tools/automations/index.ts +131 -0
  267. package/app/src/pages/dashboard/(cms)/tools/cache/index.ts +92 -0
  268. package/app/src/pages/dashboard/(cms)/tools/export/index.ts +99 -0
  269. package/app/src/pages/dashboard/(cms)/tools/health/index.ts +189 -0
  270. package/app/src/pages/dashboard/(cms)/tools/jobs/index.ts +93 -0
  271. package/app/src/pages/dashboard/(cms)/tools/links/index.ts +115 -0
  272. package/app/src/pages/dashboard/(cms)/tools/redirects/index.ts +161 -0
  273. package/app/src/pages/dashboard/(cms)/tools/replace/index.ts +124 -0
  274. package/app/src/pages/dashboard/(cms)/tools/schema/index.ts +54 -0
  275. package/app/src/pages/dashboard/(cms)/tools/seo/index.ts +156 -0
  276. package/app/src/pages/dashboard/(cms)/tools/updates/index.ts +114 -0
  277. package/app/src/pages/dashboard/(cms)/tools/webhooks/index.ts +182 -0
  278. package/app/src/pages/dashboard/index.ts +214 -0
  279. package/app/src/pages/dashboard/layout.ts +320 -0
  280. package/app/src/pages/dashboard/profile/index.ts +211 -0
  281. package/app/src/pages/dashboard/profile/security/index.ts +255 -0
  282. package/app/src/pages/dashboard/roles/[id]/index.ts +116 -0
  283. package/app/src/pages/dashboard/roles/index.ts +134 -0
  284. package/app/src/pages/dashboard/roles/new/index.ts +95 -0
  285. package/app/src/pages/dashboard/sessions/index.ts +105 -0
  286. package/app/src/pages/dashboard/users/[id]/index.ts +472 -0
  287. package/app/src/pages/dashboard/users/index.ts +299 -0
  288. package/app/src/pages/dashboard/users/new/index.ts +123 -0
  289. package/app/src/passkeys.client.ts +18 -0
  290. package/app/src/plugins/default-theme/assets/cover.svg +31 -0
  291. package/app/src/plugins/default-theme/assets/logo.svg +8 -0
  292. package/app/src/plugins/default-theme/parts/comments.ts +66 -0
  293. package/app/src/plugins/default-theme/parts/list.ts +38 -0
  294. package/app/src/plugins/default-theme/parts/media.ts +15 -0
  295. package/app/src/plugins/default-theme/parts/options.ts +45 -0
  296. package/app/src/plugins/default-theme/plugin.json +275 -0
  297. package/app/src/plugins/default-theme/templates/archive.ts +14 -0
  298. package/app/src/plugins/default-theme/templates/entry-blank.ts +13 -0
  299. package/app/src/plugins/default-theme/templates/entry.ts +27 -0
  300. package/app/src/plugins/default-theme/templates/home.ts +8 -0
  301. package/app/src/plugins/default-theme/templates/layout.ts +40 -0
  302. package/app/src/plugins/default-theme/templates/not-found.ts +10 -0
  303. package/app/src/plugins/default-theme/templates/search.ts +32 -0
  304. package/app/src/services/rbac.ts +65 -0
  305. package/app/src/services/roles.ts +89 -0
  306. package/app/src/services/users.ts +173 -0
  307. package/package.json +123 -3
  308. package/src/automations.ts +95 -0
  309. package/src/bindings.ts +138 -0
  310. package/src/block-references.ts +239 -0
  311. package/src/block-shape.ts +155 -0
  312. package/src/blocks.ts +1157 -0
  313. package/src/cache.ts +54 -0
  314. package/src/checks.ts +198 -0
  315. package/src/cloudflare-workers.d.ts +13 -0
  316. package/src/cloudflare.ts +61 -0
  317. package/src/collab.ts +372 -0
  318. package/src/collections.ts +421 -0
  319. package/src/comments.ts +46 -0
  320. package/src/cron.ts +95 -0
  321. package/src/dashboard-menu.ts +105 -0
  322. package/src/diff.ts +113 -0
  323. package/src/editor-layout.ts +316 -0
  324. package/src/errors.ts +50 -0
  325. package/src/field-groups.ts +498 -0
  326. package/src/fields.ts +411 -0
  327. package/src/form-builder.ts +1053 -0
  328. package/src/forms.ts +109 -0
  329. package/src/highlight.ts +134 -0
  330. package/src/hooks.ts +510 -0
  331. package/src/icon-catalog.ts +55 -0
  332. package/src/icons.ts +128 -0
  333. package/src/images.ts +149 -0
  334. package/src/index.ts +100 -0
  335. package/src/isolate-core.ts +245 -0
  336. package/src/isolate.ts +19 -0
  337. package/src/isolation.ts +69 -0
  338. package/src/mail.ts +182 -0
  339. package/src/manifest.ts +476 -0
  340. package/src/media.ts +193 -0
  341. package/src/menus.ts +287 -0
  342. package/src/module.ts +32 -0
  343. package/src/modules/content.ts +64 -0
  344. package/src/modules/forms.ts +35 -0
  345. package/src/node.ts +66 -0
  346. package/src/notes.ts +237 -0
  347. package/src/permissions.ts +139 -0
  348. package/src/plugin-settings.ts +114 -0
  349. package/src/records.ts +56 -0
  350. package/src/redirects.ts +59 -0
  351. package/src/resource.ts +245 -0
  352. package/src/richtext.ts +402 -0
  353. package/src/schema-json.ts +112 -0
  354. package/src/search.ts +89 -0
  355. package/src/seo.ts +477 -0
  356. package/src/server/accounts.ts +418 -0
  357. package/src/server/ai.ts +33 -0
  358. package/src/server/api-tokens.ts +91 -0
  359. package/src/server/areas.ts +116 -0
  360. package/src/server/audit.ts +94 -0
  361. package/src/server/auth.ts +89 -0
  362. package/src/server/automations.ts +190 -0
  363. package/src/server/autosaves.ts +69 -0
  364. package/src/server/brand-icons.ts +50 -0
  365. package/src/server/brands.ts +86 -0
  366. package/src/server/budget.ts +97 -0
  367. package/src/server/cache.ts +104 -0
  368. package/src/server/capabilities.ts +333 -0
  369. package/src/server/cloudflare.ts +92 -0
  370. package/src/server/comments.ts +237 -0
  371. package/src/server/drafts.ts +176 -0
  372. package/src/server/field-groups.ts +88 -0
  373. package/src/server/files.ts +780 -0
  374. package/src/server/forms.ts +726 -0
  375. package/src/server/handoffs.ts +107 -0
  376. package/src/server/host-schema.ts +312 -0
  377. package/src/server/host.ts +2892 -0
  378. package/src/server/images.ts +34 -0
  379. package/src/server/index.ts +59 -0
  380. package/src/server/indexnow.ts +91 -0
  381. package/src/server/isolation.ts +183 -0
  382. package/src/server/locked.ts +45 -0
  383. package/src/server/mail.ts +93 -0
  384. package/src/server/markdown.ts +24 -0
  385. package/src/server/menus.ts +286 -0
  386. package/src/server/network-policy.ts +60 -0
  387. package/src/server/network.ts +665 -0
  388. package/src/server/notes.ts +275 -0
  389. package/src/server/outbox.ts +213 -0
  390. package/src/server/path-moves.ts +33 -0
  391. package/src/server/payments.ts +59 -0
  392. package/src/server/previews.ts +62 -0
  393. package/src/server/purge.ts +140 -0
  394. package/src/server/reconcile.ts +38 -0
  395. package/src/server/redirects.ts +183 -0
  396. package/src/server/repository.ts +1107 -0
  397. package/src/server/schedules.ts +105 -0
  398. package/src/server/schema.ts +562 -0
  399. package/src/server/security.ts +391 -0
  400. package/src/server/seed.ts +52 -0
  401. package/src/server/shared-fields.ts +34 -0
  402. package/src/server/site-export.ts +151 -0
  403. package/src/server/site-import.ts +482 -0
  404. package/src/server/site-search.ts +289 -0
  405. package/src/server/site-settings.ts +286 -0
  406. package/src/server/sites.ts +243 -0
  407. package/src/server/stores.ts +314 -0
  408. package/src/server/stripe.ts +173 -0
  409. package/src/server/taxonomies.ts +415 -0
  410. package/src/server/tokens.ts +25 -0
  411. package/src/server/traffic.ts +118 -0
  412. package/src/server/users.ts +653 -0
  413. package/src/server/webhooks.ts +245 -0
  414. package/src/settings-controls.ts +54 -0
  415. package/src/settings-document.ts +111 -0
  416. package/src/settings.ts +426 -0
  417. package/src/storage/cloudflare.ts +94 -0
  418. package/src/storage/index.ts +30 -0
  419. package/src/storage/node.ts +114 -0
  420. package/src/taxonomy.ts +51 -0
  421. package/src/theme.ts +1135 -0
  422. package/src/to-markdown.ts +179 -0
  423. package/src/updates.ts +126 -0
  424. package/src/version.ts +2 -0
  425. package/src/vite.d.ts +25 -0
  426. package/src/vite.js +199 -0
  427. package/src/webhooks.ts +107 -0
@@ -0,0 +1,189 @@
1
+ import { Cossack, Page, State, Server, Client, type HeadValue } from '@cossackframework/core';
2
+ import { input } from '@cossackframework/core/input';
3
+ import { settingsSectionHref } from '#app/cms/settings-search';
4
+ import { Badge, Button, Card, CardBody, CardHeader } from '@cossackframework/ui';
5
+ import { html, component, type TemplateResult } from '@cossackframework/renderer';
6
+ import { ANONYMOUS, ARTICLE_TYPES, CmsError, CRAWLER_GROUPS, hasPermission, isCmsError, PERMISSIONS, recordTitle, type FieldFilter } from '@cossackframework/cms';
7
+ import type { CrawlerVisits, NotFoundRow } from '@cossackframework/cms/server';
8
+ import { requireAny } from '#app/cms/guards';
9
+ import { siteOrigin } from '#app/cms/seo';
10
+ import { notice, pageHeader, shortDate } from '#app/cms/ui';
11
+
12
+ interface Finding { id: string; tone: 'ok' | 'warn' | 'info'; title: string; detail: string; href?: string; items?: { title: string; href: string }[] }
13
+
14
+ const KINDS = ['entry', 'archive', 'home', 'term', 'author', 'search', 'markdown', 'llms', 'sitemap', 'robots', 'feed', 'not-found'] as const;
15
+ const GROUP_LABELS: Record<string, string> = Object.fromEntries(CRAWLER_GROUPS.map(group => [group.id, group.label]));
16
+
17
+ /**
18
+ * How the site stands with search and answer engines: what crawlers fetched in the last two
19
+ * weeks, which paths visitors miss, and content that is not ready (no summary, hidden entries
20
+ * that are linked, authors without a profile), with the settings that matter.
21
+ */
22
+ @Page({ transport: 'http', middlewares: [requireAny(PERMISSIONS.manageSettings, PERMISSIONS.manageRedirects)] })
23
+ export default class HealthPage extends Cossack {
24
+ @State() visits: CrawlerVisits[] = [];
25
+ @State() missing: NotFoundRow[] = [];
26
+ @State() findings: Finding[] = [];
27
+ @State() days = 14;
28
+ @State() error = '';
29
+ /** What the last dismissal did, shown with the missing pages. */
30
+ @State() message = '';
31
+ /** The site search index: entries it holds, and whether a rebuild runs. */
32
+ @State() search: { entries: number; rebuilding: boolean } = { entries: 0, rebuilding: false };
33
+ @State() canRebuild = false;
34
+ @State() searchMessage = '';
35
+
36
+ head(): HeadValue {
37
+ return { title: __('Health') };
38
+ }
39
+
40
+ async init() {
41
+ await this.load();
42
+ }
43
+
44
+ @Server()
45
+ async load() {
46
+ const cms = this.c.get('cms');
47
+ try {
48
+ this.search = await cms.siteSearch.status();
49
+ this.canRebuild = hasPermission(this.c.get('principal'), PERMISSIONS.manageSettings);
50
+ this.visits = await cms.traffic.visits(this.days);
51
+ this.missing = await cms.traffic.notFound({ limit: 50 });
52
+ this.findings = await this.inspect();
53
+ } catch (error) {
54
+ if (!isCmsError(error)) throw error;
55
+ this.error = error.message;
56
+ }
57
+ }
58
+
59
+ /** Content and settings findings, worst first. */
60
+ private async inspect(): Promise<Finding[]> {
61
+ const cms = this.c.get('cms');
62
+ const settings = await cms.settings.all();
63
+ const findings: Finding[] = [];
64
+ const origin = siteOrigin(this.c);
65
+ if (settings['reading.discourageSearchEngines']) findings.push({ id: 'hidden', tone: 'warn', title: __('The site is hidden from search engines'), detail: __('Settings → Reading asks every engine to stay away; nothing below matters until that is off.'), href: settingsSectionHref('reading') });
66
+ if (!cms.mail) findings.push({ id: 'mail', tone: 'warn', title: __('No email sender'), detail: __('Password resets, form notifications, comment and note emails are not sent. Bind EMAIL (Cloudflare Email Service), or set SMTP_HOST, SMTP_USER and SMTP_PASS on Node, and MAIL_FROM for the sender.') });
67
+ else if (cms.mailFrom === 'no-reply@example.com') findings.push({ id: 'mail-from', tone: 'info', title: __('MAIL_FROM is not set'), detail: __('Emails go out from no-reply@example.com, which receivers may refuse. Set MAIL_FROM to an address on a domain you send from.') });
68
+ if (!cms.ai) findings.push({ id: 'ai', tone: 'info', title: __('No AI provider'), detail: __('Set ANTHROPIC_API_KEY (and ANTHROPIC_MODEL), or bind Workers AI as AI, for the editor\'s Assistant and for plugins that ask for ai.') });
69
+ if (!env('APP_URL', '')) findings.push({ id: 'app-url', tone: 'warn', title: __('APP_URL is not set'), detail: `${__('Canonical URLs, structured data and IndexNow pings use the request\'s origin instead; set APP_URL to the public address')} (${origin}).` });
70
+ if (!settings['seo.logo']) findings.push({ id: 'logo', tone: 'info', title: __('No publisher logo'), detail: __('Settings → SEO → Logo gives the Organization node an image; engines show it next to the site in results and answers.'), href: settingsSectionHref('seo') });
71
+ if (!settings['seo.sameAs'].trim()) findings.push({ id: 'same-as', tone: 'info', title: __('No publisher profiles'), detail: __('Settings → SEO → Profiles tells engines which entity publishes the site (social accounts, Wikidata).'), href: settingsSectionHref('seo') });
72
+ if (!settings['indexnow.enabled']) findings.push({ id: 'indexnow', tone: 'info', title: __('IndexNow is off'), detail: __('Turn it on under Settings → IndexNow so Bing, Yandex and the answers built on them learn of changes within minutes.'), href: settingsSectionHref('indexnow') });
73
+ if (!cms.purge.configured && settings['cache.hold'] !== 'none') findings.push({ id: 'cache-purger', tone: 'info', title: __('No cache purger'), detail: __('A cache in front of the site holds pages until their hold ends. Set CLOUDFLARE_API_TOKEN so changes purge Cloudflare at once; Tools → Cache shows the purges.'), href: '/dashboard/tools/cache' });
74
+ if (!settings['crawlers.allowSearch']) findings.push({ id: 'search-blocked', tone: 'warn', title: __('Search engines are blocked in robots.txt'), detail: __('Settings → Crawlers turns Googlebot and Bingbot away, which also removes the site from AI Overviews and Copilot.'), href: settingsSectionHref('crawlers') });
75
+ if (!settings['crawlers.allowAiSearch']) findings.push({ id: 'ai-search-blocked', tone: 'info', title: __('AI search crawlers are blocked'), detail: __('ChatGPT search, Claude and Perplexity cannot cite the site. Intended? Then this is fine.'), href: settingsSectionHref('crawlers') });
76
+ findings.push({ id: 'cdn', tone: 'info', title: __('Behind Cloudflare? Check its AI bot settings'), detail: __('New Cloudflare zones block AI crawlers by default. The block covers AI search crawlers too, and some rules catch search engines; robots.txt cannot override it. Review Security → Bots in the Cloudflare dashboard.') });
77
+
78
+ const collections = cms.collections().filter(collection => typeof collection.path === 'string' && collection.publishable !== false && !collection.managed);
79
+ const noSummary: { title: string; href: string }[] = [];
80
+ const hiddenLinked: { title: string; href: string }[] = [];
81
+ const noDescription: { title: string; href: string }[] = [];
82
+ let published = 0;
83
+ for (const collection of collections) {
84
+ const where: { [field: string]: FieldFilter } = { status: 'published' };
85
+ const page = await cms.resource(`cms/${collection.name}`).list({ where, limit: 100, order: { field: 'publishedAt', direction: 'desc' } }, { principal: ANONYMOUS }).catch(() => ({ records: [] }));
86
+ const article = ARTICLE_TYPES.has(collection.schema?.type ?? 'WebPage');
87
+ for (const record of page.records) {
88
+ published++;
89
+ const href = `/dashboard/content/${collection.name}/${record.id}`;
90
+ const seo = (record.seo ?? {}) as { description?: string; noindex?: boolean; cornerstone?: boolean };
91
+ if (article && !(typeof record.summary === 'string' && record.summary.trim())) noSummary.push({ title: recordTitle(record, 'title'), href });
92
+ if (!seo.description && !(typeof record.summary === 'string' && record.summary.trim()) && !record.excerpt) noDescription.push({ title: recordTitle(record, 'title'), href });
93
+ if (seo.noindex && seo.cornerstone) hiddenLinked.push({ title: recordTitle(record, 'title'), href });
94
+ }
95
+ }
96
+ if (noSummary.length) findings.push({ id: 'summary', tone: 'warn', title: `${noSummary.length} ${noSummary.length === 1 ? __('article has no summary') : __('articles have no summary')}`, detail: __('The summary is the answer engines quote and the meta description falls back to. Add one in each entry\'s Search and sharing box.'), items: noSummary.slice(0, 10) });
97
+ if (noDescription.length) findings.push({ id: 'description', tone: 'info', title: `${noDescription.length} ${noDescription.length === 1 ? __('entry has nothing to describe it') : __('entries have nothing to describe them')}`, detail: __('No meta description, summary or excerpt: engines choose a passage themselves. The SEO editor fills them in for many entries at once.'), href: '/dashboard/tools/seo?filter=missing', items: noDescription.slice(0, 10) });
98
+ if (hiddenLinked.length) findings.push({ id: 'hidden-cornerstone', tone: 'warn', title: `${hiddenLinked.length} ${__('cornerstone entries are hidden from search engines')}`, detail: __('They are marked noindex and cornerstone at once; one of the two is wrong.'), items: hiddenLinked });
99
+ if (settings['seo.authorPages']) {
100
+ const authors = await cms.users.authors({ limit: 200 });
101
+ const bare = authors.filter(user => !(typeof user.meta.bio === 'string' && user.meta.bio.trim()));
102
+ if (authors.length && bare.length) findings.push({ id: 'authors', tone: 'info', title: `${bare.length} ${bare.length === 1 ? __('author has no bio') : __('authors have no bio')}`, detail: __('Author pages and Person nodes show the bio, job title, website and profiles from each user\'s Public profile.'), items: bare.slice(0, 10).map(user => ({ title: user.name, href: '/dashboard/profile/public' })) });
103
+ }
104
+ if (published && !noSummary.length && !hiddenLinked.length) findings.push({ id: 'content-ok', tone: 'ok', title: __('Content is ready'), detail: `${published} ${__('published entries read; every article has a summary.')}` });
105
+ return findings.sort((a, b) => ['warn', 'info', 'ok'].indexOf(a.tone) - ['warn', 'info', 'ok'].indexOf(b.tone));
106
+ }
107
+
108
+ @Client()
109
+ async rebuild() {
110
+ this.searchMessage = '';
111
+ await this.rebuildSearch();
112
+ this.searchMessage = __('Rebuilding: the index fills in the background, a few hundred entries at a time.');
113
+ }
114
+
115
+ /** Clear the search index and fill it again from the entries. */
116
+ @Server()
117
+ async rebuildSearch() {
118
+ if (!hasPermission(this.c.get('principal'), PERMISSIONS.manageSettings)) throw new CmsError('CMS_FORBIDDEN', 'Rebuilding the search index needs the Manage settings permission.');
119
+ const cms = this.c.get('cms');
120
+ await cms.siteSearch.rebuild();
121
+ this.search = await cms.siteSearch.status();
122
+ }
123
+
124
+ @Client()
125
+ async forget(path: string) {
126
+ this.message = '';
127
+ await this.forgetMissing(path);
128
+ this.message = __('Removed from the list.');
129
+ }
130
+
131
+ @Server({ input: input.args(input.string({ minLength: 1, maxLength: 200 })) })
132
+ async forgetMissing(path: string) {
133
+ await this.c.get('cms').traffic.forgetNotFound(path);
134
+ this.missing = this.missing.filter(row => row.path !== path);
135
+ }
136
+
137
+ private crawlerTable(): TemplateResult {
138
+ if (!this.visits.length) return html`<p class="text-sm text-muted-foreground">${__('No known crawler fetched the site in this period. Crawlers are counted by their user agent; browsers are not.')}</p>`;
139
+ const kinds = KINDS.filter(kind => this.visits.some(visit => visit.byKind[kind]));
140
+ return html`<div class="overflow-x-auto"><table class="w-full text-sm">
141
+ <thead><tr class="text-left text-xs uppercase text-muted-foreground"><th class="py-1 pr-3 font-medium">${__('Crawler')}</th><th class="py-1 pr-3 font-medium">${__('Total')}</th>${kinds.map(kind => html`<th class="py-1 pr-3 font-medium">${kind}</th>`)}<th class="py-1 font-medium">${__('Last seen')}</th></tr></thead>
142
+ <tbody>${this.visits.map(visit => html`<tr class="border-t border-border">
143
+ <td class="py-1.5 pr-3"><span class="text-foreground">${visit.agent}</span> <span class="text-xs text-muted-foreground">${GROUP_LABELS[visit.group] ?? visit.group}</span></td>
144
+ <td class="py-1.5 pr-3 tabular-nums font-medium text-foreground">${visit.total}</td>
145
+ ${kinds.map(kind => html`<td class="py-1.5 pr-3 tabular-nums text-muted-foreground">${visit.byKind[kind] ?? '—'}</td>`)}
146
+ <td class="py-1.5 text-muted-foreground">${visit.lastDay}</td></tr>`)}</tbody></table></div>`;
147
+ }
148
+
149
+ render() {
150
+ const tone = (value: Finding['tone']) => value === 'ok' ? 'bg-emerald-500' : value === 'warn' ? 'bg-amber-500' : 'bg-sky-500';
151
+ return html`<div class="space-y-6">
152
+ ${pageHeader(__('Health'), { description: __('How the site stands with search and answer engines: what they fetch, what visitors miss, and what to fix.') })}
153
+ ${this.error ? notice(this.error, 'error') : null}
154
+ ${component(Card, {}, html`
155
+ ${component(CardHeader, {}, html`<h2 class="text-base font-semibold text-foreground">${__('Findings')}</h2>`)}
156
+ ${component(CardBody, {}, html`<ul class="divide-y divide-border">${this.findings.map(finding => html`<li class="flex gap-3 py-3">
157
+ <span class=${`mt-1.5 inline-block size-2.5 shrink-0 rounded-full ${tone(finding.tone)}`} aria-hidden="true"></span>
158
+ <div class="min-w-0 space-y-1">
159
+ <p class="text-sm font-medium text-foreground">${finding.href ? html`<a href=${finding.href} class="text-foreground hover:text-primary">${finding.title}</a>` : finding.title}</p>
160
+ <p class="text-sm text-muted-foreground">${finding.detail}</p>
161
+ ${finding.items?.length ? html`<p class="text-sm">${finding.items.map((item, index) => html`${index ? ', ' : ''}<a href=${item.href} class="text-primary hover:underline">${item.title}</a>`)}</p>` : null}
162
+ </div></li>`)}</ul>`)}`)}
163
+ ${component(Card, {}, html`
164
+ ${component(CardHeader, {}, html`<div class="flex flex-wrap items-center justify-between gap-2"><h2 class="text-base font-semibold text-foreground">${__('Site search')}</h2>
165
+ ${this.canRebuild ? component(Button, { type: 'button', size: 'sm', variant: 'outline', disabled: this.search.rebuilding, '@click': () => this.rebuild() }, __('Rebuild')) : null}</div>
166
+ <p class="text-sm text-muted-foreground">${__('The index the site\'s search reads: published entries visitors may read. Each change keeps it in step; rebuild it after an import, or if results look out of date.')}</p>`)}
167
+ ${component(CardBody, { class: 'space-y-2' }, html`${this.searchMessage ? notice(this.searchMessage, 'success') : null}
168
+ <p class="text-sm text-foreground"><span class="tabular-nums font-medium">${this.search.entries}</span> ${this.search.entries === 1 ? __('entry indexed') : __('entries indexed')}${this.search.rebuilding ? html` · <span class="text-muted-foreground">${__('rebuilding')}</span>` : null}</p>`)}`)}
169
+ ${component(Card, {}, html`
170
+ ${component(CardHeader, {}, html`<div class="flex flex-wrap items-center justify-between gap-2"><h2 class="text-base font-semibold text-foreground">${__('Crawler visits')} <span class="text-sm font-normal text-muted-foreground">${__('last')} ${this.days} ${__('days')}</span></h2>
171
+ <div class="flex gap-1">${[7, 14, 30, 90].map(days => component(Button, { type: 'button', size: 'sm', variant: days === this.days ? 'default' : 'outline', '@click': () => { this.days = days; void this.load(); } }, `${days}d`))}</div></div>
172
+ <p class="text-sm text-muted-foreground">${__('Which engines fetch the site, and what: entries, archives, the sitemap, llms.txt, Markdown. If an AI search crawler never shows, check robots.txt and the CDN; if it fetches llms.txt or Markdown, those surfaces are read.')}</p>`)}
173
+ ${component(CardBody, {}, this.crawlerTable())}`)}
174
+ ${component(Card, {}, html`
175
+ ${component(CardHeader, {}, html`<h2 class="text-base font-semibold text-foreground">${__('Missing pages')} <span class="text-sm font-normal text-muted-foreground">(${this.missing.length})</span></h2>
176
+ <p class="text-sm text-muted-foreground">${__('Paths that answered 404 to readers or crawlers, most hit first. Redirect the ones that used to be pages.')}</p>`)}
177
+ ${component(CardBody, { class: 'space-y-3' }, html`${this.message ? notice(this.message, 'success') : null}${this.missing.length ? html`<div class="overflow-x-auto"><table class="w-full text-sm">
178
+ <thead><tr class="text-left text-xs uppercase text-muted-foreground"><th class="py-1 pr-3 font-medium">${__('Path')}</th><th class="py-1 pr-3 font-medium">${__('Hits')}</th><th class="py-1 pr-3 font-medium">${__('Last')}</th><th class="py-1 pr-3 font-medium">${__('From')}</th><th class="py-1 font-medium"></th></tr></thead>
179
+ <tbody>${this.missing.map(row => html`<tr class="border-t border-border">
180
+ <td class="py-1.5 pr-3"><code class="rounded bg-muted px-1.5 py-0.5 text-xs text-foreground">${row.path}</code></td>
181
+ <td class="py-1.5 pr-3 tabular-nums">${row.hits}</td><td class="py-1.5 pr-3 text-muted-foreground">${shortDate(row.lastHitAt)}</td>
182
+ <td class="max-w-48 truncate py-1.5 pr-3 text-xs text-muted-foreground" title=${row.referrer}>${row.referrer ? new URL(row.referrer).host : '—'}</td>
183
+ <td class="py-1.5 text-right whitespace-nowrap"><a href=${`/dashboard/tools/redirects?source=${encodeURIComponent(row.path)}`} class="text-primary hover:underline">${__('Redirect')}</a>
184
+ <button type="button" class="ml-3 text-muted-foreground hover:text-foreground bg-transparent border-none p-0 cursor-pointer" @click=${() => this.forget(row.path)}>${__('Dismiss')}</button></td></tr>`)}</tbody></table></div>`
185
+ : html`<p class="text-sm text-muted-foreground">${__('Nothing missed yet.')}</p>`}`)}`)}
186
+ ${component(Badge, { variant: 'secondary' }, `${__('Counted since the upgrade that added this page; older visits are not known.')}`)}
187
+ </div>`;
188
+ }
189
+ }
@@ -0,0 +1,93 @@
1
+ import { Cossack, Page, State, flash, flashed, type HeadValue } from '@cossackframework/core';
2
+ import { Badge, Card, CardBody, CardHeader } from '@cossackframework/ui';
3
+ import { html, component } from '@cossackframework/renderer';
4
+ import { isCmsError, isSameOriginPost, PERMISSIONS } from '@cossackframework/cms';
5
+ import type { ScheduleRow } from '@cossackframework/cms/server';
6
+ import { requireAny } from '#app/cms/guards';
7
+ import { notice, pageHeader, shortDate } from '#app/cms/ui';
8
+ import { actionButton } from '#app/cms/network-view';
9
+
10
+ interface Waiting { id: string; topic: string; attempts: number; availableAt: number; plugins: string[] | null }
11
+ interface Dead { id: string; topic: string; attempts: number; at: number; plugins: string[] }
12
+
13
+ /**
14
+ * Tools → Jobs: the outbox (after-commit events, webhooks' sources, cache purges, plugin jobs)
15
+ * as it stands: what waits, what failed for good and for which plugins, and the plugins'
16
+ * schedules with their next time. Retry or drop a failed event; run the queue now.
17
+ */
18
+ @Page({ transport: 'http', middlewares: [requireAny(PERMISSIONS.manageSettings)] })
19
+ export default class JobsPage extends Cossack {
20
+ @State() waiting: Waiting[] = [];
21
+ @State() dead: Dead[] = [];
22
+ @State() schedules: ScheduleRow[] = [];
23
+ @State() message = '';
24
+ @State() error = '';
25
+
26
+ head(): HeadValue {
27
+ return { title: 'Jobs' };
28
+ }
29
+
30
+ async init() {
31
+ const cms = this.c.get('cms');
32
+ this.waiting = await cms.outbox.pending({ limit: 100 });
33
+ this.dead = await cms.outbox.deadLettered({ limit: 100 });
34
+ this.schedules = await cms.schedules.list();
35
+ this.message = flashed<string>('jobs.message') ?? '';
36
+ this.error = flashed<string>('jobs.error') ?? '';
37
+ }
38
+
39
+ async post() {
40
+ if (!isSameOriginPost(this.c.req.raw)) return this.c.text('Forbidden', 403);
41
+ const form = await this.c.req.formData();
42
+ const action = String(form.get('action') ?? '');
43
+ const id = String(form.get('id') ?? '');
44
+ const cms = this.c.get('cms');
45
+ try {
46
+ if (action === 'run') {
47
+ await cms.schedules.tick();
48
+ const report = await cms.outbox.dispatch({ limit: 100 });
49
+ await cms.webhooks.dispatch({ limit: 50 });
50
+ flash('jobs.message', `${__('Ran the queue:')} ${report.delivered.length} ${__('delivered')}, ${report.retrying.length} ${__('retrying')}, ${report.deadLettered.length} ${__('given up')}.`);
51
+ } else if (action === 'retry') {
52
+ const retried = await cms.outbox.retry(id);
53
+ flash(retried ? 'jobs.message' : 'jobs.error', retried ? __('Queued again; it runs on the next pass.') : __('Nothing to retry.'));
54
+ } else if (action === 'remove') {
55
+ const removed = await cms.outbox.remove(id);
56
+ flash(removed ? 'jobs.message' : 'jobs.error', removed ? __('Removed.') : __('Nothing to remove.'));
57
+ } else throw new Error(__('Unknown action.'));
58
+ } catch (error) {
59
+ flash('jobs.error', isCmsError(error) || error instanceof Error ? (error as Error).message : __('The action failed.'));
60
+ }
61
+ return this.redirect('/dashboard/tools/jobs');
62
+ }
63
+
64
+ render() {
65
+ const TOPICS: Record<string, string> = { 'plugin.job': __('Plugin job'), 'cache.purge': __('Cache purge'), 'form.submitted': __('Form submission'), 'payment.event': __('Payment'), 'user.registered': __('Registration'), 'user.signed-in': __('Sign-in') };
66
+ const topic = (name: string) => TOPICS[name] ?? __('Content change');
67
+ const row = (entry: { id: string; topic: string; attempts: number; plugins: string[] | null }, when: string, actions: unknown) => html`<li class="flex flex-wrap items-center justify-between gap-2 px-4 py-2 text-sm" data-job=${entry.id}>
68
+ <span><span class="font-medium text-foreground">${topic(entry.topic)}</span> <code class="text-xs text-muted-foreground">${entry.id.length > 60 ? `${entry.id.slice(0, 57)}…` : entry.id}</code>
69
+ <span class="block text-xs text-muted-foreground">${when} · ${entry.attempts} ${__('attempt(s)')}${entry.plugins?.length ? html` · ${__('waiting on')} ${entry.plugins.join(', ')}` : null}</span></span>
70
+ <span class="flex gap-2">${actions}</span></li>`;
71
+ return html`<div class="space-y-6">
72
+ ${pageHeader(__('Jobs'), { description: __('Background work: content events on their way to plugins and webhooks, cache purges, plugin jobs and schedules.') })}
73
+ ${this.message ? notice(this.message, 'success') : null}
74
+ ${this.error ? notice(this.error, 'error') : null}
75
+ <div class="flex flex-wrap gap-2">${actionButton('run', __('Run the queue now'))}</div>
76
+ ${component(Card, {}, html`${component(CardHeader, {}, html`<h2 class="text-base font-semibold text-foreground">${__('Waiting')} ${component(Badge, { variant: 'secondary' }, String(this.waiting.length))}</h2>`)}
77
+ ${component(CardBody, { class: 'p-0' }, this.waiting.length ? html`<ul class="divide-y divide-border" data-testid="jobs-waiting">${this.waiting.map(entry => row(entry, `${__('due')} ${shortDate(entry.availableAt)}`,
78
+ html`${actionButton('retry', __('Run now'), { id: entry.id })}${actionButton('remove', __('Drop'), { id: entry.id }, { danger: true })}`))}</ul>`
79
+ : html`<p class="px-4 py-6 text-sm text-muted-foreground">${__('Nothing is waiting.')}</p>`)}`)}
80
+ ${component(Card, {}, html`${component(CardHeader, {}, html`<h2 class="text-base font-semibold text-foreground">${__('Given up')} ${component(Badge, { variant: this.dead.length ? 'destructive' : 'secondary' }, String(this.dead.length))}</h2>
81
+ <p class="text-sm text-muted-foreground">${__('Events that failed ten times for the plugins listed. Retry once the plugin is fixed, or drop them.')}</p>`)}
82
+ ${component(CardBody, { class: 'p-0' }, this.dead.length ? html`<ul class="divide-y divide-border" data-testid="jobs-dead">${this.dead.map(entry => row(entry, `${__('gave up')} ${shortDate(entry.at)}`,
83
+ html`${actionButton('retry', __('Retry'), { id: entry.id })}${actionButton('remove', __('Drop'), { id: entry.id }, { danger: true })}`))}</ul>`
84
+ : html`<p class="px-4 py-6 text-sm text-muted-foreground">${__('Nothing failed for good.')}</p>`)}`)}
85
+ ${component(Card, {}, html`${component(CardHeader, {}, html`<h2 class="text-base font-semibold text-foreground">${__('Schedules')}</h2>
86
+ <p class="text-sm text-muted-foreground">${__('Jobs the clock queues for active plugins, from their manifests.')}</p>`)}
87
+ ${component(CardBody, { class: 'p-0' }, this.schedules.length ? html`<ul class="divide-y divide-border" data-testid="jobs-schedules">${this.schedules.map(schedule => html`<li class="flex flex-wrap items-center justify-between gap-2 px-4 py-2 text-sm">
88
+ <span><span class="font-medium text-foreground">${schedule.plugin}</span> · ${schedule.name} <code class="text-xs text-muted-foreground">${schedule.cron}</code></span>
89
+ <span class="text-xs text-muted-foreground">${__('next')} ${shortDate(schedule.nextAt)}${schedule.lastAt ? html` · ${__('last')} ${shortDate(schedule.lastAt)}` : null}</span></li>`)}</ul>`
90
+ : html`<p class="px-4 py-6 text-sm text-muted-foreground">${__('No plugin declares a schedule.')}</p>`)}`)}
91
+ </div>`;
92
+ }
93
+ }
@@ -0,0 +1,115 @@
1
+ import { Cossack, Page, State, type HeadValue } from '@cossackframework/core';
2
+ import { Badge, Card, CardBody, CardHeader } from '@cossackframework/ui';
3
+ import { html, component } from '@cossackframework/renderer';
4
+ import { ANONYMOUS, blockLinks, internalLinkPath, isCmsError, markdownLinks, PERMISSIONS, recordTitle, richTextLinks, type Block, type FieldFilter, type RecordShape, type RichTextDoc } from '@cossackframework/cms';
5
+ import { requireAny } from '#app/cms/guards';
6
+ import { notice, pageHeader } from '#app/cms/ui';
7
+
8
+ interface LinkedEntry { id: string; title: string; url: string; collection: string; edit: string; inbound: number; outbound: number; cornerstone: boolean }
9
+
10
+ const SCAN_LIMIT = 2000;
11
+
12
+ /**
13
+ * Internal links across the site's published entries: which entries nothing links to
14
+ * (orphans), which cornerstone entries have few links, and the most linked. Read on request
15
+ * from the entries' content, as a visitor sees them; sites with more than 2,000 entries are sampled.
16
+ */
17
+ @Page({ transport: 'http', middlewares: [requireAny(PERMISSIONS.manageRedirects, PERMISSIONS.manageCollections)] })
18
+ export default class LinksPage extends Cossack {
19
+ @State() entries: LinkedEntry[] = [];
20
+ @State() scanned = 0;
21
+ @State() sampled = false;
22
+ @State() error = '';
23
+
24
+ head(): HeadValue {
25
+ return { title: __('Links') };
26
+ }
27
+
28
+ async init() {
29
+ const cms = this.c.get('cms');
30
+ const host = new URL(this.c.req.url).host;
31
+ try {
32
+ // Visitors' view of the site: collections they cannot read (private ones) have no public pages.
33
+ const readable = new Set(cms.readable(ANONYMOUS).map(resource => resource.id));
34
+ const collections = cms.collections().filter(collection => typeof collection.path === 'string' && collection.slug !== false && !collection.managed && readable.has(`cms/${collection.name}`));
35
+ const found: { record: RecordShape; collection: typeof collections[number]; url: string; links: string[] }[] = [];
36
+ for (const collection of collections) {
37
+ const resource = cms.resourceById(`cms/${collection.name}`);
38
+ const repository = cms.resource(resource.id);
39
+ const where: { [field: string]: FieldFilter } = collection.publishable === false ? {} : { status: 'published' };
40
+ for (let offset = 0; offset < SCAN_LIMIT && found.length < SCAN_LIMIT; offset += 100) {
41
+ const page = await repository.list({ where, limit: 100, offset, order: { field: 'updatedAt', direction: 'desc' } }, { principal: ANONYMOUS });
42
+ const urls = await cms.entryUrls(collection, page.records);
43
+ for (const record of page.records) {
44
+ const url = urls.get(record.id);
45
+ if (!url) continue;
46
+ const links: string[] = [];
47
+ for (const [name, declaration] of Object.entries(resource.fields)) {
48
+ const value = record[name];
49
+ if (declaration.kind === 'blocks' && Array.isArray(value)) links.push(...blockLinks(value as Block[]));
50
+ else if (declaration.kind === 'richtext' && value && typeof value === 'object') links.push(...richTextLinks(value as RichTextDoc));
51
+ else if (declaration.kind === 'text' && declaration.format === 'markdown' && typeof value === 'string') links.push(...markdownLinks(value));
52
+ }
53
+ found.push({ record, collection, url, links });
54
+ }
55
+ if (page.records.length < 100) break;
56
+ if (offset + 100 >= SCAN_LIMIT) this.sampled = true;
57
+ }
58
+ }
59
+ this.scanned = found.length;
60
+ const byUrl = new Map(found.map(entry => [entry.url, entry]));
61
+ const inbound = new Map<string, number>();
62
+ for (const entry of found) {
63
+ for (const href of new Set(entry.links.map(link => internalLinkPath(link, host)).filter((path): path is string => !!path))) {
64
+ const target = byUrl.get(path(href));
65
+ if (target && target !== entry) inbound.set(target.url, (inbound.get(target.url) ?? 0) + 1);
66
+ }
67
+ }
68
+ this.entries = found.map(entry => ({
69
+ id: entry.record.id, title: recordTitle(entry.record, 'title'), url: entry.url, collection: entry.collection.singular, edit: `/dashboard/content/${entry.collection.name}/${entry.record.id}`,
70
+ inbound: inbound.get(entry.url) ?? 0, outbound: new Set(entry.links.map(link => internalLinkPath(link, host)).filter(Boolean)).size,
71
+ cornerstone: (entry.record.seo as { cornerstone?: boolean } | null)?.cornerstone === true,
72
+ }));
73
+ } catch (error) {
74
+ if (!isCmsError(error)) throw error;
75
+ this.error = error.message;
76
+ }
77
+ }
78
+
79
+ private table(rows: LinkedEntry[], empty: string) {
80
+ if (!rows.length) return html`<p class="text-sm text-muted-foreground">${empty}</p>`;
81
+ return html`<div class="overflow-x-auto"><table class="w-full text-sm">
82
+ <thead><tr class="text-left text-xs uppercase text-muted-foreground"><th class="py-1 pr-3 font-medium">${__('Entry')}</th><th class="py-1 pr-3 font-medium">${__('Links in')}</th><th class="py-1 font-medium">${__('Links out')}</th></tr></thead>
83
+ <tbody>${rows.map(row => html`<tr class="border-t border-border">
84
+ <td class="py-1.5 pr-3"><a href=${row.edit} class="text-primary hover:underline">${row.title}</a> <span class="text-xs text-muted-foreground">${row.collection}${row.cornerstone ? html` · ${component(Badge, { variant: 'secondary' }, __('Cornerstone'))}` : ''}</span>
85
+ <div class="truncate text-xs text-muted-foreground">${row.url}</div></td>
86
+ <td class="py-1.5 pr-3 tabular-nums">${row.inbound}</td><td class="py-1.5 tabular-nums">${row.outbound}</td></tr>`)}</tbody></table></div>`;
87
+ }
88
+
89
+ render() {
90
+ const orphans = this.entries.filter(entry => entry.inbound === 0).sort((a, b) => a.title.localeCompare(b.title));
91
+ const weakCornerstones = this.entries.filter(entry => entry.cornerstone && entry.inbound < 3).sort((a, b) => a.inbound - b.inbound);
92
+ const top = [...this.entries].sort((a, b) => b.inbound - a.inbound).slice(0, 20);
93
+ return html`<div class="space-y-6">
94
+ ${pageHeader(__('Links'), { description: `${__('Internal links between the site\'s entries')}: ${this.scanned} ${__('entries read')}${this.sampled ? ` (${__('the newest 2,000')})` : ''}.` })}
95
+ ${this.error ? notice(this.error, 'error') : null}
96
+ ${weakCornerstones.length ? component(Card, {}, html`
97
+ ${component(CardHeader, {}, html`<h2 class="text-base font-semibold text-foreground">${__('Cornerstone entries with few links')}</h2>
98
+ <p class="text-sm text-muted-foreground">${__('Your most important entries should be the most linked. Link to them from related entries and from menus.')}</p>`)}
99
+ ${component(CardBody, {}, this.table(weakCornerstones, ''))}`) : null}
100
+ ${component(Card, {}, html`
101
+ ${component(CardHeader, {}, html`<h2 class="text-base font-semibold text-foreground">${__('Orphaned entries')} <span class="text-sm font-normal text-muted-foreground">(${orphans.length})</span></h2>
102
+ <p class="text-sm text-muted-foreground">${__('No other entry links to these. Engines find them through the sitemap alone and rank them lower; add a link from a related entry.')}</p>`)}
103
+ ${component(CardBody, {}, this.table(orphans, __('Every entry is linked from another one.')))}`)}
104
+ ${component(Card, {}, html`
105
+ ${component(CardHeader, {}, html`<h2 class="text-base font-semibold text-foreground">${__('Most linked')}</h2>`)}
106
+ ${component(CardBody, {}, this.table(top, __('No entries yet.')))}`)}
107
+ </div>`;
108
+ }
109
+ }
110
+
111
+ /** A link without its query and fragment, and without a trailing slash, as entry URLs are compared. */
112
+ function path(href: string): string {
113
+ const clean = href.split(/[?#]/)[0]!;
114
+ return clean.length > 1 ? clean.replace(/\/+$/, '') : clean;
115
+ }
@@ -0,0 +1,161 @@
1
+ import { Cossack, Page, State, Server, Client, type HeadValue } from '@cossackframework/core';
2
+ import { input } from '@cossackframework/core/input';
3
+ import { AlertDialog, Badge, Button, Card, CardBody, Field, Input, NativeSelect, Pagination } from '@cossackframework/ui';
4
+ import { html, component } from '@cossackframework/renderer';
5
+ import { isCmsError, PERMISSIONS, principalId, REDIRECT_STATUSES, type Redirect, type RedirectStatus } from '@cossackframework/cms';
6
+ import { requireAny } from '#app/cms/guards';
7
+ import { notice, pageHeader, shortDate } from '#app/cms/ui';
8
+
9
+ const PAGE_SIZE = 20;
10
+ const TYPES: Record<RedirectStatus, string> = { 301: '301 Moved permanently', 302: '302 Found (temporary)', 307: '307 Temporary redirect', 308: '308 Permanent redirect', 410: '410 Gone' };
11
+
12
+ interface Form { id: string; source: string; target: string; status: RedirectStatus; note: string }
13
+ const EMPTY: Form = { id: '', source: '', target: '', status: 301, note: '' };
14
+
15
+ /**
16
+ * Redirects for addresses without content. The CMS adds 301s itself when a published entry's
17
+ * address changes; add your own for moved or retired pages. A source ending in `/*` matches
18
+ * everything below it, and a target ending in `/*` keeps the rest of the path.
19
+ */
20
+ @Page({ transport: 'http', middlewares: [requireAny(PERMISSIONS.manageRedirects)] })
21
+ export default class RedirectsPage extends Cossack {
22
+ @State() items: Redirect[] = [];
23
+ @State() total = 0;
24
+ @State() page = 1;
25
+ @State() search = '';
26
+ @State() kind: '' | 'auto' | 'manual' = '';
27
+ @State() form: Form = { ...EMPTY };
28
+ @State() error = '';
29
+ /** What the last save did. */
30
+ @State() message = '';
31
+ @State() pendingDelete: Redirect | null = null;
32
+
33
+ head(): HeadValue {
34
+ return { title: __('Redirects') };
35
+ }
36
+
37
+ async init() {
38
+ this.search = (this.c.req.query('q') ?? '').slice(0, 200);
39
+ const kind = this.c.req.query('kind');
40
+ this.kind = kind === 'auto' || kind === 'manual' ? kind : '';
41
+ const page = Number(this.c.req.query('page'));
42
+ this.page = Number.isSafeInteger(page) && page > 0 ? page : 1;
43
+ // Tools → Health links a missing path here to redirect it.
44
+ const source = (this.c.req.query('source') ?? '').slice(0, 500);
45
+ if (source.startsWith('/')) this.form = { ...EMPTY, source };
46
+ await this.load();
47
+ }
48
+
49
+ @Server()
50
+ private async load() {
51
+ const { redirects } = this.c.get('cms');
52
+ const result = await redirects.list({ search: this.search, ...(this.kind ? { kind: this.kind } : {}), offset: (this.page - 1) * PAGE_SIZE, limit: PAGE_SIZE });
53
+ this.items = result.items;
54
+ this.total = result.total;
55
+ }
56
+
57
+ @Client()
58
+ edit(item: Redirect) {
59
+ this.form = { id: item.id, source: item.source, target: item.target, status: item.status, note: item.note };
60
+ document.getElementById('redirect-source')?.focus();
61
+ }
62
+
63
+ @Client()
64
+ async submit(event: Event) {
65
+ event.preventDefault();
66
+ const editing = Boolean(this.form.id);
67
+ this.message = '';
68
+ await this.save(this.form);
69
+ if (!this.error) this.message = editing ? __('Redirect updated.') : __('Redirect added.');
70
+ }
71
+
72
+ @Server()
73
+ async save(form: Form) {
74
+ this.error = '';
75
+ try {
76
+ const { redirects } = this.c.get('cms');
77
+ const input = { source: form.source, target: form.target, status: Number(form.status) as RedirectStatus, note: form.note };
78
+ await redirects.save(input, { ...(form.id ? { id: form.id } : {}), by: principalId(this.c.get('principal')) });
79
+ await this.c.get('cms').traffic.forgetNotFound(form.source.trim());
80
+ this.form = { ...EMPTY };
81
+ await this.load();
82
+ } catch (error) {
83
+ this.error = isCmsError(error) ? error.message : __('The redirect could not be saved.');
84
+ }
85
+ }
86
+
87
+ @Server({ input: input.args(input.string({ minLength: 1, maxLength: 200 })) })
88
+ async remove(id: string) {
89
+ this.message = '';
90
+ await this.c.get('cms').redirects.delete(id);
91
+ if (this.form.id === id) this.form = { ...EMPTY };
92
+ await this.load();
93
+ }
94
+
95
+ private href(changes: Record<string, string | number>) {
96
+ const next = { q: this.search, kind: this.kind, page: this.page, ...changes };
97
+ const params = new URLSearchParams(Object.entries(next).filter(([key, value]) => value && !(key === 'page' && Number(value) <= 1)).map(([key, value]) => [key, String(value)]));
98
+ return `/dashboard/tools/redirects${params.size ? `?${params}` : ''}`;
99
+ }
100
+
101
+ render() {
102
+ const totalPages = Math.max(1, Math.ceil(this.total / PAGE_SIZE));
103
+ const gone = Number(this.form.status) === 410;
104
+ return html`<div class="space-y-6">
105
+ ${pageHeader(__('Redirects'), { description: __('Send visitors from addresses without content to new ones. Redirects never hide a live page.') })}
106
+ ${this.message ? notice(this.message, 'success') : null}
107
+ ${this.error ? notice(this.error, 'error') : null}
108
+ ${component(Card, {}, component(CardBody, {}, html`<form class="grid gap-4 md:grid-cols-[1fr_1fr_14rem]" @submit=${(event: Event) => this.submit(event)}>
109
+ ${component(Field, { label: __('Source path'), for: 'redirect-source', hint: __('Such as /old-page, or /old/* for everything below it.'),
110
+ control: attributes => component(Input, { ...attributes, required: true, placeholder: '/old-page', '.value': this.form.source, '@input': (event: Event) => { this.form = { ...this.form, source: (event.target as HTMLInputElement).value }; } }) })}
111
+ ${component(Field, { label: __('Target'), for: 'redirect-target', hint: gone ? __('Gone pages have no target.') : __('A path or a full URL; /new/* keeps the rest of the path.'),
112
+ control: attributes => component(Input, { ...attributes, disabled: gone, placeholder: '/new-page', '.value': gone ? '' : this.form.target, '@input': (event: Event) => { this.form = { ...this.form, target: (event.target as HTMLInputElement).value }; } }) })}
113
+ ${component(Field, { label: __('Type'), for: 'redirect-status',
114
+ control: attributes => component(NativeSelect, { ...attributes, '@change': (event: Event) => { this.form = { ...this.form, status: Number((event.target as HTMLSelectElement).value) as RedirectStatus }; } }, html`
115
+ ${REDIRECT_STATUSES.map(status => html`<option value=${status} ?selected=${Number(this.form.status) === status}>${__(TYPES[status])}</option>`)}`) })}
116
+ <div class="md:col-span-2">${component(Field, { label: __('Note'), for: 'redirect-note',
117
+ control: attributes => component(Input, { ...attributes, maxlength: 200, '.value': this.form.note, '@input': (event: Event) => { this.form = { ...this.form, note: (event.target as HTMLInputElement).value }; } }) })}</div>
118
+ <div class="flex items-end gap-2">
119
+ ${component(Button, { type: 'submit' }, this.form.id ? __('Update redirect') : __('Add redirect'))}
120
+ ${this.form.id ? component(Button, { type: 'button', variant: 'ghost', '@click': () => { this.form = { ...EMPTY }; } }, __('Cancel')) : null}
121
+ </div>
122
+ </form>`))}
123
+ <div class="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between">
124
+ <nav aria-label=${__('Filter by kind')} class="flex gap-3 text-sm">
125
+ ${([['', __('All')], ['manual', __('Added by people')], ['auto', __('Automatic')]] as const).map(([value, label]) => html`<a href=${this.href({ kind: value, page: 1 })}
126
+ aria-current=${this.kind === value ? 'page' : 'false'} class=${this.kind === value ? 'font-semibold text-foreground no-underline' : 'text-primary no-underline hover:underline'}>${label}</a>`)}
127
+ </nav>
128
+ <form method="get" class="flex flex-wrap gap-2" role="search">
129
+ ${this.kind ? html`<input type="hidden" name="kind" value=${this.kind}>` : null}
130
+ ${component(Input, { type: 'search', name: 'q', size: 'sm', value: this.search, placeholder: __('Search redirects'), 'aria-label': __('Search redirects') })}
131
+ ${component(Button, { type: 'submit', size: 'sm', variant: 'outline' }, __('Search'))}
132
+ </form>
133
+ </div>
134
+ ${component(Card, {}, component(CardBody, { class: 'p-0' }, html`<div class="overflow-x-auto"><table class="w-full text-sm">
135
+ <thead><tr class="border-b border-border text-left text-xs uppercase tracking-wide text-muted-foreground">
136
+ <th class="px-3 py-2 font-medium">${__('Source')}</th><th class="px-3 py-2 font-medium">${__('Target')}</th><th class="px-3 py-2 font-medium">${__('Type')}</th>
137
+ <th class="px-3 py-2 font-medium">${__('Hits')}</th><th class="px-3 py-2 font-medium"><span class="sr-only">${__('Actions')}</span></th>
138
+ </tr></thead>
139
+ <tbody>${this.items.map(item => html`<tr class="border-b border-border last:border-0 align-top" data-redirect=${item.source}>
140
+ <td class="px-3 py-2"><code class="break-all text-foreground">${item.source}</code>${item.note ? html`<span class="block text-xs text-muted-foreground">${item.note}</span>` : null}</td>
141
+ <td class="px-3 py-2"><code class="break-all text-muted-foreground">${item.status === 410 ? '—' : item.target}</code></td>
142
+ <td class="px-3 py-2"><span class="flex flex-wrap gap-1">${component(Badge, { variant: item.status === 410 ? 'destructive' : 'secondary' }, String(item.status))}
143
+ ${item.kind === 'auto' ? component(Badge, { variant: 'outline' }, __('Automatic')) : null}</span></td>
144
+ <td class="px-3 py-2 text-muted-foreground">${item.hits}${item.lastHitAt ? html`<span class="block text-xs">${shortDate(item.lastHitAt)}</span>` : null}</td>
145
+ <td class="px-3 py-2 text-right"><span class="flex justify-end gap-3 text-xs">
146
+ <button type="button" class="text-primary hover:underline bg-transparent border-none p-0 cursor-pointer" @click=${() => this.edit(item)}>${__('Edit')}</button>
147
+ <button type="button" class="text-destructive hover:underline bg-transparent border-none p-0 cursor-pointer" @click=${() => { this.pendingDelete = item; }}>${__('Delete')}</button>
148
+ </span></td>
149
+ </tr>`)}</tbody></table>
150
+ ${this.items.length ? null : html`<p class="px-4 py-10 text-center text-sm text-muted-foreground">${__('No redirects yet.')}</p>`}</div>`))}
151
+ ${totalPages > 1 ? component(Pagination, { page: this.page, totalPages, label: __('Pagination'), previousLabel: __('Previous page'), nextLabel: __('Next page'),
152
+ pageLabel: (page: number) => `${__('Page')} ${page}`, href: (page: number) => this.href({ page }) }) : null}
153
+ ${component(AlertDialog, {
154
+ id: 'delete-redirect-dialog', open: this.pendingDelete !== null, title: __('Delete this redirect?'),
155
+ description: this.pendingDelete ? `${this.pendingDelete.source} ${__('will answer “Page not found” again.')}` : '',
156
+ cancelLabel: __('Cancel'), actionLabel: __('Delete'), actionVariant: 'destructive',
157
+ onAction: () => { const item = this.pendingDelete; this.pendingDelete = null; if (item) void this.remove(item.id); }, onOpenChange: () => { this.pendingDelete = null; },
158
+ })}
159
+ </div>`;
160
+ }
161
+ }