studiocms 0.1.0-beta.10

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 (582) hide show
  1. package/CHANGELOG.md +501 -0
  2. package/LICENSE +21 -0
  3. package/README.md +59 -0
  4. package/custom-renderers/index.ts +4 -0
  5. package/custom-renderers/markdocRenderers/markdocReact-components/MarkDocReactRenderer.tsx +8 -0
  6. package/custom-renderers/markdocRenderers/markdocReact-components/MarkDocReactWrapper.astro +13 -0
  7. package/custom-renderers/markdocRenderers/markdocReact.ts +56 -0
  8. package/dist/auth.d.js +0 -0
  9. package/dist/auth.d.ts +397 -0
  10. package/dist/cli/cmds/get-turso.d.ts +1 -0
  11. package/dist/cli/cmds/get-turso.js +10 -0
  12. package/dist/cli/cmds/init/index.d.ts +4 -0
  13. package/dist/cli/cmds/init/index.js +52 -0
  14. package/dist/cli/cmds/init/steps/data/studiocmsEnv.d.ts +3 -0
  15. package/dist/cli/cmds/init/steps/data/studiocmsEnv.js +71 -0
  16. package/dist/cli/cmds/init/steps/envBuilder.d.ts +21 -0
  17. package/dist/cli/cmds/init/steps/envBuilder.js +368 -0
  18. package/dist/cli/cmds/init/steps/nextSteps.d.ts +2 -0
  19. package/dist/cli/cmds/init/steps/nextSteps.js +38 -0
  20. package/dist/cli/cmds/init.d.ts +1 -0
  21. package/dist/cli/cmds/init.js +4 -0
  22. package/dist/cli/index.d.ts +1 -0
  23. package/dist/cli/index.js +9 -0
  24. package/dist/cli/lib/commander.d.ts +39 -0
  25. package/dist/cli/lib/commander.js +87 -0
  26. package/dist/cli/lib/context.d.ts +28 -0
  27. package/dist/cli/lib/context.js +55 -0
  28. package/dist/cli/lib/pathUtil.d.ts +5 -0
  29. package/dist/cli/lib/pathUtil.js +14 -0
  30. package/dist/cli/lib/runExternal.d.ts +20 -0
  31. package/dist/cli/lib/runExternal.js +40 -0
  32. package/dist/cli/lib/seasonal.d.ts +5 -0
  33. package/dist/cli/lib/seasonal.js +88 -0
  34. package/dist/cli/lib/utils.d.ts +55 -0
  35. package/dist/cli/lib/utils.js +310 -0
  36. package/dist/cli/shared/intro.d.ts +2 -0
  37. package/dist/cli/shared/intro.js +24 -0
  38. package/dist/components/DefaultEditor.astro +138 -0
  39. package/dist/components/FormattedDate.astro +12 -0
  40. package/dist/components/Generator.astro +7 -0
  41. package/dist/components/Renderer.astro +13 -0
  42. package/dist/components/auth/OAuthButton.astro +21 -0
  43. package/dist/components/auth/OAuthButtonStack.astro +36 -0
  44. package/dist/components/auth/StaticAuthCheck.astro +20 -0
  45. package/dist/components/auth/StudioCMSLogoSVG.astro +13 -0
  46. package/dist/components/auth/oAuthButtonProviders.d.ts +8 -0
  47. package/dist/components/auth/oAuthButtonProviders.js +35 -0
  48. package/dist/components/dashboard/AstroCodeDiffsScript.astro +25 -0
  49. package/dist/components/dashboard/BaseHead.astro +41 -0
  50. package/dist/components/dashboard/Code.astro +23 -0
  51. package/dist/components/dashboard/DashboardPageHeader.astro +77 -0
  52. package/dist/components/dashboard/DoubleSidebar.astro +26 -0
  53. package/dist/components/dashboard/Footer.astro +16 -0
  54. package/dist/components/dashboard/MainSidebarContent.astro +317 -0
  55. package/dist/components/dashboard/PageHeader.astro +52 -0
  56. package/dist/components/dashboard/SidebarLink.astro +61 -0
  57. package/dist/components/dashboard/SidebarModals.astro +6 -0
  58. package/dist/components/dashboard/SidebarPluginLink.astro +45 -0
  59. package/dist/components/dashboard/SingleSidebar.astro +23 -0
  60. package/dist/components/dashboard/StudioCMSLogo.astro +12 -0
  61. package/dist/components/dashboard/ThemeManager.astro +53 -0
  62. package/dist/components/dashboard/component-scripts/TinyMDE.astro +6 -0
  63. package/dist/components/dashboard/component-scripts/dateTimeListener.d.ts +1 -0
  64. package/dist/components/dashboard/component-scripts/dateTimeListener.js +14 -0
  65. package/dist/components/dashboard/component-scripts/dateWithTimeAndZone.d.ts +1 -0
  66. package/dist/components/dashboard/component-scripts/dateWithTimeAndZone.js +12 -0
  67. package/dist/components/dashboard/component-scripts/makeClientRoutable.d.ts +1 -0
  68. package/dist/components/dashboard/component-scripts/makeClientRoutable.js +9 -0
  69. package/dist/components/dashboard/component-scripts/timeAgo.d.ts +1 -0
  70. package/dist/components/dashboard/component-scripts/timeAgo.js +21 -0
  71. package/dist/components/dashboard/islands/LoginChecker.astro +52 -0
  72. package/dist/components/dashboard/islands/configuration/ConfigForm.astro +317 -0
  73. package/dist/components/dashboard/islands/configuration/LightVsDark.astro +67 -0
  74. package/dist/components/dashboard/islands/content-mgmt/CreateFolder.astro +118 -0
  75. package/dist/components/dashboard/islands/content-mgmt/CreatePage.astro +380 -0
  76. package/dist/components/dashboard/islands/content-mgmt/EditFolder.astro +138 -0
  77. package/dist/components/dashboard/islands/content-mgmt/EditPage.astro +432 -0
  78. package/dist/components/dashboard/islands/content-mgmt/InnerSidebarElement.astro +299 -0
  79. package/dist/components/dashboard/islands/content-mgmt/PageHeader.astro +455 -0
  80. package/dist/components/dashboard/islands/content-mgmt/PageList.astro +49 -0
  81. package/dist/components/dashboard/islands/content-mgmt/PluginFields.astro +29 -0
  82. package/dist/components/dashboard/islands/content-mgmt/TreeRenderer.astro +75 -0
  83. package/dist/components/dashboard/islands/content-mgmt/TreeSidebarFolder.astro +53 -0
  84. package/dist/components/dashboard/islands/content-mgmt/TreeSidebarLink.astro +51 -0
  85. package/dist/components/dashboard/islands/content-mgmt/runtime.d.ts +10 -0
  86. package/dist/components/dashboard/islands/content-mgmt/runtime.js +33 -0
  87. package/dist/components/dashboard/islands/content-mgmt/shared.d.ts +27 -0
  88. package/dist/components/dashboard/islands/content-mgmt/shared.js +31 -0
  89. package/dist/components/dashboard/islands/dashboard/DashboardGrid.astro +39 -0
  90. package/dist/components/dashboard/islands/dashboard/DashboardGridItem.astro +34 -0
  91. package/dist/components/dashboard/islands/dashboard/Test.astro +5 -0
  92. package/dist/components/dashboard/islands/dashboard/UserName.astro +6 -0
  93. package/dist/components/dashboard/islands/dashboard/shared.d.ts +2 -0
  94. package/dist/components/dashboard/islands/dashboard/shared.js +0 -0
  95. package/dist/components/dashboard/islands/plugins/SettingsRenderer.astro +29 -0
  96. package/dist/components/dashboard/islands/profile/APITokens.astro +306 -0
  97. package/dist/components/dashboard/islands/profile/BasicInfo.astro +140 -0
  98. package/dist/components/dashboard/islands/profile/BasicInfoFallback.astro +43 -0
  99. package/dist/components/dashboard/islands/profile/SocialSignin.astro +181 -0
  100. package/dist/components/dashboard/islands/profile/SocialSigninFallback.astro +83 -0
  101. package/dist/components/dashboard/islands/profile/UpdatePassword.astro +166 -0
  102. package/dist/components/dashboard/islands/profile/UpdatePasswordFallback.astro +47 -0
  103. package/dist/components/dashboard/islands/profile/oAuthButtonProviders.d.ts +8 -0
  104. package/dist/components/dashboard/islands/profile/oAuthButtonProviders.js +35 -0
  105. package/dist/components/dashboard/islands/sidebar/UserAccount.astro +23 -0
  106. package/dist/components/dashboard/islands/sidebar/VersionCheck.astro +127 -0
  107. package/dist/components/dashboard/islands/sidebar/VersionCheckChangelog.astro +107 -0
  108. package/dist/components/dashboard/islands/user-mgmt/InnerSidebarElement.astro +348 -0
  109. package/dist/components/dashboard/islands/user-mgmt/RankCheck.astro +49 -0
  110. package/dist/components/dashboard/islands/user-mgmt/SocialSignin.astro +109 -0
  111. package/dist/components/dashboard/islands/user-mgmt/UserListItem.astro +60 -0
  112. package/dist/components/dashboard/sidebar-modals/UserManagementModals.astro +103 -0
  113. package/dist/components/dashboard/sidebar-modals/VersionModal.astro +267 -0
  114. package/dist/components/dashboard/sidebarConfig.d.ts +32 -0
  115. package/dist/components/dashboard/sidebarConfig.js +88 -0
  116. package/dist/components/default-grid-items/Recently-created-pages.astro +91 -0
  117. package/dist/components/default-grid-items/Recently-signed-up.astro +71 -0
  118. package/dist/components/default-grid-items/Recently-updated-pages.astro +96 -0
  119. package/dist/components/default-grid-items/Totals.astro +107 -0
  120. package/dist/components/default-grid-items/utils.d.ts +17 -0
  121. package/dist/components/default-grid-items/utils.js +26 -0
  122. package/dist/components/image/CustomImage.astro +90 -0
  123. package/dist/components/user-quick-tools.d.ts +42 -0
  124. package/dist/components/user-quick-tools.js +312 -0
  125. package/dist/config.d.ts +3 -0
  126. package/dist/config.js +4 -0
  127. package/dist/consts.d.ts +61 -0
  128. package/dist/consts.js +39 -0
  129. package/dist/core.d.js +0 -0
  130. package/dist/core.d.ts +226 -0
  131. package/dist/db/config.d.ts +4 -0
  132. package/dist/db/config.js +6 -0
  133. package/dist/db/tables.js +168 -0
  134. package/dist/errors.d.ts +19 -0
  135. package/dist/errors.js +11 -0
  136. package/dist/index.d.ts +152 -0
  137. package/dist/index.js +1179 -0
  138. package/dist/layouts/auth/AuthLayout.astro +74 -0
  139. package/dist/layouts/auth/FallbackCanvas.astro +123 -0
  140. package/dist/layouts/auth/ThemeManager.astro +53 -0
  141. package/dist/layouts/auth/ThreeCanvasLoader.astro +18 -0
  142. package/dist/layouts/dashboard/Layout.astro +64 -0
  143. package/dist/lib/auth/encryption.d.ts +30 -0
  144. package/dist/lib/auth/encryption.js +39 -0
  145. package/dist/lib/auth/password.d.ts +27 -0
  146. package/dist/lib/auth/password.js +42 -0
  147. package/dist/lib/auth/rate-limit.d.ts +136 -0
  148. package/dist/lib/auth/rate-limit.js +214 -0
  149. package/dist/lib/auth/session.d.ts +85 -0
  150. package/dist/lib/auth/session.js +93 -0
  151. package/dist/lib/auth/types.d.ts +83 -0
  152. package/dist/lib/auth/types.js +0 -0
  153. package/dist/lib/auth/user.d.ts +148 -0
  154. package/dist/lib/auth/user.js +133 -0
  155. package/dist/lib/dashboardGrid.d.ts +119 -0
  156. package/dist/lib/dashboardGrid.js +0 -0
  157. package/dist/lib/dynamic-sitemap/index.d.ts +42 -0
  158. package/dist/lib/dynamic-sitemap/index.js +45 -0
  159. package/dist/lib/dynamic-sitemap/sitemap-index.xml.d.ts +8 -0
  160. package/dist/lib/dynamic-sitemap/sitemap-index.xml.js +20 -0
  161. package/dist/lib/dynamic-sitemap/sitemap-index.xml.ts +45 -0
  162. package/dist/lib/head.d.ts +9 -0
  163. package/dist/lib/head.js +65 -0
  164. package/dist/lib/headDefaults.d.ts +18 -0
  165. package/dist/lib/headDefaults.js +75 -0
  166. package/dist/lib/i18n/LanguageSelector.astro +114 -0
  167. package/dist/lib/i18n/client.d.ts +591 -0
  168. package/dist/lib/i18n/client.js +83 -0
  169. package/dist/lib/i18n/config.d.ts +16 -0
  170. package/dist/lib/i18n/config.js +8 -0
  171. package/dist/lib/i18n/index.d.ts +578 -0
  172. package/dist/lib/i18n/index.js +63 -0
  173. package/dist/lib/i18n/translations/de.json +64 -0
  174. package/dist/lib/i18n/translations/en-us.json +238 -0
  175. package/dist/lib/i18n/translations/es.json +64 -0
  176. package/dist/lib/i18n/translations/fr.json +64 -0
  177. package/dist/lib/index.d.ts +7 -0
  178. package/dist/lib/index.js +7 -0
  179. package/dist/lib/jsonUtils.d.ts +2 -0
  180. package/dist/lib/jsonUtils.js +11 -0
  181. package/dist/lib/makeAPIRoute.d.ts +45 -0
  182. package/dist/lib/makeAPIRoute.js +16 -0
  183. package/dist/lib/makePublicRoute.d.ts +7 -0
  184. package/dist/lib/makePublicRoute.js +6 -0
  185. package/dist/lib/pathGenerators.d.ts +20 -0
  186. package/dist/lib/pathGenerators.js +66 -0
  187. package/dist/lib/plugins/dashboard-pages.d.ts +71 -0
  188. package/dist/lib/plugins/dashboard-pages.js +11 -0
  189. package/dist/lib/plugins/frontend-navigation.d.ts +18 -0
  190. package/dist/lib/plugins/frontend-navigation.js +39 -0
  191. package/dist/lib/plugins/index.d.ts +2 -0
  192. package/dist/lib/plugins/index.js +2 -0
  193. package/dist/lib/removeLeadingTrailingSlashes.d.ts +7 -0
  194. package/dist/lib/removeLeadingTrailingSlashes.js +13 -0
  195. package/dist/lib/renderer/astro-remark.d.ts +13 -0
  196. package/dist/lib/renderer/astro-remark.js +11 -0
  197. package/dist/lib/renderer/contentRenderer.d.ts +13 -0
  198. package/dist/lib/renderer/contentRenderer.js +31 -0
  199. package/dist/lib/renderer/errors.d.ts +5 -0
  200. package/dist/lib/renderer/errors.js +25 -0
  201. package/dist/lib/renderer/markdoc-renderers/markdocHTML.d.ts +3 -0
  202. package/dist/lib/renderer/markdoc-renderers/markdocHTML.js +14 -0
  203. package/dist/lib/renderer/markdoc-renderers/markdocReactStatic.d.ts +3 -0
  204. package/dist/lib/renderer/markdoc-renderers/markdocReactStatic.js +14 -0
  205. package/dist/lib/renderer/markdoc.d.ts +11 -0
  206. package/dist/lib/renderer/markdoc.js +28 -0
  207. package/dist/lib/renderer/mdx.d.ts +10 -0
  208. package/dist/lib/renderer/mdx.js +37 -0
  209. package/dist/lib/renderer/runtime.d.ts +8 -0
  210. package/dist/lib/renderer/runtime.js +30 -0
  211. package/dist/lib/renderer/shared.d.ts +15 -0
  212. package/dist/lib/renderer/shared.js +13 -0
  213. package/dist/lib/renderer/studiocms.d.ts +11 -0
  214. package/dist/lib/renderer/studiocms.js +22 -0
  215. package/dist/lib/renderer/types.d.ts +12 -0
  216. package/dist/lib/renderer/types.js +0 -0
  217. package/dist/lib/robots/core.d.ts +24 -0
  218. package/dist/lib/robots/core.js +187 -0
  219. package/dist/lib/robots/index.d.ts +11 -0
  220. package/dist/lib/robots/index.js +47 -0
  221. package/dist/lib/robots/types.d.ts +185 -0
  222. package/dist/lib/robots/types.js +0 -0
  223. package/dist/lib/robots/utils.d.ts +22 -0
  224. package/dist/lib/robots/utils.js +22 -0
  225. package/dist/lib/routeMap.d.ts +257 -0
  226. package/dist/lib/routeMap.js +249 -0
  227. package/dist/lib/urlGen.d.ts +11 -0
  228. package/dist/lib/urlGen.js +26 -0
  229. package/dist/lib/webVitals/checkForWebVitalsPlugin.d.ts +18 -0
  230. package/dist/lib/webVitals/checkForWebVitalsPlugin.js +82 -0
  231. package/dist/lib/webVitals/consts.d.ts +240 -0
  232. package/dist/lib/webVitals/consts.js +40 -0
  233. package/dist/lib/webVitals/dashboard-grid-items/CoreVitals.astro +66 -0
  234. package/dist/lib/webVitals/dashboard-grid-items/MetricCard.astro +24 -0
  235. package/dist/lib/webVitals/dashboard-grid-items/SummaryCard.astro +56 -0
  236. package/dist/lib/webVitals/dashboard-grid-items/metric.css +103 -0
  237. package/dist/lib/webVitals/dashboard-grid-items/shared.d.ts +29 -0
  238. package/dist/lib/webVitals/dashboard-grid-items/shared.js +35 -0
  239. package/dist/lib/webVitals/pages/analytics/body.astro +186 -0
  240. package/dist/lib/webVitals/pages/analytics/header.astro +42 -0
  241. package/dist/lib/webVitals/schemas.d.ts +78 -0
  242. package/dist/lib/webVitals/schemas.js +37 -0
  243. package/dist/lib/webVitals/types.d.ts +156 -0
  244. package/dist/lib/webVitals/types.js +0 -0
  245. package/dist/lib/webVitals/utils/buildDataObject.d.ts +8 -0
  246. package/dist/lib/webVitals/utils/buildDataObject.js +28 -0
  247. package/dist/lib/webVitals/utils/buildPageRouteDataObject.d.ts +15 -0
  248. package/dist/lib/webVitals/utils/buildPageRouteDataObject.js +70 -0
  249. package/dist/lib/webVitals/utils/buildPerPageDataObject.d.ts +23 -0
  250. package/dist/lib/webVitals/utils/buildPerPageDataObject.js +209 -0
  251. package/dist/lib/webVitals/utils/checkDate.d.ts +5 -0
  252. package/dist/lib/webVitals/utils/checkDate.js +19 -0
  253. package/dist/lib/webVitals/utils/webVitalsUtils.d.ts +24 -0
  254. package/dist/lib/webVitals/utils/webVitalsUtils.js +234 -0
  255. package/dist/lib/webVitals/webVital.d.ts +20 -0
  256. package/dist/lib/webVitals/webVital.js +40 -0
  257. package/dist/lib/webVitals/webVitalsRouteSummary.d.ts +19 -0
  258. package/dist/lib/webVitals/webVitalsRouteSummary.js +59 -0
  259. package/dist/lib/webVitals/webVitalsSummary.d.ts +19 -0
  260. package/dist/lib/webVitals/webVitalsSummary.js +49 -0
  261. package/dist/plugins.d.ts +2 -0
  262. package/dist/plugins.js +6 -0
  263. package/dist/renderer.d.js +0 -0
  264. package/dist/renderer.d.ts +23 -0
  265. package/dist/routes/api/render.astro +25 -0
  266. package/dist/routes/auth/api/auth0/callback.d.ts +4 -0
  267. package/dist/routes/auth/api/auth0/callback.js +117 -0
  268. package/dist/routes/auth/api/auth0/index.d.ts +4 -0
  269. package/dist/routes/auth/api/auth0/index.js +36 -0
  270. package/dist/routes/auth/api/auth0/shared.d.ts +13 -0
  271. package/dist/routes/auth/api/auth0/shared.js +24 -0
  272. package/dist/routes/auth/api/discord/callback.d.ts +4 -0
  273. package/dist/routes/auth/api/discord/callback.js +112 -0
  274. package/dist/routes/auth/api/discord/index.d.ts +4 -0
  275. package/dist/routes/auth/api/discord/index.js +36 -0
  276. package/dist/routes/auth/api/discord/shared.d.ts +12 -0
  277. package/dist/routes/auth/api/discord/shared.js +17 -0
  278. package/dist/routes/auth/api/github/callback.d.ts +4 -0
  279. package/dist/routes/auth/api/github/callback.js +112 -0
  280. package/dist/routes/auth/api/github/index.d.ts +4 -0
  281. package/dist/routes/auth/api/github/index.js +36 -0
  282. package/dist/routes/auth/api/github/shared.d.ts +13 -0
  283. package/dist/routes/auth/api/github/shared.js +14 -0
  284. package/dist/routes/auth/api/google/callback.d.ts +4 -0
  285. package/dist/routes/auth/api/google/callback.js +115 -0
  286. package/dist/routes/auth/api/google/index.d.ts +4 -0
  287. package/dist/routes/auth/api/google/index.js +38 -0
  288. package/dist/routes/auth/api/google/shared.d.ts +12 -0
  289. package/dist/routes/auth/api/google/shared.js +19 -0
  290. package/dist/routes/auth/api/login.d.ts +4 -0
  291. package/dist/routes/auth/api/login.js +46 -0
  292. package/dist/routes/auth/api/logout.d.ts +5 -0
  293. package/dist/routes/auth/api/logout.js +55 -0
  294. package/dist/routes/auth/api/register.d.ts +4 -0
  295. package/dist/routes/auth/api/register.js +64 -0
  296. package/dist/routes/auth/api/shared.d.ts +2 -0
  297. package/dist/routes/auth/api/shared.js +21 -0
  298. package/dist/routes/auth/login.astro +118 -0
  299. package/dist/routes/auth/logout.astro +28 -0
  300. package/dist/routes/auth/signup.astro +124 -0
  301. package/dist/routes/dashboard/[...pluginPage].astro +88 -0
  302. package/dist/routes/dashboard/configuration.astro +61 -0
  303. package/dist/routes/dashboard/content-management/createfolder.astro +83 -0
  304. package/dist/routes/dashboard/content-management/createpage.astro +86 -0
  305. package/dist/routes/dashboard/content-management/diff.astro +135 -0
  306. package/dist/routes/dashboard/content-management/editfolder.astro +67 -0
  307. package/dist/routes/dashboard/content-management/editpage.astro +71 -0
  308. package/dist/routes/dashboard/content-management/index.astro +91 -0
  309. package/dist/routes/dashboard/index.astro +56 -0
  310. package/dist/routes/dashboard/password-reset.astro +206 -0
  311. package/dist/routes/dashboard/plugins/[plugin].astro +104 -0
  312. package/dist/routes/dashboard/profile.astro +87 -0
  313. package/dist/routes/dashboard/studiocms_api/dashboard/api-tokens.d.ts +5 -0
  314. package/dist/routes/dashboard/studiocms_api/dashboard/api-tokens.js +90 -0
  315. package/dist/routes/dashboard/studiocms_api/dashboard/config.d.ts +4 -0
  316. package/dist/routes/dashboard/studiocms_api/dashboard/config.js +63 -0
  317. package/dist/routes/dashboard/studiocms_api/dashboard/content/folder.d.ts +6 -0
  318. package/dist/routes/dashboard/studiocms_api/dashboard/content/folder.js +121 -0
  319. package/dist/routes/dashboard/studiocms_api/dashboard/content/page.d.ts +6 -0
  320. package/dist/routes/dashboard/studiocms_api/dashboard/content/page.js +258 -0
  321. package/dist/routes/dashboard/studiocms_api/dashboard/create-reset-link.d.ts +4 -0
  322. package/dist/routes/dashboard/studiocms_api/dashboard/create-reset-link.js +59 -0
  323. package/dist/routes/dashboard/studiocms_api/dashboard/create-user-invite.d.ts +4 -0
  324. package/dist/routes/dashboard/studiocms_api/dashboard/create-user-invite.js +105 -0
  325. package/dist/routes/dashboard/studiocms_api/dashboard/create-user.d.ts +4 -0
  326. package/dist/routes/dashboard/studiocms_api/dashboard/create-user.js +100 -0
  327. package/dist/routes/dashboard/studiocms_api/dashboard/partials/Editor.astro +61 -0
  328. package/dist/routes/dashboard/studiocms_api/dashboard/partials/LiveRender.astro +30 -0
  329. package/dist/routes/dashboard/studiocms_api/dashboard/partials/UserListItems.astro +39 -0
  330. package/dist/routes/dashboard/studiocms_api/dashboard/plugins/[plugin].d.ts +2 -0
  331. package/dist/routes/dashboard/studiocms_api/dashboard/plugins/[plugin].js +32 -0
  332. package/dist/routes/dashboard/studiocms_api/dashboard/profile.d.ts +4 -0
  333. package/dist/routes/dashboard/studiocms_api/dashboard/profile.js +130 -0
  334. package/dist/routes/dashboard/studiocms_api/dashboard/reset-password.d.ts +4 -0
  335. package/dist/routes/dashboard/studiocms_api/dashboard/reset-password.js +105 -0
  336. package/dist/routes/dashboard/studiocms_api/dashboard/search-list.d.ts +4 -0
  337. package/dist/routes/dashboard/studiocms_api/dashboard/search-list.js +55 -0
  338. package/dist/routes/dashboard/studiocms_api/dashboard/users.d.ts +5 -0
  339. package/dist/routes/dashboard/studiocms_api/dashboard/users.js +92 -0
  340. package/dist/routes/dashboard/studiocms_api/dashboard/verify-session.d.ts +2 -0
  341. package/dist/routes/dashboard/studiocms_api/dashboard/verify-session.js +72 -0
  342. package/dist/routes/dashboard/user-management/edit.astro +631 -0
  343. package/dist/routes/dashboard/user-management/index.astro +103 -0
  344. package/dist/routes/error-pages/404.astro +66 -0
  345. package/dist/routes/firstTimeSetupRoutes/1-start.astro +253 -0
  346. package/dist/routes/firstTimeSetupRoutes/2-next.astro +208 -0
  347. package/dist/routes/firstTimeSetupRoutes/3-done.astro +95 -0
  348. package/dist/routes/firstTimeSetupRoutes/api/step-1.d.ts +2 -0
  349. package/dist/routes/firstTimeSetupRoutes/api/step-1.js +126 -0
  350. package/dist/routes/firstTimeSetupRoutes/api/step-2.d.ts +2 -0
  351. package/dist/routes/firstTimeSetupRoutes/api/step-2.js +110 -0
  352. package/dist/routes/firstTimeSetupRoutes/components/Layout.astro +41 -0
  353. package/dist/routes/firstTimeSetupRoutes/components/PageHeader.astro +60 -0
  354. package/dist/routes/firstTimeSetupRoutes/components/TabItem.astro +44 -0
  355. package/dist/routes/firstTimeSetupRoutes/components/Tabs.astro +170 -0
  356. package/dist/routes/firstTimeSetupRoutes/snippets/opt1-astro.config.diff +14 -0
  357. package/dist/routes/firstTimeSetupRoutes/snippets/opt2-astro.config.diff +9 -0
  358. package/dist/routes/firstTimeSetupRoutes/snippets/opt2-studiocms.config.diff +5 -0
  359. package/dist/routes/rest/utils/auth-token.d.ts +17 -0
  360. package/dist/routes/rest/utils/auth-token.js +31 -0
  361. package/dist/routes/rest/v1/folders/[id].d.ts +6 -0
  362. package/dist/routes/rest/v1/folders/[id].js +106 -0
  363. package/dist/routes/rest/v1/folders/index.d.ts +5 -0
  364. package/dist/routes/rest/v1/folders/index.js +88 -0
  365. package/dist/routes/rest/v1/pages/[id]/history/[diffid].d.ts +4 -0
  366. package/dist/routes/rest/v1/pages/[id]/history/[diffid].js +55 -0
  367. package/dist/routes/rest/v1/pages/[id]/history/index.d.ts +4 -0
  368. package/dist/routes/rest/v1/pages/[id]/history/index.js +61 -0
  369. package/dist/routes/rest/v1/pages/[id]/index.d.ts +6 -0
  370. package/dist/routes/rest/v1/pages/[id]/index.js +165 -0
  371. package/dist/routes/rest/v1/pages/index.d.ts +5 -0
  372. package/dist/routes/rest/v1/pages/index.js +113 -0
  373. package/dist/routes/rest/v1/public/folders/[id].d.ts +4 -0
  374. package/dist/routes/rest/v1/public/folders/[id].js +43 -0
  375. package/dist/routes/rest/v1/public/folders/index.d.ts +4 -0
  376. package/dist/routes/rest/v1/public/folders/index.js +49 -0
  377. package/dist/routes/rest/v1/public/pages/[id].d.ts +4 -0
  378. package/dist/routes/rest/v1/public/pages/[id].js +46 -0
  379. package/dist/routes/rest/v1/public/pages/index.d.ts +4 -0
  380. package/dist/routes/rest/v1/public/pages/index.js +61 -0
  381. package/dist/routes/rest/v1/settings/index.d.ts +5 -0
  382. package/dist/routes/rest/v1/settings/index.js +75 -0
  383. package/dist/routes/rest/v1/users/[id].d.ts +6 -0
  384. package/dist/routes/rest/v1/users/[id].js +212 -0
  385. package/dist/routes/rest/v1/users/index.d.ts +5 -0
  386. package/dist/routes/rest/v1/users/index.js +138 -0
  387. package/dist/routes/sdk/fallback-list-pages.json.d.ts +2 -0
  388. package/dist/routes/sdk/fallback-list-pages.json.js +19 -0
  389. package/dist/routes/sdk/fallback-list-pages.json.ts +22 -0
  390. package/dist/routes/sdk/full-changelog.json.d.ts +16 -0
  391. package/dist/routes/sdk/full-changelog.json.js +170 -0
  392. package/dist/routes/sdk/full-changelog.json.ts +224 -0
  393. package/dist/routes/sdk/list-pages.d.ts +4 -0
  394. package/dist/routes/sdk/list-pages.js +34 -0
  395. package/dist/routes/sdk/update-latest-version-cache.d.ts +4 -0
  396. package/dist/routes/sdk/update-latest-version-cache.js +41 -0
  397. package/dist/runtime/AstroComponentProxy.d.ts +29 -0
  398. package/dist/runtime/AstroComponentProxy.js +47 -0
  399. package/dist/runtime/decoder/decode-codepoint.d.ts +18 -0
  400. package/dist/runtime/decoder/decode-codepoint.js +58 -0
  401. package/dist/runtime/decoder/decode-data-html.d.ts +1 -0
  402. package/dist/runtime/decoder/decode-data-html.js +7 -0
  403. package/dist/runtime/decoder/decode-data-xml.d.ts +1 -0
  404. package/dist/runtime/decoder/decode-data-xml.js +7 -0
  405. package/dist/runtime/decoder/index.d.ts +34 -0
  406. package/dist/runtime/decoder/index.js +18 -0
  407. package/dist/runtime/decoder/util.d.ts +208 -0
  408. package/dist/runtime/decoder/util.js +415 -0
  409. package/dist/schemas/config/auth.d.ts +175 -0
  410. package/dist/schemas/config/auth.js +65 -0
  411. package/dist/schemas/config/componentoverrides.d.ts +17 -0
  412. package/dist/schemas/config/componentoverrides.js +14 -0
  413. package/dist/schemas/config/dashboard.d.ts +154 -0
  414. package/dist/schemas/config/dashboard.js +59 -0
  415. package/dist/schemas/config/defaultFrontend.d.ts +125 -0
  416. package/dist/schemas/config/defaultFrontend.js +57 -0
  417. package/dist/schemas/config/developer.d.ts +15 -0
  418. package/dist/schemas/config/developer.js +14 -0
  419. package/dist/schemas/config/imageService.d.ts +13 -0
  420. package/dist/schemas/config/imageService.js +12 -0
  421. package/dist/schemas/config/index.d.ts +1153 -0
  422. package/dist/schemas/config/index.js +95 -0
  423. package/dist/schemas/config/integrations.d.ts +14 -0
  424. package/dist/schemas/config/integrations.js +12 -0
  425. package/dist/schemas/config/markdoc.d.ts +172 -0
  426. package/dist/schemas/config/markdoc.js +68 -0
  427. package/dist/schemas/config/mdx.d.ts +455 -0
  428. package/dist/schemas/config/mdx.js +71 -0
  429. package/dist/schemas/config/rendererConfig.d.ts +659 -0
  430. package/dist/schemas/config/rendererConfig.js +51 -0
  431. package/dist/schemas/config/sdk.d.ts +167 -0
  432. package/dist/schemas/config/sdk.js +85 -0
  433. package/dist/schemas/config/studiocms-markdown-remark.d.ts +292 -0
  434. package/dist/schemas/config/studiocms-markdown-remark.js +63 -0
  435. package/dist/schemas/index.d.ts +2 -0
  436. package/dist/schemas/index.js +2 -0
  437. package/dist/schemas/plugins/index.d.ts +7373 -0
  438. package/dist/schemas/plugins/index.js +192 -0
  439. package/dist/schemas/plugins/shared.d.ts +1752 -0
  440. package/dist/schemas/plugins/shared.js +221 -0
  441. package/dist/scripts/formListener.d.ts +16 -0
  442. package/dist/scripts/formListener.js +46 -0
  443. package/dist/scripts/three.d.ts +1 -0
  444. package/dist/scripts/three.js +278 -0
  445. package/dist/scripts/utils/fitModelToViewport.d.ts +8 -0
  446. package/dist/scripts/utils/fitModelToViewport.js +19 -0
  447. package/dist/sdk/StudioCMSVirtualCache.d.ts +283 -0
  448. package/dist/sdk/StudioCMSVirtualCache.js +685 -0
  449. package/dist/sdk/cache.d.ts +11 -0
  450. package/dist/sdk/cache.js +12 -0
  451. package/dist/sdk/core.d.ts +865 -0
  452. package/dist/sdk/core.js +1966 -0
  453. package/dist/sdk/errors.d.ts +21 -0
  454. package/dist/sdk/errors.js +11 -0
  455. package/dist/sdk/index.d.ts +371 -0
  456. package/dist/sdk/index.js +8 -0
  457. package/dist/sdk/lib/foldertree.d.ts +50 -0
  458. package/dist/sdk/lib/foldertree.js +123 -0
  459. package/dist/sdk/lib/generators.d.ts +30 -0
  460. package/dist/sdk/lib/generators.js +25 -0
  461. package/dist/sdk/lib/packages.d.ts +8 -0
  462. package/dist/sdk/lib/packages.js +14 -0
  463. package/dist/sdk/lib/parsers.d.ts +14 -0
  464. package/dist/sdk/lib/parsers.js +10 -0
  465. package/dist/sdk/lib/users.d.ts +19 -0
  466. package/dist/sdk/lib/users.js +26 -0
  467. package/dist/sdk/tables.d.ts +1198 -0
  468. package/dist/sdk/tables.js +55 -0
  469. package/dist/sdk/types/index.d.ts +175 -0
  470. package/dist/sdk/types/index.js +0 -0
  471. package/dist/sdk/types/tableDefs.d.ts +75 -0
  472. package/dist/sdk/types/tableDefs.js +0 -0
  473. package/dist/sdk/types/tsAlias.d.ts +155 -0
  474. package/dist/sdk/types/tsAlias.js +0 -0
  475. package/dist/sdk/utils/db.d.ts +5 -0
  476. package/dist/sdk/utils/db.js +15 -0
  477. package/dist/stubs/auth-lib.d.ts +2 -0
  478. package/dist/stubs/auth-lib.js +519 -0
  479. package/dist/stubs/auth-scripts.d.ts +2 -0
  480. package/dist/stubs/auth-scripts.js +29 -0
  481. package/dist/stubs/auth-utils.d.ts +2 -0
  482. package/dist/stubs/auth-utils.js +36 -0
  483. package/dist/stubs/changelog.d.ts +2 -0
  484. package/dist/stubs/changelog.js +16 -0
  485. package/dist/stubs/components.d.ts +2 -0
  486. package/dist/stubs/components.js +67 -0
  487. package/dist/stubs/core.d.ts +2 -0
  488. package/dist/stubs/core.js +49 -0
  489. package/dist/stubs/i18n-dts.d.ts +2 -0
  490. package/dist/stubs/i18n-dts.js +117 -0
  491. package/dist/stubs/images.d.ts +1 -0
  492. package/dist/stubs/images.js +30 -0
  493. package/dist/stubs/index.d.ts +1 -0
  494. package/dist/stubs/index.js +40 -0
  495. package/dist/stubs/lib.d.ts +2 -0
  496. package/dist/stubs/lib.js +123 -0
  497. package/dist/stubs/plugins.d.ts +2 -0
  498. package/dist/stubs/plugins.js +60 -0
  499. package/dist/stubs/proxy.d.ts +2 -0
  500. package/dist/stubs/proxy.js +40 -0
  501. package/dist/stubs/renderer-config.d.ts +2 -0
  502. package/dist/stubs/renderer-config.js +18 -0
  503. package/dist/stubs/renderer-markdownConfig.d.ts +2 -0
  504. package/dist/stubs/renderer-markdownConfig.js +17 -0
  505. package/dist/stubs/renderer.d.ts +2 -0
  506. package/dist/stubs/renderer.js +44 -0
  507. package/dist/stubs/sdk.d.ts +2 -0
  508. package/dist/stubs/sdk.js +202 -0
  509. package/dist/stubs/webVitals.d.ts +2 -0
  510. package/dist/stubs/webVitals.js +40 -0
  511. package/dist/styles/404.css +47 -0
  512. package/dist/styles/SyntaxFont.woff2 +0 -0
  513. package/dist/styles/authlayout.css +138 -0
  514. package/dist/styles/dashboard-base.css +493 -0
  515. package/dist/styles/dashboard-code.css +33 -0
  516. package/dist/styles/dashboard-diff.css +389 -0
  517. package/dist/styles/dashboard-tiny-mde.css +224 -0
  518. package/dist/styles/md-remark-callouts/github.css +56 -0
  519. package/dist/styles/md-remark-callouts/obsidian.css +66 -0
  520. package/dist/styles/md-remark-callouts/vitepress.css +58 -0
  521. package/dist/styles/md-remark-headings.css +48 -0
  522. package/dist/types.d.ts +43 -0
  523. package/dist/types.js +0 -0
  524. package/dist/utils/addAPIRoutes.d.ts +9 -0
  525. package/dist/utils/addAPIRoutes.js +33 -0
  526. package/dist/utils/addIntegrationArray.d.ts +24 -0
  527. package/dist/utils/addIntegrationArray.js +11 -0
  528. package/dist/utils/addIntegrationArrayWithCheck.d.ts +11 -0
  529. package/dist/utils/addIntegrationArrayWithCheck.js +24 -0
  530. package/dist/utils/astroConfigCheck.d.ts +8 -0
  531. package/dist/utils/astroConfigCheck.js +31 -0
  532. package/dist/utils/astroEnvConfig.d.ts +45 -0
  533. package/dist/utils/astroEnvConfig.js +9 -0
  534. package/dist/utils/authEnvCheck.d.ts +38 -0
  535. package/dist/utils/authEnvCheck.js +82 -0
  536. package/dist/utils/changelog.d.ts +1 -0
  537. package/dist/utils/changelog.js +53 -0
  538. package/dist/utils/changelogLoader.d.ts +15 -0
  539. package/dist/utils/changelogLoader.js +104 -0
  540. package/dist/utils/checkENV.d.ts +27 -0
  541. package/dist/utils/checkENV.js +115 -0
  542. package/dist/utils/configManager.d.ts +22 -0
  543. package/dist/utils/configManager.js +98 -0
  544. package/dist/utils/configResolver.d.ts +283 -0
  545. package/dist/utils/configResolver.js +105 -0
  546. package/dist/utils/defineStudioCMSConfig.d.ts +165 -0
  547. package/dist/utils/defineStudioCMSConfig.js +6 -0
  548. package/dist/utils/getLabelForPermissionLevel.d.ts +2 -0
  549. package/dist/utils/getLabelForPermissionLevel.js +17 -0
  550. package/dist/utils/injectRouteArray.d.ts +19 -0
  551. package/dist/utils/injectRouteArray.js +75 -0
  552. package/dist/utils/integrationLogger.d.ts +7 -0
  553. package/dist/utils/integrationLogger.js +18 -0
  554. package/dist/utils/integrations.d.ts +4 -0
  555. package/dist/utils/integrations.js +32 -0
  556. package/dist/utils/isDashboardRoute.d.ts +7 -0
  557. package/dist/utils/isDashboardRoute.js +10 -0
  558. package/dist/utils/loginBackgrounds/studiocms-blobs-dark.png +0 -0
  559. package/dist/utils/loginBackgrounds/studiocms-blobs-light.png +0 -0
  560. package/dist/utils/loginBackgrounds/studiocms-blocks-dark.png +0 -0
  561. package/dist/utils/loginBackgrounds/studiocms-blocks-light.png +0 -0
  562. package/dist/utils/loginBackgrounds/studiocms-curves-dark.png +0 -0
  563. package/dist/utils/loginBackgrounds/studiocms-curves-light.png +0 -0
  564. package/dist/utils/makePageTitle.d.ts +3 -0
  565. package/dist/utils/makePageTitle.js +7 -0
  566. package/dist/utils/pageListPackageLabel.d.ts +4 -0
  567. package/dist/utils/pageListPackageLabel.js +12 -0
  568. package/dist/utils/readJson.d.ts +1 -0
  569. package/dist/utils/readJson.js +7 -0
  570. package/dist/utils/routeBuilder.d.ts +18 -0
  571. package/dist/utils/routeBuilder.js +96 -0
  572. package/dist/utils/safeString.d.ts +1 -0
  573. package/dist/utils/safeString.js +6 -0
  574. package/dist/utils/simpleResponse.d.ts +1 -0
  575. package/dist/utils/simpleResponse.js +29 -0
  576. package/dist/utils/validImages.d.ts +13 -0
  577. package/dist/utils/validImages.js +39 -0
  578. package/dist/virtual.d.js +0 -0
  579. package/dist/virtual.d.ts +9 -0
  580. package/package.json +219 -0
  581. package/studiocms-cli.mjs +13 -0
  582. package/ui.d.ts +291 -0
@@ -0,0 +1,685 @@
1
+ import { CMSSiteConfigId, versionCacheLifetime } from "../consts.js";
2
+ import { StudioCMSCacheError } from "./errors.js";
3
+ class StudioCMSVirtualCache {
4
+ SiteConfigMapID = "__StudioCMS_Site_Config";
5
+ VersionMapID = "__StudioCMS_Latest_Version";
6
+ FolderTreeMapID = "__StudioCMS_Folder_Tree";
7
+ PageFolderTreeMapID = "__StudioCMS_Page_Folder_Tree";
8
+ FolderListMapID = "__StudioCMS_Folder_List";
9
+ StudioCMSPkgId = "studiocms";
10
+ CMSSiteConfigId = CMSSiteConfigId;
11
+ versionCacheLifetime = versionCacheLifetime;
12
+ cacheConfig;
13
+ sdk;
14
+ pages = /* @__PURE__ */ new Map();
15
+ siteConfig = /* @__PURE__ */ new Map();
16
+ version = /* @__PURE__ */ new Map();
17
+ folderTree = /* @__PURE__ */ new Map();
18
+ pageFolderTree = /* @__PURE__ */ new Map();
19
+ FolderList = /* @__PURE__ */ new Map();
20
+ cacheModule;
21
+ constructor(cacheConfig, sdkCore) {
22
+ this.cacheConfig = cacheConfig;
23
+ this.sdk = sdkCore;
24
+ this.cacheModule = {
25
+ GET: {
26
+ page: {
27
+ byId: async (id) => await this.getPageById(id),
28
+ bySlug: async (slug) => await this.getPageBySlug(slug)
29
+ },
30
+ pages: async (includeDrafts = false) => await this.getAllPages(includeDrafts),
31
+ siteConfig: async () => await this.getSiteConfig(),
32
+ latestVersion: async () => await this.getVersion(),
33
+ folderTree: async () => await this.getFolderTree(),
34
+ pageFolderTree: async (includeDrafts) => await this.getPageFolderTree(includeDrafts),
35
+ folderList: async () => await this.getFolderList(),
36
+ folder: async (id) => await this.sdk.GET.databaseEntry.folder(id)
37
+ },
38
+ CLEAR: {
39
+ page: {
40
+ byId: (id) => this.clearPageById(id),
41
+ bySlug: (slug) => this.clearPageBySlug(slug)
42
+ },
43
+ pages: () => this.clearAllPages(),
44
+ latestVersion: () => this.clearVersion(),
45
+ folderTree: () => this.clearFolderTree(),
46
+ folderList: () => this.clearFolderList()
47
+ },
48
+ UPDATE: {
49
+ page: {
50
+ byId: async (id, data) => await this.updatePageById(id, data),
51
+ bySlug: async (slug, data) => await this.updatePageBySlug(slug, data)
52
+ },
53
+ siteConfig: async (data) => await this.updateSiteConfig(data),
54
+ latestVersion: async () => await this.updateVersion(),
55
+ folderTree: async () => await this.updateFolderTree(),
56
+ folderList: async () => await this.updateFolderList(),
57
+ folder: async (data) => {
58
+ const updatedEntry = await this.sdk.UPDATE.folder(data);
59
+ await this.updateFolderTree();
60
+ await this.updateFolderList();
61
+ this.clearFolderTree();
62
+ return updatedEntry;
63
+ }
64
+ },
65
+ db: sdkCore.db
66
+ };
67
+ }
68
+ // Misc Utils
69
+ /**
70
+ * Checks if the cache entry has expired based on the provided lifetime.
71
+ *
72
+ * @param entry - The cache entry to check, which should implement the BaseCacheObject interface.
73
+ * @param lifetime - The lifetime duration in milliseconds. Defaults to the cacheConfig's lifetime if not provided.
74
+ * @returns A boolean indicating whether the cache entry has expired.
75
+ */
76
+ isCacheExpired(entry, lifetime = this.cacheConfig.lifetime) {
77
+ return (/* @__PURE__ */ new Date()).getTime() - entry.lastCacheUpdate.getTime() > lifetime;
78
+ }
79
+ /**
80
+ * Checks if the cache is enabled based on the cache configuration.
81
+ *
82
+ * @returns {boolean} True if the cache is enabled, false otherwise.
83
+ */
84
+ isEnabled() {
85
+ return this.cacheConfig.enabled;
86
+ }
87
+ /**
88
+ * Fetches the latest version of the StudioCMS package from the NPM registry.
89
+ *
90
+ * @returns {Promise<string>} A promise that resolves to the latest version string of the StudioCMS package.
91
+ * @throws {StudioCMSCacheError} If there is an error fetching the latest version from NPM.
92
+ */
93
+ async getLatestVersionFromNPM(pkg, ver = "latest") {
94
+ try {
95
+ const npmResponse = await fetch(`https://registry.npmjs.org/${pkg}/${ver}`);
96
+ const npmData = await npmResponse.json();
97
+ return npmData.version;
98
+ } catch (error) {
99
+ throw new StudioCMSCacheError("Error fetching latest version from NPM");
100
+ }
101
+ }
102
+ /**
103
+ * Generates a VersionCacheObject with the provided version and the current date as the last cache update.
104
+ *
105
+ * @param version - The version string to be included in the VersionCacheObject.
106
+ * @returns An object containing the provided version and the current date as the last cache update.
107
+ */
108
+ versionReturn(version) {
109
+ return {
110
+ version,
111
+ lastCacheUpdate: /* @__PURE__ */ new Date()
112
+ };
113
+ }
114
+ /**
115
+ * Generates a cache object for the given site configuration.
116
+ *
117
+ * @param siteConfig - The site configuration to be cached.
118
+ * @returns An object containing the site configuration data and the timestamp of the cache update.
119
+ */
120
+ siteConfigReturn(siteConfig) {
121
+ return {
122
+ data: siteConfig,
123
+ lastCacheUpdate: /* @__PURE__ */ new Date()
124
+ };
125
+ }
126
+ /**
127
+ * Returns a PageDataCacheObject containing the provided CombinedPageData and the current date as the last cache update.
128
+ *
129
+ * @param data - The combined page data to be cached.
130
+ * @returns An object containing the provided data and the current date as the last cache update.
131
+ */
132
+ pageDataReturn(data) {
133
+ return {
134
+ data,
135
+ lastCacheUpdate: /* @__PURE__ */ new Date()
136
+ };
137
+ }
138
+ /**
139
+ * Returns a FolderTreeCacheObject containing the provided folder tree data and the current date as the last cache update.
140
+ *
141
+ * @param data - The folder tree data to be cached.
142
+ * @returns An object containing the provided data and the current date as the last cache update.
143
+ */
144
+ folderTreeReturn(data) {
145
+ return {
146
+ data,
147
+ lastCacheUpdate: /* @__PURE__ */ new Date()
148
+ };
149
+ }
150
+ folderListReturn(data) {
151
+ return {
152
+ data,
153
+ lastCacheUpdate: /* @__PURE__ */ new Date()
154
+ };
155
+ }
156
+ // Folder Tree Utils
157
+ async getFolderList() {
158
+ try {
159
+ if (!this.isEnabled()) {
160
+ const folderList = await this.sdk.getAvailableFolders();
161
+ if (!folderList) {
162
+ throw new StudioCMSCacheError("Folder list not found in database");
163
+ }
164
+ return this.folderListReturn(folderList);
165
+ }
166
+ const list = this.FolderList.get(this.FolderListMapID);
167
+ if (!list || this.isCacheExpired(list)) {
168
+ const folderList = await this.sdk.getAvailableFolders();
169
+ if (!folderList) {
170
+ throw new StudioCMSCacheError("Folder list not found in database");
171
+ }
172
+ this.FolderList.set(this.FolderListMapID, this.folderListReturn(folderList));
173
+ return this.folderListReturn(folderList);
174
+ }
175
+ return list;
176
+ } catch (error) {
177
+ throw new StudioCMSCacheError("Error fetching folder list");
178
+ }
179
+ }
180
+ async updateFolderList() {
181
+ try {
182
+ const folderList = await this.sdk.getAvailableFolders();
183
+ if (!this.isEnabled()) {
184
+ return this.folderListReturn(folderList);
185
+ }
186
+ this.FolderList.set(this.FolderListMapID, this.folderListReturn(folderList));
187
+ return this.folderListReturn(folderList);
188
+ } catch (error) {
189
+ throw new StudioCMSCacheError("Error updating folder list");
190
+ }
191
+ }
192
+ clearFolderList() {
193
+ if (!this.isEnabled()) {
194
+ return;
195
+ }
196
+ this.FolderList.clear();
197
+ return;
198
+ }
199
+ /**
200
+ * Retrieves the folder tree from the cache or the database.
201
+ *
202
+ * @returns {Promise<FolderTreeCacheObject>} A promise that resolves to the folder tree.
203
+ * @throws {StudioCMSCacheError} If the folder tree is not found in the database or if there is an error fetching the folder tree.
204
+ */
205
+ async getFolderTree() {
206
+ try {
207
+ if (!this.isEnabled()) {
208
+ const folderTree = await this.sdk.buildFolderTree();
209
+ if (!folderTree) {
210
+ throw new StudioCMSCacheError("Folder tree not found in database");
211
+ }
212
+ return this.folderTreeReturn(folderTree);
213
+ }
214
+ const tree = this.folderTree.get(this.FolderTreeMapID);
215
+ if (!tree || this.isCacheExpired(tree)) {
216
+ const folderTree = await this.sdk.buildFolderTree();
217
+ if (!folderTree) {
218
+ throw new StudioCMSCacheError("Folder tree not found in database");
219
+ }
220
+ this.folderTree.set(this.FolderTreeMapID, this.folderTreeReturn(folderTree));
221
+ return this.folderTreeReturn(folderTree);
222
+ }
223
+ return tree;
224
+ } catch (error) {
225
+ throw new StudioCMSCacheError("Error fetching folder tree");
226
+ }
227
+ }
228
+ /**
229
+ * Retrieves the folder tree from the cache or the database.
230
+ *
231
+ * @returns {Promise<FolderTreeCacheObject>} A promise that resolves to the folder tree.
232
+ * @throws {StudioCMSCacheError} If the folder tree is not found in the database or if there is an error fetching the folder tree.
233
+ */
234
+ async getPageFolderTree(includeDrafts = false) {
235
+ try {
236
+ if (!this.isEnabled()) {
237
+ const folderTree = await this.sdk.buildFolderTree();
238
+ const pages = await this.sdk.GET.database.pages(includeDrafts);
239
+ if (!folderTree) {
240
+ throw new StudioCMSCacheError("Folder tree not found in database");
241
+ }
242
+ for (const page of pages) {
243
+ if (!includeDrafts && page.draft) {
244
+ continue;
245
+ }
246
+ if (page.parentFolder) {
247
+ this.sdk.addPageToFolderTree(folderTree, page.parentFolder, {
248
+ id: page.id,
249
+ name: page.title,
250
+ page: true,
251
+ pageData: page,
252
+ children: []
253
+ });
254
+ } else {
255
+ folderTree.push({
256
+ id: page.id,
257
+ name: page.title,
258
+ page: true,
259
+ pageData: page,
260
+ children: []
261
+ });
262
+ }
263
+ }
264
+ return this.folderTreeReturn(folderTree);
265
+ }
266
+ const tree = this.pageFolderTree.get(this.PageFolderTreeMapID);
267
+ if (!tree || this.isCacheExpired(tree)) {
268
+ const folderTree = await this.sdk.buildFolderTree();
269
+ const pages = await this.sdk.GET.database.pages(includeDrafts);
270
+ if (!folderTree) {
271
+ throw new StudioCMSCacheError("Folder tree could not be constructed from database");
272
+ }
273
+ for (const page of pages) {
274
+ if (!includeDrafts && page.draft) {
275
+ continue;
276
+ }
277
+ if (page.parentFolder) {
278
+ this.sdk.addPageToFolderTree(folderTree, page.parentFolder, {
279
+ id: page.id,
280
+ name: page.title,
281
+ page: true,
282
+ pageData: page,
283
+ children: []
284
+ });
285
+ } else {
286
+ folderTree.push({
287
+ id: page.id,
288
+ name: page.title,
289
+ page: true,
290
+ pageData: page,
291
+ children: []
292
+ });
293
+ }
294
+ }
295
+ this.folderTree.set(this.PageFolderTreeMapID, this.folderTreeReturn(folderTree));
296
+ this.clearFolderTree();
297
+ return this.folderTreeReturn(folderTree);
298
+ }
299
+ return tree;
300
+ } catch (error) {
301
+ throw new StudioCMSCacheError("Error fetching folder tree");
302
+ }
303
+ }
304
+ /**
305
+ * Updates the folder tree in the cache and database.
306
+ *
307
+ * @returns {Promise<FolderTreeCacheObject>} A promise that resolves to the updated folder tree.
308
+ * @throws {StudioCMSCacheError} If there is an error updating the folder tree.
309
+ */
310
+ async updateFolderTree() {
311
+ try {
312
+ const folderTree = await this.sdk.buildFolderTree();
313
+ if (!this.isEnabled()) {
314
+ return this.folderTreeReturn(folderTree);
315
+ }
316
+ this.folderTree.set(this.FolderTreeMapID, this.folderTreeReturn(folderTree));
317
+ return this.folderTreeReturn(folderTree);
318
+ } catch (error) {
319
+ throw new StudioCMSCacheError("Error updating folder tree");
320
+ }
321
+ }
322
+ /**
323
+ * Clears the folder tree from the cache.
324
+ */
325
+ clearFolderTree() {
326
+ if (!this.isEnabled()) {
327
+ return;
328
+ }
329
+ this.folderTree.clear();
330
+ return;
331
+ }
332
+ // Version Utils
333
+ /**
334
+ * Retrieves the version information from the cache or fetches the latest version from NPM if the cache is disabled or expired.
335
+ *
336
+ * @returns {Promise<VersionCacheObject>} A promise that resolves to the version information object.
337
+ */
338
+ async getVersion() {
339
+ try {
340
+ if (!this.isEnabled()) {
341
+ const version = await this.getLatestVersionFromNPM(this.StudioCMSPkgId);
342
+ return this.versionReturn(version);
343
+ }
344
+ const latestVersion = this.version.get(this.VersionMapID);
345
+ if (!latestVersion || this.isCacheExpired(latestVersion, this.versionCacheLifetime)) {
346
+ const version = await this.getLatestVersionFromNPM(this.StudioCMSPkgId);
347
+ const latestVersion2 = this.versionReturn(version);
348
+ this.version.set(this.VersionMapID, latestVersion2);
349
+ return latestVersion2;
350
+ }
351
+ return latestVersion;
352
+ } catch (error) {
353
+ throw new StudioCMSCacheError("Error fetching version information");
354
+ }
355
+ }
356
+ /**
357
+ * Updates the version cache with the latest version from NPM.
358
+ *
359
+ * @returns {Promise<VersionCacheObject>} A promise that resolves to the new version cache object.
360
+ *
361
+ * @throws {Error} If there is an issue retrieving the latest version from NPM.
362
+ */
363
+ async updateVersion() {
364
+ try {
365
+ const latestVersion = await this.getLatestVersionFromNPM(this.StudioCMSPkgId);
366
+ const newVersion = this.versionReturn(latestVersion);
367
+ if (!this.isEnabled()) {
368
+ return newVersion;
369
+ }
370
+ this.version.set(this.VersionMapID, newVersion);
371
+ return newVersion;
372
+ } catch (error) {
373
+ throw new StudioCMSCacheError("Error updating version information");
374
+ }
375
+ }
376
+ /**
377
+ * Clears the current version from the cache.
378
+ *
379
+ * This method removes all entries associated with the current version
380
+ * from the cache, effectively resetting it.
381
+ */
382
+ clearVersion() {
383
+ if (!this.isEnabled()) {
384
+ return;
385
+ }
386
+ this.version.clear();
387
+ return;
388
+ }
389
+ // Site Config Utils
390
+ /**
391
+ * Retrieves the site configuration from the cache or database.
392
+ *
393
+ * If caching is disabled, it fetches the site configuration directly from the database.
394
+ * If caching is enabled, it first checks the cache for the site configuration. If the cache is expired or not found,
395
+ * it fetches the site configuration from the database, updates the cache, and returns the configuration.
396
+ *
397
+ * @returns {Promise<SiteConfigCacheObject>} A promise that resolves to the site configuration object.
398
+ * @throws {StudioCMSCacheError} If the site configuration is not found in the database.
399
+ */
400
+ async getSiteConfig() {
401
+ try {
402
+ if (!this.isEnabled()) {
403
+ const newSiteConfig = await this.sdk.GET.database.config();
404
+ if (!newSiteConfig) {
405
+ throw new StudioCMSCacheError("Site config not found in database");
406
+ }
407
+ return this.siteConfigReturn(newSiteConfig);
408
+ }
409
+ const siteConfig = this.siteConfig.get(this.SiteConfigMapID);
410
+ if (!siteConfig || this.isCacheExpired(siteConfig)) {
411
+ const newSiteConfig = await this.sdk.GET.database.config();
412
+ if (!newSiteConfig) {
413
+ throw new StudioCMSCacheError("Site config not found in database");
414
+ }
415
+ const returnConfig = this.siteConfigReturn(newSiteConfig);
416
+ this.siteConfig.set(this.SiteConfigMapID, returnConfig);
417
+ return returnConfig;
418
+ }
419
+ return siteConfig;
420
+ } catch (error) {
421
+ throw new StudioCMSCacheError("Error fetching site configuration", error.stack);
422
+ }
423
+ }
424
+ /**
425
+ * Updates the site configuration in the database and cache.
426
+ *
427
+ * @param data - The new site configuration data to be updated.
428
+ * @returns A promise that resolves to the updated site configuration cache object.
429
+ * @throws {StudioCMSCacheError} If the updated data could not be retrieved from the database.
430
+ */
431
+ async updateSiteConfig(data) {
432
+ try {
433
+ const newSiteConfig = await this.sdk.UPDATE.siteConfig({ ...data, id: this.CMSSiteConfigId });
434
+ if (!newSiteConfig) {
435
+ throw new StudioCMSCacheError("Could not retrieve updated data from the database.");
436
+ }
437
+ const returnConfig = this.siteConfigReturn(newSiteConfig);
438
+ if (!this.isEnabled()) {
439
+ return returnConfig;
440
+ }
441
+ this.siteConfig.set(this.SiteConfigMapID, returnConfig);
442
+ return returnConfig;
443
+ } catch (error) {
444
+ throw new StudioCMSCacheError("Error updating site configuration");
445
+ }
446
+ }
447
+ // Page Utils
448
+ /**
449
+ * Clear a page from the cache by its ID
450
+ * @param id - The ID of the page
451
+ *
452
+ * @returns void
453
+ */
454
+ clearPageById(id) {
455
+ if (!this.isEnabled()) {
456
+ return;
457
+ }
458
+ this.pages.delete(id);
459
+ return;
460
+ }
461
+ /**
462
+ * Clear a page from the cache by its slug and package
463
+ * @param slug - The slug of the page
464
+ * @param pkg - The package of the page
465
+ *
466
+ * @returns void
467
+ */
468
+ clearPageBySlug(slug) {
469
+ if (!this.isEnabled()) {
470
+ return;
471
+ }
472
+ const keyIndex = [];
473
+ for (const [key, cachedObject] of this.pages) {
474
+ if (cachedObject.data.slug === slug) {
475
+ keyIndex.push(key);
476
+ }
477
+ }
478
+ for (const key of keyIndex) {
479
+ this.pages.delete(key);
480
+ }
481
+ return;
482
+ }
483
+ /**
484
+ * Clear all pages from the cache
485
+ *
486
+ * @returns void
487
+ */
488
+ clearAllPages() {
489
+ if (!this.isEnabled()) {
490
+ return;
491
+ }
492
+ this.pages.clear();
493
+ return;
494
+ }
495
+ /**
496
+ * Retrieves all pages from the cache or the database.
497
+ *
498
+ * @returns {Promise<PageDataCacheObject[]>} A promise that resolves to an array of page data cache objects.
499
+ *
500
+ * @throws {StudioCMS_SDK_Error} If the cache is empty and could not be updated, or if the cache is expired and could not be updated.
501
+ *
502
+ * @remarks
503
+ * - If caching is disabled, the data is retrieved directly from the database.
504
+ * - If the cache is empty, the data is retrieved from the database and stored in the cache.
505
+ * - If the cache contains data, it checks for expired entries and updates them from the database if necessary.
506
+ */
507
+ async getAllPages(includeDrafts = false) {
508
+ try {
509
+ if (!this.isEnabled()) {
510
+ const pages = await this.sdk.GET.database.pages(includeDrafts);
511
+ return pages.map((page) => this.pageDataReturn(page));
512
+ }
513
+ const { data: tree } = await this.getFolderTree();
514
+ if (this.pages.size === 0) {
515
+ const updatedData = await this.sdk.GET.database.pages(includeDrafts, tree);
516
+ if (!updatedData) {
517
+ throw new StudioCMSCacheError("Cache is empty and could not be updated.");
518
+ }
519
+ for (const data of updatedData) {
520
+ this.pages.set(data.id, this.pageDataReturn(data));
521
+ }
522
+ return updatedData.map((data) => this.pageDataReturn(data));
523
+ }
524
+ const cacheMap = Array.from(this.pages.values());
525
+ for (const object of cacheMap) {
526
+ if (this.isCacheExpired(object)) {
527
+ const updatedData = await this.sdk.GET.databaseEntry.pages.byId(object.data.id, tree);
528
+ if (!updatedData) {
529
+ throw new StudioCMSCacheError("Cache is expired and could not be updated.");
530
+ }
531
+ this.pages.set(updatedData.id, this.pageDataReturn(updatedData));
532
+ }
533
+ }
534
+ return Array.from(this.pages.values());
535
+ } catch (error) {
536
+ throw new StudioCMSCacheError("Error fetching all pages");
537
+ }
538
+ }
539
+ /**
540
+ * Retrieves a page by its ID, either from the cache or the database.
541
+ *
542
+ * @param {string} id - The ID of the page to retrieve.
543
+ * @returns {Promise<PageDataCacheObject>} - A promise that resolves to the page data.
544
+ * @throws {StudioCMSCacheError} - Throws an error if the page is not found in the database or if there is an error fetching the page.
545
+ */
546
+ async getPageById(id) {
547
+ try {
548
+ if (!this.isEnabled()) {
549
+ const page = await this.sdk.GET.databaseEntry.pages.byId(id);
550
+ if (!page) {
551
+ throw new StudioCMSCacheError("Page not found in database");
552
+ }
553
+ return this.pageDataReturn(page);
554
+ }
555
+ const { data: tree } = await this.getFolderTree();
556
+ const cachedPage = this.pages.get(id);
557
+ if (!cachedPage || this.isCacheExpired(cachedPage)) {
558
+ const page = await this.sdk.GET.databaseEntry.pages.byId(id, tree);
559
+ if (!page) {
560
+ throw new StudioCMSCacheError("Page not found in database");
561
+ }
562
+ const returnPage = this.pageDataReturn(page);
563
+ this.pages.set(id, returnPage);
564
+ return returnPage;
565
+ }
566
+ return cachedPage;
567
+ } catch (error) {
568
+ throw new StudioCMSCacheError("Error fetching page by ID");
569
+ }
570
+ }
571
+ /**
572
+ * Retrieves a page by its slug from the cache or database.
573
+ *
574
+ * @param {string} slug - The slug of the page to retrieve.
575
+ * @returns {Promise<PageDataCacheObject>} A promise that resolves to the page data.
576
+ * @throws {StudioCMSCacheError} If the page is not found in the database or if there is an error fetching the page.
577
+ */
578
+ async getPageBySlug(slug) {
579
+ try {
580
+ if (!this.isEnabled()) {
581
+ const page = await this.sdk.GET.databaseEntry.pages.bySlug(slug);
582
+ if (!page) {
583
+ throw new StudioCMSCacheError("Page not found in database");
584
+ }
585
+ return this.pageDataReturn(page);
586
+ }
587
+ const { data: tree } = await this.getFolderTree();
588
+ const cachedPage = Array.from(this.pages.values()).find((page) => page.data.slug === slug);
589
+ if (!cachedPage || this.isCacheExpired(cachedPage)) {
590
+ const page = await this.sdk.GET.databaseEntry.pages.bySlug(slug, tree);
591
+ if (!page) {
592
+ throw new StudioCMSCacheError("Page not found in database");
593
+ }
594
+ const returnPage = this.pageDataReturn(page);
595
+ this.pages.set(page.id, returnPage);
596
+ return returnPage;
597
+ }
598
+ return cachedPage;
599
+ } catch (error) {
600
+ throw new StudioCMSCacheError("Error fetching page by slug");
601
+ }
602
+ }
603
+ /**
604
+ * Updates a page by its ID with the provided data.
605
+ *
606
+ * @param id - The ID of the page to update.
607
+ * @param data - An object containing the page data and page content to update.
608
+ * @param data.pageData - The data of the page to update.
609
+ * @param data.pageContent - The content of the page to update.
610
+ * @returns A promise that resolves to the updated page data cache object.
611
+ * @throws {StudioCMSCacheError} If the page is not found in the database or if there is an error updating the page.
612
+ */
613
+ async updatePageById(id, data) {
614
+ try {
615
+ if (!this.isEnabled()) {
616
+ await this.sdk.UPDATE.page(data.pageData);
617
+ await this.sdk.UPDATE.pageContent(data.pageContent);
618
+ const updatedData2 = await this.sdk.GET.databaseEntry.pages.byId(id);
619
+ if (!updatedData2) {
620
+ throw new StudioCMSCacheError("Page not found in database");
621
+ }
622
+ return this.pageDataReturn(updatedData2);
623
+ }
624
+ const { data: tree } = await this.updateFolderTree();
625
+ await this.sdk.UPDATE.page(data.pageData);
626
+ await this.sdk.UPDATE.pageContent(data.pageContent);
627
+ const updatedData = await this.sdk.GET.databaseEntry.pages.byId(id, tree);
628
+ if (!updatedData) {
629
+ throw new StudioCMSCacheError("Page not found in database");
630
+ }
631
+ const returnData = this.pageDataReturn(updatedData);
632
+ this.pages.set(id, returnData);
633
+ this.clearFolderTree();
634
+ return returnData;
635
+ } catch (error) {
636
+ throw new StudioCMSCacheError("Error updating page by ID");
637
+ }
638
+ }
639
+ /**
640
+ * Updates a page by its slug and package name.
641
+ *
642
+ * @param slug - The slug of the page to update.
643
+ * @param pkg - The package name of the page to update.
644
+ * @param data - An object containing the page data and page content to update.
645
+ * @param data.pageData - The data of the page to update.
646
+ * @param data.pageContent - The content of the page to update.
647
+ * @returns A promise that resolves to the updated page data cache object.
648
+ * @throws {StudioCMSCacheError} If the page is not found in the cache or database, or if there is an error updating the page.
649
+ */
650
+ async updatePageBySlug(slug, data) {
651
+ try {
652
+ if (!this.isEnabled()) {
653
+ await this.sdk.UPDATE.page(data.pageData);
654
+ await this.sdk.UPDATE.pageContent(data.pageContent);
655
+ const updatedData2 = await this.sdk.GET.databaseEntry.pages.bySlug(slug);
656
+ if (!updatedData2) {
657
+ throw new StudioCMSCacheError("Page not found in database");
658
+ }
659
+ return this.pageDataReturn(updatedData2);
660
+ }
661
+ const { data: tree } = await this.updateFolderTree();
662
+ const cachedPage = Array.from(this.pages.values()).find((page) => page.data.slug === slug);
663
+ if (!cachedPage) {
664
+ throw new StudioCMSCacheError("Page not found in cache");
665
+ }
666
+ await this.sdk.UPDATE.page(data.pageData);
667
+ await this.sdk.UPDATE.pageContent(data.pageContent);
668
+ const updatedData = await this.sdk.GET.databaseEntry.pages.bySlug(slug, tree);
669
+ if (!updatedData) {
670
+ throw new StudioCMSCacheError("Page not found in database");
671
+ }
672
+ const returnData = this.pageDataReturn(updatedData);
673
+ this.pages.set(updatedData.id, returnData);
674
+ this.clearFolderTree();
675
+ return returnData;
676
+ } catch (error) {
677
+ throw new StudioCMSCacheError("Error updating page by slug");
678
+ }
679
+ }
680
+ }
681
+ var StudioCMSVirtualCache_default = StudioCMSVirtualCache;
682
+ export {
683
+ StudioCMSVirtualCache,
684
+ StudioCMSVirtualCache_default as default
685
+ };
@@ -0,0 +1,11 @@
1
+ import type { PageDataCacheObject, STUDIOCMS_SDK_CACHE, SiteConfigCacheObject, VersionCacheObject } from './types/index.js';
2
+ export type { STUDIOCMS_SDK_CACHE, PageDataCacheObject, SiteConfigCacheObject, VersionCacheObject };
3
+ /**
4
+ * A constant representing the StudioCMS SDK Cache.
5
+ * This cache is used to store and retrieve data within the StudioCMS SDK.
6
+ *
7
+ * @constant
8
+ * @type {STUDIOCMS_SDK_CACHE}
9
+ */
10
+ export declare const studioCMS_SDK_Cache: STUDIOCMS_SDK_CACHE;
11
+ export default studioCMS_SDK_Cache;