studiocms 0.1.0-beta.25 → 0.1.0-beta.26

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 (397) hide show
  1. package/CHANGELOG.md +91 -0
  2. package/dist/cli/users/steps/libsqlCreateUsers.js +1 -3
  3. package/dist/cli/users/steps/libsqlModifyUsers.js +1 -3
  4. package/dist/components/auth/OAuthButton.astro +1 -1
  5. package/dist/components/auth/OAuthButtonStack.astro +1 -1
  6. package/dist/components/auth/component-scripts/formListener.js +1 -1
  7. package/dist/components/dashboard/BaseHead.astro +6 -17
  8. package/dist/components/dashboard/DashboardGrid.astro +2 -2
  9. package/dist/components/dashboard/DashboardGridItem.astro +2 -1
  10. package/dist/components/dashboard/DashboardPageHeader.astro +8 -4
  11. package/dist/components/dashboard/DoubleSidebar.astro +2 -2
  12. package/dist/components/dashboard/LoginChecker.astro +3 -2
  13. package/dist/components/dashboard/MainSidebarContent.astro +16 -12
  14. package/dist/components/dashboard/PageHeader.astro +3 -2
  15. package/dist/components/dashboard/SidebarLink.astro +5 -5
  16. package/dist/components/dashboard/SidebarPluginLink.astro +3 -3
  17. package/dist/components/dashboard/SingleSidebar.astro +2 -2
  18. package/dist/components/dashboard/configuration/ConfigForm.astro +49 -47
  19. package/dist/components/dashboard/configuration/LoginPreview.astro +6 -4
  20. package/dist/components/dashboard/content-mgmt/CreateFolder.astro +3 -2
  21. package/dist/components/dashboard/content-mgmt/CreatePage.astro +8 -5
  22. package/dist/components/dashboard/content-mgmt/EditFolder.astro +3 -2
  23. package/dist/components/dashboard/content-mgmt/EditPage.astro +25 -13
  24. package/dist/components/dashboard/content-mgmt/InnerSidebarElement.astro +23 -15
  25. package/dist/components/dashboard/content-mgmt/PageHeader.astro +23 -14
  26. package/dist/components/dashboard/content-mgmt/PluginFields.astro +6 -1
  27. package/dist/components/dashboard/content-mgmt/TreeRenderer.astro +6 -6
  28. package/dist/components/dashboard/content-mgmt/TreeSidebarFolder.astro +4 -4
  29. package/dist/components/dashboard/content-mgmt/TreeSidebarLink.astro +4 -4
  30. package/dist/components/dashboard/plugins/SettingsRenderer.astro +6 -1
  31. package/dist/components/dashboard/profile/APITokens.astro +14 -8
  32. package/dist/components/dashboard/profile/BasicInfo.astro +8 -4
  33. package/dist/components/dashboard/profile/Notifications.astro +7 -4
  34. package/dist/components/dashboard/profile/SocialSignin.astro +8 -5
  35. package/dist/components/dashboard/profile/UpdatePassword.astro +6 -3
  36. package/dist/components/dashboard/sidebar/UserAccount.astro +1 -2
  37. package/dist/components/dashboard/sidebar/VersionCheck.astro +7 -7
  38. package/dist/components/dashboard/sidebar/VersionCheckChangelog.astro +28 -6
  39. package/dist/components/dashboard/sidebar-modals/UserManagementModals.astro +8 -3
  40. package/dist/components/dashboard/sidebar-modals/VersionModal.astro +16 -15
  41. package/dist/components/dashboard/sidebarConfig.d.ts +2 -2
  42. package/dist/components/dashboard/sidebarConfig.js +6 -6
  43. package/dist/components/dashboard/user-mgmt/InnerSidebarElement.astro +16 -9
  44. package/dist/components/dashboard/user-mgmt/RankCheck.astro +6 -8
  45. package/dist/components/dashboard/user-mgmt/SocialSignin.astro +9 -10
  46. package/dist/components/dashboard/user-mgmt/UserListItem.astro +8 -6
  47. package/dist/components/default-grid-items/Recently-created-pages.astro +11 -9
  48. package/dist/components/default-grid-items/Recently-signed-up.astro +8 -8
  49. package/dist/components/default-grid-items/Recently-updated-pages.astro +11 -9
  50. package/dist/components/default-grid-items/Totals.astro +7 -6
  51. package/dist/components/first-time-setup/PageHeader.astro +4 -3
  52. package/dist/components/shared/SSRUser.astro +200 -0
  53. package/dist/components/shared/head/Favicons.astro +6 -0
  54. package/dist/components/shared/head/Global.astro +4 -0
  55. package/dist/components/shared/head/TitleTags.astro +14 -0
  56. package/dist/config.d.ts +1 -4
  57. package/dist/consts.d.ts +34 -1
  58. package/dist/consts.js +42 -1
  59. package/dist/db/config.d.ts +22 -37
  60. package/dist/db/config.js +14 -2
  61. package/dist/handlers/astroConfigCheck.js +1 -1
  62. package/dist/handlers/changelog.d.ts +1 -0
  63. package/dist/handlers/changelog.js +54 -0
  64. package/dist/handlers/index.d.ts +1 -2
  65. package/dist/handlers/index.js +2 -4
  66. package/dist/handlers/pluginHandler.d.ts +2 -1
  67. package/dist/handlers/pluginHandler.js +14 -8
  68. package/dist/index.d.ts +1 -0
  69. package/dist/index.js +115 -107
  70. package/dist/integrations/dynamic-sitemap/index.js +1 -1
  71. package/dist/integrations/webVitals/checkForWebVitalsPlugin.js +3 -3
  72. package/dist/integrations/webVitals/dashboard-grid-items/CoreVitals.astro +1 -1
  73. package/dist/integrations/webVitals/dashboard-grid-items/MetricCard.astro +3 -2
  74. package/dist/integrations/webVitals/dashboard-grid-items/SummaryCard.astro +2 -2
  75. package/dist/integrations/webVitals/dashboard-grid-items/metric.css +17 -17
  76. package/dist/integrations/webVitals/dashboard-grid-items/shared.d.ts +4 -4
  77. package/dist/integrations/webVitals/dashboard-grid-items/shared.js +3 -3
  78. package/dist/integrations/webVitals/pages/analytics/body.astro +10 -9
  79. package/dist/integrations/webVitals/utils/webVitalsUtils.d.ts +9 -9
  80. package/dist/layouts/AuthLayout.astro +7 -18
  81. package/dist/layouts/DashboardLayout.astro +3 -2
  82. package/dist/layouts/FirstTimeSetupLayout.astro +7 -18
  83. package/dist/middleware/index.js +3 -13
  84. package/dist/middleware/utils.d.ts +1 -1
  85. package/dist/middleware/utils.js +8 -5
  86. package/dist/routes/api/auth/login.js +1 -6
  87. package/dist/routes/api/auth/logout.js +3 -2
  88. package/dist/routes/api/auth/register.js +1 -7
  89. package/dist/routes/api/dashboard/content/page.js +5 -5
  90. package/dist/routes/api/dashboard/create-user-invite.js +1 -1
  91. package/dist/routes/api/dashboard/create-user.d.ts +0 -7
  92. package/dist/routes/api/dashboard/create-user.js +18 -23
  93. package/dist/routes/api/dashboard/email-notification-settings-site.js +10 -0
  94. package/dist/routes/api/dashboard/profile.js +1 -1
  95. package/dist/routes/api/dashboard/reset-password.js +1 -1
  96. package/dist/routes/api/dashboard/users.js +27 -10
  97. package/dist/routes/api/dashboard/verify-email.js +5 -2
  98. package/dist/routes/api/dashboard/verify-session.js +3 -2
  99. package/dist/routes/api/rest/utils/auth-token.d.ts +1 -1
  100. package/dist/routes/api/rest/v1/pages/[id]/index.js +3 -10
  101. package/dist/routes/api/rest/v1/users/[id].js +24 -23
  102. package/dist/routes/api/rest/v1/users/index.js +1 -1
  103. package/dist/routes/api/sdk/utils/changelog.d.ts +0 -15
  104. package/dist/routes/api/sdk/utils/changelog.js +9 -112
  105. package/dist/routes/auth/login.astro +16 -9
  106. package/dist/routes/auth/signup.astro +2 -1
  107. package/dist/routes/dashboard/configuration.astro +3 -2
  108. package/dist/routes/dashboard/content-management/createfolder.astro +1 -1
  109. package/dist/routes/dashboard/content-management/createpage.astro +1 -1
  110. package/dist/routes/dashboard/content-management/diff.astro +8 -5
  111. package/dist/routes/dashboard/content-management/index.astro +1 -1
  112. package/dist/routes/dashboard/password-reset.astro +8 -5
  113. package/dist/routes/dashboard/plugins/[plugin].astro +4 -3
  114. package/dist/routes/dashboard/smtp-configuration.astro +21 -10
  115. package/dist/routes/dashboard/unverified-email.astro +2 -4
  116. package/dist/routes/dashboard/user-management/edit.astro +30 -22
  117. package/dist/routes/dashboard/user-management/index.astro +2 -2
  118. package/dist/routes/error-pages/404.astro +1 -1
  119. package/dist/routes/firstTimeSetupRoutes/1-start.astro +15 -14
  120. package/dist/routes/firstTimeSetupRoutes/2-next.astro +14 -11
  121. package/dist/routes/firstTimeSetupRoutes/3-done.astro +3 -2
  122. package/dist/routes/firstTimeSetupRoutes/api/step-2.js +1 -1
  123. package/dist/schemas/plugins/index.d.ts +64 -64
  124. package/dist/schemas/plugins/shared.d.ts +84 -84
  125. package/dist/schemas/plugins/shared.js +10 -16
  126. package/dist/styles/404.css +1 -1
  127. package/dist/styles/code-component.css +8 -8
  128. package/dist/styles/dashboard-base.css +29 -29
  129. package/dist/styles/dashboard-diff.css +31 -31
  130. package/dist/types.d.ts +2 -22
  131. package/dist/utils/effects/smtp.d.ts +2 -3
  132. package/dist/utils/effects/smtp.js +5 -1
  133. package/dist/utils/safeString.d.ts +1 -1
  134. package/dist/utils/safeString.js +1 -3
  135. package/dist/utils/stripIconify.d.ts +13 -0
  136. package/dist/utils/stripIconify.js +11 -0
  137. package/dist/utils/tinyMDParser.js +5 -5
  138. package/dist/virtual.d.ts +17 -60
  139. package/dist/virtuals/auth/core.d.ts +91 -0
  140. package/dist/virtuals/auth/core.js +45 -0
  141. package/dist/virtuals/auth/index.d.ts +1 -4
  142. package/dist/virtuals/auth/index.js +1 -4
  143. package/dist/virtuals/auth/verify-email.d.ts +3 -3
  144. package/dist/virtuals/i18n/LanguageSelector.astro +1 -1
  145. package/dist/virtuals/i18n/client.d.ts +100 -4
  146. package/dist/virtuals/i18n/client.js +11 -10
  147. package/dist/virtuals/i18n/config.d.ts +417 -3
  148. package/dist/virtuals/i18n/config.js +22 -1
  149. package/dist/virtuals/i18n/server.d.ts +116 -0
  150. package/dist/virtuals/i18n/{index.js → server.js} +6 -19
  151. package/dist/virtuals/i18n/v-files.d.ts +30 -0
  152. package/dist/virtuals/i18n/v-files.js +46 -0
  153. package/dist/virtuals/lib/head.d.ts +1 -25
  154. package/dist/virtuals/lib/head.js +1 -73
  155. package/dist/virtuals/lib/headDefaults.d.ts +2 -2
  156. package/dist/virtuals/lib/pathGenerators.d.ts +1 -20
  157. package/dist/virtuals/lib/pathGenerators.js +1 -66
  158. package/dist/virtuals/lib/urlGen.d.ts +2 -1
  159. package/dist/virtuals/lib/urlGen.js +4 -24
  160. package/dist/virtuals/mailer/index.d.ts +4 -34
  161. package/dist/virtuals/mailer/index.js +3 -16
  162. package/dist/virtuals/plugins/dashboard-pages.d.ts +8 -8
  163. package/dist/virtuals/scripts/user-quick-tools.d.ts +3 -2
  164. package/dist/virtuals/scripts/user-quick-tools.js +135 -53
  165. package/dist/virtuals/sdk/effect/collectors.d.ts +1 -1
  166. package/dist/virtuals/sdk/effect/foldertree.d.ts +1 -1
  167. package/dist/virtuals/sdk/effect/parsers.js +1 -1
  168. package/dist/virtuals/sdk/index.d.ts +2 -1
  169. package/dist/virtuals/sdk/modules/auth.d.ts +6 -5
  170. package/dist/virtuals/sdk/modules/config.d.ts +272 -0
  171. package/dist/virtuals/sdk/modules/config.js +205 -0
  172. package/dist/virtuals/sdk/modules/get.d.ts +10 -23
  173. package/dist/virtuals/sdk/modules/get.js +27 -40
  174. package/dist/virtuals/sdk/modules/init.d.ts +4 -18
  175. package/dist/virtuals/sdk/modules/init.js +7 -8
  176. package/dist/virtuals/sdk/modules/notificationSettings.d.ts +5 -22
  177. package/dist/virtuals/sdk/modules/notificationSettings.js +7 -29
  178. package/dist/virtuals/sdk/modules/post.d.ts +5 -5
  179. package/dist/virtuals/sdk/modules/post.js +14 -9
  180. package/dist/virtuals/sdk/modules/rest_api.d.ts +3 -3
  181. package/dist/virtuals/sdk/modules/update.d.ts +19 -19
  182. package/dist/virtuals/sdk/modules/update.js +28 -25
  183. package/dist/virtuals/sdk/sdkCore.d.ts +5 -3
  184. package/dist/virtuals/sdk/sdkCore.js +9 -4
  185. package/dist/virtuals/sdk/types/index.d.ts +4 -3
  186. package/dist/virtuals/sdk/types/tableDefs.d.ts +5 -4
  187. package/dist/virtuals/sdk/types/tsAlias.d.ts +4 -0
  188. package/dist/virtuals/sdk/utils.d.ts +3 -2
  189. package/dist/virtuals/utils.d.ts +21 -17
  190. package/dist/virtuals/utils.js +10 -6
  191. package/package.json +15 -20
  192. package/src/cli/users/steps/libsqlCreateUsers.ts +2 -4
  193. package/src/cli/users/steps/libsqlModifyUsers.ts +2 -4
  194. package/src/components/auth/OAuthButton.astro +1 -1
  195. package/src/components/auth/OAuthButtonStack.astro +1 -1
  196. package/src/components/auth/component-scripts/formListener.ts +1 -1
  197. package/src/components/dashboard/BaseHead.astro +6 -17
  198. package/src/components/dashboard/DashboardGrid.astro +2 -2
  199. package/src/components/dashboard/DashboardGridItem.astro +2 -1
  200. package/src/components/dashboard/DashboardPageHeader.astro +8 -4
  201. package/src/components/dashboard/DoubleSidebar.astro +2 -2
  202. package/src/components/dashboard/LoginChecker.astro +3 -2
  203. package/src/components/dashboard/MainSidebarContent.astro +16 -12
  204. package/src/components/dashboard/PageHeader.astro +3 -2
  205. package/src/components/dashboard/SidebarLink.astro +5 -5
  206. package/src/components/dashboard/SidebarPluginLink.astro +3 -3
  207. package/src/components/dashboard/SingleSidebar.astro +2 -2
  208. package/src/components/dashboard/configuration/ConfigForm.astro +49 -47
  209. package/src/components/dashboard/configuration/LoginPreview.astro +6 -4
  210. package/src/components/dashboard/content-mgmt/CreateFolder.astro +3 -2
  211. package/src/components/dashboard/content-mgmt/CreatePage.astro +8 -5
  212. package/src/components/dashboard/content-mgmt/EditFolder.astro +3 -2
  213. package/src/components/dashboard/content-mgmt/EditPage.astro +25 -13
  214. package/src/components/dashboard/content-mgmt/InnerSidebarElement.astro +23 -15
  215. package/src/components/dashboard/content-mgmt/PageHeader.astro +23 -14
  216. package/src/components/dashboard/content-mgmt/PluginFields.astro +6 -1
  217. package/src/components/dashboard/content-mgmt/TreeRenderer.astro +6 -6
  218. package/src/components/dashboard/content-mgmt/TreeSidebarFolder.astro +4 -4
  219. package/src/components/dashboard/content-mgmt/TreeSidebarLink.astro +4 -4
  220. package/src/components/dashboard/plugins/SettingsRenderer.astro +6 -1
  221. package/src/components/dashboard/profile/APITokens.astro +14 -8
  222. package/src/components/dashboard/profile/BasicInfo.astro +8 -4
  223. package/src/components/dashboard/profile/Notifications.astro +7 -4
  224. package/src/components/dashboard/profile/SocialSignin.astro +8 -5
  225. package/src/components/dashboard/profile/UpdatePassword.astro +6 -3
  226. package/src/components/dashboard/sidebar/UserAccount.astro +1 -2
  227. package/src/components/dashboard/sidebar/VersionCheck.astro +7 -7
  228. package/src/components/dashboard/sidebar/VersionCheckChangelog.astro +28 -6
  229. package/src/components/dashboard/sidebar-modals/UserManagementModals.astro +8 -3
  230. package/src/components/dashboard/sidebar-modals/VersionModal.astro +16 -15
  231. package/src/components/dashboard/sidebarConfig.ts +8 -8
  232. package/src/components/dashboard/user-mgmt/InnerSidebarElement.astro +16 -9
  233. package/src/components/dashboard/user-mgmt/RankCheck.astro +6 -8
  234. package/src/components/dashboard/user-mgmt/SocialSignin.astro +9 -10
  235. package/src/components/dashboard/user-mgmt/UserListItem.astro +8 -6
  236. package/src/components/default-grid-items/Recently-created-pages.astro +11 -9
  237. package/src/components/default-grid-items/Recently-signed-up.astro +8 -8
  238. package/src/components/default-grid-items/Recently-updated-pages.astro +11 -9
  239. package/src/components/default-grid-items/Totals.astro +7 -6
  240. package/src/components/first-time-setup/PageHeader.astro +4 -3
  241. package/src/components/shared/SSRUser.astro +200 -0
  242. package/src/components/shared/head/Favicons.astro +6 -0
  243. package/src/components/shared/head/Global.astro +4 -0
  244. package/src/components/shared/head/TitleTags.astro +14 -0
  245. package/src/config.ts +1 -4
  246. package/src/consts.ts +67 -1
  247. package/src/db/config.ts +43 -2
  248. package/src/handlers/astroConfigCheck.ts +1 -1
  249. package/src/handlers/changelog.ts +67 -0
  250. package/src/handlers/index.ts +1 -2
  251. package/src/handlers/pluginHandler.ts +16 -9
  252. package/src/index.ts +142 -121
  253. package/src/integrations/dynamic-sitemap/index.ts +1 -1
  254. package/src/integrations/webVitals/checkForWebVitalsPlugin.ts +3 -3
  255. package/src/integrations/webVitals/dashboard-grid-items/CoreVitals.astro +1 -1
  256. package/src/integrations/webVitals/dashboard-grid-items/MetricCard.astro +3 -2
  257. package/src/integrations/webVitals/dashboard-grid-items/SummaryCard.astro +2 -2
  258. package/src/integrations/webVitals/dashboard-grid-items/metric.css +17 -17
  259. package/src/integrations/webVitals/dashboard-grid-items/shared.ts +7 -7
  260. package/src/integrations/webVitals/pages/analytics/body.astro +10 -9
  261. package/src/layouts/AuthLayout.astro +7 -18
  262. package/src/layouts/DashboardLayout.astro +3 -2
  263. package/src/layouts/FirstTimeSetupLayout.astro +7 -18
  264. package/src/middleware/index.ts +3 -19
  265. package/src/middleware/utils.ts +7 -4
  266. package/src/routes/api/auth/login.ts +1 -6
  267. package/src/routes/api/auth/logout.ts +3 -2
  268. package/src/routes/api/auth/register.ts +1 -7
  269. package/src/routes/api/dashboard/config.ts +3 -2
  270. package/src/routes/api/dashboard/content/page.ts +6 -6
  271. package/src/routes/api/dashboard/create-user-invite.ts +3 -2
  272. package/src/routes/api/dashboard/create-user.ts +21 -23
  273. package/src/routes/api/dashboard/email-notification-settings-site.ts +27 -2
  274. package/src/routes/api/dashboard/profile.ts +1 -1
  275. package/src/routes/api/dashboard/reset-password.ts +1 -1
  276. package/src/routes/api/dashboard/users.ts +33 -15
  277. package/src/routes/api/dashboard/verify-email.ts +5 -2
  278. package/src/routes/api/dashboard/verify-session.ts +3 -2
  279. package/src/routes/api/rest/v1/pages/[id]/index.ts +3 -13
  280. package/src/routes/api/rest/v1/users/[id].ts +24 -23
  281. package/src/routes/api/rest/v1/users/index.ts +1 -1
  282. package/src/routes/api/sdk/utils/changelog.ts +2 -143
  283. package/src/routes/auth/login.astro +16 -9
  284. package/src/routes/auth/signup.astro +2 -1
  285. package/src/routes/dashboard/configuration.astro +3 -2
  286. package/src/routes/dashboard/content-management/createfolder.astro +1 -1
  287. package/src/routes/dashboard/content-management/createpage.astro +1 -1
  288. package/src/routes/dashboard/content-management/diff.astro +8 -5
  289. package/src/routes/dashboard/content-management/index.astro +1 -1
  290. package/src/routes/dashboard/password-reset.astro +8 -5
  291. package/src/routes/dashboard/plugins/[plugin].astro +4 -3
  292. package/src/routes/dashboard/smtp-configuration.astro +21 -10
  293. package/src/routes/dashboard/unverified-email.astro +2 -4
  294. package/src/routes/dashboard/user-management/edit.astro +30 -22
  295. package/src/routes/dashboard/user-management/index.astro +2 -2
  296. package/src/routes/error-pages/404.astro +1 -1
  297. package/src/routes/firstTimeSetupRoutes/1-start.astro +15 -14
  298. package/src/routes/firstTimeSetupRoutes/2-next.astro +14 -11
  299. package/src/routes/firstTimeSetupRoutes/3-done.astro +3 -2
  300. package/src/routes/firstTimeSetupRoutes/api/step-2.ts +1 -1
  301. package/src/schemas/plugins/shared.ts +13 -25
  302. package/src/styles/404.css +1 -1
  303. package/src/styles/code-component.css +8 -8
  304. package/src/styles/dashboard-base.css +29 -29
  305. package/src/styles/dashboard-diff.css +31 -31
  306. package/src/types.ts +3 -20
  307. package/src/utils/effects/smtp.ts +8 -4
  308. package/src/utils/safeString.ts +1 -6
  309. package/src/utils/stripIconify.ts +20 -0
  310. package/src/utils/tinyMDParser.ts +7 -7
  311. package/src/virtual.d.ts +17 -60
  312. package/src/virtuals/auth/core.ts +82 -0
  313. package/src/virtuals/auth/index.ts +1 -4
  314. package/src/virtuals/i18n/LanguageSelector.astro +1 -1
  315. package/src/virtuals/i18n/client.ts +115 -11
  316. package/src/virtuals/i18n/config.ts +154 -3
  317. package/src/virtuals/i18n/{index.ts → server.ts} +42 -46
  318. package/src/virtuals/i18n/v-files.ts +122 -0
  319. package/src/virtuals/lib/head.ts +1 -114
  320. package/src/virtuals/lib/pathGenerators.ts +1 -72
  321. package/src/virtuals/lib/urlGen.ts +4 -29
  322. package/src/virtuals/mailer/index.ts +7 -34
  323. package/src/virtuals/scripts/user-quick-tools.ts +151 -59
  324. package/src/virtuals/sdk/effect/parsers.ts +1 -1
  325. package/src/virtuals/sdk/modules/auth.ts +2 -1
  326. package/src/virtuals/sdk/modules/config.ts +602 -0
  327. package/src/virtuals/sdk/modules/get.ts +32 -48
  328. package/src/virtuals/sdk/modules/init.ts +18 -26
  329. package/src/virtuals/sdk/modules/notificationSettings.ts +8 -44
  330. package/src/virtuals/sdk/modules/post.ts +17 -18
  331. package/src/virtuals/sdk/modules/update.ts +31 -29
  332. package/src/virtuals/sdk/sdkCore.ts +5 -0
  333. package/src/virtuals/sdk/types/index.ts +4 -8
  334. package/src/virtuals/sdk/types/tableDefs.ts +4 -4
  335. package/src/virtuals/sdk/types/tsAlias.ts +4 -0
  336. package/src/virtuals/sdk/utils.ts +2 -2
  337. package/src/virtuals/utils.ts +29 -25
  338. package/ui.d.ts +1301 -274
  339. package/dist/components/first-time-setup/TabItem.astro +0 -44
  340. package/dist/components/first-time-setup/Tabs.astro +0 -170
  341. package/dist/handlers/changelog/changelogLoader.d.ts +0 -15
  342. package/dist/handlers/changelog/changelogLoader.js +0 -104
  343. package/dist/handlers/changelog/index.d.ts +0 -1
  344. package/dist/handlers/changelog/index.js +0 -53
  345. package/dist/handlers/scriptHandler.d.ts +0 -30
  346. package/dist/handlers/scriptHandler.js +0 -25
  347. package/dist/utils/addIntegrationArray.d.ts +0 -24
  348. package/dist/utils/addIntegrationArray.js +0 -11
  349. package/dist/utils/getLatestVersion.d.ts +0 -12
  350. package/dist/utils/getLatestVersion.js +0 -36
  351. package/dist/utils/integrationLogger.d.ts +0 -8
  352. package/dist/utils/integrationLogger.js +0 -23
  353. package/dist/utils/jsonUtils.d.ts +0 -13
  354. package/dist/utils/jsonUtils.js +0 -11
  355. package/dist/utils/pageTypeFilter.d.ts +0 -2
  356. package/dist/utils/pageTypeFilter.js +0 -16
  357. package/dist/virtuals/auth/encryption.d.ts +0 -46
  358. package/dist/virtuals/auth/encryption.js +0 -82
  359. package/dist/virtuals/auth/password.d.ts +0 -47
  360. package/dist/virtuals/auth/password.js +0 -147
  361. package/dist/virtuals/auth/session.d.ts +0 -77
  362. package/dist/virtuals/auth/session.js +0 -146
  363. package/dist/virtuals/auth/user.d.ts +0 -155
  364. package/dist/virtuals/auth/user.js +0 -251
  365. package/dist/virtuals/auth/utils/lists/passwords.d.ts +0 -2
  366. package/dist/virtuals/auth/utils/lists/passwords.js +0 -10006
  367. package/dist/virtuals/auth/utils/lists/usernames.d.ts +0 -2
  368. package/dist/virtuals/auth/utils/lists/usernames.js +0 -547
  369. package/dist/virtuals/auth/utils/scrypt.d.ts +0 -17
  370. package/dist/virtuals/auth/utils/scrypt.js +0 -30
  371. package/dist/virtuals/auth/utils/unsafeCheck.d.ts +0 -34
  372. package/dist/virtuals/auth/utils/unsafeCheck.js +0 -39
  373. package/dist/virtuals/i18n/index.d.ts +0 -2471
  374. package/dist/virtuals/lib/jsonUtils.d.ts +0 -2
  375. package/dist/virtuals/lib/jsonUtils.js +0 -14
  376. package/dist/virtuals/lib/removeLeadingTrailingSlashes.d.ts +0 -10
  377. package/dist/virtuals/lib/removeLeadingTrailingSlashes.js +0 -5
  378. package/src/components/first-time-setup/TabItem.astro +0 -44
  379. package/src/components/first-time-setup/Tabs.astro +0 -170
  380. package/src/handlers/changelog/changelogLoader.ts +0 -138
  381. package/src/handlers/changelog/index.ts +0 -67
  382. package/src/handlers/scriptHandler.ts +0 -86
  383. package/src/utils/addIntegrationArray.ts +0 -35
  384. package/src/utils/getLatestVersion.ts +0 -67
  385. package/src/utils/integrationLogger.ts +0 -29
  386. package/src/utils/jsonUtils.ts +0 -20
  387. package/src/utils/pageTypeFilter.ts +0 -13
  388. package/src/virtuals/auth/encryption.ts +0 -148
  389. package/src/virtuals/auth/password.ts +0 -279
  390. package/src/virtuals/auth/session.ts +0 -290
  391. package/src/virtuals/auth/user.ts +0 -501
  392. package/src/virtuals/auth/utils/lists/passwords.ts +0 -10004
  393. package/src/virtuals/auth/utils/lists/usernames.ts +0 -546
  394. package/src/virtuals/auth/utils/scrypt.ts +0 -42
  395. package/src/virtuals/auth/utils/unsafeCheck.ts +0 -72
  396. package/src/virtuals/lib/jsonUtils.ts +0 -11
  397. package/src/virtuals/lib/removeLeadingTrailingSlashes.ts +0 -11
@@ -1,7 +1,8 @@
1
1
  ---
2
2
  import type { UserSessionData } from 'studiocms:auth/lib/types';
3
3
  import type { SiteConfigCacheObject } from 'studiocms:sdk/types';
4
- import { Toaster } from 'studiocms:ui/components';
4
+ import { Toaster } from 'studiocms:ui/components/toaster';
5
+ import type { AvailablePermissionRanks } from '@withstudiocms/auth-kit/types';
5
6
  import BaseHead from '../components/dashboard/BaseHead.astro';
6
7
  import DoubleSidebar from '../components/dashboard/DoubleSidebar.astro';
7
8
  import LoginChecker from '../components/dashboard/LoginChecker.astro';
@@ -28,7 +29,7 @@ type Props = {
28
29
  description?: string;
29
30
  lang?: string;
30
31
  sidebar?: false | 'single' | 'double';
31
- requiredPermission?: 'owner' | 'admin' | 'editor' | 'visitor' | 'unknown' | 'none';
32
+ requiredPermission?: AvailablePermissionRanks | 'none';
32
33
  currentUser: UserSessionData | null;
33
34
  };
34
35
 
@@ -2,9 +2,11 @@
2
2
  import 'studiocms:ui/global-css';
3
3
  import '../styles/dashboard-base.css';
4
4
  import '../styles/dashboard-diff.css';
5
- import { Toaster } from 'studiocms:ui/components';
5
+ import { Toaster } from 'studiocms:ui/components/toaster';
6
+ import Favicons from '../components/shared/head/Favicons.astro';
7
+ import Global from '../components/shared/head/Global.astro';
8
+ import TitleTags from '../components/shared/head/TitleTags.astro';
6
9
  import ThemeManager from '../components/shared/ThemeManager.astro';
7
- import { FAVICON_ASSETS, STUDIOCMS_THEME_COLOR } from '../consts.js';
8
10
 
9
11
  type Props = {
10
12
  title?: string;
@@ -23,22 +25,9 @@ const {
23
25
  <html {lang}>
24
26
 
25
27
  <head>
26
- {/* Global Metadata */}
27
- <meta charset="utf-8" />
28
- <meta name="viewport" content="width=device-width,initial-scale=1" />
29
-
30
- {/* Favicon */}
31
- <link rel="icon" href={FAVICON_ASSETS.svg} type="image/svg+xml" />
32
- <link rel="icon" href={FAVICON_ASSETS.png.light} type="image/png" media="(prefers-color-scheme: dark)" />
33
- <link rel="icon" href={FAVICON_ASSETS.png.dark} type="image/png" media="(prefers-color-scheme: light)" />
34
-
35
- {/* Primary Meta Tags */}
36
- <title>{title}</title>
37
- <meta name="title" content={title} />
38
- <meta name="description" content={description} />
39
- <meta name="theme-color" content={STUDIOCMS_THEME_COLOR} />
40
-
41
- {/* Theme Manager */}
28
+ <Global />
29
+ <Favicons />
30
+ <TitleTags {title} {description} />
42
31
  <ThemeManager />
43
32
  </head>
44
33
  <body>
@@ -40,12 +40,6 @@ const onRequest = defineMiddlewareRouter([
40
40
  defaultLang,
41
41
  latestVersion
42
42
  });
43
- context.locals.SCMSGenerator = `StudioCMS v${SCMSVersion}`;
44
- context.locals.SCMSUiGenerator = `StudioCMS UI v${SCMSUiVersion}`;
45
- context.locals.latestVersion = latestVersion;
46
- context.locals.siteConfig = siteConfig ?? makeFallbackSiteConfig();
47
- context.locals.defaultLang = defaultLang;
48
- context.locals.routeMap = StudioCMSRoutes;
49
43
  return next();
50
44
  })
51
45
  },
@@ -64,20 +58,17 @@ const onRequest = defineMiddlewareRouter([
64
58
  VerifyEmail
65
59
  ]);
66
60
  return { getUserData: getUserData2, isEmailVerificationEnabled: isEmailVerificationEnabled2 };
67
- }).pipe(User.Provide, VerifyEmail.Provide);
61
+ }).pipe(VerifyEmail.Provide);
68
62
  const [userSessionData, emailVerificationEnabled] = yield* Effect.all([
69
63
  getUserData(context),
70
64
  isEmailVerificationEnabled()
71
65
  ]);
72
- const userPermissionLevel = yield* getUserPermissions(userSessionData).pipe(User.Provide);
66
+ const userPermissionLevel = yield* getUserPermissions(userSessionData);
73
67
  yield* setLocals(context, SetLocal.SECURITY, {
74
68
  userSessionData,
75
69
  emailVerificationEnabled,
76
70
  userPermissionLevel
77
71
  });
78
- context.locals.userSessionData = userSessionData;
79
- context.locals.emailVerificationEnabled = emailVerificationEnabled;
80
- context.locals.userPermissionLevel = userPermissionLevel;
81
72
  return next();
82
73
  })
83
74
  },
@@ -104,7 +95,7 @@ const onRequest = defineMiddlewareRouter([
104
95
  const getUserData = yield* Effect.gen(function* () {
105
96
  const { getUserData: getUserData2 } = yield* User;
106
97
  return getUserData2;
107
- }).pipe(User.Provide);
98
+ });
108
99
  const userSessionData = context.locals.StudioCMS.security?.userSessionData ?? (yield* getUserData(context));
109
100
  if (!userSessionData.isLoggedIn) return context.redirect(StudioCMSRoutes.authLinks.loginURL);
110
101
  return next();
@@ -133,7 +124,6 @@ const onRequest = defineMiddlewareRouter([
133
124
  yield* setLocals(context, SetLocal.PLUGINS, {
134
125
  editorCSRFToken: csrfToken
135
126
  });
136
- context.locals.wysiwygCsrfToken = csrfToken;
137
127
  return next();
138
128
  })
139
129
  }
@@ -17,7 +17,7 @@ export declare const getUserPermissions: (userData: UserSessionData) => Effect.E
17
17
  isEditor: boolean;
18
18
  isAdmin: boolean;
19
19
  isOwner: boolean;
20
- }, import("../virtuals/auth/user.js").UserError, import("../virtuals/auth/user.js").User>;
20
+ }, import("@withstudiocms/auth-kit/errors").SessionError | import("@withstudiocms/auth-kit/errors").UserError, never>;
21
21
  /**
22
22
  * Creates a fallback site configuration object with default values.
23
23
  *
@@ -1,13 +1,15 @@
1
1
  import { User } from "studiocms:auth/lib";
2
+ import { UserPermissionLevel } from "@withstudiocms/auth-kit/types";
2
3
  import { deepmerge, Effect, genLogger } from "../effect.js";
4
+ import { CURRENT_CONFIG_VERSION } from "../virtuals/sdk/modules/config.js";
3
5
  const getUserPermissions = (userData) => genLogger("studiocms/middleware/utils/getUserPermissions")(function* () {
4
6
  const { getUserPermissionLevel } = yield* User;
5
7
  const userPermissionLevel = yield* getUserPermissionLevel(userData);
6
8
  return {
7
- isVisitor: userPermissionLevel >= User.UserPermissionLevel.visitor,
8
- isEditor: userPermissionLevel >= User.UserPermissionLevel.editor,
9
- isAdmin: userPermissionLevel >= User.UserPermissionLevel.admin,
10
- isOwner: userPermissionLevel >= User.UserPermissionLevel.owner
9
+ isVisitor: userPermissionLevel >= UserPermissionLevel.visitor,
10
+ isEditor: userPermissionLevel >= UserPermissionLevel.editor,
11
+ isAdmin: userPermissionLevel >= UserPermissionLevel.admin,
12
+ isOwner: userPermissionLevel >= UserPermissionLevel.owner
11
13
  };
12
14
  });
13
15
  const makeFallbackSiteConfig = () => ({
@@ -23,7 +25,8 @@ const makeFallbackSiteConfig = () => ({
23
25
  loginPageBackground: "studiocms-curves",
24
26
  loginPageCustomImage: null,
25
27
  siteIcon: null,
26
- title: "StudioCMS-Setup"
28
+ title: "StudioCMS-Setup",
29
+ _config_version: CURRENT_CONFIG_VERSION
27
30
  }
28
31
  });
29
32
  var SetLocal = /* @__PURE__ */ ((SetLocal2) => {
@@ -11,12 +11,7 @@ import {
11
11
  pipeLogger
12
12
  } from "../../../effect.js";
13
13
  import { AuthAPIUtils } from "./shared.js";
14
- const deps = Layer.mergeAll(
15
- Password.Default,
16
- AuthAPIUtils.Default,
17
- VerifyEmail.Default,
18
- Session.Default
19
- );
14
+ const deps = Layer.mergeAll(AuthAPIUtils.Default, VerifyEmail.Default);
20
15
  const { POST, OPTIONS, ALL } = createEffectAPIRoutes(
21
16
  {
22
17
  POST: (ctx) => genLogger("studiocms/routes/api/auth/login/POST")(function* () {
@@ -1,5 +1,6 @@
1
1
  import { Session } from "studiocms:auth/lib";
2
2
  import { StudioCMSRoutes } from "studiocms:lib";
3
+ import { AuthSessionCookieName } from "../../../consts.js";
3
4
  import {
4
5
  AllResponse,
5
6
  createEffectAPIRoutes,
@@ -13,7 +14,7 @@ const { POST, OPTIONS, ALL } = createEffectAPIRoutes(
13
14
  POST: (ctx) => genLogger("studiocms/routes/api/auth/logout/POST")(function* () {
14
15
  const { validateSessionToken, deleteSessionTokenCookie, invalidateSession } = yield* Session;
15
16
  const { cookies, redirect } = ctx;
16
- const sessionToken = cookies.get(Session.sessionCookieName)?.value ?? null;
17
+ const sessionToken = cookies.get(AuthSessionCookieName)?.value ?? null;
17
18
  if (!sessionToken) return redirect(StudioCMSRoutes.authLinks.loginURL);
18
19
  const { session, user } = yield* validateSessionToken(sessionToken);
19
20
  if (session === null) {
@@ -26,7 +27,7 @@ const { POST, OPTIONS, ALL } = createEffectAPIRoutes(
26
27
  }
27
28
  yield* Effect.all([invalidateSession(session.id), deleteSessionTokenCookie(ctx)]);
28
29
  return redirect(StudioCMSRoutes.mainLinks.baseSiteURL);
29
- }).pipe(Session.Provide),
30
+ }),
30
31
  OPTIONS: () => Effect.try(() => OptionsResponse({ allowedMethods: ["GET", "POST"] })),
31
32
  ALL: () => Effect.try(() => AllResponse())
32
33
  },
@@ -11,13 +11,7 @@ import {
11
11
  pipeLogger
12
12
  } from "../../../effect.js";
13
13
  import { AuthAPIUtils } from "./shared.js";
14
- const deps = Layer.mergeAll(
15
- AuthAPIUtils.Default,
16
- User.Default,
17
- VerifyEmail.Default,
18
- Password.Default,
19
- Session.Default
20
- );
14
+ const deps = Layer.mergeAll(AuthAPIUtils.Default, VerifyEmail.Default);
21
15
  const { POST, OPTIONS, ALL } = createEffectAPIRoutes(
22
16
  {
23
17
  POST: (ctx) => genLogger("studiocms/routes/api/auth/register/POST")(function* () {
@@ -135,10 +135,10 @@ const { POST, PATCH, DELETE, OPTIONS, ALL } = createEffectAPIRoutes(
135
135
  return apiResponseLogger(400, "Invalid form data, contentId is required");
136
136
  }
137
137
  const currentPageData = yield* sdk.GET.page.byId(data.id);
138
- if (!currentPageData.data) {
138
+ if (!currentPageData) {
139
139
  return apiResponseLogger(404, "Page not found");
140
140
  }
141
- const { authorId, contributorIds } = currentPageData.data;
141
+ const { authorId, contributorIds, defaultContent } = currentPageData.data;
142
142
  let AuthorId = authorId;
143
143
  if (!authorId) {
144
144
  AuthorId = userData.user?.id || null;
@@ -153,9 +153,6 @@ const { POST, PATCH, DELETE, OPTIONS, ALL } = createEffectAPIRoutes(
153
153
  const startMetaData = (yield* sdk.GET.databaseTable.pageData()).find(
154
154
  (metaData) => metaData.id === data.id
155
155
  );
156
- const {
157
- data: { defaultContent }
158
- } = yield* sdk.GET.page.byId(data.id);
159
156
  const apiRoute = getPageTypeEndpoints(data.package, "onEdit");
160
157
  yield* sdk.UPDATE.page.byId(data.id, {
161
158
  pageData: data,
@@ -208,6 +205,9 @@ const { POST, PATCH, DELETE, OPTIONS, ALL } = createEffectAPIRoutes(
208
205
  return apiResponseLogger(400, "Invalid request");
209
206
  }
210
207
  const pageToDelete = yield* sdk.GET.page.byId(id);
208
+ if (!pageToDelete) {
209
+ return apiResponseLogger(404, "Page not found");
210
+ }
211
211
  const apiRoute = getPageTypeEndpoints(pageToDelete.data.package, "onDelete");
212
212
  yield* sdk.DELETE.page(id);
213
213
  if (apiRoute) {
@@ -133,7 +133,7 @@ const { POST, OPTIONS, ALL } = createEffectAPIRoutes(
133
133
  return apiResponseLogger(200, "User invite created and email sent");
134
134
  }
135
135
  return apiResponseLogger(200, resetLink.toString());
136
- }).pipe(User.Provide, Mailer.Provide, Notifications.Provide),
136
+ }).pipe(Mailer.Provide, Notifications.Provide),
137
137
  OPTIONS: () => Effect.try(() => OptionsResponse({ allowedMethods: ["POST"] })),
138
138
  ALL: () => Effect.try(() => AllResponse())
139
139
  },
@@ -1,8 +1 @@
1
- export declare enum UserPermissionLevel {
2
- visitor = 1,
3
- editor = 2,
4
- admin = 3,
5
- owner = 4,
6
- unknown = 0
7
- }
8
1
  export declare const POST: import("astro").APIRoute, OPTIONS: import("astro").APIRoute, ALL: import("astro").APIRoute;
@@ -2,7 +2,9 @@ import { Password, User } from "studiocms:auth/lib";
2
2
  import { apiResponseLogger } from "studiocms:logger";
3
3
  import { Notifications } from "studiocms:notifier";
4
4
  import { SDKCore } from "studiocms:sdk";
5
+ import { UserPermissionLevel } from "@withstudiocms/auth-kit/types";
5
6
  import { z } from "astro/zod";
7
+ import { ValidRanks } from "../../../consts.js";
6
8
  import {
7
9
  AllResponse,
8
10
  createEffectAPIRoutes,
@@ -12,14 +14,6 @@ import {
12
14
  OptionsResponse,
13
15
  readAPIContextJson
14
16
  } from "../../../effect.js";
15
- var UserPermissionLevel = /* @__PURE__ */ ((UserPermissionLevel2) => {
16
- UserPermissionLevel2[UserPermissionLevel2["visitor"] = 1] = "visitor";
17
- UserPermissionLevel2[UserPermissionLevel2["editor"] = 2] = "editor";
18
- UserPermissionLevel2[UserPermissionLevel2["admin"] = 3] = "admin";
19
- UserPermissionLevel2[UserPermissionLevel2["owner"] = 4] = "owner";
20
- UserPermissionLevel2[UserPermissionLevel2["unknown"] = 0] = "unknown";
21
- return UserPermissionLevel2;
22
- })(UserPermissionLevel || {});
23
17
  const { POST, OPTIONS, ALL } = createEffectAPIRoutes(
24
18
  {
25
19
  POST: (ctx) => genLogger("studiocms/routes/api/dashboard/create-user.POST")(function* () {
@@ -53,41 +47,43 @@ const { POST, OPTIONS, ALL } = createEffectAPIRoutes(
53
47
  if (!rank) {
54
48
  return apiResponseLogger(400, "Missing field: Rank is required");
55
49
  }
56
- const allowedRanks = /* @__PURE__ */ new Set(["owner", "admin", "editor", "visitor"]);
57
- if (!allowedRanks.has(rank)) {
50
+ if (!ValidRanks.has(rank) || rank === "unknown") {
58
51
  return apiResponseLogger(400, "Invalid rank");
59
52
  }
60
53
  const callerPerm = yield* userHelper.getUserPermissionLevel(userData);
61
54
  const rankToPerm = (r) => {
62
55
  switch (r) {
63
56
  case "owner":
64
- return User.UserPermissionLevel.owner;
57
+ return UserPermissionLevel.owner;
65
58
  case "admin":
66
- return User.UserPermissionLevel.admin;
59
+ return UserPermissionLevel.admin;
67
60
  case "editor":
68
- return User.UserPermissionLevel.editor;
61
+ return UserPermissionLevel.editor;
69
62
  case "visitor":
70
- return User.UserPermissionLevel.visitor;
63
+ return UserPermissionLevel.visitor;
71
64
  default:
72
- return User.UserPermissionLevel.unknown;
65
+ return UserPermissionLevel.unknown;
73
66
  }
74
67
  };
75
68
  const targetPerm = rankToPerm(rank);
76
69
  const permWeight = (lvl) => {
77
70
  switch (lvl) {
78
- case User.UserPermissionLevel.owner:
71
+ case UserPermissionLevel.owner:
79
72
  return 4;
80
- case User.UserPermissionLevel.admin:
73
+ case UserPermissionLevel.admin:
81
74
  return 3;
82
- case User.UserPermissionLevel.editor:
75
+ case UserPermissionLevel.editor:
83
76
  return 2;
84
- case User.UserPermissionLevel.visitor:
77
+ case UserPermissionLevel.visitor:
85
78
  return 1;
86
79
  default:
87
80
  return 0;
88
81
  }
89
82
  };
90
- if (permWeight(callerPerm) <= permWeight(targetPerm)) {
83
+ if (rank === "owner" && callerPerm !== UserPermissionLevel.owner) {
84
+ return createJsonResponse({ error: "Forbidden" }, { status: 403 });
85
+ }
86
+ if (permWeight(callerPerm) < permWeight(targetPerm)) {
91
87
  return createJsonResponse({ error: "Forbidden" }, { status: 403 });
92
88
  }
93
89
  const checkEmail = z.coerce.string().email({ message: "Email address is invalid" }).safeParse(email);
@@ -124,7 +120,7 @@ const { POST, OPTIONS, ALL } = createEffectAPIRoutes(
124
120
  200,
125
121
  JSON.stringify({ username, email, displayname, rank, password })
126
122
  );
127
- }).pipe(Password.Provide, User.Provide, Notifications.Provide),
123
+ }).pipe(Notifications.Provide),
128
124
  OPTIONS: () => Effect.try(() => OptionsResponse({ allowedMethods: ["POST"] })),
129
125
  ALL: () => Effect.try(() => AllResponse())
130
126
  },
@@ -144,6 +140,5 @@ const { POST, OPTIONS, ALL } = createEffectAPIRoutes(
144
140
  export {
145
141
  ALL,
146
142
  OPTIONS,
147
- POST,
148
- UserPermissionLevel
143
+ POST
149
144
  };
@@ -23,6 +23,16 @@ const { POST, OPTIONS, ALL } = createEffectAPIRoutes(
23
23
  return apiResponseLogger(403, "Unauthorized");
24
24
  }
25
25
  yield* readAPIContextJson(ctx).pipe(
26
+ Effect.map((raw) => {
27
+ const rawData = raw ?? {};
28
+ const safe = {
29
+ emailVerification: typeof rawData.emailVerification === "boolean" ? rawData.emailVerification : void 0,
30
+ requireAdminVerification: typeof rawData.requireAdminVerification === "boolean" ? rawData.requireAdminVerification : void 0,
31
+ requireEditorVerification: typeof rawData.requireEditorVerification === "boolean" ? rawData.requireEditorVerification : void 0,
32
+ oAuthBypassVerification: typeof rawData.oAuthBypassVerification === "boolean" ? rawData.oAuthBypassVerification : void 0
33
+ };
34
+ return safe;
35
+ }),
26
36
  Effect.flatMap((data) => sdk.notificationSettings.site.update(data))
27
37
  );
28
38
  return apiResponseLogger(200, "Notification settings updated");
@@ -129,7 +129,7 @@ const { POST, OPTIONS, ALL } = createEffectAPIRoutes(
129
129
  default:
130
130
  return apiResponseLogger(400, "Invalid form data, mode is required or unsupported");
131
131
  }
132
- }).pipe(Password.Provide, User.Provide, Notifications.Provide),
132
+ }).pipe(Notifications.Provide),
133
133
  OPTIONS: () => Effect.try(() => OptionsResponse({ allowedMethods: ["POST"] })),
134
134
  ALL: () => Effect.try(() => AllResponse())
135
135
  },
@@ -64,7 +64,7 @@ const { POST, OPTIONS, ALL } = createEffectAPIRoutes(
64
64
  notify.sendAdminNotification("user_updated", userData.username)
65
65
  ]);
66
66
  return apiResponseLogger(200, "User password updated successfully");
67
- }).pipe(Notifications.Provide, Password.Provide),
67
+ }).pipe(Notifications.Provide),
68
68
  OPTIONS: () => Effect.try(() => OptionsResponse({ allowedMethods: ["POST"] })),
69
69
  ALL: () => Effect.try(() => AllResponse())
70
70
  },
@@ -3,6 +3,8 @@ import { developerConfig } from "studiocms:config";
3
3
  import { apiResponseLogger } from "studiocms:logger";
4
4
  import { Notifications } from "studiocms:notifier";
5
5
  import { SDKCore } from "studiocms:sdk";
6
+ import { UserPermissionLevel } from "@withstudiocms/auth-kit/types";
7
+ import { ValidRanks } from "../../../consts.js";
6
8
  import {
7
9
  AllResponse,
8
10
  createEffectAPIRoutes,
@@ -28,8 +30,7 @@ const { POST, DELETE, OPTIONS, ALL } = createEffectAPIRoutes(
28
30
  if (!id || !rank) {
29
31
  return apiResponseLogger(400, "Invalid request");
30
32
  }
31
- const validRanks = /* @__PURE__ */ new Set(["owner", "admin", "editor", "visitor"]);
32
- if (!validRanks.has(rank)) {
33
+ if (!ValidRanks.has(rank) || rank === "unknown") {
33
34
  return apiResponseLogger(400, "Invalid rank supplied");
34
35
  }
35
36
  const insertData = {
@@ -44,20 +45,36 @@ const { POST, DELETE, OPTIONS, ALL } = createEffectAPIRoutes(
44
45
  const toLevel = (r) => {
45
46
  switch (r) {
46
47
  case "owner":
47
- return User.UserPermissionLevel.owner;
48
+ return UserPermissionLevel.owner;
48
49
  case "admin":
49
- return User.UserPermissionLevel.admin;
50
+ return UserPermissionLevel.admin;
50
51
  case "editor":
51
- return User.UserPermissionLevel.editor;
52
+ return UserPermissionLevel.editor;
52
53
  case "visitor":
53
- return User.UserPermissionLevel.visitor;
54
+ return UserPermissionLevel.visitor;
54
55
  default:
55
- return User.UserPermissionLevel.unknown;
56
+ return UserPermissionLevel.unknown;
56
57
  }
57
58
  };
58
- const targetCurrentLevel = toLevel(user.permissionsData?.rank);
59
+ const targetCurrentLevel = toLevel(
60
+ user.permissionsData?.rank
61
+ );
59
62
  const targetNewLevel = toLevel(rank);
60
- const isAllowedToUpdateRank = userPermissionLevel > targetCurrentLevel && userPermissionLevel > targetNewLevel && (rank !== "owner" || userPermissionLevel === User.UserPermissionLevel.owner);
63
+ const weight = (lvl) => {
64
+ switch (lvl) {
65
+ case UserPermissionLevel.owner:
66
+ return 4;
67
+ case UserPermissionLevel.admin:
68
+ return 3;
69
+ case UserPermissionLevel.editor:
70
+ return 2;
71
+ case UserPermissionLevel.visitor:
72
+ return 1;
73
+ default:
74
+ return 0;
75
+ }
76
+ };
77
+ const isAllowedToUpdateRank = weight(userPermissionLevel) > weight(targetCurrentLevel) && weight(userPermissionLevel) >= weight(targetNewLevel) && (rank !== "owner" || userPermissionLevel === UserPermissionLevel.owner);
61
78
  if (!isAllowedToUpdateRank) {
62
79
  return apiResponseLogger(403, "Unauthorized");
63
80
  }
@@ -75,7 +92,7 @@ const { POST, DELETE, OPTIONS, ALL } = createEffectAPIRoutes(
75
92
  notifications.sendAdminNotification("user_updated", user.username)
76
93
  ]);
77
94
  return apiResponseLogger(200, "User rank updated successfully");
78
- }).pipe(User.Provide, Notifications.Provide),
95
+ }).pipe(Notifications.Provide),
79
96
  DELETE: (ctx) => genLogger("studiocms/routes/api/dashboard/users.DELETE")(function* () {
80
97
  const [notifications, sdk] = yield* Effect.all([Notifications, SDKCore]);
81
98
  if (developerConfig.demoMode !== false) {
@@ -1,5 +1,5 @@
1
1
  import { VerifyEmail } from "studiocms:auth/lib";
2
- import { removeLeadingTrailingSlashes } from "studiocms:lib";
2
+ import { stripLeadingAndTrailingSlashes } from "studiocms:lib";
3
3
  import { apiResponseLogger } from "studiocms:logger";
4
4
  import { SDKCore } from "studiocms:sdk";
5
5
  import {
@@ -37,8 +37,11 @@ const { GET, OPTIONS, ALL } = createEffectAPIRoutes(
37
37
  }),
38
38
  sdk.AUTH.verifyEmail.delete(userId)
39
39
  ]);
40
+ if (!ctx.site) {
41
+ return apiResponseLogger(400, "Site URL is not configured");
42
+ }
40
43
  return ctx.redirect(
41
- removeLeadingTrailingSlashes(ctx.site?.toString()) + ctx.locals.StudioCMS.routeMap.mainLinks.dashboardIndex
44
+ stripLeadingAndTrailingSlashes(ctx.site.toString()) + ctx.locals.StudioCMS.routeMap.mainLinks.dashboardIndex
42
45
  );
43
46
  }).pipe(VerifyEmail.Provide),
44
47
  OPTIONS: () => Effect.try(() => OptionsResponse({ allowedMethods: ["GET"] })),
@@ -1,6 +1,7 @@
1
1
  import { Session } from "studiocms:auth/lib";
2
2
  import { logger as _logger } from "studiocms:logger";
3
3
  import { SDKCore } from "studiocms:sdk";
4
+ import { AuthSessionCookieName } from "../../../consts.js";
4
5
  import {
5
6
  AllResponse,
6
7
  createEffectAPIRoutes,
@@ -42,7 +43,7 @@ const { POST, OPTIONS, ALL } = createEffectAPIRoutes(
42
43
  const logger = _logger.fork("studiocms:runtime:api:verify-session");
43
44
  const { cookies } = ctx;
44
45
  const { originPathname } = yield* parseAPIContextJson(ctx, JsonData);
45
- const sessionToken = cookies.get(Session.sessionCookieName)?.value ?? null;
46
+ const sessionToken = cookies.get(AuthSessionCookieName)?.value ?? null;
46
47
  if (!sessionToken) {
47
48
  logger.info(
48
49
  `No session token found in cookies, returning unknown session status. Origin: ${originPathname}`
@@ -89,7 +90,7 @@ const { POST, OPTIONS, ALL } = createEffectAPIRoutes(
89
90
  break;
90
91
  }
91
92
  return responseBuilder(ctx, true, user, permissionLevel);
92
- }).pipe(Session.Provide),
93
+ }),
93
94
  OPTIONS: () => Effect.try(() => OptionsResponse({ allowedMethods: ["POST"] })),
94
95
  ALL: () => Effect.try(() => AllResponse())
95
96
  },
@@ -13,5 +13,5 @@ import { Effect } from '../../../../effect.js';
13
13
  export declare const verifyAuthTokenFromHeader: (context: APIContext) => Effect.Effect<Response | {
14
14
  userId: string;
15
15
  key: string;
16
- rank: string;
16
+ rank: "unknown" | "owner" | "admin" | "editor" | "visitor";
17
17
  }, import("effect/Cause").UnknownException | import("../../../../virtuals/sdk/errors.js").SDKCoreError, never>;
@@ -70,7 +70,7 @@ const { GET, PATCH, DELETE, OPTIONS, ALL } = createEffectAPIRoutes(
70
70
  if (!currentPageData) {
71
71
  return apiResponseLogger(404, "Page not found");
72
72
  }
73
- const { authorId, contributorIds } = currentPageData.data;
73
+ const { authorId, contributorIds, defaultContent } = currentPageData.data;
74
74
  let AuthorId = authorId;
75
75
  if (!authorId) {
76
76
  AuthorId = userId || null;
@@ -80,15 +80,12 @@ const { GET, PATCH, DELETE, OPTIONS, ALL } = createEffectAPIRoutes(
80
80
  ContributorIds.push(userId);
81
81
  }
82
82
  data.authorId = AuthorId;
83
- data.contributorIds = JSON.stringify(ContributorIds);
83
+ data.contributorIds = ContributorIds;
84
84
  data.updatedAt = /* @__PURE__ */ new Date();
85
85
  const startMetaData = (yield* sdk.GET.databaseTable.pageData()).find(
86
86
  (metaData) => metaData.id === data.id
87
87
  );
88
- const {
89
- data: { defaultContent }
90
- } = yield* sdk.GET.page.byId(data.id);
91
- const _updated = yield* sdk.UPDATE.page.byId(data.id, {
88
+ yield* sdk.UPDATE.page.byId(data.id, {
92
89
  pageData: data,
93
90
  pageContent: content
94
91
  });
@@ -141,10 +138,6 @@ const { GET, PATCH, DELETE, OPTIONS, ALL } = createEffectAPIRoutes(
141
138
  if (!slug) {
142
139
  return apiResponseLogger(400, "Invalid request");
143
140
  }
144
- const isHomePage = yield* sdk.GET.page.bySlug("index");
145
- if (isHomePage.data && isHomePage.data.id === id) {
146
- return apiResponseLogger(400, "Cannot delete home page");
147
- }
148
141
  const page = yield* sdk.GET.page.byId(id);
149
142
  if (!page) {
150
143
  return apiResponseLogger(404, "Page not found");