diff --git a/template-component/convex.json b/template-component/convex.json index 1704a04d..07199a61 100644 --- a/template-component/convex.json +++ b/template-component/convex.json @@ -1,3 +1,7 @@ { - "functions": "example/convex" + "$schema": "https://raw.githubusercontent.com/get-convex/convex-backend/refs/heads/main/npm-packages/convex/schemas/convex.schema.json", + "functions": "example/convex", + "codegen": { + "staticApi": true + } } diff --git a/template-component/example/convex/_generated/api.d.ts b/template-component/example/convex/_generated/api.d.ts index 2f1979a4..9918c619 100644 --- a/template-component/example/convex/_generated/api.d.ts +++ b/template-component/example/convex/_generated/api.d.ts @@ -8,35 +8,33 @@ * @module */ -import type * as example from "../example.js"; - -import type { - ApiFromModules, - FilterApi, - FunctionReference, -} from "convex/server"; +import type { FunctionReference } from "convex/server"; /** - * A utility for referencing Convex functions in your app's API. + * A utility for referencing Convex functions in your app's public API. * * Usage: * ```js * const myFunctionReference = api.myModule.myFunction; * ``` */ -declare const fullApi: ApiFromModules<{ - example: typeof example; -}>; -declare const fullApiWithMounts: typeof fullApi; +export declare const api: { + example: { + addOne: FunctionReference<"mutation", "public", {}, any>; + add: FunctionReference<"mutation", "public", { name: string }, any>; + count: FunctionReference<"query", "public", { name: string }, any>; + }; +}; -export declare const api: FilterApi< - typeof fullApiWithMounts, - FunctionReference ->; -export declare const internal: FilterApi< - typeof fullApiWithMounts, - FunctionReference ->; +/** + * A utility for referencing Convex functions in your app's internal API. + * + * Usage: + * ```js + * const myFunctionReference = internal.myModule.myFunction; + * ``` + */ +export declare const internal: {}; export declare const components: { shardedCounter: { diff --git a/template-component/src/client/index.ts b/template-component/src/client/index.ts index 24d30368..d43137ca 100644 --- a/template-component/src/client/index.ts +++ b/template-component/src/client/index.ts @@ -1,12 +1,12 @@ import { mutationGeneric, queryGeneric } from "convex/server"; import { v } from "convex/values"; -import type { Mounts } from "../component/_generated/api.js"; +import type { api } from "../component/_generated/api.js"; import type { UseApi, RunMutationCtx, RunQueryCtx } from "./types.js"; // UseApi is an alternative that has jump-to-definition but is // less stable and reliant on types within the component files, which can cause // issues where passing `components.foo` doesn't match the argument -export type ShardedCounterComponent = UseApi; +export type ShardedCounterComponent = UseApi; export class ShardedCounter> { constructor( diff --git a/template-component/src/component/_generated/api.d.ts b/template-component/src/component/_generated/api.d.ts index 38b1ff9c..b3716e20 100644 --- a/template-component/src/component/_generated/api.d.ts +++ b/template-component/src/component/_generated/api.d.ts @@ -8,26 +8,17 @@ * @module */ -import type * as lib from "../lib.js"; - -import type { - ApiFromModules, - FilterApi, - FunctionReference, -} from "convex/server"; +import type { FunctionReference } from "convex/server"; /** - * A utility for referencing Convex functions in your app's API. + * A utility for referencing Convex functions in your app's public API. * * Usage: * ```js * const myFunctionReference = api.myModule.myFunction; * ``` */ -declare const fullApi: ApiFromModules<{ - lib: typeof lib; -}>; -export type Mounts = { +export declare const api: { lib: { add: FunctionReference< "mutation", @@ -38,18 +29,15 @@ export type Mounts = { count: FunctionReference<"query", "public", { name: string }, number>; }; }; -// 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 ->; +/** + * A utility for referencing Convex functions in your app's internal API. + * + * Usage: + * ```js + * const myFunctionReference = internal.myModule.myFunction; + * ``` + */ +export declare const internal: {}; export declare const components: {};