Skip to content
Open
Show file tree
Hide file tree
Changes from 103 commits
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
484d554
Add Prisma provider and compute examples
AmanVarshney01 May 17, 2026
0952b7a
fix(prisma): finalize provider cleanup
AmanVarshney01 May 22, 2026
72fc72c
feat(prisma): add effect-native compute platform
AmanVarshney01 May 26, 2026
ada0c1f
fix(prisma): track managed compute env keys
AmanVarshney01 May 26, 2026
7f366f0
fix(prisma): namespace connection binding env keys
AmanVarshney01 May 26, 2026
f0f5483
fix(prisma): mark compute bundles as runtime phase
AmanVarshney01 May 26, 2026
e153873
test(prisma): cover connection binding runtime client
AmanVarshney01 May 26, 2026
e4853dc
fix(prisma): reject invalid effect-native compute inputs
AmanVarshney01 May 26, 2026
c1425db
fix(prisma): resolve connection bindings at runtime
AmanVarshney01 May 26, 2026
f1ae927
fix(prisma): preserve optional connection binding values
AmanVarshney01 May 26, 2026
d84c1ae
fix(prisma): escape connection binding sentinels
AmanVarshney01 May 26, 2026
d885485
fix(prisma): fall back to global compute version routes
AmanVarshney01 May 26, 2026
3fbaf96
fix(prisma): preserve compute version fallback errors
AmanVarshney01 May 26, 2026
c3b4613
fix(prisma): tolerate missing session on default skips
AmanVarshney01 May 26, 2026
70086b4
fix(prisma): add connection env helpers
AmanVarshney01 May 26, 2026
bdc04f5
fix(prisma): harden compute destroy env cleanup
AmanVarshney01 May 26, 2026
5878fa8
fix(prisma): type connection env keys
AmanVarshney01 May 26, 2026
a4146ea
test(prisma): block stale compute app export
AmanVarshney01 May 26, 2026
a77805d
fix(prisma): adopt latest compute version on read
AmanVarshney01 May 26, 2026
3e7f9e3
fix(prisma): derive compute promotion from live state
AmanVarshney01 May 26, 2026
a54b444
test(prisma): cover native compute bindings
AmanVarshney01 May 26, 2026
3dce432
fix(prisma): clean up failed compute uploads
AmanVarshney01 May 26, 2026
5e7f17f
fix(prisma): resolve compute artifacts before remote writes
AmanVarshney01 May 26, 2026
6f7b193
fix(prisma): ignore branch env overrides
AmanVarshney01 May 26, 2026
e14e197
fix(prisma): keep compute cleanup idempotent
AmanVarshney01 May 26, 2026
932176c
fix(prisma): select default project database
AmanVarshney01 May 26, 2026
62ad56d
fix(prisma): skip absent compute env markers
AmanVarshney01 May 26, 2026
937ae2d
fix(prisma): find unnamed default database
AmanVarshney01 May 26, 2026
3458fda
fix(prisma): remember compute env class
AmanVarshney01 May 26, 2026
6d1d5c5
docs(prisma): show compute runtime bindings
AmanVarshney01 May 26, 2026
b04ab28
fix(prisma): reconcile project settings removal
AmanVarshney01 May 26, 2026
a58fa06
fix(prisma): retry transient transport errors
AmanVarshney01 May 26, 2026
b2496a7
fix(prisma): ignore null connection secrets
AmanVarshney01 May 26, 2026
75d84b3
fix(prisma): validate compute dev props
AmanVarshney01 May 26, 2026
1af0216
fix(prisma): validate environment variables locally
AmanVarshney01 May 26, 2026
f65df52
fix(prisma): keep env validation internal
AmanVarshney01 May 26, 2026
d517bc2
fix(prisma): skip dev project deletes
AmanVarshney01 May 26, 2026
45ce426
chore(prisma): remove compute service cast
AmanVarshney01 May 26, 2026
cca14ff
chore(prisma): keep generated contract stable
AmanVarshney01 May 26, 2026
655f7c2
fix(prisma): avoid retrying unsafe posts
AmanVarshney01 May 26, 2026
73fd3e7
fix(prisma): avoid retrying transfers
AmanVarshney01 May 26, 2026
ebaada0
fix(prisma): reobserve compute cleanup conflicts
AmanVarshney01 May 26, 2026
d5d5e3b
test(prisma): cover compute platform factory types
AmanVarshney01 May 26, 2026
46e5b37
fix(prisma): expose compute process services
AmanVarshney01 May 26, 2026
de3ef8c
test(prisma): cover named compute handlers
AmanVarshney01 May 26, 2026
521aac6
fix(prisma): validate compute handler names
AmanVarshney01 May 26, 2026
d4673ac
test(prisma): cover compute connection binding in dev
AmanVarshney01 May 26, 2026
2b5ede5
fix(prisma): avoid mutating system env vars
AmanVarshney01 May 26, 2026
5e78796
test(prisma): pin compute binding env precedence
AmanVarshney01 May 26, 2026
649ec2d
test(prisma): cover compute destroy system envs
AmanVarshney01 May 26, 2026
ff96509
fix(prisma): detect compute version artifact changes
AmanVarshney01 May 26, 2026
f418832
fix(prisma): diff stable fields with unresolved refs
AmanVarshney01 May 26, 2026
ce90b65
fix(prisma): canonicalize database source diffs
AmanVarshney01 May 26, 2026
d5d5518
fix(prisma): canonicalize project and version diffs
AmanVarshney01 May 26, 2026
1a198c3
feat(prisma): allow connection binding on lambda
AmanVarshney01 May 26, 2026
ea271fe
docs(prisma): show connection binding on platforms
AmanVarshney01 May 26, 2026
df8110a
test(prisma): cover connection binding on lambda types
AmanVarshney01 May 26, 2026
768c7a3
fix(prisma): preserve replacements with unresolved branch refs
AmanVarshney01 May 26, 2026
37ed8b3
fix(prisma): preserve version replacements with unresolved update refs
AmanVarshney01 May 26, 2026
129d89b
fix(prisma): preserve replacements with unresolved update inputs
AmanVarshney01 May 26, 2026
9e89e24
fix(prisma): preserve compute replacement with unresolved region
AmanVarshney01 May 26, 2026
136a2e8
test(prisma): pin compute artifact reconciliation
AmanVarshney01 May 26, 2026
df5ff11
test(prisma): cover runtime connection binding policy
AmanVarshney01 May 26, 2026
c249a04
test(prisma): pin generated docs surface
AmanVarshney01 May 26, 2026
d478a94
feat(prisma): support worker connection bindings
AmanVarshney01 May 26, 2026
ee820bb
fix(prisma): fall back when compute version read misses
AmanVarshney01 May 26, 2026
afc5ff3
fix(prisma): share compute version observation
AmanVarshney01 May 26, 2026
46759c4
fix(prisma): keep compute version helper internal
AmanVarshney01 May 26, 2026
721d247
test(prisma): block internal deep imports
AmanVarshney01 May 26, 2026
57dcd82
refactor(prisma): centralize compute version observation
AmanVarshney01 May 26, 2026
3423734
fix(prisma): observe default resources before delete
AmanVarshney01 May 26, 2026
50e0103
fix(prisma): read compute versions from saved service id
AmanVarshney01 May 26, 2026
e2db7b7
fix(prisma): avoid listing on saved compute version reads
AmanVarshney01 May 26, 2026
c01b58c
fix(prisma): always observe default resources before delete
AmanVarshney01 May 26, 2026
504e3ec
fix(prisma): observe env vars before delete
AmanVarshney01 May 26, 2026
b3dd958
fix(prisma): skip redundant compute promotion
AmanVarshney01 May 26, 2026
d4b8527
fix(prisma): skip redundant compute version promotion
AmanVarshney01 May 26, 2026
8f45ca5
fix(prisma): prefer service-scoped compute version start
AmanVarshney01 May 26, 2026
c16e6f1
fix(prisma): fallback when stopping compute versions
AmanVarshney01 May 26, 2026
f2a449c
fix(prisma): start compute versions before promotion
AmanVarshney01 May 26, 2026
9d046ad
fix(prisma): reject unstarted compute promotion
AmanVarshney01 May 26, 2026
0c709cb
fix(prisma): verify compute version delete fallback
AmanVarshney01 May 26, 2026
2519b05
fix(prisma): prefer preview url for unpromoted compute
AmanVarshney01 May 26, 2026
69f4dfa
test(prisma): harden provider invariants
AmanVarshney01 May 26, 2026
97af09e
test(prisma): require resource field docs
AmanVarshney01 May 26, 2026
cff84c1
test(prisma): ban raw async escape hatches
AmanVarshney01 May 26, 2026
ab52d34
test(prisma): assert runtime binding context
AmanVarshney01 May 26, 2026
cfad62b
test(prisma): verify binding policy provider
AmanVarshney01 May 26, 2026
f6d3d15
fix(prisma): preserve dev provider stable ids
AmanVarshney01 May 26, 2026
85ac95c
fix(prisma): clean up failed compute versions
AmanVarshney01 May 26, 2026
c572070
fix(prisma): sync database branch after create
AmanVarshney01 May 26, 2026
5c64ff5
fix(prisma): align api response types
AmanVarshney01 May 26, 2026
537a88f
fix(prisma): tighten database source input
AmanVarshney01 May 26, 2026
0ba7b6f
fix(prisma): model project create database shape
AmanVarshney01 May 26, 2026
56eac06
fix(prisma): retry blocked project cleanup
AmanVarshney01 May 26, 2026
568725b
fix(prisma): fingerprint compute branch deployments
AmanVarshney01 May 26, 2026
9811910
fix(prisma): validate compute version preconditions
AmanVarshney01 May 26, 2026
e13b51d
fix(prisma): reject unassigned compute branch ids
AmanVarshney01 May 26, 2026
a2c2f5f
fix(prisma): keep tanstack example route generation stable
AmanVarshney01 May 26, 2026
5a97b31
fix(prisma): honor persisted compute env keys
AmanVarshney01 May 26, 2026
1e24dbf
fix(prisma): find project env vars past branch overrides
AmanVarshney01 May 26, 2026
abb2ea0
fix(prisma): use explicit postgres binding in tanstack example
AmanVarshney01 May 26, 2026
7b5cf0f
Add Effect-native Prisma Compute example
AmanVarshney01 May 28, 2026
c1a9d94
feat(prisma): add custom domains and finalize examples
AmanVarshney01 Jun 1, 2026
e64b9a0
Merge remote-tracking branch 'origin/main' into aman/prisma-alchemy-p…
AmanVarshney01 Jun 2, 2026
c1effac
fix(prisma): clean up compute service create failures
AmanVarshney01 Jun 2, 2026
00e0113
fix(prisma): stabilize effect compute runtime bindings
AmanVarshney01 Jun 2, 2026
80bc98b
Merge branch 'main' into aman/prisma-alchemy-provider
AmanVarshney01 Jun 5, 2026
c4e251c
chore(prisma): use effect config in examples
AmanVarshney01 Jun 5, 2026
0ea1864
Merge remote-tracking branch 'origin/main' into aman/prisma-alchemy-p…
AmanVarshney01 Jun 5, 2026
20d93d4
fix(prisma): scope compute env vars by branch role
AmanVarshney01 Jun 5, 2026
58412ad
Merge remote-tracking branch 'origin/main' into aman/prisma-alchemy-p…
AmanVarshney01 Jun 5, 2026
ab174e1
fix(prisma): expose management client from providers()
AmanVarshney01 Jun 12, 2026
995dfd4
Merge remote-tracking branch 'origin/main' into aman/prisma-alchemy-p…
AmanVarshney01 Jun 22, 2026
54b9301
feat(prisma): align provider with current alchemy
AmanVarshney01 Jun 23, 2026
9c0efda
Merge branch 'main' into aman/prisma-alchemy-provider
sam-goodwin Jul 7, 2026
af6e178
feat(prisma): migrate to current alchemy APIs and latest management A…
AmanVarshney01 Jul 8, 2026
74ff764
feat(prisma): harden management api provider
AmanVarshney01 Jul 10, 2026
b369ec6
chore: merge main into prisma provider
AmanVarshney01 Jul 10, 2026
4bbc6ed
chore(prisma): minimize dependency churn
AmanVarshney01 Jul 10, 2026
eb579ae
fix(prisma): harden production deploys
AmanVarshney01 Jul 10, 2026
059c314
Merge remote-tracking branch 'origin/main' into aman/prisma-alchemy-p…
AmanVarshney01 Jul 10, 2026
7004791
fix(prisma): close production reconciliation gaps
AmanVarshney01 Jul 10, 2026
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
2 changes: 2 additions & 0 deletions .oxfmtrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
"**/*.mdx",
"**/*.md",
"**/.vendor/**",
"examples/prisma-tanstack-start/src/prisma/contract.d.ts",
"examples/prisma-tanstack-start/src/prisma/contract.json",
"**/package.json"
]
}
378 changes: 362 additions & 16 deletions bun.lock

Large diffs are not rendered by default.

49 changes: 49 additions & 0 deletions examples/prisma-compute-effect/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Prisma Compute Effect

Minimal Effect-native Prisma Compute service managed by Alchemy.

This example is intentionally not a framework app. It shows the provider-native
runtime path:

- `Prisma.Project`
- `Prisma.Branch`
- `Prisma.Postgres`
- `Prisma.Connection`
- `Prisma.Compute(..., Effect.gen(...))`
- `Prisma.Connection.bind(Connection)` inside the deployed runtime

The deployed service responds on `/` and `/api/health` with JSON showing the
bound database and connection IDs.

## Deploy

```sh
export PRISMA_SERVICE_TOKEN="..."
bun run deploy
```

`PRISMA_API_TOKEN` also works.

## Check It

```sh
curl "$URL/"
curl "$URL/api/health"
```

The response should include:

```json
{
"ok": true,
"mode": "effect-native",
"hasDatabaseUrl": true
}
```

## Destroy

```sh
export PRISMA_SERVICE_TOKEN="..."
bun run destroy
```
142 changes: 142 additions & 0 deletions examples/prisma-compute-effect/alchemy.run.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
import * as Alchemy from "alchemy";
import * as Prisma from "alchemy/Prisma";
import * as Effect from "effect/Effect";
import { HttpServerRequest } from "effect/unstable/http/HttpServerRequest";
import * as HttpServerResponse from "effect/unstable/http/HttpServerResponse";

const region = "eu-west-3";
const port = 3000;

const serviceName =
process.env.PRISMA_EFFECT_SERVICE ?? "alchemy-prisma-compute-effect";
const projectName = process.env.PRISMA_PROJECT ?? `${serviceName}-project`;
const message =
process.env.PRISMA_EFFECT_MESSAGE ??
"hello from Effect-native Prisma Compute";

const runtimeEnv = (key: string, fallback: string) =>
Effect.sync(() => process.env[key] ?? fallback);

export const Project = Prisma.Project("Project", {
name: projectName,
createDatabase: false,
region,
});

export const MainBranch = Prisma.Branch(
"MainBranch",
Effect.gen(function* () {
const project = yield* Project;
return {
project,
gitName: "main",
isDefault: true,
};
}),
);

export const Postgres = Prisma.Postgres(
"Postgres",
Effect.gen(function* () {
const project = yield* Project;
const branch = yield* MainBranch;
return {
project,
name: "main",
region,
branchId: branch.branchId,
isDefault: true,
};
}),
);

export const Connection = Prisma.Connection(
"Connection",
Effect.gen(function* () {
const postgres = yield* Postgres;
return {
database: postgres,
name: "api",
};
}),
);
Comment thread
AmanVarshney01 marked this conversation as resolved.
Outdated

export const Api = Prisma.Compute(
Comment thread
AmanVarshney01 marked this conversation as resolved.
Outdated
"Api",
Effect.gen(function* () {
const project = yield* Project;
Comment thread
AmanVarshney01 marked this conversation as resolved.
Outdated
const branch = yield* MainBranch;
return {
project,
serviceName,
regionId: region,
branchId: branch.branchId,
main: import.meta.filename,
handler: "Api" as const,
port,
env: {
PRISMA_EFFECT_MESSAGE: message,
PRISMA_PROJECT_ID: project.projectId,
PRISMA_BRANCH_ID: branch.branchId,
},
destroyOldVersion: true,
};
}),
Effect.gen(function* () {
const db = yield* Prisma.Connection.bind(Connection);

return {
fetch: Effect.gen(function* () {
const request = yield* HttpServerRequest;
const url = new URL(request.url, "http://localhost");

if (url.pathname !== "/" && url.pathname !== "/api/health") {
return HttpServerResponse.text("Not found", { status: 404 });
}

if (request.method !== "GET") {
return HttpServerResponse.text("Method not allowed", { status: 405 });
}

const databaseUrl = yield* db.databaseUrl;
const response = {
ok: true,
mode: "effect-native",
message: yield* runtimeEnv("PRISMA_EFFECT_MESSAGE", message),
projectId: yield* runtimeEnv("PRISMA_PROJECT_ID", ""),
branchId: yield* runtimeEnv("PRISMA_BRANCH_ID", ""),
databaseId: yield* db.databaseId,
connectionId: yield* db.connectionId,
hasDatabaseUrl: databaseUrl !== undefined,
};

return yield* HttpServerResponse.json(response);
}),
};
}).pipe(Effect.provide(Prisma.ConnectionBindingLive)),
);

export default Alchemy.Stack(
"PrismaComputeEffect",
{
providers: Prisma.providers(),
state: Alchemy.localState(),
},
Effect.gen(function* () {
const project = yield* Project;
const branch = yield* MainBranch;
const postgres = yield* Postgres;
const connection = yield* Connection;
const api = yield* Api;

return {
projectId: project.projectId,
branchId: branch.branchId,
databaseId: postgres.databaseId,
connectionId: connection.connectionId,
computeServiceId: api.computeServiceId,
computeVersionId: api.computeVersionId,
url: api.url,
};
}),
);
27 changes: 27 additions & 0 deletions examples/prisma-compute-effect/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "prisma-compute-effect",
"version": "0.0.0",
"private": true,
"license": "Apache-2.0",
"repository": {
"type": "git",
"url": "git+https://github.com/alchemy-run/alchemy-effect.git",
"directory": "examples/prisma-compute-effect"
},
"type": "module",
"scripts": {
"build": "tsc -b",
"deploy": "alchemy deploy",
"destroy": "alchemy destroy",
"tail": "alchemy tail"
},
"dependencies": {
"@effect/platform-bun": "catalog:",
"alchemy": "workspace:*",
"effect": "catalog:"
},
"devDependencies": {
"@types/node": "catalog:",
"typescript": "catalog:"
}
}
17 changes: 17 additions & 0 deletions examples/prisma-compute-effect/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"extends": "../../tsconfig.base.json",
"include": ["alchemy.run.ts"],
"compilerOptions": {
"noEmit": true,
"rootDir": ".",
"module": "Preserve",
"moduleResolution": "Bundler",
"target": "ESNext",
"types": ["node"]
},
"references": [
{
"path": "../../packages/alchemy/tsconfig.json"
}
]
}
5 changes: 5 additions & 0 deletions examples/prisma-tanstack-start/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.alchemy
.output
dist
node_modules
tsconfig.tsbuildinfo
102 changes: 102 additions & 0 deletions examples/prisma-tanstack-start/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Prisma TanStack Start

Minimal TanStack Start app with Prisma Next queries, Prisma Postgres, and
Prisma Compute managed by Alchemy.

## What It Creates

- A Prisma project.
- A `main` Prisma branch.
- A Prisma Postgres database via `Prisma.Postgres(...)`.
- A database connection with redacted connection strings.
- A standalone Prisma environment variable for shared project config.
- A Prisma Compute service.
- A single Compute version built from TanStack Start's `.output` artifact.
- Runtime env vars for database URLs, Prisma resource IDs, and app config.
- A Prisma Next contract in `src/prisma/contract.prisma`.
- Generated Prisma Next artifacts in `src/prisma/contract.json` and
`src/prisma/contract.d.ts`.
- A seed script that inserts demo users/posts and server routes that query them
through `@prisma-next/postgres/runtime`.

The app uses an explicit Compute build command:

```sh
bun run db:setup && bun run build
```

`db:setup` emits the Prisma Next contract, initializes the database shape, and
seeds demo data before `vite build` writes the TanStack Start `.output` artifact.
The Compute version starts `server/index.mjs` on port `3000`.

## Local Dev

```sh
bun install
bun run dev
```

`alchemy dev` starts a local Prisma Postgres with `@prisma/dev`, passes the same
`DATABASE_URL`/`DIRECT_URL` env names used by deploy, runs `bun run db:setup`,
and then starts Vite with `bun run dev:start`.

Open `http://localhost:3000`.

If port 3000 is busy:

```sh
PRISMA_TANSTACK_DEV_PORT=3011 bun run dev
```

## Prisma Next Workflow

```sh
bun run emit # regenerate contract.json + contract.d.ts
bun run db:init # apply the contract to DATABASE_URL
bun run seed # refresh the demo rows
bun run db:setup # all of the above, in order
```

The Vite dev server also auto-emits the contract on edits. The explicit scripts
remain the source of truth for deploys and CI so builds are reproducible.

The runtime uses `pg`, so the example uses `Prisma.connectionEnv(connection)` to
pass a direct `postgres://` connection string as `DATABASE_URL`/`DIRECT_URL`.
The pooled `prisma+postgres://` URL is exported separately as
`POOLED_DATABASE_URL` but is intentionally not used by
`@prisma-next/postgres/runtime`.

## Deploy

```sh
export PRISMA_SERVICE_TOKEN="..."
bun run deploy
```

`PRISMA_API_TOKEN` also works. The deploy output prints the Compute URL.

## Check It

```sh
curl "$URL/"
curl "$URL/api/health"
```

The health response should include:

```json
{
"ok": true,
"counts": {
"users": 2,
"posts": 3
}
}
```

## Destroy

```sh
export PRISMA_SERVICE_TOKEN="..."
bun run destroy
```
Loading