@basicbenframework/cms 0.0.0-stage → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (590) hide show
  1. package/LICENSE +9 -0
  2. package/README.md +206 -2
  3. package/db/migrations/001_create_users.js +15 -0
  4. package/db/migrations/002_create_posts.js +18 -0
  5. package/db/migrations/003_create_categories.js +19 -0
  6. package/db/migrations/004_create_tags.js +16 -0
  7. package/db/migrations/005_create_post_tags.js +16 -0
  8. package/db/migrations/006_create_pages.js +26 -0
  9. package/db/migrations/007_create_comments.js +24 -0
  10. package/db/migrations/008_create_media.js +22 -0
  11. package/db/migrations/009_update_posts_blogging.js +27 -0
  12. package/db/migrations/010_create_settings.js +29 -0
  13. package/db/migrations/011_add_user_roles.js +23 -0
  14. package/db/migrations/012_create_auth_tokens.js +30 -0
  15. package/db/migrations/013_add_email_verified.js +24 -0
  16. package/db/migrations/014_create_user_two_factor.js +30 -0
  17. package/db/migrations/015_create_user_credentials.js +35 -0
  18. package/db/migrations/016_create_rate_limits.js +31 -0
  19. package/db/migrations/017_add_content_html.js +38 -0
  20. package/db/migrations/018_create_api_tokens.js +34 -0
  21. package/db/migrations/019_create_post_categories.js +40 -0
  22. package/db/migrations/020_add_author_profiles.js +60 -0
  23. package/db/migrations/021_add_page_featured_image.js +23 -0
  24. package/db/migrations/022_backfill_post_slugs_and_excerpts.js +57 -0
  25. package/db/migrations/023_add_user_session_controls.js +25 -0
  26. package/db/migrations/024_add_post_status_and_trash.js +45 -0
  27. package/db/migrations/025_add_social_and_indexing_fields.js +40 -0
  28. package/db/migrations/026_create_post_revisions.js +29 -0
  29. package/db/migrations/027_add_media_dimensions.js +19 -0
  30. package/db/migrations/028_create_navigation_menus.js +65 -0
  31. package/db/migrations/029_create_redirects.js +40 -0
  32. package/db/migrations/030_add_comment_status_and_notifications.js +53 -0
  33. package/db/migrations/031_create_post_locks.js +38 -0
  34. package/db/migrations/032_create_snippets.js +31 -0
  35. package/db/migrations/033_create_members.js +70 -0
  36. package/db/migrations/034_add_post_visibility.js +28 -0
  37. package/db/migrations/035_create_newsletters.js +72 -0
  38. package/db/migrations/036_create_analytics.js +89 -0
  39. package/db/migrations/037_create_ops_heartbeats.js +30 -0
  40. package/db/migrations/038_create_content_types.js +84 -0
  41. package/db/migrations/039_create_content_type_fields.js +47 -0
  42. package/db/migrations/040_create_taxonomies.js +80 -0
  43. package/db/migrations/041_add_newsletter_handoff.js +28 -0
  44. package/db/migrations/042_create_mysendbox_contacts.js +63 -0
  45. package/lib/cli/backup.d.mts +2 -0
  46. package/lib/cli/backup.mjs +124 -0
  47. package/lib/cli/export.d.mts +2 -0
  48. package/lib/cli/export.mjs +54 -0
  49. package/lib/cli/import-ghost.d.mts +2 -0
  50. package/lib/cli/import-ghost.mjs +50 -0
  51. package/lib/cli/import-json.d.mts +2 -0
  52. package/lib/cli/import-json.mjs +61 -0
  53. package/lib/cli/import-wordpress.d.mts +2 -0
  54. package/lib/cli/import-wordpress.mjs +169 -0
  55. package/lib/cli/import-wxr.d.mts +2 -0
  56. package/lib/cli/import-wxr.mjs +55 -0
  57. package/lib/cli/index.d.mts +2 -0
  58. package/lib/cli/index.mjs +53 -0
  59. package/lib/cli/lib/backup.d.mts +112 -0
  60. package/lib/cli/lib/backup.mjs +297 -0
  61. package/lib/cli/lib/ghost.d.mts +30 -0
  62. package/lib/cli/lib/ghost.mjs +201 -0
  63. package/lib/cli/lib/html-to-markdown.d.mts +61 -0
  64. package/lib/cli/lib/html-to-markdown.mjs +523 -0
  65. package/lib/cli/lib/import-common.d.mts +100 -0
  66. package/lib/cli/lib/import-common.mjs +252 -0
  67. package/lib/cli/lib/json-import.d.mts +22 -0
  68. package/lib/cli/lib/json-import.mjs +422 -0
  69. package/lib/cli/lib/site-import.d.mts +32 -0
  70. package/lib/cli/lib/site-import.mjs +456 -0
  71. package/lib/cli/lib/wordpress-rest.d.mts +25 -0
  72. package/lib/cli/lib/wordpress-rest.mjs +177 -0
  73. package/lib/cli/lib/wxr.d.mts +18 -0
  74. package/lib/cli/lib/wxr.mjs +307 -0
  75. package/lib/cli/lib/xml.d.mts +33 -0
  76. package/lib/cli/lib/xml.mjs +186 -0
  77. package/lib/cli/restore.d.mts +2 -0
  78. package/lib/cli/restore.mjs +98 -0
  79. package/lib/client/components/Alert.d.ts +7 -0
  80. package/lib/client/components/Alert.js +8 -0
  81. package/lib/client/components/Avatar.d.ts +15 -0
  82. package/lib/client/components/Avatar.js +10 -0
  83. package/lib/client/components/BackLink.d.ts +7 -0
  84. package/lib/client/components/BackLink.js +6 -0
  85. package/lib/client/components/Button.d.ts +7 -0
  86. package/lib/client/components/Button.js +12 -0
  87. package/lib/client/components/Card.d.ts +7 -0
  88. package/lib/client/components/Card.js +6 -0
  89. package/lib/client/components/CommentThread.d.ts +15 -0
  90. package/lib/client/components/CommentThread.js +101 -0
  91. package/lib/client/components/Empty.d.ts +6 -0
  92. package/lib/client/components/Empty.js +6 -0
  93. package/lib/client/components/Input.d.ts +6 -0
  94. package/lib/client/components/Input.js +6 -0
  95. package/lib/client/components/Link.d.ts +31 -0
  96. package/lib/client/components/Link.js +49 -0
  97. package/lib/client/components/Loading.d.ts +1 -0
  98. package/lib/client/components/Loading.js +6 -0
  99. package/lib/client/components/Logo.d.ts +5 -0
  100. package/lib/client/components/Logo.js +4 -0
  101. package/lib/client/components/MarkdownEditor.d.ts +41 -0
  102. package/lib/client/components/MarkdownEditor.js +156 -0
  103. package/lib/client/components/Nav/DarkModeToggle.d.ts +6 -0
  104. package/lib/client/components/Nav/DarkModeToggle.js +6 -0
  105. package/lib/client/components/Nav/DesktopNav.d.ts +8 -0
  106. package/lib/client/components/Nav/DesktopNav.js +9 -0
  107. package/lib/client/components/Nav/MobileNav.d.ts +9 -0
  108. package/lib/client/components/Nav/MobileNav.js +15 -0
  109. package/lib/client/components/NavLink.d.ts +8 -0
  110. package/lib/client/components/NavLink.js +6 -0
  111. package/lib/client/components/PageHeader.d.ts +8 -0
  112. package/lib/client/components/PageHeader.js +6 -0
  113. package/lib/client/components/PostCard.d.ts +8 -0
  114. package/lib/client/components/PostCard.js +7 -0
  115. package/lib/client/components/Textarea.d.ts +6 -0
  116. package/lib/client/components/Textarea.js +6 -0
  117. package/lib/client/components/ThemeContext.d.ts +18 -0
  118. package/lib/client/components/ThemeContext.js +8 -0
  119. package/lib/client/components/admin/AdminIcons.d.ts +13 -0
  120. package/lib/client/components/admin/AdminIcons.js +66 -0
  121. package/lib/client/components/admin/ContentModelPanels.d.ts +22 -0
  122. package/lib/client/components/admin/ContentModelPanels.js +93 -0
  123. package/lib/client/components/admin/FeaturedImageBox.d.ts +21 -0
  124. package/lib/client/components/admin/FeaturedImageBox.js +24 -0
  125. package/lib/client/components/admin/MediaGrid.d.ts +23 -0
  126. package/lib/client/components/admin/MediaGrid.js +69 -0
  127. package/lib/client/components/admin/MediaPicker.d.ts +17 -0
  128. package/lib/client/components/admin/MediaPicker.js +61 -0
  129. package/lib/client/components/admin/Pagination.d.ts +27 -0
  130. package/lib/client/components/admin/Pagination.js +29 -0
  131. package/lib/client/components/admin/SnippetPicker.d.ts +27 -0
  132. package/lib/client/components/admin/SnippetPicker.js +65 -0
  133. package/lib/client/components/admin/TermPicker.d.ts +52 -0
  134. package/lib/client/components/admin/TermPicker.js +58 -0
  135. package/lib/client/contexts/ToastContext.d.ts +12 -0
  136. package/lib/client/contexts/ToastContext.js +49 -0
  137. package/lib/client/features.d.ts +11 -0
  138. package/lib/client/features.js +7 -0
  139. package/lib/client/hooks/useContentTypes.d.ts +48 -0
  140. package/lib/client/hooks/useContentTypes.js +48 -0
  141. package/lib/client/hooks/useMediaLibrary.d.ts +46 -0
  142. package/lib/client/hooks/useMediaLibrary.js +189 -0
  143. package/lib/client/hooks/usePostLock.d.ts +32 -0
  144. package/lib/client/hooks/usePostLock.js +107 -0
  145. package/lib/client/host/index.d.ts +71 -0
  146. package/lib/client/host/index.js +58 -0
  147. package/lib/client/i18n/index.d.ts +79 -0
  148. package/lib/client/i18n/index.js +177 -0
  149. package/lib/client/i18n/locales/es/content.d.ts +4 -0
  150. package/lib/client/i18n/locales/es/content.js +220 -0
  151. package/lib/client/i18n/locales/es/editor.d.ts +9 -0
  152. package/lib/client/i18n/locales/es/editor.js +144 -0
  153. package/lib/client/i18n/locales/es/index.d.ts +8 -0
  154. package/lib/client/i18n/locales/es/index.js +7 -0
  155. package/lib/client/i18n/locales/es/layout.d.ts +4 -0
  156. package/lib/client/i18n/locales/es/layout.js +35 -0
  157. package/lib/client/i18n/locales/es/people.d.ts +4 -0
  158. package/lib/client/i18n/locales/es/people.js +187 -0
  159. package/lib/client/i18n/locales/es/site.d.ts +4 -0
  160. package/lib/client/i18n/locales/es/site.js +208 -0
  161. package/lib/client/layouts/AdminLayout.d.ts +7 -0
  162. package/lib/client/layouts/AdminLayout.js +1046 -0
  163. package/lib/client/layouts/AppLayout.d.ts +6 -0
  164. package/lib/client/layouts/AppLayout.js +19 -0
  165. package/lib/client/layouts/AuthLayout.d.ts +6 -0
  166. package/lib/client/layouts/AuthLayout.js +14 -0
  167. package/lib/client/layouts/DocsLayout.d.ts +6 -0
  168. package/lib/client/layouts/DocsLayout.js +28 -0
  169. package/lib/client/layouts/RootLayout.d.ts +6 -0
  170. package/lib/client/layouts/RootLayout.js +11 -0
  171. package/lib/client/pages/AcceptInvite.d.ts +8 -0
  172. package/lib/client/pages/AcceptInvite.js +60 -0
  173. package/lib/client/pages/Auth.d.ts +1 -0
  174. package/lib/client/pages/Auth.js +40 -0
  175. package/lib/client/pages/Authentication.d.ts +1 -0
  176. package/lib/client/pages/Authentication.js +230 -0
  177. package/lib/client/pages/Content.d.ts +1 -0
  178. package/lib/client/pages/Content.js +21 -0
  179. package/lib/client/pages/Database.d.ts +1 -0
  180. package/lib/client/pages/Database.js +264 -0
  181. package/lib/client/pages/Extending.d.ts +1 -0
  182. package/lib/client/pages/Extending.js +28 -0
  183. package/lib/client/pages/Feed.d.ts +1 -0
  184. package/lib/client/pages/Feed.js +19 -0
  185. package/lib/client/pages/FeedPost.d.ts +1 -0
  186. package/lib/client/pages/FeedPost.js +31 -0
  187. package/lib/client/pages/ForgotPassword.d.ts +8 -0
  188. package/lib/client/pages/ForgotPassword.js +38 -0
  189. package/lib/client/pages/GettingStarted.d.ts +1 -0
  190. package/lib/client/pages/GettingStarted.js +84 -0
  191. package/lib/client/pages/Headless.d.ts +1 -0
  192. package/lib/client/pages/Headless.js +49 -0
  193. package/lib/client/pages/Home.d.ts +1 -0
  194. package/lib/client/pages/Home.js +67 -0
  195. package/lib/client/pages/PostForm.d.ts +1 -0
  196. package/lib/client/pages/PostForm.js +55 -0
  197. package/lib/client/pages/Posts.d.ts +1 -0
  198. package/lib/client/pages/Posts.js +35 -0
  199. package/lib/client/pages/Profile.d.ts +1 -0
  200. package/lib/client/pages/Profile.js +153 -0
  201. package/lib/client/pages/ResetPassword.d.ts +8 -0
  202. package/lib/client/pages/ResetPassword.js +52 -0
  203. package/lib/client/pages/Routing.d.ts +1 -0
  204. package/lib/client/pages/Routing.js +192 -0
  205. package/lib/client/pages/Storage.d.ts +1 -0
  206. package/lib/client/pages/Storage.js +54 -0
  207. package/lib/client/pages/Testing.d.ts +1 -0
  208. package/lib/client/pages/Testing.js +141 -0
  209. package/lib/client/pages/Validation.d.ts +1 -0
  210. package/lib/client/pages/Validation.js +123 -0
  211. package/lib/client/pages/admin/Categories.d.ts +2 -0
  212. package/lib/client/pages/admin/Categories.js +75 -0
  213. package/lib/client/pages/admin/Comments.d.ts +11 -0
  214. package/lib/client/pages/admin/Comments.js +247 -0
  215. package/lib/client/pages/admin/ContentTypes.d.ts +2 -0
  216. package/lib/client/pages/admin/ContentTypes.js +163 -0
  217. package/lib/client/pages/admin/Dashboard.d.ts +2 -0
  218. package/lib/client/pages/admin/Dashboard.js +66 -0
  219. package/lib/client/pages/admin/Health.d.ts +12 -0
  220. package/lib/client/pages/admin/Health.js +148 -0
  221. package/lib/client/pages/admin/Media.d.ts +2 -0
  222. package/lib/client/pages/admin/Media.js +101 -0
  223. package/lib/client/pages/admin/Navigation.d.ts +9 -0
  224. package/lib/client/pages/admin/Navigation.js +230 -0
  225. package/lib/client/pages/admin/Pages.d.ts +2 -0
  226. package/lib/client/pages/admin/Pages.js +53 -0
  227. package/lib/client/pages/admin/PostEditor.d.ts +17 -0
  228. package/lib/client/pages/admin/PostEditor.js +532 -0
  229. package/lib/client/pages/admin/Posts.d.ts +2 -0
  230. package/lib/client/pages/admin/Posts.js +152 -0
  231. package/lib/client/pages/admin/Redirects.d.ts +10 -0
  232. package/lib/client/pages/admin/Redirects.js +87 -0
  233. package/lib/client/pages/admin/Settings.d.ts +2 -0
  234. package/lib/client/pages/admin/Settings.js +111 -0
  235. package/lib/client/pages/admin/Snippets.d.ts +14 -0
  236. package/lib/client/pages/admin/Snippets.js +85 -0
  237. package/lib/client/pages/admin/Tags.d.ts +2 -0
  238. package/lib/client/pages/admin/Tags.js +74 -0
  239. package/lib/client/pages/admin/Taxonomies.d.ts +2 -0
  240. package/lib/client/pages/admin/Taxonomies.js +130 -0
  241. package/lib/client/pages/admin/Tokens.d.ts +9 -0
  242. package/lib/client/pages/admin/Tokens.js +260 -0
  243. package/lib/client/pages/admin/Tools.d.ts +12 -0
  244. package/lib/client/pages/admin/Tools.js +111 -0
  245. package/lib/client/pages/admin/Users.d.ts +13 -0
  246. package/lib/client/pages/admin/Users.js +313 -0
  247. package/lib/client/pages/api-reference.d.ts +33 -0
  248. package/lib/client/pages/api-reference.js +198 -0
  249. package/lib/client/styles.css +37 -0
  250. package/lib/config.d.ts +24 -0
  251. package/lib/config.js +39 -0
  252. package/lib/controllers/AdminController.d.ts +46 -0
  253. package/lib/controllers/AdminController.js +134 -0
  254. package/lib/controllers/AuthController.d.ts +15 -0
  255. package/lib/controllers/AuthController.js +194 -0
  256. package/lib/controllers/AuthorController.d.ts +17 -0
  257. package/lib/controllers/AuthorController.js +19 -0
  258. package/lib/controllers/CategoryController.d.ts +10 -0
  259. package/lib/controllers/CategoryController.js +88 -0
  260. package/lib/controllers/CommentController.d.ts +68 -0
  261. package/lib/controllers/CommentController.js +438 -0
  262. package/lib/controllers/ContentTypeController.d.ts +24 -0
  263. package/lib/controllers/ContentTypeController.js +91 -0
  264. package/lib/controllers/EmailVerificationController.d.ts +33 -0
  265. package/lib/controllers/EmailVerificationController.js +116 -0
  266. package/lib/controllers/ExportController.d.ts +15 -0
  267. package/lib/controllers/ExportController.js +41 -0
  268. package/lib/controllers/FeedController.d.ts +14 -0
  269. package/lib/controllers/FeedController.js +246 -0
  270. package/lib/controllers/HealthController.d.ts +21 -0
  271. package/lib/controllers/HealthController.js +176 -0
  272. package/lib/controllers/HomeController.d.ts +12 -0
  273. package/lib/controllers/HomeController.js +16 -0
  274. package/lib/controllers/MediaController.d.ts +24 -0
  275. package/lib/controllers/MediaController.js +189 -0
  276. package/lib/controllers/NavigationController.d.ts +22 -0
  277. package/lib/controllers/NavigationController.js +176 -0
  278. package/lib/controllers/PageController.d.ts +13 -0
  279. package/lib/controllers/PageController.js +172 -0
  280. package/lib/controllers/PasskeyController.d.ts +36 -0
  281. package/lib/controllers/PasskeyController.js +201 -0
  282. package/lib/controllers/PasswordResetController.d.ts +44 -0
  283. package/lib/controllers/PasswordResetController.js +160 -0
  284. package/lib/controllers/PostController.d.ts +51 -0
  285. package/lib/controllers/PostController.js +538 -0
  286. package/lib/controllers/PostLockController.d.ts +62 -0
  287. package/lib/controllers/PostLockController.js +101 -0
  288. package/lib/controllers/ProfileController.d.ts +13 -0
  289. package/lib/controllers/ProfileController.js +160 -0
  290. package/lib/controllers/PublicApiController.d.ts +23 -0
  291. package/lib/controllers/PublicApiController.js +100 -0
  292. package/lib/controllers/RedirectController.d.ts +32 -0
  293. package/lib/controllers/RedirectController.js +95 -0
  294. package/lib/controllers/SettingsController.d.ts +28 -0
  295. package/lib/controllers/SettingsController.js +105 -0
  296. package/lib/controllers/SnippetController.d.ts +27 -0
  297. package/lib/controllers/SnippetController.js +123 -0
  298. package/lib/controllers/TagController.d.ts +9 -0
  299. package/lib/controllers/TagController.js +70 -0
  300. package/lib/controllers/TaxonomyController.d.ts +24 -0
  301. package/lib/controllers/TaxonomyController.js +149 -0
  302. package/lib/controllers/TokenController.d.ts +27 -0
  303. package/lib/controllers/TokenController.js +83 -0
  304. package/lib/controllers/TwoFactorController.d.ts +31 -0
  305. package/lib/controllers/TwoFactorController.js +213 -0
  306. package/lib/controllers/UserController.d.ts +110 -0
  307. package/lib/controllers/UserController.js +504 -0
  308. package/lib/features/analytics/AnalyticsPage.d.ts +11 -0
  309. package/lib/features/analytics/AnalyticsPage.js +123 -0
  310. package/lib/features/analytics/admin.d.ts +3 -0
  311. package/lib/features/analytics/admin.js +9 -0
  312. package/lib/features/analytics/controller.d.ts +19 -0
  313. package/lib/features/analytics/controller.js +79 -0
  314. package/lib/features/analytics/helpers.d.ts +84 -0
  315. package/lib/features/analytics/helpers.js +181 -0
  316. package/lib/features/analytics/i18n/es.d.ts +4 -0
  317. package/lib/features/analytics/i18n/es.js +31 -0
  318. package/lib/features/analytics/index.d.ts +28 -0
  319. package/lib/features/analytics/index.js +91 -0
  320. package/lib/features/analytics/manifest.d.ts +8 -0
  321. package/lib/features/analytics/manifest.js +18 -0
  322. package/lib/features/analytics/model.d.ts +130 -0
  323. package/lib/features/analytics/model.js +206 -0
  324. package/lib/features/members/Member.d.ts +93 -0
  325. package/lib/features/members/Member.js +194 -0
  326. package/lib/features/members/MemberAdminController.d.ts +60 -0
  327. package/lib/features/members/MemberAdminController.js +262 -0
  328. package/lib/features/members/MemberController.d.ts +88 -0
  329. package/lib/features/members/MemberController.js +250 -0
  330. package/lib/features/members/MembersPage.d.ts +10 -0
  331. package/lib/features/members/MembersPage.js +216 -0
  332. package/lib/features/members/PostAccessBox.d.ts +15 -0
  333. package/lib/features/members/PostAccessBox.js +70 -0
  334. package/lib/features/members/admin.d.ts +3 -0
  335. package/lib/features/members/admin.js +12 -0
  336. package/lib/features/members/csv.d.ts +21 -0
  337. package/lib/features/members/csv.js +74 -0
  338. package/lib/features/members/events.d.ts +34 -0
  339. package/lib/features/members/events.js +34 -0
  340. package/lib/features/members/i18n/es.d.ts +4 -0
  341. package/lib/features/members/i18n/es.js +106 -0
  342. package/lib/features/members/index.d.ts +44 -0
  343. package/lib/features/members/index.js +106 -0
  344. package/lib/features/members/manifest.d.ts +8 -0
  345. package/lib/features/members/manifest.js +18 -0
  346. package/lib/features/members/middleware.d.ts +42 -0
  347. package/lib/features/members/middleware.js +74 -0
  348. package/lib/features/members/newsletter.d.ts +177 -0
  349. package/lib/features/members/newsletter.js +439 -0
  350. package/lib/features/members/rate-limits.d.ts +34 -0
  351. package/lib/features/members/rate-limits.js +50 -0
  352. package/lib/features/members/request.d.ts +13 -0
  353. package/lib/features/members/request.js +6 -0
  354. package/lib/features/members/routes.d.ts +15 -0
  355. package/lib/features/members/routes.js +59 -0
  356. package/lib/features/members/session.d.ts +102 -0
  357. package/lib/features/members/session.js +158 -0
  358. package/lib/features/members/settings.d.ts +14 -0
  359. package/lib/features/members/settings.js +23 -0
  360. package/lib/features/mysendbox/MySendboxSettingsCard.d.ts +7 -0
  361. package/lib/features/mysendbox/MySendboxSettingsCard.js +48 -0
  362. package/lib/features/mysendbox/admin.d.ts +3 -0
  363. package/lib/features/mysendbox/admin.js +9 -0
  364. package/lib/features/mysendbox/broadcasts.d.ts +61 -0
  365. package/lib/features/mysendbox/broadcasts.js +124 -0
  366. package/lib/features/mysendbox/client.d.ts +95 -0
  367. package/lib/features/mysendbox/client.js +61 -0
  368. package/lib/features/mysendbox/config.d.ts +27 -0
  369. package/lib/features/mysendbox/config.js +74 -0
  370. package/lib/features/mysendbox/contacts.d.ts +121 -0
  371. package/lib/features/mysendbox/contacts.js +378 -0
  372. package/lib/features/mysendbox/controller.d.ts +11 -0
  373. package/lib/features/mysendbox/controller.js +47 -0
  374. package/lib/features/mysendbox/i18n/es.d.ts +4 -0
  375. package/lib/features/mysendbox/i18n/es.js +28 -0
  376. package/lib/features/mysendbox/index.d.ts +18 -0
  377. package/lib/features/mysendbox/index.js +71 -0
  378. package/lib/features/mysendbox/manifest.d.ts +7 -0
  379. package/lib/features/mysendbox/manifest.js +6 -0
  380. package/lib/features/mysendbox/routes.d.ts +6 -0
  381. package/lib/features/mysendbox/routes.js +14 -0
  382. package/lib/features/mysendbox/webhook.d.ts +23 -0
  383. package/lib/features/mysendbox/webhook.js +104 -0
  384. package/lib/features/theme/OEmbedController.d.ts +31 -0
  385. package/lib/features/theme/OEmbedController.js +128 -0
  386. package/lib/features/theme/ThemeController.d.ts +20 -0
  387. package/lib/features/theme/ThemeController.js +256 -0
  388. package/lib/features/theme/ThemeSettingsCard.d.ts +7 -0
  389. package/lib/features/theme/ThemeSettingsCard.js +12 -0
  390. package/lib/features/theme/admin.d.ts +3 -0
  391. package/lib/features/theme/admin.js +9 -0
  392. package/lib/features/theme/html.d.ts +48 -0
  393. package/lib/features/theme/html.js +97 -0
  394. package/lib/features/theme/i18n/es.d.ts +4 -0
  395. package/lib/features/theme/i18n/es.js +9 -0
  396. package/lib/features/theme/index.d.ts +11 -0
  397. package/lib/features/theme/index.js +23 -0
  398. package/lib/features/theme/manifest.d.ts +7 -0
  399. package/lib/features/theme/manifest.js +6 -0
  400. package/lib/features/theme/oembed.d.ts +36 -0
  401. package/lib/features/theme/oembed.js +58 -0
  402. package/lib/features/theme/routes.d.ts +17 -0
  403. package/lib/features/theme/routes.js +54 -0
  404. package/lib/features/theme/templates.d.ts +103 -0
  405. package/lib/features/theme/templates.js +283 -0
  406. package/lib/features.d.ts +15 -0
  407. package/lib/features.js +6 -0
  408. package/lib/features.manifest.d.ts +10 -0
  409. package/lib/features.manifest.js +6 -0
  410. package/lib/helpers/access.d.ts +62 -0
  411. package/lib/helpers/access.js +92 -0
  412. package/lib/helpers/api.d.ts +20 -0
  413. package/lib/helpers/api.js +44 -0
  414. package/lib/helpers/comment-guard.d.ts +145 -0
  415. package/lib/helpers/comment-guard.js +253 -0
  416. package/lib/helpers/comment-mail.d.ts +53 -0
  417. package/lib/helpers/comment-mail.js +188 -0
  418. package/lib/helpers/content-model.d.ts +50 -0
  419. package/lib/helpers/content-model.js +84 -0
  420. package/lib/helpers/content-paths.d.ts +107 -0
  421. package/lib/helpers/content-paths.js +200 -0
  422. package/lib/helpers/export-data.d.ts +85 -0
  423. package/lib/helpers/export-data.js +229 -0
  424. package/lib/helpers/gating.d.ts +53 -0
  425. package/lib/helpers/gating.js +83 -0
  426. package/lib/helpers/health.d.ts +91 -0
  427. package/lib/helpers/health.js +279 -0
  428. package/lib/helpers/heartbeat.d.ts +35 -0
  429. package/lib/helpers/heartbeat.js +55 -0
  430. package/lib/helpers/image-size.d.ts +18 -0
  431. package/lib/helpers/image-size.js +83 -0
  432. package/lib/helpers/images.d.ts +29 -0
  433. package/lib/helpers/images.js +41 -0
  434. package/lib/helpers/mail-templates.d.ts +11 -0
  435. package/lib/helpers/mail-templates.js +42 -0
  436. package/lib/helpers/publish-due.d.ts +28 -0
  437. package/lib/helpers/publish-due.js +67 -0
  438. package/lib/helpers/redirects.d.ts +43 -0
  439. package/lib/helpers/redirects.js +80 -0
  440. package/lib/helpers/seo-fields.d.ts +13 -0
  441. package/lib/helpers/seo-fields.js +52 -0
  442. package/lib/helpers/session.d.ts +30 -0
  443. package/lib/helpers/session.js +27 -0
  444. package/lib/helpers/site-settings.d.ts +98 -0
  445. package/lib/helpers/site-settings.js +232 -0
  446. package/lib/helpers/site.d.ts +14 -0
  447. package/lib/helpers/site.js +23 -0
  448. package/lib/helpers/write-hooks.d.ts +33 -0
  449. package/lib/helpers/write-hooks.js +37 -0
  450. package/lib/hooks.d.ts +17 -0
  451. package/lib/hooks.js +101 -0
  452. package/lib/host/core-tasks.d.ts +4 -0
  453. package/lib/host/core-tasks.js +26 -0
  454. package/lib/host/cron.d.ts +39 -0
  455. package/lib/host/cron.js +85 -0
  456. package/lib/host/enabled.d.ts +4 -0
  457. package/lib/host/enabled.js +40 -0
  458. package/lib/host/index.d.ts +81 -0
  459. package/lib/host/index.js +87 -0
  460. package/lib/host/manifest.d.ts +34 -0
  461. package/lib/host/manifest.js +7 -0
  462. package/lib/host/menu.d.ts +18 -0
  463. package/lib/host/menu.js +15 -0
  464. package/lib/main.d.ts +1 -0
  465. package/lib/main.js +24 -0
  466. package/lib/middleware/api-auth.d.ts +59 -0
  467. package/lib/middleware/api-auth.js +164 -0
  468. package/lib/middleware/auth.d.ts +49 -0
  469. package/lib/middleware/auth.js +112 -0
  470. package/lib/middleware/cache.d.ts +17 -0
  471. package/lib/middleware/cache.js +52 -0
  472. package/lib/middleware/rate-limits.d.ts +199 -0
  473. package/lib/middleware/rate-limits.js +276 -0
  474. package/lib/middleware/viewer.d.ts +13 -0
  475. package/lib/middleware/viewer.js +16 -0
  476. package/lib/models/Category.d.ts +24 -0
  477. package/lib/models/Category.js +102 -0
  478. package/lib/models/Comment.d.ts +120 -0
  479. package/lib/models/Comment.js +283 -0
  480. package/lib/models/ContentType.d.ts +142 -0
  481. package/lib/models/ContentType.js +462 -0
  482. package/lib/models/Credential.d.ts +21 -0
  483. package/lib/models/Credential.js +31 -0
  484. package/lib/models/Media.d.ts +53 -0
  485. package/lib/models/Media.js +132 -0
  486. package/lib/models/Menu.d.ts +131 -0
  487. package/lib/models/Menu.js +312 -0
  488. package/lib/models/Page.d.ts +55 -0
  489. package/lib/models/Page.js +218 -0
  490. package/lib/models/Post.d.ts +136 -0
  491. package/lib/models/Post.js +406 -0
  492. package/lib/models/PostLock.d.ts +67 -0
  493. package/lib/models/PostLock.js +112 -0
  494. package/lib/models/PostRevision.d.ts +45 -0
  495. package/lib/models/PostRevision.js +82 -0
  496. package/lib/models/PublicContent.d.ts +283 -0
  497. package/lib/models/PublicContent.js +577 -0
  498. package/lib/models/Redirect.d.ts +123 -0
  499. package/lib/models/Redirect.js +225 -0
  500. package/lib/models/Settings.d.ts +61 -0
  501. package/lib/models/Settings.js +128 -0
  502. package/lib/models/Snippet.d.ts +36 -0
  503. package/lib/models/Snippet.js +64 -0
  504. package/lib/models/Tag.d.ts +23 -0
  505. package/lib/models/Tag.js +117 -0
  506. package/lib/models/Taxonomy.d.ts +127 -0
  507. package/lib/models/Taxonomy.js +321 -0
  508. package/lib/models/TwoFactor.d.ts +26 -0
  509. package/lib/models/TwoFactor.js +60 -0
  510. package/lib/models/User.d.ts +49 -0
  511. package/lib/models/User.js +128 -0
  512. package/lib/models/derive.d.ts +69 -0
  513. package/lib/models/derive.js +81 -0
  514. package/lib/models/pagination.d.ts +30 -0
  515. package/lib/models/pagination.js +36 -0
  516. package/lib/models/visibility.d.ts +31 -0
  517. package/lib/models/visibility.js +47 -0
  518. package/lib/routes/App.d.ts +2 -0
  519. package/lib/routes/App.js +146 -0
  520. package/lib/routes/api/admin.d.ts +6 -0
  521. package/lib/routes/api/admin.js +11 -0
  522. package/lib/routes/api/auth.d.ts +6 -0
  523. package/lib/routes/api/auth.js +24 -0
  524. package/lib/routes/api/authors.d.ts +5 -0
  525. package/lib/routes/api/authors.js +8 -0
  526. package/lib/routes/api/categories.d.ts +8 -0
  527. package/lib/routes/api/categories.js +15 -0
  528. package/lib/routes/api/comments.d.ts +8 -0
  529. package/lib/routes/api/comments.js +35 -0
  530. package/lib/routes/api/content-model.d.ts +17 -0
  531. package/lib/routes/api/content-model.js +67 -0
  532. package/lib/routes/api/cron.d.ts +6 -0
  533. package/lib/routes/api/cron.js +9 -0
  534. package/lib/routes/api/export.d.ts +5 -0
  535. package/lib/routes/api/export.js +11 -0
  536. package/lib/routes/api/feed.d.ts +5 -0
  537. package/lib/routes/api/feed.js +16 -0
  538. package/lib/routes/api/media.d.ts +8 -0
  539. package/lib/routes/api/media.js +25 -0
  540. package/lib/routes/api/navigation.d.ts +12 -0
  541. package/lib/routes/api/navigation.js +17 -0
  542. package/lib/routes/api/ops.d.ts +9 -0
  543. package/lib/routes/api/ops.js +19 -0
  544. package/lib/routes/api/pages.d.ts +8 -0
  545. package/lib/routes/api/pages.js +21 -0
  546. package/lib/routes/api/passkeys.d.ts +7 -0
  547. package/lib/routes/api/passkeys.js +13 -0
  548. package/lib/routes/api/posts.d.ts +8 -0
  549. package/lib/routes/api/posts.js +39 -0
  550. package/lib/routes/api/profile.d.ts +6 -0
  551. package/lib/routes/api/profile.js +8 -0
  552. package/lib/routes/api/redirects.d.ts +12 -0
  553. package/lib/routes/api/redirects.js +13 -0
  554. package/lib/routes/api/settings.d.ts +8 -0
  555. package/lib/routes/api/settings.js +15 -0
  556. package/lib/routes/api/snippets.d.ts +15 -0
  557. package/lib/routes/api/snippets.js +16 -0
  558. package/lib/routes/api/tags.d.ts +8 -0
  559. package/lib/routes/api/tags.js +14 -0
  560. package/lib/routes/api/tokens.d.ts +7 -0
  561. package/lib/routes/api/tokens.js +15 -0
  562. package/lib/routes/api/two-factor.d.ts +7 -0
  563. package/lib/routes/api/two-factor.js +15 -0
  564. package/lib/routes/api/users.d.ts +8 -0
  565. package/lib/routes/api/users.js +25 -0
  566. package/lib/routes/api/v1.d.ts +12 -0
  567. package/lib/routes/api/v1.js +55 -0
  568. package/lib/routes/api/verification.d.ts +6 -0
  569. package/lib/routes/api/verification.js +11 -0
  570. package/lib/server/index.d.ts +24 -0
  571. package/lib/server/index.js +110 -0
  572. package/lib/types/index.d.ts +298 -0
  573. package/lib/types/index.js +1 -0
  574. package/lib/vite.d.ts +2 -0
  575. package/lib/vite.js +101 -0
  576. package/mail/comment-moderation.html +27 -0
  577. package/mail/comment-moderation.txt +13 -0
  578. package/mail/comment-reply.html +28 -0
  579. package/mail/comment-reply.txt +14 -0
  580. package/mail/invitation.html +25 -0
  581. package/mail/invitation.txt +11 -0
  582. package/mail/member-magic-link.html +23 -0
  583. package/mail/member-magic-link.txt +10 -0
  584. package/mail/newsletter.html +26 -0
  585. package/mail/newsletter.txt +13 -0
  586. package/mail/password-reset.html +26 -0
  587. package/mail/password-reset.txt +10 -0
  588. package/mail/verify-email.html +25 -0
  589. package/mail/verify-email.txt +8 -0
  590. package/package.json +85 -4
@@ -0,0 +1,264 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useTheme } from "../components/ThemeContext.js";
3
+ import { Card } from "../components/Card.js";
4
+ import { PageHeader } from "../components/PageHeader.js";
5
+ export function Database() {
6
+ const { t } = useTheme();
7
+ const CodeBlock = ({ children, title }) => (_jsxs("div", { className: "mt-4", children: [title && _jsx("div", { className: `text-xs font-medium mb-2 ${t.muted}`, children: title }), _jsx("div", { className: `rounded-lg p-4 font-mono text-sm ${t.card} border ${t.border} overflow-x-auto`, children: _jsx("pre", { className: t.text, children: children }) })] }));
8
+ return (_jsxs("div", { children: [_jsx(PageHeader, { title: "Database", subtitle: "Drivers, migrations, seeding, and the query builder" }), _jsxs("div", { className: "space-y-6", children: [_jsxs(Card, { children: [_jsx("h2", { className: "text-lg font-semibold mb-2", children: "Drivers" }), _jsxs("p", { className: `text-sm ${t.muted} mb-4`, children: ["There are two drivers: ", _jsx("code", { children: "sqlite" }), " and ", _jsx("code", { children: "postgres" }), "(", _jsx("code", { children: "pg" }), " is an accepted alias). Anything else throws", _jsx("code", { children: "Unknown database driver" }), " when the connection is opened. Configure the one you want in ", _jsx("code", { children: "basicben.config.js" }), "."] }), _jsxs("div", { className: "grid gap-3 sm:grid-cols-2 mb-4", children: [_jsxs("div", { className: `rounded-lg p-3 ${t.card} border ${t.border}`, children: [_jsx("div", { className: "font-semibold text-sm", children: "SQLite" }), _jsxs("p", { className: `text-xs mt-1 ${t.muted}`, children: ["The default. Uses Node's built-in ", _jsx("code", { children: "node:sqlite" }), ", so there is nothing to install \u2014 but it needs Node 24 or newer."] })] }), _jsxs("div", { className: `rounded-lg p-3 ${t.card} border ${t.border}`, children: [_jsx("div", { className: "font-semibold text-sm", children: "PostgreSQL" }), _jsxs("p", { className: `text-xs mt-1 ${t.muted}`, children: ["Uses ", _jsx("code", { children: "pg" }), ", an optional dependency. Run ", _jsx("code", { children: "npm install pg" }), "if it is not already present."] })] })] }), _jsx(CodeBlock, { title: "basicben.config.js \u2014 SQLite (default)", children: `export default {
9
+ db: {
10
+ driver: 'sqlite',
11
+ url: './database.sqlite'
12
+ }
13
+ }` }), _jsx(CodeBlock, { title: "basicben.config.js \u2014 Postgres", children: `export default {
14
+ db: {
15
+ driver: 'postgres',
16
+ url: process.env.DATABASE_URL,
17
+ poolSize: 10 // optional, defaults to 10
18
+ }
19
+ }` }), _jsxs("p", { className: `text-sm ${t.muted} mt-4`, children: ["The connection string is taken from ", _jsx("code", { children: "db.url" }), ", then", _jsx("code", { children: "process.env.DATABASE_URL" }), ", then ", _jsx("code", { children: "./database.sqlite" }), ". Leaving", _jsx("code", { children: "db" }), " out of the config entirely gives you a local SQLite file, which is why a new project works before you have configured anything."] }), _jsx("p", { className: `text-sm ${t.muted} mt-4`, children: "The connection is a single cached instance for the life of the process. The first call opens it; every later call reuses it." })] }), _jsxs(Card, { children: [_jsx("h2", { className: "text-lg font-semibold mb-2", children: "Hosted Databases" }), _jsx("p", { className: `text-sm ${t.muted} mb-4`, children: "There is no adapter for any hosted provider specifically. What works is decided by wire protocol, not by branding." }), _jsxs("div", { className: "space-y-3", children: [_jsxs("div", { className: `rounded-lg p-3 ${t.card} border ${t.border}`, children: [_jsx("div", { className: "font-semibold text-sm", children: "Neon \u2014 works" }), _jsxs("p", { className: `text-xs mt-1 ${t.muted}`, children: ["Neon speaks the Postgres wire protocol, so use", _jsx("code", { children: "driver: 'postgres'" }), " with the connection string Neon gives you. Setting ", _jsx("code", { children: "driver: 'neon'" }), " throws."] })] }), _jsxs("div", { className: `rounded-lg p-3 ${t.card} border ${t.border}`, children: [_jsx("div", { className: "font-semibold text-sm", children: "Supabase, RDS, and other Postgres hosts \u2014 works" }), _jsxs("p", { className: `text-xs mt-1 ${t.muted}`, children: ["Same as Neon: ", _jsx("code", { children: "driver: 'postgres'" }), " and their connection string."] })] }), _jsxs("div", { className: `rounded-lg p-3 ${t.card} border ${t.border}`, children: [_jsx("div", { className: "font-semibold text-sm", children: "Turso and libSQL \u2014 not yet" }), _jsxs("p", { className: `text-xs mt-1 ${t.muted}`, children: ["An HTTP libSQL adapter is planned but not shipped. ", _jsx("code", { children: "driver: 'turso'" }), "throws today."] })] }), _jsxs("div", { className: `rounded-lg p-3 ${t.card} border ${t.border}`, children: [_jsx("div", { className: "font-semibold text-sm", children: "PlanetScale \u2014 not supported" }), _jsx("p", { className: `text-xs mt-1 ${t.muted}`, children: "PlanetScale is MySQL. There is no MySQL driver, and MySQL is not a goal." })] })] }), _jsx(CodeBlock, { title: "Neon, Supabase, or any Postgres host", children: `export default {
20
+ db: {
21
+ driver: 'postgres',
22
+ url: process.env.DATABASE_URL
23
+ }
24
+ }` })] }), _jsxs(Card, { children: [_jsx("h2", { className: "text-lg font-semibold mb-2", children: "Migrations" }), _jsxs("p", { className: `text-sm ${t.muted} mb-4`, children: ["A migration is a file in ", _jsx("code", { children: "db/migrations/" }), " that exports ", _jsx("code", { children: "up" }), " and", _jsx("code", { children: "down" }), ". Both receive the database adapter and run raw SQL through", _jsx("code", { children: "db.exec()" }), ". There is no schema builder \u2014 you write the SQL your database understands."] }), _jsx(CodeBlock, { title: "Generate a migration", children: `npm run make:migration create_posts
25
+ # Creates: db/migrations/<timestamp>_create_posts.js` }), _jsx(CodeBlock, { title: "db/migrations/001_create_posts.js", children: `export const up = async (db) => {
26
+ await db.exec(\`
27
+ CREATE TABLE posts (
28
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
29
+ user_id INTEGER NOT NULL,
30
+ title TEXT NOT NULL,
31
+ content TEXT,
32
+ published INTEGER DEFAULT 0,
33
+ created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
34
+ FOREIGN KEY (user_id) REFERENCES users(id)
35
+ )
36
+ \`)
37
+ }
38
+
39
+ export const down = async (db) => {
40
+ await db.exec('DROP TABLE IF EXISTS posts')
41
+ }` }), _jsxs("p", { className: `text-sm ${t.muted} mt-4`, children: ["Files run in filename order, and each run is recorded in a ", _jsx("code", { children: "_migrations" }), "table along with a batch number. A rollback undoes the whole last batch in reverse order, so if one ", _jsx("code", { children: "migrate" }), " applied five files, one rollback removes all five."] }), _jsxs("p", { className: `text-sm ${t.muted} mt-4`, children: ["Each file runs in its own transaction, together with the row recording that it ran \u2014 both commit or neither does. A migration that creates two tables and throws between them used to leave the first one behind with nothing recorded, so the next", ' ', _jsx("code", { children: "migrate" }), " failed on ", _jsx("em", { children: "table already exists" }), " and there was nothing to roll back. The database is now either before the migration or after it."] }), _jsxs("p", { className: `text-sm ${t.muted} mt-4`, children: ["Two statements cannot run inside a transaction, and neither appears in what this framework ships: Postgres refuses ", _jsx("code", { children: "CREATE INDEX CONCURRENTLY" }), " and", ' ', _jsx("code", { children: "VACUUM" }), ", and SQLite ignores ", _jsx("code", { children: "PRAGMA foreign_keys" }), " there \u2014 the table-rebuild pattern that turns constraints off has to do it outside. A migration that opens its own ", _jsx("code", { children: "db.transaction()" }), " is fine: it joins the one already open rather than starting a second, which both drivers refuse."] }), _jsxs("div", { className: "mt-4 grid gap-3 sm:grid-cols-2", children: [_jsxs("div", { className: `rounded-lg p-3 ${t.card} border ${t.border}`, children: [_jsx("code", { className: "text-sm font-semibold", children: "npm run migrate" }), _jsx("p", { className: `text-xs mt-1 ${t.muted}`, children: "Run pending migrations" })] }), _jsxs("div", { className: `rounded-lg p-3 ${t.card} border ${t.border}`, children: [_jsx("code", { className: "text-sm font-semibold", children: "npm run migrate:rollback" }), _jsx("p", { className: `text-xs mt-1 ${t.muted}`, children: "Undo the last batch" })] }), _jsxs("div", { className: `rounded-lg p-3 ${t.card} border ${t.border}`, children: [_jsx("code", { className: "text-sm font-semibold", children: "npm run migrate:fresh" }), _jsx("p", { className: `text-xs mt-1 ${t.muted}`, children: "Drop every table and migrate again" })] }), _jsxs("div", { className: `rounded-lg p-3 ${t.card} border ${t.border}`, children: [_jsx("code", { className: "text-sm font-semibold", children: "npm run migrate:status" }), _jsx("p", { className: `text-xs mt-1 ${t.muted}`, children: "Show which files have run" })] })] }), _jsxs("p", { className: `text-sm ${t.muted} mt-4`, children: ["The generated stub and the migrations that ship with a new project are written in SQLite dialect. If you are targeting Postgres, translate as you go:", _jsx("code", { children: "INTEGER PRIMARY KEY AUTOINCREMENT" }), " becomes ", _jsx("code", { children: "SERIAL PRIMARY KEY" }), " or", _jsx("code", { children: "GENERATED ALWAYS AS IDENTITY" }), ", and ", _jsx("code", { children: "DATETIME" }), " becomes", _jsx("code", { children: "TIMESTAMP" }), ". Nothing rewrites SQL for you."] })] }), _jsxs(Card, { children: [_jsx("h2", { className: "text-lg font-semibold mb-2", children: "Seeding" }), _jsxs("p", { className: `text-sm ${t.muted} mb-4`, children: ["Seeds populate a database with starting data. Each file in ", _jsx("code", { children: "db/seeds/" }), "exports a ", _jsx("code", { children: "seed" }), " function (a default export also works), and files run in filename order, which is why they are usually numbered."] }), _jsx(CodeBlock, { title: "db/seeds/01_users.js", children: `import { db } from '@basicbenframework/core/db'
42
+ import { hashPassword } from '@basicbenframework/core/auth'
43
+ import { ROLES } from '@basicbenframework/core/auth/permissions'
44
+
45
+ export async function seed() {
46
+ const password = await hashPassword('password123')
47
+
48
+ await (await db.table('users')).insert({
49
+ name: 'Admin User',
50
+ email: 'admin@example.com',
51
+ password,
52
+ role: ROLES.ADMIN
53
+ })
54
+
55
+ console.log('Seeded 1 user')
56
+ }` }), _jsxs("p", { className: `text-sm ${t.muted} mt-4`, children: ["Seed a password through ", _jsx("code", { children: "hashPassword" }), " rather than writing a literal, and set", _jsx("code", { children: "role" }), " explicitly. The column defaults to ", _jsx("code", { children: "subscriber" }), ", and the migration that promotes the first account runs before any seeder, against an empty table \u2014 so a seeded user named \u201CAdmin User\u201D without a role is a subscriber that cannot reach anything the admin area gates."] }), _jsx(CodeBlock, { title: "db/seeds/02_posts.js", children: `import { db } from '@basicbenframework/core/db'
57
+
58
+ export async function seed() {
59
+ const user = await (await db.table('users')).first()
60
+
61
+ await (await db.table('posts')).insert({
62
+ user_id: user.id,
63
+ title: 'Welcome to BasicBen',
64
+ content: 'Your first post.',
65
+ published: 1
66
+ })
67
+ }` }), _jsxs("div", { className: "mt-4 grid gap-3 sm:grid-cols-2", children: [_jsxs("div", { className: `rounded-lg p-3 ${t.card} border ${t.border}`, children: [_jsx("code", { className: "text-sm font-semibold", children: "npm run seed" }), _jsx("p", { className: `text-xs mt-1 ${t.muted}`, children: "Run every seed file" })] }), _jsxs("div", { className: `rounded-lg p-3 ${t.card} border ${t.border}`, children: [_jsx("code", { className: "text-sm font-semibold", children: "npx basicben seed 01_users" }), _jsx("p", { className: `text-xs mt-1 ${t.muted}`, children: "Run one file, named without the extension" })] }), _jsxs("div", { className: `rounded-lg p-3 ${t.card} border ${t.border}`, children: [_jsx("code", { className: "text-sm font-semibold", children: "npx basicben make:seed users" }), _jsx("p", { className: `text-xs mt-1 ${t.muted}`, children: "Generate db/seeds/users.js" })] }), _jsxs("div", { className: `rounded-lg p-3 ${t.card} border ${t.border}`, children: [_jsx("code", { className: "text-sm font-semibold", children: "npx basicben db:seed" }), _jsx("p", { className: `text-xs mt-1 ${t.muted}`, children: "Alias for seed" })] })] }), _jsx("p", { className: `text-sm ${t.muted} mt-4`, children: "Seeds are not tracked the way migrations are, so running them twice runs them twice. Against a table with a unique constraint the second run fails, which is usually what you want to notice." })] }), _jsxs(Card, { children: [_jsx("h2", { className: "text-lg font-semibold mb-2", children: "Query Builder" }), _jsxs("p", { className: `text-sm ${t.muted} mb-4`, children: [_jsx("code", { children: "query(table)" }), " and ", _jsx("code", { children: "db.table(table)" }), " both return a builder, and both are async because they open the connection first. That is where the double await in these examples comes from: the outer one waits for the query, the inner one waits for the builder."] }), _jsx(CodeBlock, { title: "Reading", children: `import { db, query } from '@basicbenframework/core/db'
68
+
69
+ // Every row
70
+ const users = await (await query('users')).get()
71
+
72
+ // One row by id, or undefined
73
+ const user = await (await query('users')).find(1)
74
+
75
+ // Two arguments mean equals
76
+ const admins = await (await query('users'))
77
+ .where('is_admin', 1)
78
+ .get()
79
+
80
+ // Three arguments take an operator
81
+ const recent = await (await query('posts'))
82
+ .where('published', 1)
83
+ .where('id', '>', 100)
84
+ .orderBy('created_at', 'DESC')
85
+ .limit(10)
86
+ .get()
87
+
88
+ // first() adds LIMIT 1 and returns the row itself
89
+ const latest = await (await query('posts'))
90
+ .orderBy('created_at', 'DESC')
91
+ .first()
92
+
93
+ // db.table() is the same builder under a different name
94
+ const drafts = await (await db.table('posts')).where('published', 0).get()` }), _jsx(CodeBlock, { title: "Writing", children: `const result = await (await query('posts')).insert({
95
+ user_id: 1,
96
+ title: 'My Post',
97
+ content: 'Hello world'
98
+ })
99
+
100
+ result.lastInsertRowid // id of the new row
101
+ result.changes // 1
102
+
103
+ await (await query('posts'))
104
+ .where('id', postId)
105
+ .update({ title: 'Updated Title' })
106
+
107
+ await (await query('posts'))
108
+ .where('id', postId)
109
+ .delete()` }), _jsxs("p", { className: `text-sm ${t.muted} mt-4`, children: ["On Postgres, ", _jsx("code", { children: "insert()" }), " appends ", _jsx("code", { children: "RETURNING id" }), " so", _jsx("code", { children: "lastInsertRowid" }), " is filled in there too. A hand-written", _jsx("code", { children: "INSERT" }), " without that clause returns ", _jsx("code", { children: "null" }), " instead, which is a good reason to insert through the builder."] }), _jsx(CodeBlock, { title: "Counting and paging", children: `const total = await (await query('posts'))
110
+ .where('published', 1)
111
+ .count()
112
+
113
+ const taken = await (await query('users'))
114
+ .where('email', 'test@example.com')
115
+ .exists()
116
+
117
+ const page = await (await query('posts'))
118
+ .orderBy('created_at', 'DESC')
119
+ .paginate(1, 15)
120
+
121
+ // { data, total, page, perPage, totalPages }` }), _jsx("p", { className: `text-sm ${t.muted} mt-4`, children: "The full method list is short by design." }), _jsx("div", { className: "mt-4 grid gap-2 sm:grid-cols-2", children: [
122
+ { name: 'select(...cols)', desc: 'Columns to return; defaults to *' },
123
+ { name: 'where(col, val)', desc: 'Equality shorthand' },
124
+ { name: 'where(col, op, val)', desc: '=, !=, <, >, <=, >=, LIKE, IN and friends' },
125
+ { name: 'whereNull(col)', desc: 'IS NULL' },
126
+ { name: 'whereNotNull(col)', desc: 'IS NOT NULL' },
127
+ { name: 'orderBy(col, dir)', desc: 'ASC or DESC' },
128
+ { name: 'limit(n) / offset(n)', desc: 'Slice the result' },
129
+ { name: 'get() / first()', desc: 'All rows, or the first one' },
130
+ { name: 'find(id)', desc: 'Shorthand for where(\'id\', id).first()' },
131
+ { name: 'insert(data)', desc: 'Returns { lastInsertRowid, changes }' },
132
+ { name: 'update(data) / delete()', desc: 'Return { lastInsertRowid, changes }' },
133
+ { name: 'count() / exists()', desc: 'A number, and whether it is above zero' },
134
+ { name: 'paginate(page, perPage)', desc: 'Rows plus the totals to render a pager' },
135
+ { name: 'only(...) / except(...)', desc: 'Mass assignment rules, below' },
136
+ { name: 'toSql()', desc: 'The SELECT this builder would run' },
137
+ ].map(({ name, desc }) => (_jsxs("div", { className: `rounded-lg p-3 ${t.card} border ${t.border}`, children: [_jsx("code", { className: "text-sm font-semibold", children: name }), _jsx("p", { className: `text-xs mt-1 ${t.muted}`, children: desc })] }, name))) }), _jsxs("p", { className: `text-sm ${t.muted} mt-4`, children: ["Multiple ", _jsx("code", { children: "where" }), " calls are joined with ", _jsx("code", { children: "AND" }), ". Table and column names are validated against ", _jsx("code", { children: "[a-zA-Z_][a-zA-Z0-9_]*" }), " and quoted, and every value goes in as a bound parameter, so user input cannot become SQL."] })] }), _jsxs(Card, { children: [_jsx("h2", { className: "text-lg font-semibold mb-2", children: "Booleans on SQLite" }), _jsxs("p", { className: `text-sm ${t.muted} mb-4`, children: [_jsx("code", { children: "node:sqlite" }), " refuses to bind JavaScript booleans. Passing", _jsx("code", { children: "true" }), " or ", _jsx("code", { children: "false" }), " as a value throws", _jsx("code", { children: "Provided value cannot be bound to SQLite parameter" }), ", whether it came from an insert or a where clause. Store flags as integers and convert at the edge."] }), _jsx(CodeBlock, { title: "Use 1 and 0", children: `// Throws on SQLite
138
+ await (await query('posts')).insert({ title: 'Draft', published: false })
139
+ await (await query('posts')).where('published', true).get()
140
+
141
+ // Works
142
+ await (await query('posts')).insert({ title: 'Draft', published: 0 })
143
+ await (await query('posts')).where('published', 1).get()
144
+
145
+ // Convert where the value arrives, not everywhere it is used
146
+ await (await query('posts')).insert({
147
+ title: req.body.title,
148
+ published: req.body.published ? 1 : 0
149
+ })` })] }), _jsxs(Card, { children: [_jsx("h2", { className: "text-lg font-semibold mb-2", children: "Mass Assignment Protection" }), _jsxs("p", { className: `text-sm ${t.muted} mb-4`, children: [_jsx("code", { children: "only()" }), " lists the columns a write may touch; ", _jsx("code", { children: "except()" }), " lists the ones it may not. Anything excluded is dropped silently rather than raising, so a request body with extra fields still succeeds \u2014 minus the fields it should not have set. ", _jsx("code", { children: "id" }), " is blocked by default."] }), _jsx(CodeBlock, { title: "Whitelist with only()", children: `await (await query('users'))
150
+ .only('name', 'email', 'bio')
151
+ .insert(req.body)
152
+
153
+ // Given { name: 'Bob', email: 'bob@test.com', is_admin: 1 }
154
+ // the row is written without is_admin` }), _jsx(CodeBlock, { title: "Blacklist with except()", children: `await (await query('users'))
155
+ .except('id', 'is_admin', 'created_at')
156
+ .where('id', userId)
157
+ .update(req.body)` }), _jsxs("p", { className: `text-sm ${t.muted} mt-4`, children: ["Prefer ", _jsx("code", { children: "only()" }), ". A whitelist stays correct when someone adds a column later; a blacklist quietly stops covering everything."] })] }), _jsxs(Card, { children: [_jsx("h2", { className: "text-lg font-semibold mb-2", children: "What the Builder Does Not Do" }), _jsxs("p", { className: `text-sm ${t.muted} mb-4`, children: ["The list above is all of it. There is no ", _jsx("code", { children: "join" }), ", no", _jsx("code", { children: "whereIn" }), ", no ", _jsx("code", { children: "orWhere" }), ", no ", _jsx("code", { children: "groupBy" }), ", and no aggregate beyond ", _jsx("code", { children: "count()" }), ". This is deliberate: a builder that covers every query ends up as large as the SQL it hides. When you need more, write SQL."] }), _jsx(CodeBlock, { title: "A join is a raw query", children: `import { db } from '@basicbenframework/core/db'
158
+
159
+ const posts = await db.all(
160
+ \`SELECT posts.*, users.name AS author
161
+ FROM posts
162
+ JOIN users ON users.id = posts.user_id
163
+ WHERE posts.published = ?
164
+ ORDER BY posts.created_at DESC
165
+ LIMIT 5\`,
166
+ [1]
167
+ )` }), _jsx(CodeBlock, { title: "So is IN, with one placeholder per value", children: `const ids = [1, 2, 3]
168
+ const placeholders = ids.map(() => '?').join(', ')
169
+
170
+ const users = await db.all(
171
+ \`SELECT * FROM users WHERE id IN (\${placeholders})\`,
172
+ ids
173
+ )` }), _jsx("p", { className: `text-sm ${t.muted} mt-4`, children: "Build placeholders from the array length and pass the values separately, never by interpolating the values themselves." })] }), _jsxs(Card, { children: [_jsx("h2", { className: "text-lg font-semibold mb-2", children: "Raw Queries" }), _jsx("p", { className: `text-sm ${t.muted} mb-4`, children: "The adapter is available directly for anything the builder does not cover." }), _jsx(CodeBlock, { title: "db.all, db.get, db.run, db.exec", children: `import { db } from '@basicbenframework/core/db'
174
+
175
+ // Many rows
176
+ const posts = await db.all(
177
+ 'SELECT * FROM posts WHERE user_id = ? AND published = ?',
178
+ [userId, 1]
179
+ )
180
+
181
+ // One row, or undefined
182
+ const user = await db.get('SELECT * FROM users WHERE email = ?', [email])
183
+
184
+ // Writes: { lastInsertRowid, changes }
185
+ const result = await db.run(
186
+ 'INSERT INTO posts (title, user_id) VALUES (?, ?)',
187
+ [title, userId]
188
+ )
189
+
190
+ // Statements with no parameters, such as DDL
191
+ await db.exec('CREATE INDEX idx_posts_user ON posts (user_id)')` }), _jsxs("p", { className: `text-sm ${t.muted} mt-4`, children: ["Raw SQL reaches the driver exactly as written, so the placeholder style is yours to get right: ", _jsx("code", { children: "?" }), " on SQLite, ", _jsx("code", { children: "$1" }), ", ", _jsx("code", { children: "$2" }), " on Postgres. The builder handles that difference for you, which is one more reason to use it for ordinary queries and save raw SQL for the queries that need it."] })] }), _jsxs(Card, { children: [_jsx("h2", { className: "text-lg font-semibold mb-2", children: "Transactions" }), _jsxs("p", { className: `text-sm ${t.muted} mb-4`, children: [_jsx("code", { children: "db.transaction()" }), " wraps the callback in ", _jsx("code", { children: "BEGIN" }), " and", _jsx("code", { children: "COMMIT" }), ", rolls back if it throws, and returns whatever the callback returns. The callback receives a transaction-scoped adapter, and its result is awaited before the commit, so async work inside is safe."] }), _jsx(CodeBlock, { title: "Transferring between two rows", children: `const remaining = await db.transaction(async (tx) => {
192
+ await tx.run(
193
+ 'UPDATE accounts SET balance = balance - ? WHERE id = ?',
194
+ [100, fromId]
195
+ )
196
+ await tx.run(
197
+ 'UPDATE accounts SET balance = balance + ? WHERE id = ?',
198
+ [100, toId]
199
+ )
200
+
201
+ const row = await tx.get('SELECT balance FROM accounts WHERE id = ?', [fromId])
202
+ return row.balance
203
+ })` }), _jsxs("p", { className: `text-sm ${t.muted} mt-4`, children: ["Use ", _jsx("code", { children: "tx" }), " inside the callback rather than ", _jsx("code", { children: "db" }), ". On Postgres the transaction holds one pooled client, and a statement sent through ", _jsx("code", { children: "db" }), "takes a different connection \u2014 it would commit on its own and survive the rollback. The ", _jsx("code", { children: "tx" }), " object exposes ", _jsx("code", { children: "run" }), ", ", _jsx("code", { children: "get" }), ",", _jsx("code", { children: "all" }), " and ", _jsx("code", { children: "exec" }), "; the query builder does not accept it, so transactional work is written in SQL."] })] }), _jsxs(Card, { children: [_jsx("h2", { className: "text-lg font-semibold mb-2", children: "Models" }), _jsx("p", { className: `text-sm ${t.muted} mb-4`, children: "A model here is a plain object that groups the queries for one table. There is no base class to extend, no active record, no relations, and no lazy loading \u2014 a model has exactly the methods you write." }), _jsxs("p", { className: `text-sm ${t.muted} mb-4`, children: [_jsx("code", { children: "npx basicben make:model Post" }), " scaffolds one with a", _jsx("code", { children: "fillable" }), " list and ", _jsx("code", { children: "all" }), ", ", _jsx("code", { children: "find" }), ",", _jsx("code", { children: "create" }), ", ", _jsx("code", { children: "update" }), " and ", _jsx("code", { children: "destroy" }), " built on the query builder. Check the import at the top of anything you generate: it should read", _jsx("code", { children: "@basicbenframework/core/db" }), ". Older scaffolds import from", _jsx("code", { children: "'basicben'" }), ", which is not a published package and will not resolve."] }), _jsx(CodeBlock, { title: "src/models/Post.js", children: `import { getDb, query } from '@basicbenframework/core/db'
204
+
205
+ // Columns update() may write. Without this, passing req.body straight
206
+ // through would let a caller set any column at all.
207
+ const UPDATABLE = ['title', 'content', 'published']
208
+
209
+ export const Post = {
210
+ async find(id) {
211
+ const db = await getDb()
212
+ return db.get('SELECT * FROM posts WHERE id = ?', [id])
213
+ },
214
+
215
+ // A join has to be raw SQL, so this lives on the model rather than
216
+ // being reassembled at every call site.
217
+ async findPublished() {
218
+ const db = await getDb()
219
+ return db.all(\`
220
+ SELECT posts.*, users.name AS author_name
221
+ FROM posts
222
+ JOIN users ON users.id = posts.user_id
223
+ WHERE posts.published = 1
224
+ ORDER BY posts.created_at DESC
225
+ \`)
226
+ },
227
+
228
+ async create(data) {
229
+ // Through the builder so Postgres gets RETURNING id and the new
230
+ // id comes back.
231
+ const posts = await query('posts')
232
+ const result = await posts.insert({
233
+ user_id: data.user_id,
234
+ title: data.title,
235
+ content: data.content,
236
+ published: data.published ? 1 : 0
237
+ })
238
+ return { id: result.lastInsertRowid, ...data }
239
+ },
240
+
241
+ async update(id, data) {
242
+ const fields = Object.keys(data).filter(k => UPDATABLE.includes(k))
243
+ if (fields.length === 0) return this.find(id)
244
+
245
+ return (await query('posts'))
246
+ .only(...UPDATABLE)
247
+ .where('id', id)
248
+ .update(data)
249
+ }
250
+ }` }), _jsxs("p", { className: `text-sm ${t.muted} mt-4`, children: ["Controllers then call ", _jsx("code", { children: "Post.create(...)" }), " instead of assembling queries themselves, which keeps the column list in one file."] })] }), _jsxs(Card, { children: [_jsx("h2", { className: "text-lg font-semibold mb-2", children: "Validating Against the Database" }), _jsxs("p", { className: `text-sm ${t.muted} mb-4`, children: ["Two validation rules query the database. Both are async, so the", _jsx("code", { children: "validate" }), " call must be awaited like any other."] }), _jsx(CodeBlock, { title: "unique and exists", children: `import { validate, rules } from '@basicbenframework/core/validation'
251
+
252
+ const result = await validate(req.body, {
253
+ // No other row in users has this email
254
+ email: [rules.required, rules.email, rules.unique('users')],
255
+
256
+ // Check a named column instead of the field name
257
+ slug: [rules.unique('categories', 'slug')],
258
+
259
+ // The referenced row must exist
260
+ user_id: [rules.required, rules.exists('users')]
261
+ })` }), _jsx(CodeBlock, { title: "Ignoring the record being updated", children: `// Without the third argument, a user saving their profile without
262
+ // changing their email would collide with themselves.
263
+ email: [rules.required, rules.email, rules.unique('users', 'email', currentUserId)]` })] })] })] }));
264
+ }
@@ -0,0 +1 @@
1
+ export declare function Extending(): import("react").JSX.Element;
@@ -0,0 +1,28 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useTheme } from "../components/ThemeContext.js";
3
+ import { Card } from "../components/Card.js";
4
+ import { PageHeader } from "../components/PageHeader.js";
5
+ export function Extending() {
6
+ const { t } = useTheme();
7
+ const CodeBlock = ({ children, title }) => (_jsxs("div", { className: "mt-4", children: [title && _jsx("div", { className: `text-xs font-medium mb-2 ${t.muted}`, children: title }), _jsx("div", { className: `rounded-lg p-4 font-mono text-sm ${t.card} border ${t.border} overflow-x-auto`, children: _jsx("pre", { className: t.text, children: children }) })] }));
8
+ return (_jsxs("div", { children: [_jsx(PageHeader, { title: "Extending", subtitle: "Hooks \u2014 change what the framework does without forking it" }), _jsxs("div", { className: "space-y-6", children: [_jsxs(Card, { children: [_jsx("h2", { className: "text-lg font-semibold mb-2", children: "Where extensions live" }), _jsxs("p", { className: `text-sm ${t.muted} mb-4`, children: [_jsx("code", { children: "src/hooks.ts" }), ", imported once by ", _jsx("code", { children: "src/server/index.ts" }), ". Every listener is registered before the server handles its first request."] }), _jsx(CodeBlock, { title: "src/hooks.ts", children: `import { hooks, HOOKS } from '@basicbenframework/core/hooks'
9
+
10
+ hooks.on(HOOKS.POST_CREATING, async (data) => ({
11
+ ...data,
12
+ title: data.title.trim()
13
+ }))
14
+
15
+ hooks.on(HOOKS.MEDIA_UPLOADED, async ({ url }) => {
16
+ await purgeCdn(url)
17
+ })` }), _jsxs("p", { className: `text-sm ${t.muted} mt-4`, children: ["There was once a plugin system wrapping this \u2014 an object with a name, a version and an activation switch. It was removed. A plugin could not be installed at runtime on any host that rebuilds from an image, so what remained was a container around exactly these calls, and ", _jsx("code", { children: "import" }), " already does that job. Shipping an extension as an npm package still works: install it, import it, call ", _jsx("code", { children: "hooks.on" }), "."] })] }), _jsxs(Card, { children: [_jsx("h2", { className: "text-lg font-semibold mb-2", children: "Two kinds of hook" }), _jsxs("p", { className: `text-sm ${t.muted} mb-4`, children: ["The distinction is the thing to get right. A ", _jsx("strong", { children: "filter" }), " transforms a value and ", _jsx("em", { children: "must return it" }), " \u2014 returning nothing replaces the value with undefined. A", ' ', _jsx("strong", { children: "notification" }), " is told something happened and its return value is ignored."] }), _jsx(CodeBlock, { children: `// Filters — return the value, changed.
18
+ 'post.creating' // return { cancel: true, reason } to refuse the write
19
+ 'content.render' // the rendered HTML, before sanitizing
20
+ 'admin.menu' // the sidebar items
21
+
22
+ // Notifications — the return value is ignored.
23
+ 'post.created'
24
+ 'media.uploaded'
25
+ 'server.started'` }), _jsxs("p", { className: `text-sm ${t.muted} mt-4`, children: ["A listener that throws is contained: the others still run. The exception is the", ' ', _jsx("code", { children: "*.creating" }), ", ", _jsx("code", { children: "*.updating" }), " and ", _jsx("code", { children: "*.deleting" }), " filters for posts, pages, comments and media: there a throw refuses the write, the same as", ' ', _jsx("code", { children: "cancel" }), ", so a guard that crashes cannot wave a write through. Pass a name so the logged error points at the culprit \u2014 without one it says which hook threw but not which listener, which is no help on a hook with several."] }), _jsx(CodeBlock, { children: `hooks.on(HOOKS.POST_CREATED, reindex, { name: 'search-index' })
26
+
27
+ // Hook "post.created" (search-index) threw: connection refused` }), _jsxs("p", { className: `text-sm ${t.muted} mt-4`, children: [_jsx("code", { children: "priority" }), " takes a number too \u2014 lower runs first, default 10. Set", ' ', _jsx("code", { children: "BASICBEN_DEBUG_HOOKS=1" }), " for stack traces."] })] }), _jsxs(Card, { children: [_jsx("h2", { className: "text-lg font-semibold mb-2", children: "Every hook" }), _jsxs("p", { className: `text-sm ${t.muted} mb-4`, children: ["All 39, by family: ", _jsx("code", { children: "server.*" }), ", ", _jsx("code", { children: "request.*" }), ", ", _jsx("code", { children: "post.*" }), ",", ' ', _jsx("code", { children: "page.*" }), ", ", _jsx("code", { children: "comment.*" }), ",", ' ', _jsx("code", { children: "content.render/save/delete" }), ", ", _jsx("code", { children: "media.*" }), ", ", _jsx("code", { children: "auth.*" }), ",", ' ', _jsx("code", { children: "email.*" }), ", ", _jsx("code", { children: "mail.*" }), ", ", _jsx("code", { children: "admin.*" }), ". Every hook the framework declares fires \u2014 that is checked by a test that walks the constants and looks for a call site. The CMS adds three of its own, ", _jsx("code", { children: "media.creating" }), ",", ' ', _jsx("code", { children: "media.updating" }), " and ", _jsx("code", { children: "media.deleting" }), ", exported as", ' ', _jsx("code", { children: "MEDIA_HOOKS" }), " from ", _jsx("code", { children: "src/helpers/write-hooks.ts" }), "."] })] }), _jsxs(Card, { children: [_jsx("h2", { className: "text-lg font-semibold mb-2", children: "Where hooks fire matters" }), _jsxs("p", { className: `text-sm ${t.muted}`, children: ["The registry is a singleton per JavaScript realm, and the browser is a different realm from the server. ", _jsx("code", { children: "src/hooks.ts" }), " is imported by the server entry, so a hook fired in the browser would consult an empty registry. That is why", ' ', _jsx("code", { children: "admin.menu" }), " and ", _jsx("code", { children: "admin.dashboard" }), " fire on the server and reach the UI through an API \u2014 the admin asks the server what to render, because the server is where the listeners are."] })] })] })] }));
28
+ }
@@ -0,0 +1 @@
1
+ export declare function Feed(): import("react").JSX.Element;
@@ -0,0 +1,19 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState, useEffect } from 'react';
3
+ import { useNavigate } from '@basicbenframework/core/client';
4
+ import { PageHeader } from "../components/PageHeader.js";
5
+ import { PostCard } from "../components/PostCard.js";
6
+ import { Loading } from "../components/Loading.js";
7
+ import { Empty } from "../components/Empty.js";
8
+ import { api } from "../../helpers/api.js";
9
+ export function Feed() {
10
+ const navigate = useNavigate();
11
+ const [posts, setPosts] = useState([]);
12
+ const [loading, setLoading] = useState(true);
13
+ useEffect(() => {
14
+ api('/api/feed').then(data => setPosts(data.posts)).finally(() => setLoading(false));
15
+ }, []);
16
+ if (loading)
17
+ return _jsx(Loading, {});
18
+ return (_jsxs("div", { children: [_jsx(PageHeader, { title: "Feed" }), posts.length === 0 ? (_jsx(Empty, { children: "No posts yet" })) : (_jsx("div", { className: "space-y-4", children: posts.map(post => (_jsx(PostCard, { post: post, onClick: () => navigate(`/feed/${post.id}`), showAuthor: true }, post.id))) }))] }));
19
+ }
@@ -0,0 +1 @@
1
+ export declare function FeedPost(): import("react").JSX.Element | null;
@@ -0,0 +1,31 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState, useEffect } from 'react';
3
+ import { useNavigate, useParams } from '@basicbenframework/core/client';
4
+ import { useTheme } from "../components/ThemeContext.js";
5
+ import { Card } from "../components/Card.js";
6
+ import { Avatar } from "../components/Avatar.js";
7
+ import { BackLink } from "../components/BackLink.js";
8
+ import { Link } from "../components/Link.js";
9
+ import { Loading } from "../components/Loading.js";
10
+ import { CommentThread } from "../components/CommentThread.js";
11
+ import { api } from "../../helpers/api.js";
12
+ export function FeedPost() {
13
+ const navigate = useNavigate();
14
+ const params = useParams();
15
+ const postId = params.id;
16
+ const { t } = useTheme();
17
+ const [post, setPost] = useState(null);
18
+ const [loading, setLoading] = useState(true);
19
+ useEffect(() => {
20
+ api(`/api/feed/${postId}`)
21
+ .then(data => setPost(data.post))
22
+ .catch(() => navigate('/feed'))
23
+ .finally(() => setLoading(false));
24
+ }, [postId]);
25
+ if (loading)
26
+ return _jsx(Loading, {});
27
+ if (!post)
28
+ return null;
29
+ const author = post.author;
30
+ return (_jsxs("div", { children: [_jsx(BackLink, { onClick: () => navigate('/feed'), children: "Back to feed" }), _jsxs(Card, { className: "p-6", children: [post.featured_image_url && (_jsx("img", { src: post.featured_image_url, alt: "", className: "w-full max-h-96 object-cover rounded-lg mb-6" })), _jsx("h1", { className: "text-2xl font-bold mb-3", children: post.title }), _jsxs("div", { className: "flex items-center gap-2 mb-6", children: [_jsx(Avatar, { name: post.author_name || '', src: author?.avatar_url, size: "sm" }), _jsxs("p", { className: `text-sm ${t.muted}`, children: ["By ", post.author_name, " \u2022 ", new Date(post.created_at).toLocaleDateString()] })] }), _jsx("p", { className: "whitespace-pre-wrap", children: post.content })] }), author?.bio && (_jsx(Card, { className: "p-6 mt-4", children: _jsxs("div", { className: "flex gap-3", children: [_jsx(Avatar, { name: author.name, src: author.avatar_url, size: "lg" }), _jsxs("div", { children: [_jsx("p", { className: "font-medium", children: author.name }), _jsx("p", { className: `text-sm ${t.muted} mt-1`, children: author.bio }), author.website && (_jsx(Link, { href: author.website, target: "_blank", rel: "noopener noreferrer nofollow", className: "text-sm underline mt-1 inline-block", children: author.website }))] })] }) })), _jsx(CommentThread, { postId: post.id })] }));
31
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Ask for a password reset link.
3
+ *
4
+ * The server gives the same answer for every address, so this page does too:
5
+ * it shows the server's message and nothing else. Saying "check your inbox"
6
+ * only when the account exists would undo the point.
7
+ */
8
+ export declare function ForgotPassword(): import("react").JSX.Element;
@@ -0,0 +1,38 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useState } from 'react';
3
+ import { useNavigate } from '@basicbenframework/core/client';
4
+ import { useTheme } from "../components/ThemeContext.js";
5
+ import { Input } from "../components/Input.js";
6
+ import { Button } from "../components/Button.js";
7
+ import { api } from "../../helpers/api.js";
8
+ import { useToast } from "../contexts/ToastContext.js";
9
+ /**
10
+ * Ask for a password reset link.
11
+ *
12
+ * The server gives the same answer for every address, so this page does too:
13
+ * it shows the server's message and nothing else. Saying "check your inbox"
14
+ * only when the account exists would undo the point.
15
+ */
16
+ export function ForgotPassword() {
17
+ const navigate = useNavigate();
18
+ const { t } = useTheme();
19
+ const toast = useToast();
20
+ const [email, setEmail] = useState('');
21
+ const [loading, setLoading] = useState(false);
22
+ const [sent, setSent] = useState(null);
23
+ const handleSubmit = async (e) => {
24
+ e.preventDefault();
25
+ setLoading(true);
26
+ try {
27
+ const data = await api.post('/api/auth/forgot-password', { email });
28
+ setSent(data.message);
29
+ }
30
+ catch (err) {
31
+ toast.error(err.message);
32
+ }
33
+ finally {
34
+ setLoading(false);
35
+ }
36
+ };
37
+ return (_jsxs("div", { className: "max-w-xs mx-auto py-8", children: [_jsx("h1", { className: "text-2xl font-bold text-center mb-1", children: "Reset your password" }), sent ? (_jsx("p", { className: `text-sm ${t.muted} text-center mb-6`, children: sent })) : (_jsxs(_Fragment, { children: [_jsx("p", { className: `text-sm ${t.muted} text-center mb-6`, children: "We'll email you a link to choose a new one" }), _jsxs("form", { onSubmit: handleSubmit, className: "space-y-3 mt-4", children: [_jsx(Input, { type: "email", placeholder: "Email", required: true, value: email, onChange: (e) => setEmail(e.target.value) }), _jsx(Button, { type: "submit", disabled: loading, className: "w-full", children: loading ? '...' : 'Send reset link' })] })] })), _jsx("p", { className: `text-xs ${t.muted} text-center mt-4`, children: _jsx("button", { onClick: () => navigate('/login'), className: "underline hover:no-underline", children: "Back to sign in" }) })] }));
38
+ }
@@ -0,0 +1 @@
1
+ export declare function GettingStarted(): import("react").JSX.Element;
@@ -0,0 +1,84 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useTheme } from "../components/ThemeContext.js";
3
+ import { Card } from "../components/Card.js";
4
+ import { PageHeader } from "../components/PageHeader.js";
5
+ export function GettingStarted() {
6
+ const { t } = useTheme();
7
+ const devCommands = [
8
+ { cmd: 'npm run dev', desc: 'Start Vite and the API server with hot reload' },
9
+ { cmd: 'npm run build', desc: 'Build client and server for production' },
10
+ { cmd: 'npm run build -- --static', desc: 'Build the client only, for static hosts' },
11
+ { cmd: 'npm run start', desc: 'Run the production server' },
12
+ { cmd: 'npm run test', desc: 'Run tests with Vitest' },
13
+ ];
14
+ const makeCommands = [
15
+ { cmd: 'npm run make:controller Post', desc: 'Generate a controller' },
16
+ { cmd: 'npm run make:model Post', desc: 'Generate a model' },
17
+ { cmd: 'npm run make:migration create_posts', desc: 'Generate a migration' },
18
+ { cmd: 'npx basicben make:route post', desc: 'Generate a route file' },
19
+ { cmd: 'npx basicben make:middleware auth', desc: 'Generate middleware' },
20
+ { cmd: 'npx basicben make:seed posts', desc: 'Generate a seeder' },
21
+ ];
22
+ const dbCommands = [
23
+ { cmd: 'npm run migrate', desc: 'Run pending migrations' },
24
+ { cmd: 'npm run migrate:rollback', desc: 'Roll back the last batch' },
25
+ { cmd: 'npm run migrate:fresh', desc: 'Drop everything and re-run' },
26
+ { cmd: 'npm run migrate:status', desc: 'Show migration status' },
27
+ { cmd: 'npx basicben seed', desc: 'Run database seeders' },
28
+ ];
29
+ return (_jsxs("div", { children: [_jsx(PageHeader, { title: "Getting Started", subtitle: "Create a project, learn the layout, and run the CLI" }), _jsxs("div", { className: "space-y-6", children: [_jsxs(Card, { children: [_jsx("h2", { className: "text-lg font-semibold mb-4", children: "Quick Start" }), _jsxs("div", { className: `rounded-lg p-4 font-mono text-sm ${t.card} border ${t.border} overflow-x-auto`, children: [_jsx("div", { className: t.muted, children: "# Create a new project" }), _jsx("div", { children: "npx @basicbenframework/create my-app" }), _jsx("div", { className: "mt-2" }), _jsx("div", { className: t.muted, children: "# Navigate to the project" }), _jsx("div", { children: "cd my-app" }), _jsx("div", { className: "mt-2" }), _jsx("div", { className: t.muted, children: "# Install dependencies" }), _jsx("div", { children: "npm install" }), _jsx("div", { className: "mt-2" }), _jsx("div", { className: t.muted, children: "# Create the database" }), _jsx("div", { children: "npm run migrate" }), _jsx("div", { className: "mt-2" }), _jsx("div", { className: t.muted, children: "# Start the development server" }), _jsx("div", { children: "npm run dev" })] }), _jsxs("p", { className: `text-sm ${t.muted} mt-4`, children: ["What you get is the CMS: posts, pages, categories, tags, media, comments, an admin panel and a headless content API at ", _jsx("code", { children: "/api/v1" }), ". Not a blank application \u2014 a working one you delete the parts of that you do not want. The first account you register becomes the admin."] }), _jsx("p", { className: `text-sm ${t.muted} mt-4`, children: "Apps are TypeScript. Nothing forces you to annotate anything \u2014 Vite compiles the app either way \u2014 but the types are there when you want them, and the admin panel is written against them. BasicBen requires Node 24 or later." }), _jsxs("p", { className: `text-sm ${t.muted} mt-4`, children: ["The command downloads the CMS repository rather than unpacking a copy bundled inside the package, so it is never a stale snapshot. What it gives you is ", _jsx("em", { children: "yours" }), ", with no link back \u2014 which is usually what you want, and means framework fixes reach you through ", _jsx("code", { children: "@basicbenframework/core" }), " but CMS changes do not. If you would rather track the CMS and merge its fixes, fork it instead of scaffolding:", ' ', _jsx("code", { children: "git clone https://github.com/BasicBenFramework/basicben.git my-app" }), "."] })] }), _jsxs(Card, { children: [_jsx("h2", { className: "text-lg font-semibold mb-4", children: "Project Structure" }), _jsx("div", { className: `rounded-lg p-4 font-mono text-sm ${t.card} border ${t.border} overflow-x-auto`, children: _jsx("pre", { className: t.text, children: `my-app/
30
+ ├── src/
31
+ │ ├── client/ # React frontend
32
+ │ │ ├── components/ # Reusable components
33
+ │ │ ├── contexts/ # React context providers
34
+ │ │ ├── layouts/ # Page layouts
35
+ │ │ └── pages/ # Page components, including admin/
36
+ │ ├── routes/
37
+ │ │ ├── App.tsx # Client routes
38
+ │ │ └── api/ # API route files
39
+ │ ├── controllers/ # Request handlers
40
+ │ ├── models/ # Database models
41
+ │ ├── middleware/ # Request middleware
42
+ │ ├── helpers/ # Shared utilities
43
+ │ ├── types/ # Shared type definitions
44
+ │ ├── server/ # Server entry point
45
+ │ └── main.tsx # Client entry point
46
+ ├── db/
47
+ │ ├── migrations/ # Database migrations
48
+ │ └── seeds/ # Database seeders
49
+ ├── mail/ # Email templates
50
+ ├── public/ # Static assets
51
+ ├── index.html # HTML shell
52
+ ├── tsconfig.json # TypeScript config
53
+ ├── vite.config.ts # Vite config
54
+ └── basicben.config.js # Framework config` }) }), _jsxs("p", { className: `text-sm ${t.muted} mt-4`, children: ["Both halves of the app live under ", _jsx("code", { children: "src/routes/" }), ". ", _jsx("code", { children: "App.tsx" }), " defines the routes the browser renders, and everything in ", _jsx("code", { children: "api/" }), " defines the routes the server answers. Files in ", _jsx("code", { children: "api/" }), " are loaded automatically at startup, so a new file becomes live routes without being registered anywhere."] })] }), _jsxs(Card, { children: [_jsx("h2", { className: "text-lg font-semibold mb-4", children: "CLI Commands" }), _jsxs("p", { className: `text-sm ${t.muted} mb-4`, children: ["A new project ships with npm scripts for the commands you run most. Everything else is available through ", _jsx("code", { children: "npx basicben" }), ", and ", _jsx("code", { children: "npx basicben help" }), " lists the full set."] }), _jsx("h3", { className: `text-sm font-medium mb-2 ${t.muted}`, children: "Development" }), _jsx("div", { className: "grid gap-2 sm:grid-cols-2 mb-4", children: devCommands.map(({ cmd, desc }) => (_jsxs("div", { className: `rounded-lg p-3 ${t.card} border ${t.border}`, children: [_jsx("code", { className: "text-sm font-semibold", children: cmd }), _jsx("p", { className: `text-xs mt-1 ${t.muted}`, children: desc })] }, cmd))) }), _jsx("h3", { className: `text-sm font-medium mb-2 ${t.muted}`, children: "Scaffolding" }), _jsx("div", { className: "grid gap-2 sm:grid-cols-2 mb-4", children: makeCommands.map(({ cmd, desc }) => (_jsxs("div", { className: `rounded-lg p-3 ${t.card} border ${t.border}`, children: [_jsx("code", { className: "text-sm font-semibold", children: cmd }), _jsx("p", { className: `text-xs mt-1 ${t.muted}`, children: desc })] }, cmd))) }), _jsx("h3", { className: `text-sm font-medium mb-2 ${t.muted}`, children: "Database" }), _jsx("div", { className: "grid gap-2 sm:grid-cols-2", children: dbCommands.map(({ cmd, desc }) => (_jsxs("div", { className: `rounded-lg p-3 ${t.card} border ${t.border}`, children: [_jsx("code", { className: "text-sm font-semibold", children: cmd }), _jsx("p", { className: `text-xs mt-1 ${t.muted}`, children: desc })] }, cmd))) }), _jsxs("p", { className: `text-sm ${t.muted} mt-4`, children: ["The generators write TypeScript and refuse to overwrite a file that already exists. Migrations and seeders are ", _jsx("code", { children: ".ts" }), " too \u2014 Node strips the types, so they run with no build step."] })] }), _jsxs(Card, { children: [_jsx("h2", { className: "text-lg font-semibold mb-4", children: "Imports" }), _jsxs("p", { className: `text-sm ${t.muted} mb-4`, children: ["The framework is published as ", _jsx("code", { children: "@basicbenframework/core" }), ". It is organised into subpaths so the client bundle never pulls in server code."] }), _jsx("div", { className: `rounded-lg p-4 font-mono text-sm ${t.card} border ${t.border} overflow-x-auto`, children: _jsx("pre", { className: t.text, children: `import { createServer } from '@basicbenframework/core/server'
55
+ import { createClientApp } from '@basicbenframework/core/client'
56
+ import { db, query } from '@basicbenframework/core/db'
57
+ import { validate, rules } from '@basicbenframework/core/validation'
58
+ import { signJwt, verifyJwt } from '@basicbenframework/core/auth'
59
+ import { can, ROLES } from '@basicbenframework/core/auth/permissions'
60
+ import { hooks, HOOKS } from '@basicbenframework/core/hooks'
61
+ import { createApiToken } from '@basicbenframework/core/auth/api-tokens'` }) })] }), _jsxs(Card, { children: [_jsx("h2", { className: "text-lg font-semibold mb-4", children: "Configuration" }), _jsxs("p", { className: `text-sm ${t.muted} mb-4`, children: [_jsx("code", { children: "basicben.config.js" }), " is read at startup. Every key is optional and falls back to a default, so you only set what you want to change."] }), _jsx("div", { className: `rounded-lg p-4 font-mono text-sm ${t.card} border ${t.border} overflow-x-auto`, children: _jsx("pre", { className: t.text, children: `export default {
62
+ port: 3001,
63
+
64
+ cors: {
65
+ origin: '*',
66
+ methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH'],
67
+ credentials: true
68
+ },
69
+
70
+ bodyParser: {
71
+ limit: '1mb'
72
+ },
73
+
74
+ static: {
75
+ dir: 'public',
76
+ spa: true // serve index.html for unmatched client routes
77
+ },
78
+
79
+ db: {
80
+ driver: 'sqlite',
81
+ url: process.env.DATABASE_URL || './data.db'
82
+ }
83
+ }` }) }), _jsxs("p", { className: `text-sm ${t.muted} mt-4`, children: ["Set ", _jsx("code", { children: "spa: true" }), " before deploying. Without it the production server returns 404 for any client route that is not a real file, which breaks deep links and page refreshes."] }), _jsxs("p", { className: `text-sm ${t.muted} mt-4`, children: ["The same keys can be passed straight to ", _jsx("code", { children: "createServer" }), ", which is what the generated ", _jsx("code", { children: "src/server/index.ts" }), " does; an argument there wins over the file."] })] }), _jsxs(Card, { children: [_jsx("h2", { className: "text-lg font-semibold mb-4", children: "Resources" }), _jsxs("div", { className: "flex flex-wrap gap-3", children: [_jsxs("a", { href: "https://github.com/BasicBenFramework/core", target: "_blank", rel: "noopener noreferrer", className: `inline-flex items-center gap-2 px-4 py-2 rounded-lg ${t.btnSecondary} transition text-sm`, children: [_jsx("svg", { className: "w-4 h-4", fill: "currentColor", viewBox: "0 0 24 24", children: _jsx("path", { d: "M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z" }) }), "GitHub"] }), _jsxs("a", { href: "https://basicben.com", target: "_blank", rel: "noopener noreferrer", className: `inline-flex items-center gap-2 px-4 py-2 rounded-lg ${t.btnSecondary} transition text-sm`, children: [_jsx("svg", { className: "w-4 h-4", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253" }) }), "Documentation"] })] })] })] })] }));
84
+ }
@@ -0,0 +1 @@
1
+ export declare function Headless(): import("react").JSX.Element;