Skip to content

Commit

Permalink
Merge branch 'canary' into qr/fix-build-module-resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
qrohlf authored Feb 14, 2023
2 parents 82f28f0 + 3b1aa1c commit b4c57fc
Show file tree
Hide file tree
Showing 117 changed files with 1,522 additions and 406 deletions.
12 changes: 12 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@
"NEXT_PRIVATE_LOCAL_WEBPACK": "1"
}
},
{
"name": "Launch app-dir build",
"type": "node",
"request": "launch",
"cwd": "${workspaceFolder}",
"runtimeExecutable": "pnpm",
"runtimeArgs": ["debug", "build", "test/e2e/app-dir/app"],
"skipFiles": ["<node_internals>/**"],
"env": {
"NEXT_PRIVATE_LOCAL_WEBPACK": "1"
}
},
{
"name": "Launch app development",
"type": "node",
Expand Down
1 change: 1 addition & 0 deletions examples/convex/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Production environment variables go here
2 changes: 1 addition & 1 deletion examples/convex/convex/_generated/api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
31 changes: 0 additions & 31 deletions examples/convex/convex/_generated/clientConfig.d.ts

This file was deleted.

31 changes: 0 additions & 31 deletions examples/convex/convex/_generated/clientConfig.js

This file was deleted.

19 changes: 9 additions & 10 deletions examples/convex/convex/_generated/dataModel.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -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.
*
Expand All @@ -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.
*
Expand Down
2 changes: 1 addition & 1 deletion examples/convex/convex/_generated/dataModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
2 changes: 1 addition & 1 deletion examples/convex/convex/_generated/react.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
2 changes: 1 addition & 1 deletion examples/convex/convex/_generated/react.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
38 changes: 30 additions & 8 deletions examples/convex/convex/_generated/server.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -40,15 +42,15 @@ 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.
*
* 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`.
*
Expand All @@ -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.
*
Expand All @@ -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.
*
Expand Down
34 changes: 25 additions & 9 deletions examples/convex/convex/_generated/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;
12 changes: 6 additions & 6 deletions examples/convex/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
3 changes: 1 addition & 2 deletions examples/convex/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
8 changes: 5 additions & 3 deletions examples/with-docker-compose/next-app/prod.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM node:18-alpine AS base

# Step 1. Rebuild the source code only when needed
FROM node:18-alpine AS builder
FROM base AS builder

WORKDIR /app

Expand Down Expand Up @@ -41,7 +43,7 @@ RUN \
# Note: It is not necessary to add an intermediate step that does a full copy of `node_modules` here

# Step 2. Production image, copy all the files and run next
FROM node:18-alpine AS runner
FROM base AS runner

WORKDIR /app

Expand All @@ -68,4 +70,4 @@ ENV NEXT_PUBLIC_ENV_VARIABLE=${NEXT_PUBLIC_ENV_VARIABLE}

# Note: Don't expose ports here, Compose will handle that for us

CMD node server.js
CMD ["node", "server.js"]
8 changes: 5 additions & 3 deletions examples/with-docker-multi-env/docker/development/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM node:18-alpine AS base

# 1. Install dependencies only when needed
FROM node:16-alpine AS deps
FROM base AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat

Expand All @@ -15,7 +17,7 @@ RUN \
fi

# 2. Rebuild the source code only when needed
FROM node:16-alpine AS builder
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
Expand All @@ -24,7 +26,7 @@ COPY .env.development.sample .env.production
RUN yarn build

# 3. Production image, copy all the files and run next
FROM node:16-alpine AS runner
FROM base AS runner
WORKDIR /app

ENV NODE_ENV=production
Expand Down
Loading

0 comments on commit b4c57fc

Please sign in to comment.