@checkstack/frontend 0.1.0 → 0.2.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 CHANGED
@@ -1,5 +1,94 @@
1
1
  # @checkstack/frontend
2
2
 
3
+ ## 0.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 4eed42d: Fix "No QueryClient set" error in containerized builds
8
+
9
+ **Problem**: The containerized application was throwing "No QueryClient set, use QueryClientProvider to set one" errors during plugin registration. This didn't happen in dev mode.
10
+
11
+ **Root Cause**: The `@tanstack/react-query` package was being bundled separately in different workspace packages, causing multiple React Query contexts. The `QueryClientProvider` from the main app wasn't visible to plugin code due to this module duplication.
12
+
13
+ **Changes**:
14
+
15
+ - `@checkstack/frontend-api`: Export `useQueryClient` from the centralized React Query import, ensuring all packages use the same context
16
+ - `@checkstack/dashboard-frontend`: Import `useQueryClient` from `@checkstack/frontend-api` instead of directly from `@tanstack/react-query`, and remove the direct dependency
17
+ - `@checkstack/frontend`: Add `@tanstack/react-query` to Vite's `resolve.dedupe` as a safety net
18
+
19
+ - Updated dependencies [4eed42d]
20
+ - @checkstack/frontend-api@0.3.0
21
+ - @checkstack/auth-frontend@0.3.1
22
+ - @checkstack/catalog-frontend@0.3.1
23
+ - @checkstack/command-frontend@0.2.1
24
+ - @checkstack/ui@0.2.2
25
+
26
+ ## 0.2.0
27
+
28
+ ### Minor Changes
29
+
30
+ - 7a23261: ## TanStack Query Integration
31
+
32
+ Migrated all frontend components to use `usePluginClient` hook with TanStack Query integration, replacing the legacy `forPlugin()` pattern.
33
+
34
+ ### New Features
35
+
36
+ - **`usePluginClient` hook**: Provides type-safe access to plugin APIs with `.useQuery()` and `.useMutation()` methods
37
+ - **Automatic request deduplication**: Multiple components requesting the same data share a single network request
38
+ - **Built-in caching**: Configurable stale time and cache duration per query
39
+ - **Loading/error states**: TanStack Query provides `isLoading`, `error`, `isRefetching` states automatically
40
+ - **Background refetching**: Stale data is automatically refreshed when components mount
41
+
42
+ ### Contract Changes
43
+
44
+ All RPC contracts now require `operationType: "query"` or `operationType: "mutation"` metadata:
45
+
46
+ ```typescript
47
+ const getItems = proc()
48
+ .meta({ operationType: "query", access: [access.read] })
49
+ .output(z.array(itemSchema))
50
+ .query();
51
+
52
+ const createItem = proc()
53
+ .meta({ operationType: "mutation", access: [access.manage] })
54
+ .input(createItemSchema)
55
+ .output(itemSchema)
56
+ .mutation();
57
+ ```
58
+
59
+ ### Migration
60
+
61
+ ```typescript
62
+ // Before (forPlugin pattern)
63
+ const api = useApi(myPluginApiRef);
64
+ const [items, setItems] = useState<Item[]>([]);
65
+ useEffect(() => {
66
+ api.getItems().then(setItems);
67
+ }, [api]);
68
+
69
+ // After (usePluginClient pattern)
70
+ const client = usePluginClient(MyPluginApi);
71
+ const { data: items, isLoading } = client.getItems.useQuery({});
72
+ ```
73
+
74
+ ### Bug Fixes
75
+
76
+ - Fixed `rpc.test.ts` test setup for middleware type inference
77
+ - Fixed `SearchDialog` to use `setQuery` instead of deprecated `search` method
78
+ - Fixed null→undefined warnings in notification and queue frontends
79
+
80
+ ### Patch Changes
81
+
82
+ - Updated dependencies [7a23261]
83
+ - @checkstack/frontend-api@0.2.0
84
+ - @checkstack/common@0.3.0
85
+ - @checkstack/auth-frontend@0.3.0
86
+ - @checkstack/catalog-frontend@0.3.0
87
+ - @checkstack/command-frontend@0.2.0
88
+ - @checkstack/ui@0.2.1
89
+ - @checkstack/signal-common@0.1.1
90
+ - @checkstack/signal-frontend@0.0.7
91
+
3
92
  ## 0.1.0
4
93
 
5
94
  ### Minor Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@checkstack/frontend",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
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
- <ApiProvider registry={apiRegistry}>
198
- <SignalProvider backendUrl={baseUrl}>
199
- <ToastProvider>
200
- <AppContent />
201
- </ToastProvider>
202
- </SignalProvider>
203
- </ApiProvider>
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
 
package/vite.config.ts CHANGED
@@ -53,7 +53,13 @@ export default defineConfig(() => {
53
53
  // Force all monorepo packages to use the same React copy at build time.
54
54
  // Without this, each workspace package can bundle its own React copy,
55
55
  // causing "useContext is null" errors from context mismatch.
56
- dedupe: ["react", "react-dom", "react-router-dom", "react/jsx-runtime"],
56
+ dedupe: [
57
+ "react",
58
+ "react-dom",
59
+ "react-router-dom",
60
+ "react/jsx-runtime",
61
+ "@tanstack/react-query",
62
+ ],
57
63
  alias: {
58
64
  "@": path.resolve(__dirname, "./src"),
59
65
  },