@jmruthers/pace-core 0.5.76 → 0.5.78

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 (447) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/{RBACService-C4udt_Zp.d.ts → AuthService-Df3IozMG.d.ts} +10 -118
  3. package/dist/{DataTable-ntgmhO2W.d.ts → DataTable-BE0OXZKQ.d.ts} +9 -2
  4. package/dist/{DataTable-4GAVPIEG.js → DataTable-ETGVF4Y5.js} +50 -13
  5. package/dist/{PublicLoadingSpinner-BiNER8F5.d.ts → PublicLoadingSpinner-CnUaz0vG.d.ts} +5 -2
  6. package/dist/{UnifiedAuthProvider-Bj6YCf7c.d.ts → UnifiedAuthProvider-B391Aqum.d.ts} +42 -45
  7. package/dist/{UnifiedAuthProvider-3NKDOSOK.js → UnifiedAuthProvider-P5SOJAQ6.js} +4 -5
  8. package/dist/{api-DDMUKIUD.js → api-KG4A2X7P.js} +9 -3
  9. package/dist/{audit-6TOCAMKO.js → audit-65VNHEV2.js} +2 -2
  10. package/dist/{chunk-K34IM5CT.js → chunk-2OGV6IRV.js} +196 -626
  11. package/dist/chunk-2OGV6IRV.js.map +1 -0
  12. package/dist/{chunk-NTNILOBC.js → chunk-5BO3MI5Y.js} +4 -4
  13. package/dist/{chunk-XLZ7U46Z.js → chunk-CVMVPYAL.js} +9 -60
  14. package/dist/chunk-CVMVPYAL.js.map +1 -0
  15. package/dist/{chunk-URUTVZ7N.js → chunk-FL4ZCQLD.js} +2 -2
  16. package/dist/{chunk-LW7MMEAQ.js → chunk-FT2M4R4F.js} +2 -2
  17. package/dist/{chunk-5BSLGBYI.js → chunk-JCQZ6LA7.js} +2 -8
  18. package/dist/{chunk-5BSLGBYI.js.map → chunk-JCQZ6LA7.js.map} +1 -1
  19. package/dist/{chunk-KHJS6VIA.js → chunk-LRQ6RBJC.js} +157 -112
  20. package/dist/chunk-LRQ6RBJC.js.map +1 -0
  21. package/dist/{chunk-WN6XJWOS.js → chunk-MNJXXD6C.js} +274 -743
  22. package/dist/chunk-MNJXXD6C.js.map +1 -0
  23. package/dist/{chunk-KK73ZB4E.js → chunk-PTR5PMPE.js} +153 -132
  24. package/dist/chunk-PTR5PMPE.js.map +1 -0
  25. package/dist/{chunk-B2WTCLCV.js → chunk-Q7APDV6H.js} +18 -8
  26. package/dist/chunk-Q7APDV6H.js.map +1 -0
  27. package/dist/{chunk-A4FUBC7B.js → chunk-QGVSOUJ2.js} +2 -4
  28. package/dist/{chunk-A4FUBC7B.js.map → chunk-QGVSOUJ2.js.map} +1 -1
  29. package/dist/{chunk-FGMFQSHX.js → chunk-S63MFSY6.js} +500 -551
  30. package/dist/chunk-S63MFSY6.js.map +1 -0
  31. package/dist/{chunk-AFGTSUAD.js → chunk-VSOKOFRF.js} +4 -4
  32. package/dist/chunk-WUXCWRL6.js +20 -0
  33. package/dist/chunk-WUXCWRL6.js.map +1 -0
  34. package/dist/{chunk-Y6TXWPJO.js → chunk-YVVGHRGI.js} +105 -31
  35. package/dist/chunk-YVVGHRGI.js.map +1 -0
  36. package/dist/{chunk-M5IWZRBT.js → chunk-ZMNXIJP4.js} +2187 -981
  37. package/dist/chunk-ZMNXIJP4.js.map +1 -0
  38. package/dist/components.d.ts +6 -6
  39. package/dist/components.js +14 -18
  40. package/dist/components.js.map +1 -1
  41. package/dist/{database-C3Szpi5J.d.ts → database-BXAfr2Y_.d.ts} +18 -0
  42. package/dist/hooks.d.ts +5 -5
  43. package/dist/hooks.js +8 -9
  44. package/dist/hooks.js.map +1 -1
  45. package/dist/index.d.ts +19 -27
  46. package/dist/index.js +21 -29
  47. package/dist/index.js.map +1 -1
  48. package/dist/{organisation-BtshODVF.d.ts → organisation-D6qRDtbF.d.ts} +1 -1
  49. package/dist/providers.d.ts +7 -21
  50. package/dist/providers.js +3 -10
  51. package/dist/rbac/index.d.ts +71 -221
  52. package/dist/rbac/index.js +15 -16
  53. package/dist/{types-CGX9Vyf5.d.ts → types-BDg1mAGG.d.ts} +36 -6
  54. package/dist/types.d.ts +3 -3
  55. package/dist/types.js +61 -18
  56. package/dist/types.js.map +1 -1
  57. package/dist/{unified-CM7T0aTK.d.ts → unified-DQ4VcT7H.d.ts} +1 -1
  58. package/dist/{usePublicRouteParams-B-CumWRc.d.ts → usePublicRouteParams-BlgwXweB.d.ts} +3 -3
  59. package/dist/utils.d.ts +2 -2
  60. package/dist/utils.js +52 -9
  61. package/dist/utils.js.map +1 -1
  62. package/docs/CONTENT_AUDIT_REPORT.md +253 -0
  63. package/docs/DOCUMENTATION_AUDIT.md +172 -0
  64. package/docs/README.md +142 -147
  65. package/docs/STYLE_GUIDE.md +37 -0
  66. package/docs/api/classes/ColumnFactory.md +17 -17
  67. package/docs/api/classes/ErrorBoundary.md +1 -1
  68. package/docs/api/classes/InvalidScopeError.md +4 -4
  69. package/docs/api/classes/MissingUserContextError.md +4 -4
  70. package/docs/api/classes/OrganisationContextRequiredError.md +4 -4
  71. package/docs/api/classes/PermissionDeniedError.md +5 -5
  72. package/docs/api/classes/PublicErrorBoundary.md +1 -1
  73. package/docs/api/classes/RBACAuditManager.md +8 -8
  74. package/docs/api/classes/RBACCache.md +35 -5
  75. package/docs/api/classes/RBACEngine.md +49 -20
  76. package/docs/api/classes/RBACError.md +4 -4
  77. package/docs/api/classes/RBACNotInitializedError.md +4 -4
  78. package/docs/api/classes/SecureSupabaseClient.md +1 -1
  79. package/docs/api/classes/StorageUtils.md +1 -1
  80. package/docs/api/enums/FileCategory.md +1 -1
  81. package/docs/api/interfaces/AggregateConfig.md +4 -4
  82. package/docs/api/interfaces/ButtonProps.md +1 -1
  83. package/docs/api/interfaces/CardProps.md +1 -1
  84. package/docs/api/interfaces/ColorPalette.md +1 -1
  85. package/docs/api/interfaces/ColorShade.md +1 -1
  86. package/docs/api/interfaces/DataAccessRecord.md +1 -1
  87. package/docs/api/interfaces/DataRecord.md +11 -0
  88. package/docs/api/interfaces/DataTableAction.md +65 -29
  89. package/docs/api/interfaces/DataTableColumn.md +36 -23
  90. package/docs/api/interfaces/DataTableProps.md +80 -38
  91. package/docs/api/interfaces/DataTableToolbarButton.md +7 -7
  92. package/docs/api/interfaces/EmptyStateConfig.md +5 -5
  93. package/docs/api/interfaces/EnhancedNavigationMenuProps.md +1 -1
  94. package/docs/api/interfaces/EventLogoProps.md +1 -1
  95. package/docs/api/interfaces/FileDisplayProps.md +1 -1
  96. package/docs/api/interfaces/FileMetadata.md +1 -1
  97. package/docs/api/interfaces/FileReference.md +1 -1
  98. package/docs/api/interfaces/FileSizeLimits.md +1 -1
  99. package/docs/api/interfaces/FileUploadOptions.md +1 -1
  100. package/docs/api/interfaces/FileUploadProps.md +1 -1
  101. package/docs/api/interfaces/FooterProps.md +1 -1
  102. package/docs/api/interfaces/InactivityWarningModalProps.md +1 -1
  103. package/docs/api/interfaces/InputProps.md +1 -1
  104. package/docs/api/interfaces/LabelProps.md +1 -1
  105. package/docs/api/interfaces/LoginFormProps.md +1 -1
  106. package/docs/api/interfaces/NavigationAccessRecord.md +11 -11
  107. package/docs/api/interfaces/NavigationContextType.md +9 -9
  108. package/docs/api/interfaces/NavigationGuardProps.md +1 -1
  109. package/docs/api/interfaces/NavigationItem.md +1 -1
  110. package/docs/api/interfaces/NavigationMenuProps.md +1 -1
  111. package/docs/api/interfaces/NavigationProviderProps.md +7 -7
  112. package/docs/api/interfaces/Organisation.md +1 -1
  113. package/docs/api/interfaces/OrganisationContextType.md +1 -1
  114. package/docs/api/interfaces/OrganisationMembership.md +1 -1
  115. package/docs/api/interfaces/OrganisationProviderProps.md +1 -1
  116. package/docs/api/interfaces/OrganisationSecurityError.md +1 -1
  117. package/docs/api/interfaces/PaceAppLayoutProps.md +1 -1
  118. package/docs/api/interfaces/PaceLoginPageProps.md +16 -3
  119. package/docs/api/interfaces/PageAccessRecord.md +1 -1
  120. package/docs/api/interfaces/PagePermissionContextType.md +1 -1
  121. package/docs/api/interfaces/PagePermissionGuardProps.md +2 -2
  122. package/docs/api/interfaces/PagePermissionProviderProps.md +1 -1
  123. package/docs/api/interfaces/PaletteData.md +1 -1
  124. package/docs/api/interfaces/PermissionEnforcerProps.md +4 -4
  125. package/docs/api/interfaces/PublicErrorBoundaryProps.md +1 -1
  126. package/docs/api/interfaces/PublicErrorBoundaryState.md +1 -1
  127. package/docs/api/interfaces/PublicLoadingSpinnerProps.md +1 -1
  128. package/docs/api/interfaces/PublicPageFooterProps.md +1 -1
  129. package/docs/api/interfaces/PublicPageHeaderProps.md +1 -1
  130. package/docs/api/interfaces/PublicPageLayoutProps.md +1 -1
  131. package/docs/api/interfaces/RBACConfig.md +1 -1
  132. package/docs/api/interfaces/RBACLogger.md +1 -1
  133. package/docs/api/interfaces/RoleBasedRouterContextType.md +1 -1
  134. package/docs/api/interfaces/RoleBasedRouterProps.md +1 -1
  135. package/docs/api/interfaces/RouteAccessRecord.md +2 -2
  136. package/docs/api/interfaces/RouteConfig.md +2 -2
  137. package/docs/api/interfaces/SecureDataContextType.md +1 -1
  138. package/docs/api/interfaces/SecureDataProviderProps.md +1 -1
  139. package/docs/api/interfaces/StorageConfig.md +1 -1
  140. package/docs/api/interfaces/StorageFileInfo.md +1 -1
  141. package/docs/api/interfaces/StorageFileMetadata.md +1 -1
  142. package/docs/api/interfaces/StorageListOptions.md +1 -1
  143. package/docs/api/interfaces/StorageListResult.md +1 -1
  144. package/docs/api/interfaces/StorageUploadOptions.md +1 -1
  145. package/docs/api/interfaces/StorageUploadResult.md +1 -1
  146. package/docs/api/interfaces/StorageUrlOptions.md +1 -1
  147. package/docs/api/interfaces/StyleImport.md +1 -1
  148. package/docs/api/interfaces/SwitchProps.md +1 -1
  149. package/docs/api/interfaces/ToastActionElement.md +1 -1
  150. package/docs/api/interfaces/ToastProps.md +1 -1
  151. package/docs/api/interfaces/UnifiedAuthContextType.md +94 -521
  152. package/docs/api/interfaces/UnifiedAuthProviderProps.md +16 -16
  153. package/docs/api/interfaces/UseInactivityTrackerOptions.md +1 -1
  154. package/docs/api/interfaces/UseInactivityTrackerReturn.md +1 -1
  155. package/docs/api/interfaces/UsePublicEventLogoOptions.md +1 -1
  156. package/docs/api/interfaces/UsePublicEventLogoReturn.md +1 -1
  157. package/docs/api/interfaces/UsePublicEventOptions.md +1 -1
  158. package/docs/api/interfaces/UsePublicEventReturn.md +1 -1
  159. package/docs/api/interfaces/UsePublicRouteParamsReturn.md +1 -1
  160. package/docs/api/interfaces/UseResolvedScopeOptions.md +1 -1
  161. package/docs/api/interfaces/UseResolvedScopeReturn.md +1 -1
  162. package/docs/api/interfaces/UserEventAccess.md +11 -11
  163. package/docs/api/interfaces/UserMenuProps.md +1 -1
  164. package/docs/api/interfaces/UserProfile.md +1 -1
  165. package/docs/api/modules.md +251 -269
  166. package/docs/api-reference/components.md +193 -0
  167. package/docs/api-reference/hooks.md +265 -0
  168. package/docs/api-reference/providers.md +6 -0
  169. package/docs/api-reference/types.md +6 -0
  170. package/docs/api-reference/utilities.md +207 -0
  171. package/docs/architecture/README.md +6 -0
  172. package/docs/{database-schema-requirements.md → architecture/database-schema-requirements.md} +6 -0
  173. package/docs/architecture/rbac-security-architecture.md +258 -0
  174. package/docs/architecture/services.md +9 -1
  175. package/docs/best-practices/README.md +6 -0
  176. package/docs/best-practices/accessibility.md +6 -0
  177. package/docs/{common-patterns.md → best-practices/common-patterns.md} +6 -0
  178. package/docs/best-practices/deployment.md +6 -0
  179. package/docs/best-practices/performance.md +475 -2
  180. package/docs/best-practices/security.md +6 -0
  181. package/docs/best-practices/testing.md +6 -0
  182. package/docs/core-concepts/authentication.md +6 -0
  183. package/docs/core-concepts/events.md +6 -0
  184. package/docs/core-concepts/organisations.md +6 -0
  185. package/docs/core-concepts/permissions.md +6 -0
  186. package/docs/core-concepts/rbac-system.md +8 -0
  187. package/docs/documentation-index.md +121 -182
  188. package/docs/{consuming-app-vite-config.md → getting-started/consuming-app-vite-config.md} +6 -0
  189. package/docs/getting-started/documentation-index.md +40 -0
  190. package/docs/getting-started/examples/README.md +878 -35
  191. package/docs/{faq.md → getting-started/faq.md} +7 -1
  192. package/docs/getting-started/installation-guide.md +6 -0
  193. package/docs/{quick-reference.md → getting-started/quick-reference.md} +6 -0
  194. package/docs/implementation-guides/app-layout.md +6 -0
  195. package/docs/implementation-guides/authentication.md +1021 -0
  196. package/docs/implementation-guides/component-styling.md +6 -0
  197. package/docs/implementation-guides/data-tables.md +1264 -2076
  198. package/docs/implementation-guides/dynamic-colors.md +6 -0
  199. package/docs/implementation-guides/event-theming-summary.md +6 -0
  200. package/docs/{file-reference-system.md → implementation-guides/file-reference-system.md} +6 -0
  201. package/docs/implementation-guides/file-upload-storage.md +6 -0
  202. package/docs/implementation-guides/forms.md +6 -0
  203. package/docs/implementation-guides/inactivity-tracking.md +6 -0
  204. package/docs/implementation-guides/navigation.md +6 -0
  205. package/docs/implementation-guides/organisation-security.md +6 -0
  206. package/docs/implementation-guides/permission-enforcement.md +6 -0
  207. package/docs/implementation-guides/public-pages-advanced.md +6 -0
  208. package/docs/implementation-guides/public-pages.md +6 -0
  209. package/docs/migration/MIGRATION_GUIDE.md +827 -351
  210. package/docs/migration/README.md +7 -1
  211. package/docs/migration/organisation-context-timing-fix.md +6 -0
  212. package/docs/migration/rbac-migration.md +44 -1
  213. package/docs/migration/service-architecture.md +6 -0
  214. package/docs/migration/v0.4.15-tailwind-scanning.md +6 -0
  215. package/docs/migration/v0.4.16-css-first-approach.md +6 -0
  216. package/docs/migration/v0.4.17-source-path-fix.md +6 -0
  217. package/docs/rbac/README-rbac-rls-integration.md +6 -0
  218. package/docs/rbac/README.md +6 -0
  219. package/docs/rbac/advanced-patterns.md +6 -0
  220. package/docs/rbac/api-reference.md +7 -1
  221. package/docs/rbac/breaking-changes-v3.md +222 -0
  222. package/docs/rbac/examples/rbac-rls-integration-example.md +6 -0
  223. package/docs/rbac/examples.md +6 -0
  224. package/docs/rbac/getting-started.md +6 -0
  225. package/docs/rbac/migration-guide.md +260 -0
  226. package/docs/rbac/quick-start.md +70 -13
  227. package/docs/rbac/rbac-rls-integration.md +6 -0
  228. package/docs/rbac/super-admin-guide.md +6 -0
  229. package/docs/rbac/troubleshooting.md +6 -0
  230. package/docs/security/README.md +6 -0
  231. package/docs/security/checklist.md +6 -0
  232. package/docs/styles/README.md +7 -1
  233. package/docs/{usage.md → styles/usage.md} +6 -0
  234. package/docs/testing/README.md +6 -0
  235. package/docs/{visual-testing.md → testing/visual-testing.md} +6 -0
  236. package/docs/troubleshooting/README.md +387 -5
  237. package/docs/troubleshooting/cake-page-permission-guard-issue-summary.md +6 -0
  238. package/docs/troubleshooting/common-issues.md +6 -0
  239. package/docs/troubleshooting/database-view-compatibility.md +6 -0
  240. package/docs/troubleshooting/organisation-context-setup.md +6 -0
  241. package/docs/troubleshooting/react-hooks-issue-analysis.md +6 -0
  242. package/docs/troubleshooting/styling-issues.md +6 -0
  243. package/docs/troubleshooting/tailwind-content-scanning.md +6 -0
  244. package/package.json +1 -1
  245. package/src/__tests__/helpers/__tests__/test-providers.test.tsx +2 -1
  246. package/src/__tests__/helpers/test-providers.tsx +3 -53
  247. package/src/components/DataTable/DataTable.test.tsx +319 -0
  248. package/src/components/DataTable/DataTable.tsx +32 -11
  249. package/src/components/DataTable/__tests__/{DataTable.comprehensive.test.tsx → DataTable.comprehensive.test.tsx.skip} +6 -4
  250. package/src/components/DataTable/__tests__/{DataTable.test.tsx → DataTable.test.tsx.skip} +6 -4
  251. package/src/components/DataTable/__tests__/DataTableCore.test.tsx +31 -9
  252. package/src/components/DataTable/__tests__/a11y.basic.test.tsx +601 -0
  253. package/src/components/DataTable/__tests__/keyboard.test.tsx +615 -0
  254. package/src/components/DataTable/__tests__/pagination.modes.test.tsx +639 -0
  255. package/src/components/DataTable/__tests__/ssr.strict-mode.test.tsx.skip +330 -0
  256. package/src/components/DataTable/components/AccessDeniedPage.tsx +2 -2
  257. package/src/components/DataTable/components/ActionButtons.tsx +88 -104
  258. package/src/components/DataTable/components/DataTableCore.tsx +309 -337
  259. package/src/components/DataTable/components/DataTableErrorBoundary.tsx +4 -2
  260. package/src/components/DataTable/components/DataTableModals.tsx +22 -1
  261. package/src/components/DataTable/components/EditableRow.tsx +69 -84
  262. package/src/components/DataTable/components/EmptyState.tsx +5 -1
  263. package/src/components/DataTable/components/ImportModal.tsx +65 -36
  264. package/src/components/DataTable/components/PaginationControls.tsx +40 -100
  265. package/src/components/DataTable/components/UnifiedTableBody.tsx +125 -148
  266. package/src/components/DataTable/context/DataTableContext.tsx +1 -1
  267. package/src/components/DataTable/core/ColumnFactory.ts +5 -0
  268. package/src/components/DataTable/examples/HierarchicalActionsExample.tsx +12 -10
  269. package/src/components/DataTable/examples/HierarchicalExample.tsx +1 -1
  270. package/src/components/DataTable/examples/InitialPageSizeExample.tsx +1 -0
  271. package/src/components/DataTable/examples/PerformanceExample.tsx +1 -0
  272. package/src/components/DataTable/hooks/__tests__/useColumnOrderPersistence.test.ts +1 -5
  273. package/src/components/DataTable/hooks/__tests__/useColumnVisibilityPersistence.test.ts +167 -0
  274. package/src/components/DataTable/hooks/index.ts +7 -0
  275. package/src/components/DataTable/hooks/useColumnOrderPersistence.ts +32 -15
  276. package/src/components/DataTable/hooks/useColumnVisibilityPersistence.ts +102 -0
  277. package/src/components/DataTable/hooks/useDataTableConfiguration.ts +89 -0
  278. package/src/components/DataTable/hooks/useDataTableDataPipeline.ts +117 -0
  279. package/src/components/DataTable/hooks/useDataTablePermissions.ts +71 -27
  280. package/src/components/DataTable/hooks/useDataTableState.ts +39 -11
  281. package/src/components/DataTable/hooks/useEffectiveColumnOrder.ts +33 -0
  282. package/src/components/DataTable/hooks/useHierarchicalState.ts +15 -1
  283. package/src/components/DataTable/hooks/useKeyboardNavigation.ts +447 -0
  284. package/src/components/DataTable/hooks/useServerSideDataEffect.ts +94 -0
  285. package/src/components/DataTable/hooks/useTableColumns.ts +10 -7
  286. package/src/components/DataTable/hooks/useTableHandlers.ts +174 -0
  287. package/src/components/DataTable/index.ts +12 -3
  288. package/src/components/DataTable/types.ts +129 -9
  289. package/src/components/DataTable/utils/__tests__/exportUtils.test.ts +159 -22
  290. package/src/components/DataTable/utils/__tests__/flexibleImport.test.ts +111 -0
  291. package/src/components/DataTable/utils/__tests__/rowUtils.test.ts +15 -29
  292. package/src/components/DataTable/utils/a11yUtils.ts +244 -0
  293. package/src/components/DataTable/utils/debugTools.ts +609 -0
  294. package/src/components/DataTable/utils/exportUtils.ts +114 -16
  295. package/src/components/DataTable/utils/flexibleImport.ts +202 -32
  296. package/src/components/DataTable/utils/hierarchicalUtils.ts +1 -1
  297. package/src/components/DataTable/utils/index.ts +2 -0
  298. package/src/components/DataTable/utils/paginationUtils.ts +350 -0
  299. package/src/components/DataTable/utils/rowUtils.ts +6 -5
  300. package/src/components/NavigationMenu/NavigationMenu.test.tsx +19 -24
  301. package/src/components/NavigationMenu/NavigationMenu.tsx +19 -8
  302. package/src/components/PaceAppLayout/__tests__/PaceAppLayout.security.test.tsx +1 -23
  303. package/src/components/PaceLoginPage/PaceLoginPage.test.tsx +56 -6
  304. package/src/components/PaceLoginPage/PaceLoginPage.tsx +137 -13
  305. package/src/components/PublicLayout/__tests__/PublicPageHeader.test.tsx +1 -1
  306. package/src/components/Select/Select.tsx +1 -0
  307. package/src/components/examples/PermissionExample.tsx +173 -0
  308. package/src/examples/CorrectPublicPageImplementation.tsx +301 -0
  309. package/src/examples/PublicEventPage.tsx +274 -0
  310. package/src/examples/PublicPageApp.tsx +308 -0
  311. package/src/examples/PublicPageUsageExample.tsx +216 -0
  312. package/src/hooks/__tests__/useOrganisationPermissions.unit.test.tsx +12 -1
  313. package/src/hooks/__tests__/useOrganisationSecurity.unit.test.tsx +129 -17
  314. package/src/hooks/__tests__/useRBAC.unit.test.ts +151 -846
  315. package/src/hooks/useOrganisationPermissions.test.ts +42 -18
  316. package/src/hooks/useOrganisationPermissions.ts +12 -6
  317. package/src/hooks/useOrganisationSecurity.test.ts +138 -85
  318. package/src/hooks/useOrganisationSecurity.ts +41 -10
  319. package/src/index.ts +0 -1
  320. package/src/providers/AuthProvider.simplified.tsx +880 -0
  321. package/src/providers/UnifiedAuthProvider.test.simple.tsx +8 -8
  322. package/src/providers/__tests__/UnifiedAuthProvider.test.tsx +29 -19
  323. package/src/providers/index.ts +0 -1
  324. package/src/providers/services/EventServiceProvider.tsx +19 -15
  325. package/src/providers/services/InactivityServiceProvider.tsx +19 -15
  326. package/src/providers/services/OrganisationServiceProvider.tsx +19 -15
  327. package/src/providers/services/UnifiedAuthProvider.tsx +156 -127
  328. package/src/providers/services/__tests__/AuthServiceProvider.integration.test.tsx +1 -1
  329. package/src/providers/services/__tests__/UnifiedAuthProvider.integration.test.tsx +3 -3
  330. package/src/rbac/README.md +1 -1
  331. package/src/rbac/__tests__/adapters.comprehensive.test.tsx +25 -27
  332. package/src/rbac/__tests__/auth-rbac-security.integration.test.tsx +313 -0
  333. package/src/rbac/__tests__/engine.comprehensive.test.ts +114 -348
  334. package/src/rbac/__tests__/rbac-engine-core-logic.test.ts +28 -110
  335. package/src/rbac/__tests__/rbac-engine-simplified.test.ts +33 -85
  336. package/src/rbac/__tests__/scenarios.user-role.test.tsx +2 -2
  337. package/src/rbac/adapters.tsx +26 -69
  338. package/src/rbac/api.test.ts +90 -27
  339. package/src/rbac/api.ts +61 -10
  340. package/src/rbac/audit.test.ts +33 -38
  341. package/src/rbac/audit.ts +21 -6
  342. package/src/rbac/cache.ts +33 -1
  343. package/src/rbac/components/NavigationGuard.tsx +11 -11
  344. package/src/rbac/components/NavigationProvider.test.tsx +11 -5
  345. package/src/rbac/components/NavigationProvider.tsx +37 -13
  346. package/src/rbac/components/PagePermissionGuard.tsx +111 -50
  347. package/src/rbac/components/PagePermissionProvider.tsx +5 -5
  348. package/src/rbac/components/PermissionEnforcer.tsx +11 -11
  349. package/src/rbac/components/RoleBasedRouter.tsx +5 -5
  350. package/src/rbac/components/SecureDataProvider.tsx +5 -5
  351. package/src/rbac/components/__tests__/NavigationGuard.test.tsx +8 -8
  352. package/src/rbac/components/__tests__/PagePermissionGuard.test.tsx +14 -14
  353. package/src/rbac/components/__tests__/PermissionEnforcer.test.tsx +12 -12
  354. package/src/rbac/components/__tests__/RoleBasedRouter.test.tsx +6 -6
  355. package/src/rbac/engine.test.simple.ts +19 -13
  356. package/src/rbac/engine.test.ts +1 -0
  357. package/src/rbac/engine.ts +330 -766
  358. package/src/rbac/errors.ts +156 -0
  359. package/src/rbac/hooks/usePermissions.ts +32 -10
  360. package/src/rbac/hooks/useRBAC.test.ts +126 -512
  361. package/src/rbac/hooks/useRBAC.ts +147 -193
  362. package/src/rbac/hooks/useResolvedScope.ts +12 -0
  363. package/src/rbac/index.ts +7 -4
  364. package/src/rbac/security.ts +109 -18
  365. package/src/rbac/types.ts +12 -1
  366. package/src/services/AuthService.ts +2 -15
  367. package/src/services/EventService.ts +43 -46
  368. package/src/services/OrganisationService.ts +51 -31
  369. package/src/services/__tests__/AuthService.test.ts +1 -1
  370. package/src/services/__tests__/EventService.test.ts +1 -1
  371. package/src/services/__tests__/OrganisationService.test.ts +1 -1
  372. package/src/services/base/BaseService.ts +8 -0
  373. package/src/styles/base.css +208 -0
  374. package/src/styles/semantic.css +24 -0
  375. package/src/types/database.generated.ts +7347 -0
  376. package/src/types/database.ts +20 -0
  377. package/src/utils/logger.ts +179 -0
  378. package/src/utils/organisationContext.ts +11 -4
  379. package/src/utils/storage/__tests__/helpers.unit.test.ts +6 -2
  380. package/dist/appNameResolver-UURKN7NF.js +0 -22
  381. package/dist/audit-6TOCAMKO.js.map +0 -1
  382. package/dist/chunk-B2WTCLCV.js.map +0 -1
  383. package/dist/chunk-FGMFQSHX.js.map +0 -1
  384. package/dist/chunk-K34IM5CT.js.map +0 -1
  385. package/dist/chunk-KHJS6VIA.js.map +0 -1
  386. package/dist/chunk-KK73ZB4E.js.map +0 -1
  387. package/dist/chunk-M5IWZRBT.js.map +0 -1
  388. package/dist/chunk-ULBI5JGB.js +0 -109
  389. package/dist/chunk-ULBI5JGB.js.map +0 -1
  390. package/dist/chunk-WN6XJWOS.js.map +0 -1
  391. package/dist/chunk-XLZ7U46Z.js.map +0 -1
  392. package/dist/chunk-Y6TXWPJO.js.map +0 -1
  393. package/docs/DOCUMENTATION_CHECKLIST.md +0 -281
  394. package/docs/TERMINOLOGY.md +0 -231
  395. package/docs/api/interfaces/RBACContextType.md +0 -468
  396. package/docs/api/interfaces/RBACProviderProps.md +0 -107
  397. package/docs/best-practices/performance-expansion.md +0 -473
  398. package/docs/breaking-changes.md +0 -179
  399. package/docs/consuming-app-example.md +0 -290
  400. package/docs/documentation-templates.md +0 -539
  401. package/docs/examples/navigation-menu-auth-fix.md +0 -344
  402. package/docs/getting-started/examples/basic-auth-app.md +0 -520
  403. package/docs/getting-started/examples/full-featured-app.md +0 -616
  404. package/docs/getting-started/quick-start.md +0 -376
  405. package/docs/implementation-guides/datatable-filtering.md +0 -313
  406. package/docs/implementation-guides/datatable-rbac-usage.md +0 -317
  407. package/docs/implementation-guides/hierarchical-datatable.md +0 -850
  408. package/docs/implementation-guides/large-datasets.md +0 -281
  409. package/docs/implementation-guides/performance.md +0 -403
  410. package/docs/migration/quick-migration-guide.md +0 -320
  411. package/docs/migration-guide.md +0 -193
  412. package/docs/migration-guides/unified-auth-provider-mandatory-timeouts.md +0 -226
  413. package/docs/performance/README.md +0 -551
  414. package/docs/style-guide.md +0 -964
  415. package/docs/troubleshooting/authentication-issues.md +0 -334
  416. package/docs/troubleshooting/debugging.md +0 -1117
  417. package/docs/troubleshooting/migration.md +0 -918
  418. package/src/__tests__/hooks/usePermissions.test.ts +0 -261
  419. package/src/components/PaceAppLayout/__tests__/PaceAppLayout.rbac.test.tsx +0 -574
  420. package/src/hooks/__tests__/ServiceHooks.test.tsx +0 -613
  421. package/src/hooks/services/__tests__/useServiceHooks.test.tsx +0 -137
  422. package/src/hooks/services/usePermissions.ts +0 -70
  423. package/src/hooks/services/useRBACService.ts +0 -30
  424. package/src/hooks/usePermissionCheck.ts +0 -150
  425. package/src/providers/__tests__/ServiceProviders.test.tsx +0 -477
  426. package/src/providers/services/RBACServiceProvider.tsx +0 -79
  427. package/src/rbac/__tests__/integration.authflow.test.tsx +0 -119
  428. package/src/rbac/__tests__/integration.navigation.test.tsx +0 -69
  429. package/src/rbac/__tests__/integration.securedata.test.tsx +0 -92
  430. package/src/rbac/__tests__/integration.smoke.test.tsx +0 -73
  431. package/src/rbac/providers/RBACProvider.tsx +0 -645
  432. package/src/rbac/providers/__tests__/RBACProvider.integration.test.tsx +0 -688
  433. package/src/rbac/providers/__tests__/RBACProvider.test.tsx +0 -1186
  434. package/src/rbac/providers/index.ts +0 -11
  435. package/src/services/RBACService.ts +0 -522
  436. package/src/services/__tests__/RBACService.test.ts +0 -492
  437. package/src/services/interfaces/IRBACService.ts +0 -62
  438. package/src/utils/appNameResolver.test 2.ts +0 -494
  439. /package/dist/{DataTable-4GAVPIEG.js.map → DataTable-ETGVF4Y5.js.map} +0 -0
  440. /package/dist/{UnifiedAuthProvider-3NKDOSOK.js.map → UnifiedAuthProvider-P5SOJAQ6.js.map} +0 -0
  441. /package/dist/{api-DDMUKIUD.js.map → api-KG4A2X7P.js.map} +0 -0
  442. /package/dist/{appNameResolver-UURKN7NF.js.map → audit-65VNHEV2.js.map} +0 -0
  443. /package/dist/{chunk-NTNILOBC.js.map → chunk-5BO3MI5Y.js.map} +0 -0
  444. /package/dist/{chunk-URUTVZ7N.js.map → chunk-FL4ZCQLD.js.map} +0 -0
  445. /package/dist/{chunk-LW7MMEAQ.js.map → chunk-FT2M4R4F.js.map} +0 -0
  446. /package/dist/{chunk-AFGTSUAD.js.map → chunk-VSOKOFRF.js.map} +0 -0
  447. /package/docs/{app.css.example → styles/app.css.example} +0 -0
@@ -1,13 +1,7 @@
1
1
  import {
2
- AccessLevel,
3
- init_unified
4
- } from "./chunk-ULBI5JGB.js";
5
- import {
6
- DebugLogger,
7
- init_debugLogger,
8
2
  init_organisationContext,
9
3
  setOrganisationContext
10
- } from "./chunk-XLZ7U46Z.js";
4
+ } from "./chunk-CVMVPYAL.js";
11
5
  import {
12
6
  __esm
13
7
  } from "./chunk-PLDDJCW6.js";
@@ -75,6 +69,13 @@ var init_BaseService = __esm({
75
69
  getInitialized() {
76
70
  return this.isInitialized;
77
71
  }
72
+ /**
73
+ * Reset initialization state (allows re-initialization)
74
+ * Use when dependencies change and service needs to re-initialize
75
+ */
76
+ resetInitialization() {
77
+ this.isInitialized = false;
78
+ }
78
79
  };
79
80
  }
80
81
  });
@@ -86,13 +87,12 @@ var init_AuthService = __esm({
86
87
  "src/services/AuthService.ts"() {
87
88
  "use strict";
88
89
  init_BaseService();
89
- init_debugLogger();
90
90
  AuthService = class extends BaseService {
91
91
  constructor(supabaseClient) {
92
92
  super();
93
93
  this.user = null;
94
94
  this.session = null;
95
- this.authLoading = true;
95
+ this.authLoading = false;
96
96
  this.authError = null;
97
97
  this.supabaseClient = null;
98
98
  this.authStateSubscription = null;
@@ -324,21 +324,17 @@ var init_AuthService = __esm({
324
324
  this.authStateSubscription = this.supabaseClient.auth.onAuthStateChange(
325
325
  (event, session) => {
326
326
  try {
327
- DebugLogger.log("AuthService", "Auth state changed:", event, session?.user?.email);
328
327
  if (event === "SIGNED_OUT") {
329
- DebugLogger.log("AuthService", "User signed out, clearing all state");
330
328
  this.session = null;
331
329
  this.user = null;
332
330
  this.authError = null;
333
331
  } else if (event === "SIGNED_IN" || event === "TOKEN_REFRESHED") {
334
- DebugLogger.log("AuthService", "User signed in or token refreshed");
335
332
  this.session = session;
336
333
  this.user = session?.user ?? null;
337
334
  if (session) {
338
335
  this.authError = null;
339
336
  }
340
337
  } else if (event === "INITIAL_SESSION") {
341
- DebugLogger.log("AuthService", "Initial session event");
342
338
  if (session) {
343
339
  this.session = session;
344
340
  this.user = session.user ?? null;
@@ -366,23 +362,17 @@ var init_AuthService = __esm({
366
362
  return;
367
363
  }
368
364
  try {
369
- DebugLogger.log("AuthService", "Initializing authentication...");
370
365
  const { data: { session: currentSession }, error: sessionError } = await this.supabaseClient.auth.getSession();
371
366
  if (sessionError) {
372
367
  console.warn("[AuthService] Error getting current session:", sessionError);
373
368
  }
374
369
  if (currentSession) {
375
- DebugLogger.log("AuthService", "Session restored from storage:", currentSession.user?.email);
376
370
  this.session = currentSession;
377
371
  this.user = currentSession.user;
378
372
  this.authError = null;
379
373
  } else {
380
- DebugLogger.log("AuthService", "No session found in storage");
381
374
  const { data: { user: currentUser }, error: userError } = await this.supabaseClient.auth.getUser();
382
- if (userError) {
383
- DebugLogger.log("AuthService", "No user found:", userError.message);
384
- } else if (currentUser) {
385
- DebugLogger.log("AuthService", "User found without session:", currentUser.email);
375
+ if (!userError && currentUser) {
386
376
  this.user = currentUser;
387
377
  }
388
378
  }
@@ -457,461 +447,6 @@ var init_AuthServiceProvider = __esm({
457
447
  }
458
448
  });
459
449
 
460
- // src/services/RBACService.ts
461
- var RBACService;
462
- var init_RBACService = __esm({
463
- "src/services/RBACService.ts"() {
464
- "use strict";
465
- init_BaseService();
466
- init_unified();
467
- init_debugLogger();
468
- RBACService = class extends BaseService {
469
- constructor(supabaseClient, user, session, appName) {
470
- super();
471
- this.permissions = {};
472
- this.roles = [];
473
- this.accessLevel = "viewer" /* VIEWER */;
474
- this.rbacLoading = false;
475
- this.rbacError = null;
476
- this.selectedEventId = null;
477
- this.appConfig = null;
478
- this.userEventAccess = [];
479
- this.eventAccessLoading = false;
480
- this.selectedOrganisationId = null;
481
- // Dependencies
482
- this.supabaseClient = null;
483
- this.user = null;
484
- this.session = null;
485
- this.appName = "";
486
- this.supabaseClient = supabaseClient;
487
- this.user = user;
488
- this.session = session;
489
- this.appName = appName;
490
- }
491
- // Update dependencies
492
- updateDependencies(user, session, appName) {
493
- this.user = user;
494
- this.session = session;
495
- this.appName = appName;
496
- this.notify();
497
- }
498
- // RBAC state getters
499
- getPermissions() {
500
- return this.permissions;
501
- }
502
- getRoles() {
503
- return this.roles;
504
- }
505
- getAccessLevel() {
506
- return this.accessLevel;
507
- }
508
- isLoading() {
509
- return this.rbacLoading;
510
- }
511
- getError() {
512
- return this.rbacError;
513
- }
514
- getSelectedEventId() {
515
- return this.selectedEventId;
516
- }
517
- getAppConfig() {
518
- return this.appConfig;
519
- }
520
- getUserEventAccess() {
521
- return this.userEventAccess;
522
- }
523
- isEventAccessLoading() {
524
- return this.eventAccessLoading;
525
- }
526
- getSelectedOrganisationId() {
527
- return this.selectedOrganisationId;
528
- }
529
- // RBAC methods
530
- hasPermission(permission, orgId) {
531
- return !!this.permissions[permission];
532
- }
533
- hasAnyPermission(permissions, orgId) {
534
- return permissions.some((p) => !!this.permissions[p]);
535
- }
536
- hasAllPermissions(permissions, orgId) {
537
- return permissions.every((p) => !!this.permissions[p]);
538
- }
539
- hasRole(role) {
540
- const isSuperAdmin = this.user?.user_metadata?.globalRole === "super_admin";
541
- if (role.toLowerCase() === "super_admin" || role.toLowerCase() === "super") {
542
- return isSuperAdmin;
543
- }
544
- return this.roles.includes(role);
545
- }
546
- hasAccessLevel(level) {
547
- const levels = Object.values(AccessLevel);
548
- return levels.indexOf(this.accessLevel) >= levels.indexOf(level);
549
- }
550
- canAccess(resource, action, orgId) {
551
- const permission = `${resource}:${action}`;
552
- return this.hasPermission(permission, orgId);
553
- }
554
- async validatePermission(permission, orgId) {
555
- return this.hasPermission(permission, orgId);
556
- }
557
- async validateAccess(resource, action, orgId) {
558
- return this.canAccess(resource, action, orgId);
559
- }
560
- async refreshPermissions(eventId, orgId) {
561
- if (!this.supabaseClient || !this.user || !this.appConfig || !this.session) {
562
- DebugLogger.log("RBACService", "refreshPermissions: Missing required dependencies, clearing permissions");
563
- this.permissions = {};
564
- this.roles = [];
565
- this.accessLevel = "viewer" /* VIEWER */;
566
- this.notify();
567
- return;
568
- }
569
- const isSuperAdmin = this.user?.user_metadata?.globalRole === "super_admin";
570
- if (isSuperAdmin) {
571
- this.permissions = {
572
- "admin:create": true,
573
- "admin:read": true,
574
- "admin:update": true,
575
- "admin:delete": true,
576
- "users:create": true,
577
- "users:read": true,
578
- "users:update": true,
579
- "users:delete": true,
580
- "events:create": true,
581
- "events:read": true,
582
- "events:update": true,
583
- "events:delete": true
584
- };
585
- this.roles = ["super_admin"];
586
- this.accessLevel = "admin" /* ADMIN */;
587
- this.notify();
588
- return;
589
- }
590
- const shouldLoadDirectPermissions = !eventId && !this.appConfig.requires_event;
591
- const shouldLoadEventPermissions = eventId;
592
- const shouldClearPermissions = !eventId && this.appConfig.requires_event;
593
- if (shouldClearPermissions) {
594
- this.permissions = {};
595
- this.roles = [];
596
- this.accessLevel = "viewer" /* VIEWER */;
597
- this.notify();
598
- return;
599
- }
600
- if (!shouldLoadDirectPermissions && !shouldLoadEventPermissions) {
601
- return;
602
- }
603
- this.rbacLoading = true;
604
- this.rbacError = null;
605
- this.notify();
606
- try {
607
- const { getCurrentAppName } = await import("./appNameResolver-UURKN7NF.js");
608
- const resolvedAppName = getCurrentAppName() || this.appName;
609
- const { data: appData, error: appError } = await this.supabaseClient.from("rbac_apps").select("id").eq("name", resolvedAppName).eq("is_active", true).single();
610
- if (appError || !appData) {
611
- console.warn("App not found or inactive:", resolvedAppName);
612
- this.rbacLoading = false;
613
- this.notify();
614
- return;
615
- }
616
- const { data, error } = await this.supabaseClient.rpc("rbac_permissions_get", {
617
- p_user_id: this.user.id,
618
- p_app_id: appData.id,
619
- p_event_id: eventId || null,
620
- p_organisation_id: orgId || this.selectedOrganisationId || null
621
- });
622
- if (error) {
623
- throw error;
624
- }
625
- const { permissions, roles, access_level } = this.transformRBACPermissions(data, this.appName);
626
- this.permissions = permissions;
627
- this.roles = roles;
628
- this.accessLevel = access_level;
629
- } catch (err) {
630
- this.rbacError = err;
631
- } finally {
632
- this.rbacLoading = false;
633
- this.notify();
634
- }
635
- }
636
- setSelectedEventId(eventId) {
637
- this.selectedEventId = eventId;
638
- this.notify();
639
- }
640
- async loadUserEventAccess(orgId) {
641
- if (!this.supabaseClient || !this.user || !this.session) {
642
- DebugLogger.log("RBACService", "loadUserEventAccess: Missing required dependencies, clearing event access");
643
- this.userEventAccess = [];
644
- this.notify();
645
- return;
646
- }
647
- this.eventAccessLoading = true;
648
- this.notify();
649
- try {
650
- const { getCurrentAppName } = await import("./appNameResolver-UURKN7NF.js");
651
- const resolvedAppName = getCurrentAppName() || this.appName;
652
- const { data: appData, error: appError } = await this.supabaseClient.from("rbac_apps").select("id").eq("name", resolvedAppName).eq("is_active", true).single();
653
- if (appError || !appData) {
654
- console.warn("App not found or inactive:", resolvedAppName);
655
- this.eventAccessLoading = false;
656
- this.notify();
657
- return;
658
- }
659
- const { data, error } = await this.supabaseClient.from("rbac_event_app_roles").select(`
660
- event_id,
661
- role,
662
- granted_at
663
- `).eq("user_id", this.user.id).eq("app_id", appData.id);
664
- if (error) {
665
- console.error("Failed to load user event access:", error);
666
- this.userEventAccess = [];
667
- this.notify();
668
- return;
669
- }
670
- const eventAccess = data?.map((item) => ({
671
- event_id: item.event_id,
672
- event_name: item.event_name || "Unknown Event",
673
- // Event details not available in this query
674
- event_description: item.event_description || null,
675
- // Not available in this schema
676
- start_date: item.start_date || "",
677
- // Event date not available in this query
678
- end_date: item.end_date || "",
679
- // Event date not available in this query
680
- event_status: item.event_status || "unknown",
681
- // Not available in this schema
682
- app_id: item.app_id || appData.id,
683
- access_level: item.access_level || item.role,
684
- // Map role to access_level
685
- granted_at: item.granted_at,
686
- organisation_id: item.organisation_id || ""
687
- // Will be populated from event's organisation_id if needed
688
- })) || [];
689
- this.userEventAccess = eventAccess;
690
- } catch (error) {
691
- console.error("Error loading user event access:", error);
692
- this.userEventAccess = [];
693
- } finally {
694
- this.eventAccessLoading = false;
695
- this.notify();
696
- }
697
- }
698
- getUserEventAccessById(eventId) {
699
- return this.userEventAccess.find((access) => access.event_id === eventId);
700
- }
701
- requireOrganisationContext() {
702
- if (!this.selectedOrganisationId) {
703
- throw new Error("Organisation context is required but not available");
704
- }
705
- return this.selectedOrganisationId;
706
- }
707
- // Lifecycle methods
708
- async initialize() {
709
- await super.initialize();
710
- await this.loadAppConfig();
711
- const isSuperAdmin = this.user?.user_metadata?.globalRole === "super_admin";
712
- if (!isSuperAdmin && this.appConfig) {
713
- await this.refreshPermissions(this.selectedEventId || void 0);
714
- }
715
- await this.loadPersistedState();
716
- }
717
- cleanup() {
718
- super.cleanup();
719
- }
720
- async doInitialize() {
721
- const isSuperAdmin = this.user?.user_metadata?.globalRole === "super_admin";
722
- if (isSuperAdmin) {
723
- this.roles = ["super_admin"];
724
- this.accessLevel = "admin" /* ADMIN */;
725
- this.permissions = {
726
- "admin:create": true,
727
- "admin:read": true,
728
- "admin:update": true,
729
- "admin:delete": true,
730
- "users:create": true,
731
- "users:read": true,
732
- "users:update": true,
733
- "users:delete": true,
734
- "events:create": true,
735
- "events:read": true,
736
- "events:update": true,
737
- "events:delete": true
738
- };
739
- } else {
740
- this.roles = [];
741
- this.accessLevel = "viewer" /* VIEWER */;
742
- this.permissions = {};
743
- }
744
- }
745
- doCleanup() {
746
- }
747
- async loadAppConfig() {
748
- if (!this.supabaseClient) return;
749
- try {
750
- const { getCurrentAppName } = await import("./appNameResolver-UURKN7NF.js");
751
- const resolvedAppName = getCurrentAppName() || this.appName;
752
- const { data: appData, error: appError } = await this.supabaseClient.from("rbac_apps").select("id").eq("name", resolvedAppName).eq("is_active", true).single();
753
- if (appError || !appData) {
754
- console.warn("App not found or inactive:", resolvedAppName);
755
- this.appConfig = {
756
- supports_direct_access: false,
757
- requires_event: true
758
- };
759
- return;
760
- }
761
- const response = await this.supabaseClient.rpc("get_app_config", {
762
- app_id: appData.id
763
- });
764
- const { data } = response || {};
765
- if (data && data.length > 0) {
766
- this.appConfig = {
767
- supports_direct_access: false,
768
- requires_event: data[0].requires_event
769
- };
770
- } else {
771
- this.appConfig = {
772
- supports_direct_access: false,
773
- requires_event: true
774
- };
775
- }
776
- } catch (error) {
777
- console.warn("Failed to load app configuration:", error);
778
- this.appConfig = {
779
- supports_direct_access: false,
780
- requires_event: true
781
- };
782
- }
783
- }
784
- async loadPersistedState() {
785
- try {
786
- const persistedEvent = localStorage.getItem("pace-core-selected-event");
787
- if (persistedEvent) {
788
- this.selectedEventId = JSON.parse(persistedEvent);
789
- }
790
- } catch (error) {
791
- console.warn("Clearing corrupted localStorage data");
792
- localStorage.removeItem("pace-core-selected-event");
793
- }
794
- }
795
- transformRBACPermissions(rbacData, appName) {
796
- const permissions = {};
797
- let roles = [];
798
- let access_level = "viewer" /* VIEWER */;
799
- if (!rbacData || !Array.isArray(rbacData)) {
800
- return { permissions: {}, roles: ["viewer"], access_level: "viewer" /* VIEWER */ };
801
- }
802
- const superAdminPerm = rbacData.find((p) => p.permission_type === "all_permissions");
803
- if (superAdminPerm) {
804
- return {
805
- permissions: { "all:all": true },
806
- roles: ["super"],
807
- access_level: "super" /* SUPER */
808
- };
809
- }
810
- const eventAppPerms = rbacData.filter((p) => p.permission_type === "event_app_access");
811
- if (eventAppPerms.length > 0) {
812
- const role = eventAppPerms[0].role_name;
813
- switch (role) {
814
- case "event_admin":
815
- access_level = "admin" /* ADMIN */;
816
- roles = ["admin"];
817
- break;
818
- case "planner":
819
- access_level = "planner" /* PLANNER */;
820
- roles = ["planner"];
821
- break;
822
- case "participant":
823
- access_level = "participant" /* PARTICIPANT */;
824
- roles = ["participant"];
825
- break;
826
- case "editor":
827
- access_level = "editor" /* EDITOR */;
828
- roles = ["editor"];
829
- break;
830
- case "viewer":
831
- default:
832
- access_level = "viewer" /* VIEWER */;
833
- roles = ["viewer"];
834
- break;
835
- }
836
- eventAppPerms.forEach((perm) => {
837
- if (perm.permission) {
838
- permissions[perm.permission] = true;
839
- }
840
- });
841
- const basePermissions = ["read"];
842
- if (["event_admin", "planner"].includes(role)) {
843
- basePermissions.push("create", "update");
844
- }
845
- if (role === "event_admin") {
846
- basePermissions.push("delete");
847
- }
848
- basePermissions.forEach((operation) => {
849
- permissions[`default:${operation}`] = true;
850
- });
851
- }
852
- const orgPerms = rbacData.filter((p) => p.permission_type === "organisation_access");
853
- if (orgPerms.length > 0) {
854
- const role = orgPerms[0].role_name;
855
- if (role === "org_admin") {
856
- access_level = "admin" /* ADMIN */;
857
- roles = ["admin"];
858
- ["create", "read", "update", "delete"].forEach((operation) => {
859
- permissions[`default:${operation}`] = true;
860
- });
861
- }
862
- }
863
- return { permissions, roles, access_level };
864
- }
865
- };
866
- }
867
- });
868
-
869
- // src/providers/services/RBACServiceProvider.tsx
870
- import { createContext as createContext2, useContext as useContext2, useMemo as useMemo2, useEffect as useEffect2 } from "react";
871
- import { jsx as jsx2 } from "react/jsx-runtime";
872
- function RBACServiceProvider({
873
- children,
874
- supabaseClient,
875
- user,
876
- session,
877
- appName
878
- }) {
879
- const rbacService = useMemo2(
880
- () => new RBACService(supabaseClient, user, session, appName),
881
- [supabaseClient, user, session, appName]
882
- );
883
- useEffect2(() => {
884
- rbacService.updateDependencies(user, session, appName);
885
- }, [rbacService, user, session, appName]);
886
- useEffect2(() => {
887
- rbacService.initialize().catch((error) => {
888
- console.error("[RBACServiceProvider] Failed to initialize RBAC service:", error);
889
- });
890
- return () => {
891
- rbacService.cleanup();
892
- };
893
- }, [rbacService]);
894
- const contextValue = useMemo2(() => ({
895
- rbacService
896
- }), [rbacService]);
897
- return /* @__PURE__ */ jsx2(RBACServiceContext.Provider, { value: contextValue, children });
898
- }
899
- var RBACServiceContext, useRBACService;
900
- var init_RBACServiceProvider = __esm({
901
- "src/providers/services/RBACServiceProvider.tsx"() {
902
- "use strict";
903
- init_RBACService();
904
- RBACServiceContext = createContext2(null);
905
- useRBACService = () => {
906
- const context = useContext2(RBACServiceContext);
907
- if (!context) {
908
- throw new Error("useRBACService must be used within RBACServiceProvider");
909
- }
910
- return context.rbacService;
911
- };
912
- }
913
- });
914
-
915
450
  // src/services/OrganisationService.ts
916
451
  var OrganisationService;
917
452
  var init_OrganisationService = __esm({
@@ -919,7 +454,6 @@ var init_OrganisationService = __esm({
919
454
  "use strict";
920
455
  init_BaseService();
921
456
  init_organisationContext();
922
- init_debugLogger();
923
457
  OrganisationService = class extends BaseService {
924
458
  constructor(supabaseClient, user, session) {
925
459
  super();
@@ -927,7 +461,7 @@ var init_OrganisationService = __esm({
927
461
  this._organisations = [];
928
462
  this._userMemberships = [];
929
463
  this._roleMapState = /* @__PURE__ */ new Map();
930
- this._isLoading = true;
464
+ this._isLoading = false;
931
465
  this._error = null;
932
466
  this._isContextReady = false;
933
467
  this.retryCount = 0;
@@ -1002,13 +536,17 @@ var init_OrganisationService = __esm({
1002
536
  }
1003
537
  // Update dependencies
1004
538
  updateDependencies(user, session) {
539
+ const wasAuthenticated = !!(this.user && this.session);
540
+ const isAuthenticated = !!(user && session);
1005
541
  this.user = user;
1006
542
  this.session = session;
543
+ if (wasAuthenticated && !isAuthenticated) {
544
+ this.isInitialized = false;
545
+ }
1007
546
  this.notify();
1008
547
  }
1009
548
  // Organisation methods
1010
549
  async switchOrganisation(orgId) {
1011
- DebugLogger.log("OrganisationService", "Switching to organisation:", orgId);
1012
550
  if (!this.validateOrganisationAccess(orgId)) {
1013
551
  throw new Error(`User does not have access to organisation ${orgId}`);
1014
552
  }
@@ -1019,7 +557,6 @@ var init_OrganisationService = __esm({
1019
557
  this._selectedOrganisation = targetOrg;
1020
558
  localStorage.setItem("pace-core-selected-organisation", JSON.stringify(targetOrg));
1021
559
  await this.setDatabaseOrganisationContext(targetOrg);
1022
- DebugLogger.log("OrganisationService", "Switched to organisation:", targetOrg.display_name);
1023
560
  this.notify();
1024
561
  }
1025
562
  getUserRole(orgId) {
@@ -1075,14 +612,15 @@ var init_OrganisationService = __esm({
1075
612
  // Lifecycle methods
1076
613
  async initialize() {
1077
614
  await super.initialize();
1078
- await this.loadUserOrganisations();
615
+ if (!this.isLoadingRef) {
616
+ await this.loadUserOrganisations();
617
+ }
1079
618
  }
1080
619
  cleanup() {
1081
620
  this.isLoadingRef = false;
1082
621
  this.hasFailedRef = false;
1083
622
  this.lastLoadTimeRef = 0;
1084
623
  if (this.abortControllerRef) {
1085
- this.abortControllerRef.abort();
1086
624
  this.abortControllerRef = null;
1087
625
  }
1088
626
  this._selectedOrganisation = null;
@@ -1106,13 +644,18 @@ var init_OrganisationService = __esm({
1106
644
  return;
1107
645
  }
1108
646
  try {
1109
- await setOrganisationContext(this.supabaseClient, organisation.id);
1110
- DebugLogger.log("OrganisationService", "Database organisation context set to:", organisation.display_name);
647
+ console.log("[OrganisationService] Setting database organisation context for:", organisation.id);
648
+ const timeoutPromise = new Promise((_, reject) => {
649
+ setTimeout(() => reject(new Error("Context setting timeout after 5 seconds")), 5e3);
650
+ });
651
+ const contextPromise = setOrganisationContext(this.supabaseClient, organisation.id);
652
+ await Promise.race([contextPromise, timeoutPromise]);
653
+ console.log("[OrganisationService] Database organisation context set successfully");
1111
654
  this._isContextReady = true;
1112
655
  this.notify();
1113
656
  } catch (error) {
1114
657
  console.error("[OrganisationService] Failed to set database organisation context:", error);
1115
- this._isContextReady = false;
658
+ this._isContextReady = true;
1116
659
  this.notify();
1117
660
  }
1118
661
  }
@@ -1120,7 +663,6 @@ var init_OrganisationService = __esm({
1120
663
  const callId = Math.random().toString(36).substr(2, 9);
1121
664
  console.log(`[OrganisationService] Starting loadUserOrganisations call ${callId}`);
1122
665
  if (!this.user || !this.session || !this.supabaseClient) {
1123
- DebugLogger.log("OrganisationService", "Clearing organisation state - no user, session, or supabase client");
1124
666
  this._selectedOrganisation = null;
1125
667
  this._organisations = [];
1126
668
  this._userMemberships = [];
@@ -1131,11 +673,19 @@ var init_OrganisationService = __esm({
1131
673
  }
1132
674
  if (this.isLoadingRef) {
1133
675
  console.log("OrganisationService", "Already loading, skipping duplicate load");
676
+ this._isLoading = true;
677
+ this.notify();
1134
678
  return;
1135
679
  }
1136
680
  const now = Date.now();
1137
681
  if (now - this.lastLoadTimeRef < 2e3) {
1138
682
  console.log("OrganisationService", "Too soon since last load, skipping");
683
+ if (this._organisations.length > 0 || this._selectedOrganisation) {
684
+ this._isLoading = false;
685
+ } else {
686
+ this._isLoading = true;
687
+ }
688
+ this.notify();
1139
689
  return;
1140
690
  }
1141
691
  if (this.abortControllerRef) {
@@ -1149,7 +699,6 @@ var init_OrganisationService = __esm({
1149
699
  this._error = null;
1150
700
  this.notify();
1151
701
  try {
1152
- DebugLogger.log("OrganisationService", "Loading organisations for user:", this.user.id);
1153
702
  console.log("[OrganisationService] Supabase client ready:", {
1154
703
  isConnected: !!this.supabaseClient,
1155
704
  hasAuth: !!this.supabaseClient.auth,
@@ -1234,7 +783,6 @@ var init_OrganisationService = __esm({
1234
783
  throw membershipError;
1235
784
  }
1236
785
  }
1237
- DebugLogger.log("OrganisationService", "Raw memberships data:", memberships);
1238
786
  if (!memberships || memberships.length === 0) {
1239
787
  throw new Error("User has no active organisation memberships");
1240
788
  }
@@ -1258,7 +806,6 @@ var init_OrganisationService = __esm({
1258
806
  console.warn("[OrganisationService] No valid organisation IDs found in memberships:", memberships);
1259
807
  throw new Error("No valid organisation IDs found in memberships");
1260
808
  }
1261
- DebugLogger.log("OrganisationService", "Valid organisation IDs:", organisationIds);
1262
809
  if (abortSignal.aborted) {
1263
810
  throw new Error("Request aborted");
1264
811
  }
@@ -1279,7 +826,6 @@ var init_OrganisationService = __esm({
1279
826
  if (activeOrgs.length === 0) {
1280
827
  throw new Error("User has no access to active organisations");
1281
828
  }
1282
- DebugLogger.log("OrganisationService", "Active organisations:", activeOrgs);
1283
829
  this._organisations = activeOrgs;
1284
830
  this._userMemberships = memberships;
1285
831
  this._roleMapState = roleMap;
@@ -1292,7 +838,6 @@ var init_OrganisationService = __esm({
1292
838
  const validPersistedOrg = activeOrgs.find((org) => org.id === persistedOrg.id);
1293
839
  if (validPersistedOrg) {
1294
840
  initialOrg = validPersistedOrg;
1295
- DebugLogger.log("OrganisationService", "Restored persisted organisation:", initialOrg.display_name);
1296
841
  } else {
1297
842
  console.warn("[OrganisationService] Persisted organisation not found in active orgs, clearing cache");
1298
843
  localStorage.removeItem("pace-core-selected-organisation");
@@ -1312,24 +857,18 @@ var init_OrganisationService = __esm({
1312
857
  const foundOrg = organisations.find((org) => org.id === adminMembership.organisation_id);
1313
858
  if (foundOrg) {
1314
859
  initialOrg = foundOrg;
1315
- DebugLogger.log("OrganisationService", "Selected org_admin organisation:", initialOrg.display_name);
1316
860
  }
1317
861
  }
1318
862
  }
1319
863
  if (!initialOrg) {
1320
864
  initialOrg = activeOrgs[0];
1321
- DebugLogger.log("OrganisationService", "Selected first organisation:", initialOrg.display_name);
1322
865
  }
1323
866
  if (!initialOrg) {
1324
867
  throw new Error("No valid organisation found for user");
1325
868
  }
1326
869
  this._selectedOrganisation = initialOrg;
1327
870
  localStorage.setItem("pace-core-selected-organisation", JSON.stringify(initialOrg));
1328
- DebugLogger.log("OrganisationService", "Organisation context established:", {
1329
- selectedOrganisation: initialOrg.display_name,
1330
- totalOrganisations: activeOrgs.length,
1331
- userRole: roleMap.get(initialOrg.id)
1332
- });
871
+ await this.setDatabaseOrganisationContext(initialOrg);
1333
872
  this.retryCount = 0;
1334
873
  this.hasFailedRef = false;
1335
874
  } catch (err) {
@@ -1360,42 +899,44 @@ var init_OrganisationService = __esm({
1360
899
  });
1361
900
 
1362
901
  // src/providers/services/OrganisationServiceProvider.tsx
1363
- import { createContext as createContext3, useContext as useContext3, useMemo as useMemo3, useEffect as useEffect3 } from "react";
1364
- import { jsx as jsx3 } from "react/jsx-runtime";
902
+ import { createContext as createContext2, useContext as useContext2, useMemo as useMemo2, useEffect as useEffect2, useRef } from "react";
903
+ import { jsx as jsx2 } from "react/jsx-runtime";
1365
904
  function OrganisationServiceProvider({
1366
905
  children,
1367
906
  supabaseClient,
1368
907
  user,
1369
908
  session
1370
909
  }) {
1371
- const organisationService = useMemo3(
1372
- () => new OrganisationService(supabaseClient, user, session),
1373
- [supabaseClient, user, session]
1374
- );
1375
- useEffect3(() => {
910
+ const organisationServiceRef = useRef(null);
911
+ if (!organisationServiceRef.current) {
912
+ organisationServiceRef.current = new OrganisationService(supabaseClient, user, session);
913
+ }
914
+ const organisationService = organisationServiceRef.current;
915
+ useEffect2(() => {
1376
916
  organisationService.updateDependencies(user, session);
1377
- }, [organisationService, user, session]);
1378
- useEffect3(() => {
917
+ let isMounted = true;
1379
918
  organisationService.initialize().catch((error) => {
1380
- console.error("[OrganisationServiceProvider] Failed to initialize organisation service:", error);
919
+ if (isMounted) {
920
+ console.error("[OrganisationServiceProvider] Failed to initialize organisation service:", error);
921
+ }
1381
922
  });
1382
923
  return () => {
1383
- organisationService.cleanup();
924
+ isMounted = false;
1384
925
  };
1385
- }, [organisationService]);
1386
- const contextValue = useMemo3(() => ({
926
+ }, [organisationService, user, session]);
927
+ const contextValue = useMemo2(() => ({
1387
928
  organisationService
1388
929
  }), [organisationService]);
1389
- return /* @__PURE__ */ jsx3(OrganisationServiceContext.Provider, { value: contextValue, children });
930
+ return /* @__PURE__ */ jsx2(OrganisationServiceContext.Provider, { value: contextValue, children });
1390
931
  }
1391
932
  var OrganisationServiceContext, useOrganisationService;
1392
933
  var init_OrganisationServiceProvider = __esm({
1393
934
  "src/providers/services/OrganisationServiceProvider.tsx"() {
1394
935
  "use strict";
1395
936
  init_OrganisationService();
1396
- OrganisationServiceContext = createContext3(null);
937
+ OrganisationServiceContext = createContext2(null);
1397
938
  useOrganisationService = () => {
1398
- const context = useContext3(OrganisationServiceContext);
939
+ const context = useContext2(OrganisationServiceContext);
1399
940
  if (!context) {
1400
941
  throw new Error("useOrganisationService must be used within OrganisationServiceProvider");
1401
942
  }
@@ -1410,13 +951,13 @@ var init_EventService = __esm({
1410
951
  "src/services/EventService.ts"() {
1411
952
  "use strict";
1412
953
  init_BaseService();
1413
- init_debugLogger();
1414
954
  EventService = class extends BaseService {
1415
955
  constructor(supabaseClient, user, session, appName, selectedOrganisation, setSelectedEventId) {
1416
956
  super();
1417
957
  this.events = [];
1418
958
  this.selectedEvent = null;
1419
- this._isLoading = true;
959
+ this._isLoading = false;
960
+ // Start as false to avoid blocking UI
1420
961
  this.error = null;
1421
962
  // Dependencies
1422
963
  this.supabaseClient = null;
@@ -1439,12 +980,23 @@ var init_EventService = __esm({
1439
980
  }
1440
981
  // Update dependencies
1441
982
  updateDependencies(supabaseClient, user, session, appName, selectedOrganisation, setSelectedEventId) {
983
+ const previousOrgId = this.selectedOrganisation?.id;
984
+ const newOrgId = selectedOrganisation?.id;
1442
985
  this.supabaseClient = supabaseClient;
1443
986
  this.user = user;
1444
987
  this.session = session;
1445
988
  this.appName = appName;
1446
989
  this.selectedOrganisation = selectedOrganisation;
1447
990
  this.setSelectedEventId = setSelectedEventId;
991
+ if (previousOrgId !== newOrgId) {
992
+ this.resetInitialization();
993
+ this.isInitializedRef = false;
994
+ this.isFetchingRef = false;
995
+ if (previousOrgId !== null && newOrgId !== previousOrgId) {
996
+ this.events = [];
997
+ this.selectedEvent = null;
998
+ }
999
+ }
1448
1000
  this.notify();
1449
1001
  }
1450
1002
  // Event state getters
@@ -1514,12 +1066,10 @@ var init_EventService = __esm({
1514
1066
  if (persistedEventId && events.length > 0) {
1515
1067
  const persistedEvent = events.find((event) => event.event_id === persistedEventId);
1516
1068
  if (persistedEvent) {
1517
- DebugLogger.log("EventService", "Restoring persisted event:", persistedEvent.event_name);
1518
1069
  this.selectedEvent = persistedEvent;
1519
1070
  this.setSelectedEventId?.(persistedEventId);
1520
1071
  return true;
1521
1072
  } else {
1522
- DebugLogger.log("EventService", "Persisted event not found in current events, clearing storage");
1523
1073
  sessionStorage.removeItem("pace-core-selected-event");
1524
1074
  localStorage.removeItem("pace-core-selected-event");
1525
1075
  }
@@ -1550,7 +1100,6 @@ var init_EventService = __esm({
1550
1100
  autoSelectNextEvent(events) {
1551
1101
  const nextEvent = this.getNextEventByDate(events);
1552
1102
  if (nextEvent) {
1553
- DebugLogger.log("EventService", "Auto-selecting next event:", nextEvent.event_name);
1554
1103
  this.selectedEvent = nextEvent;
1555
1104
  this.setSelectedEventId?.(nextEvent.event_id);
1556
1105
  this.persistEventSelection(nextEvent.event_id);
@@ -1571,40 +1120,22 @@ var init_EventService = __esm({
1571
1120
  }
1572
1121
  async fetchEvents() {
1573
1122
  if (!this.user || !this.session || !this.supabaseClient || !this.appName || !this.selectedOrganisation) {
1574
- DebugLogger.log("EventService", "Missing required dependencies, skipping fetch");
1575
- this._isLoading = false;
1576
1123
  this.notify();
1577
1124
  return;
1578
1125
  }
1126
+ this._isLoading = true;
1127
+ this.notify();
1579
1128
  if (this.isFetchingRef) {
1580
- DebugLogger.log("EventService", "Already fetching events, skipping");
1581
1129
  return;
1582
1130
  }
1583
- DebugLogger.log("EventService", "User and organisation found, fetching events for:", {
1584
- userId: this.user.id,
1585
- appName: this.appName,
1586
- organisationId: this.selectedOrganisation.id,
1587
- organisationName: this.selectedOrganisation.display_name
1588
- });
1589
1131
  this.isFetchingRef = true;
1590
1132
  let isMounted = true;
1591
1133
  try {
1592
- DebugLogger.log("EventService", "Calling data_user_events_get RPC with:", {
1593
- user_id: this.user.id,
1594
- organisation_id: this.selectedOrganisation.id,
1595
- app_name: this.appName
1596
- });
1597
1134
  const { data, error: rpcError } = await this.supabaseClient.rpc("data_user_events_get", {
1598
1135
  p_user_id: this.user.id,
1599
1136
  p_organisation_id: this.selectedOrganisation.id,
1600
1137
  p_app_name: this.appName
1601
1138
  });
1602
- DebugLogger.log("EventService", "RPC response:", {
1603
- data,
1604
- error: rpcError,
1605
- dataLength: data?.length || 0,
1606
- organisationId: this.selectedOrganisation.id
1607
- });
1608
1139
  if (rpcError) {
1609
1140
  throw new Error(rpcError.message || "Failed to fetch events");
1610
1141
  }
@@ -1640,7 +1171,6 @@ var init_EventService = __esm({
1640
1171
  if (!persistedEventLoaded && !this.userClearedEventRef) {
1641
1172
  const nextEvent = this.getNextEventByDate(transformedEvents);
1642
1173
  if (nextEvent) {
1643
- DebugLogger.log("EventService", "Auto-selecting next event after no persisted event found:", nextEvent.event_name);
1644
1174
  this.hasAutoSelectedRef = true;
1645
1175
  this.selectedEvent = nextEvent;
1646
1176
  this.setSelectedEventId?.(nextEvent.event_id);
@@ -1689,8 +1219,8 @@ var init_EventService = __esm({
1689
1219
  });
1690
1220
 
1691
1221
  // src/providers/services/EventServiceProvider.tsx
1692
- import { createContext as createContext4, useContext as useContext4, useMemo as useMemo4, useEffect as useEffect4 } from "react";
1693
- import { jsx as jsx4 } from "react/jsx-runtime";
1222
+ import { createContext as createContext3, useContext as useContext3, useMemo as useMemo3, useEffect as useEffect3, useRef as useRef2 } from "react";
1223
+ import { jsx as jsx3 } from "react/jsx-runtime";
1694
1224
  function EventServiceProvider({
1695
1225
  children,
1696
1226
  supabaseClient,
@@ -1700,34 +1230,36 @@ function EventServiceProvider({
1700
1230
  selectedOrganisation,
1701
1231
  setSelectedEventId
1702
1232
  }) {
1703
- const eventService = useMemo4(
1704
- () => new EventService(supabaseClient, user, session, appName, selectedOrganisation, setSelectedEventId),
1705
- [supabaseClient, user, session, appName, selectedOrganisation, setSelectedEventId]
1706
- );
1707
- useEffect4(() => {
1233
+ const eventServiceRef = useRef2(null);
1234
+ if (!eventServiceRef.current) {
1235
+ eventServiceRef.current = new EventService(supabaseClient, user, session, appName, selectedOrganisation, setSelectedEventId);
1236
+ }
1237
+ const eventService = eventServiceRef.current;
1238
+ useEffect3(() => {
1708
1239
  eventService.updateDependencies(supabaseClient, user, session, appName, selectedOrganisation, setSelectedEventId);
1709
- }, [eventService, supabaseClient, user, session, appName, selectedOrganisation, setSelectedEventId]);
1710
- useEffect4(() => {
1240
+ let isMounted = true;
1711
1241
  eventService.initialize().catch((error) => {
1712
- console.error("[EventServiceProvider] Failed to initialize event service:", error);
1242
+ if (isMounted) {
1243
+ console.error("[EventServiceProvider] Failed to initialize event service:", error);
1244
+ }
1713
1245
  });
1714
1246
  return () => {
1715
- eventService.cleanup();
1247
+ isMounted = false;
1716
1248
  };
1717
- }, [eventService]);
1718
- const contextValue = useMemo4(() => ({
1249
+ }, [eventService, supabaseClient, user, session, appName, selectedOrganisation, setSelectedEventId]);
1250
+ const contextValue = useMemo3(() => ({
1719
1251
  eventService
1720
1252
  }), [eventService]);
1721
- return /* @__PURE__ */ jsx4(EventServiceContext.Provider, { value: contextValue, children });
1253
+ return /* @__PURE__ */ jsx3(EventServiceContext.Provider, { value: contextValue, children });
1722
1254
  }
1723
1255
  var EventServiceContext, useEventService;
1724
1256
  var init_EventServiceProvider = __esm({
1725
1257
  "src/providers/services/EventServiceProvider.tsx"() {
1726
1258
  "use strict";
1727
1259
  init_EventService();
1728
- EventServiceContext = createContext4(null);
1260
+ EventServiceContext = createContext3(null);
1729
1261
  useEventService = () => {
1730
- const context = useContext4(EventServiceContext);
1262
+ const context = useContext3(EventServiceContext);
1731
1263
  if (!context) {
1732
1264
  throw new Error("useEventService must be used within EventServiceProvider");
1733
1265
  }
@@ -2051,8 +1583,8 @@ var init_InactivityService = __esm({
2051
1583
  });
2052
1584
 
2053
1585
  // src/providers/services/InactivityServiceProvider.tsx
2054
- import { createContext as createContext5, useContext as useContext5, useMemo as useMemo5, useEffect as useEffect5 } from "react";
2055
- import { jsx as jsx5 } from "react/jsx-runtime";
1586
+ import { createContext as createContext4, useContext as useContext4, useMemo as useMemo4, useEffect as useEffect4, useRef as useRef3 } from "react";
1587
+ import { jsx as jsx4 } from "react/jsx-runtime";
2056
1588
  function InactivityServiceProvider({
2057
1589
  children,
2058
1590
  supabaseClient,
@@ -2062,34 +1594,36 @@ function InactivityServiceProvider({
2062
1594
  warnBeforeMs = 60 * 1e3,
2063
1595
  onIdleLogout
2064
1596
  }) {
2065
- const inactivityService = useMemo5(
2066
- () => new InactivityService(supabaseClient, user, session, idleTimeoutMs, warnBeforeMs, onIdleLogout),
2067
- [supabaseClient, user, session, idleTimeoutMs, warnBeforeMs, onIdleLogout]
2068
- );
2069
- useEffect5(() => {
1597
+ const inactivityServiceRef = useRef3(null);
1598
+ if (!inactivityServiceRef.current) {
1599
+ inactivityServiceRef.current = new InactivityService(supabaseClient, user, session, idleTimeoutMs, warnBeforeMs, onIdleLogout);
1600
+ }
1601
+ const inactivityService = inactivityServiceRef.current;
1602
+ useEffect4(() => {
2070
1603
  inactivityService.updateDependencies(supabaseClient, user, session, idleTimeoutMs, warnBeforeMs, onIdleLogout);
2071
- }, [inactivityService, supabaseClient, user, session, idleTimeoutMs, warnBeforeMs, onIdleLogout]);
2072
- useEffect5(() => {
1604
+ let isMounted = true;
2073
1605
  inactivityService.initialize().catch((error) => {
2074
- console.error("[InactivityServiceProvider] Failed to initialize inactivity service:", error);
1606
+ if (isMounted) {
1607
+ console.error("[InactivityServiceProvider] Failed to initialize inactivity service:", error);
1608
+ }
2075
1609
  });
2076
1610
  return () => {
2077
- inactivityService.cleanup();
1611
+ isMounted = false;
2078
1612
  };
2079
- }, [inactivityService]);
2080
- const contextValue = useMemo5(() => ({
1613
+ }, [inactivityService, supabaseClient, user, session, idleTimeoutMs, warnBeforeMs, onIdleLogout]);
1614
+ const contextValue = useMemo4(() => ({
2081
1615
  inactivityService
2082
1616
  }), [inactivityService]);
2083
- return /* @__PURE__ */ jsx5(InactivityServiceContext.Provider, { value: contextValue, children });
1617
+ return /* @__PURE__ */ jsx4(InactivityServiceContext.Provider, { value: contextValue, children });
2084
1618
  }
2085
1619
  var InactivityServiceContext, useInactivityService;
2086
1620
  var init_InactivityServiceProvider = __esm({
2087
1621
  "src/providers/services/InactivityServiceProvider.tsx"() {
2088
1622
  "use strict";
2089
1623
  init_InactivityService();
2090
- InactivityServiceContext = createContext5(null);
1624
+ InactivityServiceContext = createContext4(null);
2091
1625
  useInactivityService = () => {
2092
- const context = useContext5(InactivityServiceContext);
1626
+ const context = useContext4(InactivityServiceContext);
2093
1627
  if (!context) {
2094
1628
  throw new Error("useInactivityService must be used within InactivityServiceProvider");
2095
1629
  }
@@ -2099,14 +1633,14 @@ var init_InactivityServiceProvider = __esm({
2099
1633
  });
2100
1634
 
2101
1635
  // src/hooks/services/useAuthService.ts
2102
- import { useContext as useContext6, useReducer, useEffect as useEffect6 } from "react";
1636
+ import { useContext as useContext5, useReducer, useEffect as useEffect5 } from "react";
2103
1637
  function useAuthService2() {
2104
- const context = useContext6(AuthServiceContext);
1638
+ const context = useContext5(AuthServiceContext);
2105
1639
  if (!context) {
2106
1640
  throw new Error("useAuthService must be used within AuthServiceProvider");
2107
1641
  }
2108
1642
  const [, forceUpdate] = useReducer((x) => x + 1, 0);
2109
- useEffect6(() => {
1643
+ useEffect5(() => {
2110
1644
  return context.authService.subscribe(() => forceUpdate());
2111
1645
  }, [context.authService]);
2112
1646
  return context.authService;
@@ -2118,35 +1652,15 @@ var init_useAuthService = __esm({
2118
1652
  }
2119
1653
  });
2120
1654
 
2121
- // src/hooks/services/useRBACService.ts
2122
- import { useContext as useContext7, useReducer as useReducer2, useEffect as useEffect7 } from "react";
2123
- function useRBACService2() {
2124
- const context = useContext7(RBACServiceContext);
2125
- if (!context) {
2126
- throw new Error("useRBACService must be used within RBACServiceProvider");
2127
- }
2128
- const [, forceUpdate] = useReducer2((x) => x + 1, 0);
2129
- useEffect7(() => {
2130
- return context.rbacService.subscribe(() => forceUpdate());
2131
- }, [context.rbacService]);
2132
- return context.rbacService;
2133
- }
2134
- var init_useRBACService = __esm({
2135
- "src/hooks/services/useRBACService.ts"() {
2136
- "use strict";
2137
- init_RBACServiceProvider();
2138
- }
2139
- });
2140
-
2141
1655
  // src/hooks/services/useOrganisationService.ts
2142
- import { useContext as useContext8, useReducer as useReducer3, useEffect as useEffect8 } from "react";
1656
+ import { useContext as useContext6, useReducer as useReducer2, useEffect as useEffect6 } from "react";
2143
1657
  function useOrganisationService2() {
2144
- const context = useContext8(OrganisationServiceContext);
1658
+ const context = useContext6(OrganisationServiceContext);
2145
1659
  if (!context) {
2146
1660
  throw new Error("useOrganisationService must be used within OrganisationServiceProvider");
2147
1661
  }
2148
- const [, forceUpdate] = useReducer3((x) => x + 1, 0);
2149
- useEffect8(() => {
1662
+ const [, forceUpdate] = useReducer2((x) => x + 1, 0);
1663
+ useEffect6(() => {
2150
1664
  return context.organisationService.subscribe(() => forceUpdate());
2151
1665
  }, [context.organisationService]);
2152
1666
  return context.organisationService;
@@ -2159,14 +1673,14 @@ var init_useOrganisationService = __esm({
2159
1673
  });
2160
1674
 
2161
1675
  // src/hooks/services/useEventService.ts
2162
- import { useContext as useContext9, useReducer as useReducer4, useEffect as useEffect9 } from "react";
1676
+ import { useContext as useContext7, useReducer as useReducer3, useEffect as useEffect7 } from "react";
2163
1677
  function useEventService2() {
2164
- const context = useContext9(EventServiceContext);
1678
+ const context = useContext7(EventServiceContext);
2165
1679
  if (!context) {
2166
1680
  throw new Error("useEventService must be used within EventServiceProvider");
2167
1681
  }
2168
- const [, forceUpdate] = useReducer4((x) => x + 1, 0);
2169
- useEffect9(() => {
1682
+ const [, forceUpdate] = useReducer3((x) => x + 1, 0);
1683
+ useEffect7(() => {
2170
1684
  return context.eventService.subscribe(() => forceUpdate());
2171
1685
  }, [context.eventService]);
2172
1686
  return context.eventService;
@@ -2179,14 +1693,14 @@ var init_useEventService = __esm({
2179
1693
  });
2180
1694
 
2181
1695
  // src/hooks/services/useInactivityService.ts
2182
- import { useContext as useContext10, useReducer as useReducer5, useEffect as useEffect10 } from "react";
1696
+ import { useContext as useContext8, useReducer as useReducer4, useEffect as useEffect8 } from "react";
2183
1697
  function useInactivityService2() {
2184
- const context = useContext10(InactivityServiceContext);
1698
+ const context = useContext8(InactivityServiceContext);
2185
1699
  if (!context) {
2186
1700
  throw new Error("useInactivityService must be used within InactivityServiceProvider");
2187
1701
  }
2188
- const [, forceUpdate] = useReducer5((x) => x + 1, 0);
2189
- useEffect10(() => {
1702
+ const [, forceUpdate] = useReducer4((x) => x + 1, 0);
1703
+ useEffect8(() => {
2190
1704
  return context.inactivityService.subscribe(() => forceUpdate());
2191
1705
  }, [context.inactivityService]);
2192
1706
  return context.inactivityService;
@@ -2199,113 +1713,149 @@ var init_useInactivityService = __esm({
2199
1713
  });
2200
1714
 
2201
1715
  // src/providers/services/UnifiedAuthProvider.tsx
2202
- import { createContext as createContext6, useContext as useContext11, useMemo as useMemo6 } from "react";
2203
- import { jsx as jsx6 } from "react/jsx-runtime";
1716
+ import { createContext as createContext5, useContext as useContext9, useMemo as useMemo5 } from "react";
1717
+ import { Fragment, jsx as jsx5 } from "react/jsx-runtime";
2204
1718
  function UnifiedAuthContextProvider({
2205
1719
  children,
2206
1720
  appName,
1721
+ appConfig = { requires_event: true },
1722
+ // Default to requiring events
2207
1723
  ...props
2208
1724
  }) {
2209
1725
  const authService = useAuthService2();
2210
- const rbacService = useRBACService2();
2211
1726
  const organisationService = useOrganisationService2();
2212
- const eventService = useEventService2();
2213
1727
  const inactivityService = useInactivityService2();
2214
- const contextValue = useMemo6(() => ({
2215
- // Auth state
2216
- user: authService.getUser(),
2217
- session: authService.getSession(),
2218
- isAuthenticated: authService.isAuthenticated(),
2219
- authLoading: authService.isLoading(),
2220
- authError: authService.getError(),
2221
- error: authService.getError(),
2222
- // Alias for backward compatibility
2223
- supabase: authService.getSupabaseClient(),
2224
- // Auth methods
2225
- signIn: authService.signIn.bind(authService),
2226
- signUp: authService.signUp.bind(authService),
2227
- signOut: authService.signOut.bind(authService),
2228
- resetPassword: authService.resetPassword.bind(authService),
2229
- updatePassword: authService.updatePassword.bind(authService),
2230
- refreshSession: authService.refreshSession.bind(authService),
2231
- // RBAC state
2232
- permissions: rbacService.getPermissions(),
2233
- roles: rbacService.getRoles(),
2234
- accessLevel: rbacService.getAccessLevel(),
2235
- rbacLoading: rbacService.isLoading(),
2236
- rbacError: rbacService.getError(),
2237
- selectedEventId: rbacService.getSelectedEventId(),
2238
- appConfig: rbacService.getAppConfig(),
2239
- userEventAccess: rbacService.getUserEventAccess(),
2240
- eventAccessLoading: rbacService.isEventAccessLoading(),
2241
- selectedOrganisationId: rbacService.getSelectedOrganisationId(),
2242
- // RBAC methods
2243
- hasPermission: rbacService.hasPermission.bind(rbacService),
2244
- hasAnyPermission: rbacService.hasAnyPermission.bind(rbacService),
2245
- hasAllPermissions: rbacService.hasAllPermissions.bind(rbacService),
2246
- hasRole: rbacService.hasRole.bind(rbacService),
2247
- hasAccessLevel: rbacService.hasAccessLevel.bind(rbacService),
2248
- canAccess: rbacService.canAccess.bind(rbacService),
2249
- validatePermission: rbacService.validatePermission.bind(rbacService),
2250
- validateAccess: rbacService.validateAccess.bind(rbacService),
2251
- refreshPermissions: rbacService.refreshPermissions.bind(rbacService),
2252
- setSelectedEventId: rbacService.setSelectedEventId.bind(rbacService),
2253
- loadUserEventAccess: rbacService.loadUserEventAccess.bind(rbacService),
2254
- getUserEventAccess: rbacService.getUserEventAccess.bind(rbacService),
2255
- requireOrganisationContext: rbacService.requireOrganisationContext.bind(rbacService),
2256
- // Organisation state
2257
- selectedOrganisation: organisationService.getSelectedOrganisation(),
2258
- organisations: organisationService.getOrganisations(),
2259
- userMemberships: organisationService.getUserMemberships(),
2260
- organisationLoading: organisationService.isLoading(),
2261
- organisationError: organisationService.getError(),
2262
- hasValidOrganisationContext: organisationService.hasValidOrganisationContext(),
2263
- isContextReady: organisationService.isContextReady(),
2264
- // Organisation methods
2265
- switchOrganisation: organisationService.switchOrganisation.bind(organisationService),
2266
- getUserRole: organisationService.getUserRole.bind(organisationService),
2267
- validateOrganisationAccess: organisationService.validateOrganisationAccess.bind(organisationService),
2268
- refreshOrganisations: organisationService.refreshOrganisations.bind(organisationService),
2269
- ensureOrganisationContext: organisationService.ensureOrganisationContext.bind(organisationService),
2270
- isOrganisationSecure: organisationService.isOrganisationSecure.bind(organisationService),
2271
- getPrimaryOrganisation: organisationService.getPrimaryOrganisation.bind(organisationService),
2272
- // Event state
2273
- events: eventService.getEvents(),
2274
- selectedEvent: eventService.getSelectedEvent(),
2275
- eventLoading: eventService.isLoading(),
2276
- eventError: eventService.getError(),
2277
- // Event methods
2278
- setSelectedEvent: eventService.setSelectedEvent.bind(eventService),
2279
- refreshEvents: eventService.refreshEvents.bind(eventService),
2280
- // Inactivity state
2281
- showInactivityWarning: inactivityService.getShowInactivityWarning(),
2282
- inactivityTimeRemaining: inactivityService.getInactivityTimeRemaining(),
2283
- isIdle: inactivityService.isIdle(),
2284
- timeRemaining: inactivityService.getTimeRemaining(),
2285
- showWarning: inactivityService.isWarningShown(),
2286
- isTracking: inactivityService.isTracking(),
2287
- // Inactivity methods
2288
- resetActivity: inactivityService.resetActivity.bind(inactivityService),
2289
- startTracking: inactivityService.startTracking.bind(inactivityService),
2290
- stopTracking: inactivityService.stopTracking.bind(inactivityService),
2291
- handleIdleLogout: inactivityService.handleIdleLogout.bind(inactivityService),
2292
- handleStaySignedIn: inactivityService.handleStaySignedIn.bind(inactivityService),
2293
- handleSignOutNow: inactivityService.handleSignOutNow.bind(inactivityService),
2294
- // Additional unified properties
2295
- appName,
2296
- isLoading: authService.isLoading() || rbacService.isLoading() || organisationService.isLoading() || eventService.isLoading(),
2297
- hasErrors: !!(authService.getError() || rbacService.getError() || organisationService.getError() || eventService.getError())
2298
- }), [authService, rbacService, organisationService, eventService, inactivityService, appName]);
2299
- return /* @__PURE__ */ jsx6(UnifiedAuthContext.Provider, { value: contextValue, children });
1728
+ let eventService;
1729
+ try {
1730
+ eventService = useEventService2();
1731
+ } catch (error) {
1732
+ eventService = {
1733
+ getEvents: () => [],
1734
+ getSelectedEvent: () => null,
1735
+ isLoading: () => false,
1736
+ getError: () => null,
1737
+ setSelectedEvent: () => {
1738
+ },
1739
+ refreshEvents: async () => {
1740
+ }
1741
+ };
1742
+ }
1743
+ const currentUser = authService.getUser();
1744
+ const currentSession = authService.getSession();
1745
+ const isAuth = !!(currentUser && currentSession);
1746
+ const authLoading = authService.isLoading();
1747
+ const orgLoading = organisationService.isLoading();
1748
+ const eventLoading = eventService.isLoading();
1749
+ const totalLoading = authLoading || orgLoading || eventLoading;
1750
+ console.log("[UnifiedAuthContext] Auth state:", {
1751
+ isAuthenticated: isAuth,
1752
+ user: currentUser?.email,
1753
+ session: currentSession ? "exists" : "null",
1754
+ totalLoading,
1755
+ authLoading,
1756
+ orgLoading,
1757
+ eventLoading,
1758
+ orgContextReady: organisationService.isContextReady()
1759
+ });
1760
+ const contextValue = useMemo5(() => {
1761
+ return {
1762
+ // Auth state
1763
+ user: currentUser,
1764
+ session: currentSession,
1765
+ isAuthenticated: isAuth,
1766
+ authLoading,
1767
+ authError: authService.getError(),
1768
+ error: authService.getError(),
1769
+ // Alias for backward compatibility
1770
+ supabase: authService.getSupabaseClient(),
1771
+ // Auth methods
1772
+ signIn: authService.signIn.bind(authService),
1773
+ signUp: authService.signUp.bind(authService),
1774
+ signOut: authService.signOut.bind(authService),
1775
+ resetPassword: authService.resetPassword.bind(authService),
1776
+ updatePassword: authService.updatePassword.bind(authService),
1777
+ refreshSession: authService.refreshSession.bind(authService),
1778
+ // Organisation state
1779
+ selectedOrganisation: organisationService.getSelectedOrganisation(),
1780
+ organisations: organisationService.getOrganisations(),
1781
+ userMemberships: organisationService.getUserMemberships(),
1782
+ organisationLoading: orgLoading,
1783
+ organisationError: organisationService.getError(),
1784
+ hasValidOrganisationContext: organisationService.hasValidOrganisationContext(),
1785
+ isContextReady: organisationService.isContextReady(),
1786
+ // Organisation methods
1787
+ switchOrganisation: organisationService.switchOrganisation.bind(organisationService),
1788
+ getUserRole: organisationService.getUserRole.bind(organisationService),
1789
+ validateOrganisationAccess: organisationService.validateOrganisationAccess.bind(organisationService),
1790
+ refreshOrganisations: organisationService.refreshOrganisations.bind(organisationService),
1791
+ ensureOrganisationContext: organisationService.ensureOrganisationContext.bind(organisationService),
1792
+ isOrganisationSecure: organisationService.isOrganisationSecure.bind(organisationService),
1793
+ getPrimaryOrganisation: organisationService.getPrimaryOrganisation.bind(organisationService),
1794
+ // Event state
1795
+ events: eventService.getEvents(),
1796
+ selectedEvent: eventService.getSelectedEvent(),
1797
+ eventLoading,
1798
+ eventError: eventService.getError(),
1799
+ // Event methods
1800
+ setSelectedEvent: eventService.setSelectedEvent.bind(eventService),
1801
+ refreshEvents: eventService.refreshEvents.bind(eventService),
1802
+ // Inactivity state
1803
+ showInactivityWarning: inactivityService.getShowInactivityWarning(),
1804
+ inactivityTimeRemaining: inactivityService.getInactivityTimeRemaining(),
1805
+ isIdle: inactivityService.isIdle(),
1806
+ timeRemaining: inactivityService.getTimeRemaining(),
1807
+ showWarning: inactivityService.isWarningShown(),
1808
+ isTracking: inactivityService.isTracking(),
1809
+ // Inactivity methods
1810
+ resetActivity: inactivityService.resetActivity.bind(inactivityService),
1811
+ startTracking: inactivityService.startTracking.bind(inactivityService),
1812
+ stopTracking: inactivityService.stopTracking.bind(inactivityService),
1813
+ handleIdleLogout: inactivityService.handleIdleLogout.bind(inactivityService),
1814
+ handleStaySignedIn: inactivityService.handleStaySignedIn.bind(inactivityService),
1815
+ handleSignOutNow: inactivityService.handleSignOutNow.bind(inactivityService),
1816
+ // Additional unified properties
1817
+ appName,
1818
+ appConfig,
1819
+ isLoading: totalLoading,
1820
+ hasErrors: !!(authService.getError() || organisationService.getError() || eventService.getError())
1821
+ };
1822
+ }, [authService, organisationService, eventService, inactivityService, appName, appConfig, currentUser, currentSession, isAuth, authLoading, orgLoading, eventLoading, totalLoading]);
1823
+ return /* @__PURE__ */ jsx5(UnifiedAuthContext.Provider, { value: contextValue, children });
1824
+ }
1825
+ function EventServiceProviderWrapper({
1826
+ children,
1827
+ supabaseClient,
1828
+ user,
1829
+ session,
1830
+ appName
1831
+ }) {
1832
+ const organisationService = useOrganisationService2();
1833
+ const selectedOrganisation = organisationService.getSelectedOrganisation();
1834
+ if (!user || !session) {
1835
+ return /* @__PURE__ */ jsx5(Fragment, { children });
1836
+ }
1837
+ return /* @__PURE__ */ jsx5(
1838
+ EventServiceProvider,
1839
+ {
1840
+ supabaseClient,
1841
+ user,
1842
+ session,
1843
+ appName,
1844
+ selectedOrganisation,
1845
+ setSelectedEventId: () => {
1846
+ },
1847
+ children
1848
+ }
1849
+ );
2300
1850
  }
2301
1851
  function ServiceAwareProviders({
2302
1852
  children,
2303
1853
  supabaseClient,
2304
1854
  appName,
1855
+ appConfig,
2305
1856
  persistState,
2306
1857
  enablePersistence,
2307
1858
  requireOrganisationContext,
2308
- enableRBAC,
2309
1859
  idleTimeoutMs,
2310
1860
  warnBeforeMs,
2311
1861
  onIdleLogout,
@@ -2313,55 +1863,43 @@ function ServiceAwareProviders({
2313
1863
  dangerouslyDisableInactivity
2314
1864
  }) {
2315
1865
  const authService = useAuthService2();
2316
- return /* @__PURE__ */ jsx6(
2317
- RBACServiceProvider,
1866
+ return /* @__PURE__ */ jsx5(
1867
+ OrganisationServiceProvider,
2318
1868
  {
2319
1869
  supabaseClient,
2320
1870
  user: authService.getUser(),
2321
1871
  session: authService.getSession(),
2322
- appName,
2323
- children: /* @__PURE__ */ jsx6(
2324
- OrganisationServiceProvider,
1872
+ children: /* @__PURE__ */ jsx5(
1873
+ EventServiceProviderWrapper,
2325
1874
  {
2326
1875
  supabaseClient,
2327
1876
  user: authService.getUser(),
2328
1877
  session: authService.getSession(),
2329
- children: /* @__PURE__ */ jsx6(
2330
- EventServiceProvider,
1878
+ appName,
1879
+ children: /* @__PURE__ */ jsx5(
1880
+ InactivityServiceProvider,
2331
1881
  {
2332
1882
  supabaseClient,
2333
1883
  user: authService.getUser(),
2334
1884
  session: authService.getSession(),
2335
- appName,
2336
- selectedOrganisation: null,
2337
- setSelectedEventId: (eventId) => {
2338
- },
2339
- children: /* @__PURE__ */ jsx6(
2340
- InactivityServiceProvider,
1885
+ idleTimeoutMs,
1886
+ warnBeforeMs,
1887
+ onIdleLogout,
1888
+ children: /* @__PURE__ */ jsx5(
1889
+ UnifiedAuthContextProvider,
2341
1890
  {
1891
+ appName,
1892
+ appConfig,
2342
1893
  supabaseClient,
2343
- user: authService.getUser(),
2344
- session: authService.getSession(),
1894
+ persistState,
1895
+ enablePersistence,
1896
+ requireOrganisationContext,
2345
1897
  idleTimeoutMs,
2346
1898
  warnBeforeMs,
2347
1899
  onIdleLogout,
2348
- children: /* @__PURE__ */ jsx6(
2349
- UnifiedAuthContextProvider,
2350
- {
2351
- appName,
2352
- supabaseClient,
2353
- persistState,
2354
- enablePersistence,
2355
- requireOrganisationContext,
2356
- enableRBAC,
2357
- idleTimeoutMs,
2358
- warnBeforeMs,
2359
- onIdleLogout,
2360
- renderInactivityWarning,
2361
- dangerouslyDisableInactivity,
2362
- children
2363
- }
2364
- )
1900
+ renderInactivityWarning,
1901
+ dangerouslyDisableInactivity,
1902
+ children
2365
1903
  }
2366
1904
  )
2367
1905
  }
@@ -2375,10 +1913,11 @@ function UnifiedAuthProvider({
2375
1913
  children,
2376
1914
  supabaseClient,
2377
1915
  appName,
1916
+ appConfig = { requires_event: true },
1917
+ // Default to requiring events
2378
1918
  persistState = true,
2379
1919
  enablePersistence,
2380
1920
  requireOrganisationContext = true,
2381
- enableRBAC = false,
2382
1921
  idleTimeoutMs = 30 * 60 * 1e3,
2383
1922
  // 30 minutes
2384
1923
  warnBeforeMs = 60 * 1e3,
@@ -2387,15 +1926,15 @@ function UnifiedAuthProvider({
2387
1926
  renderInactivityWarning,
2388
1927
  dangerouslyDisableInactivity = false
2389
1928
  }) {
2390
- return /* @__PURE__ */ jsx6(AuthServiceProvider, { supabaseClient, children: /* @__PURE__ */ jsx6(
1929
+ return /* @__PURE__ */ jsx5(AuthServiceProvider, { supabaseClient, children: /* @__PURE__ */ jsx5(
2391
1930
  ServiceAwareProviders,
2392
1931
  {
2393
1932
  supabaseClient,
2394
1933
  appName,
1934
+ appConfig,
2395
1935
  persistState,
2396
1936
  enablePersistence,
2397
1937
  requireOrganisationContext,
2398
- enableRBAC,
2399
1938
  idleTimeoutMs,
2400
1939
  warnBeforeMs,
2401
1940
  onIdleLogout,
@@ -2410,18 +1949,16 @@ var init_UnifiedAuthProvider = __esm({
2410
1949
  "src/providers/services/UnifiedAuthProvider.tsx"() {
2411
1950
  "use strict";
2412
1951
  init_AuthServiceProvider();
2413
- init_RBACServiceProvider();
2414
1952
  init_OrganisationServiceProvider();
2415
1953
  init_EventServiceProvider();
2416
1954
  init_InactivityServiceProvider();
2417
1955
  init_useAuthService();
2418
- init_useRBACService();
2419
1956
  init_useOrganisationService();
2420
1957
  init_useEventService();
2421
1958
  init_useInactivityService();
2422
- UnifiedAuthContext = createContext6(void 0);
1959
+ UnifiedAuthContext = createContext5(void 0);
2423
1960
  useUnifiedAuth = () => {
2424
- const context = useContext11(UnifiedAuthContext);
1961
+ const context = useContext9(UnifiedAuthContext);
2425
1962
  if (!context) {
2426
1963
  throw new Error("useUnifiedAuth must be used within a UnifiedAuthProvider");
2427
1964
  }
@@ -2435,10 +1972,6 @@ export {
2435
1972
  AuthServiceProvider,
2436
1973
  useAuthService,
2437
1974
  init_AuthServiceProvider,
2438
- RBACServiceContext,
2439
- RBACServiceProvider,
2440
- useRBACService,
2441
- init_RBACServiceProvider,
2442
1975
  OrganisationServiceContext,
2443
1976
  OrganisationServiceProvider,
2444
1977
  useOrganisationService,
@@ -2453,8 +1986,6 @@ export {
2453
1986
  init_InactivityServiceProvider,
2454
1987
  useAuthService2,
2455
1988
  init_useAuthService,
2456
- useRBACService2,
2457
- init_useRBACService,
2458
1989
  useOrganisationService2,
2459
1990
  init_useOrganisationService,
2460
1991
  useEventService2,
@@ -2465,4 +1996,4 @@ export {
2465
1996
  UnifiedAuthProvider,
2466
1997
  init_UnifiedAuthProvider
2467
1998
  };
2468
- //# sourceMappingURL=chunk-WN6XJWOS.js.map
1999
+ //# sourceMappingURL=chunk-MNJXXD6C.js.map