@jmruthers/pace-core 0.5.54 → 0.5.55
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/README.md +0 -4
- package/dist/{DataTable-7FMFXA7A.js → DataTable-4T627QFJ.js} +11 -11
- package/dist/{PublicLoadingSpinner-Bq_-BeK-.d.ts → PublicLoadingSpinner-SL8WaQN7.d.ts} +2 -21
- package/dist/{api-H5A3H4IR.js → api-LUNF5O6M.js} +3 -3
- package/dist/{appConfig-BVGyuvI7.d.ts → appConfig-DjpeG6P-.d.ts} +9 -1
- package/dist/{appNameResolver-7GHF5ED2.js → appNameResolver-UURKN7NF.js} +2 -2
- package/dist/{audit-BUW3LMJB.js → audit-6TOCAMKO.js} +2 -2
- package/dist/{chunk-MZBUOP4P.js → chunk-5BSLGBYI.js} +4 -3
- package/dist/chunk-5BSLGBYI.js.map +1 -0
- package/dist/{chunk-I5Z3QH5X.js → chunk-66C4BSAY.js} +2 -2
- package/dist/{chunk-I5Z3QH5X.js.map → chunk-66C4BSAY.js.map} +1 -1
- package/dist/{chunk-MYP2EGHX.js → chunk-AJ2KMES7.js} +21 -14
- package/dist/chunk-AJ2KMES7.js.map +1 -0
- package/dist/{chunk-EL2O4IUX.js → chunk-AQFRLC7K.js} +16 -24
- package/dist/{chunk-EL2O4IUX.js.map → chunk-AQFRLC7K.js.map} +1 -1
- package/dist/{chunk-7BNPOCLL.js → chunk-B2WTCLCV.js} +6 -2
- package/dist/chunk-B2WTCLCV.js.map +1 -0
- package/dist/{chunk-WJARTBCT.js → chunk-D7ARGIA3.js} +16 -7
- package/dist/chunk-D7ARGIA3.js.map +1 -0
- package/dist/{chunk-NRK4AIHQ.js → chunk-KBRACSJI.js} +3 -3
- package/dist/{chunk-NYUJ4FJR.js → chunk-KJDPSM64.js} +7 -7
- package/dist/chunk-KJDPSM64.js.map +1 -0
- package/dist/{chunk-GWSBHC4J.js → chunk-KLPVOPRI.js} +261 -38
- package/dist/chunk-KLPVOPRI.js.map +1 -0
- package/dist/{chunk-TRIZ7IB7.js → chunk-MPQDF75X.js} +148 -288
- package/dist/chunk-MPQDF75X.js.map +1 -0
- package/dist/{chunk-MSFACPQQ.js → chunk-PAEM3OWN.js} +11 -11
- package/dist/{chunk-MSFACPQQ.js.map → chunk-PAEM3OWN.js.map} +1 -1
- package/dist/{chunk-GIO7BFE7.js → chunk-RQD3D2CO.js} +66 -169
- package/dist/{chunk-GIO7BFE7.js.map → chunk-RQD3D2CO.js.map} +1 -1
- package/dist/{chunk-YDJW5XTN.js → chunk-STT7INZR.js} +25 -1
- package/dist/chunk-STT7INZR.js.map +1 -0
- package/dist/{chunk-6MTY77WU.js → chunk-TNMXZLDR.js} +3 -3
- package/dist/{chunk-BC3S53OZ.js → chunk-UQE2Y64H.js} +30 -14
- package/dist/chunk-UQE2Y64H.js.map +1 -0
- package/dist/{chunk-22KLBHPS.js → chunk-W66AZIOH.js} +2 -2
- package/dist/chunk-W66AZIOH.js.map +1 -0
- package/dist/{chunk-SS3E6QLB.js → chunk-YNUBMSMV.js} +2 -2
- package/dist/chunk-YNUBMSMV.js.map +1 -0
- package/dist/{chunk-NZ655MWE.js → chunk-ZOD2ZY6X.js} +5 -4
- package/dist/chunk-ZOD2ZY6X.js.map +1 -0
- package/dist/{chunk-74C6SNEC.js → chunk-ZPK5656W.js} +3 -3
- package/dist/{chunk-74C6SNEC.js.map → chunk-ZPK5656W.js.map} +1 -1
- package/dist/components.d.ts +22 -899
- package/dist/components.js +436 -3118
- package/dist/components.js.map +1 -1
- package/dist/file-reference-9xUOnwyt.d.ts +70 -0
- package/dist/hooks.d.ts +2 -2
- package/dist/hooks.js +10 -10
- package/dist/hooks.js.map +1 -1
- package/dist/index.d.ts +49 -9
- package/dist/index.js +190 -25
- package/dist/index.js.map +1 -1
- package/dist/{organisation-CO3Sh3_D.d.ts → organisation-t-vvQC3g.d.ts} +1 -8
- package/dist/providers.d.ts +2 -2
- package/dist/providers.js +5 -5
- package/dist/rbac/index.d.ts +65 -46
- package/dist/rbac/index.js +10 -12
- package/dist/styles/core.css +0 -125
- package/dist/types.d.ts +2 -1
- package/dist/types.js +3 -1
- package/dist/types.js.map +1 -1
- package/dist/{usePublicRouteParams-B2OcAsur.d.ts → usePublicRouteParams-CdoFxnJK.d.ts} +1 -1
- package/dist/utils.d.ts +3 -4
- package/dist/utils.js +44 -13
- package/dist/utils.js.map +1 -1
- package/docs/FILE_REFERENCE_SYSTEM.md +440 -0
- package/docs/INDEX.md +7 -5
- package/docs/README.md +0 -1
- package/docs/api/README.md +0 -4
- 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 +2 -2
- package/docs/api/classes/PublicErrorBoundary.md +1 -1
- package/docs/api/classes/RBACAuditManager.md +12 -12
- package/docs/api/classes/RBACCache.md +1 -1
- package/docs/api/classes/RBACEngine.md +6 -6
- 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 +281 -0
- package/docs/api/interfaces/AggregateConfig.md +1 -1
- package/docs/api/interfaces/ButtonProps.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/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/EventContextType.md +1 -1
- package/docs/api/interfaces/EventLogoProps.md +1 -1
- package/docs/api/interfaces/EventProviderProps.md +1 -1
- package/docs/api/interfaces/FileSizeLimits.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 +1 -1
- package/docs/api/interfaces/LabelProps.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 +1 -1
- package/docs/api/interfaces/PagePermissionProviderProps.md +1 -1
- package/docs/api/interfaces/PaletteData.md +1 -1
- package/docs/api/interfaces/PermissionEnforcerProps.md +4 -4
- package/docs/api/interfaces/PublicErrorBoundaryProps.md +1 -1
- package/docs/api/interfaces/PublicErrorBoundaryState.md +1 -1
- package/docs/api/interfaces/PublicLoadingSpinnerProps.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/RBACConfig.md +1 -1
- package/docs/api/interfaces/RBACContextType.md +1 -1
- 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 +2 -2
- package/docs/api/interfaces/RouteConfig.md +2 -2
- 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/ToastActionElement.md +1 -1
- package/docs/api/interfaces/ToastProps.md +1 -1
- package/docs/api/interfaces/UnifiedAuthContextType.md +1 -1
- package/docs/api/interfaces/UnifiedAuthProviderProps.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 +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/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 +204 -200
- package/docs/api-reference/components.md +141 -163
- package/docs/api-reference/hooks.md +347 -0
- package/docs/core-concepts/rbac-system.md +69 -16
- package/docs/getting-started/examples/basic-auth-app.md +0 -1
- package/docs/implementation-guides/datatable-rbac-usage.md +12 -11
- package/docs/implementation-guides/file-upload-storage.md +733 -0
- package/docs/implementation-guides/inactivity-tracking.md +779 -0
- package/docs/implementation-guides/organisation-security.md +748 -0
- package/docs/implementation-guides/public-pages-advanced.md +1022 -0
- package/docs/migration/MIGRATION_GUIDE.md +684 -0
- package/docs/migration/README.md +13 -2
- package/docs/migration/rbac-migration.md +73 -0
- package/docs/rbac/examples/rbac-rls-integration-example.md +11 -13
- package/docs/style-guide.md +269 -1
- package/package.json +1 -1
- package/src/__tests__/TESTING_GUIDELINES.md +331 -18
- package/src/__tests__/helpers/supabaseMock.ts +99 -0
- package/src/__tests__/rbac/PagePermissionGuard.test.tsx +10 -7
- package/src/__tests__/shared.ts +6 -0
- package/src/components/DataTable/components/ActionButtons.tsx +2 -2
- package/src/components/DataTable/components/DataTableCore.tsx +2 -2
- package/src/components/DataTable/components/UnifiedTableBody.tsx +1 -1
- package/src/components/DataTable/utils/debugTools.ts +2 -2
- package/src/components/Dialog/Dialog.test.tsx +12 -2
- package/src/components/ErrorBoundary/ErrorBoundary.test.tsx +6 -6
- package/src/components/ErrorBoundary/ErrorBoundary.tsx +2 -2
- package/src/components/FileDisplay.tsx +233 -0
- package/src/components/FileUpload.tsx +176 -0
- package/src/components/Footer/Footer.test.tsx +7 -7
- package/src/components/NavigationMenu/NavigationMenu.test.tsx +13 -6
- package/src/components/OrganisationSelector/OrganisationSelector.test.tsx +30 -3
- package/src/components/OrganisationSelector/OrganisationSelector.tsx +1 -1
- package/src/components/PaceAppLayout/__tests__/PaceAppLayout.rbac.test.tsx +558 -0
- package/src/components/PublicLayout/PublicErrorBoundary.tsx +1 -1
- package/src/components/PublicLayout/PublicPageDebugger.tsx +2 -2
- package/src/components/PublicLayout/PublicPageDiagnostic.tsx +2 -2
- package/src/components/PublicLayout/PublicPageProvider.tsx +2 -2
- package/src/components/Select/Select.test.tsx +50 -15
- package/src/components/SuperAdminGuard.tsx +2 -2
- package/src/components/__tests__/SuperAdminGuard.test.tsx +559 -0
- package/src/components/index.ts +0 -183
- package/src/hooks/__tests__/useOrganisationPermissions.unit.test.tsx +2 -2
- package/src/hooks/__tests__/usePermissionCache.unit.test.ts +1 -1
- package/src/hooks/__tests__/useRBAC.unit.test.ts +191 -138
- package/src/hooks/public/usePublicEvent.ts +2 -2
- package/src/hooks/useAppConfig.ts +3 -3
- package/src/hooks/useComponentPerformance.ts +1 -1
- package/src/hooks/useDataTablePerformance.ts +1 -1
- package/src/hooks/useFileReference.ts +232 -0
- package/src/hooks/useOrganisationPermissions.test.ts +254 -344
- package/src/hooks/useOrganisationPermissions.ts +15 -7
- package/src/hooks/useOrganisationSecurity.test.ts +390 -402
- package/src/hooks/usePerformanceMonitor.ts +1 -1
- package/src/hooks/usePermissionCache.test.ts +264 -395
- package/src/hooks/usePermissionCache.ts +34 -4
- package/src/hooks/useSecureDataAccess.test.ts +486 -0
- package/src/hooks/useSecureDataAccess.ts +4 -1
- package/src/providers/InactivityProvider.tsx +2 -2
- package/src/providers/OrganisationProvider.test.simple.tsx +168 -0
- package/src/providers/OrganisationProvider.test.tsx +168 -0
- package/src/providers/OrganisationProvider.tsx +18 -31
- package/src/providers/UnifiedAuthProvider.test.simple.tsx +205 -0
- package/src/providers/UnifiedAuthProvider.test.tsx +128 -0
- package/src/providers/__tests__/InactivityProvider.test.tsx +3 -4
- package/src/providers/__tests__/OrganisationProvider.test.tsx +19 -14
- package/src/rbac/__tests__/integration.authflow.test.tsx +123 -0
- package/src/rbac/__tests__/integration.navigation.test.tsx +72 -0
- package/src/rbac/__tests__/integration.securedata.test.tsx +92 -0
- package/src/rbac/__tests__/integration.smoke.test.tsx +73 -0
- package/src/rbac/__tests__/rbac-core.test.tsx +26 -22
- package/src/rbac/__tests__/rbac-engine-core-logic.test.ts +411 -0
- package/src/rbac/__tests__/rbac-engine-simplified.test.ts +285 -0
- package/src/rbac/__tests__/rbac-functions.test.ts +655 -0
- package/src/rbac/__tests__/rbac-integration.test.ts +532 -0
- package/src/rbac/__tests__/scenarios.user-role.test.tsx +196 -0
- package/src/rbac/api.test.ts +6 -6
- package/src/rbac/api.ts +2 -2
- package/src/rbac/audit.test.ts +485 -0
- package/src/rbac/audit.ts +7 -1
- package/src/rbac/cache-invalidation.ts +318 -0
- package/src/rbac/cache.test.ts +286 -0
- package/src/rbac/components/EnhancedNavigationMenu.test.tsx +559 -0
- package/src/rbac/components/EnhancedNavigationMenu.tsx +29 -23
- package/src/rbac/components/NavigationProvider.test.tsx +449 -0
- package/src/rbac/components/PagePermissionGuard.tsx +4 -4
- package/src/rbac/components/PagePermissionProvider.test.tsx +479 -0
- package/src/rbac/components/SecureDataProvider.test.tsx +511 -0
- package/src/rbac/components/__tests__/PagePermissionGuard.race-condition.test.tsx +159 -430
- package/src/rbac/components/__tests__/PagePermissionGuard.test.tsx +4 -5
- package/src/rbac/components/__tests__/PagePermissionGuard.verification.test.tsx +112 -118
- package/src/rbac/config.test.ts +410 -0
- package/src/rbac/engine.test.simple.ts +237 -0
- package/src/rbac/engine.test.ts +233 -0
- package/src/rbac/engine.ts +37 -41
- package/src/rbac/examples/CompleteRBACExample.tsx +3 -3
- package/src/rbac/examples/EventBasedApp.tsx +4 -4
- package/src/rbac/hooks/useRBAC.simple.test.ts +16 -0
- package/src/rbac/hooks/useRBAC.test.ts +207 -455
- package/src/rbac/hooks/useRBAC.ts +30 -22
- package/src/rbac/permissions.test.ts +128 -0
- package/src/rbac/permissions.ts +56 -141
- package/src/rbac/providers/RBACProvider.tsx +1 -1
- package/src/rbac/secureClient.test.ts +444 -0
- package/src/rbac/security.test.ts +390 -0
- package/src/rbac/security.ts +1 -1
- package/src/rbac/types.test.ts +382 -0
- package/src/rbac/types.ts +2 -2
- package/src/styles/core.css +0 -125
- package/src/types/file-reference.ts +77 -0
- package/src/types/rbac-functions.ts +290 -0
- package/src/types/supabase.ts +10 -28
- package/src/types/unified.ts +4 -1
- package/src/utils/__tests__/bundleAnalysis.unit.test.ts +81 -55
- package/src/utils/__tests__/lazyLoad.unit.test.tsx +21 -12
- package/src/utils/__tests__/organisationContext.unit.test.ts +13 -7
- package/src/utils/__tests__/performanceBudgets.unit.test.ts +3 -3
- package/src/utils/__tests__/sessionTracking.unit.test.ts +32 -12
- package/src/utils/appConfig.ts +1 -1
- package/src/utils/appIdResolver.test.ts +503 -0
- package/src/utils/appIdResolver.ts +1 -1
- package/src/utils/appNameResolver.test.ts +494 -0
- package/src/utils/appNameResolver.ts +3 -2
- package/src/utils/bundleAnalysis.ts +3 -3
- package/src/utils/debugLogger.ts +1 -1
- package/src/utils/file-reference.ts +263 -0
- package/src/utils/formatDate.test.ts +2 -2
- package/src/utils/organisationContext.test.ts +340 -0
- package/src/utils/organisationContext.ts +19 -6
- package/src/utils/performanceBudgets.ts +2 -2
- package/src/utils/permissionUtils.test.ts +393 -0
- package/src/utils/permissionUtils.ts +5 -2
- package/src/utils/secureDataAccess.test.ts +715 -0
- package/src/utils/secureDataAccess.ts +21 -5
- package/src/utils/sessionTracking.ts +34 -4
- package/src/utils/storage/__tests__/helpers.unit.test.ts +328 -0
- package/src/utils/storage/__tests__/index.unit.test.ts +16 -0
- package/src/utils/storage/helpers.ts +20 -25
- package/src/utils/storage/index.ts +29 -1
- package/src/vite-env.d.ts +17 -0
- package/dist/chunk-22KLBHPS.js.map +0 -1
- package/dist/chunk-7BNPOCLL.js.map +0 -1
- package/dist/chunk-BC3S53OZ.js.map +0 -1
- package/dist/chunk-GWSBHC4J.js.map +0 -1
- package/dist/chunk-MYP2EGHX.js.map +0 -1
- package/dist/chunk-MZBUOP4P.js.map +0 -1
- package/dist/chunk-NYUJ4FJR.js.map +0 -1
- package/dist/chunk-NZ655MWE.js.map +0 -1
- package/dist/chunk-SS3E6QLB.js.map +0 -1
- package/dist/chunk-TRIZ7IB7.js.map +0 -1
- package/dist/chunk-WJARTBCT.js.map +0 -1
- package/dist/chunk-YDJW5XTN.js.map +0 -1
- package/docs/print-components/README.md +0 -258
- package/docs/print-components/api-reference.md +0 -636
- package/docs/print-components/examples/README.md +0 -204
- package/docs/print-components/examples/basic-report.tsx +0 -92
- package/docs/print-components/examples/card-catalog.tsx +0 -149
- package/docs/print-components/examples/cover-page-report.tsx +0 -163
- package/docs/print-components/quick-start.md +0 -363
- package/src/components/PrintButton/PrintButton.tsx +0 -321
- package/src/components/PrintButton/PrintButtonGroup.tsx +0 -84
- package/src/components/PrintButton/PrintToolbar.tsx +0 -94
- package/src/components/PrintButton/__tests__/PrintButton.test.tsx +0 -271
- package/src/components/PrintButton/examples/PrintButtonShowcase.tsx +0 -438
- package/src/components/PrintButton/index.ts +0 -33
- package/src/components/PrintButton/types.ts +0 -173
- package/src/components/PrintCard/PrintCard.tsx +0 -154
- package/src/components/PrintCard/PrintCardContent.tsx +0 -57
- package/src/components/PrintCard/PrintCardFooter.tsx +0 -60
- package/src/components/PrintCard/PrintCardGrid.tsx +0 -91
- package/src/components/PrintCard/PrintCardHeader.tsx +0 -78
- package/src/components/PrintCard/PrintCardImage.tsx +0 -81
- package/src/components/PrintCard/examples/PrintCardShowcase.tsx +0 -239
- package/src/components/PrintCard/index.ts +0 -34
- package/src/components/PrintCard/types.ts +0 -171
- package/src/components/PrintDataTable/PrintDataTable.tsx +0 -215
- package/src/components/PrintDataTable/PrintTableGroup.tsx +0 -90
- package/src/components/PrintDataTable/PrintTableRow.tsx +0 -76
- package/src/components/PrintDataTable/index.ts +0 -25
- package/src/components/PrintDataTable/types.ts +0 -67
- package/src/components/PrintFooter/PrintFooter.tsx +0 -183
- package/src/components/PrintFooter/PrintFooterContent.tsx +0 -71
- package/src/components/PrintFooter/PrintFooterInfo.tsx +0 -86
- package/src/components/PrintFooter/PrintPageNumber.tsx +0 -90
- package/src/components/PrintFooter/examples/PrintFooterShowcase.tsx +0 -390
- package/src/components/PrintFooter/index.ts +0 -30
- package/src/components/PrintFooter/types.ts +0 -149
- package/src/components/PrintGrid/PrintGrid.tsx +0 -180
- package/src/components/PrintGrid/PrintGridBreakpoint.tsx +0 -109
- package/src/components/PrintGrid/PrintGridContainer.tsx +0 -128
- package/src/components/PrintGrid/PrintGridItem.tsx +0 -220
- package/src/components/PrintGrid/examples/PrintGridShowcase.tsx +0 -359
- package/src/components/PrintGrid/index.ts +0 -31
- package/src/components/PrintGrid/types.ts +0 -159
- package/src/components/PrintHeader/PrintCoverHeader.tsx +0 -230
- package/src/components/PrintHeader/PrintHeader.tsx +0 -150
- package/src/components/PrintHeader/index.ts +0 -17
- package/src/components/PrintHeader/types.ts +0 -42
- package/src/components/PrintLayout/PrintLayout.tsx +0 -122
- package/src/components/PrintLayout/PrintLayoutContext.tsx +0 -66
- package/src/components/PrintLayout/PrintPageBreak.tsx +0 -52
- package/src/components/PrintLayout/examples/PrintShowcase.tsx +0 -230
- package/src/components/PrintLayout/index.ts +0 -19
- package/src/components/PrintLayout/types.ts +0 -37
- package/src/components/PrintPageBreak/PrintPageBreak.tsx +0 -120
- package/src/components/PrintPageBreak/PrintPageBreakGroup.tsx +0 -90
- package/src/components/PrintPageBreak/PrintPageBreakIndicator.tsx +0 -112
- package/src/components/PrintPageBreak/examples/PrintPageBreakShowcase.tsx +0 -279
- package/src/components/PrintPageBreak/index.ts +0 -23
- package/src/components/PrintPageBreak/types.ts +0 -94
- package/src/components/PrintSection/PrintColumn.tsx +0 -104
- package/src/components/PrintSection/PrintDivider.tsx +0 -101
- package/src/components/PrintSection/PrintSection.tsx +0 -129
- package/src/components/PrintSection/PrintSectionContent.tsx +0 -75
- package/src/components/PrintSection/PrintSectionHeader.tsx +0 -97
- package/src/components/PrintSection/examples/PrintSectionShowcase.tsx +0 -258
- package/src/components/PrintSection/index.ts +0 -33
- package/src/components/PrintSection/types.ts +0 -155
- package/src/components/PrintText/PrintText.tsx +0 -116
- package/src/components/PrintText/index.ts +0 -16
- package/src/components/PrintText/types.ts +0 -24
- package/src/rbac/__tests__/integration.test.tsx +0 -218
- package/src/utils/print/PrintDataProcessor.ts +0 -390
- package/src/utils/print/examples/PrintUtilitiesShowcase.tsx +0 -397
- package/src/utils/print/index.ts +0 -29
- package/src/utils/print/types.ts +0 -196
- package/src/utils/print/usePrintOptimization.ts +0 -272
- /package/dist/{DataTable-7FMFXA7A.js.map → DataTable-4T627QFJ.js.map} +0 -0
- /package/dist/{api-H5A3H4IR.js.map → api-LUNF5O6M.js.map} +0 -0
- /package/dist/{appNameResolver-7GHF5ED2.js.map → appNameResolver-UURKN7NF.js.map} +0 -0
- /package/dist/{audit-BUW3LMJB.js.map → audit-6TOCAMKO.js.map} +0 -0
- /package/dist/{chunk-NRK4AIHQ.js.map → chunk-KBRACSJI.js.map} +0 -0
- /package/dist/{chunk-6MTY77WU.js.map → chunk-TNMXZLDR.js.map} +0 -0
|
@@ -0,0 +1,494 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file App Name Resolver Tests
|
|
3
|
+
* @package @jmruthers/pace-core
|
|
4
|
+
* @module Utils/AppNameResolver
|
|
5
|
+
* @since 1.0.0
|
|
6
|
+
*
|
|
7
|
+
* Comprehensive tests for app name resolution utility functions covering all critical functionality.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
|
|
11
|
+
import {
|
|
12
|
+
getAppNameFromPackageJson,
|
|
13
|
+
getAppNameFromBuildTime,
|
|
14
|
+
getAppNameFromGlobal,
|
|
15
|
+
getAppNameFromEnvironment,
|
|
16
|
+
getCurrentAppName,
|
|
17
|
+
setRBACAppName
|
|
18
|
+
} from './appNameResolver';
|
|
19
|
+
|
|
20
|
+
// Mock Node.js modules
|
|
21
|
+
const mockFs = {
|
|
22
|
+
existsSync: vi.fn(),
|
|
23
|
+
readFileSync: vi.fn()
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const mockPath = {
|
|
27
|
+
join: vi.fn()
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
vi.mock('fs', () => mockFs);
|
|
31
|
+
vi.mock('path', () => mockPath);
|
|
32
|
+
|
|
33
|
+
describe('App Name Resolver', () => {
|
|
34
|
+
beforeEach(() => {
|
|
35
|
+
vi.clearAllMocks();
|
|
36
|
+
// Reset global variables
|
|
37
|
+
delete (globalThis as any).__RBAC_APP_NAME__;
|
|
38
|
+
delete (globalThis as any).RBAC_APP_NAME;
|
|
39
|
+
delete (globalThis as any).process;
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
afterEach(() => {
|
|
43
|
+
vi.restoreAllMocks();
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
describe('getAppNameFromPackageJson', () => {
|
|
47
|
+
it('reads app name from package.json in Node.js environment', () => {
|
|
48
|
+
// Mock Node.js environment
|
|
49
|
+
Object.defineProperty(global, 'window', { value: undefined, writable: true });
|
|
50
|
+
Object.defineProperty(global, 'require', { value: vi.fn(), writable: true });
|
|
51
|
+
|
|
52
|
+
mockPath.join.mockReturnValue('/path/to/package.json');
|
|
53
|
+
mockFs.existsSync.mockReturnValue(true);
|
|
54
|
+
mockFs.readFileSync.mockReturnValue(JSON.stringify({ name: '@org/my-app' }));
|
|
55
|
+
|
|
56
|
+
const result = getAppNameFromPackageJson();
|
|
57
|
+
|
|
58
|
+
expect(result).toBe('my-app');
|
|
59
|
+
expect(mockPath.join).toHaveBeenCalledWith(expect.any(String), 'package.json');
|
|
60
|
+
expect(mockFs.existsSync).toHaveBeenCalledWith('/path/to/package.json');
|
|
61
|
+
expect(mockFs.readFileSync).toHaveBeenCalledWith('/path/to/package.json', 'utf8');
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('handles scoped packages correctly', () => {
|
|
65
|
+
Object.defineProperty(global, 'window', { value: undefined, writable: true });
|
|
66
|
+
Object.defineProperty(global, 'require', { value: vi.fn(), writable: true });
|
|
67
|
+
|
|
68
|
+
mockPath.join.mockReturnValue('/path/to/package.json');
|
|
69
|
+
mockFs.existsSync.mockReturnValue(true);
|
|
70
|
+
mockFs.readFileSync.mockReturnValue(JSON.stringify({ name: '@myorg/super-app' }));
|
|
71
|
+
|
|
72
|
+
const result = getAppNameFromPackageJson();
|
|
73
|
+
|
|
74
|
+
expect(result).toBe('super-app');
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('handles non-scoped packages correctly', () => {
|
|
78
|
+
Object.defineProperty(global, 'window', { value: undefined, writable: true });
|
|
79
|
+
Object.defineProperty(global, 'require', { value: vi.fn(), writable: true });
|
|
80
|
+
|
|
81
|
+
mockPath.join.mockReturnValue('/path/to/package.json');
|
|
82
|
+
mockFs.existsSync.mockReturnValue(true);
|
|
83
|
+
mockFs.readFileSync.mockReturnValue(JSON.stringify({ name: 'my-app' }));
|
|
84
|
+
|
|
85
|
+
const result = getAppNameFromPackageJson();
|
|
86
|
+
|
|
87
|
+
expect(result).toBe('my-app');
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('tries multiple package.json paths', () => {
|
|
91
|
+
Object.defineProperty(global, 'window', { value: undefined, writable: true });
|
|
92
|
+
Object.defineProperty(global, 'require', { value: vi.fn(), writable: true });
|
|
93
|
+
|
|
94
|
+
mockPath.join
|
|
95
|
+
.mockReturnValueOnce('/path/to/package.json')
|
|
96
|
+
.mockReturnValueOnce('/path/to/../../package.json')
|
|
97
|
+
.mockReturnValueOnce('/path/to/../../../package.json');
|
|
98
|
+
|
|
99
|
+
mockFs.existsSync
|
|
100
|
+
.mockReturnValueOnce(false)
|
|
101
|
+
.mockReturnValueOnce(false)
|
|
102
|
+
.mockReturnValueOnce(true);
|
|
103
|
+
|
|
104
|
+
mockFs.readFileSync.mockReturnValue(JSON.stringify({ name: 'my-app' }));
|
|
105
|
+
|
|
106
|
+
const result = getAppNameFromPackageJson();
|
|
107
|
+
|
|
108
|
+
expect(result).toBe('my-app');
|
|
109
|
+
expect(mockPath.join).toHaveBeenCalledTimes(3);
|
|
110
|
+
expect(mockFs.existsSync).toHaveBeenCalledTimes(3);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it('returns null in browser environment', () => {
|
|
114
|
+
Object.defineProperty(global, 'window', { value: {}, writable: true });
|
|
115
|
+
|
|
116
|
+
const result = getAppNameFromPackageJson();
|
|
117
|
+
|
|
118
|
+
expect(result).toBeNull();
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it('handles missing package.json gracefully', () => {
|
|
122
|
+
Object.defineProperty(global, 'window', { value: undefined, writable: true });
|
|
123
|
+
Object.defineProperty(global, 'require', { value: vi.fn(), writable: true });
|
|
124
|
+
|
|
125
|
+
mockPath.join.mockReturnValue('/path/to/package.json');
|
|
126
|
+
mockFs.existsSync.mockReturnValue(false);
|
|
127
|
+
|
|
128
|
+
const result = getAppNameFromPackageJson();
|
|
129
|
+
|
|
130
|
+
expect(result).toBeNull();
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it('handles invalid JSON gracefully', () => {
|
|
134
|
+
Object.defineProperty(global, 'window', { value: undefined, writable: true });
|
|
135
|
+
Object.defineProperty(global, 'require', { value: vi.fn(), writable: true });
|
|
136
|
+
|
|
137
|
+
mockPath.join.mockReturnValue('/path/to/package.json');
|
|
138
|
+
mockFs.existsSync.mockReturnValue(true);
|
|
139
|
+
mockFs.readFileSync.mockReturnValue('invalid json');
|
|
140
|
+
|
|
141
|
+
const consoleSpy = vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
142
|
+
|
|
143
|
+
const result = getAppNameFromPackageJson();
|
|
144
|
+
|
|
145
|
+
expect(result).toBeNull();
|
|
146
|
+
expect(consoleSpy).toHaveBeenCalledWith(
|
|
147
|
+
'[RBAC] Could not read app name from package.json:',
|
|
148
|
+
expect.any(Error)
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
consoleSpy.mockRestore();
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it('handles missing name field in package.json', () => {
|
|
155
|
+
Object.defineProperty(global, 'window', { value: undefined, writable: true });
|
|
156
|
+
Object.defineProperty(global, 'require', { value: vi.fn(), writable: true });
|
|
157
|
+
|
|
158
|
+
mockPath.join.mockReturnValue('/path/to/package.json');
|
|
159
|
+
mockFs.existsSync.mockReturnValue(true);
|
|
160
|
+
mockFs.readFileSync.mockReturnValue(JSON.stringify({ version: '1.0.0' }));
|
|
161
|
+
|
|
162
|
+
const result = getAppNameFromPackageJson();
|
|
163
|
+
|
|
164
|
+
expect(result).toBeNull();
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
describe('getAppNameFromBuildTime', () => {
|
|
169
|
+
it('reads app name from build-time injected variable', () => {
|
|
170
|
+
(globalThis as any).__RBAC_APP_NAME__ = 'my-app';
|
|
171
|
+
|
|
172
|
+
const result = getAppNameFromBuildTime();
|
|
173
|
+
|
|
174
|
+
expect(result).toBe('my-app');
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it('trims whitespace from build-time variable', () => {
|
|
178
|
+
(globalThis as any).__RBAC_APP_NAME__ = ' my-app ';
|
|
179
|
+
|
|
180
|
+
const result = getAppNameFromBuildTime();
|
|
181
|
+
|
|
182
|
+
expect(result).toBe('my-app');
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
it('returns null when build-time variable is not set', () => {
|
|
186
|
+
const result = getAppNameFromBuildTime();
|
|
187
|
+
|
|
188
|
+
expect(result).toBeNull();
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
it('returns null when build-time variable is empty', () => {
|
|
192
|
+
(globalThis as any).__RBAC_APP_NAME__ = '';
|
|
193
|
+
|
|
194
|
+
const result = getAppNameFromBuildTime();
|
|
195
|
+
|
|
196
|
+
expect(result).toBeNull();
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it('handles errors gracefully', () => {
|
|
200
|
+
// Mock globalThis access to throw error
|
|
201
|
+
Object.defineProperty(globalThis, '__RBAC_APP_NAME__', {
|
|
202
|
+
get: () => { throw new Error('Access denied'); }
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
const result = getAppNameFromBuildTime();
|
|
206
|
+
|
|
207
|
+
expect(result).toBeNull();
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
describe('getAppNameFromGlobal', () => {
|
|
212
|
+
it('reads app name from global variable', () => {
|
|
213
|
+
(globalThis as any).RBAC_APP_NAME = 'my-app';
|
|
214
|
+
|
|
215
|
+
const result = getAppNameFromGlobal();
|
|
216
|
+
|
|
217
|
+
expect(result).toBe('my-app');
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
it('trims whitespace from global variable', () => {
|
|
221
|
+
(globalThis as any).RBAC_APP_NAME = ' my-app ';
|
|
222
|
+
|
|
223
|
+
const result = getAppNameFromGlobal();
|
|
224
|
+
|
|
225
|
+
expect(result).toBe('my-app');
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
it('returns null when global variable is not set', () => {
|
|
229
|
+
const result = getAppNameFromGlobal();
|
|
230
|
+
|
|
231
|
+
expect(result).toBeNull();
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
it('returns null when global variable is empty', () => {
|
|
235
|
+
(globalThis as any).RBAC_APP_NAME = '';
|
|
236
|
+
|
|
237
|
+
const result = getAppNameFromGlobal();
|
|
238
|
+
|
|
239
|
+
expect(result).toBeNull();
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
it('handles errors gracefully', () => {
|
|
243
|
+
// Mock globalThis access to throw error
|
|
244
|
+
Object.defineProperty(globalThis, 'RBAC_APP_NAME', {
|
|
245
|
+
get: () => { throw new Error('Access denied'); }
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
const result = getAppNameFromGlobal();
|
|
249
|
+
|
|
250
|
+
expect(result).toBeNull();
|
|
251
|
+
});
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
describe('getAppNameFromEnvironment', () => {
|
|
255
|
+
it('reads app name from environment variable', () => {
|
|
256
|
+
const originalEnv = process.env;
|
|
257
|
+
process.env = { ...originalEnv, RBAC_APP_NAME: 'my-app' };
|
|
258
|
+
|
|
259
|
+
const result = getAppNameFromEnvironment();
|
|
260
|
+
|
|
261
|
+
expect(result).toBe('my-app');
|
|
262
|
+
|
|
263
|
+
process.env = originalEnv;
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
it('trims whitespace from environment variable', () => {
|
|
267
|
+
const originalEnv = process.env;
|
|
268
|
+
process.env = { ...originalEnv, RBAC_APP_NAME: ' my-app ' };
|
|
269
|
+
|
|
270
|
+
const result = getAppNameFromEnvironment();
|
|
271
|
+
|
|
272
|
+
expect(result).toBe('my-app');
|
|
273
|
+
|
|
274
|
+
process.env = originalEnv;
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
it('returns null when environment variable is not set', () => {
|
|
278
|
+
const originalEnv = process.env;
|
|
279
|
+
process.env = { ...originalEnv };
|
|
280
|
+
delete process.env.RBAC_APP_NAME;
|
|
281
|
+
|
|
282
|
+
const result = getAppNameFromEnvironment();
|
|
283
|
+
|
|
284
|
+
expect(result).toBeNull();
|
|
285
|
+
|
|
286
|
+
process.env = originalEnv;
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
it('returns null when environment variable is empty', () => {
|
|
290
|
+
const originalEnv = process.env;
|
|
291
|
+
process.env = { ...originalEnv, RBAC_APP_NAME: '' };
|
|
292
|
+
|
|
293
|
+
const result = getAppNameFromEnvironment();
|
|
294
|
+
|
|
295
|
+
expect(result).toBeNull();
|
|
296
|
+
|
|
297
|
+
process.env = originalEnv;
|
|
298
|
+
});
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
describe('getCurrentAppName', () => {
|
|
302
|
+
it('returns app name from build-time variable (highest priority)', () => {
|
|
303
|
+
(globalThis as any).__RBAC_APP_NAME__ = 'build-time-app';
|
|
304
|
+
(globalThis as any).RBAC_APP_NAME = 'global-app';
|
|
305
|
+
|
|
306
|
+
const originalEnv = process.env;
|
|
307
|
+
process.env = { ...originalEnv, RBAC_APP_NAME: 'env-app' };
|
|
308
|
+
|
|
309
|
+
const result = getCurrentAppName();
|
|
310
|
+
|
|
311
|
+
expect(result).toBe('build-time-app');
|
|
312
|
+
|
|
313
|
+
process.env = originalEnv;
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
it('falls back to global variable when build-time is not available', () => {
|
|
317
|
+
(globalThis as any).RBAC_APP_NAME = 'global-app';
|
|
318
|
+
|
|
319
|
+
const originalEnv = process.env;
|
|
320
|
+
process.env = { ...originalEnv, RBAC_APP_NAME: 'env-app' };
|
|
321
|
+
|
|
322
|
+
const result = getCurrentAppName();
|
|
323
|
+
|
|
324
|
+
expect(result).toBe('global-app');
|
|
325
|
+
|
|
326
|
+
process.env = originalEnv;
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
it('falls back to environment variable when others are not available', () => {
|
|
330
|
+
const originalEnv = process.env;
|
|
331
|
+
process.env = { ...originalEnv, RBAC_APP_NAME: 'env-app' };
|
|
332
|
+
|
|
333
|
+
const result = getCurrentAppName();
|
|
334
|
+
|
|
335
|
+
expect(result).toBe('env-app');
|
|
336
|
+
|
|
337
|
+
process.env = originalEnv;
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
it('falls back to package.json when others are not available', () => {
|
|
341
|
+
Object.defineProperty(global, 'window', { value: undefined, writable: true });
|
|
342
|
+
Object.defineProperty(global, 'require', { value: vi.fn(), writable: true });
|
|
343
|
+
|
|
344
|
+
mockPath.join.mockReturnValue('/path/to/package.json');
|
|
345
|
+
mockFs.existsSync.mockReturnValue(true);
|
|
346
|
+
mockFs.readFileSync.mockReturnValue(JSON.stringify({ name: 'package-app' }));
|
|
347
|
+
|
|
348
|
+
const result = getCurrentAppName();
|
|
349
|
+
|
|
350
|
+
expect(result).toBe('package-app');
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
it('returns fallback when all methods fail', () => {
|
|
354
|
+
const result = getCurrentAppName();
|
|
355
|
+
|
|
356
|
+
expect(result).toBe('pace-core');
|
|
357
|
+
});
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
describe('setRBACAppName', () => {
|
|
361
|
+
it('sets global app name variable', () => {
|
|
362
|
+
setRBACAppName('my-app');
|
|
363
|
+
|
|
364
|
+
expect((globalThis as any).RBAC_APP_NAME).toBe('my-app');
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
it('trims whitespace when setting app name', () => {
|
|
368
|
+
setRBACAppName(' my-app ');
|
|
369
|
+
|
|
370
|
+
expect((globalThis as any).RBAC_APP_NAME).toBe('my-app');
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
it('handles null/undefined app name', () => {
|
|
374
|
+
setRBACAppName(null as any);
|
|
375
|
+
setRBACAppName(undefined as any);
|
|
376
|
+
|
|
377
|
+
expect((globalThis as any).RBAC_APP_NAME).toBeUndefined();
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
it('handles empty app name', () => {
|
|
381
|
+
setRBACAppName('');
|
|
382
|
+
|
|
383
|
+
expect((globalThis as any).RBAC_APP_NAME).toBe('');
|
|
384
|
+
});
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
describe('Integration Tests', () => {
|
|
388
|
+
it('works with real-world scenarios', () => {
|
|
389
|
+
// Test build-time injection
|
|
390
|
+
(globalThis as any).__RBAC_APP_NAME__ = 'production-app';
|
|
391
|
+
expect(getCurrentAppName()).toBe('production-app');
|
|
392
|
+
|
|
393
|
+
// Test global variable fallback
|
|
394
|
+
delete (globalThis as any).__RBAC_APP_NAME__;
|
|
395
|
+
(globalThis as any).RBAC_APP_NAME = 'development-app';
|
|
396
|
+
expect(getCurrentAppName()).toBe('development-app');
|
|
397
|
+
|
|
398
|
+
// Test environment variable fallback
|
|
399
|
+
delete (globalThis as any).RBAC_APP_NAME__;
|
|
400
|
+
const originalEnv = process.env;
|
|
401
|
+
process.env = { ...originalEnv, RBAC_APP_NAME: 'test-app' };
|
|
402
|
+
expect(getCurrentAppName()).toBe('test-app');
|
|
403
|
+
|
|
404
|
+
process.env = originalEnv;
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
it('handles complex app name patterns', () => {
|
|
408
|
+
const appNames = [
|
|
409
|
+
'my-app',
|
|
410
|
+
'my_app',
|
|
411
|
+
'MyApp',
|
|
412
|
+
'myapp',
|
|
413
|
+
'@org/my-app',
|
|
414
|
+
'my-app-v2',
|
|
415
|
+
'my-app@1.0.0'
|
|
416
|
+
];
|
|
417
|
+
|
|
418
|
+
appNames.forEach(appName => {
|
|
419
|
+
setRBACAppName(appName);
|
|
420
|
+
expect(getCurrentAppName()).toBe(appName);
|
|
421
|
+
});
|
|
422
|
+
});
|
|
423
|
+
});
|
|
424
|
+
|
|
425
|
+
describe('Error Handling', () => {
|
|
426
|
+
it('handles file system errors gracefully', () => {
|
|
427
|
+
Object.defineProperty(global, 'window', { value: undefined, writable: true });
|
|
428
|
+
Object.defineProperty(global, 'require', { value: vi.fn(), writable: true });
|
|
429
|
+
|
|
430
|
+
mockPath.join.mockReturnValue('/path/to/package.json');
|
|
431
|
+
mockFs.existsSync.mockReturnValue(true);
|
|
432
|
+
mockFs.readFileSync.mockImplementation(() => {
|
|
433
|
+
throw new Error('Permission denied');
|
|
434
|
+
});
|
|
435
|
+
|
|
436
|
+
const consoleSpy = vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
437
|
+
|
|
438
|
+
const result = getAppNameFromPackageJson();
|
|
439
|
+
|
|
440
|
+
expect(result).toBeNull();
|
|
441
|
+
expect(consoleSpy).toHaveBeenCalledWith(
|
|
442
|
+
'[RBAC] Could not read app name from package.json:',
|
|
443
|
+
expect.any(Error)
|
|
444
|
+
);
|
|
445
|
+
|
|
446
|
+
consoleSpy.mockRestore();
|
|
447
|
+
});
|
|
448
|
+
|
|
449
|
+
it('handles JSON parsing errors gracefully', () => {
|
|
450
|
+
Object.defineProperty(global, 'window', { value: undefined, writable: true });
|
|
451
|
+
Object.defineProperty(global, 'require', { value: vi.fn(), writable: true });
|
|
452
|
+
|
|
453
|
+
mockPath.join.mockReturnValue('/path/to/package.json');
|
|
454
|
+
mockFs.existsSync.mockReturnValue(true);
|
|
455
|
+
mockFs.readFileSync.mockReturnValue('{ "name": "my-app" }'); // Valid JSON but missing closing brace
|
|
456
|
+
|
|
457
|
+
const consoleSpy = vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
458
|
+
|
|
459
|
+
const result = getAppNameFromPackageJson();
|
|
460
|
+
|
|
461
|
+
expect(result).toBeNull();
|
|
462
|
+
expect(consoleSpy).toHaveBeenCalledWith(
|
|
463
|
+
'[RBAC] Could not read app name from package.json:',
|
|
464
|
+
expect.any(Error)
|
|
465
|
+
);
|
|
466
|
+
|
|
467
|
+
consoleSpy.mockRestore();
|
|
468
|
+
});
|
|
469
|
+
});
|
|
470
|
+
|
|
471
|
+
describe('Performance', () => {
|
|
472
|
+
it('caches results efficiently', () => {
|
|
473
|
+
const startTime = Date.now();
|
|
474
|
+
|
|
475
|
+
// Call multiple times
|
|
476
|
+
for (let i = 0; i < 1000; i++) {
|
|
477
|
+
getCurrentAppName();
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
const endTime = Date.now();
|
|
481
|
+
|
|
482
|
+
expect(endTime - startTime).toBeLessThan(100); // Should be very fast
|
|
483
|
+
});
|
|
484
|
+
|
|
485
|
+
it('handles large app names efficiently', () => {
|
|
486
|
+
const largeAppName = 'a'.repeat(1000);
|
|
487
|
+
setRBACAppName(largeAppName);
|
|
488
|
+
|
|
489
|
+
const result = getCurrentAppName();
|
|
490
|
+
|
|
491
|
+
expect(result).toBe(largeAppName);
|
|
492
|
+
});
|
|
493
|
+
});
|
|
494
|
+
});
|
|
@@ -23,7 +23,8 @@ export function getAppNameFromPackageJson(): string | null {
|
|
|
23
23
|
|
|
24
24
|
// Look for package.json in common locations
|
|
25
25
|
const possiblePaths = [
|
|
26
|
-
|
|
26
|
+
// Only use process.cwd() if we're in a Node.js environment
|
|
27
|
+
...(typeof process !== 'undefined' && process.cwd ? [path.join(process.cwd(), 'package.json')] : []),
|
|
27
28
|
path.join(__dirname, '../../package.json'),
|
|
28
29
|
path.join(__dirname, '../../../package.json'),
|
|
29
30
|
];
|
|
@@ -116,7 +117,7 @@ export function getAppNameFromEnvironment(): string | null {
|
|
|
116
117
|
];
|
|
117
118
|
|
|
118
119
|
for (const envVar of envVars) {
|
|
119
|
-
const value =
|
|
120
|
+
const value = import.meta.env[envVar];
|
|
120
121
|
if (value && value.trim()) {
|
|
121
122
|
return value.trim();
|
|
122
123
|
}
|
|
@@ -14,7 +14,7 @@ interface ChunkInfo {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
class BundleAnalyzer {
|
|
17
|
-
private enabled =
|
|
17
|
+
private enabled = import.meta.env.MODE === 'development';
|
|
18
18
|
|
|
19
19
|
analyzeBundle(): BundleStats | null {
|
|
20
20
|
if (!this.enabled) return null;
|
|
@@ -104,7 +104,7 @@ export const bundleAnalyzer = new BundleAnalyzer();
|
|
|
104
104
|
|
|
105
105
|
// Helper to check if imports are optimized
|
|
106
106
|
export function validateImportPattern(moduleId: string, importedItems: string[]): void {
|
|
107
|
-
if (
|
|
107
|
+
if (import.meta.env.MODE !== 'development') return;
|
|
108
108
|
|
|
109
109
|
const largeModules = ['lodash', 'moment', 'rxjs'];
|
|
110
110
|
const isLargeModule = largeModules.some(mod => moduleId.includes(mod));
|
|
@@ -121,7 +121,7 @@ export function validateImportPattern(moduleId: string, importedItems: string[])
|
|
|
121
121
|
|
|
122
122
|
// Monitor dynamic imports
|
|
123
123
|
export function trackDynamicImport(moduleName: string): void {
|
|
124
|
-
if (
|
|
124
|
+
if (import.meta.env.MODE !== 'development') return;
|
|
125
125
|
|
|
126
126
|
// TODO: Replace with proper logging service integration
|
|
127
127
|
// For now, we'll log to console for testing purposes
|
package/src/utils/debugLogger.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* Only logs in development mode to prevent production console spam
|
|
11
11
|
*/
|
|
12
12
|
export class DebugLogger {
|
|
13
|
-
private static isDevelopment =
|
|
13
|
+
private static isDevelopment = import.meta.env.MODE === 'development';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Log debug information only in development mode
|