@cossackframework/cms 0.0.0 → 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 +145 -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 +114 -2
  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,10 @@
1
+ /** The icon picker of taxonomy terms and collections: the whole catalog, searchable and by category. Client-safe. */
2
+ import { component, type TemplateResult } from '@cossackframework/renderer';
3
+ import { Field, IconPicker } from '@cossackframework/ui';
4
+ import { ICON_CATALOG } from './icons';
5
+
6
+ /** An icon field: every icon of the catalog, searched or browsed by category. `allowEmpty` offers None. */
7
+ export function iconSelect(id: string, value: string, change: (value: string) => void, error?: string, options: { hint?: string; allowEmpty?: boolean } = {}): TemplateResult {
8
+ return component(Field, { label: __('Icon'), for: `${id}-picker`, ...(error ? { error } : {}), hint: options.hint ?? __('Shown beside the term in menus and lists.'),
9
+ control: () => component(IconPicker, { id, value, icons: ICON_CATALOG, label: __('Icon'), allowEmpty: options.allowEmpty !== false, onChange: (name: string) => change(name) }) });
10
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Counting what crawlers fetch and what visitors miss, in the background of a request so
3
+ * pages never wait on the write. Server-only.
4
+ */
5
+ import type { Context } from 'hono';
6
+ import type { VisitKind } from '@cossackframework/cms/server';
7
+
8
+ function later(c: Context, work: Promise<unknown>): void {
9
+ const settled = work.catch(error => console.error('[cms] traffic could not be recorded', error));
10
+ try { c.executionCtx.waitUntil(settled); } catch { /* Node keeps running the promise. */ }
11
+ }
12
+
13
+ /** Count the request when a known crawler made it. */
14
+ export function trackCrawler(c: Context, kind: VisitKind): void {
15
+ const agent = c.req.header('user-agent') ?? '';
16
+ const cms = c.get('cms');
17
+ if (!cms || !agent || !/bot|spider|crawl|slurp|-user\b|ChatGPT|Claude|Perplexity|Diffbot|Google|Bytespider|Amazonbot/i.test(agent)) return;
18
+ later(c, cms.traffic.recordVisit(agent, kind));
19
+ }
20
+
21
+ /** Record a page path that answered 404, with its referrer. */
22
+ export function trackNotFound(c: Context): void {
23
+ const cms = c.get('cms');
24
+ if (!cms || (c.req.method !== 'GET' && c.req.method !== 'HEAD')) return;
25
+ later(c, cms.traffic.recordNotFound(c.req.path, c.req.header('referer')));
26
+ }
@@ -0,0 +1,170 @@
1
+ /** Small view helpers shared by the CMS dashboard screens. */
2
+ import { Client, ClientState, Component, Cossack } from '@cossackframework/core';
3
+ import { component, html, ifDefined, type TemplateResult } from '@cossackframework/renderer';
4
+ import { Alert, Badge, Icon, Tooltip } from '@cossackframework/ui';
5
+ import { icon } from './icons';
6
+
7
+ /** A small square button with an icon alone; its label is a tooltip and its accessible name. */
8
+ export function iconButton(id: string, name: string, label: string, run: (event: Event) => void, options: { disabled?: boolean; danger?: boolean; pressed?: boolean; class?: string; size?: 'sm' | 'md' } = {}): TemplateResult {
9
+ const size = options.size === 'md' ? 'h-8 w-8' : 'h-7 w-7';
10
+ const tone = options.danger ? 'hover:border-destructive/40 hover:bg-destructive/10 hover:text-destructive' : 'hover:bg-muted hover:text-foreground';
11
+ return component(Tooltip, { id: `${id}-tip`, label }, html`<button type="button" aria-describedby=${`${id}-tip`} aria-label=${label} ?disabled=${options.disabled === true}
12
+ aria-pressed=${ifDefined(options.pressed === undefined ? undefined : options.pressed ? 'true' : 'false')}
13
+ class=${`inline-flex ${size} items-center justify-center rounded border border-border bg-background text-muted-foreground cursor-pointer disabled:cursor-default disabled:opacity-40 [&_svg]:size-4 ${tone} ${options.class ?? ''}`}
14
+ @click=${run}>${component(Icon, { entry: icon(name), size: 16 })}</button>`);
15
+ }
16
+
17
+ // Tab, page and list helpers live with the shared dashboard shell, which the users screen uses without the CMS.
18
+ export { countBadge, rememberTab, tabFromQuery } from '../dashboard/tabs';
19
+ export { clampPerPage, saveScreenPreferences, screenCookie, screenHelp, screenOptions, screenPreferences, type ScreenPreferences } from '../dashboard/page';
20
+ export { linkButton, notice, pageHeader, type NoticeTone } from '@cossackframework/ui/blocks';
21
+
22
+ /** Labels of entry statuses. */
23
+ export const STATUS_LABELS: Record<string, string> = { draft: 'Draft', pending: 'Pending review', scheduled: 'Scheduled', published: 'Published', trash: 'Trash' };
24
+
25
+ export function statusBadge(status: unknown): TemplateResult | null {
26
+ if (status === 'published') return component(Badge, { variant: 'success' }, __('Published'));
27
+ if (status === 'scheduled') return component(Badge, { variant: 'default' }, __('Scheduled'));
28
+ if (status === 'pending') return component(Badge, { variant: 'warning' }, __('Pending review'));
29
+ if (status === 'draft') return component(Badge, { variant: 'secondary' }, __('Draft'));
30
+ if (status === 'trash') return component(Badge, { variant: 'destructive' }, __('Trash'));
31
+ return null;
32
+ }
33
+
34
+ /** `2026/10/16 at 3:45 pm` in UTC, as dashboard lists show times. */
35
+ export function shortDate(value: unknown): string {
36
+ if (typeof value !== 'number') return '';
37
+ const date = new Date(value);
38
+ const pad = (part: number) => String(part).padStart(2, '0');
39
+ const hours = date.getUTCHours();
40
+ return `${date.getUTCFullYear()}/${pad(date.getUTCMonth() + 1)}/${pad(date.getUTCDate())} ${__('at')} ${hours % 12 || 12}:${pad(date.getUTCMinutes())} ${hours < 12 ? 'am' : 'pm'}`;
41
+ }
42
+
43
+ export const CONTROL = 'w-full rounded-md border border-input bg-background px-3 py-2 text-sm text-foreground focus:outline-none focus:ring-2 focus:ring-ring';
44
+
45
+ export type MetaBoxProps = {
46
+ title: string;
47
+ body: TemplateResult | TemplateResult[] | null;
48
+ /** The heading's ID; also the key the open state is remembered under. */
49
+ id?: string;
50
+ /** Something beside the title, such as a count or a link. */
51
+ extra?: TemplateResult | null;
52
+ /** Start collapsed. */
53
+ collapsed?: boolean;
54
+ };
55
+
56
+ /**
57
+ * A boxed section like a WordPress meta box: its heading toggles the body with an animated
58
+ * collapse, and the state is remembered per box in this browser.
59
+ */
60
+ @Component()
61
+ export class MetaBox extends Cossack {
62
+ declare props: MetaBoxProps;
63
+ /** The visitor's choice; null until they toggle or a remembered state loads. */
64
+ @ClientState() private open: boolean | null = null;
65
+
66
+ private get key(): string {
67
+ return `cms.box.${this.props.id ?? this.props.title}`;
68
+ }
69
+
70
+ private get isOpen(): boolean {
71
+ return this.open ?? this.props.collapsed !== true;
72
+ }
73
+
74
+ onMount() {
75
+ try {
76
+ const stored = localStorage.getItem(this.key);
77
+ if (stored === 'open' || stored === 'closed') this.open = stored === 'open';
78
+ } catch { /* storage unavailable */ }
79
+ }
80
+
81
+ @Client()
82
+ toggle() {
83
+ this.open = !this.isOpen;
84
+ try { localStorage.setItem(this.key, this.open ? 'open' : 'closed'); } catch { /* storage unavailable */ }
85
+ }
86
+
87
+ render(): TemplateResult {
88
+ const open = this.isOpen;
89
+ const heading = this.props.id ?? '';
90
+ const panel = heading ? `${heading}-panel` : '';
91
+ return html`<section class="cs-meta-box rounded-lg border border-border bg-card" aria-labelledby=${ifDefined(heading || undefined)}>
92
+ <h2 id=${ifDefined(heading || undefined)} class=${`flex items-center gap-2 bg-muted/50 px-4 py-2.5 text-sm font-semibold text-foreground ${open ? 'rounded-t-lg border-b border-border' : 'rounded-lg'}`}>
93
+ <button type="button" class="flex min-w-0 flex-1 items-center gap-2 border-none bg-transparent p-0 text-left text-sm font-semibold text-foreground cursor-pointer"
94
+ aria-expanded=${open ? 'true' : 'false'} aria-controls=${ifDefined(panel || undefined)} aria-label=${`${open ? __('Collapse') : __('Expand')} ${this.props.title}`} @click=${() => this.toggle()}>
95
+ <span class=${`inline-flex shrink-0 text-muted-foreground transition-transform duration-200 motion-reduce:transition-none [&_svg]:size-4 ${open ? 'rotate-90' : ''}`} aria-hidden="true">${component(Icon, { entry: icon('alt-arrow-right'), size: 16 })}</span>
96
+ <span class="min-w-0 flex-1 truncate">${this.props.title}</span>
97
+ </button>
98
+ ${this.props.extra ?? null}
99
+ </h2>
100
+ <div id=${ifDefined(panel || undefined)} class=${`grid transition-[grid-template-rows] duration-200 ease-out motion-reduce:transition-none ${open ? 'grid-rows-[1fr]' : 'grid-rows-[0fr]'}`} ?inert=${!open} aria-hidden=${open ? 'false' : 'true'}>
101
+ <div class="min-h-0 overflow-hidden"><div class="space-y-3 p-4">${this.props.body}</div></div>
102
+ </div>
103
+ </section>`;
104
+ }
105
+ }
106
+
107
+ /** A boxed section in the editor's sidebar, like WordPress meta boxes: collapsible, with its state remembered. */
108
+ export function box(title: string, body: TemplateResult | TemplateResult[] | null, options: { id?: string; extra?: TemplateResult | null; collapsed?: boolean } = {}): TemplateResult {
109
+ return component(MetaBox, { title, body, ...options });
110
+ }
111
+
112
+ /**
113
+ * Who made a plugin or theme: the author's name, and their website as a link showing its
114
+ * address, so both are read without hovering. Nothing when the manifest names no author.
115
+ */
116
+ /** "By Acme · acme.example · Email" under a plugin or theme, from its manifest's author. */
117
+ export function authorLine(author: { name: string; url: string; email: string } | null | undefined): TemplateResult | null {
118
+ if (!author) return null;
119
+ let host = '';
120
+ try { host = author.url ? new URL(author.url).host.replace(/^www\./, '') : ''; } catch { host = author.url; }
121
+ return html`<p class="text-xs text-muted-foreground">${__('By')} <span class="text-foreground">${author.name}</span>${author.url ? html` · <a href=${author.url} target="_blank" rel="noopener noreferrer" class="text-primary hover:underline">${host}</a>` : null}${author.email ? html` · <a href=${`mailto:${author.email}`} class="text-primary hover:underline">${__('Email')}</a>` : null}</p>`;
122
+ }
123
+
124
+ /** A stable hue from a name, for generated artwork. */
125
+ function hue(name: string): number {
126
+ let hash = 0;
127
+ for (const character of name) hash = (hash * 31 + character.codePointAt(0)!) % 360;
128
+ return hash;
129
+ }
130
+
131
+ /** Up to two initials of a name, `?` for none, for avatars without a picture. */
132
+ export function initials(label: string): string {
133
+ return label.split(/[\s-]+/).filter(Boolean).slice(0, 2).map(word => [...word][0]!.toUpperCase()).join('') || '?';
134
+ }
135
+
136
+ /**
137
+ * A plugin's or theme's logo or cover from its `assets/`, or artwork generated from its name
138
+ * when it ships none, so every card stays recognizable.
139
+ */
140
+ export function artwork(kind: 'logo' | 'cover', url: string | null, name: string, label: string, className = ''): TemplateResult {
141
+ if (url) return html`<img src=${url} alt="" loading="lazy" class=${`${kind === 'logo' ? 'size-12 rounded-lg' : 'w-full'} object-cover ${className}`}>`;
142
+ const tone = hue(name);
143
+ if (kind === 'logo') return html`<span aria-hidden="true" class=${`flex size-12 shrink-0 items-center justify-center rounded-lg text-base font-semibold text-white ${className}`}
144
+ style=${`background: hsl(${tone} 55% 45%)`}>${initials(label)}</span>`;
145
+ return html`<div aria-hidden="true" class=${`flex w-full items-center justify-center ${className}`}
146
+ style=${`background: linear-gradient(135deg, hsl(${tone} 70% 58%), hsl(${(tone + 45) % 360} 65% 38%))`}>
147
+ <span class="rounded-lg bg-white/15 px-4 py-2 text-lg font-semibold text-white backdrop-blur-sm">${label}</span>
148
+ </div>`;
149
+ }
150
+
151
+ /**
152
+ * The danger notice of a plugin asking for unrestricted access, above the page's table so no
153
+ * filter or horizontal scroll hides it. `action` is the confirmation, or
154
+ * null for a reader who cannot grant it. It says what granting allows and never calls other
155
+ * plugins safe: only this one skips the checks, and the checks are not a sandbox.
156
+ */
157
+ export function unrestrictedNotice(name: string, action: TemplateResult | null): TemplateResult {
158
+ return html`<div data-testid=${`plugin-unrestricted-${name}`}>${component(Alert, { variant: 'destructive', title: `${__('Danger:')} ${name} ${__('asks for unrestricted access')}` }, html`
159
+ <p>${__('It can do anything: read and change all content and accounts, use the database directly, read the application\'s secrets, reach every site, and send data anywhere. It skips the checks other plugins pass, and its code is already part of this application. Grant this only if you trust its author.')}</p>
160
+ ${action}`)}</div>`;
161
+ }
162
+
163
+ /** The box to tick and the button of an unrestricted grant, in a plain form of its own: it works without JavaScript. */
164
+ export function unrestrictedConfirm(field: { name: string; value: string }, submit: { name: string; value: string; label: string }, hidden: Record<string, string> = {}): TemplateResult {
165
+ return html`<form method="post" class="mt-3 flex flex-wrap items-center gap-3">
166
+ ${Object.entries(hidden).map(([name, value]) => html`<input type="hidden" name=${name} value=${value}>`)}
167
+ <label class="flex items-center gap-2 text-sm font-medium"><input type="checkbox" name=${field.name} value=${field.value} class="size-4 cursor-pointer accent-destructive">${__('I trust this plugin with everything in this application')}</label>
168
+ <button type="submit" name=${submit.name} value=${submit.value} class="inline-flex items-center justify-center rounded-md border-none bg-destructive px-2.5 py-1 text-xs font-medium text-destructive-foreground cursor-pointer">${submit.label}</button>
169
+ </form>`;
170
+ }
@@ -0,0 +1,124 @@
1
+ import { CMS_VERSION, checkForUpdate, compareVersions, type UpdateAnswer, type UpdateCheck } from '@cossackframework/cms';
2
+ import type { CmsNetwork } from '@cossackframework/cms/server';
3
+
4
+ /**
5
+ * The update notice and the Update button (specs/cms-updates.md). The check and the request are
6
+ * the network's: one answer and one pending request for all its sites, kept in the network's state.
7
+ */
8
+ const CHECK = 'updates.check';
9
+ const REQUEST = 'updates.request';
10
+ const DAY = 24 * 3600 * 1000;
11
+
12
+ export interface UpdateSettings { check: boolean; url: string; channel: string }
13
+
14
+ /** An update a person asked the project's pipeline for. */
15
+ export interface UpdateRequest {
16
+ version: string;
17
+ requestedAt: number;
18
+ /** The user's ID. */
19
+ requestedBy: string;
20
+ }
21
+
22
+ export interface UpdateHook { url: string; token: string }
23
+
24
+ /** The hook from the environment, never from the database: both values, or none. */
25
+ export function updateHook(env: { CMS_UPDATE_HOOK_URL?: string; CMS_UPDATE_HOOK_TOKEN?: string }): UpdateHook | null {
26
+ const url = env.CMS_UPDATE_HOOK_URL?.trim(), token = env.CMS_UPDATE_HOOK_TOKEN?.trim();
27
+ if (!url || !token) return null;
28
+ try { return /^https?:$/.test(new URL(url).protocol) ? { url, token } : null; }
29
+ catch { return null; }
30
+ }
31
+
32
+ /** The page where the hook's work shows, when the hook is GitHub's `repository_dispatch`. */
33
+ export function hookProgressUrl(hook: UpdateHook | null): string | null {
34
+ const match = hook && /^https:\/\/api\.github\.com\/repos\/([^/]+)\/([^/]+)\/dispatches\/?$/.exec(hook.url);
35
+ return match ? `https://github.com/${match[1]}/${match[2]}/actions` : null;
36
+ }
37
+
38
+ /** The last check, or null when none ran. A check for another version or channel no longer counts. */
39
+ export async function storedCheck(network: CmsNetwork, settings: UpdateSettings): Promise<UpdateCheck | null> {
40
+ const stored = await network.state<UpdateCheck>(CHECK).catch(() => undefined);
41
+ if (!stored || stored.installed !== CMS_VERSION || stored.channel !== settings.channel) return null;
42
+ return stored;
43
+ }
44
+
45
+ /**
46
+ * Ask the update server when the last check is a day old, and keep its answer. The scheduled
47
+ * run calls this; a page never does, so no page waits for the update server.
48
+ */
49
+ export async function refreshUpdateCheck(network: CmsNetwork, settings: UpdateSettings, options: { now?: number; force?: boolean; fetch?: typeof globalThis.fetch } = {}): Promise<UpdateCheck | null> {
50
+ if (!settings.check) return null;
51
+ const now = options.now ?? Date.now();
52
+ const previous = await storedCheck(network, settings);
53
+ if (previous && !options.force && now - previous.checkedAt < DAY) return previous;
54
+ const check = await checkForUpdate({ installed: CMS_VERSION, url: settings.url, channel: settings.channel, now, previous, ...(options.fetch ? { fetch: options.fetch } : {}) });
55
+ await network.setState(CHECK, check);
56
+ return check;
57
+ }
58
+
59
+ /** The pending request, or null: it ends when the running version reaches it, or after a day. */
60
+ export async function pendingRequest(network: CmsNetwork, now = Date.now()): Promise<UpdateRequest | null> {
61
+ const stored = await network.state<UpdateRequest | null>(REQUEST).catch(() => undefined);
62
+ if (!stored || typeof stored.version !== 'string') return null;
63
+ if ((compareVersions(CMS_VERSION, stored.version) ?? 0) >= 0 || now - stored.requestedAt > DAY) return null;
64
+ return stored;
65
+ }
66
+
67
+ export async function clearRequest(network: CmsNetwork): Promise<void> {
68
+ await network.setState(REQUEST, null);
69
+ }
70
+
71
+ /** What Tools → Updates shows. */
72
+ export interface UpdateStatus {
73
+ installed: string;
74
+ checking: boolean;
75
+ checkedAt: number | null;
76
+ available: UpdateAnswer | null;
77
+ error: string;
78
+ request: UpdateRequest | null;
79
+ /** The project set a hook, so the page shows the button. */
80
+ hook: boolean;
81
+ progressUrl: string | null;
82
+ }
83
+
84
+ export async function updateStatus(network: CmsNetwork, settings: UpdateSettings, hook: UpdateHook | null, now = Date.now()): Promise<UpdateStatus> {
85
+ const check = settings.check ? await storedCheck(network, settings) : null;
86
+ return {
87
+ installed: CMS_VERSION, checking: settings.check, checkedAt: check?.checkedAt ?? null, available: check?.available ?? null, error: check?.error ?? '',
88
+ request: await pendingRequest(network, now), hook: hook !== null, progressUrl: hookProgressUrl(hook),
89
+ };
90
+ }
91
+
92
+ /**
93
+ * Ask the project's pipeline to update the site. The version is the one the stored check
94
+ * names: the caller cannot name another. The body is GitHub's `repository_dispatch` shape, which
95
+ * any other pipeline can accept too.
96
+ */
97
+ export async function requestUpdate(network: CmsNetwork, settings: UpdateSettings, hook: UpdateHook | null, by: string, options: { now?: number; fetch?: typeof globalThis.fetch } = {}): Promise<UpdateRequest> {
98
+ if (!hook) throw new Error('No update hook is set: add CMS_UPDATE_HOOK_URL and CMS_UPDATE_HOOK_TOKEN to the environment.');
99
+ const now = options.now ?? Date.now();
100
+ const available = (await storedCheck(network, settings))?.available;
101
+ if (!available) throw new Error('No newer version is known. The site checks once a day.');
102
+ if (available.minimumFrom && (compareVersions(CMS_VERSION, available.minimumFrom) ?? 0) < 0) throw new Error(`Version ${available.latest} needs ${available.minimumFrom} first: update in two steps, with cossack upgrade --tag ${available.minimumFrom}.`);
103
+ if (await pendingRequest(network, now)) throw new Error('An update is already requested.');
104
+ const response = await (options.fetch ?? globalThis.fetch)(hook.url, {
105
+ method: 'POST', redirect: 'error', signal: AbortSignal.timeout(10_000),
106
+ headers: { authorization: `Bearer ${hook.token}`, 'content-type': 'application/json', accept: 'application/vnd.github+json, application/json', 'user-agent': 'cossack-cms' },
107
+ body: JSON.stringify({ event_type: 'cossack-update', client_payload: { version: available.latest } }),
108
+ });
109
+ await response.body?.cancel().catch(() => undefined);
110
+ if (!response.ok) throw new Error(`The update hook answered ${response.status}. Check CMS_UPDATE_HOOK_URL and the token's access.`);
111
+ const request: UpdateRequest = { version: available.latest, requestedAt: now, requestedBy: by };
112
+ await network.setState(REQUEST, request);
113
+ return request;
114
+ }
115
+
116
+ /** Whether a newer version is known, for the dashboard menu; read at most once a minute per process. */
117
+ let known: { at: number; value: boolean } | undefined;
118
+ export async function updateAvailable(network: CmsNetwork, settings: UpdateSettings, now = Date.now()): Promise<boolean> {
119
+ if (!settings.check) return false;
120
+ if (known && now - known.at < 60_000) return known.value;
121
+ const value = Boolean((await storedCheck(network, settings))?.available);
122
+ known = { at: now, value };
123
+ return value;
124
+ }
@@ -0,0 +1,26 @@
1
+ import { isCmsError, mediaUrl, type Principal } from '@cossackframework/cms';
2
+ import type { CmsHost } from '@cossackframework/cms/server';
3
+ import type { MediaPreview } from './content';
4
+
5
+ /** Store uploaded files, one at a time, within the Media settings' size limit. */
6
+ export async function uploadFiles(cms: CmsHost, files: readonly File[], principal: Principal, signal?: AbortSignal): Promise<{ files: MediaPreview[]; errors: string[] }> {
7
+ const service = cms.files;
8
+ if (!service) return { files: [], errors: ['File storage is not configured.'] };
9
+ const maxBytes = (await cms.settings.get('media.maxUploadMb')) * 1024 * 1024;
10
+ const uploaded: MediaPreview[] = [];
11
+ const errors: string[] = [];
12
+ for (const file of files.slice(0, 20)) {
13
+ try {
14
+ const stored = await service.upload({ name: file.name, contentType: file.type, size: file.size, body: file.stream() }, { principal, maxBytes, ...(signal ? { signal } : {}) });
15
+ uploaded.push({ id: stored.id, url: mediaUrl(stored), title: stored.title, alt: stored.alt, contentType: stored.contentType, width: stored.width, height: stored.height });
16
+ } catch (error) {
17
+ errors.push(`${file.name}: ${isCmsError(error) ? error.message : 'the upload failed.'}`);
18
+ }
19
+ }
20
+ return { files: uploaded, errors };
21
+ }
22
+
23
+ /** Files from a submitted form's `file` fields. */
24
+ export function formFiles(form: FormData): File[] {
25
+ return form.getAll('file').filter((entry): entry is File => typeof entry === 'object' && entry !== null && 'stream' in entry && (entry as File).size > 0);
26
+ }
@@ -0,0 +1,13 @@
1
+ // The Durable Object class and Worker entrypoints of the CMS, which a Workers project's
2
+ // `src/index.ts` exports by name and its wrangler.jsonc names.
3
+ import { cloudflarePluginRunner, createPluginBridge, PluginTail } from '@cossackframework/cms/cloudflare';
4
+ import { networkFor, setPluginRunner } from './index';
5
+
6
+ // Unconfirmed RomeDB writes (ROMEDB_PENDING) survive isolate restarts here.
7
+ export { RomeDBPendingWrites } from '@cossackframework/romedb/cloudflare';
8
+
9
+ // Isolated plugins run in Workers of their own through the Worker Loader binding (LOADER, which
10
+ // cossack add plugin adds with the first one), and call the CMS back through PluginBridge.
11
+ setPluginRunner(cloudflarePluginRunner());
12
+ export const PluginBridge = createPluginBridge<unknown>((env, site) => networkFor(env as never).hostById(site));
13
+ export { PluginTail };
@@ -0,0 +1,30 @@
1
+ // src/config/auth.ts
2
+ //
3
+ // Auth configuration. Read values anywhere with `config('auth.<key>')`:
4
+ //
5
+ // config('auth.redirectAfterLogin') // '/dashboard'
6
+ // config('auth.redirectAfterLogout') // '/auth/login'
7
+ //
8
+ // Both defaults are env-overridable.
9
+ import type { EnvFunction } from '@cossackframework/framework/config';
10
+ import { authOptions } from '../auth-options';
11
+
12
+ export interface AuthConfig {
13
+ /** Where to send users after a successful login or registration. */
14
+ redirectAfterLogin: string;
15
+ /** Where to send users after logout, or when an unauthenticated user hits a private route. */
16
+ redirectAfterLogout: string;
17
+ }
18
+
19
+ // Register the typed shape so `config('auth.redirectAfterLogin')` infers `string`.
20
+ declare module '@cossackframework/framework/config' {
21
+ interface CossackConfigRegistry {
22
+ auth: AuthConfig;
23
+ }
24
+ }
25
+
26
+ export default ({ env }: { env: EnvFunction }): AuthConfig => ({
27
+ // The default is the project's choice (src/dashboard.config.ts): the dashboard, or the home page without one.
28
+ redirectAfterLogin: env('AUTH_REDIRECT_AFTER_LOGIN', authOptions.redirectAfterLogin),
29
+ redirectAfterLogout: env('AUTH_REDIRECT_AFTER_LOGOUT', '/auth/login'),
30
+ });
@@ -0,0 +1,18 @@
1
+ import type { EnvFunction } from '@cossackframework/framework/config';
2
+
3
+ /**
4
+ * RomeDB connection for the CMS. On Node, ROMEDB_URL defaults to the file
5
+ * storage/romedb/app.romedb, which needs no token. Workers always reach RomeDB over HTTP.
6
+ * Added sites keep their databases beside a main file, or under ROMEDB_SITES_URL (a RomeDB
7
+ * Cloud organization) with an organization key. Tokens are secrets; they never reach the browser.
8
+ */
9
+ export const requirements = { variables: {
10
+ ROMEDB_URL: { type: 'string', required: true, secret: true, runtimes: ['cloudflare'] },
11
+ ROMEDB_TOKEN: { type: 'string', required: true, secret: true, runtimes: ['cloudflare'] },
12
+ ROMEDB_SITES_URL: { type: 'string', required: false },
13
+ ROMEDB_SITES_TOKEN: { type: 'string', required: false, secret: true },
14
+ }, bindings: {
15
+ ROMEDB_PENDING: { kind: 'object', required: true, runtimes: ['cloudflare'] },
16
+ } } as const;
17
+
18
+ export default ({ env }: { env: EnvFunction }) => ({ url: env('ROMEDB_URL') });