@tanstack/cta-framework-solid 0.27.1 → 0.29.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.
- package/ADD-ON-AUTHORING.md +211 -1
- package/add-ons/convex/README.md +4 -0
- package/add-ons/convex/assets/_dot_cursorrules.append +93 -0
- package/add-ons/convex/assets/_dot_env.local.append +3 -0
- package/add-ons/convex/assets/convex/_generated/api.d.ts +36 -0
- package/add-ons/convex/assets/convex/_generated/api.js +22 -0
- package/add-ons/convex/assets/convex/_generated/dataModel.d.ts +60 -0
- package/add-ons/convex/assets/convex/_generated/server.d.ts +142 -0
- package/add-ons/convex/assets/convex/_generated/server.js +89 -0
- package/add-ons/convex/assets/convex/schema.ts +14 -0
- package/add-ons/convex/assets/convex/todos.ts +43 -0
- package/add-ons/convex/assets/convex/tsconfig.json +25 -0
- package/add-ons/convex/assets/src/integrations/convex/provider.tsx +12 -0
- package/add-ons/convex/assets/src/routes/demo/convex.tsx +169 -0
- package/add-ons/convex/info.json +23 -0
- package/add-ons/convex/package.json +7 -0
- package/add-ons/convex/small-logo.svg +5 -0
- package/add-ons/start/assets/public/tanstack-circle-logo.png +0 -0
- package/add-ons/start/assets/public/tanstack-word-logo-white.svg +1 -0
- package/add-ons/start/assets/src/router.tsx.ejs +0 -2
- package/add-ons/start/assets/src/routes/index.tsx.ejs +154 -0
- package/add-ons/start/package.json +3 -2
- package/add-ons/strapi/README.md +14 -0
- package/add-ons/strapi/assets/_dot_env.local.append +2 -0
- package/add-ons/strapi/assets/src/lib/strapiClient.ts +7 -0
- package/add-ons/strapi/assets/src/routes/demo/strapi.tsx +69 -0
- package/add-ons/strapi/assets/src/routes/demo/strapi_.$articleId.tsx +78 -0
- package/add-ons/strapi/info.json +18 -0
- package/add-ons/strapi/package.json +5 -0
- package/add-ons/strapi/small-logo.svg +8 -0
- package/package.json +2 -2
- package/project/base/src/components/Header.tsx.ejs +160 -11
- package/project/base/src/routes/__root.tsx.ejs +5 -0
- package/tests/snapshots/solid/solid-cr-ts-start-npm.json +5 -5
- package/tests/snapshots/solid/solid-fr-ts-npm.json +1 -1
- package/tests/snapshots/solid/solid-fr-ts-tw-npm.json +1 -1
package/ADD-ON-AUTHORING.md
CHANGED
|
@@ -79,7 +79,7 @@ The code is integrated into these locations with these application architectures
|
|
|
79
79
|
Code in `assets/src/components/my-provider.tsx`:
|
|
80
80
|
|
|
81
81
|
```ts
|
|
82
|
-
export default function MyProvider({ children }: { children:
|
|
82
|
+
export default function MyProvider({ children }: { children: JSX.Element }) {
|
|
83
83
|
return <SomeKindOfProvider>{children}</SomeKindOfProvider>
|
|
84
84
|
}
|
|
85
85
|
```
|
|
@@ -153,3 +153,213 @@ If you don't want a header link you can omit the `url` and `name` properties.
|
|
|
153
153
|
You **MUST** specify routes in the `info.json` file if your add-on supports the `code-router` mode. This is because the `code-routers` setup needs to import the routes in order to add them to the router.
|
|
154
154
|
|
|
155
155
|
By convension you should prefix demo routes with `demo` to make it clear that they are demo routes so they can be easily identified and removed.
|
|
156
|
+
|
|
157
|
+
# Add-on Options
|
|
158
|
+
|
|
159
|
+
The CTA framework supports configurable add-ons through an options system that allows users to customize add-on behavior during creation. This enables more flexible and reusable add-ons that can adapt to different use cases.
|
|
160
|
+
|
|
161
|
+
## Overview
|
|
162
|
+
|
|
163
|
+
Add-on options allow developers to create configurable add-ons where users can select from predefined choices that affect:
|
|
164
|
+
|
|
165
|
+
- Which files are included in the generated project
|
|
166
|
+
- Template variable values used during file generation
|
|
167
|
+
- Package dependencies that get installed
|
|
168
|
+
- Configuration file contents
|
|
169
|
+
|
|
170
|
+
## Configuration Format
|
|
171
|
+
|
|
172
|
+
Options are defined in the `info.json` file using the following schema:
|
|
173
|
+
|
|
174
|
+
```json
|
|
175
|
+
{
|
|
176
|
+
"name": "My Add-on",
|
|
177
|
+
"description": "A configurable add-on",
|
|
178
|
+
"options": {
|
|
179
|
+
"optionName": {
|
|
180
|
+
"type": "select",
|
|
181
|
+
"label": "Display Label",
|
|
182
|
+
"description": "Optional description shown to users",
|
|
183
|
+
"default": "defaultValue",
|
|
184
|
+
"options": [
|
|
185
|
+
{ "value": "option1", "label": "Option 1" },
|
|
186
|
+
{ "value": "option2", "label": "Option 2" }
|
|
187
|
+
]
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Option Types
|
|
194
|
+
|
|
195
|
+
#### Select Options
|
|
196
|
+
|
|
197
|
+
The `select` type allows users to choose from a predefined list of options:
|
|
198
|
+
|
|
199
|
+
```json
|
|
200
|
+
"database": {
|
|
201
|
+
"type": "select",
|
|
202
|
+
"label": "Database Provider",
|
|
203
|
+
"description": "Choose your database provider",
|
|
204
|
+
"default": "postgres",
|
|
205
|
+
"options": [
|
|
206
|
+
{ "value": "postgres", "label": "PostgreSQL" },
|
|
207
|
+
{ "value": "mysql", "label": "MySQL" },
|
|
208
|
+
{ "value": "sqlite", "label": "SQLite" }
|
|
209
|
+
]
|
|
210
|
+
}
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
**Properties:**
|
|
214
|
+
|
|
215
|
+
- `type`: Must be `"select"`
|
|
216
|
+
- `label`: Display text shown to users
|
|
217
|
+
- `description`: Optional help text
|
|
218
|
+
- `default`: Default value that must match one of the option values
|
|
219
|
+
- `options`: Array of value/label pairs
|
|
220
|
+
|
|
221
|
+
## Template Usage
|
|
222
|
+
|
|
223
|
+
Option values are available in EJS templates through the `addOnOption` variable:
|
|
224
|
+
|
|
225
|
+
```ejs
|
|
226
|
+
<!-- Access option value -->
|
|
227
|
+
<% if (addOnOption.myAddOnId.database === 'postgres') { %>
|
|
228
|
+
PostgreSQL specific code
|
|
229
|
+
<% } %>
|
|
230
|
+
|
|
231
|
+
<!-- Use option value in output -->
|
|
232
|
+
const driver = '<%= addOnOption.myAddOnId.database %>'
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
The structure is: `addOnOption.{addOnId}.{optionName}`
|
|
236
|
+
|
|
237
|
+
### Template Conditional Logic
|
|
238
|
+
|
|
239
|
+
Within template files, use `ignoreFile()` to skip file generation:
|
|
240
|
+
|
|
241
|
+
```ejs
|
|
242
|
+
<% if (addOnOption.database.database !== 'postgres') { ignoreFile() } %>
|
|
243
|
+
import { PrismaClient } from '@prisma/client'
|
|
244
|
+
|
|
245
|
+
declare global {
|
|
246
|
+
var __prisma: PrismaClient | undefined
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export const prisma = globalThis.__prisma || new PrismaClient()
|
|
250
|
+
|
|
251
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
252
|
+
globalThis.__prisma = prisma
|
|
253
|
+
}
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
## Complete Example: Database Add-on
|
|
257
|
+
|
|
258
|
+
Here's how you could implement a configurable database add-on for Solid:
|
|
259
|
+
|
|
260
|
+
### Examples
|
|
261
|
+
|
|
262
|
+
Configuration in `info.json`:
|
|
263
|
+
|
|
264
|
+
```json
|
|
265
|
+
{
|
|
266
|
+
"name": "Database Integration",
|
|
267
|
+
"description": "Add database support with configurable providers to your Solid application.",
|
|
268
|
+
"modes": ["file-router"],
|
|
269
|
+
"options": {
|
|
270
|
+
"database": {
|
|
271
|
+
"type": "select",
|
|
272
|
+
"label": "Database Provider",
|
|
273
|
+
"description": "Choose your database provider",
|
|
274
|
+
"default": "postgres",
|
|
275
|
+
"options": [
|
|
276
|
+
{ "value": "postgres", "label": "PostgreSQL" },
|
|
277
|
+
{ "value": "mysql", "label": "MySQL" },
|
|
278
|
+
{ "value": "sqlite", "label": "SQLite" }
|
|
279
|
+
]
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
Code in `assets/src/routes/demo.database.tsx.ejs`:
|
|
286
|
+
|
|
287
|
+
```ejs
|
|
288
|
+
import { createSignal, onMount } from 'solid-js'
|
|
289
|
+
|
|
290
|
+
export default function DatabaseDemo() {
|
|
291
|
+
const [status, setStatus] = createSignal('Connecting...')
|
|
292
|
+
|
|
293
|
+
onMount(async () => {
|
|
294
|
+
try {
|
|
295
|
+
// Database-specific connection logic
|
|
296
|
+
<% if (addOnOption.database.database === 'postgres') { %>
|
|
297
|
+
const { prisma } = await import('../db')
|
|
298
|
+
await prisma.$connect()
|
|
299
|
+
setStatus('Connected to PostgreSQL!')
|
|
300
|
+
<% } else if (addOnOption.database.database === 'mysql') { %>
|
|
301
|
+
const { prisma } = await import('../db')
|
|
302
|
+
await prisma.$connect()
|
|
303
|
+
setStatus('Connected to MySQL!')
|
|
304
|
+
<% } else if (addOnOption.database.database === 'sqlite') { %>
|
|
305
|
+
const { prisma } = await import('../db')
|
|
306
|
+
await prisma.$connect()
|
|
307
|
+
setStatus('Connected to SQLite!')
|
|
308
|
+
<% } %>
|
|
309
|
+
} catch (error) {
|
|
310
|
+
setStatus(`Connection failed: ${error.message}`)
|
|
311
|
+
}
|
|
312
|
+
})
|
|
313
|
+
|
|
314
|
+
return (
|
|
315
|
+
<div>
|
|
316
|
+
<h1>Database Demo</h1>
|
|
317
|
+
<p>Database Type: <%= addOnOption.database.database %></p>
|
|
318
|
+
<p>Status: {status()}</p>
|
|
319
|
+
</div>
|
|
320
|
+
)
|
|
321
|
+
}
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
Code in `package.json.ejs`:
|
|
325
|
+
|
|
326
|
+
```ejs
|
|
327
|
+
{
|
|
328
|
+
"prisma": "^6.16.3",
|
|
329
|
+
"@prisma/client": "^6.16.3"<% if (addOnOption.database.database === 'postgres') { %>,
|
|
330
|
+
"pg": "^8.11.0",
|
|
331
|
+
"@types/pg": "^8.10.0"<% } else if (addOnOption.database.database === 'mysql') { %>,
|
|
332
|
+
"mysql2": "^3.6.0"<% } else if (addOnOption.database.database === 'sqlite') { %><% } %>
|
|
333
|
+
}
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
## CLI Usage
|
|
337
|
+
|
|
338
|
+
### Interactive Mode
|
|
339
|
+
|
|
340
|
+
When using the CLI interactively, users are prompted for each option:
|
|
341
|
+
|
|
342
|
+
```bash
|
|
343
|
+
create-tsrouter-app my-solid-app
|
|
344
|
+
# User selects database add-on
|
|
345
|
+
# CLI prompts: "Database Integration: Database Provider" with options
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
### Non-Interactive Mode
|
|
349
|
+
|
|
350
|
+
Options can be specified via JSON configuration:
|
|
351
|
+
|
|
352
|
+
```bash
|
|
353
|
+
create-tsrouter-app my-solid-app --add-ons database --add-on-config '{"database":{"database":"mysql"}}'
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
## Best Practices
|
|
357
|
+
|
|
358
|
+
1. **Use descriptive labels** - Make option purposes clear to users
|
|
359
|
+
2. **Provide sensible defaults** - Choose the most common use case
|
|
360
|
+
3. **Group related files** - Use consistent prefixing for option-specific files
|
|
361
|
+
4. **Document options** - Include descriptions to help users understand choices
|
|
362
|
+
5. **Test all combinations** - Ensure each option value generates working code
|
|
363
|
+
6. **Use validation** - The system validates options against the schema automatically
|
|
364
|
+
7. **Consider Solid patterns** - Use Solid-specific patterns like signals and resources
|
|
365
|
+
8. **Framework compatibility** - Ensure generated code works with Solid's reactivity system
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
This document serves as some special instructions when working with Convex.
|
|
2
|
+
|
|
3
|
+
# Schemas
|
|
4
|
+
|
|
5
|
+
When designing the schema please see this page on built in System fields and data types available: https://docs.convex.dev/database/types
|
|
6
|
+
|
|
7
|
+
Here are some specifics that are often mishandled:
|
|
8
|
+
|
|
9
|
+
## v (https://docs.convex.dev/api/modules/values#v)
|
|
10
|
+
|
|
11
|
+
The validator builder.
|
|
12
|
+
|
|
13
|
+
This builder allows you to build validators for Convex values.
|
|
14
|
+
|
|
15
|
+
Validators can be used in schema definitions and as input validators for Convex functions.
|
|
16
|
+
|
|
17
|
+
Type declaration
|
|
18
|
+
Name Type
|
|
19
|
+
id <TableName>(tableName: TableName) => VId<GenericId<TableName>, "required">
|
|
20
|
+
null () => VNull<null, "required">
|
|
21
|
+
number () => VFloat64<number, "required">
|
|
22
|
+
float64 () => VFloat64<number, "required">
|
|
23
|
+
bigint () => VInt64<bigint, "required">
|
|
24
|
+
int64 () => VInt64<bigint, "required">
|
|
25
|
+
boolean () => VBoolean<boolean, "required">
|
|
26
|
+
string () => VString<string, "required">
|
|
27
|
+
bytes () => VBytes<ArrayBuffer, "required">
|
|
28
|
+
literal <T>(literal: T) => VLiteral<T, "required">
|
|
29
|
+
array <T>(element: T) => VArray<T["type"][], T, "required">
|
|
30
|
+
object <T>(fields: T) => VObject<Expand<{ [Property in string | number | symbol]?: Exclude<Infer<T[Property]>, undefined> } & { [Property in string | number | symbol]: Infer<T[Property]> }>, T, "required", { [Property in string | number | symbol]: Property | `${Property & string}.${T[Property]["fieldPaths"]}` }[keyof T] & string>
|
|
31
|
+
record <Key, Value>(keys: Key, values: Value) => VRecord<Record<Infer<Key>, Value["type"]>, Key, Value, "required", string>
|
|
32
|
+
union <T>(...members: T) => VUnion<T[number]["type"], T, "required", T[number]["fieldPaths"]>
|
|
33
|
+
any () => VAny<any, "required", string>
|
|
34
|
+
optional <T>(value: T) => VOptional<T>
|
|
35
|
+
|
|
36
|
+
## System fields (https://docs.convex.dev/database/types#system-fields)
|
|
37
|
+
|
|
38
|
+
Every document in Convex has two automatically-generated system fields:
|
|
39
|
+
|
|
40
|
+
_id: The document ID of the document.
|
|
41
|
+
_creationTime: The time this document was created, in milliseconds since the Unix epoch.
|
|
42
|
+
|
|
43
|
+
You do not need to add indices as these are added automatically.
|
|
44
|
+
|
|
45
|
+
## Example Schema
|
|
46
|
+
|
|
47
|
+
This is an example of a well crafted schema.
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
import { defineSchema, defineTable } from "convex/server";
|
|
51
|
+
import { v } from "convex/values";
|
|
52
|
+
|
|
53
|
+
export default defineSchema(
|
|
54
|
+
{
|
|
55
|
+
users: defineTable({
|
|
56
|
+
name: v.string(),
|
|
57
|
+
}),
|
|
58
|
+
|
|
59
|
+
sessions: defineTable({
|
|
60
|
+
userId: v.id("users"),
|
|
61
|
+
sessionId: v.string(),
|
|
62
|
+
}).index("sessionId", ["sessionId"]),
|
|
63
|
+
|
|
64
|
+
threads: defineTable({
|
|
65
|
+
uuid: v.string(),
|
|
66
|
+
summary: v.optional(v.string()),
|
|
67
|
+
summarizer: v.optional(v.id("_scheduled_functions")),
|
|
68
|
+
}).index("uuid", ["uuid"]),
|
|
69
|
+
|
|
70
|
+
messages: defineTable({
|
|
71
|
+
message: v.string(),
|
|
72
|
+
threadId: v.id("threads"),
|
|
73
|
+
author: v.union(
|
|
74
|
+
v.object({
|
|
75
|
+
role: v.literal("system"),
|
|
76
|
+
}),
|
|
77
|
+
v.object({
|
|
78
|
+
role: v.literal("assistant"),
|
|
79
|
+
context: v.array(v.id("messages")),
|
|
80
|
+
model: v.optional(v.string()),
|
|
81
|
+
}),
|
|
82
|
+
v.object({
|
|
83
|
+
role: v.literal("user"),
|
|
84
|
+
userId: v.id("users"),
|
|
85
|
+
}),
|
|
86
|
+
),
|
|
87
|
+
})
|
|
88
|
+
.index("threadId", ["threadId"]),
|
|
89
|
+
},
|
|
90
|
+
);
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Sourced from: https://github.com/PatrickJS/awesome-cursorrules/blob/main/rules/convex-cursorrules-prompt-file/.cursorrules
|
|
@@ -0,0 +1,36 @@
|
|
|
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 {
|
|
12
|
+
ApiFromModules,
|
|
13
|
+
FilterApi,
|
|
14
|
+
FunctionReference,
|
|
15
|
+
} from "convex/server";
|
|
16
|
+
import type * as todos from "../todos.js";
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A utility for referencing Convex functions in your app's API.
|
|
20
|
+
*
|
|
21
|
+
* Usage:
|
|
22
|
+
* ```js
|
|
23
|
+
* const myFunctionReference = api.myModule.myFunction;
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
declare const fullApi: ApiFromModules<{
|
|
27
|
+
todos: typeof todos;
|
|
28
|
+
}>;
|
|
29
|
+
export declare const api: FilterApi<
|
|
30
|
+
typeof fullApi,
|
|
31
|
+
FunctionReference<any, "public">
|
|
32
|
+
>;
|
|
33
|
+
export declare const internal: FilterApi<
|
|
34
|
+
typeof fullApi,
|
|
35
|
+
FunctionReference<any, "internal">
|
|
36
|
+
>;
|
|
@@ -0,0 +1,22 @@
|
|
|
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 } 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;
|
|
@@ -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(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,142 @@
|
|
|
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,0 +1,89 @@
|
|
|
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 a Convex HTTP action.
|
|
84
|
+
*
|
|
85
|
+
* @param func - The function. It receives an {@link ActionCtx} as its first argument, and a `Request` object
|
|
86
|
+
* as its second.
|
|
87
|
+
* @returns The wrapped endpoint function. Route a URL path to this function in `convex/http.js`.
|
|
88
|
+
*/
|
|
89
|
+
export const httpAction = httpActionGeneric;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { defineSchema, defineTable } from 'convex/server'
|
|
2
|
+
import { v } from 'convex/values'
|
|
3
|
+
|
|
4
|
+
export default defineSchema({
|
|
5
|
+
products: defineTable({
|
|
6
|
+
title: v.string(),
|
|
7
|
+
imageId: v.string(),
|
|
8
|
+
price: v.number(),
|
|
9
|
+
}),
|
|
10
|
+
todos: defineTable({
|
|
11
|
+
text: v.string(),
|
|
12
|
+
completed: v.boolean(),
|
|
13
|
+
}),
|
|
14
|
+
})
|