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