@prisma/composer 0.16.0 → 0.17.0-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/control.mjs +4 -4
- package/dist/control.mjs.map +1 -1
- package/dist/{dist-CVk7Pk4B.mjs → dist-D1TA1xGC.mjs} +30 -2
- package/dist/dist-D1TA1xGC.mjs.map +1 -0
- package/dist/{execute-deploy-destroy-5sr2Z9oW-BwSEIjEk.mjs → execute-deploy-destroy-CVKQiKpo-CzpBXnZY.mjs} +4 -4
- package/dist/{execute-deploy-destroy-5sr2Z9oW-BwSEIjEk.mjs.map → execute-deploy-destroy-CVKQiKpo-CzpBXnZY.mjs.map} +1 -1
- package/dist/{execute-dev-B8CNl38E-DSfuvfyJ.mjs → execute-dev-CidXpugP-CWF-EG4V.mjs} +3 -3
- package/dist/{execute-dev-B8CNl38E-DSfuvfyJ.mjs.map → execute-dev-CidXpugP-CWF-EG4V.mjs.map} +1 -1
- package/dist/nextjs-control.mjs +6 -17
- package/dist/nextjs-control.mjs.map +1 -1
- package/dist/node-control.mjs +4 -6
- package/dist/node-control.mjs.map +1 -1
- package/dist/{run-alchemy--ZIvgqyU-BtZTukrY.mjs → run-alchemy-B6u4TxA0-DMUphChq.mjs} +7 -9
- package/dist/run-alchemy-B6u4TxA0-DMUphChq.mjs.map +1 -0
- package/package.json +11 -10
- package/skills/prisma-composer-core-concepts/SKILL.md +478 -0
- package/dist/dist-CVk7Pk4B.mjs.map +0 -1
- package/dist/run-alchemy--ZIvgqyU-BtZTukrY.mjs.map +0 -1
- package/skills/prisma-composer/SKILL.md +0 -805
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import { t as CliStructuredError } from "./errors-0e8IVwzi.mjs";
|
|
2
2
|
import * as fs$1 from "node:fs";
|
|
3
3
|
import * as path$1 from "node:path";
|
|
4
|
-
import
|
|
5
|
-
//#region ../../0-framework/3-tooling/cli/dist/run-alchemy
|
|
4
|
+
import spawn from "cross-spawn";
|
|
5
|
+
//#region ../../0-framework/3-tooling/cli/dist/run-alchemy-B6u4TxA0.mjs
|
|
6
6
|
/**
|
|
7
7
|
* Pipeline step 7 (deploy-cli.md § The pipeline; design-notes.md's "Driving
|
|
8
|
-
* Alchemy" call): hand the terminal to the generated stack file.
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* bin's own launcher (`alchemy/bin/cli.js`) does its own node/bun dispatch
|
|
13
|
-
* from there, driven by the env it inherits.
|
|
8
|
+
* Alchemy" call): hand the terminal to the generated stack file.
|
|
9
|
+
*
|
|
10
|
+
* Resolves the installed `alchemy` bin and launches package-manager shims with
|
|
11
|
+
* cross-spawn.
|
|
14
12
|
*
|
|
15
13
|
* This module composes the invocation; it does not decide how the child is
|
|
16
14
|
* started. Under the CLI the engine starts it (`ctx.spawn`), which is what
|
|
@@ -91,4 +89,4 @@ const spawnAlchemy = async (invocation) => {
|
|
|
91
89
|
//#endregion
|
|
92
90
|
export { spawnAlchemy as n, alchemyInvocation as t };
|
|
93
91
|
|
|
94
|
-
//# sourceMappingURL=run-alchemy
|
|
92
|
+
//# sourceMappingURL=run-alchemy-B6u4TxA0-DMUphChq.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-alchemy-B6u4TxA0-DMUphChq.mjs","names":["path","fs"],"sources":["../../../0-framework/3-tooling/cli/dist/run-alchemy-B6u4TxA0.mjs"],"sourcesContent":["import { CliStructuredError } from \"@internal/foundation/errors\";\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport spawn from \"cross-spawn\";\n//#region src/run-alchemy.ts\n/**\n* Pipeline step 7 (deploy-cli.md § The pipeline; design-notes.md's \"Driving\n* Alchemy\" call): hand the terminal to the generated stack file.\n*\n* Resolves the installed `alchemy` bin and launches package-manager shims with\n* cross-spawn.\n*\n* This module composes the invocation; it does not decide how the child is\n* started. Under the CLI the engine starts it (`ctx.spawn`), which is what\n* makes Ctrl-C reach the child natively and keeps signal policy in one place.\n* `spawnAlchemy` is the default for programmatic hosts driving\n* `@prisma/composer/control`, which have no engine to borrow.\n*/\n/** Walks up from `startDir` looking for `node_modules/.bin/alchemy`. */\nfunction resolveAlchemyBin(startDir) {\n\tlet dir = startDir;\n\twhile (true) {\n\t\tconst candidate = path.join(dir, \"node_modules\", \".bin\", \"alchemy\");\n\t\tif (fs.existsSync(candidate)) return candidate;\n\t\tconst parent = path.dirname(dir);\n\t\tif (parent === dir) throw new CliStructuredError(\"DEPLOY.ALCHEMY_BIN_MISSING\", `Could not find an installed \\`alchemy\\` bin above \"${startDir}\".`, { fix: \"Add \\\"alchemy\\\" as a dependency of your app.\" });\n\t\tdir = parent;\n\t}\n}\n/**\n* Resolves the invocation against this machine — the step every adapter takes\n* and no caller should. Raises DEPLOY.ALCHEMY_BIN_MISSING when the app has no\n* alchemy installed.\n*/\nfunction alchemyCommandLine(invocation) {\n\treturn {\n\t\tcommand: resolveAlchemyBin(invocation.cwd),\n\t\targs: [\n\t\t\tinvocation.action,\n\t\t\tinvocation.stackFileRelativePath,\n\t\t\t\"--yes\",\n\t\t\t\"--stage\",\n\t\t\tinvocation.stage\n\t\t],\n\t\tcwd: invocation.cwd,\n\t\tenv: invocation.env\n\t};\n}\n/** What becomes `alchemy deploy|destroy <stack file> --yes --stage <stage>`. */\nfunction alchemyInvocation(input) {\n\treturn {\n\t\taction: input.command,\n\t\tstackFileRelativePath: input.stackFileRelativePath,\n\t\tcwd: input.cwd,\n\t\tstage: input.stage,\n\t\tenv: {\n\t\t\t...input.containerEnv,\n\t\t\t...input.preflightEnv,\n\t\t\t...input.env\n\t\t}\n\t};\n}\n/**\n* The default runner for hosts with no engine: inherited stdio, the caller's\n* own process group, and the child's status returned verbatim. It does not\n* collapse a signal into an exit code — that collapse is what made a\n* Ctrl-C'd deploy report itself as a failure.\n*/\nconst spawnAlchemy = async (invocation) => {\n\tconst line = alchemyCommandLine(invocation);\n\treturn new Promise((resolve, reject) => {\n\t\tconst child = spawn(line.command, [...line.args], {\n\t\t\tcwd: line.cwd,\n\t\t\tstdio: \"inherit\",\n\t\t\tenv: {\n\t\t\t\t...process.env,\n\t\t\t\t...line.env\n\t\t\t}\n\t\t});\n\t\tchild.on(\"error\", reject);\n\t\tchild.on(\"close\", (exitCode, signal) => {\n\t\t\tresolve({\n\t\t\t\texitCode,\n\t\t\t\tsignal\n\t\t\t});\n\t\t});\n\t});\n};\n//#endregion\nexport { spawnAlchemy as i, alchemyInvocation as n, resolveAlchemyBin as r, alchemyCommandLine as t };\n\n//# sourceMappingURL=run-alchemy-B6u4TxA0.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;AAmBA,SAAS,kBAAkB,UAAU;CACpC,IAAI,MAAM;CACV,OAAO,MAAM;EACZ,MAAM,YAAYA,OAAK,KAAK,KAAK,gBAAgB,QAAQ,SAAS;EAClE,IAAIC,KAAG,WAAW,SAAS,GAAG,OAAO;EACrC,MAAM,SAASD,OAAK,QAAQ,GAAG;EAC/B,IAAI,WAAW,KAAK,MAAM,IAAI,mBAAmB,8BAA8B,sDAAsD,SAAS,KAAK,EAAE,KAAK,+CAA+C,CAAC;EAC1M,MAAM;CACP;AACD;;;;;;AAMA,SAAS,mBAAmB,YAAY;CACvC,OAAO;EACN,SAAS,kBAAkB,WAAW,GAAG;EACzC,MAAM;GACL,WAAW;GACX,WAAW;GACX;GACA;GACA,WAAW;EACZ;EACA,KAAK,WAAW;EAChB,KAAK,WAAW;CACjB;AACD;;AAEA,SAAS,kBAAkB,OAAO;CACjC,OAAO;EACN,QAAQ,MAAM;EACd,uBAAuB,MAAM;EAC7B,KAAK,MAAM;EACX,OAAO,MAAM;EACb,KAAK;GACJ,GAAG,MAAM;GACT,GAAG,MAAM;GACT,GAAG,MAAM;EACV;CACD;AACD;;;;;;;AAOA,MAAM,eAAe,OAAO,eAAe;CAC1C,MAAM,OAAO,mBAAmB,UAAU;CAC1C,OAAO,IAAI,SAAS,SAAS,WAAW;EACvC,MAAM,QAAQ,MAAM,KAAK,SAAS,CAAC,GAAG,KAAK,IAAI,GAAG;GACjD,KAAK,KAAK;GACV,OAAO;GACP,KAAK;IACJ,GAAG,QAAQ;IACX,GAAG,KAAK;GACT;EACD,CAAC;EACD,MAAM,GAAG,SAAS,MAAM;EACxB,MAAM,GAAG,UAAU,UAAU,WAAW;GACvC,QAAQ;IACP;IACA;GACD,CAAC;EACF,CAAC;CACF,CAAC;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma/composer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0-dev.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Prisma Composer — build a Prisma App by composing Modules. Core authoring, deploy pipeline, and the service-rpc/node/nextjs authoring surfaces. The `prisma-composer` CLI lives in @prisma/composer-cli.",
|
|
6
6
|
"exports": {
|
|
@@ -33,21 +33,22 @@
|
|
|
33
33
|
"alchemy": "2.0.0-beta.74",
|
|
34
34
|
"arktype": "^2.2.3",
|
|
35
35
|
"c12": "^3.3.4",
|
|
36
|
+
"cross-spawn": "^7.0.6",
|
|
36
37
|
"effect": "4.0.0-rc.112",
|
|
37
38
|
"esbuild": "^0.28.1",
|
|
38
39
|
"@prisma/management-api-sdk": "^1.60.0"
|
|
39
40
|
},
|
|
40
41
|
"devDependencies": {
|
|
41
42
|
"@effect/vitest": "4.0.0-rc.112",
|
|
42
|
-
"@internal/assemble": "0.
|
|
43
|
-
"@internal/cli": "0.
|
|
44
|
-
"@internal/core": "0.
|
|
45
|
-
"@internal/foundation": "0.
|
|
46
|
-
"@internal/lowering": "0.
|
|
47
|
-
"@internal/nextjs": "0.
|
|
48
|
-
"@internal/node": "0.
|
|
49
|
-
"@internal/service-rpc": "0.
|
|
50
|
-
"@internal/tsdown-config": "0.
|
|
43
|
+
"@internal/assemble": "0.17.0-dev.1",
|
|
44
|
+
"@internal/cli": "0.17.0-dev.1",
|
|
45
|
+
"@internal/core": "0.17.0-dev.1",
|
|
46
|
+
"@internal/foundation": "0.17.0-dev.1",
|
|
47
|
+
"@internal/lowering": "0.17.0-dev.1",
|
|
48
|
+
"@internal/nextjs": "0.17.0-dev.1",
|
|
49
|
+
"@internal/node": "0.17.0-dev.1",
|
|
50
|
+
"@internal/service-rpc": "0.17.0-dev.1",
|
|
51
|
+
"@internal/tsdown-config": "0.17.0-dev.1",
|
|
51
52
|
"@types/node": "^26.0.1",
|
|
52
53
|
"tsdown": "^0.22.7",
|
|
53
54
|
"typescript": "^6.0.3"
|
|
@@ -0,0 +1,478 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: prisma-composer-core-concepts
|
|
3
|
+
metadata:
|
|
4
|
+
library: "@prisma/composer"
|
|
5
|
+
library_version: "0.17.0-dev.1"
|
|
6
|
+
version: 2026.9.1
|
|
7
|
+
description: >-
|
|
8
|
+
Use when deploying or managing an app that uses Prisma Composer
|
|
9
|
+
(`@prisma/composer`): wiring its services and Modules, running it locally,
|
|
10
|
+
testing composed services, or standing up / tearing down an environment.
|
|
11
|
+
Triggers on "prisma composer", "@prisma/composer", "prisma app", the
|
|
12
|
+
`prisma-composer` CLI, `compute()`, `module()`, `contract()`,
|
|
13
|
+
`service.load()`, `mockService`, `bootstrapService`.
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# Prisma Composer core concepts
|
|
17
|
+
|
|
18
|
+
A **Prisma App** is a tree of typed declarations composed in TypeScript and
|
|
19
|
+
handed to the `prisma-composer` CLI. This file covers structures,
|
|
20
|
+
hierarchies, relationships, and workflows: the concepts you cannot observe
|
|
21
|
+
from the code or the CLI's help output. It is not a CLI reference; discover
|
|
22
|
+
any individual command and its flags with `--help`. Commands named here
|
|
23
|
+
belong to the `prisma-composer` CLI itself; a host CLI that embeds Composer
|
|
24
|
+
may not carry every verb, so confirm a command exists via `--help` rather
|
|
25
|
+
than inferring it. The Prisma platform moves fast, so treat this file as the
|
|
26
|
+
stable conceptual core and find current, fuller documentation at
|
|
27
|
+
<https://www.prisma.io/docs>. For working code, read `examples/` in the
|
|
28
|
+
prisma/composer repo.
|
|
29
|
+
|
|
30
|
+
Two principles govern everything and are binding
|
|
31
|
+
(`docs/design/01-principles/`):
|
|
32
|
+
|
|
33
|
+
1. **Your code never reads its environment.** Dependencies, configuration,
|
|
34
|
+
credentials, and the port all arrive through the service node, typed.
|
|
35
|
+
`process.env` is never the answer.
|
|
36
|
+
2. **Composer never bundles or transforms your code.** You build with your own
|
|
37
|
+
bundler; the framework assembles the built output by deterministic steps
|
|
38
|
+
and hands it to the configured deploy target.
|
|
39
|
+
|
|
40
|
+
## Declarations are data
|
|
41
|
+
|
|
42
|
+
Everything you author is a declaration: plain data describing a piece of the
|
|
43
|
+
app, executing nothing when imported. Three node kinds exist:
|
|
44
|
+
|
|
45
|
+
| Kind | Declared with | Purpose |
|
|
46
|
+
| --- | --- | --- |
|
|
47
|
+
| Service | `compute()` | A running unit of your code; atomic, Composer sees only its ports |
|
|
48
|
+
| Resource | `rawPostgres()`, `bucket()` | A stateful managed dependency |
|
|
49
|
+
| Module | `module()` | A grouping boundary; runs no code of its own, exposes typed ports |
|
|
50
|
+
|
|
51
|
+
Nodes connect through **ports**: `deps` declares what a node requires,
|
|
52
|
+
`expose` declares what it offers. Wiring happens in a Module's builder via
|
|
53
|
+
`provision()`, and the root Module, handed to the CLI, is the App:
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
// module.ts
|
|
57
|
+
import { module } from '@prisma/composer';
|
|
58
|
+
|
|
59
|
+
export default module('store', ({ provision }) => {
|
|
60
|
+
const catalog = provision(catalogModule);
|
|
61
|
+
provision(storefrontService, { deps: { catalog: catalog.rpc } });
|
|
62
|
+
});
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Because ports are typed, **the compiler verifies every wire**. A dependency
|
|
66
|
+
wired to the wrong producer, a missing RPC handler, a literal input value of
|
|
67
|
+
the wrong shape: all of it fails `tsc`, not the deploy. Env-bound input is
|
|
68
|
+
the exception: those values exist only at deploy, so secret-binding
|
|
69
|
+
mismatches and missing platform variables surface as early deploy-time
|
|
70
|
+
refusals instead (see Two channels below). Typecheck, then build, then
|
|
71
|
+
deploy; don't use the cloud to find out whether the wiring is correct.
|
|
72
|
+
|
|
73
|
+
Composer itself is target-agnostic: `@prisma/composer` carries authoring,
|
|
74
|
+
testing, and the CLI, coupled to no platform. A deploy target is an extension
|
|
75
|
+
registered in the deploy config; `@prisma/composer-prisma-cloud` is the
|
|
76
|
+
Prisma Cloud target and the one this skill's deploy sections assume. Its
|
|
77
|
+
root exports `compute`, `rawPostgres`, `bucket`, `envSecret`, and
|
|
78
|
+
`envParam`; the ORM vocabulary (`postgres`, `dataContract`) lives under the
|
|
79
|
+
`/orm` subpath, alongside the shared `/cron`, `/storage`, `/streams`,
|
|
80
|
+
`/auth`, and `/email` modules. These are the only two Composer packages a
|
|
81
|
+
basic Prisma Cloud app needs, and nothing installs them for you: a fresh
|
|
82
|
+
project starts with neither, so add both as dependencies first. An
|
|
83
|
+
extension adds its own `prisma-composer-*` package alongside them. Compose
|
|
84
|
+
an existing Module before implementing a capability yourself; wiring one in
|
|
85
|
+
is a couple of lines.
|
|
86
|
+
|
|
87
|
+
Within the entry graph (everything reachable from `module.ts`), write
|
|
88
|
+
relative imports with explicit `.ts` extensions (`./service.ts`, with
|
|
89
|
+
`allowImportingTsExtensions` in tsconfig): that form resolves everywhere.
|
|
90
|
+
The `prisma-composer` CLI also maps `./service.js` and extensionless
|
|
91
|
+
`./service` to the `.ts` source, but other hosts may not.
|
|
92
|
+
|
|
93
|
+
## The service node is the only doorway
|
|
94
|
+
|
|
95
|
+
Your runtime code receives everything from the service declaration it
|
|
96
|
+
imports:
|
|
97
|
+
|
|
98
|
+
1. `service.load()`: dependencies (typed RPC clients, database bindings).
|
|
99
|
+
2. `service.input()`: the whole input as one schema-validated object;
|
|
100
|
+
credentials in it are redacting `SecretString` boxes.
|
|
101
|
+
3. `service.port()`: the reserved port to bind (default 3000).
|
|
102
|
+
|
|
103
|
+
A service declaration is pure data; the server entry is what your build
|
|
104
|
+
produces and the platform boots:
|
|
105
|
+
|
|
106
|
+
```ts
|
|
107
|
+
// service.ts
|
|
108
|
+
export default compute({
|
|
109
|
+
name: 'auth',
|
|
110
|
+
deps: { db: rawPostgres() },
|
|
111
|
+
build: node({ module: import.meta.url, entry: '../dist/server.mjs' }),
|
|
112
|
+
expose: { rpc: authContract },
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
// server.ts
|
|
116
|
+
const { db } = service.load(); // { url }: you construct your own client
|
|
117
|
+
const handler = serve(service, {
|
|
118
|
+
rpc: { verify: async ({ token }) => ({ ok: token.length > 0 }) },
|
|
119
|
+
});
|
|
120
|
+
Bun.serve({ port: service.port(), hostname: '0.0.0.0', fetch: handler });
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
The consumer declares `deps: { auth: rpc(authContract) }` and gets a typed
|
|
124
|
+
client back from `load()`.
|
|
125
|
+
|
|
126
|
+
## Two channels: dependencies and input
|
|
127
|
+
|
|
128
|
+
| The value is… | Declare | Provide | Read |
|
|
129
|
+
| --- | --- | --- | --- |
|
|
130
|
+
| produced by another node | `deps: { db: rawPostgres() }` | wire at `provision()` | `load()` |
|
|
131
|
+
| anything else (config or credential) | one field of the `input` schema | bind at `provision()`: literal, `envParam()`, or `envSecret()` | `input()` |
|
|
132
|
+
|
|
133
|
+
The service declares its whole incoming configuration, plain values and
|
|
134
|
+
credentials together, as **one [Standard Schema](https://standardschema.dev)**
|
|
135
|
+
(arktype is the house choice). A credential is a field typed as
|
|
136
|
+
`secretString()` from `@prisma/composer/arktype`; conditional legality ("no
|
|
137
|
+
stripe key unless billing is on") is an ordinary schema union. The binding at
|
|
138
|
+
`provision()` mirrors the schema's shape; `envSecret('NAME')` names the
|
|
139
|
+
platform variable and never carries the value.
|
|
140
|
+
|
|
141
|
+
Rules that bite:
|
|
142
|
+
|
|
143
|
+
1. **Secretness is enforced by validation.** A literal bound where the schema
|
|
144
|
+
expects `SecretString` fails the deploy; `envSecret` bound to a plain
|
|
145
|
+
string field fails the same way.
|
|
146
|
+
2. **`envParam` values arrive as raw strings**; bind them to string fields.
|
|
147
|
+
The stage's platform variable is the store; the deploying shell only seeds
|
|
148
|
+
a missing name (and the deploy fails early, naming the variable, when both
|
|
149
|
+
lack it). Changing the platform value needs a redeploy.
|
|
150
|
+
3. **Absence is the schema's call.** An env-bound field whose variable is
|
|
151
|
+
unset or empty resolves to *key omitted*, which is legal only if the
|
|
152
|
+
schema allows it (optional field, union arm). The deploy report prints the
|
|
153
|
+
serialized input document (secrets ride as `{"$secret":"VAR"}` pointers)
|
|
154
|
+
and every key that resolved absent.
|
|
155
|
+
4. **The reserved `port` is outside the schema.** Read it through
|
|
156
|
+
`service.port()`, never `process.env`. The framework also exports `PORT`
|
|
157
|
+
for Next.js standalone, which binds it itself.
|
|
158
|
+
5. **A Module forwards a secret need without learning the platform name.**
|
|
159
|
+
Declare `secrets: { signingKey: secret() }` on the Module boundary and
|
|
160
|
+
pass the forwarded ref as a binding leaf; the parent binds the real
|
|
161
|
+
source.
|
|
162
|
+
6. `input.apiKey.expose()` is the only way to a secret's value; the box
|
|
163
|
+
redacts everywhere else (logs, JSON, errors).
|
|
164
|
+
|
|
165
|
+
## Contracts and RPC
|
|
166
|
+
|
|
167
|
+
A contract is the typed interface through which services communicate. It
|
|
168
|
+
lives with the service that owns it, typed by any Standard Schema validator,
|
|
169
|
+
and both provider (`serve()`, exhaustive over the contract's methods at
|
|
170
|
+
compile time) and consumer (`rpc(contract)`) reference the same value. Calls
|
|
171
|
+
travel as RPC over HTTP. Two behaviours are provisioned for you and must not
|
|
172
|
+
be reimplemented:
|
|
173
|
+
|
|
174
|
+
1. **Service keys.** At deploy, Composer mints a distinct unguessable key per
|
|
175
|
+
consumer→provider binding; `serve()` returns `401` to anything else before
|
|
176
|
+
the handler runs. Nothing in your code declares it. Consequences: don't
|
|
177
|
+
build your own service-to-service auth, and don't `curl` a deployed
|
|
178
|
+
`/rpc/<method>` to check it works. An unwired caller always gets `401`,
|
|
179
|
+
which looks like a broken deploy and isn't. Debug through a consumer, or
|
|
180
|
+
locally, where nothing is enforced. Keys are per binding (one leaking
|
|
181
|
+
can't impersonate another consumer), service-scoped (any valid key
|
|
182
|
+
reaches every method; split services to gate separately), rotated only by
|
|
183
|
+
removing the binding or destroying the stack and redeploying, and stored
|
|
184
|
+
in deploy-owned `COMPOSER_*` variables you never hand-edit.
|
|
185
|
+
2. **Idempotency and retries.** Every generated-client call carries an
|
|
186
|
+
`Idempotency-Key`; dropped calls retry with backoff, and `serve()` runs
|
|
187
|
+
one call per key, replaying the completed answer to late retries. Every
|
|
188
|
+
method is therefore safely retryable and no contract declares anything
|
|
189
|
+
about it (there is no "is this idempotent" flag; don't invent one). A
|
|
190
|
+
handler may take an optional third argument `(input, deps, ctx)` and read
|
|
191
|
+
`ctx.idempotencyKey` (`string | undefined`) if it needs exactly-once
|
|
192
|
+
beyond one instance's memory; most don't. Locally and in tests nothing is
|
|
193
|
+
provisioned, so `serve()` passes every call through: never supply a key
|
|
194
|
+
in test inputs.
|
|
195
|
+
|
|
196
|
+
## Builds are yours
|
|
197
|
+
|
|
198
|
+
You build, the framework assembles. For a plain server process, `entry` must
|
|
199
|
+
point at a single self-contained ESM file: everything inlined except runtime
|
|
200
|
+
built-ins (`bun`, `bun:*`, `node:*`). Deploy copies that one file and never
|
|
201
|
+
ships `node_modules`, so anything left un-inlined fails at boot, not at
|
|
202
|
+
deploy. Rules that bite:
|
|
203
|
+
|
|
204
|
+
1. **Two services in one package means two separate builds**, one per entry.
|
|
205
|
+
A single multi-entry build splits shared code into a chunk neither output
|
|
206
|
+
contains.
|
|
207
|
+
2. **A directory build uses `dir` + `entry`** (`dir` relative to the service
|
|
208
|
+
module, `entry` a file inside `dir`; `../` is an error). The tree is
|
|
209
|
+
copied verbatim, so the server must resolve siblings against
|
|
210
|
+
`import.meta.url`, not the working directory. The tree must contain no
|
|
211
|
+
symlinks: the packager rejects them, names the link, and assembly fails.
|
|
212
|
+
3. **Next.js**: `next build` with `output: 'standalone'` is the whole build;
|
|
213
|
+
`nextjs({ module, appDir })` names the app root. Any page or action that
|
|
214
|
+
calls `load()` needs `export const dynamic = 'force-dynamic'`, because
|
|
215
|
+
the runtime environment doesn't exist at build time and Next ignores
|
|
216
|
+
runtime env for prerendered routes.
|
|
217
|
+
4. **Always build before `deploy` or `dev`.** Neither builds for you.
|
|
218
|
+
|
|
219
|
+
Deploy configuration lives in `prisma-composer.config.ts` (or `.mts`, `.mjs`,
|
|
220
|
+
`.js`; nearest ancestor of the entry wins, `.ts` first within a directory).
|
|
221
|
+
It registers extensions (`prismaCloud()`, `nodeBuild()`, `nextjsBuild()` when
|
|
222
|
+
the app has a Next.js service) and the deploy-state backend
|
|
223
|
+
(`prismaState()`). It is read by the CLI's operations (deploy, destroy, and
|
|
224
|
+
dev; a `dev` run without one refuses, naming the missing file) and never
|
|
225
|
+
imported by app code.
|
|
226
|
+
|
|
227
|
+
## Databases and migrations
|
|
228
|
+
|
|
229
|
+
Two kinds of Postgres dependency:
|
|
230
|
+
|
|
231
|
+
1. **`rawPostgres()`**: the binding is `{ url }` and the app owns its client.
|
|
232
|
+
2. **`postgres(...)`**: a Prisma-ORM-typed database. The binding is
|
|
233
|
+
`{ url, client }` (ADR-0040): the raw connection URL plus the typed
|
|
234
|
+
client Composer constructs from your data contract, lazily on first
|
|
235
|
+
access, so queries go through `binding.client` and are compile-time
|
|
236
|
+
checked. Both `postgres` and `dataContract` import from
|
|
237
|
+
`@prisma/composer-prisma-cloud/orm`, not the package root. One
|
|
238
|
+
`dataContract`-wrapped value (emitted from `contract.prisma` by
|
|
239
|
+
`prisma contract emit`) is referenced by both the dependency end
|
|
240
|
+
(`deps: { db: postgres(catalogData) }`) and the resource end, which also
|
|
241
|
+
names the `prisma.config.ts` path so the deploy's migration step can
|
|
242
|
+
find `migrations/`.
|
|
243
|
+
|
|
244
|
+
**Deploys are replay-only**: they apply the migrations committed under
|
|
245
|
+
`migrations/` and never create schema themselves. Every schema change,
|
|
246
|
+
including the first schema of a new database, follows one loop:
|
|
247
|
+
|
|
248
|
+
1. Edit `contract.prisma`.
|
|
249
|
+
2. `prisma contract emit` regenerates `contract.json` + `contract.d.ts`.
|
|
250
|
+
3. `prisma migration plan --name <slug>` authors the migration (on an empty
|
|
251
|
+
graph this authors the baseline).
|
|
252
|
+
4. Commit `migrations/` with the change, then deploy. A fresh database
|
|
253
|
+
replays the whole path from empty.
|
|
254
|
+
|
|
255
|
+
If no authored path reaches the target contract, deploy (and `dev` against a
|
|
256
|
+
stale local database) refuses with `MIGRATION_PATH_NOT_FOUND`; its message
|
|
257
|
+
lists the two ways out: author the missing migration, or, when iterating
|
|
258
|
+
against a local
|
|
259
|
+
database only, `prisma db update`. Never skip step 3 before a deploy. See
|
|
260
|
+
`examples/store/modules/catalog` for the complete pattern.
|
|
261
|
+
|
|
262
|
+
## Deploy model: converge, don't script
|
|
263
|
+
|
|
264
|
+
Deploy compares the declared topology against recorded deploy state and
|
|
265
|
+
applies only the difference. Re-deploying with nothing changed is a no-op;
|
|
266
|
+
removing a node removes its deployed resource. The Prisma Cloud target
|
|
267
|
+
requires exactly two environment variables: `PRISMA_SERVICE_TOKEN` and
|
|
268
|
+
`PRISMA_WORKSPACE_ID`. There is no interactive login.
|
|
269
|
+
|
|
270
|
+
**Stages.** A stage is an environment name chosen on the command line at
|
|
271
|
+
deploy time, never written in the topology. The identical graph deploys
|
|
272
|
+
everywhere. On the Prisma Cloud target, a Prisma App is one Project and a
|
|
273
|
+
stage is a Branch of it, with its own running services, its own empty
|
|
274
|
+
database, its own configuration. A stage name must be a valid git ref name;
|
|
275
|
+
an invalid name is a hard error.
|
|
276
|
+
|
|
277
|
+
**Destroy** always requires an explicit target: a bare destroy is an error,
|
|
278
|
+
and naming a stage and production together is too. Destroying a stage
|
|
279
|
+
deletes its Branch after removing its resources. Destroying production
|
|
280
|
+
removes only the resources inside the production Branch, never the Branch
|
|
281
|
+
itself directly; once the Project is empty it is deleted too, and that
|
|
282
|
+
deletion takes the production Branch with it. A Project still holding
|
|
283
|
+
another stage's resources is kept. Destroy never creates anything:
|
|
284
|
+
destroying a
|
|
285
|
+
never-deployed stage fails rather than standing one up.
|
|
286
|
+
|
|
287
|
+
**The engine underneath is alchemy.** Convergence is executed by
|
|
288
|
+
[alchemy](https://alchemy.run), a third-party infrastructure-as-code engine
|
|
289
|
+
that arrives as an ordinary, exactly-pinned npm dependency of
|
|
290
|
+
`@prisma/composer` (2.0.0-beta.74 at this library version). Your code never
|
|
291
|
+
imports or configures it; consult alchemy's own docs for the engine itself.
|
|
292
|
+
What matters operationally:
|
|
293
|
+
|
|
294
|
+
1. Deploy and destroy write the pipeline's results to a generated, gitignored
|
|
295
|
+
stack file at `.prisma-composer/alchemy.run.ts`, then run the alchemy CLI
|
|
296
|
+
against it as a child process; `dev` does the same at
|
|
297
|
+
`.prisma-composer/dev/alchemy.run.ts` with local providers. The file
|
|
298
|
+
carries the computed values as literals but reads credentials via
|
|
299
|
+
`fromEnv()`, so nothing sensitive lands on disk, and it is regenerated
|
|
300
|
+
every run: output, not configuration, never edited.
|
|
301
|
+
2. Failures are bisectable through that file. A failing deploy names its
|
|
302
|
+
path; running `alchemy deploy .prisma-composer/alchemy.run.ts` directly
|
|
303
|
+
separates "the framework computed the wrong thing" from "the engine or
|
|
304
|
+
platform rejected the right thing". An engine failure surfaces as
|
|
305
|
+
`DEPLOY.ENGINE_FAILED` carrying the exit code and that reproduce command;
|
|
306
|
+
the child's live output streams to the terminal either way.
|
|
307
|
+
3. Destroy evaluates the same stack program as deploy, and evaluating it
|
|
308
|
+
packages the assembled bundles, so **an app must be built before it can
|
|
309
|
+
be torn down**.
|
|
310
|
+
4. alchemy is why the `effect` pin exists: it resolves the `effect`
|
|
311
|
+
constellation, and a hoisted newer `effect` halts every command (failure
|
|
312
|
+
mode 1 below).
|
|
313
|
+
|
|
314
|
+
**The deploy report** ends with the app's own topology: authored names, the
|
|
315
|
+
platform resource each became, and public URLs. Read ids out of it rather
|
|
316
|
+
than hunting in the Console. A URL appears only where the address is
|
|
317
|
+
genuinely public: a service prints one, a database never does, and a
|
|
318
|
+
node whose product is secret material reports no resource line at all.
|
|
319
|
+
|
|
320
|
+
**Connection contract refusals.** A connection declares the values it needs
|
|
321
|
+
by name; a producer that omits one fails the deploy, naming the edge, the
|
|
322
|
+
param, and what the producer did supply:
|
|
323
|
+
|
|
324
|
+
```text
|
|
325
|
+
Connection input "auth.db" declares param "url", but its producer "db" did not
|
|
326
|
+
supply it — the producer's outputs carry [host].
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
This is a deploy-time refusal, not a broken deploy, and it can appear on an
|
|
330
|
+
app whose code didn't change (the gap used to pass silently as `undefined`
|
|
331
|
+
and crash the consumer at boot). Fix whichever end is wrong; don't mark the
|
|
332
|
+
param `optional` unless absent really is legal. Only reachable if you
|
|
333
|
+
authored the connection or an extension on one side.
|
|
334
|
+
|
|
335
|
+
**Driving deploys from code.** `@prisma/composer/control` exposes typed
|
|
336
|
+
`deploy`, `destroy`, `dev`, and `log` returning structured results. Failures
|
|
337
|
+
come back as `{ ok: false, failure }` with a dotted `failure.code` from a
|
|
338
|
+
closed registry (e.g. `ASSEMBLE.BUILD_FAILED`, `DEPLOY.ENGINE_FAILED`,
|
|
339
|
+
`DEPS.EFFECT_VERSION_CONFLICT`); branch on the code, not the message. A
|
|
340
|
+
non-structured rejection out of an operation is a bug in composer, not an
|
|
341
|
+
expected failure.
|
|
342
|
+
|
|
343
|
+
## Local development
|
|
344
|
+
|
|
345
|
+
The `dev` command runs the whole app on this machine, wired as it deploys,
|
|
346
|
+
against local emulators. No cloud credentials are needed or read. Concepts
|
|
347
|
+
that surprise:
|
|
348
|
+
|
|
349
|
+
1. It runs the same pipeline as deploy, so **build first**, exactly like
|
|
350
|
+
deploy. It watches built output and restarts a service when its build
|
|
351
|
+
changes.
|
|
352
|
+
2. Ctrl-C stops the app's processes but leaves local databases, buckets, and
|
|
353
|
+
their data up: the next `dev` is a warm start. Starting clean, wiping
|
|
354
|
+
this app's local instances and data first, is an explicit opt-in flag.
|
|
355
|
+
3. `dev` does not print service logs; `log` is a separate, read-only command
|
|
356
|
+
that follows the already-running app's merged logs. It never builds,
|
|
357
|
+
provisions, starts, or stops anything.
|
|
358
|
+
4. An unset secret doesn't block a local run: it becomes a placeholder plus a
|
|
359
|
+
warning, and only the code path that spends it fails, at the external
|
|
360
|
+
service it calls.
|
|
361
|
+
5. Windows isn't supported yet.
|
|
362
|
+
|
|
363
|
+
## Testing is an environment seam
|
|
364
|
+
|
|
365
|
+
A test is just another environment: one where you decide what `load()` and
|
|
366
|
+
`input()` return, never by editing the code under test.
|
|
367
|
+
|
|
368
|
+
| You want to… | Use | From |
|
|
369
|
+
| --- | --- | --- |
|
|
370
|
+
| Test a page / action / handler in isolation | `mockService` | `@prisma/composer/testing` |
|
|
371
|
+
| Run the real boot + request path against a fake dependency | `bootstrapService` | `@prisma/composer-prisma-cloud/testing` |
|
|
372
|
+
|
|
373
|
+
`mockService` returns a copy of the service whose `load()` yields your
|
|
374
|
+
doubles (type-checked against the declared deps) and whose `input()` yields
|
|
375
|
+
the object passed under the reserved `input` key (required exactly when the
|
|
376
|
+
service declares an input schema; handed over as-is, not validated). Wiring
|
|
377
|
+
the module substitution is your runner's job (`vi.mock` in Vitest,
|
|
378
|
+
`mock.module` in bun test).
|
|
379
|
+
|
|
380
|
+
`bootstrapService` boots the service's real built entry in-process against a
|
|
381
|
+
config you choose; drive it over real HTTP. Gotchas:
|
|
382
|
+
|
|
383
|
+
1. `service.port` must be concrete: the entry self-listens, and no
|
|
384
|
+
OS-assigned port is reported back.
|
|
385
|
+
2. There is no `close()`; run each integration-test file in its own process
|
|
386
|
+
(bun test does).
|
|
387
|
+
3. Next.js services take a third argument, a boot thunk, resolved with
|
|
388
|
+
`standaloneServerPath` from `@prisma/composer/nextjs/control`.
|
|
389
|
+
4. A service with an input schema takes `input` in the config, a binding
|
|
390
|
+
exactly like `provision()`'s, run through the real serialize/read path.
|
|
391
|
+
|
|
392
|
+
A dependency's type is its contract, so any value of that shape is a valid
|
|
393
|
+
double: a bare object, the real client over an in-memory handler, or a real
|
|
394
|
+
local server. Ship a dependency's fake from its own package as a `/fake`
|
|
395
|
+
entry point, outside `src/`, so the fake and the real service share one
|
|
396
|
+
contract.
|
|
397
|
+
|
|
398
|
+
## Building blocks and extensions
|
|
399
|
+
|
|
400
|
+
First-party Modules ship inside `@prisma/composer-prisma-cloud` and
|
|
401
|
+
provision exactly like your own:
|
|
402
|
+
|
|
403
|
+
| Import | What it provisions | Exposes |
|
|
404
|
+
| --- | --- | --- |
|
|
405
|
+
| `cron` from `/cron` | An always-on scheduler firing your schedule at your runner service | nothing |
|
|
406
|
+
| `storage` from `/storage` | An S3-backed blob store (own Postgres + minted credentials) | `store` |
|
|
407
|
+
| `streams` from `/streams` | Durable append-only event streams over a `store` | `streams` |
|
|
408
|
+
| `auth` from `/auth` | Signup, login, sessions, and JWT verification (Better Auth in one service, own database) | `api`, `session`, `admin` |
|
|
409
|
+
| `email` from `/email` | Transactional email with a stored outbox (own service and database) | `send`, `outbox` |
|
|
410
|
+
|
|
411
|
+
`bucket()` (imported alongside `rawPostgres`) is a raw S3-compatible bucket:
|
|
412
|
+
the dependency end receives `{ url, bucket, accessKeyId, secretAccessKey }`,
|
|
413
|
+
shape-compatible with `/storage`'s `s3()` dependency, so a service wired to
|
|
414
|
+
`s3()` can be rewired to a `bucket` resource unchanged.
|
|
415
|
+
|
|
416
|
+
An extension (a package bringing its own Modules, resources, or deploy
|
|
417
|
+
target) is published on npm as `prisma-composer-*`. The ecosystem is new:
|
|
418
|
+
today the blocks above plus your own Modules are the whole set, so verify a
|
|
419
|
+
`prisma-composer-*` package exists on npm before reaching for it.
|
|
420
|
+
|
|
421
|
+
## Failure modes quick reference
|
|
422
|
+
|
|
423
|
+
1. **Every `prisma-composer` command halts at start-up on an `effect`
|
|
424
|
+
version conflict** (`Dependency conflict: alchemy resolves effect@...`).
|
|
425
|
+
Another dependency floated a newer `effect` and the package manager
|
|
426
|
+
hoisted it over Composer's pin. Pin the whole `effect` constellation in
|
|
427
|
+
the app's `package.json` `overrides` (yarn: `resolutions`; pnpm:
|
|
428
|
+
`pnpm.overrides`): `effect` plus `@effect/sql-d1`, `@effect/sql-pg`,
|
|
429
|
+
`@effect/vitest`, and `@effect/platform-bun`/`-node`/`-node-shared`, all
|
|
430
|
+
at Composer's exact pin, then reinstall. The repo's examples carry the
|
|
431
|
+
block.
|
|
432
|
+
2. **A deployed `/rpc/<method>` returns `401` to anything but a wired
|
|
433
|
+
peer.** Not a broken deploy; see Contracts above.
|
|
434
|
+
3. **Scale-to-zero closes idle database connections.** A persistent client
|
|
435
|
+
crashes into a 502 restart loop unless the pool is small and
|
|
436
|
+
reconnect-friendly (`new SQL({ url, max: 1, idleTimeout: 10 })` for Bun)
|
|
437
|
+
and the process logs `uncaughtException`/`unhandledRejection` instead of
|
|
438
|
+
dying. Under `dev` watch-restarts against the local emulator, add
|
|
439
|
+
`prepare: false` as well: restarted processes collide on
|
|
440
|
+
prepared-statement names in the emulator's shared session.
|
|
441
|
+
4. **Cold starts reset service-to-service connections.** A call into a
|
|
442
|
+
scaled-to-zero service can get `ECONNRESET`; retry it.
|
|
443
|
+
5. **Bind `0.0.0.0`, not loopback.** The platform routes external HTTP to
|
|
444
|
+
the VM; a loopback-only listener is unreachable.
|
|
445
|
+
6. **The ingress buffers streaming responses.** An open SSE tail delivers
|
|
446
|
+
nothing and times out at 60s; don't build on streamed HTTP responses.
|
|
447
|
+
7. **Naming rules fail at load, not typecheck.** Provision ids and declared
|
|
448
|
+
node names must be ASCII letters and digits only (`[A-Za-z0-9]`): they
|
|
449
|
+
derive config keys and address segments, so a hyphenated name like
|
|
450
|
+
`my-db` passes `tsc` and then fails the load. The root module's name is
|
|
451
|
+
exempt. A provision id shorter than 3 characters is rejected by the
|
|
452
|
+
platform (name the database `'database'`, not `'db'`), and a service
|
|
453
|
+
whose name equals its enclosing Module's reads as `auth.auth` unless
|
|
454
|
+
given an explicit `id`.
|
|
455
|
+
8. **`MIGRATION_PATH_NOT_FOUND`**: see Databases above; author the missing
|
|
456
|
+
migration, don't skip the plan step.
|
|
457
|
+
9. **Date/time columns hand back `Temporal.*` values on read.** Bun and
|
|
458
|
+
stock Node ship no global `Temporal`, so a service with `DateTime`
|
|
459
|
+
contract columns compiles and deploys, then fails on the first timestamp
|
|
460
|
+
read. Provide the global at the server entry
|
|
461
|
+
(`import 'temporal-polyfill/global'`) or use string column types.
|
|
462
|
+
|
|
463
|
+
## What Composer doesn't do yet
|
|
464
|
+
|
|
465
|
+
Name the gap instead of inventing an API:
|
|
466
|
+
|
|
467
|
+
1. **No interactive auth in the `prisma-composer` CLI.** Its deploys
|
|
468
|
+
authenticate only via a static
|
|
469
|
+
`PRISMA_SERVICE_TOKEN`; there is no `login` flow.
|
|
470
|
+
2. **No in-memory contract bindings.** A dependency can't yet be wired to a
|
|
471
|
+
co-located handler without HTTP; use `bootstrapService` with a loopback
|
|
472
|
+
fake.
|
|
473
|
+
3. **RPC over HTTP is the only contract kind.** No gRPC, WebSocket, or
|
|
474
|
+
streaming contracts.
|
|
475
|
+
|
|
476
|
+
For anything else missing, check `examples/`, `docs/design/10-domains/`, and
|
|
477
|
+
`docs/design/90-decisions/` in the prisma/composer repo, then file an issue
|
|
478
|
+
there rather than guessing.
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dist-CVk7Pk4B.mjs","names":[],"sources":["../../../0-framework/2-authoring/bundle-paths/dist/index.mjs"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\n//#region src/bundle-paths.ts\n/**\n* The path-containment predicate and bundle-link validation shared by every\n* assembly and packaging seam (node/nextjs adapters, the compute artifact\n* writer, the local extractor). This predicate is the enforcement point of\n* ADR-0047's boundary — a symlink may be preserved only while its target\n* stays inside the assembled bundle — so it exists exactly once.\n*/\n/** Lexical containment: `candidate` is `root` itself or below it. Both paths\n* must already be absolute or share a resolution base; no filesystem access. */\nfunction isWithin(root, candidate) {\n\tconst relative = path.relative(root, candidate);\n\treturn relative === \"\" || !relative.startsWith(`..${path.sep}`) && relative !== \"..\" && !path.isAbsolute(relative);\n}\n/** Walks the assembled bundle and rejects a dangling symlink or one whose\n* resolved target escapes the bundle root. Symlinked directories are not\n* descended: their targets are validated, and their contents belong to the\n* target's own location. */\nasync function assertBundleSymlinksStayInside(bundleDir) {\n\tconst realRoot = await fs.promises.realpath(bundleDir);\n\tconst walk = async (directory) => {\n\t\tfor (const entry of await fs.promises.readdir(directory, { withFileTypes: true })) {\n\t\t\tconst full = path.join(directory, entry.name);\n\t\t\tif (entry.isSymbolicLink()) {\n\t\t\t\tlet realTarget;\n\t\t\t\ttry {\n\t\t\t\t\trealTarget = await fs.promises.realpath(full);\n\t\t\t\t} catch {\n\t\t\t\t\tthrow new Error(`the assembled bundle contains a dangling symlink: ${full}`);\n\t\t\t\t}\n\t\t\t\tif (!isWithin(realRoot, realTarget)) throw new Error(`the assembled bundle contains a symlink whose target escapes the bundle: ${full} -> ${await fs.promises.readlink(full)}`);\n\t\t\t} else if (entry.isDirectory()) await walk(full);\n\t\t}\n\t};\n\tawait walk(bundleDir);\n}\n//#endregion\nexport { assertBundleSymlinksStayInside, isWithin };\n\n//# sourceMappingURL=index.mjs.map"],"mappings":";;;;;;;;;;;;AAYA,SAAS,SAAS,MAAM,WAAW;CAClC,MAAM,WAAW,KAAK,SAAS,MAAM,SAAS;CAC9C,OAAO,aAAa,MAAM,CAAC,SAAS,WAAW,KAAK,KAAK,KAAK,KAAK,aAAa,QAAQ,CAAC,KAAK,WAAW,QAAQ;AAClH;;;;;AAKA,eAAe,+BAA+B,WAAW;CACxD,MAAM,WAAW,MAAM,GAAG,SAAS,SAAS,SAAS;CACrD,MAAM,OAAO,OAAO,cAAc;EACjC,KAAK,MAAM,SAAS,MAAM,GAAG,SAAS,QAAQ,WAAW,EAAE,eAAe,KAAK,CAAC,GAAG;GAClF,MAAM,OAAO,KAAK,KAAK,WAAW,MAAM,IAAI;GAC5C,IAAI,MAAM,eAAe,GAAG;IAC3B,IAAI;IACJ,IAAI;KACH,aAAa,MAAM,GAAG,SAAS,SAAS,IAAI;IAC7C,QAAQ;KACP,MAAM,IAAI,MAAM,qDAAqD,MAAM;IAC5E;IACA,IAAI,CAAC,SAAS,UAAU,UAAU,GAAG,MAAM,IAAI,MAAM,4EAA4E,KAAK,MAAM,MAAM,GAAG,SAAS,SAAS,IAAI,GAAG;GAC/K,OAAO,IAAI,MAAM,YAAY,GAAG,MAAM,KAAK,IAAI;EAChD;CACD;CACA,MAAM,KAAK,SAAS;AACrB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"run-alchemy--ZIvgqyU-BtZTukrY.mjs","names":["path","fs"],"sources":["../../../0-framework/3-tooling/cli/dist/run-alchemy--ZIvgqyU.mjs"],"sourcesContent":["import { CliStructuredError } from \"@internal/foundation/errors\";\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport { spawn } from \"node:child_process\";\n//#region src/run-alchemy.ts\n/**\n* Pipeline step 7 (deploy-cli.md § The pipeline; design-notes.md's \"Driving\n* Alchemy\" call): hand the terminal to the generated stack file. Resolves the\n* workspace's own installed `alchemy` bin (walking up `node_modules/.bin`\n* from the generated file's package dir) rather than going through\n* `bunx`/`npx`, so this works the same under node and bun — the resolved\n* bin's own launcher (`alchemy/bin/cli.js`) does its own node/bun dispatch\n* from there, driven by the env it inherits.\n*\n* This module composes the invocation; it does not decide how the child is\n* started. Under the CLI the engine starts it (`ctx.spawn`), which is what\n* makes Ctrl-C reach the child natively and keeps signal policy in one place.\n* `spawnAlchemy` is the default for programmatic hosts driving\n* `@prisma/composer/control`, which have no engine to borrow.\n*/\n/** Walks up from `startDir` looking for `node_modules/.bin/alchemy`. */\nfunction resolveAlchemyBin(startDir) {\n\tlet dir = startDir;\n\twhile (true) {\n\t\tconst candidate = path.join(dir, \"node_modules\", \".bin\", \"alchemy\");\n\t\tif (fs.existsSync(candidate)) return candidate;\n\t\tconst parent = path.dirname(dir);\n\t\tif (parent === dir) throw new CliStructuredError(\"DEPLOY.ALCHEMY_BIN_MISSING\", `Could not find an installed \\`alchemy\\` bin above \"${startDir}\".`, { fix: \"Add \\\"alchemy\\\" as a dependency of your app.\" });\n\t\tdir = parent;\n\t}\n}\n/**\n* Resolves the invocation against this machine — the step every adapter takes\n* and no caller should. Raises DEPLOY.ALCHEMY_BIN_MISSING when the app has no\n* alchemy installed.\n*/\nfunction alchemyCommandLine(invocation) {\n\treturn {\n\t\tcommand: resolveAlchemyBin(invocation.cwd),\n\t\targs: [\n\t\t\tinvocation.action,\n\t\t\tinvocation.stackFileRelativePath,\n\t\t\t\"--yes\",\n\t\t\t\"--stage\",\n\t\t\tinvocation.stage\n\t\t],\n\t\tcwd: invocation.cwd,\n\t\tenv: invocation.env\n\t};\n}\n/** What becomes `alchemy deploy|destroy <stack file> --yes --stage <stage>`. */\nfunction alchemyInvocation(input) {\n\treturn {\n\t\taction: input.command,\n\t\tstackFileRelativePath: input.stackFileRelativePath,\n\t\tcwd: input.cwd,\n\t\tstage: input.stage,\n\t\tenv: {\n\t\t\t...input.containerEnv,\n\t\t\t...input.preflightEnv,\n\t\t\t...input.env\n\t\t}\n\t};\n}\n/**\n* The default runner for hosts with no engine: inherited stdio, the caller's\n* own process group, and the child's status returned verbatim. It does not\n* collapse a signal into an exit code — that collapse is what made a\n* Ctrl-C'd deploy report itself as a failure.\n*/\nconst spawnAlchemy = async (invocation) => {\n\tconst line = alchemyCommandLine(invocation);\n\treturn new Promise((resolve, reject) => {\n\t\tconst child = spawn(line.command, [...line.args], {\n\t\t\tcwd: line.cwd,\n\t\t\tstdio: \"inherit\",\n\t\t\tenv: {\n\t\t\t\t...process.env,\n\t\t\t\t...line.env\n\t\t\t}\n\t\t});\n\t\tchild.on(\"error\", reject);\n\t\tchild.on(\"close\", (exitCode, signal) => {\n\t\t\tresolve({\n\t\t\t\texitCode,\n\t\t\t\tsignal\n\t\t\t});\n\t\t});\n\t});\n};\n//#endregion\nexport { spawnAlchemy as i, alchemyInvocation as n, resolveAlchemyBin as r, alchemyCommandLine as t };\n\n//# sourceMappingURL=run-alchemy--ZIvgqyU.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAqBA,SAAS,kBAAkB,UAAU;CACpC,IAAI,MAAM;CACV,OAAO,MAAM;EACZ,MAAM,YAAYA,OAAK,KAAK,KAAK,gBAAgB,QAAQ,SAAS;EAClE,IAAIC,KAAG,WAAW,SAAS,GAAG,OAAO;EACrC,MAAM,SAASD,OAAK,QAAQ,GAAG;EAC/B,IAAI,WAAW,KAAK,MAAM,IAAI,mBAAmB,8BAA8B,sDAAsD,SAAS,KAAK,EAAE,KAAK,+CAA+C,CAAC;EAC1M,MAAM;CACP;AACD;;;;;;AAMA,SAAS,mBAAmB,YAAY;CACvC,OAAO;EACN,SAAS,kBAAkB,WAAW,GAAG;EACzC,MAAM;GACL,WAAW;GACX,WAAW;GACX;GACA;GACA,WAAW;EACZ;EACA,KAAK,WAAW;EAChB,KAAK,WAAW;CACjB;AACD;;AAEA,SAAS,kBAAkB,OAAO;CACjC,OAAO;EACN,QAAQ,MAAM;EACd,uBAAuB,MAAM;EAC7B,KAAK,MAAM;EACX,OAAO,MAAM;EACb,KAAK;GACJ,GAAG,MAAM;GACT,GAAG,MAAM;GACT,GAAG,MAAM;EACV;CACD;AACD;;;;;;;AAOA,MAAM,eAAe,OAAO,eAAe;CAC1C,MAAM,OAAO,mBAAmB,UAAU;CAC1C,OAAO,IAAI,SAAS,SAAS,WAAW;EACvC,MAAM,QAAQ,MAAM,KAAK,SAAS,CAAC,GAAG,KAAK,IAAI,GAAG;GACjD,KAAK,KAAK;GACV,OAAO;GACP,KAAK;IACJ,GAAG,QAAQ;IACX,GAAG,KAAK;GACT;EACD,CAAC;EACD,MAAM,GAAG,SAAS,MAAM;EACxB,MAAM,GAAG,UAAU,UAAU,WAAW;GACvC,QAAQ;IACP;IACA;GACD,CAAC;EACF,CAAC;CACF,CAAC;AACF"}
|