studiocms 0.1.0-beta.21 → 0.1.0-beta.22

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 (511) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/LICENSE +1 -1
  3. package/dist/cli/add/index.js +12 -8
  4. package/dist/cli/crypto/genJWT/index.js +1 -1
  5. package/dist/cli/init/steps/env.js +1 -1
  6. package/dist/cli/users/steps/libsqlCreateUsers.js +1 -1
  7. package/dist/cli/users/steps/libsqlModifyUsers.js +1 -1
  8. package/dist/cli/utils/context.js +1 -1
  9. package/dist/cli/utils/user-utils.js +2 -3
  10. package/dist/componentRegistry/PropsParser.d.ts +15 -0
  11. package/dist/componentRegistry/PropsParser.js +214 -0
  12. package/dist/componentRegistry/Registry.d.ts +46 -0
  13. package/dist/componentRegistry/Registry.js +79 -0
  14. package/dist/componentRegistry/errors.d.ts +67 -0
  15. package/dist/componentRegistry/errors.js +12 -0
  16. package/dist/componentRegistry/handler.d.ts +34 -0
  17. package/dist/componentRegistry/handler.js +110 -0
  18. package/dist/componentRegistry/index.d.ts +6 -0
  19. package/dist/componentRegistry/index.js +6 -0
  20. package/dist/componentRegistry/runtime.d.ts +46 -0
  21. package/dist/componentRegistry/runtime.js +61 -0
  22. package/dist/componentRegistry/types.d.ts +59 -0
  23. package/dist/components/Renderer.astro +16 -4
  24. package/dist/components/dashboard/DashboardGridItem.astro +1 -1
  25. package/dist/components/dashboard/SidebarModals.astro +1 -0
  26. package/dist/components/dashboard/content-mgmt/CreatePage.astro +1 -1
  27. package/dist/components/dashboard/content-mgmt/EditFolder.astro +1 -1
  28. package/dist/components/dashboard/content-mgmt/EditPage.astro +2 -2
  29. package/dist/components/dashboard/content-mgmt/PageHeader.astro +3 -3
  30. package/dist/components/dashboard/content-mgmt/PageList.astro +1 -1
  31. package/dist/components/dashboard/content-mgmt/PluginFields.astro +1 -2
  32. package/dist/components/dashboard/content-mgmt/runtime.js +1 -2
  33. package/dist/components/dashboard/content-mgmt/shared.js +1 -1
  34. package/dist/components/dashboard/plugins/SettingsRenderer.astro +1 -2
  35. package/dist/components/dashboard/profile/APITokens.astro +1 -1
  36. package/dist/components/dashboard/profile/SocialSignin.astro +1 -1
  37. package/dist/components/dashboard/sidebar/UserAccount.astro +1 -1
  38. package/dist/components/dashboard/sidebar-modals/VersionModal.astro +2 -2
  39. package/dist/components/dashboard/sidebarConfig.js +1 -1
  40. package/dist/components/dashboard/user-mgmt/InnerSidebarElement.astro +1 -1
  41. package/dist/components/default-grid-items/Recently-created-pages.astro +1 -1
  42. package/dist/components/default-grid-items/Recently-signed-up.astro +1 -1
  43. package/dist/components/default-grid-items/Recently-updated-pages.astro +3 -4
  44. package/dist/components/default-grid-items/Totals.astro +1 -1
  45. package/dist/components/default-grid-items/utils.js +7 -1
  46. package/dist/components/user-quick-tools.js +9 -6
  47. package/dist/config.d.ts +76 -2
  48. package/dist/config.js +3 -1
  49. package/dist/consts.d.ts +20 -0
  50. package/dist/db/tables.js +1 -1
  51. package/dist/global.d.ts +1 -1
  52. package/dist/index.d.ts +0 -55
  53. package/dist/index.js +39 -75
  54. package/dist/lib/auth/encryption.d.ts +0 -34
  55. package/dist/lib/auth/encryption.js +10 -42
  56. package/dist/lib/auth/password.d.ts +1 -33
  57. package/dist/lib/auth/password.js +13 -38
  58. package/dist/lib/auth/session.d.ts +2 -85
  59. package/dist/lib/auth/session.js +25 -98
  60. package/dist/lib/auth/user.d.ts +3 -124
  61. package/dist/lib/auth/user.js +25 -117
  62. package/dist/lib/auth/utils/scrypt.js +1 -1
  63. package/dist/lib/auth/verify-email.d.ts +6 -78
  64. package/dist/lib/auth/verify-email.js +17 -67
  65. package/dist/lib/effects/logger.js +1 -1
  66. package/dist/lib/effects/smtp.js +1 -7
  67. package/dist/lib/i18n/client.d.ts +4 -2
  68. package/dist/lib/i18n/client.js +1 -0
  69. package/dist/lib/index.d.ts +2 -2
  70. package/dist/lib/index.js +2 -2
  71. package/dist/lib/jsonUtils.d.ts +2 -2
  72. package/dist/lib/jsonUtils.js +3 -0
  73. package/dist/lib/mailer/index.d.ts +2 -76
  74. package/dist/lib/mailer/index.js +13 -62
  75. package/dist/lib/mailer/templates/index.d.ts +1 -1
  76. package/dist/lib/mailer/templates/index.js +8 -8
  77. package/dist/lib/notifier/index.d.ts +2 -32
  78. package/dist/lib/notifier/index.js +9 -34
  79. package/dist/lib/plugins/frontend-navigation.js +2 -2
  80. package/dist/lib/plugins/index.d.ts +1 -1
  81. package/dist/lib/plugins/index.js +1 -1
  82. package/dist/lib/webVitals/checkForWebVitalsPlugin.js +1 -1
  83. package/dist/lib/webVitals/dashboard-grid-items/CoreVitals.astro +1 -1
  84. package/dist/lib/webVitals/dashboard-grid-items/metric.css +1 -1
  85. package/dist/lib/webVitals/utils/webVitalsUtils.d.ts +9 -9
  86. package/dist/lib/webVitals/webVital.js +4 -4
  87. package/dist/lib/webVitals/webVitalsSummary.js +1 -1
  88. package/dist/middleware/index.js +46 -38
  89. package/dist/middleware/utils.d.ts +4 -1
  90. package/dist/middleware/utils.js +3 -1
  91. package/dist/pluginHandler.d.ts +34 -2
  92. package/dist/pluginHandler.js +58 -64
  93. package/dist/plugins.d.ts +1 -1
  94. package/dist/routeHandler.d.ts +41 -0
  95. package/dist/routeHandler.js +7 -37
  96. package/dist/routes/api/auth/[provider]/_effects/_shared.d.ts +223 -0
  97. package/dist/routes/api/auth/[provider]/_effects/_shared.js +86 -0
  98. package/dist/routes/api/auth/[provider]/_effects/auth0.d.ts +49 -0
  99. package/dist/routes/api/auth/[provider]/_effects/auth0.js +160 -0
  100. package/dist/routes/api/auth/[provider]/_effects/discord.d.ts +44 -0
  101. package/dist/routes/api/auth/[provider]/_effects/discord.js +161 -0
  102. package/dist/routes/api/auth/[provider]/_effects/github.d.ts +44 -0
  103. package/dist/routes/api/auth/[provider]/_effects/github.js +151 -0
  104. package/dist/routes/api/auth/[provider]/_effects/google.d.ts +52 -0
  105. package/dist/routes/api/auth/[provider]/_effects/google.js +160 -0
  106. package/dist/routes/api/auth/[provider]/_effects/index.d.ts +35 -0
  107. package/dist/routes/api/auth/[provider]/_effects/index.js +93 -0
  108. package/dist/routes/api/auth/[provider]/callback.js +19 -0
  109. package/dist/routes/api/auth/[provider]/index.js +19 -0
  110. package/dist/routes/api/auth/forgot-password.js +11 -12
  111. package/dist/routes/api/auth/login.js +19 -26
  112. package/dist/routes/api/auth/logout.js +10 -9
  113. package/dist/routes/api/auth/register.js +29 -40
  114. package/dist/routes/api/auth/shared.d.ts +6 -0
  115. package/dist/routes/api/auth/shared.js +37 -22
  116. package/dist/routes/api/dashboard/api-tokens.js +2 -2
  117. package/dist/routes/api/dashboard/config.js +1 -1
  118. package/dist/routes/api/dashboard/content/diff.js +1 -1
  119. package/dist/routes/api/dashboard/content/folder.js +3 -3
  120. package/dist/routes/api/dashboard/content/page.js +6 -10
  121. package/dist/routes/api/dashboard/create-reset-link.js +1 -1
  122. package/dist/routes/api/dashboard/create-user-invite.js +1 -1
  123. package/dist/routes/api/dashboard/create-user.js +1 -1
  124. package/dist/routes/api/dashboard/email-notification-settings-site.js +1 -1
  125. package/dist/routes/api/dashboard/partials/Editor.astro +14 -3
  126. package/dist/routes/api/dashboard/partials/LiveRender.astro +20 -21
  127. package/dist/routes/api/dashboard/partials/UserListItems.astro +1 -0
  128. package/dist/routes/api/dashboard/profile.js +1 -1
  129. package/dist/routes/api/dashboard/resend-verify-email.js +1 -1
  130. package/dist/routes/api/dashboard/reset-password.js +1 -1
  131. package/dist/routes/api/dashboard/search-list.js +7 -2
  132. package/dist/routes/api/dashboard/update-user-notifications.js +1 -1
  133. package/dist/routes/api/dashboard/users.js +2 -2
  134. package/dist/routes/api/dashboard/verify-email.js +1 -1
  135. package/dist/routes/api/dashboard/verify-session.d.ts +44 -1
  136. package/dist/routes/api/dashboard/verify-session.js +30 -6
  137. package/dist/routes/api/render.astro +4 -8
  138. package/dist/routes/api/rest/utils/auth-token.d.ts +2 -2
  139. package/dist/routes/api/rest/utils/auth-token.js +1 -1
  140. package/dist/routes/api/rest/v1/folders/[id].js +3 -3
  141. package/dist/routes/api/rest/v1/folders/index.js +2 -2
  142. package/dist/routes/api/rest/v1/pages/[id]/history/[diffid].js +1 -1
  143. package/dist/routes/api/rest/v1/pages/[id]/history/index.js +1 -1
  144. package/dist/routes/api/rest/v1/pages/[id]/index.js +5 -5
  145. package/dist/routes/api/rest/v1/pages/index.js +3 -3
  146. package/dist/routes/api/rest/v1/public/folders/[id].js +1 -1
  147. package/dist/routes/api/rest/v1/public/folders/index.js +1 -1
  148. package/dist/routes/api/rest/v1/public/pages/[id].js +1 -1
  149. package/dist/routes/api/rest/v1/public/pages/index.js +1 -1
  150. package/dist/routes/api/rest/v1/settings/index.js +2 -2
  151. package/dist/routes/api/rest/v1/users/[id].js +3 -3
  152. package/dist/routes/api/rest/v1/users/index.js +2 -2
  153. package/dist/routes/api/sdk/fallback-list-pages.json.js +1 -1
  154. package/dist/routes/api/sdk/list-pages.js +1 -1
  155. package/dist/routes/api/sdk/update-latest-version-cache.js +1 -1
  156. package/dist/routes/dashboard/configuration.astro +1 -1
  157. package/dist/routes/dashboard/content-management/diff.astro +2 -2
  158. package/dist/routes/dashboard/password-reset.astro +1 -1
  159. package/dist/routes/dashboard/profile.astro +1 -1
  160. package/dist/routes/dashboard/smtp-configuration.astro +1 -1
  161. package/dist/routes/dashboard/user-management/edit.astro +1 -1
  162. package/dist/routes/firstTimeSetupRoutes/3-done.astro +1 -2
  163. package/dist/routes/firstTimeSetupRoutes/api/step-1.js +1 -30
  164. package/dist/routes/firstTimeSetupRoutes/api/step-2.js +1 -1
  165. package/dist/runtime/AstroComponentProxy.d.ts +5 -3
  166. package/dist/runtime/decoder/util.d.ts +1 -1
  167. package/dist/runtime/decoder/util.js +4 -4
  168. package/dist/schemas/config/dashboard.js +0 -10
  169. package/dist/schemas/config/index.d.ts +0 -426
  170. package/dist/schemas/config/index.js +0 -5
  171. package/dist/schemas/plugins/index.d.ts +76 -1
  172. package/dist/schemas/plugins/index.js +21 -2
  173. package/dist/scriptHandler.d.ts +23 -6
  174. package/dist/scriptHandler.js +18 -21
  175. package/dist/sdk/consts.d.ts +33 -0
  176. package/dist/sdk/consts.js +14 -0
  177. package/dist/sdk/effect/collectors.d.ts +44 -2
  178. package/dist/sdk/effect/collectors.js +8 -5
  179. package/dist/sdk/effect/db.d.ts +78 -1
  180. package/dist/sdk/effect/db.js +1 -2
  181. package/dist/sdk/effect/foldertree.d.ts +23 -2
  182. package/dist/sdk/effect/foldertree.js +1 -2
  183. package/dist/sdk/effect/generators.d.ts +13 -1
  184. package/dist/sdk/effect/generators.js +1 -2
  185. package/dist/sdk/effect/getVersionFromNPM.d.ts +26 -0
  186. package/dist/sdk/effect/index.d.ts +2 -2
  187. package/dist/sdk/effect/index.js +2 -2
  188. package/dist/sdk/effect/lib/jwt-generator.d.ts +29 -0
  189. package/dist/sdk/effect/parsers.d.ts +18 -1
  190. package/dist/sdk/effect/parsers.js +1 -2
  191. package/dist/sdk/effect/users.d.ts +25 -1
  192. package/dist/sdk/effect/users.js +1 -2
  193. package/dist/sdk/errors.d.ts +14 -11
  194. package/dist/sdk/errors.js +0 -4
  195. package/dist/sdk/index.d.ts +28 -1167
  196. package/dist/sdk/index.js +7 -9
  197. package/dist/sdk/modules/auth.d.ts +323 -0
  198. package/dist/sdk/modules/auth.js +428 -0
  199. package/dist/sdk/modules/clear.d.ts +87 -0
  200. package/dist/sdk/modules/clear.js +136 -0
  201. package/dist/sdk/modules/delete.d.ts +130 -0
  202. package/dist/sdk/modules/delete.js +245 -0
  203. package/dist/sdk/modules/diffTracking.d.ts +157 -0
  204. package/dist/sdk/modules/diffTracking.js +390 -0
  205. package/dist/sdk/modules/get.d.ts +370 -0
  206. package/dist/sdk/modules/get.js +849 -0
  207. package/dist/sdk/modules/init.d.ts +75 -0
  208. package/dist/sdk/modules/init.js +55 -0
  209. package/dist/sdk/modules/notificationSettings.d.ts +63 -0
  210. package/dist/sdk/modules/notificationSettings.js +73 -0
  211. package/dist/sdk/modules/post.d.ts +209 -0
  212. package/dist/sdk/modules/post.js +421 -0
  213. package/dist/sdk/modules/resetTokenBucket.d.ts +64 -0
  214. package/dist/sdk/modules/resetTokenBucket.js +91 -0
  215. package/dist/sdk/modules/rest_api.d.ts +84 -0
  216. package/dist/sdk/modules/rest_api.js +99 -0
  217. package/dist/sdk/modules/update.d.ts +182 -0
  218. package/dist/sdk/modules/update.js +307 -0
  219. package/dist/sdk/sdkCore.d.ts +102 -992
  220. package/dist/sdk/sdkCore.js +119 -2507
  221. package/dist/sdk/types/index.d.ts +86 -5
  222. package/dist/sdk/types/tsAlias.d.ts +26 -0
  223. package/dist/sdk/utils.d.ts +148 -0
  224. package/dist/sdk/utils.js +90 -0
  225. package/dist/styles/OnestFont.woff2 +0 -0
  226. package/dist/styles/SyntaxFont.woff2 +0 -0
  227. package/dist/styles/authlayout.css +4 -4
  228. package/dist/styles/dashboard-base.css +27 -29
  229. package/dist/styles/dashboard-diff.css +3 -15
  230. package/dist/utils/authEnvCheck.d.ts +1 -1
  231. package/dist/utils/pageTypeFilter.d.ts +2 -9
  232. package/dist/utils/pageTypeFilter.js +8 -18
  233. package/dist/utils/tinyMDParser.d.ts +1 -0
  234. package/dist/utils/tinyMDParser.js +9 -0
  235. package/dist/virtual.d.ts +105 -501
  236. package/package.json +58 -57
  237. package/src/cli/add/index.ts +15 -10
  238. package/src/cli/add/updateStudioCMSConfig.ts +2 -2
  239. package/src/cli/add/validatePlugins.ts +3 -3
  240. package/src/cli/crypto/genJWT/index.ts +1 -1
  241. package/src/cli/init/steps/env.ts +1 -1
  242. package/src/cli/users/index.ts +1 -1
  243. package/src/cli/users/steps/libsqlCreateUsers.ts +1 -1
  244. package/src/cli/users/steps/libsqlModifyUsers.ts +1 -1
  245. package/src/cli/utils/context.ts +1 -1
  246. package/src/cli/utils/intro.ts +1 -1
  247. package/src/cli/utils/logger.ts +0 -1
  248. package/src/cli/utils/user-utils.ts +2 -3
  249. package/src/componentRegistry/PropsParser.ts +270 -0
  250. package/src/componentRegistry/Registry.ts +119 -0
  251. package/src/componentRegistry/errors.ts +58 -0
  252. package/src/componentRegistry/handler.ts +185 -0
  253. package/src/componentRegistry/index.ts +6 -0
  254. package/src/componentRegistry/runtime.ts +105 -0
  255. package/src/componentRegistry/types.ts +63 -0
  256. package/src/components/Renderer.astro +16 -4
  257. package/src/components/dashboard/DashboardGridItem.astro +1 -1
  258. package/src/components/dashboard/SidebarModals.astro +1 -0
  259. package/src/components/dashboard/component-scripts/makeClientRoutable.ts +1 -1
  260. package/src/components/dashboard/content-mgmt/CreatePage.astro +1 -1
  261. package/src/components/dashboard/content-mgmt/EditFolder.astro +1 -1
  262. package/src/components/dashboard/content-mgmt/EditPage.astro +2 -2
  263. package/src/components/dashboard/content-mgmt/PageHeader.astro +3 -3
  264. package/src/components/dashboard/content-mgmt/PageList.astro +1 -1
  265. package/src/components/dashboard/content-mgmt/PluginFields.astro +1 -2
  266. package/src/components/dashboard/content-mgmt/runtime.ts +2 -3
  267. package/src/components/dashboard/content-mgmt/shared.ts +1 -1
  268. package/src/components/dashboard/plugins/SettingsRenderer.astro +1 -2
  269. package/src/components/dashboard/profile/APITokens.astro +1 -1
  270. package/src/components/dashboard/profile/SocialSignin.astro +1 -1
  271. package/src/components/dashboard/sidebar/UserAccount.astro +1 -1
  272. package/src/components/dashboard/sidebar-modals/VersionModal.astro +2 -2
  273. package/src/components/dashboard/sidebarConfig.ts +1 -1
  274. package/src/components/dashboard/user-mgmt/InnerSidebarElement.astro +1 -1
  275. package/src/components/default-grid-items/Recently-created-pages.astro +1 -1
  276. package/src/components/default-grid-items/Recently-signed-up.astro +1 -1
  277. package/src/components/default-grid-items/Recently-updated-pages.astro +3 -4
  278. package/src/components/default-grid-items/Totals.astro +1 -1
  279. package/src/components/default-grid-items/utils.ts +7 -1
  280. package/src/components/user-quick-tools.ts +10 -7
  281. package/src/config.ts +33 -2
  282. package/src/consts.ts +34 -0
  283. package/src/db/tables.ts +1 -1
  284. package/src/global.d.ts +1 -1
  285. package/src/index.ts +51 -91
  286. package/src/lib/auth/encryption.ts +1 -67
  287. package/src/lib/auth/password.ts +7 -68
  288. package/src/lib/auth/session.ts +2 -158
  289. package/src/lib/auth/user.ts +3 -212
  290. package/src/lib/auth/utils/scrypt.ts +1 -1
  291. package/src/lib/auth/verify-email.ts +3 -134
  292. package/src/lib/dashboardGrid.ts +1 -1
  293. package/src/lib/effects/logger.ts +4 -4
  294. package/src/lib/effects/smtp.ts +1 -6
  295. package/src/lib/i18n/client.ts +13 -7
  296. package/src/lib/index.ts +2 -2
  297. package/src/lib/jsonUtils.ts +5 -4
  298. package/src/lib/mailer/index.ts +2 -127
  299. package/src/lib/mailer/templates/index.ts +1 -1
  300. package/src/lib/notifier/index.ts +2 -66
  301. package/src/lib/plugins/frontend-navigation.ts +2 -2
  302. package/src/lib/plugins/index.ts +1 -1
  303. package/src/lib/renderer/errors.ts +1 -1
  304. package/src/lib/webVitals/checkForWebVitalsPlugin.ts +1 -2
  305. package/src/lib/webVitals/dashboard-grid-items/CoreVitals.astro +1 -1
  306. package/src/lib/webVitals/dashboard-grid-items/metric.css +1 -1
  307. package/src/lib/webVitals/webVital.ts +4 -4
  308. package/src/lib/webVitals/webVitalsRouteSummary.ts +1 -1
  309. package/src/lib/webVitals/webVitalsSummary.ts +1 -1
  310. package/src/middleware/index.ts +51 -42
  311. package/src/middleware/utils.ts +7 -3
  312. package/src/pluginHandler.ts +122 -68
  313. package/src/plugins.ts +1 -1
  314. package/src/routeHandler.ts +84 -38
  315. package/src/routes/api/auth/[provider]/_effects/_shared.ts +176 -0
  316. package/src/routes/api/auth/[provider]/_effects/auth0.ts +236 -0
  317. package/src/routes/api/auth/[provider]/_effects/discord.ts +232 -0
  318. package/src/routes/api/auth/[provider]/_effects/github.ts +221 -0
  319. package/src/routes/api/auth/[provider]/_effects/google.ts +238 -0
  320. package/src/routes/api/auth/[provider]/_effects/index.ts +119 -0
  321. package/src/routes/api/auth/[provider]/callback.ts +18 -0
  322. package/src/routes/api/auth/[provider]/index.ts +18 -0
  323. package/src/routes/api/auth/forgot-password.ts +13 -22
  324. package/src/routes/api/auth/login.ts +20 -27
  325. package/src/routes/api/auth/logout.ts +10 -9
  326. package/src/routes/api/auth/register.ts +30 -42
  327. package/src/routes/api/auth/shared.ts +43 -26
  328. package/src/routes/api/dashboard/api-tokens.ts +2 -2
  329. package/src/routes/api/dashboard/config.ts +1 -1
  330. package/src/routes/api/dashboard/content/diff.ts +1 -1
  331. package/src/routes/api/dashboard/content/folder.ts +3 -3
  332. package/src/routes/api/dashboard/content/page.ts +10 -16
  333. package/src/routes/api/dashboard/create-reset-link.ts +1 -1
  334. package/src/routes/api/dashboard/create-user-invite.ts +1 -1
  335. package/src/routes/api/dashboard/create-user.ts +1 -1
  336. package/src/routes/api/dashboard/email-notification-settings-site.ts +1 -1
  337. package/src/routes/api/dashboard/partials/Editor.astro +14 -3
  338. package/src/routes/api/dashboard/partials/LiveRender.astro +20 -21
  339. package/src/routes/api/dashboard/partials/UserListItems.astro +1 -0
  340. package/src/routes/api/dashboard/profile.ts +7 -7
  341. package/src/routes/api/dashboard/resend-verify-email.ts +1 -1
  342. package/src/routes/api/dashboard/reset-password.ts +1 -1
  343. package/src/routes/api/dashboard/search-list.ts +7 -2
  344. package/src/routes/api/dashboard/update-user-notifications.ts +1 -1
  345. package/src/routes/api/dashboard/users.ts +2 -2
  346. package/src/routes/api/dashboard/verify-email.ts +1 -1
  347. package/src/routes/api/dashboard/verify-session.ts +61 -5
  348. package/src/routes/api/render.astro +4 -8
  349. package/src/routes/api/rest/utils/auth-token.ts +1 -1
  350. package/src/routes/api/rest/v1/folders/[id].ts +3 -3
  351. package/src/routes/api/rest/v1/folders/index.ts +2 -2
  352. package/src/routes/api/rest/v1/pages/[id]/history/[diffid].ts +1 -1
  353. package/src/routes/api/rest/v1/pages/[id]/history/index.ts +1 -1
  354. package/src/routes/api/rest/v1/pages/[id]/index.ts +6 -6
  355. package/src/routes/api/rest/v1/pages/index.ts +3 -3
  356. package/src/routes/api/rest/v1/public/folders/[id].ts +1 -1
  357. package/src/routes/api/rest/v1/public/folders/index.ts +1 -1
  358. package/src/routes/api/rest/v1/public/pages/[id].ts +1 -1
  359. package/src/routes/api/rest/v1/public/pages/index.ts +1 -1
  360. package/src/routes/api/rest/v1/settings/index.ts +2 -2
  361. package/src/routes/api/rest/v1/users/[id].ts +3 -3
  362. package/src/routes/api/rest/v1/users/index.ts +2 -2
  363. package/src/routes/api/sdk/fallback-list-pages.json.ts +1 -1
  364. package/src/routes/api/sdk/list-pages.ts +1 -1
  365. package/src/routes/api/sdk/update-latest-version-cache.ts +1 -1
  366. package/src/routes/api/sdk/utils/changelog.ts +1 -2
  367. package/src/routes/dashboard/configuration.astro +1 -1
  368. package/src/routes/dashboard/content-management/diff.astro +2 -2
  369. package/src/routes/dashboard/password-reset.astro +1 -1
  370. package/src/routes/dashboard/profile.astro +1 -1
  371. package/src/routes/dashboard/smtp-configuration.astro +1 -1
  372. package/src/routes/dashboard/user-management/edit.astro +1 -1
  373. package/src/routes/firstTimeSetupRoutes/3-done.astro +1 -2
  374. package/src/routes/firstTimeSetupRoutes/api/step-1.ts +1 -32
  375. package/src/routes/firstTimeSetupRoutes/api/step-2.ts +1 -1
  376. package/src/runtime/AstroComponentProxy.ts +15 -16
  377. package/src/runtime/decoder/util.ts +7 -7
  378. package/src/schemas/config/dashboard.ts +0 -10
  379. package/src/schemas/config/index.ts +0 -6
  380. package/src/schemas/plugins/index.ts +64 -4
  381. package/src/schemas/plugins/shared.ts +1 -1
  382. package/src/scriptHandler.ts +69 -28
  383. package/src/scripts/three.ts +2 -2
  384. package/src/sdk/consts.ts +38 -0
  385. package/src/sdk/effect/collectors.ts +56 -3
  386. package/src/sdk/effect/db.ts +116 -2
  387. package/src/sdk/effect/foldertree.ts +22 -1
  388. package/src/sdk/effect/generators.ts +14 -2
  389. package/src/sdk/effect/getVersionFromNPM.ts +33 -0
  390. package/src/sdk/effect/index.ts +2 -2
  391. package/src/sdk/effect/lib/jwt-generator.ts +50 -0
  392. package/src/sdk/effect/parsers.ts +22 -1
  393. package/src/sdk/effect/users.ts +25 -1
  394. package/src/sdk/errors.ts +14 -12
  395. package/src/sdk/index.ts +20 -33
  396. package/src/sdk/modules/auth.ts +533 -0
  397. package/src/sdk/modules/clear.ts +179 -0
  398. package/src/sdk/modules/delete.ts +289 -0
  399. package/src/sdk/modules/diffTracking.ts +557 -0
  400. package/src/sdk/modules/get.ts +1278 -0
  401. package/src/sdk/modules/init.ts +85 -0
  402. package/src/sdk/modules/notificationSettings.ts +117 -0
  403. package/src/sdk/modules/post.ts +544 -0
  404. package/src/sdk/modules/resetTokenBucket.ts +144 -0
  405. package/src/sdk/modules/rest_api.ts +147 -0
  406. package/src/sdk/modules/update.ts +427 -0
  407. package/src/sdk/sdkCore.ts +207 -3340
  408. package/src/sdk/types/index.ts +87 -6
  409. package/src/sdk/types/tsAlias.ts +30 -0
  410. package/src/sdk/utils.ts +238 -0
  411. package/src/styles/authlayout.css +5 -4
  412. package/src/styles/dashboard-base.css +27 -29
  413. package/src/styles/dashboard-diff.css +6 -17
  414. package/src/utils/authEnvCheck.ts +1 -1
  415. package/src/utils/changelogLoader.ts +0 -2
  416. package/src/utils/pageTypeFilter.ts +8 -40
  417. package/src/utils/tinyMDParser.ts +8 -0
  418. package/src/virtual.d.ts +105 -501
  419. package/ui.d.ts +8 -22
  420. package/dist/components/editors/html.astro +0 -154
  421. package/dist/components/editors/markdown.astro +0 -141
  422. package/dist/components/editors/utils/TinyMDE.astro +0 -6
  423. package/dist/components/renderers/markdown-prerender.d.ts +0 -10
  424. package/dist/components/renderers/markdown-prerender.js +0 -46
  425. package/dist/components/renderers/studiocms-html.astro +0 -30
  426. package/dist/components/renderers/studiocms-markdown.astro +0 -35
  427. package/dist/lib/renderer/runtime.d.ts +0 -8
  428. package/dist/lib/renderer/runtime.js +0 -32
  429. package/dist/lib/renderer/shared.d.ts +0 -12
  430. package/dist/lib/renderer/shared.js +0 -9
  431. package/dist/lib/renderer/types.d.ts +0 -12
  432. package/dist/routes/api/auth/auth0/callback.js +0 -16
  433. package/dist/routes/api/auth/auth0/effect.d.ts +0 -27
  434. package/dist/routes/api/auth/auth0/effect.js +0 -157
  435. package/dist/routes/api/auth/auth0/index.js +0 -16
  436. package/dist/routes/api/auth/discord/callback.d.ts +0 -4
  437. package/dist/routes/api/auth/discord/callback.js +0 -16
  438. package/dist/routes/api/auth/discord/effect.d.ts +0 -26
  439. package/dist/routes/api/auth/discord/effect.js +0 -150
  440. package/dist/routes/api/auth/discord/index.d.ts +0 -4
  441. package/dist/routes/api/auth/discord/index.js +0 -16
  442. package/dist/routes/api/auth/github/callback.d.ts +0 -4
  443. package/dist/routes/api/auth/github/callback.js +0 -16
  444. package/dist/routes/api/auth/github/effect.d.ts +0 -26
  445. package/dist/routes/api/auth/github/effect.js +0 -136
  446. package/dist/routes/api/auth/github/index.d.ts +0 -4
  447. package/dist/routes/api/auth/github/index.js +0 -16
  448. package/dist/routes/api/auth/google/callback.d.ts +0 -4
  449. package/dist/routes/api/auth/google/callback.js +0 -16
  450. package/dist/routes/api/auth/google/effect.d.ts +0 -25
  451. package/dist/routes/api/auth/google/effect.js +0 -149
  452. package/dist/routes/api/auth/google/index.d.ts +0 -4
  453. package/dist/routes/api/auth/google/index.js +0 -16
  454. package/dist/schemas/config/pageTypeOptions.d.ts +0 -651
  455. package/dist/schemas/config/pageTypeOptions.js +0 -46
  456. package/dist/sdk/cache-core.d.ts +0 -217
  457. package/dist/sdk/cache-core.js +0 -64
  458. package/dist/sdk/cache.d.ts +0 -7
  459. package/dist/sdk/cache.js +0 -7
  460. package/dist/sdk/core.d.ts +0 -1018
  461. package/dist/sdk/core.js +0 -726
  462. package/dist/styles/dashboard-tiny-mde.css +0 -224
  463. package/dist/styles/md-remark-callouts/github.css +0 -56
  464. package/dist/styles/md-remark-callouts/obsidian.css +0 -66
  465. package/dist/styles/md-remark-callouts/vitepress.css +0 -58
  466. package/dist/styles/md-remark-headings.css +0 -48
  467. package/dist/utils/configManager.d.ts +0 -17
  468. package/dist/utils/configManager.js +0 -142
  469. package/dist/utils/configResolver.d.ts +0 -188
  470. package/dist/utils/configResolver.js +0 -106
  471. package/dist/utils/defineStudioCMSConfig.d.ts +0 -118
  472. package/dist/utils/defineStudioCMSConfig.js +0 -6
  473. package/src/components/editors/html.astro +0 -154
  474. package/src/components/editors/markdown.astro +0 -141
  475. package/src/components/editors/utils/TinyMDE.astro +0 -6
  476. package/src/components/renderers/markdown-prerender.ts +0 -61
  477. package/src/components/renderers/studiocms-html.astro +0 -30
  478. package/src/components/renderers/studiocms-markdown.astro +0 -35
  479. package/src/lib/renderer/runtime.ts +0 -41
  480. package/src/lib/renderer/shared.ts +0 -21
  481. package/src/lib/renderer/types.ts +0 -16
  482. package/src/routes/api/auth/auth0/callback.ts +0 -17
  483. package/src/routes/api/auth/auth0/effect.ts +0 -210
  484. package/src/routes/api/auth/auth0/index.ts +0 -17
  485. package/src/routes/api/auth/discord/callback.ts +0 -17
  486. package/src/routes/api/auth/discord/effect.ts +0 -202
  487. package/src/routes/api/auth/discord/index.ts +0 -17
  488. package/src/routes/api/auth/github/callback.ts +0 -17
  489. package/src/routes/api/auth/github/effect.ts +0 -191
  490. package/src/routes/api/auth/github/index.ts +0 -17
  491. package/src/routes/api/auth/google/callback.ts +0 -17
  492. package/src/routes/api/auth/google/effect.ts +0 -199
  493. package/src/routes/api/auth/google/index.ts +0 -17
  494. package/src/schemas/config/pageTypeOptions.ts +0 -62
  495. package/src/sdk/cache-core.ts +0 -105
  496. package/src/sdk/cache.ts +0 -16
  497. package/src/sdk/core.ts +0 -977
  498. package/src/styles/dashboard-tiny-mde.css +0 -260
  499. package/src/styles/md-remark-callouts/github.css +0 -72
  500. package/src/styles/md-remark-callouts/obsidian.css +0 -83
  501. package/src/styles/md-remark-callouts/vitepress.css +0 -72
  502. package/src/styles/md-remark-headings.css +0 -56
  503. package/src/utils/configManager.ts +0 -190
  504. package/src/utils/configResolver.ts +0 -141
  505. package/src/utils/defineStudioCMSConfig.ts +0 -33
  506. /package/dist/{utils → componentRegistry}/convert-hyphens.d.ts +0 -0
  507. /package/dist/{utils → componentRegistry}/convert-hyphens.js +0 -0
  508. /package/dist/{lib/renderer → componentRegistry}/types.js +0 -0
  509. /package/dist/routes/api/auth/{auth0 → [provider]}/callback.d.ts +0 -0
  510. /package/dist/routes/api/auth/{auth0 → [provider]}/index.d.ts +0 -0
  511. /package/src/{utils → componentRegistry}/convert-hyphens.ts +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,42 @@
1
1
  # studiocms
2
2
 
3
+ ## 0.1.0-beta.22
4
+
5
+ ### Patch Changes
6
+
7
+ - [#649](https://github.com/withstudiocms/studiocms/pull/649) [`336397f`](https://github.com/withstudiocms/studiocms/commit/336397f31a63bdb05a17a6a7e9a0ab22601bbb61) Thanks [@Adammatthiesen](https://github.com/Adammatthiesen)! - Remove deprecated `@astrojs/web-vitals` support in favor of new `@studiocms/web-vitals` package
8
+
9
+ - [#644](https://github.com/withstudiocms/studiocms/pull/644) [`83a47ff`](https://github.com/withstudiocms/studiocms/commit/83a47ff1912f30bae20461b2bfd994efe3f35749) Thanks [@Adammatthiesen](https://github.com/Adammatthiesen)! - Add support for the SDK folder getter to get by name or ID instead of just ID, and add jsdoc comments to missing functions for the SDK
10
+
11
+ - [#629](https://github.com/withstudiocms/studiocms/pull/629) [`356791d`](https://github.com/withstudiocms/studiocms/commit/356791d80aa8a33cbb77e2c83ca8fc70eaf3b5dd) Thanks [@Adammatthiesen](https://github.com/Adammatthiesen)! - Refactor component registry into new custom handler for reading component props during initialization for usage within StudioCMS Dashboard editors
12
+
13
+ #### Breaking Changes
14
+
15
+ - `studiocms:component-proxy` has been replaced by `studiocms:component-registry`
16
+ - Added `studiocms:component-registry/runtime` virtual module which exports types, and the following helpers, `getRegistryComponents` and `getRendererComponents` used for getting Components with props, and the renderer components respectively.
17
+ - `importComponentKeys` has been carried over but deprecated in favor for the new `getRendererComponents` function.
18
+
19
+ - [#642](https://github.com/withstudiocms/studiocms/pull/642) [`e9be97d`](https://github.com/withstudiocms/studiocms/commit/e9be97dabcd8e479f929a43919332e5deb187900) Thanks [@Adammatthiesen](https://github.com/Adammatthiesen)! - Fix: Correct exports for components, layouts, and add export for styles
20
+
21
+ - [#650](https://github.com/withstudiocms/studiocms/pull/650) [`3e7f7ca`](https://github.com/withstudiocms/studiocms/commit/3e7f7ca6ea2a304fe66eac95496542cc50169eb2) Thanks [@Adammatthiesen](https://github.com/Adammatthiesen)! - Update various deps and lint repo with updated biome version
22
+
23
+ - [#643](https://github.com/withstudiocms/studiocms/pull/643) [`9cfba9a`](https://github.com/withstudiocms/studiocms/commit/9cfba9ad57f8fb1b2a10081fbe5f9dfc26bed57d) Thanks [@Adammatthiesen](https://github.com/Adammatthiesen)! - Moved MD and HTML pagetypes into their own plugins
24
+
25
+ - [#656](https://github.com/withstudiocms/studiocms/pull/656) [`3233abe`](https://github.com/withstudiocms/studiocms/commit/3233abe727ac9ba6f1886ef5a931db81f0da4326) Thanks [@Adammatthiesen](https://github.com/Adammatthiesen)! - Update dependencies
26
+
27
+ - [#637](https://github.com/withstudiocms/studiocms/pull/637) [`7511f47`](https://github.com/withstudiocms/studiocms/commit/7511f47042104bed83f985c336c7d62cc1fd3b2f) Thanks [@Adammatthiesen](https://github.com/Adammatthiesen)! - Remove Deprecated SDK functions and refactor SDK to make it easier to modify/read
28
+
29
+ - [#643](https://github.com/withstudiocms/studiocms/pull/643) [`9cfba9a`](https://github.com/withstudiocms/studiocms/commit/9cfba9ad57f8fb1b2a10081fbe5f9dfc26bed57d) Thanks [@Adammatthiesen](https://github.com/Adammatthiesen)! - All internal base included pagetypes have been removed, allowing even more flexibility when it comes to how studiocms works for the user. This change also means that you will be required to install at least one rendering plugin for studiocms
30
+
31
+ - [#640](https://github.com/withstudiocms/studiocms/pull/640) [`fe3fa26`](https://github.com/withstudiocms/studiocms/commit/fe3fa262b80a17ea2d89d8f09e4c3ac97f64ca5f) Thanks [@Adammatthiesen](https://github.com/Adammatthiesen)! - Remove previously deprected functions and old hashing system
32
+
33
+ - [#635](https://github.com/withstudiocms/studiocms/pull/635) [`54da8e7`](https://github.com/withstudiocms/studiocms/commit/54da8e7ff080f44a02ca8139c8ddade37f1d32f4) Thanks [@Adammatthiesen](https://github.com/Adammatthiesen)! - Refactor oAuth endpoints into two dynamic endpoints with a provider param in the route and cleanup all auth endpoints code.
34
+
35
+ - [#657](https://github.com/withstudiocms/studiocms/pull/657) [`a05bb16`](https://github.com/withstudiocms/studiocms/commit/a05bb16d3dd0d1a429558b4dce316ad7fb80b049) Thanks [@Adammatthiesen](https://github.com/Adammatthiesen)! - Migrate to using new config utils package that contains generic config helpers instead of relying on specific ones built-in to studiocms
36
+
37
+ - Updated dependencies [[`a05bb16`](https://github.com/withstudiocms/studiocms/commit/a05bb16d3dd0d1a429558b4dce316ad7fb80b049)]:
38
+ - @withstudiocms/config-utils@0.1.0-beta.1
39
+
3
40
  ## 0.1.0-beta.21
4
41
 
5
42
  ### Patch Changes
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024 StudioCMS - Adam Matthiesen, Jacob Jenkins, Paul Valladares
3
+ Copyright (c) 2025-present StudioCMS - withstudiocms (https://github.com/withstudiocms)
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,11 +1,11 @@
1
- import { promises as fs, existsSync } from "node:fs";
1
+ import { existsSync, promises as fs } from "node:fs";
2
2
  import { fileURLToPath } from "node:url";
3
3
  import { Args, Command } from "@effect/cli";
4
4
  import { cancelled, success } from "@withstudiocms/cli-kit/messages";
5
5
  import { exists, pathToFileURL, resolveRoot } from "@withstudiocms/cli-kit/utils";
6
6
  import { builders, loadFile } from "magicast";
7
7
  import { getDefaultExportOptions } from "magicast/helpers";
8
- import { Console, Effect, genLogger } from "../../effect.js";
8
+ import { Console, Effect, genLogger, Layer } from "../../effect.js";
9
9
  import { CliContext, genContext } from "../utils/context.js";
10
10
  import { logger } from "../utils/logger.js";
11
11
  import { TryToInstallPlugins } from "./tryToInstallPlugins.js";
@@ -13,8 +13,11 @@ import { UpdateStudioCMSConfig } from "./updateStudioCMSConfig.js";
13
13
  import { ValidatePlugins } from "./validatePlugins.js";
14
14
  const ALIASES = /* @__PURE__ */ new Map([
15
15
  ["blog", "@studiocms/blog"],
16
- ["mdx", "@studiocms/mdx"],
16
+ ["cloudinary", "@studiocms/cloudinary-image-service"],
17
+ ["html", "@studiocms/html"],
17
18
  ["markdoc", "@studiocms/markdoc"],
19
+ ["md", "@studiocms/md"],
20
+ ["mdx", "@studiocms/mdx"],
18
21
  ["wysiwyg", "@studiocms/wysiwyg"]
19
22
  ]);
20
23
  const StudioCMSScopes = ["@studiocms", "@withstudiocms"];
@@ -112,6 +115,11 @@ const loadConfigModule = (configURL, validatedPlugins) => genLogger("studiocms/c
112
115
  }
113
116
  return mod;
114
117
  });
118
+ const addPluginDeps = Layer.mergeAll(
119
+ ValidatePlugins.Default,
120
+ TryToInstallPlugins.Default,
121
+ UpdateStudioCMSConfig.Default
122
+ );
115
123
  const addPlugin = Command.make(
116
124
  "add",
117
125
  {
@@ -203,11 +211,7 @@ const addPlugin = Command.make(
203
211
  );
204
212
  }
205
213
  }
206
- }).pipe(
207
- Effect.provide(ValidatePlugins.Default),
208
- Effect.provide(TryToInstallPlugins.Default),
209
- Effect.provide(UpdateStudioCMSConfig.Default)
210
- )
214
+ }).pipe(Effect.provide(addPluginDeps))
211
215
  ).pipe(Command.withDescription("Add StudioCMS plugin(s) to your project"));
212
216
  export {
213
217
  ALIASES,
@@ -78,7 +78,7 @@ const genJWT = Command.make(
78
78
  let privateKey;
79
79
  try {
80
80
  privateKey = yield* Effect.tryPromise(() => importPKCS8(keyString, alg));
81
- } catch (e) {
81
+ } catch (_e) {
82
82
  spinner.stop("Invalid or unsupported private key");
83
83
  return yield* Effect.fail(new Error("Invalid or unsupported private key"));
84
84
  }
@@ -16,7 +16,7 @@ import {
16
16
  runShellCommand
17
17
  } from "@withstudiocms/cli-kit/utils";
18
18
  import { logger } from "../../utils/logger.js";
19
- import { ExampleEnv, buildEnvFile } from "../../utils/studiocmsEnv.js";
19
+ import { buildEnvFile, ExampleEnv } from "../../utils/studiocmsEnv.js";
20
20
  var EnvBuilderAction = /* @__PURE__ */ ((EnvBuilderAction2) => {
21
21
  EnvBuilderAction2["builder"] = "builder";
22
22
  EnvBuilderAction2["example"] = "example";
@@ -1,7 +1,7 @@
1
1
  import { StudioCMSColorwayError, StudioCMSColorwayInfo } from "@withstudiocms/cli-kit/colors";
2
2
  import { z } from "astro/zod";
3
3
  import dotenv from "dotenv";
4
- import { Effect, convertToVanilla } from "../../../effect.js";
4
+ import { convertToVanilla, Effect } from "../../../effect.js";
5
5
  import { CheckIfUnsafe } from "../../../lib/auth/utils/unsafeCheck.js";
6
6
  import { checkRequiredEnvVars } from "../../utils/checkRequiredEnvVars.js";
7
7
  import { createUserAvatar } from "../../utils/createUserAvatar.js";
@@ -1,7 +1,7 @@
1
1
  import { StudioCMSColorwayError, StudioCMSColorwayInfo } from "@withstudiocms/cli-kit/colors";
2
2
  import dotenv from "dotenv";
3
3
  import { eq } from "drizzle-orm";
4
- import { Effect, convertToVanilla } from "../../../effect.js";
4
+ import { convertToVanilla, Effect } from "../../../effect.js";
5
5
  import { CheckIfUnsafe } from "../../../lib/auth/utils/unsafeCheck.js";
6
6
  import { checkRequiredEnvVars } from "../../utils/checkRequiredEnvVars.js";
7
7
  import { logger } from "../../utils/logger.js";
@@ -2,7 +2,7 @@ import * as prompts from "@clack/prompts";
2
2
  import { detectPackageManager } from "@withstudiocms/cli-kit/context";
3
3
  import { cancelMessage, getName } from "@withstudiocms/cli-kit/messages";
4
4
  import chalk from "chalk";
5
- import { Context, Effect, Layer, genLogger } from "../../effect.js";
5
+ import { Context, Effect, genLogger, Layer } from "../../effect.js";
6
6
  class CliContext extends Context.Tag("CliContext")() {
7
7
  static makeLayer = (context) => Layer.succeed(this, this.of(context));
8
8
  static makeProvide = (context) => Effect.provide(this.makeLayer(context));
@@ -1,13 +1,12 @@
1
- import crypto from "node:crypto";
2
- import { scrypt } from "node:crypto";
1
+ import crypto, { scrypt } from "node:crypto";
3
2
  import {
4
3
  Brand,
5
4
  Context,
6
5
  Data,
7
6
  Effect,
8
- Layer,
9
7
  errorTap,
10
8
  genLogger,
9
+ Layer,
11
10
  pipeLogger
12
11
  } from "../../effect.js";
13
12
  const parsedN = Number.parseInt(process.env.SCRYPT_N ?? "", 10);
@@ -0,0 +1,15 @@
1
+ import { Effect } from '../effect.js';
2
+ import { ComponentRegistryError, FileParseError } from './errors.js';
3
+ import type { AstroComponentProps } from './types.js';
4
+ declare const PropsParser_base: Effect.Service.Class<PropsParser, "PropsParser", {
5
+ readonly effect: Effect.Effect<{
6
+ parseComponentProps: (sourceCode: string) => Effect.Effect<AstroComponentProps[], ComponentRegistryError, never>;
7
+ extractPropsFromAstroFile: (astroFileContent: string) => Effect.Effect<string, FileParseError, never>;
8
+ }, never, never>;
9
+ }>;
10
+ /**
11
+ * Service for parsing component props from TypeScript source code and extracting prop definitions from Astro files.
12
+ */
13
+ export declare class PropsParser extends PropsParser_base {
14
+ }
15
+ export {};
@@ -0,0 +1,214 @@
1
+ import { Project, SyntaxKind } from "ts-morph";
2
+ import { Effect, genLogger, pipeLogger } from "../effect.js";
3
+ import { ComponentRegistryError, FileParseError } from "./errors.js";
4
+ class PropsParser extends Effect.Service()("PropsParser", {
5
+ effect: genLogger("studiocms/componentRegistry/PropsParser")(function* () {
6
+ return {
7
+ parseComponentProps: (sourceCode) => pipeLogger("studiocms/componentRegistry/PropsParser.parseComponentProps")(
8
+ Effect.try({
9
+ try: () => {
10
+ const project = new Project();
11
+ const sourceFile = project.createSourceFile("temp.ts", sourceCode);
12
+ const results = [];
13
+ const extractJSDocInfo = (node) => {
14
+ const jsDocComments = node.getJsDocs();
15
+ let description;
16
+ let defaultValue;
17
+ const jsDocTags = [];
18
+ if (jsDocComments.length > 0) {
19
+ description = jsDocComments[0].getDescription().trim();
20
+ for (const jsDoc of jsDocComments) {
21
+ const tags = jsDoc.getTags();
22
+ for (const tag of tags) {
23
+ const tagName = tag.getTagName();
24
+ const commentText = tag.getCommentText();
25
+ switch (tagName) {
26
+ case "param": {
27
+ const paramInfo = tag.getStructure();
28
+ jsDocTags.push({
29
+ tagName,
30
+ text: commentText,
31
+ name: paramInfo.tagName,
32
+ type: typeof paramInfo.text === "string" ? paramInfo.text : void 0
33
+ });
34
+ break;
35
+ }
36
+ case "default": {
37
+ defaultValue = commentText;
38
+ jsDocTags.push({
39
+ tagName,
40
+ text: commentText
41
+ });
42
+ break;
43
+ }
44
+ case "example":
45
+ case "since":
46
+ case "deprecated":
47
+ case "see":
48
+ case "author":
49
+ case "version":
50
+ case "throws":
51
+ case "returns":
52
+ case "readonly":
53
+ case "internal":
54
+ case "beta":
55
+ case "alpha":
56
+ case "experimental": {
57
+ jsDocTags.push({
58
+ tagName,
59
+ text: commentText
60
+ });
61
+ break;
62
+ }
63
+ default: {
64
+ jsDocTags.push({
65
+ tagName,
66
+ text: commentText
67
+ });
68
+ }
69
+ }
70
+ }
71
+ }
72
+ }
73
+ return { description, defaultValue, jsDocTags };
74
+ };
75
+ const interfaces = sourceFile.getInterfaces();
76
+ for (const interfaceDecl of interfaces) {
77
+ const interfaceName = interfaceDecl.getName();
78
+ const props = [];
79
+ const properties = interfaceDecl.getProperties();
80
+ for (const property of properties) {
81
+ const propName = property.getName();
82
+ const propType = property.getTypeNode()?.getText() || "unknown";
83
+ const isOptional = property.hasQuestionToken();
84
+ const { description, defaultValue, jsDocTags } = extractJSDocInfo(property);
85
+ props.push({
86
+ name: propName,
87
+ type: propType,
88
+ optional: isOptional,
89
+ description,
90
+ defaultValue,
91
+ jsDocTags: jsDocTags.length > 0 ? jsDocTags : void 0
92
+ });
93
+ }
94
+ results.push({ name: interfaceName, props });
95
+ }
96
+ const typeAliases = sourceFile.getTypeAliases();
97
+ for (const typeAlias of typeAliases) {
98
+ const typeName = typeAlias.getName();
99
+ const typeNode = typeAlias.getTypeNode();
100
+ if (typeNode && typeNode.getKind() === SyntaxKind.TypeLiteral) {
101
+ const props = [];
102
+ const typeLiteral = typeNode.asKindOrThrow(SyntaxKind.TypeLiteral);
103
+ const members = typeLiteral.getMembers();
104
+ for (const member of members) {
105
+ if (member.getKind() === SyntaxKind.PropertySignature) {
106
+ const propSig = member.asKindOrThrow(SyntaxKind.PropertySignature);
107
+ const propName = propSig.getName();
108
+ const propType = propSig.getTypeNode()?.getText() || "unknown";
109
+ const isOptional = propSig.hasQuestionToken();
110
+ const { description, defaultValue, jsDocTags } = extractJSDocInfo(propSig);
111
+ props.push({
112
+ name: propName,
113
+ type: propType,
114
+ optional: isOptional,
115
+ description,
116
+ defaultValue,
117
+ jsDocTags: jsDocTags.length > 0 ? jsDocTags : void 0
118
+ });
119
+ }
120
+ }
121
+ results.push({ name: typeName, props });
122
+ } else {
123
+ console.log(
124
+ `Type alias ${typeName} is not a type literal, kind: ${typeNode?.getKindName()}`
125
+ );
126
+ }
127
+ }
128
+ return results;
129
+ },
130
+ catch: (error) => {
131
+ console.error("Error parsing component props:", error);
132
+ return new ComponentRegistryError({
133
+ message: "Failed to parse component props",
134
+ cause: error
135
+ });
136
+ }
137
+ })
138
+ ),
139
+ extractPropsFromAstroFile: (astroFileContent) => pipeLogger("studiocms/componentRegistry/PropsParser.extractPropsFromAstroFile")(
140
+ Effect.try({
141
+ try: () => {
142
+ const frontmatterMatch = astroFileContent.match(/^---\s*\n([\s\S]*?)\n---/m);
143
+ if (!frontmatterMatch) {
144
+ throw new Error("No frontmatter found in Astro file");
145
+ }
146
+ const frontmatter = frontmatterMatch[1];
147
+ const interfaceMatch = frontmatter.match(
148
+ /((?:export\s+)?interface\s+Props\s*\{[\s\S]*?\n\})/m
149
+ );
150
+ if (interfaceMatch) {
151
+ const propsDefinition2 = interfaceMatch[0].replace(/^export\s+/, "");
152
+ return propsDefinition2;
153
+ }
154
+ const typeMatch = frontmatter.match(
155
+ /((?:export\s+)?type\s+Props\s*=\s*\{[\s\S]*?\n\})/m
156
+ );
157
+ if (typeMatch) {
158
+ const propsDefinition2 = typeMatch[0].replace(/^export\s+/, "");
159
+ return propsDefinition2;
160
+ }
161
+ const propsStart = frontmatter.search(
162
+ /(?:export\s+)?(?:interface|type)\s+Props\s*[={]/
163
+ );
164
+ if (propsStart === -1) {
165
+ throw new Error("No Props interface or type found in frontmatter");
166
+ }
167
+ const propsSubstring = frontmatter.substring(propsStart);
168
+ let braceCount = 0;
169
+ let inString = false;
170
+ let stringChar = "";
171
+ let i = 0;
172
+ for (i = 0; i < propsSubstring.length; i++) {
173
+ const char = propsSubstring[i];
174
+ const prevChar = i > 0 ? propsSubstring[i - 1] : "";
175
+ if ((char === '"' || char === "'" || char === "`") && prevChar !== "\\") {
176
+ if (!inString) {
177
+ inString = true;
178
+ stringChar = char;
179
+ } else if (char === stringChar) {
180
+ inString = false;
181
+ stringChar = "";
182
+ }
183
+ }
184
+ if (!inString) {
185
+ if (char === "{") {
186
+ braceCount++;
187
+ } else if (char === "}") {
188
+ braceCount--;
189
+ if (braceCount === 0) {
190
+ break;
191
+ }
192
+ }
193
+ }
194
+ }
195
+ const propsDefinition = propsSubstring.substring(0, i + 1).replace(/^export\s+/, "");
196
+ return propsDefinition;
197
+ },
198
+ catch: (error) => {
199
+ console.error("Error extracting props from Astro file:", error);
200
+ return new FileParseError({
201
+ filePath: "astro-content",
202
+ message: error instanceof Error ? error.message : "Failed to extract props from Astro file",
203
+ cause: error
204
+ });
205
+ }
206
+ })
207
+ )
208
+ };
209
+ })
210
+ }) {
211
+ }
212
+ export {
213
+ PropsParser
214
+ };
@@ -0,0 +1,46 @@
1
+ import * as FileSystem from '@effect/platform/FileSystem';
2
+ import * as Path from '@effect/platform/Path';
3
+ import { Effect } from '../effect.js';
4
+ import { ComponentNotFoundError, ComponentRegistryError, FileParseError } from './errors.js';
5
+ import { PropsParser } from './PropsParser.js';
6
+ import type { AstroComponentProps } from './types.js';
7
+ declare const ComponentRegistry_base: Effect.Service.Class<ComponentRegistry, "ComponentRegistry", {
8
+ readonly dependencies: readonly [import("effect/Layer").Layer<PropsParser, never, never>, import("effect/Layer").Layer<Path.Path, never, never>, import("effect/Layer").Layer<FileSystem.FileSystem, never, never>];
9
+ readonly effect: Effect.Effect<{
10
+ registerComponentFromFile: (filePath: string, componentName?: string) => Effect.Effect<void, ComponentRegistryError | FileParseError | import("@effect/platform/Error").PlatformError, never>;
11
+ getAllComponents: () => Effect.Effect<Map<string, AstroComponentProps>, never, never>;
12
+ getComponentProps: (componentName: string) => Effect.Effect<AstroComponentProps | undefined, ComponentNotFoundError, never>;
13
+ validateProps: (componentName: string, props: Record<string, unknown>) => Effect.Effect<{
14
+ valid: boolean;
15
+ errors: string[];
16
+ }, ComponentNotFoundError, never>;
17
+ }, never, never>;
18
+ }>;
19
+ /**
20
+ * A service class for registering, retrieving, and validating Astro component props.
21
+ *
22
+ * The `ComponentRegistry` provides methods to:
23
+ * - Register a component and its props from an Astro file.
24
+ * - Retrieve the props definition for a registered component.
25
+ * - List all registered components and their props.
26
+ * - Validate a set of props against a registered component's prop definition.
27
+ *
28
+ * Dependencies:
29
+ * - `PropsParser.Default`: Used to extract and parse props from Astro files.
30
+ * - `Path.layer`: Used for file path operations.
31
+ * - `NodeFileSystem.layer`: Used for reading files from the filesystem.
32
+ *
33
+ * Methods:
34
+ * - `registerComponentFromFile(filePath: string, componentName?: string)`: Registers a component by reading and parsing its props from the specified Astro file.
35
+ * - `getComponentProps(componentName: string)`: Retrieves the props definition for the specified component.
36
+ * - `getAllComponents()`: Returns a map of all registered components and their props.
37
+ * - `validateProps(componentName: string, props: Record<string, unknown>)`: Validates the provided props against the registered component's prop definition, checking for missing required props and unknown props.
38
+ *
39
+ * Errors:
40
+ * - Throws `FileParseError` if the Astro file cannot be parsed.
41
+ * - Throws `ComponentRegistryError` if registration fails.
42
+ * - Throws `ComponentNotFoundError` if a requested component is not registered.
43
+ */
44
+ export declare class ComponentRegistry extends ComponentRegistry_base {
45
+ }
46
+ export {};
@@ -0,0 +1,79 @@
1
+ import * as FileSystem from "@effect/platform/FileSystem";
2
+ import * as Path from "@effect/platform/Path";
3
+ import * as NodeFileSystem from "@effect/platform-node/NodeFileSystem";
4
+ import { Effect, genLogger } from "../effect.js";
5
+ import { ComponentNotFoundError, ComponentRegistryError, FileParseError } from "./errors.js";
6
+ import { PropsParser } from "./PropsParser.js";
7
+ class ComponentRegistry extends Effect.Service()("ComponentRegistry", {
8
+ dependencies: [PropsParser.Default, Path.layer, NodeFileSystem.layer],
9
+ effect: genLogger("studiocms/componentRegistry/Registry")(function* () {
10
+ const parser = yield* PropsParser;
11
+ const fs = yield* FileSystem.FileSystem;
12
+ const path = yield* Path.Path;
13
+ const components = /* @__PURE__ */ new Map();
14
+ return {
15
+ registerComponentFromFile: (filePath, componentName) => genLogger("studiocms/componentRegistry/Registry.registerComponentFromFile")(function* () {
16
+ const fileContent = yield* fs.readFileString(filePath);
17
+ const propsDefinition = yield* parser.extractPropsFromAstroFile(fileContent).pipe(
18
+ Effect.mapError(
19
+ (error) => new FileParseError({
20
+ filePath,
21
+ message: error.message,
22
+ cause: error.cause
23
+ })
24
+ )
25
+ );
26
+ const name = componentName || path.basename(filePath, path.extname(filePath));
27
+ const parsed = yield* parser.parseComponentProps(propsDefinition).pipe(
28
+ Effect.mapError(
29
+ (error) => new ComponentRegistryError({
30
+ message: `Failed to register component ${name}`,
31
+ cause: error
32
+ })
33
+ )
34
+ );
35
+ if (parsed.length > 0) {
36
+ components.set(name, parsed[0]);
37
+ }
38
+ }),
39
+ getAllComponents: () => Effect.succeed(new Map(components)),
40
+ getComponentProps: (componentName) => genLogger("studiocms/componentRegistry/Registry.getComponentProps")(function* () {
41
+ const component = components.get(componentName);
42
+ if (!component) {
43
+ yield* Effect.fail(new ComponentNotFoundError({ componentName }));
44
+ }
45
+ return component;
46
+ }),
47
+ validateProps: (componentName, props) => genLogger("studiocms/componentRegistry/Registry.validateProps")(function* () {
48
+ const component = components.get(componentName);
49
+ if (!component) {
50
+ yield* Effect.fail(new ComponentNotFoundError({ componentName }));
51
+ }
52
+ const errors = [];
53
+ const providedProps = new Set(Object.keys(props));
54
+ if (component) {
55
+ for (const prop of component.props) {
56
+ if (!prop.optional && !providedProps.has(prop.name)) {
57
+ errors.push(`Required prop "${prop.name}" is missing`);
58
+ }
59
+ }
60
+ const validPropNames = new Set(component.props.map((p) => p.name));
61
+ for (const propName of providedProps) {
62
+ if (!validPropNames.has(propName)) {
63
+ errors.push(`Unknown prop "${propName}"`);
64
+ }
65
+ }
66
+ }
67
+ return { valid: errors.length === 0, errors };
68
+ })
69
+ };
70
+ }).pipe(
71
+ Effect.provide(PropsParser.Default),
72
+ Effect.provide(Path.layer),
73
+ Effect.provide(NodeFileSystem.layer)
74
+ )
75
+ }) {
76
+ }
77
+ export {
78
+ ComponentRegistry
79
+ };
@@ -0,0 +1,67 @@
1
+ declare const ComponentRegistryError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
2
+ readonly _tag: "ComponentRegistryError";
3
+ } & Readonly<A>;
4
+ /**
5
+ * Error class representing issues related to the component registry.
6
+ *
7
+ * @remarks
8
+ * This error extends a tagged error type with the tag `'ComponentRegistryError'`.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * throw new ComponentRegistryError({ message: "Component not found" });
13
+ * ```
14
+ *
15
+ * @property message - A descriptive error message.
16
+ * @property cause - (Optional) The underlying cause of the error, if any.
17
+ */
18
+ export declare class ComponentRegistryError extends ComponentRegistryError_base<{
19
+ readonly message: string;
20
+ readonly cause?: unknown;
21
+ }> {
22
+ }
23
+ declare const FileParseError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
24
+ readonly _tag: "FileParseError";
25
+ } & Readonly<A>;
26
+ /**
27
+ * Error thrown when a file fails to parse.
28
+ *
29
+ * @remarks
30
+ * This error extends a tagged error type with the tag 'FileParseError'.
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * throw new FileParseError({ filePath: '/path/to/file', message: 'Invalid format' });
35
+ * ```
36
+ *
37
+ * @property filePath - The path of the file that failed to parse.
38
+ * @property message - A descriptive error message.
39
+ * @property cause - (Optional) The underlying cause of the error, if available.
40
+ */
41
+ export declare class FileParseError extends FileParseError_base<{
42
+ readonly filePath: string;
43
+ readonly message: string;
44
+ readonly cause?: unknown;
45
+ }> {
46
+ }
47
+ declare const ComponentNotFoundError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
48
+ readonly _tag: "ComponentNotFoundError";
49
+ } & Readonly<A>;
50
+ /**
51
+ * Error thrown when a requested component cannot be found in the registry.
52
+ *
53
+ * @remarks
54
+ * This error extends a tagged error type with the tag 'ComponentNotFoundError'.
55
+ *
56
+ * @example
57
+ * ```typescript
58
+ * throw new ComponentNotFoundError({ componentName: 'MyComponent' });
59
+ * ```
60
+ *
61
+ * @property componentName - The name of the component that was not found.
62
+ */
63
+ export declare class ComponentNotFoundError extends ComponentNotFoundError_base<{
64
+ readonly componentName: string;
65
+ }> {
66
+ }
67
+ export {};
@@ -0,0 +1,12 @@
1
+ import { Data } from "../effect.js";
2
+ class ComponentRegistryError extends Data.TaggedError("ComponentRegistryError") {
3
+ }
4
+ class FileParseError extends Data.TaggedError("FileParseError") {
5
+ }
6
+ class ComponentNotFoundError extends Data.TaggedError("ComponentNotFoundError") {
7
+ }
8
+ export {
9
+ ComponentNotFoundError,
10
+ ComponentRegistryError,
11
+ FileParseError
12
+ };
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Options for the component registry handler.
3
+ *
4
+ * @property verbose - Enables verbose logging when set to true.
5
+ * @property name - The name associated with the registry handler.
6
+ * @property componentRegistry - An optional record mapping component names to their string identifiers.
7
+ */
8
+ type componentRegistryHandlerOptions = {
9
+ verbose: boolean;
10
+ name: string;
11
+ componentRegistry: Record<string, string> | undefined;
12
+ builtInComponents?: Record<string, string>;
13
+ };
14
+ /**
15
+ * Handles the setup and registration of components in the StudioCMS component registry during the Astro config setup phase.
16
+ *
17
+ * This utility:
18
+ * - Logs the start and progress of the registry setup.
19
+ * - Iterates over the provided component registry, validating and resolving component paths.
20
+ * - Registers valid `.astro` components in the registry.
21
+ * - Extracts and maps component props for all registered components.
22
+ * - Adds virtual imports for component keys, props, and runtime exports.
23
+ *
24
+ * @param params - The Astro integration setup parameters, including logger and config.
25
+ * @param options - Options for the handler, including the component registry, verbosity, and registry name.
26
+ * @returns An asynchronous effect that sets up the component registry and provides virtual imports for use in the project.
27
+ *
28
+ * @remarks
29
+ * - Only components with string values ending in `.astro` are registered.
30
+ * - Component keys are normalized to lowercase and hyphens are converted to underscores for safe usage.
31
+ * - Virtual imports are added for both the registry and its runtime.
32
+ */
33
+ export declare const componentRegistryHandler: import("astro-integration-kit").HookUtility<"astro:config:setup", [componentRegistryHandlerOptions], Promise<void>>;
34
+ export {};