use-convex 1.0.0 → 1.2.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/README.md +38 -15
- package/dist/module.d.mts +1 -0
- package/dist/runtime/composables/prewarmQuery.d.ts +3 -2
- package/dist/runtime/composables/useConvexAction.d.ts +3 -2
- package/dist/runtime/composables/useConvexFileUpload.d.ts +5 -4
- package/dist/runtime/composables/useConvexMutation.d.ts +4 -3
- package/dist/runtime/composables/useConvexPaginatedQuery.d.ts +3 -1
- package/dist/runtime/composables/useConvexQueries.d.ts +4 -3
- package/dist/runtime/composables/useConvexQuery.d.ts +4 -3
- package/dist/runtime/composables/useConvexR2Upload.d.ts +4 -3
- package/dist/runtime/server/fetch.d.ts +5 -4
- package/dist/runtime/utils/functionReference.d.ts +10 -0
- package/dist/runtime/utils/functionReference.js +0 -0
- package/dist/runtime/utils/queryKey.d.ts +2 -2
- package/dist/types.d.mts +2 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ export default defineNuxtConfig({
|
|
|
26
26
|
<script setup lang="ts">
|
|
27
27
|
import { api } from '~~/convex/_generated/api'
|
|
28
28
|
|
|
29
|
-
const { data, pending, error } = await useConvexQuery(api.tasks.list, {})
|
|
29
|
+
const { data, pending, error } = await useConvexQuery(api.tasks.list, {}, { authenticated: true })
|
|
30
30
|
</script>
|
|
31
31
|
```
|
|
32
32
|
|
|
@@ -58,6 +58,7 @@ Set `convex.server: false` to skip SSR snapshots globally, or pass `{ server: fa
|
|
|
58
58
|
const { data, pending, error, refresh } = await useConvexQuery(
|
|
59
59
|
api.tasks.list,
|
|
60
60
|
{}, // args, a ref / getter, or 'skip'
|
|
61
|
+
{ authenticated: true }, // wait for Convex auth before live subscribe
|
|
61
62
|
)
|
|
62
63
|
```
|
|
63
64
|
|
|
@@ -84,11 +85,14 @@ prewarmQuery(api.tasks.list, {})
|
|
|
84
85
|
|
|
85
86
|
### Several queries
|
|
86
87
|
|
|
88
|
+
Browser-only live map (no SSR). Each value is `data | undefined` (loading) | `Error`. Combine with `useConvexQuery` when you need an SSR snapshot for known queries.
|
|
89
|
+
|
|
87
90
|
```ts
|
|
88
91
|
const results = useConvexQueries(() => ({
|
|
89
|
-
|
|
90
|
-
|
|
92
|
+
tasks: { query: api.tasks.list, args: {} },
|
|
93
|
+
files: showFiles.value ? { query: api.files.list, args: {} } : 'skip',
|
|
91
94
|
}))
|
|
95
|
+
// results.value.tasks
|
|
92
96
|
```
|
|
93
97
|
|
|
94
98
|
### Pagination
|
|
@@ -97,8 +101,9 @@ const results = useConvexQueries(() => ({
|
|
|
97
101
|
const { results, status, isLoading, loadMore } = await useConvexPaginatedQuery(
|
|
98
102
|
api.tasks.listPaginated,
|
|
99
103
|
{},
|
|
100
|
-
{ initialNumItems: 20 },
|
|
104
|
+
{ initialNumItems: 20, authenticated: true },
|
|
101
105
|
)
|
|
106
|
+
// loadMore() when status === 'CanLoadMore'
|
|
102
107
|
```
|
|
103
108
|
|
|
104
109
|
The first page is SSR'd. On the browser, every loaded page stays live. `loadMore` fetches the next page.
|
|
@@ -115,10 +120,10 @@ const { mutate, pending, error } = useConvexMutation(api.tasks.create, {
|
|
|
115
120
|
])
|
|
116
121
|
},
|
|
117
122
|
})
|
|
118
|
-
await mutate({ text: 'Ship it' })
|
|
123
|
+
await mutate({ text: 'Ship it' }) // browser-only
|
|
119
124
|
|
|
120
|
-
const { run } = useConvexAction(api.
|
|
121
|
-
await run({ text: '
|
|
125
|
+
const { run, pending, error } = useConvexAction(api.tasks.shout)
|
|
126
|
+
const shouted = await run({ text: 'hello' }) // browser-only
|
|
122
127
|
```
|
|
123
128
|
|
|
124
129
|
For paginated lists:
|
|
@@ -133,7 +138,7 @@ insertAtTop({
|
|
|
133
138
|
|
|
134
139
|
Also available: `insertAtBottomIfLoaded`, `insertAtPosition`, `optimisticallyUpdateValueInPaginatedQuery`.
|
|
135
140
|
|
|
136
|
-
`useConvex()` returns the browser `ConvexClient` when you need an escape hatch. `useConvexConnectionState()` is a reactive WebSocket `
|
|
141
|
+
`useConvex()` returns the browser `ConvexClient` when you need an escape hatch. `useConvexConnectionState()` is a reactive `ShallowRef<ConnectionState | null>` (WebSocket status: `isWebSocketConnected`, `hasInflightRequests`, …).
|
|
137
142
|
|
|
138
143
|
## File uploads
|
|
139
144
|
|
|
@@ -145,7 +150,7 @@ const { upload, pending, error, progress } = useConvexFileUpload({
|
|
|
145
150
|
saveFile: api.files.save, // ({ storageId, name, contentType, size, ... }) => Id<"files">
|
|
146
151
|
})
|
|
147
152
|
|
|
148
|
-
await upload(file)
|
|
153
|
+
await upload(file) // progress: 0..1 while bytes fly
|
|
149
154
|
// optional extra save args: await upload(file, { caption: '…' })
|
|
150
155
|
```
|
|
151
156
|
|
|
@@ -169,8 +174,9 @@ export const { generateUploadUrl, syncMetadata } = r2.clientApi({
|
|
|
169
174
|
```
|
|
170
175
|
|
|
171
176
|
```ts
|
|
177
|
+
// Pass r2.clientApi() exports: { generateUploadUrl, syncMetadata }
|
|
172
178
|
const { upload, pending, error, progress } = useConvexR2Upload(api.r2)
|
|
173
|
-
const key = await upload(file)
|
|
179
|
+
const key = await upload(file) // R2 object key
|
|
174
180
|
```
|
|
175
181
|
|
|
176
182
|
That runs `generateUploadUrl` → `PUT` to the signed URL → `syncMetadata({ key })`, with XHR progress. Use built-in `useConvexFileUpload` for Convex storage; use this helper when you adopt the R2 component.
|
|
@@ -303,6 +309,15 @@ export default defineEventHandler(async (event) => {
|
|
|
303
309
|
})
|
|
304
310
|
```
|
|
305
311
|
|
|
312
|
+
```ts
|
|
313
|
+
// server/api/shout.post.ts
|
|
314
|
+
export default defineEventHandler(async (event) => {
|
|
315
|
+
requireConvexAuth(event)
|
|
316
|
+
const { text } = await readBody(event)
|
|
317
|
+
return await fetchAction(api.tasks.shout, { text }, { event })
|
|
318
|
+
})
|
|
319
|
+
```
|
|
320
|
+
|
|
306
321
|
`fetchAction` uses the same options. Each helper builds a fresh `ConvexHttpClient`. Override with `{ token }` when you already have a JWT. `getConvexToken(event)` reads the cookie without throwing.
|
|
307
322
|
|
|
308
323
|
## Config
|
|
@@ -353,7 +368,8 @@ pnpm run dev
|
|
|
353
368
|
|
|
354
369
|
| Route | What it shows |
|
|
355
370
|
| --------- | ----------------------------------------------------- |
|
|
356
|
-
| `/` |
|
|
371
|
+
| `/` | Shell session: features + composable call-shape demos |
|
|
372
|
+
| `/live` | SSR snapshot + live overlay (sign up, CRUD todos) |
|
|
357
373
|
| `/server` | Nitro `fetchQuery` / `fetchMutation` / `fetchAction` |
|
|
358
374
|
| `/files` | `useConvexFileUpload` (upload, list, preview, delete) |
|
|
359
375
|
| `/extras` | `live: false`, pagination, action, connection state |
|
|
@@ -362,17 +378,24 @@ On `/server`: `GET /api/health` is public; `GET`/`POST /api/tasks` use the cooki
|
|
|
362
378
|
|
|
363
379
|
## Releasing
|
|
364
380
|
|
|
365
|
-
Releases run from `.github/workflows/release.yml` when commits land on `main
|
|
381
|
+
Releases run from `.github/workflows/release.yml` when commits that touch `src/` land on `main` (or when the workflow is run manually). Version bumps follow [conventional commits](https://www.conventionalcommits.org/):
|
|
366
382
|
|
|
367
383
|
| Commit | Release |
|
|
368
384
|
| ------------------------------ | ------- |
|
|
369
|
-
| `fix:` | patch |
|
|
370
|
-
| `feat:` | minor |
|
|
371
385
|
| `feat!:` or `BREAKING CHANGE:` | major |
|
|
372
|
-
| `
|
|
386
|
+
| `feat:` | minor |
|
|
387
|
+
| anything else under `src/` | patch |
|
|
373
388
|
|
|
374
389
|
semantic-release publishes `use-convex` to npm, tags `vX.Y.Z`, and opens a GitHub Release. The repo `package.json` version is not committed back.
|
|
375
390
|
|
|
391
|
+
Publishing uses [npm trusted publishing](https://docs.npmjs.com/trusted-publishers) (OIDC), not an `NPM_TOKEN`. On [the `use-convex` package settings](https://www.npmjs.com/package/use-convex?activeTab=settings) add a GitHub Actions trusted publisher:
|
|
392
|
+
|
|
393
|
+
- **Organization or user:** `jrmybtlr`
|
|
394
|
+
- **Repository:** `convex-nuxt`
|
|
395
|
+
- **Workflow filename:** `release.yml`
|
|
396
|
+
- **Environment:** leave empty
|
|
397
|
+
- **Allowed actions:** include **`npm publish`** (new publishers default to staged publish only)
|
|
398
|
+
|
|
376
399
|
## License
|
|
377
400
|
|
|
378
401
|
MIT
|
package/dist/module.d.mts
CHANGED
|
@@ -9,6 +9,7 @@ export { ConvexR2UploadApi, ConvexR2UploadProgress } from '../dist/runtime/compo
|
|
|
9
9
|
export { PaginatedQueryArgs, PaginatedQueryItem, PaginatedQueryReference, PaginationStatus, UseConvexPaginatedQueryOptions, UseConvexPaginatedQueryReturn } from '../dist/runtime/composables/useConvexPaginatedQuery.js';
|
|
10
10
|
export { ConvexQueriesRequest, ConvexQueriesResult, ConvexQueryRequestEntry } from '../dist/runtime/composables/useConvexQueries.js';
|
|
11
11
|
export { ConvexFetchOptions } from '../dist/runtime/server/fetch.js';
|
|
12
|
+
export { ConvexRef } from '../dist/runtime/utils/functionReference.js';
|
|
12
13
|
export { ConvexAuthContext, ConvexNuxtContext } from '../dist/runtime/utils/context.js';
|
|
13
14
|
export { ConnectionState } from '../dist/runtime/composables/useConvexConnectionState.js';
|
|
14
15
|
export { ConvexGate } from '../dist/runtime/composables/useConvexGate.js';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { FunctionArgs
|
|
1
|
+
import type { FunctionArgs } from 'convex/server';
|
|
2
|
+
import type { ConvexRef } from '../utils/functionReference.js';
|
|
2
3
|
/**
|
|
3
4
|
* Start a live subscription early so the first `useConvexQuery` / screen
|
|
4
5
|
* paint can reuse warm client state (React `prewarmQuery` parity).
|
|
@@ -6,4 +7,4 @@ import type { FunctionArgs, FunctionReference } from 'convex/server';
|
|
|
6
7
|
* Returns an unsubscribe function. When called during Vue `setup`, the
|
|
7
8
|
* subscription is also cleaned up with the current effect scope.
|
|
8
9
|
*/
|
|
9
|
-
export declare function prewarmQuery<Query extends
|
|
10
|
+
export declare function prewarmQuery<Query extends ConvexRef<'query'>>(query: Query, args?: FunctionArgs<Query>): () => void;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import type { FunctionArgs,
|
|
1
|
+
import type { FunctionArgs, FunctionReturnType } from 'convex/server';
|
|
2
2
|
import { type MaybeRefOrGetter } from 'vue';
|
|
3
|
+
import type { ConvexRef } from '../utils/functionReference.js';
|
|
3
4
|
/**
|
|
4
5
|
* Browser action helper. Returns `{ run, error, pending }`.
|
|
5
6
|
*
|
|
6
7
|
* Safe to call during SSR setup — the ConvexClient is only touched when
|
|
7
8
|
* `run()` runs in the browser.
|
|
8
9
|
*/
|
|
9
|
-
export declare function useConvexAction<Action extends
|
|
10
|
+
export declare function useConvexAction<Action extends ConvexRef<'action'>>(action: Action): {
|
|
10
11
|
run: (args?: MaybeRefOrGetter<FunctionArgs<Action>>) => Promise<FunctionReturnType<Action>>;
|
|
11
12
|
error: import("vue").Ref<Error | null, Error | null>;
|
|
12
13
|
pending: import("vue").ComputedRef<boolean>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { FunctionArgs,
|
|
1
|
+
import type { FunctionArgs, FunctionReturnType } from 'convex/server';
|
|
2
|
+
import type { ConvexRef } from '../utils/functionReference.js';
|
|
2
3
|
/** Built-in fields the composable always passes into `saveFile`. */
|
|
3
4
|
export type ConvexFileUploadMeta = {
|
|
4
5
|
storageId: string;
|
|
@@ -6,8 +7,8 @@ export type ConvexFileUploadMeta = {
|
|
|
6
7
|
contentType: string;
|
|
7
8
|
size: number;
|
|
8
9
|
};
|
|
9
|
-
export type ConvexFileUploadExtraArgs<SaveFile extends
|
|
10
|
-
export interface UseConvexFileUploadOptions<GenerateUploadUrl extends
|
|
10
|
+
export type ConvexFileUploadExtraArgs<SaveFile extends ConvexRef<'mutation'>> = Omit<FunctionArgs<SaveFile>, 'storageId' | 'name' | 'contentType' | 'size'>;
|
|
11
|
+
export interface UseConvexFileUploadOptions<GenerateUploadUrl extends ConvexRef<'mutation'>, SaveFile extends ConvexRef<'mutation'>> {
|
|
11
12
|
/**
|
|
12
13
|
* Mutation that returns a short-lived Convex upload URL
|
|
13
14
|
* (`ctx.storage.generateUploadUrl()`). Must enforce auth itself.
|
|
@@ -35,7 +36,7 @@ export declare function postFileToUploadUrl(uploadUrl: string, file: File, onPro
|
|
|
35
36
|
* in the browser. Your Convex mutations must enforce auth; never expose an
|
|
36
37
|
* unauthenticated `generateUploadUrl`.
|
|
37
38
|
*/
|
|
38
|
-
export declare function useConvexFileUpload<GenerateUploadUrl extends
|
|
39
|
+
export declare function useConvexFileUpload<GenerateUploadUrl extends ConvexRef<'mutation'>, SaveFile extends ConvexRef<'mutation'>>(options: UseConvexFileUploadOptions<GenerateUploadUrl, SaveFile>): {
|
|
39
40
|
upload: (file: File, extra?: ConvexFileUploadExtraArgs<SaveFile> extends Record<string, never> ? undefined : ConvexFileUploadExtraArgs<SaveFile>) => Promise<FunctionReturnType<SaveFile>>;
|
|
40
41
|
error: import("vue").Ref<Error | null, Error | null>;
|
|
41
42
|
pending: import("vue").ComputedRef<boolean>;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { FunctionArgs,
|
|
1
|
+
import type { FunctionArgs, FunctionReturnType } from 'convex/server';
|
|
2
2
|
import type { OptimisticUpdate } from 'convex/browser';
|
|
3
3
|
import { type MaybeRefOrGetter } from 'vue';
|
|
4
|
+
import type { ConvexRef } from '../utils/functionReference.js';
|
|
4
5
|
export type { OptimisticUpdate };
|
|
5
|
-
export interface UseConvexMutationOptions<Mutation extends
|
|
6
|
+
export interface UseConvexMutationOptions<Mutation extends ConvexRef<'mutation'>> {
|
|
6
7
|
/**
|
|
7
8
|
* Local query update applied while the mutation is in flight.
|
|
8
9
|
* Passed through to `ConvexClient.mutation` → `BaseConvexClient`.
|
|
@@ -18,7 +19,7 @@ export interface UseConvexMutationOptions<Mutation extends FunctionReference<'mu
|
|
|
18
19
|
* Pass `{ optimisticUpdate }` to apply temporary local query results while
|
|
19
20
|
* the mutation is in flight (same contract as React `withOptimisticUpdate`).
|
|
20
21
|
*/
|
|
21
|
-
export declare function useConvexMutation<Mutation extends
|
|
22
|
+
export declare function useConvexMutation<Mutation extends ConvexRef<'mutation'>>(mutation: Mutation, options?: UseConvexMutationOptions<Mutation>): {
|
|
22
23
|
mutate: (args?: MaybeRefOrGetter<FunctionArgs<Mutation>>) => Promise<FunctionReturnType<Mutation>>;
|
|
23
24
|
error: import("vue").Ref<Error | null, Error | null>;
|
|
24
25
|
pending: import("vue").ComputedRef<boolean>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FunctionArgs, FunctionReference, FunctionReturnType, PaginationOptions, PaginationResult } from 'convex/server';
|
|
1
|
+
import type { FunctionArgs, FunctionReference, FunctionReference_future, FunctionReturnType, PaginationOptions, PaginationResult } from 'convex/server';
|
|
2
2
|
import { type ComputedRef, type MaybeRefOrGetter, type Ref } from 'vue';
|
|
3
3
|
/**
|
|
4
4
|
* A query usable with {@link useConvexPaginatedQuery}.
|
|
@@ -6,6 +6,8 @@ import { type ComputedRef, type MaybeRefOrGetter, type Ref } from 'vue';
|
|
|
6
6
|
*/
|
|
7
7
|
export type PaginatedQueryReference = FunctionReference<'query', 'public', {
|
|
8
8
|
paginationOpts: PaginationOptions;
|
|
9
|
+
}, PaginationResult<unknown>> | FunctionReference_future<'query', 'public', {
|
|
10
|
+
paginationOpts: PaginationOptions;
|
|
9
11
|
}, PaginationResult<unknown>>;
|
|
10
12
|
export type PaginatedQueryArgs<Query extends PaginatedQueryReference> = Omit<FunctionArgs<Query>, 'paginationOpts'>;
|
|
11
13
|
export type PaginatedQueryItem<Query extends PaginatedQueryReference> = FunctionReturnType<Query>['page'][number];
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { FunctionArgs,
|
|
1
|
+
import type { FunctionArgs, FunctionReturnType } from 'convex/server';
|
|
2
2
|
import { type ComputedRef, type MaybeRefOrGetter } from 'vue';
|
|
3
|
+
import type { ConvexRef } from '../utils/functionReference.js';
|
|
3
4
|
/** One entry in a {@link useConvexQueries} request map. */
|
|
4
|
-
export type ConvexQueryRequestEntry<Query extends
|
|
5
|
+
export type ConvexQueryRequestEntry<Query extends ConvexRef<'query'> = ConvexRef<'query'>> = {
|
|
5
6
|
query: Query;
|
|
6
7
|
args: FunctionArgs<Query>;
|
|
7
8
|
};
|
|
@@ -14,7 +15,7 @@ export type ConvexQueriesResult<Request extends ConvexQueriesRequest> = {
|
|
|
14
15
|
[K in keyof Request]: Request[K] extends {
|
|
15
16
|
query: infer Query;
|
|
16
17
|
args: infer _Args;
|
|
17
|
-
} ? Query extends
|
|
18
|
+
} ? Query extends ConvexRef<'query'> ? FunctionReturnType<Query> | undefined | Error : undefined : undefined;
|
|
18
19
|
};
|
|
19
20
|
/**
|
|
20
21
|
* Subscribe to a dynamic map of Convex queries (React `useQueries` parity).
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { FunctionArgs,
|
|
1
|
+
import type { FunctionArgs, FunctionReturnType } from 'convex/server';
|
|
2
|
+
import type { ConvexRef } from '../utils/functionReference.js';
|
|
2
3
|
import { type ComputedRef, type MaybeRefOrGetter, type Ref } from 'vue';
|
|
3
|
-
export type ConvexQueryArgs<Query extends
|
|
4
|
+
export type ConvexQueryArgs<Query extends ConvexRef<'query'>> = FunctionArgs<Query> | 'skip';
|
|
4
5
|
export interface UseConvexQueryOptions {
|
|
5
6
|
/**
|
|
6
7
|
* Explicit Nuxt payload/cache key.
|
|
@@ -53,4 +54,4 @@ export interface UseConvexQueryReturn<T> {
|
|
|
53
54
|
* a duplicate HTTP request. On the browser, a live `ConvexClient` subscription
|
|
54
55
|
* overlays the payload (`live ?? payload`), matching Next.js `usePreloadedQuery`.
|
|
55
56
|
*/
|
|
56
|
-
export declare function useConvexQuery<Query extends
|
|
57
|
+
export declare function useConvexQuery<Query extends ConvexRef<'query'>>(query: Query, args?: MaybeRefOrGetter<ConvexQueryArgs<Query>>, options?: UseConvexQueryOptions): Promise<UseConvexQueryReturn<FunctionReturnType<Query>>>;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FunctionReturnType } from 'convex/server';
|
|
2
|
+
import type { ConvexRef } from '../utils/functionReference.js';
|
|
2
3
|
/**
|
|
3
4
|
* Subset of `@convex-dev/r2` `clientApi()` exports needed for client uploads.
|
|
4
5
|
* Pass `api.example` (or any module that re-exports these two mutations).
|
|
5
6
|
*/
|
|
6
7
|
export type ConvexR2UploadApi = {
|
|
7
|
-
generateUploadUrl:
|
|
8
|
-
syncMetadata:
|
|
8
|
+
generateUploadUrl: ConvexRef<'mutation'>;
|
|
9
|
+
syncMetadata: ConvexRef<'mutation'>;
|
|
9
10
|
};
|
|
10
11
|
export type ConvexR2UploadProgress = {
|
|
11
12
|
loaded: number;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { FunctionArgs,
|
|
1
|
+
import type { FunctionArgs, FunctionReturnType } from 'convex/server';
|
|
2
2
|
import type { H3Event } from 'h3';
|
|
3
|
+
import type { ConvexRef } from '../utils/functionReference.js';
|
|
3
4
|
export interface ConvexFetchOptions {
|
|
4
5
|
/**
|
|
5
6
|
* Deployment URL. Defaults to `NUXT_PUBLIC_CONVEX_URL` / runtimeConfig.
|
|
@@ -30,12 +31,12 @@ export declare function resolveToken(options: ConvexFetchOptions): string | unde
|
|
|
30
31
|
* })
|
|
31
32
|
* ```
|
|
32
33
|
*/
|
|
33
|
-
export declare function fetchQuery<Query extends
|
|
34
|
+
export declare function fetchQuery<Query extends ConvexRef<'query'>>(query: Query, args?: FunctionArgs<Query>, options?: ConvexFetchOptions): Promise<FunctionReturnType<Query>>;
|
|
34
35
|
/**
|
|
35
36
|
* One-shot mutation via ConvexHttpClient. Use in Nitro routes / server middleware.
|
|
36
37
|
*/
|
|
37
|
-
export declare function fetchMutation<Mutation extends
|
|
38
|
+
export declare function fetchMutation<Mutation extends ConvexRef<'mutation'>>(mutation: Mutation, args?: FunctionArgs<Mutation>, options?: ConvexFetchOptions): Promise<FunctionReturnType<Mutation>>;
|
|
38
39
|
/**
|
|
39
40
|
* One-shot action via ConvexHttpClient. Use in Nitro routes / server middleware.
|
|
40
41
|
*/
|
|
41
|
-
export declare function fetchAction<Action extends
|
|
42
|
+
export declare function fetchAction<Action extends ConvexRef<'action'>>(action: Action, args?: FunctionArgs<Action>, options?: ConvexFetchOptions): Promise<FunctionReturnType<Action>>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { FunctionReference, FunctionReference_future, FunctionType } from 'convex/server';
|
|
2
|
+
/**
|
|
3
|
+
* Function reference accepted by use-convex client APIs.
|
|
4
|
+
*
|
|
5
|
+
* Convex 1.46+ introduced {@link FunctionReference_future} for stricter
|
|
6
|
+
* callback argument checking. Generated `api` refs remain plain
|
|
7
|
+
* {@link FunctionReference}; library surfaces accept either kind so callers
|
|
8
|
+
* can pass both (same contract as Convex React hooks).
|
|
9
|
+
*/
|
|
10
|
+
export type ConvexRef<Type extends FunctionType> = FunctionReference<Type> | FunctionReference_future<Type>;
|
|
File without changes
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ConvexRef } from './functionReference.js';
|
|
2
2
|
/**
|
|
3
3
|
* Stable Nuxt payload / useAsyncData key for a Convex query.
|
|
4
4
|
*
|
|
5
5
|
* `'skip'` means "don't fetch" — it must not change the key, otherwise
|
|
6
6
|
* auth-gated queries lose the SSR payload on the client.
|
|
7
7
|
*/
|
|
8
|
-
export declare function convexQueryKey(query:
|
|
8
|
+
export declare function convexQueryKey(query: ConvexRef<'query'>, args: unknown, explicitKey?: string): string;
|
package/dist/types.d.mts
CHANGED
|
@@ -22,6 +22,8 @@ export { type ConvexQueriesRequest, type ConvexQueriesResult, type ConvexQueryRe
|
|
|
22
22
|
|
|
23
23
|
export { type ConvexFetchOptions } from '../dist/runtime/server/fetch.js'
|
|
24
24
|
|
|
25
|
+
export { type ConvexRef } from '../dist/runtime/utils/functionReference.js'
|
|
26
|
+
|
|
25
27
|
export { type ConvexAuthContext, type ConvexNuxtContext } from '../dist/runtime/utils/context.js'
|
|
26
28
|
|
|
27
29
|
export { type ConnectionState } from '../dist/runtime/composables/useConvexConnectionState.js'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "use-convex",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "First-class Convex integration for Nuxt",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@nuxt/schema": "^4.0.0",
|
|
51
51
|
"@nuxt/test-utils": "^3.23.0",
|
|
52
52
|
"@types/node": "^26.5.0",
|
|
53
|
-
"convex": "^1.
|
|
53
|
+
"convex": "^1.46.0",
|
|
54
54
|
"convex-test": "^0.0.56",
|
|
55
55
|
"happy-dom": "^20.14.0",
|
|
56
56
|
"nitropack": "^2.13.0",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"vue-tsc": "^3.0.0"
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
66
|
-
"convex": "^1.
|
|
66
|
+
"convex": "^1.46.0",
|
|
67
67
|
"nuxt": "^4.0.0",
|
|
68
68
|
"vue": "^3.5.0"
|
|
69
69
|
},
|