use-convex 1.1.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/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/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
|
},
|