@checkstack/frontend-api 0.5.0 → 0.5.2
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 +38 -0
- package/package.json +4 -4
- package/src/orpc-query.tsx +8 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
# @checkstack/frontend-api
|
|
2
2
|
|
|
3
|
+
## 0.5.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f23f3c9: Establish the canonical optimistic-UI pattern for oRPC mutations
|
|
8
|
+
(`onMutate` snapshot / patch, `onError` rollback, `onSettled`
|
|
9
|
+
invalidate) and apply it to the two highest-frequency toggles where
|
|
10
|
+
perceived latency was most visible:
|
|
11
|
+
|
|
12
|
+
- `markAsRead` on the Notifications page — clicking the check on a
|
|
13
|
+
notification card now flips the read state immediately instead of
|
|
14
|
+
waiting for the round-trip.
|
|
15
|
+
- `pauseConfiguration` / `resumeConfiguration` on the Health Check
|
|
16
|
+
Config page — pause/resume now flip the row's badge instantly,
|
|
17
|
+
rolling back on server error.
|
|
18
|
+
|
|
19
|
+
The wrapper type for `useMutation` on each plugin client gained an
|
|
20
|
+
optional `TContext` generic so optimistic sites can return a snapshot
|
|
21
|
+
from `onMutate` and consume it in `onError` without `unknown` casts.
|
|
22
|
+
The runtime behaviour and the auto-invalidation on success are
|
|
23
|
+
unchanged; the change is additive on the type surface only.
|
|
24
|
+
|
|
25
|
+
Full pattern and "when NOT to use it" guidance live in
|
|
26
|
+
`docs/frontend/optimistic-updates.md`.
|
|
27
|
+
|
|
28
|
+
- Updated dependencies [f23f3c9]
|
|
29
|
+
- Updated dependencies [f23f3c9]
|
|
30
|
+
- @checkstack/common@0.11.0
|
|
31
|
+
- @checkstack/signal-common@0.2.4
|
|
32
|
+
|
|
33
|
+
## 0.5.1
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- Updated dependencies [9016526]
|
|
38
|
+
- @checkstack/common@0.10.0
|
|
39
|
+
- @checkstack/signal-common@0.2.3
|
|
40
|
+
|
|
3
41
|
## 0.5.0
|
|
4
42
|
|
|
5
43
|
### Minor Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@checkstack/frontend-api",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"license": "Elastic-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"react": "^18.0.0"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@checkstack/common": "0.
|
|
17
|
-
"@checkstack/signal-common": "0.2.
|
|
16
|
+
"@checkstack/common": "0.10.0",
|
|
17
|
+
"@checkstack/signal-common": "0.2.3",
|
|
18
18
|
"@orpc/client": "^1.13.14",
|
|
19
19
|
"@orpc/contract": "^1.13.14",
|
|
20
20
|
"@orpc/react-query": "1.13.4",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"@types/react": "^18.0.0",
|
|
27
27
|
"typescript": "^5.0.0",
|
|
28
28
|
"@checkstack/tsconfig": "0.0.7",
|
|
29
|
-
"@checkstack/scripts": "0.3.
|
|
29
|
+
"@checkstack/scripts": "0.3.2"
|
|
30
30
|
},
|
|
31
31
|
"checkstack": {
|
|
32
32
|
"type": "tooling"
|
package/src/orpc-query.tsx
CHANGED
|
@@ -94,14 +94,19 @@ interface QueryProcedure<TInput, TOutput> {
|
|
|
94
94
|
/**
|
|
95
95
|
* Mutation procedure hook interface - only exposes useMutation.
|
|
96
96
|
* Mutations don't take input directly - it's passed to mutate/mutateAsync.
|
|
97
|
+
*
|
|
98
|
+
* `TContext` is threaded through the options so optimistic-update sites
|
|
99
|
+
* can return a snapshot from `onMutate` and read it back in `onError`
|
|
100
|
+
* without resorting to `unknown` casts. See
|
|
101
|
+
* `docs/frontend/optimistic-updates.md` for the canonical pattern.
|
|
97
102
|
*/
|
|
98
103
|
interface MutationProcedure<TInput, TOutput> {
|
|
99
|
-
useMutation: (
|
|
104
|
+
useMutation: <TContext = unknown>(
|
|
100
105
|
options?: Omit<
|
|
101
|
-
UseMutationOptions<TOutput, Error, TInput>,
|
|
106
|
+
UseMutationOptions<TOutput, Error, TInput, TContext>,
|
|
102
107
|
"mutationFn" | "mutationKey"
|
|
103
108
|
>,
|
|
104
|
-
) => UseMutationResult<TOutput, Error, TInput>;
|
|
109
|
+
) => UseMutationResult<TOutput, Error, TInput, TContext>;
|
|
105
110
|
}
|
|
106
111
|
|
|
107
112
|
/**
|