@jmruthers/pace-core 0.5.191 → 0.6.1
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.
- package/CHANGELOG.md +29 -0
- package/README.md +7 -1
- package/cursor-rules/00-pace-core-compliance.mdc +372 -0
- package/cursor-rules/01-standards-compliance.mdc +275 -0
- package/cursor-rules/02-project-structure.mdc +200 -0
- package/cursor-rules/03-solid-principles.mdc +341 -0
- package/cursor-rules/04-testing-standards.mdc +315 -0
- package/cursor-rules/05-bug-reports-and-features.mdc +246 -0
- package/cursor-rules/06-code-quality.mdc +392 -0
- package/cursor-rules/07-tech-stack-compliance.mdc +309 -0
- package/cursor-rules/CHANGELOG.md +101 -0
- package/cursor-rules/README.md +191 -0
- package/dist/{AuthService-CbP_utw2.d.ts → AuthService-DjnJHDtC.d.ts} +1 -0
- package/dist/{DataTable-Be6dH_dR.d.ts → DataTable-CH1U5Tpy.d.ts} +1 -1
- package/dist/{DataTable-WKRZD47S.js → DataTable-DQ7RSOHE.js} +8 -7
- package/dist/{PublicPageProvider-ULXC_u6U.d.ts → PublicPageProvider-ce4xlHYA.d.ts} +37 -156
- package/dist/{UnifiedAuthProvider-BYA9qB-o.d.ts → UnifiedAuthProvider-185Ih4dj.d.ts} +2 -0
- package/dist/{UnifiedAuthProvider-FTSG5XH7.js → UnifiedAuthProvider-ATAP5UTR.js} +3 -3
- package/dist/{api-IHKALJZD.js → api-N774RPUA.js} +2 -2
- package/dist/{chunk-6C4YBBJM.js → chunk-3QRJFVBR.js} +1 -1
- package/dist/chunk-3QRJFVBR.js.map +1 -0
- package/dist/{chunk-OETXORNB.js → chunk-3XTALGJF.js} +211 -136
- package/dist/chunk-3XTALGJF.js.map +1 -0
- package/dist/{chunk-6TQDD426.js → chunk-4N5C5XZU.js} +47 -228
- package/dist/chunk-4N5C5XZU.js.map +1 -0
- package/dist/{chunk-LOMZXPSN.js → chunk-4ZC4GX36.js} +47 -74
- package/dist/chunk-4ZC4GX36.js.map +1 -0
- package/dist/{chunk-6LTQQAT6.js → chunk-BYFSK72L.js} +357 -158
- package/dist/chunk-BYFSK72L.js.map +1 -0
- package/dist/{chunk-XYXSXPUK.js → chunk-EXUD6RNJ.js} +50 -10
- package/dist/chunk-EXUD6RNJ.js.map +1 -0
- package/dist/{chunk-VKB2CO4Z.js → chunk-GLK6VM3F.js} +244 -249
- package/dist/chunk-GLK6VM3F.js.map +1 -0
- package/dist/{chunk-HW3OVDUF.js → chunk-J36DSWQK.js} +1 -1
- package/dist/{chunk-HW3OVDUF.js.map → chunk-J36DSWQK.js.map} +1 -1
- package/dist/{chunk-XNYQOL3Z.js → chunk-JBKQ3SAO.js} +9 -18
- package/dist/chunk-JBKQ3SAO.js.map +1 -0
- package/dist/{chunk-ROXMHMY2.js → chunk-KNC55RTG.js} +13 -3
- package/dist/{chunk-ROXMHMY2.js.map → chunk-KNC55RTG.js.map} +1 -1
- package/dist/{chunk-QWWZ5CAQ.js → chunk-LXQLPRQ2.js} +2 -2
- package/dist/{chunk-ULHIJK66.js → chunk-T33XF5ZC.js} +255 -140
- package/dist/chunk-T33XF5ZC.js.map +1 -0
- package/dist/{chunk-VRGWKHDB.js → chunk-XM25TVIE.js} +100 -33
- package/dist/chunk-XM25TVIE.js.map +1 -0
- package/dist/components.d.ts +4 -4
- package/dist/components.js +9 -9
- package/dist/hooks.d.ts +6 -6
- package/dist/hooks.js +20 -25
- package/dist/hooks.js.map +1 -1
- package/dist/index.d.ts +11 -11
- package/dist/index.js +18 -21
- package/dist/index.js.map +1 -1
- package/dist/providers.d.ts +3 -3
- package/dist/providers.js +2 -2
- package/dist/rbac/index.d.ts +2 -20
- package/dist/rbac/index.js +7 -9
- package/dist/{usePublicRouteParams-TZe0gy-4.d.ts → usePublicRouteParams-BJAlWfuJ.d.ts} +3 -3
- package/dist/{useToast-C8gR5ir4.d.ts → useToast-AyaT-x7p.d.ts} +2 -2
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +3 -3
- package/docs/api/classes/ColumnFactory.md +1 -1
- package/docs/api/classes/ErrorBoundary.md +1 -1
- package/docs/api/classes/InvalidScopeError.md +1 -1
- package/docs/api/classes/Logger.md +1 -1
- package/docs/api/classes/MissingUserContextError.md +1 -1
- package/docs/api/classes/OrganisationContextRequiredError.md +1 -1
- package/docs/api/classes/PermissionDeniedError.md +2 -2
- package/docs/api/classes/RBACAuditManager.md +2 -2
- package/docs/api/classes/RBACCache.md +1 -1
- package/docs/api/classes/RBACEngine.md +2 -2
- package/docs/api/classes/RBACError.md +1 -1
- package/docs/api/classes/RBACNotInitializedError.md +1 -1
- package/docs/api/classes/SecureSupabaseClient.md +10 -10
- package/docs/api/classes/StorageUtils.md +1 -1
- package/docs/api/enums/FileCategory.md +1 -1
- package/docs/api/enums/LogLevel.md +1 -1
- package/docs/api/enums/RBACErrorCode.md +1 -1
- package/docs/api/enums/RPCFunction.md +1 -1
- package/docs/api/interfaces/AddressFieldProps.md +1 -1
- package/docs/api/interfaces/AddressFieldRef.md +1 -1
- package/docs/api/interfaces/AggregateConfig.md +1 -1
- package/docs/api/interfaces/AutocompleteOptions.md +1 -1
- package/docs/api/interfaces/AvatarProps.md +1 -1
- package/docs/api/interfaces/BadgeProps.md +1 -1
- package/docs/api/interfaces/ButtonProps.md +1 -1
- package/docs/api/interfaces/CalendarProps.md +1 -1
- package/docs/api/interfaces/CardProps.md +1 -1
- package/docs/api/interfaces/ColorPalette.md +1 -1
- package/docs/api/interfaces/ColorShade.md +1 -1
- package/docs/api/interfaces/ComplianceResult.md +1 -1
- package/docs/api/interfaces/DataAccessRecord.md +1 -1
- package/docs/api/interfaces/DataRecord.md +1 -1
- package/docs/api/interfaces/DataTableAction.md +1 -1
- package/docs/api/interfaces/DataTableColumn.md +1 -1
- package/docs/api/interfaces/DataTableProps.md +1 -1
- package/docs/api/interfaces/DataTableToolbarButton.md +1 -1
- package/docs/api/interfaces/DatabaseComplianceResult.md +1 -1
- package/docs/api/interfaces/DatabaseIssue.md +1 -1
- package/docs/api/interfaces/EmptyStateConfig.md +1 -1
- package/docs/api/interfaces/EnhancedNavigationMenuProps.md +1 -1
- package/docs/api/interfaces/EventAppRoleData.md +1 -1
- package/docs/api/interfaces/ExportColumn.md +1 -1
- package/docs/api/interfaces/ExportOptions.md +1 -1
- package/docs/api/interfaces/FileDisplayProps.md +24 -11
- package/docs/api/interfaces/FileMetadata.md +1 -1
- package/docs/api/interfaces/FileReference.md +1 -1
- package/docs/api/interfaces/FileSizeLimits.md +1 -1
- package/docs/api/interfaces/FileUploadOptions.md +1 -1
- package/docs/api/interfaces/FileUploadProps.md +1 -1
- package/docs/api/interfaces/FooterProps.md +1 -1
- package/docs/api/interfaces/FormFieldProps.md +1 -1
- package/docs/api/interfaces/FormProps.md +1 -1
- package/docs/api/interfaces/GrantEventAppRoleParams.md +1 -1
- package/docs/api/interfaces/InactivityWarningModalProps.md +1 -1
- package/docs/api/interfaces/InputProps.md +1 -1
- package/docs/api/interfaces/LabelProps.md +1 -1
- package/docs/api/interfaces/LoggerConfig.md +1 -1
- package/docs/api/interfaces/LoginFormProps.md +1 -1
- package/docs/api/interfaces/NavigationAccessRecord.md +2 -2
- package/docs/api/interfaces/NavigationContextType.md +1 -1
- package/docs/api/interfaces/NavigationGuardProps.md +1 -1
- package/docs/api/interfaces/NavigationItem.md +1 -1
- package/docs/api/interfaces/NavigationMenuProps.md +1 -1
- package/docs/api/interfaces/NavigationProviderProps.md +1 -1
- package/docs/api/interfaces/Organisation.md +1 -1
- package/docs/api/interfaces/OrganisationContextType.md +1 -1
- package/docs/api/interfaces/OrganisationMembership.md +1 -1
- package/docs/api/interfaces/OrganisationProviderProps.md +1 -1
- package/docs/api/interfaces/OrganisationSecurityError.md +1 -1
- package/docs/api/interfaces/PaceAppLayoutProps.md +1 -1
- package/docs/api/interfaces/PaceLoginPageProps.md +1 -1
- package/docs/api/interfaces/PageAccessRecord.md +1 -1
- package/docs/api/interfaces/PagePermissionContextType.md +1 -1
- package/docs/api/interfaces/PagePermissionGuardProps.md +2 -2
- package/docs/api/interfaces/PagePermissionProviderProps.md +1 -1
- package/docs/api/interfaces/PaletteData.md +1 -1
- package/docs/api/interfaces/ParsedAddress.md +1 -1
- package/docs/api/interfaces/PermissionEnforcerProps.md +4 -4
- package/docs/api/interfaces/ProgressProps.md +1 -1
- package/docs/api/interfaces/ProtectedRouteProps.md +1 -1
- package/docs/api/interfaces/PublicPageFooterProps.md +1 -1
- package/docs/api/interfaces/PublicPageHeaderProps.md +1 -1
- package/docs/api/interfaces/PublicPageLayoutProps.md +1 -1
- package/docs/api/interfaces/QuickFix.md +1 -1
- package/docs/api/interfaces/RBACAccessValidateParams.md +1 -1
- package/docs/api/interfaces/RBACAccessValidateResult.md +1 -1
- package/docs/api/interfaces/RBACAuditLogParams.md +1 -1
- package/docs/api/interfaces/RBACAuditLogResult.md +1 -1
- package/docs/api/interfaces/RBACConfig.md +2 -2
- package/docs/api/interfaces/RBACContext.md +1 -1
- package/docs/api/interfaces/RBACLogger.md +1 -1
- package/docs/api/interfaces/RBACPageAccessCheckParams.md +1 -1
- package/docs/api/interfaces/RBACPerformanceMetrics.md +1 -1
- package/docs/api/interfaces/RBACPermissionCheckParams.md +1 -1
- package/docs/api/interfaces/RBACPermissionCheckResult.md +2 -2
- package/docs/api/interfaces/RBACPermissionsGetParams.md +1 -1
- package/docs/api/interfaces/RBACPermissionsGetResult.md +1 -1
- package/docs/api/interfaces/RBACResult.md +1 -1
- package/docs/api/interfaces/RBACRoleGrantParams.md +2 -2
- package/docs/api/interfaces/RBACRoleGrantResult.md +1 -1
- package/docs/api/interfaces/RBACRoleRevokeParams.md +2 -2
- package/docs/api/interfaces/RBACRoleRevokeResult.md +1 -1
- package/docs/api/interfaces/RBACRoleValidateParams.md +2 -2
- package/docs/api/interfaces/RBACRoleValidateResult.md +1 -1
- package/docs/api/interfaces/RBACRolesListParams.md +1 -1
- package/docs/api/interfaces/RBACRolesListResult.md +2 -2
- package/docs/api/interfaces/RBACSessionTrackParams.md +1 -1
- package/docs/api/interfaces/RBACSessionTrackResult.md +1 -1
- package/docs/api/interfaces/ResourcePermissions.md +1 -1
- package/docs/api/interfaces/RevokeEventAppRoleParams.md +1 -1
- package/docs/api/interfaces/RoleBasedRouterContextType.md +1 -1
- package/docs/api/interfaces/RoleBasedRouterProps.md +1 -1
- package/docs/api/interfaces/RoleManagementResult.md +1 -1
- package/docs/api/interfaces/RouteAccessRecord.md +2 -2
- package/docs/api/interfaces/RouteConfig.md +2 -2
- package/docs/api/interfaces/RuntimeComplianceResult.md +1 -1
- package/docs/api/interfaces/SecureDataContextType.md +1 -1
- package/docs/api/interfaces/SecureDataProviderProps.md +1 -1
- package/docs/api/interfaces/SessionRestorationLoaderProps.md +1 -1
- package/docs/api/interfaces/SetupIssue.md +1 -1
- package/docs/api/interfaces/StorageConfig.md +1 -1
- package/docs/api/interfaces/StorageFileInfo.md +1 -1
- package/docs/api/interfaces/StorageFileMetadata.md +1 -1
- package/docs/api/interfaces/StorageListOptions.md +1 -1
- package/docs/api/interfaces/StorageListResult.md +1 -1
- package/docs/api/interfaces/StorageUploadOptions.md +1 -1
- package/docs/api/interfaces/StorageUploadResult.md +1 -1
- package/docs/api/interfaces/StorageUrlOptions.md +1 -1
- package/docs/api/interfaces/StyleImport.md +1 -1
- package/docs/api/interfaces/SwitchProps.md +1 -1
- package/docs/api/interfaces/TabsContentProps.md +1 -1
- package/docs/api/interfaces/TabsListProps.md +1 -1
- package/docs/api/interfaces/TabsProps.md +1 -1
- package/docs/api/interfaces/TabsTriggerProps.md +1 -1
- package/docs/api/interfaces/TextareaProps.md +1 -1
- package/docs/api/interfaces/ToastActionElement.md +1 -1
- package/docs/api/interfaces/ToastProps.md +1 -1
- package/docs/api/interfaces/UnifiedAuthContextType.md +60 -38
- package/docs/api/interfaces/UnifiedAuthProviderProps.md +13 -13
- package/docs/api/interfaces/UseFormDialogOptions.md +1 -1
- package/docs/api/interfaces/UseFormDialogReturn.md +1 -1
- package/docs/api/interfaces/UseInactivityTrackerOptions.md +1 -1
- package/docs/api/interfaces/UseInactivityTrackerReturn.md +1 -1
- package/docs/api/interfaces/UsePublicEventLogoOptions.md +2 -2
- package/docs/api/interfaces/UsePublicEventLogoReturn.md +1 -1
- package/docs/api/interfaces/UsePublicEventOptions.md +1 -1
- package/docs/api/interfaces/UsePublicEventReturn.md +1 -1
- package/docs/api/interfaces/UsePublicFileDisplayOptions.md +2 -2
- package/docs/api/interfaces/UsePublicFileDisplayReturn.md +1 -1
- package/docs/api/interfaces/UsePublicRouteParamsReturn.md +1 -1
- package/docs/api/interfaces/UseResolvedScopeOptions.md +2 -2
- package/docs/api/interfaces/UseResolvedScopeReturn.md +1 -1
- package/docs/api/interfaces/UseResourcePermissionsOptions.md +1 -1
- package/docs/api/interfaces/UserEventAccess.md +1 -1
- package/docs/api/interfaces/UserMenuProps.md +1 -1
- package/docs/api/interfaces/UserProfile.md +1 -1
- package/docs/api/modules.md +194 -209
- package/docs/getting-started/cursor-rules.md +262 -0
- package/docs/getting-started/installation-guide.md +6 -1
- package/docs/getting-started/quick-start.md +6 -1
- package/docs/migration/MIGRATION_GUIDE.md +4 -4
- package/docs/migration/REACT_19_MIGRATION.md +227 -0
- package/docs/migration/database-changes-december-2025.md +2 -1
- package/docs/rbac/event-based-apps.md +124 -6
- package/docs/standards/README.md +39 -0
- package/docs/troubleshooting/migration.md +4 -4
- package/examples/PublicPages/PublicEventPage.tsx +1 -1
- package/package.json +11 -6
- package/scripts/audit-consuming-app.cjs +961 -0
- package/scripts/check-pace-core-compliance.cjs +315 -61
- package/scripts/install-cursor-rules.cjs +236 -0
- package/src/__tests__/helpers/test-providers.tsx +1 -1
- package/src/__tests__/helpers/test-utils.tsx +1 -1
- package/src/__tests__/rls-policies.test.ts +3 -1
- package/src/components/Badge/Badge.tsx +2 -4
- package/src/components/Button/Button.tsx +5 -4
- package/src/components/Calendar/Calendar.tsx +1 -1
- package/src/components/DataTable/DataTable.test.tsx +57 -93
- package/src/components/DataTable/DataTable.tsx +2 -2
- package/src/components/DataTable/__tests__/DataTable.default-state.test.tsx +172 -45
- package/src/components/DataTable/__tests__/DataTable.grouping-aggregation.test.tsx +121 -28
- package/src/components/DataTable/__tests__/DataTableCore.test-setup.ts +9 -8
- package/src/components/DataTable/__tests__/DataTableCore.test.tsx +20 -52
- package/src/components/DataTable/__tests__/a11y.basic.test.tsx +170 -34
- package/src/components/DataTable/__tests__/keyboard.test.tsx +75 -12
- package/src/components/DataTable/__tests__/pagination.modes.test.tsx +88 -16
- package/src/components/DataTable/__tests__/ssr.strict-mode.test.tsx +12 -12
- package/src/components/DataTable/components/AccessDeniedPage.tsx +1 -1
- package/src/components/DataTable/components/BulkOperationsDropdown.tsx +1 -1
- package/src/components/DataTable/components/DataTableCore.tsx +4 -7
- package/src/components/DataTable/components/DataTableModals.tsx +1 -1
- package/src/components/DataTable/components/EditableRow.tsx +1 -1
- package/src/components/DataTable/components/UnifiedTableBody.tsx +86 -17
- package/src/components/DataTable/components/__tests__/DataTableModals.test.tsx +23 -23
- package/src/components/DataTable/components/__tests__/EditableRow.test.tsx +11 -11
- package/src/components/DataTable/components/__tests__/ExpandButton.test.tsx +36 -36
- package/src/components/DataTable/components/__tests__/GroupHeader.test.tsx +27 -27
- package/src/components/DataTable/components/__tests__/ImportModal.test.tsx +39 -39
- package/src/components/DataTable/components/__tests__/UnifiedTableBody.test.tsx +33 -33
- package/src/components/DataTable/components/__tests__/ViewRowModal.test.tsx +29 -29
- package/src/components/DataTable/hooks/useColumnReordering.ts +2 -2
- package/src/components/DataTable/hooks/useDataTablePermissions.ts +75 -10
- package/src/components/DataTable/hooks/useKeyboardNavigation.ts +2 -2
- package/src/components/DatePickerWithTimezone/DatePickerWithTimezone.test.tsx +8 -14
- package/src/components/Dialog/Dialog.tsx +6 -5
- package/src/components/ErrorBoundary/ErrorBoundary.tsx +1 -1
- package/src/components/EventSelector/EventSelector.tsx +1 -1
- package/src/components/FileDisplay/FileDisplay.test.tsx +4 -3
- package/src/components/FileDisplay/FileDisplay.tsx +16 -4
- package/src/components/Footer/Footer.tsx +1 -1
- package/src/components/Form/Form.test.tsx +36 -15
- package/src/components/Form/Form.tsx +30 -26
- package/src/components/Header/Header.tsx +1 -1
- package/src/components/InactivityWarningModal/InactivityWarningModal.test.tsx +40 -40
- package/src/components/InactivityWarningModal/InactivityWarningModal.tsx +1 -1
- package/src/components/Input/Input.tsx +28 -30
- package/src/components/Label/Label.tsx +1 -1
- package/src/components/LoadingSpinner/LoadingSpinner.tsx +1 -1
- package/src/components/LoginForm/LoginForm.test.tsx +42 -42
- package/src/components/LoginForm/LoginForm.tsx +8 -8
- package/src/components/NavigationMenu/NavigationMenu.test.tsx +6 -4
- package/src/components/NavigationMenu/NavigationMenu.tsx +2 -11
- package/src/components/OrganisationSelector/OrganisationSelector.tsx +0 -1
- package/src/components/PaceAppLayout/PaceAppLayout.performance.test.tsx +1 -1
- package/src/components/PaceAppLayout/PaceAppLayout.test.tsx +75 -52
- package/src/components/PaceAppLayout/PaceAppLayout.tsx +98 -69
- package/src/components/PaceAppLayout/README.md +1 -1
- package/src/components/PaceLoginPage/PaceLoginPage.tsx +1 -8
- package/src/components/PasswordChange/PasswordChangeForm.test.tsx +33 -33
- package/src/components/PasswordChange/PasswordChangeForm.tsx +1 -1
- package/src/components/Progress/Progress.tsx +1 -1
- package/src/components/ProtectedRoute/ProtectedRoute.test.tsx +5 -9
- package/src/components/ProtectedRoute/ProtectedRoute.tsx +0 -1
- package/src/components/PublicLayout/PublicPageLayout.tsx +1 -1
- package/src/components/PublicLayout/PublicPageProvider.tsx +0 -1
- package/src/components/Select/Select.tsx +33 -22
- package/src/components/SessionRestorationLoader/SessionRestorationLoader.tsx +1 -1
- package/src/components/Table/Table.tsx +1 -1
- package/src/components/Textarea/Textarea.tsx +27 -29
- package/src/components/Toast/Toast.tsx +1 -1
- package/src/components/Tooltip/Tooltip.tsx +1 -1
- package/src/components/UserMenu/UserMenu.tsx +1 -1
- package/src/hooks/__tests__/hooks.integration.test.tsx +80 -55
- package/src/hooks/__tests__/useSecureDataAccess.unit.test.tsx +14 -7
- package/src/hooks/__tests__/useStorage.unit.test.ts +36 -36
- package/src/hooks/public/usePublicEvent.ts +1 -1
- package/src/hooks/public/usePublicEventLogo.ts +1 -1
- package/src/hooks/public/usePublicRouteParams.ts +1 -1
- package/src/hooks/services/useAuthService.ts +21 -3
- package/src/hooks/services/useEventService.ts +21 -3
- package/src/hooks/services/useInactivityService.ts +21 -3
- package/src/hooks/services/useOrganisationService.ts +21 -3
- package/src/hooks/useDataTableState.ts +8 -18
- package/src/hooks/useFileDisplay.ts +10 -17
- package/src/hooks/useFocusManagement.ts +2 -2
- package/src/hooks/useFocusTrap.ts +4 -4
- package/src/hooks/useFormDialog.ts +8 -7
- package/src/hooks/useInactivityTracker.ts +1 -1
- package/src/hooks/usePermissionCache.ts +1 -1
- package/src/hooks/useSecureDataAccess.test.ts +16 -9
- package/src/hooks/useSecureDataAccess.ts +22 -6
- package/src/hooks/useToast.ts +2 -2
- package/src/providers/__tests__/OrganisationProvider.test.tsx +57 -13
- package/src/providers/__tests__/ProviderLifecycle.test.tsx +21 -6
- package/src/providers/__tests__/UnifiedAuthProvider.test.tsx +10 -10
- package/src/providers/services/EventServiceProvider.tsx +0 -8
- package/src/providers/services/UnifiedAuthProvider.tsx +196 -46
- package/src/providers/services/__tests__/AuthServiceProvider.integration.test.tsx +13 -3
- package/src/rbac/__tests__/adapters.comprehensive.test.tsx +34 -40
- package/src/rbac/__tests__/isSuperAdmin.real.test.ts +82 -0
- package/src/rbac/adapters.tsx +3 -22
- package/src/rbac/api.test.ts +2 -2
- package/src/rbac/api.ts +7 -1
- package/src/rbac/components/EnhancedNavigationMenu.tsx +3 -16
- package/src/rbac/components/NavigationGuard.tsx +2 -11
- package/src/rbac/components/NavigationProvider.tsx +1 -2
- package/src/rbac/components/PagePermissionGuard.tsx +1 -1
- package/src/rbac/components/PagePermissionProvider.tsx +1 -1
- package/src/rbac/components/PermissionEnforcer.tsx +46 -13
- package/src/rbac/components/RoleBasedRouter.tsx +1 -1
- package/src/rbac/components/SecureDataProvider.tsx +1 -2
- package/src/rbac/components/__tests__/EnhancedNavigationMenu.test.tsx +7 -43
- package/src/rbac/components/__tests__/NavigationGuard.test.tsx +4 -11
- package/src/rbac/components/__tests__/NavigationProvider.test.tsx +3 -3
- package/src/rbac/components/__tests__/SecureDataProvider.fixed.test.tsx +1 -1
- package/src/rbac/components/__tests__/SecureDataProvider.test.tsx +1 -1
- package/src/rbac/engine.ts +14 -2
- package/src/rbac/hooks/index.ts +0 -3
- package/src/rbac/hooks/usePermissions.ts +51 -11
- package/src/rbac/hooks/useRBAC.ts +3 -13
- package/src/rbac/hooks/useResolvedScope.test.ts +75 -54
- package/src/rbac/hooks/useResolvedScope.ts +58 -33
- package/src/rbac/hooks/useSecureSupabase.ts +4 -9
- package/src/rbac/secureClient.ts +43 -0
- package/src/services/EventService.ts +4 -57
- package/src/services/InactivityService.ts +127 -34
- package/src/services/OrganisationService.ts +68 -10
- package/src/utils/security/secureDataAccess.test.ts +31 -20
- package/src/utils/security/secureDataAccess.ts +4 -3
- package/dist/chunk-6C4YBBJM.js.map +0 -1
- package/dist/chunk-6LTQQAT6.js.map +0 -1
- package/dist/chunk-6TQDD426.js.map +0 -1
- package/dist/chunk-LOMZXPSN.js.map +0 -1
- package/dist/chunk-OETXORNB.js.map +0 -1
- package/dist/chunk-ULHIJK66.js.map +0 -1
- package/dist/chunk-VKB2CO4Z.js.map +0 -1
- package/dist/chunk-VRGWKHDB.js.map +0 -1
- package/dist/chunk-XNYQOL3Z.js.map +0 -1
- package/dist/chunk-XYXSXPUK.js.map +0 -1
- package/scripts/check-pace-core-compliance.js +0 -512
- package/src/rbac/hooks/useSuperAdminBypass.ts +0 -126
- package/src/utils/context/superAdminOverride.ts +0 -58
- /package/dist/{DataTable-WKRZD47S.js.map → DataTable-DQ7RSOHE.js.map} +0 -0
- /package/dist/{UnifiedAuthProvider-FTSG5XH7.js.map → UnifiedAuthProvider-ATAP5UTR.js.map} +0 -0
- /package/dist/{api-IHKALJZD.js.map → api-N774RPUA.js.map} +0 -0
- /package/dist/{chunk-QWWZ5CAQ.js.map → chunk-LXQLPRQ2.js.map} +0 -0
- /package/examples/{rbac → RBAC}/CompleteRBACExample.tsx +0 -0
- /package/examples/{rbac → RBAC}/EventBasedApp.tsx +0 -0
- /package/examples/{rbac → RBAC}/PermissionExample.tsx +0 -0
- /package/examples/{rbac → RBAC}/index.ts +0 -0
|
@@ -38,7 +38,7 @@ const mockSupabase = {
|
|
|
38
38
|
const mockFile = new File(['test content'], 'test.txt', { type: 'text/plain' });
|
|
39
39
|
|
|
40
40
|
describe('useStorage Hook', () => {
|
|
41
|
-
const
|
|
41
|
+
const baseProps = {
|
|
42
42
|
supabase: mockSupabase,
|
|
43
43
|
appName: 'test-app',
|
|
44
44
|
orgId: 'test-org',
|
|
@@ -46,7 +46,7 @@ describe('useStorage Hook', () => {
|
|
|
46
46
|
|
|
47
47
|
describe('Initial State', () => {
|
|
48
48
|
it('should initialize with correct default values', () => {
|
|
49
|
-
const { result } = renderHook(() => useStorage(
|
|
49
|
+
const { result } = renderHook(() => useStorage(baseProps));
|
|
50
50
|
|
|
51
51
|
expect(result.current.isUploading).toBe(false);
|
|
52
52
|
expect(result.current.uploadError).toBe(null);
|
|
@@ -58,7 +58,7 @@ describe('useStorage Hook', () => {
|
|
|
58
58
|
});
|
|
59
59
|
|
|
60
60
|
it('should provide all required functions', () => {
|
|
61
|
-
const { result } = renderHook(() => useStorage(
|
|
61
|
+
const { result } = renderHook(() => useStorage(baseProps));
|
|
62
62
|
|
|
63
63
|
expect(typeof result.current.uploadFile).toBe('function');
|
|
64
64
|
expect(typeof result.current.getPublicUrl).toBe('function');
|
|
@@ -106,7 +106,7 @@ describe('useStorage Hook', () => {
|
|
|
106
106
|
vi.mocked(uploadFile).mockResolvedValue(mockUploadResult);
|
|
107
107
|
vi.mocked(listFiles).mockResolvedValue(mockListResult);
|
|
108
108
|
|
|
109
|
-
const { result } = renderHook(() => useStorage(
|
|
109
|
+
const { result } = renderHook(() => useStorage(baseProps));
|
|
110
110
|
|
|
111
111
|
let uploadResult: any;
|
|
112
112
|
await act(async () => {
|
|
@@ -132,7 +132,7 @@ describe('useStorage Hook', () => {
|
|
|
132
132
|
|
|
133
133
|
vi.mocked(uploadFile).mockResolvedValue(mockUploadResult);
|
|
134
134
|
|
|
135
|
-
const { result } = renderHook(() => useStorage(
|
|
135
|
+
const { result } = renderHook(() => useStorage(baseProps));
|
|
136
136
|
|
|
137
137
|
let uploadResult: any;
|
|
138
138
|
await act(async () => {
|
|
@@ -153,7 +153,7 @@ describe('useStorage Hook', () => {
|
|
|
153
153
|
vi.mocked(uploadFile).mockResolvedValue(mockUploadResult);
|
|
154
154
|
vi.mocked(listFiles).mockResolvedValue({ files: [], totalCount: 0, hasMore: false });
|
|
155
155
|
|
|
156
|
-
const { result } = renderHook(() => useStorage(
|
|
156
|
+
const { result } = renderHook(() => useStorage(baseProps));
|
|
157
157
|
|
|
158
158
|
const customOptions = {
|
|
159
159
|
isPublic: true,
|
|
@@ -179,7 +179,7 @@ describe('useStorage Hook', () => {
|
|
|
179
179
|
it('should handle upload exception', async () => {
|
|
180
180
|
vi.mocked(uploadFile).mockRejectedValue(new Error('Network error'));
|
|
181
181
|
|
|
182
|
-
const { result } = renderHook(() => useStorage(
|
|
182
|
+
const { result } = renderHook(() => useStorage(baseProps));
|
|
183
183
|
|
|
184
184
|
let uploadResult: any;
|
|
185
185
|
await act(async () => {
|
|
@@ -197,7 +197,7 @@ describe('useStorage Hook', () => {
|
|
|
197
197
|
it('should handle upload exception with non-Error object', async () => {
|
|
198
198
|
vi.mocked(uploadFile).mockRejectedValue('String error');
|
|
199
199
|
|
|
200
|
-
const { result } = renderHook(() => useStorage(
|
|
200
|
+
const { result } = renderHook(() => useStorage(baseProps));
|
|
201
201
|
|
|
202
202
|
let uploadResult: any;
|
|
203
203
|
await act(async () => {
|
|
@@ -217,7 +217,7 @@ describe('useStorage Hook', () => {
|
|
|
217
217
|
const mockUrl = 'https://example.com/public/test-file.txt';
|
|
218
218
|
vi.mocked(getPublicUrl).mockReturnValue(mockUrl);
|
|
219
219
|
|
|
220
|
-
const { result } = renderHook(() => useStorage(
|
|
220
|
+
const { result } = renderHook(() => useStorage(baseProps));
|
|
221
221
|
|
|
222
222
|
const url = result.current.getPublicUrl('test-org/public/test-file.txt');
|
|
223
223
|
|
|
@@ -229,7 +229,7 @@ describe('useStorage Hook', () => {
|
|
|
229
229
|
const mockUrl = 'https://example.com/public/test-file.txt';
|
|
230
230
|
vi.mocked(getPublicUrl).mockReturnValue(mockUrl);
|
|
231
231
|
|
|
232
|
-
const { result } = renderHook(() => useStorage(
|
|
232
|
+
const { result } = renderHook(() => useStorage(baseProps));
|
|
233
233
|
|
|
234
234
|
const url = result.current.getFileUrl('test-org/public/test-file.txt');
|
|
235
235
|
|
|
@@ -245,7 +245,7 @@ describe('useStorage Hook', () => {
|
|
|
245
245
|
|
|
246
246
|
vi.mocked(getSignedUrl).mockResolvedValue(mockSignedUrl);
|
|
247
247
|
|
|
248
|
-
const { result } = renderHook(() => useStorage(
|
|
248
|
+
const { result } = renderHook(() => useStorage(baseProps));
|
|
249
249
|
|
|
250
250
|
let signedUrl: string | null = null;
|
|
251
251
|
await act(async () => {
|
|
@@ -263,7 +263,7 @@ describe('useStorage Hook', () => {
|
|
|
263
263
|
it('should handle signed URL failure', async () => {
|
|
264
264
|
vi.mocked(getSignedUrl).mockRejectedValue(new Error('Signing failed'));
|
|
265
265
|
|
|
266
|
-
const { result } = renderHook(() => useStorage(
|
|
266
|
+
const { result } = renderHook(() => useStorage(baseProps));
|
|
267
267
|
|
|
268
268
|
let signedUrl: string | null = null;
|
|
269
269
|
await act(async () => {
|
|
@@ -276,7 +276,7 @@ describe('useStorage Hook', () => {
|
|
|
276
276
|
it('should handle signed URL with null result', async () => {
|
|
277
277
|
vi.mocked(getSignedUrl).mockResolvedValue(null);
|
|
278
278
|
|
|
279
|
-
const { result } = renderHook(() => useStorage(
|
|
279
|
+
const { result } = renderHook(() => useStorage(baseProps));
|
|
280
280
|
|
|
281
281
|
let signedUrl: string | null = null;
|
|
282
282
|
await act(async () => {
|
|
@@ -295,7 +295,7 @@ describe('useStorage Hook', () => {
|
|
|
295
295
|
vi.mocked(deleteFile).mockResolvedValue(mockDeleteResult);
|
|
296
296
|
vi.mocked(listFiles).mockResolvedValue(mockListResult);
|
|
297
297
|
|
|
298
|
-
const { result } = renderHook(() => useStorage(
|
|
298
|
+
const { result } = renderHook(() => useStorage(baseProps));
|
|
299
299
|
|
|
300
300
|
let deleteResult: any;
|
|
301
301
|
await act(async () => {
|
|
@@ -311,7 +311,7 @@ describe('useStorage Hook', () => {
|
|
|
311
311
|
|
|
312
312
|
vi.mocked(deleteFile).mockResolvedValue(mockDeleteResult);
|
|
313
313
|
|
|
314
|
-
const { result } = renderHook(() => useStorage(
|
|
314
|
+
const { result } = renderHook(() => useStorage(baseProps));
|
|
315
315
|
|
|
316
316
|
let deleteResult: any;
|
|
317
317
|
await act(async () => {
|
|
@@ -324,7 +324,7 @@ describe('useStorage Hook', () => {
|
|
|
324
324
|
it('should handle delete file exception', async () => {
|
|
325
325
|
vi.mocked(deleteFile).mockRejectedValue(new Error('Network error'));
|
|
326
326
|
|
|
327
|
-
const { result } = renderHook(() => useStorage(
|
|
327
|
+
const { result } = renderHook(() => useStorage(baseProps));
|
|
328
328
|
|
|
329
329
|
let deleteResult: any;
|
|
330
330
|
await act(async () => {
|
|
@@ -344,7 +344,7 @@ describe('useStorage Hook', () => {
|
|
|
344
344
|
vi.mocked(archiveFile).mockResolvedValue(mockArchiveResult);
|
|
345
345
|
vi.mocked(listFiles).mockResolvedValue(mockListResult);
|
|
346
346
|
|
|
347
|
-
const { result } = renderHook(() => useStorage(
|
|
347
|
+
const { result } = renderHook(() => useStorage(baseProps));
|
|
348
348
|
|
|
349
349
|
let archiveResult: any;
|
|
350
350
|
await act(async () => {
|
|
@@ -363,7 +363,7 @@ describe('useStorage Hook', () => {
|
|
|
363
363
|
|
|
364
364
|
vi.mocked(archiveFile).mockResolvedValue(mockArchiveResult);
|
|
365
365
|
|
|
366
|
-
const { result } = renderHook(() => useStorage(
|
|
366
|
+
const { result } = renderHook(() => useStorage(baseProps));
|
|
367
367
|
|
|
368
368
|
let archiveResult: any;
|
|
369
369
|
await act(async () => {
|
|
@@ -376,7 +376,7 @@ describe('useStorage Hook', () => {
|
|
|
376
376
|
it('should handle archive file exception', async () => {
|
|
377
377
|
vi.mocked(archiveFile).mockRejectedValue(new Error('Network error'));
|
|
378
378
|
|
|
379
|
-
const { result } = renderHook(() => useStorage(
|
|
379
|
+
const { result } = renderHook(() => useStorage(baseProps));
|
|
380
380
|
|
|
381
381
|
let archiveResult: any;
|
|
382
382
|
await act(async () => {
|
|
@@ -417,7 +417,7 @@ describe('useStorage Hook', () => {
|
|
|
417
417
|
|
|
418
418
|
vi.mocked(listFiles).mockResolvedValue(mockListResult);
|
|
419
419
|
|
|
420
|
-
const { result } = renderHook(() => useStorage(
|
|
420
|
+
const { result } = renderHook(() => useStorage(baseProps));
|
|
421
421
|
|
|
422
422
|
let listResult: any;
|
|
423
423
|
await act(async () => {
|
|
@@ -439,7 +439,7 @@ describe('useStorage Hook', () => {
|
|
|
439
439
|
|
|
440
440
|
vi.mocked(listFiles).mockResolvedValue(mockListResult);
|
|
441
441
|
|
|
442
|
-
const { result } = renderHook(() => useStorage(
|
|
442
|
+
const { result } = renderHook(() => useStorage(baseProps));
|
|
443
443
|
|
|
444
444
|
const customOptions = {
|
|
445
445
|
pathPrefix: 'documents',
|
|
@@ -465,7 +465,7 @@ describe('useStorage Hook', () => {
|
|
|
465
465
|
it('should handle list files failure', async () => {
|
|
466
466
|
vi.mocked(listFiles).mockRejectedValue(new Error('List failed'));
|
|
467
467
|
|
|
468
|
-
const { result } = renderHook(() => useStorage(
|
|
468
|
+
const { result } = renderHook(() => useStorage(baseProps));
|
|
469
469
|
|
|
470
470
|
let listResult: any;
|
|
471
471
|
await act(async () => {
|
|
@@ -481,7 +481,7 @@ describe('useStorage Hook', () => {
|
|
|
481
481
|
it('should handle list files exception with non-Error object', async () => {
|
|
482
482
|
vi.mocked(listFiles).mockRejectedValue('String error');
|
|
483
483
|
|
|
484
|
-
const { result } = renderHook(() => useStorage(
|
|
484
|
+
const { result } = renderHook(() => useStorage(baseProps));
|
|
485
485
|
|
|
486
486
|
let listResult: any;
|
|
487
487
|
await act(async () => {
|
|
@@ -497,7 +497,7 @@ describe('useStorage Hook', () => {
|
|
|
497
497
|
|
|
498
498
|
vi.mocked(listFiles).mockResolvedValue(mockListResult);
|
|
499
499
|
|
|
500
|
-
const { result } = renderHook(() => useStorage(
|
|
500
|
+
const { result } = renderHook(() => useStorage(baseProps));
|
|
501
501
|
|
|
502
502
|
await act(async () => {
|
|
503
503
|
await result.current.refreshFiles();
|
|
@@ -519,7 +519,7 @@ describe('useStorage Hook', () => {
|
|
|
519
519
|
|
|
520
520
|
vi.mocked(uploadFile).mockReturnValue(uploadPromise);
|
|
521
521
|
|
|
522
|
-
const { result } = renderHook(() => useStorage(
|
|
522
|
+
const { result } = renderHook(() => useStorage(baseProps));
|
|
523
523
|
|
|
524
524
|
expect(result.current.isUploading).toBe(false);
|
|
525
525
|
|
|
@@ -545,7 +545,7 @@ describe('useStorage Hook', () => {
|
|
|
545
545
|
|
|
546
546
|
vi.mocked(listFiles).mockReturnValue(listPromise);
|
|
547
547
|
|
|
548
|
-
const { result } = renderHook(() => useStorage(
|
|
548
|
+
const { result } = renderHook(() => useStorage(baseProps));
|
|
549
549
|
|
|
550
550
|
expect(result.current.isListing).toBe(false);
|
|
551
551
|
|
|
@@ -566,13 +566,13 @@ describe('useStorage Hook', () => {
|
|
|
566
566
|
|
|
567
567
|
describe('Aliases', () => {
|
|
568
568
|
it('should provide isLoading alias for isListing', () => {
|
|
569
|
-
const { result } = renderHook(() => useStorage(
|
|
569
|
+
const { result } = renderHook(() => useStorage(baseProps));
|
|
570
570
|
|
|
571
571
|
expect(result.current.isLoading).toBe(result.current.isListing);
|
|
572
572
|
});
|
|
573
573
|
|
|
574
574
|
it('should provide error alias for listError', () => {
|
|
575
|
-
const { result } = renderHook(() => useStorage(
|
|
575
|
+
const { result } = renderHook(() => useStorage(baseProps));
|
|
576
576
|
|
|
577
577
|
expect(result.current.error).toBe(result.current.listError);
|
|
578
578
|
});
|
|
@@ -580,7 +580,7 @@ describe('useStorage Hook', () => {
|
|
|
580
580
|
});
|
|
581
581
|
|
|
582
582
|
describe('useFileUpload Hook', () => {
|
|
583
|
-
const
|
|
583
|
+
const baseProps = {
|
|
584
584
|
supabase: mockSupabase,
|
|
585
585
|
appName: 'test-app',
|
|
586
586
|
orgId: 'test-org',
|
|
@@ -588,7 +588,7 @@ describe('useFileUpload Hook', () => {
|
|
|
588
588
|
|
|
589
589
|
describe('Initial State', () => {
|
|
590
590
|
it('should initialize with correct default values', () => {
|
|
591
|
-
const { result } = renderHook(() => useFileUpload(
|
|
591
|
+
const { result } = renderHook(() => useFileUpload(baseProps));
|
|
592
592
|
|
|
593
593
|
expect(result.current.uploadProgress).toBe(0);
|
|
594
594
|
expect(result.current.isUploading).toBe(false);
|
|
@@ -605,7 +605,7 @@ describe('useFileUpload Hook', () => {
|
|
|
605
605
|
|
|
606
606
|
vi.mocked(uploadFile).mockResolvedValue(mockUploadResult);
|
|
607
607
|
|
|
608
|
-
const { result } = renderHook(() => useFileUpload(
|
|
608
|
+
const { result } = renderHook(() => useFileUpload(baseProps));
|
|
609
609
|
|
|
610
610
|
let uploadResult: any;
|
|
611
611
|
await act(async () => {
|
|
@@ -628,7 +628,7 @@ describe('useFileUpload Hook', () => {
|
|
|
628
628
|
|
|
629
629
|
vi.mocked(uploadFile).mockReturnValue(uploadPromise);
|
|
630
630
|
|
|
631
|
-
const { result } = renderHook(() => useFileUpload(
|
|
631
|
+
const { result } = renderHook(() => useFileUpload(baseProps));
|
|
632
632
|
|
|
633
633
|
act(() => {
|
|
634
634
|
result.current.uploadWithProgress(mockFile);
|
|
@@ -670,7 +670,7 @@ describe('useFileUpload Hook', () => {
|
|
|
670
670
|
|
|
671
671
|
vi.mocked(uploadFile).mockResolvedValue(mockUploadResult);
|
|
672
672
|
|
|
673
|
-
const { result } = renderHook(() => useFileUpload(
|
|
673
|
+
const { result } = renderHook(() => useFileUpload(baseProps));
|
|
674
674
|
|
|
675
675
|
let uploadResult: any;
|
|
676
676
|
await act(async () => {
|
|
@@ -686,7 +686,7 @@ describe('useFileUpload Hook', () => {
|
|
|
686
686
|
it('should handle upload exception', async () => {
|
|
687
687
|
vi.mocked(uploadFile).mockRejectedValue(new Error('Network error'));
|
|
688
688
|
|
|
689
|
-
const { result } = renderHook(() => useFileUpload(
|
|
689
|
+
const { result } = renderHook(() => useFileUpload(baseProps));
|
|
690
690
|
|
|
691
691
|
let uploadResult: any;
|
|
692
692
|
await act(async () => {
|
|
@@ -707,7 +707,7 @@ describe('useFileUpload Hook', () => {
|
|
|
707
707
|
|
|
708
708
|
vi.mocked(uploadFile).mockResolvedValue(mockUploadResult);
|
|
709
709
|
|
|
710
|
-
const { result } = renderHook(() => useFileUpload(
|
|
710
|
+
const { result } = renderHook(() => useFileUpload(baseProps));
|
|
711
711
|
|
|
712
712
|
await act(async () => {
|
|
713
713
|
await result.current.uploadWithProgress(mockFile);
|
|
@@ -729,7 +729,7 @@ describe('useFileUpload Hook', () => {
|
|
|
729
729
|
|
|
730
730
|
vi.mocked(uploadFile).mockResolvedValue(mockUploadResult);
|
|
731
731
|
|
|
732
|
-
const { result } = renderHook(() => useFileUpload(
|
|
732
|
+
const { result } = renderHook(() => useFileUpload(baseProps));
|
|
733
733
|
|
|
734
734
|
const customOptions = {
|
|
735
735
|
isPublic: true,
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* Provides authentication service with reactive state updates.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { useContext, useReducer, useEffect } from 'react';
|
|
11
|
+
import { useContext, useReducer, useEffect, useRef } from 'react';
|
|
12
12
|
import { AuthServiceContext } from '../../providers/services/AuthServiceProvider';
|
|
13
13
|
import { AuthService } from '../../services/AuthService';
|
|
14
14
|
|
|
@@ -19,11 +19,29 @@ export function useAuthService(): AuthService {
|
|
|
19
19
|
throw new Error('useAuthService must be used within AuthServiceProvider');
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
// Subscribe to service state changes
|
|
22
|
+
// Subscribe to service state changes with debouncing to prevent excessive re-renders
|
|
23
23
|
const [, forceUpdate] = useReducer(x => x + 1, 0);
|
|
24
|
+
const timeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
24
25
|
|
|
25
26
|
useEffect(() => {
|
|
26
|
-
|
|
27
|
+
const debouncedUpdate = () => {
|
|
28
|
+
if (timeoutRef.current) {
|
|
29
|
+
clearTimeout(timeoutRef.current);
|
|
30
|
+
}
|
|
31
|
+
timeoutRef.current = setTimeout(() => {
|
|
32
|
+
forceUpdate();
|
|
33
|
+
timeoutRef.current = null;
|
|
34
|
+
}, 50); // 50ms debounce to batch rapid updates
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const unsubscribe = context.authService.subscribe(debouncedUpdate);
|
|
38
|
+
|
|
39
|
+
return () => {
|
|
40
|
+
unsubscribe();
|
|
41
|
+
if (timeoutRef.current) {
|
|
42
|
+
clearTimeout(timeoutRef.current);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
27
45
|
}, [context.authService]);
|
|
28
46
|
|
|
29
47
|
return context.authService;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* Provides event service with reactive state updates.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { useContext, useReducer, useEffect } from 'react';
|
|
11
|
+
import { useContext, useReducer, useEffect, useRef } from 'react';
|
|
12
12
|
import { EventServiceContext } from '../../providers/services/EventServiceProvider';
|
|
13
13
|
import { EventService } from '../../services/EventService';
|
|
14
14
|
|
|
@@ -19,11 +19,29 @@ export function useEventService(): EventService {
|
|
|
19
19
|
throw new Error('useEventService must be used within EventServiceProvider');
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
// Subscribe to service state changes
|
|
22
|
+
// Subscribe to service state changes with debouncing to prevent excessive re-renders
|
|
23
23
|
const [, forceUpdate] = useReducer(x => x + 1, 0);
|
|
24
|
+
const timeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
24
25
|
|
|
25
26
|
useEffect(() => {
|
|
26
|
-
|
|
27
|
+
const debouncedUpdate = () => {
|
|
28
|
+
if (timeoutRef.current) {
|
|
29
|
+
clearTimeout(timeoutRef.current);
|
|
30
|
+
}
|
|
31
|
+
timeoutRef.current = setTimeout(() => {
|
|
32
|
+
forceUpdate();
|
|
33
|
+
timeoutRef.current = null;
|
|
34
|
+
}, 50); // 50ms debounce to batch rapid updates
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const unsubscribe = context.eventService.subscribe(debouncedUpdate);
|
|
38
|
+
|
|
39
|
+
return () => {
|
|
40
|
+
unsubscribe();
|
|
41
|
+
if (timeoutRef.current) {
|
|
42
|
+
clearTimeout(timeoutRef.current);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
27
45
|
}, [context.eventService]);
|
|
28
46
|
|
|
29
47
|
return context.eventService;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* Provides inactivity service with reactive state updates.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { useContext, useReducer, useEffect } from 'react';
|
|
11
|
+
import { useContext, useReducer, useEffect, useRef } from 'react';
|
|
12
12
|
import { InactivityServiceContext } from '../../providers/services/InactivityServiceProvider';
|
|
13
13
|
import { InactivityService } from '../../services/InactivityService';
|
|
14
14
|
|
|
@@ -19,11 +19,29 @@ export function useInactivityService(): InactivityService {
|
|
|
19
19
|
throw new Error('useInactivityService must be used within InactivityServiceProvider');
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
// Subscribe to service state changes
|
|
22
|
+
// Subscribe to service state changes with debouncing to prevent excessive re-renders
|
|
23
23
|
const [, forceUpdate] = useReducer(x => x + 1, 0);
|
|
24
|
+
const timeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
24
25
|
|
|
25
26
|
useEffect(() => {
|
|
26
|
-
|
|
27
|
+
const debouncedUpdate = () => {
|
|
28
|
+
if (timeoutRef.current) {
|
|
29
|
+
clearTimeout(timeoutRef.current);
|
|
30
|
+
}
|
|
31
|
+
timeoutRef.current = setTimeout(() => {
|
|
32
|
+
forceUpdate();
|
|
33
|
+
timeoutRef.current = null;
|
|
34
|
+
}, 50); // 50ms debounce to batch rapid updates
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const unsubscribe = context.inactivityService.subscribe(debouncedUpdate);
|
|
38
|
+
|
|
39
|
+
return () => {
|
|
40
|
+
unsubscribe();
|
|
41
|
+
if (timeoutRef.current) {
|
|
42
|
+
clearTimeout(timeoutRef.current);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
27
45
|
}, [context.inactivityService]);
|
|
28
46
|
|
|
29
47
|
return context.inactivityService;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* Provides organisation service with reactive state updates.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { useContext, useReducer, useEffect } from 'react';
|
|
11
|
+
import { useContext, useReducer, useEffect, useRef } from 'react';
|
|
12
12
|
import { OrganisationServiceContext } from '../../providers/services/OrganisationServiceProvider';
|
|
13
13
|
import { OrganisationService } from '../../services/OrganisationService';
|
|
14
14
|
|
|
@@ -19,11 +19,29 @@ export function useOrganisationService(): OrganisationService {
|
|
|
19
19
|
throw new Error('useOrganisationService must be used within OrganisationServiceProvider');
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
// Subscribe to service state changes
|
|
22
|
+
// Subscribe to service state changes with debouncing to prevent excessive re-renders
|
|
23
23
|
const [, forceUpdate] = useReducer(x => x + 1, 0);
|
|
24
|
+
const timeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
24
25
|
|
|
25
26
|
useEffect(() => {
|
|
26
|
-
|
|
27
|
+
const debouncedUpdate = () => {
|
|
28
|
+
if (timeoutRef.current) {
|
|
29
|
+
clearTimeout(timeoutRef.current);
|
|
30
|
+
}
|
|
31
|
+
timeoutRef.current = setTimeout(() => {
|
|
32
|
+
forceUpdate();
|
|
33
|
+
timeoutRef.current = null;
|
|
34
|
+
}, 50); // 50ms debounce to batch rapid updates
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const unsubscribe = context.organisationService.subscribe(debouncedUpdate);
|
|
38
|
+
|
|
39
|
+
return () => {
|
|
40
|
+
unsubscribe();
|
|
41
|
+
if (timeoutRef.current) {
|
|
42
|
+
clearTimeout(timeoutRef.current);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
27
45
|
}, [context.organisationService]);
|
|
28
46
|
|
|
29
47
|
return context.organisationService;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @description Hook for managing DataTable state
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { useState, useCallback
|
|
6
|
+
import { useState, useCallback } from 'react';
|
|
7
7
|
import type { SortingState, ColumnFiltersState, ExpandedState } from '@tanstack/react-table';
|
|
8
8
|
|
|
9
9
|
export interface DataTableState {
|
|
@@ -63,24 +63,14 @@ export function useDataTableState(options: UseDataTableStateOptions) {
|
|
|
63
63
|
setSelectedRows([]);
|
|
64
64
|
}, [initialPageSize]);
|
|
65
65
|
|
|
66
|
-
// Computed values
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
return data.slice(start, end);
|
|
71
|
-
}, [data, pageIndex, pageSize]);
|
|
66
|
+
// Computed values - React Compiler handles memoization automatically
|
|
67
|
+
const start = pageIndex * pageSize;
|
|
68
|
+
const end = start + pageSize;
|
|
69
|
+
const paginatedData = data.slice(start, end);
|
|
72
70
|
|
|
73
|
-
const totalPages =
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const hasNextPage = useMemo(() => {
|
|
78
|
-
return pageIndex < totalPages - 1;
|
|
79
|
-
}, [pageIndex, totalPages]);
|
|
80
|
-
|
|
81
|
-
const hasPreviousPage = useMemo(() => {
|
|
82
|
-
return pageIndex > 0;
|
|
83
|
-
}, [pageIndex]);
|
|
71
|
+
const totalPages = Math.ceil(data.length / pageSize);
|
|
72
|
+
const hasNextPage = pageIndex < totalPages - 1;
|
|
73
|
+
const hasPreviousPage = pageIndex > 0;
|
|
84
74
|
|
|
85
75
|
return {
|
|
86
76
|
state: {
|
|
@@ -391,12 +391,7 @@ export function useFileDisplay(
|
|
|
391
391
|
// Category is stored in file_metadata JSONB field, not a direct column
|
|
392
392
|
if (category) {
|
|
393
393
|
// Single file mode - get files by category using RPC
|
|
394
|
-
|
|
395
|
-
table_name,
|
|
396
|
-
record_id,
|
|
397
|
-
category,
|
|
398
|
-
organisation_id
|
|
399
|
-
});
|
|
394
|
+
// Removed verbose debug log - only log on errors
|
|
400
395
|
files = await service.getFilesByCategory(
|
|
401
396
|
table_name,
|
|
402
397
|
record_id,
|
|
@@ -510,21 +505,13 @@ export function useFileDisplay(
|
|
|
510
505
|
if (category && files.length > 0) {
|
|
511
506
|
// Single file mode - get first file
|
|
512
507
|
const firstFile = files[0];
|
|
513
|
-
|
|
514
|
-
id: firstFile.id,
|
|
515
|
-
file_path: firstFile.file_path,
|
|
516
|
-
is_public: firstFile.is_public,
|
|
517
|
-
has_file_metadata: !!firstFile.file_metadata,
|
|
518
|
-
category_in_metadata: firstFile.file_metadata?.category
|
|
519
|
-
});
|
|
520
|
-
|
|
508
|
+
// Removed verbose debug logs - only log on errors
|
|
521
509
|
setFileReference(firstFile);
|
|
522
510
|
|
|
523
511
|
// Generate URL based on file visibility
|
|
524
512
|
let url: string | null = null;
|
|
525
513
|
if (firstFile.is_public) {
|
|
526
514
|
url = getPublicUrl(supabase, firstFile.file_path, true);
|
|
527
|
-
logger.debug('useFileDisplay', 'Generated public URL:', url);
|
|
528
515
|
} else {
|
|
529
516
|
const signedUrlResult = await getSignedUrl(supabase, firstFile.file_path, {
|
|
530
517
|
appName: 'pace-core',
|
|
@@ -533,9 +520,15 @@ export function useFileDisplay(
|
|
|
533
520
|
expiresIn: 3600
|
|
534
521
|
});
|
|
535
522
|
url = signedUrlResult?.url || null;
|
|
536
|
-
|
|
523
|
+
// Only log if URL generation fails
|
|
524
|
+
if (!url) {
|
|
525
|
+
logger.warn('useFileDisplay', 'Failed to generate signed URL for file:', {
|
|
526
|
+
file_path: firstFile.file_path,
|
|
527
|
+
record_id,
|
|
528
|
+
table_name
|
|
529
|
+
});
|
|
530
|
+
}
|
|
537
531
|
}
|
|
538
|
-
logger.debug('useFileDisplay', 'Setting file URL:', url ? 'URL set' : 'URL is null');
|
|
539
532
|
setFileUrl(url);
|
|
540
533
|
} else {
|
|
541
534
|
// Multiple files mode - generate URLs for all files in batch
|
|
@@ -11,8 +11,8 @@ export interface FocusManagementOptions {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export interface FocusManagementReturn {
|
|
14
|
-
containerRef: React.RefObject<HTMLDivElement>;
|
|
15
|
-
focusRef: React.RefObject<HTMLElement>;
|
|
14
|
+
containerRef: React.RefObject<HTMLDivElement | null>;
|
|
15
|
+
focusRef: React.RefObject<HTMLElement | null>;
|
|
16
16
|
setFocus: (element: HTMLElement | null) => void;
|
|
17
17
|
focusFirst: () => void;
|
|
18
18
|
focusLast: () => void;
|
|
@@ -16,7 +16,7 @@ export interface FocusTrapOptions {
|
|
|
16
16
|
|
|
17
17
|
export interface FocusTrapReturn {
|
|
18
18
|
/** Ref to attach to the container element */
|
|
19
|
-
containerRef: React.RefObject<HTMLElement>;
|
|
19
|
+
containerRef: React.RefObject<HTMLElement | null>;
|
|
20
20
|
/** Focus the first focusable element */
|
|
21
21
|
focusFirst: () => void;
|
|
22
22
|
/** Focus the last focusable element */
|
|
@@ -58,9 +58,9 @@ export function useFocusTrap(options: FocusTrapOptions = {}): FocusTrapReturn {
|
|
|
58
58
|
containerRef.current.querySelectorAll<HTMLElement>(focusableSelector)
|
|
59
59
|
).filter((element) => {
|
|
60
60
|
return (
|
|
61
|
-
|
|
62
|
-
!element.hasAttribute('
|
|
63
|
-
element.offsetParent !== null
|
|
61
|
+
// visible check
|
|
62
|
+
(!element.hasAttribute('disabled') &&
|
|
63
|
+
!element.hasAttribute('hidden') && element.offsetParent !== null)
|
|
64
64
|
);
|
|
65
65
|
});
|
|
66
66
|
}, [focusableSelector]);
|