@checkstack/frontend-api 0.0.3 → 0.1.0
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 +81 -0
- package/package.json +1 -1
- package/src/core-apis.ts +23 -13
- package/src/plugin-registry.ts +3 -3
- package/src/plugin.ts +3 -3
- package/src/slots.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,86 @@
|
|
|
1
1
|
# @checkstack/frontend-api
|
|
2
2
|
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 9faec1f: # Unified AccessRule Terminology Refactoring
|
|
8
|
+
|
|
9
|
+
This release completes a comprehensive terminology refactoring from "permission" to "accessRule" across the entire codebase, establishing a consistent and modern access control vocabulary.
|
|
10
|
+
|
|
11
|
+
## Changes
|
|
12
|
+
|
|
13
|
+
### Core Infrastructure (`@checkstack/common`)
|
|
14
|
+
|
|
15
|
+
- Introduced `AccessRule` interface as the primary access control type
|
|
16
|
+
- Added `accessPair()` helper for creating read/manage access rule pairs
|
|
17
|
+
- Added `access()` builder for individual access rules
|
|
18
|
+
- Replaced `Permission` type with `AccessRule` throughout
|
|
19
|
+
|
|
20
|
+
### API Changes
|
|
21
|
+
|
|
22
|
+
- `env.registerPermissions()` → `env.registerAccessRules()`
|
|
23
|
+
- `meta.permissions` → `meta.access` in RPC contracts
|
|
24
|
+
- `usePermission()` → `useAccess()` in frontend hooks
|
|
25
|
+
- Route `permission:` field → `accessRule:` field
|
|
26
|
+
|
|
27
|
+
### UI Changes
|
|
28
|
+
|
|
29
|
+
- "Roles & Permissions" tab → "Roles & Access Rules"
|
|
30
|
+
- "You don't have permission..." → "You don't have access..."
|
|
31
|
+
- All permission-related UI text updated
|
|
32
|
+
|
|
33
|
+
### Documentation & Templates
|
|
34
|
+
|
|
35
|
+
- Updated 18 documentation files with AccessRule terminology
|
|
36
|
+
- Updated 7 scaffolding templates with `accessPair()` pattern
|
|
37
|
+
- All code examples use new AccessRule API
|
|
38
|
+
|
|
39
|
+
## Migration Guide
|
|
40
|
+
|
|
41
|
+
### Backend Plugins
|
|
42
|
+
|
|
43
|
+
```diff
|
|
44
|
+
- import { permissionList } from "./permissions";
|
|
45
|
+
- env.registerPermissions(permissionList);
|
|
46
|
+
+ import { accessRules } from "./access";
|
|
47
|
+
+ env.registerAccessRules(accessRules);
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### RPC Contracts
|
|
51
|
+
|
|
52
|
+
```diff
|
|
53
|
+
- .meta({ userType: "user", permissions: [permissions.read.id] })
|
|
54
|
+
+ .meta({ userType: "user", access: [access.read] })
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Frontend Hooks
|
|
58
|
+
|
|
59
|
+
```diff
|
|
60
|
+
- const canRead = accessApi.usePermission(permissions.read.id);
|
|
61
|
+
+ const canRead = accessApi.useAccess(access.read);
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Routes
|
|
65
|
+
|
|
66
|
+
```diff
|
|
67
|
+
- permission: permissions.entityRead.id,
|
|
68
|
+
+ accessRule: access.read,
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Patch Changes
|
|
72
|
+
|
|
73
|
+
- Updated dependencies [9faec1f]
|
|
74
|
+
- Updated dependencies [f533141]
|
|
75
|
+
- @checkstack/common@0.2.0
|
|
76
|
+
|
|
77
|
+
## 0.0.4
|
|
78
|
+
|
|
79
|
+
### Patch Changes
|
|
80
|
+
|
|
81
|
+
- Updated dependencies [8e43507]
|
|
82
|
+
- @checkstack/common@0.1.0
|
|
83
|
+
|
|
3
84
|
## 0.0.3
|
|
4
85
|
|
|
5
86
|
### Patch Changes
|
package/package.json
CHANGED
package/src/core-apis.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
PermissionAction,
|
|
3
|
-
ClientDefinition,
|
|
4
|
-
InferClient,
|
|
5
|
-
} from "@checkstack/common";
|
|
1
|
+
import { AccessRule, ClientDefinition, InferClient } from "@checkstack/common";
|
|
6
2
|
import { createApiRef } from "./api-ref";
|
|
7
3
|
|
|
8
4
|
export interface LoggerApi {
|
|
@@ -22,16 +18,30 @@ export interface FetchApi {
|
|
|
22
18
|
export const loggerApiRef = createApiRef<LoggerApi>("core.logger");
|
|
23
19
|
export const fetchApiRef = createApiRef<FetchApi>("core.fetch");
|
|
24
20
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Unified access API for checking user access via AccessRules.
|
|
23
|
+
*
|
|
24
|
+
* Uses the same AccessRule objects from plugin common packages
|
|
25
|
+
* that are used in backend contracts.
|
|
26
|
+
*/
|
|
27
|
+
export interface AccessApi {
|
|
28
|
+
/**
|
|
29
|
+
* Check if the current user has access based on an AccessRule.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```tsx
|
|
33
|
+
* import { catalogAccess } from "@checkstack/catalog-common";
|
|
34
|
+
*
|
|
35
|
+
* const { allowed, loading } = accessApi.useAccess(catalogAccess.system.manage);
|
|
36
|
+
* if (allowed) {
|
|
37
|
+
* // User can manage systems
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
useAccess(accessRule: AccessRule): { loading: boolean; allowed: boolean };
|
|
32
42
|
}
|
|
33
43
|
|
|
34
|
-
export const
|
|
44
|
+
export const accessApiRef = createApiRef<AccessApi>("core.access");
|
|
35
45
|
|
|
36
46
|
export interface RpcApi {
|
|
37
47
|
client: unknown;
|
package/src/plugin-registry.ts
CHANGED
|
@@ -14,7 +14,7 @@ interface ResolvedRoute {
|
|
|
14
14
|
pluginId: string;
|
|
15
15
|
element?: React.ReactNode;
|
|
16
16
|
title?: string;
|
|
17
|
-
|
|
17
|
+
accessRule?: string;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
class PluginRegistry {
|
|
@@ -61,7 +61,7 @@ class PluginRegistry {
|
|
|
61
61
|
pluginId: route.route.pluginId,
|
|
62
62
|
element: route.element,
|
|
63
63
|
title: route.title,
|
|
64
|
-
|
|
64
|
+
accessRule: route.accessRule?.id,
|
|
65
65
|
};
|
|
66
66
|
|
|
67
67
|
// Add to route map for resolution
|
|
@@ -175,7 +175,7 @@ class PluginRegistry {
|
|
|
175
175
|
path: fullPath,
|
|
176
176
|
element: route.element,
|
|
177
177
|
title: route.title,
|
|
178
|
-
|
|
178
|
+
accessRule: route.accessRule?.id,
|
|
179
179
|
};
|
|
180
180
|
});
|
|
181
181
|
});
|
package/src/plugin.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { SlotDefinition } from "./slots";
|
|
|
4
4
|
import type {
|
|
5
5
|
RouteDefinition,
|
|
6
6
|
PluginMetadata,
|
|
7
|
-
|
|
7
|
+
AccessRule,
|
|
8
8
|
} from "@checkstack/common";
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -51,8 +51,8 @@ export interface PluginRoute {
|
|
|
51
51
|
/** Page title */
|
|
52
52
|
title?: string;
|
|
53
53
|
|
|
54
|
-
/**
|
|
55
|
-
|
|
54
|
+
/** Access rule required to access this route (use access object from common package) */
|
|
55
|
+
accessRule?: AccessRule;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
/**
|
package/src/slots.ts
CHANGED
|
@@ -44,10 +44,10 @@ export const NavbarRightSlot = createSlot("core.layout.navbar.right");
|
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
46
|
* Context for user menu item slots.
|
|
47
|
-
* Provides the user's
|
|
47
|
+
* Provides the user's access rules array and authentication info for synchronous checks.
|
|
48
48
|
*/
|
|
49
49
|
export interface UserMenuItemsContext {
|
|
50
|
-
|
|
50
|
+
accessRules: string[];
|
|
51
51
|
hasCredentialAccount: boolean;
|
|
52
52
|
}
|
|
53
53
|
|