@checkstack/frontend 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 +66 -0
- package/package.json +3 -1
- package/src/App.tsx +30 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,71 @@
|
|
|
1
1
|
# @checkstack/frontend
|
|
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/frontend-api@0.2.0
|
|
61
|
+
- @checkstack/common@0.3.0
|
|
62
|
+
- @checkstack/auth-frontend@0.3.0
|
|
63
|
+
- @checkstack/catalog-frontend@0.3.0
|
|
64
|
+
- @checkstack/command-frontend@0.2.0
|
|
65
|
+
- @checkstack/ui@0.2.1
|
|
66
|
+
- @checkstack/signal-common@0.1.1
|
|
67
|
+
- @checkstack/signal-frontend@0.0.7
|
|
68
|
+
|
|
3
69
|
## 0.1.0
|
|
4
70
|
|
|
5
71
|
### Minor Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@checkstack/frontend",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vite",
|
|
@@ -21,6 +21,8 @@
|
|
|
21
21
|
"@checkstack/signal-frontend": "workspace:*",
|
|
22
22
|
"@checkstack/ui": "workspace:*",
|
|
23
23
|
"@orpc/client": "^1.13.2",
|
|
24
|
+
"@tanstack/react-query": "^5.64.0",
|
|
25
|
+
"@tanstack/react-query-devtools": "^5.64.0",
|
|
24
26
|
"better-auth": "^1.1.8",
|
|
25
27
|
"class-variance-authority": "^0.7.0",
|
|
26
28
|
"clsx": "^2.1.0",
|
package/src/App.tsx
CHANGED
|
@@ -23,7 +23,10 @@ import {
|
|
|
23
23
|
RuntimeConfigProvider,
|
|
24
24
|
useRuntimeConfigLoading,
|
|
25
25
|
useRuntimeConfig,
|
|
26
|
+
OrpcQueryProvider,
|
|
26
27
|
} from "@checkstack/frontend-api";
|
|
28
|
+
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
29
|
+
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
|
|
27
30
|
import { ConsoleLoggerApi } from "./apis/logger-api";
|
|
28
31
|
import { CoreFetchApi } from "./apis/fetch-api";
|
|
29
32
|
import { CoreRpcApi } from "./apis/rpc-api";
|
|
@@ -37,6 +40,20 @@ import { SignalProvider } from "@checkstack/signal-frontend";
|
|
|
37
40
|
import { usePluginLifecycle } from "./hooks/usePluginLifecycle";
|
|
38
41
|
import { useCommands, useGlobalShortcuts } from "@checkstack/command-frontend";
|
|
39
42
|
|
|
43
|
+
// Create a stable query client instance
|
|
44
|
+
const queryClient = new QueryClient({
|
|
45
|
+
defaultOptions: {
|
|
46
|
+
queries: {
|
|
47
|
+
// Default stale time of 30 seconds for all queries
|
|
48
|
+
staleTime: 30_000,
|
|
49
|
+
// Keep unused data in cache for 5 minutes
|
|
50
|
+
gcTime: 5 * 60 * 1000,
|
|
51
|
+
// Don't refetch on window focus by default (can be overridden per query)
|
|
52
|
+
refetchOnWindowFocus: false,
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
|
|
40
57
|
/**
|
|
41
58
|
* Component that registers global keyboard shortcuts for all commands.
|
|
42
59
|
* Uses react-router's navigate for SPA navigation.
|
|
@@ -194,13 +211,19 @@ function AppWithApis() {
|
|
|
194
211
|
}
|
|
195
212
|
|
|
196
213
|
return (
|
|
197
|
-
<
|
|
198
|
-
<
|
|
199
|
-
<
|
|
200
|
-
<
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
214
|
+
<QueryClientProvider client={queryClient}>
|
|
215
|
+
<ApiProvider registry={apiRegistry}>
|
|
216
|
+
<OrpcQueryProvider>
|
|
217
|
+
<SignalProvider backendUrl={baseUrl}>
|
|
218
|
+
<ToastProvider>
|
|
219
|
+
<AppContent />
|
|
220
|
+
</ToastProvider>
|
|
221
|
+
</SignalProvider>
|
|
222
|
+
</OrpcQueryProvider>
|
|
223
|
+
</ApiProvider>
|
|
224
|
+
{/* DevTools only in development - toggle with keyboard or floating button */}
|
|
225
|
+
<ReactQueryDevtools initialIsOpen={false} buttonPosition="bottom-left" />
|
|
226
|
+
</QueryClientProvider>
|
|
204
227
|
);
|
|
205
228
|
}
|
|
206
229
|
|