Skip to content

Commit 117a108

Browse files
yyyyaaaclaude
andcommitted
Merge origin/main into feat/blocks: resolve provision-layer conflicts
Reconcile origin/main (version-sync + finish-graphql-export-flow, #26/#27) with the Blocks tiering refactor that routes app provisioning to the modules host, bakes provision recipes into the template, and tiers the base template to auth:email. Ten provision-layer files were reconciled across the merge: graphql/provision/provision.ts and the nextjs/constructive-app packages/provision sources (config.ts, create-db.ts, helpers.ts, provision.ts, seed/index.ts) plus the baked provision recipes (provision_new_user procedure, app_namespaces namespaceprovision trigger + trigger fn). main's version-sync and export-flow changes are kept alongside the tiering refactor's routing of provisioning to the modules host. use-create-organization.ts stays deleted: the base tier strips the org/b2b surface, so the admin organizations create hook is intentionally not reintroduced from main. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2 parents bf7c613 + eb01ab1 commit 117a108

13,477 files changed

Lines changed: 139962 additions & 1806 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,42 @@ Boilerplate templates for Constructive applications.
66

77
- **nextjs/constructive-app** — Next.js frontend boilerplate with auth, org management, and GraphQL SDK integration
88

9+
## Quick Local Setup
10+
11+
### Local Development
12+
13+
```bash
14+
# 1. Start Postgres
15+
docker compose up -d
16+
17+
# 2. Install dependencies
18+
pnpm install
19+
20+
# 3. Setup database
21+
eval "$(pgpm env)"
22+
createdb myapp
23+
pgpm admin-users bootstrap --database myapp --yes
24+
pgpm admin-users add --database myapp --test --yes
25+
pgpm deploy --package myapp-service --database myapp --yes
26+
pgpm deploy --package myapp --database myapp --yes
27+
pgpm deploy --package myapp-test-seed --database myapp --yes
28+
29+
# 4. Start GraphQL server
30+
PGDATABASE=myapp cnc server --port 3000 --origin "*"
31+
32+
# 5. Codegen
33+
pnpm run codegen
34+
35+
# 6. Start the app
36+
cd nextjs/constructive-app && pnpm run dev
37+
```
38+
39+
940

1041
## Setup
1142

43+
> **AI agents:** The `src/graphql/sdk/` directory in `nextjs/constructive-app` is auto-generated by `@constructive-io/graphql-codegen`. Never edit it manually — fix the upstream config and re-run `pnpm codegen`.
44+
1245
In constructive-db repo:
1346

1447
```bash
@@ -33,5 +66,6 @@ eval "$(pgpm env)"
3366
pnpm run create-db
3467
pnpm run provision
3568
pnpm run codegen
69+
pnpm run seed
3670
pnpm run dev
3771
```

graphql/provision/provision.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,14 +208,19 @@ async function main(): Promise<void> {
208208
// -----------------------------------------------------------------------
209209
// Step 2: Create database
210210
// -----------------------------------------------------------------------
211+
// The databaseProvisionModule mutation was moved from the "api" endpoint
212+
// to the "modules" endpoint in the 2025-05 upstream refactor.
213+
// We point public_.createClient() at the modules endpoint — the SDK
214+
// still has the databaseProvisionModule model, it just lives on a
215+
// different subdomain now.
211216
console.log('Step 2: Creating database...');
212217

213-
const apiDb = platform.createClient({
214-
endpoint: config.platformApi,
218+
const modulesClient = platform.createClient({
219+
endpoint: process.env.MODULES_ENDPOINT || 'http://modules.localhost:3000/graphql',
215220
headers: { Authorization: `Bearer ${accessToken}` },
216221
});
217222

218-
const dbResult = await apiDb.databaseProvisionModule.create({
223+
const dbResult = await modulesClient.databaseProvisionModule.create({
219224
data: {
220225
databaseName: config.database.name,
221226
ownerId: userId,
@@ -234,6 +239,13 @@ async function main(): Promise<void> {
234239
const databaseName = provisionModule?.databaseName ?? config.database.name;
235240
console.log(` Database created. id=${databaseId}, name=${databaseName}`);
236241

242+
// Create API client for subsequent operations (tables, relations).
243+
// These use the api endpoint (api-{dbName}.localhost), not modules.
244+
const apiDb = platform.createClient({
245+
endpoint: config.platformApi,
246+
headers: { Authorization: `Bearer ${accessToken}` },
247+
});
248+
237249
// -----------------------------------------------------------------------
238250
// Step 3: Resolve schema prefix and apply workarounds
239251
// -----------------------------------------------------------------------

nextjs/constructive-app/.env.example

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# This single value derives all GraphQL endpoints:
33
# admin-{db}.localhost:3000 → organizations, members, permissions
44
# auth-{db}.localhost:3000 → users, authentication
5-
# app-public-{db}.localhost:3000 → your business data
5+
# api-{db}.localhost:3000 → your business data
66
NEXT_PUBLIC_DB_NAME=your-db-name
77

88
# Optional: Override the default API port (default: 3000)
@@ -11,14 +11,16 @@ NEXT_PUBLIC_DB_NAME=your-db-name
1111
# Optional: Override individual endpoints (bypasses DB_NAME derivation)
1212
# NEXT_PUBLIC_ADMIN_ENDPOINT=http://admin-mydb.localhost:3000/graphql
1313
# NEXT_PUBLIC_AUTH_ENDPOINT=http://auth-mydb.localhost:3000/graphql
14-
# NEXT_PUBLIC_APP_ENDPOINT=http://app-public-mydb.localhost:3000/graphql
14+
# NEXT_PUBLIC_APP_ENDPOINT=http://api-mydb.localhost:3000/graphql
1515

1616
# -----------------------------------------------------------------------------
1717
# Provisioning variables (set by create-db, read by provision/seed scripts)
1818
# -----------------------------------------------------------------------------
1919
# Root metaschema endpoints
2020
API_ENDPOINT=http://api.localhost:3000/graphql
2121
AUTH_ENDPOINT=http://auth.localhost:3000/graphql
22+
# Modules API endpoint — blueprint, constructBlueprint, databaseProvisionModule
23+
MODULES_ENDPOINT=http://modules.localhost:3000/graphql
2224

2325
# Database configuration
2426
DATABASE_NAME=myapp
@@ -29,6 +31,17 @@ ADMIN_PASSWORD=Password123!
2931
ACCESS_TOKEN=
3032
DATABASE_ID=
3133

34+
# -----------------------------------------------------------------------------
35+
# GraphQL export variables
36+
# -----------------------------------------------------------------------------
37+
# Override endpoints for pgpm export:graphql
38+
# META_ENDPOINT=http://api.localhost:3000/graphql
39+
# MIGRATE_ENDPOINT=http://migrate.localhost:3000/graphql
40+
# DB_AUTH_ENDPOINT=http://auth-{databaseName}.localhost:3000/graphql
41+
# Extension names for the exported modules
42+
# EXTENSION_NAME=myapp
43+
# META_EXTENSION_NAME=myapp-service
44+
3245
# Postgres (set by pgpm env or manually)
3346
PGHOST=localhost
3447
PGPORT=5432

nextjs/constructive-app/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
|-----|----------|------------|------|
1313
| admin | http://admin-myapp.localhost:3000/graphql | React Query, ORM | [./src/graphql/sdk/admin/README.md](./src/graphql/sdk/admin/README.md) |
1414
| auth | http://auth-myapp.localhost:3000/graphql | React Query, ORM | [./src/graphql/sdk/auth/README.md](./src/graphql/sdk/auth/README.md) |
15-
| app | http://app-public-myapp.localhost:3000/graphql | React Query, ORM | [./src/graphql/sdk/app/README.md](./src/graphql/sdk/app/README.md) |
15+
| app | http://api-myapp.localhost:3000/graphql | React Query, ORM | [./src/graphql/sdk/app/README.md](./src/graphql/sdk/app/README.md) |
1616

1717
---
1818

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
services:
2+
postgres:
3+
container_name: postgres
4+
image: docker.io/constructiveio/postgres-plus:18
5+
environment:
6+
- POSTGRES_USER=postgres
7+
- POSTGRES_PASSWORD=password
8+
ports:
9+
- "5432:5432"
10+
expose:
11+
- "5432"
12+
volumes:
13+
- ./bin:/sql-bin
14+
- ./packages:/sql-packages
15+
- ./extensions:/sql-extensions
16+
17+
minio:
18+
container_name: minio
19+
image: minio/minio
20+
environment:
21+
- MINIO_ACCESS_KEY=minioadmin
22+
- MINIO_SECRET_KEY=minioadmin
23+
ports:
24+
- "9000:9000"
25+
expose:
26+
- "9000"
27+
command: server /data
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2025 Dan Lynch <pyramation@gmail.com>
4+
Copyright (c) 2025 Constructive
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
EXTENSION = pgpm-database-jobs
2+
DATA = sql/pgpm-database-jobs--0.26.3.sql
3+
4+
PG_CONFIG = pg_config
5+
PGXS := $(shell $(PG_CONFIG) --pgxs)
6+
include $(PGXS)

0 commit comments

Comments
 (0)