Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions .cursor/rules/convex_rules.mdc
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ Note: `paginationOpts` is an object with the following properties:

## Schema guidelines
- Always define your schema in `convex/schema.ts`.
- Always import the schema definition functions from `convex/server`:
- Always import the schema definition functions from `convex/server`.
- System fields are automatically added to all documents and are prefixed with an underscore. The two system fields that are automatically added to all documents are `_creationTime` which has the validator `v.number()` and `_id` which has the validator `v.id(tableName)`.
- Always include all index fields in the index name. For example, if an index is defined as `["field1", "field2"]`, the index name should be "by_field1_and_field2".
- Index fields must be queried in the same order they are defined. If you want to be able to query by "field1" then "field2" and by "field2" then "field1", you must create separate indexes.
Expand Down Expand Up @@ -480,8 +480,8 @@ import OpenAI from "openai";
import { internal } from "./_generated/api";

/**
* Create a user with a given name.
*/
* Create a user with a given name.
*/
export const createUser = mutation({
args: {
name: v.string(),
Expand All @@ -493,8 +493,8 @@ export const createUser = mutation({
});

/**
* Create a channel with a given name.
*/
* Create a channel with a given name.
*/
export const createChannel = mutation({
args: {
name: v.string(),
Expand All @@ -506,8 +506,8 @@ export const createChannel = mutation({
});

/**
* List the 10 most recent messages from a channel in descending creation order.
*/
* List the 10 most recent messages from a channel in descending creation order.
*/
export const listMessages = query({
args: {
channelId: v.id("channels"),
Expand All @@ -532,8 +532,8 @@ export const listMessages = query({
});

/**
* Send a message to a channel and schedule a response from the AI.
*/
* Send a message to a channel and schedule a response from the AI.
*/
export const sendMessage = mutation({
args: {
channelId: v.id("channels"),
Expand Down Expand Up @@ -672,5 +672,4 @@ export default defineSchema({
export default function App() {
return <div>Hello World</div>;
}
```

```
59 changes: 59 additions & 0 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Preview Playground PR

on:
pull_request:
paths:
- "playground/**"

permissions:
contents: read
pull-requests: write

jobs:
preview:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4

- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: 20
cache: "npm"

- name: Install root dependencies & build
run: npm ci && npm run build

- name: Install playground dependencies
run: cd playground && npm i

- name: Build Vite project
run: cd playground && npm run build

- name: Enable SPA routing
run: cp playground/dist/index.html playground/dist/200.html

- name: Deploy to Surge
run: |
npm install -g surge
surge playground/dist agent-pr-${{ github.event.pull_request.number }}.surge.sh --token ${{ secrets.SURGE_TOKEN }}

- name: Comment PR with preview URL
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7
with:
script: |
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});

if (comments.some(c => c.body.includes('🚀 Preview Deployment'))) {
return; // Already commented
}

await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: `## 🚀 Preview Deployment\n\nYour preview is ready!\n\n**URL:** https://agent-pr-${{ github.event.pull_request.number }}.surge.sh`
});
2 changes: 1 addition & 1 deletion example/convex/_generated/dataModel.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export type Doc<TableName extends TableNames> = DocumentByName<
* Convex documents are uniquely identified by their `Id`, which is accessible
* on the `_id` field. To learn more, see [Document IDs](https://docs.convex.dev/using/document-ids).
*
* Documents can be loaded using `db.get(id)` in query and mutation functions.
* Documents can be loaded using `db.get(tableName, id)` in query and mutation functions.
*
* IDs are just strings at runtime, but this type can be used to distinguish them from other
* strings when type checking.
Expand Down
Loading
Loading