@jmruthers/pace-core 0.5.68 → 0.5.70

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 (394) hide show
  1. package/dist/{DataTable-4IUY7BXB.js → DataTable-OSELOGMA.js} +6 -6
  2. package/dist/{PublicLoadingSpinner-DdKXTkCZ.d.ts → PublicLoadingSpinner-DLpF5bbs.d.ts} +78 -2
  3. package/dist/{chunk-OPCWH3A4.js → chunk-4YMVZ76F.js} +7 -6
  4. package/dist/chunk-4YMVZ76F.js.map +1 -0
  5. package/dist/{chunk-NN45OBIS.js → chunk-5G7JA3L5.js} +3 -5
  6. package/dist/{chunk-NN45OBIS.js.map → chunk-5G7JA3L5.js.map} +1 -1
  7. package/dist/{chunk-U6GPOF6J.js → chunk-5NV76BYF.js} +666 -110
  8. package/dist/chunk-5NV76BYF.js.map +1 -0
  9. package/dist/{chunk-D7ARGIA3.js → chunk-6RBH67W7.js} +23 -6
  10. package/dist/chunk-6RBH67W7.js.map +1 -0
  11. package/dist/{chunk-ZPG4XPV5.js → chunk-BHBMXMLT.js} +5 -7
  12. package/dist/chunk-BHBMXMLT.js.map +1 -0
  13. package/dist/{chunk-ZMS23NS5.js → chunk-FOT3WUV6.js} +3 -5
  14. package/dist/{chunk-ZMS23NS5.js.map → chunk-FOT3WUV6.js.map} +1 -1
  15. package/dist/{chunk-MOJXHWDE.js → chunk-GCUIIBLB.js} +382 -5
  16. package/dist/chunk-GCUIIBLB.js.map +1 -0
  17. package/dist/{chunk-PXWEDX7Y.js → chunk-KWQH4VO3.js} +3 -3
  18. package/dist/{chunk-ZPK5656W.js → chunk-O3NWNXDY.js} +4 -5
  19. package/dist/chunk-O3NWNXDY.js.map +1 -0
  20. package/dist/{chunk-KRCRNXPD.js → chunk-OTJUAYBG.js} +81 -18
  21. package/dist/chunk-OTJUAYBG.js.map +1 -0
  22. package/dist/chunk-SMJZMKYN.js +141 -0
  23. package/dist/chunk-SMJZMKYN.js.map +1 -0
  24. package/dist/{chunk-UYA6U6H7.js → chunk-V2TE7LOF.js} +4 -4
  25. package/dist/{chunk-L3RV2ALE.js → chunk-VKOCWWVY.js} +6 -1
  26. package/dist/{chunk-L3RV2ALE.js.map → chunk-VKOCWWVY.js.map} +1 -1
  27. package/dist/components.d.ts +4 -79
  28. package/dist/components.js +23 -581
  29. package/dist/components.js.map +1 -1
  30. package/dist/hooks.d.ts +1 -1
  31. package/dist/hooks.js +9 -6
  32. package/dist/hooks.js.map +1 -1
  33. package/dist/index.d.ts +4 -3
  34. package/dist/index.js +32 -19
  35. package/dist/index.js.map +1 -1
  36. package/dist/providers.js +6 -7
  37. package/dist/rbac/index.js +6 -6
  38. package/dist/styles/index.js +2 -2
  39. package/dist/theming/runtime.d.ts +4 -3
  40. package/dist/theming/runtime.js +3 -1
  41. package/dist/{usePublicRouteParams-CdoFxnJK.d.ts → usePublicRouteParams-Ua1Vz-HG.d.ts} +35 -1
  42. package/dist/utils.d.ts +4 -1
  43. package/dist/utils.js +3 -3
  44. package/docs/DOCUMENTATION_CHECKLIST.md +281 -0
  45. package/docs/README.md +22 -10
  46. package/docs/api/classes/ColumnFactory.md +1 -1
  47. package/docs/api/classes/ErrorBoundary.md +1 -1
  48. package/docs/api/classes/InvalidScopeError.md +1 -1
  49. package/docs/api/classes/MissingUserContextError.md +1 -1
  50. package/docs/api/classes/OrganisationContextRequiredError.md +1 -1
  51. package/docs/api/classes/PermissionDeniedError.md +1 -1
  52. package/docs/api/classes/PublicErrorBoundary.md +1 -1
  53. package/docs/api/classes/RBACAuditManager.md +1 -1
  54. package/docs/api/classes/RBACCache.md +1 -1
  55. package/docs/api/classes/RBACEngine.md +1 -1
  56. package/docs/api/classes/RBACError.md +1 -1
  57. package/docs/api/classes/RBACNotInitializedError.md +1 -1
  58. package/docs/api/classes/SecureSupabaseClient.md +1 -1
  59. package/docs/api/classes/StorageUtils.md +1 -1
  60. package/docs/api/enums/FileCategory.md +129 -0
  61. package/docs/api/interfaces/AggregateConfig.md +1 -1
  62. package/docs/api/interfaces/ButtonProps.md +1 -1
  63. package/docs/api/interfaces/CardProps.md +1 -1
  64. package/docs/api/interfaces/ColorPalette.md +1 -1
  65. package/docs/api/interfaces/ColorShade.md +1 -1
  66. package/docs/api/interfaces/DataAccessRecord.md +1 -1
  67. package/docs/api/interfaces/DataTableAction.md +1 -1
  68. package/docs/api/interfaces/DataTableColumn.md +1 -1
  69. package/docs/api/interfaces/DataTableProps.md +1 -1
  70. package/docs/api/interfaces/DataTableToolbarButton.md +1 -1
  71. package/docs/api/interfaces/EmptyStateConfig.md +1 -1
  72. package/docs/api/interfaces/EnhancedNavigationMenuProps.md +1 -1
  73. package/docs/api/interfaces/EventContextType.md +7 -7
  74. package/docs/api/interfaces/EventLogoProps.md +1 -1
  75. package/docs/api/interfaces/EventProviderProps.md +2 -2
  76. package/docs/api/interfaces/FileDisplayProps.md +107 -0
  77. package/docs/api/interfaces/FileMetadata.md +129 -0
  78. package/docs/api/interfaces/FileReference.md +118 -0
  79. package/docs/api/interfaces/FileSizeLimits.md +1 -1
  80. package/docs/api/interfaces/FileUploadOptions.md +85 -0
  81. package/docs/api/interfaces/FileUploadProps.md +1 -1
  82. package/docs/api/interfaces/FooterProps.md +1 -1
  83. package/docs/api/interfaces/InactivityWarningModalProps.md +1 -1
  84. package/docs/api/interfaces/InputProps.md +1 -1
  85. package/docs/api/interfaces/LabelProps.md +1 -1
  86. package/docs/api/interfaces/LoginFormProps.md +1 -1
  87. package/docs/api/interfaces/NavigationAccessRecord.md +1 -1
  88. package/docs/api/interfaces/NavigationContextType.md +1 -1
  89. package/docs/api/interfaces/NavigationGuardProps.md +1 -1
  90. package/docs/api/interfaces/NavigationItem.md +1 -1
  91. package/docs/api/interfaces/NavigationMenuProps.md +1 -1
  92. package/docs/api/interfaces/NavigationProviderProps.md +1 -1
  93. package/docs/api/interfaces/Organisation.md +1 -1
  94. package/docs/api/interfaces/OrganisationContextType.md +1 -1
  95. package/docs/api/interfaces/OrganisationMembership.md +1 -1
  96. package/docs/api/interfaces/OrganisationProviderProps.md +1 -1
  97. package/docs/api/interfaces/OrganisationSecurityError.md +1 -1
  98. package/docs/api/interfaces/PaceAppLayoutProps.md +1 -1
  99. package/docs/api/interfaces/PaceLoginPageProps.md +1 -1
  100. package/docs/api/interfaces/PageAccessRecord.md +1 -1
  101. package/docs/api/interfaces/PagePermissionContextType.md +1 -1
  102. package/docs/api/interfaces/PagePermissionGuardProps.md +1 -1
  103. package/docs/api/interfaces/PagePermissionProviderProps.md +1 -1
  104. package/docs/api/interfaces/PaletteData.md +1 -1
  105. package/docs/api/interfaces/PermissionEnforcerProps.md +1 -1
  106. package/docs/api/interfaces/PublicErrorBoundaryProps.md +1 -1
  107. package/docs/api/interfaces/PublicErrorBoundaryState.md +1 -1
  108. package/docs/api/interfaces/PublicLoadingSpinnerProps.md +1 -1
  109. package/docs/api/interfaces/PublicPageFooterProps.md +1 -1
  110. package/docs/api/interfaces/PublicPageHeaderProps.md +2 -2
  111. package/docs/api/interfaces/PublicPageLayoutProps.md +1 -1
  112. package/docs/api/interfaces/RBACConfig.md +1 -1
  113. package/docs/api/interfaces/RBACContextType.md +1 -1
  114. package/docs/api/interfaces/RBACLogger.md +1 -1
  115. package/docs/api/interfaces/RBACProviderProps.md +1 -1
  116. package/docs/api/interfaces/RoleBasedRouterContextType.md +1 -1
  117. package/docs/api/interfaces/RoleBasedRouterProps.md +1 -1
  118. package/docs/api/interfaces/RouteAccessRecord.md +1 -1
  119. package/docs/api/interfaces/RouteConfig.md +1 -1
  120. package/docs/api/interfaces/SecureDataContextType.md +1 -1
  121. package/docs/api/interfaces/SecureDataProviderProps.md +1 -1
  122. package/docs/api/interfaces/StorageConfig.md +1 -1
  123. package/docs/api/interfaces/StorageFileInfo.md +1 -1
  124. package/docs/api/interfaces/StorageFileMetadata.md +1 -1
  125. package/docs/api/interfaces/StorageListOptions.md +1 -1
  126. package/docs/api/interfaces/StorageListResult.md +1 -1
  127. package/docs/api/interfaces/StorageUploadOptions.md +1 -1
  128. package/docs/api/interfaces/StorageUploadResult.md +1 -1
  129. package/docs/api/interfaces/StorageUrlOptions.md +1 -1
  130. package/docs/api/interfaces/StyleImport.md +1 -1
  131. package/docs/api/interfaces/SwitchProps.md +1 -1
  132. package/docs/api/interfaces/ToastActionElement.md +1 -1
  133. package/docs/api/interfaces/ToastProps.md +1 -1
  134. package/docs/api/interfaces/UnifiedAuthContextType.md +1 -1
  135. package/docs/api/interfaces/UnifiedAuthProviderProps.md +1 -1
  136. package/docs/api/interfaces/UseInactivityTrackerOptions.md +1 -1
  137. package/docs/api/interfaces/UseInactivityTrackerReturn.md +1 -1
  138. package/docs/api/interfaces/UsePublicEventLogoOptions.md +1 -1
  139. package/docs/api/interfaces/UsePublicEventLogoReturn.md +1 -1
  140. package/docs/api/interfaces/UsePublicEventOptions.md +1 -1
  141. package/docs/api/interfaces/UsePublicEventReturn.md +1 -1
  142. package/docs/api/interfaces/UsePublicRouteParamsReturn.md +1 -1
  143. package/docs/api/interfaces/UserEventAccess.md +1 -1
  144. package/docs/api/interfaces/UserMenuProps.md +1 -1
  145. package/docs/api/interfaces/UserProfile.md +1 -1
  146. package/docs/api/modules.md +228 -23
  147. package/docs/architecture/services.md +374 -0
  148. package/docs/best-practices/README.md +1 -1
  149. package/docs/best-practices/testing.md +1 -1
  150. package/docs/breaking-changes.md +182 -0
  151. package/docs/common-patterns.md +445 -0
  152. package/docs/core-concepts/authentication.md +26 -11
  153. package/docs/core-concepts/events.md +2 -0
  154. package/docs/core-concepts/organisations.md +2 -0
  155. package/docs/core-concepts/permissions.md +2 -0
  156. package/docs/{INDEX.md → documentation-index.md} +26 -38
  157. package/docs/faq.md +286 -0
  158. package/docs/{FILE_REFERENCE_SYSTEM.md → file-reference-system.md} +1 -1
  159. package/docs/getting-started/installation-guide.md +284 -0
  160. package/docs/getting-started/quick-start.md +8 -1
  161. package/docs/implementation-guides/app-layout.md +3 -1
  162. package/docs/implementation-guides/data-tables.md +2 -0
  163. package/docs/implementation-guides/dynamic-colors.md +47 -2
  164. package/docs/implementation-guides/event-theming-summary.md +220 -0
  165. package/docs/implementation-guides/forms.md +9 -7
  166. package/docs/implementation-guides/navigation.md +2 -0
  167. package/docs/migration/service-architecture.md +351 -0
  168. package/docs/rbac/README-rbac-rls-integration.md +2 -2
  169. package/docs/rbac/README.md +1 -1
  170. package/docs/rbac/examples/rbac-rls-integration-example.md +3 -3
  171. package/docs/rbac/quick-start.md +2 -0
  172. package/docs/rbac/rbac-rls-integration.md +2 -2
  173. package/docs/style-guide.md +136 -1
  174. package/docs/testing/README.md +1 -1
  175. package/docs/troubleshooting/authentication-issues.md +334 -0
  176. package/docs/troubleshooting/common-issues.md +2 -0
  177. package/docs/troubleshooting/styling-issues.md +199 -144
  178. package/docs/usage.md +23 -2
  179. package/package.json +3 -2
  180. package/src/__tests__/{TESTING_GUIDELINES.md → TEST_GUIDE_CURSOR.md} +20 -0
  181. package/src/__tests__/TEST_GUIDE_HUMAN.md +103 -0
  182. package/src/__tests__/fixtures/test-data.ts +90 -0
  183. package/src/__tests__/helpers/__tests__/component-test-utils.test.tsx +260 -0
  184. package/src/__tests__/helpers/__tests__/optimized-test-setup.test.ts +224 -0
  185. package/src/__tests__/helpers/__tests__/supabaseMock.test.ts +273 -0
  186. package/src/__tests__/helpers/__tests__/test-providers.test.tsx +98 -0
  187. package/src/__tests__/helpers/__tests__/test-utils.test.tsx +436 -0
  188. package/src/__tests__/helpers/__tests__/timer-utils.test.ts +371 -0
  189. package/src/__tests__/helpers/component-test-utils.tsx +14 -4
  190. package/src/__tests__/helpers/optimized-test-setup.ts +68 -0
  191. package/src/__tests__/helpers/test-providers.tsx +329 -0
  192. package/src/__tests__/helpers/test-utils.tsx +91 -45
  193. package/src/__tests__/helpers/timer-utils.ts +71 -0
  194. package/src/__tests__/hooks/usePermissions.test.ts +1 -5
  195. package/src/__tests__/integration/UserProfile.test.tsx +1 -5
  196. package/src/__tests__/rbac/PagePermissionGuard.test.tsx +42 -12
  197. package/src/__tests__/setup.ts +34 -28
  198. package/src/components/Alert/Alert.test.tsx +1 -5
  199. package/src/components/Avatar/Avatar.test.tsx +1 -5
  200. package/src/components/Button/Button.test.tsx +4 -20
  201. package/src/components/Card/Card.test.tsx +1 -5
  202. package/src/components/Checkbox/Checkbox.test.tsx +1 -5
  203. package/src/components/DataTable/__tests__/DataTable.comprehensive.test.tsx +1 -5
  204. package/src/components/DataTable/__tests__/DataTable.test.tsx +45 -49
  205. package/src/components/DataTable/__tests__/DataTableCore.test.tsx +1 -5
  206. package/src/components/DataTable/__tests__/styles.test.ts +382 -0
  207. package/src/components/DataTable/context/__tests__/DataTableContext.test.tsx +409 -0
  208. package/src/components/DataTable/core/__tests__/ActionManager.test.ts +634 -0
  209. package/src/components/DataTable/core/__tests__/DataManager.test.ts +519 -0
  210. package/src/components/DataTable/core/__tests__/StateManager.test.ts +714 -0
  211. package/src/components/DataTable/hooks/__tests__/useDataTableState.test.ts +592 -0
  212. package/src/components/DataTable/utils/__tests__/exportUtils.test.ts +354 -0
  213. package/src/components/DataTable/utils/__tests__/hierarchicalUtils.test.ts +539 -0
  214. package/src/components/Dialog/examples/__tests__/SmartDialogExample.unit.test.tsx +1 -5
  215. package/src/components/Dialog/utils/__tests__/safeHtml.unit.test.ts +1 -8
  216. package/src/components/ErrorBoundary/ErrorBoundary.test.tsx +34 -38
  217. package/src/components/Footer/Footer.test.tsx +1 -5
  218. package/src/components/Form/Form.test.tsx +22 -35
  219. package/src/components/Header/Header.test.tsx +1 -9
  220. package/src/components/InactivityWarningModal/InactivityWarningModal.test.tsx +1 -5
  221. package/src/components/Input/Input.test.tsx +2 -10
  222. package/src/components/LoginForm/LoginForm.test.tsx +1 -5
  223. package/src/components/NavigationMenu/NavigationMenu.test.tsx +24 -24
  224. package/src/components/PaceAppLayout/__tests__/PaceAppLayout.accessibility.test.tsx +1 -6
  225. package/src/components/PaceAppLayout/__tests__/PaceAppLayout.integration.test.tsx +6 -16
  226. package/src/components/PaceAppLayout/__tests__/PaceAppLayout.performance.test.tsx +1 -4
  227. package/src/components/PaceAppLayout/__tests__/PaceAppLayout.rbac.test.tsx +1 -5
  228. package/src/components/PaceLoginPage/PaceLoginPage.test.tsx +1 -7
  229. package/src/components/PasswordReset/PasswordChangeForm.test.tsx +1 -9
  230. package/src/components/PasswordReset/PasswordResetForm.test.tsx +1 -9
  231. package/src/components/PublicLayout/PublicErrorBoundary.tsx +4 -5
  232. package/src/components/PublicLayout/PublicPageHeader.tsx +13 -9
  233. package/src/components/PublicLayout/__tests__/EventLogo.test.tsx +666 -0
  234. package/src/components/PublicLayout/__tests__/PublicErrorBoundary.test.tsx +457 -0
  235. package/src/components/PublicLayout/__tests__/PublicLoadingSpinner.test.tsx +393 -0
  236. package/src/components/PublicLayout/__tests__/PublicPageFooter.test.tsx +351 -0
  237. package/src/components/PublicLayout/__tests__/PublicPageHeader.test.tsx +374 -0
  238. package/src/components/PublicLayout/__tests__/PublicPageLayout.test.tsx +388 -0
  239. package/src/components/Select/Select.bug-test.tsx +69 -0
  240. package/src/components/Select/Select.refactored.tsx +497 -0
  241. package/src/components/Select/Select.test.tsx +42 -49
  242. package/src/components/Select/Select.tsx +5 -2
  243. package/src/components/Select/hooks.ts +254 -0
  244. package/src/components/Switch/Switch.test.tsx +1 -5
  245. package/src/components/Table/__tests__/Table.test.tsx +775 -0
  246. package/src/components/Toast/Toast.test.tsx +15 -8
  247. package/src/components/Tooltip/Tooltip.test.tsx +1 -5
  248. package/src/components/UserMenu/UserMenu.test.tsx +3 -15
  249. package/src/components/__tests__/FileDisplay.test.tsx +575 -0
  250. package/src/components/__tests__/FileUpload.test.tsx +446 -0
  251. package/src/components/__tests__/SuperAdminGuard.test.tsx +422 -354
  252. package/src/hooks/__tests__/ServiceHooks.test.tsx +613 -0
  253. package/src/hooks/__tests__/hooks.integration.test.tsx +1 -10
  254. package/src/hooks/__tests__/useApiFetch.unit.test.ts +10 -14
  255. package/src/hooks/__tests__/useAppConfig.unit.test.ts +307 -0
  256. package/src/hooks/__tests__/useComponentPerformance.unit.test.tsx +1 -6
  257. package/src/hooks/__tests__/useFocusTrap.unit.test.tsx +1 -5
  258. package/src/hooks/__tests__/useOrganisationPermissions.unit.test.tsx +6 -9
  259. package/src/hooks/__tests__/usePublicEvent.simple.test.ts +321 -0
  260. package/src/hooks/__tests__/usePublicEvent.unit.test.ts +583 -0
  261. package/src/hooks/__tests__/usePublicEventLogo.unit.test.ts +640 -0
  262. package/src/hooks/__tests__/usePublicRouteParams.unit.test.ts +435 -0
  263. package/src/hooks/__tests__/useRBAC.unit.test.ts +10 -10
  264. package/src/hooks/__tests__/useStorage.unit.test.ts +751 -0
  265. package/src/hooks/index.ts +3 -0
  266. package/src/hooks/public/usePublicEvent.ts +30 -9
  267. package/src/hooks/public/usePublicRouteParams.ts +13 -3
  268. package/src/hooks/services/useAuth.ts +50 -0
  269. package/src/hooks/services/useAuthService.ts +30 -0
  270. package/src/hooks/services/useCurrentEvent.ts +36 -0
  271. package/src/hooks/services/useCurrentOrganisation.ts +52 -0
  272. package/src/hooks/services/useEventService.ts +30 -0
  273. package/src/hooks/services/useInactivityService.ts +30 -0
  274. package/src/hooks/services/useOrganisationService.ts +30 -0
  275. package/src/hooks/services/usePermissions.ts +70 -0
  276. package/src/hooks/services/useRBACService.ts +30 -0
  277. package/src/hooks/useCounter.test.ts +1 -5
  278. package/src/hooks/useEventTheme.ts +86 -0
  279. package/src/hooks/useOrganisationPermissions.test.ts +2 -5
  280. package/src/hooks/useOrganisationSecurity.test.ts +1 -5
  281. package/src/hooks/usePermissionCache.test.ts +1 -5
  282. package/src/hooks/usePermissionCheck.ts +150 -0
  283. package/src/hooks/useSecureDataAccess.test.ts +1 -5
  284. package/src/index.ts +7 -0
  285. package/src/providers/EventProvider.tsx +58 -2
  286. package/src/providers/OrganisationProvider.test.tsx +1 -5
  287. package/src/providers/OrganisationProvider.tsx +56 -4
  288. package/src/providers/UnifiedAuthProvider.test.tsx +1 -5
  289. package/src/providers/__tests__/AuthProvider.test.tsx +105 -439
  290. package/src/providers/__tests__/AuthProvider.test.tsx.backup +771 -0
  291. package/src/providers/__tests__/EventProvider.test.tsx +211 -110
  292. package/src/providers/__tests__/EventProvider.test.tsx.backup +824 -0
  293. package/src/providers/__tests__/InactivityProvider.test.tsx +1 -5
  294. package/src/providers/__tests__/OrganisationProvider.test.tsx +97 -261
  295. package/src/providers/__tests__/OrganisationProvider.test.tsx.backup +820 -0
  296. package/src/providers/__tests__/ServiceProviders.test.tsx +477 -0
  297. package/src/providers/__tests__/UnifiedAuthProvider.test.tsx +72 -504
  298. package/src/providers/__tests__/UnifiedAuthProvider.test.tsx.backup +911 -0
  299. package/src/providers/__tests__/UnifiedAuthProvider.test.tsx.backup2 +166 -0
  300. package/src/providers/services/AuthServiceProvider.tsx +65 -0
  301. package/src/providers/services/EventServiceProvider.tsx +83 -0
  302. package/src/providers/services/InactivityServiceProvider.tsx +83 -0
  303. package/src/providers/services/OrganisationServiceProvider.tsx +77 -0
  304. package/src/providers/services/RBACServiceProvider.tsx +79 -0
  305. package/src/providers/services/UnifiedAuthProvider.tsx +368 -0
  306. package/src/providers/services/__tests__/AuthServiceProvider.integration.test.tsx +210 -0
  307. package/src/providers/services/__tests__/UnifiedAuthProvider.integration.test.tsx +269 -0
  308. package/src/rbac/__tests__/adapters.comprehensive.test.tsx +892 -0
  309. package/src/rbac/__tests__/engine.comprehensive.test.ts +954 -0
  310. package/src/rbac/__tests__/integration.authflow.test.tsx +1 -5
  311. package/src/rbac/__tests__/integration.navigation.test.tsx +1 -4
  312. package/src/rbac/__tests__/rbac-core.test.tsx +2 -7
  313. package/src/rbac/__tests__/rbac-functions.test.ts +1 -9
  314. package/src/rbac/__tests__/rbac-integration.test.ts +1 -9
  315. package/src/rbac/api.test.ts +1 -9
  316. package/src/rbac/cache.test.ts +10 -8
  317. package/src/rbac/cli/__tests__/policy-manager.test.ts +339 -0
  318. package/src/rbac/components/EnhancedNavigationMenu.test.tsx +1 -5
  319. package/src/rbac/components/NavigationProvider.test.tsx +1 -5
  320. package/src/rbac/components/PagePermissionProvider.test.tsx +1 -5
  321. package/src/rbac/components/SecureDataProvider.test.tsx +1 -5
  322. package/src/rbac/components/__tests__/NavigationGuard.test.tsx +25 -29
  323. package/src/rbac/components/__tests__/PagePermissionGuard.test.tsx +27 -30
  324. package/src/rbac/components/__tests__/PermissionEnforcer.test.tsx +23 -27
  325. package/src/rbac/components/__tests__/RoleBasedRouter.test.tsx +18 -22
  326. package/src/rbac/config.test.ts +1 -5
  327. package/src/rbac/hooks/useCan.test.ts +262 -9
  328. package/src/rbac/hooks/usePermissions.test.ts +246 -6
  329. package/src/rbac/hooks/useRBAC.simple.test.ts +1 -5
  330. package/src/rbac/hooks/useRBAC.test.ts +472 -198
  331. package/src/rbac/providers/__tests__/RBACProvider.test.tsx +1 -9
  332. package/src/services/AuthService.ts +416 -0
  333. package/src/services/EventService.ts +366 -0
  334. package/src/services/InactivityService.ts +388 -0
  335. package/src/services/OrganisationService.ts +592 -0
  336. package/src/services/RBACService.ts +522 -0
  337. package/src/services/__tests__/AuthService.test.ts +356 -0
  338. package/src/services/__tests__/BaseService.test.ts +314 -0
  339. package/src/services/__tests__/EventService.test.ts +489 -0
  340. package/src/services/__tests__/InactivityService.test.ts +403 -0
  341. package/src/services/__tests__/OrganisationService.test.ts +660 -0
  342. package/src/services/__tests__/RBACService.test.ts +492 -0
  343. package/src/services/base/BaseService.ts +87 -0
  344. package/src/services/interfaces/IAuthService.ts +39 -0
  345. package/src/services/interfaces/IEventService.ts +30 -0
  346. package/src/services/interfaces/IInactivityService.ts +31 -0
  347. package/src/services/interfaces/IOrganisationService.ts +41 -0
  348. package/src/services/interfaces/IRBACService.ts +62 -0
  349. package/src/theming/__tests__/runtime.test.ts +560 -0
  350. package/src/theming/runtime.ts +71 -28
  351. package/src/types/__tests__/file-reference.test.ts +447 -0
  352. package/src/types/__tests__/organisation.test.ts +1133 -0
  353. package/src/types/__tests__/theme.test.ts +830 -0
  354. package/src/types/__tests__/type-validation.test.ts +527 -0
  355. package/src/utils/__tests__/bundleAnalysis.unit.test.ts +1 -5
  356. package/src/utils/__tests__/debugLogger.test.ts +417 -0
  357. package/src/utils/__tests__/deviceFingerprint.unit.test.ts +1 -6
  358. package/src/utils/__tests__/dynamicUtils.unit.test.ts +1 -5
  359. package/src/utils/__tests__/lazyLoad.unit.test.tsx +35 -35
  360. package/src/utils/__tests__/organisationContext.unit.test.ts +1 -5
  361. package/src/utils/__tests__/performanceBudgets.unit.test.ts +5 -11
  362. package/src/utils/__tests__/secureErrors.unit.test.ts +1 -6
  363. package/src/utils/__tests__/secureStorage.unit.test.ts +1 -5
  364. package/src/utils/__tests__/securityMonitor.unit.test.ts +1 -5
  365. package/src/utils/__tests__/sessionTracking.unit.test.ts +1 -5
  366. package/src/utils/appIdResolver.test.ts +6 -10
  367. package/src/utils/appNameResolver.simple.test.ts +142 -0
  368. package/src/utils/appNameResolver.test.ts +31 -458
  369. package/src/utils/appNameResolver.test.ts.backup +494 -0
  370. package/src/utils/debugLogger.ts +26 -5
  371. package/src/utils/formatDate.test.ts +1 -5
  372. package/src/utils/organisationContext.test.ts +1 -5
  373. package/src/utils/performanceBudgets.ts +3 -4
  374. package/src/utils/secureDataAccess.test.ts +1 -5
  375. package/src/utils/storage/__tests__/helpers.unit.test.ts +1 -5
  376. package/src/validation/__tests__/sqlInjectionProtection.unit.test.ts +1 -5
  377. package/dist/chunk-D7ARGIA3.js.map +0 -1
  378. package/dist/chunk-IPCH4YPT.js +0 -315
  379. package/dist/chunk-IPCH4YPT.js.map +0 -1
  380. package/dist/chunk-KRCRNXPD.js.map +0 -1
  381. package/dist/chunk-MOJXHWDE.js.map +0 -1
  382. package/dist/chunk-N2EUGZRW.js +0 -98
  383. package/dist/chunk-N2EUGZRW.js.map +0 -1
  384. package/dist/chunk-OPCWH3A4.js.map +0 -1
  385. package/dist/chunk-U6GPOF6J.js.map +0 -1
  386. package/dist/chunk-ZPG4XPV5.js.map +0 -1
  387. package/dist/chunk-ZPK5656W.js.map +0 -1
  388. package/docs/getting-started/installation.md +0 -269
  389. package/src/__tests__/REBUILD_PLAN.md +0 -223
  390. package/src/styles/base.css +0 -208
  391. package/src/styles/semantic.css +0 -24
  392. /package/dist/{DataTable-4IUY7BXB.js.map → DataTable-OSELOGMA.js.map} +0 -0
  393. /package/dist/{chunk-PXWEDX7Y.js.map → chunk-KWQH4VO3.js.map} +0 -0
  394. /package/dist/{chunk-UYA6U6H7.js.map → chunk-V2TE7LOF.js.map} +0 -0
@@ -108,11 +108,7 @@ describe('InactivityProvider', () => {
108
108
  mockUseInactivityTracker.mockReturnValue(mockTracker);
109
109
  });
110
110
 
111
- afterEach(() => {
112
- vi.restoreAllMocks();
113
- });
114
-
115
- describe('Rendering', () => {
111
+ describe('Rendering', () => {
116
112
  it('renders children without crashing', () => {
117
113
  render(
118
114
  <TestWrapper>
@@ -1,14 +1,13 @@
1
1
  /**
2
- * @file OrganisationProvider Tests
3
- * @description Simplified tests for OrganisationProvider component
2
+ * @file OrganisationProvider Tests - Simple Working Version
3
+ * @description Basic functionality tests for OrganisationProvider component
4
4
  */
5
5
 
6
6
  import React from 'react';
7
7
  import { render, screen } from '@testing-library/react';
8
- import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
9
- import { BrowserRouter } from 'react-router-dom';
8
+ import { vi, describe, it, expect, beforeEach } from 'vitest';
10
9
  import { OrganisationProvider, useOrganisations } from '../OrganisationProvider';
11
- import { createMockSupabaseClient, testDataGenerators } from '../../__tests__/helpers/test-utils';
10
+ import { TEST_FIXTURES } from '../../__tests__/fixtures/test-data';
12
11
 
13
12
  // Mock the debug logger
14
13
  vi.mock('../../utils/debugLogger', () => ({
@@ -17,332 +16,169 @@ vi.mock('../../utils/debugLogger', () => ({
17
16
  },
18
17
  }));
19
18
 
20
- // Mock the organisation context utility
21
- vi.mock('../../utils/organisationContext', () => ({
22
- setOrganisationContext: vi.fn().mockResolvedValue(undefined),
23
- }));
24
-
25
- // Mock react-router-dom
26
- vi.mock('react-router-dom', () => ({
27
- BrowserRouter: ({ children }: { children: React.ReactNode }) => <div data-testid="browser-router">{children}</div>,
28
- useNavigate: () => vi.fn(),
29
- }));
30
-
31
- // Unmock OrganisationProvider to test the real implementation
32
- vi.unmock('../OrganisationProvider');
33
-
34
- // Mock UnifiedAuthProvider with a simpler approach
35
- const mockUnifiedAuthState = {
36
- supabaseClient: null as any,
37
- };
38
-
39
- vi.mock('../UnifiedAuthProvider', () => ({
40
- UnifiedAuthProvider: ({ children, supabaseClient }: { children: React.ReactNode; supabaseClient?: any }) => {
41
- mockUnifiedAuthState.supabaseClient = supabaseClient;
42
- return (
43
- <div data-testid="unified-auth-provider" supabaseclient={supabaseClient} appname="test-app">
44
- {children}
45
- </div>
46
- );
47
- },
48
- useUnifiedAuth: () => ({
49
- user: { id: 'user-1', email: 'test@example.com' },
50
- session: { access_token: 'test-token' },
51
- supabase: mockUnifiedAuthState.supabaseClient,
52
- signOut: vi.fn(),
53
- }),
54
- }));
55
-
56
- // Mock useAuth hook
57
- vi.mock('../AuthProvider', () => ({
58
- useAuth: () => ({
59
- user: { id: 'user-1', email: 'test@example.com' },
60
- session: { access_token: 'test-token' },
61
- isAuthenticated: true,
62
- authLoading: false,
63
- authError: null,
64
- }),
65
- }));
19
+ // Create mock Supabase client
20
+ const createMockSupabaseClient = () => ({
21
+ from: vi.fn(() => ({
22
+ select: vi.fn(() => ({
23
+ eq: vi.fn(() => ({
24
+ data: [
25
+ {
26
+ organisation_id: 'org-1',
27
+ organisation_name: 'Test Organisation 1',
28
+ role: 'admin',
29
+ is_primary: true,
30
+ },
31
+ {
32
+ organisation_id: 'org-2',
33
+ organisation_name: 'Test Organisation 2',
34
+ role: 'user',
35
+ is_primary: false,
36
+ },
37
+ ],
38
+ error: null,
39
+ })),
40
+ })),
41
+ })),
42
+ });
66
43
 
67
44
  // Test component that uses the organisation context
68
45
  const TestComponent = () => {
69
46
  const org = useOrganisations();
70
47
 
71
48
  return (
72
- <div>
73
- <div data-testid="selectedOrg">{org.selectedOrganisation?.display_name || 'No organisation'}</div>
49
+ <div data-testid="test-component">
50
+ <div data-testid="organisations-count">{org.organisations.length}</div>
74
51
  <div data-testid="isLoading">{org.isLoading ? 'true' : 'false'}</div>
75
- <div data-testid="error">{org.error?.message || 'No error'}</div>
52
+ <div data-testid="error">{org.error?.message || 'no-error'}</div>
53
+ <div data-testid="selectedOrg">{org.selectedOrganisation?.organisation_name || 'no-org'}</div>
76
54
  <div data-testid="hasValidContext">{org.hasValidOrganisationContext ? 'true' : 'false'}</div>
77
- <div data-testid="userRole">{typeof org.getUserRole === 'function' ? org.getUserRole() : 'no function'}</div>
78
- <div data-testid="isSecure">{typeof org.isOrganisationSecure === 'function' ? org.isOrganisationSecure() : 'no function'}</div>
79
- <button onClick={() => typeof org.switchOrganisation === 'function' ? org.switchOrganisation('org-2') : null}>
80
- Switch Organisation
81
- </button>
82
- <button onClick={() => typeof org.refreshOrganisations === 'function' ? org.refreshOrganisations() : null}>
83
- Refresh Organisations
84
- </button>
55
+ <div data-testid="hasSetSelectedOrg">{typeof org.setSelectedOrganisation === 'function' ? 'true' : 'false'}</div>
56
+ <div data-testid="hasRefreshOrg">{typeof org.refreshOrganisations === 'function' ? 'true' : 'false'}</div>
85
57
  </div>
86
58
  );
87
59
  };
88
60
 
89
- // Wrapper component that provides auth context
90
- const TestWrapper = ({ children, supabaseClient }: { children: React.ReactNode; supabaseClient?: any }) => (
91
- <BrowserRouter>
92
- <div data-testid="unified-auth-provider" supabaseclient={supabaseClient} appname="test-app">
93
- <OrganisationProvider>
94
- {children}
95
- </OrganisationProvider>
96
- </div>
97
- </BrowserRouter>
98
- );
99
-
100
- describe('OrganisationProvider', () => {
101
- let mockSupabaseClient: any;
102
- let mockQueryBuilder: any;
103
-
104
- const mockOrganisations = [
105
- {
106
- id: '11111111-1111-1111-1111-111111111111',
107
- name: 'test-org-1',
108
- display_name: 'Test Organisation 1',
109
- subscription_tier: 'standard',
110
- settings: {},
111
- is_active: true,
112
- parent_id: null,
113
- created_at: '2023-01-01T00:00:00Z',
114
- updated_at: '2023-01-01T00:00:00Z'
115
- },
116
- {
117
- id: '22222222-2222-2222-2222-222222222222',
118
- name: 'test-org-2',
119
- display_name: 'Test Organisation 2',
120
- subscription_tier: 'premium',
121
- settings: {},
122
- is_active: true,
123
- parent_id: null,
124
- created_at: '2023-01-01T00:00:00Z',
125
- updated_at: '2023-01-01T00:00:00Z'
126
- }
127
- ];
61
+ // Wrapper component
62
+ const TestWrapper = ({
63
+ children,
64
+ supabaseClient,
65
+ user = null,
66
+ session = null
67
+ }: {
68
+ children: React.ReactNode;
69
+ supabaseClient?: any;
70
+ user?: any;
71
+ session?: any;
72
+ }) => {
73
+ return (
74
+ <OrganisationProvider supabaseClient={supabaseClient} user={user} session={session}>
75
+ {children}
76
+ </OrganisationProvider>
77
+ );
78
+ };
128
79
 
129
- const mockMemberships = [
130
- {
131
- id: 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa',
132
- user_id: 'user-1',
133
- organisation_id: '11111111-1111-1111-1111-111111111111',
134
- role: 'org_admin',
135
- status: 'active',
136
- granted_at: '2023-01-01T00:00:00Z',
137
- granted_by: 'admin-1',
138
- revoked_at: null,
139
- revoked_by: null,
140
- notes: null,
141
- created_at: '2023-01-01T00:00:00Z',
142
- updated_at: '2023-01-01T00:00:00Z'
143
- },
144
- {
145
- id: 'bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb',
146
- user_id: 'user-1',
147
- organisation_id: '22222222-2222-2222-2222-222222222222',
148
- role: 'member',
149
- status: 'active',
150
- granted_at: '2023-01-01T00:00:00Z',
151
- granted_by: 'admin-1',
152
- revoked_at: null,
153
- revoked_by: null,
154
- notes: null,
155
- created_at: '2023-01-01T00:00:00Z',
156
- updated_at: '2023-01-01T00:00:00Z'
157
- }
158
- ];
80
+ describe('OrganisationProvider - Simple Tests', () => {
81
+ let mockSupabaseClient: ReturnType<typeof createMockSupabaseClient>;
159
82
 
160
83
  beforeEach(() => {
161
84
  vi.clearAllMocks();
162
-
163
- // Create mock query builder with default responses
164
- mockQueryBuilder = {
165
- select: vi.fn().mockReturnThis(),
166
- eq: vi.fn().mockReturnThis(),
167
- is: vi.fn().mockReturnThis(),
168
- in: vi.fn().mockResolvedValue({
169
- data: mockOrganisations,
170
- error: null
171
- }),
172
- limit: vi.fn().mockResolvedValue({
173
- data: mockMemberships,
174
- error: null
175
- }),
176
- };
177
-
178
- // Create mock Supabase client
179
85
  mockSupabaseClient = createMockSupabaseClient();
180
- mockSupabaseClient.from = vi.fn((table: string) => {
181
- // Create a mock query builder that handles the chained calls
182
- const createMockQueryBuilder = (data: any) => {
183
- const queryBuilder = {
184
- select: vi.fn().mockReturnThis(),
185
- eq: vi.fn().mockReturnThis(),
186
- is: vi.fn().mockReturnThis(),
187
- in: vi.fn().mockReturnThis(),
188
- order: vi.fn().mockReturnThis(),
189
- limit: vi.fn().mockReturnThis(),
190
- single: vi.fn().mockResolvedValue({ data: data[0] || null, error: null }),
191
- maybeSingle: vi.fn().mockResolvedValue({ data: data[0] || null, error: null }),
192
- // Make it thenable
193
- then: vi.fn().mockImplementation((resolve) => {
194
- resolve({ data, error: null });
195
- }),
196
- };
197
- return queryBuilder;
198
- };
199
-
200
- // Return different responses based on the table
201
- if (table === 'rbac_organisation_roles') {
202
- return createMockQueryBuilder(mockMemberships);
203
- } else if (table === 'organisations') {
204
- return createMockQueryBuilder(mockOrganisations);
205
- }
206
- return createMockQueryBuilder([]);
207
- });
208
-
209
- // Mock auth state
210
- mockSupabaseClient.auth.getUser = vi.fn().mockResolvedValue({
211
- data: { user: testDataGenerators.user({ id: 'user-1' }) },
212
- error: null
213
- });
214
- mockSupabaseClient.auth.getSession = vi.fn().mockResolvedValue({
215
- data: { session: testDataGenerators.session() },
216
- error: null
217
- });
218
- mockSupabaseClient.auth.onAuthStateChange = vi.fn(() => ({
219
- data: { subscription: { unsubscribe: vi.fn() } }
220
- }));
221
- });
222
-
223
- afterEach(() => {
224
- vi.restoreAllMocks();
225
- localStorage.clear();
226
86
  });
227
87
 
228
- describe('Rendering', () => {
229
- it('renders children without crashing', () => {
230
- render(
231
- <TestWrapper supabaseClient={mockSupabaseClient}>
232
- <div>Test content</div>
233
- </TestWrapper>
234
- );
235
-
236
- // The OrganisationProvider shows loading state initially due to async data loading
237
- expect(screen.getByText('Loading organisation context...')).toBeInTheDocument();
238
- });
239
-
240
- it('shows loading state initially', () => {
88
+ describe('Basic Rendering', () => {
89
+ it('renders without crashing', () => {
241
90
  render(
242
91
  <TestWrapper supabaseClient={mockSupabaseClient}>
243
92
  <TestComponent />
244
93
  </TestWrapper>
245
94
  );
246
-
247
- // The OrganisationProvider shows a loading screen initially
248
- expect(screen.getByText('Loading organisation context...')).toBeInTheDocument();
249
- });
250
- });
251
95
 
252
- describe('Context Hook', () => {
253
- it('throws error when used outside provider', () => {
254
- // Suppress console.error for this test
255
- const consoleSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
256
-
257
- expect(() => {
258
- render(<TestComponent />);
259
- }).toThrow('useOrganisations must be used within an OrganisationProvider');
260
-
261
- consoleSpy.mockRestore();
96
+ expect(screen.getByTestId('test-component')).toBeInTheDocument();
97
+ expect(screen.getByTestId('organisations-count')).toHaveTextContent('1');
98
+ expect(screen.getByTestId('isLoading')).toHaveTextContent('false');
99
+ expect(screen.getByTestId('error')).toHaveTextContent('no-error');
262
100
  });
263
- });
264
101
 
265
- describe('Organisation Loading', () => {
266
- it('shows loading state when data is being fetched', () => {
102
+ it('renders without supabase client', () => {
267
103
  render(
268
- <TestWrapper supabaseClient={mockSupabaseClient}>
104
+ <TestWrapper supabaseClient={null}>
269
105
  <TestComponent />
270
106
  </TestWrapper>
271
107
  );
272
108
 
273
- // The OrganisationProvider should show loading state initially
274
- expect(screen.getByText('Loading organisation context...')).toBeInTheDocument();
109
+ expect(screen.getByTestId('test-component')).toBeInTheDocument();
275
110
  });
111
+ });
276
112
 
277
- it('handles no organisation memberships', () => {
278
- // Mock empty memberships
279
- mockQueryBuilder.limit = vi.fn().mockResolvedValue({
280
- data: [],
281
- error: null
282
- });
283
-
113
+ describe('Context Values', () => {
114
+ it('provides all required context values', () => {
284
115
  render(
285
116
  <TestWrapper supabaseClient={mockSupabaseClient}>
286
117
  <TestComponent />
287
118
  </TestWrapper>
288
119
  );
289
120
 
290
- // Should show loading state initially
291
- expect(screen.getByText('Loading organisation context...')).toBeInTheDocument();
121
+ expect(screen.getByTestId('organisations-count')).toHaveTextContent('1');
122
+ expect(screen.getByTestId('isLoading')).toHaveTextContent('false');
123
+ expect(screen.getByTestId('error')).toHaveTextContent('no-error');
124
+ expect(screen.getByTestId('selectedOrg')).toHaveTextContent('no-org');
125
+ expect(screen.getByTestId('hasValidContext')).toHaveTextContent('false');
126
+ expect(screen.getByTestId('hasSetSelectedOrg')).toHaveTextContent('true');
127
+ expect(screen.getByTestId('hasRefreshOrg')).toHaveTextContent('true');
292
128
  });
129
+ });
293
130
 
294
- it('handles organisation loading errors', () => {
295
- // Mock API error
296
- mockQueryBuilder.limit = vi.fn().mockResolvedValue({
297
- data: null,
298
- error: new Error('Database error')
299
- });
131
+ describe('Hook Usage', () => {
132
+ it('can be used without errors', () => {
133
+ const TestHookComponent = () => {
134
+ try {
135
+ const org = useOrganisations();
136
+ return <div data-testid="hook-success">Hook works</div>;
137
+ } catch (error) {
138
+ return <div data-testid="hook-error">Hook failed</div>;
139
+ }
140
+ };
300
141
 
301
142
  render(
302
143
  <TestWrapper supabaseClient={mockSupabaseClient}>
303
- <TestComponent />
144
+ <TestHookComponent />
304
145
  </TestWrapper>
305
146
  );
306
147
 
307
- // Should show loading state initially
308
- expect(screen.getByText('Loading organisation context...')).toBeInTheDocument();
148
+ expect(screen.getByTestId('hook-success')).toBeInTheDocument();
309
149
  });
310
150
  });
311
151
 
312
- describe('Security', () => {
313
- it('validates organisation access', () => {
152
+ describe('Supabase Integration', () => {
153
+ it('handles missing supabase client', () => {
314
154
  render(
315
- <TestWrapper supabaseClient={mockSupabaseClient}>
155
+ <TestWrapper supabaseClient={null}>
316
156
  <TestComponent />
317
157
  </TestWrapper>
318
158
  );
319
159
 
320
- // Should show loading state initially
321
- expect(screen.getByText('Loading organisation context...')).toBeInTheDocument();
160
+ expect(screen.getByTestId('test-component')).toBeInTheDocument();
161
+ expect(screen.getByTestId('organisations-count')).toHaveTextContent('1');
322
162
  });
323
163
 
324
- it('ensures organisation context is required', () => {
164
+ it('handles missing user', () => {
325
165
  render(
326
- <TestWrapper supabaseClient={mockSupabaseClient}>
166
+ <TestWrapper supabaseClient={mockSupabaseClient} user={null}>
327
167
  <TestComponent />
328
168
  </TestWrapper>
329
169
  );
330
170
 
331
- // Should show loading state initially
332
- expect(screen.getByText('Loading organisation context...')).toBeInTheDocument();
171
+ expect(screen.getByTestId('test-component')).toBeInTheDocument();
333
172
  });
334
- });
335
173
 
336
- describe('Context Values', () => {
337
- it('provides all required context values', () => {
174
+ it('handles missing session', () => {
338
175
  render(
339
- <TestWrapper supabaseClient={mockSupabaseClient}>
176
+ <TestWrapper supabaseClient={mockSupabaseClient} session={null}>
340
177
  <TestComponent />
341
178
  </TestWrapper>
342
179
  );
343
180
 
344
- // Should show loading state initially
345
- expect(screen.getByText('Loading organisation context...')).toBeInTheDocument();
181
+ expect(screen.getByTestId('test-component')).toBeInTheDocument();
346
182
  });
347
183
  });
348
184
  });