@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,299 @@
1
+ import { ClientVisibleError, Cossack, Page, State, Server, Client } from '@cossackframework/core';
2
+ import { input } from '@cossackframework/core/input';
3
+ import { Avatar, Badge, NativeSelect, AlertDialog } from '@cossackframework/ui';
4
+ import { html, component } from '@cossackframework/renderer';
5
+ import { canAssignRoles, canGrantRoles, canManageUser, guard } from '#app/services/rbac';
6
+ import type { PublicUser } from '#app/auth';
7
+ import {
8
+ getUser,
9
+ listUsers,
10
+ deleteUser,
11
+ syncUserRoles,
12
+ type UserSummary,
13
+ type ListUsersResult,
14
+ } from '#app/services/users';
15
+ import { listRoles, type RoleDetail } from '#app/services/roles';
16
+ import { bulkBar, type BulkChoice } from '#app/dashboard/bulk';
17
+ import { timeAgo } from '#app/dashboard/time-ago';
18
+ import { listFilters, listFooter, listTable, rowActions } from '#app/dashboard/list-table';
19
+ import { linkButton, notice, pageHeader } from '@cossackframework/ui/blocks';
20
+
21
+ const PAGE_SIZE = 20;
22
+
23
+ @Page({ transport: 'http', middlewares: [guard.requireRole('admin')] })
24
+ export default class UsersPage extends Cossack {
25
+ @State() users: UserSummary[] = [];
26
+ @State() allRoles: RoleDetail[] = [];
27
+ @State() total = 0;
28
+ @State() page = 1;
29
+ @State() error = '';
30
+ /** Currently applied search (seeded from ?search= in the URL). */
31
+ @State() appliedSearch = '';
32
+ /** Currently applied role filter, as a role NAME (?role=name from the URL). */
33
+ @State() appliedRoleName = '';
34
+ /** Resolved role id matching appliedRoleName (looked up in init). */
35
+ @State() roleId = '';
36
+ /** User pending deletion confirmation (null = dialog closed). */
37
+ @State() pendingDelete: UserSummary | null = null;
38
+ /** Role managers set roles in bulk; others only delete accounts they may manage. */
39
+ @State() canAssignRoles = false;
40
+ /** Rows that can be selected: not your own account, and only accounts you may manage. */
41
+ @State() selectable: string[] = [];
42
+ @State() selected: string[] = [];
43
+ @State() bulk = '';
44
+ /** A bulk action waiting for confirmation. */
45
+ @State() pendingBulk: BulkChoice | null = null;
46
+ @State() message = '';
47
+ /** When the page was rendered, for "Last signed in" as time ago. */
48
+ @State() now = 0;
49
+
50
+ @Server()
51
+ async init() {
52
+ this.now = Date.now();
53
+ // Drive initial state from the URL so search + role filter are
54
+ // bookmarkable/shareable. The search form is a native GET; the "View
55
+ // Users" button on the roles page links here as ?role=<role_name>.
56
+ this.appliedSearch = this.c.req.query('search')?.trim() ?? '';
57
+ this.appliedRoleName = this.c.req.query('role')?.trim() ?? '';
58
+ const pageParam = Number(this.c.req.query('page'));
59
+ this.page = pageParam >= 1 ? pageParam : 1;
60
+
61
+ const roles = await listRoles();
62
+ this.allRoles = roles;
63
+ this.canAssignRoles = canAssignRoles(this.user as PublicUser | undefined);
64
+ // Resolve role name → id (the URL carries the human-readable name).
65
+ if (this.appliedRoleName) {
66
+ const match = roles.find((r) => r.name === this.appliedRoleName);
67
+ this.roleId = match?.id ?? '';
68
+ }
69
+
70
+ const result = await this.query();
71
+ this.applyResult(result);
72
+ }
73
+
74
+ /** Builds and runs the list query from the current filter/pagination state. */
75
+ private async query(): Promise<ListUsersResult> {
76
+ return listUsers({
77
+ search: this.appliedSearch || undefined,
78
+ roleId: this.roleId || undefined,
79
+ page: this.page,
80
+ pageSize: PAGE_SIZE,
81
+ });
82
+ }
83
+
84
+ private applyResult(result: ListUsersResult) {
85
+ this.users = result.items;
86
+ this.total = result.total;
87
+ const actor = this.user as PublicUser | undefined;
88
+ this.selectable = result.items.filter(u => u.id !== actor?.id && canManageUser(actor, u)).map(u => u.id);
89
+ this.selected = this.selected.filter(id => this.selectable.includes(id));
90
+ }
91
+
92
+ /** Delete, or (for role managers) `role:<id>` to give the selected users that role alone. */
93
+ private bulkChoices(): BulkChoice[] {
94
+ return [
95
+ { key: 'delete', label: __('Delete'), confirm: __('The selected accounts and their sessions will be deleted. This cannot be undone.') },
96
+ ...(this.canAssignRoles ? this.allRoles.map(role => ({ key: `role:${role.id}`, label: `${__('Change role to')} ${role.name}` })) : []),
97
+ ];
98
+ }
99
+
100
+ @Client()
101
+ async submitBulk() {
102
+ const choice = this.bulkChoices().find(entry => entry.key === this.bulk);
103
+ if (!choice || !this.selected.length) return;
104
+ if (choice.confirm) { this.pendingBulk = choice; return; }
105
+ await this.runBulk(choice.key);
106
+ }
107
+
108
+ @Client()
109
+ async runBulk(key: string) {
110
+ this.pendingBulk = null;
111
+ await this.applyBulk(this.selected, key);
112
+ }
113
+
114
+ /**
115
+ * Apply a bulk action account by account. Your own account and accounts you may not manage
116
+ * are skipped, so an administrator always remains: the one acting.
117
+ */
118
+ @Server({ input: input.args(input.array(input.string({ minLength: 1, maxLength: 200 }), { maxItems: 1000 }), input.string({ maxLength: 2000 })) })
119
+ async applyBulk(ids: string[], key: string) {
120
+ this.error = '';
121
+ this.message = '';
122
+ const actor = this.user as PublicUser | undefined;
123
+ const roleId = key.startsWith('role:') ? key.slice('role:'.length) : '';
124
+ if (key !== 'delete' && !roleId) return;
125
+ const granted = roleId ? (await listRoles()).find(role => role.id === roleId) : undefined;
126
+ if (roleId && (!canAssignRoles(actor) || !granted)) { this.error = __('Only an administrator can change roles.'); return; }
127
+ if (granted && !canGrantRoles(actor, [granted])) { this.error = __('You cannot give a role with permissions you do not have.'); return; }
128
+ let done = 0, skipped = 0;
129
+ for (const id of [...new Set(ids)].slice(0, 100)) {
130
+ const target = await getUser(id);
131
+ if (!target || id === actor?.id || !canManageUser(actor, target)) { skipped++; continue; }
132
+ if (roleId) await syncUserRoles(id, [roleId]);
133
+ else {
134
+ // An account the user service keeps (a stronger network account) is skipped like the others.
135
+ try { await deleteUser(id); } catch (error) { if (error instanceof ClientVisibleError) { skipped++; continue; } throw error; }
136
+ }
137
+ done++;
138
+ }
139
+ this.selected = [];
140
+ this.bulk = '';
141
+ const result = await this.query();
142
+ const maxPage = Math.max(1, Math.ceil(result.total / PAGE_SIZE));
143
+ if (this.page > maxPage) { this.page = maxPage; this.applyResult(await this.query()); } else this.applyResult(result);
144
+ this.message = `${done} ${done === 1 ? __('user updated.') : __('users updated.')}${skipped ? ` ${skipped} ${__('skipped.')}` : ''}`;
145
+ if (!done && skipped) this.error = __('None of the selected accounts can be changed by you.');
146
+ }
147
+
148
+ /** Re-run the query (used after mutations). */
149
+ @Server()
150
+ private async refresh() {
151
+ const result = await this.query();
152
+ this.applyResult(result);
153
+ }
154
+
155
+ @Server()
156
+ async remove(id: string) {
157
+ this.message = '';
158
+ this.error = '';
159
+ if (id === this.user!.id) {
160
+ this.error = __('You cannot delete your own account from here.');
161
+ return;
162
+ }
163
+ try {
164
+ const target = await getUser(id);
165
+ if (target && !canManageUser(this.user as PublicUser | undefined, target)) {
166
+ this.error = __('Only an administrator can delete this account.');
167
+ return;
168
+ }
169
+ await deleteUser(id);
170
+ this.message = __('User deleted.');
171
+ const result = await this.query();
172
+ const maxPage = Math.max(1, Math.ceil(result.total / PAGE_SIZE));
173
+ if (this.page > maxPage) {
174
+ this.page = maxPage;
175
+ this.applyResult(await this.query());
176
+ } else {
177
+ this.applyResult(result);
178
+ }
179
+ } catch (e: any) {
180
+ this.error = e?.message || __('Could not delete user');
181
+ }
182
+ }
183
+
184
+ /** Open the delete-confirmation dialog for a user (client-side). */
185
+ @Client()
186
+ requestDelete(u: UserSummary) {
187
+ if (u.id === this.user!.id) return;
188
+ this.pendingDelete = u;
189
+ }
190
+
191
+ /** Confirm: actually delete the pending user, then close the dialog. */
192
+ @Client()
193
+ async confirmDelete() {
194
+ const u = this.pendingDelete;
195
+ this.pendingDelete = null;
196
+ if (!u) return;
197
+ await this.remove(u.id);
198
+ }
199
+
200
+ /** Query-string for pagination links — preserves the current search + role. */
201
+ private pageHref(p: number): string {
202
+ const params = new URLSearchParams();
203
+ if (this.appliedSearch) params.set('search', this.appliedSearch);
204
+ if (this.appliedRoleName) params.set('role', this.appliedRoleName);
205
+ if (p > 1) params.set('page', String(p));
206
+ const qs = params.toString();
207
+ return qs ? `/dashboard/users?${qs}` : '/dashboard/users';
208
+ }
209
+
210
+ private formatDate(iso: string): string {
211
+ try {
212
+ return new Date(iso).toLocaleDateString();
213
+ } catch {
214
+ return iso;
215
+ }
216
+ }
217
+
218
+ private formatDateTime(iso: string): string {
219
+ try {
220
+ return new Date(iso).toLocaleString(undefined, { dateStyle: 'medium', timeStyle: 'short' });
221
+ } catch {
222
+ return iso;
223
+ }
224
+ }
225
+
226
+ render() {
227
+ const totalPages = Math.max(1, Math.ceil(this.total / PAGE_SIZE));
228
+ const bulk = (id: string) => bulkBar({ id, choices: this.bulkChoices(), value: this.bulk, count: this.selected.length,
229
+ choose: key => { this.bulk = key; }, apply: () => this.submitBulk() });
230
+ return html`
231
+ <div class="space-y-6">
232
+ ${pageHeader(__('Users'), { description: __('Manage user accounts.'), titleActions: linkButton(__('New user'), '/dashboard/users/new', 'primary', { size: 'sm' }) })}
233
+ ${this.message && !this.error ? notice(this.message, 'success') : null}
234
+ ${this.error ? notice(this.error, 'error') : null}
235
+ <div class="space-y-3">
236
+ ${listFilters({ action: '/dashboard/users', id: 'users-filter-form', search: { name: 'search', value: this.appliedSearch, placeholder: __('Search by name or email') },
237
+ filters: html`<div class="w-44">${component(NativeSelect, { name: 'role', size: 'sm', 'aria-label': __('Filter by role'),
238
+ '@change': (event: Event) => (event.currentTarget as HTMLSelectElement).form?.requestSubmit() }, html`
239
+ <option value="" ?selected=${!this.appliedRoleName}>${__('All roles')}</option>
240
+ ${this.allRoles.map((r) => html`<option value=${r.name} ?selected=${this.appliedRoleName === r.name}>${r.name}</option>`)}`)}</div>` })}
241
+ ${this.selectable.length ? bulk('users-bulk') : null}
242
+ </div>
243
+ ${listTable<UserSummary>({
244
+ rows: this.users, key: u => u.id, rowAttribute: 'data-user', empty: __('No users found.'),
245
+ ...(this.selectable.length ? { selection: { selected: this.selected, selectable: this.selectable, label: u => u.name || u.email, change: ids => { this.selected = ids; } } } : {}),
246
+ columns: [
247
+ { label: __('User'), cell: u => html`<div class="flex items-start gap-3">
248
+ ${component(Avatar, { src: u.avatar ?? undefined, alt: u.name, size: 32 })}
249
+ <div class="min-w-0">
250
+ <a href="/dashboard/users/${u.id}" class="font-medium text-foreground no-underline hover:text-primary">${u.name || '—'}</a>
251
+ ${u.id === this.user!.id ? html` ${component(Badge, { variant: 'secondary' }, __('You'))}` : null}
252
+ ${u.badge ? html` ${component(Badge, { variant: 'outline' }, u.badge)}` : null}
253
+ <span class="block text-xs text-muted-foreground">${u.email}</span>
254
+ ${rowActions([
255
+ { id: `user-${u.id}-edit`, label: __('Edit'), href: `/dashboard/users/${u.id}` },
256
+ ...(u.id !== this.user!.id && this.selectable.includes(u.id) ? [{ id: `user-${u.id}-delete`, label: __('Delete'), danger: true, run: () => this.requestDelete(u) }] : []),
257
+ ])}
258
+ </div>
259
+ </div>` },
260
+ { label: __('Roles'), cell: u => html`<div class="flex flex-wrap gap-1">${u.roles.length === 0
261
+ ? html`<span class="text-xs text-muted-foreground">—</span>` : u.roles.map((r) => component(Badge, { variant: 'outline' }, r.name))}</div>` },
262
+ { label: __('Last signed in'), class: 'text-muted-foreground', cell: u => u.lastSignedInAt
263
+ ? html`<time datetime=${u.lastSignedInAt} title=${this.formatDateTime(u.lastSignedInAt)}>${timeAgo(u.lastSignedInAt, this.now)}</time>` : __('Never') },
264
+ { label: __('Created'), class: 'text-muted-foreground', cell: u => this.formatDate(u.createdAt) },
265
+ ],
266
+ })}
267
+ ${this.users.length && this.selectable.length ? bulk('users-bulk-bottom') : null}
268
+ ${listFooter({ total: this.total, page: this.page, totalPages, href: p => this.pageHref(p) })}
269
+
270
+ ${component(AlertDialog, {
271
+ id: 'bulk-users-dialog',
272
+ open: this.pendingBulk !== null,
273
+ // Closed dialogs still need their labels.
274
+ title: this.pendingBulk ? `${this.pendingBulk.label} ${this.selected.length} ${this.selected.length === 1 ? __('user') : __('users')}?` : __('Apply'),
275
+ description: this.pendingBulk?.confirm ?? '',
276
+ cancelLabel: __('Cancel'),
277
+ actionLabel: this.pendingBulk?.label || __('Apply'),
278
+ actionVariant: this.pendingBulk?.key === 'delete' ? 'destructive' : 'primary',
279
+ onAction: () => { if (this.pendingBulk) void this.runBulk(this.pendingBulk.key); },
280
+ onOpenChange: () => { this.pendingBulk = null; },
281
+ })}
282
+
283
+ ${component(AlertDialog, {
284
+ id: 'delete-user-dialog',
285
+ open: this.pendingDelete !== null,
286
+ title: __('Delete user?'),
287
+ description: this.pendingDelete
288
+ ? `${__('Are you sure you want to delete')} ${this.pendingDelete.name || this.pendingDelete.email}? ${__('This action cannot be undone.')}`
289
+ : '',
290
+ cancelLabel: __('Cancel'),
291
+ actionLabel: __('Delete'),
292
+ actionVariant: 'destructive',
293
+ onAction: () => this.confirmDelete(),
294
+ onOpenChange: () => { this.pendingDelete = null; },
295
+ })}
296
+ </div>
297
+ `;
298
+ }
299
+ }
@@ -0,0 +1,123 @@
1
+ import { ClientVisibleError, Cossack, Page, Store, State, Validate, Client, Server, storeRules } from '@cossackframework/core';
2
+ import { input } from '@cossackframework/core/input';
3
+ import { Card, CardBody, CardHeader, Checkbox, Field, Input, PasswordInput, Button, Form } from '@cossackframework/ui';
4
+ import { linkButton, notice, pageHeader } from '@cossackframework/ui/blocks';
5
+ import { html, component, bind } from '@cossackframework/renderer';
6
+ import { canAssignRoles, canGrantRoles, guard } from '#app/services/rbac';
7
+ import { createUser } from '#app/services/users';
8
+ import { defaultRole, getRole, listRoles, type RoleDetail } from '#app/services/roles';
9
+ import type { PublicUser } from '#app/auth';
10
+
11
+ interface NewUserForm {
12
+ name: string;
13
+ email: string;
14
+ password: string;
15
+ roleIds: string[];
16
+ /** Send an invitation with a link to set the password instead of setting one here. */
17
+ invite: boolean;
18
+ }
19
+
20
+ /**
21
+ * Add a user. Role managers (administrators by default) choose the roles; other user managers
22
+ * add users with the default role.
23
+ */
24
+ @Page({ transport: 'http', middlewares: [guard.requireRole('admin')] })
25
+ export default class NewUserPage extends Cossack {
26
+ @Store()
27
+ @Validate({
28
+ rules: storeRules<NewUserForm>({
29
+ email: { required: true, email: true, message: 'Enter a valid email' },
30
+ password: { minLength: 8, message: 'Password must be at least 8 characters' },
31
+ }),
32
+ config: { trigger: 'all', runOn: 'both' }
33
+ })
34
+ form: NewUserForm = { name: '', email: '', password: '', roleIds: [], invite: false };
35
+
36
+ @State() error = '';
37
+ @State() canAssignRoles = false;
38
+ @State() roles: RoleDetail[] = [];
39
+ @State() defaultRoleName = '';
40
+
41
+ async init() {
42
+ this.canAssignRoles = canAssignRoles(this.user as PublicUser | undefined);
43
+ const fallback = await defaultRole();
44
+ this.defaultRoleName = fallback?.name ?? '';
45
+ if (this.canAssignRoles) {
46
+ this.roles = await listRoles();
47
+ this.form.roleIds = fallback ? [fallback.id] : [];
48
+ }
49
+ }
50
+
51
+ @Client()
52
+ toggleRole(roleId: string, checked: boolean) {
53
+ this.form.roleIds = checked ? [...new Set([...this.form.roleIds, roleId])] : this.form.roleIds.filter(id => id !== roleId);
54
+ }
55
+
56
+ @Client()
57
+ async handleSubmit(event: Event) {
58
+ event.preventDefault();
59
+ this.error = '';
60
+ const ok = await this.validateAll();
61
+ if (!ok) return;
62
+ if (!this.form.invite && !this.form.password) { this.error = __('Enter a password, or send an invitation.'); return; }
63
+ try {
64
+ await this.create(this.form.name, this.form.email, this.form.invite ? '' : this.form.password, this.form.roleIds, this.form.invite);
65
+ } catch (e: any) {
66
+ this.error = e?.message || __('Could not create user');
67
+ }
68
+ }
69
+
70
+ @Server({ input: input.args(input.string({ maxLength: 200 }), input.string({ maxLength: 320 }), input.string({ maxLength: 1000 }),
71
+ input.array(input.string({ maxLength: 200 }), { maxItems: 50 }), input.boolean().optional()) })
72
+ async create(name: string, email: string, password: string, roleIds: string[], invite = false) {
73
+ // Roles from the form count only for a role manager; others get the default role. Each
74
+ // requested role is read by its ID, so none escapes the check however many roles exist.
75
+ const chosen = canAssignRoles(this.user as PublicUser | undefined) ? [...new Set(roleIds)] : undefined;
76
+ if (chosen) {
77
+ const roles = await Promise.all(chosen.map(id => getRole(id)));
78
+ if (roles.some(role => !role)) throw new ClientVisibleError(__('Role not found'));
79
+ if (!canGrantRoles(this.user as PublicUser | undefined, roles as RoleDetail[])) throw new ClientVisibleError(__('You cannot give a role with permissions you do not have.'));
80
+ }
81
+ await createUser({ email, ...(invite ? { invite: true } : { password }), name: name || undefined, ...(chosen ? { roleIds: chosen } : {}) });
82
+ this.redirect('/dashboard/users');
83
+ }
84
+
85
+ render() {
86
+ return html`
87
+ <div class="max-w-2xl space-y-6">
88
+ ${pageHeader(__('New user'), { description: __('Create a new user account.') })}
89
+ ${this.error ? notice(this.error, 'error') : null}
90
+
91
+ ${component(Card, {}, html`
92
+ ${component(CardHeader, {}, html`<h2 class="text-base font-semibold text-foreground">${__('Details')}</h2>`)}
93
+ ${component(CardBody, {}, html`
94
+ ${component(Form, {
95
+ submit: (e: Event) => this.handleSubmit(e),
96
+ }, html`
97
+ <div class="flex flex-col space-y-4">
98
+ ${component(Field, { label: __('Name'), for: 'name',
99
+ control: attributes => component(Input, { ...attributes, type: 'text', '.value': bind(this.form, 'name') }) })}
100
+ ${component(Field, { label: __('Email'), for: 'email', error: this.getError('form.email'),
101
+ control: attributes => component(Input, { ...attributes, type: 'email', placeholder: 'user@example.com', variant: this.hasError('form.email') ? 'error' : 'default', '.value': bind(this.form, 'email') }) })}
102
+ ${component(Checkbox, { label: __('Send an invitation email with a link to set the password'), checked: this.form.invite, '@change': (e: Event) => { this.form.invite = (e.target as HTMLInputElement).checked; } })}
103
+ ${this.form.invite ? null : component(Field, { label: __('Password'), for: 'password', error: this.getError('form.password'),
104
+ control: attributes => component(PasswordInput, { ...attributes, value: this.form.password, onValueChange: (v: string) => this.form.password = v }) })}
105
+ ${this.canAssignRoles ? html`<fieldset class="space-y-2">
106
+ <legend class="mb-1 text-sm font-medium text-foreground">${__('Roles')}</legend>
107
+ ${this.roles.length ? this.roles.map(role => html`<div>${component(Checkbox, { label: role.name, checked: this.form.roleIds.includes(role.id), '@change': (e: Event) => this.toggleRole(role.id, (e.target as HTMLInputElement).checked) })}</div>`)
108
+ : html`<p class="text-sm text-muted-foreground">${__('No roles defined yet.')}</p>`}
109
+ </fieldset>` : html`<p class="text-sm text-muted-foreground">${this.defaultRoleName
110
+ ? `${__('The new user gets the default role')}: ${this.defaultRoleName}.`
111
+ : __('The new user starts without a role.')}</p>`}
112
+ <div class="flex items-center gap-2">
113
+ ${component(Button, { type: 'submit' }, __('Create user'))}
114
+ ${linkButton(__('Cancel'), '/dashboard/users', 'outline')}
115
+ </div>
116
+ </div>
117
+ `)}
118
+ `)}
119
+ `)}
120
+ </div>
121
+ `;
122
+ }
123
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Passkey ceremonies in the browser through SimpleWebAuthn: create a passkey for the
3
+ * signed-in user, or sign in with one. The server makes the options and checks the answers.
4
+ */
5
+ import type { PublicKeyCredentialCreationOptionsJSON, PublicKeyCredentialRequestOptionsJSON } from '@simplewebauthn/browser';
6
+
7
+ /** Whether this browser can create and use passkeys. */
8
+ export const passkeysSupported = typeof window !== 'undefined' && typeof window.PublicKeyCredential === 'function';
9
+
10
+ export async function createPasskey(options: unknown) {
11
+ const { startRegistration } = await import('@simplewebauthn/browser');
12
+ return startRegistration({ optionsJSON: options as PublicKeyCredentialCreationOptionsJSON });
13
+ }
14
+
15
+ export async function usePasskey(options: unknown) {
16
+ const { startAuthentication } = await import('@simplewebauthn/browser');
17
+ return startAuthentication({ optionsJSON: options as PublicKeyCredentialRequestOptionsJSON });
18
+ }
@@ -0,0 +1,31 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 900" role="img" aria-label="Cossack Default theme preview">
2
+ <rect width="1200" height="900" fill="#fafafa"/>
3
+ <rect width="1200" height="110" fill="#ffffff"/>
4
+ <rect y="110" width="1200" height="2" fill="#e4e4e7"/>
5
+ <rect x="120" y="34" width="210" height="24" rx="6" fill="#18181b"/>
6
+ <rect x="120" y="68" width="150" height="12" rx="6" fill="#a1a1aa"/>
7
+ <rect x="640" y="46" width="70" height="16" rx="8" fill="#52525b"/>
8
+ <rect x="736" y="46" width="70" height="16" rx="8" fill="#a1a1aa"/>
9
+ <rect x="832" y="46" width="70" height="16" rx="8" fill="#a1a1aa"/>
10
+ <rect x="928" y="36" width="152" height="36" rx="8" fill="#ffffff" stroke="#e4e4e7" stroke-width="2"/>
11
+ <g transform="translate(220 170)">
12
+ <rect width="300" height="225" rx="14" fill="#d4d4d8"/>
13
+ <rect x="340" y="20" width="420" height="30" rx="8" fill="#18181b"/>
14
+ <rect x="340" y="68" width="200" height="12" rx="6" fill="#a1a1aa"/>
15
+ <rect x="340" y="104" width="420" height="12" rx="6" fill="#d4d4d8"/>
16
+ <rect x="340" y="128" width="400" height="12" rx="6" fill="#d4d4d8"/>
17
+ <rect x="340" y="152" width="300" height="12" rx="6" fill="#d4d4d8"/>
18
+ <rect x="340" y="188" width="110" height="14" rx="7" fill="#2563eb"/>
19
+ </g>
20
+ <g transform="translate(220 450)">
21
+ <rect width="300" height="225" rx="14" fill="#e4e4e7"/>
22
+ <rect x="340" y="20" width="380" height="30" rx="8" fill="#18181b"/>
23
+ <rect x="340" y="68" width="200" height="12" rx="6" fill="#a1a1aa"/>
24
+ <rect x="340" y="104" width="420" height="12" rx="6" fill="#d4d4d8"/>
25
+ <rect x="340" y="128" width="360" height="12" rx="6" fill="#d4d4d8"/>
26
+ <rect x="340" y="188" width="110" height="14" rx="7" fill="#2563eb"/>
27
+ </g>
28
+ <rect y="790" width="1200" height="2" fill="#e4e4e7"/>
29
+ <rect x="120" y="830" width="240" height="14" rx="7" fill="#a1a1aa"/>
30
+ <rect x="960" y="830" width="120" height="14" rx="7" fill="#a1a1aa"/>
31
+ </svg>
@@ -0,0 +1,8 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 96" role="img" aria-label="Cossack Default theme">
2
+ <rect width="96" height="96" rx="20" fill="#18181b"/>
3
+ <rect x="18" y="20" width="60" height="10" rx="3" fill="#fafafa"/>
4
+ <rect x="18" y="38" width="38" height="6" rx="3" fill="#a1a1aa"/>
5
+ <rect x="18" y="50" width="60" height="6" rx="3" fill="#52525b"/>
6
+ <rect x="18" y="62" width="52" height="6" rx="3" fill="#52525b"/>
7
+ <rect x="18" y="74" width="30" height="6" rx="3" fill="#52525b"/>
8
+ </svg>
@@ -0,0 +1,66 @@
1
+ /** The comment list and form below an entry. */
2
+ import { component, html, unsafeHTML, type TemplateResult } from '@cossackframework/renderer';
3
+ import { Turnstile } from '@cossackframework/ui';
4
+ import type { CommentFormView, CommentView, CommentsView } from '@cossackframework/cms';
5
+
6
+ const INPUT = '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';
7
+
8
+ /** The comment form; `parent` makes it a reply. The hidden `website` field catches bots. */
9
+ function commentForm(form: CommentFormView, parent: string | null): TemplateResult {
10
+ if (form.requireSignIn) return html`<p class="text-sm text-muted-foreground"><a href=${form.signInUrl} class="text-primary hover:underline">${__('Log in')}</a> ${__('to post a comment.')}</p>`;
11
+ const id = (name: string) => `comment-${parent ?? 'new'}-${name}`;
12
+ return html`<form method="post" action=${form.action} class="space-y-3">
13
+ <input type="hidden" name="collection" value=${form.collection}>
14
+ <input type="hidden" name="entry" value=${form.entry}>
15
+ ${parent ? html`<input type="hidden" name="parent" value=${parent}>` : null}
16
+ <div aria-hidden="true" class="hidden"><label>${__('Leave this empty')} <input type="text" name="website" tabindex="-1" autocomplete="off"></label></div>
17
+ <div class="space-y-1">
18
+ <label for=${id('content')} class="block text-sm font-medium text-foreground">${parent ? __('Your reply') : __('Your comment')}</label>
19
+ <textarea id=${id('content')} name="content" required rows="4" maxlength="5000" class=${INPUT}></textarea>
20
+ </div>
21
+ ${form.userName ? html`<p class="text-xs text-muted-foreground">${__('Commenting as')} ${form.userName}.</p>` : html`<div class="grid gap-3 sm:grid-cols-3">
22
+ <div class="space-y-1"><label for=${id('name')} class="block text-sm font-medium text-foreground">${__('Name')}${form.requireNameEmail ? ' *' : ''}</label>
23
+ <input id=${id('name')} name="authorName" maxlength="100" ?required=${form.requireNameEmail} autocomplete="name" class=${INPUT}></div>
24
+ <div class="space-y-1"><label for=${id('email')} class="block text-sm font-medium text-foreground">${__('Email')}${form.requireNameEmail ? ' *' : ''}</label>
25
+ <input id=${id('email')} name="authorEmail" type="email" maxlength="254" ?required=${form.requireNameEmail} autocomplete="email" class=${INPUT}></div>
26
+ <div class="space-y-1"><label for=${id('url')} class="block text-sm font-medium text-foreground">${__('Website')}</label>
27
+ <input id=${id('url')} name="authorUrl" type="url" maxlength="200" autocomplete="url" class=${INPUT}></div>
28
+ </div>
29
+ <p class="text-xs text-muted-foreground">${__('Your email address will not be published.')}</p>`}
30
+ ${form.turnstileSiteKey ? component(Turnstile, { id: id('verify'), siteKey: form.turnstileSiteKey, action: 'comment', label: __('Bot protection') }) : null}
31
+ <button type="submit" class="rounded-md border-none bg-primary px-4 py-2 text-sm font-medium text-primary-foreground cursor-pointer">${parent ? __('Post reply') : __('Post comment')}</button>
32
+ </form>`;
33
+ }
34
+
35
+ function comment(item: CommentView, form: CommentFormView | null): TemplateResult {
36
+ return html`<li id=${`comment-${item.id}`} class="space-y-3">
37
+ <article class="flex gap-3">
38
+ ${item.avatar ? html`<img src=${item.avatar} alt="" width="40" height="40" class="size-10 shrink-0 rounded-full object-cover">`
39
+ : html`<span aria-hidden="true" class="flex size-10 shrink-0 items-center justify-center rounded-full bg-muted text-sm font-semibold text-muted-foreground">${[...item.author][0]?.toUpperCase() ?? '?'}</span>`}
40
+ <div class="min-w-0 flex-1 space-y-1">
41
+ <p class="text-sm"><span class="font-semibold text-foreground">${item.authorUrl ? html`<a href=${item.authorUrl} rel="ugc nofollow noopener" class="text-foreground hover:underline">${item.author}</a>` : item.author}</span>
42
+ <span class="text-muted-foreground"> · ${item.date}</span></p>
43
+ <div class="text-sm leading-6 text-foreground [&_p]:my-2">${unsafeHTML(item.html)}</div>
44
+ ${item.replyable && form ? html`<details class="text-sm"><summary class="cursor-pointer text-primary">${__('Reply')}</summary><div class="mt-3">${commentForm(form, item.id)}</div></details>` : null}
45
+ </div>
46
+ </article>
47
+ ${item.replies.length ? html`<ol class="ml-6 space-y-4 border-l border-border pl-4 sm:ml-12">${item.replies.map(reply => comment(reply, form))}</ol>` : null}
48
+ </li>`;
49
+ }
50
+
51
+ const COMMENT_ERRORS: Record<string, string> = {
52
+ closed: 'Comments are closed.', 'sign-in': 'Log in to comment.', 'too-fast': 'You are commenting too quickly. Wait a moment and try again.',
53
+ invalid: 'Write a comment, with your name and a valid email address.', bot: 'The check against bots failed. Try again.',
54
+ };
55
+
56
+ export function comments(view: CommentsView): TemplateResult {
57
+ return html`<section id="comments" aria-labelledby="comments-title" class="space-y-6 border-t border-border pt-8">
58
+ <h2 id="comments-title" class="text-2xl font-semibold text-foreground">${view.count ? `${view.count} ${view.count === 1 ? __('comment') : __('comments')}` : __('Comments')}</h2>
59
+ ${view.notice === 'held' ? html`<p role="status" class="rounded-md border border-border bg-muted px-3 py-2 text-sm">${__('Thanks! Your comment is awaiting moderation.')}</p>` : null}
60
+ ${view.notice === 'posted' ? html`<p role="status" class="rounded-md border border-border bg-muted px-3 py-2 text-sm">${__('Thanks! Your comment is posted.')}</p>` : null}
61
+ ${view.error ? html`<p role="alert" class="rounded-md border border-destructive/50 px-3 py-2 text-sm text-destructive">${__(COMMENT_ERRORS[view.error] ?? 'Your comment could not be posted.')}</p>` : null}
62
+ ${view.items.length ? html`<ol class="space-y-6">${view.items.map(item => comment(item, view.form))}</ol>` : view.open ? html`<p class="text-sm text-muted-foreground">${__('No comments yet.')}</p>` : null}
63
+ ${view.form ? html`<div class="space-y-3"><h3 class="text-lg font-semibold text-foreground">${__('Leave a comment')}</h3>${commentForm(view.form, null)}</div>`
64
+ : html`<p class="text-sm text-muted-foreground">${__('Comments are closed.')}</p>`}
65
+ </section>`;
66
+ }
@@ -0,0 +1,38 @@
1
+ /** Entry cards, pagination and the list that archives, the home page and search share. */
2
+ import { html, type TemplateResult } from '@cossackframework/renderer';
3
+ import type { ArchiveView, EntryView, Paging } from '@cossackframework/cms';
4
+ import { image } from './media';
5
+
6
+ function card(entry: EntryView): TemplateResult {
7
+ return html`<article class="group grid gap-4 sm:grid-cols-[12rem_minmax(0,1fr)]">
8
+ ${entry.image ? html`<a href=${entry.url ?? '#'} class="block overflow-hidden rounded-lg">${image(entry.image, 'aspect-[4/3] w-full object-cover transition-transform group-hover:scale-105', '(min-width: 640px) 12rem, 100vw')}</a>` : html`<span class="hidden sm:block"></span>`}
9
+ <div class="space-y-2">
10
+ <h2 class="text-xl font-semibold"><a href=${entry.url ?? '#'} class="text-foreground no-underline hover:text-primary">${entry.title}</a></h2>
11
+ ${entry.date || entry.authors.length ? html`<p class="text-xs text-muted-foreground">${entry.date}${entry.authors.length ? ` · ${entry.authors.map(author => author.name).join(', ')}` : ''}</p>` : null}
12
+ ${entry.excerpt ? html`<p class="text-sm leading-6 text-muted-foreground">${entry.excerpt}</p>` : null}
13
+ ${entry.url ? html`<a href=${entry.url} class="text-sm font-medium text-primary hover:underline">${__('Read more')} →</a>` : null}
14
+ </div>
15
+ </article>`;
16
+ }
17
+
18
+ /** The URL of a page of a list: the base, with `page=N` added to its query after the first. */
19
+ export function pageHref(paging: Paging, page: number): string {
20
+ return page > 1 ? `${paging.base}${paging.base.includes('?') ? '&' : '?'}page=${page}` : paging.base;
21
+ }
22
+
23
+ function pagination(paging: Paging): TemplateResult | null {
24
+ if (paging.pages <= 1) return null;
25
+ const href = (page: number) => pageHref(paging, page);
26
+ return html`<nav aria-label=${__('Pages')} class="flex items-center justify-between border-t border-border pt-6 text-sm">
27
+ ${paging.page > 1 ? html`<a href=${href(paging.page - 1)} class="text-primary hover:underline" rel="prev">← ${__('Newer')}</a>` : html`<span></span>`}
28
+ <span class="text-muted-foreground">${__('Page')} ${paging.page} ${__('of')} ${paging.pages}</span>
29
+ ${paging.page < paging.pages ? html`<a href=${href(paging.page + 1)} class="text-primary hover:underline" rel="next">${__('Older')} →</a>` : html`<span></span>`}
30
+ </nav>`;
31
+ }
32
+
33
+ export function list(view: ArchiveView, empty: string): TemplateResult {
34
+ return html`<div class="cms-measure space-y-10">
35
+ ${view.entries.length ? view.entries.map(card) : html`<p class="py-10 text-center text-muted-foreground">${empty}</p>`}
36
+ ${pagination(view.paging)}
37
+ </div>`;
38
+ }
@@ -0,0 +1,15 @@
1
+ /** Images with their resized variants. */
2
+ import { html, ifDefined, type TemplateResult } from '@cossackframework/renderer';
3
+ import { placeholderStyle, wideSrcset, type MediaView } from '@cossackframework/cms';
4
+
5
+ /** An image with its resized variants; `sizes` says how wide it shows, so the browser picks one. */
6
+ export function image(media: MediaView | null, className: string, sizes = '(min-width: 1024px) 1024px, 100vw', wide = false): TemplateResult | null {
7
+ if (!media) return null;
8
+ const fill = wide && Boolean(media.srcset);
9
+ const srcset = fill ? wideSrcset(media.srcset) : media.srcset;
10
+ // A 16:9 frame: its size, so the page does not shift while the image loads.
11
+ const height = fill && media.width ? Math.round(media.width * 9 / 16) : media.height;
12
+ return html`<img src=${media.url} srcset=${ifDefined(srcset || undefined)} sizes=${ifDefined(srcset ? sizes : undefined)} alt=${media.alt} width=${media.width ?? ''} height=${height ?? ''}
13
+ loading=${media.priority ? 'eager' : 'lazy'} fetchpriority=${ifDefined(media.priority ? 'high' : undefined)} decoding="async" class=${className}
14
+ style=${ifDefined(placeholderStyle(media.placeholder, media.width, height) || undefined)}>`;
15
+ }