@checkstack/theme-common 0.0.5 → 0.1.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/rpc-contract.ts +11 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,64 @@
|
|
|
1
1
|
# @checkstack/theme-common
|
|
2
2
|
|
|
3
|
+
## 0.1.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.0.5
|
|
4
63
|
|
|
5
64
|
### Patch Changes
|
package/package.json
CHANGED
package/src/rpc-contract.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
createClientDefinition,
|
|
4
|
-
type ProcedureMetadata,
|
|
5
|
-
} from "@checkstack/common";
|
|
1
|
+
import { createClientDefinition, proc } from "@checkstack/common";
|
|
6
2
|
import { pluginMetadata } from "./plugin-metadata";
|
|
7
3
|
import { z } from "zod";
|
|
8
4
|
|
|
@@ -10,14 +6,15 @@ import { z } from "zod";
|
|
|
10
6
|
export const ThemeSchema = z.enum(["light", "dark", "system"]);
|
|
11
7
|
export type Theme = z.infer<typeof ThemeSchema>;
|
|
12
8
|
|
|
13
|
-
// Base builder with full metadata support
|
|
14
|
-
const _base = oc.$meta<ProcedureMetadata>({});
|
|
15
|
-
|
|
16
9
|
// Theme RPC Contract
|
|
17
10
|
export const themeContract = {
|
|
18
11
|
// Get current user's theme preference
|
|
19
12
|
// User-only - each user reads their own theme
|
|
20
|
-
getTheme:
|
|
13
|
+
getTheme: proc({
|
|
14
|
+
operationType: "query",
|
|
15
|
+
userType: "user",
|
|
16
|
+
access: [],
|
|
17
|
+
}).output(
|
|
21
18
|
z.object({
|
|
22
19
|
theme: ThemeSchema,
|
|
23
20
|
})
|
|
@@ -25,8 +22,11 @@ export const themeContract = {
|
|
|
25
22
|
|
|
26
23
|
// Set current user's theme preference
|
|
27
24
|
// User-only - each user sets their own theme
|
|
28
|
-
setTheme:
|
|
29
|
-
|
|
25
|
+
setTheme: proc({
|
|
26
|
+
operationType: "mutation",
|
|
27
|
+
userType: "user",
|
|
28
|
+
access: [],
|
|
29
|
+
})
|
|
30
30
|
.input(
|
|
31
31
|
z.object({
|
|
32
32
|
theme: ThemeSchema,
|