@beignet/react-query 0.0.20 → 0.0.22
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 +8 -0
- package/README.md +7 -0
- package/package.json +4 -2
- package/skills/client/SKILL.md +117 -0
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -19,6 +19,13 @@ npm install @beignet/react-query @beignet/core @tanstack/react-query react
|
|
|
19
19
|
|
|
20
20
|
This package requires TypeScript 5.0 or higher for proper type inference.
|
|
21
21
|
|
|
22
|
+
## Agent skills
|
|
23
|
+
|
|
24
|
+
This package ships a TanStack Intent skill for coding agents:
|
|
25
|
+
`@beignet/react-query#client`. Load it when adding typed client setup, React
|
|
26
|
+
Query options, feature client helpers, hooks, cache invalidation, server
|
|
27
|
+
prefetching, or client/server boundary fixes in a Beignet app.
|
|
28
|
+
|
|
22
29
|
## Setup
|
|
23
30
|
|
|
24
31
|
### 1. Create your app client helpers
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@beignet/react-query",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.22",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "TanStack Query integration for Beignet",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"!src/**/*.test.ts",
|
|
18
18
|
"!src/**/*.test.tsx",
|
|
19
19
|
"!src/**/*.test-d.ts",
|
|
20
|
+
"skills",
|
|
20
21
|
"README.md",
|
|
21
22
|
"CHANGELOG.md"
|
|
22
23
|
],
|
|
@@ -34,7 +35,8 @@
|
|
|
34
35
|
"api",
|
|
35
36
|
"typescript",
|
|
36
37
|
"react-query",
|
|
37
|
-
"tanstack"
|
|
38
|
+
"tanstack",
|
|
39
|
+
"tanstack-intent"
|
|
38
40
|
],
|
|
39
41
|
"license": "MIT",
|
|
40
42
|
"repository": {
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: client
|
|
3
|
+
description: "Build Beignet browser client and TanStack Query integration with @beignet/react-query: createClient, createReactQuery, queryOptions, mutationOptions, cache keys, feature client helpers, hooks, QueryClientProvider, server prefetching, and client/server boundary fixes. Use when adding or debugging React Query usage in a Beignet app."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Beignet React Query Client
|
|
7
|
+
|
|
8
|
+
Use this skill when working in a Beignet app that depends on
|
|
9
|
+
`@beignet/react-query`. Read the app's root `client/` helpers and nearest
|
|
10
|
+
feature client module before adding new helpers.
|
|
11
|
+
|
|
12
|
+
## Shared Client Setup
|
|
13
|
+
|
|
14
|
+
Root `client/` owns shared frontend adapter factories. In `src/` apps this is
|
|
15
|
+
usually `src/client/`.
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { createClient } from "@beignet/core/client";
|
|
19
|
+
import { createReactQuery } from "@beignet/react-query";
|
|
20
|
+
import { QueryClient } from "@tanstack/react-query";
|
|
21
|
+
|
|
22
|
+
export const apiClient = createClient({
|
|
23
|
+
baseUrl: "",
|
|
24
|
+
validateInput: true,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export const rq = createReactQuery(apiClient);
|
|
28
|
+
|
|
29
|
+
export function makeQueryClient() {
|
|
30
|
+
return new QueryClient();
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Reuse the app's existing helper names and client options. Do not introduce a
|
|
35
|
+
parallel Beignet client unless the app already has a multi-client convention.
|
|
36
|
+
|
|
37
|
+
## Feature Client Helpers
|
|
38
|
+
|
|
39
|
+
Feature-specific query options, mutations, and hooks may live under the
|
|
40
|
+
feature. Prefer the canonical directory form for new apps:
|
|
41
|
+
|
|
42
|
+
```txt
|
|
43
|
+
features/todos/client/queries.ts
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Existing apps may use:
|
|
47
|
+
|
|
48
|
+
```txt
|
|
49
|
+
features/todos/client.ts
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Follow the existing style unless intentionally migrating. Do not mix both
|
|
53
|
+
within one feature.
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
import { rq } from "@/client";
|
|
57
|
+
import { createTodo, listTodos } from "@/features/todos/contracts";
|
|
58
|
+
|
|
59
|
+
export const listTodosQuery = () =>
|
|
60
|
+
rq(listTodos).queryOptions({ query: { limit: 20 } });
|
|
61
|
+
|
|
62
|
+
export const createTodoMutation = () =>
|
|
63
|
+
rq(createTodo).mutationOptions();
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Components
|
|
67
|
+
|
|
68
|
+
Components and anything reachable from `"use client"` may import:
|
|
69
|
+
|
|
70
|
+
- contracts
|
|
71
|
+
- schemas
|
|
72
|
+
- feature client helpers
|
|
73
|
+
- root `client/` helpers
|
|
74
|
+
- TanStack Query primitives
|
|
75
|
+
- React Hook Form and UI helpers
|
|
76
|
+
|
|
77
|
+
They must not import:
|
|
78
|
+
|
|
79
|
+
- use cases
|
|
80
|
+
- feature route groups
|
|
81
|
+
- concrete infra adapters
|
|
82
|
+
- provider packages
|
|
83
|
+
- `server/`
|
|
84
|
+
- `app-context.ts`
|
|
85
|
+
- Node runtime modules
|
|
86
|
+
|
|
87
|
+
Call server behavior through Beignet contracts and typed clients.
|
|
88
|
+
|
|
89
|
+
## Query And Mutation Patterns
|
|
90
|
+
|
|
91
|
+
- Use `queryOptions(...)` so options work with `useQuery`, `prefetchQuery`,
|
|
92
|
+
`fetchQuery`, and server prefetching.
|
|
93
|
+
- Use `mutationOptions(...)` with `useMutation`.
|
|
94
|
+
- Use `rq(contract).invalidate(queryClient)` or the app's existing key helper
|
|
95
|
+
after successful mutations.
|
|
96
|
+
- If the app configures `createReactQuery(apiClient, { keyHeaders })`, preserve
|
|
97
|
+
that when adding helpers so tenant or header-scoped caches stay distinct.
|
|
98
|
+
- Keep business validation in use cases. Client validation is for UX and early
|
|
99
|
+
feedback.
|
|
100
|
+
|
|
101
|
+
## Common Fix
|
|
102
|
+
|
|
103
|
+
If `beignet lint` says a client component reaches a use-case module:
|
|
104
|
+
|
|
105
|
+
1. Move shared DTOs and validation to `features/<feature>/schemas.ts`.
|
|
106
|
+
2. Remove imports from use cases, routes, infra, providers, or `server/`.
|
|
107
|
+
3. Add a feature client helper that imports only contracts and root client
|
|
108
|
+
helpers.
|
|
109
|
+
4. Update components to call the helper through TanStack Query.
|
|
110
|
+
|
|
111
|
+
Then run:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
beignet lint
|
|
115
|
+
beignet doctor --strict
|
|
116
|
+
bun run typecheck
|
|
117
|
+
```
|