Skip to content

Commit 283e1f6

Browse files
committed
feat: add convex package and generated files
- Added "convex" package to package.json and package-lock.json. - Updated tsconfig.json to include convex types for TypeScript. - Created generated files for Convex API utilities: - api.d.ts - api.js - dataModel.d.ts - server.d.ts - server.js
1 parent 4446ed9 commit 283e1f6

8 files changed

Lines changed: 341 additions & 0 deletions

File tree

convex/_generated/api.d.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/* eslint-disable */
2+
/**
3+
* Generated `api` utility.
4+
*
5+
* THIS CODE IS AUTOMATICALLY GENERATED.
6+
*
7+
* To regenerate, run `npx convex dev`.
8+
* @module
9+
*/
10+
11+
import type { AnyApi, AnyComponents } from "convex/server";
12+
13+
export declare const api: AnyApi;
14+
export declare const internal: AnyApi;
15+
export declare const components: AnyComponents;

convex/_generated/api.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* eslint-disable */
2+
/**
3+
* Generated `api` utility.
4+
*
5+
* THIS CODE IS AUTOMATICALLY GENERATED.
6+
*
7+
* To regenerate, run `npx convex dev`.
8+
* @module
9+
*/
10+
11+
import { anyApi, componentsGeneric } from "convex/server";
12+
13+
/**
14+
* A utility for referencing Convex functions in your app's API.
15+
*
16+
* Usage:
17+
* ```js
18+
* const myFunctionReference = api.myModule.myFunction;
19+
* ```
20+
*/
21+
export const api = anyApi;
22+
export const internal = anyApi;
23+
export const components = componentsGeneric();

convex/_generated/dataModel.d.ts

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/* eslint-disable */
2+
/**
3+
* Generated data model types.
4+
*
5+
* THIS CODE IS AUTOMATICALLY GENERATED.
6+
*
7+
* To regenerate, run `npx convex dev`.
8+
* @module
9+
*/
10+
11+
import type {
12+
DataModelFromSchemaDefinition,
13+
DocumentByName,
14+
TableNamesInDataModel,
15+
SystemTableNames,
16+
} from "convex/server";
17+
import type { GenericId } from "convex/values";
18+
import schema from "../schema.js";
19+
20+
/**
21+
* The names of all of your Convex tables.
22+
*/
23+
export type TableNames = TableNamesInDataModel<DataModel>;
24+
25+
/**
26+
* The type of a document stored in Convex.
27+
*
28+
* @typeParam TableName - A string literal type of the table name (like "users").
29+
*/
30+
export type Doc<TableName extends TableNames> = DocumentByName<
31+
DataModel,
32+
TableName
33+
>;
34+
35+
/**
36+
* An identifier for a document in Convex.
37+
*
38+
* Convex documents are uniquely identified by their `Id`, which is accessible
39+
* on the `_id` field. To learn more, see [Document IDs](https://docs.convex.dev/using/document-ids).
40+
*
41+
* Documents can be loaded using `db.get(tableName, id)` in query and mutation functions.
42+
*
43+
* IDs are just strings at runtime, but this type can be used to distinguish them from other
44+
* strings when type checking.
45+
*
46+
* @typeParam TableName - A string literal type of the table name (like "users").
47+
*/
48+
export type Id<TableName extends TableNames | SystemTableNames> =
49+
GenericId<TableName>;
50+
51+
/**
52+
* A type describing your Convex data model.
53+
*
54+
* This type includes information about what tables you have, the type of
55+
* documents stored in those tables, and the indexes defined on them.
56+
*
57+
* This type is used to parameterize methods like `queryGeneric` and
58+
* `mutationGeneric` to make them type-safe.
59+
*/
60+
export type DataModel = DataModelFromSchemaDefinition<typeof schema>;

convex/_generated/server.d.ts

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
/* eslint-disable */
2+
/**
3+
* Generated utilities for implementing server-side Convex query and mutation functions.
4+
*
5+
* THIS CODE IS AUTOMATICALLY GENERATED.
6+
*
7+
* To regenerate, run `npx convex dev`.
8+
* @module
9+
*/
10+
11+
import {
12+
ActionBuilder,
13+
HttpActionBuilder,
14+
MutationBuilder,
15+
QueryBuilder,
16+
GenericActionCtx,
17+
GenericMutationCtx,
18+
GenericQueryCtx,
19+
GenericDatabaseReader,
20+
GenericDatabaseWriter,
21+
} from "convex/server";
22+
import type { DataModel } from "./dataModel.js";
23+
24+
/**
25+
* Define a query in this Convex app's public API.
26+
*
27+
* This function will be allowed to read your Convex database and will be accessible from the client.
28+
*
29+
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
30+
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
31+
*/
32+
export declare const query: QueryBuilder<DataModel, "public">;
33+
34+
/**
35+
* Define a query that is only accessible from other Convex functions (but not from the client).
36+
*
37+
* This function will be allowed to read from your Convex database. It will not be accessible from the client.
38+
*
39+
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
40+
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
41+
*/
42+
export declare const internalQuery: QueryBuilder<DataModel, "internal">;
43+
44+
/**
45+
* Define a mutation in this Convex app's public API.
46+
*
47+
* This function will be allowed to modify your Convex database and will be accessible from the client.
48+
*
49+
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
50+
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
51+
*/
52+
export declare const mutation: MutationBuilder<DataModel, "public">;
53+
54+
/**
55+
* Define a mutation that is only accessible from other Convex functions (but not from the client).
56+
*
57+
* This function will be allowed to modify your Convex database. It will not be accessible from the client.
58+
*
59+
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
60+
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
61+
*/
62+
export declare const internalMutation: MutationBuilder<DataModel, "internal">;
63+
64+
/**
65+
* Define an action in this Convex app's public API.
66+
*
67+
* An action is a function which can execute any JavaScript code, including non-deterministic
68+
* code and code with side-effects, like calling third-party services.
69+
* They can be run in Convex's JavaScript environment or in Node.js using the "use node" directive.
70+
* They can interact with the database indirectly by calling queries and mutations using the {@link ActionCtx}.
71+
*
72+
* @param func - The action. It receives an {@link ActionCtx} as its first argument.
73+
* @returns The wrapped action. Include this as an `export` to name it and make it accessible.
74+
*/
75+
export declare const action: ActionBuilder<DataModel, "public">;
76+
77+
/**
78+
* Define an action that is only accessible from other Convex functions (but not from the client).
79+
*
80+
* @param func - The function. It receives an {@link ActionCtx} as its first argument.
81+
* @returns The wrapped function. Include this as an `export` to name it and make it accessible.
82+
*/
83+
export declare const internalAction: ActionBuilder<DataModel, "internal">;
84+
85+
/**
86+
* Define an HTTP action.
87+
*
88+
* The wrapped function will be used to respond to HTTP requests received
89+
* by a Convex deployment if the requests matches the path and method where
90+
* this action is routed. Be sure to route your httpAction in `convex/http.js`.
91+
*
92+
* @param func - The function. It receives an {@link ActionCtx} as its first argument
93+
* and a Fetch API `Request` object as its second.
94+
* @returns The wrapped function. Import this function from `convex/http.js` and route it to hook it up.
95+
*/
96+
export declare const httpAction: HttpActionBuilder;
97+
98+
/**
99+
* A set of services for use within Convex query functions.
100+
*
101+
* The query context is passed as the first argument to any Convex query
102+
* function run on the server.
103+
*
104+
* This differs from the {@link MutationCtx} because all of the services are
105+
* read-only.
106+
*/
107+
export type QueryCtx = GenericQueryCtx<DataModel>;
108+
109+
/**
110+
* A set of services for use within Convex mutation functions.
111+
*
112+
* The mutation context is passed as the first argument to any Convex mutation
113+
* function run on the server.
114+
*/
115+
export type MutationCtx = GenericMutationCtx<DataModel>;
116+
117+
/**
118+
* A set of services for use within Convex action functions.
119+
*
120+
* The action context is passed as the first argument to any Convex action
121+
* function run on the server.
122+
*/
123+
export type ActionCtx = GenericActionCtx<DataModel>;
124+
125+
/**
126+
* An interface to read from the database within Convex query functions.
127+
*
128+
* The two entry points are {@link DatabaseReader.get}, which fetches a single
129+
* document by its {@link Id}, or {@link DatabaseReader.query}, which starts
130+
* building a query.
131+
*/
132+
export type DatabaseReader = GenericDatabaseReader<DataModel>;
133+
134+
/**
135+
* An interface to read from and write to the database within Convex mutation
136+
* functions.
137+
*
138+
* Convex guarantees that all writes within a single mutation are
139+
* executed atomically, so you never have to worry about partial writes leaving
140+
* your data in an inconsistent state. See [the Convex Guide](https://docs.convex.dev/understanding/convex-fundamentals/functions#atomicity-and-optimistic-concurrency-control)
141+
* for the guarantees Convex provides your functions.
142+
*/
143+
export type DatabaseWriter = GenericDatabaseWriter<DataModel>;

convex/_generated/server.js

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/* eslint-disable */
2+
/**
3+
* Generated utilities for implementing server-side Convex query and mutation functions.
4+
*
5+
* THIS CODE IS AUTOMATICALLY GENERATED.
6+
*
7+
* To regenerate, run `npx convex dev`.
8+
* @module
9+
*/
10+
11+
import {
12+
actionGeneric,
13+
httpActionGeneric,
14+
queryGeneric,
15+
mutationGeneric,
16+
internalActionGeneric,
17+
internalMutationGeneric,
18+
internalQueryGeneric,
19+
} from "convex/server";
20+
21+
/**
22+
* Define a query in this Convex app's public API.
23+
*
24+
* This function will be allowed to read your Convex database and will be accessible from the client.
25+
*
26+
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
27+
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
28+
*/
29+
export const query = queryGeneric;
30+
31+
/**
32+
* Define a query that is only accessible from other Convex functions (but not from the client).
33+
*
34+
* This function will be allowed to read from your Convex database. It will not be accessible from the client.
35+
*
36+
* @param func - The query function. It receives a {@link QueryCtx} as its first argument.
37+
* @returns The wrapped query. Include this as an `export` to name it and make it accessible.
38+
*/
39+
export const internalQuery = internalQueryGeneric;
40+
41+
/**
42+
* Define a mutation in this Convex app's public API.
43+
*
44+
* This function will be allowed to modify your Convex database and will be accessible from the client.
45+
*
46+
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
47+
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
48+
*/
49+
export const mutation = mutationGeneric;
50+
51+
/**
52+
* Define a mutation that is only accessible from other Convex functions (but not from the client).
53+
*
54+
* This function will be allowed to modify your Convex database. It will not be accessible from the client.
55+
*
56+
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
57+
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
58+
*/
59+
export const internalMutation = internalMutationGeneric;
60+
61+
/**
62+
* Define an action in this Convex app's public API.
63+
*
64+
* An action is a function which can execute any JavaScript code, including non-deterministic
65+
* code and code with side-effects, like calling third-party services.
66+
* They can be run in Convex's JavaScript environment or in Node.js using the "use node" directive.
67+
* They can interact with the database indirectly by calling queries and mutations using the {@link ActionCtx}.
68+
*
69+
* @param func - The action. It receives an {@link ActionCtx} as its first argument.
70+
* @returns The wrapped action. Include this as an `export` to name it and make it accessible.
71+
*/
72+
export const action = actionGeneric;
73+
74+
/**
75+
* Define an action that is only accessible from other Convex functions (but not from the client).
76+
*
77+
* @param func - The function. It receives an {@link ActionCtx} as its first argument.
78+
* @returns The wrapped function. Include this as an `export` to name it and make it accessible.
79+
*/
80+
export const internalAction = internalActionGeneric;
81+
82+
/**
83+
* Define an HTTP action.
84+
*
85+
* The wrapped function will be used to respond to HTTP requests received
86+
* by a Convex deployment if the requests matches the path and method where
87+
* this action is routed. Be sure to route your httpAction in `convex/http.js`.
88+
*
89+
* @param func - The function. It receives an {@link ActionCtx} as its first argument
90+
* and a Fetch API `Request` object as its second.
91+
* @returns The wrapped function. Import this function from `convex/http.js` and route it to hook it up.
92+
*/
93+
export const httpAction = httpActionGeneric;

package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@
129129
"cmdk": "^1.1.1",
130130
"concurrently": "^9.2.1",
131131
"convert-csv-to-json": "^3.20.0",
132+
"convex": "^1.31.4",
132133
"crawlee": "^3.15.3",
133134
"critters": "^0.0.25",
134135
"csv-parse": "^6.1.0",

tsconfig.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@
5959
"hooks/**/*.tsx",
6060
"pages/**/*.ts",
6161
"pages/**/*.tsx",
62+
"convex/**/*.ts",
63+
"convex/**/*.tsx",
64+
"convex/**/*.d.ts",
65+
"convex/mastra/**/*.ts",
66+
"convex/**/*.js",
6267
// Tests are excluded from the main typecheck run to avoid typechecking test-only imports
6368
// that may pull in declaration files with unsupported syntax from node_modules.
6469
"types/**/*.d.ts"

0 commit comments

Comments
 (0)