@nordsym/apiclaw 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/.github/ISSUE_TEMPLATE/add-api.yml +123 -0
  2. package/BRIEFING.md +30 -0
  3. package/CONCEPT.md +494 -0
  4. package/README.md +272 -0
  5. package/backend/convex/README.md +90 -0
  6. package/backend/convex/_generated/api.d.ts +55 -0
  7. package/backend/convex/_generated/api.js +23 -0
  8. package/backend/convex/_generated/dataModel.d.ts +60 -0
  9. package/backend/convex/_generated/server.d.ts +143 -0
  10. package/backend/convex/_generated/server.js +93 -0
  11. package/backend/convex/apiKeys.ts +75 -0
  12. package/backend/convex/purchases.ts +74 -0
  13. package/backend/convex/schema.ts +45 -0
  14. package/backend/convex/transactions.ts +57 -0
  15. package/backend/convex/tsconfig.json +25 -0
  16. package/backend/convex/users.ts +94 -0
  17. package/backend/package-lock.json +521 -0
  18. package/backend/package.json +15 -0
  19. package/dist/credits.d.ts +54 -0
  20. package/dist/credits.d.ts.map +1 -0
  21. package/dist/credits.js +209 -0
  22. package/dist/credits.js.map +1 -0
  23. package/dist/discovery.d.ts +37 -0
  24. package/dist/discovery.d.ts.map +1 -0
  25. package/dist/discovery.js +109 -0
  26. package/dist/discovery.js.map +1 -0
  27. package/dist/index.d.ts +13 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +355 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/registry/apis.json +20894 -0
  32. package/dist/registry/parse_apis.py +146 -0
  33. package/dist/revenuecat.d.ts +61 -0
  34. package/dist/revenuecat.d.ts.map +1 -0
  35. package/dist/revenuecat.js +166 -0
  36. package/dist/revenuecat.js.map +1 -0
  37. package/dist/test.d.ts +6 -0
  38. package/dist/test.d.ts.map +1 -0
  39. package/dist/test.js +81 -0
  40. package/dist/test.js.map +1 -0
  41. package/dist/types.d.ts +96 -0
  42. package/dist/types.d.ts.map +1 -0
  43. package/dist/types.js +3 -0
  44. package/dist/types.js.map +1 -0
  45. package/dist/webhooks/revenuecat.d.ts +48 -0
  46. package/dist/webhooks/revenuecat.d.ts.map +1 -0
  47. package/dist/webhooks/revenuecat.js +119 -0
  48. package/dist/webhooks/revenuecat.js.map +1 -0
  49. package/docs/revenuecat-setup.md +89 -0
  50. package/landing/next-env.d.ts +5 -0
  51. package/landing/next.config.mjs +6 -0
  52. package/landing/package-lock.json +1666 -0
  53. package/landing/package.json +27 -0
  54. package/landing/postcss.config.js +6 -0
  55. package/landing/src/app/api/keys/route.ts +71 -0
  56. package/landing/src/app/api/log/route.ts +37 -0
  57. package/landing/src/app/api/stats/route.ts +37 -0
  58. package/landing/src/app/globals.css +261 -0
  59. package/landing/src/app/layout.tsx +37 -0
  60. package/landing/src/app/page.tsx +753 -0
  61. package/landing/src/app/page.tsx.bak +567 -0
  62. package/landing/src/components/AddKeyModal.tsx +159 -0
  63. package/landing/tailwind.config.ts +34 -0
  64. package/landing/tsconfig.json +20 -0
  65. package/newsletter-template.html +71 -0
  66. package/outreach/OUTREACH-SYSTEM.md +211 -0
  67. package/outreach/email-template.html +179 -0
  68. package/outreach/targets.md +133 -0
  69. package/package.json +39 -0
  70. package/src/credits.ts +261 -0
  71. package/src/discovery.ts +147 -0
  72. package/src/index.ts +396 -0
  73. package/src/registry/apis.json +20894 -0
  74. package/src/registry/parse_apis.py +146 -0
  75. package/src/revenuecat.ts +239 -0
  76. package/src/test.ts +97 -0
  77. package/src/types.ts +110 -0
  78. package/src/webhooks/revenuecat.ts +187 -0
  79. package/tsconfig.json +20 -0
package/README.md ADDED
@@ -0,0 +1,272 @@
1
+ # APIvault
2
+
3
+ **Agent-native API discovery and purchasing via MCP.**
4
+
5
+ > The place where AI agents discover, evaluate, and purchase API access directly. No dashboard. No manual signup. Agent-first.
6
+
7
+ ## What is this?
8
+
9
+ APIvault is an MCP server that lets AI agents:
10
+ 1. **Discover** APIs based on capabilities ("I need to send SMS")
11
+ 2. **Evaluate** pricing, features, and success rates
12
+ 3. **Purchase** access and receive credentials instantly
13
+ 4. **Track** usage and balance
14
+
15
+ ## Quick Start
16
+
17
+ ### 1. Install dependencies
18
+
19
+ ```bash
20
+ cd ~/clawd/products/api-discovery
21
+ pnpm install
22
+ ```
23
+
24
+ ### 2. Build
25
+
26
+ ```bash
27
+ pnpm build
28
+ ```
29
+
30
+ ### 3. Run tests
31
+
32
+ ```bash
33
+ pnpm test
34
+ ```
35
+
36
+ ### 4. Add to Claude Desktop
37
+
38
+ Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
39
+
40
+ ```json
41
+ {
42
+ "mcpServers": {
43
+ "apivault": {
44
+ "command": "node",
45
+ "args": ["/Users/gustavhemmingsson/clawd/products/api-discovery/dist/index.js"]
46
+ }
47
+ }
48
+ }
49
+ ```
50
+
51
+ ### 5. Run manually (stdio)
52
+
53
+ ```bash
54
+ node dist/index.js
55
+ ```
56
+
57
+ ## MCP Tools
58
+
59
+ ### `discover_apis`
60
+
61
+ Search for APIs by describing what you need.
62
+
63
+ ```
64
+ Input:
65
+ query: "send SMS to Swedish numbers"
66
+ category?: "communication" | "search" | "ai"
67
+ max_results?: 5
68
+ region?: "SE" | "EU" | "global"
69
+
70
+ Output:
71
+ - Ranked list of matching APIs
72
+ - Relevance scores
73
+ - Pricing info
74
+ - Success rates
75
+ ```
76
+
77
+ ### `get_api_details`
78
+
79
+ Get full information about a specific API.
80
+
81
+ ```
82
+ Input:
83
+ api_id: "46elks"
84
+
85
+ Output:
86
+ - Full API specification
87
+ - All endpoints
88
+ - Pricing details
89
+ - Features and compliance
90
+ ```
91
+
92
+ ### `purchase_access`
93
+
94
+ Purchase API access using credits.
95
+
96
+ ```
97
+ Input:
98
+ api_id: "46elks"
99
+ amount_usd: 10
100
+
101
+ Output:
102
+ - Purchase confirmation
103
+ - API credentials (key, username/password)
104
+ - Credits received
105
+ - Access URLs
106
+ ```
107
+
108
+ ### `check_balance`
109
+
110
+ Check your credit balance and active purchases.
111
+
112
+ ```
113
+ Input:
114
+ agent_id?: "your_agent_id"
115
+
116
+ Output:
117
+ - Current balance in USD
118
+ - List of active purchases
119
+ - Total spent
120
+ ```
121
+
122
+ ### `add_credits`
123
+
124
+ Add credits to your account (for testing).
125
+
126
+ ```
127
+ Input:
128
+ amount_usd: 50
129
+
130
+ Output:
131
+ - New balance
132
+ ```
133
+
134
+ ### `list_categories`
135
+
136
+ List all available API categories.
137
+
138
+ ## Available APIs (MVP)
139
+
140
+ | Provider | Category | Capabilities |
141
+ |----------|----------|--------------|
142
+ | **46elks** | communication | SMS, Voice, MMS |
143
+ | **Resend** | communication | Email, Templates |
144
+ | **Brave Search** | search | Web, News, Images |
145
+ | **OpenRouter** | ai | LLM Chat, Completions |
146
+ | **ElevenLabs** | ai | TTS, Voice Cloning |
147
+
148
+ ## Architecture
149
+
150
+ ```
151
+ ┌─────────────────────────────────────────────────────┐
152
+ │ AI Agent │
153
+ └─────────────────────┬───────────────────────────────┘
154
+ │ MCP Protocol
155
+ ┌─────────────────────▼───────────────────────────────┐
156
+ │ APIvault MCP Server │
157
+ ├──────────────┬──────────────┬───────────────────────┤
158
+ │ Discovery │ Credits │ Purchase │
159
+ │ Engine │ System │ Handler │
160
+ └──────────────┴──────────────┴───────────────────────┘
161
+
162
+ ┌─────────────────────▼───────────────────────────────┐
163
+ │ API Registry (JSON) │
164
+ │ • 5 APIs with full metadata │
165
+ │ • Pricing, endpoints, features │
166
+ └─────────────────────────────────────────────────────┘
167
+ ```
168
+
169
+ ## MVP Status
170
+
171
+ ### ✅ Working
172
+ - [x] MCP server with 6 tools
173
+ - [x] API discovery with keyword matching
174
+ - [x] API registry with 5 providers
175
+ - [x] In-memory credit system
176
+ - [x] Mock credential generation
177
+ - [x] Purchase flow
178
+
179
+ ### 🚧 Stub/Mock
180
+ - [ ] Real API key provisioning (mock credentials)
181
+ - [ ] Supabase persistence (in-memory)
182
+ - [ ] Semantic search (keyword matching)
183
+ - [ ] Real-time usage tracking
184
+ - [ ] Webhook notifications
185
+
186
+ ### 🔮 Future
187
+ - [ ] Stripe Agent Toolkit integration
188
+ - [ ] Supabase for persistence
189
+ - [ ] Embeddings for semantic search
190
+ - [ ] More API providers
191
+ - [ ] Usage webhooks
192
+
193
+ ## Backend (Convex)
194
+
195
+ **Deployment:** `https://blessed-chicken-640.convex.cloud`
196
+ **Dashboard:** https://dashboard.convex.dev/t/gustav-4d573/apiclaw
197
+
198
+ ### Schema
199
+
200
+ - **users** — email, clerkId, credits (cents)
201
+ - **purchases** — userId, apiId, credentials, status, purchasedAt, expiresAt
202
+ - **transactions** — userId, type, amount, description, createdAt
203
+
204
+ ### Functions
205
+
206
+ ```typescript
207
+ // Users
208
+ users:getOrCreate(email, clerkId?) // Get or create user
209
+ users:addCredits(userId, amount) // Add/subtract credits
210
+ users:getBalance(userId) // Get balance
211
+ users:get(userId) // Get user by ID
212
+ users:getByEmail(email) // Get user by email
213
+
214
+ // Purchases
215
+ purchases:create(userId, apiId, credentials, expiresAt?)
216
+ purchases:listByUser(userId)
217
+ purchases:getByUserAndApi(userId, apiId)
218
+ purchases:updateStatus(purchaseId, status)
219
+
220
+ // Transactions
221
+ transactions:log(userId, type, amount, description)
222
+ transactions:listByUser(userId, limit?)
223
+ ```
224
+
225
+ ### Dev Commands
226
+
227
+ ```bash
228
+ cd backend
229
+ npx convex dev # Start dev mode
230
+ npx convex deploy # Deploy to prod
231
+ ```
232
+
233
+ ## File Structure
234
+
235
+ ```
236
+ api-discovery/
237
+ ├── README.md
238
+ ├── package.json
239
+ ├── tsconfig.json
240
+ ├── CONCEPT.md # Original research
241
+ ├── src/
242
+ │ ├── index.ts # MCP server entry
243
+ │ ├── types.ts # TypeScript types
244
+ │ ├── discovery.ts # Search engine
245
+ │ ├── credits.ts # Credit system
246
+ │ ├── test.ts # Test script
247
+ │ └── registry/
248
+ │ └── apis.json # API definitions
249
+ └── backend/
250
+ └── convex/
251
+ ├── schema.ts
252
+ ├── users.ts
253
+ ├── purchases.ts
254
+ └── transactions.ts
255
+ ```
256
+
257
+ ## Development
258
+
259
+ ```bash
260
+ # Watch mode
261
+ pnpm dev
262
+
263
+ # Build
264
+ pnpm build
265
+
266
+ # Test
267
+ pnpm test
268
+ ```
269
+
270
+ ## License
271
+
272
+ MIT - NordSym
@@ -0,0 +1,90 @@
1
+ # Welcome to your Convex functions directory!
2
+
3
+ Write your Convex functions here.
4
+ See https://docs.convex.dev/functions for more.
5
+
6
+ A query function that takes two arguments looks like:
7
+
8
+ ```ts
9
+ // convex/myFunctions.ts
10
+ import { query } from "./_generated/server";
11
+ import { v } from "convex/values";
12
+
13
+ export const myQueryFunction = query({
14
+ // Validators for arguments.
15
+ args: {
16
+ first: v.number(),
17
+ second: v.string(),
18
+ },
19
+
20
+ // Function implementation.
21
+ handler: async (ctx, args) => {
22
+ // Read the database as many times as you need here.
23
+ // See https://docs.convex.dev/database/reading-data.
24
+ const documents = await ctx.db.query("tablename").collect();
25
+
26
+ // Arguments passed from the client are properties of the args object.
27
+ console.log(args.first, args.second);
28
+
29
+ // Write arbitrary JavaScript here: filter, aggregate, build derived data,
30
+ // remove non-public properties, or create new objects.
31
+ return documents;
32
+ },
33
+ });
34
+ ```
35
+
36
+ Using this query function in a React component looks like:
37
+
38
+ ```ts
39
+ const data = useQuery(api.myFunctions.myQueryFunction, {
40
+ first: 10,
41
+ second: "hello",
42
+ });
43
+ ```
44
+
45
+ A mutation function looks like:
46
+
47
+ ```ts
48
+ // convex/myFunctions.ts
49
+ import { mutation } from "./_generated/server";
50
+ import { v } from "convex/values";
51
+
52
+ export const myMutationFunction = mutation({
53
+ // Validators for arguments.
54
+ args: {
55
+ first: v.string(),
56
+ second: v.string(),
57
+ },
58
+
59
+ // Function implementation.
60
+ handler: async (ctx, args) => {
61
+ // Insert or modify documents in the database here.
62
+ // Mutations can also read from the database like queries.
63
+ // See https://docs.convex.dev/database/writing-data.
64
+ const message = { body: args.first, author: args.second };
65
+ const id = await ctx.db.insert("messages", message);
66
+
67
+ // Optionally, return a value from your mutation.
68
+ return await ctx.db.get("messages", id);
69
+ },
70
+ });
71
+ ```
72
+
73
+ Using this mutation function in a React component looks like:
74
+
75
+ ```ts
76
+ const mutation = useMutation(api.myFunctions.myMutationFunction);
77
+ function handleButtonPress() {
78
+ // fire and forget, the most common way to use mutations
79
+ mutation({ first: "Hello!", second: "me" });
80
+ // OR
81
+ // use the result once the mutation has completed
82
+ mutation({ first: "Hello!", second: "me" }).then((result) =>
83
+ console.log(result),
84
+ );
85
+ }
86
+ ```
87
+
88
+ Use the Convex CLI to push your functions to a deployment. See everything
89
+ the Convex CLI can do by running `npx convex -h` in your project root
90
+ directory. To learn more, launch the docs with `npx convex docs`.
@@ -0,0 +1,55 @@
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 * as apiKeys from "../apiKeys.js";
12
+ import type * as purchases from "../purchases.js";
13
+ import type * as transactions from "../transactions.js";
14
+ import type * as users from "../users.js";
15
+
16
+ import type {
17
+ ApiFromModules,
18
+ FilterApi,
19
+ FunctionReference,
20
+ } from "convex/server";
21
+
22
+ declare const fullApi: ApiFromModules<{
23
+ apiKeys: typeof apiKeys;
24
+ purchases: typeof purchases;
25
+ transactions: typeof transactions;
26
+ users: typeof users;
27
+ }>;
28
+
29
+ /**
30
+ * A utility for referencing Convex functions in your app's public API.
31
+ *
32
+ * Usage:
33
+ * ```js
34
+ * const myFunctionReference = api.myModule.myFunction;
35
+ * ```
36
+ */
37
+ export declare const api: FilterApi<
38
+ typeof fullApi,
39
+ FunctionReference<any, "public">
40
+ >;
41
+
42
+ /**
43
+ * A utility for referencing Convex functions in your app's internal API.
44
+ *
45
+ * Usage:
46
+ * ```js
47
+ * const myFunctionReference = internal.myModule.myFunction;
48
+ * ```
49
+ */
50
+ export declare const internal: FilterApi<
51
+ typeof fullApi,
52
+ FunctionReference<any, "internal">
53
+ >;
54
+
55
+ export declare const components: {};
@@ -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();
@@ -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>;
@@ -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>;