@checkstack/maintenance-common 0.2.0 → 0.3.1
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/access.ts +18 -1
- package/src/rpc-contract.ts +59 -47
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,73 @@
|
|
|
1
1
|
# @checkstack/maintenance-common
|
|
2
2
|
|
|
3
|
+
## 0.3.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [4eed42d]
|
|
8
|
+
- @checkstack/frontend-api@0.3.0
|
|
9
|
+
|
|
10
|
+
## 0.3.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- 7a23261: ## TanStack Query Integration
|
|
15
|
+
|
|
16
|
+
Migrated all frontend components to use `usePluginClient` hook with TanStack Query integration, replacing the legacy `forPlugin()` pattern.
|
|
17
|
+
|
|
18
|
+
### New Features
|
|
19
|
+
|
|
20
|
+
- **`usePluginClient` hook**: Provides type-safe access to plugin APIs with `.useQuery()` and `.useMutation()` methods
|
|
21
|
+
- **Automatic request deduplication**: Multiple components requesting the same data share a single network request
|
|
22
|
+
- **Built-in caching**: Configurable stale time and cache duration per query
|
|
23
|
+
- **Loading/error states**: TanStack Query provides `isLoading`, `error`, `isRefetching` states automatically
|
|
24
|
+
- **Background refetching**: Stale data is automatically refreshed when components mount
|
|
25
|
+
|
|
26
|
+
### Contract Changes
|
|
27
|
+
|
|
28
|
+
All RPC contracts now require `operationType: "query"` or `operationType: "mutation"` metadata:
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
const getItems = proc()
|
|
32
|
+
.meta({ operationType: "query", access: [access.read] })
|
|
33
|
+
.output(z.array(itemSchema))
|
|
34
|
+
.query();
|
|
35
|
+
|
|
36
|
+
const createItem = proc()
|
|
37
|
+
.meta({ operationType: "mutation", access: [access.manage] })
|
|
38
|
+
.input(createItemSchema)
|
|
39
|
+
.output(itemSchema)
|
|
40
|
+
.mutation();
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Migration
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
// Before (forPlugin pattern)
|
|
47
|
+
const api = useApi(myPluginApiRef);
|
|
48
|
+
const [items, setItems] = useState<Item[]>([]);
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
api.getItems().then(setItems);
|
|
51
|
+
}, [api]);
|
|
52
|
+
|
|
53
|
+
// After (usePluginClient pattern)
|
|
54
|
+
const client = usePluginClient(MyPluginApi);
|
|
55
|
+
const { data: items, isLoading } = client.getItems.useQuery({});
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Bug Fixes
|
|
59
|
+
|
|
60
|
+
- Fixed `rpc.test.ts` test setup for middleware type inference
|
|
61
|
+
- Fixed `SearchDialog` to use `setQuery` instead of deprecated `search` method
|
|
62
|
+
- Fixed null→undefined warnings in notification and queue frontends
|
|
63
|
+
|
|
64
|
+
### Patch Changes
|
|
65
|
+
|
|
66
|
+
- Updated dependencies [7a23261]
|
|
67
|
+
- @checkstack/frontend-api@0.2.0
|
|
68
|
+
- @checkstack/common@0.3.0
|
|
69
|
+
- @checkstack/signal-common@0.1.1
|
|
70
|
+
|
|
3
71
|
## 0.2.0
|
|
4
72
|
|
|
5
73
|
### Minor Changes
|
package/package.json
CHANGED
package/src/access.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { accessPair } from "@checkstack/common";
|
|
1
|
+
import { access, accessPair } from "@checkstack/common";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Access rules for the Maintenance plugin.
|
|
@@ -7,6 +7,7 @@ export const maintenanceAccess = {
|
|
|
7
7
|
/**
|
|
8
8
|
* Maintenance access with both read and manage levels.
|
|
9
9
|
* Read is public by default.
|
|
10
|
+
* Uses system-level instance access for team-based filtering.
|
|
10
11
|
*/
|
|
11
12
|
maintenance: accessPair(
|
|
12
13
|
"maintenance",
|
|
@@ -16,10 +17,26 @@ export const maintenanceAccess = {
|
|
|
16
17
|
"Manage planned maintenances - create, edit, delete, and add updates",
|
|
17
18
|
},
|
|
18
19
|
{
|
|
20
|
+
idParam: "systemId",
|
|
19
21
|
readIsDefault: true,
|
|
20
22
|
readIsPublic: true,
|
|
21
23
|
}
|
|
22
24
|
),
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Bulk maintenance access for viewing maintenances for multiple systems.
|
|
28
|
+
* Uses recordKey for filtering the output record by accessible system IDs.
|
|
29
|
+
*/
|
|
30
|
+
bulkMaintenance: access(
|
|
31
|
+
"maintenance.maintenance",
|
|
32
|
+
"read",
|
|
33
|
+
"View planned maintenances",
|
|
34
|
+
{
|
|
35
|
+
recordKey: "maintenances",
|
|
36
|
+
isDefault: true,
|
|
37
|
+
isPublic: true,
|
|
38
|
+
}
|
|
39
|
+
),
|
|
23
40
|
};
|
|
24
41
|
|
|
25
42
|
/**
|
package/src/rpc-contract.ts
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import { oc } from "@orpc/contract";
|
|
2
1
|
import { z } from "zod";
|
|
3
|
-
import {
|
|
4
|
-
createClientDefinition,
|
|
5
|
-
type ProcedureMetadata,
|
|
6
|
-
} from "@checkstack/common";
|
|
2
|
+
import { createClientDefinition, proc } from "@checkstack/common";
|
|
7
3
|
import { maintenanceAccess } from "./access";
|
|
8
4
|
import { pluginMetadata } from "./plugin-metadata";
|
|
9
5
|
import {
|
|
@@ -16,15 +12,13 @@ import {
|
|
|
16
12
|
MaintenanceStatusEnum,
|
|
17
13
|
} from "./schemas";
|
|
18
14
|
|
|
19
|
-
const _base = oc.$meta<ProcedureMetadata>({});
|
|
20
|
-
|
|
21
15
|
export const maintenanceContract = {
|
|
22
16
|
/** List all maintenances with optional status filter */
|
|
23
|
-
listMaintenances:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
17
|
+
listMaintenances: proc({
|
|
18
|
+
operationType: "query",
|
|
19
|
+
userType: "public",
|
|
20
|
+
access: [maintenanceAccess.maintenance.read],
|
|
21
|
+
})
|
|
28
22
|
.input(
|
|
29
23
|
z
|
|
30
24
|
.object({
|
|
@@ -36,65 +30,83 @@ export const maintenanceContract = {
|
|
|
36
30
|
.output(z.object({ maintenances: z.array(MaintenanceWithSystemsSchema) })),
|
|
37
31
|
|
|
38
32
|
/** Get a single maintenance with all details */
|
|
39
|
-
getMaintenance:
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
33
|
+
getMaintenance: proc({
|
|
34
|
+
operationType: "query",
|
|
35
|
+
userType: "public",
|
|
36
|
+
access: [maintenanceAccess.maintenance.read],
|
|
37
|
+
})
|
|
44
38
|
.input(z.object({ id: z.string() }))
|
|
45
39
|
.output(MaintenanceDetailSchema.nullable()),
|
|
46
40
|
|
|
47
41
|
/** Get active or upcoming maintenances for a specific system */
|
|
48
|
-
getMaintenancesForSystem:
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
42
|
+
getMaintenancesForSystem: proc({
|
|
43
|
+
operationType: "query",
|
|
44
|
+
userType: "public",
|
|
45
|
+
access: [maintenanceAccess.maintenance.read],
|
|
46
|
+
})
|
|
53
47
|
.input(z.object({ systemId: z.string() }))
|
|
54
48
|
.output(z.array(MaintenanceWithSystemsSchema)),
|
|
55
49
|
|
|
50
|
+
/** Get active maintenances for multiple systems in a single request.
|
|
51
|
+
* Used for efficient dashboard rendering to avoid N+1 queries.
|
|
52
|
+
*/
|
|
53
|
+
getBulkMaintenancesForSystems: proc({
|
|
54
|
+
operationType: "query",
|
|
55
|
+
userType: "public",
|
|
56
|
+
access: [maintenanceAccess.bulkMaintenance],
|
|
57
|
+
})
|
|
58
|
+
.input(z.object({ systemIds: z.array(z.string()) }))
|
|
59
|
+
.output(
|
|
60
|
+
z.object({
|
|
61
|
+
maintenances: z.record(
|
|
62
|
+
z.string(),
|
|
63
|
+
z.array(MaintenanceWithSystemsSchema)
|
|
64
|
+
),
|
|
65
|
+
})
|
|
66
|
+
),
|
|
67
|
+
|
|
56
68
|
/** Create a new maintenance */
|
|
57
|
-
createMaintenance:
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
69
|
+
createMaintenance: proc({
|
|
70
|
+
operationType: "mutation",
|
|
71
|
+
userType: "authenticated",
|
|
72
|
+
access: [maintenanceAccess.maintenance.manage],
|
|
73
|
+
})
|
|
62
74
|
.input(CreateMaintenanceInputSchema)
|
|
63
75
|
.output(MaintenanceWithSystemsSchema),
|
|
64
76
|
|
|
65
77
|
/** Update an existing maintenance */
|
|
66
|
-
updateMaintenance:
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
78
|
+
updateMaintenance: proc({
|
|
79
|
+
operationType: "mutation",
|
|
80
|
+
userType: "authenticated",
|
|
81
|
+
access: [maintenanceAccess.maintenance.manage],
|
|
82
|
+
})
|
|
71
83
|
.input(UpdateMaintenanceInputSchema)
|
|
72
84
|
.output(MaintenanceWithSystemsSchema),
|
|
73
85
|
|
|
74
86
|
/** Add a status update to a maintenance */
|
|
75
|
-
addUpdate:
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
87
|
+
addUpdate: proc({
|
|
88
|
+
operationType: "mutation",
|
|
89
|
+
userType: "authenticated",
|
|
90
|
+
access: [maintenanceAccess.maintenance.manage],
|
|
91
|
+
})
|
|
80
92
|
.input(AddMaintenanceUpdateInputSchema)
|
|
81
93
|
.output(MaintenanceUpdateSchema),
|
|
82
94
|
|
|
83
95
|
/** Close a maintenance early (sets status to completed) */
|
|
84
|
-
closeMaintenance:
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
96
|
+
closeMaintenance: proc({
|
|
97
|
+
operationType: "mutation",
|
|
98
|
+
userType: "authenticated",
|
|
99
|
+
access: [maintenanceAccess.maintenance.manage],
|
|
100
|
+
})
|
|
89
101
|
.input(z.object({ id: z.string(), message: z.string().optional() }))
|
|
90
102
|
.output(MaintenanceWithSystemsSchema),
|
|
91
103
|
|
|
92
104
|
/** Delete a maintenance */
|
|
93
|
-
deleteMaintenance:
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
105
|
+
deleteMaintenance: proc({
|
|
106
|
+
operationType: "mutation",
|
|
107
|
+
userType: "authenticated",
|
|
108
|
+
access: [maintenanceAccess.maintenance.manage],
|
|
109
|
+
})
|
|
98
110
|
.input(z.object({ id: z.string() }))
|
|
99
111
|
.output(z.object({ success: z.boolean() })),
|
|
100
112
|
};
|