nuxt-backend 0.1.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 +744 -0
- package/dist/convex/auth.config.d.ts +9 -0
- package/dist/convex/auth.config.d.ts.map +1 -0
- package/dist/convex/auth.config.js +14 -0
- package/dist/convex/auth.config.js.map +1 -0
- package/dist/convex/client/index.d.ts +12784 -0
- package/dist/convex/client/index.d.ts.map +1 -0
- package/dist/convex/client/index.js +230 -0
- package/dist/convex/client/index.js.map +1 -0
- package/dist/convex/component/_generated/api.d.ts +36 -0
- package/dist/convex/component/_generated/api.d.ts.map +1 -0
- package/dist/convex/component/_generated/api.js +31 -0
- package/dist/convex/component/_generated/api.js.map +1 -0
- package/dist/convex/component/_generated/component.d.ts +549 -0
- package/dist/convex/component/_generated/component.d.ts.map +1 -0
- package/dist/convex/component/_generated/component.js +11 -0
- package/dist/convex/component/_generated/component.js.map +1 -0
- package/dist/convex/component/_generated/dataModel.d.ts +46 -0
- package/dist/convex/component/_generated/dataModel.d.ts.map +1 -0
- package/dist/convex/component/_generated/dataModel.js +11 -0
- package/dist/convex/component/_generated/dataModel.js.map +1 -0
- package/dist/convex/component/_generated/server.d.ts +121 -0
- package/dist/convex/component/_generated/server.d.ts.map +1 -0
- package/dist/convex/component/_generated/server.js +78 -0
- package/dist/convex/component/_generated/server.js.map +1 -0
- package/dist/convex/component/adapter.d.ts +3 -0
- package/dist/convex/component/adapter.d.ts.map +1 -0
- package/dist/convex/component/adapter.js +23 -0
- package/dist/convex/component/adapter.js.map +1 -0
- package/dist/convex/component/constants.d.ts +3 -0
- package/dist/convex/component/constants.d.ts.map +1 -0
- package/dist/convex/component/constants.js +3 -0
- package/dist/convex/component/constants.js.map +1 -0
- package/dist/convex/component/convex.config.d.ts +14 -0
- package/dist/convex/component/convex.config.d.ts.map +1 -0
- package/dist/convex/component/convex.config.js +15 -0
- package/dist/convex/component/convex.config.js.map +1 -0
- package/dist/convex/component/schema.d.ts +278 -0
- package/dist/convex/component/schema.d.ts.map +1 -0
- package/dist/convex/component/schema.js +91 -0
- package/dist/convex/component/schema.js.map +1 -0
- package/dist/module.d.ts +47 -0
- package/dist/module.js +275 -0
- package/dist/module.json +9 -0
- package/dist/runtime/nuxt/auth/middleware.d.ts +12 -0
- package/dist/runtime/nuxt/auth/middleware.js +31 -0
- package/dist/runtime/nuxt/auth/proxy.d.ts +6 -0
- package/dist/runtime/nuxt/auth/proxy.js +11 -0
- package/dist/runtime/nuxt/auth/server.d.ts +86 -0
- package/dist/runtime/nuxt/auth/server.js +110 -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 +102 -0
- package/dist/runtime/nuxt/index.js +77 -0
- package/dist/runtime/vue/auth/client.d.ts +14 -0
- package/dist/runtime/vue/auth/client.js +7 -0
- package/dist/runtime/vue/auth/cross-domain.d.ts +8 -0
- package/dist/runtime/vue/auth/cross-domain.js +34 -0
- package/dist/runtime/vue/auth/helpers.d.ts +52 -0
- package/dist/runtime/vue/auth/helpers.js +35 -0
- package/dist/runtime/vue/auth/hydration.d.ts +14 -0
- package/dist/runtime/vue/auth/hydration.js +23 -0
- package/dist/runtime/vue/auth/index.d.ts +79 -0
- package/dist/runtime/vue/auth/index.js +81 -0
- package/dist/runtime/vue/auth/plugin.client.d.ts +6 -0
- package/dist/runtime/vue/auth/plugin.client.js +30 -0
- package/dist/runtime/vue/auth/plugin.server.d.ts +17 -0
- package/dist/runtime/vue/auth/plugin.server.js +29 -0
- package/dist/runtime/vue/auth/use-auth.d.ts +84 -0
- package/dist/runtime/vue/auth/use-auth.js +77 -0
- package/dist/runtime/vue/client.d.ts +245 -0
- package/dist/runtime/vue/client.js +341 -0
- package/dist/runtime/vue/composables/use-action.d.ts +45 -0
- package/dist/runtime/vue/composables/use-action.js +10 -0
- package/dist/runtime/vue/composables/use-connection-state.d.ts +25 -0
- package/dist/runtime/vue/composables/use-connection-state.js +13 -0
- package/dist/runtime/vue/composables/use-mutation.d.ts +60 -0
- package/dist/runtime/vue/composables/use-mutation.js +36 -0
- package/dist/runtime/vue/composables/use-paginated-query.d.ts +101 -0
- package/dist/runtime/vue/composables/use-paginated-query.js +508 -0
- package/dist/runtime/vue/composables/use-queries.d.ts +45 -0
- package/dist/runtime/vue/composables/use-queries.js +32 -0
- package/dist/runtime/vue/composables/use-query.d.ts +82 -0
- package/dist/runtime/vue/composables/use-query.js +63 -0
- package/dist/runtime/vue/composables/use-subscription.d.ts +14 -0
- package/dist/runtime/vue/composables/use-subscription.js +15 -0
- package/dist/runtime/vue/hydration.d.ts +42 -0
- package/dist/runtime/vue/hydration.js +18 -0
- package/dist/runtime/vue/index.d.ts +29 -0
- package/dist/runtime/vue/index.js +38 -0
- package/dist/runtime/vue/queries-observer.d.ts +38 -0
- package/dist/runtime/vue/queries-observer.js +127 -0
- package/dist/types.d.ts +3 -0
- package/package.json +157 -0
- package/src/convex/auth.config.ts +21 -0
- package/src/convex/client/index.ts +329 -0
- package/src/convex/component/_generated/api.ts +52 -0
- package/src/convex/component/_generated/component.ts +1338 -0
- package/src/convex/component/_generated/dataModel.ts +60 -0
- package/src/convex/component/_generated/server.ts +156 -0
- package/src/convex/component/adapter.ts +42 -0
- package/src/convex/component/constants.ts +2 -0
- package/src/convex/component/convex.config.ts +16 -0
- package/src/convex/component/schema.ts +93 -0
- package/src/convex/test.ts +34 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { makeFunctionReference } from "convex/server";
|
|
2
|
+
import { useConvex } from "../client.js";
|
|
3
|
+
export function useAction(action) {
|
|
4
|
+
const actionReference = typeof action === "string" ? makeFunctionReference(action) : action;
|
|
5
|
+
const convex = useConvex();
|
|
6
|
+
return function(...args) {
|
|
7
|
+
return convex.action(actionReference, ...args);
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export const useConvexAction = useAction;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ConnectionState } from 'convex/browser';
|
|
2
|
+
import { type ShallowRef } from 'vue';
|
|
3
|
+
/**
|
|
4
|
+
* Subscribe reactively to the Convex WebSocket connection state.
|
|
5
|
+
*
|
|
6
|
+
* Returns a shallow ref that updates automatically whenever the connection
|
|
7
|
+
* state changes. Useful for displaying online/offline indicators or request
|
|
8
|
+
* spinners.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```vue
|
|
12
|
+
* <script setup lang="ts">
|
|
13
|
+
* const conn = useConvexConnectionState()
|
|
14
|
+
* </script>
|
|
15
|
+
*
|
|
16
|
+
* <template>
|
|
17
|
+
* <span v-if="!conn.isWebSocketConnected">Offline</span>
|
|
18
|
+
* </template>
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @returns A shallow ref containing the current {@link ConnectionState}.
|
|
22
|
+
*
|
|
23
|
+
* @public
|
|
24
|
+
*/
|
|
25
|
+
export declare function useConvexConnectionState(): ShallowRef<ConnectionState>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { shallowRef, watchEffect } from "vue";
|
|
2
|
+
import { useConvex } from "../client.js";
|
|
3
|
+
export function useConvexConnectionState() {
|
|
4
|
+
const convex = useConvex();
|
|
5
|
+
const state = shallowRef(convex.connectionState());
|
|
6
|
+
watchEffect((onCleanup) => {
|
|
7
|
+
const unsubscribe = convex.subscribeToConnectionState((newState) => {
|
|
8
|
+
state.value = newState;
|
|
9
|
+
});
|
|
10
|
+
onCleanup(unsubscribe);
|
|
11
|
+
});
|
|
12
|
+
return state;
|
|
13
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
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
|
+
* A callable object that runs a Convex mutation and optionally applies an
|
|
6
|
+
* optimistic update before the server response arrives.
|
|
7
|
+
*
|
|
8
|
+
* Returned by {@link useMutation} and {@link createMutation}.
|
|
9
|
+
*
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export interface VueMutation<Mutation extends FunctionReference<'mutation'>> {
|
|
13
|
+
/** Execute the mutation, returning a Promise of its return value. */
|
|
14
|
+
(...args: OptionalRestArgs<Mutation>): Promise<FunctionReturnType<Mutation>>;
|
|
15
|
+
/**
|
|
16
|
+
* Define an optimistic update to apply as part of this mutation.
|
|
17
|
+
*
|
|
18
|
+
* @returns A new `VueMutation` with the update configured.
|
|
19
|
+
*/
|
|
20
|
+
withOptimisticUpdate(optimisticUpdate: OptimisticUpdate<FunctionArgs<Mutation>>): VueMutation<Mutation>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Create a mutation function bound to the given client.
|
|
24
|
+
*
|
|
25
|
+
* Low-level alternative to {@link useMutation} for contexts where the
|
|
26
|
+
* Vue composition API (and its `inject`) is unavailable — e.g. unit tests.
|
|
27
|
+
*
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
export declare function createMutation<Mutation extends FunctionReference<'mutation'>>(mutationReference: Mutation, client: ConvexVueClient, update?: OptimisticUpdate<FunctionArgs<Mutation>>): VueMutation<Mutation>;
|
|
31
|
+
/**
|
|
32
|
+
* Construct a new {@link VueMutation}.
|
|
33
|
+
*
|
|
34
|
+
* Returns a function that you can call to execute a Convex mutation.
|
|
35
|
+
* The returned function is stable (same reference) for the lifetime of the composable.
|
|
36
|
+
*
|
|
37
|
+
* Mutations can optionally be configured with optimistic updates.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```vue
|
|
41
|
+
* <script setup lang="ts">
|
|
42
|
+
* import { useMutation } from '#imports'
|
|
43
|
+
* import { api } from '#backend/api'
|
|
44
|
+
*
|
|
45
|
+
* const createTask = useMutation(api.tasks.create)
|
|
46
|
+
*
|
|
47
|
+
* async function handleClick() {
|
|
48
|
+
* await createTask({ text: 'New task' })
|
|
49
|
+
* }
|
|
50
|
+
* </script>
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @param mutation - A FunctionReference for the public mutation to run.
|
|
54
|
+
* @returns The {@link VueMutation} object.
|
|
55
|
+
*
|
|
56
|
+
* @public
|
|
57
|
+
*/
|
|
58
|
+
export declare function useMutation<Mutation extends FunctionReference<'mutation'>>(mutation: Mutation): VueMutation<Mutation>;
|
|
59
|
+
/** @public */
|
|
60
|
+
export declare const useConvexMutation: typeof useMutation;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { getFunctionName, makeFunctionReference } from "convex/server";
|
|
2
|
+
import { useConvex } from "../client.js";
|
|
3
|
+
function isEventLike(value) {
|
|
4
|
+
return typeof value === "object" && value !== null && "bubbles" in value && "cancelable" in value && "target" in value && "preventDefault" in value && typeof value.preventDefault === "function";
|
|
5
|
+
}
|
|
6
|
+
function assertNotAccidentalArgument(value) {
|
|
7
|
+
if (isEventLike(value)) {
|
|
8
|
+
throw new Error(
|
|
9
|
+
"Convex mutation called with Event object. Did you use a Convex mutation as an event handler directly? Event handlers like @click receive a native 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."
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export function createMutation(mutationReference, client, update) {
|
|
14
|
+
function mutation(...args) {
|
|
15
|
+
const mutationArgs = args[0] ?? {};
|
|
16
|
+
assertNotAccidentalArgument(mutationArgs);
|
|
17
|
+
return client.mutation(mutationReference, mutationArgs, {
|
|
18
|
+
optimisticUpdate: update
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
mutation.withOptimisticUpdate = function withOptimisticUpdate(optimisticUpdate) {
|
|
22
|
+
if (update !== void 0) {
|
|
23
|
+
throw new Error(
|
|
24
|
+
`Already specified optimistic update for mutation ${getFunctionName(mutationReference)}`
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
return createMutation(mutationReference, client, optimisticUpdate);
|
|
28
|
+
};
|
|
29
|
+
return mutation;
|
|
30
|
+
}
|
|
31
|
+
export function useMutation(mutation) {
|
|
32
|
+
const mutationReference = typeof mutation === "string" ? makeFunctionReference(mutation) : mutation;
|
|
33
|
+
const convex = useConvex();
|
|
34
|
+
return createMutation(mutationReference, convex);
|
|
35
|
+
}
|
|
36
|
+
export const useConvexMutation = useMutation;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { OptimisticLocalStore } from 'convex/browser';
|
|
2
|
+
import type { Value } from 'convex/values';
|
|
3
|
+
import { type MaybeRefOrGetter, type ShallowRef } from 'vue';
|
|
4
|
+
import type { PaginatedQueryReference, PaginatedQueryArgs, PaginatedQueryItem, UsePaginatedQueryReturnType, UsePaginatedQueryOptions, UsePaginatedQueryObjectReturnType } from 'convex/react';
|
|
5
|
+
export type { PaginatedQueryReference, PaginatedQueryArgs, PaginatedQueryItem, UsePaginatedQueryReturnType, UsePaginatedQueryResult, UsePaginatedQueryOptions, UsePaginatedQueryObjectReturnType, PaginationStatus, } from 'convex/react';
|
|
6
|
+
/** @internal */
|
|
7
|
+
export declare function resetPaginationId(): void;
|
|
8
|
+
/**
|
|
9
|
+
* Load data reactively from a paginated query to create a growing list.
|
|
10
|
+
*
|
|
11
|
+
* This can be used to power "infinite scroll" UIs.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```vue
|
|
15
|
+
* <script setup lang="ts">
|
|
16
|
+
* import { usePaginatedQuery } from '#imports'
|
|
17
|
+
* import { api } from '#backend/api'
|
|
18
|
+
*
|
|
19
|
+
* const { results, status, loadMore, isLoading } = usePaginatedQuery(
|
|
20
|
+
* api.messages.list,
|
|
21
|
+
* { channel: '#general' },
|
|
22
|
+
* { initialNumItems: 5 },
|
|
23
|
+
* )
|
|
24
|
+
* </script>
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
export declare function usePaginatedQuery<Query extends PaginatedQueryReference>(query: Query, args: MaybeRefOrGetter<PaginatedQueryArgs<Query> | 'skip'>, options: {
|
|
30
|
+
initialNumItems: number;
|
|
31
|
+
}): ShallowRef<UsePaginatedQueryReturnType<Query>>;
|
|
32
|
+
/** @public */
|
|
33
|
+
export declare const useConvexPaginatedQuery: typeof usePaginatedQuery;
|
|
34
|
+
/**
|
|
35
|
+
* Experimental paginated query that adds an object-form overload on top of the
|
|
36
|
+
* positional {@link usePaginatedQuery}, mirroring the public name React's
|
|
37
|
+
* Convex integration exposes (`usePaginatedQuery_experimental`).
|
|
38
|
+
*
|
|
39
|
+
* The positional overload behaves exactly like {@link usePaginatedQuery}: it
|
|
40
|
+
* returns the TitleCase {@link UsePaginatedQueryReturnType} and throws on error.
|
|
41
|
+
* The object overload returns the lowercase-status
|
|
42
|
+
* {@link UsePaginatedQueryObjectReturnType} and surfaces errors via
|
|
43
|
+
* `status: 'error'` (unless `throwOnError: true`).
|
|
44
|
+
*
|
|
45
|
+
* Note: React backs its experimental hook with the Convex client's native
|
|
46
|
+
* `PaginatedQueryClient`, which the published `convex` package does not export.
|
|
47
|
+
* This port reuses our manual page-management implementation, which produces
|
|
48
|
+
* identical observable results (`results`/`data`, `status`, `loadMore`).
|
|
49
|
+
*
|
|
50
|
+
* @public
|
|
51
|
+
*/
|
|
52
|
+
export declare function usePaginatedQuery_experimental<Query extends PaginatedQueryReference>(query: Query, args: MaybeRefOrGetter<PaginatedQueryArgs<Query> | 'skip'>, options: {
|
|
53
|
+
initialNumItems: number;
|
|
54
|
+
}): ShallowRef<UsePaginatedQueryReturnType<Query>>;
|
|
55
|
+
export declare function usePaginatedQuery_experimental<Query extends PaginatedQueryReference, ThrowOnError extends boolean = false>(options: MaybeRefOrGetter<UsePaginatedQueryOptions<Query, ThrowOnError>>): ShallowRef<UsePaginatedQueryObjectReturnType<Query, ThrowOnError>>;
|
|
56
|
+
/**
|
|
57
|
+
* Optimistically update values in a paginated list.
|
|
58
|
+
*
|
|
59
|
+
* @public
|
|
60
|
+
*/
|
|
61
|
+
export declare function optimisticallyUpdateValueInPaginatedQuery<Query extends PaginatedQueryReference>(localStore: OptimisticLocalStore, query: Query, args: PaginatedQueryArgs<Query>, updateValue: (currentValue: PaginatedQueryItem<Query>) => PaginatedQueryItem<Query>): void;
|
|
62
|
+
/**
|
|
63
|
+
* Insert an item at the top of a paginated list, regardless of sort order.
|
|
64
|
+
*
|
|
65
|
+
* Only updates if the first page is already loaded — otherwise the insertion
|
|
66
|
+
* would flash in/out once the real first page arrives.
|
|
67
|
+
*
|
|
68
|
+
* @public
|
|
69
|
+
*/
|
|
70
|
+
export declare function insertAtTop<Query extends PaginatedQueryReference>(options: {
|
|
71
|
+
paginatedQuery: Query;
|
|
72
|
+
argsToMatch?: Partial<PaginatedQueryArgs<Query>>;
|
|
73
|
+
localQueryStore: OptimisticLocalStore;
|
|
74
|
+
item: PaginatedQueryItem<Query>;
|
|
75
|
+
}): void;
|
|
76
|
+
/**
|
|
77
|
+
* Insert an item at the bottom of a paginated list, but only if the final
|
|
78
|
+
* page has loaded (otherwise it would pop out when the server responds).
|
|
79
|
+
*
|
|
80
|
+
* @public
|
|
81
|
+
*/
|
|
82
|
+
export declare function insertAtBottomIfLoaded<Query extends PaginatedQueryReference>(options: {
|
|
83
|
+
paginatedQuery: Query;
|
|
84
|
+
argsToMatch?: Partial<PaginatedQueryArgs<Query>>;
|
|
85
|
+
localQueryStore: OptimisticLocalStore;
|
|
86
|
+
item: PaginatedQueryItem<Query>;
|
|
87
|
+
}): void;
|
|
88
|
+
/**
|
|
89
|
+
* Insert an item at its sorted position across loaded pages of a paginated
|
|
90
|
+
* query, given a sort order and a function deriving the sort key.
|
|
91
|
+
*
|
|
92
|
+
* @public
|
|
93
|
+
*/
|
|
94
|
+
export declare function insertAtPosition<Query extends PaginatedQueryReference>(options: {
|
|
95
|
+
paginatedQuery: Query;
|
|
96
|
+
argsToMatch?: Partial<PaginatedQueryArgs<Query>>;
|
|
97
|
+
sortOrder: 'asc' | 'desc';
|
|
98
|
+
sortKeyFromItem: (item: PaginatedQueryItem<Query>) => Value | Value[];
|
|
99
|
+
localQueryStore: OptimisticLocalStore;
|
|
100
|
+
item: PaginatedQueryItem<Query>;
|
|
101
|
+
}): void;
|