nuxt-convex-module 0.0.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/LICENSE +21 -0
- package/README.md +242 -0
- package/dist/chunks/index.mjs +64 -0
- package/dist/devtools-client/200.html +1 -0
- package/dist/devtools-client/404.html +1 -0
- package/dist/devtools-client/_nuxt/B29GGJ5n.js +1 -0
- package/dist/devtools-client/_nuxt/BSDEpQet.js +1 -0
- package/dist/devtools-client/_nuxt/BY23OQOo.js +1 -0
- package/dist/devtools-client/_nuxt/BZYRaL-G.js +1 -0
- package/dist/devtools-client/_nuxt/Byw6FxnC.js +1 -0
- package/dist/devtools-client/_nuxt/CJJ_hcZN.js +1 -0
- package/dist/devtools-client/_nuxt/CS6WMFOx.js +2 -0
- package/dist/devtools-client/_nuxt/CZbAGcNC.js +1 -0
- package/dist/devtools-client/_nuxt/Cr6_aklh.js +2 -0
- package/dist/devtools-client/_nuxt/DNfpyBVU.js +3 -0
- package/dist/devtools-client/_nuxt/DPWXUmcI.js +1 -0
- package/dist/devtools-client/_nuxt/builds/latest.json +1 -0
- package/dist/devtools-client/_nuxt/builds/meta/a7708498-bd09-4de2-b5ab-19b380293c77.json +1 -0
- package/dist/devtools-client/_nuxt/dy_xXcv9.js +1 -0
- package/dist/devtools-client/_nuxt/entry.DbTJhkHT.css +1 -0
- package/dist/devtools-client/_nuxt/error-404.CwGGO2Kz.css +1 -0
- package/dist/devtools-client/_nuxt/error-500.8ZJqCQm8.css +1 -0
- package/dist/devtools-client/_nuxt/ncgEdbEt.js +1 -0
- package/dist/devtools-client/_nuxt/queries.CE_dtt9-.css +1 -0
- package/dist/devtools-client/auth/index.html +1 -0
- package/dist/devtools-client/icon.svg +6 -0
- package/dist/devtools-client/index.html +1 -0
- package/dist/devtools-client/logs/index.html +1 -0
- package/dist/devtools-client/queries/index.html +1 -0
- package/dist/module.d.ts +189 -0
- package/dist/module.js +489 -0
- package/dist/module.json +13 -0
- package/dist/runtime/auth0/vue/index.d.ts +58 -0
- package/dist/runtime/auth0/vue/index.js +33 -0
- package/dist/runtime/better-auth/nuxt/middleware.d.ts +14 -0
- package/dist/runtime/better-auth/nuxt/middleware.js +39 -0
- package/dist/runtime/better-auth/nuxt/proxy.d.ts +6 -0
- package/dist/runtime/better-auth/nuxt/proxy.js +11 -0
- package/dist/runtime/better-auth/nuxt/server.d.ts +106 -0
- package/dist/runtime/better-auth/nuxt/server.js +123 -0
- package/dist/runtime/better-auth/vue/auth-boundary.d.ts +131 -0
- package/dist/runtime/better-auth/vue/auth-boundary.js +78 -0
- package/dist/runtime/better-auth/vue/client.d.ts +358 -0
- package/dist/runtime/better-auth/vue/client.js +5 -0
- package/dist/runtime/better-auth/vue/cross-domain.d.ts +39 -0
- package/dist/runtime/better-auth/vue/cross-domain.js +45 -0
- package/dist/runtime/better-auth/vue/hydration.d.ts +20 -0
- package/dist/runtime/better-auth/vue/hydration.js +52 -0
- package/dist/runtime/better-auth/vue/index.d.ts +12 -0
- package/dist/runtime/better-auth/vue/index.js +6 -0
- package/dist/runtime/better-auth/vue/plugin.client.d.ts +6 -0
- package/dist/runtime/better-auth/vue/plugin.client.js +32 -0
- package/dist/runtime/better-auth/vue/plugin.server.d.ts +24 -0
- package/dist/runtime/better-auth/vue/plugin.server.js +42 -0
- package/dist/runtime/better-auth/vue/use-auth.d.ts +92 -0
- package/dist/runtime/better-auth/vue/use-auth.js +82 -0
- package/dist/runtime/clerk/vue/index.d.ts +81 -0
- package/dist/runtime/clerk/vue/index.js +49 -0
- package/dist/runtime/devtools/bridge.d.ts +12 -0
- package/dist/runtime/devtools/bridge.js +191 -0
- package/dist/runtime/devtools/plugin.client.d.ts +8 -0
- package/dist/runtime/devtools/plugin.client.js +34 -0
- package/dist/runtime/devtools/types.d.ts +78 -0
- package/dist/runtime/devtools/types.js +0 -0
- package/dist/runtime/nuxt/composables/use-async-query.d.ts +144 -0
- package/dist/runtime/nuxt/composables/use-async-query.js +104 -0
- package/dist/runtime/nuxt/config.d.ts +7 -0
- package/dist/runtime/nuxt/config.js +12 -0
- package/dist/runtime/nuxt/index.d.ts +136 -0
- package/dist/runtime/nuxt/index.js +91 -0
- package/dist/runtime/polar/vue/components.d.ts +184 -0
- package/dist/runtime/polar/vue/components.js +115 -0
- package/dist/runtime/vue/auth/helpers.d.ts +67 -0
- package/dist/runtime/vue/auth/helpers.js +50 -0
- package/dist/runtime/vue/auth/index.d.ts +125 -0
- package/dist/runtime/vue/auth/index.js +97 -0
- package/dist/runtime/vue/client.d.ts +305 -0
- package/dist/runtime/vue/client.js +382 -0
- package/dist/runtime/vue/composables/use-action.d.ts +62 -0
- package/dist/runtime/vue/composables/use-action.js +13 -0
- package/dist/runtime/vue/composables/use-connection-state.d.ts +30 -0
- package/dist/runtime/vue/composables/use-connection-state.js +14 -0
- package/dist/runtime/vue/composables/use-mutation.d.ts +76 -0
- package/dist/runtime/vue/composables/use-mutation.js +34 -0
- package/dist/runtime/vue/composables/use-paginated-query.d.ts +132 -0
- package/dist/runtime/vue/composables/use-paginated-query.js +513 -0
- package/dist/runtime/vue/composables/use-queries.d.ts +62 -0
- package/dist/runtime/vue/composables/use-queries.js +37 -0
- package/dist/runtime/vue/composables/use-query.d.ts +87 -0
- package/dist/runtime/vue/composables/use-query.js +53 -0
- package/dist/runtime/vue/composables/use-storage-url.d.ts +46 -0
- package/dist/runtime/vue/composables/use-storage-url.js +9 -0
- package/dist/runtime/vue/composables/use-subscription.d.ts +15 -0
- package/dist/runtime/vue/composables/use-subscription.js +33 -0
- package/dist/runtime/vue/composables/use-upload-queue.d.ts +117 -0
- package/dist/runtime/vue/composables/use-upload-queue.js +115 -0
- package/dist/runtime/vue/composables/use-upload.d.ts +134 -0
- package/dist/runtime/vue/composables/use-upload.js +114 -0
- package/dist/runtime/vue/hydration.d.ts +66 -0
- package/dist/runtime/vue/hydration.js +46 -0
- package/dist/runtime/vue/index.d.ts +94 -0
- package/dist/runtime/vue/index.js +42 -0
- package/dist/runtime/vue/plugin.d.ts +18 -0
- package/dist/runtime/vue/plugin.js +16 -0
- package/dist/runtime/vue/provide.d.ts +39 -0
- package/dist/runtime/vue/provide.js +15 -0
- package/dist/runtime/vue/queries-observer.d.ts +41 -0
- package/dist/runtime/vue/queries-observer.js +126 -0
- package/dist/types.d.ts +3 -0
- package/package.json +233 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { FunctionReference, FunctionReturnType, OptionalRestArgs } from 'convex/server';
|
|
2
|
+
/**
|
|
3
|
+
* An interface to execute a Convex action on the server.
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export interface VueAction<Action extends FunctionReference<'action'>> {
|
|
8
|
+
/**
|
|
9
|
+
* Execute the function on the server, returning a `Promise` of its return value.
|
|
10
|
+
*
|
|
11
|
+
* @param args - Arguments for the function to pass up to the server.
|
|
12
|
+
* @returns The return value of the server-side function call.
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
(...args: OptionalRestArgs<Action>): Promise<FunctionReturnType<Action>>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Construct a new {@link VueAction}.
|
|
19
|
+
*
|
|
20
|
+
* Returns a function that you can call to execute a Convex action. Actions
|
|
21
|
+
* can call third-party APIs and perform side effects. The returned function
|
|
22
|
+
* is stable for the lifetime of the composable (same reference identity).
|
|
23
|
+
*
|
|
24
|
+
* **Error handling:** Actions can fail (e.g., if an external API is down).
|
|
25
|
+
* Always wrap action calls in try/catch or handle the rejected promise.
|
|
26
|
+
*
|
|
27
|
+
* **Note:** In most cases, calling an action directly from a client is an
|
|
28
|
+
* anti-pattern. Prefer having the client call a mutation that captures the
|
|
29
|
+
* user's intent (by writing to the database) and then schedules the action
|
|
30
|
+
* via `ctx.scheduler.runAfter`. This ensures the intent is durably recorded
|
|
31
|
+
* even if the client disconnects.
|
|
32
|
+
*
|
|
33
|
+
* Throws an error if no Convex client has been provided.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```vue
|
|
37
|
+
* <script setup lang="ts">
|
|
38
|
+
* import { useAction } from '#imports'
|
|
39
|
+
* import { api } from '#convex/api'
|
|
40
|
+
*
|
|
41
|
+
* const generate = useAction(api.ai.generateSummary)
|
|
42
|
+
*
|
|
43
|
+
* async function handleClick() {
|
|
44
|
+
* try {
|
|
45
|
+
* const summary = await generate({ text: 'Some long text...' })
|
|
46
|
+
* console.log(summary)
|
|
47
|
+
* } catch (error) {
|
|
48
|
+
* console.error('Action failed:', error)
|
|
49
|
+
* }
|
|
50
|
+
* }
|
|
51
|
+
* </script>
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* @param action - A {@link server.FunctionReference} for the public action
|
|
55
|
+
* to run like `api.dir1.dir2.filename.func`.
|
|
56
|
+
* @returns The {@link VueAction} object with that name.
|
|
57
|
+
*
|
|
58
|
+
* @public
|
|
59
|
+
*/
|
|
60
|
+
export declare function useAction<Action extends FunctionReference<'action'>>(action: Action): VueAction<Action>;
|
|
61
|
+
/** @public */
|
|
62
|
+
export declare const useConvexAction: typeof useAction;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { makeFunctionReference } from "convex/server";
|
|
2
|
+
import { useConvexOrThrow } from "../client.js";
|
|
3
|
+
function createAction(actionReference, client) {
|
|
4
|
+
return function(args) {
|
|
5
|
+
return client.action(actionReference, args);
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export function useAction(action) {
|
|
9
|
+
const convex = useConvexOrThrow("useAction");
|
|
10
|
+
const actionReference = typeof action === "string" ? makeFunctionReference(action) : action;
|
|
11
|
+
return createAction(actionReference, convex);
|
|
12
|
+
}
|
|
13
|
+
export const useConvexAction = useAction;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ConnectionState } from 'convex/browser';
|
|
2
|
+
import type { ShallowRef } from 'vue';
|
|
3
|
+
/**
|
|
4
|
+
* Vue composable to get the current {@link ConnectionState} and subscribe to changes.
|
|
5
|
+
*
|
|
6
|
+
* This composable returns a shallow ref of the current connection state that
|
|
7
|
+
* automatically updates when any part of the connection state changes (e.g.,
|
|
8
|
+
* when going online/offline, when requests start/complete, etc.).
|
|
9
|
+
*
|
|
10
|
+
* The shape of ConnectionState may change in the future which may cause this
|
|
11
|
+
* composable to update more frequently.
|
|
12
|
+
*
|
|
13
|
+
* Throws an error if no Convex client has been provided.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```vue
|
|
17
|
+
* <script setup lang="ts">
|
|
18
|
+
* const conn = useConvexConnectionState()
|
|
19
|
+
* </script>
|
|
20
|
+
*
|
|
21
|
+
* <template>
|
|
22
|
+
* <span v-if="!conn.isWebSocketConnected">Offline</span>
|
|
23
|
+
* </template>
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @returns The current {@link ConnectionState} with the Convex deployment.
|
|
27
|
+
*
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
export declare function useConvexConnectionState(): ShallowRef<ConnectionState>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useConvexOrThrow } from "../client.js";
|
|
2
|
+
import { useSubscription } from "./use-subscription.js";
|
|
3
|
+
export function useConvexConnectionState() {
|
|
4
|
+
const convex = useConvexOrThrow("useConvexConnectionState");
|
|
5
|
+
const getCurrentValue = () => {
|
|
6
|
+
return convex.connectionState();
|
|
7
|
+
};
|
|
8
|
+
const subscribe = (callback) => {
|
|
9
|
+
return convex.subscribeToConnectionState(() => {
|
|
10
|
+
callback();
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
return useSubscription({ getCurrentValue, subscribe });
|
|
14
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { OptimisticUpdate } from 'convex/browser';
|
|
2
|
+
import type { FunctionArgs, FunctionReference, FunctionReturnType, OptionalRestArgs } from 'convex/server';
|
|
3
|
+
import { type ConvexVueClient } from '../client.js';
|
|
4
|
+
/**
|
|
5
|
+
* An interface to execute a Convex mutation function on the server.
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export interface VueMutation<Mutation extends FunctionReference<'mutation'>> {
|
|
10
|
+
/**
|
|
11
|
+
* Execute the mutation on the server, returning a `Promise` of its return value.
|
|
12
|
+
*
|
|
13
|
+
* @param args - Arguments for the mutation to pass up to the server.
|
|
14
|
+
* @returns The return value of the server-side function call.
|
|
15
|
+
*/
|
|
16
|
+
(...args: OptionalRestArgs<Mutation>): Promise<FunctionReturnType<Mutation>>;
|
|
17
|
+
/**
|
|
18
|
+
* Define an optimistic update to apply as part of this mutation.
|
|
19
|
+
*
|
|
20
|
+
* This is a temporary update to the local query results to facilitate a
|
|
21
|
+
* fast, interactive UI. It enables query results to update before a mutation
|
|
22
|
+
* executed on the server.
|
|
23
|
+
*
|
|
24
|
+
* When the mutation is invoked, the optimistic update will be applied.
|
|
25
|
+
*
|
|
26
|
+
* Optimistic updates can also be used to temporarily remove queries from the
|
|
27
|
+
* client and create loading experiences until a mutation completes and the
|
|
28
|
+
* new query results are synced.
|
|
29
|
+
*
|
|
30
|
+
* The update will be automatically rolled back when the mutation is fully
|
|
31
|
+
* completed and queries have been updated.
|
|
32
|
+
*
|
|
33
|
+
* @param optimisticUpdate - The optimistic update to apply.
|
|
34
|
+
* @returns A new `VueMutation` with the update configured.
|
|
35
|
+
*
|
|
36
|
+
* @public
|
|
37
|
+
*/
|
|
38
|
+
withOptimisticUpdate<T extends OptimisticUpdate<FunctionArgs<Mutation>>>(optimisticUpdate: T & (ReturnType<T> extends Promise<any> ? 'Optimistic update handlers must be synchronous' : {})): VueMutation<Mutation>;
|
|
39
|
+
}
|
|
40
|
+
export declare function createMutation(mutationReference: FunctionReference<'mutation'>, client: ConvexVueClient, update?: OptimisticUpdate<any>): VueMutation<any>;
|
|
41
|
+
/**
|
|
42
|
+
* Construct a new {@link VueMutation}.
|
|
43
|
+
*
|
|
44
|
+
* Returns a function that you can call to execute a Convex mutation. The
|
|
45
|
+
* returned function is stable for the lifetime of the composable (same
|
|
46
|
+
* reference identity), so it can be safely passed around and memoized.
|
|
47
|
+
*
|
|
48
|
+
* Mutations can optionally be configured with
|
|
49
|
+
* [optimistic updates](https://docs.convex.dev/client/react/optimistic-updates)
|
|
50
|
+
* for instant UI feedback.
|
|
51
|
+
*
|
|
52
|
+
* Throws an error if no Convex client has been provided.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```vue
|
|
56
|
+
* <script setup lang="ts">
|
|
57
|
+
* import { useMutation } from '#imports'
|
|
58
|
+
* import { api } from '#convex/api'
|
|
59
|
+
*
|
|
60
|
+
* const createTask = useMutation(api.tasks.create)
|
|
61
|
+
*
|
|
62
|
+
* async function handleClick() {
|
|
63
|
+
* await createTask({ text: 'New task' })
|
|
64
|
+
* }
|
|
65
|
+
* </script>
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* @param mutation - A {@link server.FunctionReference} for the public mutation
|
|
69
|
+
* to run like `api.dir1.dir2.filename.func`.
|
|
70
|
+
* @returns The {@link VueMutation} object with that name.
|
|
71
|
+
*
|
|
72
|
+
* @public
|
|
73
|
+
*/
|
|
74
|
+
export declare function useMutation<Mutation extends FunctionReference<'mutation'>>(mutation: Mutation): VueMutation<Mutation>;
|
|
75
|
+
/** @public */
|
|
76
|
+
export declare const useConvexMutation: typeof useMutation;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { getFunctionName, makeFunctionReference } from "convex/server";
|
|
2
|
+
import { useConvexOrThrow } from "../client.js";
|
|
3
|
+
export function createMutation(mutationReference, client, update) {
|
|
4
|
+
function mutation(args) {
|
|
5
|
+
assertNotAccidentalArgument(args);
|
|
6
|
+
return client.mutation(mutationReference, args, {
|
|
7
|
+
optimisticUpdate: update
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
mutation.withOptimisticUpdate = function withOptimisticUpdate(optimisticUpdate) {
|
|
11
|
+
if (update !== void 0) {
|
|
12
|
+
throw new Error(
|
|
13
|
+
`Already specified optimistic update for mutation ${getFunctionName(
|
|
14
|
+
mutationReference
|
|
15
|
+
)}`
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
return createMutation(mutationReference, client, optimisticUpdate);
|
|
19
|
+
};
|
|
20
|
+
return mutation;
|
|
21
|
+
}
|
|
22
|
+
export function useMutation(mutation) {
|
|
23
|
+
const mutationReference = typeof mutation === "string" ? makeFunctionReference(mutation) : mutation;
|
|
24
|
+
const convex = useConvexOrThrow("useMutation");
|
|
25
|
+
return createMutation(mutationReference, convex);
|
|
26
|
+
}
|
|
27
|
+
export const useConvexMutation = useMutation;
|
|
28
|
+
function assertNotAccidentalArgument(value) {
|
|
29
|
+
if (typeof value === "object" && value !== null && "bubbles" in value && "cancelable" in value && "preventDefault" in value) {
|
|
30
|
+
throw new Error(
|
|
31
|
+
`Convex function called with Event object. Did you use a Convex function as an event handler directly? Event handlers like @click receive an event object as their first argument. These Event objects are not valid Convex values. Try wrapping the function like \`const handler = () => myMutation();\` and using \`handler\` in the event handler.`
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import type { OptimisticLocalStore } from 'convex/browser';
|
|
2
|
+
import type { Value } from 'convex/values';
|
|
3
|
+
import { type ComputedRef, type MaybeRefOrGetter } from 'vue';
|
|
4
|
+
import type { PaginatedQueryReference, PaginatedQueryArgs, PaginatedQueryItem, PaginationStatus, UsePaginatedQueryOptions, UsePaginatedQueryObjectReturnType } from 'convex/react';
|
|
5
|
+
export type { PaginatedQueryReference, PaginatedQueryArgs, PaginatedQueryItem, UsePaginatedQueryResult, UsePaginatedQueryOptions, UsePaginatedQueryObjectReturnType, PaginationStatus, } from 'convex/react';
|
|
6
|
+
/**
|
|
7
|
+
* Load data reactively from a paginated query to create a growing list.
|
|
8
|
+
*
|
|
9
|
+
* This can be used to power "infinite scroll" UIs.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```vue
|
|
13
|
+
* <script setup lang="ts">
|
|
14
|
+
* import { usePaginatedQuery } from '#imports'
|
|
15
|
+
* import { api } from '#convex/api'
|
|
16
|
+
*
|
|
17
|
+
* const { results, status, loadMore } = usePaginatedQuery(
|
|
18
|
+
* api.messages.list,
|
|
19
|
+
* { channel: '#general' },
|
|
20
|
+
* { initialNumItems: 5 },
|
|
21
|
+
* )
|
|
22
|
+
* </script>
|
|
23
|
+
*
|
|
24
|
+
* <template>
|
|
25
|
+
* <div v-for="{ _id, body } in results" :key="_id">{{ body }}</div>
|
|
26
|
+
* <button :disabled="status !== 'CanLoadMore'" @click="loadMore(5)">Load More</button>
|
|
27
|
+
* </template>
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @public
|
|
31
|
+
*/
|
|
32
|
+
export declare function usePaginatedQuery<Query extends PaginatedQueryReference>(query: Query, args: MaybeRefOrGetter<PaginatedQueryArgs<Query> | 'skip'>, options: {
|
|
33
|
+
initialNumItems: number;
|
|
34
|
+
}): UsePaginatedQueryReturnType<Query>;
|
|
35
|
+
/** @internal */
|
|
36
|
+
export declare function resetPaginationId(): void;
|
|
37
|
+
/**
|
|
38
|
+
* Return shape of {@link usePaginatedQuery} — the fields of upstream's
|
|
39
|
+
* `UsePaginatedQueryResult` as `ComputedRef`s plus a *stable* `loadMore`
|
|
40
|
+
* function. This is the Vue translation of upstream's per-render plain object:
|
|
41
|
+
* it keeps the documented destructuring idiom reactive,
|
|
42
|
+
* `const { results, status, loadMore } = usePaginatedQuery(...)`.
|
|
43
|
+
*
|
|
44
|
+
* (Upstream's name is kept even though the shape is ref-wrapped — the same
|
|
45
|
+
* treatment as `ConvexAuthState` — so mechanically ported type annotations
|
|
46
|
+
* keep compiling. The plain union stays available as
|
|
47
|
+
* {@link UsePaginatedQueryResult}.)
|
|
48
|
+
*
|
|
49
|
+
* @public
|
|
50
|
+
*/
|
|
51
|
+
export type UsePaginatedQueryReturnType<Query extends PaginatedQueryReference> = {
|
|
52
|
+
results: ComputedRef<PaginatedQueryItem<Query>[]>;
|
|
53
|
+
status: ComputedRef<PaginationStatus>;
|
|
54
|
+
isLoading: ComputedRef<boolean>;
|
|
55
|
+
/**
|
|
56
|
+
* Fetch `numItems` more results. Stable across state changes; only fetches
|
|
57
|
+
* when `status` is `'CanLoadMore'` (matching the documented semantics).
|
|
58
|
+
*/
|
|
59
|
+
loadMore: (numItems: number) => void;
|
|
60
|
+
};
|
|
61
|
+
/** @public */
|
|
62
|
+
export declare const useConvexPaginatedQuery: typeof usePaginatedQuery;
|
|
63
|
+
/**
|
|
64
|
+
* Optimistically update values in a paginated list.
|
|
65
|
+
*
|
|
66
|
+
* @public
|
|
67
|
+
*/
|
|
68
|
+
export declare function optimisticallyUpdateValueInPaginatedQuery<Query extends PaginatedQueryReference>(localStore: OptimisticLocalStore, query: Query, args: PaginatedQueryArgs<Query>, updateValue: (currentValue: PaginatedQueryItem<Query>) => PaginatedQueryItem<Query>): void;
|
|
69
|
+
/**
|
|
70
|
+
* Insert an item at the top of a paginated list, regardless of sort order.
|
|
71
|
+
*
|
|
72
|
+
* Only updates if the first page is already loaded — otherwise the insertion
|
|
73
|
+
* would flash in/out once the real first page arrives.
|
|
74
|
+
*
|
|
75
|
+
* @public
|
|
76
|
+
*/
|
|
77
|
+
export declare function insertAtTop<Query extends PaginatedQueryReference>(options: {
|
|
78
|
+
paginatedQuery: Query;
|
|
79
|
+
argsToMatch?: Partial<PaginatedQueryArgs<Query>>;
|
|
80
|
+
localQueryStore: OptimisticLocalStore;
|
|
81
|
+
item: PaginatedQueryItem<Query>;
|
|
82
|
+
}): void;
|
|
83
|
+
/**
|
|
84
|
+
* Insert an item at the bottom of a paginated list, but only if the final
|
|
85
|
+
* page has loaded (otherwise it would pop out when the server responds).
|
|
86
|
+
*
|
|
87
|
+
* @public
|
|
88
|
+
*/
|
|
89
|
+
export declare function insertAtBottomIfLoaded<Query extends PaginatedQueryReference>(options: {
|
|
90
|
+
paginatedQuery: Query;
|
|
91
|
+
argsToMatch?: Partial<PaginatedQueryArgs<Query>>;
|
|
92
|
+
localQueryStore: OptimisticLocalStore;
|
|
93
|
+
item: PaginatedQueryItem<Query>;
|
|
94
|
+
}): void;
|
|
95
|
+
/**
|
|
96
|
+
* Insert an item at its sorted position across loaded pages of a paginated
|
|
97
|
+
* query, given a sort order and a function deriving the sort key.
|
|
98
|
+
*
|
|
99
|
+
* @public
|
|
100
|
+
*/
|
|
101
|
+
export declare function insertAtPosition<Query extends PaginatedQueryReference>(options: {
|
|
102
|
+
paginatedQuery: Query;
|
|
103
|
+
argsToMatch?: Partial<PaginatedQueryArgs<Query>>;
|
|
104
|
+
sortOrder: 'asc' | 'desc';
|
|
105
|
+
sortKeyFromItem: (item: PaginatedQueryItem<Query>) => Value | Value[];
|
|
106
|
+
localQueryStore: OptimisticLocalStore;
|
|
107
|
+
item: PaginatedQueryItem<Query>;
|
|
108
|
+
}): void;
|
|
109
|
+
/**
|
|
110
|
+
* Experimental paginated query that adds an object-form overload on top of the
|
|
111
|
+
* positional {@link usePaginatedQuery}, mirroring the public name React's
|
|
112
|
+
* Convex integration exposes (`usePaginatedQuery_experimental`).
|
|
113
|
+
*
|
|
114
|
+
* The positional overload behaves exactly like {@link usePaginatedQuery}: it
|
|
115
|
+
* returns the object-of-refs {@link UsePaginatedQueryReturnType} (TitleCase
|
|
116
|
+
* statuses) and throws on error. The object overload returns a `ComputedRef`
|
|
117
|
+
* of the lowercase-status discriminated union
|
|
118
|
+
* {@link UsePaginatedQueryObjectReturnType} — kept whole (not split into refs)
|
|
119
|
+
* so the `status`/`data`/`error` type narrowing survives — and surfaces errors
|
|
120
|
+
* via `status: 'error'` (unless `throwOnError: true`).
|
|
121
|
+
*
|
|
122
|
+
* Note: React backs its experimental hook with the Convex client's native
|
|
123
|
+
* `PaginatedQueryClient`, which the published `convex` package does not export.
|
|
124
|
+
* This port reuses our manual page-management implementation, which produces
|
|
125
|
+
* identical observable results (`results`/`data`, `status`, `loadMore`).
|
|
126
|
+
*
|
|
127
|
+
* @public
|
|
128
|
+
*/
|
|
129
|
+
export declare function usePaginatedQuery_experimental<Query extends PaginatedQueryReference>(query: Query, args: MaybeRefOrGetter<PaginatedQueryArgs<Query> | 'skip'>, options: {
|
|
130
|
+
initialNumItems: number;
|
|
131
|
+
}): UsePaginatedQueryReturnType<Query>;
|
|
132
|
+
export declare function usePaginatedQuery_experimental<Query extends PaginatedQueryReference, ThrowOnError extends boolean = false>(options: MaybeRefOrGetter<UsePaginatedQueryOptions<Query, ThrowOnError>>): ComputedRef<UsePaginatedQueryObjectReturnType<Query, ThrowOnError>>;
|