orpc-nuxt 0.1.0 → 0.1.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/README.md +29 -24
- package/dist/module.json +2 -2
- package/dist/module.mjs +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -165,7 +165,29 @@ Invalidation marks matching queries as stale and refetches active ones.
|
|
|
165
165
|
Inactive queries can refresh when used again.
|
|
166
166
|
Create the decorated client inside your app plugin so callbacks use that app's QueryClient.
|
|
167
167
|
|
|
168
|
-
##
|
|
168
|
+
## Direct calls and oRPC utilities
|
|
169
|
+
|
|
170
|
+
Use `.call()` when you just need a procedure's response, without query state or caching:
|
|
171
|
+
|
|
172
|
+
```ts
|
|
173
|
+
const post = await orpc.blog.posts.get.call({ id: 1 })
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
The client also exposes oRPC's utilities:
|
|
177
|
+
|
|
178
|
+
- `.key()` builds a cache key prefix for a procedure or router branch.
|
|
179
|
+
- `.queryKey()` builds a query key for a specific input.
|
|
180
|
+
- `.queryOptions()` builds options for Vue Query's `useQuery`.
|
|
181
|
+
- `.mutationOptions()` builds options for Vue Query's `useMutation`.
|
|
182
|
+
- `.infiniteOptions()` builds options for Vue Query's `useInfiniteQuery` for pagination.
|
|
183
|
+
|
|
184
|
+
Subscription composables are not available yet.
|
|
185
|
+
Procedures that return streams keep the oRPC utilities but do not get this package's `useQuery` or `useMutation` methods.
|
|
186
|
+
The module does not automatically transfer streamed query results from server to browser.
|
|
187
|
+
|
|
188
|
+
## Query data
|
|
189
|
+
|
|
190
|
+
### Updating cached data
|
|
169
191
|
|
|
170
192
|
Assigning a new response to `data.value` updates the shared cache for the query's current input.
|
|
171
193
|
Other components reading the same query see the update too.
|
|
@@ -173,19 +195,19 @@ Nested properties are readonly unless you enable `clone: true`.
|
|
|
173
195
|
|
|
174
196
|
```ts
|
|
175
197
|
const { data } = await orpc.blog.posts.get.useQuery({ id: 1 })
|
|
176
|
-
const savePost = orpc.blog.posts.update.useMutation()
|
|
177
198
|
|
|
178
|
-
const response = await
|
|
199
|
+
const response = await orpc.blog.posts.update.call({
|
|
179
200
|
id: 1,
|
|
180
201
|
title: "Updated title",
|
|
181
202
|
})
|
|
203
|
+
|
|
182
204
|
data.value = response
|
|
183
205
|
```
|
|
184
206
|
|
|
185
207
|
Treat the original `response` as readonly after assigning it to `data.value`.
|
|
186
208
|
The assignment passes it to the cache without a defensive copy, so changing `response.title` could modify cached data directly.
|
|
187
209
|
|
|
188
|
-
|
|
210
|
+
### Mutable data
|
|
189
211
|
|
|
190
212
|
With `clone: true`, `data.value` contains a reactive local copy that you can edit, for example in a form.
|
|
191
213
|
There are two ways to change it:
|
|
@@ -197,14 +219,12 @@ There are two ways to change it:
|
|
|
197
219
|
const id = 1
|
|
198
220
|
const { data } = await orpc.blog.posts.get.useQuery({ id }, { clone: true })
|
|
199
221
|
|
|
200
|
-
const savePost = orpc.blog.posts.update.useMutation()
|
|
201
|
-
|
|
202
222
|
if (data.value) {
|
|
203
223
|
// Only this query's local copy changes.
|
|
204
224
|
data.value.title = "Local draft"
|
|
205
225
|
|
|
206
226
|
// Save the draft, then share the server's response with other components.
|
|
207
|
-
data.value = await
|
|
227
|
+
data.value = await orpc.blog.posts.update.call({
|
|
208
228
|
id,
|
|
209
229
|
title: data.value.title,
|
|
210
230
|
})
|
|
@@ -219,21 +239,6 @@ Keep a separate form draft if it must survive these updates.
|
|
|
219
239
|
|
|
220
240
|
You cannot combine `clone: true` with `select`; selected results are readonly.
|
|
221
241
|
|
|
222
|
-
## Direct calls and oRPC utilities
|
|
223
|
-
|
|
224
|
-
Use `.call()` when you just need a procedure's response, without query state or caching:
|
|
225
|
-
|
|
226
|
-
```ts
|
|
227
|
-
const post = await orpc.blog.posts.get.call({ id: 1 })
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
The client also exposes oRPC's `.key()`, `.queryKey()`, `.queryOptions()`, `.mutationOptions()`, and `.infiniteOptions()` utilities.
|
|
231
|
-
You can pass their options to Vue Query composables, for example `.infiniteOptions()` to `useInfiniteQuery` for pagination.
|
|
232
|
-
|
|
233
|
-
Subscription composables are not available yet.
|
|
234
|
-
Procedures that return streams keep the oRPC utilities but do not get this package's `useQuery` or `useMutation` methods.
|
|
235
|
-
The module does not automatically transfer streamed query results from server to browser.
|
|
236
|
-
|
|
237
242
|
## Advanced
|
|
238
243
|
|
|
239
244
|
### Separate API service
|
|
@@ -442,6 +447,6 @@ Install dependencies with `bun install`, then run `bun run build`, `bun run type
|
|
|
442
447
|
To try the package in a Nuxt app, build it and run `bunx nuxt dev tests/fixtures/nuxt`.
|
|
443
448
|
The example app uses the built package, so rebuild after changing its source.
|
|
444
449
|
|
|
445
|
-
Run `bunx playwright install chromium`, then `bun run test:nuxt` to check the packed npm archive with Nuxt 3
|
|
450
|
+
Run `bunx playwright install chromium`, then `bun run test:nuxt` to check the packed npm archive with the oldest and newest supported Nuxt 3 and Nuxt 4 releases.
|
|
446
451
|
Each version is checked with both module-managed and app-managed QueryClients, including types, SSR, and hydration in development and production.
|
|
447
|
-
To check one version, use `bun run test:nuxt 3.
|
|
452
|
+
To check one version, use `bun run test:nuxt 3.14.1592`.
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "orpc-nuxt",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "oRPC integration for Nuxt.",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "oRPC integration for Nuxt with TanStack Vue Query composables.",
|
|
5
5
|
"homepage": "https://github.com/IlyaSemenov/orpc-nuxt#readme",
|
|
6
6
|
"bugs": "https://github.com/IlyaSemenov/orpc-nuxt/issues",
|
|
7
7
|
"license": "MIT",
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
"types": "tsc --noEmit && tsc --noEmit -p tests/tsconfig.json && nuxt typecheck tests/fixtures/nuxt"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@nuxt/kit": "^4.
|
|
54
|
-
"devalue": "^5.
|
|
53
|
+
"@nuxt/kit": "^3.14.1592 || ^4.0.1",
|
|
54
|
+
"devalue": "^5.0.0",
|
|
55
55
|
"es-toolkit": "^1.52.0"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"@orpc/client": "2.0.0-beta.35",
|
|
76
76
|
"@orpc/tanstack-query": "2.0.0-beta.35",
|
|
77
77
|
"@tanstack/vue-query": "^5.102.8",
|
|
78
|
-
"nuxt": "^3.
|
|
78
|
+
"nuxt": "^3.14.1592 || ^4.0.1",
|
|
79
79
|
"vue": "^3.5.0"
|
|
80
80
|
},
|
|
81
81
|
"packageManager": "bun@1.3.14"
|