@jmruthers/pace-core 0.5.74 → 0.5.76
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/dist/DataTable-4GAVPIEG.js +120 -0
- package/dist/{PublicLoadingSpinner-DLpF5bbs.d.ts → PublicLoadingSpinner-BiNER8F5.d.ts} +30 -19
- package/dist/RBACService-C4udt_Zp.d.ts +528 -0
- package/dist/{UnifiedAuthProvider-K4NRGXL4.js → UnifiedAuthProvider-3NKDOSOK.js} +6 -4
- package/dist/UnifiedAuthProvider-Bj6YCf7c.d.ts +113 -0
- package/dist/chunk-5F3NDPJV.js +232 -0
- package/dist/chunk-5F3NDPJV.js.map +1 -0
- package/dist/chunk-A4FUBC7B.js +17 -0
- package/dist/chunk-A4FUBC7B.js.map +1 -0
- package/dist/{chunk-SMJZMKYN.js → chunk-A6HBIY5P.js} +2 -11
- package/dist/{chunk-SMJZMKYN.js.map → chunk-A6HBIY5P.js.map} +1 -1
- package/dist/{chunk-LVQ26TCN.js → chunk-AFGTSUAD.js} +43 -127
- package/dist/chunk-AFGTSUAD.js.map +1 -0
- package/dist/{chunk-BKVGJVUR.js → chunk-K34IM5CT.js} +497 -33
- package/dist/chunk-K34IM5CT.js.map +1 -0
- package/dist/{chunk-UJMCGBLS.js → chunk-KHJS6VIA.js} +203 -41
- package/dist/chunk-KHJS6VIA.js.map +1 -0
- package/dist/{chunk-ORSMVXO2.js → chunk-KK73ZB4E.js} +9 -14
- package/dist/chunk-KK73ZB4E.js.map +1 -0
- package/dist/{chunk-VKOCWWVY.js → chunk-L3RV2ALE.js} +1 -6
- package/dist/{chunk-VKOCWWVY.js.map → chunk-L3RV2ALE.js.map} +1 -1
- package/dist/chunk-LW7MMEAQ.js +59 -0
- package/dist/chunk-LW7MMEAQ.js.map +1 -0
- package/dist/{chunk-IHMMNKNA.js → chunk-M5IWZRBT.js} +5118 -1864
- package/dist/chunk-M5IWZRBT.js.map +1 -0
- package/dist/{chunk-DG5Z55HH.js → chunk-NTNILOBC.js} +7 -9
- package/dist/chunk-NTNILOBC.js.map +1 -0
- package/dist/chunk-PYUXFQJ3.js +11 -0
- package/dist/chunk-PYUXFQJ3.js.map +1 -0
- package/dist/chunk-URUTVZ7N.js +27 -0
- package/dist/chunk-URUTVZ7N.js.map +1 -0
- package/dist/chunk-WN6XJWOS.js +2468 -0
- package/dist/chunk-WN6XJWOS.js.map +1 -0
- package/dist/{chunk-3SP4P7NS.js → chunk-XLZ7U46Z.js} +59 -1
- package/dist/chunk-XLZ7U46Z.js.map +1 -0
- package/dist/{chunk-H2TNUICK.js → chunk-Y6TXWPJO.js} +50 -50
- package/dist/chunk-Y6TXWPJO.js.map +1 -0
- package/dist/{chunk-YNUBMSMV.js → chunk-YCKPEMJA.js} +186 -263
- package/dist/chunk-YCKPEMJA.js.map +1 -0
- package/dist/components.d.ts +4 -5
- package/dist/components.js +35 -41
- package/dist/components.js.map +1 -1
- package/dist/hooks.d.ts +20 -43
- package/dist/hooks.js +13 -12
- package/dist/hooks.js.map +1 -1
- package/dist/index.d.ts +156 -10
- package/dist/index.js +193 -96
- package/dist/index.js.map +1 -1
- package/dist/{organisation-t-vvQC3g.d.ts → organisation-BtshODVF.d.ts} +4 -3
- package/dist/providers.d.ts +27 -38
- package/dist/providers.js +33 -23
- package/dist/rbac/index.d.ts +114 -5
- package/dist/rbac/index.js +15 -15
- package/dist/styles/index.js +2 -2
- package/dist/theming/runtime.js +1 -3
- package/dist/types.d.ts +3 -3
- package/dist/types.js +1 -1
- package/dist/types.js.map +1 -1
- package/dist/{unified-CMPjE_fv.d.ts → unified-CM7T0aTK.d.ts} +1 -1
- package/dist/useInactivityTracker-MRUU55XI.js +10 -0
- package/dist/{usePublicRouteParams-Ua1Vz-HG.d.ts → usePublicRouteParams-B-CumWRc.d.ts} +3 -3
- package/dist/utils.js +7 -9
- package/dist/utils.js.map +1 -1
- package/dist/validation.d.ts +1 -1
- package/docs/TERMINOLOGY.md +231 -0
- 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/MissingUserContextError.md +1 -1
- package/docs/api/classes/OrganisationContextRequiredError.md +1 -1
- package/docs/api/classes/PermissionDeniedError.md +1 -1
- package/docs/api/classes/PublicErrorBoundary.md +1 -1
- package/docs/api/classes/RBACAuditManager.md +1 -1
- package/docs/api/classes/RBACCache.md +1 -1
- package/docs/api/classes/RBACEngine.md +1 -1
- package/docs/api/classes/RBACError.md +1 -1
- package/docs/api/classes/RBACNotInitializedError.md +1 -1
- package/docs/api/classes/SecureSupabaseClient.md +1 -1
- package/docs/api/classes/StorageUtils.md +1 -1
- package/docs/api/enums/FileCategory.md +1 -1
- package/docs/api/interfaces/AggregateConfig.md +1 -1
- package/docs/api/interfaces/ButtonProps.md +3 -3
- package/docs/api/interfaces/CardProps.md +2 -2
- package/docs/api/interfaces/ColorPalette.md +1 -1
- package/docs/api/interfaces/ColorShade.md +1 -1
- package/docs/api/interfaces/DataAccessRecord.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/EmptyStateConfig.md +1 -1
- package/docs/api/interfaces/EnhancedNavigationMenuProps.md +1 -1
- package/docs/api/interfaces/EventLogoProps.md +2 -2
- package/docs/api/interfaces/FileDisplayProps.md +1 -1
- 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/InactivityWarningModalProps.md +1 -1
- package/docs/api/interfaces/InputProps.md +2 -2
- package/docs/api/interfaces/LabelProps.md +1 -1
- package/docs/api/interfaces/LoginFormProps.md +1 -1
- package/docs/api/interfaces/NavigationAccessRecord.md +1 -1
- 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 +28 -17
- package/docs/api/interfaces/OrganisationMembership.md +1 -1
- package/docs/api/interfaces/OrganisationProviderProps.md +2 -2
- 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 +1 -1
- package/docs/api/interfaces/PagePermissionProviderProps.md +1 -1
- package/docs/api/interfaces/PaletteData.md +1 -1
- package/docs/api/interfaces/PermissionEnforcerProps.md +1 -1
- package/docs/api/interfaces/PublicErrorBoundaryProps.md +1 -1
- package/docs/api/interfaces/PublicErrorBoundaryState.md +1 -1
- package/docs/api/interfaces/PublicLoadingSpinnerProps.md +2 -2
- 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/RBACConfig.md +1 -1
- package/docs/api/interfaces/RBACContextType.md +5 -11
- package/docs/api/interfaces/RBACLogger.md +1 -1
- package/docs/api/interfaces/RBACProviderProps.md +1 -1
- package/docs/api/interfaces/RoleBasedRouterContextType.md +1 -1
- package/docs/api/interfaces/RoleBasedRouterProps.md +1 -1
- package/docs/api/interfaces/RouteAccessRecord.md +1 -1
- package/docs/api/interfaces/RouteConfig.md +1 -1
- package/docs/api/interfaces/SecureDataContextType.md +1 -1
- package/docs/api/interfaces/SecureDataProviderProps.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/ToastActionElement.md +1 -1
- package/docs/api/interfaces/ToastProps.md +1 -1
- package/docs/api/interfaces/UnifiedAuthContextType.md +524 -440
- package/docs/api/interfaces/UnifiedAuthProviderProps.md +14 -14
- package/docs/api/interfaces/UseInactivityTrackerOptions.md +1 -1
- package/docs/api/interfaces/UseInactivityTrackerReturn.md +1 -1
- package/docs/api/interfaces/UsePublicEventLogoOptions.md +1 -1
- 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/UsePublicRouteParamsReturn.md +1 -1
- package/docs/api/interfaces/UseResolvedScopeOptions.md +47 -0
- package/docs/api/interfaces/UseResolvedScopeReturn.md +47 -0
- package/docs/api/interfaces/UserEventAccess.md +11 -11
- package/docs/api/interfaces/UserMenuProps.md +1 -1
- package/docs/api/interfaces/UserProfile.md +1 -1
- package/docs/api/modules.md +234 -61
- package/docs/api-reference/providers.md +26 -7
- package/docs/architecture/services.md +30 -32
- package/docs/best-practices/README.md +20 -0
- package/docs/best-practices/accessibility.md +566 -0
- package/docs/best-practices/performance-expansion.md +473 -0
- package/docs/breaking-changes.md +2 -5
- package/docs/core-concepts/authentication.md +15 -7
- package/docs/documentation-index.md +1 -1
- package/docs/documentation-templates.md +539 -0
- package/docs/getting-started/quick-start.md +16 -66
- package/docs/implementation-guides/component-styling.md +410 -0
- package/docs/implementation-guides/data-tables.md +1 -1
- package/docs/migration/service-architecture.md +121 -260
- package/docs/rbac/README-rbac-rls-integration.md +48 -38
- package/docs/style-guide.md +39 -0
- package/{src/rbac/examples → examples/RBAC}/CompleteRBACExample.tsx +3 -2
- package/{src/rbac/examples → examples/RBAC}/EventBasedApp.tsx +5 -4
- package/{src/components/examples → examples/RBAC}/PermissionExample.tsx +7 -6
- package/examples/RBAC/__tests__/PermissionExample.test.tsx +150 -0
- package/examples/RBAC/index.ts +13 -0
- package/examples/README.md +37 -0
- package/examples/index.ts +22 -0
- package/{src/examples → examples/public-pages}/CorrectPublicPageImplementation.tsx +1 -1
- package/{src/examples → examples/public-pages}/PublicEventPage.tsx +1 -1
- package/{src/examples → examples/public-pages}/PublicPageApp.tsx +1 -1
- package/{src/examples → examples/public-pages}/PublicPageUsageExample.tsx +1 -1
- package/examples/public-pages/__tests__/PublicPageUsageExample.test.tsx +159 -0
- package/examples/public-pages/index.ts +14 -0
- package/package.json +22 -18
- package/src/__tests__/TEST_GUIDE_CURSOR.md +940 -9
- package/src/__tests__/helpers/README.md +255 -0
- package/src/__tests__/helpers/index.ts +62 -0
- package/src/__tests__/helpers/supabaseMock.ts +75 -5
- package/src/__tests__/rbac/PagePermissionGuard.test.tsx +6 -8
- package/src/components/DataTable/__tests__/DataTable.default-state.test.tsx +17 -6
- package/src/components/DataTable/__tests__/DataTableCore.test.tsx +73 -9
- package/src/components/DataTable/components/DataTableCore.tsx +280 -475
- package/src/components/DataTable/components/UnifiedTableBody.tsx +120 -153
- package/src/components/DataTable/components/__tests__/COVERAGE_NOTE.md +55 -0
- package/src/components/DataTable/components/index.ts +1 -2
- package/src/components/DataTable/context/__tests__/DataTableContext.test.tsx +208 -275
- package/src/components/DataTable/core/__tests__/ColumnFactory.test.ts +254 -0
- package/src/components/DataTable/core/index.ts +1 -8
- package/src/components/DataTable/examples/__tests__/HierarchicalExample.test.tsx +45 -0
- package/src/components/DataTable/examples/__tests__/PerformanceExample.test.tsx +117 -0
- package/src/components/DataTable/hooks/__tests__/useColumnOrderPersistence.test.ts +525 -0
- package/src/components/DataTable/hooks/__tests__/useColumnReordering.test.ts +570 -0
- package/src/components/DataTable/hooks/__tests__/useHierarchicalState.test.ts +214 -0
- package/src/components/DataTable/hooks/__tests__/useTableColumns.test.ts +224 -0
- package/src/components/DataTable/hooks/index.ts +6 -0
- package/src/components/DataTable/hooks/useColumnReordering.ts +1 -0
- package/src/components/DataTable/hooks/useDataTablePermissions.ts +149 -0
- package/src/components/DataTable/hooks/useDataTableState.ts +12 -6
- package/src/components/DataTable/hooks/useHierarchicalState.ts +26 -8
- package/src/components/DataTable/hooks/useTableColumns.ts +153 -0
- package/src/components/DataTable/index.ts +1 -9
- package/src/components/DataTable/utils/__tests__/COVERAGE_NOTE.md +89 -0
- package/src/components/DataTable/utils/__tests__/exportUtils.test.ts +3 -6
- package/src/components/DataTable/utils/__tests__/flexibleImport.test.ts +462 -0
- package/src/components/DataTable/utils/__tests__/hierarchicalSorting.test.ts +247 -0
- package/src/components/DataTable/utils/__tests__/hierarchicalUtils.test.ts +8 -6
- package/src/components/DataTable/utils/__tests__/performanceUtils.test.ts +466 -0
- package/src/components/DataTable/utils/__tests__/rowUtils.test.ts +265 -0
- package/src/components/DataTable/utils/errorHandling.ts +52 -460
- package/src/components/DataTable/utils/exportUtils.ts +46 -15
- package/src/components/DataTable/utils/hierarchicalSorting.ts +50 -3
- package/src/components/DataTable/utils/hierarchicalUtils.ts +167 -34
- package/src/components/DataTable/utils/index.ts +5 -0
- package/src/components/DataTable/utils/rowUtils.ts +68 -0
- package/src/components/Dialog/examples/__tests__/HtmlDialogExample.test.tsx +71 -0
- package/src/components/Dialog/examples/__tests__/SimpleHtmlTest.test.tsx +122 -0
- package/src/components/EventSelector/EventSelector.test.tsx +672 -0
- package/src/components/EventSelector/EventSelector.tsx +1 -1
- package/src/components/Header/Header.test.tsx +35 -1
- package/src/components/Header/Header.tsx +3 -1
- package/src/components/Label/__tests__/Label.test.tsx +434 -0
- package/src/components/OrganisationSelector/OrganisationSelector.tsx +3 -3
- package/src/components/PaceAppLayout/__tests__/PaceAppLayout.rbac.test.tsx +24 -4
- package/src/components/PaceLoginPage/PaceLoginPage.test.tsx +3 -2
- package/src/components/PublicLayout/__tests__/PublicPageContextChecker.test.tsx +190 -0
- package/src/components/PublicLayout/__tests__/PublicPageDebugger.test.tsx +185 -0
- package/src/components/PublicLayout/__tests__/PublicPageProvider.test.tsx +313 -0
- package/src/components/Select/Select.test.tsx +143 -120
- package/src/components/Select/Select.tsx +47 -212
- package/src/components/Select/hooks.ts +36 -1
- package/src/components/Select/index.ts +2 -1
- package/src/hooks/__tests__/useFocusManagement.unit.test.ts +220 -0
- package/src/hooks/__tests__/useIsMobile.unit.test.ts +117 -0
- package/src/hooks/__tests__/useKeyboardShortcuts.unit.test.ts +295 -0
- package/src/hooks/__tests__/useOrganisationSecurity.unit.test.tsx +29 -19
- package/src/hooks/__tests__/useRBAC.unit.test.ts +7 -3
- package/src/hooks/__tests__/useSecureDataAccess.unit.test.tsx +115 -19
- package/src/hooks/services/__tests__/useServiceHooks.test.tsx +137 -0
- package/src/hooks/useEventTheme.test.ts +350 -0
- package/src/hooks/useEventTheme.ts +1 -1
- package/src/hooks/useEvents.ts +61 -0
- package/src/hooks/useOrganisationSecurity.test.ts +4 -4
- package/src/hooks/useOrganisationSecurity.ts +2 -2
- package/src/hooks/useOrganisations.ts +64 -0
- package/src/hooks/useSecureDataAccess.test.ts +37 -30
- package/src/hooks/useSecureDataAccess.ts +2 -2
- package/src/index.ts +18 -3
- package/src/providers/AuthProvider.tsx +8 -292
- package/src/providers/EventProvider.tsx +15 -425
- package/src/providers/InactivityProvider.tsx +8 -231
- package/src/providers/OrganisationProvider.test.simple.tsx +3 -2
- package/src/providers/OrganisationProvider.tsx +11 -890
- package/src/providers/UnifiedAuthProvider.tsx +8 -320
- package/src/providers/__tests__/AuthProvider.test.tsx +18 -17
- package/src/providers/__tests__/EventProvider.test.tsx +253 -2
- package/src/providers/__tests__/InactivityProvider.test-helper.tsx +65 -0
- package/src/providers/__tests__/InactivityProvider.test.tsx +46 -114
- package/src/providers/__tests__/OrganisationProvider.test.tsx +313 -3
- package/src/providers/__tests__/ProviderLifecycle.test.tsx +341 -0
- package/src/providers/__tests__/UnifiedAuthProvider.test.tsx +383 -2
- package/src/providers/index.ts +8 -7
- package/src/providers/services/EventServiceProvider.tsx +3 -0
- package/src/providers/services/UnifiedAuthProvider.tsx +3 -0
- package/src/rbac/hooks/__tests__/usePermissions.integration.test.ts +437 -0
- package/src/rbac/hooks/index.ts +2 -0
- package/src/rbac/hooks/usePermissions.test.ts +296 -0
- package/src/rbac/hooks/useRBAC.test.ts +9 -5
- package/src/rbac/hooks/useRBAC.ts +3 -3
- package/src/rbac/hooks/useResolvedScope.ts +232 -0
- package/src/rbac/providers/__tests__/RBACProvider.integration.test.tsx +688 -0
- package/src/rbac/providers/__tests__/RBACProvider.test.tsx +507 -0
- package/src/services/AuthService.ts +19 -4
- package/src/services/__tests__/AuthService.test.ts +288 -0
- package/src/services/__tests__/InactivityService.lifecycle.test.ts +411 -0
- package/src/services/__tests__/OrganisationService.pagination.test.ts +375 -0
- package/src/styles/core.css +2 -0
- package/src/types/__tests__/README.md +114 -0
- package/src/types/__tests__/guards.test.ts +246 -0
- package/src/types/__tests__/validation.test.ts +731 -0
- package/src/types/guards.ts +1 -0
- package/src/types/organisation.ts +3 -2
- package/src/utils/__tests__/file-reference.test.ts +383 -0
- package/src/utils/__tests__/performanceBenchmark.test.ts +175 -0
- package/src/utils/appNameResolver.test.ts +54 -0
- package/src/validation/__tests__/csrf.unit.test.ts +63 -0
- package/src/validation/__tests__/passwordSchema.unit.test.ts +105 -0
- package/src/validation/__tests__/sanitization.unit.test.ts +250 -0
- package/src/validation/__tests__/schemaUtils.unit.test.ts +451 -0
- package/src/validation/__tests__/user.unit.test.ts +440 -0
- package/dist/DataTable-2QR5TER5.js +0 -102
- package/dist/RBACProvider-BO4ilsQB.d.ts +0 -63
- package/dist/UnifiedAuthProvider-D02AMXgO.d.ts +0 -103
- package/dist/chunk-3SP4P7NS.js.map +0 -1
- package/dist/chunk-B5LK25HV.js +0 -953
- package/dist/chunk-B5LK25HV.js.map +0 -1
- package/dist/chunk-BKVGJVUR.js.map +0 -1
- package/dist/chunk-C5Q5LRU5.js +0 -5691
- package/dist/chunk-C5Q5LRU5.js.map +0 -1
- package/dist/chunk-CDDYJCYU.js +0 -79
- package/dist/chunk-CDDYJCYU.js.map +0 -1
- package/dist/chunk-DG5Z55HH.js.map +0 -1
- package/dist/chunk-H2TNUICK.js.map +0 -1
- package/dist/chunk-IHMMNKNA.js.map +0 -1
- package/dist/chunk-LVQ26TCN.js.map +0 -1
- package/dist/chunk-ORSMVXO2.js.map +0 -1
- package/dist/chunk-TYHR5X4W.js +0 -33
- package/dist/chunk-TYHR5X4W.js.map +0 -1
- package/dist/chunk-UJMCGBLS.js.map +0 -1
- package/dist/chunk-V6BHACCH.js +0 -17
- package/dist/chunk-V6BHACCH.js.map +0 -1
- package/dist/chunk-YNUBMSMV.js.map +0 -1
- package/dist/eventContext-BBA42P6G.js +0 -14
- package/dist/rbac/cli/policy-manager.js +0 -278
- package/dist/rbac/cli/policy-manager.js.map +0 -1
- package/docs/api/interfaces/EventContextType.md +0 -96
- package/docs/api/interfaces/EventProviderProps.md +0 -19
- package/docs/documentation-style-checklist.md +0 -294
- package/src/components/DataTable/components/DataTableBody.tsx +0 -488
- package/src/components/DataTable/components/DraggableColumnHeader.tsx +0 -144
- package/src/components/DataTable/components/VirtualizedDataTable.tsx +0 -515
- package/src/components/DataTable/core/ActionManager.ts +0 -235
- package/src/components/DataTable/core/ColumnManager.ts +0 -205
- package/src/components/DataTable/core/DataManager.ts +0 -188
- package/src/components/DataTable/core/DataTableContext.tsx +0 -181
- package/src/components/DataTable/core/LocalDataAdapter.ts +0 -264
- package/src/components/DataTable/core/PluginRegistry.ts +0 -229
- package/src/components/DataTable/core/StateManager.ts +0 -311
- package/src/components/DataTable/core/__tests__/ActionManager.test.ts +0 -634
- package/src/components/DataTable/core/__tests__/DataManager.test.ts +0 -519
- package/src/components/DataTable/core/__tests__/StateManager.test.ts +0 -714
- package/src/components/DataTable/core/interfaces.ts +0 -338
- package/src/components/DataTable/utils/debugTools.ts +0 -583
- package/src/components/Select/Select.bug-test.tsx +0 -69
- package/src/components/Select/Select.refactored.tsx +0 -497
- package/src/providers/OrganisationProvider.test.tsx +0 -164
- package/src/providers/UnifiedAuthProvider.test.tsx +0 -124
- package/src/providers/__tests__/AuthProvider.test.tsx.backup +0 -771
- package/src/providers/__tests__/EventProvider.test.tsx.backup +0 -824
- package/src/providers/__tests__/OrganisationProvider.test.tsx.backup +0 -820
- package/src/providers/__tests__/UnifiedAuthProvider.test.tsx.backup +0 -911
- package/src/providers/__tests__/UnifiedAuthProvider.test.tsx.backup2 +0 -166
- package/src/rbac/cli/__tests__/policy-manager.test.ts +0 -339
- package/src/rbac/cli/policy-manager.ts +0 -443
- package/dist/{DataTable-2QR5TER5.js.map → DataTable-4GAVPIEG.js.map} +0 -0
- package/dist/{UnifiedAuthProvider-K4NRGXL4.js.map → UnifiedAuthProvider-3NKDOSOK.js.map} +0 -0
- package/dist/{eventContext-BBA42P6G.js.map → useInactivityTracker-MRUU55XI.js.map} +0 -0
- package/dist/{validation-PM_iOaTI.d.ts → validation-D8VcbTzC.d.ts} +2 -2
- /package/src/utils/{appNameResolver.test.ts.backup → appNameResolver.test 2.ts} +0 -0
|
@@ -1,494 +1,86 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @file Error Handling
|
|
2
|
+
* @file Error Handling Stubs
|
|
3
3
|
* @package @jmruthers/pace-core
|
|
4
|
-
* @module Components/DataTable/Utils/
|
|
5
|
-
*
|
|
4
|
+
* @module Components/DataTable/Utils/Stubs
|
|
5
|
+
*
|
|
6
|
+
* Minimal stubs for removed error handling utilities.
|
|
7
|
+
* This file exists only to prevent import errors in useDataTablePerformance.
|
|
6
8
|
*/
|
|
7
9
|
|
|
8
|
-
|
|
10
|
+
export interface FallbackConfig {
|
|
11
|
+
enabled: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const DEFAULT_FALLBACK_CONFIG: FallbackConfig = {
|
|
15
|
+
enabled: false
|
|
16
|
+
};
|
|
9
17
|
|
|
10
|
-
/**
|
|
11
|
-
* Error types for DataTable performance operations
|
|
12
|
-
*/
|
|
13
18
|
export enum DataTableErrorType {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
PERFORMANCE_MONITOR_ERROR = 'PERFORMANCE_MONITOR_ERROR',
|
|
20
|
-
VISIBILITY_TRACKER_ERROR = 'VISIBILITY_TRACKER_ERROR',
|
|
19
|
+
VIRTUALIZATION = 'virtualization',
|
|
20
|
+
SEARCH_INDEX = 'search_index',
|
|
21
|
+
DATA_CHUNK = 'data_chunk',
|
|
22
|
+
SERVER_FETCH = 'server_fetch',
|
|
23
|
+
MEMORY = 'memory'
|
|
21
24
|
}
|
|
22
25
|
|
|
23
|
-
/**
|
|
24
|
-
* Custom error class for DataTable operations
|
|
25
|
-
*/
|
|
26
26
|
export class DataTableError extends Error {
|
|
27
|
-
public readonly type: DataTableErrorType;
|
|
28
|
-
public readonly timestamp: number;
|
|
29
|
-
public readonly context?: Record<string, any>;
|
|
30
|
-
public readonly recoverable: boolean;
|
|
31
|
-
|
|
32
27
|
constructor(
|
|
33
28
|
message: string,
|
|
34
|
-
type: DataTableErrorType,
|
|
35
|
-
|
|
36
|
-
recoverable: boolean = true
|
|
29
|
+
public type: DataTableErrorType,
|
|
30
|
+
public recoverable: boolean = true
|
|
37
31
|
) {
|
|
38
32
|
super(message);
|
|
39
33
|
this.name = 'DataTableError';
|
|
40
|
-
this.type = type;
|
|
41
|
-
this.timestamp = Date.now();
|
|
42
|
-
this.context = context;
|
|
43
|
-
this.recoverable = recoverable;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Fallback configurations for different performance features
|
|
49
|
-
*/
|
|
50
|
-
export interface FallbackConfig {
|
|
51
|
-
/** Fallback pagination mode when auto-detection fails */
|
|
52
|
-
fallbackPaginationMode: PaginationMode;
|
|
53
|
-
/** Fallback page size options */
|
|
54
|
-
fallbackPageSizeOptions: number[];
|
|
55
|
-
/** Maximum retry attempts for server requests */
|
|
56
|
-
maxRetries: number;
|
|
57
|
-
/** Retry delay in milliseconds */
|
|
58
|
-
retryDelay: number;
|
|
59
|
-
/** Maximum memory usage before falling back (in MB) */
|
|
60
|
-
maxMemoryUsage: number;
|
|
61
|
-
/** Enable graceful degradation */
|
|
62
|
-
enableGracefulDegradation: boolean;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Default fallback configuration
|
|
67
|
-
*/
|
|
68
|
-
export const DEFAULT_FALLBACK_CONFIG: FallbackConfig = {
|
|
69
|
-
fallbackPaginationMode: 'client',
|
|
70
|
-
fallbackPageSizeOptions: [10, 25, 50],
|
|
71
|
-
maxRetries: 3,
|
|
72
|
-
retryDelay: 1000,
|
|
73
|
-
maxMemoryUsage: 100, // 100MB
|
|
74
|
-
enableGracefulDegradation: true,
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Error recovery strategies
|
|
79
|
-
*/
|
|
80
|
-
export interface ErrorRecoveryStrategy {
|
|
81
|
-
canRecover(error: DataTableError): boolean;
|
|
82
|
-
recover(error: DataTableError, context?: any): Promise<any> | any;
|
|
83
|
-
getFallback(error: DataTableError): any;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Virtualization error recovery
|
|
88
|
-
*/
|
|
89
|
-
export class VirtualizationErrorRecovery implements ErrorRecoveryStrategy {
|
|
90
|
-
canRecover(error: DataTableError): boolean {
|
|
91
|
-
return error.type === DataTableErrorType.VIRTUALIZATION_ERROR && error.recoverable;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
recover(error: DataTableError): any {
|
|
95
|
-
console.warn('Virtualization failed, falling back to standard rendering:', error.message);
|
|
96
|
-
return {
|
|
97
|
-
enableVirtualization: false,
|
|
98
|
-
fallbackMessage: 'Virtual scrolling disabled due to compatibility issues',
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
getFallback(): any {
|
|
103
|
-
return {
|
|
104
|
-
enableVirtualization: false,
|
|
105
|
-
height: 400,
|
|
106
|
-
overscan: 0,
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Search index error recovery
|
|
113
|
-
*/
|
|
114
|
-
export class SearchIndexErrorRecovery implements ErrorRecoveryStrategy {
|
|
115
|
-
canRecover(error: DataTableError): boolean {
|
|
116
|
-
return error.type === DataTableErrorType.SEARCH_INDEX_ERROR && error.recoverable;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
recover(error: DataTableError): any {
|
|
120
|
-
console.warn('Search indexing failed, falling back to basic search:', error.message);
|
|
121
|
-
return {
|
|
122
|
-
enableSearchIndex: false,
|
|
123
|
-
fallbackMessage: 'Advanced search disabled, using basic text search',
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
getFallback(): any {
|
|
128
|
-
return {
|
|
129
|
-
enableSearchIndex: false,
|
|
130
|
-
fuzzySearch: false,
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Data chunk error recovery
|
|
137
|
-
*/
|
|
138
|
-
export class DataChunkErrorRecovery implements ErrorRecoveryStrategy {
|
|
139
|
-
canRecover(error: DataTableError): boolean {
|
|
140
|
-
return error.type === DataTableErrorType.DATA_CHUNK_ERROR && error.recoverable;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
recover(error: DataTableError): any {
|
|
144
|
-
console.warn('Data chunking failed, loading all data:', error.message);
|
|
145
|
-
return {
|
|
146
|
-
enableChunking: false,
|
|
147
|
-
fallbackMessage: 'Memory optimization disabled, all data loaded',
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
getFallback(): any {
|
|
152
|
-
return {
|
|
153
|
-
enableChunking: false,
|
|
154
|
-
chunkSize: Number.MAX_SAFE_INTEGER,
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Server fetch error recovery with retry logic
|
|
161
|
-
*/
|
|
162
|
-
export class ServerFetchErrorRecovery implements ErrorRecoveryStrategy {
|
|
163
|
-
private retryCount = 0;
|
|
164
|
-
private readonly maxRetries: number;
|
|
165
|
-
private readonly retryDelay: number;
|
|
166
|
-
|
|
167
|
-
constructor(config: FallbackConfig = DEFAULT_FALLBACK_CONFIG) {
|
|
168
|
-
this.maxRetries = config.maxRetries;
|
|
169
|
-
this.retryDelay = config.retryDelay;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
canRecover(error: DataTableError): boolean {
|
|
173
|
-
return error.type === DataTableErrorType.SERVER_FETCH_ERROR &&
|
|
174
|
-
this.retryCount < this.maxRetries;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
async recover(error: DataTableError, retryFn?: () => Promise<any>): Promise<any> {
|
|
178
|
-
this.retryCount++;
|
|
179
|
-
const delay = this.retryDelay * Math.pow(2, this.retryCount - 1); // Exponential backoff
|
|
180
|
-
|
|
181
|
-
console.warn(`Server fetch failed, retrying in ${delay}ms (attempt ${this.retryCount}/${this.maxRetries}):`, error.message);
|
|
182
|
-
|
|
183
|
-
await new Promise(resolve => setTimeout(resolve, delay));
|
|
184
|
-
|
|
185
|
-
if (retryFn) {
|
|
186
|
-
try {
|
|
187
|
-
const result = await retryFn();
|
|
188
|
-
this.retryCount = 0; // Reset on success
|
|
189
|
-
return result;
|
|
190
|
-
} catch (retryError) {
|
|
191
|
-
if (this.retryCount >= this.maxRetries) {
|
|
192
|
-
throw new DataTableError(
|
|
193
|
-
'Max retry attempts exceeded',
|
|
194
|
-
DataTableErrorType.SERVER_FETCH_ERROR,
|
|
195
|
-
{ originalError: error, retryCount: this.retryCount },
|
|
196
|
-
false
|
|
197
|
-
);
|
|
198
|
-
}
|
|
199
|
-
return this.recover(error, retryFn);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
return this.getFallback(error);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
getFallback(error: DataTableError): any {
|
|
207
|
-
return {
|
|
208
|
-
paginationMode: 'client',
|
|
209
|
-
fallbackMessage: 'Server unavailable, switched to client-side mode',
|
|
210
|
-
data: [],
|
|
211
|
-
totalCount: 0,
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
/**
|
|
217
|
-
* Memory error recovery
|
|
218
|
-
*/
|
|
219
|
-
export class MemoryErrorRecovery implements ErrorRecoveryStrategy {
|
|
220
|
-
private readonly maxMemoryUsage: number;
|
|
221
|
-
|
|
222
|
-
constructor(config: FallbackConfig = DEFAULT_FALLBACK_CONFIG) {
|
|
223
|
-
this.maxMemoryUsage = config.maxMemoryUsage;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
canRecover(error: DataTableError): boolean {
|
|
227
|
-
return error.type === DataTableErrorType.MEMORY_ERROR;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
recover(error: DataTableError): any {
|
|
231
|
-
console.warn('Memory usage too high, enabling aggressive optimizations:', error.message);
|
|
232
|
-
return {
|
|
233
|
-
enableChunking: true,
|
|
234
|
-
chunkSize: 100, // Smaller chunks
|
|
235
|
-
maxChunksInMemory: 2, // Fewer chunks in memory
|
|
236
|
-
enableVirtualization: true,
|
|
237
|
-
fallbackMessage: 'Memory optimization enabled to reduce usage',
|
|
238
|
-
};
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
getFallback(): any {
|
|
242
|
-
return {
|
|
243
|
-
paginationMode: 'server',
|
|
244
|
-
enableChunking: true,
|
|
245
|
-
chunkSize: 50,
|
|
246
|
-
maxChunksInMemory: 1,
|
|
247
|
-
};
|
|
248
34
|
}
|
|
249
35
|
}
|
|
250
36
|
|
|
251
|
-
/**
|
|
252
|
-
* Central error recovery manager
|
|
253
|
-
*/
|
|
254
37
|
export class ErrorRecoveryManager {
|
|
255
|
-
private
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
constructor(config: FallbackConfig = DEFAULT_FALLBACK_CONFIG) {
|
|
260
|
-
this.strategies.set(DataTableErrorType.VIRTUALIZATION_ERROR, new VirtualizationErrorRecovery());
|
|
261
|
-
this.strategies.set(DataTableErrorType.SEARCH_INDEX_ERROR, new SearchIndexErrorRecovery());
|
|
262
|
-
this.strategies.set(DataTableErrorType.DATA_CHUNK_ERROR, new DataChunkErrorRecovery());
|
|
263
|
-
this.strategies.set(DataTableErrorType.SERVER_FETCH_ERROR, new ServerFetchErrorRecovery(config));
|
|
264
|
-
this.strategies.set(DataTableErrorType.MEMORY_ERROR, new MemoryErrorRecovery(config));
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
/**
|
|
268
|
-
* Handle error with appropriate recovery strategy
|
|
269
|
-
*/
|
|
270
|
-
async handleError(error: DataTableError, context?: any): Promise<any> {
|
|
271
|
-
// Log the error
|
|
272
|
-
this.logError(error);
|
|
273
|
-
|
|
274
|
-
// Get recovery strategy
|
|
275
|
-
const strategy = this.strategies.get(error.type);
|
|
276
|
-
if (!strategy) {
|
|
277
|
-
console.error('No recovery strategy found for error type:', error.type);
|
|
278
|
-
throw error;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
// Attempt recovery
|
|
282
|
-
if (strategy.canRecover(error)) {
|
|
283
|
-
try {
|
|
284
|
-
return await strategy.recover(error, context);
|
|
285
|
-
} catch (recoveryError) {
|
|
286
|
-
console.error('Recovery failed:', recoveryError);
|
|
287
|
-
return strategy.getFallback(error);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
// Return fallback if recovery not possible
|
|
292
|
-
return strategy.getFallback(error);
|
|
38
|
+
constructor(private config: FallbackConfig) {}
|
|
39
|
+
|
|
40
|
+
async handleError(error: DataTableError) {
|
|
41
|
+
return { recovered: false, strategy: null };
|
|
293
42
|
}
|
|
294
|
-
|
|
295
|
-
/**
|
|
296
|
-
* Log error for debugging and monitoring
|
|
297
|
-
*/
|
|
298
|
-
private logError(error: DataTableError): void {
|
|
299
|
-
this.errorLog.push(error);
|
|
300
|
-
|
|
301
|
-
// Maintain log size
|
|
302
|
-
if (this.errorLog.length > this.maxErrorLogSize) {
|
|
303
|
-
this.errorLog.shift();
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
// Log to console with context
|
|
307
|
-
console.error('DataTable Error:', {
|
|
308
|
-
type: error.type,
|
|
309
|
-
message: error.message,
|
|
310
|
-
timestamp: new Date(error.timestamp).toISOString(),
|
|
311
|
-
context: error.context,
|
|
312
|
-
recoverable: error.recoverable,
|
|
313
|
-
});
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
/**
|
|
317
|
-
* Get error statistics for monitoring
|
|
318
|
-
*/
|
|
319
|
-
getErrorStats(): {
|
|
320
|
-
totalErrors: number;
|
|
321
|
-
errorsByType: Record<string, number>;
|
|
322
|
-
recentErrors: DataTableError[];
|
|
323
|
-
} {
|
|
324
|
-
const errorsByType: Record<string, number> = {};
|
|
325
|
-
|
|
326
|
-
for (const error of this.errorLog) {
|
|
327
|
-
errorsByType[error.type] = (errorsByType[error.type] || 0) + 1;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
return {
|
|
331
|
-
totalErrors: this.errorLog.length,
|
|
332
|
-
errorsByType,
|
|
333
|
-
recentErrors: this.errorLog.slice(-10), // Last 10 errors
|
|
334
|
-
};
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
/**
|
|
338
|
-
* Clear error log
|
|
339
|
-
*/
|
|
43
|
+
|
|
340
44
|
clearErrorLog(): void {
|
|
341
|
-
|
|
45
|
+
// Stub method
|
|
342
46
|
}
|
|
343
47
|
}
|
|
344
48
|
|
|
345
|
-
/**
|
|
346
|
-
* Safe execution wrapper with error handling
|
|
347
|
-
*/
|
|
348
|
-
export async function safeExecute<T>(
|
|
349
|
-
operation: () => Promise<T> | T,
|
|
350
|
-
errorType: DataTableErrorType,
|
|
351
|
-
context?: Record<string, any>,
|
|
352
|
-
recoveryManager?: ErrorRecoveryManager
|
|
353
|
-
): Promise<T | null> {
|
|
354
|
-
try {
|
|
355
|
-
return await operation();
|
|
356
|
-
} catch (error) {
|
|
357
|
-
const dataTableError = new DataTableError(
|
|
358
|
-
error instanceof Error ? error.message : 'Unknown error',
|
|
359
|
-
errorType,
|
|
360
|
-
{ ...context, originalError: error }
|
|
361
|
-
);
|
|
362
|
-
|
|
363
|
-
if (recoveryManager) {
|
|
364
|
-
try {
|
|
365
|
-
return await recoveryManager.handleError(dataTableError);
|
|
366
|
-
} catch (recoveryError) {
|
|
367
|
-
console.error('Recovery failed:', recoveryError);
|
|
368
|
-
return null;
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
throw dataTableError;
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
/**
|
|
377
|
-
* Memory usage monitor with automatic fallbacks
|
|
378
|
-
*/
|
|
379
49
|
export class MemoryMonitor {
|
|
380
|
-
private
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
constructor(
|
|
385
|
-
maxMemoryUsage: number = 100, // MB
|
|
386
|
-
onMemoryExceeded?: (usage: number) => void
|
|
387
|
-
) {
|
|
388
|
-
this.maxMemoryUsage = maxMemoryUsage;
|
|
389
|
-
this.onMemoryExceeded = onMemoryExceeded;
|
|
50
|
+
constructor(private threshold: number = 100) {}
|
|
51
|
+
|
|
52
|
+
getCurrentUsage(): number {
|
|
53
|
+
return 0;
|
|
390
54
|
}
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
*/
|
|
395
|
-
startMonitoring(interval: number = 5000): void {
|
|
396
|
-
this.checkInterval = setInterval(() => {
|
|
397
|
-
const memoryUsage = this.getCurrentMemoryUsage();
|
|
398
|
-
|
|
399
|
-
if (memoryUsage > this.maxMemoryUsage) {
|
|
400
|
-
this.onMemoryExceeded?.(memoryUsage);
|
|
401
|
-
|
|
402
|
-
// Trigger memory error for recovery
|
|
403
|
-
const error = new DataTableError(
|
|
404
|
-
`Memory usage exceeded ${this.maxMemoryUsage}MB (current: ${memoryUsage}MB)`,
|
|
405
|
-
DataTableErrorType.MEMORY_ERROR,
|
|
406
|
-
{ memoryUsage, maxMemoryUsage: this.maxMemoryUsage }
|
|
407
|
-
);
|
|
408
|
-
|
|
409
|
-
console.warn(error.message);
|
|
410
|
-
}
|
|
411
|
-
}, interval);
|
|
55
|
+
|
|
56
|
+
checkThreshold(): boolean {
|
|
57
|
+
return true;
|
|
412
58
|
}
|
|
413
|
-
|
|
414
|
-
/**
|
|
415
|
-
* Stop monitoring
|
|
416
|
-
*/
|
|
59
|
+
|
|
417
60
|
stopMonitoring(): void {
|
|
418
|
-
|
|
419
|
-
clearInterval(this.checkInterval);
|
|
420
|
-
this.checkInterval = null;
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
/**
|
|
425
|
-
* Get current memory usage in MB
|
|
426
|
-
*/
|
|
427
|
-
private getCurrentMemoryUsage(): number {
|
|
428
|
-
if ('memory' in performance) {
|
|
429
|
-
const memory = (performance as any).memory;
|
|
430
|
-
return memory.usedJSHeapSize / (1024 * 1024);
|
|
431
|
-
}
|
|
432
|
-
return 0;
|
|
61
|
+
// Stub method
|
|
433
62
|
}
|
|
434
63
|
}
|
|
435
64
|
|
|
436
|
-
/**
|
|
437
|
-
* Circuit breaker pattern for preventing cascading failures
|
|
438
|
-
*/
|
|
439
65
|
export class CircuitBreaker {
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
this.state = 'HALF_OPEN';
|
|
453
|
-
} else {
|
|
454
|
-
throw new DataTableError(
|
|
455
|
-
'Circuit breaker is OPEN',
|
|
456
|
-
DataTableErrorType.SERVER_FETCH_ERROR,
|
|
457
|
-
{ state: this.state, failureCount: this.failureCount },
|
|
458
|
-
false
|
|
459
|
-
);
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
try {
|
|
464
|
-
const result = await operation();
|
|
465
|
-
this.onSuccess();
|
|
466
|
-
return result;
|
|
467
|
-
} catch (error) {
|
|
468
|
-
this.onFailure();
|
|
469
|
-
throw error;
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
private onSuccess(): void {
|
|
474
|
-
this.failureCount = 0;
|
|
475
|
-
this.state = 'CLOSED';
|
|
476
|
-
}
|
|
66
|
+
constructor() {}
|
|
67
|
+
|
|
68
|
+
isOpen(): boolean {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
recordSuccess(): void {}
|
|
73
|
+
|
|
74
|
+
recordFailure(): void {}
|
|
75
|
+
|
|
76
|
+
reset(): void {}
|
|
77
|
+
}
|
|
477
78
|
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
this.state = 'OPEN';
|
|
484
|
-
}
|
|
79
|
+
export function safeExecute<T>(fn: () => T, fallback: T): T {
|
|
80
|
+
try {
|
|
81
|
+
return fn();
|
|
82
|
+
} catch {
|
|
83
|
+
return fallback;
|
|
485
84
|
}
|
|
85
|
+
}
|
|
486
86
|
|
|
487
|
-
getState(): { state: string; failureCount: number; lastFailureTime: number } {
|
|
488
|
-
return {
|
|
489
|
-
state: this.state,
|
|
490
|
-
failureCount: this.failureCount,
|
|
491
|
-
lastFailureTime: this.lastFailureTime,
|
|
492
|
-
};
|
|
493
|
-
}
|
|
494
|
-
}
|
|
@@ -82,6 +82,7 @@ export function generateCSVContent<TData>(
|
|
|
82
82
|
* @param data - Array of data objects to export
|
|
83
83
|
* @param columns - Column definitions for mapping
|
|
84
84
|
* @param filename - Optional filename for download (default: "download.csv")
|
|
85
|
+
* @returns Promise that resolves when export is complete, rejects on error
|
|
85
86
|
*
|
|
86
87
|
* @example
|
|
87
88
|
* ```tsx
|
|
@@ -96,7 +97,12 @@ export function generateCSVContent<TData>(
|
|
|
96
97
|
* { accessorKey: 'email', header: 'Email' }
|
|
97
98
|
* ];
|
|
98
99
|
*
|
|
99
|
-
*
|
|
100
|
+
* try {
|
|
101
|
+
* await exportToCSV(users, columns, 'users.csv');
|
|
102
|
+
* showSuccessToast('Data exported successfully');
|
|
103
|
+
* } catch (error) {
|
|
104
|
+
* showErrorToast('Failed to export data');
|
|
105
|
+
* }
|
|
100
106
|
* ```
|
|
101
107
|
*
|
|
102
108
|
* @remarks
|
|
@@ -104,23 +110,48 @@ export function generateCSVContent<TData>(
|
|
|
104
110
|
* - Uses column headers for CSV headers
|
|
105
111
|
* - Sanitizes data to prevent CSV injection
|
|
106
112
|
* - Triggers browser download
|
|
113
|
+
* - Throws error if export fails
|
|
107
114
|
*/
|
|
108
115
|
export function exportToCSV<TData>(
|
|
109
116
|
data: TData[],
|
|
110
117
|
columns: any[],
|
|
111
118
|
filename: string = "download.csv"
|
|
112
|
-
): void {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
119
|
+
): Promise<void> {
|
|
120
|
+
return new Promise((resolve, reject) => {
|
|
121
|
+
try {
|
|
122
|
+
if (!data || data.length === 0) {
|
|
123
|
+
throw new Error('No data to export');
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (!columns || columns.length === 0) {
|
|
127
|
+
throw new Error('No columns defined for export');
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const csvContent = generateCSVContent(data, columns);
|
|
131
|
+
|
|
132
|
+
// Create and trigger download
|
|
133
|
+
const blob = new Blob([csvContent], { type: "text/csv;charset=utf-8;" });
|
|
134
|
+
const link = document.createElement("a");
|
|
135
|
+
const url = URL.createObjectURL(blob);
|
|
136
|
+
|
|
137
|
+
link.setAttribute("href", url);
|
|
138
|
+
link.setAttribute("download", filename);
|
|
139
|
+
link.style.display = "none";
|
|
140
|
+
|
|
141
|
+
// Handle click event
|
|
142
|
+
link.onclick = () => {
|
|
143
|
+
setTimeout(() => {
|
|
144
|
+
URL.revokeObjectURL(url);
|
|
145
|
+
resolve();
|
|
146
|
+
}, 100);
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
document.body.appendChild(link);
|
|
150
|
+
link.click();
|
|
151
|
+
document.body.removeChild(link);
|
|
152
|
+
} catch (error) {
|
|
153
|
+
console.error('Failed to export data to CSV:', error);
|
|
154
|
+
reject(error);
|
|
155
|
+
}
|
|
156
|
+
});
|
|
126
157
|
}
|
|
@@ -9,10 +9,57 @@ import type { HierarchicalDataRow } from '../types';
|
|
|
9
9
|
import type { SortingState } from '@tanstack/react-table';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
* Sorts hierarchical data
|
|
13
|
-
*
|
|
12
|
+
* Sorts hierarchical data by structure only (parents before children).
|
|
13
|
+
* This is the basic hierarchical ordering without any column-based sorting.
|
|
14
|
+
*
|
|
15
|
+
* @param data - Array of hierarchical data rows
|
|
16
|
+
* @returns Data sorted with parents first, then their children
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```tsx
|
|
20
|
+
* const sorted = sortHierarchicalDataByStructure([...data]);
|
|
21
|
+
* ```
|
|
14
22
|
*/
|
|
15
|
-
export function
|
|
23
|
+
export function sortHierarchicalDataByStructure<TData extends HierarchicalDataRow>(
|
|
24
|
+
data: TData[]
|
|
25
|
+
): TData[] {
|
|
26
|
+
const sorted: TData[] = [];
|
|
27
|
+
const processed = new Set<string>();
|
|
28
|
+
|
|
29
|
+
// First, add all parent rows
|
|
30
|
+
data.forEach(row => {
|
|
31
|
+
if (row.isParent && !processed.has(row.id)) {
|
|
32
|
+
sorted.push(row);
|
|
33
|
+
processed.add(row.id);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// Then, add children in order
|
|
38
|
+
data.forEach(row => {
|
|
39
|
+
if (!row.isParent && !processed.has(row.id)) {
|
|
40
|
+
sorted.push(row);
|
|
41
|
+
processed.add(row.id);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
return sorted;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Sorts hierarchical data while preserving parent-child relationships.
|
|
50
|
+
* Parent rows maintain their order, child rows are sorted within their parent groups.
|
|
51
|
+
* This applies column-based sorting based on the provided sorting state.
|
|
52
|
+
*
|
|
53
|
+
* @param data - Array of hierarchical data rows
|
|
54
|
+
* @param sorting - TanStack Table sorting state (column + direction)
|
|
55
|
+
* @returns Data sorted with parents first, children sorted within each parent
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```tsx
|
|
59
|
+
* const sorted = sortHierarchicalDataWithSorting(data, [{ id: 'name', desc: false }]);
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export function sortHierarchicalDataWithSorting<TData extends HierarchicalDataRow>(
|
|
16
63
|
data: TData[],
|
|
17
64
|
sorting: SortingState
|
|
18
65
|
): TData[] {
|