@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,109 +0,0 @@
1
- import {
2
- __esm
3
- } from "./chunk-PLDDJCW6.js";
4
-
5
- // src/types/file-reference.ts
6
- var FileCategory;
7
- var init_file_reference = __esm({
8
- "src/types/file-reference.ts"() {
9
- "use strict";
10
- FileCategory = /* @__PURE__ */ ((FileCategory2) => {
11
- FileCategory2["PROFILE_PHOTOS"] = "profile_photos";
12
- FileCategory2["ID_DOCUMENTS"] = "id_documents";
13
- FileCategory2["QUALIFICATIONS"] = "qualifications";
14
- FileCategory2["MEDICAL_DOCUMENTS"] = "medical_documents";
15
- FileCategory2["DISH_IMAGES"] = "dish_images";
16
- FileCategory2["EVENT_LOGOS"] = "event_logos";
17
- FileCategory2["GENERAL_DOCUMENTS"] = "general_documents";
18
- FileCategory2["IMAGES"] = "images";
19
- FileCategory2["AUDIO"] = "audio";
20
- FileCategory2["VIDEO"] = "video";
21
- FileCategory2["ARCHIVES"] = "archives";
22
- return FileCategory2;
23
- })(FileCategory || {});
24
- }
25
- });
26
-
27
- // src/types/unified.ts
28
- function createUserId(id) {
29
- return id;
30
- }
31
- function createSessionToken(token) {
32
- return token;
33
- }
34
- function createPermissionString(permission) {
35
- return permission;
36
- }
37
- function createRequestId(id) {
38
- return id;
39
- }
40
- function isUserId(value) {
41
- return typeof value === "string" && value.length > 0;
42
- }
43
- function isSessionToken(value) {
44
- return typeof value === "string" && value.length > 0;
45
- }
46
- function isPermissionString(value) {
47
- if (typeof value !== "string" || value.length === 0) return false;
48
- return value.includes(":") && value.split(":").length === 2;
49
- }
50
- function isRequestId(value) {
51
- return typeof value === "string" && value.length > 0;
52
- }
53
- var AuthErrorCode, PermissionErrorCode, AccessLevel;
54
- var init_unified = __esm({
55
- "src/types/unified.ts"() {
56
- "use strict";
57
- init_file_reference();
58
- AuthErrorCode = /* @__PURE__ */ ((AuthErrorCode2) => {
59
- AuthErrorCode2["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
60
- AuthErrorCode2["INVALID_CREDENTIALS"] = "INVALID_CREDENTIALS";
61
- AuthErrorCode2["USER_NOT_FOUND"] = "USER_NOT_FOUND";
62
- AuthErrorCode2["EMAIL_NOT_CONFIRMED"] = "EMAIL_NOT_CONFIRMED";
63
- AuthErrorCode2["PASSWORD_TOO_WEAK"] = "PASSWORD_TOO_WEAK";
64
- AuthErrorCode2["WEAK_PASSWORD"] = "WEAK_PASSWORD";
65
- AuthErrorCode2["RATE_LIMITED"] = "RATE_LIMITED";
66
- AuthErrorCode2["RATE_LIMIT_EXCEEDED"] = "RATE_LIMIT_EXCEEDED";
67
- AuthErrorCode2["SESSION_EXPIRED"] = "SESSION_EXPIRED";
68
- AuthErrorCode2["PERMISSION_DENIED"] = "PERMISSION_DENIED";
69
- AuthErrorCode2["NETWORK_ERROR"] = "NETWORK_ERROR";
70
- return AuthErrorCode2;
71
- })(AuthErrorCode || {});
72
- PermissionErrorCode = /* @__PURE__ */ ((PermissionErrorCode2) => {
73
- PermissionErrorCode2["INSUFFICIENT_PERMISSIONS"] = "INSUFFICIENT_PERMISSIONS";
74
- PermissionErrorCode2["INVALID_PERMISSION"] = "INVALID_PERMISSION";
75
- PermissionErrorCode2["PERMISSION_CHECK_FAILED"] = "PERMISSION_CHECK_FAILED";
76
- PermissionErrorCode2["ACCESS_DENIED"] = "ACCESS_DENIED";
77
- return PermissionErrorCode2;
78
- })(PermissionErrorCode || {});
79
- AccessLevel = /* @__PURE__ */ ((AccessLevel2) => {
80
- AccessLevel2["NONE"] = "none";
81
- AccessLevel2["VIEWER"] = "viewer";
82
- AccessLevel2["PARTICIPANT"] = "participant";
83
- AccessLevel2["EDITOR"] = "editor";
84
- AccessLevel2["PLANNER"] = "planner";
85
- AccessLevel2["ADMIN"] = "admin";
86
- AccessLevel2["SUPER_ADMIN"] = "super_admin";
87
- AccessLevel2["SUPER"] = "super";
88
- return AccessLevel2;
89
- })(AccessLevel || {});
90
- }
91
- });
92
-
93
- export {
94
- FileCategory,
95
- init_file_reference,
96
- AuthErrorCode,
97
- PermissionErrorCode,
98
- AccessLevel,
99
- createUserId,
100
- createSessionToken,
101
- createPermissionString,
102
- createRequestId,
103
- isUserId,
104
- isSessionToken,
105
- isPermissionString,
106
- isRequestId,
107
- init_unified
108
- };
109
- //# sourceMappingURL=chunk-ULBI5JGB.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/types/file-reference.ts","../src/types/unified.ts"],"sourcesContent":["// File Reference System Types\n// These types define the structure for the centralized file reference system\n\nexport interface FileReference {\n id: string;\n table_name: string;\n record_id: string;\n file_path: string;\n file_metadata: FileMetadata;\n organisation_id: string;\n app_id: string;\n is_public: boolean;\n created_at: string;\n updated_at: string;\n}\n\nexport interface FileMetadata {\n fileName: string;\n fileType: string;\n fileSize?: number;\n width?: number;\n height?: number;\n category: FileCategory;\n hash?: string;\n uploadedBy?: string;\n uploadedAt?: string;\n tags?: string[];\n customMetadata?: Record<string, any>;\n}\n\nexport enum FileCategory {\n PROFILE_PHOTOS = 'profile_photos',\n ID_DOCUMENTS = 'id_documents',\n QUALIFICATIONS = 'qualifications',\n MEDICAL_DOCUMENTS = 'medical_documents',\n DISH_IMAGES = 'dish_images',\n EVENT_LOGOS = 'event_logos',\n GENERAL_DOCUMENTS = 'general_documents',\n IMAGES = 'images',\n AUDIO = 'audio',\n VIDEO = 'video',\n ARCHIVES = 'archives'\n}\n\nexport interface FileUploadOptions {\n table_name: string;\n record_id: string;\n organisation_id: string;\n app_id: string;\n category: FileCategory;\n is_public?: boolean;\n custom_metadata?: Record<string, any>;\n}\n\nexport interface FileReferenceService {\n createFileReference(options: FileUploadOptions, file: File): Promise<FileReference>;\n getFileReference(table_name: string, record_id: string, organisation_id: string): Promise<FileReference | null>;\n getFileUrl(table_name: string, record_id: string, organisation_id: string): Promise<string | null>;\n getSignedUrl(table_name: string, record_id: string, organisation_id: string, expires_in?: number): Promise<string | null>;\n updateFileReference(id: string, updates: Partial<FileReference>): Promise<FileReference>;\n deleteFileReference(table_name: string, record_id: string, organisation_id: string, delete_file?: boolean): Promise<boolean>;\n listFileReferences(table_name: string, record_id: string, organisation_id: string): Promise<FileReference[]>;\n getFileCount(table_name: string, record_id: string, organisation_id: string): Promise<number>;\n}\n\nexport interface StorageUploadOptions {\n orgId: string;\n category: FileCategory;\n isPublic?: boolean;\n customPath?: string;\n}\n\nexport interface FileUploadResult {\n file_reference: FileReference;\n file_url: string;\n signed_url?: string;\n}\n","/**\n * @file Unified types for PACE Core\n * @package @jmruthers/pace-core\n * @module unified\n * @since 0.1.0\n */\n\n/**\n * @file Unified Types for DataTable\n * @package @jmruthers/pace-core\n * @module Types\n * @since 0.3.0\n */\n\n// Authentication Error Codes\nexport enum AuthErrorCode {\n UNKNOWN_ERROR = 'UNKNOWN_ERROR',\n INVALID_CREDENTIALS = 'INVALID_CREDENTIALS',\n USER_NOT_FOUND = 'USER_NOT_FOUND',\n EMAIL_NOT_CONFIRMED = 'EMAIL_NOT_CONFIRMED',\n PASSWORD_TOO_WEAK = 'PASSWORD_TOO_WEAK',\n WEAK_PASSWORD = 'WEAK_PASSWORD',\n RATE_LIMITED = 'RATE_LIMITED',\n RATE_LIMIT_EXCEEDED = 'RATE_LIMIT_EXCEEDED',\n SESSION_EXPIRED = 'SESSION_EXPIRED',\n PERMISSION_DENIED = 'PERMISSION_DENIED',\n NETWORK_ERROR = 'NETWORK_ERROR'\n}\n\n// Permission Error Codes\nexport enum PermissionErrorCode {\n INSUFFICIENT_PERMISSIONS = 'INSUFFICIENT_PERMISSIONS',\n INVALID_PERMISSION = 'INVALID_PERMISSION',\n PERMISSION_CHECK_FAILED = 'PERMISSION_CHECK_FAILED',\n ACCESS_DENIED = 'ACCESS_DENIED'\n}\n\n// Access Levels - using lowercase to match test expectations\nexport enum AccessLevel {\n NONE = 'none',\n VIEWER = 'viewer',\n PARTICIPANT = 'participant',\n EDITOR = 'editor',\n PLANNER = 'planner',\n ADMIN = 'admin',\n SUPER_ADMIN = 'super_admin',\n SUPER = 'super'\n}\n\n// Branded Types\nexport type UserId = string & { __brand: 'UserId' };\nexport type SessionToken = string & { __brand: 'SessionToken' };\nexport type PermissionString = string & { __brand: 'PermissionString' };\nexport type RequestId = string & { __brand: 'RequestId' };\n\n// Branded Type Creators\nexport function createUserId(id: string): UserId {\n return id as UserId;\n}\n\nexport function createSessionToken(token: string): SessionToken {\n return token as SessionToken;\n}\n\nexport function createPermissionString(permission: string): PermissionString {\n return permission as PermissionString;\n}\n\nexport function createRequestId(id: string): RequestId {\n return id as RequestId;\n}\n\n// Type Guards for branded types\nexport function isUserId(value: unknown): value is UserId {\n return typeof value === 'string' && value.length > 0;\n}\n\nexport function isSessionToken(value: unknown): value is SessionToken {\n return typeof value === 'string' && value.length > 0;\n}\n\nexport function isPermissionString(value: unknown): value is PermissionString {\n if (typeof value !== 'string' || value.length === 0) return false;\n // Basic validation for permission format (resource:action)\n return value.includes(':') && value.split(':').length === 2;\n}\n\nexport function isRequestId(value: unknown): value is RequestId {\n return typeof value === 'string' && value.length > 0;\n}\n\n// Permission Types\nexport type PermissionMap = Record<string, boolean>;\n\n// Permission Context\nexport interface PermissionContext {\n eventId?: string;\n appName?: string;\n userId?: string;\n}\n\n// Auth Error Interface - Define locally to avoid circular dependency\nexport interface AuthError extends Error {\n __isAuthError: true;\n name: 'AuthError';\n message: string;\n code: AuthErrorCode;\n user_message: string;\n timestamp: number;\n}\n\n// Permission Error Interface\nexport interface PermissionError extends Error {\n __isPermissionError: true;\n name: 'PermissionError';\n message: string;\n code: PermissionErrorCode;\n timestamp: number;\n}\n\n// Theme Types - Consolidated from theme.ts\nexport interface ThemeColors {\n primary: string;\n secondary: string;\n hover?: string;\n active?: string;\n bgSoft?: string;\n}\n\nexport interface EventTheme {\n mid: ThemeColors;\n light: ThemeColors;\n}\n\n// Event Types - Updated to match database schema exactly with organisation context\nexport interface Event {\n // Primary identification\n id: string;\n event_id: string;\n event_name: string;\n event_code?: string;\n \n // Organisation context - MANDATORY for security\n organisation_id: string;\n \n // Event details\n event_date?: string; // Use event_date from database for proper sorting\n event_days?: number;\n event_venue?: string;\n event_participants?: number;\n is_visible?: boolean;\n \n // Visual branding\n event_logo?: string; // DEPRECATED: Use file_references table instead\n event_colours?: Record<string, unknown> | null; // JSONB field for theme colors\n event_col_d1?: string;\n event_col_d2?: string;\n event_col_m1?: string;\n event_col_m2?: string;\n event_col_l1?: string;\n event_col_l2?: string;\n \n // Additional metadata\n event_news?: string;\n event_billing?: string;\n event_catering_email?: string;\n event_email?: string;\n event_footer?: string;\n event_rounddown?: number;\n event_youthmultiplier?: number;\n event_typicalunit?: number;\n \n // Timestamps\n created_at: string;\n updated_at: string;\n created_by?: string;\n updated_by?: string;\n \n // Legacy compatibility\n name?: string; // Alias for event_name\n description?: string;\n start_date?: string; // Alias for event_date\n end_date?: string;\n theme_colors?: EventTheme;\n}\n\n// Event Context Type\nexport interface EventContextType {\n selectedEvent: Event | null;\n currentEvent: Event | null; // Added missing property\n events: Event[];\n isLoading: boolean;\n error: string | null;\n selectEvent: (event: Event) => void;\n setCurrentEvent: (event: Event | null) => void; // Added missing property\n clearSelection: () => void;\n refreshEvents: () => Promise<void>;\n createEvent: (event: Partial<Event>) => Promise<Event>;\n updateEvent: (id: string, updates: Partial<Event>) => Promise<Event>;\n deleteEvent: (id: string) => Promise<void>;\n}\n\n// RBAC Types\nexport interface UserPermissions {\n user_id: UserId;\n accessLevel: AccessLevel;\n permissions: PermissionMap;\n roles: string[];\n}\n\n// Re-export standard Supabase types for consistency\n// Note: These are the same as what's in @supabase/supabase-js\nexport interface User {\n id: string;\n email?: string;\n created_at: string;\n updated_at: string;\n email_confirmed_at?: string;\n last_sign_in_at?: string;\n user_metadata?: Record<string, unknown>;\n app_metadata?: Record<string, unknown>;\n}\n\nexport interface Session {\n access_token: string;\n refresh_token?: string;\n expires_in: number;\n expires_at: number;\n token_type: string;\n user: User;\n provider_token?: string;\n provider_refresh_token?: string;\n}\n\nexport interface DataRecord {\n id: string | number;\n [key: string]: unknown;\n}\n\nexport interface DataTableAction<T = unknown> {\n label: string;\n onClick: (row: T) => void;\n testId?: string;\n disabled?: boolean | ((row: T) => boolean);\n variant?: 'primary' | 'secondary' | 'destructive';\n}\n\nexport interface DataTableColumn<T = unknown> {\n id?: string;\n key: string;\n label: string;\n sortable?: boolean;\n filterable?: boolean;\n accessorKey?: keyof T;\n accessorFn?: (row: T) => unknown;\n cell?: (value: unknown, row: T) => React.ReactNode;\n header?: React.ReactNode;\n enableSorting?: boolean;\n enableColumnFilter?: boolean;\n enableGrouping?: boolean;\n enableHiding?: boolean;\n}\n\n// Re-export file reference types\nexport * from './file-reference';\n"],"mappings":";;;;;AAAA,IA8BY;AA9BZ;AAAA;AAAA;AA8BO,IAAK,eAAL,kBAAKA,kBAAL;AACL,MAAAA,cAAA,oBAAiB;AACjB,MAAAA,cAAA,kBAAe;AACf,MAAAA,cAAA,oBAAiB;AACjB,MAAAA,cAAA,uBAAoB;AACpB,MAAAA,cAAA,iBAAc;AACd,MAAAA,cAAA,iBAAc;AACd,MAAAA,cAAA,uBAAoB;AACpB,MAAAA,cAAA,YAAS;AACT,MAAAA,cAAA,WAAQ;AACR,MAAAA,cAAA,WAAQ;AACR,MAAAA,cAAA,cAAW;AAXD,aAAAA;AAAA,OAAA;AAAA;AAAA;;;AC0BL,SAAS,aAAa,IAAoB;AAC/C,SAAO;AACT;AAEO,SAAS,mBAAmB,OAA6B;AAC9D,SAAO;AACT;AAEO,SAAS,uBAAuB,YAAsC;AAC3E,SAAO;AACT;AAEO,SAAS,gBAAgB,IAAuB;AACrD,SAAO;AACT;AAGO,SAAS,SAAS,OAAiC;AACxD,SAAO,OAAO,UAAU,YAAY,MAAM,SAAS;AACrD;AAEO,SAAS,eAAe,OAAuC;AACpE,SAAO,OAAO,UAAU,YAAY,MAAM,SAAS;AACrD;AAEO,SAAS,mBAAmB,OAA2C;AAC5E,MAAI,OAAO,UAAU,YAAY,MAAM,WAAW,EAAG,QAAO;AAE5D,SAAO,MAAM,SAAS,GAAG,KAAK,MAAM,MAAM,GAAG,EAAE,WAAW;AAC5D;AAEO,SAAS,YAAY,OAAoC;AAC9D,SAAO,OAAO,UAAU,YAAY,MAAM,SAAS;AACrD;AAzFA,IAeY,eAeA,qBAQA;AAtCZ;AAAA;AAAA;AAwQA;AAzPO,IAAK,gBAAL,kBAAKC,mBAAL;AACL,MAAAA,eAAA,mBAAgB;AAChB,MAAAA,eAAA,yBAAsB;AACtB,MAAAA,eAAA,oBAAiB;AACjB,MAAAA,eAAA,yBAAsB;AACtB,MAAAA,eAAA,uBAAoB;AACpB,MAAAA,eAAA,mBAAgB;AAChB,MAAAA,eAAA,kBAAe;AACf,MAAAA,eAAA,yBAAsB;AACtB,MAAAA,eAAA,qBAAkB;AAClB,MAAAA,eAAA,uBAAoB;AACpB,MAAAA,eAAA,mBAAgB;AAXN,aAAAA;AAAA,OAAA;AAeL,IAAK,sBAAL,kBAAKC,yBAAL;AACL,MAAAA,qBAAA,8BAA2B;AAC3B,MAAAA,qBAAA,wBAAqB;AACrB,MAAAA,qBAAA,6BAA0B;AAC1B,MAAAA,qBAAA,mBAAgB;AAJN,aAAAA;AAAA,OAAA;AAQL,IAAK,cAAL,kBAAKC,iBAAL;AACL,MAAAA,aAAA,UAAO;AACP,MAAAA,aAAA,YAAS;AACT,MAAAA,aAAA,iBAAc;AACd,MAAAA,aAAA,YAAS;AACT,MAAAA,aAAA,aAAU;AACV,MAAAA,aAAA,WAAQ;AACR,MAAAA,aAAA,iBAAc;AACd,MAAAA,aAAA,WAAQ;AARE,aAAAA;AAAA,OAAA;AAAA;AAAA;","names":["FileCategory","AuthErrorCode","PermissionErrorCode","AccessLevel"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/services/base/BaseService.ts","../src/services/AuthService.ts","../src/providers/services/AuthServiceProvider.tsx","../src/services/RBACService.ts","../src/providers/services/RBACServiceProvider.tsx","../src/services/OrganisationService.ts","../src/providers/services/OrganisationServiceProvider.tsx","../src/services/EventService.ts","../src/providers/services/EventServiceProvider.tsx","../src/services/InactivityService.ts","../src/providers/services/InactivityServiceProvider.tsx","../src/hooks/services/useAuthService.ts","../src/hooks/services/useRBACService.ts","../src/hooks/services/useOrganisationService.ts","../src/hooks/services/useEventService.ts","../src/hooks/services/useInactivityService.ts","../src/providers/services/UnifiedAuthProvider.tsx"],"sourcesContent":["/**\n * @file Base Service Class\n * @package @jmruthers/pace-core\n * @module Services/Base\n * @since 0.1.0\n *\n * Base service class implementing the observable pattern for React subscriptions.\n * All services extend this class to provide state change notifications.\n */\n\nexport type StateChangeCallback = () => void;\n\nexport abstract class BaseService {\n private subscribers: Array<StateChangeCallback> = [];\n private isInitialized = false;\n\n /**\n * Subscribe to state changes\n * @param callback Function to call when state changes\n * @returns Unsubscribe function\n */\n subscribe(callback: StateChangeCallback): () => void {\n this.subscribers.push(callback);\n \n // Return unsubscribe function that removes only the first occurrence\n return () => {\n const index = this.subscribers.indexOf(callback);\n if (index > -1) {\n this.subscribers.splice(index, 1);\n }\n };\n }\n\n /**\n * Notify all subscribers of state changes\n * This triggers React re-renders\n */\n protected notify(): void {\n this.subscribers.forEach(callback => {\n try {\n callback();\n } catch (error) {\n console.error('[BaseService] Error in subscriber callback:', error);\n }\n });\n }\n\n /**\n * Initialize the service\n * Override in subclasses to implement initialization logic\n */\n async initialize(): Promise<void> {\n if (this.isInitialized) {\n return;\n }\n \n await this.doInitialize();\n this.isInitialized = true;\n }\n\n /**\n * Cleanup the service\n * Override in subclasses to implement cleanup logic\n */\n cleanup(): void {\n this.subscribers = [];\n this.doCleanup();\n this.isInitialized = false;\n }\n\n /**\n * Check if service is initialized\n */\n protected getInitialized(): boolean {\n return this.isInitialized;\n }\n\n /**\n * Override in subclasses to implement initialization logic\n */\n protected abstract doInitialize(): Promise<void>;\n\n /**\n * Override in subclasses to implement cleanup logic\n */\n protected abstract doCleanup(): void;\n}","/**\n * @file Authentication Service\n * @package @jmruthers/pace-core\n * @module Services\n * @since 0.1.0\n *\n * Authentication service implementation.\n * Handles user authentication, session management, and auth-related operations.\n */\n\nimport { type SupabaseClient, type User, type Session, AuthError } from '@supabase/supabase-js';\nimport { BaseService } from './base/BaseService';\nimport { IAuthService, AuthResult } from './interfaces/IAuthService';\nimport { DebugLogger } from '../utils/debugLogger';\n\nexport class AuthService extends BaseService implements IAuthService {\n private user: User | null = null;\n private session: Session | null = null;\n private authLoading = true;\n private authError: AuthError | null = null;\n private supabaseClient: SupabaseClient | null = null;\n private authStateSubscription: any = null;\n\n constructor(supabaseClient: SupabaseClient) {\n super();\n this.supabaseClient = supabaseClient;\n }\n\n // Auth state getters\n getUser(): User | null {\n return this.user;\n }\n\n getSession(): Session | null {\n return this.session;\n }\n\n isAuthenticated(): boolean {\n return !!(this.user && this.session);\n }\n\n isLoading(): boolean {\n return this.authLoading;\n }\n\n getError(): AuthError | null {\n return this.authError;\n }\n\n getSupabaseClient(): SupabaseClient | null {\n return this.supabaseClient;\n }\n\n // Auth methods\n async signIn(email: string, password?: string): Promise<AuthResult> {\n if (!this.supabaseClient) {\n const error = new AuthError('Supabase client not available');\n this.authError = error;\n this.notify();\n return { user: null, session: null, error };\n }\n\n try {\n const { data, error } = await this.supabaseClient.auth.signInWithPassword({\n email,\n password: password || '',\n });\n \n if (error) {\n this.authError = error;\n this.user = null;\n this.session = null;\n } else {\n this.authError = null;\n this.user = data.user;\n this.session = data.session;\n }\n \n this.notify();\n return { user: data.user, session: data.session, error };\n } catch (error) {\n // Convert regular Error to AuthError if needed\n const authError = error instanceof AuthError \n ? error \n : new AuthError(error instanceof Error ? error.message : 'Authentication failed');\n this.authError = authError;\n this.user = null;\n this.session = null;\n this.notify();\n return { user: null, session: null, error: authError };\n }\n }\n\n async signUp(email: string, password: string): Promise<AuthResult> {\n if (!this.supabaseClient) {\n const error = new AuthError('Supabase client not available');\n this.authError = error;\n this.notify();\n return { user: null, session: null, error };\n }\n\n try {\n const { data, error } = await this.supabaseClient.auth.signUp({\n email,\n password,\n });\n \n if (error) {\n this.authError = error;\n this.user = null;\n this.session = null;\n } else {\n this.authError = null;\n this.user = data.user;\n this.session = data.session;\n }\n \n this.notify();\n return { user: data.user, session: data.session, error };\n } catch (error) {\n // Convert regular Error to AuthError if needed\n const authError = error instanceof AuthError \n ? error \n : new AuthError(error instanceof Error ? error.message : 'Authentication failed');\n this.authError = authError;\n this.user = null;\n this.session = null;\n this.notify();\n return { user: null, session: null, error: authError };\n }\n }\n\n async signOut(): Promise<AuthResult> {\n if (!this.supabaseClient) {\n const error = new AuthError('Supabase client not available');\n this.authError = error;\n this.notify();\n return { user: null, session: null, error };\n }\n\n try {\n const { error } = await this.supabaseClient.auth.signOut();\n \n if (error) {\n this.authError = error;\n } else {\n this.authError = null;\n this.user = null;\n this.session = null;\n }\n \n this.notify();\n return { user: null, session: null, error };\n } catch (error) {\n // Convert regular Error to AuthError if needed\n const authError = error instanceof AuthError \n ? error \n : new AuthError(error instanceof Error ? error.message : 'Authentication failed');\n this.authError = authError;\n this.user = null;\n this.session = null;\n this.notify();\n return { user: null, session: null, error: authError };\n }\n }\n\n async resetPassword(email: string): Promise<AuthResult> {\n if (!this.supabaseClient) {\n const error = new AuthError('Supabase client not available');\n this.authError = error;\n this.notify();\n return { user: null, session: null, error };\n }\n\n try {\n const { error } = await this.supabaseClient.auth.resetPasswordForEmail(email);\n \n if (error) {\n this.authError = error;\n } else {\n this.authError = null;\n }\n \n this.notify();\n return { user: null, session: null, error };\n } catch (error) {\n // Convert regular Error to AuthError if needed\n const authError = error instanceof AuthError \n ? error \n : new AuthError(error instanceof Error ? error.message : 'Authentication failed');\n this.authError = authError;\n this.notify();\n return { user: null, session: null, error: authError };\n }\n }\n\n async updatePassword(password: string): Promise<AuthResult> {\n if (!this.supabaseClient) {\n const error = new AuthError('Supabase client not available');\n this.authError = error;\n this.notify();\n return { user: null, session: null, error };\n }\n\n try {\n const { error } = await this.supabaseClient.auth.updateUser({\n password,\n });\n \n if (error) {\n this.authError = error;\n } else {\n this.authError = null;\n }\n \n this.notify();\n return { user: null, session: null, error };\n } catch (error) {\n const authError = error as AuthError;\n this.authError = authError;\n this.notify();\n return { user: null, session: null, error: authError };\n }\n }\n\n async refreshSession(): Promise<AuthResult> {\n if (!this.supabaseClient) {\n const error = new AuthError('Supabase client not available');\n this.authError = error;\n this.notify();\n return { user: null, session: null, error };\n }\n\n try {\n const { data, error } = await this.supabaseClient.auth.refreshSession();\n \n if (error) {\n this.authError = error;\n this.user = null;\n this.session = null;\n } else {\n this.authError = null;\n // Only update user and session if both are present (valid session)\n if (data?.user && data?.session) {\n this.user = data.user;\n this.session = data.session;\n } else {\n // If no valid session, clear everything\n this.user = null;\n this.session = null;\n }\n }\n \n this.notify();\n // Only return user if we have a valid session\n return { \n user: (data?.user && data?.session) ? data.user : null, \n session: data?.session ?? null, \n error \n };\n } catch (error) {\n // Convert regular Error to AuthError if needed\n const authError = error instanceof AuthError \n ? error \n : new AuthError(error instanceof Error ? error.message : 'Authentication failed');\n this.authError = authError;\n this.user = null;\n this.session = null;\n this.notify();\n return { user: null, session: null, error: authError };\n }\n }\n\n // Lifecycle methods\n async initialize(): Promise<void> {\n await super.initialize();\n await this.setupAuthStateListener();\n await this.restoreSession();\n }\n\n cleanup(): void {\n if (this.authStateSubscription && typeof this.authStateSubscription.unsubscribe === 'function') {\n this.authStateSubscription.unsubscribe();\n this.authStateSubscription = null;\n }\n super.cleanup();\n }\n\n protected async doInitialize(): Promise<void> {\n // Setup global error handlers\n this.setupErrorHandlers();\n }\n\n protected doCleanup(): void {\n // Remove global error handlers\n this.removeErrorHandlers();\n }\n\n private async setupAuthStateListener(): Promise<void> {\n if (!this.supabaseClient) {\n this.authLoading = false;\n this.notify();\n return;\n }\n\n try {\n this.authStateSubscription = this.supabaseClient.auth.onAuthStateChange(\n (event, session) => {\n try {\n DebugLogger.log('AuthService', 'Auth state changed:', event, session?.user?.email);\n \n // Handle different auth events\n if (event === 'SIGNED_OUT') {\n DebugLogger.log('AuthService', 'User signed out, clearing all state');\n this.session = null;\n this.user = null;\n this.authError = null;\n } else if (event === 'SIGNED_IN' || event === 'TOKEN_REFRESHED') {\n DebugLogger.log('AuthService', 'User signed in or token refreshed');\n this.session = session;\n this.user = session?.user ?? null;\n \n // Only clear auth error if we have a valid session\n if (session) {\n this.authError = null;\n }\n } else if (event === 'INITIAL_SESSION') {\n DebugLogger.log('AuthService', 'Initial session event');\n if (session) {\n this.session = session;\n this.user = session.user ?? null;\n this.authError = null;\n }\n }\n \n // Always set loading to false after any auth state change\n this.authLoading = false;\n this.notify();\n } catch (error) {\n console.warn('[AuthService] Error in auth state change handler:', error);\n this.authLoading = false;\n this.notify();\n }\n }\n );\n } catch (error) {\n console.error('[AuthService] Failed to setup auth state listener:', error);\n throw error; // Re-throw to propagate to the provider\n }\n }\n\n private async restoreSession(): Promise<void> {\n if (!this.supabaseClient) {\n this.authLoading = false;\n this.notify();\n return;\n }\n\n try {\n DebugLogger.log('AuthService', 'Initializing authentication...');\n \n // First, try to get the current session\n const { data: { session: currentSession }, error: sessionError } = await this.supabaseClient.auth.getSession();\n \n if (sessionError) {\n console.warn('[AuthService] Error getting current session:', sessionError);\n // Don't treat session errors as fatal - user might not be logged in\n }\n\n if (currentSession) {\n DebugLogger.log('AuthService', 'Session restored from storage:', currentSession.user?.email);\n this.session = currentSession;\n this.user = currentSession.user;\n this.authError = null;\n } else {\n DebugLogger.log('AuthService', 'No session found in storage');\n // Try to get user anyway (in case session is expired but user exists)\n const { data: { user: currentUser }, error: userError } = await this.supabaseClient.auth.getUser();\n \n if (userError) {\n DebugLogger.log('AuthService', 'No user found:', userError.message);\n } else if (currentUser) {\n DebugLogger.log('AuthService', 'User found without session:', currentUser.email);\n this.user = currentUser;\n // Don't set session if it's null - this prevents issues\n }\n }\n\n this.authLoading = false;\n this.notify();\n } catch (error) {\n console.error('[AuthService] Error during auth initialization:', error);\n this.authLoading = false;\n // Don't set auth error for initialization failures - user might not be logged in\n this.notify();\n }\n }\n\n private setupErrorHandlers(): void {\n if (typeof window === 'undefined') return;\n\n const handleError = (event: ErrorEvent) => {\n if (event.error?.message?.includes('AuthSessionMissingError') || \n event.error?.message?.includes('Auth session missing')) {\n console.warn('[AuthService] Suppressing AuthSessionMissingError during logout');\n event.preventDefault();\n return false;\n }\n };\n\n const handleUnhandledRejection = (event: PromiseRejectionEvent) => {\n if (event.reason?.message?.includes('AuthSessionMissingError') ||\n event.reason?.message?.includes('Auth session missing')) {\n console.warn('[AuthService] Suppressing unhandled AuthSessionMissingError');\n event.preventDefault();\n return false;\n }\n };\n\n window.addEventListener('error', handleError);\n window.addEventListener('unhandledrejection', handleUnhandledRejection);\n }\n\n private removeErrorHandlers(): void {\n if (typeof window === 'undefined') return;\n\n // Note: We can't remove specific handlers without storing references\n // In a real implementation, you'd store the handler references\n // For now, we'll rely on the service being cleaned up\n }\n}","/**\n * @file Auth Service Provider\n * @package @jmruthers/pace-core\n * @module Providers/Services\n * @since 0.1.0\n *\n * React provider for AuthService.\n * Provides authentication service instance to React components.\n */\n\nimport React, { createContext, useContext, useMemo, useEffect } from 'react';\nimport { type SupabaseClient } from '@supabase/supabase-js';\nimport { AuthService } from '../../services/AuthService';\n\n// Context type\nexport interface AuthServiceContextType {\n authService: AuthService;\n}\n\nexport const AuthServiceContext = createContext<AuthServiceContextType | null>(null);\n\nexport interface AuthServiceProviderProps {\n children: React.ReactNode;\n supabaseClient: SupabaseClient;\n}\n\nexport function AuthServiceProvider({ children, supabaseClient }: AuthServiceProviderProps) {\n // Create service instance with useMemo to prevent recreation on every render\n const authService = useMemo(\n () => new AuthService(supabaseClient),\n [supabaseClient]\n );\n\n // Initialize service on mount\n useEffect(() => {\n authService.initialize().catch(error => {\n console.error('[AuthServiceProvider] Failed to initialize auth service:', error);\n });\n\n // Cleanup on unmount\n return () => {\n authService.cleanup();\n };\n }, [authService]);\n\n const contextValue = useMemo(() => ({\n authService\n }), [authService]);\n\n return (\n <AuthServiceContext.Provider value={contextValue}>\n {children}\n </AuthServiceContext.Provider>\n );\n}\n\nexport const useAuthService = (): AuthService => {\n const context = useContext(AuthServiceContext);\n \n if (!context) {\n throw new Error('useAuthService must be used within AuthServiceProvider');\n }\n \n return context.authService;\n};","/**\n * @file RBAC Service\n * @package @jmruthers/pace-core\n * @module Services\n * @since 0.1.0\n *\n * RBAC service implementation.\n * Handles role-based access control, permissions, and event access management.\n */\n\nimport { type SupabaseClient, type User, type Session } from '@supabase/supabase-js';\nimport { BaseService } from './base/BaseService';\nimport { IRBACService, UserEventAccess, AppConfig } from './interfaces/IRBACService';\nimport { AccessLevel } from '../types/unified';\nimport { DebugLogger } from '../utils/debugLogger';\n\nexport class RBACService extends BaseService implements IRBACService {\n private permissions: Record<string, boolean> = {};\n private roles: string[] = [];\n private accessLevel: AccessLevel = AccessLevel.VIEWER;\n private rbacLoading = false;\n private rbacError: Error | null = null;\n private selectedEventId: string | null = null;\n private appConfig: AppConfig | null = null;\n private userEventAccess: UserEventAccess[] = [];\n private eventAccessLoading = false;\n private selectedOrganisationId: string | null = null;\n\n // Dependencies\n private supabaseClient: SupabaseClient | null = null;\n private user: User | null = null;\n private session: Session | null = null;\n private appName: string = '';\n\n constructor(supabaseClient: SupabaseClient, user: User | null, session: Session | null, appName: string) {\n super();\n this.supabaseClient = supabaseClient;\n this.user = user;\n this.session = session;\n this.appName = appName;\n }\n\n // Update dependencies\n updateDependencies(user: User | null, session: Session | null, appName: string): void {\n this.user = user;\n this.session = session;\n this.appName = appName;\n this.notify();\n }\n\n // RBAC state getters\n getPermissions(): Record<string, boolean> {\n return this.permissions;\n }\n\n getRoles(): string[] {\n return this.roles;\n }\n\n getAccessLevel(): AccessLevel {\n return this.accessLevel;\n }\n\n isLoading(): boolean {\n return this.rbacLoading;\n }\n\n getError(): Error | null {\n return this.rbacError;\n }\n\n getSelectedEventId(): string | null {\n return this.selectedEventId;\n }\n\n getAppConfig(): AppConfig | null {\n return this.appConfig;\n }\n\n getUserEventAccess(): UserEventAccess[] {\n return this.userEventAccess;\n }\n\n isEventAccessLoading(): boolean {\n return this.eventAccessLoading;\n }\n\n getSelectedOrganisationId(): string | null {\n return this.selectedOrganisationId;\n }\n\n // RBAC methods\n hasPermission(permission: string, orgId?: string): boolean {\n return !!this.permissions[permission];\n }\n\n hasAnyPermission(permissions: string[], orgId?: string): boolean {\n return permissions.some(p => !!this.permissions[p]);\n }\n\n hasAllPermissions(permissions: string[], orgId?: string): boolean {\n return permissions.every(p => !!this.permissions[p]);\n }\n\n hasRole(role: string): boolean {\n const isSuperAdmin = this.user?.user_metadata?.globalRole === 'super_admin';\n if (role.toLowerCase() === 'super_admin' || role.toLowerCase() === 'super') {\n return isSuperAdmin;\n }\n return this.roles.includes(role);\n }\n\n hasAccessLevel(level: AccessLevel): boolean {\n const levels = Object.values(AccessLevel);\n return levels.indexOf(this.accessLevel) >= levels.indexOf(level);\n }\n\n canAccess(resource: string, action: string, orgId?: string): boolean {\n const permission = `${resource}:${action}`;\n return this.hasPermission(permission, orgId);\n }\n\n async validatePermission(permission: string, orgId?: string): Promise<boolean> {\n return this.hasPermission(permission, orgId);\n }\n\n async validateAccess(resource: string, action: string, orgId?: string): Promise<boolean> {\n return this.canAccess(resource, action, orgId);\n }\n\n async refreshPermissions(eventId?: string, orgId?: string): Promise<void> {\n if (!this.supabaseClient || !this.user || !this.appConfig || !this.session) {\n DebugLogger.log('RBACService', 'refreshPermissions: Missing required dependencies, clearing permissions');\n this.permissions = {};\n this.roles = [];\n this.accessLevel = AccessLevel.VIEWER;\n this.notify();\n return;\n }\n\n // Check for super admin first - admin override should happen regardless of app configuration\n const isSuperAdmin = this.user?.user_metadata?.globalRole === 'super_admin';\n if (isSuperAdmin) {\n this.permissions = {\n 'admin:create': true,\n 'admin:read': true,\n 'admin:update': true,\n 'admin:delete': true,\n 'users:create': true,\n 'users:read': true,\n 'users:update': true,\n 'users:delete': true,\n 'events:create': true,\n 'events:read': true,\n 'events:update': true,\n 'events:delete': true\n };\n this.roles = ['super_admin'];\n this.accessLevel = AccessLevel.ADMIN;\n this.notify();\n return;\n }\n\n // Determine if we should load permissions without an event\n const shouldLoadDirectPermissions = !eventId && !this.appConfig.requires_event;\n const shouldLoadEventPermissions = eventId;\n const shouldClearPermissions = !eventId && this.appConfig.requires_event;\n\n // If no eventId and app requires events, clear permissions\n if (shouldClearPermissions) {\n this.permissions = {};\n this.roles = [];\n this.accessLevel = AccessLevel.VIEWER;\n this.notify();\n return;\n }\n\n // Only proceed if we should load permissions\n if (!shouldLoadDirectPermissions && !shouldLoadEventPermissions) {\n return;\n }\n\n this.rbacLoading = true;\n this.rbacError = null;\n this.notify();\n\n try {\n // Use the same app name resolution as PagePermissionGuard\n const { getCurrentAppName } = await import('../utils/appNameResolver');\n const resolvedAppName = getCurrentAppName() || this.appName;\n \n // First resolve app name to app_id\n const { data: appData, error: appError } = await this.supabaseClient\n .from('rbac_apps')\n .select('id')\n .eq('name', resolvedAppName)\n .eq('is_active', true)\n .single();\n\n if (appError || !appData) {\n console.warn('App not found or inactive:', resolvedAppName);\n this.rbacLoading = false;\n this.notify();\n return;\n }\n\n const { data, error } = await this.supabaseClient.rpc('rbac_permissions_get', {\n p_user_id: this.user.id,\n p_app_id: appData.id,\n p_event_id: eventId || null,\n p_organisation_id: orgId || this.selectedOrganisationId || null\n });\n\n if (error) {\n throw error;\n }\n\n const { permissions, roles, access_level } = this.transformRBACPermissions(data, this.appName);\n\n this.permissions = permissions;\n this.roles = roles;\n this.accessLevel = access_level;\n } catch (err: any) {\n this.rbacError = err;\n } finally {\n this.rbacLoading = false;\n this.notify();\n }\n }\n\n setSelectedEventId(eventId: string | null): void {\n this.selectedEventId = eventId;\n this.notify();\n }\n\n async loadUserEventAccess(orgId?: string): Promise<void> {\n if (!this.supabaseClient || !this.user || !this.session) {\n DebugLogger.log('RBACService', 'loadUserEventAccess: Missing required dependencies, clearing event access');\n this.userEventAccess = [];\n this.notify();\n return;\n }\n\n this.eventAccessLoading = true;\n this.notify();\n\n try {\n // Use the same app name resolution as PagePermissionGuard\n const { getCurrentAppName } = await import('../utils/appNameResolver');\n const resolvedAppName = getCurrentAppName() || this.appName;\n \n // First resolve app name to app_id\n const { data: appData, error: appError } = await this.supabaseClient\n .from('rbac_apps')\n .select('id')\n .eq('name', resolvedAppName)\n .eq('is_active', true)\n .single();\n\n if (appError || !appData) {\n console.warn('App not found or inactive:', resolvedAppName);\n this.eventAccessLoading = false;\n this.notify();\n return;\n }\n\n const { data, error } = await this.supabaseClient\n .from('rbac_event_app_roles')\n .select(`\n event_id,\n role,\n granted_at\n `)\n .eq('user_id', this.user.id)\n .eq('app_id', appData.id);\n\n if (error) {\n console.error('Failed to load user event access:', error);\n this.userEventAccess = [];\n this.notify();\n return;\n }\n\n const eventAccess = data?.map(item => ({\n event_id: item.event_id,\n event_name: (item as any).event_name || 'Unknown Event', // Event details not available in this query\n event_description: (item as any).event_description || null, // Not available in this schema\n start_date: (item as any).start_date || '', // Event date not available in this query\n end_date: (item as any).end_date || '', // Event date not available in this query\n event_status: (item as any).event_status || 'unknown', // Not available in this schema\n app_id: (item as any).app_id || appData.id,\n access_level: (item as any).access_level || item.role, // Map role to access_level\n granted_at: item.granted_at,\n organisation_id: (item as any).organisation_id || '' // Will be populated from event's organisation_id if needed\n })) || [];\n\n this.userEventAccess = eventAccess;\n } catch (error) {\n console.error('Error loading user event access:', error);\n this.userEventAccess = [];\n } finally {\n this.eventAccessLoading = false;\n this.notify();\n }\n }\n\n getUserEventAccessById(eventId: string): UserEventAccess | undefined {\n return this.userEventAccess.find(access => access.event_id === eventId);\n }\n\n requireOrganisationContext(): string {\n if (!this.selectedOrganisationId) {\n throw new Error('Organisation context is required but not available');\n }\n return this.selectedOrganisationId;\n }\n\n // Lifecycle methods\n async initialize(): Promise<void> {\n await super.initialize();\n await this.loadAppConfig();\n \n // Load permissions for regular users after app config is loaded\n const isSuperAdmin = this.user?.user_metadata?.globalRole === 'super_admin';\n if (!isSuperAdmin && this.appConfig) {\n await this.refreshPermissions(this.selectedEventId || undefined);\n }\n \n await this.loadPersistedState();\n }\n\n cleanup(): void {\n super.cleanup();\n }\n\n protected async doInitialize(): Promise<void> {\n // Set super admin roles and permissions based on user metadata\n const isSuperAdmin = this.user?.user_metadata?.globalRole === 'super_admin';\n if (isSuperAdmin) {\n this.roles = ['super_admin'];\n this.accessLevel = AccessLevel.ADMIN;\n // Set super admin permissions immediately\n this.permissions = {\n 'admin:create': true,\n 'admin:read': true,\n 'admin:update': true,\n 'admin:delete': true,\n 'users:create': true,\n 'users:read': true,\n 'users:update': true,\n 'users:delete': true,\n 'events:create': true,\n 'events:read': true,\n 'events:update': true,\n 'events:delete': true\n };\n } else {\n this.roles = [];\n this.accessLevel = AccessLevel.VIEWER;\n this.permissions = {};\n }\n }\n\n protected doCleanup(): void {\n // No specific cleanup needed\n }\n\n private async loadAppConfig(): Promise<void> {\n if (!this.supabaseClient) return;\n\n try {\n // Use the same app name resolution as PagePermissionGuard\n const { getCurrentAppName } = await import('../utils/appNameResolver');\n const resolvedAppName = getCurrentAppName() || this.appName;\n \n // First resolve app name to app_id\n const { data: appData, error: appError } = await this.supabaseClient\n .from('rbac_apps')\n .select('id')\n .eq('name', resolvedAppName)\n .eq('is_active', true)\n .single();\n\n if (appError || !appData) {\n console.warn('App not found or inactive:', resolvedAppName);\n this.appConfig = {\n supports_direct_access: false,\n requires_event: true\n };\n return;\n }\n\n const response = await this.supabaseClient.rpc('get_app_config', {\n app_id: appData.id\n });\n \n const { data } = response || {};\n\n if (data && data.length > 0) {\n this.appConfig = {\n supports_direct_access: false,\n requires_event: data[0].requires_event\n };\n } else {\n // Default configuration if app not found\n this.appConfig = {\n supports_direct_access: false,\n requires_event: true\n };\n }\n } catch (error) {\n console.warn('Failed to load app configuration:', error);\n // Default configuration on error\n this.appConfig = {\n supports_direct_access: false,\n requires_event: true\n };\n }\n }\n\n private async loadPersistedState(): Promise<void> {\n try {\n const persistedEvent = localStorage.getItem('pace-core-selected-event');\n if (persistedEvent) {\n this.selectedEventId = JSON.parse(persistedEvent);\n }\n } catch (error) {\n console.warn(\"Clearing corrupted localStorage data\");\n localStorage.removeItem('pace-core-selected-event');\n }\n }\n\n private transformRBACPermissions(rbacData: any[], appName: string) {\n const permissions: Record<string, boolean> = {};\n let roles: string[] = [];\n let access_level: AccessLevel = AccessLevel.VIEWER;\n\n if (!rbacData || !Array.isArray(rbacData)) {\n return { permissions: {}, roles: ['viewer'], access_level: AccessLevel.VIEWER };\n }\n\n // Check for super admin first\n const superAdminPerm = rbacData.find((p: any) => p.permission_type === 'all_permissions');\n if (superAdminPerm) {\n return { \n permissions: { 'all:all': true } as Record<string, boolean>, \n roles: ['super'], \n access_level: AccessLevel.SUPER \n };\n }\n\n // Process event-app permissions\n const eventAppPerms = rbacData.filter((p: any) => p.permission_type === 'event_app_access');\n if (eventAppPerms.length > 0) {\n const role = eventAppPerms[0].role_name;\n \n // Map RBAC roles to AccessLevel\n switch (role) {\n case 'event_admin':\n access_level = AccessLevel.ADMIN;\n roles = ['admin'];\n break;\n case 'planner':\n access_level = AccessLevel.PLANNER;\n roles = ['planner'];\n break;\n case 'participant':\n access_level = AccessLevel.PARTICIPANT;\n roles = ['participant'];\n break;\n case 'editor':\n access_level = AccessLevel.EDITOR;\n roles = ['editor'];\n break;\n case 'viewer':\n default:\n access_level = AccessLevel.VIEWER;\n roles = ['viewer'];\n break;\n }\n\n // Set permissions from the RPC response\n eventAppPerms.forEach((perm: any) => {\n if (perm.permission) {\n permissions[perm.permission] = true;\n }\n });\n\n // For now, we'll set basic permissions based on role\n // In a full implementation, you'd want to fetch page-specific permissions\n const basePermissions = ['read'];\n if (['event_admin', 'planner'].includes(role)) {\n basePermissions.push('create', 'update');\n }\n if (role === 'event_admin') {\n basePermissions.push('delete');\n }\n\n // Set permissions for all pages (simplified approach)\n // In a real implementation, you'd want to get actual page permissions\n basePermissions.forEach(operation => {\n permissions[`default:${operation}`] = true;\n });\n }\n\n // Process organisation permissions\n const orgPerms = rbacData.filter((p: any) => p.permission_type === 'organisation_access');\n if (orgPerms.length > 0) {\n const role = orgPerms[0].role_name;\n if (role === 'org_admin') {\n access_level = AccessLevel.ADMIN;\n roles = ['admin'];\n // Org admins get all permissions\n ['create', 'read', 'update', 'delete'].forEach(operation => {\n permissions[`default:${operation}`] = true;\n });\n }\n }\n\n return { permissions, roles, access_level };\n }\n}","/**\n * @file RBAC Service Provider\n * @package @jmruthers/pace-core\n * @module Providers/Services\n * @since 0.1.0\n *\n * React provider for RBACService.\n * Provides RBAC service instance to React components.\n */\n\nimport React, { createContext, useContext, useMemo, useEffect } from 'react';\nimport { type SupabaseClient, type User, type Session } from '@supabase/supabase-js';\nimport { RBACService } from '../../services/RBACService';\n\n// Context type\nexport interface RBACServiceContextType {\n rbacService: RBACService;\n}\n\nexport const RBACServiceContext = createContext<RBACServiceContextType | null>(null);\n\nexport interface RBACServiceProviderProps {\n children: React.ReactNode;\n supabaseClient: SupabaseClient;\n user: User | null;\n session: Session | null;\n appName: string;\n}\n\nexport function RBACServiceProvider({ \n children, \n supabaseClient, \n user, \n session, \n appName \n}: RBACServiceProviderProps) {\n // Create service instance with useMemo to prevent recreation on every render\n const rbacService = useMemo(\n () => new RBACService(supabaseClient, user, session, appName),\n [supabaseClient, user, session, appName]\n );\n\n // Update service dependencies when they change\n useEffect(() => {\n rbacService.updateDependencies(user, session, appName);\n }, [rbacService, user, session, appName]);\n\n // Initialize service on mount\n useEffect(() => {\n rbacService.initialize().catch(error => {\n console.error('[RBACServiceProvider] Failed to initialize RBAC service:', error);\n });\n\n // Cleanup on unmount\n return () => {\n rbacService.cleanup();\n };\n }, [rbacService]);\n\n const contextValue = useMemo(() => ({\n rbacService\n }), [rbacService]);\n\n return (\n <RBACServiceContext.Provider value={contextValue}>\n {children}\n </RBACServiceContext.Provider>\n );\n}\n\nexport const useRBACService = (): RBACService => {\n const context = useContext(RBACServiceContext);\n \n if (!context) {\n throw new Error('useRBACService must be used within RBACServiceProvider');\n }\n \n return context.rbacService;\n};","/**\n * @file Organisation Service\n * @package @jmruthers/pace-core\n * @module Services\n * @since 0.1.0\n *\n * Organisation service implementation.\n * Handles organisation management and selection with security-first approach.\n */\n\nimport { type SupabaseClient, type User, type Session } from '@supabase/supabase-js';\nimport { BaseService } from './base/BaseService';\nimport { IOrganisationService } from './interfaces/IOrganisationService';\nimport type {\n Organisation,\n OrganisationMembership,\n OrganisationSecurityError,\n OrganisationHierarchy\n} from '../types/organisation';\nimport { setOrganisationContext } from '../utils/organisationContext';\nimport { DebugLogger } from '../utils/debugLogger';\n\nexport class OrganisationService extends BaseService implements IOrganisationService {\n private _selectedOrganisation: Organisation | null = null;\n private _organisations: Organisation[] = [];\n private _userMemberships: OrganisationMembership[] = [];\n private _roleMapState: Map<string, string> = new Map();\n private _isLoading = true;\n private _error: Error | null = null;\n private _isContextReady = false;\n private retryCount = 0;\n\n // Dependencies\n private supabaseClient: SupabaseClient | null = null;\n private user: User | null = null;\n private session: Session | null = null;\n\n // Internal state management\n private isLoadingRef = false;\n private lastLoadTimeRef = 0;\n private hasFailedRef = false;\n private abortControllerRef: AbortController | null = null;\n\n constructor(supabaseClient: SupabaseClient, user: User | null, session: Session | null) {\n super();\n this.supabaseClient = supabaseClient;\n this.user = user;\n this.session = session;\n }\n\n // Interface implementation\n getSelectedOrganisation(): Organisation | null { return this._selectedOrganisation; }\n getOrganisations(): Organisation[] { return this._organisations; }\n getUserMemberships(): OrganisationMembership[] { return this._userMemberships; }\n isLoading(): boolean { return this._isLoading; }\n getError(): Error | null { return this._error; }\n hasValidOrganisationContext(): boolean { return !!(this._selectedOrganisation && !this._isLoading && !this._error && this._isContextReady); }\n isContextReady(): boolean { return this._isContextReady; }\n\n // Additional methods for testing\n setSelectedOrganisation(organisation: Organisation | null): void {\n this._selectedOrganisation = organisation;\n if (organisation) {\n localStorage.setItem('pace-core-selected-organisation', JSON.stringify(organisation));\n this.setDatabaseOrganisationContext(organisation);\n } else {\n localStorage.removeItem('pace-core-selected-organisation');\n this._isContextReady = false;\n }\n this.notify();\n }\n\n // For testing: expose dependencies\n getDependencies(): { user: User | null; session: Session | null; supabaseClient: SupabaseClient | null } {\n return {\n user: this.user,\n session: this.session,\n supabaseClient: this.supabaseClient\n };\n }\n\n // For testing: manually set state\n setTestState(\n organisations: Organisation[],\n memberships: OrganisationMembership[],\n roleMap: Map<string, string>,\n selectedOrg: Organisation | null = null\n ): void {\n this._organisations = organisations;\n this._userMemberships = memberships;\n this._roleMapState = roleMap;\n if (selectedOrg) {\n this._selectedOrganisation = selectedOrg;\n } else if (organisations.length > 0) {\n this._selectedOrganisation = organisations[0];\n }\n this._isLoading = false;\n this._error = null;\n this.notify();\n }\n\n // Update dependencies\n updateDependencies(user: User | null, session: Session | null): void {\n this.user = user;\n this.session = session;\n this.notify();\n }\n\n // Organisation methods\n async switchOrganisation(orgId: string): Promise<void> {\n DebugLogger.log(\"OrganisationService\", \"Switching to organisation:\", orgId);\n \n // Validate access\n if (!this.validateOrganisationAccess(orgId)) {\n throw new Error(`User does not have access to organisation ${orgId}`) as OrganisationSecurityError;\n }\n \n const targetOrg = this._organisations.find(org => org.id === orgId);\n if (!targetOrg) {\n throw new Error(`Organisation ${orgId} not found in user's organisations`) as OrganisationSecurityError;\n }\n \n this._selectedOrganisation = targetOrg;\n \n // Persist selection\n localStorage.setItem('pace-core-selected-organisation', JSON.stringify(targetOrg));\n \n // Set database organisation context\n await this.setDatabaseOrganisationContext(targetOrg);\n \n DebugLogger.log(\"OrganisationService\", \"Switched to organisation:\", targetOrg.display_name);\n this.notify();\n }\n\n getUserRole(orgId?: string): string {\n const targetOrgId = orgId || this._selectedOrganisation?.id;\n if (!targetOrgId) return 'no_access';\n \n // Use roleMapState to get the role for this organisation\n return this._roleMapState.get(targetOrgId) || 'no_access';\n }\n\n validateOrganisationAccess(orgId: string): boolean {\n return this._userMemberships.some((m: any) => \n m.organisation_id === orgId && \n m.status === 'active' &&\n m.revoked_at === null\n );\n }\n\n async refreshOrganisations(): Promise<void> {\n if (!this.user || !this.session || !this.supabaseClient) return;\n \n // Force reload by triggering the effect\n this._isLoading = true;\n this.notify();\n await this.loadUserOrganisations();\n }\n\n ensureOrganisationContext(): Organisation {\n if (!this._selectedOrganisation) {\n throw new Error('Organisation context is required but not available') as OrganisationSecurityError;\n }\n return this._selectedOrganisation;\n }\n\n isOrganisationSecure(): boolean {\n return !!(this._selectedOrganisation && this.user);\n }\n\n getPrimaryOrganisation(): Organisation | null {\n // Look for org_admin role first, then leader, then member\n const rolePriority = ['org_admin', 'leader', 'member'];\n \n for (const role of rolePriority) {\n const membership = this._userMemberships.find((m: any) => m.role === role);\n if (membership) {\n return this._organisations.find((org: any) => org.id === membership.organisation_id) || null;\n }\n }\n \n return null;\n }\n\n buildOrganisationHierarchy(orgs: Organisation[]): OrganisationHierarchy[] {\n const orgMap = new Map<string, Organisation>();\n orgs.forEach(org => orgMap.set(org.id, org));\n \n const roots: OrganisationHierarchy[] = [];\n \n orgs.forEach(org => {\n if (!org.parent_id) {\n // Root organisation\n roots.push({\n organisation: org,\n children: [],\n depth: 0\n });\n }\n });\n \n // For now, return flat structure - hierarchy building can be added later\n return roots;\n }\n\n // Lifecycle methods\n async initialize(): Promise<void> {\n await super.initialize();\n await this.loadUserOrganisations();\n }\n\n cleanup(): void {\n // Cleanup on unmount\n this.isLoadingRef = false;\n this.hasFailedRef = false;\n this.lastLoadTimeRef = 0;\n // Abort any pending requests\n if (this.abortControllerRef) {\n this.abortControllerRef.abort();\n this.abortControllerRef = null;\n }\n // Reset state\n this._selectedOrganisation = null;\n this._organisations = [];\n this._userMemberships = [];\n this._roleMapState = new Map();\n this._isLoading = false;\n this._error = null;\n this._isContextReady = false;\n super.cleanup();\n }\n\n protected async doInitialize(): Promise<void> {\n // Initial setup\n }\n\n protected doCleanup(): void {\n // Cleanup any resources\n }\n\n private async setDatabaseOrganisationContext(organisation: Organisation): Promise<void> {\n if (!this.supabaseClient || !this.session) {\n console.warn('[OrganisationService] No Supabase client or session available for setting organisation context');\n this._isContextReady = false;\n this.notify();\n return;\n }\n\n try {\n await setOrganisationContext(this.supabaseClient, organisation.id);\n DebugLogger.log('OrganisationService', 'Database organisation context set to:', organisation.display_name);\n this._isContextReady = true;\n this.notify();\n } catch (error) {\n console.error('[OrganisationService] Failed to set database organisation context:', error);\n this._isContextReady = false;\n this.notify();\n // Don't throw - this is a non-critical operation\n }\n }\n\n private async loadUserOrganisations(): Promise<void> {\n // Add call tracking to detect race conditions\n const callId = Math.random().toString(36).substr(2, 9);\n console.log(`[OrganisationService] Starting loadUserOrganisations call ${callId}`);\n \n if (!this.user || !this.session || !this.supabaseClient) {\n // Clear state when no user, session, or supabase client\n DebugLogger.log('OrganisationService', 'Clearing organisation state - no user, session, or supabase client');\n this._selectedOrganisation = null;\n this._organisations = [];\n this._userMemberships = [];\n this._isLoading = false;\n this._error = null;\n this.notify();\n return;\n }\n\n // Additional check to prevent loading during auth state changes\n if (this.isLoadingRef) {\n console.log(\"OrganisationService\", \"Already loading, skipping duplicate load\");\n return;\n }\n\n // Prevent rapid retries - minimum 2 seconds between attempts\n const now = Date.now();\n if (now - this.lastLoadTimeRef < 2000) {\n console.log(\"OrganisationService\", \"Too soon since last load, skipping\");\n return;\n }\n\n // Cancel any existing request\n if (this.abortControllerRef) {\n this.abortControllerRef.abort();\n }\n\n // Create new abort controller for this request\n this.abortControllerRef = new AbortController();\n const abortSignal = this.abortControllerRef.signal;\n\n this.lastLoadTimeRef = now;\n this.isLoadingRef = true;\n this._isLoading = true;\n this._error = null;\n this.notify();\n \n try {\n DebugLogger.log(\"OrganisationService\", \"Loading organisations for user:\", this.user.id);\n \n // Debug: Log Supabase client configuration\n console.log(\"[OrganisationService] Supabase client ready:\", {\n isConnected: !!this.supabaseClient,\n hasAuth: !!this.supabaseClient.auth,\n hasRpc: !!this.supabaseClient.rpc\n });\n \n // Get user's organisation memberships using secure RPC function\n // Only get actual members (org_admin, leader, member) - exclude supporters\n let memberships, membershipError;\n try {\n console.log(\"[OrganisationService] Making RPC call to data_user_organisation_roles_get...\");\n \n // Add timeout and abort signal to prevent hanging RPC calls\n const timeoutPromise = new Promise((_, reject) => {\n const timeoutId = setTimeout(() => reject(new Error('RPC call timeout after 10 seconds')), 10000);\n abortSignal.addEventListener('abort', () => {\n clearTimeout(timeoutId);\n reject(new Error('Request aborted'));\n });\n });\n \n const rpcPromise = this.supabaseClient.rpc('data_user_organisation_roles_get', {\n p_user_id: this.user.id,\n p_organisation_id: null\n });\n \n // Check if request was aborted before making the call\n if (abortSignal.aborted) {\n throw new Error('Request aborted');\n }\n \n const result = await Promise.race([rpcPromise, timeoutPromise]) as any;\n \n console.log(\"[OrganisationService] RPC call completed:\", {\n hasData: !!result.data,\n hasError: !!result.error,\n dataLength: result.data?.length || 0,\n errorMessage: result.error?.message || 'No error'\n });\n \n // Filter to only actual members (org_admin, leader, member) - exclude supporters\n memberships = result.data?.filter((role: any) => \n ['org_admin', 'leader', 'member'].includes(role.role)\n ) || [];\n membershipError = result.error;\n } catch (queryError: any) {\n membershipError = queryError;\n }\n\n if (membershipError) {\n console.error(\"[OrganisationService] Error loading memberships:\", membershipError);\n \n // If RPC fails with timeout, try direct database query as fallback\n if (membershipError.message?.includes('timeout')) {\n console.log(\"[OrganisationService] RPC timed out, trying direct database query as fallback...\");\n try {\n // Check if request was aborted before making fallback query\n if (abortSignal.aborted) {\n throw new Error('Request aborted');\n }\n\n const { data: fallbackData, error: fallbackError } = await this.supabaseClient\n .from('rbac_organisation_roles')\n .select(`\n id,\n user_id,\n organisation_id,\n role,\n status,\n granted_at,\n granted_by,\n revoked_at,\n revoked_by,\n notes,\n created_at,\n updated_at,\n organisations!inner(\n id,\n name,\n display_name,\n subscription_tier,\n settings,\n is_active,\n parent_id,\n created_at,\n updated_at\n )\n `)\n .eq('user_id', this.user.id)\n .eq('status', 'active')\n .is('revoked_at', null)\n .in('role', ['org_admin', 'leader', 'member']);\n \n if (fallbackError) {\n console.error(\"[OrganisationService] Fallback query also failed:\", fallbackError);\n throw membershipError; // Throw original error\n }\n \n console.log(\"[OrganisationService] Fallback query successful, got\", fallbackData?.length || 0, \"memberships\");\n memberships = fallbackData || [];\n membershipError = null;\n } catch (fallbackErr) {\n console.error(\"[OrganisationService] Fallback query failed:\", fallbackErr);\n throw membershipError; // Throw original error\n }\n } else {\n throw membershipError;\n }\n }\n \n DebugLogger.log(\"OrganisationService\", \"Raw memberships data:\", memberships);\n \n if (!memberships || memberships.length === 0) {\n throw new Error('User has no active organisation memberships') as OrganisationSecurityError;\n }\n\n // Get organisation details for the memberships\n const organisationIds = memberships\n .map((m: any) => m.organisation_id)\n .filter((id: string) => {\n // Better validation to prevent empty string UUID errors\n if (!id || typeof id !== 'string') {\n console.warn(\"[OrganisationService] Invalid organisation ID (not string):\", id);\n return false;\n }\n const trimmedId = id.trim();\n if (trimmedId === '') {\n console.warn(\"[OrganisationService] Empty organisation ID found\");\n return false;\n }\n // Validate UUID format\n const isValidUuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(trimmedId);\n if (!isValidUuid) {\n console.warn(\"[OrganisationService] Invalid UUID format:\", trimmedId);\n }\n return isValidUuid;\n });\n \n if (organisationIds.length === 0) {\n console.warn(\"[OrganisationService] No valid organisation IDs found in memberships:\", memberships);\n throw new Error('No valid organisation IDs found in memberships') as OrganisationSecurityError;\n }\n \n DebugLogger.log(\"OrganisationService\", \"Valid organisation IDs:\", organisationIds);\n \n // Check if request was aborted before making organisations query\n if (abortSignal.aborted) {\n throw new Error('Request aborted');\n }\n \n const { data: allOrganisations, error: orgError } = await this.supabaseClient\n .from('organisations')\n .select('id, name, display_name, subscription_tier, settings, is_active, parent_id, created_at, updated_at');\n \n if (orgError) {\n console.error(\"[OrganisationService] Error loading organisations:\", orgError);\n throw orgError;\n }\n \n // Filter manually on the client side\n const organisations = allOrganisations?.filter(org => \n organisationIds.includes(org.id)\n ) || [];\n\n // Create a map of organisation_id to role from the memberships data\n const roleMap = new Map<string, string>();\n memberships?.forEach((membership: any) => {\n roleMap.set(membership.organisation_id, membership.role);\n });\n\n // Extract organisations and memberships\n const orgs = organisations as Organisation[];\n const activeOrgs = orgs.filter(org => org.is_active);\n \n if (activeOrgs.length === 0) {\n throw new Error('User has no access to active organisations') as OrganisationSecurityError;\n }\n\n DebugLogger.log(\"OrganisationService\", \"Active organisations:\", activeOrgs);\n \n this._organisations = activeOrgs;\n this._userMemberships = memberships as OrganisationMembership[];\n \n // Store role map in component state for later use\n this._roleMapState = roleMap;\n \n // Auto-select organisation: try persisted, then primary, then first\n let initialOrg: Organisation | null = null;\n \n // 1. Try to restore from localStorage\n try {\n const persistedOrgString = localStorage.getItem('pace-core-selected-organisation');\n if (persistedOrgString) {\n const persistedOrg = JSON.parse(persistedOrgString) as Organisation;\n // Validate persisted org ID before using it\n if (persistedOrg.id && typeof persistedOrg.id === 'string' && persistedOrg.id.trim() !== '') {\n const validPersistedOrg = activeOrgs.find(org => org.id === persistedOrg.id);\n if (validPersistedOrg) {\n initialOrg = validPersistedOrg;\n DebugLogger.log(\"OrganisationService\", \"Restored persisted organisation:\", initialOrg.display_name);\n } else {\n console.warn(\"[OrganisationService] Persisted organisation not found in active orgs, clearing cache\");\n localStorage.removeItem('pace-core-selected-organisation');\n }\n } else {\n console.warn(\"[OrganisationService] Invalid persisted organisation ID, clearing cache\");\n localStorage.removeItem('pace-core-selected-organisation');\n }\n }\n } catch (storageError) {\n console.warn(\"[OrganisationService] Failed to restore persisted organisation:\", storageError);\n // Clear potentially corrupted cache\n localStorage.removeItem('pace-core-selected-organisation');\n }\n \n // 2. Fall back to org_admin role organisation (highest privilege)\n if (!initialOrg) {\n const adminMembership = memberships.find((m: any) => m.role === 'org_admin');\n if (adminMembership) {\n const foundOrg = organisations.find((org: any) => org.id === adminMembership.organisation_id);\n if (foundOrg) {\n initialOrg = foundOrg;\n DebugLogger.log(\"OrganisationService\", \"Selected org_admin organisation:\", initialOrg.display_name);\n }\n }\n }\n \n // 3. Fall back to first organisation\n if (!initialOrg) {\n initialOrg = activeOrgs[0];\n DebugLogger.log(\"OrganisationService\", \"Selected first organisation:\", initialOrg.display_name);\n }\n \n if (!initialOrg) {\n throw new Error('No valid organisation found for user') as OrganisationSecurityError;\n }\n\n this._selectedOrganisation = initialOrg;\n \n // Persist selection\n localStorage.setItem('pace-core-selected-organisation', JSON.stringify(initialOrg));\n \n DebugLogger.log(\"OrganisationService\", \"Organisation context established:\", {\n selectedOrganisation: initialOrg.display_name,\n totalOrganisations: activeOrgs.length,\n userRole: roleMap.get(initialOrg.id)\n });\n \n // Reset retry count and failed flag on success\n this.retryCount = 0;\n this.hasFailedRef = false;\n \n } catch (err) {\n console.error(\"[OrganisationService] Failed to load organisations:\", err);\n this._error = err as Error;\n // Increment retry count on error\n this.retryCount = this.retryCount + 1;\n // Set failed flag to prevent further attempts\n this.hasFailedRef = true;\n // Clear all cached data on error to prevent corruption\n this.clearAllCachedData();\n } finally {\n // Always cleanup refs and abort controller\n this.isLoadingRef = false;\n this._isLoading = false;\n this.abortControllerRef = null;\n this.notify();\n }\n }\n\n private clearAllCachedData(): void {\n localStorage.removeItem('pace-core-selected-organisation');\n localStorage.removeItem('pace-core-organisation-context');\n this._selectedOrganisation = null;\n this._organisations = [];\n this._userMemberships = [];\n this._roleMapState = new Map();\n this.retryCount = 0;\n this._isContextReady = false;\n // Don't clear _error here - let it persist for error reporting\n }\n}","/**\n * @file Organisation Service Provider\n * @package @jmruthers/pace-core\n * @module Providers/Services\n * @since 0.1.0\n *\n * React provider for OrganisationService.\n * Provides organisation service instance to React components.\n */\n\nimport React, { createContext, useContext, useMemo, useEffect } from 'react';\nimport { type SupabaseClient, type User, type Session } from '@supabase/supabase-js';\nimport { OrganisationService } from '../../services/OrganisationService';\n\n// Context type\nexport interface OrganisationServiceContextType {\n organisationService: OrganisationService;\n}\n\nexport const OrganisationServiceContext = createContext<OrganisationServiceContextType | null>(null);\n\nexport interface OrganisationServiceProviderProps {\n children: React.ReactNode;\n supabaseClient: SupabaseClient;\n user: User | null;\n session: Session | null;\n}\n\nexport function OrganisationServiceProvider({ \n children, \n supabaseClient, \n user, \n session \n}: OrganisationServiceProviderProps) {\n // Create service instance with useMemo to prevent recreation on every render\n const organisationService = useMemo(\n () => new OrganisationService(supabaseClient, user, session),\n [supabaseClient, user, session]\n );\n\n // Update service dependencies when they change\n useEffect(() => {\n organisationService.updateDependencies(user, session);\n }, [organisationService, user, session]);\n\n // Initialize service on mount\n useEffect(() => {\n organisationService.initialize().catch(error => {\n console.error('[OrganisationServiceProvider] Failed to initialize organisation service:', error);\n });\n\n // Cleanup on unmount\n return () => {\n organisationService.cleanup();\n };\n }, [organisationService]);\n\n const contextValue = useMemo(() => ({\n organisationService\n }), [organisationService]);\n\n return (\n <OrganisationServiceContext.Provider value={contextValue}>\n {children}\n </OrganisationServiceContext.Provider>\n );\n}\n\nexport const useOrganisationService = (): OrganisationService => {\n const context = useContext(OrganisationServiceContext);\n \n if (!context) {\n throw new Error('useOrganisationService must be used within OrganisationServiceProvider');\n }\n \n return context.organisationService;\n};","/**\n * @file Event Service\n * @package @jmruthers/pace-core\n * @module Services\n * @since 0.1.0\n *\n * Event service implementation.\n * Handles event management and selection with organisation context validation.\n */\n\nimport { BaseService } from './base/BaseService';\nimport { IEventService } from './interfaces/IEventService';\nimport { Event } from '../types/unified';\nimport { DebugLogger } from '../utils/debugLogger';\n\nexport class EventService extends BaseService implements IEventService {\n private events: Event[] = [];\n private selectedEvent: Event | null = null;\n private _isLoading = true;\n private error: Error | null = null;\n\n // Dependencies\n private supabaseClient: any = null;\n private user: any = null;\n private session: any = null;\n private appName: string = '';\n private selectedOrganisation: any = null;\n private setSelectedEventId: ((eventId: string | null) => void) | null = null;\n\n // Internal state management\n private isInitializedRef = false;\n private isFetchingRef = false;\n private hasAutoSelectedRef = false;\n private userClearedEventRef = false;\n\n constructor(\n supabaseClient: any,\n user: any,\n session: any,\n appName: string,\n selectedOrganisation: any,\n setSelectedEventId: (eventId: string | null) => void\n ) {\n super();\n this.supabaseClient = supabaseClient;\n this.user = user;\n this.session = session;\n this.appName = appName;\n this.selectedOrganisation = selectedOrganisation;\n this.setSelectedEventId = setSelectedEventId;\n }\n\n // Update dependencies\n updateDependencies(\n supabaseClient: any,\n user: any,\n session: any,\n appName: string,\n selectedOrganisation: any,\n setSelectedEventId: (eventId: string | null) => void\n ): void {\n this.supabaseClient = supabaseClient;\n this.user = user;\n this.session = session;\n this.appName = appName;\n this.selectedOrganisation = selectedOrganisation;\n this.setSelectedEventId = setSelectedEventId;\n this.notify();\n }\n\n // Event state getters\n getEvents(): Event[] {\n return this.events;\n }\n\n getSelectedEvent(): Event | null {\n return this.selectedEvent;\n }\n\n isLoading(): boolean {\n return this._isLoading;\n }\n\n getError(): Error | null {\n return this.error;\n }\n\n // Event methods\n setSelectedEvent(event: Event | null): void {\n if (event) {\n // SECURITY: Validate event belongs to current organisation\n try {\n console.log('[EventService] Event selection validation:', {\n eventId: event.event_id,\n eventName: event.event_name,\n eventOrganisationId: event.organisation_id,\n selectedOrganisationId: this.selectedOrganisation?.id,\n selectedOrganisationName: this.selectedOrganisation?.display_name,\n match: event.organisation_id === this.selectedOrganisation?.id\n });\n \n if (this.selectedOrganisation && event.organisation_id !== this.selectedOrganisation.id) {\n console.error('[EventService] Event organisation_id does not match selected organisation', {\n eventOrganisationId: event.organisation_id,\n selectedOrganisationId: this.selectedOrganisation.id,\n eventName: event.event_name\n });\n return;\n }\n } catch (error) {\n console.error('[EventService] Error during event validation:', error);\n }\n\n this.selectedEvent = event;\n this.setSelectedEventId?.(event.event_id);\n this.persistEventSelection(event.event_id);\n // Reset the user cleared flag when selecting an event\n this.userClearedEventRef = false;\n } else {\n this.selectedEvent = null;\n this.setSelectedEventId?.(null);\n // Clear both sessionStorage and localStorage\n sessionStorage.removeItem('pace-core-selected-event');\n localStorage.removeItem('pace-core-selected-event');\n // Reset the auto-selection flag when clearing the event\n this.hasAutoSelectedRef = false;\n // Mark that user explicitly cleared the event to prevent auto-selection\n this.userClearedEventRef = true;\n }\n this.notify();\n }\n\n async refreshEvents(): Promise<void> {\n this.isInitializedRef = false;\n this.isFetchingRef = false;\n // Don't reset the user cleared flag - respect user's choice\n await this.fetchEvents();\n }\n\n async loadPersistedEvent(events: Event[]): Promise<boolean> {\n try {\n // Try sessionStorage first (tab-specific)\n let persistedEventId = sessionStorage.getItem('pace-core-selected-event');\n \n // Fallback to localStorage if no sessionStorage value (for new tabs)\n if (!persistedEventId) {\n persistedEventId = localStorage.getItem('pace-core-selected-event');\n // If we found a value in localStorage, also store it in sessionStorage for this tab\n if (persistedEventId) {\n sessionStorage.setItem('pace-core-selected-event', persistedEventId);\n }\n }\n \n if (persistedEventId && events.length > 0) {\n const persistedEvent = events.find(event => event.event_id === persistedEventId);\n if (persistedEvent) {\n DebugLogger.log('EventService', 'Restoring persisted event:', persistedEvent.event_name);\n this.selectedEvent = persistedEvent;\n this.setSelectedEventId?.(persistedEventId);\n return true;\n } else {\n DebugLogger.log('EventService', 'Persisted event not found in current events, clearing storage');\n // Clear invalid persisted event\n sessionStorage.removeItem('pace-core-selected-event');\n localStorage.removeItem('pace-core-selected-event');\n }\n }\n } catch (error) {\n console.warn('[EventService] Failed to load persisted event:', error);\n }\n return false;\n }\n\n persistEventSelection(eventId: string): void {\n try {\n // Store in sessionStorage for tab-specific persistence\n sessionStorage.setItem('pace-core-selected-event', eventId);\n // Also store in localStorage as fallback for new tabs\n localStorage.setItem('pace-core-selected-event', eventId);\n } catch (error) {\n console.warn('[EventService] Failed to persist event selection:', error);\n }\n }\n\n clearEventSelection(): void {\n try {\n // Clear from both storage locations\n sessionStorage.removeItem('pace-core-selected-event');\n localStorage.removeItem('pace-core-selected-event');\n // Clear the selected event\n this.selectedEvent = null;\n this.setSelectedEventId?.(null);\n } catch (error) {\n console.warn('[EventService] Failed to clear event selection:', error);\n }\n }\n\n autoSelectNextEvent(events: Event[]): void {\n const nextEvent = this.getNextEventByDate(events);\n if (nextEvent) {\n DebugLogger.log('EventService', 'Auto-selecting next event:', nextEvent.event_name);\n this.selectedEvent = nextEvent;\n this.setSelectedEventId?.(nextEvent.event_id);\n this.persistEventSelection(nextEvent.event_id);\n }\n }\n\n // Lifecycle methods\n async initialize(): Promise<void> {\n await super.initialize();\n await this.fetchEvents();\n }\n\n cleanup(): void {\n super.cleanup();\n }\n\n protected async doInitialize(): Promise<void> {\n // Initial setup - fetch events on initialization\n await this.fetchEvents();\n }\n\n protected doCleanup(): void {\n // Cleanup any resources\n }\n\n private async fetchEvents(): Promise<void> {\n if (!this.user || !this.session || !this.supabaseClient || !this.appName || !this.selectedOrganisation) {\n DebugLogger.log('EventService', 'Missing required dependencies, skipping fetch');\n this._isLoading = false;\n this.notify();\n return;\n }\n\n // Prevent multiple simultaneous fetches\n if (this.isFetchingRef) {\n DebugLogger.log('EventService', 'Already fetching events, skipping');\n return;\n }\n\n DebugLogger.log('EventService', 'User and organisation found, fetching events for:', {\n userId: this.user.id,\n appName: this.appName,\n organisationId: this.selectedOrganisation.id,\n organisationName: this.selectedOrganisation.display_name\n });\n\n this.isFetchingRef = true;\n let isMounted = true;\n\n try {\n // Call the RPC function following the established pattern\n DebugLogger.log('EventService', 'Calling data_user_events_get RPC with:', {\n user_id: this.user.id,\n organisation_id: this.selectedOrganisation.id,\n app_name: this.appName\n });\n\n const { data, error: rpcError } = await this.supabaseClient.rpc('data_user_events_get', {\n p_user_id: this.user.id,\n p_organisation_id: this.selectedOrganisation.id,\n p_app_name: this.appName\n });\n\n DebugLogger.log('EventService', 'RPC response:', {\n data,\n error: rpcError,\n dataLength: data?.length || 0,\n organisationId: this.selectedOrganisation.id\n });\n\n if (rpcError) {\n throw new Error(rpcError.message || 'Failed to fetch events');\n }\n\n if (isMounted) {\n const eventsData = data || [];\n console.log('[EventService] Loaded events:', eventsData.map((event: any) => ({\n eventId: event.event_id,\n eventName: event.event_name,\n organisationId: event.organisation_id,\n selectedOrganisationId: this.selectedOrganisation?.id\n })));\n\n // Transform the data to match our Event interface\n const transformedEvents: Event[] = eventsData.map((event: any) => ({\n id: event.event_id, // Use event_id as the primary id\n event_id: event.event_id,\n event_name: event.event_name,\n event_date: event.event_date,\n event_venue: event.event_venue,\n event_participants: event.event_participants,\n event_colours: event.event_colours,\n event_logo: '', // No logo field in event table\n organisation_id: event.organisation_id,\n is_visible: event.is_visible,\n // Legacy compatibility\n name: event.event_name,\n start_date: event.event_date\n }));\n\n this.events = transformedEvents;\n this.error = null;\n\n // Reset auto-selection ref for new events\n this.hasAutoSelectedRef = false;\n\n // Try to restore persisted event first\n const persistedEventLoaded = await this.loadPersistedEvent(transformedEvents);\n \n // If no persisted event was loaded and user hasn't explicitly cleared an event, auto-select the next event\n if (!persistedEventLoaded && !this.userClearedEventRef) {\n const nextEvent = this.getNextEventByDate(transformedEvents);\n if (nextEvent) {\n DebugLogger.log('EventService', 'Auto-selecting next event after no persisted event found:', nextEvent.event_name);\n this.hasAutoSelectedRef = true;\n this.selectedEvent = nextEvent;\n this.setSelectedEventId?.(nextEvent.event_id);\n this.persistEventSelection(nextEvent.event_id);\n }\n }\n }\n } catch (err) {\n console.error('[EventService] Error fetching events:', err);\n const _error = err instanceof Error ? err : new Error('Unknown error occurred');\n \n if (isMounted) {\n this.error = _error;\n this.events = [];\n }\n } finally {\n if (isMounted) {\n this._isLoading = false;\n }\n this.isFetchingRef = false;\n this.notify();\n }\n }\n\n getNextEventByDate(events?: Event[]): Event | null {\n const eventsToUse = events || this.events;\n if (!eventsToUse || eventsToUse.length === 0) {\n return null;\n }\n\n const now = new Date();\n const futureEvents = eventsToUse.filter(event => {\n if (!event.event_date) return false;\n const eventDate = new Date(event.event_date);\n return eventDate >= now;\n });\n\n if (futureEvents.length === 0) {\n return null;\n }\n\n // Sort by date (ascending) to get the next event\n const sortedFutureEvents = futureEvents.sort((a, b) => {\n const dateA = new Date(a.event_date!);\n const dateB = new Date(b.event_date!);\n return dateA.getTime() - dateB.getTime();\n });\n\n return sortedFutureEvents[0];\n }\n}","/**\n * @file Event Service Provider\n * @package @jmruthers/pace-core\n * @module Providers/Services\n * @since 0.1.0\n *\n * React provider for EventService.\n * Provides event service instance to React components.\n */\n\nimport React, { createContext, useContext, useMemo, useEffect } from 'react';\nimport { type SupabaseClient, type User, type Session } from '@supabase/supabase-js';\nimport { EventService } from '../../services/EventService';\n\n// Context type\nexport interface EventServiceContextType {\n eventService: EventService;\n}\n\n// Backward compatibility type alias\nexport type EventContextType = EventServiceContextType;\n\nexport const EventServiceContext = createContext<EventServiceContextType | null>(null);\n\nexport interface EventServiceProviderProps {\n children: React.ReactNode;\n supabaseClient: SupabaseClient;\n user: User | null;\n session: Session | null;\n appName: string;\n selectedOrganisation: any;\n setSelectedEventId: (eventId: string | null) => void;\n}\n\nexport function EventServiceProvider({ \n children, \n supabaseClient, \n user, \n session, \n appName,\n selectedOrganisation,\n setSelectedEventId\n}: EventServiceProviderProps) {\n // Create service instance with useMemo to prevent recreation on every render\n const eventService = useMemo(\n () => new EventService(supabaseClient, user, session, appName, selectedOrganisation, setSelectedEventId),\n [supabaseClient, user, session, appName, selectedOrganisation, setSelectedEventId]\n );\n\n // Update service dependencies when they change\n useEffect(() => {\n eventService.updateDependencies(supabaseClient, user, session, appName, selectedOrganisation, setSelectedEventId);\n }, [eventService, supabaseClient, user, session, appName, selectedOrganisation, setSelectedEventId]);\n\n // Initialize service on mount\n useEffect(() => {\n eventService.initialize().catch(error => {\n console.error('[EventServiceProvider] Failed to initialize event service:', error);\n });\n\n // Cleanup on unmount\n return () => {\n eventService.cleanup();\n };\n }, [eventService]);\n\n const contextValue = useMemo(() => ({\n eventService\n }), [eventService]);\n\n return (\n <EventServiceContext.Provider value={contextValue}>\n {children}\n </EventServiceContext.Provider>\n );\n}\n\nexport const useEventService = (): EventService => {\n const context = useContext(EventServiceContext);\n \n if (!context) {\n throw new Error('useEventService must be used within EventServiceProvider');\n }\n \n return context.eventService;\n};","/**\n * @file Inactivity Service\n * @package @jmruthers/pace-core\n * @module Services\n * @since 0.1.0\n *\n * Inactivity service implementation.\n * Handles inactivity tracking, auto-logout, and warning modals.\n */\n\nimport { BaseService } from './base/BaseService';\nimport { IInactivityService } from './interfaces/IInactivityService';\n\nexport class InactivityService extends BaseService implements IInactivityService {\n private _showInactivityWarning = false;\n private _inactivityTimeRemaining = 0;\n private _isIdle = false;\n private _timeRemaining = 0;\n private _showWarning = false;\n private _isTracking = false;\n\n // Dependencies\n private supabaseClient: any = null;\n private user: any = null;\n private session: any = null;\n private idleTimeoutMs = 30 * 60 * 1000; // 30 minutes\n private warnBeforeMs = 60 * 1000; // 60 seconds\n private onIdleLogout: ((reason: 'inactivity') => void) | null = null;\n\n // Internal state management\n private inactivityTracker: any = null;\n private isInactivityEnabled = true;\n\n constructor(\n supabaseClient: any,\n user: any,\n session: any,\n idleTimeoutMs: number = 30 * 60 * 1000,\n warnBeforeMs: number = 60 * 1000,\n onIdleLogout: (reason: 'inactivity') => void\n ) {\n super();\n this.supabaseClient = supabaseClient;\n this.user = user;\n this.session = session;\n this.idleTimeoutMs = idleTimeoutMs;\n this.warnBeforeMs = warnBeforeMs;\n this.onIdleLogout = onIdleLogout;\n \n // Initialize time remaining to idle timeout\n this._timeRemaining = idleTimeoutMs;\n }\n\n // Interface implementation\n isIdle(): boolean { return this._isIdle; }\n getTimeRemaining(): number { return this._timeRemaining; }\n isWarningShown(): boolean { return this._showWarning; }\n isTracking(): boolean { return this._isTracking; }\n getShowInactivityWarning(): boolean { return this._showInactivityWarning; }\n getInactivityTimeRemaining(): number { return this._inactivityTimeRemaining; }\n\n // Additional getter methods that tests expect\n getIsIdle(): boolean { return this._isIdle; }\n getIsTracking(): boolean { return this._isTracking; }\n getShowWarning(): boolean { return this._showWarning; }\n\n // Additional methods for testing\n setShowInactivityWarning(value: boolean): void {\n this._showInactivityWarning = value;\n this.notify();\n }\n\n setInactivityTimeRemaining(value: number): void {\n this._inactivityTimeRemaining = value;\n this.notify();\n }\n\n setIsIdle(value: boolean): void {\n this._isIdle = value;\n this.notify();\n }\n\n setTimeRemaining(value: number): void {\n this._timeRemaining = value;\n this.notify();\n }\n\n setShowWarning(value: boolean): void {\n this._showWarning = value;\n this.notify();\n }\n\n setIsTracking(value: boolean): void {\n this._isTracking = value;\n this.notify();\n }\n\n triggerWarning(timeRemaining: number): void {\n this._showInactivityWarning = true;\n this._inactivityTimeRemaining = Math.ceil(timeRemaining / 1000);\n this._showWarning = true;\n this.notify();\n }\n\n triggerIdle(): void {\n this._isIdle = true;\n this.handleIdleLogout();\n this.notify();\n }\n\n // Update dependencies\n updateDependencies(\n supabaseClient: any,\n user: any,\n session: any,\n idleTimeoutMs?: number,\n warnBeforeMs?: number,\n onIdleLogout?: (reason: 'inactivity') => void\n ): void {\n this.supabaseClient = supabaseClient;\n this.user = user;\n this.session = session;\n if (idleTimeoutMs !== undefined) this.idleTimeoutMs = idleTimeoutMs;\n if (warnBeforeMs !== undefined) this.warnBeforeMs = warnBeforeMs;\n if (onIdleLogout !== undefined) this.onIdleLogout = onIdleLogout;\n this.notify();\n }\n\n // Inactivity methods\n resetActivity(): void {\n if (this.inactivityTracker) {\n this.inactivityTracker.resetActivity();\n }\n this._isIdle = false;\n this._showWarning = false;\n this._showInactivityWarning = false;\n this._inactivityTimeRemaining = 0;\n this._timeRemaining = this.idleTimeoutMs;\n this.notify();\n }\n\n startTracking(): void {\n if (this.inactivityTracker) {\n this.inactivityTracker.startTracking();\n }\n this._isTracking = true;\n this.notify();\n }\n\n stopTracking(): void {\n if (this.inactivityTracker) {\n this.inactivityTracker.stopTracking();\n }\n this._isTracking = false;\n this.notify();\n }\n\n async handleIdleLogout(): Promise<void> {\n // Hide warning\n this._showInactivityWarning = false;\n this._inactivityTimeRemaining = 0;\n \n // Stop tracking\n this.stopTracking();\n \n // Sign out via Supabase\n try {\n if (this.supabaseClient) {\n await this.supabaseClient.auth.signOut();\n }\n } catch (error: any) {\n console.error('[InactivityService] Error during idle logout:', error);\n }\n \n // Call app callback for navigation/redirect\n this.onIdleLogout?.('inactivity');\n this.notify();\n }\n\n handleStaySignedIn(): void {\n this._showInactivityWarning = false;\n this._inactivityTimeRemaining = 0;\n this.resetActivity();\n this.notify();\n }\n\n async handleSignOutNow(): Promise<void> {\n this._showInactivityWarning = false;\n this._inactivityTimeRemaining = 0;\n this.stopTracking();\n \n // Sign out via Supabase\n try {\n if (this.supabaseClient) {\n await this.supabaseClient.auth.signOut();\n }\n } catch (error: any) {\n console.error('[InactivityService] Error during manual sign out:', error);\n }\n \n // Call app callback for navigation/redirect\n this.onIdleLogout?.('inactivity');\n this.notify();\n }\n\n // Lifecycle methods\n async initialize(): Promise<void> {\n await super.initialize();\n await this.setupInactivityTracker();\n }\n\n cleanup(): void {\n if (this.inactivityTracker) {\n this.inactivityTracker.cleanup?.();\n this.inactivityTracker = null;\n }\n this._isTracking = false;\n this._isIdle = false;\n this._showWarning = false;\n this._showInactivityWarning = false;\n this._timeRemaining = 0;\n this._inactivityTimeRemaining = 0;\n super.cleanup();\n }\n\n protected async doInitialize(): Promise<void> {\n // Production safety check for inactivity feature\n if (typeof window !== 'undefined') {\n const isProduction = import.meta.env.MODE === 'production';\n \n if (isProduction) {\n console.warn('[InactivityService] Inactivity feature enabled in production');\n }\n }\n }\n\n protected doCleanup(): void {\n // Cleanup any resources\n }\n\n private async setupInactivityTracker(): Promise<void> {\n if (typeof window === 'undefined') return;\n\n // Check if inactivity is enabled\n this.isInactivityEnabled = this.user && this.session;\n\n if (!this.isInactivityEnabled) {\n return;\n }\n\n try {\n // Dynamically import the inactivity tracker hook\n const { useInactivityTracker } = await import('../hooks/useInactivityTracker');\n \n // Create a mock implementation since we can't use hooks in services\n // In a real implementation, you'd need to create a non-hook version\n this.inactivityTracker = {\n isIdle: false,\n timeRemaining: 0,\n showWarning: false,\n isTracking: false,\n resetActivity: () => {\n this._isIdle = false;\n this._timeRemaining = 0;\n this._showWarning = false;\n this.notify();\n },\n startTracking: () => {\n this._isTracking = true;\n this.notify();\n },\n stopTracking: () => {\n this._isTracking = false;\n this.notify();\n },\n cleanup: () => {\n this._isTracking = false;\n this._isIdle = false;\n this._showWarning = false;\n this._timeRemaining = 0;\n }\n };\n\n // Set up event handlers\n this.setupEventHandlers();\n } catch (error) {\n console.error('[InactivityService] Failed to setup inactivity tracker:', error);\n }\n }\n\n private setupEventHandlers(): void {\n if (typeof window === 'undefined') return;\n\n let idleTimer: NodeJS.Timeout | null = null;\n let warningTimer: NodeJS.Timeout | null = null;\n let lastActivity = Date.now();\n\n const resetTimers = () => {\n lastActivity = Date.now();\n \n if (idleTimer) {\n clearTimeout(idleTimer);\n idleTimer = null;\n }\n \n if (warningTimer) {\n clearTimeout(warningTimer);\n warningTimer = null;\n }\n\n this._showInactivityWarning = false;\n this._inactivityTimeRemaining = 0;\n this._isIdle = false;\n this._showWarning = false;\n this.notify();\n };\n\n const startIdleTimer = () => {\n if (idleTimer) {\n clearTimeout(idleTimer);\n }\n\n idleTimer = setTimeout(() => {\n this._isIdle = true;\n this._showWarning = true;\n this.notify();\n \n // Start warning timer\n warningTimer = setTimeout(() => {\n this.handleIdleLogout();\n }, this.warnBeforeMs);\n }, this.idleTimeoutMs - this.warnBeforeMs);\n };\n\n const startWarningTimer = () => {\n if (warningTimer) {\n clearTimeout(warningTimer);\n }\n\n warningTimer = setTimeout(() => {\n this.handleIdleLogout();\n }, this.warnBeforeMs);\n };\n\n // Activity detection\n const activityEvents = ['mousedown', 'mousemove', 'keypress', 'scroll', 'touchstart', 'click'];\n \n const handleActivity = () => {\n resetTimers();\n startIdleTimer();\n };\n\n // Add event listeners\n activityEvents.forEach(event => {\n document.addEventListener(event, handleActivity, true);\n });\n\n // Start initial timer\n startIdleTimer();\n\n // Store cleanup function\n this.inactivityTracker.cleanup = () => {\n if (idleTimer) {\n clearTimeout(idleTimer);\n idleTimer = null;\n }\n \n if (warningTimer) {\n clearTimeout(warningTimer);\n warningTimer = null;\n }\n\n activityEvents.forEach(event => {\n document.removeEventListener(event, handleActivity, true);\n });\n\n this._isTracking = false;\n this._isIdle = false;\n this._showWarning = false;\n this._timeRemaining = 0;\n this._showInactivityWarning = false;\n this._inactivityTimeRemaining = 0;\n };\n\n this._isTracking = true;\n this.notify();\n }\n}","/**\n * @file Inactivity Service Provider\n * @package @jmruthers/pace-core\n * @module Providers/Services\n * @since 0.1.0\n *\n * React provider for InactivityService.\n * Provides inactivity service instance to React components.\n */\n\nimport React, { createContext, useContext, useMemo, useEffect } from 'react';\nimport { type SupabaseClient, type User, type Session } from '@supabase/supabase-js';\nimport { InactivityService } from '../../services/InactivityService';\n\n// Context type\nexport interface InactivityServiceContextType {\n inactivityService: InactivityService;\n}\n\nexport const InactivityServiceContext = createContext<InactivityServiceContextType | null>(null);\n\nexport interface InactivityServiceProviderProps {\n children: React.ReactNode;\n supabaseClient: SupabaseClient;\n user: User | null;\n session: Session | null;\n idleTimeoutMs?: number;\n warnBeforeMs?: number;\n onIdleLogout: (reason: 'inactivity') => void;\n}\n\nexport function InactivityServiceProvider({ \n children, \n supabaseClient, \n user, \n session, \n idleTimeoutMs = 30 * 60 * 1000,\n warnBeforeMs = 60 * 1000,\n onIdleLogout\n}: InactivityServiceProviderProps) {\n // Create service instance with useMemo to prevent recreation on every render\n const inactivityService = useMemo(\n () => new InactivityService(supabaseClient, user, session, idleTimeoutMs, warnBeforeMs, onIdleLogout),\n [supabaseClient, user, session, idleTimeoutMs, warnBeforeMs, onIdleLogout]\n );\n\n // Update service dependencies when they change\n useEffect(() => {\n inactivityService.updateDependencies(supabaseClient, user, session, idleTimeoutMs, warnBeforeMs, onIdleLogout);\n }, [inactivityService, supabaseClient, user, session, idleTimeoutMs, warnBeforeMs, onIdleLogout]);\n\n // Initialize service on mount\n useEffect(() => {\n inactivityService.initialize().catch(error => {\n console.error('[InactivityServiceProvider] Failed to initialize inactivity service:', error);\n });\n\n // Cleanup on unmount\n return () => {\n inactivityService.cleanup();\n };\n }, [inactivityService]);\n\n const contextValue = useMemo(() => ({\n inactivityService\n }), [inactivityService]);\n\n return (\n <InactivityServiceContext.Provider value={contextValue}>\n {children}\n </InactivityServiceContext.Provider>\n );\n}\n\nexport const useInactivityService = (): InactivityService => {\n const context = useContext(InactivityServiceContext);\n \n if (!context) {\n throw new Error('useInactivityService must be used within InactivityServiceProvider');\n }\n \n return context.inactivityService;\n};","/**\n * @file Auth Service Hook\n * @package @jmruthers/pace-core\n * @module Hooks/Services\n * @since 0.1.0\n *\n * React hook for AuthService.\n * Provides authentication service with reactive state updates.\n */\n\nimport { useContext, useReducer, useEffect } from 'react';\nimport { AuthServiceContext } from '../../providers/services/AuthServiceProvider';\nimport { AuthService } from '../../services/AuthService';\n\nexport function useAuthService(): AuthService {\n const context = useContext(AuthServiceContext);\n \n if (!context) {\n throw new Error('useAuthService must be used within AuthServiceProvider');\n }\n \n // Subscribe to service state changes\n const [, forceUpdate] = useReducer(x => x + 1, 0);\n \n useEffect(() => {\n return context.authService.subscribe(() => forceUpdate());\n }, [context.authService]);\n \n return context.authService;\n}","/**\n * @file RBAC Service Hook\n * @package @jmruthers/pace-core\n * @module Hooks/Services\n * @since 0.1.0\n *\n * React hook for RBACService.\n * Provides RBAC service with reactive state updates.\n */\n\nimport { useContext, useReducer, useEffect } from 'react';\nimport { RBACServiceContext } from '../../providers/services/RBACServiceProvider';\nimport { RBACService } from '../../services/RBACService';\n\nexport function useRBACService(): RBACService {\n const context = useContext(RBACServiceContext);\n \n if (!context) {\n throw new Error('useRBACService must be used within RBACServiceProvider');\n }\n \n // Subscribe to service state changes\n const [, forceUpdate] = useReducer(x => x + 1, 0);\n \n useEffect(() => {\n return context.rbacService.subscribe(() => forceUpdate());\n }, [context.rbacService]);\n \n return context.rbacService;\n}","/**\n * @file Organisation Service Hook\n * @package @jmruthers/pace-core\n * @module Hooks/Services\n * @since 0.1.0\n *\n * React hook for OrganisationService.\n * Provides organisation service with reactive state updates.\n */\n\nimport { useContext, useReducer, useEffect } from 'react';\nimport { OrganisationServiceContext } from '../../providers/services/OrganisationServiceProvider';\nimport { OrganisationService } from '../../services/OrganisationService';\n\nexport function useOrganisationService(): OrganisationService {\n const context = useContext(OrganisationServiceContext);\n \n if (!context) {\n throw new Error('useOrganisationService must be used within OrganisationServiceProvider');\n }\n \n // Subscribe to service state changes\n const [, forceUpdate] = useReducer(x => x + 1, 0);\n \n useEffect(() => {\n return context.organisationService.subscribe(() => forceUpdate());\n }, [context.organisationService]);\n \n return context.organisationService;\n}","/**\n * @file Event Service Hook\n * @package @jmruthers/pace-core\n * @module Hooks/Services\n * @since 0.1.0\n *\n * React hook for EventService.\n * Provides event service with reactive state updates.\n */\n\nimport { useContext, useReducer, useEffect } from 'react';\nimport { EventServiceContext } from '../../providers/services/EventServiceProvider';\nimport { EventService } from '../../services/EventService';\n\nexport function useEventService(): EventService {\n const context = useContext(EventServiceContext);\n \n if (!context) {\n throw new Error('useEventService must be used within EventServiceProvider');\n }\n \n // Subscribe to service state changes\n const [, forceUpdate] = useReducer(x => x + 1, 0);\n \n useEffect(() => {\n return context.eventService.subscribe(() => forceUpdate());\n }, [context.eventService]);\n \n return context.eventService;\n}","/**\n * @file Inactivity Service Hook\n * @package @jmruthers/pace-core\n * @module Hooks/Services\n * @since 0.1.0\n *\n * React hook for InactivityService.\n * Provides inactivity service with reactive state updates.\n */\n\nimport { useContext, useReducer, useEffect } from 'react';\nimport { InactivityServiceContext } from '../../providers/services/InactivityServiceProvider';\nimport { InactivityService } from '../../services/InactivityService';\n\nexport function useInactivityService(): InactivityService {\n const context = useContext(InactivityServiceContext);\n \n if (!context) {\n throw new Error('useInactivityService must be used within InactivityServiceProvider');\n }\n \n // Subscribe to service state changes\n const [, forceUpdate] = useReducer(x => x + 1, 0);\n \n useEffect(() => {\n return context.inactivityService.subscribe(() => forceUpdate());\n }, [context.inactivityService]);\n \n return context.inactivityService;\n}","/**\n * @file Unified Auth Provider\n * @package @jmruthers/pace-core\n * @module Providers/Services\n * @since 0.1.0\n *\n * Unified authentication provider using service architecture.\n * Combines all services in a single provider for backward compatibility.\n */\n\nimport React, { createContext, useContext, useMemo } from 'react';\nimport { type SupabaseClient } from '@supabase/supabase-js';\nimport { AuthServiceProvider } from './AuthServiceProvider';\nimport { RBACServiceProvider } from './RBACServiceProvider';\nimport { OrganisationServiceProvider } from './OrganisationServiceProvider';\nimport { EventServiceProvider } from './EventServiceProvider';\nimport { InactivityServiceProvider } from './InactivityServiceProvider';\nimport { useAuthService } from '../../hooks/services/useAuthService';\nimport { useRBACService } from '../../hooks/services/useRBACService';\nimport { useOrganisationService } from '../../hooks/services/useOrganisationService';\nimport { useEventService } from '../../hooks/services/useEventService';\nimport { useInactivityService } from '../../hooks/services/useInactivityService';\n\n// Re-export UserEventAccess type from IRBACService\nexport type { UserEventAccess } from '../../services/interfaces/IRBACService';\n\n// Combined context type - now service-aware and secure\nexport interface UnifiedAuthContextType {\n // Auth state\n user: any | null;\n session: any | null;\n isAuthenticated: boolean;\n authLoading: boolean;\n authError: any | null;\n error: any | null; // Alias for authError for backward compatibility\n supabase: SupabaseClient | null;\n \n // Auth methods\n signIn: (email: string, password?: string) => Promise<{ error: any | null }>;\n signUp: (email: string, password: string) => Promise<{ error: any | null }>;\n signOut: () => Promise<{ error: any | null }>;\n resetPassword: (email: string) => Promise<{ error: any | null }>;\n updatePassword: (password: string) => Promise<{ error: any | null }>;\n refreshSession: () => Promise<{ error: any | null }>;\n\n // RBAC state\n permissions: Record<string, boolean>;\n roles: string[];\n accessLevel: any;\n rbacLoading: boolean;\n rbacError: Error | null;\n selectedEventId: string | null;\n appConfig: any | null;\n userEventAccess: any[];\n eventAccessLoading: boolean;\n selectedOrganisationId: string | null;\n \n // RBAC methods\n hasPermission: (permission: string, orgId?: string) => boolean;\n hasAnyPermission: (permissions: string[], orgId?: string) => boolean;\n hasAllPermissions: (permissions: string[], orgId?: string) => boolean;\n hasRole: (role: string) => boolean;\n hasAccessLevel: (level: any) => boolean;\n canAccess: (resource: string, action: string, orgId?: string) => boolean;\n validatePermission: (permission: string, orgId?: string) => Promise<boolean>;\n validateAccess: (resource: string, action: string, orgId?: string) => Promise<boolean>;\n refreshPermissions: (eventId?: string, orgId?: string) => Promise<void>;\n setSelectedEventId: (eventId: string | null) => void;\n loadUserEventAccess: (orgId?: string) => Promise<void>;\n getUserEventAccess: (eventId: string) => any | undefined;\n requireOrganisationContext: () => string;\n\n // Organisation state\n selectedOrganisation: any | null;\n organisations: any[];\n userMemberships: any[];\n organisationLoading: boolean;\n organisationError: Error | null;\n hasValidOrganisationContext: boolean;\n isContextReady: boolean;\n \n // Organisation methods\n switchOrganisation: (orgId: string) => Promise<void>;\n getUserRole: (orgId?: string) => string;\n validateOrganisationAccess: (orgId: string) => boolean;\n refreshOrganisations: () => Promise<void>;\n ensureOrganisationContext: () => any;\n isOrganisationSecure: () => boolean;\n getPrimaryOrganisation: () => any | null;\n\n // Event state\n events: any[];\n selectedEvent: any | null;\n eventLoading: boolean;\n eventError: Error | null;\n \n // Event methods\n setSelectedEvent: (event: any | null) => void;\n refreshEvents: () => Promise<void>;\n\n // Inactivity state\n showInactivityWarning: boolean;\n inactivityTimeRemaining: number;\n isIdle: boolean;\n timeRemaining: number;\n showWarning: boolean;\n isTracking: boolean;\n \n // Inactivity methods\n resetActivity: () => void;\n startTracking: () => void;\n stopTracking: () => void;\n handleIdleLogout: () => Promise<void>;\n handleStaySignedIn: () => void;\n handleSignOutNow: () => Promise<void>;\n\n // Additional unified properties\n appName: string;\n isLoading: boolean;\n hasErrors: boolean;\n}\n\nconst UnifiedAuthContext = createContext<UnifiedAuthContextType | undefined>(undefined);\n\nexport const useUnifiedAuth = () => {\n const context = useContext(UnifiedAuthContext);\n if (!context) {\n throw new Error('useUnifiedAuth must be used within a UnifiedAuthProvider');\n }\n return context;\n};\n\nexport interface UnifiedAuthProviderProps {\n children: React.ReactNode;\n supabaseClient: SupabaseClient;\n appName: string;\n persistState?: boolean;\n enablePersistence?: boolean;\n requireOrganisationContext?: boolean;\n enableRBAC?: boolean;\n \n // Inactivity auto-logout configuration - MANDATORY for security\n idleTimeoutMs: number; // REQUIRED: Inactivity timeout in milliseconds\n warnBeforeMs: number; // REQUIRED: Warning time before logout in milliseconds\n onIdleLogout: (reason: 'inactivity') => void; // REQUIRED: App handles redirect/navigation\n renderInactivityWarning?: (args: {\n timeRemaining: number;\n onStaySignedIn: () => void;\n onSignOutNow: () => void;\n }) => React.ReactNode; // Optional custom warning UI\n dangerouslyDisableInactivity?: boolean; // Dev-only; must not disable in production\n}\n\n// Internal component that combines all contexts\nfunction UnifiedAuthContextProvider({ \n children, \n appName,\n ...props \n}: UnifiedAuthProviderProps) {\n const authService = useAuthService();\n const rbacService = useRBACService();\n const organisationService = useOrganisationService();\n const eventService = useEventService();\n const inactivityService = useInactivityService();\n\n // Memoized combined context value\n const contextValue = useMemo<UnifiedAuthContextType>(() => ({\n // Auth state\n user: authService.getUser(),\n session: authService.getSession(),\n isAuthenticated: authService.isAuthenticated(),\n authLoading: authService.isLoading(),\n authError: authService.getError(),\n error: authService.getError(), // Alias for backward compatibility\n supabase: authService.getSupabaseClient(),\n \n // Auth methods\n signIn: authService.signIn.bind(authService),\n signUp: authService.signUp.bind(authService),\n signOut: authService.signOut.bind(authService),\n resetPassword: authService.resetPassword.bind(authService),\n updatePassword: authService.updatePassword.bind(authService),\n refreshSession: authService.refreshSession.bind(authService),\n\n // RBAC state\n permissions: rbacService.getPermissions(),\n roles: rbacService.getRoles(),\n accessLevel: rbacService.getAccessLevel(),\n rbacLoading: rbacService.isLoading(),\n rbacError: rbacService.getError(),\n selectedEventId: rbacService.getSelectedEventId(),\n appConfig: rbacService.getAppConfig(),\n userEventAccess: rbacService.getUserEventAccess(),\n eventAccessLoading: rbacService.isEventAccessLoading(),\n selectedOrganisationId: rbacService.getSelectedOrganisationId(),\n \n // RBAC methods\n hasPermission: rbacService.hasPermission.bind(rbacService),\n hasAnyPermission: rbacService.hasAnyPermission.bind(rbacService),\n hasAllPermissions: rbacService.hasAllPermissions.bind(rbacService),\n hasRole: rbacService.hasRole.bind(rbacService),\n hasAccessLevel: rbacService.hasAccessLevel.bind(rbacService),\n canAccess: rbacService.canAccess.bind(rbacService),\n validatePermission: rbacService.validatePermission.bind(rbacService),\n validateAccess: rbacService.validateAccess.bind(rbacService),\n refreshPermissions: rbacService.refreshPermissions.bind(rbacService),\n setSelectedEventId: rbacService.setSelectedEventId.bind(rbacService),\n loadUserEventAccess: rbacService.loadUserEventAccess.bind(rbacService),\n getUserEventAccess: rbacService.getUserEventAccess.bind(rbacService),\n requireOrganisationContext: rbacService.requireOrganisationContext.bind(rbacService),\n\n // Organisation state\n selectedOrganisation: organisationService.getSelectedOrganisation(),\n organisations: organisationService.getOrganisations(),\n userMemberships: organisationService.getUserMemberships(),\n organisationLoading: organisationService.isLoading(),\n organisationError: organisationService.getError(),\n hasValidOrganisationContext: organisationService.hasValidOrganisationContext(),\n isContextReady: organisationService.isContextReady(),\n \n // Organisation methods\n switchOrganisation: organisationService.switchOrganisation.bind(organisationService),\n getUserRole: organisationService.getUserRole.bind(organisationService),\n validateOrganisationAccess: organisationService.validateOrganisationAccess.bind(organisationService),\n refreshOrganisations: organisationService.refreshOrganisations.bind(organisationService),\n ensureOrganisationContext: organisationService.ensureOrganisationContext.bind(organisationService),\n isOrganisationSecure: organisationService.isOrganisationSecure.bind(organisationService),\n getPrimaryOrganisation: organisationService.getPrimaryOrganisation.bind(organisationService),\n\n // Event state\n events: eventService.getEvents(),\n selectedEvent: eventService.getSelectedEvent(),\n eventLoading: eventService.isLoading(),\n eventError: eventService.getError(),\n \n // Event methods\n setSelectedEvent: eventService.setSelectedEvent.bind(eventService),\n refreshEvents: eventService.refreshEvents.bind(eventService),\n\n // Inactivity state\n showInactivityWarning: inactivityService.getShowInactivityWarning(),\n inactivityTimeRemaining: inactivityService.getInactivityTimeRemaining(),\n isIdle: inactivityService.isIdle(),\n timeRemaining: inactivityService.getTimeRemaining(),\n showWarning: inactivityService.isWarningShown(),\n isTracking: inactivityService.isTracking(),\n \n // Inactivity methods\n resetActivity: inactivityService.resetActivity.bind(inactivityService),\n startTracking: inactivityService.startTracking.bind(inactivityService),\n stopTracking: inactivityService.stopTracking.bind(inactivityService),\n handleIdleLogout: inactivityService.handleIdleLogout.bind(inactivityService),\n handleStaySignedIn: inactivityService.handleStaySignedIn.bind(inactivityService),\n handleSignOutNow: inactivityService.handleSignOutNow.bind(inactivityService),\n\n // Additional unified properties\n appName,\n isLoading: authService.isLoading() || rbacService.isLoading() || organisationService.isLoading() || eventService.isLoading(),\n hasErrors: !!(authService.getError() || rbacService.getError() || organisationService.getError() || eventService.getError()),\n }), [authService, rbacService, organisationService, eventService, inactivityService, appName]);\n\n return (\n <UnifiedAuthContext.Provider value={contextValue}>\n {children}\n </UnifiedAuthContext.Provider>\n );\n}\n\n// Internal component that provides user/session to child providers\nfunction ServiceAwareProviders({ \n children, \n supabaseClient,\n appName,\n persistState,\n enablePersistence,\n requireOrganisationContext,\n enableRBAC,\n idleTimeoutMs,\n warnBeforeMs,\n onIdleLogout,\n renderInactivityWarning,\n dangerouslyDisableInactivity\n}: UnifiedAuthProviderProps) {\n const authService = useAuthService();\n\n return (\n <RBACServiceProvider\n supabaseClient={supabaseClient}\n user={authService.getUser()}\n session={authService.getSession()}\n appName={appName}\n >\n <OrganisationServiceProvider\n supabaseClient={supabaseClient}\n user={authService.getUser()}\n session={authService.getSession()}\n >\n <EventServiceProvider\n supabaseClient={supabaseClient}\n user={authService.getUser()}\n session={authService.getSession()}\n appName={appName}\n selectedOrganisation={null} // Will be updated by OrganisationService\n setSelectedEventId={(eventId: string | null) => {\n // This will be handled by the RBACService\n }}\n >\n <InactivityServiceProvider\n supabaseClient={supabaseClient}\n user={authService.getUser()}\n session={authService.getSession()}\n idleTimeoutMs={idleTimeoutMs}\n warnBeforeMs={warnBeforeMs}\n onIdleLogout={onIdleLogout}\n >\n <UnifiedAuthContextProvider\n appName={appName}\n supabaseClient={supabaseClient}\n persistState={persistState}\n enablePersistence={enablePersistence}\n requireOrganisationContext={requireOrganisationContext}\n enableRBAC={enableRBAC}\n idleTimeoutMs={idleTimeoutMs}\n warnBeforeMs={warnBeforeMs}\n onIdleLogout={onIdleLogout}\n renderInactivityWarning={renderInactivityWarning}\n dangerouslyDisableInactivity={dangerouslyDisableInactivity}\n >\n {children}\n </UnifiedAuthContextProvider>\n </InactivityServiceProvider>\n </EventServiceProvider>\n </OrganisationServiceProvider>\n </RBACServiceProvider>\n );\n}\n\nexport function UnifiedAuthProvider({\n children,\n supabaseClient,\n appName,\n persistState = true,\n enablePersistence,\n requireOrganisationContext = true,\n enableRBAC = false,\n idleTimeoutMs = 30 * 60 * 1000, // 30 minutes\n warnBeforeMs = 60 * 1000, // 60 seconds\n onIdleLogout,\n renderInactivityWarning,\n dangerouslyDisableInactivity = false\n}: UnifiedAuthProviderProps) {\n return (\n <AuthServiceProvider supabaseClient={supabaseClient}>\n <ServiceAwareProviders\n supabaseClient={supabaseClient}\n appName={appName}\n persistState={persistState}\n enablePersistence={enablePersistence}\n requireOrganisationContext={requireOrganisationContext}\n enableRBAC={enableRBAC}\n idleTimeoutMs={idleTimeoutMs}\n warnBeforeMs={warnBeforeMs}\n onIdleLogout={onIdleLogout}\n renderInactivityWarning={renderInactivityWarning}\n dangerouslyDisableInactivity={dangerouslyDisableInactivity}\n >\n {children}\n </ServiceAwareProviders>\n </AuthServiceProvider>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAAA,IAYsB;AAZtB;AAAA;AAAA;AAYO,IAAe,cAAf,MAA2B;AAAA,MAA3B;AACL,aAAQ,cAA0C,CAAC;AACnD,aAAQ,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAOxB,UAAU,UAA2C;AACnD,aAAK,YAAY,KAAK,QAAQ;AAG9B,eAAO,MAAM;AACX,gBAAM,QAAQ,KAAK,YAAY,QAAQ,QAAQ;AAC/C,cAAI,QAAQ,IAAI;AACd,iBAAK,YAAY,OAAO,OAAO,CAAC;AAAA,UAClC;AAAA,QACF;AAAA,MACF;AAAA;AAAA;AAAA;AAAA;AAAA,MAMU,SAAe;AACvB,aAAK,YAAY,QAAQ,cAAY;AACnC,cAAI;AACF,qBAAS;AAAA,UACX,SAAS,OAAO;AACd,oBAAQ,MAAM,+CAA+C,KAAK;AAAA,UACpE;AAAA,QACF,CAAC;AAAA,MACH;AAAA;AAAA;AAAA;AAAA;AAAA,MAMA,MAAM,aAA4B;AAChC,YAAI,KAAK,eAAe;AACtB;AAA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AA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MAEC;AAAA;AAAA,EACH,GACF;AAEJ;AAlXA,IA0HM,oBAEO;AA5Hb;AAAA;AAAA;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAqGA,IAAM,qBAAqBH,eAAkD,MAAS;AAE/E,IAAM,iBAAiB,MAAM;AAClC,YAAM,UAAUC,aAAW,kBAAkB;AAC7C,UAAI,CAAC,SAAS;AACZ,cAAM,IAAI,MAAM,0DAA0D;AAAA,MAC5E;AACA,aAAO;AAAA,IACT;AAAA;AAAA;","names":["createContext","useContext","useMemo","useEffect","jsx","createContext","useContext","useMemo","useEffect","jsx","createContext","useContext","useMemo","useEffect","jsx","createContext","useContext","useMemo","useEffect","jsx","useContext","useEffect","useAuthService","useContext","useReducer","useEffect","useRBACService","useContext","useReducer","useEffect","useOrganisationService","useContext","useReducer","useEffect","useEventService","useContext","useReducer","useEffect","useInactivityService","createContext","useContext","useMemo","jsx","useAuthService","useRBACService","useOrganisationService","useEventService","useInactivityService"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/utils/debugLogger.ts","../src/utils/organisationContext.ts"],"sourcesContent":["/**\n * @file Debug Logger Utility\n * @package @jmruthers/pace-core\n * @module Utils/DebugLogger\n * @since 0.4.76\n */\n\n/**\n * Debug logger that respects environment settings\n * Only logs in development mode to prevent production console spam\n */\nexport class DebugLogger {\n /**\n * Check if we're in development mode\n */\n private static get isDevelopment(): boolean {\n return import.meta.env.MODE === 'development';\n }\n\n /**\n * Log debug information only in development mode\n */\n static log(component: string, message: string, ...args: any[]): void {\n if (this.isDevelopment) {\n try {\n console.log(`[${component}] ${message}`, ...args);\n } catch (e) {\n // Gracefully handle console method errors\n }\n }\n }\n\n /**\n * Log error information (always logged)\n */\n static error(component: string, message: string, ...args: any[]): void {\n try {\n console.error(`[${component}] ${message}`, ...args);\n } catch (e) {\n // Gracefully handle console method errors\n }\n }\n\n /**\n * Log warning information (always logged)\n */\n static warn(component: string, message: string, ...args: any[]): void {\n try {\n console.warn(`[${component}] ${message}`, ...args);\n } catch (e) {\n // Gracefully handle console method errors\n }\n }\n\n /**\n * Log info information only in development mode\n */\n static info(component: string, message: string, ...args: any[]): void {\n if (this.isDevelopment) {\n try {\n console.info(`[${component}] ${message}`, ...args);\n } catch (e) {\n // Gracefully handle console method errors\n }\n }\n }\n}\n","/**\n * @file Organisation Context Utility\n * @package @jmruthers/pace-core\n * @module Utils/OrganisationContext\n * @since 0.4.0\n *\n * Utility functions for managing organisation context in database sessions.\n * Provides fallback mechanisms for when database functions are not available.\n */\n\nimport type { SupabaseClient } from '@supabase/supabase-js';\n\n/**\n * Set organisation context in the database session\n * \n * This function attempts to set the organisation context using a database function.\n * If the function is not available, it falls back gracefully without throwing errors.\n * \n * @param supabase - Supabase client instance\n * @param organisationId - The organisation ID to set as context\n * @returns Promise that resolves when context is set (or falls back gracefully)\n */\nexport async function setOrganisationContext(\n supabase: SupabaseClient,\n organisationId: string\n): Promise<void> {\n if (!supabase || !organisationId) {\n // TODO: Replace with proper logging service integration\n return;\n }\n\n try {\n // Try to call the database function to set organisation context\n const { error } = await supabase.rpc('rbac_audit_log', {\n p_event_type: 'organisation_switched',\n p_organisation_id: organisationId,\n p_metadata: { action: 'set_context' }\n });\n\n if (error) {\n // Function might not exist yet - this is expected during migration\n // Silent fail - will fall back to client-side filtering\n // TODO: Replace with proper logging service integration\n } else {\n // TODO: Replace with proper logging service integration\n }\n } catch (error) {\n // Handle any other errors gracefully\n // Silent fail - will fall back to client-side filtering\n // TODO: Replace with proper logging service integration\n }\n}\n\n/**\n * Clear organisation context from the database session\n * \n * @param supabase - Supabase client instance\n * @returns Promise that resolves when context is cleared\n */\nexport async function clearOrganisationContext(\n supabase: SupabaseClient\n): Promise<void> {\n if (!supabase) {\n // TODO: Replace with proper logging service integration\n return;\n }\n\n try {\n const { error } = await supabase.rpc('rbac_audit_log', {\n p_event_type: 'organisation_switched',\n p_metadata: { action: 'clear_context' }\n });\n \n if (error) {\n // Silent fail - function not available\n // TODO: Replace with proper logging service integration\n } else {\n // TODO: Replace with proper logging service integration\n }\n } catch (error) {\n // Silent fail - error occurred\n // TODO: Replace with proper logging service integration\n }\n}\n\n/**\n * Get current organisation context from the database session\n * \n * @param supabase - Supabase client instance\n * @returns Promise that resolves to the current organisation ID or null\n */\nexport async function getOrganisationContext(\n supabase: SupabaseClient\n): Promise<string | null> {\n if (!supabase) {\n // TODO: Replace with proper logging service integration\n return null;\n }\n\n try {\n // For now, return null since we're not using database context\n // This will be replaced with proper context management\n const data = null;\n const error = null;\n \n if (error) {\n // TODO: Replace with proper logging service integration\n return null;\n }\n \n // Validate that data is a string (allow empty strings)\n if (typeof data === 'string') {\n return data;\n }\n \n // Return null for invalid data formats\n return null;\n } catch (error) {\n // TODO: Replace with proper logging service integration\n return null;\n }\n}\n\n/**\n * Check if organisation context functions are available in the database\n * \n * @param supabase - Supabase client instance\n * @returns Promise that resolves to true if functions are available\n */\nexport async function isOrganisationContextAvailable(\n supabase: SupabaseClient\n): Promise<boolean> {\n if (!supabase) {\n return false;\n }\n\n try {\n const { error } = await supabase.rpc('get_organisation_context');\n \n if (error) {\n return false;\n }\n \n return true;\n } catch (error) {\n return false;\n }\n} "],"mappings":";;;;;AAAA,IAWa;AAXb;AAAA;AAAA;AAWO,IAAM,cAAN,MAAkB;AAAA;AAAA;AAAA;AAAA,MAIvB,WAAmB,gBAAyB;AAC1C,eAAO,YAAY,IAAI,SAAS;AAAA,MAClC;AAAA;AAAA;AAAA;AAAA,MAKA,OAAO,IAAI,WAAmB,YAAoB,MAAmB;AACnE,YAAI,KAAK,eAAe;AACtB,cAAI;AACF,oBAAQ,IAAI,IAAI,SAAS,KAAK,OAAO,IAAI,GAAG,IAAI;AAAA,UAClD,SAAS,GAAG;AAAA,UAEZ;AAAA,QACF;AAAA,MACF;AAAA;AAAA;A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