@checkstack/command-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 +59 -0
- package/package.json +1 -1
- package/src/index.ts +11 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,64 @@
|
|
|
1
1
|
# @checkstack/command-common
|
|
2
2
|
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 7a23261: ## TanStack Query Integration
|
|
8
|
+
|
|
9
|
+
Migrated all frontend components to use `usePluginClient` hook with TanStack Query integration, replacing the legacy `forPlugin()` pattern.
|
|
10
|
+
|
|
11
|
+
### New Features
|
|
12
|
+
|
|
13
|
+
- **`usePluginClient` hook**: Provides type-safe access to plugin APIs with `.useQuery()` and `.useMutation()` methods
|
|
14
|
+
- **Automatic request deduplication**: Multiple components requesting the same data share a single network request
|
|
15
|
+
- **Built-in caching**: Configurable stale time and cache duration per query
|
|
16
|
+
- **Loading/error states**: TanStack Query provides `isLoading`, `error`, `isRefetching` states automatically
|
|
17
|
+
- **Background refetching**: Stale data is automatically refreshed when components mount
|
|
18
|
+
|
|
19
|
+
### Contract Changes
|
|
20
|
+
|
|
21
|
+
All RPC contracts now require `operationType: "query"` or `operationType: "mutation"` metadata:
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
const getItems = proc()
|
|
25
|
+
.meta({ operationType: "query", access: [access.read] })
|
|
26
|
+
.output(z.array(itemSchema))
|
|
27
|
+
.query();
|
|
28
|
+
|
|
29
|
+
const createItem = proc()
|
|
30
|
+
.meta({ operationType: "mutation", access: [access.manage] })
|
|
31
|
+
.input(createItemSchema)
|
|
32
|
+
.output(itemSchema)
|
|
33
|
+
.mutation();
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Migration
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
// Before (forPlugin pattern)
|
|
40
|
+
const api = useApi(myPluginApiRef);
|
|
41
|
+
const [items, setItems] = useState<Item[]>([]);
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
api.getItems().then(setItems);
|
|
44
|
+
}, [api]);
|
|
45
|
+
|
|
46
|
+
// After (usePluginClient pattern)
|
|
47
|
+
const client = usePluginClient(MyPluginApi);
|
|
48
|
+
const { data: items, isLoading } = client.getItems.useQuery({});
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Bug Fixes
|
|
52
|
+
|
|
53
|
+
- Fixed `rpc.test.ts` test setup for middleware type inference
|
|
54
|
+
- Fixed `SearchDialog` to use `setQuery` instead of deprecated `search` method
|
|
55
|
+
- Fixed null→undefined warnings in notification and queue frontends
|
|
56
|
+
|
|
57
|
+
### Patch Changes
|
|
58
|
+
|
|
59
|
+
- Updated dependencies [7a23261]
|
|
60
|
+
- @checkstack/common@0.3.0
|
|
61
|
+
|
|
3
62
|
## 0.1.0
|
|
4
63
|
|
|
5
64
|
### Minor Changes
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { oc } from "@orpc/contract";
|
|
2
1
|
import { z } from "zod";
|
|
3
2
|
import {
|
|
4
3
|
createClientDefinition,
|
|
5
4
|
definePluginMetadata,
|
|
6
|
-
|
|
5
|
+
proc,
|
|
7
6
|
} from "@checkstack/common";
|
|
8
7
|
|
|
9
8
|
// =============================================================================
|
|
@@ -64,8 +63,6 @@ export type Command = z.infer<typeof CommandSchema>;
|
|
|
64
63
|
// RPC CONTRACT
|
|
65
64
|
// =============================================================================
|
|
66
65
|
|
|
67
|
-
const _base = oc.$meta<ProcedureMetadata>({});
|
|
68
|
-
|
|
69
66
|
/**
|
|
70
67
|
* Command palette RPC contract.
|
|
71
68
|
* Provides search functionality across all registered providers.
|
|
@@ -75,8 +72,11 @@ export const commandContract = {
|
|
|
75
72
|
* Search across all registered search providers.
|
|
76
73
|
* Returns results filtered by user access rules.
|
|
77
74
|
*/
|
|
78
|
-
search:
|
|
79
|
-
|
|
75
|
+
search: proc({
|
|
76
|
+
operationType: "query",
|
|
77
|
+
userType: "public",
|
|
78
|
+
access: [],
|
|
79
|
+
})
|
|
80
80
|
.input(z.object({ query: z.string() }))
|
|
81
81
|
.output(z.array(SearchResultSchema)),
|
|
82
82
|
|
|
@@ -84,9 +84,11 @@ export const commandContract = {
|
|
|
84
84
|
* Get all registered commands (for browsing without a query).
|
|
85
85
|
* Returns commands filtered by user access rules.
|
|
86
86
|
*/
|
|
87
|
-
getCommands:
|
|
88
|
-
|
|
89
|
-
|
|
87
|
+
getCommands: proc({
|
|
88
|
+
operationType: "query",
|
|
89
|
+
userType: "public",
|
|
90
|
+
access: [],
|
|
91
|
+
}).output(z.array(SearchResultSchema)),
|
|
90
92
|
};
|
|
91
93
|
|
|
92
94
|
export type CommandContract = typeof commandContract;
|