@checkstack/incident-common 0.1.0 → 0.2.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 CHANGED
@@ -1,5 +1,81 @@
1
1
  # @checkstack/incident-common
2
2
 
3
+ ## 0.2.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
+ - @checkstack/frontend-api@0.1.0
77
+ - @checkstack/signal-common@0.1.0
78
+
3
79
  ## 0.1.0
4
80
 
5
81
  ### Minor Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@checkstack/incident-common",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
package/src/access.ts ADDED
@@ -0,0 +1,30 @@
1
+ import { accessPair } from "@checkstack/common";
2
+
3
+ /**
4
+ * Access rules for the Incident plugin.
5
+ */
6
+ export const incidentAccess = {
7
+ /**
8
+ * Incident access with both read and manage levels.
9
+ * Read is public by default.
10
+ */
11
+ incident: accessPair(
12
+ "incident",
13
+ {
14
+ read: "View incidents",
15
+ manage: "Manage incidents - create, edit, resolve, and delete",
16
+ },
17
+ {
18
+ readIsDefault: true,
19
+ readIsPublic: true,
20
+ }
21
+ ),
22
+ };
23
+
24
+ /**
25
+ * All access rules for registration with the plugin system.
26
+ */
27
+ export const incidentAccessRules = [
28
+ incidentAccess.incident.read,
29
+ incidentAccess.incident.manage,
30
+ ];
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { permissions, permissionList } from "./permissions";
1
+ export { incidentAccess, incidentAccessRules } from "./access";
2
2
  export {
3
3
  incidentContract,
4
4
  IncidentApi,
@@ -2,10 +2,9 @@ import { oc } from "@orpc/contract";
2
2
  import { z } from "zod";
3
3
  import {
4
4
  createClientDefinition,
5
- createResourceAccessList,
6
5
  type ProcedureMetadata,
7
6
  } from "@checkstack/common";
8
- import { permissions } from "./permissions";
7
+ import { incidentAccess } from "./access";
9
8
  import { pluginMetadata } from "./plugin-metadata";
10
9
  import {
11
10
  IncidentWithSystemsSchema,
@@ -19,16 +18,12 @@ import {
19
18
 
20
19
  const _base = oc.$meta<ProcedureMetadata>({});
21
20
 
22
- // Resource access configurations for team-based access control
23
- const incidentListAccess = createResourceAccessList("incident", "incidents");
24
-
25
21
  export const incidentContract = {
26
22
  /** List all incidents with optional filters */
27
23
  listIncidents: _base
28
24
  .meta({
29
25
  userType: "public",
30
- permissions: [permissions.incidentRead.id],
31
- resourceAccess: [incidentListAccess],
26
+ access: [incidentAccess.incident.read],
32
27
  })
33
28
  .input(
34
29
  z
@@ -45,7 +40,7 @@ export const incidentContract = {
45
40
  getIncident: _base
46
41
  .meta({
47
42
  userType: "public",
48
- permissions: [permissions.incidentRead.id],
43
+ access: [incidentAccess.incident.read],
49
44
  })
50
45
  .input(z.object({ id: z.string() }))
51
46
  .output(IncidentDetailSchema.nullable()),
@@ -54,7 +49,7 @@ export const incidentContract = {
54
49
  getIncidentsForSystem: _base
55
50
  .meta({
56
51
  userType: "public",
57
- permissions: [permissions.incidentRead.id],
52
+ access: [incidentAccess.incident.read],
58
53
  })
59
54
  .input(z.object({ systemId: z.string() }))
60
55
  .output(z.array(IncidentWithSystemsSchema)),
@@ -63,7 +58,7 @@ export const incidentContract = {
63
58
  createIncident: _base
64
59
  .meta({
65
60
  userType: "authenticated",
66
- permissions: [permissions.incidentManage.id],
61
+ access: [incidentAccess.incident.manage],
67
62
  })
68
63
  .input(CreateIncidentInputSchema)
69
64
  .output(IncidentWithSystemsSchema),
@@ -72,7 +67,7 @@ export const incidentContract = {
72
67
  updateIncident: _base
73
68
  .meta({
74
69
  userType: "authenticated",
75
- permissions: [permissions.incidentManage.id],
70
+ access: [incidentAccess.incident.manage],
76
71
  })
77
72
  .input(UpdateIncidentInputSchema)
78
73
  .output(IncidentWithSystemsSchema),
@@ -81,7 +76,7 @@ export const incidentContract = {
81
76
  addUpdate: _base
82
77
  .meta({
83
78
  userType: "authenticated",
84
- permissions: [permissions.incidentManage.id],
79
+ access: [incidentAccess.incident.manage],
85
80
  })
86
81
  .input(AddIncidentUpdateInputSchema)
87
82
  .output(IncidentUpdateSchema),
@@ -90,7 +85,7 @@ export const incidentContract = {
90
85
  resolveIncident: _base
91
86
  .meta({
92
87
  userType: "authenticated",
93
- permissions: [permissions.incidentManage.id],
88
+ access: [incidentAccess.incident.manage],
94
89
  })
95
90
  .input(z.object({ id: z.string(), message: z.string().optional() }))
96
91
  .output(IncidentWithSystemsSchema),
@@ -99,7 +94,7 @@ export const incidentContract = {
99
94
  deleteIncident: _base
100
95
  .meta({
101
96
  userType: "authenticated",
102
- permissions: [permissions.incidentManage.id],
97
+ access: [incidentAccess.incident.manage],
103
98
  })
104
99
  .input(z.object({ id: z.string() }))
105
100
  .output(z.object({ success: z.boolean() })),
@@ -1,13 +0,0 @@
1
- import { createPermission, type Permission } from "@checkstack/common";
2
-
3
- export const permissions = {
4
- /** Read access to incidents - granted to all users by default */
5
- incidentRead: createPermission("incident", "read", "View incidents", {
6
- isAuthenticatedDefault: true,
7
- isPublicDefault: true,
8
- }),
9
- /** Manage incidents - create, edit, resolve, and delete */
10
- incidentManage: createPermission("incident", "manage", "Manage incidents"),
11
- } as const satisfies Record<string, Permission>;
12
-
13
- export const permissionList = Object.values(permissions);