codeforlife 2.8.3 → 2.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (364) hide show
  1. package/dist/Countdown-DFI1RljW.js +28 -0
  2. package/dist/Countdown-DFI1RljW.js.map +1 -0
  3. package/dist/Countdown-zY3nMzmi.cjs +2 -0
  4. package/dist/Countdown-zY3nMzmi.cjs.map +1 -0
  5. package/dist/Image-D5jC9UoX.js +21 -0
  6. package/dist/Image-D5jC9UoX.js.map +1 -0
  7. package/dist/Image-mgT45r_B.cjs +2 -0
  8. package/dist/Image-mgT45r_B.cjs.map +1 -0
  9. package/dist/LinkButton-BYFkvL_O.cjs +2 -0
  10. package/dist/LinkButton-BYFkvL_O.cjs.map +1 -0
  11. package/dist/LinkButton-oK0RThqn.js +12 -0
  12. package/dist/LinkButton-oK0RThqn.js.map +1 -0
  13. package/dist/Navigate-Dq47aqC8.js +25 -0
  14. package/dist/Navigate-Dq47aqC8.js.map +1 -0
  15. package/dist/Navigate-dQocLhzN.cjs +2 -0
  16. package/dist/Navigate-dQocLhzN.cjs.map +1 -0
  17. package/dist/api/endpoints/index.cjs.js +2 -0
  18. package/dist/api/endpoints/index.cjs.js.map +1 -0
  19. package/dist/api/endpoints/index.d.ts +81 -0
  20. package/dist/api/endpoints/index.es.js +78 -0
  21. package/dist/api/endpoints/index.es.js.map +1 -0
  22. package/dist/api/index.cjs.js +4 -0
  23. package/dist/api/index.cjs.js.map +1 -0
  24. package/dist/api/index.d.ts +77 -0
  25. package/dist/api/index.es.js +541 -0
  26. package/dist/api/index.es.js.map +1 -0
  27. package/dist/api-Cbyt3rw0.js +92 -0
  28. package/dist/api-Cbyt3rw0.js.map +1 -0
  29. package/dist/api-CnMfjRk3.cjs +2 -0
  30. package/dist/api-CnMfjRk3.cjs.map +1 -0
  31. package/dist/api-Cs4Y-WeI.js +20 -0
  32. package/dist/api-Cs4Y-WeI.js.map +1 -0
  33. package/dist/api-DIgp_6Vr.cjs +2 -0
  34. package/dist/api-DIgp_6Vr.cjs.map +1 -0
  35. package/dist/api.d.ts +123 -0
  36. package/dist/auth-BPfUPjmM.js +237 -0
  37. package/dist/auth-BPfUPjmM.js.map +1 -0
  38. package/dist/auth-Vf1MgMci.cjs +2 -0
  39. package/dist/auth-Vf1MgMci.cjs.map +1 -0
  40. package/dist/auth.d.ts +40 -0
  41. package/dist/components/form/index.cjs.js +2 -0
  42. package/dist/components/form/index.cjs.js.map +1 -0
  43. package/dist/components/form/index.d.ts +86 -0
  44. package/dist/components/form/index.es.js +18 -0
  45. package/dist/components/form/index.es.js.map +1 -0
  46. package/dist/components/index.cjs.js +11 -0
  47. package/dist/components/index.cjs.js.map +1 -0
  48. package/dist/components/index.d.ts +90 -0
  49. package/dist/components/index.es.js +383 -0
  50. package/dist/components/index.es.js.map +1 -0
  51. package/dist/components/page/index.cjs.js +2 -0
  52. package/dist/components/page/index.cjs.js.map +1 -0
  53. package/dist/components/page/index.d.ts +77 -0
  54. package/dist/components/page/index.es.js +9 -0
  55. package/dist/components/page/index.es.js.map +1 -0
  56. package/dist/components/router/index.cjs.js +2 -0
  57. package/dist/components/router/index.cjs.js.map +1 -0
  58. package/dist/components/router/index.d.ts +78 -0
  59. package/dist/components/router/index.es.js +11 -0
  60. package/dist/components/router/index.es.js.map +1 -0
  61. package/dist/components/table/index.cjs.js +2 -0
  62. package/dist/components/table/index.cjs.js.map +1 -0
  63. package/dist/components/table/index.d.ts +75 -0
  64. package/dist/components/table/index.es.js +9 -0
  65. package/dist/components/table/index.es.js.map +1 -0
  66. package/dist/en-gb-B_rK7Jx1.js +20 -0
  67. package/dist/en-gb-B_rK7Jx1.js.map +1 -0
  68. package/dist/en-gb-CpyEkKq3.cjs +2 -0
  69. package/dist/en-gb-CpyEkKq3.cjs.map +1 -0
  70. package/dist/features/index.cjs.js +2 -0
  71. package/dist/features/index.cjs.js.map +1 -0
  72. package/dist/features/index.d.ts +76 -0
  73. package/dist/features/index.es.js +47 -0
  74. package/dist/features/index.es.js.map +1 -0
  75. package/dist/form.d.ts +40 -0
  76. package/dist/general-BPbbmkeX.cjs +2 -0
  77. package/dist/general-BPbbmkeX.cjs.map +1 -0
  78. package/dist/general-CtTJPCJn.js +58 -0
  79. package/dist/general-CtTJPCJn.js.map +1 -0
  80. package/dist/general.d.ts +53 -0
  81. package/dist/hooks/index.cjs.js +2 -0
  82. package/dist/hooks/index.cjs.js.map +1 -0
  83. package/dist/hooks/index.d.ts +77 -0
  84. package/dist/hooks/index.es.js +25 -0
  85. package/dist/hooks/index.es.js.map +1 -0
  86. package/dist/index-2W--_sNE.js +30 -0
  87. package/dist/index-2W--_sNE.js.map +1 -0
  88. package/dist/index-BUMdUVBH.cjs +5 -0
  89. package/dist/index-BUMdUVBH.cjs.map +1 -0
  90. package/dist/index-B_Zy_zwA.cjs +2 -0
  91. package/dist/index-B_Zy_zwA.cjs.map +1 -0
  92. package/dist/index-BgsynEGX.cjs +2 -0
  93. package/dist/index-BgsynEGX.cjs.map +1 -0
  94. package/dist/index-CA-ugBSa.cjs +2 -0
  95. package/dist/index-CA-ugBSa.cjs.map +1 -0
  96. package/dist/index-CNtOlJ49.js +572 -0
  97. package/dist/index-CNtOlJ49.js.map +1 -0
  98. package/dist/index-DkM_cG3a.js +237 -0
  99. package/dist/index-DkM_cG3a.js.map +1 -0
  100. package/dist/index-Dqp7dpn3.js +1111 -0
  101. package/dist/index-Dqp7dpn3.js.map +1 -0
  102. package/dist/index.cjs.js +2 -0
  103. package/dist/index.cjs.js.map +1 -0
  104. package/dist/index.d.ts +78 -0
  105. package/dist/index.es.js +7 -0
  106. package/dist/index.es.js.map +1 -0
  107. package/dist/jsx-runtime-CeSfJrVB.cjs +31 -0
  108. package/dist/jsx-runtime-CeSfJrVB.cjs.map +1 -0
  109. package/dist/jsx-runtime-Dpn_P65e.js +634 -0
  110. package/dist/jsx-runtime-Dpn_P65e.js.map +1 -0
  111. package/dist/middlewares/index.cjs.js +2 -0
  112. package/dist/middlewares/index.cjs.js.map +1 -0
  113. package/dist/middlewares/index.d.ts +73 -0
  114. package/dist/middlewares/index.es.js +10 -0
  115. package/dist/middlewares/index.es.js.map +1 -0
  116. package/dist/palette-CE2mKYse.cjs +2 -0
  117. package/dist/palette-CE2mKYse.cjs.map +1 -0
  118. package/dist/palette-C_L0akN_.js +43 -0
  119. package/dist/palette-C_L0akN_.js.map +1 -0
  120. package/dist/router.d.ts +48 -0
  121. package/dist/rtk-query.modern-CjetfYPg.js +3038 -0
  122. package/dist/rtk-query.modern-CjetfYPg.js.map +1 -0
  123. package/dist/rtk-query.modern-PBCErCqb.cjs +15 -0
  124. package/dist/rtk-query.modern-PBCErCqb.cjs.map +1 -0
  125. package/dist/schema.d.ts +89 -0
  126. package/dist/schemas-BZbJpkD5.cjs +2 -0
  127. package/dist/schemas-BZbJpkD5.cjs.map +1 -0
  128. package/dist/schemas-DlOtf2vf.js +162 -0
  129. package/dist/schemas-DlOtf2vf.js.map +1 -0
  130. package/dist/server.cjs.js +6 -0
  131. package/dist/server.cjs.js.map +1 -0
  132. package/dist/server.d.ts +129 -0
  133. package/dist/server.es.js +127 -0
  134. package/dist/server.es.js.map +1 -0
  135. package/dist/session-CE2U7oL1.cjs +2 -0
  136. package/dist/session-CE2U7oL1.cjs.map +1 -0
  137. package/dist/session-CacrgFSv.cjs +2 -0
  138. package/dist/session-CacrgFSv.cjs.map +1 -0
  139. package/dist/session-D312kYKk.js +32 -0
  140. package/dist/session-D312kYKk.js.map +1 -0
  141. package/dist/session-oI-Ht2C8.js +30 -0
  142. package/dist/session-oI-Ht2C8.js.map +1 -0
  143. package/dist/settings/index.cjs.js +2 -0
  144. package/dist/settings/index.cjs.js.map +1 -0
  145. package/dist/settings/index.d.ts +76 -0
  146. package/dist/settings/index.es.js +17 -0
  147. package/dist/settings/index.es.js.map +1 -0
  148. package/dist/slices/index.cjs.js +2 -0
  149. package/dist/slices/index.cjs.js.map +1 -0
  150. package/dist/slices/index.d.ts +74 -0
  151. package/dist/slices/index.es.js +6 -0
  152. package/dist/slices/index.es.js.map +1 -0
  153. package/dist/store.d.ts +17 -0
  154. package/dist/style.css +1 -0
  155. package/dist/test.d.ts +75 -0
  156. package/dist/theme/components/index.cjs.js +2 -0
  157. package/dist/theme/components/index.cjs.js.map +1 -0
  158. package/dist/theme/components/index.d.ts +75 -0
  159. package/dist/theme/components/index.es.js +6 -0
  160. package/dist/theme/components/index.es.js.map +1 -0
  161. package/dist/theme/index.cjs.js +2 -0
  162. package/dist/theme/index.cjs.js.map +1 -0
  163. package/dist/theme/index.d.ts +79 -0
  164. package/dist/theme/index.es.js +222 -0
  165. package/dist/theme/index.es.js.map +1 -0
  166. package/dist/theme.d.ts +19 -0
  167. package/dist/urls-DtHr1d3H.js +14 -0
  168. package/dist/urls-DtHr1d3H.js.map +1 -0
  169. package/dist/urls-MaVXL_C2.cjs +2 -0
  170. package/dist/urls-MaVXL_C2.cjs.map +1 -0
  171. package/dist/utils/api.cjs.js +2 -0
  172. package/dist/utils/api.cjs.js.map +1 -0
  173. package/dist/utils/api.d.ts +144 -0
  174. package/dist/utils/api.es.js +16 -0
  175. package/dist/utils/api.es.js.map +1 -0
  176. package/dist/utils/auth.cjs.js +2 -0
  177. package/dist/utils/auth.cjs.js.map +1 -0
  178. package/dist/utils/auth.d.ts +100 -0
  179. package/dist/utils/auth.es.js +117 -0
  180. package/dist/utils/auth.es.js.map +1 -0
  181. package/dist/utils/form.cjs.js +2 -0
  182. package/dist/utils/form.cjs.js.map +1 -0
  183. package/dist/utils/form.d.ts +97 -0
  184. package/dist/utils/form.es.js +76 -0
  185. package/dist/utils/form.es.js.map +1 -0
  186. package/dist/utils/general.cjs.js +2 -0
  187. package/dist/utils/general.cjs.js.map +1 -0
  188. package/dist/utils/general.d.ts +102 -0
  189. package/{src/utils/general.ts → dist/utils/general.es.js} +87 -165
  190. package/dist/utils/general.es.js.map +1 -0
  191. package/dist/utils/router.cjs.js +2 -0
  192. package/dist/utils/router.cjs.js.map +1 -0
  193. package/dist/utils/router.d.ts +91 -0
  194. package/dist/utils/router.es.js +33 -0
  195. package/dist/utils/router.es.js.map +1 -0
  196. package/dist/utils/schema.cjs.js +2 -0
  197. package/dist/utils/schema.cjs.js.map +1 -0
  198. package/dist/utils/schema.d.ts +115 -0
  199. package/dist/utils/schema.es.js +123 -0
  200. package/dist/utils/schema.es.js.map +1 -0
  201. package/dist/utils/store.cjs.js +2 -0
  202. package/dist/utils/store.cjs.js.map +1 -0
  203. package/dist/utils/store.d.ts +82 -0
  204. package/dist/utils/store.es.js +20 -0
  205. package/dist/utils/store.es.js.map +1 -0
  206. package/dist/utils/test.cjs.js +2 -0
  207. package/dist/utils/test.cjs.js.map +1 -0
  208. package/dist/utils/test.d.ts +125 -0
  209. package/dist/utils/test.es.js +60 -0
  210. package/dist/utils/test.es.js.map +1 -0
  211. package/dist/utils/theme.cjs.js +2 -0
  212. package/dist/utils/theme.cjs.js.map +1 -0
  213. package/dist/utils/theme.d.ts +83 -0
  214. package/dist/utils/theme.es.js +12 -0
  215. package/dist/utils/theme.es.js.map +1 -0
  216. package/dist/utils/window.cjs.js +2 -0
  217. package/dist/utils/window.cjs.js.map +1 -0
  218. package/dist/utils/window.d.ts +74 -0
  219. package/dist/utils/window.es.js +11 -0
  220. package/dist/utils/window.es.js.map +1 -0
  221. package/dist/window.d.ts +5 -0
  222. package/package.json +142 -37
  223. package/.github/workflows/main.yml +0 -55
  224. package/.prettierignore +0 -1
  225. package/CHANGELOG.md +0 -2027
  226. package/CONTRIBUTING.md +0 -3
  227. package/eslint.config.js +0 -17
  228. package/src/api/createApi.ts +0 -91
  229. package/src/api/endpoints/authFactor.ts +0 -31
  230. package/src/api/endpoints/index.ts +0 -9
  231. package/src/api/endpoints/klass.ts +0 -87
  232. package/src/api/endpoints/school.ts +0 -34
  233. package/src/api/endpoints/session.ts +0 -47
  234. package/src/api/endpoints/user.ts +0 -70
  235. package/src/api/index.ts +0 -5
  236. package/src/api/models.ts +0 -145
  237. package/src/api/schemas.ts +0 -243
  238. package/src/api/tagTypes.ts +0 -12
  239. package/src/api/urls.ts +0 -13
  240. package/src/components/App.css +0 -38
  241. package/src/components/App.tsx +0 -152
  242. package/src/components/ClickableTooltip.tsx +0 -43
  243. package/src/components/CopyIconButton.test.tsx +0 -16
  244. package/src/components/CopyIconButton.tsx +0 -27
  245. package/src/components/Countdown.tsx +0 -42
  246. package/src/components/DownloadFileButton.tsx +0 -55
  247. package/src/components/ElevatedAppBar.tsx +0 -41
  248. package/src/components/Image.tsx +0 -41
  249. package/src/components/InputFileButton.tsx +0 -27
  250. package/src/components/ItemizedList.tsx +0 -63
  251. package/src/components/OrderedGrid.tsx +0 -92
  252. package/src/components/ScrollIntoViewLink.tsx +0 -22
  253. package/src/components/SyncError.tsx +0 -14
  254. package/src/components/TablePagination.tsx +0 -142
  255. package/src/components/YouTubeVideo.tsx +0 -26
  256. package/src/components/form/ApiAutocompleteField.tsx +0 -187
  257. package/src/components/form/AutocompleteField.tsx +0 -135
  258. package/src/components/form/CheckboxField.tsx +0 -86
  259. package/src/components/form/CountryField.tsx +0 -75
  260. package/src/components/form/DatePickerField.tsx +0 -126
  261. package/src/components/form/EmailField.tsx +0 -38
  262. package/src/components/form/FirstNameField.tsx +0 -40
  263. package/src/components/form/Form.tsx +0 -165
  264. package/src/components/form/OtpField.tsx +0 -28
  265. package/src/components/form/PasswordField.tsx +0 -71
  266. package/src/components/form/RepeatField.tsx +0 -123
  267. package/src/components/form/SubmitButton.tsx +0 -57
  268. package/src/components/form/TextField.tsx +0 -150
  269. package/src/components/form/UkCountyField.tsx +0 -68
  270. package/src/components/form/index.tsx +0 -35
  271. package/src/components/index.ts +0 -28
  272. package/src/components/page/Banner.tsx +0 -95
  273. package/src/components/page/Notification.tsx +0 -71
  274. package/src/components/page/Page.tsx +0 -73
  275. package/src/components/page/Section.tsx +0 -21
  276. package/src/components/page/TabBar.tsx +0 -131
  277. package/src/components/page/index.ts +0 -10
  278. package/src/components/router/Link.tsx +0 -23
  279. package/src/components/router/LinkButton.tsx +0 -22
  280. package/src/components/router/LinkIconButton.tsx +0 -22
  281. package/src/components/router/LinkListItem.tsx +0 -22
  282. package/src/components/router/LinkTab.tsx +0 -22
  283. package/src/components/router/Navigate.tsx +0 -33
  284. package/src/components/router/index.tsx +0 -9
  285. package/src/components/table/CellStack.tsx +0 -19
  286. package/src/components/table/Table.tsx +0 -55
  287. package/src/components/table/index.tsx +0 -8
  288. package/src/features/InactiveDialog.tsx +0 -40
  289. package/src/features/ScreenTimeDialog.tsx +0 -30
  290. package/src/features/index.ts +0 -4
  291. package/src/fonts/ttf/Inter-VariableFont_slnt,wght.ttf +0 -0
  292. package/src/fonts/ttf/SpaceGrotesk-VariableFont_wght.ttf +0 -0
  293. package/src/hooks/api.tsx +0 -39
  294. package/src/hooks/auth.tsx +0 -397
  295. package/src/hooks/form.tsx +0 -11
  296. package/src/hooks/general.tsx +0 -110
  297. package/src/hooks/index.ts +0 -5
  298. package/src/hooks/router.tsx +0 -168
  299. package/src/images/svg/brain.svg +0 -1
  300. package/src/index.ts +0 -2
  301. package/src/middlewares/index.ts +0 -1
  302. package/src/middlewares/session.ts +0 -21
  303. package/src/scripts/freshDesk.js +0 -473
  304. package/src/scripts/index.ts +0 -1
  305. package/src/server.js +0 -187
  306. package/src/settings/custom.ts +0 -22
  307. package/src/settings/index.ts +0 -7
  308. package/src/settings/vite.ts +0 -26
  309. package/src/setupTests.ts +0 -2
  310. package/src/slices/createSlice.ts +0 -8
  311. package/src/slices/index.ts +0 -2
  312. package/src/slices/session.ts +0 -32
  313. package/src/theme/ThemedBox.tsx +0 -265
  314. package/src/theme/colors.ts +0 -57
  315. package/src/theme/components/MuiAccordion.tsx +0 -13
  316. package/src/theme/components/MuiAutocomplete.tsx +0 -11
  317. package/src/theme/components/MuiButton.ts +0 -70
  318. package/src/theme/components/MuiCardActions.tsx +0 -12
  319. package/src/theme/components/MuiCheckbox.ts +0 -12
  320. package/src/theme/components/MuiContainer.ts +0 -19
  321. package/src/theme/components/MuiDialog.tsx +0 -16
  322. package/src/theme/components/MuiFormControlLabel.ts +0 -18
  323. package/src/theme/components/MuiFormHelperText.ts +0 -12
  324. package/src/theme/components/MuiGrid2.ts +0 -16
  325. package/src/theme/components/MuiInputBase.ts +0 -14
  326. package/src/theme/components/MuiLink.ts +0 -41
  327. package/src/theme/components/MuiList.ts +0 -12
  328. package/src/theme/components/MuiListItemText.ts +0 -18
  329. package/src/theme/components/MuiMenu.ts +0 -14
  330. package/src/theme/components/MuiMenuItem.ts +0 -15
  331. package/src/theme/components/MuiSelect.ts +0 -16
  332. package/src/theme/components/MuiTab.ts +0 -29
  333. package/src/theme/components/MuiTable.ts +0 -29
  334. package/src/theme/components/MuiTableBody.ts +0 -15
  335. package/src/theme/components/MuiTableHead.ts +0 -26
  336. package/src/theme/components/MuiTabs.ts +0 -26
  337. package/src/theme/components/MuiTextField.ts +0 -86
  338. package/src/theme/components/MuiToolbar.ts +0 -11
  339. package/src/theme/components/MuiTypography.ts +0 -12
  340. package/src/theme/components/_components.ts +0 -95
  341. package/src/theme/components/index.ts +0 -57
  342. package/src/theme/index.ts +0 -25
  343. package/src/theme/palette.ts +0 -98
  344. package/src/theme/spacing.ts +0 -8
  345. package/src/theme/typography.ts +0 -101
  346. package/src/utils/api.test.ts +0 -19
  347. package/src/utils/api.tsx +0 -339
  348. package/src/utils/auth.ts +0 -78
  349. package/src/utils/form.test.ts +0 -50
  350. package/src/utils/form.ts +0 -193
  351. package/src/utils/general.test.ts +0 -55
  352. package/src/utils/router.test.ts +0 -156
  353. package/src/utils/router.ts +0 -67
  354. package/src/utils/schema.ts +0 -290
  355. package/src/utils/store.ts +0 -31
  356. package/src/utils/test.tsx +0 -82
  357. package/src/utils/theme.tsx +0 -83
  358. package/src/utils/window.ts +0 -11
  359. package/src/vite-env.d.ts +0 -1
  360. package/tsconfig.app.json +0 -4
  361. package/tsconfig.json +0 -7
  362. package/tsconfig.node.json +0 -4
  363. package/types/fixes.d.ts +0 -18
  364. package/vite.config.ts +0 -23
package/src/server.js DELETED
@@ -1,187 +0,0 @@
1
- /**
2
- * © Ocado Group
3
- * Created on 13/12/2024 at 12:15:05(+00:00).
4
- *
5
- * A server for an app in a live environment.
6
- * Based off: https://github.com/bluwy/create-vite-extra/blob/master/template-ssr-react-ts/server.js
7
- */
8
-
9
- import fs from "node:fs/promises"
10
- import express from "express"
11
- import { Cache } from "memory-cache"
12
-
13
- export default class Server {
14
- constructor(
15
- /** @type {Partial<{ mode: "development" | "staging" | "production"; port: number; base: string }>} */
16
- { mode, port, base } = {},
17
- ) {
18
- /** @type {boolean} */
19
- this.envIsProduction = process.env.NODE_ENV === "production"
20
- /** @type {string} */
21
- this.templateHtml = ""
22
- /** @type {string} */
23
- this.hostname = this.envIsProduction ? "0.0.0.0" : "127.0.0.1"
24
-
25
- /** @type {"development" | "staging" | "production"} */
26
- this.mode = mode || process.env.MODE || "development"
27
- /** @type {number} */
28
- this.port =
29
- port ||
30
- (process.env.PORT
31
- ? Number(process.env.PORT)
32
- : this.envIsProduction
33
- ? 8080
34
- : 5173)
35
- /** @type {string} */
36
- this.base = base || process.env.BASE || "/"
37
-
38
- /** @type {import('express').Express} */
39
- this.app = express()
40
- /** @type {import('vite').ViteDevServer | undefined} */
41
- this.vite = undefined
42
- /** @type {import('memory-cache').Cache<string, any>} */
43
- this.cache = new Cache()
44
-
45
- /** @type {string} */
46
- this.healthCheckCacheKey = "health-check"
47
- /** @type {number} */
48
- this.healthCheckCacheTimeout = 30000
49
- /** @type {Record<"healthy" | "startingUp" | "shuttingDown" | "unhealthy" | "unknown", number>} */
50
- this.healthCheckStatusCodes = {
51
- // The app is running normally.
52
- healthy: 200,
53
- // The app is performing app-specific initialisation which must
54
- // complete before it will serve normal application requests
55
- // (perhaps the app is warming a cache or something similar). You
56
- // only need to use this status if your app will be in a start-up
57
- // mode for a prolonged period of time.
58
- startingUp: 503,
59
- // The app is shutting down. As with startingUp, you only need to
60
- // use this status if your app takes a prolonged amount of time
61
- // to shutdown, perhaps because it waits for a long-running
62
- // process to complete before shutting down.
63
- shuttingDown: 503,
64
- // The app is not running normally.
65
- unhealthy: 503,
66
- // The app is not able to report its own state.
67
- unknown: 503,
68
- }
69
- }
70
-
71
- /** @type {(request: import('express').Request) => { healthStatus: "healthy" | "startingUp" | "shuttingDown" | "unhealthy" | "unknown"; additionalInfo: string; details?: Array<{ name: string; description: string; health: "healthy" | "startingUp" | "shuttingDown" | "unhealthy" | "unknown" }> }} */
72
- getHealthCheck(request) {
73
- return {
74
- healthStatus: "healthy",
75
- additionalInfo: "All healthy.",
76
- }
77
- }
78
-
79
- /** @type {(request: import('express').Request, response: import('express').Response) => void} */
80
- handleHealthCheck(request, response) {
81
- /** @type {{ appId: string; healthStatus: "healthy" | "startingUp" | "shuttingDown" | "unhealthy" | "unknown"; lastCheckedTimestamp: string; additionalInformation: string; startupTimestamp: string; appVersion: string; details: Array<{ name: string; description: string; health: "healthy" | "startingUp" | "shuttingDown" | "unhealthy" | "unknown" }> }} */
82
- let value = this.cache.get(this.healthCheckCacheKey)
83
- if (value === null) {
84
- const healthCheck = this.getHealthCheck(request)
85
-
86
- if (healthCheck.healthStatus !== "healthy") {
87
- console.warn(`health check: ${JSON.stringify(healthCheck)}`)
88
- }
89
-
90
- value = {
91
- appId: process.env.APP_ID || "REPLACE_ME",
92
- healthStatus: healthCheck.healthStatus,
93
- lastCheckedTimestamp: new Date().toISOString(),
94
- additionalInformation: healthCheck.additionalInfo,
95
- startupTimestamp: new Date().toISOString(),
96
- appVersion: process.env.APP_VERSION || "REPLACE_ME",
97
- details: healthCheck.details || [],
98
- }
99
-
100
- this.cache.put(
101
- this.healthCheckCacheKey,
102
- value,
103
- this.healthCheckCacheTimeout,
104
- )
105
- }
106
-
107
- response.status(this.healthCheckStatusCodes[value.healthStatus]).json(value)
108
- }
109
-
110
- /** @type {(request: import('express').Request, response: import('express').Response) => Promise<void>} */
111
- async handleServeHtml(request, response) {
112
- try {
113
- const path = request.originalUrl.replace(this.base, "")
114
-
115
- /** @type {string} */
116
- let template
117
- /** @type {(path: string) => Promise<{ head?: string; html?: string }>} */
118
- let render
119
- if (this.envIsProduction) {
120
- render = (await import("../../../dist/server/entry-server.js")).render
121
-
122
- // Use cached template.
123
- template = this.templateHtml
124
- } else {
125
- render = (await this.vite.ssrLoadModule("/src/entry-server.tsx")).render
126
-
127
- // Always read fresh template.
128
- template = await fs.readFile("./index.html", "utf-8")
129
- template = await this.vite.transformIndexHtml(path, template)
130
- }
131
-
132
- const rendered = await render(path)
133
-
134
- const html = template
135
- .replace(`<!--app-head-->`, rendered.head ?? "")
136
- .replace(`<!--app-html-->`, rendered.html ?? "")
137
-
138
- response.status(200).set({ "Content-Type": "text/html" }).send(html)
139
- } catch (error) {
140
- this.vite?.ssrFixStacktrace(error)
141
- console.error(error.stack)
142
- response.status(500).end(this.envIsProduction ? undefined : error.stack)
143
- }
144
- }
145
-
146
- async run() {
147
- this.app.get("/health-check", (request, response) => {
148
- this.handleHealthCheck(request, response)
149
- })
150
-
151
- if (this.envIsProduction) {
152
- const compression = (await import("compression")).default
153
- const sirv = (await import("sirv")).default
154
-
155
- this.templateHtml = await fs.readFile("./dist/client/index.html", "utf-8")
156
-
157
- this.app.use(compression())
158
- this.app.use(this.base, sirv("./dist/client", { extensions: [] }))
159
- } else {
160
- const { createServer } = await import("vite")
161
-
162
- this.vite = await createServer({
163
- server: { middlewareMode: true },
164
- appType: "custom",
165
- base: this.base,
166
- mode: this.mode,
167
- })
168
-
169
- this.app.use(this.vite.middlewares)
170
- }
171
-
172
- this.app.get("*", async (request, response) => {
173
- await this.handleServeHtml(request, response)
174
- })
175
-
176
- this.app.listen(this.port, this.hostname, () => {
177
- let startMessage =
178
- "Server started.\n" +
179
- `url: http://${this.hostname}:${this.port}\n` +
180
- `environment: ${process.env.NODE_ENV}\n`
181
-
182
- if (!this.envIsProduction) startMessage += `mode: ${this.mode}\n`
183
-
184
- console.log(startMessage)
185
- })
186
- }
187
- }
@@ -1,22 +0,0 @@
1
- /**
2
- * This file contains all of our custom settings we define for our own purposes.
3
- *
4
- * This file is based on:
5
- * https://github.com/ocadotechnology/codeforlife-package-python/blob/main/codeforlife/settings/custom.py
6
- */
7
-
8
- // Shorthand to access environment variables.
9
- const env = import.meta.env as Record<string, string | undefined>
10
-
11
- // The name of the current service.
12
- export const SERVICE_NAME = env.VITE_SERVICE_NAME ?? "REPLACE_ME"
13
-
14
- // The api url of the current service.
15
- export const SERVICE_API_URL =
16
- env.VITE_SERVICE_API_URL ?? "http://localhost:8000"
17
-
18
- // The names of cookies.
19
- export const CSRF_COOKIE_NAME = `${SERVICE_NAME}_csrftoken`
20
- export const SESSION_COOKIE_NAME = env.VITE_SESSION_COOKIE_NAME ?? "session_key"
21
- export const SESSION_METADATA_COOKIE_NAME =
22
- env.VITE_SESSION_METADATA_COOKIE_NAME ?? "session_metadata"
@@ -1,7 +0,0 @@
1
- // Shorthand to access environment variables.
2
- export default new Proxy(import.meta.env, {
3
- get: (target, name: string) => target[`VITE_${name}`] as string,
4
- }) as Record<string, string>
5
-
6
- export * from "./custom"
7
- export * from "./vite"
@@ -1,26 +0,0 @@
1
- /**
2
- * This file contains all of vite's environment variables.
3
- *
4
- * https://vite.dev/guide/env-and-mode#env-variables
5
- */
6
-
7
- // Shorthand to access environment variables.
8
- const env = import.meta.env
9
-
10
- // The mode the app is running in.
11
- export const MODE = env.MODE
12
-
13
- // The base url the app is being served from.
14
- // This is determined by the base config option.
15
- export const BASE_URL = env.BASE_URL
16
-
17
- // Whether the app is running in production (running the dev server with
18
- // NODE_ENV='production' or running an app built with NODE_ENV='production').
19
- export const PROD = env.PROD
20
-
21
- // Whether the app is running in development (always the opposite of
22
- // import.meta.env.PROD)
23
- export const DEV = env.DEV
24
-
25
- // Whether the app is running in the server.
26
- export const SSR = env.SSR
package/src/setupTests.ts DELETED
@@ -1,2 +0,0 @@
1
- // TODO: investigate if this can be moved to the workspace
2
- import "@testing-library/jest-dom/vitest"
@@ -1,8 +0,0 @@
1
- import { asyncThunkCreator, buildCreateSlice } from "@reduxjs/toolkit"
2
-
3
- // `buildCreateSlice` allows us to create a slice with async thunks.
4
- const createSlice = buildCreateSlice({
5
- creators: { asyncThunk: asyncThunkCreator },
6
- })
7
-
8
- export default createSlice
@@ -1,2 +0,0 @@
1
- export { default as createSlice } from "./createSlice"
2
- export { default as sessionSlice, type SessionState } from "./session"
@@ -1,32 +0,0 @@
1
- import Cookies from "js-cookie"
2
-
3
- import { SESSION_METADATA_COOKIE_NAME } from "../settings"
4
- import createSlice from "./createSlice"
5
-
6
- export interface SessionState {
7
- isLoggedIn: boolean
8
- }
9
-
10
- const initialState: SessionState = {
11
- isLoggedIn: Boolean(Cookies.get(SESSION_METADATA_COOKIE_NAME)),
12
- }
13
-
14
- const sessionSlice = createSlice({
15
- name: "session",
16
- initialState,
17
- reducers: create => ({
18
- login: create.reducer(state => {
19
- state.isLoggedIn = true
20
- }),
21
- logout: create.reducer(state => {
22
- state.isLoggedIn = false
23
- }),
24
- }),
25
- selectors: {
26
- selectIsLoggedIn: session => session.isLoggedIn,
27
- },
28
- })
29
-
30
- export default sessionSlice
31
- export const { login, logout } = sessionSlice.actions
32
- export const { selectIsLoggedIn } = sessionSlice.selectors
@@ -1,265 +0,0 @@
1
- import {
2
- Box,
3
- type BoxProps,
4
- type CSSObject,
5
- type PaletteColor,
6
- type SxProps,
7
- type ThemeOptions,
8
- ThemeProvider,
9
- buttonClasses,
10
- createTheme,
11
- responsiveFontSizes,
12
- } from "@mui/material"
13
- import {
14
- Circle as CircleIcon,
15
- Hexagon as HexagonIcon,
16
- } from "@mui/icons-material"
17
- import { type CommonProps } from "@mui/material/OverridableComponent"
18
- import type React from "react"
19
-
20
- import { getStyleOverrides, includesClassNames } from "../utils/theme"
21
- import { primary, secondary, tertiary } from "./colors"
22
- import type Components from "./components/_components"
23
- import palette from "./palette"
24
- import { themeOptions } from "."
25
-
26
- export interface ThemedBoxProps extends BoxProps {
27
- options?: ThemeOptions
28
- withShapes?: boolean
29
- userType: "teacher" | "student" | "independent"
30
- bgcolor?: string
31
- }
32
-
33
- const ThemedBox: React.FC<ThemedBoxProps> = ({
34
- options = themeOptions,
35
- withShapes = false,
36
- userType,
37
- bgcolor,
38
- children,
39
- sx,
40
- ...otherBoxProps
41
- }) => {
42
- let circleColor: "primary" | "secondary" | "tertiary"
43
- let hexagonColor: "primary" | "secondary" | "tertiary"
44
- let contrastText: string
45
- switch (userType) {
46
- case "teacher":
47
- bgcolor = bgcolor ?? primary[400]
48
- circleColor = "tertiary"
49
- hexagonColor = "secondary"
50
- contrastText = (palette.primary as PaletteColor).contrastText
51
- break
52
- case "student":
53
- bgcolor = bgcolor ?? tertiary[500]
54
- circleColor = "secondary"
55
- hexagonColor = "primary"
56
- contrastText = palette.tertiary.contrastText
57
- break
58
- case "independent":
59
- bgcolor = bgcolor ?? secondary[500]
60
- circleColor = "primary"
61
- hexagonColor = "tertiary"
62
- contrastText = (palette.secondary as PaletteColor).contrastText
63
- break
64
- }
65
-
66
- const commonIconSxProps: SxProps = {
67
- display: { xs: "none", md: "block" },
68
- fontSize: "180px",
69
- position: "absolute",
70
- }
71
-
72
- const fontStyleOverrides = {
73
- color: contrastText,
74
- textDecorationColor: contrastText,
75
- }
76
-
77
- function overrideStyles(
78
- ownerState: CommonProps,
79
- styleOverrides: CSSObject,
80
- componentKey: keyof Components,
81
- muiClassName: string = "root",
82
- ): CSSObject {
83
- return {
84
- // Get the original styles.
85
- ...getStyleOverrides(
86
- ownerState,
87
- componentKey,
88
- muiClassName,
89
- options.components,
90
- ),
91
- // Override styles unless the class name 'no-override' is set.
92
- ...(!includesClassNames(ownerState, ["no-override"]) && styleOverrides),
93
- }
94
- }
95
-
96
- const theme = responsiveFontSizes(
97
- createTheme({
98
- ...options,
99
- components: {
100
- ...options.components,
101
- MuiTypography: {
102
- ...options.components?.MuiTypography,
103
- styleOverrides: {
104
- ...options.components?.MuiTypography?.styleOverrides,
105
- root: ({ ownerState }) =>
106
- overrideStyles(
107
- ownerState,
108
- {
109
- ...fontStyleOverrides,
110
- },
111
- "MuiTypography",
112
- ),
113
- },
114
- },
115
- MuiFormHelperText: {
116
- ...options.components?.MuiFormHelperText,
117
- styleOverrides: {
118
- ...options.components?.MuiFormHelperText?.styleOverrides,
119
- root: ({ ownerState }) =>
120
- overrideStyles(
121
- ownerState,
122
- {
123
- ...fontStyleOverrides,
124
- },
125
- "MuiFormHelperText",
126
- ),
127
- },
128
- },
129
- MuiLink: {
130
- ...options.components?.MuiLink,
131
- styleOverrides: {
132
- ...options.components?.MuiLink?.styleOverrides,
133
- root: ({ ownerState }) =>
134
- overrideStyles(
135
- ownerState,
136
- {
137
- ...fontStyleOverrides,
138
- },
139
- "MuiLink",
140
- ),
141
- },
142
- },
143
- MuiButton: {
144
- ...options.components?.MuiButton,
145
- styleOverrides: {
146
- ...options.components?.MuiButton?.styleOverrides,
147
- contained: ({ ownerState }) =>
148
- overrideStyles(
149
- ownerState,
150
- {
151
- ...(userType === "independent" && {
152
- backgroundColor: "white",
153
- "&:hover": {
154
- backgroundColor: "#f6f5f5",
155
- boxShadow: [
156
- "0px 6px 10px 0px rgba(0, 0, 0, 0.14)",
157
- "0px 1px 18px 0px rgba(0, 0, 0, 0.12)",
158
- "0px 3px 5px 0px rgba(0, 0, 0, 0.2);",
159
- ].join(),
160
- },
161
- [`&.${buttonClasses.disabled}`]: {
162
- backgroundColor: "white",
163
- color: contrastText,
164
- },
165
- }),
166
- },
167
- "MuiButton",
168
- "contained",
169
- ),
170
- outlined: ({ ownerState }) =>
171
- overrideStyles(
172
- ownerState,
173
- {
174
- ...fontStyleOverrides,
175
- border: `2px solid ${contrastText}`,
176
- "&:hover": {
177
- border: `2px solid ${contrastText}`,
178
- backgroundColor: "transparent",
179
- textDecoration: "underline",
180
- },
181
- },
182
- "MuiButton",
183
- "outlined",
184
- ),
185
- },
186
- },
187
- MuiCheckbox: {
188
- ...options.components?.MuiCheckbox,
189
- styleOverrides: {
190
- ...options.components?.MuiCheckbox?.styleOverrides,
191
- root: ({ ownerState }) =>
192
- overrideStyles(
193
- ownerState,
194
- {
195
- color: `${contrastText} !important`,
196
- },
197
- "MuiCheckbox",
198
- ),
199
- },
200
- },
201
- MuiSvgIcon: {
202
- ...options.components?.MuiSvgIcon,
203
- styleOverrides: {
204
- ...options.components?.MuiSvgIcon?.styleOverrides,
205
- root: ({ ownerState }) =>
206
- overrideStyles(
207
- ownerState,
208
- {
209
- "&.checkbox-error": {
210
- color: `${contrastText} !important`,
211
- },
212
- },
213
- "MuiSvgIcon",
214
- ),
215
- },
216
- },
217
- },
218
- }),
219
- )
220
-
221
- return (
222
- <ThemeProvider theme={theme}>
223
- <Box
224
- sx={{
225
- ...sx,
226
- ...(withShapes && {
227
- paddingY: { xs: 2, sm: 3, md: 5 },
228
- paddingX: { xs: 2, sm: 5, md: 10 },
229
- marginX: { md: "90px" },
230
- }),
231
- bgcolor,
232
- alignItems: "center",
233
- position: "relative",
234
- }}
235
- {...otherBoxProps}
236
- >
237
- {withShapes && (
238
- <>
239
- <CircleIcon
240
- color={circleColor}
241
- sx={{
242
- ...commonIconSxProps,
243
- top: "5%",
244
- left: "0%",
245
- transform: "translate(-60%, 0%)",
246
- }}
247
- />
248
- <HexagonIcon
249
- color={hexagonColor}
250
- sx={{
251
- ...commonIconSxProps,
252
- bottom: "5%",
253
- right: "0%",
254
- transform: "translate(60%, 0%) rotate(90deg)",
255
- }}
256
- />
257
- </>
258
- )}
259
- {children}
260
- </Box>
261
- </ThemeProvider>
262
- )
263
- }
264
-
265
- export default ThemedBox
@@ -1,57 +0,0 @@
1
- export default interface Color {
2
- 900: string
3
- 800: string
4
- 700: string
5
- 600: string
6
- 500: string
7
- 400: string
8
- 300: string
9
- 200: string
10
- 100: string
11
- 50: string
12
- }
13
-
14
- // primary / teacher
15
- export const primary: Color = {
16
- 900: "#A60039",
17
- 800: "#BE0947",
18
- 700: "#C90548",
19
- 600: "#D40149",
20
- 500: "#E0004D",
21
- 400: "#EE0857",
22
- 300: "#FA1664",
23
- 200: "#FF397C",
24
- 100: "#FF6699",
25
- 50: "#FF9ABC",
26
- }
27
- export { primary as teacher }
28
-
29
- // secondary / indy
30
- export const secondary: Color = {
31
- 900: "#BF9400",
32
- 800: "#CFA30B",
33
- 700: "#DEAD06",
34
- 600: "#EAB502",
35
- 500: "#F6BE00",
36
- 400: "#FFC709",
37
- 300: "#FFD23D",
38
- 200: "#FFDA5C",
39
- 100: "#FFE382",
40
- 50: "#FFEDAD",
41
- }
42
- export { secondary as indy }
43
-
44
- // tertiary / student
45
- export const tertiary: Color = {
46
- 900: "#01668C",
47
- 800: "#007FAF",
48
- 700: "#008CC1",
49
- 600: "#0099D2",
50
- 500: "#00A3E0",
51
- 400: "#04AFEF",
52
- 300: "#08BAFC",
53
- 200: "#27C4FF",
54
- 100: "#4DCEFF",
55
- 50: "#85DDFF",
56
- }
57
- export { tertiary as student }
@@ -1,13 +0,0 @@
1
- import type Components from "./_components"
2
-
3
- const MuiAccordion: Components["MuiAccordion"] = {
4
- styleOverrides: {
5
- root: {
6
- borderRadius: "0px !important",
7
- margin: "0px !important",
8
- width: "100%",
9
- },
10
- },
11
- }
12
-
13
- export default MuiAccordion
@@ -1,11 +0,0 @@
1
- import type Components from "./_components"
2
-
3
- const MuiAutocomplete: Components["MuiAutocomplete"] = {
4
- styleOverrides: {
5
- root: {
6
- width: "100%",
7
- },
8
- },
9
- }
10
-
11
- export default MuiAutocomplete