better-convex-nuxt 0.1.5
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 +171 -0
- package/dist/module.d.mts +24 -0
- package/dist/module.json +12 -0
- package/dist/module.mjs +148 -0
- package/dist/runtime/components/ConvexAuthLoading.d.vue.ts +13 -0
- package/dist/runtime/components/ConvexAuthLoading.vue +8 -0
- package/dist/runtime/components/ConvexAuthLoading.vue.d.ts +13 -0
- package/dist/runtime/components/ConvexAuthenticated.d.vue.ts +13 -0
- package/dist/runtime/components/ConvexAuthenticated.vue +8 -0
- package/dist/runtime/components/ConvexAuthenticated.vue.d.ts +13 -0
- package/dist/runtime/components/ConvexUnauthenticated.d.vue.ts +13 -0
- package/dist/runtime/components/ConvexUnauthenticated.vue +8 -0
- package/dist/runtime/components/ConvexUnauthenticated.vue.d.ts +13 -0
- package/dist/runtime/composables/index.d.ts +11 -0
- package/dist/runtime/composables/index.js +31 -0
- package/dist/runtime/composables/useAuthClient.d.ts +36 -0
- package/dist/runtime/composables/useAuthClient.js +6 -0
- package/dist/runtime/composables/useConvex.d.ts +28 -0
- package/dist/runtime/composables/useConvex.js +6 -0
- package/dist/runtime/composables/useConvexAction.d.ts +105 -0
- package/dist/runtime/composables/useConvexAction.js +64 -0
- package/dist/runtime/composables/useConvexAuth.d.ts +46 -0
- package/dist/runtime/composables/useConvexAuth.js +34 -0
- package/dist/runtime/composables/useConvexCached.d.ts +32 -0
- package/dist/runtime/composables/useConvexCached.js +7 -0
- package/dist/runtime/composables/useConvexConnectionState.d.ts +85 -0
- package/dist/runtime/composables/useConvexConnectionState.js +77 -0
- package/dist/runtime/composables/useConvexData.d.ts +37 -0
- package/dist/runtime/composables/useConvexData.js +6 -0
- package/dist/runtime/composables/useConvexMutation.d.ts +359 -0
- package/dist/runtime/composables/useConvexMutation.js +111 -0
- package/dist/runtime/composables/useConvexPaginatedQuery.d.ts +389 -0
- package/dist/runtime/composables/useConvexPaginatedQuery.js +670 -0
- package/dist/runtime/composables/useConvexQuery.d.ts +155 -0
- package/dist/runtime/composables/useConvexQuery.js +351 -0
- package/dist/runtime/composables/useLazyConvexQuery.d.ts +26 -0
- package/dist/runtime/composables/useLazyConvexQuery.js +7 -0
- package/dist/runtime/composables/usePermissions.d.ts +105 -0
- package/dist/runtime/composables/usePermissions.js +52 -0
- package/dist/runtime/plugin.client.d.ts +20 -0
- package/dist/runtime/plugin.client.js +113 -0
- package/dist/runtime/plugin.server.d.ts +12 -0
- package/dist/runtime/plugin.server.js +88 -0
- package/dist/runtime/server/api/auth/[...].d.ts +2 -0
- package/dist/runtime/server/api/auth/[...].js +103 -0
- package/dist/runtime/server/tsconfig.json +3 -0
- package/dist/runtime/server/utils/convex.d.ts +80 -0
- package/dist/runtime/server/utils/convex.js +109 -0
- package/dist/runtime/types.d.ts +22 -0
- package/dist/runtime/utils/convex-cache.d.ts +42 -0
- package/dist/runtime/utils/convex-cache.js +50 -0
- package/dist/runtime/utils/query-helpers.d.ts +136 -0
- package/dist/runtime/utils/query-helpers.js +87 -0
- package/dist/types.d.mts +3 -0
- package/package.json +97 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-present Matthias Amon
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# Better Convex Nuxt
|
|
2
|
+
|
|
3
|
+
[![npm version][npm-version-src]][npm-version-href]
|
|
4
|
+
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
|
5
|
+
[![License][license-src]][license-href]
|
|
6
|
+
[![Nuxt][nuxt-src]][nuxt-href]
|
|
7
|
+
|
|
8
|
+
Full-featured [Convex](https://convex.dev) integration for [Nuxt](https://nuxt.com) with SSR, real-time subscriptions, authentication, and permissions.
|
|
9
|
+
|
|
10
|
+
- [Documentation](https://better-convex-nuxt.vercel.app)
|
|
11
|
+
- [Online Playground](https://stackblitz.com/github/lupinum-dev/better-convex-nuxt?file=playground%2Fapp.vue)
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
- **Real-time Queries** - Fetch data with SSR, then upgrade to WebSocket subscriptions
|
|
16
|
+
- **Optimistic Updates** - Instant UI feedback with automatic rollback on failure
|
|
17
|
+
- **Authentication** - Better Auth integration with email/password, OAuth, and magic links
|
|
18
|
+
- **Permissions** - Role-based access control with ownership rules
|
|
19
|
+
- **SSR Support** - Server-side rendering with hydration
|
|
20
|
+
- **Type Safety** - Full TypeScript inference from your Convex schema
|
|
21
|
+
|
|
22
|
+
## Quick Setup
|
|
23
|
+
|
|
24
|
+
Install the module:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npx nuxi module add better-convex-nuxt
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Add your Convex URL to `.env`:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
CONVEX_URL=https://your-project.convex.cloud
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
That's it! Start using Convex in your Nuxt app.
|
|
37
|
+
|
|
38
|
+
## Usage
|
|
39
|
+
|
|
40
|
+
### Queries
|
|
41
|
+
|
|
42
|
+
```vue
|
|
43
|
+
<script setup lang="ts">
|
|
44
|
+
import { api } from '~/convex/_generated/api'
|
|
45
|
+
|
|
46
|
+
// Real-time subscription with SSR support
|
|
47
|
+
const { data: tasks, status } = await useConvexQuery(
|
|
48
|
+
api.tasks.list,
|
|
49
|
+
{ status: 'active' }
|
|
50
|
+
)
|
|
51
|
+
</script>
|
|
52
|
+
|
|
53
|
+
<template>
|
|
54
|
+
<ul v-if="status === 'success'">
|
|
55
|
+
<li v-for="task in tasks" :key="task._id">
|
|
56
|
+
{{ task.text }}
|
|
57
|
+
</li>
|
|
58
|
+
</ul>
|
|
59
|
+
</template>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Mutations
|
|
63
|
+
|
|
64
|
+
```vue
|
|
65
|
+
<script setup lang="ts">
|
|
66
|
+
import { api } from '~/convex/_generated/api'
|
|
67
|
+
|
|
68
|
+
const { mutate, pending } = useConvexMutation(api.tasks.create, {
|
|
69
|
+
optimisticUpdate: (localStore, args) => {
|
|
70
|
+
updateQuery({
|
|
71
|
+
query: api.tasks.list,
|
|
72
|
+
args: {},
|
|
73
|
+
localQueryStore: localStore,
|
|
74
|
+
updater: (current) => current
|
|
75
|
+
? [{ _id: 'temp', text: args.text, completed: false }, ...current]
|
|
76
|
+
: []
|
|
77
|
+
})
|
|
78
|
+
}
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
await mutate({ text: 'Ship my app' })
|
|
82
|
+
</script>
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Authentication
|
|
86
|
+
|
|
87
|
+
```vue
|
|
88
|
+
<script setup lang="ts">
|
|
89
|
+
const { isAuthenticated, user } = useConvexAuth()
|
|
90
|
+
const authClient = useAuthClient()
|
|
91
|
+
|
|
92
|
+
async function handleLogin() {
|
|
93
|
+
await authClient.signIn.social({ provider: 'github' })
|
|
94
|
+
}
|
|
95
|
+
</script>
|
|
96
|
+
|
|
97
|
+
<template>
|
|
98
|
+
<div v-if="isAuthenticated">
|
|
99
|
+
Welcome, {{ user?.name }}!
|
|
100
|
+
</div>
|
|
101
|
+
<button v-else @click="handleLogin">
|
|
102
|
+
Sign in with GitHub
|
|
103
|
+
</button>
|
|
104
|
+
</template>
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Composables
|
|
108
|
+
|
|
109
|
+
| Composable | Description |
|
|
110
|
+
| -------------------------- | ---------------------------------------------------- |
|
|
111
|
+
| `useConvexQuery` | Execute queries with SSR and real-time subscriptions |
|
|
112
|
+
| `useLazyConvexQuery` | Non-blocking queries that load in background |
|
|
113
|
+
| `useConvexMutation` | Execute mutations with optimistic updates |
|
|
114
|
+
| `useConvexAction` | Execute Convex actions |
|
|
115
|
+
| `useConvexPaginatedQuery` | Paginated queries with `loadMore()` |
|
|
116
|
+
| `useConvexAuth` | Authentication state (user, token, isAuthenticated) |
|
|
117
|
+
| `useConvexConnectionState` | WebSocket connection status |
|
|
118
|
+
| `useConvexCached` | Read cached query data |
|
|
119
|
+
| `useConvex` | Access raw ConvexClient instance |
|
|
120
|
+
|
|
121
|
+
## Components
|
|
122
|
+
|
|
123
|
+
| Component | Description |
|
|
124
|
+
| ------------------------- | ------------------------------------------- |
|
|
125
|
+
| `<ConvexAuthenticated>` | Renders content only when authenticated |
|
|
126
|
+
| `<ConvexUnauthenticated>` | Renders content only when not authenticated |
|
|
127
|
+
| `<ConvexAuthLoading>` | Renders content during auth state loading |
|
|
128
|
+
|
|
129
|
+
## Documentation
|
|
130
|
+
|
|
131
|
+
Visit [better-convex-nuxt.vercel.app](https://better-convex-nuxt.vercel.app) for full documentation including:
|
|
132
|
+
|
|
133
|
+
- [Installation & Setup](https://better-convex-nuxt.vercel.app/getting-started/installation)
|
|
134
|
+
- [SSR Patterns](https://better-convex-nuxt.vercel.app/patterns/ssr-patterns)
|
|
135
|
+
- [Optimistic Updates](https://better-convex-nuxt.vercel.app/patterns/optimistic-updates)
|
|
136
|
+
- [Permissions](https://better-convex-nuxt.vercel.app/patterns/permissions)
|
|
137
|
+
- [Server Utilities](https://better-convex-nuxt.vercel.app/server/server-utilities)
|
|
138
|
+
|
|
139
|
+
## Contributing
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
# Install dependencies
|
|
143
|
+
pnpm install
|
|
144
|
+
|
|
145
|
+
# Generate type stubs
|
|
146
|
+
pnpm dev:prepare
|
|
147
|
+
|
|
148
|
+
# Develop with the playground
|
|
149
|
+
pnpm dev
|
|
150
|
+
|
|
151
|
+
# Run tests
|
|
152
|
+
pnpm test
|
|
153
|
+
|
|
154
|
+
# Lint
|
|
155
|
+
pnpm lint
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## License
|
|
159
|
+
|
|
160
|
+
[MIT](./LICENSE)
|
|
161
|
+
|
|
162
|
+
<!-- Badges -->
|
|
163
|
+
|
|
164
|
+
[npm-version-src]: https://img.shields.io/npm/v/better-convex-nuxt/latest.svg?style=flat&colorA=020420&colorB=00DC82
|
|
165
|
+
[npm-version-href]: https://npmjs.com/package/better-convex-nuxt
|
|
166
|
+
[npm-downloads-src]: https://img.shields.io/npm/dm/better-convex-nuxt.svg?style=flat&colorA=020420&colorB=00DC82
|
|
167
|
+
[npm-downloads-href]: https://npm.chart.dev/better-convex-nuxt
|
|
168
|
+
[license-src]: https://img.shields.io/npm/l/better-convex-nuxt.svg?style=flat&colorA=020420&colorB=00DC82
|
|
169
|
+
[license-href]: https://npmjs.com/package/better-convex-nuxt
|
|
170
|
+
[nuxt-src]: https://img.shields.io/badge/Nuxt-020420?logo=nuxt
|
|
171
|
+
[nuxt-href]: https://nuxt.com
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
|
|
3
|
+
interface BetterAuthOptions {
|
|
4
|
+
/** @deprecated Use siteUrl instead */
|
|
5
|
+
url?: string;
|
|
6
|
+
}
|
|
7
|
+
interface ModuleOptions {
|
|
8
|
+
/** Convex deployment URL (WebSocket) - e.g., https://your-app.convex.cloud */
|
|
9
|
+
url?: string;
|
|
10
|
+
/** Convex site URL (HTTP/Auth) - e.g., https://your-app.convex.site. Auto-derived from url if not set. */
|
|
11
|
+
siteUrl?: string;
|
|
12
|
+
/** @deprecated Use siteUrl instead */
|
|
13
|
+
auth?: BetterAuthOptions;
|
|
14
|
+
/**
|
|
15
|
+
* Enable permission composables (createPermissions factory).
|
|
16
|
+
* When true, auto-imports createPermissions for building usePermissions.
|
|
17
|
+
* @default false
|
|
18
|
+
*/
|
|
19
|
+
permissions?: boolean;
|
|
20
|
+
}
|
|
21
|
+
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
22
|
+
|
|
23
|
+
export { _default as default };
|
|
24
|
+
export type { BetterAuthOptions, ModuleOptions };
|
package/dist/module.json
ADDED
package/dist/module.mjs
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { defineNuxtModule, createResolver, addPlugin, addServerHandler, addTemplate, addImports, addServerImports, addComponentsDir } from '@nuxt/kit';
|
|
2
|
+
import { defu } from 'defu';
|
|
3
|
+
|
|
4
|
+
const module$1 = defineNuxtModule({
|
|
5
|
+
meta: {
|
|
6
|
+
name: "better-convex-nuxt",
|
|
7
|
+
configKey: "convex",
|
|
8
|
+
compatibility: {
|
|
9
|
+
nuxt: ">=3.0.0"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
defaults: {
|
|
13
|
+
url: process.env.CONVEX_URL,
|
|
14
|
+
siteUrl: process.env.CONVEX_SITE_URL,
|
|
15
|
+
permissions: false
|
|
16
|
+
},
|
|
17
|
+
setup(options, nuxt) {
|
|
18
|
+
const resolver = createResolver(import.meta.url);
|
|
19
|
+
const derivedSiteUrl = options.siteUrl || options.auth?.url || (options.url?.replace(".convex.cloud", ".convex.site") ?? "");
|
|
20
|
+
const convexConfig = defu(
|
|
21
|
+
nuxt.options.runtimeConfig.public.convex,
|
|
22
|
+
{
|
|
23
|
+
url: options.url || "",
|
|
24
|
+
siteUrl: derivedSiteUrl,
|
|
25
|
+
// Keep auth.url for backwards compatibility
|
|
26
|
+
auth: {
|
|
27
|
+
url: options.auth?.url || derivedSiteUrl
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
nuxt.options.runtimeConfig.public.convex = convexConfig;
|
|
32
|
+
addPlugin({
|
|
33
|
+
src: resolver.resolve("./runtime/plugin.server"),
|
|
34
|
+
mode: "server"
|
|
35
|
+
});
|
|
36
|
+
addPlugin(resolver.resolve("./runtime/plugin.client"));
|
|
37
|
+
addServerHandler({
|
|
38
|
+
route: "/api/auth/**",
|
|
39
|
+
handler: resolver.resolve("./runtime/server/api/auth/[...]")
|
|
40
|
+
});
|
|
41
|
+
addTemplate({
|
|
42
|
+
filename: "types/better-convex-nuxt.d.ts",
|
|
43
|
+
getContents: () => `
|
|
44
|
+
import type { ConvexClient } from 'convex/browser'
|
|
45
|
+
import type { createAuthClient } from 'better-auth/vue'
|
|
46
|
+
|
|
47
|
+
type AuthClient = ReturnType<typeof createAuthClient>
|
|
48
|
+
|
|
49
|
+
declare module '#app' {
|
|
50
|
+
interface NuxtApp {
|
|
51
|
+
$convex: ConvexClient
|
|
52
|
+
$auth?: AuthClient
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
declare module 'vue' {
|
|
57
|
+
interface ComponentCustomProperties {
|
|
58
|
+
$convex: ConvexClient
|
|
59
|
+
$auth?: AuthClient
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export {}
|
|
64
|
+
`
|
|
65
|
+
});
|
|
66
|
+
addImports([
|
|
67
|
+
{ name: "useConvexAuth", from: resolver.resolve("./runtime/composables/useConvexAuth") },
|
|
68
|
+
{ name: "useConvex", from: resolver.resolve("./runtime/composables/useConvex") },
|
|
69
|
+
{
|
|
70
|
+
name: "useConvexMutation",
|
|
71
|
+
from: resolver.resolve("./runtime/composables/useConvexMutation")
|
|
72
|
+
},
|
|
73
|
+
{ name: "useConvexAction", from: resolver.resolve("./runtime/composables/useConvexAction") },
|
|
74
|
+
{ name: "useAuthClient", from: resolver.resolve("./runtime/composables/useAuthClient") },
|
|
75
|
+
{ name: "useConvexQuery", from: resolver.resolve("./runtime/composables/useConvexQuery") },
|
|
76
|
+
{ name: "useConvexCached", from: resolver.resolve("./runtime/composables/useConvexCached") },
|
|
77
|
+
{ name: "useConvexData", from: resolver.resolve("./runtime/composables/useConvexData") },
|
|
78
|
+
{
|
|
79
|
+
name: "useLazyConvexQuery",
|
|
80
|
+
from: resolver.resolve("./runtime/composables/useLazyConvexQuery")
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: "useConvexPaginatedQuery",
|
|
84
|
+
from: resolver.resolve("./runtime/composables/useConvexPaginatedQuery")
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
name: "useConvexConnectionState",
|
|
88
|
+
from: resolver.resolve("./runtime/composables/useConvexConnectionState")
|
|
89
|
+
},
|
|
90
|
+
// Optimistic update helpers for regular queries
|
|
91
|
+
{ name: "updateQuery", from: resolver.resolve("./runtime/composables/useConvexMutation") },
|
|
92
|
+
{ name: "setQueryData", from: resolver.resolve("./runtime/composables/useConvexMutation") },
|
|
93
|
+
{
|
|
94
|
+
name: "updateAllQueries",
|
|
95
|
+
from: resolver.resolve("./runtime/composables/useConvexMutation")
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
name: "deleteFromQuery",
|
|
99
|
+
from: resolver.resolve("./runtime/composables/useConvexMutation")
|
|
100
|
+
},
|
|
101
|
+
// Optimistic update helpers for paginated queries (already available from useConvexPaginatedQuery)
|
|
102
|
+
{
|
|
103
|
+
name: "insertAtTop",
|
|
104
|
+
from: resolver.resolve("./runtime/composables/useConvexPaginatedQuery")
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
name: "insertAtPosition",
|
|
108
|
+
from: resolver.resolve("./runtime/composables/useConvexPaginatedQuery")
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
name: "insertAtBottomIfLoaded",
|
|
112
|
+
from: resolver.resolve("./runtime/composables/useConvexPaginatedQuery")
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
name: "optimisticallyUpdateValueInPaginatedQuery",
|
|
116
|
+
from: resolver.resolve("./runtime/composables/useConvexPaginatedQuery")
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
name: "deleteFromPaginatedQuery",
|
|
120
|
+
from: resolver.resolve("./runtime/composables/useConvexPaginatedQuery")
|
|
121
|
+
}
|
|
122
|
+
]);
|
|
123
|
+
if (options.permissions) {
|
|
124
|
+
addImports([
|
|
125
|
+
{
|
|
126
|
+
name: "createPermissions",
|
|
127
|
+
from: resolver.resolve("./runtime/composables/usePermissions")
|
|
128
|
+
}
|
|
129
|
+
]);
|
|
130
|
+
}
|
|
131
|
+
addServerImports([
|
|
132
|
+
{ name: "fetchQuery", from: resolver.resolve("./runtime/server/utils/convex") },
|
|
133
|
+
{ name: "fetchMutation", from: resolver.resolve("./runtime/server/utils/convex") },
|
|
134
|
+
{ name: "fetchAction", from: resolver.resolve("./runtime/server/utils/convex") }
|
|
135
|
+
]);
|
|
136
|
+
addComponentsDir({
|
|
137
|
+
path: resolver.resolve("./runtime/components"),
|
|
138
|
+
global: true
|
|
139
|
+
});
|
|
140
|
+
nuxt.hook("prepare:types", (opts) => {
|
|
141
|
+
opts.references.push({
|
|
142
|
+
path: resolver.resolve(nuxt.options.buildDir, "types/better-convex-nuxt.d.ts")
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
export { module$1 as default };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare var __VLS_1: {};
|
|
2
|
+
type __VLS_Slots = {} & {
|
|
3
|
+
default?: (props: typeof __VLS_1) => any;
|
|
4
|
+
};
|
|
5
|
+
declare const __VLS_base: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
6
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
7
|
+
declare const _default: typeof __VLS_export;
|
|
8
|
+
export default _default;
|
|
9
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
10
|
+
new (): {
|
|
11
|
+
$slots: S;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare var __VLS_1: {};
|
|
2
|
+
type __VLS_Slots = {} & {
|
|
3
|
+
default?: (props: typeof __VLS_1) => any;
|
|
4
|
+
};
|
|
5
|
+
declare const __VLS_base: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
6
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
7
|
+
declare const _default: typeof __VLS_export;
|
|
8
|
+
export default _default;
|
|
9
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
10
|
+
new (): {
|
|
11
|
+
$slots: S;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare var __VLS_1: {};
|
|
2
|
+
type __VLS_Slots = {} & {
|
|
3
|
+
default?: (props: typeof __VLS_1) => any;
|
|
4
|
+
};
|
|
5
|
+
declare const __VLS_base: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
6
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
7
|
+
declare const _default: typeof __VLS_export;
|
|
8
|
+
export default _default;
|
|
9
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
10
|
+
new (): {
|
|
11
|
+
$slots: S;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare var __VLS_1: {};
|
|
2
|
+
type __VLS_Slots = {} & {
|
|
3
|
+
default?: (props: typeof __VLS_1) => any;
|
|
4
|
+
};
|
|
5
|
+
declare const __VLS_base: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
6
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
7
|
+
declare const _default: typeof __VLS_export;
|
|
8
|
+
export default _default;
|
|
9
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
10
|
+
new (): {
|
|
11
|
+
$slots: S;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare var __VLS_1: {};
|
|
2
|
+
type __VLS_Slots = {} & {
|
|
3
|
+
default?: (props: typeof __VLS_1) => any;
|
|
4
|
+
};
|
|
5
|
+
declare const __VLS_base: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
6
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
7
|
+
declare const _default: typeof __VLS_export;
|
|
8
|
+
export default _default;
|
|
9
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
10
|
+
new (): {
|
|
11
|
+
$slots: S;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare var __VLS_1: {};
|
|
2
|
+
type __VLS_Slots = {} & {
|
|
3
|
+
default?: (props: typeof __VLS_1) => any;
|
|
4
|
+
};
|
|
5
|
+
declare const __VLS_base: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
6
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
7
|
+
declare const _default: typeof __VLS_export;
|
|
8
|
+
export default _default;
|
|
9
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
10
|
+
new (): {
|
|
11
|
+
$slots: S;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { useConvexAuth } from './useConvexAuth.js';
|
|
2
|
+
export { useConvex } from './useConvex.js';
|
|
3
|
+
export { useConvexConnectionState, type ConnectionState, type UseConvexConnectionStateOptions, } from './useConvexConnectionState.js';
|
|
4
|
+
export { useConvexMutation, type MutationStatus, type UseConvexMutationReturn, type UseConvexMutationOptions, updateQuery, setQueryData, updateAllQueries, deleteFromQuery, type UpdateQueryOptions, type SetQueryDataOptions, type UpdateAllQueriesOptions, type DeleteFromQueryOptions, } from './useConvexMutation.js';
|
|
5
|
+
export type { OptimisticLocalStore } from 'convex/browser';
|
|
6
|
+
export { useConvexAction, type ActionStatus, type UseConvexActionReturn, type UseConvexActionOptions, } from './useConvexAction.js';
|
|
7
|
+
export { useAuthClient } from './useAuthClient.js';
|
|
8
|
+
export { useConvexQuery, type QueryStatus, type UseConvexQueryReturn, type UseConvexQueryData, type UseConvexQueryOptions, } from './useConvexQuery.js';
|
|
9
|
+
export { useConvexCached } from './useConvexCached.js';
|
|
10
|
+
export { useConvexPaginatedQuery, type PaginationStatus, type UseConvexPaginatedQueryOptions, type UseConvexPaginatedQueryReturn, type PaginatedQueryReference, type PaginatedQueryArgs, type PaginatedQueryItem, insertAtTop, insertAtPosition, insertAtBottomIfLoaded, optimisticallyUpdateValueInPaginatedQuery, deleteFromPaginatedQuery, type InsertAtTopOptions, type InsertAtPositionOptions, type InsertAtBottomIfLoadedOptions, type UpdateInPaginatedQueryOptions, type DeleteFromPaginatedQueryOptions, } from './useConvexPaginatedQuery.js';
|
|
11
|
+
export { createPermissions, type PermissionContext, type Resource, type CheckPermissionFn, type CreatePermissionsOptions, type UsePermissionsReturn, type UsePermissionGuardOptions, } from './usePermissions.js';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export { useConvexAuth } from "./useConvexAuth.js";
|
|
2
|
+
export { useConvex } from "./useConvex.js";
|
|
3
|
+
export {
|
|
4
|
+
useConvexConnectionState
|
|
5
|
+
} from "./useConvexConnectionState.js";
|
|
6
|
+
export {
|
|
7
|
+
useConvexMutation,
|
|
8
|
+
updateQuery,
|
|
9
|
+
setQueryData,
|
|
10
|
+
updateAllQueries,
|
|
11
|
+
deleteFromQuery
|
|
12
|
+
} from "./useConvexMutation.js";
|
|
13
|
+
export {
|
|
14
|
+
useConvexAction
|
|
15
|
+
} from "./useConvexAction.js";
|
|
16
|
+
export { useAuthClient } from "./useAuthClient.js";
|
|
17
|
+
export {
|
|
18
|
+
useConvexQuery
|
|
19
|
+
} from "./useConvexQuery.js";
|
|
20
|
+
export { useConvexCached } from "./useConvexCached.js";
|
|
21
|
+
export {
|
|
22
|
+
useConvexPaginatedQuery,
|
|
23
|
+
insertAtTop,
|
|
24
|
+
insertAtPosition,
|
|
25
|
+
insertAtBottomIfLoaded,
|
|
26
|
+
optimisticallyUpdateValueInPaginatedQuery,
|
|
27
|
+
deleteFromPaginatedQuery
|
|
28
|
+
} from "./useConvexPaginatedQuery.js";
|
|
29
|
+
export {
|
|
30
|
+
createPermissions
|
|
31
|
+
} from "./usePermissions.js";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { createAuthClient } from 'better-auth/vue';
|
|
2
|
+
type AuthClient = ReturnType<typeof createAuthClient>;
|
|
3
|
+
/**
|
|
4
|
+
* Composable for accessing the Better Auth client instance.
|
|
5
|
+
*
|
|
6
|
+
* Returns the auth client that is:
|
|
7
|
+
* - Configured with the auth server URL
|
|
8
|
+
* - Integrated with Convex for token synchronization
|
|
9
|
+
* - Ready for sign-in, sign-out, and session management
|
|
10
|
+
*
|
|
11
|
+
* SSR-safe: Can be called during component setup. Returns null during SSR,
|
|
12
|
+
* but this is safe because auth operations (sign in, sign out) should only
|
|
13
|
+
* be triggered by user interactions which only happen on the client.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```vue
|
|
17
|
+
* <script setup>
|
|
18
|
+
* // Safe to call at setup time - returns null on SSR, client on browser
|
|
19
|
+
* const authClient = useAuthClient()
|
|
20
|
+
*
|
|
21
|
+
* // Auth operations are event handlers - only run on client
|
|
22
|
+
* async function login(email: string, password: string) {
|
|
23
|
+
* const { data, error } = await authClient!.signIn.email({
|
|
24
|
+
* email,
|
|
25
|
+
* password
|
|
26
|
+
* })
|
|
27
|
+
* }
|
|
28
|
+
*
|
|
29
|
+
* async function logout() {
|
|
30
|
+
* await authClient?.signOut()
|
|
31
|
+
* }
|
|
32
|
+
* </script>
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare function useAuthClient(): AuthClient | null;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ConvexClient } from 'convex/browser';
|
|
2
|
+
/**
|
|
3
|
+
* Composable for accessing the Convex client instance.
|
|
4
|
+
*
|
|
5
|
+
* Returns the singleton ConvexClient that is:
|
|
6
|
+
* - Configured with auth token from SSR
|
|
7
|
+
* - Ready to use for queries, mutations, and actions
|
|
8
|
+
*
|
|
9
|
+
* Note: Returns null during SSR as ConvexClient only works on the client.
|
|
10
|
+
* Use this composable in client-only code or check for null.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```vue
|
|
14
|
+
* <script setup>
|
|
15
|
+
* import { api } from '~/convex/_generated/api'
|
|
16
|
+
*
|
|
17
|
+
* const convex = useConvex()
|
|
18
|
+
*
|
|
19
|
+
* // For client-only usage
|
|
20
|
+
* onMounted(async () => {
|
|
21
|
+
* if (convex) {
|
|
22
|
+
* const result = await convex.query(api.tasks.list)
|
|
23
|
+
* }
|
|
24
|
+
* })
|
|
25
|
+
* </script>
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function useConvex(): ConvexClient | null;
|