|
| 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 | + * This function will be used to respond to HTTP requests received by a Convex |
| 89 | + * deployment if the requests matches the path and method where this action |
| 90 | + * is routed. Be sure to route your action in `convex/http.js`. |
| 91 | + * |
| 92 | + * @param func - The function. It receives an {@link ActionCtx} as its first argument. |
| 93 | + * @returns The wrapped function. Import this function from `convex/http.js` and route it to hook it up. |
| 94 | + */ |
| 95 | +export declare const httpAction: HttpActionBuilder; |
| 96 | + |
| 97 | +/** |
| 98 | + * A set of services for use within Convex query functions. |
| 99 | + * |
| 100 | + * The query context is passed as the first argument to any Convex query |
| 101 | + * function run on the server. |
| 102 | + * |
| 103 | + * This differs from the {@link MutationCtx} because all of the services are |
| 104 | + * read-only. |
| 105 | + */ |
| 106 | +export type QueryCtx = GenericQueryCtx<DataModel>; |
| 107 | + |
| 108 | +/** |
| 109 | + * A set of services for use within Convex mutation functions. |
| 110 | + * |
| 111 | + * The mutation context is passed as the first argument to any Convex mutation |
| 112 | + * function run on the server. |
| 113 | + */ |
| 114 | +export type MutationCtx = GenericMutationCtx<DataModel>; |
| 115 | + |
| 116 | +/** |
| 117 | + * A set of services for use within Convex action functions. |
| 118 | + * |
| 119 | + * The action context is passed as the first argument to any Convex action |
| 120 | + * function run on the server. |
| 121 | + */ |
| 122 | +export type ActionCtx = GenericActionCtx<DataModel>; |
| 123 | + |
| 124 | +/** |
| 125 | + * An interface to read from the database within Convex query functions. |
| 126 | + * |
| 127 | + * The two entry points are {@link DatabaseReader.get}, which fetches a single |
| 128 | + * document by its {@link Id}, or {@link DatabaseReader.query}, which starts |
| 129 | + * building a query. |
| 130 | + */ |
| 131 | +export type DatabaseReader = GenericDatabaseReader<DataModel>; |
| 132 | + |
| 133 | +/** |
| 134 | + * An interface to read from and write to the database within Convex mutation |
| 135 | + * functions. |
| 136 | + * |
| 137 | + * Convex guarantees that all writes within a single mutation are |
| 138 | + * executed atomically, so you never have to worry about partial writes leaving |
| 139 | + * your data in an inconsistent state. See [the Convex Guide](https://docs.convex.dev/understanding/convex-fundamentals/functions#atomicity-and-optimistic-concurrency-control) |
| 140 | + * for the guarantees Convex provides your functions. |
| 141 | + */ |
| 142 | +export type DatabaseWriter = GenericDatabaseWriter<DataModel>; |
0 commit comments