@checkstack/common 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 +68 -0
- package/package.json +1 -1
- package/src/types.ts +80 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,73 @@
|
|
|
1
1
|
# @checkstack/common
|
|
2
2
|
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 8e43507: # Teams and Resource-Level Access Control
|
|
8
|
+
|
|
9
|
+
This release introduces a comprehensive Teams system for organizing users and controlling access to resources at a granular level.
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
### Team Management
|
|
14
|
+
|
|
15
|
+
- Create, update, and delete teams with name and description
|
|
16
|
+
- Add/remove users from teams
|
|
17
|
+
- Designate team managers with elevated privileges
|
|
18
|
+
- View team membership and manager status
|
|
19
|
+
|
|
20
|
+
### Resource-Level Access Control
|
|
21
|
+
|
|
22
|
+
- Grant teams access to specific resources (systems, health checks, incidents, maintenances)
|
|
23
|
+
- Configure read-only or manage permissions per team
|
|
24
|
+
- Resource-level "Team Only" mode that restricts access exclusively to team members
|
|
25
|
+
- Separate `resourceAccessSettings` table for resource-level settings (not per-grant)
|
|
26
|
+
- Automatic cleanup of grants when teams are deleted (database cascade)
|
|
27
|
+
|
|
28
|
+
### Middleware Integration
|
|
29
|
+
|
|
30
|
+
- Extended `autoAuthMiddleware` to support resource access checks
|
|
31
|
+
- Single-resource pre-handler validation for detail endpoints
|
|
32
|
+
- Automatic list filtering for collection endpoints
|
|
33
|
+
- S2S endpoints for access verification
|
|
34
|
+
|
|
35
|
+
### Frontend Components
|
|
36
|
+
|
|
37
|
+
- `TeamsTab` component for managing teams in Auth Settings
|
|
38
|
+
- `TeamAccessEditor` component for assigning team access to resources
|
|
39
|
+
- Resource-level "Team Only" toggle in `TeamAccessEditor`
|
|
40
|
+
- Integration into System, Health Check, Incident, and Maintenance editors
|
|
41
|
+
|
|
42
|
+
## Breaking Changes
|
|
43
|
+
|
|
44
|
+
### API Response Format Changes
|
|
45
|
+
|
|
46
|
+
List endpoints now return objects with named keys instead of arrays directly:
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
// Before
|
|
50
|
+
const systems = await catalogApi.getSystems();
|
|
51
|
+
|
|
52
|
+
// After
|
|
53
|
+
const { systems } = await catalogApi.getSystems();
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Affected endpoints:
|
|
57
|
+
|
|
58
|
+
- `catalog.getSystems` → `{ systems: [...] }`
|
|
59
|
+
- `healthcheck.getConfigurations` → `{ configurations: [...] }`
|
|
60
|
+
- `incident.listIncidents` → `{ incidents: [...] }`
|
|
61
|
+
- `maintenance.listMaintenances` → `{ maintenances: [...] }`
|
|
62
|
+
|
|
63
|
+
### User Identity Enrichment
|
|
64
|
+
|
|
65
|
+
`RealUser` and `ApplicationUser` types now include `teamIds: string[]` field with team memberships.
|
|
66
|
+
|
|
67
|
+
## Documentation
|
|
68
|
+
|
|
69
|
+
See `docs/backend/teams.md` for complete API reference and integration guide.
|
|
70
|
+
|
|
3
71
|
## 0.0.3
|
|
4
72
|
|
|
5
73
|
### Patch Changes
|
package/package.json
CHANGED
package/src/types.ts
CHANGED
|
@@ -2,6 +2,80 @@
|
|
|
2
2
|
// RPC PROCEDURE METADATA
|
|
3
3
|
// =============================================================================
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Configuration for resource-level access control.
|
|
7
|
+
* Used to enforce fine-grained permissions based on team grants.
|
|
8
|
+
*/
|
|
9
|
+
export interface ResourceAccessConfig {
|
|
10
|
+
/**
|
|
11
|
+
* The resource type identifier (e.g., "system", "healthcheck").
|
|
12
|
+
* Will be auto-prefixed with pluginId in middleware (e.g., "catalog.system").
|
|
13
|
+
*/
|
|
14
|
+
resourceType: string;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Parameter name in request input to extract resource ID from.
|
|
18
|
+
* Uses dot notation for nested params (e.g., "params.id").
|
|
19
|
+
* Required for single-resource access checks.
|
|
20
|
+
*/
|
|
21
|
+
idParam?: string;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Filter mode for list endpoints.
|
|
25
|
+
* - "single": Check access to a single resource (default)
|
|
26
|
+
* - "list": Post-filter result array based on team access
|
|
27
|
+
*/
|
|
28
|
+
filterMode?: "single" | "list";
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Key in response object containing the array to filter.
|
|
32
|
+
* Required when filterMode is "list".
|
|
33
|
+
* Example: "systems" for response { systems: [...] }
|
|
34
|
+
*/
|
|
35
|
+
outputKey?: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Creates a ResourceAccessConfig for single-resource access checks.
|
|
40
|
+
*
|
|
41
|
+
* @param resourceType - The resource type (auto-prefixed with pluginId)
|
|
42
|
+
* @param idParam - Parameter path in input to extract resource ID from
|
|
43
|
+
*/
|
|
44
|
+
export function createResourceAccess(
|
|
45
|
+
resourceType: string,
|
|
46
|
+
idParam: string
|
|
47
|
+
): ResourceAccessConfig {
|
|
48
|
+
return { resourceType, idParam, filterMode: "single" };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Creates a ResourceAccessConfig for list filtering.
|
|
53
|
+
*
|
|
54
|
+
* @param resourceType - The resource type (auto-prefixed with pluginId)
|
|
55
|
+
* @param outputKey - Key in response object containing the array to filter
|
|
56
|
+
*/
|
|
57
|
+
export function createResourceAccessList(
|
|
58
|
+
resourceType: string,
|
|
59
|
+
outputKey: string
|
|
60
|
+
): ResourceAccessConfig {
|
|
61
|
+
return { resourceType, filterMode: "list", outputKey };
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Qualifies a resource type with the plugin namespace.
|
|
66
|
+
* @param pluginId - The plugin identifier
|
|
67
|
+
* @param resourceType - The unqualified resource type
|
|
68
|
+
* @returns Qualified resource type (e.g., "catalog.system")
|
|
69
|
+
*/
|
|
70
|
+
export function qualifyResourceType(
|
|
71
|
+
pluginId: string,
|
|
72
|
+
resourceType: string
|
|
73
|
+
): string {
|
|
74
|
+
// If already qualified (contains a dot), return as-is
|
|
75
|
+
if (resourceType.includes(".")) return resourceType;
|
|
76
|
+
return `${pluginId}.${resourceType}`;
|
|
77
|
+
}
|
|
78
|
+
|
|
5
79
|
/**
|
|
6
80
|
* Metadata interface for RPC procedures.
|
|
7
81
|
* Used by contracts to define auth requirements and by backend middleware to enforce them.
|
|
@@ -34,4 +108,10 @@ export interface ProcedureMetadata {
|
|
|
34
108
|
* User must have at least one of the listed permissions, or "*" (wildcard).
|
|
35
109
|
*/
|
|
36
110
|
permissions?: string[];
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Resource-level access control configurations.
|
|
114
|
+
* When specified, middleware checks team-based grants for the resources.
|
|
115
|
+
*/
|
|
116
|
+
resourceAccess?: ResourceAccessConfig[];
|
|
37
117
|
}
|