···88 * @module
99 */
10101111-import { AnyDataModel } from "convex/server";
1111+import type {
1212+ DataModelFromSchemaDefinition,
1313+ DocumentByName,
1414+ TableNamesInDataModel,
1515+ SystemTableNames,
1616+} from "convex/server";
1217import type { GenericId } from "convex/values";
1313-1414-/**
1515- * No `schema.ts` file found!
1616- *
1717- * This generated code has permissive types like `Doc = any` because
1818- * Convex doesn't know your schema. If you'd like more type safety, see
1919- * https://docs.convex.dev/using/schemas for instructions on how to add a
2020- * schema file.
2121- *
2222- * After you change a schema, rerun codegen with `npx convex dev`.
2323- */
1818+import schema from "../schema.js";
24192520/**
2621 * The names of all of your Convex tables.
2722 */
2828-export type TableNames = string;
2323+export type TableNames = TableNamesInDataModel<DataModel>;
29243025/**
3126 * The type of a document stored in Convex.
2727+ *
2828+ * @typeParam TableName - A string literal type of the table name (like "users").
3229 */
3333-export type Doc = any;
3030+export type Doc<TableName extends TableNames> = DocumentByName<
3131+ DataModel,
3232+ TableName
3333+>;
34343535/**
3636 * An identifier for a document in Convex.
···4242 *
4343 * IDs are just strings at runtime, but this type can be used to distinguish them from other
4444 * strings when type checking.
4545+ *
4646+ * @typeParam TableName - A string literal type of the table name (like "users").
4547 */
4646-export type Id<TableName extends TableNames = TableNames> =
4848+export type Id<TableName extends TableNames | SystemTableNames> =
4749 GenericId<TableName>;
48504951/**
···5557 * This type is used to parameterize methods like `queryGeneric` and
5658 * `mutationGeneric` to make them type-safe.
5759 */
5858-export type DataModel = AnyDataModel;
6060+export type DataModel = DataModelFromSchemaDefinition<typeof schema>;