Unverified Commit d83a3c8e authored by Tom Ballinger's avatar Tom Ballinger Committed by GitHub

Update Convex demo to 0.9.1 (#45866)

Update Convex to 0.9.1

## Documentation / Examples

- [x] Make sure the linting passes by running `pnpm build && pnpm lint`
- [x] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
parent 6ea64002
# Production environment variables go here
......@@ -4,7 +4,7 @@
*
* THIS CODE IS AUTOMATICALLY GENERATED.
*
* Generated by convex@0.5.0.
* Generated by convex@0.9.1.
* To regenerate, run `npx convex codegen`.
* @module
*/
......
/* eslint-disable */
/**
* Generated development client configuration.
*
* THIS CODE IS AUTOMATICALLY GENERATED.
*
* Generated by convex@0.5.0.
* To regenerate, run `npx convex codegen`.
* @module
*/
import type { ClientConfiguration } from "convex/browser";
/**
* The DEV Convex client configuration.
*
* This configuration connects your client to your dev Convex deployment
* when `npx convex dev` is running.
*
* To generate the production version, run `npx convex deploy`.
*
* Usage:
*
* ```ts
* import clientConfig from "../convex/_generated/clientConfig";
*
* const convex = new ConvexReactClient(clientConfig);
* ```
*/
declare const clientConfig: ClientConfiguration;
export default clientConfig;
/* eslint-disable */
/**
* Generated development client configuration.
*
* THIS CODE IS AUTOMATICALLY GENERATED.
*
* Generated by convex@0.5.0.
* To regenerate, run `npx convex codegen`.
* @module
*/
/**
* The DEV Convex client configuration.
*
* This configuration connects your client to your dev Convex deployment
* when `npx convex dev` is running.
*
* To generate the production version, run `npx convex deploy`.
*
* Usage:
*
* ```ts
* import clientConfig from "../convex/_generated/clientConfig";
*
* const convex = new ConvexReactClient(clientConfig);
* ```
*/
const clientConfig = {
address: "http://localhost:8187",
};
export default clientConfig;
......@@ -4,16 +4,13 @@
*
* THIS CODE IS AUTOMATICALLY GENERATED.
*
* Generated by convex@0.5.0.
* Generated by convex@0.9.1.
* To regenerate, run `npx convex codegen`.
* @module
*/
import type {
DataModelFromSchemaDefinition,
DocumentMapFromSchemaDefinition,
} from "convex/schema";
import type { TableNamesInDataModel } from "convex/server";
import type { DataModelFromSchemaDefinition } from "convex/schema";
import type { DocumentByName, TableNamesInDataModel } from "convex/server";
import { GenericId, GenericIdConstructor } from "convex/values";
import schema from "../schema";
......@@ -27,14 +24,16 @@ export type TableNames = TableNamesInDataModel<DataModel>;
*
* @typeParam TableName - A string literal type of the table name (like "users").
*/
export type Document<TableName extends TableNames> =
DocumentMapFromSchemaDefinition<typeof schema>[TableName];
export type Document<TableName extends TableNames> = DocumentByName<
DataModel,
TableName
>;
/**
* An identifier for a document in Convex.
*
* Convex documents are uniquely identified by their `Id`, which is accessible
* on the `_id` field. To learn more, see [Data Modeling](https://docs.convex.dev/using/data-modeling).
* 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.
*
......@@ -50,7 +49,7 @@ export type Id<TableName extends TableNames> = GenericId<TableName>;
* An identifier for a document in Convex.
*
* Convex documents are uniquely identified by their `Id`, which is accessible
* on the `_id` field. To learn more, see [Data Modeling](https://docs.convex.dev/using/data-modeling).
* 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.
*
......
......@@ -4,7 +4,7 @@
*
* THIS CODE IS AUTOMATICALLY GENERATED.
*
* Generated by convex@0.5.0.
* Generated by convex@0.9.1.
* To regenerate, run `npx convex codegen`.
* @module
*/
......
......@@ -4,7 +4,7 @@
*
* THIS CODE IS AUTOMATICALLY GENERATED.
*
* Generated by convex@0.5.0.
* Generated by convex@0.9.1.
* To regenerate, run `npx convex codegen`.
* @module
*/
......
......@@ -4,7 +4,7 @@
*
* THIS CODE IS AUTOMATICALLY GENERATED.
*
* Generated by convex@0.5.0.
* Generated by convex@0.9.1.
* To regenerate, run `npx convex codegen`.
* @module
*/
......
......@@ -4,18 +4,20 @@
*
* THIS CODE IS AUTOMATICALLY GENERATED.
*
* Generated by convex@0.5.0.
* Generated by convex@0.9.1.
* To regenerate, run `npx convex codegen`.
* @module
*/
import {
ActionBuilderForAPI,
MutationBuilderForDataModel,
HttpEndpointBuilderForAPI,
MutationBuilder,
QueryBuilderForDataModel,
ActionCtx as GenericActionCtx,
QueryCtx as GenericQueryCtx,
HttpEndpointCtx as GenericHttpEndpointCtx,
MutationCtx as GenericMutationCtx,
QueryCtx as GenericQueryCtx,
DatabaseReader as GenericDatabaseReader,
DatabaseWriter as GenericDatabaseWriter,
} from "convex/server";
......@@ -40,7 +42,7 @@ export declare const query: QueryBuilderForDataModel<DataModel>;
* @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
* @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
*/
export declare const mutation: MutationBuilderForDataModel<DataModel>;
export declare const mutation: MutationBuilder<DataModel, API>;
/**
* Define an action in this Convex app's public API.
......@@ -48,7 +50,7 @@ export declare const mutation: MutationBuilderForDataModel<DataModel>;
* An action is a function which can execute any JavaScript code, including non-deterministic
* code and code with side-effects. Actions are often used to call into third-party services.
* Actions execute in a Node.js environment and can interact with the database indirectly by
* calling queries and mutations via the provided `dbFunctions` object. Actions need to be defined
* calling queries and mutations via the provided {@link ActionCtx} object. Actions need to be defined
* in the `/convex/actions directory`. Queries and mutations, on the other hand, must be defined
* outside of the `/convex/actions directory`.
*
......@@ -57,6 +59,18 @@ export declare const mutation: MutationBuilderForDataModel<DataModel>;
*/
export declare const action: ActionBuilderForAPI<API>;
/**
* Define an HTTP endpoint.
*
* This function will be used to respond to HTTP requests received by a Convex
* deployment if the requests matches the path and method where this endpoint
* is routed. Be sure to route your endpoint in `convex/http.js`.
*
* @param func - The endpoint function. It receives a {@link HttpEndpointCtx} as its first argument.
* @returns The wrapped endpoint function. Import this function from `convex/http.js` and route it to hook it up.
*/
export declare const httpEndpoint: HttpEndpointBuilderForAPI<API>;
/**
* A set of services for use within Convex query functions.
*
......@@ -74,16 +88,24 @@ export type QueryCtx = GenericQueryCtx<DataModel>;
* The mutation context is passed as the first argument to any Convex mutation
* function run on the server.
*/
export type MutationCtx = GenericMutationCtx<DataModel>;
export type MutationCtx = GenericMutationCtx<DataModel, API>;
/**
* A set of services for use within Convex mutation functions.
* A set of services for use within Convex action functions.
*
* The mutation context is passed as the first argument to any Convex mutation
* The action context is passed as the first argument to any Convex action
* function run on the server.
*/
export type ActionCtx = GenericActionCtx<API>;
/**
* A set of services for use within Convex HTTP endpoints.
*
* The HttpEndpointCtx is passed as the first argument to any Convex HTTP
* endpoint run on the server.
*/
export type HttpEndpointCtx = GenericHttpEndpointCtx<API>;
/**
* An interface to read from the database within Convex query functions.
*
......
......@@ -4,12 +4,17 @@
*
* THIS CODE IS AUTOMATICALLY GENERATED.
*
* Generated by convex@0.5.0.
* Generated by convex@0.9.1.
* To regenerate, run `npx convex codegen`.
* @module
*/
import { actionGeneric, queryGeneric, mutationGeneric } from "convex/server";
import {
actionGeneric,
httpEndpointGeneric,
queryGeneric,
mutationGeneric,
} from "convex/server";
/**
* Define a query in this Convex app's public API.
......@@ -32,14 +37,25 @@ export const query = queryGeneric;
export const mutation = mutationGeneric;
/**
* Define a function in this Convex app's public API.
* Define an action in this Convex app's public API.
*
* This is a generic function which unlike queries and mutations can execute any
* JavaScript code. Node functions execute in a Node.js environment and can
* interact with the database by calling queries and mutations via the provided
* convex object. Node functions need to be defined in /convex/node directory.
* An action is a function which can execute any JavaScript code, including non-deterministic
* code and code with side-effects. Actions are often used to call into third-party services.
* Actions execute in a Node.js environment and can interact with the database indirectly by
* calling queries and mutations via the provided {@link ActionCtx} object. Actions need to be defined
* in the `/convex/actions directory`. Queries and mutations, on the other hand, must be defined
* outside of the `/convex/actions directory`.
*
* @param func - The function. It receives a {@link ActionCtx} as its first argument.
* @returns The wrapped function. Include this as an `export` to name it and make it accessible.
* @param func - The action. It receives a {@link ActionCtx} as its first argument.
* @returns The wrapped action. Include this as an `export` to name it and make it accessible.
*/
export const action = actionGeneric;
/**
* Define a Convex HTTP endpoint.
*
* @param func - The function. It receives an {@link HttpEndpointCtx} as its first argument, and a `Request` object
* as its second.
* @returns The wrapped endpoint function. Route a URL path to this function in `convex/http.js`.
*/
export const httpEndpoint = httpEndpointGeneric;
......@@ -10,17 +10,17 @@
"start": "next start"
},
"dependencies": {
"convex": "0.6.0",
"convex": "0.9.1",
"next": "latest",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/node": "^18.11.11",
"@types/react": "^18.0.26",
"@types/react-dom": "^18.0.9",
"@types/node": "^18.13.0",
"@types/react": "^18.0.28",
"@types/react-dom": "^18.0.10",
"npm-run-all": "^4.1.5",
"prettier": "^2.7.1",
"typescript": "^4.7.3"
"prettier": "^2.8.4",
"typescript": "^4.9.5"
}
}
......@@ -2,8 +2,7 @@ import '../styles/globals.css'
import type { AppProps } from 'next/app'
import { ConvexProvider, ConvexReactClient } from 'convex/react'
import clientConfig from '../convex/_generated/clientConfig'
const convex = new ConvexReactClient(clientConfig)
const convex = new ConvexReactClient(process.env.NEXT_PUBLIC_CONVEX_URL)
function MyApp({ Component, pageProps }: AppProps) {
return (
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment