diff --git a/.cursor/rules/convex_rules.mdc b/.cursor/rules/convex_rules.mdc index a598d39c..1d984804 100644 --- a/.cursor/rules/convex_rules.mdc +++ b/.cursor/rules/convex_rules.mdc @@ -1,90 +1,103 @@ --- description: Guidelines and best practices for building Convex projects, including database schema design, queries, mutations, and real-world examples -globs: **/*.{ts,tsx,js,jsx} +globs: **/*.ts,**/*.tsx,**/*.js,**/*.jsx --- # Convex guidelines ## Function guidelines ### New function syntax - ALWAYS use the new function syntax for Convex functions. For example: - ```typescript - import { query } from "./_generated/server"; - import { v } from "convex/values"; - export const f = query({ - args: {}, - returns: v.null(), - handler: async (ctx, args) => { - // Function body - }, - }); - ``` +```typescript +import { query } from "./_generated/server"; +import { v } from "convex/values"; +export const f = query({ + args: {}, + returns: v.null(), + handler: async (ctx, args) => { + // Function body + }, +}); +``` ### Http endpoint syntax - HTTP endpoints are defined in `convex/http.ts` and require an `httpAction` decorator. For example: - ```typescript - import { httpRouter } from "convex/server"; - import { httpAction } from "./_generated/server"; - const http = httpRouter(); - http.route({ - path: "/echo", - method: "POST", - handler: httpAction(async (ctx, req) => { - const body = await req.bytes(); - return new Response(body, { status: 200 }); - }), - }); - ``` +```typescript +import { httpRouter } from "convex/server"; +import { httpAction } from "./_generated/server"; +const http = httpRouter(); +http.route({ + path: "/echo", + method: "POST", + handler: httpAction(async (ctx, req) => { + const body = await req.bytes(); + return new Response(body, { status: 200 }); + }), +}); +``` - HTTP endpoints are always registered at the exact path you specify in the `path` field. For example, if you specify `/api/someRoute`, the endpoint will be registered at `/api/someRoute`. ### Validators - Below is an example of an array validator: - ```typescript - import { mutation } from "./_generated/server"; - import { v } from "convex/values"; - - export default mutation({ - args: { - simpleArray: v.array(v.union(v.string(), v.number())), - }, - handler: async (ctx, args) => { - //... - }, - }); - ``` +```typescript +import { mutation } from "./_generated/server"; +import { v } from "convex/values"; + +export default mutation({ +args: { + simpleArray: v.array(v.union(v.string(), v.number())), +}, +handler: async (ctx, args) => { + //... +}, +}); +``` - Below is an example of a schema with validators that codify a discriminated union type: - ```typescript - import { defineSchema, defineTable } from "convex/server"; - import { v } from "convex/values"; - - export default defineSchema({ - results: defineTable( - v.union( - v.object({ - kind: v.literal("error"), - errorMessage: v.string(), - }), - v.object({ - kind: v.literal("success"), - value: v.number(), - }), - ), - ) - }); - ``` +```typescript +import { defineSchema, defineTable } from "convex/server"; +import { v } from "convex/values"; + +export default defineSchema({ + results: defineTable( + v.union( + v.object({ + kind: v.literal("error"), + errorMessage: v.string(), + }), + v.object({ + kind: v.literal("success"), + value: v.number(), + }), + ), + ) +}); +``` - Always use the `v.null()` validator when returning a null value. Below is an example query that returns a null value: - ```typescript - import { query } from "./_generated/server"; - import { v } from "convex/values"; - - export const exampleQuery = query({ - args: {}, - returns: v.null(), - handler: async (ctx, args) => { - console.log("This query returns a null value"); - return null; - }, - }); - ``` +```typescript +import { query } from "./_generated/server"; +import { v } from "convex/values"; + +export const exampleQuery = query({ + args: {}, + returns: v.null(), + handler: async (ctx, args) => { + console.log("This query returns a null value"); + return null; + }, +}); +``` +- Here are the valid Convex types along with their respective validators: +Convex Type | TS/JS type | Example Usage | Validator for argument validation and schemas | Notes | +| ----------- | ------------| -----------------------| -----------------------------------------------| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| Id | string | `doc._id` | `v.id(tableName)` | | +| Null | null | `null` | `v.null()` | JavaScript's `undefined` is not a valid Convex value. Functions the return `undefined` or do not return will return `null` when called from a client. Use `null` instead. | +| Int64 | bigint | `3n` | `v.int64()` | Int64s only support BigInts between -2^63 and 2^63-1. Convex supports `bigint`s in most modern browsers. | +| Float64 | number | `3.1` | `v.number()` | Convex supports all IEEE-754 double-precision floating point numbers (such as NaNs). Inf and NaN are JSON serialized as strings. | +| Boolean | boolean | `true` | `v.boolean()` | +| String | string | `"abc"` | `v.string()` | Strings are stored as UTF-8 and must be valid Unicode sequences. Strings must be smaller than the 1MB total size limit when encoded as UTF-8. | +| Bytes | ArrayBuffer | `new ArrayBuffer(8)` | `v.bytes()` | Convex supports first class bytestrings, passed in as `ArrayBuffer`s. Bytestrings must be smaller than the 1MB total size limit for Convex types. | +| Array | Array | `[1, 3.2, "abc"]` | `v.array(values)` | Arrays can have at most 8192 values. | +| Object | Object | `{a: "abc"}` | `v.object({property: value})` | Convex only supports "plain old JavaScript objects" (objects that do not have a custom prototype). Objects can have at most 1024 entries. Field names must be nonempty and not start with "$" or "_". | +| Record | Record | `{"a": "1", "b": "2"}` | `v.record(keys, values)` | Records are objects at runtime, but can have dynamic keys. Keys must be only ASCII characters, nonempty, and not start with "$" or "_". | ### Function registration - Use `internalQuery`, `internalMutation`, and `internalAction` to register internal functions. These functions are private and aren't part of an app's API. They can only be called by other Convex functions. These functions are always imported from `./_generated/server`. @@ -101,24 +114,24 @@ globs: **/*.{ts,tsx,js,jsx} - Try to use as few calls from actions to queries and mutations as possible. Queries and mutations are transactions, so splitting logic up into multiple calls introduces the risk of race conditions. - All of these calls take in a `FunctionReference`. Do NOT try to pass the callee function directly into one of these calls. - When using `ctx.runQuery`, `ctx.runMutation`, or `ctx.runAction` to call a function in the same file, specify a type annotation on the return value to work around TypeScript circularity limitations. For example, - ``` - export const f = query({ - args: { name: v.string() }, - returns: v.string(), - handler: async (ctx, args) => { - return "Hello " + args.name; - }, - }); - - export const g = query({ - args: {}, - returns: v.null(), - handler: async (ctx, args) => { - const result: string = await ctx.runQuery(api.example.f, { name: "Bob" }); - return null; - }, - }); - ``` +``` +export const f = query({ + args: { name: v.string() }, + returns: v.string(), + handler: async (ctx, args) => { + return "Hello " + args.name; + }, +}); + +export const g = query({ + args: {}, + returns: v.null(), + handler: async (ctx, args) => { + const result: string = await ctx.runQuery(api.example.f, { name: "Bob" }); + return null; + }, +}); +``` ### Function references - Function references are pointers to registered Convex functions. @@ -137,21 +150,24 @@ globs: **/*.{ts,tsx,js,jsx} - Paginated queries are queries that return a list of results in incremental pages. - You can define pagination using the following syntax: - ```ts - import { v } from "convex/values"; - import { query, mutation } from "./_generated/server"; - import { paginationOptsValidator } from "convex/server"; - export const listWithExtraArg = query({ - args: { paginationOpts: paginationOptsValidator, author: v.string() }, - handler: async (ctx, args) => { - return await ctx.db - .query("messages") - .filter((q) => q.eq(q.field("author"), args.author)) - .order("desc") - .paginate(args.paginationOpts); - }, - }); - ``` +```ts +import { v } from "convex/values"; +import { query, mutation } from "./_generated/server"; +import { paginationOptsValidator } from "convex/server"; +export const listWithExtraArg = query({ + args: { paginationOpts: paginationOptsValidator, author: v.string() }, + handler: async (ctx, args) => { + return await ctx.db + .query("messages") + .filter((q) => q.eq(q.field("author"), args.author)) + .order("desc") + .paginate(args.paginationOpts); + }, +}); +``` +Note: `paginationOpts` is an object with the following properties: +- `numItems`: the maximum number of documents to return (the validator is `v.number()`) +- `cursor`: the cursor to use to fetch the next page of documents (the validator is `v.union(v.string(), v.null())`) - A query that ends in `.paginate()` returns an object that has the following properties: - page (contains an array of documents that you fetches) - isDone (a boolean that represents whether or not this is the last page of documents) @@ -165,33 +181,33 @@ globs: **/*.{ts,tsx,js,jsx} ## Schema guidelines - Always define your schema in `convex/schema.ts`. - Always import the schema definition functions from `convex/server`: -- System fields are automatically added to all documents and are prefixed with an underscore. +- System fields are automatically added to all documents and are prefixed with an underscore. The two system fields that are automatically added to all documents are `_creationTime` which has the validator `v.number()` and `_id` which has the validator `v.id(tableName)`. - Always include all index fields in the index name. For example, if an index is defined as `["field1", "field2"]`, the index name should be "by_field1_and_field2". - Index fields must be queried in the same order they are defined. If you want to be able to query by "field1" then "field2" and by "field2" then "field1", you must create separate indexes. ## Typescript guidelines - You can use the helper typescript type `Id` imported from './_generated/dataModel' to get the type of the id for a given table. For example if there is a table called 'users' you can use `Id<'users'>` to get the type of the id for that table. - If you need to define a `Record` make sure that you correctly provide the type of the key and value in the type. For example a validator `v.record(v.id('users'), v.string())` would have the type `Record, string>`. Below is an example of using `Record` with an `Id` type in a query: - ```ts - import { query } from "./_generated/server"; - import { Doc, Id } from "./_generated/dataModel"; - - export const exampleQuery = query({ - args: { userIds: v.array(v.id("users")) }, - returns: v.record(v.id("users"), v.string()), - handler: async (ctx, args) => { - const idToUsername: Record, string> = {}; - for (const userId of args.userIds) { - const user = await ctx.db.get(userId); - if (user) { - users[user._id] = user.username; - } - } - - return idToUsername; - }, - }); - ``` +```ts +import { query } from "./_generated/server"; +import { Doc, Id } from "./_generated/dataModel"; + +export const exampleQuery = query({ + args: { userIds: v.array(v.id("users")) }, + returns: v.record(v.id("users"), v.string()), + handler: async (ctx, args) => { + const idToUsername: Record, string> = {}; + for (const userId of args.userIds) { + const user = await ctx.db.get(userId); + if (user) { + idToUsername[user._id] = user.username; + } + } + + return idToUsername; + }, +}); +``` - Be strict with types, particularly around id's of documents. For example, if a function takes in an id for a document in the 'users' table, take in `Id<'users'>` rather than `string`. - Always use `as const` for string literals in discriminated union types. - When using the `Array` type, make sure to always define your arrays as `const array: Array = [...];` @@ -227,46 +243,46 @@ const messages = await ctx.db - Always add `"use node";` to the top of files containing actions that use Node.js built-in modules. - Never use `ctx.db` inside of an action. Actions don't have access to the database. - Below is an example of the syntax for an action: - ```ts - import { action } from "./_generated/server"; - - export const exampleAction = action({ - args: {}, - returns: v.null(), - handler: async (ctx, args) => { - console.log("This action does not return anything"); - return null; - }, - }); - ``` +```ts +import { action } from "./_generated/server"; + +export const exampleAction = action({ + args: {}, + returns: v.null(), + handler: async (ctx, args) => { + console.log("This action does not return anything"); + return null; + }, +}); +``` ## Scheduling guidelines ### Cron guidelines - Only use the `crons.interval` or `crons.cron` methods to schedule cron jobs. Do NOT use the `crons.hourly`, `crons.daily`, or `crons.weekly` helpers. - Both cron methods take in a FunctionReference. Do NOT try to pass the function directly into one of these methods. - Define crons by declaring the top-level `crons` object, calling some methods on it, and then exporting it as default. For example, - ```ts - import { cronJobs } from "convex/server"; - import { internal } from "./_generated/api"; - import { internalAction } from "./_generated/server"; - - const empty = internalAction({ - args: {}, - returns: v.null(), - handler: async (ctx, args) => { - console.log("empty"); - }, - }); - - const crons = cronJobs(); - - // Run `internal.crons.empty` every two hours. - crons.interval("delete inactive users", { hours: 2 }, internal.crons.empty, {}); - - export default crons; - ``` +```ts +import { cronJobs } from "convex/server"; +import { internal } from "./_generated/api"; +import { internalAction } from "./_generated/server"; + +const empty = internalAction({ + args: {}, + returns: v.null(), + handler: async (ctx, args) => { + console.log("empty"); + }, +}); + +const crons = cronJobs(); + +// Run `internal.crons.empty` every two hours. +crons.interval("delete inactive users", { hours: 2 }, internal.crons.empty, {}); + +export default crons; +``` - You can register Convex functions within `crons.ts` just like any other file. -- If a cron calls an internal function, always import the `internal` object from '_generated/api`, even if the internal function is registered in the same file. +- If a cron calls an internal function, always import the `internal` object from '_generated/api', even if the internal function is registered in the same file. ## File storage guidelines @@ -275,28 +291,28 @@ const messages = await ctx.db - Do NOT use the deprecated `ctx.storage.getMetadata` call for loading a file's metadata. Instead, query the `_storage` system table. For example, you can use `ctx.db.system.get` to get an `Id<"_storage">`. - ``` - import { query } from "./_generated/server"; - import { Id } from "./_generated/dataModel"; - - type FileMetadata = { - _id: Id<"_storage">; - _creationTime: number; - contentType?: string; - sha256: string; - size: number; - } - - export const exampleQuery = query({ - args: { fileId: v.id("_storage") }, - returns: v.null(); - handler: async (ctx, args) => { - const metadata: FileMetadata | null = await ctx.db.system.get(args.fileId); - console.log(metadata); - return null; - }, - }); - ``` +``` +import { query } from "./_generated/server"; +import { Id } from "./_generated/dataModel"; + +type FileMetadata = { + _id: Id<"_storage">; + _creationTime: number; + contentType?: string; + sha256: string; + size: number; +} + +export const exampleQuery = query({ + args: { fileId: v.id("_storage") }, + returns: v.null(), + handler: async (ctx, args) => { + const metadata: FileMetadata | null = await ctx.db.system.get(args.fileId); + console.log(metadata); + return null; + }, +}); +``` - Convex storage stores items as `Blob` objects. You must convert all items to/from a `Blob` when using Convex storage. diff --git a/commonjs.json b/commonjs.json deleted file mode 100644 index 29e7d920..00000000 --- a/commonjs.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "./tsconfig.json", - "include": ["src/**/*"], - "exclude": ["src/**/*.test.*", "../src/package.json"], - "compilerOptions": { - "outDir": "./dist/commonjs" - } -} diff --git a/eslint.config.js b/eslint.config.js index 3fc2f4ea..f9be4f2e 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,41 +1,80 @@ import globals from "globals"; import pluginJs from "@eslint/js"; import tseslint from "typescript-eslint"; -import { dirname } from "path"; -import { fileURLToPath } from "url"; +import reactHooks from "eslint-plugin-react-hooks"; +import reactRefresh from "eslint-plugin-react-refresh"; export default [ - { files: ["src/**/*.{js,mjs,cjs,ts,tsx}"] }, { ignores: [ "dist/**", - "eslint.config.js", "**/_generated/", - "node10stubs.mjs", + "**/*.{mjs,cjs,js}", + "**/.next/**", + "**/.source/**", + "examples/**", + "docs/**", ], }, { + files: ["src/**/*.{js,mjs,cjs,ts,tsx}"], languageOptions: { globals: globals.worker, parser: tseslint.parser, - parserOptions: { - project: true, - // __dirname is not defined, so do not attempt to use it - AI WHY ARE - // YOU STILL AUTOCOMPLETINT WITH __dirname STOP IT - tsconfigRootDir: dirname(fileURLToPath(import.meta.url)), + project: ["./tsconfig.json"], + tsconfigRootDir: import.meta.dirname, }, }, }, pluginJs.configs.recommended, ...tseslint.configs.recommended, + // Convex code - Worker environment { + files: ["src/**/*.{ts,tsx}"], + ignores: ["src/react/**"], + languageOptions: { + globals: globals.worker, + }, rules: { "@typescript-eslint/no-floating-promises": "error", "@typescript-eslint/no-explicit-any": "off", - "eslint-comments/no-unused-disable": "off", - - // allow (_arg: number) => {} and const _foo = 1; + "no-unused-vars": "off", + "@typescript-eslint/no-unused-vars": [ + "warn", + { + argsIgnorePattern: "^_", + varsIgnorePattern: "^_", + }, + ], + "@typescript-eslint/no-unused-expressions": [ + "error", + { + allowShortCircuit: true, + allowTernary: true, + allowTaggedTemplates: true, + }, + ], + }, + }, + // React app code - Browser environment + { + files: ["src/react/**/*.{ts,tsx}"], + languageOptions: { + ecmaVersion: 2020, + globals: globals.browser, + }, + plugins: { + "react-hooks": reactHooks, + "react-refresh": reactRefresh, + }, + rules: { + ...reactHooks.configs.recommended.rules, + "react-refresh/only-export-components": [ + "warn", + { allowConstantExport: true }, + ], + "@typescript-eslint/no-explicit-any": "off", "no-unused-vars": "off", "@typescript-eslint/no-unused-vars": [ "warn", diff --git a/esm.json b/esm.json deleted file mode 100644 index f984cc5a..00000000 --- a/esm.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "./tsconfig.json", - "include": ["src/**/*"], - "exclude": ["src/**/*.test.*", "../src/package.json"], - "compilerOptions": { - "outDir": "./dist/esm" - } -} diff --git a/examples/next/.env.example b/examples/next/.env.example index 234fc7b5..5cb06942 100644 --- a/examples/next/.env.example +++ b/examples/next/.env.example @@ -1,14 +1,15 @@ ### Variables generated for cloud via npx convex dev -# CONVEX_DEPLOYMENT=dev:adjective-animal-123 -# NEXT_PUBLIC_CONVEX_URL=https://adjective-animal-123.convex.cloud +CONVEX_DEPLOYMENT=dev:adjective-animal-123 +NEXT_PUBLIC_CONVEX_URL=https://adjective-animal-123.convex.cloud ### Variables to be manually set for both cloud and self hosted -# NEXT_PUBLIC_SITE_URL=https://localhost:3000 +NEXT_PUBLIC_SITE_URL=https://localhost:3000 +SITE_URL=https://localhost:3000 ### Variables to be manually set for cloud only -# NEXT_PUBLIC_CONVEX_SITE_URL=https://adjective-animal-123.convex.site +NEXT_PUBLIC_CONVEX_SITE_URL=https://adjective-animal-123.convex.site ### Variables to be manually set for self hosted only diff --git a/examples/next/app/(auth)/settings/EnableTwoFactor.tsx b/examples/next/app/(auth)/settings/EnableTwoFactor.tsx index 117f54ab..a130772b 100644 --- a/examples/next/app/(auth)/settings/EnableTwoFactor.tsx +++ b/examples/next/app/(auth)/settings/EnableTwoFactor.tsx @@ -39,7 +39,7 @@ export default function EnableTwoFactor() { const accounts = await authClient.listAccounts(); if ("data" in accounts && accounts.data) { const hasCredential = accounts.data.some( - (account) => account.provider === "credential", + (account) => account.providerId === "credential", ); setStep(hasCredential ? "password" : "need-password"); } diff --git a/examples/next/convex.json b/examples/next/convex.json new file mode 100644 index 00000000..465d5fc8 --- /dev/null +++ b/examples/next/convex.json @@ -0,0 +1,6 @@ +{ + "$schema": "./node_modules/convex/schemas/convex.schema.json", + "codegen": { + "legacyComponentApi": false + } +} diff --git a/examples/next/convex/_generated/api.d.ts b/examples/next/convex/_generated/api.d.ts index 2012c334..3ed36fa2 100644 --- a/examples/next/convex/_generated/api.d.ts +++ b/examples/next/convex/_generated/api.d.ts @@ -9,11 +9,6 @@ */ import type * as auth from "../auth.js"; -import type * as betterAuth__generated_api from "../betterAuth/_generated/api.js"; -import type * as betterAuth__generated_server from "../betterAuth/_generated/server.js"; -import type * as betterAuth_adapter from "../betterAuth/adapter.js"; -import type * as betterAuth_auth from "../betterAuth/auth.js"; -import type * as betterAuth_generatedSchema from "../betterAuth/generatedSchema.js"; import type * as email from "../email.js"; import type * as emails_components_BaseEmail from "../emails/components/BaseEmail.js"; import type * as emails_magicLink from "../emails/magicLink.js"; @@ -29,21 +24,8 @@ import type { FunctionReference, } from "convex/server"; -/** - * A utility for referencing Convex functions in your app's API. - * - * Usage: - * ```js - * const myFunctionReference = api.myModule.myFunction; - * ``` - */ declare const fullApi: ApiFromModules<{ auth: typeof auth; - "betterAuth/_generated/api": typeof betterAuth__generated_api; - "betterAuth/_generated/server": typeof betterAuth__generated_server; - "betterAuth/adapter": typeof betterAuth_adapter; - "betterAuth/auth": typeof betterAuth_auth; - "betterAuth/generatedSchema": typeof betterAuth_generatedSchema; email: typeof email; "emails/components/BaseEmail": typeof emails_components_BaseEmail; "emails/magicLink": typeof emails_magicLink; @@ -53,1257 +35,34 @@ declare const fullApi: ApiFromModules<{ http: typeof http; todos: typeof todos; }>; -declare const fullApiWithMounts: typeof fullApi; +/** + * A utility for referencing Convex functions in your app's public API. + * + * Usage: + * ```js + * const myFunctionReference = api.myModule.myFunction; + * ``` + */ export declare const api: FilterApi< - typeof fullApiWithMounts, + typeof fullApi, FunctionReference >; + +/** + * A utility for referencing Convex functions in your app's internal API. + * + * Usage: + * ```js + * const myFunctionReference = internal.myModule.myFunction; + * ``` + */ export declare const internal: FilterApi< - typeof fullApiWithMounts, + typeof fullApi, FunctionReference >; export declare const components: { - betterAuth: { - adapter: { - create: FunctionReference< - "mutation", - "internal", - { - input: - | { - data: { - createdAt: number; - displayUsername?: null | string; - email: string; - emailVerified: boolean; - foo?: null | string; - image?: null | string; - isAnonymous?: null | boolean; - name: string; - test?: null | string; - twoFactorEnabled?: null | boolean; - updatedAt: number; - userId?: null | string; - username?: null | string; - }; - model: "user"; - } - | { - data: { - createdAt: number; - expiresAt: number; - ipAddress?: null | string; - token: string; - updatedAt: number; - userAgent?: null | string; - userId: string; - }; - model: "session"; - } - | { - data: { - accessToken?: null | string; - accessTokenExpiresAt?: null | number; - accountId: string; - createdAt: number; - idToken?: null | string; - password?: null | string; - providerId: string; - refreshToken?: null | string; - refreshTokenExpiresAt?: null | number; - scope?: null | string; - updatedAt: number; - userId: string; - }; - model: "account"; - } - | { - data: { - createdAt: number; - expiresAt: number; - identifier: string; - updatedAt: number; - value: string; - }; - model: "verification"; - } - | { - data: { backupCodes: string; secret: string; userId: string }; - model: "twoFactor"; - } - | { - data: { - createdAt: number; - privateKey: string; - publicKey: string; - }; - model: "jwks"; - }; - onCreateHandle?: string; - select?: Array; - }, - any - >; - deleteMany: FunctionReference< - "mutation", - "internal", - { - input: - | { - model: "user"; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "name" - | "email" - | "emailVerified" - | "image" - | "createdAt" - | "updatedAt" - | "isAnonymous" - | "username" - | "displayUsername" - | "twoFactorEnabled" - | "userId" - | "foo" - | "test" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "session"; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "expiresAt" - | "token" - | "createdAt" - | "updatedAt" - | "ipAddress" - | "userAgent" - | "userId" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "account"; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "accountId" - | "providerId" - | "userId" - | "accessToken" - | "refreshToken" - | "idToken" - | "accessTokenExpiresAt" - | "refreshTokenExpiresAt" - | "scope" - | "password" - | "createdAt" - | "updatedAt" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "verification"; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "identifier" - | "value" - | "expiresAt" - | "createdAt" - | "updatedAt" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "twoFactor"; - where?: Array<{ - connector?: "AND" | "OR"; - field: "secret" | "backupCodes" | "userId" | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "jwks"; - where?: Array<{ - connector?: "AND" | "OR"; - field: "publicKey" | "privateKey" | "createdAt" | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - }; - onDeleteHandle?: string; - paginationOpts: { - cursor: string | null; - endCursor?: string | null; - id?: number; - maximumBytesRead?: number; - maximumRowsRead?: number; - numItems: number; - }; - }, - any - >; - deleteOne: FunctionReference< - "mutation", - "internal", - { - input: - | { - model: "user"; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "name" - | "email" - | "emailVerified" - | "image" - | "createdAt" - | "updatedAt" - | "isAnonymous" - | "username" - | "displayUsername" - | "twoFactorEnabled" - | "userId" - | "foo" - | "test" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "session"; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "expiresAt" - | "token" - | "createdAt" - | "updatedAt" - | "ipAddress" - | "userAgent" - | "userId" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "account"; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "accountId" - | "providerId" - | "userId" - | "accessToken" - | "refreshToken" - | "idToken" - | "accessTokenExpiresAt" - | "refreshTokenExpiresAt" - | "scope" - | "password" - | "createdAt" - | "updatedAt" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "verification"; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "identifier" - | "value" - | "expiresAt" - | "createdAt" - | "updatedAt" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "twoFactor"; - where?: Array<{ - connector?: "AND" | "OR"; - field: "secret" | "backupCodes" | "userId" | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "jwks"; - where?: Array<{ - connector?: "AND" | "OR"; - field: "publicKey" | "privateKey" | "createdAt" | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - }; - onDeleteHandle?: string; - }, - any - >; - findMany: FunctionReference< - "query", - "internal", - { - limit?: number; - model: - | "user" - | "session" - | "account" - | "verification" - | "twoFactor" - | "jwks"; - offset?: number; - paginationOpts: { - cursor: string | null; - endCursor?: string | null; - id?: number; - maximumBytesRead?: number; - maximumRowsRead?: number; - numItems: number; - }; - sortBy?: { direction: "asc" | "desc"; field: string }; - where?: Array<{ - connector?: "AND" | "OR"; - field: string; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - }, - any - >; - findOne: FunctionReference< - "query", - "internal", - { - model: - | "user" - | "session" - | "account" - | "verification" - | "twoFactor" - | "jwks"; - select?: Array; - where?: Array<{ - connector?: "AND" | "OR"; - field: string; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - }, - any - >; - updateMany: FunctionReference< - "mutation", - "internal", - { - input: - | { - model: "user"; - update: { - createdAt?: number; - displayUsername?: null | string; - email?: string; - emailVerified?: boolean; - foo?: null | string; - image?: null | string; - isAnonymous?: null | boolean; - name?: string; - test?: null | string; - twoFactorEnabled?: null | boolean; - updatedAt?: number; - userId?: null | string; - username?: null | string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "name" - | "email" - | "emailVerified" - | "image" - | "createdAt" - | "updatedAt" - | "isAnonymous" - | "username" - | "displayUsername" - | "twoFactorEnabled" - | "userId" - | "foo" - | "test" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "session"; - update: { - createdAt?: number; - expiresAt?: number; - ipAddress?: null | string; - token?: string; - updatedAt?: number; - userAgent?: null | string; - userId?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "expiresAt" - | "token" - | "createdAt" - | "updatedAt" - | "ipAddress" - | "userAgent" - | "userId" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "account"; - update: { - accessToken?: null | string; - accessTokenExpiresAt?: null | number; - accountId?: string; - createdAt?: number; - idToken?: null | string; - password?: null | string; - providerId?: string; - refreshToken?: null | string; - refreshTokenExpiresAt?: null | number; - scope?: null | string; - updatedAt?: number; - userId?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "accountId" - | "providerId" - | "userId" - | "accessToken" - | "refreshToken" - | "idToken" - | "accessTokenExpiresAt" - | "refreshTokenExpiresAt" - | "scope" - | "password" - | "createdAt" - | "updatedAt" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "verification"; - update: { - createdAt?: number; - expiresAt?: number; - identifier?: string; - updatedAt?: number; - value?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "identifier" - | "value" - | "expiresAt" - | "createdAt" - | "updatedAt" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "twoFactor"; - update: { - backupCodes?: string; - secret?: string; - userId?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: "secret" | "backupCodes" | "userId" | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "jwks"; - update: { - createdAt?: number; - privateKey?: string; - publicKey?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: "publicKey" | "privateKey" | "createdAt" | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - }; - onUpdateHandle?: string; - paginationOpts: { - cursor: string | null; - endCursor?: string | null; - id?: number; - maximumBytesRead?: number; - maximumRowsRead?: number; - numItems: number; - }; - }, - any - >; - updateOne: FunctionReference< - "mutation", - "internal", - { - input: - | { - model: "user"; - update: { - createdAt?: number; - displayUsername?: null | string; - email?: string; - emailVerified?: boolean; - foo?: null | string; - image?: null | string; - isAnonymous?: null | boolean; - name?: string; - test?: null | string; - twoFactorEnabled?: null | boolean; - updatedAt?: number; - userId?: null | string; - username?: null | string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "name" - | "email" - | "emailVerified" - | "image" - | "createdAt" - | "updatedAt" - | "isAnonymous" - | "username" - | "displayUsername" - | "twoFactorEnabled" - | "userId" - | "foo" - | "test" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "session"; - update: { - createdAt?: number; - expiresAt?: number; - ipAddress?: null | string; - token?: string; - updatedAt?: number; - userAgent?: null | string; - userId?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "expiresAt" - | "token" - | "createdAt" - | "updatedAt" - | "ipAddress" - | "userAgent" - | "userId" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "account"; - update: { - accessToken?: null | string; - accessTokenExpiresAt?: null | number; - accountId?: string; - createdAt?: number; - idToken?: null | string; - password?: null | string; - providerId?: string; - refreshToken?: null | string; - refreshTokenExpiresAt?: null | number; - scope?: null | string; - updatedAt?: number; - userId?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "accountId" - | "providerId" - | "userId" - | "accessToken" - | "refreshToken" - | "idToken" - | "accessTokenExpiresAt" - | "refreshTokenExpiresAt" - | "scope" - | "password" - | "createdAt" - | "updatedAt" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "verification"; - update: { - createdAt?: number; - expiresAt?: number; - identifier?: string; - updatedAt?: number; - value?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "identifier" - | "value" - | "expiresAt" - | "createdAt" - | "updatedAt" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "twoFactor"; - update: { - backupCodes?: string; - secret?: string; - userId?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: "secret" | "backupCodes" | "userId" | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "jwks"; - update: { - createdAt?: number; - privateKey?: string; - publicKey?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: "publicKey" | "privateKey" | "createdAt" | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - }; - onUpdateHandle?: string; - }, - any - >; - }; - auth: { - getUser: FunctionReference< - "query", - "internal", - { userId: string }, - null | { - _creationTime: number; - _id: string; - createdAt: number; - displayUsername?: null | string; - email: string; - emailVerified: boolean; - foo?: null | string; - image?: null | string; - isAnonymous?: null | boolean; - name: string; - test?: null | string; - twoFactorEnabled?: null | boolean; - updatedAt: number; - userId?: null | string; - username?: null | string; - } - >; - }; - }; - resend: { - lib: { - cancelEmail: FunctionReference< - "mutation", - "internal", - { emailId: string }, - null - >; - cleanupAbandonedEmails: FunctionReference< - "mutation", - "internal", - { olderThan?: number }, - null - >; - cleanupOldEmails: FunctionReference< - "mutation", - "internal", - { olderThan?: number }, - null - >; - get: FunctionReference< - "query", - "internal", - { emailId: string }, - { - complained: boolean; - createdAt: number; - errorMessage?: string; - finalizedAt: number; - from: string; - headers?: Array<{ name: string; value: string }>; - html?: string; - opened: boolean; - replyTo: Array; - resendId?: string; - segment: number; - status: - | "waiting" - | "queued" - | "cancelled" - | "sent" - | "delivered" - | "delivery_delayed" - | "bounced" - | "failed"; - subject: string; - text?: string; - to: string; - } | null - >; - getStatus: FunctionReference< - "query", - "internal", - { emailId: string }, - { - complained: boolean; - errorMessage: string | null; - opened: boolean; - status: - | "waiting" - | "queued" - | "cancelled" - | "sent" - | "delivered" - | "delivery_delayed" - | "bounced" - | "failed"; - } | null - >; - handleEmailEvent: FunctionReference< - "mutation", - "internal", - { event: any }, - null - >; - sendEmail: FunctionReference< - "mutation", - "internal", - { - from: string; - headers?: Array<{ name: string; value: string }>; - html?: string; - options: { - apiKey: string; - initialBackoffMs: number; - onEmailEvent?: { fnHandle: string }; - retryAttempts: number; - testMode: boolean; - }; - replyTo?: Array; - subject: string; - text?: string; - to: string; - }, - string - >; - }; - }; + betterAuth: import("./betterAuth/_generated/component.js").ComponentApi<"betterAuth">; + resend: import("@convex-dev/resend/_generated/component.js").ComponentApi<"resend">; }; diff --git a/examples/next/convex/_generated/server.d.ts b/examples/next/convex/_generated/server.d.ts index b5c68288..bec05e68 100644 --- a/examples/next/convex/_generated/server.d.ts +++ b/examples/next/convex/_generated/server.d.ts @@ -10,7 +10,6 @@ import { ActionBuilder, - AnyComponents, HttpActionBuilder, MutationBuilder, QueryBuilder, @@ -19,15 +18,9 @@ import { GenericQueryCtx, GenericDatabaseReader, GenericDatabaseWriter, - FunctionReference, } from "convex/server"; import type { DataModel } from "./dataModel.js"; -type GenericCtx = - | GenericActionCtx - | GenericMutationCtx - | GenericQueryCtx; - /** * Define a query in this Convex app's public API. * @@ -92,11 +85,12 @@ export declare const internalAction: ActionBuilder; /** * Define an HTTP action. * - * This function will be used to respond to HTTP requests received by a Convex - * deployment if the requests matches the path and method where this action - * is routed. Be sure to route your action in `convex/http.js`. + * The wrapped function will be used to respond to HTTP requests received + * by a Convex deployment if the requests matches the path and method where + * this action is routed. Be sure to route your httpAction in `convex/http.js`. * - * @param func - The function. It receives an {@link ActionCtx} as its first argument. + * @param func - The function. It receives an {@link ActionCtx} as its first argument + * and a Fetch API `Request` object as its second. * @returns The wrapped function. Import this function from `convex/http.js` and route it to hook it up. */ export declare const httpAction: HttpActionBuilder; diff --git a/examples/next/convex/_generated/server.js b/examples/next/convex/_generated/server.js index 4a21df4f..bf3d25ad 100644 --- a/examples/next/convex/_generated/server.js +++ b/examples/next/convex/_generated/server.js @@ -16,7 +16,6 @@ import { internalActionGeneric, internalMutationGeneric, internalQueryGeneric, - componentsGeneric, } from "convex/server"; /** @@ -81,10 +80,14 @@ export const action = actionGeneric; export const internalAction = internalActionGeneric; /** - * Define a Convex HTTP action. + * Define an HTTP action. * - * @param func - The function. It receives an {@link ActionCtx} as its first argument, and a `Request` object - * as its second. - * @returns The wrapped endpoint function. Route a URL path to this function in `convex/http.js`. + * The wrapped function will be used to respond to HTTP requests received + * by a Convex deployment if the requests matches the path and method where + * this action is routed. Be sure to route your httpAction in `convex/http.js`. + * + * @param func - The function. It receives an {@link ActionCtx} as its first argument + * and a Fetch API `Request` object as its second. + * @returns The wrapped function. Import this function from `convex/http.js` and route it to hook it up. */ export const httpAction = httpActionGeneric; diff --git a/examples/next/convex/betterAuth/_generated/api.d.ts b/examples/next/convex/betterAuth/_generated/api.d.ts deleted file mode 100644 index f98863bf..00000000 --- a/examples/next/convex/betterAuth/_generated/api.d.ts +++ /dev/null @@ -1,1191 +0,0 @@ -/* eslint-disable */ -/** - * Generated `api` utility. - * - * THIS CODE IS AUTOMATICALLY GENERATED. - * - * To regenerate, run `npx convex dev`. - * @module - */ - -import type * as adapter from "../adapter.js"; -import type * as auth from "../auth.js"; -import type * as generatedSchema from "../generatedSchema.js"; - -import type { - ApiFromModules, - FilterApi, - FunctionReference, -} from "convex/server"; - -/** - * A utility for referencing Convex functions in your app's API. - * - * Usage: - * ```js - * const myFunctionReference = api.myModule.myFunction; - * ``` - */ -declare const fullApi: ApiFromModules<{ - adapter: typeof adapter; - auth: typeof auth; - generatedSchema: typeof generatedSchema; -}>; -export type Mounts = { - adapter: { - create: FunctionReference< - "mutation", - "public", - { - input: - | { - data: { - createdAt: number; - displayUsername?: null | string; - email: string; - emailVerified: boolean; - foo?: null | string; - image?: null | string; - isAnonymous?: null | boolean; - name: string; - test?: null | string; - twoFactorEnabled?: null | boolean; - updatedAt: number; - userId?: null | string; - username?: null | string; - }; - model: "user"; - } - | { - data: { - createdAt: number; - expiresAt: number; - ipAddress?: null | string; - token: string; - updatedAt: number; - userAgent?: null | string; - userId: string; - }; - model: "session"; - } - | { - data: { - accessToken?: null | string; - accessTokenExpiresAt?: null | number; - accountId: string; - createdAt: number; - idToken?: null | string; - password?: null | string; - providerId: string; - refreshToken?: null | string; - refreshTokenExpiresAt?: null | number; - scope?: null | string; - updatedAt: number; - userId: string; - }; - model: "account"; - } - | { - data: { - createdAt: number; - expiresAt: number; - identifier: string; - updatedAt: number; - value: string; - }; - model: "verification"; - } - | { - data: { backupCodes: string; secret: string; userId: string }; - model: "twoFactor"; - } - | { - data: { - createdAt: number; - privateKey: string; - publicKey: string; - }; - model: "jwks"; - }; - onCreateHandle?: string; - select?: Array; - }, - any - >; - deleteMany: FunctionReference< - "mutation", - "public", - { - input: - | { - model: "user"; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "name" - | "email" - | "emailVerified" - | "image" - | "createdAt" - | "updatedAt" - | "isAnonymous" - | "username" - | "displayUsername" - | "twoFactorEnabled" - | "userId" - | "foo" - | "test" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "session"; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "expiresAt" - | "token" - | "createdAt" - | "updatedAt" - | "ipAddress" - | "userAgent" - | "userId" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "account"; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "accountId" - | "providerId" - | "userId" - | "accessToken" - | "refreshToken" - | "idToken" - | "accessTokenExpiresAt" - | "refreshTokenExpiresAt" - | "scope" - | "password" - | "createdAt" - | "updatedAt" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "verification"; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "identifier" - | "value" - | "expiresAt" - | "createdAt" - | "updatedAt" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "twoFactor"; - where?: Array<{ - connector?: "AND" | "OR"; - field: "secret" | "backupCodes" | "userId" | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "jwks"; - where?: Array<{ - connector?: "AND" | "OR"; - field: "publicKey" | "privateKey" | "createdAt" | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - }; - onDeleteHandle?: string; - paginationOpts: { - cursor: string | null; - endCursor?: string | null; - id?: number; - maximumBytesRead?: number; - maximumRowsRead?: number; - numItems: number; - }; - }, - any - >; - deleteOne: FunctionReference< - "mutation", - "public", - { - input: - | { - model: "user"; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "name" - | "email" - | "emailVerified" - | "image" - | "createdAt" - | "updatedAt" - | "isAnonymous" - | "username" - | "displayUsername" - | "twoFactorEnabled" - | "userId" - | "foo" - | "test" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "session"; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "expiresAt" - | "token" - | "createdAt" - | "updatedAt" - | "ipAddress" - | "userAgent" - | "userId" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "account"; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "accountId" - | "providerId" - | "userId" - | "accessToken" - | "refreshToken" - | "idToken" - | "accessTokenExpiresAt" - | "refreshTokenExpiresAt" - | "scope" - | "password" - | "createdAt" - | "updatedAt" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "verification"; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "identifier" - | "value" - | "expiresAt" - | "createdAt" - | "updatedAt" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "twoFactor"; - where?: Array<{ - connector?: "AND" | "OR"; - field: "secret" | "backupCodes" | "userId" | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "jwks"; - where?: Array<{ - connector?: "AND" | "OR"; - field: "publicKey" | "privateKey" | "createdAt" | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - }; - onDeleteHandle?: string; - }, - any - >; - findMany: FunctionReference< - "query", - "public", - { - limit?: number; - model: - | "user" - | "session" - | "account" - | "verification" - | "twoFactor" - | "jwks"; - offset?: number; - paginationOpts: { - cursor: string | null; - endCursor?: string | null; - id?: number; - maximumBytesRead?: number; - maximumRowsRead?: number; - numItems: number; - }; - sortBy?: { direction: "asc" | "desc"; field: string }; - where?: Array<{ - connector?: "AND" | "OR"; - field: string; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - }, - any - >; - findOne: FunctionReference< - "query", - "public", - { - model: - | "user" - | "session" - | "account" - | "verification" - | "twoFactor" - | "jwks"; - select?: Array; - where?: Array<{ - connector?: "AND" | "OR"; - field: string; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - }, - any - >; - updateMany: FunctionReference< - "mutation", - "public", - { - input: - | { - model: "user"; - update: { - createdAt?: number; - displayUsername?: null | string; - email?: string; - emailVerified?: boolean; - foo?: null | string; - image?: null | string; - isAnonymous?: null | boolean; - name?: string; - test?: null | string; - twoFactorEnabled?: null | boolean; - updatedAt?: number; - userId?: null | string; - username?: null | string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "name" - | "email" - | "emailVerified" - | "image" - | "createdAt" - | "updatedAt" - | "isAnonymous" - | "username" - | "displayUsername" - | "twoFactorEnabled" - | "userId" - | "foo" - | "test" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "session"; - update: { - createdAt?: number; - expiresAt?: number; - ipAddress?: null | string; - token?: string; - updatedAt?: number; - userAgent?: null | string; - userId?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "expiresAt" - | "token" - | "createdAt" - | "updatedAt" - | "ipAddress" - | "userAgent" - | "userId" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "account"; - update: { - accessToken?: null | string; - accessTokenExpiresAt?: null | number; - accountId?: string; - createdAt?: number; - idToken?: null | string; - password?: null | string; - providerId?: string; - refreshToken?: null | string; - refreshTokenExpiresAt?: null | number; - scope?: null | string; - updatedAt?: number; - userId?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "accountId" - | "providerId" - | "userId" - | "accessToken" - | "refreshToken" - | "idToken" - | "accessTokenExpiresAt" - | "refreshTokenExpiresAt" - | "scope" - | "password" - | "createdAt" - | "updatedAt" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "verification"; - update: { - createdAt?: number; - expiresAt?: number; - identifier?: string; - updatedAt?: number; - value?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "identifier" - | "value" - | "expiresAt" - | "createdAt" - | "updatedAt" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "twoFactor"; - update: { - backupCodes?: string; - secret?: string; - userId?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: "secret" | "backupCodes" | "userId" | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "jwks"; - update: { - createdAt?: number; - privateKey?: string; - publicKey?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: "publicKey" | "privateKey" | "createdAt" | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - }; - onUpdateHandle?: string; - paginationOpts: { - cursor: string | null; - endCursor?: string | null; - id?: number; - maximumBytesRead?: number; - maximumRowsRead?: number; - numItems: number; - }; - }, - any - >; - updateOne: FunctionReference< - "mutation", - "public", - { - input: - | { - model: "user"; - update: { - createdAt?: number; - displayUsername?: null | string; - email?: string; - emailVerified?: boolean; - foo?: null | string; - image?: null | string; - isAnonymous?: null | boolean; - name?: string; - test?: null | string; - twoFactorEnabled?: null | boolean; - updatedAt?: number; - userId?: null | string; - username?: null | string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "name" - | "email" - | "emailVerified" - | "image" - | "createdAt" - | "updatedAt" - | "isAnonymous" - | "username" - | "displayUsername" - | "twoFactorEnabled" - | "userId" - | "foo" - | "test" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "session"; - update: { - createdAt?: number; - expiresAt?: number; - ipAddress?: null | string; - token?: string; - updatedAt?: number; - userAgent?: null | string; - userId?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "expiresAt" - | "token" - | "createdAt" - | "updatedAt" - | "ipAddress" - | "userAgent" - | "userId" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "account"; - update: { - accessToken?: null | string; - accessTokenExpiresAt?: null | number; - accountId?: string; - createdAt?: number; - idToken?: null | string; - password?: null | string; - providerId?: string; - refreshToken?: null | string; - refreshTokenExpiresAt?: null | number; - scope?: null | string; - updatedAt?: number; - userId?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "accountId" - | "providerId" - | "userId" - | "accessToken" - | "refreshToken" - | "idToken" - | "accessTokenExpiresAt" - | "refreshTokenExpiresAt" - | "scope" - | "password" - | "createdAt" - | "updatedAt" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "verification"; - update: { - createdAt?: number; - expiresAt?: number; - identifier?: string; - updatedAt?: number; - value?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "identifier" - | "value" - | "expiresAt" - | "createdAt" - | "updatedAt" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "twoFactor"; - update: { - backupCodes?: string; - secret?: string; - userId?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: "secret" | "backupCodes" | "userId" | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "jwks"; - update: { - createdAt?: number; - privateKey?: string; - publicKey?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: "publicKey" | "privateKey" | "createdAt" | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - }; - onUpdateHandle?: string; - }, - any - >; - }; - auth: { - getUser: FunctionReference< - "query", - "public", - { userId: string }, - null | { - _creationTime: number; - _id: string; - createdAt: number; - displayUsername?: null | string; - email: string; - emailVerified: boolean; - foo?: null | string; - image?: null | string; - isAnonymous?: null | boolean; - name: string; - test?: null | string; - twoFactorEnabled?: null | boolean; - updatedAt: number; - userId?: null | string; - username?: null | string; - } - >; - }; -}; -// For now fullApiWithMounts is only fullApi which provides -// jump-to-definition in component client code. -// Use Mounts for the same type without the inference. -declare const fullApiWithMounts: typeof fullApi; - -export declare const api: FilterApi< - typeof fullApiWithMounts, - FunctionReference ->; -export declare const internal: FilterApi< - typeof fullApiWithMounts, - FunctionReference ->; - -export declare const components: {}; diff --git a/examples/next/convex/betterAuth/_generated/api.js b/examples/next/convex/betterAuth/_generated/api.js deleted file mode 100644 index 44bf9858..00000000 --- a/examples/next/convex/betterAuth/_generated/api.js +++ /dev/null @@ -1,23 +0,0 @@ -/* eslint-disable */ -/** - * Generated `api` utility. - * - * THIS CODE IS AUTOMATICALLY GENERATED. - * - * To regenerate, run `npx convex dev`. - * @module - */ - -import { anyApi, componentsGeneric } from "convex/server"; - -/** - * A utility for referencing Convex functions in your app's API. - * - * Usage: - * ```js - * const myFunctionReference = api.myModule.myFunction; - * ``` - */ -export const api = anyApi; -export const internal = anyApi; -export const components = componentsGeneric(); diff --git a/examples/next/convex/betterAuth/_generated/api.ts b/examples/next/convex/betterAuth/_generated/api.ts new file mode 100644 index 00000000..7143589b --- /dev/null +++ b/examples/next/convex/betterAuth/_generated/api.ts @@ -0,0 +1,54 @@ +/* eslint-disable */ +/** + * Generated `api` utility. + * + * THIS CODE IS AUTOMATICALLY GENERATED. + * + * To regenerate, run `npx convex dev`. + * @module + */ + +import type * as adapter from "../adapter.js"; +import type * as auth from "../auth.js"; +import type * as generatedSchema from "../generatedSchema.js"; + +import type { + ApiFromModules, + FilterApi, + FunctionReference, +} from "convex/server"; +import { anyApi, componentsGeneric } from "convex/server"; + +const fullApi: ApiFromModules<{ + adapter: typeof adapter; + auth: typeof auth; + generatedSchema: typeof generatedSchema; +}> = anyApi as any; + +/** + * A utility for referencing Convex functions in your app's public API. + * + * Usage: + * ```js + * const myFunctionReference = api.myModule.myFunction; + * ``` + */ +export const api: FilterApi< + typeof fullApi, + FunctionReference +> = anyApi as any; + +/** + * A utility for referencing Convex functions in your app's internal API. + * + * Usage: + * ```js + * const myFunctionReference = internal.myModule.myFunction; + * ``` + */ +export const internal: FilterApi< + typeof fullApi, + FunctionReference +> = anyApi as any; + +export const components = componentsGeneric() as unknown as {}; diff --git a/examples/next/convex/betterAuth/_generated/component.ts b/examples/next/convex/betterAuth/_generated/component.ts new file mode 100644 index 00000000..efe212d2 --- /dev/null +++ b/examples/next/convex/betterAuth/_generated/component.ts @@ -0,0 +1,1175 @@ +/* eslint-disable */ +/** + * Generated `ComponentApi` utility. + * + * THIS CODE IS AUTOMATICALLY GENERATED. + * + * To regenerate, run `npx convex dev`. + * @module + */ + +import type { FunctionReference } from "convex/server"; + +/** + * A utility for referencing a Convex component's exposed API. + * + * Useful when expecting a parameter like `components.myComponent`. + * Usage: + * ```ts + * async function myFunction(ctx: QueryCtx, component: ComponentApi) { + * return ctx.runQuery(component.someFile.someQuery, { ...args }); + * } + * ``` + */ +export type ComponentApi = + { + adapter: { + create: FunctionReference< + "mutation", + "internal", + { + input: + | { + data: { + createdAt: number; + displayUsername?: null | string; + email: string; + emailVerified: boolean; + foo?: null | string; + image?: null | string; + isAnonymous?: null | boolean; + name: string; + test?: null | string; + twoFactorEnabled?: null | boolean; + updatedAt: number; + userId?: null | string; + username?: null | string; + }; + model: "user"; + } + | { + data: { + createdAt: number; + expiresAt: number; + ipAddress?: null | string; + token: string; + updatedAt: number; + userAgent?: null | string; + userId: string; + }; + model: "session"; + } + | { + data: { + accessToken?: null | string; + accessTokenExpiresAt?: null | number; + accountId: string; + createdAt: number; + idToken?: null | string; + password?: null | string; + providerId: string; + refreshToken?: null | string; + refreshTokenExpiresAt?: null | number; + scope?: null | string; + updatedAt: number; + userId: string; + }; + model: "account"; + } + | { + data: { + createdAt: number; + expiresAt: number; + identifier: string; + updatedAt: number; + value: string; + }; + model: "verification"; + } + | { + data: { backupCodes: string; secret: string; userId: string }; + model: "twoFactor"; + } + | { + data: { + createdAt: number; + privateKey: string; + publicKey: string; + }; + model: "jwks"; + }; + onCreateHandle?: string; + select?: Array; + }, + any, + Name + >; + deleteMany: FunctionReference< + "mutation", + "internal", + { + input: + | { + model: "user"; + where?: Array<{ + connector?: "AND" | "OR"; + field: + | "name" + | "email" + | "emailVerified" + | "image" + | "createdAt" + | "updatedAt" + | "isAnonymous" + | "username" + | "displayUsername" + | "twoFactorEnabled" + | "userId" + | "foo" + | "test" + | "_id"; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + } + | { + model: "session"; + where?: Array<{ + connector?: "AND" | "OR"; + field: + | "expiresAt" + | "token" + | "createdAt" + | "updatedAt" + | "ipAddress" + | "userAgent" + | "userId" + | "_id"; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + } + | { + model: "account"; + where?: Array<{ + connector?: "AND" | "OR"; + field: + | "accountId" + | "providerId" + | "userId" + | "accessToken" + | "refreshToken" + | "idToken" + | "accessTokenExpiresAt" + | "refreshTokenExpiresAt" + | "scope" + | "password" + | "createdAt" + | "updatedAt" + | "_id"; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + } + | { + model: "verification"; + where?: Array<{ + connector?: "AND" | "OR"; + field: + | "identifier" + | "value" + | "expiresAt" + | "createdAt" + | "updatedAt" + | "_id"; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + } + | { + model: "twoFactor"; + where?: Array<{ + connector?: "AND" | "OR"; + field: "secret" | "backupCodes" | "userId" | "_id"; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + } + | { + model: "jwks"; + where?: Array<{ + connector?: "AND" | "OR"; + field: "publicKey" | "privateKey" | "createdAt" | "_id"; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + }; + onDeleteHandle?: string; + paginationOpts: { + cursor: string | null; + endCursor?: string | null; + id?: number; + maximumBytesRead?: number; + maximumRowsRead?: number; + numItems: number; + }; + }, + any, + Name + >; + deleteOne: FunctionReference< + "mutation", + "internal", + { + input: + | { + model: "user"; + where?: Array<{ + connector?: "AND" | "OR"; + field: + | "name" + | "email" + | "emailVerified" + | "image" + | "createdAt" + | "updatedAt" + | "isAnonymous" + | "username" + | "displayUsername" + | "twoFactorEnabled" + | "userId" + | "foo" + | "test" + | "_id"; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + } + | { + model: "session"; + where?: Array<{ + connector?: "AND" | "OR"; + field: + | "expiresAt" + | "token" + | "createdAt" + | "updatedAt" + | "ipAddress" + | "userAgent" + | "userId" + | "_id"; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + } + | { + model: "account"; + where?: Array<{ + connector?: "AND" | "OR"; + field: + | "accountId" + | "providerId" + | "userId" + | "accessToken" + | "refreshToken" + | "idToken" + | "accessTokenExpiresAt" + | "refreshTokenExpiresAt" + | "scope" + | "password" + | "createdAt" + | "updatedAt" + | "_id"; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + } + | { + model: "verification"; + where?: Array<{ + connector?: "AND" | "OR"; + field: + | "identifier" + | "value" + | "expiresAt" + | "createdAt" + | "updatedAt" + | "_id"; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + } + | { + model: "twoFactor"; + where?: Array<{ + connector?: "AND" | "OR"; + field: "secret" | "backupCodes" | "userId" | "_id"; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + } + | { + model: "jwks"; + where?: Array<{ + connector?: "AND" | "OR"; + field: "publicKey" | "privateKey" | "createdAt" | "_id"; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + }; + onDeleteHandle?: string; + }, + any, + Name + >; + findMany: FunctionReference< + "query", + "internal", + { + limit?: number; + model: + | "user" + | "session" + | "account" + | "verification" + | "twoFactor" + | "jwks"; + offset?: number; + paginationOpts: { + cursor: string | null; + endCursor?: string | null; + id?: number; + maximumBytesRead?: number; + maximumRowsRead?: number; + numItems: number; + }; + sortBy?: { direction: "asc" | "desc"; field: string }; + where?: Array<{ + connector?: "AND" | "OR"; + field: string; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + }, + any, + Name + >; + findOne: FunctionReference< + "query", + "internal", + { + model: + | "user" + | "session" + | "account" + | "verification" + | "twoFactor" + | "jwks"; + select?: Array; + where?: Array<{ + connector?: "AND" | "OR"; + field: string; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + }, + any, + Name + >; + updateMany: FunctionReference< + "mutation", + "internal", + { + input: + | { + model: "user"; + update: { + createdAt?: number; + displayUsername?: null | string; + email?: string; + emailVerified?: boolean; + foo?: null | string; + image?: null | string; + isAnonymous?: null | boolean; + name?: string; + test?: null | string; + twoFactorEnabled?: null | boolean; + updatedAt?: number; + userId?: null | string; + username?: null | string; + }; + where?: Array<{ + connector?: "AND" | "OR"; + field: + | "name" + | "email" + | "emailVerified" + | "image" + | "createdAt" + | "updatedAt" + | "isAnonymous" + | "username" + | "displayUsername" + | "twoFactorEnabled" + | "userId" + | "foo" + | "test" + | "_id"; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + } + | { + model: "session"; + update: { + createdAt?: number; + expiresAt?: number; + ipAddress?: null | string; + token?: string; + updatedAt?: number; + userAgent?: null | string; + userId?: string; + }; + where?: Array<{ + connector?: "AND" | "OR"; + field: + | "expiresAt" + | "token" + | "createdAt" + | "updatedAt" + | "ipAddress" + | "userAgent" + | "userId" + | "_id"; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + } + | { + model: "account"; + update: { + accessToken?: null | string; + accessTokenExpiresAt?: null | number; + accountId?: string; + createdAt?: number; + idToken?: null | string; + password?: null | string; + providerId?: string; + refreshToken?: null | string; + refreshTokenExpiresAt?: null | number; + scope?: null | string; + updatedAt?: number; + userId?: string; + }; + where?: Array<{ + connector?: "AND" | "OR"; + field: + | "accountId" + | "providerId" + | "userId" + | "accessToken" + | "refreshToken" + | "idToken" + | "accessTokenExpiresAt" + | "refreshTokenExpiresAt" + | "scope" + | "password" + | "createdAt" + | "updatedAt" + | "_id"; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + } + | { + model: "verification"; + update: { + createdAt?: number; + expiresAt?: number; + identifier?: string; + updatedAt?: number; + value?: string; + }; + where?: Array<{ + connector?: "AND" | "OR"; + field: + | "identifier" + | "value" + | "expiresAt" + | "createdAt" + | "updatedAt" + | "_id"; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + } + | { + model: "twoFactor"; + update: { + backupCodes?: string; + secret?: string; + userId?: string; + }; + where?: Array<{ + connector?: "AND" | "OR"; + field: "secret" | "backupCodes" | "userId" | "_id"; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + } + | { + model: "jwks"; + update: { + createdAt?: number; + privateKey?: string; + publicKey?: string; + }; + where?: Array<{ + connector?: "AND" | "OR"; + field: "publicKey" | "privateKey" | "createdAt" | "_id"; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + }; + onUpdateHandle?: string; + paginationOpts: { + cursor: string | null; + endCursor?: string | null; + id?: number; + maximumBytesRead?: number; + maximumRowsRead?: number; + numItems: number; + }; + }, + any, + Name + >; + updateOne: FunctionReference< + "mutation", + "internal", + { + input: + | { + model: "user"; + update: { + createdAt?: number; + displayUsername?: null | string; + email?: string; + emailVerified?: boolean; + foo?: null | string; + image?: null | string; + isAnonymous?: null | boolean; + name?: string; + test?: null | string; + twoFactorEnabled?: null | boolean; + updatedAt?: number; + userId?: null | string; + username?: null | string; + }; + where?: Array<{ + connector?: "AND" | "OR"; + field: + | "name" + | "email" + | "emailVerified" + | "image" + | "createdAt" + | "updatedAt" + | "isAnonymous" + | "username" + | "displayUsername" + | "twoFactorEnabled" + | "userId" + | "foo" + | "test" + | "_id"; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + } + | { + model: "session"; + update: { + createdAt?: number; + expiresAt?: number; + ipAddress?: null | string; + token?: string; + updatedAt?: number; + userAgent?: null | string; + userId?: string; + }; + where?: Array<{ + connector?: "AND" | "OR"; + field: + | "expiresAt" + | "token" + | "createdAt" + | "updatedAt" + | "ipAddress" + | "userAgent" + | "userId" + | "_id"; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + } + | { + model: "account"; + update: { + accessToken?: null | string; + accessTokenExpiresAt?: null | number; + accountId?: string; + createdAt?: number; + idToken?: null | string; + password?: null | string; + providerId?: string; + refreshToken?: null | string; + refreshTokenExpiresAt?: null | number; + scope?: null | string; + updatedAt?: number; + userId?: string; + }; + where?: Array<{ + connector?: "AND" | "OR"; + field: + | "accountId" + | "providerId" + | "userId" + | "accessToken" + | "refreshToken" + | "idToken" + | "accessTokenExpiresAt" + | "refreshTokenExpiresAt" + | "scope" + | "password" + | "createdAt" + | "updatedAt" + | "_id"; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + } + | { + model: "verification"; + update: { + createdAt?: number; + expiresAt?: number; + identifier?: string; + updatedAt?: number; + value?: string; + }; + where?: Array<{ + connector?: "AND" | "OR"; + field: + | "identifier" + | "value" + | "expiresAt" + | "createdAt" + | "updatedAt" + | "_id"; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + } + | { + model: "twoFactor"; + update: { + backupCodes?: string; + secret?: string; + userId?: string; + }; + where?: Array<{ + connector?: "AND" | "OR"; + field: "secret" | "backupCodes" | "userId" | "_id"; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + } + | { + model: "jwks"; + update: { + createdAt?: number; + privateKey?: string; + publicKey?: string; + }; + where?: Array<{ + connector?: "AND" | "OR"; + field: "publicKey" | "privateKey" | "createdAt" | "_id"; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + }; + onUpdateHandle?: string; + }, + any, + Name + >; + }; + auth: { + getUser: FunctionReference< + "query", + "internal", + { userId: string }, + null | { + _creationTime: number; + _id: string; + createdAt: number; + displayUsername?: null | string; + email: string; + emailVerified: boolean; + foo?: null | string; + image?: null | string; + isAnonymous?: null | boolean; + name: string; + test?: null | string; + twoFactorEnabled?: null | boolean; + updatedAt: number; + userId?: null | string; + username?: null | string; + }, + Name + >; + }; + }; diff --git a/examples/next/convex/betterAuth/_generated/dataModel.d.ts b/examples/next/convex/betterAuth/_generated/dataModel.ts similarity index 100% rename from examples/next/convex/betterAuth/_generated/dataModel.d.ts rename to examples/next/convex/betterAuth/_generated/dataModel.ts diff --git a/examples/next/convex/betterAuth/_generated/server.js b/examples/next/convex/betterAuth/_generated/server.js deleted file mode 100644 index 4a21df4f..00000000 --- a/examples/next/convex/betterAuth/_generated/server.js +++ /dev/null @@ -1,90 +0,0 @@ -/* eslint-disable */ -/** - * Generated utilities for implementing server-side Convex query and mutation functions. - * - * THIS CODE IS AUTOMATICALLY GENERATED. - * - * To regenerate, run `npx convex dev`. - * @module - */ - -import { - actionGeneric, - httpActionGeneric, - queryGeneric, - mutationGeneric, - internalActionGeneric, - internalMutationGeneric, - internalQueryGeneric, - componentsGeneric, -} from "convex/server"; - -/** - * Define a query in this Convex app's public API. - * - * This function will be allowed to read your Convex database and will be accessible from the client. - * - * @param func - The query function. It receives a {@link QueryCtx} as its first argument. - * @returns The wrapped query. Include this as an `export` to name it and make it accessible. - */ -export const query = queryGeneric; - -/** - * Define a query that is only accessible from other Convex functions (but not from the client). - * - * This function will be allowed to read from your Convex database. It will not be accessible from the client. - * - * @param func - The query function. It receives a {@link QueryCtx} as its first argument. - * @returns The wrapped query. Include this as an `export` to name it and make it accessible. - */ -export const internalQuery = internalQueryGeneric; - -/** - * Define a mutation in this Convex app's public API. - * - * This function will be allowed to modify your Convex database and will be accessible from the client. - * - * @param func - The mutation function. It receives a {@link MutationCtx} as its first argument. - * @returns The wrapped mutation. Include this as an `export` to name it and make it accessible. - */ -export const mutation = mutationGeneric; - -/** - * Define a mutation that is only accessible from other Convex functions (but not from the client). - * - * This function will be allowed to modify your Convex database. It will not be accessible from the client. - * - * @param func - The mutation function. It receives a {@link MutationCtx} as its first argument. - * @returns The wrapped mutation. Include this as an `export` to name it and make it accessible. - */ -export const internalMutation = internalMutationGeneric; - -/** - * Define an action in this Convex app's public API. - * - * An action is a function which can execute any JavaScript code, including non-deterministic - * code and code with side-effects, like calling third-party services. - * They can be run in Convex's JavaScript environment or in Node.js using the "use node" directive. - * They can interact with the database indirectly by calling queries and mutations using the {@link ActionCtx}. - * - * @param func - The action. It receives an {@link ActionCtx} as its first argument. - * @returns The wrapped action. Include this as an `export` to name it and make it accessible. - */ -export const action = actionGeneric; - -/** - * Define an action that is only accessible from other Convex functions (but not from the client). - * - * @param func - The function. It receives an {@link ActionCtx} as its first argument. - * @returns The wrapped function. Include this as an `export` to name it and make it accessible. - */ -export const internalAction = internalActionGeneric; - -/** - * Define a Convex HTTP action. - * - * @param func - The function. It receives an {@link ActionCtx} as its first argument, and a `Request` object - * as its second. - * @returns The wrapped endpoint function. Route a URL path to this function in `convex/http.js`. - */ -export const httpAction = httpActionGeneric; diff --git a/examples/next/convex/betterAuth/_generated/server.d.ts b/examples/next/convex/betterAuth/_generated/server.ts similarity index 79% rename from examples/next/convex/betterAuth/_generated/server.d.ts rename to examples/next/convex/betterAuth/_generated/server.ts index b5c68288..24994e4e 100644 --- a/examples/next/convex/betterAuth/_generated/server.d.ts +++ b/examples/next/convex/betterAuth/_generated/server.ts @@ -8,9 +8,8 @@ * @module */ -import { +import type { ActionBuilder, - AnyComponents, HttpActionBuilder, MutationBuilder, QueryBuilder, @@ -19,15 +18,18 @@ import { GenericQueryCtx, GenericDatabaseReader, GenericDatabaseWriter, - FunctionReference, +} from "convex/server"; +import { + actionGeneric, + httpActionGeneric, + queryGeneric, + mutationGeneric, + internalActionGeneric, + internalMutationGeneric, + internalQueryGeneric, } from "convex/server"; import type { DataModel } from "./dataModel.js"; -type GenericCtx = - | GenericActionCtx - | GenericMutationCtx - | GenericQueryCtx; - /** * Define a query in this Convex app's public API. * @@ -36,7 +38,7 @@ type GenericCtx = * @param func - The query function. It receives a {@link QueryCtx} as its first argument. * @returns The wrapped query. Include this as an `export` to name it and make it accessible. */ -export declare const query: QueryBuilder; +export const query: QueryBuilder = queryGeneric; /** * Define a query that is only accessible from other Convex functions (but not from the client). @@ -46,7 +48,8 @@ export declare const query: QueryBuilder; * @param func - The query function. It receives a {@link QueryCtx} as its first argument. * @returns The wrapped query. Include this as an `export` to name it and make it accessible. */ -export declare const internalQuery: QueryBuilder; +export const internalQuery: QueryBuilder = + internalQueryGeneric; /** * Define a mutation in this Convex app's public API. @@ -56,7 +59,7 @@ export declare const internalQuery: QueryBuilder; * @param func - The mutation function. It receives a {@link MutationCtx} as its first argument. * @returns The wrapped mutation. Include this as an `export` to name it and make it accessible. */ -export declare const mutation: MutationBuilder; +export const mutation: MutationBuilder = mutationGeneric; /** * Define a mutation that is only accessible from other Convex functions (but not from the client). @@ -66,7 +69,8 @@ export declare const mutation: MutationBuilder; * @param func - The mutation function. It receives a {@link MutationCtx} as its first argument. * @returns The wrapped mutation. Include this as an `export` to name it and make it accessible. */ -export declare const internalMutation: MutationBuilder; +export const internalMutation: MutationBuilder = + internalMutationGeneric; /** * Define an action in this Convex app's public API. @@ -79,7 +83,7 @@ export declare const internalMutation: MutationBuilder; * @param func - The action. It receives an {@link ActionCtx} as its first argument. * @returns The wrapped action. Include this as an `export` to name it and make it accessible. */ -export declare const action: ActionBuilder; +export const action: ActionBuilder = actionGeneric; /** * Define an action that is only accessible from other Convex functions (but not from the client). @@ -87,19 +91,26 @@ export declare const action: ActionBuilder; * @param func - The function. It receives an {@link ActionCtx} as its first argument. * @returns The wrapped function. Include this as an `export` to name it and make it accessible. */ -export declare const internalAction: ActionBuilder; +export const internalAction: ActionBuilder = + internalActionGeneric; /** * Define an HTTP action. * - * This function will be used to respond to HTTP requests received by a Convex - * deployment if the requests matches the path and method where this action - * is routed. Be sure to route your action in `convex/http.js`. + * The wrapped function will be used to respond to HTTP requests received + * by a Convex deployment if the requests matches the path and method where + * this action is routed. Be sure to route your httpAction in `convex/http.js`. * - * @param func - The function. It receives an {@link ActionCtx} as its first argument. + * @param func - The function. It receives an {@link ActionCtx} as its first argument + * and a Fetch API `Request` object as its second. * @returns The wrapped function. Import this function from `convex/http.js` and route it to hook it up. */ -export declare const httpAction: HttpActionBuilder; +export const httpAction: HttpActionBuilder = httpActionGeneric; + +type GenericCtx = + | GenericActionCtx + | GenericMutationCtx + | GenericQueryCtx; /** * A set of services for use within Convex query functions. @@ -107,8 +118,7 @@ export declare const httpAction: HttpActionBuilder; * The query context is passed as the first argument to any Convex query * function run on the server. * - * This differs from the {@link MutationCtx} because all of the services are - * read-only. + * If you're using code generation, use the `QueryCtx` type in `convex/_generated/server.d.ts` instead. */ export type QueryCtx = GenericQueryCtx; @@ -117,6 +127,8 @@ export type QueryCtx = GenericQueryCtx; * * The mutation context is passed as the first argument to any Convex mutation * function run on the server. + * + * If you're using code generation, use the `MutationCtx` type in `convex/_generated/server.d.ts` instead. */ export type MutationCtx = GenericMutationCtx; diff --git a/examples/next/convex/polyfills.ts b/examples/next/convex/polyfills.ts index 5be025c4..1aca57c1 100644 --- a/examples/next/convex/polyfills.ts +++ b/examples/next/convex/polyfills.ts @@ -5,12 +5,10 @@ if (typeof MessageChannel === "undefined") { onmessageerror: ((ev: MessageEvent) => void) | undefined; close() {} - // eslint-disable-next-line @typescript-eslint/no-unused-vars postMessage(_message: unknown, _transfer: Transferable[] = []) {} start() {} addEventListener() {} removeEventListener() {} - // eslint-disable-next-line @typescript-eslint/no-unused-vars dispatchEvent(_event: Event): boolean { return false; } diff --git a/examples/next/package-lock.json b/examples/next/package-lock.json index e5acf291..772d720f 100644 --- a/examples/next/package-lock.json +++ b/examples/next/package-lock.json @@ -47,11 +47,12 @@ }, "../..": { "name": "@convex-dev/better-auth", - "version": "0.9.6", + "version": "0.9.7", "license": "Apache-2.0", "dependencies": { "common-tags": "^1.8.2", "convex-helpers": "^0.1.95", + "jose": "^6.1.0", "remeda": "^2.32.0", "semver": "^7.7.3", "type-fest": "^4.39.1", @@ -69,19 +70,20 @@ "@types/semver": "^7.7.0", "chokidar-cli": "^3.0.0", "concurrently": "^9.2.0", + "convex": "1.29.0", "convex-test": "^0.0.33", "eslint": "^9.9.1", "globals": "^15.9.0", "next": "^15.1.8", + "npm-run-all2": "8.0.4", "prettier": "3.2.5", - "tsc-alias": "^1.8.16", "typescript": "5.8.3", "typescript-eslint": "^8.4.0", "vitest": "^3.2.2" }, "peerDependencies": { "better-auth": "1.3.27", - "convex": "^1.28.0", + "convex": "^1.28.2", "react": "^18.3.1 || ^19.0.0", "react-dom": "^18.3.1 || ^19.0.0" } diff --git a/examples/next/package.json b/examples/next/package.json index 8ff876de..41722ece 100644 --- a/examples/next/package.json +++ b/examples/next/package.json @@ -4,10 +4,10 @@ "type": "module", "private": true, "scripts": { - "dev": "npm-run-all --parallel dev:frontend dev:backend", - "dev:backend": "convex dev --typecheck-components --live-component-sources", + "dev": "run-p -r 'dev:*'", "dev:frontend": "next dev --experimental-https", - "generate": "convex dev --once --typecheck-components", + "dev:backend": "npx convex dev --typecheck-components", + "dev:build": "chokidar '../../tsconfig*.json' '../../src/**/*.ts' -i '**/*.test.ts' -c 'npx convex codegen --component-dir ../../src/component && cd ../../ && npm run build' --initial", "lint": "next lint && tsc -p convex && eslint convex" }, "dependencies": { diff --git a/examples/react/.env.example b/examples/react/.env.example new file mode 100644 index 00000000..44ee1bbd --- /dev/null +++ b/examples/react/.env.example @@ -0,0 +1,7 @@ +CONVEX_DEPLOYMENT=dev:adjective-animal-123 + +VITE_CONVEX_URL=https://adjective-animal-123.convex.cloud +VITE_CONVEX_SITE_URL=https://adjective-animal-123.convex.site + +VITE_SITE_URL=http://localhost:5173 +SITE_URL=http://localhost:5173 \ No newline at end of file diff --git a/examples/react/convex.json b/examples/react/convex.json new file mode 100644 index 00000000..465d5fc8 --- /dev/null +++ b/examples/react/convex.json @@ -0,0 +1,6 @@ +{ + "$schema": "./node_modules/convex/schemas/convex.schema.json", + "codegen": { + "legacyComponentApi": false + } +} diff --git a/examples/react/convex/_generated/api.d.ts b/examples/react/convex/_generated/api.d.ts index de09af3f..2b5bc88d 100644 --- a/examples/react/convex/_generated/api.d.ts +++ b/examples/react/convex/_generated/api.d.ts @@ -25,14 +25,6 @@ import type { FunctionReference, } from "convex/server"; -/** - * A utility for referencing Convex functions in your app's API. - * - * Usage: - * ```js - * const myFunctionReference = api.myModule.myFunction; - * ``` - */ declare const fullApi: ApiFromModules<{ auth: typeof auth; email: typeof email; @@ -45,2244 +37,34 @@ declare const fullApi: ApiFromModules<{ todos: typeof todos; util: typeof util; }>; -declare const fullApiWithMounts: typeof fullApi; +/** + * A utility for referencing Convex functions in your app's public API. + * + * Usage: + * ```js + * const myFunctionReference = api.myModule.myFunction; + * ``` + */ export declare const api: FilterApi< - typeof fullApiWithMounts, + typeof fullApi, FunctionReference >; + +/** + * A utility for referencing Convex functions in your app's internal API. + * + * Usage: + * ```js + * const myFunctionReference = internal.myModule.myFunction; + * ``` + */ export declare const internal: FilterApi< - typeof fullApiWithMounts, + typeof fullApi, FunctionReference >; export declare const components: { - betterAuth: { - adapter: { - create: FunctionReference< - "mutation", - "internal", - { - input: - | { - data: { - createdAt: number; - displayUsername?: null | string; - email: string; - emailVerified: boolean; - image?: null | string; - isAnonymous?: null | boolean; - name: string; - phoneNumber?: null | string; - phoneNumberVerified?: null | boolean; - twoFactorEnabled?: null | boolean; - updatedAt: number; - userId?: null | string; - username?: null | string; - }; - model: "user"; - } - | { - data: { - createdAt: number; - expiresAt: number; - ipAddress?: null | string; - token: string; - updatedAt: number; - userAgent?: null | string; - userId: string; - }; - model: "session"; - } - | { - data: { - accessToken?: null | string; - accessTokenExpiresAt?: null | number; - accountId: string; - createdAt: number; - idToken?: null | string; - password?: null | string; - providerId: string; - refreshToken?: null | string; - refreshTokenExpiresAt?: null | number; - scope?: null | string; - updatedAt: number; - userId: string; - }; - model: "account"; - } - | { - data: { - createdAt: number; - expiresAt: number; - identifier: string; - updatedAt: number; - value: string; - }; - model: "verification"; - } - | { - data: { backupCodes: string; secret: string; userId: string }; - model: "twoFactor"; - } - | { - data: { - aaguid?: null | string; - backedUp: boolean; - counter: number; - createdAt?: null | number; - credentialID: string; - deviceType: string; - name?: null | string; - publicKey: string; - transports?: null | string; - userId: string; - }; - model: "passkey"; - } - | { - data: { - clientId?: null | string; - clientSecret?: null | string; - createdAt?: null | number; - disabled?: null | boolean; - icon?: null | string; - metadata?: null | string; - name?: null | string; - redirectURLs?: null | string; - type?: null | string; - updatedAt?: null | number; - userId?: null | string; - }; - model: "oauthApplication"; - } - | { - data: { - accessToken?: null | string; - accessTokenExpiresAt?: null | number; - clientId?: null | string; - createdAt?: null | number; - refreshToken?: null | string; - refreshTokenExpiresAt?: null | number; - scopes?: null | string; - updatedAt?: null | number; - userId?: null | string; - }; - model: "oauthAccessToken"; - } - | { - data: { - clientId?: null | string; - consentGiven?: null | boolean; - createdAt?: null | number; - scopes?: null | string; - updatedAt?: null | number; - userId?: null | string; - }; - model: "oauthConsent"; - } - | { - data: { - createdAt: number; - privateKey: string; - publicKey: string; - }; - model: "jwks"; - } - | { - data: { - count?: null | number; - key?: null | string; - lastRequest?: null | number; - }; - model: "rateLimit"; - } - | { - data: { count: number; key: string; lastRequest: number }; - model: "ratelimit"; - }; - onCreateHandle?: string; - select?: Array; - }, - any - >; - deleteMany: FunctionReference< - "mutation", - "internal", - { - input: - | { - model: "user"; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "name" - | "email" - | "emailVerified" - | "image" - | "createdAt" - | "updatedAt" - | "twoFactorEnabled" - | "isAnonymous" - | "username" - | "displayUsername" - | "phoneNumber" - | "phoneNumberVerified" - | "userId" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "session"; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "expiresAt" - | "token" - | "createdAt" - | "updatedAt" - | "ipAddress" - | "userAgent" - | "userId" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "account"; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "accountId" - | "providerId" - | "userId" - | "accessToken" - | "refreshToken" - | "idToken" - | "accessTokenExpiresAt" - | "refreshTokenExpiresAt" - | "scope" - | "password" - | "createdAt" - | "updatedAt" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "verification"; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "identifier" - | "value" - | "expiresAt" - | "createdAt" - | "updatedAt" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "twoFactor"; - where?: Array<{ - connector?: "AND" | "OR"; - field: "secret" | "backupCodes" | "userId" | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "passkey"; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "name" - | "publicKey" - | "userId" - | "credentialID" - | "counter" - | "deviceType" - | "backedUp" - | "transports" - | "createdAt" - | "aaguid" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "oauthApplication"; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "name" - | "icon" - | "metadata" - | "clientId" - | "clientSecret" - | "redirectURLs" - | "type" - | "disabled" - | "userId" - | "createdAt" - | "updatedAt" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "oauthAccessToken"; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "accessToken" - | "refreshToken" - | "accessTokenExpiresAt" - | "refreshTokenExpiresAt" - | "clientId" - | "userId" - | "scopes" - | "createdAt" - | "updatedAt" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "oauthConsent"; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "clientId" - | "userId" - | "scopes" - | "createdAt" - | "updatedAt" - | "consentGiven" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "jwks"; - where?: Array<{ - connector?: "AND" | "OR"; - field: "publicKey" | "privateKey" | "createdAt" | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "rateLimit"; - where?: Array<{ - connector?: "AND" | "OR"; - field: "key" | "count" | "lastRequest" | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "ratelimit"; - where?: Array<{ - connector?: "AND" | "OR"; - field: "key" | "count" | "lastRequest" | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - }; - onDeleteHandle?: string; - paginationOpts: { - cursor: string | null; - endCursor?: string | null; - id?: number; - maximumBytesRead?: number; - maximumRowsRead?: number; - numItems: number; - }; - }, - any - >; - deleteOne: FunctionReference< - "mutation", - "internal", - { - input: - | { - model: "user"; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "name" - | "email" - | "emailVerified" - | "image" - | "createdAt" - | "updatedAt" - | "twoFactorEnabled" - | "isAnonymous" - | "username" - | "displayUsername" - | "phoneNumber" - | "phoneNumberVerified" - | "userId" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "session"; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "expiresAt" - | "token" - | "createdAt" - | "updatedAt" - | "ipAddress" - | "userAgent" - | "userId" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "account"; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "accountId" - | "providerId" - | "userId" - | "accessToken" - | "refreshToken" - | "idToken" - | "accessTokenExpiresAt" - | "refreshTokenExpiresAt" - | "scope" - | "password" - | "createdAt" - | "updatedAt" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "verification"; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "identifier" - | "value" - | "expiresAt" - | "createdAt" - | "updatedAt" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "twoFactor"; - where?: Array<{ - connector?: "AND" | "OR"; - field: "secret" | "backupCodes" | "userId" | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "passkey"; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "name" - | "publicKey" - | "userId" - | "credentialID" - | "counter" - | "deviceType" - | "backedUp" - | "transports" - | "createdAt" - | "aaguid" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "oauthApplication"; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "name" - | "icon" - | "metadata" - | "clientId" - | "clientSecret" - | "redirectURLs" - | "type" - | "disabled" - | "userId" - | "createdAt" - | "updatedAt" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "oauthAccessToken"; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "accessToken" - | "refreshToken" - | "accessTokenExpiresAt" - | "refreshTokenExpiresAt" - | "clientId" - | "userId" - | "scopes" - | "createdAt" - | "updatedAt" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "oauthConsent"; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "clientId" - | "userId" - | "scopes" - | "createdAt" - | "updatedAt" - | "consentGiven" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "jwks"; - where?: Array<{ - connector?: "AND" | "OR"; - field: "publicKey" | "privateKey" | "createdAt" | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "rateLimit"; - where?: Array<{ - connector?: "AND" | "OR"; - field: "key" | "count" | "lastRequest" | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "ratelimit"; - where?: Array<{ - connector?: "AND" | "OR"; - field: "key" | "count" | "lastRequest" | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - }; - onDeleteHandle?: string; - }, - any - >; - findMany: FunctionReference< - "query", - "internal", - { - limit?: number; - model: - | "user" - | "session" - | "account" - | "verification" - | "twoFactor" - | "passkey" - | "oauthApplication" - | "oauthAccessToken" - | "oauthConsent" - | "jwks" - | "rateLimit" - | "ratelimit"; - offset?: number; - paginationOpts: { - cursor: string | null; - endCursor?: string | null; - id?: number; - maximumBytesRead?: number; - maximumRowsRead?: number; - numItems: number; - }; - sortBy?: { direction: "asc" | "desc"; field: string }; - where?: Array<{ - connector?: "AND" | "OR"; - field: string; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - }, - any - >; - findOne: FunctionReference< - "query", - "internal", - { - model: - | "user" - | "session" - | "account" - | "verification" - | "twoFactor" - | "passkey" - | "oauthApplication" - | "oauthAccessToken" - | "oauthConsent" - | "jwks" - | "rateLimit" - | "ratelimit"; - select?: Array; - where?: Array<{ - connector?: "AND" | "OR"; - field: string; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - }, - any - >; - migrationRemoveUserId: FunctionReference< - "mutation", - "internal", - { userId: string }, - any - >; - updateMany: FunctionReference< - "mutation", - "internal", - { - input: - | { - model: "user"; - update: { - createdAt?: number; - displayUsername?: null | string; - email?: string; - emailVerified?: boolean; - image?: null | string; - isAnonymous?: null | boolean; - name?: string; - phoneNumber?: null | string; - phoneNumberVerified?: null | boolean; - twoFactorEnabled?: null | boolean; - updatedAt?: number; - userId?: null | string; - username?: null | string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "name" - | "email" - | "emailVerified" - | "image" - | "createdAt" - | "updatedAt" - | "twoFactorEnabled" - | "isAnonymous" - | "username" - | "displayUsername" - | "phoneNumber" - | "phoneNumberVerified" - | "userId" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "session"; - update: { - createdAt?: number; - expiresAt?: number; - ipAddress?: null | string; - token?: string; - updatedAt?: number; - userAgent?: null | string; - userId?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "expiresAt" - | "token" - | "createdAt" - | "updatedAt" - | "ipAddress" - | "userAgent" - | "userId" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "account"; - update: { - accessToken?: null | string; - accessTokenExpiresAt?: null | number; - accountId?: string; - createdAt?: number; - idToken?: null | string; - password?: null | string; - providerId?: string; - refreshToken?: null | string; - refreshTokenExpiresAt?: null | number; - scope?: null | string; - updatedAt?: number; - userId?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "accountId" - | "providerId" - | "userId" - | "accessToken" - | "refreshToken" - | "idToken" - | "accessTokenExpiresAt" - | "refreshTokenExpiresAt" - | "scope" - | "password" - | "createdAt" - | "updatedAt" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "verification"; - update: { - createdAt?: number; - expiresAt?: number; - identifier?: string; - updatedAt?: number; - value?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "identifier" - | "value" - | "expiresAt" - | "createdAt" - | "updatedAt" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "twoFactor"; - update: { - backupCodes?: string; - secret?: string; - userId?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: "secret" | "backupCodes" | "userId" | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "passkey"; - update: { - aaguid?: null | string; - backedUp?: boolean; - counter?: number; - createdAt?: null | number; - credentialID?: string; - deviceType?: string; - name?: null | string; - publicKey?: string; - transports?: null | string; - userId?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "name" - | "publicKey" - | "userId" - | "credentialID" - | "counter" - | "deviceType" - | "backedUp" - | "transports" - | "createdAt" - | "aaguid" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "oauthApplication"; - update: { - clientId?: null | string; - clientSecret?: null | string; - createdAt?: null | number; - disabled?: null | boolean; - icon?: null | string; - metadata?: null | string; - name?: null | string; - redirectURLs?: null | string; - type?: null | string; - updatedAt?: null | number; - userId?: null | string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "name" - | "icon" - | "metadata" - | "clientId" - | "clientSecret" - | "redirectURLs" - | "type" - | "disabled" - | "userId" - | "createdAt" - | "updatedAt" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "oauthAccessToken"; - update: { - accessToken?: null | string; - accessTokenExpiresAt?: null | number; - clientId?: null | string; - createdAt?: null | number; - refreshToken?: null | string; - refreshTokenExpiresAt?: null | number; - scopes?: null | string; - updatedAt?: null | number; - userId?: null | string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "accessToken" - | "refreshToken" - | "accessTokenExpiresAt" - | "refreshTokenExpiresAt" - | "clientId" - | "userId" - | "scopes" - | "createdAt" - | "updatedAt" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "oauthConsent"; - update: { - clientId?: null | string; - consentGiven?: null | boolean; - createdAt?: null | number; - scopes?: null | string; - updatedAt?: null | number; - userId?: null | string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "clientId" - | "userId" - | "scopes" - | "createdAt" - | "updatedAt" - | "consentGiven" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "jwks"; - update: { - createdAt?: number; - privateKey?: string; - publicKey?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: "publicKey" | "privateKey" | "createdAt" | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "rateLimit"; - update: { - count?: null | number; - key?: null | string; - lastRequest?: null | number; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: "key" | "count" | "lastRequest" | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "ratelimit"; - update: { count?: number; key?: string; lastRequest?: number }; - where?: Array<{ - connector?: "AND" | "OR"; - field: "key" | "count" | "lastRequest" | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - }; - onUpdateHandle?: string; - paginationOpts: { - cursor: string | null; - endCursor?: string | null; - id?: number; - maximumBytesRead?: number; - maximumRowsRead?: number; - numItems: number; - }; - }, - any - >; - updateOne: FunctionReference< - "mutation", - "internal", - { - input: - | { - model: "user"; - update: { - createdAt?: number; - displayUsername?: null | string; - email?: string; - emailVerified?: boolean; - image?: null | string; - isAnonymous?: null | boolean; - name?: string; - phoneNumber?: null | string; - phoneNumberVerified?: null | boolean; - twoFactorEnabled?: null | boolean; - updatedAt?: number; - userId?: null | string; - username?: null | string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "name" - | "email" - | "emailVerified" - | "image" - | "createdAt" - | "updatedAt" - | "twoFactorEnabled" - | "isAnonymous" - | "username" - | "displayUsername" - | "phoneNumber" - | "phoneNumberVerified" - | "userId" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "session"; - update: { - createdAt?: number; - expiresAt?: number; - ipAddress?: null | string; - token?: string; - updatedAt?: number; - userAgent?: null | string; - userId?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "expiresAt" - | "token" - | "createdAt" - | "updatedAt" - | "ipAddress" - | "userAgent" - | "userId" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "account"; - update: { - accessToken?: null | string; - accessTokenExpiresAt?: null | number; - accountId?: string; - createdAt?: number; - idToken?: null | string; - password?: null | string; - providerId?: string; - refreshToken?: null | string; - refreshTokenExpiresAt?: null | number; - scope?: null | string; - updatedAt?: number; - userId?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "accountId" - | "providerId" - | "userId" - | "accessToken" - | "refreshToken" - | "idToken" - | "accessTokenExpiresAt" - | "refreshTokenExpiresAt" - | "scope" - | "password" - | "createdAt" - | "updatedAt" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "verification"; - update: { - createdAt?: number; - expiresAt?: number; - identifier?: string; - updatedAt?: number; - value?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "identifier" - | "value" - | "expiresAt" - | "createdAt" - | "updatedAt" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "twoFactor"; - update: { - backupCodes?: string; - secret?: string; - userId?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: "secret" | "backupCodes" | "userId" | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "passkey"; - update: { - aaguid?: null | string; - backedUp?: boolean; - counter?: number; - createdAt?: null | number; - credentialID?: string; - deviceType?: string; - name?: null | string; - publicKey?: string; - transports?: null | string; - userId?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "name" - | "publicKey" - | "userId" - | "credentialID" - | "counter" - | "deviceType" - | "backedUp" - | "transports" - | "createdAt" - | "aaguid" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "oauthApplication"; - update: { - clientId?: null | string; - clientSecret?: null | string; - createdAt?: null | number; - disabled?: null | boolean; - icon?: null | string; - metadata?: null | string; - name?: null | string; - redirectURLs?: null | string; - type?: null | string; - updatedAt?: null | number; - userId?: null | string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "name" - | "icon" - | "metadata" - | "clientId" - | "clientSecret" - | "redirectURLs" - | "type" - | "disabled" - | "userId" - | "createdAt" - | "updatedAt" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "oauthAccessToken"; - update: { - accessToken?: null | string; - accessTokenExpiresAt?: null | number; - clientId?: null | string; - createdAt?: null | number; - refreshToken?: null | string; - refreshTokenExpiresAt?: null | number; - scopes?: null | string; - updatedAt?: null | number; - userId?: null | string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "accessToken" - | "refreshToken" - | "accessTokenExpiresAt" - | "refreshTokenExpiresAt" - | "clientId" - | "userId" - | "scopes" - | "createdAt" - | "updatedAt" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "oauthConsent"; - update: { - clientId?: null | string; - consentGiven?: null | boolean; - createdAt?: null | number; - scopes?: null | string; - updatedAt?: null | number; - userId?: null | string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "clientId" - | "userId" - | "scopes" - | "createdAt" - | "updatedAt" - | "consentGiven" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "jwks"; - update: { - createdAt?: number; - privateKey?: string; - publicKey?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: "publicKey" | "privateKey" | "createdAt" | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "rateLimit"; - update: { - count?: null | number; - key?: null | string; - lastRequest?: null | number; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: "key" | "count" | "lastRequest" | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "ratelimit"; - update: { count?: number; key?: string; lastRequest?: number }; - where?: Array<{ - connector?: "AND" | "OR"; - field: "key" | "count" | "lastRequest" | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - }; - onUpdateHandle?: string; - }, - any - >; - }; - adapterTest: { - count: FunctionReference<"query", "internal", any, any>; - create: FunctionReference<"mutation", "internal", any, any>; - delete: FunctionReference<"mutation", "internal", any, any>; - deleteMany: FunctionReference<"mutation", "internal", any, any>; - findMany: FunctionReference<"query", "internal", any, any>; - findOne: FunctionReference<"query", "internal", any, any>; - update: FunctionReference<"mutation", "internal", any, any>; - updateMany: FunctionReference<"mutation", "internal", any, any>; - }; - }; - resend: { - lib: { - cancelEmail: FunctionReference< - "mutation", - "internal", - { emailId: string }, - null - >; - cleanupAbandonedEmails: FunctionReference< - "mutation", - "internal", - { olderThan?: number }, - null - >; - cleanupOldEmails: FunctionReference< - "mutation", - "internal", - { olderThan?: number }, - null - >; - createManualEmail: FunctionReference< - "mutation", - "internal", - { - from: string; - headers?: Array<{ name: string; value: string }>; - replyTo?: Array; - subject: string; - to: string; - }, - string - >; - get: FunctionReference< - "query", - "internal", - { emailId: string }, - { - complained: boolean; - createdAt: number; - errorMessage?: string; - finalizedAt: number; - from: string; - headers?: Array<{ name: string; value: string }>; - html?: string; - opened: boolean; - replyTo: Array; - resendId?: string; - segment: number; - status: - | "waiting" - | "queued" - | "cancelled" - | "sent" - | "delivered" - | "delivery_delayed" - | "bounced" - | "failed"; - subject: string; - text?: string; - to: string; - } | null - >; - getStatus: FunctionReference< - "query", - "internal", - { emailId: string }, - { - complained: boolean; - errorMessage: string | null; - opened: boolean; - status: - | "waiting" - | "queued" - | "cancelled" - | "sent" - | "delivered" - | "delivery_delayed" - | "bounced" - | "failed"; - } | null - >; - handleEmailEvent: FunctionReference< - "mutation", - "internal", - { event: any }, - null - >; - sendEmail: FunctionReference< - "mutation", - "internal", - { - from: string; - headers?: Array<{ name: string; value: string }>; - html?: string; - options: { - apiKey: string; - initialBackoffMs: number; - onEmailEvent?: { fnHandle: string }; - retryAttempts: number; - testMode: boolean; - }; - replyTo?: Array; - subject: string; - text?: string; - to: string; - }, - string - >; - updateManualEmail: FunctionReference< - "mutation", - "internal", - { - emailId: string; - errorMessage?: string; - resendId?: string; - status: - | "waiting" - | "queued" - | "cancelled" - | "sent" - | "delivered" - | "delivery_delayed" - | "bounced" - | "failed"; - }, - null - >; - }; - }; + betterAuth: import("@convex-dev/better-auth/_generated/component.js").ComponentApi<"betterAuth">; + resend: import("@convex-dev/resend/_generated/component.js").ComponentApi<"resend">; }; diff --git a/examples/react/convex/_generated/server.d.ts b/examples/react/convex/_generated/server.d.ts index b5c68288..bec05e68 100644 --- a/examples/react/convex/_generated/server.d.ts +++ b/examples/react/convex/_generated/server.d.ts @@ -10,7 +10,6 @@ import { ActionBuilder, - AnyComponents, HttpActionBuilder, MutationBuilder, QueryBuilder, @@ -19,15 +18,9 @@ import { GenericQueryCtx, GenericDatabaseReader, GenericDatabaseWriter, - FunctionReference, } from "convex/server"; import type { DataModel } from "./dataModel.js"; -type GenericCtx = - | GenericActionCtx - | GenericMutationCtx - | GenericQueryCtx; - /** * Define a query in this Convex app's public API. * @@ -92,11 +85,12 @@ export declare const internalAction: ActionBuilder; /** * Define an HTTP action. * - * This function will be used to respond to HTTP requests received by a Convex - * deployment if the requests matches the path and method where this action - * is routed. Be sure to route your action in `convex/http.js`. + * The wrapped function will be used to respond to HTTP requests received + * by a Convex deployment if the requests matches the path and method where + * this action is routed. Be sure to route your httpAction in `convex/http.js`. * - * @param func - The function. It receives an {@link ActionCtx} as its first argument. + * @param func - The function. It receives an {@link ActionCtx} as its first argument + * and a Fetch API `Request` object as its second. * @returns The wrapped function. Import this function from `convex/http.js` and route it to hook it up. */ export declare const httpAction: HttpActionBuilder; diff --git a/examples/react/convex/_generated/server.js b/examples/react/convex/_generated/server.js index 4a21df4f..bf3d25ad 100644 --- a/examples/react/convex/_generated/server.js +++ b/examples/react/convex/_generated/server.js @@ -16,7 +16,6 @@ import { internalActionGeneric, internalMutationGeneric, internalQueryGeneric, - componentsGeneric, } from "convex/server"; /** @@ -81,10 +80,14 @@ export const action = actionGeneric; export const internalAction = internalActionGeneric; /** - * Define a Convex HTTP action. + * Define an HTTP action. * - * @param func - The function. It receives an {@link ActionCtx} as its first argument, and a `Request` object - * as its second. - * @returns The wrapped endpoint function. Route a URL path to this function in `convex/http.js`. + * The wrapped function will be used to respond to HTTP requests received + * by a Convex deployment if the requests matches the path and method where + * this action is routed. Be sure to route your httpAction in `convex/http.js`. + * + * @param func - The function. It receives an {@link ActionCtx} as its first argument + * and a Fetch API `Request` object as its second. + * @returns The wrapped function. Import this function from `convex/http.js` and route it to hook it up. */ export const httpAction = httpActionGeneric; diff --git a/examples/react/convex/auth.ts b/examples/react/convex/auth.ts index b31b9a64..f8164917 100644 --- a/examples/react/convex/auth.ts +++ b/examples/react/convex/auth.ts @@ -24,7 +24,7 @@ export const createAuth = ( { optionsOnly } = { optionsOnly: false } ) => { return betterAuth({ - //trustedOrigins: [siteUrl], + trustedOrigins: [siteUrl], logger: { disabled: optionsOnly, }, diff --git a/examples/react/convex/polyfills.ts b/examples/react/convex/polyfills.ts index 5be025c4..1aca57c1 100644 --- a/examples/react/convex/polyfills.ts +++ b/examples/react/convex/polyfills.ts @@ -5,12 +5,10 @@ if (typeof MessageChannel === "undefined") { onmessageerror: ((ev: MessageEvent) => void) | undefined; close() {} - // eslint-disable-next-line @typescript-eslint/no-unused-vars postMessage(_message: unknown, _transfer: Transferable[] = []) {} start() {} addEventListener() {} removeEventListener() {} - // eslint-disable-next-line @typescript-eslint/no-unused-vars dispatchEvent(_event: Event): boolean { return false; } diff --git a/examples/react/convex/tsconfig.json b/examples/react/convex/tsconfig.json index f44108b8..a5db6815 100644 --- a/examples/react/convex/tsconfig.json +++ b/examples/react/convex/tsconfig.json @@ -18,8 +18,7 @@ "module": "ESNext", "moduleResolution": "Bundler", "isolatedModules": true, - "noEmit": true, - "customConditions": ["@convex-dev/component-source"] + "noEmit": true }, "include": ["./**/*"], "exclude": ["./_generated"] diff --git a/examples/react/package-lock.json b/examples/react/package-lock.json index 326574fb..3971fee2 100644 --- a/examples/react/package-lock.json +++ b/examples/react/package-lock.json @@ -48,12 +48,14 @@ }, "../..": { "name": "@convex-dev/better-auth", - "version": "0.9.2", + "version": "0.9.7", "license": "Apache-2.0", "dependencies": { "common-tags": "^1.8.2", "convex-helpers": "^0.1.95", + "jose": "^6.1.0", "remeda": "^2.32.0", + "semver": "^7.7.3", "type-fest": "^4.39.1", "zod": "^3.24.4" }, @@ -69,19 +71,20 @@ "@types/semver": "^7.7.0", "chokidar-cli": "^3.0.0", "concurrently": "^9.2.0", + "convex": "1.29.0", "convex-test": "^0.0.33", "eslint": "^9.9.1", "globals": "^15.9.0", "next": "^15.1.8", + "npm-run-all2": "8.0.4", "prettier": "3.2.5", - "semver": "^7.7.2", "typescript": "5.8.3", "typescript-eslint": "^8.4.0", "vitest": "^3.2.2" }, "peerDependencies": { "better-auth": "1.3.27", - "convex": "^1.26.2", + "convex": "^1.28.2", "react": "^18.3.1 || ^19.0.0", "react-dom": "^18.3.1 || ^19.0.0" } @@ -7100,17 +7103,6 @@ "funding": { "url": "https://github.com/sponsors/sindresorhus" } - }, - "node_modules/zod": { - "version": "4.1.8", - "resolved": "https://registry.npmjs.org/zod/-/zod-4.1.8.tgz", - "integrity": "sha512-5R1P+WwQqmmMIEACyzSvo4JXHY5WiAFHRMg+zBZKgKS+Q1viRa0C1hmUKtHltoIFKtIdki3pRxkmpP74jnNYHQ==", - "license": "MIT", - "optional": true, - "peer": true, - "funding": { - "url": "https://github.com/sponsors/colinhacks" - } } } } diff --git a/examples/react/package.json b/examples/react/package.json index a5e12d2a..55a09880 100644 --- a/examples/react/package.json +++ b/examples/react/package.json @@ -4,11 +4,12 @@ "type": "module", "version": "0.0.0", "scripts": { - "dev": "npm-run-all --parallel dev:frontend dev:backend", + "dev": "run-p -r 'dev:*'", "dev:frontend": "vite", - "dev:backend": "convex dev --typecheck-components --live-component-sources", - "generate": "convex dev --once", - "logs": "convex logs", + "dev:backend": "npx convex dev --typecheck-components", + "dev:build": "chokidar '../../tsconfig*.json' '../../src/**/*.ts' -i '**/*.test.ts' -c 'npx convex codegen --component-dir ../../src/component && cd ../../ && npm run build' --initial", + "predev": "npm run dev:backend -- --until-success", + "logs": "npx convex logs", "lint": "tsc -p convex && eslint convex" }, "dependencies": { diff --git a/examples/react/src/SignIn.tsx b/examples/react/src/SignIn.tsx index 35d8f531..fc723798 100644 --- a/examples/react/src/SignIn.tsx +++ b/examples/react/src/SignIn.tsx @@ -35,7 +35,7 @@ export default function SignIn() { onRequest: () => { setOtpLoading(true); }, - onSuccess: (ctx) => { + onSuccess: (_ctx) => { setOtpLoading(false); }, onError: (ctx) => { @@ -177,9 +177,9 @@ export default function SignIn() { onSubmit={(e) => { e.preventDefault(); if (signInMethod === "password") { - handleSignIn(); + void handleSignIn(); } else if (otpSent) { - handleOtpSignIn(); + void handleOtpSignIn(); } }} className="grid gap-4" diff --git a/examples/react/tsconfig.json b/examples/react/tsconfig.json index 786b673d..c4fd7c9a 100644 --- a/examples/react/tsconfig.json +++ b/examples/react/tsconfig.json @@ -16,8 +16,7 @@ "baseUrl": ".", "paths": { "@/*": ["./src/*"] - }, - "customConditions": ["@convex-dev/component-source"] + } }, "include": ["./src", "vite.config.ts"] } diff --git a/examples/tanstack/.env.example b/examples/tanstack/.env.example new file mode 100644 index 00000000..2ec69549 --- /dev/null +++ b/examples/tanstack/.env.example @@ -0,0 +1,7 @@ +CONVEX_DEPLOYMENT=dev:adjective-animal-123 + +VITE_CONVEX_URL=https://adjective-animal-123.convex.cloud + +VITE_CONVEX_SITE_URL=https://adjective-animal-123.convex.site + +SITE_URL=http://localhost:3000 \ No newline at end of file diff --git a/examples/tanstack/convex.json b/examples/tanstack/convex.json new file mode 100644 index 00000000..465d5fc8 --- /dev/null +++ b/examples/tanstack/convex.json @@ -0,0 +1,6 @@ +{ + "$schema": "./node_modules/convex/schemas/convex.schema.json", + "codegen": { + "legacyComponentApi": false + } +} diff --git a/examples/tanstack/convex/_generated/api.d.ts b/examples/tanstack/convex/_generated/api.d.ts index fc617f06..4869f2a0 100644 --- a/examples/tanstack/convex/_generated/api.d.ts +++ b/examples/tanstack/convex/_generated/api.d.ts @@ -9,10 +9,6 @@ */ import type * as auth from "../auth.js"; -import type * as betterAuth__generated_api from "../betterAuth/_generated/api.js"; -import type * as betterAuth__generated_server from "../betterAuth/_generated/server.js"; -import type * as betterAuth_adapter from "../betterAuth/adapter.js"; -import type * as betterAuth_auth from "../betterAuth/auth.js"; import type * as email from "../email.js"; import type * as emails_components_BaseEmail from "../emails/components/BaseEmail.js"; import type * as emails_magicLink from "../emails/magicLink.js"; @@ -29,20 +25,8 @@ import type { FunctionReference, } from "convex/server"; -/** - * A utility for referencing Convex functions in your app's API. - * - * Usage: - * ```js - * const myFunctionReference = api.myModule.myFunction; - * ``` - */ declare const fullApi: ApiFromModules<{ auth: typeof auth; - "betterAuth/_generated/api": typeof betterAuth__generated_api; - "betterAuth/_generated/server": typeof betterAuth__generated_server; - "betterAuth/adapter": typeof betterAuth_adapter; - "betterAuth/auth": typeof betterAuth_auth; email: typeof email; "emails/components/BaseEmail": typeof emails_components_BaseEmail; "emails/magicLink": typeof emails_magicLink; @@ -53,1261 +37,35 @@ declare const fullApi: ApiFromModules<{ migrations: typeof migrations; todos: typeof todos; }>; -declare const fullApiWithMounts: typeof fullApi; +/** + * A utility for referencing Convex functions in your app's public API. + * + * Usage: + * ```js + * const myFunctionReference = api.myModule.myFunction; + * ``` + */ export declare const api: FilterApi< - typeof fullApiWithMounts, + typeof fullApi, FunctionReference >; + +/** + * A utility for referencing Convex functions in your app's internal API. + * + * Usage: + * ```js + * const myFunctionReference = internal.myModule.myFunction; + * ``` + */ export declare const internal: FilterApi< - typeof fullApiWithMounts, + typeof fullApi, FunctionReference >; export declare const components: { - betterAuth: { - adapter: { - create: FunctionReference< - "mutation", - "internal", - { - input: - | { - data: { - createdAt: number; - email: string; - emailVerified: boolean; - foo?: null | string; - image?: null | string; - isAnonymous?: null | boolean; - name: string; - twoFactorEnabled?: null | boolean; - updatedAt: number; - userId?: null | string; - }; - model: "user"; - } - | { - data: { - createdAt: number; - expiresAt: number; - ipAddress?: null | string; - token: string; - updatedAt: number; - userAgent?: null | string; - userId: string; - }; - model: "session"; - } - | { - data: { - accessToken?: null | string; - accessTokenExpiresAt?: null | number; - accountId: string; - createdAt: number; - idToken?: null | string; - password?: null | string; - providerId: string; - refreshToken?: null | string; - refreshTokenExpiresAt?: null | number; - scope?: null | string; - updatedAt: number; - userId: string; - }; - model: "account"; - } - | { - data: { - createdAt: number; - expiresAt: number; - identifier: string; - updatedAt: number; - value: string; - }; - model: "verification"; - } - | { - data: { backupCodes: string; secret: string; userId: string }; - model: "twoFactor"; - } - | { - data: { - createdAt: number; - privateKey: string; - publicKey: string; - }; - model: "jwks"; - }; - onCreateHandle?: string; - select?: Array; - }, - any - >; - deleteMany: FunctionReference< - "mutation", - "internal", - { - input: - | { - model: "user"; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "name" - | "email" - | "emailVerified" - | "image" - | "createdAt" - | "updatedAt" - | "twoFactorEnabled" - | "isAnonymous" - | "userId" - | "foo" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "session"; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "expiresAt" - | "token" - | "createdAt" - | "updatedAt" - | "ipAddress" - | "userAgent" - | "userId" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "account"; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "accountId" - | "providerId" - | "userId" - | "accessToken" - | "refreshToken" - | "idToken" - | "accessTokenExpiresAt" - | "refreshTokenExpiresAt" - | "scope" - | "password" - | "createdAt" - | "updatedAt" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "verification"; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "identifier" - | "value" - | "expiresAt" - | "createdAt" - | "updatedAt" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "twoFactor"; - where?: Array<{ - connector?: "AND" | "OR"; - field: "secret" | "backupCodes" | "userId" | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "jwks"; - where?: Array<{ - connector?: "AND" | "OR"; - field: "publicKey" | "privateKey" | "createdAt" | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - }; - onDeleteHandle?: string; - paginationOpts: { - cursor: string | null; - endCursor?: string | null; - id?: number; - maximumBytesRead?: number; - maximumRowsRead?: number; - numItems: number; - }; - }, - any - >; - deleteOne: FunctionReference< - "mutation", - "internal", - { - input: - | { - model: "user"; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "name" - | "email" - | "emailVerified" - | "image" - | "createdAt" - | "updatedAt" - | "twoFactorEnabled" - | "isAnonymous" - | "userId" - | "foo" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "session"; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "expiresAt" - | "token" - | "createdAt" - | "updatedAt" - | "ipAddress" - | "userAgent" - | "userId" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "account"; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "accountId" - | "providerId" - | "userId" - | "accessToken" - | "refreshToken" - | "idToken" - | "accessTokenExpiresAt" - | "refreshTokenExpiresAt" - | "scope" - | "password" - | "createdAt" - | "updatedAt" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "verification"; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "identifier" - | "value" - | "expiresAt" - | "createdAt" - | "updatedAt" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "twoFactor"; - where?: Array<{ - connector?: "AND" | "OR"; - field: "secret" | "backupCodes" | "userId" | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "jwks"; - where?: Array<{ - connector?: "AND" | "OR"; - field: "publicKey" | "privateKey" | "createdAt" | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - }; - onDeleteHandle?: string; - }, - any - >; - findMany: FunctionReference< - "query", - "internal", - { - limit?: number; - model: - | "user" - | "session" - | "account" - | "verification" - | "twoFactor" - | "jwks"; - offset?: number; - paginationOpts: { - cursor: string | null; - endCursor?: string | null; - id?: number; - maximumBytesRead?: number; - maximumRowsRead?: number; - numItems: number; - }; - sortBy?: { direction: "asc" | "desc"; field: string }; - where?: Array<{ - connector?: "AND" | "OR"; - field: string; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - }, - any - >; - findOne: FunctionReference< - "query", - "internal", - { - model: - | "user" - | "session" - | "account" - | "verification" - | "twoFactor" - | "jwks"; - select?: Array; - where?: Array<{ - connector?: "AND" | "OR"; - field: string; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - }, - any - >; - migrationRemoveUserId: FunctionReference< - "mutation", - "internal", - { userId: string }, - any - >; - updateMany: FunctionReference< - "mutation", - "internal", - { - input: - | { - model: "user"; - update: { - createdAt?: number; - email?: string; - emailVerified?: boolean; - foo?: null | string; - image?: null | string; - isAnonymous?: null | boolean; - name?: string; - twoFactorEnabled?: null | boolean; - updatedAt?: number; - userId?: null | string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "name" - | "email" - | "emailVerified" - | "image" - | "createdAt" - | "updatedAt" - | "twoFactorEnabled" - | "isAnonymous" - | "userId" - | "foo" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "session"; - update: { - createdAt?: number; - expiresAt?: number; - ipAddress?: null | string; - token?: string; - updatedAt?: number; - userAgent?: null | string; - userId?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "expiresAt" - | "token" - | "createdAt" - | "updatedAt" - | "ipAddress" - | "userAgent" - | "userId" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "account"; - update: { - accessToken?: null | string; - accessTokenExpiresAt?: null | number; - accountId?: string; - createdAt?: number; - idToken?: null | string; - password?: null | string; - providerId?: string; - refreshToken?: null | string; - refreshTokenExpiresAt?: null | number; - scope?: null | string; - updatedAt?: number; - userId?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "accountId" - | "providerId" - | "userId" - | "accessToken" - | "refreshToken" - | "idToken" - | "accessTokenExpiresAt" - | "refreshTokenExpiresAt" - | "scope" - | "password" - | "createdAt" - | "updatedAt" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "verification"; - update: { - createdAt?: number; - expiresAt?: number; - identifier?: string; - updatedAt?: number; - value?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "identifier" - | "value" - | "expiresAt" - | "createdAt" - | "updatedAt" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "twoFactor"; - update: { - backupCodes?: string; - secret?: string; - userId?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: "secret" | "backupCodes" | "userId" | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "jwks"; - update: { - createdAt?: number; - privateKey?: string; - publicKey?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: "publicKey" | "privateKey" | "createdAt" | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - }; - onUpdateHandle?: string; - paginationOpts: { - cursor: string | null; - endCursor?: string | null; - id?: number; - maximumBytesRead?: number; - maximumRowsRead?: number; - numItems: number; - }; - }, - any - >; - updateOne: FunctionReference< - "mutation", - "internal", - { - input: - | { - model: "user"; - update: { - createdAt?: number; - email?: string; - emailVerified?: boolean; - foo?: null | string; - image?: null | string; - isAnonymous?: null | boolean; - name?: string; - twoFactorEnabled?: null | boolean; - updatedAt?: number; - userId?: null | string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "name" - | "email" - | "emailVerified" - | "image" - | "createdAt" - | "updatedAt" - | "twoFactorEnabled" - | "isAnonymous" - | "userId" - | "foo" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "session"; - update: { - createdAt?: number; - expiresAt?: number; - ipAddress?: null | string; - token?: string; - updatedAt?: number; - userAgent?: null | string; - userId?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "expiresAt" - | "token" - | "createdAt" - | "updatedAt" - | "ipAddress" - | "userAgent" - | "userId" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "account"; - update: { - accessToken?: null | string; - accessTokenExpiresAt?: null | number; - accountId?: string; - createdAt?: number; - idToken?: null | string; - password?: null | string; - providerId?: string; - refreshToken?: null | string; - refreshTokenExpiresAt?: null | number; - scope?: null | string; - updatedAt?: number; - userId?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "accountId" - | "providerId" - | "userId" - | "accessToken" - | "refreshToken" - | "idToken" - | "accessTokenExpiresAt" - | "refreshTokenExpiresAt" - | "scope" - | "password" - | "createdAt" - | "updatedAt" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "verification"; - update: { - createdAt?: number; - expiresAt?: number; - identifier?: string; - updatedAt?: number; - value?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "identifier" - | "value" - | "expiresAt" - | "createdAt" - | "updatedAt" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "twoFactor"; - update: { - backupCodes?: string; - secret?: string; - userId?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: "secret" | "backupCodes" | "userId" | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "jwks"; - update: { - createdAt?: number; - privateKey?: string; - publicKey?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: "publicKey" | "privateKey" | "createdAt" | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - }; - onUpdateHandle?: string; - }, - any - >; - }; - }; - resend: { - lib: { - cancelEmail: FunctionReference< - "mutation", - "internal", - { emailId: string }, - null - >; - get: FunctionReference<"query", "internal", { emailId: string }, any>; - getStatus: FunctionReference< - "query", - "internal", - { emailId: string }, - { - complained: boolean; - errorMessage: string | null; - opened: boolean; - status: - | "waiting" - | "queued" - | "cancelled" - | "sent" - | "delivered" - | "delivery_delayed" - | "bounced"; - } - >; - handleEmailEvent: FunctionReference< - "mutation", - "internal", - { event: any }, - null - >; - sendEmail: FunctionReference< - "mutation", - "internal", - { - from: string; - headers?: Array<{ name: string; value: string }>; - html?: string; - options: { - apiKey: string; - initialBackoffMs: number; - onEmailEvent?: { fnHandle: string }; - retryAttempts: number; - testMode: boolean; - }; - replyTo?: Array; - subject: string; - text?: string; - to: string; - }, - string - >; - }; - }; - migrations: { - lib: { - cancel: FunctionReference< - "mutation", - "internal", - { name: string }, - { - batchSize?: number; - cursor?: string | null; - error?: string; - isDone: boolean; - latestEnd?: number; - latestStart: number; - name: string; - next?: Array; - processed: number; - state: "inProgress" | "success" | "failed" | "canceled" | "unknown"; - } - >; - cancelAll: FunctionReference< - "mutation", - "internal", - { sinceTs?: number }, - Array<{ - batchSize?: number; - cursor?: string | null; - error?: string; - isDone: boolean; - latestEnd?: number; - latestStart: number; - name: string; - next?: Array; - processed: number; - state: "inProgress" | "success" | "failed" | "canceled" | "unknown"; - }> - >; - clearAll: FunctionReference< - "mutation", - "internal", - { before?: number }, - null - >; - getStatus: FunctionReference< - "query", - "internal", - { limit?: number; names?: Array }, - Array<{ - batchSize?: number; - cursor?: string | null; - error?: string; - isDone: boolean; - latestEnd?: number; - latestStart: number; - name: string; - next?: Array; - processed: number; - state: "inProgress" | "success" | "failed" | "canceled" | "unknown"; - }> - >; - migrate: FunctionReference< - "mutation", - "internal", - { - batchSize?: number; - cursor?: string | null; - dryRun: boolean; - fnHandle: string; - name: string; - next?: Array<{ fnHandle: string; name: string }>; - }, - { - batchSize?: number; - cursor?: string | null; - error?: string; - isDone: boolean; - latestEnd?: number; - latestStart: number; - name: string; - next?: Array; - processed: number; - state: "inProgress" | "success" | "failed" | "canceled" | "unknown"; - } - >; - }; - }; + betterAuth: import("./betterAuth/_generated/component.js").ComponentApi<"betterAuth">; + resend: import("@convex-dev/resend/_generated/component.js").ComponentApi<"resend">; + migrations: import("@convex-dev/migrations/_generated/component.js").ComponentApi<"migrations">; }; diff --git a/examples/tanstack/convex/_generated/server.d.ts b/examples/tanstack/convex/_generated/server.d.ts index b5c68288..bec05e68 100644 --- a/examples/tanstack/convex/_generated/server.d.ts +++ b/examples/tanstack/convex/_generated/server.d.ts @@ -10,7 +10,6 @@ import { ActionBuilder, - AnyComponents, HttpActionBuilder, MutationBuilder, QueryBuilder, @@ -19,15 +18,9 @@ import { GenericQueryCtx, GenericDatabaseReader, GenericDatabaseWriter, - FunctionReference, } from "convex/server"; import type { DataModel } from "./dataModel.js"; -type GenericCtx = - | GenericActionCtx - | GenericMutationCtx - | GenericQueryCtx; - /** * Define a query in this Convex app's public API. * @@ -92,11 +85,12 @@ export declare const internalAction: ActionBuilder; /** * Define an HTTP action. * - * This function will be used to respond to HTTP requests received by a Convex - * deployment if the requests matches the path and method where this action - * is routed. Be sure to route your action in `convex/http.js`. + * The wrapped function will be used to respond to HTTP requests received + * by a Convex deployment if the requests matches the path and method where + * this action is routed. Be sure to route your httpAction in `convex/http.js`. * - * @param func - The function. It receives an {@link ActionCtx} as its first argument. + * @param func - The function. It receives an {@link ActionCtx} as its first argument + * and a Fetch API `Request` object as its second. * @returns The wrapped function. Import this function from `convex/http.js` and route it to hook it up. */ export declare const httpAction: HttpActionBuilder; diff --git a/examples/tanstack/convex/_generated/server.js b/examples/tanstack/convex/_generated/server.js index 4a21df4f..bf3d25ad 100644 --- a/examples/tanstack/convex/_generated/server.js +++ b/examples/tanstack/convex/_generated/server.js @@ -16,7 +16,6 @@ import { internalActionGeneric, internalMutationGeneric, internalQueryGeneric, - componentsGeneric, } from "convex/server"; /** @@ -81,10 +80,14 @@ export const action = actionGeneric; export const internalAction = internalActionGeneric; /** - * Define a Convex HTTP action. + * Define an HTTP action. * - * @param func - The function. It receives an {@link ActionCtx} as its first argument, and a `Request` object - * as its second. - * @returns The wrapped endpoint function. Route a URL path to this function in `convex/http.js`. + * The wrapped function will be used to respond to HTTP requests received + * by a Convex deployment if the requests matches the path and method where + * this action is routed. Be sure to route your httpAction in `convex/http.js`. + * + * @param func - The function. It receives an {@link ActionCtx} as its first argument + * and a Fetch API `Request` object as its second. + * @returns The wrapped function. Import this function from `convex/http.js` and route it to hook it up. */ export const httpAction = httpActionGeneric; diff --git a/examples/tanstack/convex/betterAuth/_generated/api.d.ts b/examples/tanstack/convex/betterAuth/_generated/api.d.ts deleted file mode 100644 index d8f89f45..00000000 --- a/examples/tanstack/convex/betterAuth/_generated/api.d.ts +++ /dev/null @@ -1,1150 +0,0 @@ -/* eslint-disable */ -/** - * Generated `api` utility. - * - * THIS CODE IS AUTOMATICALLY GENERATED. - * - * To regenerate, run `npx convex dev`. - * @module - */ - -import type * as adapter from "../adapter.js"; -import type * as auth from "../auth.js"; - -import type { - ApiFromModules, - FilterApi, - FunctionReference, -} from "convex/server"; - -/** - * A utility for referencing Convex functions in your app's API. - * - * Usage: - * ```js - * const myFunctionReference = api.myModule.myFunction; - * ``` - */ -declare const fullApi: ApiFromModules<{ - adapter: typeof adapter; - auth: typeof auth; -}>; -export type Mounts = { - adapter: { - create: FunctionReference< - "mutation", - "public", - { - input: - | { - data: { - createdAt: number; - email: string; - emailVerified: boolean; - foo?: null | string; - image?: null | string; - isAnonymous?: null | boolean; - name: string; - twoFactorEnabled?: null | boolean; - updatedAt: number; - userId?: null | string; - }; - model: "user"; - } - | { - data: { - createdAt: number; - expiresAt: number; - ipAddress?: null | string; - token: string; - updatedAt: number; - userAgent?: null | string; - userId: string; - }; - model: "session"; - } - | { - data: { - accessToken?: null | string; - accessTokenExpiresAt?: null | number; - accountId: string; - createdAt: number; - idToken?: null | string; - password?: null | string; - providerId: string; - refreshToken?: null | string; - refreshTokenExpiresAt?: null | number; - scope?: null | string; - updatedAt: number; - userId: string; - }; - model: "account"; - } - | { - data: { - createdAt: number; - expiresAt: number; - identifier: string; - updatedAt: number; - value: string; - }; - model: "verification"; - } - | { - data: { backupCodes: string; secret: string; userId: string }; - model: "twoFactor"; - } - | { - data: { - createdAt: number; - privateKey: string; - publicKey: string; - }; - model: "jwks"; - }; - onCreateHandle?: string; - select?: Array; - }, - any - >; - deleteMany: FunctionReference< - "mutation", - "public", - { - input: - | { - model: "user"; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "name" - | "email" - | "emailVerified" - | "image" - | "createdAt" - | "updatedAt" - | "twoFactorEnabled" - | "isAnonymous" - | "userId" - | "foo" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "session"; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "expiresAt" - | "token" - | "createdAt" - | "updatedAt" - | "ipAddress" - | "userAgent" - | "userId" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "account"; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "accountId" - | "providerId" - | "userId" - | "accessToken" - | "refreshToken" - | "idToken" - | "accessTokenExpiresAt" - | "refreshTokenExpiresAt" - | "scope" - | "password" - | "createdAt" - | "updatedAt" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "verification"; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "identifier" - | "value" - | "expiresAt" - | "createdAt" - | "updatedAt" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "twoFactor"; - where?: Array<{ - connector?: "AND" | "OR"; - field: "secret" | "backupCodes" | "userId" | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "jwks"; - where?: Array<{ - connector?: "AND" | "OR"; - field: "publicKey" | "privateKey" | "createdAt" | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - }; - onDeleteHandle?: string; - paginationOpts: { - cursor: string | null; - endCursor?: string | null; - id?: number; - maximumBytesRead?: number; - maximumRowsRead?: number; - numItems: number; - }; - }, - any - >; - deleteOne: FunctionReference< - "mutation", - "public", - { - input: - | { - model: "user"; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "name" - | "email" - | "emailVerified" - | "image" - | "createdAt" - | "updatedAt" - | "twoFactorEnabled" - | "isAnonymous" - | "userId" - | "foo" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "session"; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "expiresAt" - | "token" - | "createdAt" - | "updatedAt" - | "ipAddress" - | "userAgent" - | "userId" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "account"; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "accountId" - | "providerId" - | "userId" - | "accessToken" - | "refreshToken" - | "idToken" - | "accessTokenExpiresAt" - | "refreshTokenExpiresAt" - | "scope" - | "password" - | "createdAt" - | "updatedAt" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "verification"; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "identifier" - | "value" - | "expiresAt" - | "createdAt" - | "updatedAt" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "twoFactor"; - where?: Array<{ - connector?: "AND" | "OR"; - field: "secret" | "backupCodes" | "userId" | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "jwks"; - where?: Array<{ - connector?: "AND" | "OR"; - field: "publicKey" | "privateKey" | "createdAt" | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - }; - onDeleteHandle?: string; - }, - any - >; - findMany: FunctionReference< - "query", - "public", - { - limit?: number; - model: - | "user" - | "session" - | "account" - | "verification" - | "twoFactor" - | "jwks"; - offset?: number; - paginationOpts: { - cursor: string | null; - endCursor?: string | null; - id?: number; - maximumBytesRead?: number; - maximumRowsRead?: number; - numItems: number; - }; - sortBy?: { direction: "asc" | "desc"; field: string }; - where?: Array<{ - connector?: "AND" | "OR"; - field: string; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - }, - any - >; - findOne: FunctionReference< - "query", - "public", - { - model: - | "user" - | "session" - | "account" - | "verification" - | "twoFactor" - | "jwks"; - select?: Array; - where?: Array<{ - connector?: "AND" | "OR"; - field: string; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - }, - any - >; - migrationRemoveUserId: FunctionReference< - "mutation", - "public", - { userId: string }, - any - >; - updateMany: FunctionReference< - "mutation", - "public", - { - input: - | { - model: "user"; - update: { - createdAt?: number; - email?: string; - emailVerified?: boolean; - foo?: null | string; - image?: null | string; - isAnonymous?: null | boolean; - name?: string; - twoFactorEnabled?: null | boolean; - updatedAt?: number; - userId?: null | string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "name" - | "email" - | "emailVerified" - | "image" - | "createdAt" - | "updatedAt" - | "twoFactorEnabled" - | "isAnonymous" - | "userId" - | "foo" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "session"; - update: { - createdAt?: number; - expiresAt?: number; - ipAddress?: null | string; - token?: string; - updatedAt?: number; - userAgent?: null | string; - userId?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "expiresAt" - | "token" - | "createdAt" - | "updatedAt" - | "ipAddress" - | "userAgent" - | "userId" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "account"; - update: { - accessToken?: null | string; - accessTokenExpiresAt?: null | number; - accountId?: string; - createdAt?: number; - idToken?: null | string; - password?: null | string; - providerId?: string; - refreshToken?: null | string; - refreshTokenExpiresAt?: null | number; - scope?: null | string; - updatedAt?: number; - userId?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "accountId" - | "providerId" - | "userId" - | "accessToken" - | "refreshToken" - | "idToken" - | "accessTokenExpiresAt" - | "refreshTokenExpiresAt" - | "scope" - | "password" - | "createdAt" - | "updatedAt" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "verification"; - update: { - createdAt?: number; - expiresAt?: number; - identifier?: string; - updatedAt?: number; - value?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "identifier" - | "value" - | "expiresAt" - | "createdAt" - | "updatedAt" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "twoFactor"; - update: { - backupCodes?: string; - secret?: string; - userId?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: "secret" | "backupCodes" | "userId" | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "jwks"; - update: { - createdAt?: number; - privateKey?: string; - publicKey?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: "publicKey" | "privateKey" | "createdAt" | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - }; - onUpdateHandle?: string; - paginationOpts: { - cursor: string | null; - endCursor?: string | null; - id?: number; - maximumBytesRead?: number; - maximumRowsRead?: number; - numItems: number; - }; - }, - any - >; - updateOne: FunctionReference< - "mutation", - "public", - { - input: - | { - model: "user"; - update: { - createdAt?: number; - email?: string; - emailVerified?: boolean; - foo?: null | string; - image?: null | string; - isAnonymous?: null | boolean; - name?: string; - twoFactorEnabled?: null | boolean; - updatedAt?: number; - userId?: null | string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "name" - | "email" - | "emailVerified" - | "image" - | "createdAt" - | "updatedAt" - | "twoFactorEnabled" - | "isAnonymous" - | "userId" - | "foo" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "session"; - update: { - createdAt?: number; - expiresAt?: number; - ipAddress?: null | string; - token?: string; - updatedAt?: number; - userAgent?: null | string; - userId?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "expiresAt" - | "token" - | "createdAt" - | "updatedAt" - | "ipAddress" - | "userAgent" - | "userId" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "account"; - update: { - accessToken?: null | string; - accessTokenExpiresAt?: null | number; - accountId?: string; - createdAt?: number; - idToken?: null | string; - password?: null | string; - providerId?: string; - refreshToken?: null | string; - refreshTokenExpiresAt?: null | number; - scope?: null | string; - updatedAt?: number; - userId?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "accountId" - | "providerId" - | "userId" - | "accessToken" - | "refreshToken" - | "idToken" - | "accessTokenExpiresAt" - | "refreshTokenExpiresAt" - | "scope" - | "password" - | "createdAt" - | "updatedAt" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "verification"; - update: { - createdAt?: number; - expiresAt?: number; - identifier?: string; - updatedAt?: number; - value?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: - | "identifier" - | "value" - | "expiresAt" - | "createdAt" - | "updatedAt" - | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "twoFactor"; - update: { - backupCodes?: string; - secret?: string; - userId?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: "secret" | "backupCodes" | "userId" | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - } - | { - model: "jwks"; - update: { - createdAt?: number; - privateKey?: string; - publicKey?: string; - }; - where?: Array<{ - connector?: "AND" | "OR"; - field: "publicKey" | "privateKey" | "createdAt" | "_id"; - operator?: - | "lt" - | "lte" - | "gt" - | "gte" - | "eq" - | "in" - | "not_in" - | "ne" - | "contains" - | "starts_with" - | "ends_with"; - value: - | string - | number - | boolean - | Array - | Array - | null; - }>; - }; - onUpdateHandle?: string; - }, - any - >; - }; -}; -// For now fullApiWithMounts is only fullApi which provides -// jump-to-definition in component client code. -// Use Mounts for the same type without the inference. -declare const fullApiWithMounts: typeof fullApi; - -export declare const api: FilterApi< - typeof fullApiWithMounts, - FunctionReference ->; -export declare const internal: FilterApi< - typeof fullApiWithMounts, - FunctionReference ->; - -export declare const components: {}; diff --git a/examples/tanstack/convex/betterAuth/_generated/api.js b/examples/tanstack/convex/betterAuth/_generated/api.js deleted file mode 100644 index 44bf9858..00000000 --- a/examples/tanstack/convex/betterAuth/_generated/api.js +++ /dev/null @@ -1,23 +0,0 @@ -/* eslint-disable */ -/** - * Generated `api` utility. - * - * THIS CODE IS AUTOMATICALLY GENERATED. - * - * To regenerate, run `npx convex dev`. - * @module - */ - -import { anyApi, componentsGeneric } from "convex/server"; - -/** - * A utility for referencing Convex functions in your app's API. - * - * Usage: - * ```js - * const myFunctionReference = api.myModule.myFunction; - * ``` - */ -export const api = anyApi; -export const internal = anyApi; -export const components = componentsGeneric(); diff --git a/examples/tanstack/convex/betterAuth/_generated/api.ts b/examples/tanstack/convex/betterAuth/_generated/api.ts new file mode 100644 index 00000000..52fad396 --- /dev/null +++ b/examples/tanstack/convex/betterAuth/_generated/api.ts @@ -0,0 +1,52 @@ +/* eslint-disable */ +/** + * Generated `api` utility. + * + * THIS CODE IS AUTOMATICALLY GENERATED. + * + * To regenerate, run `npx convex dev`. + * @module + */ + +import type * as adapter from "../adapter.js"; +import type * as auth from "../auth.js"; + +import type { + ApiFromModules, + FilterApi, + FunctionReference, +} from "convex/server"; +import { anyApi, componentsGeneric } from "convex/server"; + +const fullApi: ApiFromModules<{ + adapter: typeof adapter; + auth: typeof auth; +}> = anyApi as any; + +/** + * A utility for referencing Convex functions in your app's public API. + * + * Usage: + * ```js + * const myFunctionReference = api.myModule.myFunction; + * ``` + */ +export const api: FilterApi< + typeof fullApi, + FunctionReference +> = anyApi as any; + +/** + * A utility for referencing Convex functions in your app's internal API. + * + * Usage: + * ```js + * const myFunctionReference = internal.myModule.myFunction; + * ``` + */ +export const internal: FilterApi< + typeof fullApi, + FunctionReference +> = anyApi as any; + +export const components = componentsGeneric() as unknown as {}; diff --git a/examples/tanstack/convex/betterAuth/_generated/component.ts b/examples/tanstack/convex/betterAuth/_generated/component.ts new file mode 100644 index 00000000..32e9d81a --- /dev/null +++ b/examples/tanstack/convex/betterAuth/_generated/component.ts @@ -0,0 +1,1136 @@ +/* eslint-disable */ +/** + * Generated `ComponentApi` utility. + * + * THIS CODE IS AUTOMATICALLY GENERATED. + * + * To regenerate, run `npx convex dev`. + * @module + */ + +import type { FunctionReference } from "convex/server"; + +/** + * A utility for referencing a Convex component's exposed API. + * + * Useful when expecting a parameter like `components.myComponent`. + * Usage: + * ```ts + * async function myFunction(ctx: QueryCtx, component: ComponentApi) { + * return ctx.runQuery(component.someFile.someQuery, { ...args }); + * } + * ``` + */ +export type ComponentApi = + { + adapter: { + create: FunctionReference< + "mutation", + "internal", + { + input: + | { + data: { + createdAt: number; + email: string; + emailVerified: boolean; + foo?: null | string; + image?: null | string; + isAnonymous?: null | boolean; + name: string; + twoFactorEnabled?: null | boolean; + updatedAt: number; + userId?: null | string; + }; + model: "user"; + } + | { + data: { + createdAt: number; + expiresAt: number; + ipAddress?: null | string; + token: string; + updatedAt: number; + userAgent?: null | string; + userId: string; + }; + model: "session"; + } + | { + data: { + accessToken?: null | string; + accessTokenExpiresAt?: null | number; + accountId: string; + createdAt: number; + idToken?: null | string; + password?: null | string; + providerId: string; + refreshToken?: null | string; + refreshTokenExpiresAt?: null | number; + scope?: null | string; + updatedAt: number; + userId: string; + }; + model: "account"; + } + | { + data: { + createdAt: number; + expiresAt: number; + identifier: string; + updatedAt: number; + value: string; + }; + model: "verification"; + } + | { + data: { backupCodes: string; secret: string; userId: string }; + model: "twoFactor"; + } + | { + data: { + createdAt: number; + privateKey: string; + publicKey: string; + }; + model: "jwks"; + }; + onCreateHandle?: string; + select?: Array; + }, + any, + Name + >; + deleteMany: FunctionReference< + "mutation", + "internal", + { + input: + | { + model: "user"; + where?: Array<{ + connector?: "AND" | "OR"; + field: + | "name" + | "email" + | "emailVerified" + | "image" + | "createdAt" + | "updatedAt" + | "twoFactorEnabled" + | "isAnonymous" + | "userId" + | "foo" + | "_id"; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + } + | { + model: "session"; + where?: Array<{ + connector?: "AND" | "OR"; + field: + | "expiresAt" + | "token" + | "createdAt" + | "updatedAt" + | "ipAddress" + | "userAgent" + | "userId" + | "_id"; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + } + | { + model: "account"; + where?: Array<{ + connector?: "AND" | "OR"; + field: + | "accountId" + | "providerId" + | "userId" + | "accessToken" + | "refreshToken" + | "idToken" + | "accessTokenExpiresAt" + | "refreshTokenExpiresAt" + | "scope" + | "password" + | "createdAt" + | "updatedAt" + | "_id"; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + } + | { + model: "verification"; + where?: Array<{ + connector?: "AND" | "OR"; + field: + | "identifier" + | "value" + | "expiresAt" + | "createdAt" + | "updatedAt" + | "_id"; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + } + | { + model: "twoFactor"; + where?: Array<{ + connector?: "AND" | "OR"; + field: "secret" | "backupCodes" | "userId" | "_id"; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + } + | { + model: "jwks"; + where?: Array<{ + connector?: "AND" | "OR"; + field: "publicKey" | "privateKey" | "createdAt" | "_id"; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + }; + onDeleteHandle?: string; + paginationOpts: { + cursor: string | null; + endCursor?: string | null; + id?: number; + maximumBytesRead?: number; + maximumRowsRead?: number; + numItems: number; + }; + }, + any, + Name + >; + deleteOne: FunctionReference< + "mutation", + "internal", + { + input: + | { + model: "user"; + where?: Array<{ + connector?: "AND" | "OR"; + field: + | "name" + | "email" + | "emailVerified" + | "image" + | "createdAt" + | "updatedAt" + | "twoFactorEnabled" + | "isAnonymous" + | "userId" + | "foo" + | "_id"; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + } + | { + model: "session"; + where?: Array<{ + connector?: "AND" | "OR"; + field: + | "expiresAt" + | "token" + | "createdAt" + | "updatedAt" + | "ipAddress" + | "userAgent" + | "userId" + | "_id"; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + } + | { + model: "account"; + where?: Array<{ + connector?: "AND" | "OR"; + field: + | "accountId" + | "providerId" + | "userId" + | "accessToken" + | "refreshToken" + | "idToken" + | "accessTokenExpiresAt" + | "refreshTokenExpiresAt" + | "scope" + | "password" + | "createdAt" + | "updatedAt" + | "_id"; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + } + | { + model: "verification"; + where?: Array<{ + connector?: "AND" | "OR"; + field: + | "identifier" + | "value" + | "expiresAt" + | "createdAt" + | "updatedAt" + | "_id"; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + } + | { + model: "twoFactor"; + where?: Array<{ + connector?: "AND" | "OR"; + field: "secret" | "backupCodes" | "userId" | "_id"; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + } + | { + model: "jwks"; + where?: Array<{ + connector?: "AND" | "OR"; + field: "publicKey" | "privateKey" | "createdAt" | "_id"; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + }; + onDeleteHandle?: string; + }, + any, + Name + >; + findMany: FunctionReference< + "query", + "internal", + { + limit?: number; + model: + | "user" + | "session" + | "account" + | "verification" + | "twoFactor" + | "jwks"; + offset?: number; + paginationOpts: { + cursor: string | null; + endCursor?: string | null; + id?: number; + maximumBytesRead?: number; + maximumRowsRead?: number; + numItems: number; + }; + sortBy?: { direction: "asc" | "desc"; field: string }; + where?: Array<{ + connector?: "AND" | "OR"; + field: string; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + }, + any, + Name + >; + findOne: FunctionReference< + "query", + "internal", + { + model: + | "user" + | "session" + | "account" + | "verification" + | "twoFactor" + | "jwks"; + select?: Array; + where?: Array<{ + connector?: "AND" | "OR"; + field: string; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + }, + any, + Name + >; + migrationRemoveUserId: FunctionReference< + "mutation", + "internal", + { userId: string }, + any, + Name + >; + updateMany: FunctionReference< + "mutation", + "internal", + { + input: + | { + model: "user"; + update: { + createdAt?: number; + email?: string; + emailVerified?: boolean; + foo?: null | string; + image?: null | string; + isAnonymous?: null | boolean; + name?: string; + twoFactorEnabled?: null | boolean; + updatedAt?: number; + userId?: null | string; + }; + where?: Array<{ + connector?: "AND" | "OR"; + field: + | "name" + | "email" + | "emailVerified" + | "image" + | "createdAt" + | "updatedAt" + | "twoFactorEnabled" + | "isAnonymous" + | "userId" + | "foo" + | "_id"; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + } + | { + model: "session"; + update: { + createdAt?: number; + expiresAt?: number; + ipAddress?: null | string; + token?: string; + updatedAt?: number; + userAgent?: null | string; + userId?: string; + }; + where?: Array<{ + connector?: "AND" | "OR"; + field: + | "expiresAt" + | "token" + | "createdAt" + | "updatedAt" + | "ipAddress" + | "userAgent" + | "userId" + | "_id"; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + } + | { + model: "account"; + update: { + accessToken?: null | string; + accessTokenExpiresAt?: null | number; + accountId?: string; + createdAt?: number; + idToken?: null | string; + password?: null | string; + providerId?: string; + refreshToken?: null | string; + refreshTokenExpiresAt?: null | number; + scope?: null | string; + updatedAt?: number; + userId?: string; + }; + where?: Array<{ + connector?: "AND" | "OR"; + field: + | "accountId" + | "providerId" + | "userId" + | "accessToken" + | "refreshToken" + | "idToken" + | "accessTokenExpiresAt" + | "refreshTokenExpiresAt" + | "scope" + | "password" + | "createdAt" + | "updatedAt" + | "_id"; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + } + | { + model: "verification"; + update: { + createdAt?: number; + expiresAt?: number; + identifier?: string; + updatedAt?: number; + value?: string; + }; + where?: Array<{ + connector?: "AND" | "OR"; + field: + | "identifier" + | "value" + | "expiresAt" + | "createdAt" + | "updatedAt" + | "_id"; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + } + | { + model: "twoFactor"; + update: { + backupCodes?: string; + secret?: string; + userId?: string; + }; + where?: Array<{ + connector?: "AND" | "OR"; + field: "secret" | "backupCodes" | "userId" | "_id"; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + } + | { + model: "jwks"; + update: { + createdAt?: number; + privateKey?: string; + publicKey?: string; + }; + where?: Array<{ + connector?: "AND" | "OR"; + field: "publicKey" | "privateKey" | "createdAt" | "_id"; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + }; + onUpdateHandle?: string; + paginationOpts: { + cursor: string | null; + endCursor?: string | null; + id?: number; + maximumBytesRead?: number; + maximumRowsRead?: number; + numItems: number; + }; + }, + any, + Name + >; + updateOne: FunctionReference< + "mutation", + "internal", + { + input: + | { + model: "user"; + update: { + createdAt?: number; + email?: string; + emailVerified?: boolean; + foo?: null | string; + image?: null | string; + isAnonymous?: null | boolean; + name?: string; + twoFactorEnabled?: null | boolean; + updatedAt?: number; + userId?: null | string; + }; + where?: Array<{ + connector?: "AND" | "OR"; + field: + | "name" + | "email" + | "emailVerified" + | "image" + | "createdAt" + | "updatedAt" + | "twoFactorEnabled" + | "isAnonymous" + | "userId" + | "foo" + | "_id"; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + } + | { + model: "session"; + update: { + createdAt?: number; + expiresAt?: number; + ipAddress?: null | string; + token?: string; + updatedAt?: number; + userAgent?: null | string; + userId?: string; + }; + where?: Array<{ + connector?: "AND" | "OR"; + field: + | "expiresAt" + | "token" + | "createdAt" + | "updatedAt" + | "ipAddress" + | "userAgent" + | "userId" + | "_id"; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + } + | { + model: "account"; + update: { + accessToken?: null | string; + accessTokenExpiresAt?: null | number; + accountId?: string; + createdAt?: number; + idToken?: null | string; + password?: null | string; + providerId?: string; + refreshToken?: null | string; + refreshTokenExpiresAt?: null | number; + scope?: null | string; + updatedAt?: number; + userId?: string; + }; + where?: Array<{ + connector?: "AND" | "OR"; + field: + | "accountId" + | "providerId" + | "userId" + | "accessToken" + | "refreshToken" + | "idToken" + | "accessTokenExpiresAt" + | "refreshTokenExpiresAt" + | "scope" + | "password" + | "createdAt" + | "updatedAt" + | "_id"; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + } + | { + model: "verification"; + update: { + createdAt?: number; + expiresAt?: number; + identifier?: string; + updatedAt?: number; + value?: string; + }; + where?: Array<{ + connector?: "AND" | "OR"; + field: + | "identifier" + | "value" + | "expiresAt" + | "createdAt" + | "updatedAt" + | "_id"; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + } + | { + model: "twoFactor"; + update: { + backupCodes?: string; + secret?: string; + userId?: string; + }; + where?: Array<{ + connector?: "AND" | "OR"; + field: "secret" | "backupCodes" | "userId" | "_id"; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + } + | { + model: "jwks"; + update: { + createdAt?: number; + privateKey?: string; + publicKey?: string; + }; + where?: Array<{ + connector?: "AND" | "OR"; + field: "publicKey" | "privateKey" | "createdAt" | "_id"; + operator?: + | "lt" + | "lte" + | "gt" + | "gte" + | "eq" + | "in" + | "not_in" + | "ne" + | "contains" + | "starts_with" + | "ends_with"; + value: + | string + | number + | boolean + | Array + | Array + | null; + }>; + }; + onUpdateHandle?: string; + }, + any, + Name + >; + }; + }; diff --git a/examples/tanstack/convex/betterAuth/_generated/dataModel.d.ts b/examples/tanstack/convex/betterAuth/_generated/dataModel.ts similarity index 100% rename from examples/tanstack/convex/betterAuth/_generated/dataModel.d.ts rename to examples/tanstack/convex/betterAuth/_generated/dataModel.ts diff --git a/examples/tanstack/convex/betterAuth/_generated/server.js b/examples/tanstack/convex/betterAuth/_generated/server.js deleted file mode 100644 index 4a21df4f..00000000 --- a/examples/tanstack/convex/betterAuth/_generated/server.js +++ /dev/null @@ -1,90 +0,0 @@ -/* eslint-disable */ -/** - * Generated utilities for implementing server-side Convex query and mutation functions. - * - * THIS CODE IS AUTOMATICALLY GENERATED. - * - * To regenerate, run `npx convex dev`. - * @module - */ - -import { - actionGeneric, - httpActionGeneric, - queryGeneric, - mutationGeneric, - internalActionGeneric, - internalMutationGeneric, - internalQueryGeneric, - componentsGeneric, -} from "convex/server"; - -/** - * Define a query in this Convex app's public API. - * - * This function will be allowed to read your Convex database and will be accessible from the client. - * - * @param func - The query function. It receives a {@link QueryCtx} as its first argument. - * @returns The wrapped query. Include this as an `export` to name it and make it accessible. - */ -export const query = queryGeneric; - -/** - * Define a query that is only accessible from other Convex functions (but not from the client). - * - * This function will be allowed to read from your Convex database. It will not be accessible from the client. - * - * @param func - The query function. It receives a {@link QueryCtx} as its first argument. - * @returns The wrapped query. Include this as an `export` to name it and make it accessible. - */ -export const internalQuery = internalQueryGeneric; - -/** - * Define a mutation in this Convex app's public API. - * - * This function will be allowed to modify your Convex database and will be accessible from the client. - * - * @param func - The mutation function. It receives a {@link MutationCtx} as its first argument. - * @returns The wrapped mutation. Include this as an `export` to name it and make it accessible. - */ -export const mutation = mutationGeneric; - -/** - * Define a mutation that is only accessible from other Convex functions (but not from the client). - * - * This function will be allowed to modify your Convex database. It will not be accessible from the client. - * - * @param func - The mutation function. It receives a {@link MutationCtx} as its first argument. - * @returns The wrapped mutation. Include this as an `export` to name it and make it accessible. - */ -export const internalMutation = internalMutationGeneric; - -/** - * Define an action in this Convex app's public API. - * - * An action is a function which can execute any JavaScript code, including non-deterministic - * code and code with side-effects, like calling third-party services. - * They can be run in Convex's JavaScript environment or in Node.js using the "use node" directive. - * They can interact with the database indirectly by calling queries and mutations using the {@link ActionCtx}. - * - * @param func - The action. It receives an {@link ActionCtx} as its first argument. - * @returns The wrapped action. Include this as an `export` to name it and make it accessible. - */ -export const action = actionGeneric; - -/** - * Define an action that is only accessible from other Convex functions (but not from the client). - * - * @param func - The function. It receives an {@link ActionCtx} as its first argument. - * @returns The wrapped function. Include this as an `export` to name it and make it accessible. - */ -export const internalAction = internalActionGeneric; - -/** - * Define a Convex HTTP action. - * - * @param func - The function. It receives an {@link ActionCtx} as its first argument, and a `Request` object - * as its second. - * @returns The wrapped endpoint function. Route a URL path to this function in `convex/http.js`. - */ -export const httpAction = httpActionGeneric; diff --git a/src/component/_generated/server.d.ts b/examples/tanstack/convex/betterAuth/_generated/server.ts similarity index 79% rename from src/component/_generated/server.d.ts rename to examples/tanstack/convex/betterAuth/_generated/server.ts index b5c68288..24994e4e 100644 --- a/src/component/_generated/server.d.ts +++ b/examples/tanstack/convex/betterAuth/_generated/server.ts @@ -8,9 +8,8 @@ * @module */ -import { +import type { ActionBuilder, - AnyComponents, HttpActionBuilder, MutationBuilder, QueryBuilder, @@ -19,15 +18,18 @@ import { GenericQueryCtx, GenericDatabaseReader, GenericDatabaseWriter, - FunctionReference, +} from "convex/server"; +import { + actionGeneric, + httpActionGeneric, + queryGeneric, + mutationGeneric, + internalActionGeneric, + internalMutationGeneric, + internalQueryGeneric, } from "convex/server"; import type { DataModel } from "./dataModel.js"; -type GenericCtx = - | GenericActionCtx - | GenericMutationCtx - | GenericQueryCtx; - /** * Define a query in this Convex app's public API. * @@ -36,7 +38,7 @@ type GenericCtx = * @param func - The query function. It receives a {@link QueryCtx} as its first argument. * @returns The wrapped query. Include this as an `export` to name it and make it accessible. */ -export declare const query: QueryBuilder; +export const query: QueryBuilder = queryGeneric; /** * Define a query that is only accessible from other Convex functions (but not from the client). @@ -46,7 +48,8 @@ export declare const query: QueryBuilder; * @param func - The query function. It receives a {@link QueryCtx} as its first argument. * @returns The wrapped query. Include this as an `export` to name it and make it accessible. */ -export declare const internalQuery: QueryBuilder; +export const internalQuery: QueryBuilder = + internalQueryGeneric; /** * Define a mutation in this Convex app's public API. @@ -56,7 +59,7 @@ export declare const internalQuery: QueryBuilder; * @param func - The mutation function. It receives a {@link MutationCtx} as its first argument. * @returns The wrapped mutation. Include this as an `export` to name it and make it accessible. */ -export declare const mutation: MutationBuilder; +export const mutation: MutationBuilder = mutationGeneric; /** * Define a mutation that is only accessible from other Convex functions (but not from the client). @@ -66,7 +69,8 @@ export declare const mutation: MutationBuilder; * @param func - The mutation function. It receives a {@link MutationCtx} as its first argument. * @returns The wrapped mutation. Include this as an `export` to name it and make it accessible. */ -export declare const internalMutation: MutationBuilder; +export const internalMutation: MutationBuilder = + internalMutationGeneric; /** * Define an action in this Convex app's public API. @@ -79,7 +83,7 @@ export declare const internalMutation: MutationBuilder; * @param func - The action. It receives an {@link ActionCtx} as its first argument. * @returns The wrapped action. Include this as an `export` to name it and make it accessible. */ -export declare const action: ActionBuilder; +export const action: ActionBuilder = actionGeneric; /** * Define an action that is only accessible from other Convex functions (but not from the client). @@ -87,19 +91,26 @@ export declare const action: ActionBuilder; * @param func - The function. It receives an {@link ActionCtx} as its first argument. * @returns The wrapped function. Include this as an `export` to name it and make it accessible. */ -export declare const internalAction: ActionBuilder; +export const internalAction: ActionBuilder = + internalActionGeneric; /** * Define an HTTP action. * - * This function will be used to respond to HTTP requests received by a Convex - * deployment if the requests matches the path and method where this action - * is routed. Be sure to route your action in `convex/http.js`. + * The wrapped function will be used to respond to HTTP requests received + * by a Convex deployment if the requests matches the path and method where + * this action is routed. Be sure to route your httpAction in `convex/http.js`. * - * @param func - The function. It receives an {@link ActionCtx} as its first argument. + * @param func - The function. It receives an {@link ActionCtx} as its first argument + * and a Fetch API `Request` object as its second. * @returns The wrapped function. Import this function from `convex/http.js` and route it to hook it up. */ -export declare const httpAction: HttpActionBuilder; +export const httpAction: HttpActionBuilder = httpActionGeneric; + +type GenericCtx = + | GenericActionCtx + | GenericMutationCtx + | GenericQueryCtx; /** * A set of services for use within Convex query functions. @@ -107,8 +118,7 @@ export declare const httpAction: HttpActionBuilder; * The query context is passed as the first argument to any Convex query * function run on the server. * - * This differs from the {@link MutationCtx} because all of the services are - * read-only. + * If you're using code generation, use the `QueryCtx` type in `convex/_generated/server.d.ts` instead. */ export type QueryCtx = GenericQueryCtx; @@ -117,6 +127,8 @@ export type QueryCtx = GenericQueryCtx; * * The mutation context is passed as the first argument to any Convex mutation * function run on the server. + * + * If you're using code generation, use the `MutationCtx` type in `convex/_generated/server.d.ts` instead. */ export type MutationCtx = GenericMutationCtx; diff --git a/examples/tanstack/package-lock.json b/examples/tanstack/package-lock.json index ee228719..3b4e4c42 100644 --- a/examples/tanstack/package-lock.json +++ b/examples/tanstack/package-lock.json @@ -53,12 +53,14 @@ }, "../..": { "name": "@convex-dev/better-auth", - "version": "0.9.2", + "version": "0.9.7", "license": "Apache-2.0", "dependencies": { "common-tags": "^1.8.2", "convex-helpers": "^0.1.95", + "jose": "^6.1.0", "remeda": "^2.32.0", + "semver": "^7.7.3", "type-fest": "^4.39.1", "zod": "^3.24.4" }, @@ -74,20 +76,20 @@ "@types/semver": "^7.7.0", "chokidar-cli": "^3.0.0", "concurrently": "^9.2.0", + "convex": "1.29.0", "convex-test": "^0.0.33", "eslint": "^9.9.1", "globals": "^15.9.0", "next": "^15.1.8", + "npm-run-all2": "8.0.4", "prettier": "3.2.5", - "semver": "^7.7.2", - "tsc-alias": "^1.8.16", "typescript": "5.8.3", "typescript-eslint": "^8.4.0", "vitest": "^3.2.2" }, "peerDependencies": { "better-auth": "1.3.27", - "convex": "^1.26.2", + "convex": "^1.28.2", "react": "^18.3.1 || ^19.0.0", "react-dom": "^18.3.1 || ^19.0.0" } diff --git a/examples/tanstack/package.json b/examples/tanstack/package.json index 7307b8fc..ae944e9c 100644 --- a/examples/tanstack/package.json +++ b/examples/tanstack/package.json @@ -5,12 +5,10 @@ "type": "module", "main": "index.js", "scripts": { - "dev": "concurrently -r npm:dev:web npm:dev:db", - "dev:web": "vite dev --port 3000", - "dev:db": "npx convex dev", - "build": "vite build", - "generate": "convex dev --once", - "start": "node .output/server/index.mjs", + "dev": "run-p -r 'dev:*'", + "dev:frontend": "vite dev --port 3000", + "dev:backend": "npx convex dev --typecheck-components", + "dev:build": "chokidar '../../tsconfig*.json' '../../src/**/*.ts' -i '**/*.test.ts' -c 'npx convex codegen --component-dir ../../src/component && cd ../../ && npm run build' --initial", "lint": "prettier --check '**/*' --ignore-unknown && eslint --ext .ts,.tsx ./app", "format": "prettier --write '**/*' --ignore-unknown" }, diff --git a/examples/tanstack/src/components/DefaultCatchBoundary.tsx b/examples/tanstack/src/components/DefaultCatchBoundary.tsx index 15f31668..5332cf84 100644 --- a/examples/tanstack/src/components/DefaultCatchBoundary.tsx +++ b/examples/tanstack/src/components/DefaultCatchBoundary.tsx @@ -22,7 +22,7 @@ export function DefaultCatchBoundary({ error }: ErrorComponentProps) {