@jmruthers/pace-core 0.5.109 → 0.5.111
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 +22 -0
- package/dist/{AuthService-DrHrvXNZ.d.ts → AuthService-CVgsgtaZ.d.ts} +8 -0
- package/dist/{DataTable-5HITILXS.js → DataTable-5W2HVLLV.js} +8 -8
- package/dist/{UnifiedAuthProvider-A7I23UCN.js → UnifiedAuthProvider-LUM3QLS5.js} +3 -3
- package/dist/{api-5I3E47G2.js → api-SIZPFBFX.js} +5 -3
- package/dist/{audit-65VNHEV2.js → audit-5JI5T3SL.js} +2 -2
- package/dist/{chunk-P72NKAT5.js → chunk-2BIDKXQU.js} +157 -120
- package/dist/chunk-2BIDKXQU.js.map +1 -0
- package/dist/{chunk-S4D3Z723.js → chunk-ACYQNYHB.js} +7 -7
- package/dist/{chunk-D6MEKC27.js → chunk-EFVQBYFN.js} +2 -2
- package/dist/{chunk-EZ64QG2I.js → chunk-I5YM5BGS.js} +2 -2
- package/dist/{chunk-Q7APDV6H.js → chunk-IWJYNWXN.js} +13 -5
- package/dist/chunk-IWJYNWXN.js.map +1 -0
- package/dist/{chunk-YFMENCR4.js → chunk-JE2GFA3O.js} +3 -3
- package/dist/{chunk-AUXS7XSO.js → chunk-MW73E7SP.js} +35 -11
- package/dist/chunk-MW73E7SP.js.map +1 -0
- package/dist/{chunk-F6TSYCKP.js → chunk-PXXS26G5.js} +68 -29
- package/dist/chunk-PXXS26G5.js.map +1 -0
- package/dist/{chunk-UW2DE6JX.js → chunk-TD4BXGPE.js} +4 -4
- package/dist/{chunk-EYSXQ756.js → chunk-TDFBX7KJ.js} +2 -2
- package/dist/{chunk-WWNOVFDC.js → chunk-UGVU7L7N.js} +52 -90
- package/dist/chunk-UGVU7L7N.js.map +1 -0
- package/dist/{chunk-2W4WKJVF.js → chunk-X7SPKHYZ.js} +290 -255
- package/dist/chunk-X7SPKHYZ.js.map +1 -0
- package/dist/{chunk-3TKTL5AZ.js → chunk-ZL45MG76.js} +60 -60
- package/dist/chunk-ZL45MG76.js.map +1 -0
- package/dist/components.js +10 -10
- package/dist/hooks.d.ts +11 -1
- package/dist/hooks.js +9 -7
- package/dist/hooks.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +13 -13
- package/dist/providers.d.ts +2 -2
- package/dist/providers.js +2 -2
- package/dist/rbac/index.d.ts +46 -29
- package/dist/rbac/index.js +9 -9
- package/dist/utils.js +1 -1
- package/docs/api/classes/ColumnFactory.md +1 -1
- package/docs/api/classes/ErrorBoundary.md +1 -1
- package/docs/api/classes/InvalidScopeError.md +4 -4
- package/docs/api/classes/MissingUserContextError.md +4 -4
- package/docs/api/classes/OrganisationContextRequiredError.md +4 -4
- package/docs/api/classes/PermissionDeniedError.md +4 -4
- package/docs/api/classes/PublicErrorBoundary.md +1 -1
- package/docs/api/classes/RBACAuditManager.md +8 -8
- package/docs/api/classes/RBACCache.md +8 -8
- package/docs/api/classes/RBACEngine.md +9 -8
- package/docs/api/classes/RBACError.md +4 -4
- package/docs/api/classes/RBACNotInitializedError.md +4 -4
- 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 +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/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/EmptyStateConfig.md +1 -1
- package/docs/api/interfaces/EnhancedNavigationMenuProps.md +1 -1
- 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 +1 -1
- 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 +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 +27 -27
- package/docs/api/interfaces/PaceLoginPageProps.md +4 -4
- 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/ProtectedRouteProps.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 +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 +19 -8
- package/docs/api/interfaces/RBACLogger.md +5 -5
- package/docs/api/interfaces/RoleBasedRouterContextType.md +8 -8
- package/docs/api/interfaces/RoleBasedRouterProps.md +10 -10
- package/docs/api/interfaces/RouteAccessRecord.md +10 -10
- package/docs/api/interfaces/RouteConfig.md +19 -6
- 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 +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/UsePublicEventOptions.md +1 -1
- package/docs/api/interfaces/UsePublicEventReturn.md +1 -1
- package/docs/api/interfaces/UsePublicFileDisplayOptions.md +1 -1
- package/docs/api/interfaces/UsePublicFileDisplayReturn.md +1 -1
- package/docs/api/interfaces/UsePublicRouteParamsReturn.md +1 -1
- package/docs/api/interfaces/UseResolvedScopeOptions.md +1 -1
- package/docs/api/interfaces/UseResolvedScopeReturn.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 +44 -43
- package/docs/api-reference/hooks.md +8 -4
- package/docs/architecture/rpc-function-standards.md +3 -1
- package/docs/best-practices/common-patterns.md +3 -3
- package/docs/best-practices/deployment.md +10 -4
- package/docs/best-practices/performance.md +11 -3
- package/docs/core-concepts/organisations.md +8 -8
- package/docs/core-concepts/permissions.md +133 -72
- package/docs/documentation-index.md +0 -2
- package/docs/migration/rbac-migration.md +65 -66
- package/docs/rbac/README.md +114 -38
- package/docs/rbac/advanced-patterns.md +15 -22
- package/docs/rbac/api-reference.md +63 -16
- package/docs/rbac/examples.md +12 -12
- package/docs/rbac/getting-started.md +19 -19
- package/docs/rbac/quick-start.md +110 -35
- package/docs/rbac/troubleshooting.md +127 -3
- package/package.json +1 -1
- package/src/components/DataTable/components/__tests__/ActionButtons.test.tsx +913 -0
- package/src/components/DataTable/components/__tests__/ColumnFilter.test.tsx +609 -0
- package/src/components/DataTable/components/__tests__/EmptyState.test.tsx +434 -0
- package/src/components/DataTable/components/__tests__/LoadingState.test.tsx +120 -0
- package/src/components/DataTable/components/__tests__/PaginationControls.test.tsx +519 -0
- package/src/components/DataTable/examples/__tests__/HierarchicalActionsExample.test.tsx +316 -0
- package/src/components/DataTable/examples/__tests__/InitialPageSizeExample.test.tsx +211 -0
- package/src/components/FileUpload/FileUpload.tsx +2 -8
- package/src/components/NavigationMenu/NavigationMenu.test.tsx +38 -4
- package/src/components/NavigationMenu/NavigationMenu.tsx +71 -6
- package/src/components/PaceAppLayout/PaceAppLayout.test.tsx +193 -63
- package/src/components/PaceAppLayout/PaceAppLayout.tsx +102 -135
- package/src/components/PaceAppLayout/__tests__/PaceAppLayout.accessibility.test.tsx +41 -2
- package/src/components/PaceAppLayout/__tests__/PaceAppLayout.integration.test.tsx +61 -6
- package/src/components/PaceAppLayout/__tests__/PaceAppLayout.performance.test.tsx +71 -21
- package/src/components/PaceAppLayout/__tests__/PaceAppLayout.security.test.tsx +113 -41
- package/src/components/PaceAppLayout/__tests__/PaceAppLayout.unit.test.tsx +155 -45
- package/src/components/PaceLoginPage/PaceLoginPage.tsx +30 -1
- package/src/hooks/__tests__/usePermissionCache.simple.test.ts +63 -5
- package/src/hooks/__tests__/usePermissionCache.unit.test.ts +156 -72
- package/src/hooks/__tests__/useRBAC.unit.test.ts +4 -38
- package/src/hooks/index.ts +1 -1
- package/src/hooks/useFileDisplay.ts +51 -0
- package/src/hooks/usePermissionCache.test.ts +112 -68
- package/src/hooks/usePermissionCache.ts +55 -15
- package/src/rbac/README.md +81 -39
- package/src/rbac/__tests__/adapters.comprehensive.test.tsx +3 -3
- package/src/rbac/__tests__/engine.comprehensive.test.ts +15 -6
- package/src/rbac/__tests__/rbac-core.test.tsx +1 -1
- package/src/rbac/__tests__/rbac-engine-core-logic.test.ts +57 -4
- package/src/rbac/__tests__/rbac-engine-simplified.test.ts +3 -2
- package/src/rbac/adapters.tsx +4 -4
- package/src/rbac/api.test.ts +39 -15
- package/src/rbac/api.ts +27 -9
- package/src/rbac/audit.test.ts +2 -2
- package/src/rbac/audit.ts +14 -5
- package/src/rbac/cache.test.ts +12 -0
- package/src/rbac/cache.ts +29 -9
- package/src/rbac/components/EnhancedNavigationMenu.test.tsx +1 -1
- package/src/rbac/components/NavigationGuard.tsx +14 -14
- package/src/rbac/components/NavigationProvider.test.tsx +1 -1
- package/src/rbac/components/PagePermissionGuard.tsx +22 -38
- package/src/rbac/components/PagePermissionProvider.test.tsx +1 -1
- package/src/rbac/components/PermissionEnforcer.tsx +19 -15
- package/src/rbac/components/RoleBasedRouter.tsx +16 -9
- package/src/rbac/components/__tests__/NavigationGuard.test.tsx +123 -107
- package/src/rbac/components/__tests__/PagePermissionGuard.test.tsx +2 -2
- package/src/rbac/components/__tests__/PermissionEnforcer.test.tsx +121 -103
- package/src/rbac/config.ts +2 -0
- package/src/rbac/docs/event-based-apps.md +6 -6
- package/src/rbac/engine.ts +27 -7
- package/src/rbac/hooks/useCan.test.ts +29 -2
- package/src/rbac/hooks/usePermissions.test.ts +25 -25
- package/src/rbac/hooks/usePermissions.ts +47 -23
- package/src/rbac/hooks/useRBAC.simple.test.ts +1 -8
- package/src/rbac/hooks/useRBAC.test.ts +3 -40
- package/src/rbac/hooks/useRBAC.ts +0 -55
- package/src/rbac/hooks/useResolvedScope.ts +23 -31
- package/src/rbac/permissions.test.ts +11 -7
- package/src/rbac/security.test.ts +2 -2
- package/src/rbac/security.ts +23 -8
- package/src/rbac/types.test.ts +2 -2
- package/src/rbac/types.ts +1 -2
- package/src/services/EventService.ts +41 -13
- package/src/services/__tests__/EventService.test.ts +25 -4
- package/src/services/interfaces/IEventService.ts +1 -0
- package/src/utils/file-reference.ts +9 -0
- package/dist/chunk-2W4WKJVF.js.map +0 -1
- package/dist/chunk-3TKTL5AZ.js.map +0 -1
- package/dist/chunk-AUXS7XSO.js.map +0 -1
- package/dist/chunk-F6TSYCKP.js.map +0 -1
- package/dist/chunk-P72NKAT5.js.map +0 -1
- package/dist/chunk-Q7APDV6H.js.map +0 -1
- package/dist/chunk-WWNOVFDC.js.map +0 -1
- package/docs/rbac/breaking-changes-v3.md +0 -222
- package/docs/rbac/migration-guide.md +0 -260
- /package/dist/{DataTable-5HITILXS.js.map → DataTable-5W2HVLLV.js.map} +0 -0
- /package/dist/{UnifiedAuthProvider-A7I23UCN.js.map → UnifiedAuthProvider-LUM3QLS5.js.map} +0 -0
- /package/dist/{api-5I3E47G2.js.map → api-SIZPFBFX.js.map} +0 -0
- /package/dist/{audit-65VNHEV2.js.map → audit-5JI5T3SL.js.map} +0 -0
- /package/dist/{chunk-S4D3Z723.js.map → chunk-ACYQNYHB.js.map} +0 -0
- /package/dist/{chunk-D6MEKC27.js.map → chunk-EFVQBYFN.js.map} +0 -0
- /package/dist/{chunk-EZ64QG2I.js.map → chunk-I5YM5BGS.js.map} +0 -0
- /package/dist/{chunk-YFMENCR4.js.map → chunk-JE2GFA3O.js.map} +0 -0
- /package/dist/{chunk-UW2DE6JX.js.map → chunk-TD4BXGPE.js.map} +0 -0
- /package/dist/{chunk-EYSXQ756.js.map → chunk-TDFBX7KJ.js.map} +0 -0
package/docs/api/modules.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
[@jmruthers/pace-core - v0.5.
|
|
1
|
+
[@jmruthers/pace-core - v0.5.111](README.md) / Exports
|
|
2
2
|
|
|
3
|
-
# @jmruthers/pace-core - v0.5.
|
|
3
|
+
# @jmruthers/pace-core - v0.5.111
|
|
4
4
|
|
|
5
5
|
**`File`**
|
|
6
6
|
|
|
@@ -499,7 +499,7 @@ ___
|
|
|
499
499
|
|
|
500
500
|
#### Defined in
|
|
501
501
|
|
|
502
|
-
[packages/core/src/rbac/config.ts:
|
|
502
|
+
[packages/core/src/rbac/config.ts:14](https://github.com/jmruthers/pace-core/blob/main/packages/core/src/rbac/config.ts#L14)
|
|
503
503
|
|
|
504
504
|
___
|
|
505
505
|
|
|
@@ -641,7 +641,7 @@ You can create additional instances if needed for different contexts.
|
|
|
641
641
|
|
|
642
642
|
#### Defined in
|
|
643
643
|
|
|
644
|
-
[packages/core/src/rbac/cache.ts:
|
|
644
|
+
[packages/core/src/rbac/cache.ts:256](https://github.com/jmruthers/pace-core/blob/main/packages/core/src/rbac/cache.ts#L256)
|
|
645
645
|
|
|
646
646
|
___
|
|
647
647
|
|
|
@@ -663,7 +663,7 @@ Cache key patterns for invalidation
|
|
|
663
663
|
|
|
664
664
|
#### Defined in
|
|
665
665
|
|
|
666
|
-
[packages/core/src/rbac/cache.ts:
|
|
666
|
+
[packages/core/src/rbac/cache.ts:261](https://github.com/jmruthers/pace-core/blob/main/packages/core/src/rbac/cache.ts#L261)
|
|
667
667
|
|
|
668
668
|
___
|
|
669
669
|
|
|
@@ -2436,7 +2436,7 @@ function AdminApp() {
|
|
|
2436
2436
|
|
|
2437
2437
|
#### Defined in
|
|
2438
2438
|
|
|
2439
|
-
[packages/core/src/components/PaceAppLayout/PaceAppLayout.tsx:
|
|
2439
|
+
[packages/core/src/components/PaceAppLayout/PaceAppLayout.tsx:327](https://github.com/jmruthers/pace-core/blob/main/packages/core/src/components/PaceAppLayout/PaceAppLayout.tsx#L327)
|
|
2440
2440
|
|
|
2441
2441
|
___
|
|
2442
2442
|
|
|
@@ -2480,7 +2480,7 @@ JSX.Element - The rendered login page with enhanced functionality
|
|
|
2480
2480
|
|
|
2481
2481
|
#### Defined in
|
|
2482
2482
|
|
|
2483
|
-
[packages/core/src/components/PaceLoginPage/PaceLoginPage.tsx:
|
|
2483
|
+
[packages/core/src/components/PaceLoginPage/PaceLoginPage.tsx:166](https://github.com/jmruthers/pace-core/blob/main/packages/core/src/components/PaceLoginPage/PaceLoginPage.tsx#L166)
|
|
2484
2484
|
|
|
2485
2485
|
___
|
|
2486
2486
|
|
|
@@ -4529,7 +4529,7 @@ Can auto-infer userId from context if not provided.
|
|
|
4529
4529
|
<PermissionGuard
|
|
4530
4530
|
userId="user-123"
|
|
4531
4531
|
scope={{ organisationId: 'org-456' }}
|
|
4532
|
-
permission="
|
|
4532
|
+
permission="update:events"
|
|
4533
4533
|
pageId="page-789"
|
|
4534
4534
|
fallback={<AccessDenied />}
|
|
4535
4535
|
>
|
|
@@ -4538,7 +4538,7 @@ Can auto-infer userId from context if not provided.
|
|
|
4538
4538
|
|
|
4539
4539
|
// With context inference (requires auth context)
|
|
4540
4540
|
<PermissionGuard
|
|
4541
|
-
permission="
|
|
4541
|
+
permission="update:events"
|
|
4542
4542
|
scope={{ organisationId: 'org-456' }}
|
|
4543
4543
|
fallback={<AccessDenied />}
|
|
4544
4544
|
>
|
|
@@ -4654,7 +4654,7 @@ Wrapped handler function
|
|
|
4654
4654
|
|
|
4655
4655
|
```typescript
|
|
4656
4656
|
const protectedHandler = withPermissionGuard(
|
|
4657
|
-
{ permission: '
|
|
4657
|
+
{ permission: 'update:events', pageId: 'page-789' },
|
|
4658
4658
|
async (req, res) => {
|
|
4659
4659
|
// Handler logic here
|
|
4660
4660
|
res.json({ success: true });
|
|
@@ -4841,7 +4841,7 @@ import { createRBACMiddleware } from '@jmruthers/pace-core/rbac';
|
|
|
4841
4841
|
|
|
4842
4842
|
export default createRBACMiddleware({
|
|
4843
4843
|
protectedRoutes: [
|
|
4844
|
-
{ path: '/admin', permission: '
|
|
4844
|
+
{ path: '/admin', permission: 'update:admin' },
|
|
4845
4845
|
{ path: '/events', permission: 'read:events' },
|
|
4846
4846
|
],
|
|
4847
4847
|
fallbackUrl: '/access-denied',
|
|
@@ -4992,7 +4992,7 @@ Setup RBAC system
|
|
|
4992
4992
|
|
|
4993
4993
|
#### Defined in
|
|
4994
4994
|
|
|
4995
|
-
[packages/core/src/rbac/api.ts:
|
|
4995
|
+
[packages/core/src/rbac/api.ts:39](https://github.com/jmruthers/pace-core/blob/main/packages/core/src/rbac/api.ts#L39)
|
|
4996
4996
|
|
|
4997
4997
|
___
|
|
4998
4998
|
|
|
@@ -5027,7 +5027,7 @@ const accessLevel = await getAccessLevel({
|
|
|
5027
5027
|
|
|
5028
5028
|
#### Defined in
|
|
5029
5029
|
|
|
5030
|
-
[packages/core/src/rbac/api.ts:
|
|
5030
|
+
[packages/core/src/rbac/api.ts:90](https://github.com/jmruthers/pace-core/blob/main/packages/core/src/rbac/api.ts#L90)
|
|
5031
5031
|
|
|
5032
5032
|
___
|
|
5033
5033
|
|
|
@@ -5066,7 +5066,7 @@ const permissions = await getPermissionMap({
|
|
|
5066
5066
|
|
|
5067
5067
|
#### Defined in
|
|
5068
5068
|
|
|
5069
|
-
[packages/core/src/rbac/api.ts:
|
|
5069
|
+
[packages/core/src/rbac/api.ts:116](https://github.com/jmruthers/pace-core/blob/main/packages/core/src/rbac/api.ts#L116)
|
|
5070
5070
|
|
|
5071
5071
|
___
|
|
5072
5072
|
|
|
@@ -5088,7 +5088,7 @@ ___
|
|
|
5088
5088
|
|
|
5089
5089
|
#### Defined in
|
|
5090
5090
|
|
|
5091
|
-
[packages/core/src/rbac/api.ts:
|
|
5091
|
+
[packages/core/src/rbac/api.ts:124](https://github.com/jmruthers/pace-core/blob/main/packages/core/src/rbac/api.ts#L124)
|
|
5092
5092
|
|
|
5093
5093
|
___
|
|
5094
5094
|
|
|
@@ -5110,7 +5110,7 @@ ___
|
|
|
5110
5110
|
|
|
5111
5111
|
#### Defined in
|
|
5112
5112
|
|
|
5113
|
-
[packages/core/src/rbac/api.ts:
|
|
5113
|
+
[packages/core/src/rbac/api.ts:132](https://github.com/jmruthers/pace-core/blob/main/packages/core/src/rbac/api.ts#L132)
|
|
5114
5114
|
|
|
5115
5115
|
___
|
|
5116
5116
|
|
|
@@ -5138,14 +5138,14 @@ Promise resolving to permission result
|
|
|
5138
5138
|
const canManage = await isPermitted({
|
|
5139
5139
|
userId: 'user-123',
|
|
5140
5140
|
scope: { organisationId: 'org-456' },
|
|
5141
|
-
permission: '
|
|
5141
|
+
permission: 'update:events',
|
|
5142
5142
|
pageId: 'page-789'
|
|
5143
5143
|
});
|
|
5144
5144
|
```
|
|
5145
5145
|
|
|
5146
5146
|
#### Defined in
|
|
5147
5147
|
|
|
5148
|
-
[packages/core/src/rbac/api.ts:
|
|
5148
|
+
[packages/core/src/rbac/api.ts:156](https://github.com/jmruthers/pace-core/blob/main/packages/core/src/rbac/api.ts#L156)
|
|
5149
5149
|
|
|
5150
5150
|
___
|
|
5151
5151
|
|
|
@@ -5169,7 +5169,7 @@ Promise resolving to permission result
|
|
|
5169
5169
|
|
|
5170
5170
|
#### Defined in
|
|
5171
5171
|
|
|
5172
|
-
[packages/core/src/rbac/api.ts:
|
|
5172
|
+
[packages/core/src/rbac/api.ts:182](https://github.com/jmruthers/pace-core/blob/main/packages/core/src/rbac/api.ts#L182)
|
|
5173
5173
|
|
|
5174
5174
|
___
|
|
5175
5175
|
|
|
@@ -5193,7 +5193,7 @@ Promise<boolean> - True if user has permission
|
|
|
5193
5193
|
|
|
5194
5194
|
#### Defined in
|
|
5195
5195
|
|
|
5196
|
-
[packages/core/src/rbac/api.ts:
|
|
5196
|
+
[packages/core/src/rbac/api.ts:215](https://github.com/jmruthers/pace-core/blob/main/packages/core/src/rbac/api.ts#L215)
|
|
5197
5197
|
|
|
5198
5198
|
___
|
|
5199
5199
|
|
|
@@ -5221,7 +5221,7 @@ Promise resolving to true if user has any permission
|
|
|
5221
5221
|
|
|
5222
5222
|
#### Defined in
|
|
5223
5223
|
|
|
5224
|
-
[packages/core/src/rbac/api.ts:
|
|
5224
|
+
[packages/core/src/rbac/api.ts:225](https://github.com/jmruthers/pace-core/blob/main/packages/core/src/rbac/api.ts#L225)
|
|
5225
5225
|
|
|
5226
5226
|
___
|
|
5227
5227
|
|
|
@@ -5249,7 +5249,7 @@ Promise resolving to true if user has all permissions
|
|
|
5249
5249
|
|
|
5250
5250
|
#### Defined in
|
|
5251
5251
|
|
|
5252
|
-
[packages/core/src/rbac/api.ts:
|
|
5252
|
+
[packages/core/src/rbac/api.ts:253](https://github.com/jmruthers/pace-core/blob/main/packages/core/src/rbac/api.ts#L253)
|
|
5253
5253
|
|
|
5254
5254
|
___
|
|
5255
5255
|
|
|
@@ -5273,7 +5273,7 @@ RBACAuditManager instance
|
|
|
5273
5273
|
|
|
5274
5274
|
#### Defined in
|
|
5275
5275
|
|
|
5276
|
-
[packages/core/src/rbac/audit.ts:
|
|
5276
|
+
[packages/core/src/rbac/audit.ts:330](https://github.com/jmruthers/pace-core/blob/main/packages/core/src/rbac/audit.ts#L330)
|
|
5277
5277
|
|
|
5278
5278
|
___
|
|
5279
5279
|
|
|
@@ -5295,7 +5295,7 @@ Set the global audit manager
|
|
|
5295
5295
|
|
|
5296
5296
|
#### Defined in
|
|
5297
5297
|
|
|
5298
|
-
[packages/core/src/rbac/audit.ts:
|
|
5298
|
+
[packages/core/src/rbac/audit.ts:346](https://github.com/jmruthers/pace-core/blob/main/packages/core/src/rbac/audit.ts#L346)
|
|
5299
5299
|
|
|
5300
5300
|
___
|
|
5301
5301
|
|
|
@@ -5313,7 +5313,7 @@ Global audit manager or null if not set
|
|
|
5313
5313
|
|
|
5314
5314
|
#### Defined in
|
|
5315
5315
|
|
|
5316
|
-
[packages/core/src/rbac/audit.ts:
|
|
5316
|
+
[packages/core/src/rbac/audit.ts:355](https://github.com/jmruthers/pace-core/blob/main/packages/core/src/rbac/audit.ts#L355)
|
|
5317
5317
|
|
|
5318
5318
|
___
|
|
5319
5319
|
|
|
@@ -5335,7 +5335,7 @@ Emit an audit event using the global audit manager
|
|
|
5335
5335
|
|
|
5336
5336
|
#### Defined in
|
|
5337
5337
|
|
|
5338
|
-
[packages/core/src/rbac/audit.ts:
|
|
5338
|
+
[packages/core/src/rbac/audit.ts:364](https://github.com/jmruthers/pace-core/blob/main/packages/core/src/rbac/audit.ts#L364)
|
|
5339
5339
|
|
|
5340
5340
|
___
|
|
5341
5341
|
|
|
@@ -5467,7 +5467,7 @@ React element with permission enforcement
|
|
|
5467
5467
|
|
|
5468
5468
|
#### Defined in
|
|
5469
5469
|
|
|
5470
|
-
[packages/core/src/rbac/components/PagePermissionGuard.tsx:
|
|
5470
|
+
[packages/core/src/rbac/components/PagePermissionGuard.tsx:534](https://github.com/jmruthers/pace-core/blob/main/packages/core/src/rbac/components/PagePermissionGuard.tsx#L534)
|
|
5471
5471
|
|
|
5472
5472
|
___
|
|
5473
5473
|
|
|
@@ -5571,7 +5571,7 @@ React element with role-based routing
|
|
|
5571
5571
|
|
|
5572
5572
|
#### Defined in
|
|
5573
5573
|
|
|
5574
|
-
[packages/core/src/rbac/components/RoleBasedRouter.tsx:
|
|
5574
|
+
[packages/core/src/rbac/components/RoleBasedRouter.tsx:181](https://github.com/jmruthers/pace-core/blob/main/packages/core/src/rbac/components/RoleBasedRouter.tsx#L181)
|
|
5575
5575
|
|
|
5576
5576
|
___
|
|
5577
5577
|
|
|
@@ -5593,7 +5593,7 @@ Error if used outside of RoleBasedRouter
|
|
|
5593
5593
|
|
|
5594
5594
|
#### Defined in
|
|
5595
5595
|
|
|
5596
|
-
[packages/core/src/rbac/components/RoleBasedRouter.tsx:
|
|
5596
|
+
[packages/core/src/rbac/components/RoleBasedRouter.tsx:395](https://github.com/jmruthers/pace-core/blob/main/packages/core/src/rbac/components/RoleBasedRouter.tsx#L395)
|
|
5597
5597
|
|
|
5598
5598
|
___
|
|
5599
5599
|
|
|
@@ -5662,7 +5662,7 @@ ___
|
|
|
5662
5662
|
|
|
5663
5663
|
#### Defined in
|
|
5664
5664
|
|
|
5665
|
-
[packages/core/src/rbac/config.ts:
|
|
5665
|
+
[packages/core/src/rbac/config.ts:112](https://github.com/jmruthers/pace-core/blob/main/packages/core/src/rbac/config.ts#L112)
|
|
5666
5666
|
|
|
5667
5667
|
___
|
|
5668
5668
|
|
|
@@ -5676,7 +5676,7 @@ ___
|
|
|
5676
5676
|
|
|
5677
5677
|
#### Defined in
|
|
5678
5678
|
|
|
5679
|
-
[packages/core/src/rbac/config.ts:
|
|
5679
|
+
[packages/core/src/rbac/config.ts:117](https://github.com/jmruthers/pace-core/blob/main/packages/core/src/rbac/config.ts#L117)
|
|
5680
5680
|
|
|
5681
5681
|
___
|
|
5682
5682
|
|
|
@@ -5690,7 +5690,7 @@ ___
|
|
|
5690
5690
|
|
|
5691
5691
|
#### Defined in
|
|
5692
5692
|
|
|
5693
|
-
[packages/core/src/rbac/config.ts:
|
|
5693
|
+
[packages/core/src/rbac/config.ts:121](https://github.com/jmruthers/pace-core/blob/main/packages/core/src/rbac/config.ts#L121)
|
|
5694
5694
|
|
|
5695
5695
|
___
|
|
5696
5696
|
|
|
@@ -5704,7 +5704,7 @@ ___
|
|
|
5704
5704
|
|
|
5705
5705
|
#### Defined in
|
|
5706
5706
|
|
|
5707
|
-
[packages/core/src/rbac/config.ts:
|
|
5707
|
+
[packages/core/src/rbac/config.ts:125](https://github.com/jmruthers/pace-core/blob/main/packages/core/src/rbac/config.ts#L125)
|
|
5708
5708
|
|
|
5709
5709
|
___
|
|
5710
5710
|
|
|
@@ -5718,13 +5718,13 @@ ___
|
|
|
5718
5718
|
|
|
5719
5719
|
#### Defined in
|
|
5720
5720
|
|
|
5721
|
-
[packages/core/src/rbac/config.ts:
|
|
5721
|
+
[packages/core/src/rbac/config.ts:129](https://github.com/jmruthers/pace-core/blob/main/packages/core/src/rbac/config.ts#L129)
|
|
5722
5722
|
|
|
5723
5723
|
___
|
|
5724
5724
|
|
|
5725
5725
|
### createRBACEngine
|
|
5726
5726
|
|
|
5727
|
-
▸ **createRBACEngine**(`supabase`): [`RBACEngine`](classes/RBACEngine.md)
|
|
5727
|
+
▸ **createRBACEngine**(`supabase`, `securityConfig?`): [`RBACEngine`](classes/RBACEngine.md)
|
|
5728
5728
|
|
|
5729
5729
|
Create an RBAC engine instance
|
|
5730
5730
|
|
|
@@ -5733,6 +5733,7 @@ Create an RBAC engine instance
|
|
|
5733
5733
|
| Name | Type | Description |
|
|
5734
5734
|
| :------ | :------ | :------ |
|
|
5735
5735
|
| `supabase` | `default`\<`Database`, ``"public"``, ``"public"``, `never`, {}\> | Supabase client |
|
|
5736
|
+
| `securityConfig?` | `Partial`\<`RBACSecurityConfig`\> | Optional security configuration |
|
|
5736
5737
|
|
|
5737
5738
|
#### Returns
|
|
5738
5739
|
|
|
@@ -5742,7 +5743,7 @@ RBACEngine instance
|
|
|
5742
5743
|
|
|
5743
5744
|
#### Defined in
|
|
5744
5745
|
|
|
5745
|
-
[packages/core/src/rbac/engine.ts:
|
|
5746
|
+
[packages/core/src/rbac/engine.ts:611](https://github.com/jmruthers/pace-core/blob/main/packages/core/src/rbac/engine.ts#L611)
|
|
5746
5747
|
|
|
5747
5748
|
___
|
|
5748
5749
|
|
|
@@ -5843,7 +5844,7 @@ function MyComponent() {
|
|
|
5843
5844
|
|
|
5844
5845
|
#### Defined in
|
|
5845
5846
|
|
|
5846
|
-
[packages/core/src/rbac/hooks/usePermissions.ts:
|
|
5847
|
+
[packages/core/src/rbac/hooks/usePermissions.ts:201](https://github.com/jmruthers/pace-core/blob/main/packages/core/src/rbac/hooks/usePermissions.ts#L201)
|
|
5847
5848
|
|
|
5848
5849
|
___
|
|
5849
5850
|
|
|
@@ -5893,7 +5894,7 @@ function MyComponent() {
|
|
|
5893
5894
|
|
|
5894
5895
|
#### Defined in
|
|
5895
5896
|
|
|
5896
|
-
[packages/core/src/rbac/hooks/usePermissions.ts:
|
|
5897
|
+
[packages/core/src/rbac/hooks/usePermissions.ts:359](https://github.com/jmruthers/pace-core/blob/main/packages/core/src/rbac/hooks/usePermissions.ts#L359)
|
|
5897
5898
|
|
|
5898
5899
|
___
|
|
5899
5900
|
|
|
@@ -5950,7 +5951,7 @@ function MyComponent() {
|
|
|
5950
5951
|
|
|
5951
5952
|
#### Defined in
|
|
5952
5953
|
|
|
5953
|
-
[packages/core/src/rbac/hooks/usePermissions.ts:
|
|
5954
|
+
[packages/core/src/rbac/hooks/usePermissions.ts:434](https://github.com/jmruthers/pace-core/blob/main/packages/core/src/rbac/hooks/usePermissions.ts#L434)
|
|
5954
5955
|
|
|
5955
5956
|
___
|
|
5956
5957
|
|
|
@@ -6001,7 +6002,7 @@ function MyComponent() {
|
|
|
6001
6002
|
|
|
6002
6003
|
#### Defined in
|
|
6003
6004
|
|
|
6004
|
-
[packages/core/src/rbac/hooks/usePermissions.ts:
|
|
6005
|
+
[packages/core/src/rbac/hooks/usePermissions.ts:517](https://github.com/jmruthers/pace-core/blob/main/packages/core/src/rbac/hooks/usePermissions.ts#L517)
|
|
6005
6006
|
|
|
6006
6007
|
___
|
|
6007
6008
|
|
|
@@ -6052,7 +6053,7 @@ function MyComponent() {
|
|
|
6052
6053
|
|
|
6053
6054
|
#### Defined in
|
|
6054
6055
|
|
|
6055
|
-
[packages/core/src/rbac/hooks/usePermissions.ts:
|
|
6056
|
+
[packages/core/src/rbac/hooks/usePermissions.ts:603](https://github.com/jmruthers/pace-core/blob/main/packages/core/src/rbac/hooks/usePermissions.ts#L603)
|
|
6056
6057
|
|
|
6057
6058
|
___
|
|
6058
6059
|
|
|
@@ -6103,7 +6104,7 @@ function MyComponent() {
|
|
|
6103
6104
|
|
|
6104
6105
|
#### Defined in
|
|
6105
6106
|
|
|
6106
|
-
[packages/core/src/rbac/hooks/usePermissions.ts:
|
|
6107
|
+
[packages/core/src/rbac/hooks/usePermissions.ts:688](https://github.com/jmruthers/pace-core/blob/main/packages/core/src/rbac/hooks/usePermissions.ts#L688)
|
|
6107
6108
|
|
|
6108
6109
|
___
|
|
6109
6110
|
|
|
@@ -6123,7 +6124,7 @@ ___
|
|
|
6123
6124
|
|
|
6124
6125
|
#### Defined in
|
|
6125
6126
|
|
|
6126
|
-
[packages/core/src/rbac/hooks/useRBAC.ts:
|
|
6127
|
+
[packages/core/src/rbac/hooks/useRBAC.ts:51](https://github.com/jmruthers/pace-core/blob/main/packages/core/src/rbac/hooks/useRBAC.ts#L51)
|
|
6127
6128
|
|
|
6128
6129
|
___
|
|
6129
6130
|
|
|
@@ -512,13 +512,17 @@ function Dropdown() {
|
|
|
512
512
|
You can compose multiple hooks to create custom functionality:
|
|
513
513
|
|
|
514
514
|
```tsx
|
|
515
|
+
import { useCan } from '@jmruthers/pace-core/rbac';
|
|
516
|
+
|
|
515
517
|
function useUserDashboard() {
|
|
516
|
-
const { user, loading: authLoading } = useUnifiedAuth();
|
|
518
|
+
const { user, loading: authLoading, selectedOrganisationId } = useUnifiedAuth();
|
|
517
519
|
const { events, selectedEvent } = useEvents();
|
|
518
|
-
const {
|
|
520
|
+
const { can: canUpdateEvents } = useCan(
|
|
521
|
+
user?.id || '',
|
|
522
|
+
{ organisationId: selectedOrganisationId || '', eventId: selectedEvent?.event_id, appId: undefined },
|
|
523
|
+
'update:events'
|
|
524
|
+
);
|
|
519
525
|
const { showToast } = useToast();
|
|
520
|
-
|
|
521
|
-
const canManageEvents = hasPermission('manage:events');
|
|
522
526
|
const userEvents = events.filter(event =>
|
|
523
527
|
event.organiserId === user?.id
|
|
524
528
|
);
|
|
@@ -607,7 +607,8 @@ SELECT * FROM data_user_events_get(NULL, 'user-id', 'org-123');
|
|
|
607
607
|
3. **Add comments**: Document purpose, parameters, returns
|
|
608
608
|
4. **Add grants**: `GRANT EXECUTE ON FUNCTION ... TO authenticated;`
|
|
609
609
|
5. **Add tests**: Include test queries in migration
|
|
610
|
-
6. **
|
|
610
|
+
6. **Regenerate types**: Run `npm run generate-types` to automatically generate TypeScript types from the database schema
|
|
611
|
+
7. **Verify types**: Check that `Database['public']['Functions']['function_name']` exists in `packages/core/src/types/database.generated.ts`
|
|
611
612
|
|
|
612
613
|
### Updating Existing Functions
|
|
613
614
|
|
|
@@ -615,6 +616,7 @@ SELECT * FROM data_user_events_get(NULL, 'user-id', 'org-123');
|
|
|
615
616
|
2. **Preserve backward compatibility** - Add new parameters with defaults
|
|
616
617
|
3. **Version changes** - Update function name if breaking changes (e.g., `_v2`)
|
|
617
618
|
4. **Document changes** - Add comments explaining changes
|
|
619
|
+
5. **Regenerate types**: Run `npm run generate-types` after function changes to update TypeScript types
|
|
618
620
|
|
|
619
621
|
### Deprecating Functions
|
|
620
622
|
|
|
@@ -169,13 +169,13 @@ function AdminDashboard() {
|
|
|
169
169
|
organisationId
|
|
170
170
|
});
|
|
171
171
|
|
|
172
|
-
const
|
|
173
|
-
permissions.includes('
|
|
172
|
+
const canUpdate = permissions.includes('update:users') ||
|
|
173
|
+
permissions.includes('update:settings');
|
|
174
174
|
|
|
175
175
|
return (
|
|
176
176
|
<div>
|
|
177
177
|
{isLoading && <div>Loading...</div>}
|
|
178
|
-
{
|
|
178
|
+
{canUpdate && <AdminPanel />}
|
|
179
179
|
</div>
|
|
180
180
|
);
|
|
181
181
|
}
|
|
@@ -186,18 +186,24 @@ const AdminDashboard = lazy(() => import('./AdminDashboard'));
|
|
|
186
186
|
const UserDashboard = lazy(() => import('./UserDashboard'));
|
|
187
187
|
const Analytics = lazy(() => import('./Analytics'));
|
|
188
188
|
|
|
189
|
+
import { useCan } from '@jmruthers/pace-core/rbac';
|
|
190
|
+
|
|
189
191
|
function App() {
|
|
190
|
-
const { user } = useUnifiedAuth();
|
|
191
|
-
const {
|
|
192
|
+
const { user, selectedOrganisationId } = useUnifiedAuth();
|
|
193
|
+
const { can: canViewAdmin } = useCan(
|
|
194
|
+
user?.id || '',
|
|
195
|
+
{ organisationId: selectedOrganisationId || '', eventId: undefined, appId: undefined },
|
|
196
|
+
'read:page.admin'
|
|
197
|
+
);
|
|
192
198
|
|
|
193
199
|
return (
|
|
194
200
|
<Suspense fallback={<LoadingSpinner />}>
|
|
195
|
-
{
|
|
201
|
+
{canViewAdmin ? (
|
|
196
202
|
<AdminDashboard />
|
|
197
203
|
) : (
|
|
198
204
|
<UserDashboard />
|
|
199
205
|
)}
|
|
200
|
-
{
|
|
206
|
+
{canViewAdmin && (
|
|
201
207
|
<Suspense fallback={<div>Loading analytics...</div>}>
|
|
202
208
|
<Analytics />
|
|
203
209
|
</Suspense>
|
|
@@ -345,16 +345,24 @@ function App() {
|
|
|
345
345
|
### 3. Component Lazy Loading
|
|
346
346
|
|
|
347
347
|
```typescript
|
|
348
|
+
import { useCan } from '@jmruthers/pace-core/rbac';
|
|
349
|
+
import { useUnifiedAuth } from '@jmruthers/pace-core/providers';
|
|
350
|
+
|
|
348
351
|
// Lazy load components based on user permissions
|
|
349
352
|
function ConditionalComponent({ permission, children }) {
|
|
350
|
-
const {
|
|
353
|
+
const { user, selectedOrganisationId } = useUnifiedAuth();
|
|
354
|
+
const { can, isLoading } = useCan(
|
|
355
|
+
user?.id || '',
|
|
356
|
+
{ organisationId: selectedOrganisationId || '', eventId: undefined, appId: undefined },
|
|
357
|
+
permission
|
|
358
|
+
);
|
|
351
359
|
const [shouldLoad, setShouldLoad] = useState(false);
|
|
352
360
|
|
|
353
361
|
useEffect(() => {
|
|
354
|
-
if (
|
|
362
|
+
if (!isLoading && can) {
|
|
355
363
|
setShouldLoad(true);
|
|
356
364
|
}
|
|
357
|
-
}, [
|
|
365
|
+
}, [can, isLoading]);
|
|
358
366
|
|
|
359
367
|
if (!shouldLoad) return null;
|
|
360
368
|
|
|
@@ -404,23 +404,23 @@ const ORGANISATION_ROLES = {
|
|
|
404
404
|
```typescript
|
|
405
405
|
const ROLE_PERMISSIONS = {
|
|
406
406
|
owner: [
|
|
407
|
-
'
|
|
407
|
+
'update:organisation',
|
|
408
408
|
'delete:organisation',
|
|
409
|
-
'
|
|
410
|
-
'
|
|
411
|
-
'
|
|
409
|
+
'update:members',
|
|
410
|
+
'update:settings',
|
|
411
|
+
'update:content',
|
|
412
412
|
'view:analytics',
|
|
413
413
|
],
|
|
414
414
|
|
|
415
415
|
admin: [
|
|
416
|
-
'
|
|
417
|
-
'
|
|
418
|
-
'
|
|
416
|
+
'update:members',
|
|
417
|
+
'update:settings',
|
|
418
|
+
'update:content',
|
|
419
419
|
'view:analytics',
|
|
420
420
|
],
|
|
421
421
|
|
|
422
422
|
manager: [
|
|
423
|
-
'
|
|
423
|
+
'update:content',
|
|
424
424
|
'view:analytics',
|
|
425
425
|
],
|
|
426
426
|
|