@prisma/composer-cli 0.35.0 → 0.36.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.
Files changed (49) hide show
  1. package/dist/app-config-CErnR6NK-6QjHJ7q5.mjs +32 -0
  2. package/dist/app-config-CErnR6NK-6QjHJ7q5.mjs.map +1 -0
  3. package/dist/{container-transport-HcvNOGZL-CIoZc7Rs.mjs → config-DiZaanS3.mjs} +32 -2
  4. package/dist/config-DiZaanS3.mjs.map +1 -0
  5. package/dist/{dev-current-BB02pfSh-vMKS1rYi.mjs → dev-current-Brb4qugP-BOI9FJdz.mjs} +44 -8
  6. package/dist/dev-current-Brb4qugP-BOI9FJdz.mjs.map +1 -0
  7. package/dist/dev-environment-name-6eEr5PW8-lIZmJjfr.mjs +71 -0
  8. package/dist/dev-environment-name-6eEr5PW8-lIZmJjfr.mjs.map +1 -0
  9. package/dist/dist-B9-nLeho.mjs.map +1 -1
  10. package/dist/{execute-deploy-destroy-DwcoZIks-CiW-dlB1.mjs → execute-deploy-destroy-CNt-xpE7-CMQCNQpY.mjs} +32 -56
  11. package/dist/execute-deploy-destroy-CNt-xpE7-CMQCNQpY.mjs.map +1 -0
  12. package/dist/{execute-dev-BHRWoEnd-DrGMSTD3.mjs → execute-dev-BUk-XWBJ-DaB9ma8z.mjs} +45 -23
  13. package/dist/execute-dev-BUk-XWBJ-DaB9ma8z.mjs.map +1 -0
  14. package/dist/{execute-dev-current-D4RkOtPA-BFoZ0cXm.mjs → execute-dev-current-BdEqeKAB-xCBBITAB.mjs} +70 -34
  15. package/dist/execute-dev-current-BdEqeKAB-xCBBITAB.mjs.map +1 -0
  16. package/dist/{family-xJ6y4fXc-CFBu6q4b.d.mts → family-B2JZ8O7U-P_rOUr4w.d.mts} +123 -52
  17. package/dist/family-B2JZ8O7U-P_rOUr4w.d.mts.map +1 -0
  18. package/dist/family.d.mts +3 -3
  19. package/dist/family.d.mts.map +1 -1
  20. package/dist/family.mjs +103 -47
  21. package/dist/family.mjs.map +1 -1
  22. package/dist/{generate-dev-stack-CfneNj97-Yx3Z2-9u.mjs → generate-dev-stack-BkkU2HLE-Dek3CkAQ.mjs} +18 -13
  23. package/dist/generate-dev-stack-BkkU2HLE-Dek3CkAQ.mjs.map +1 -0
  24. package/dist/{list-deployed-df3vxBbn.mjs → list-deployed-GhPuf0RC.mjs} +70 -44
  25. package/dist/list-deployed-GhPuf0RC.mjs.map +1 -0
  26. package/dist/testing.d.mts +3 -1
  27. package/dist/testing.d.mts.map +1 -1
  28. package/dist/testing.mjs +2 -1
  29. package/dist/testing.mjs.map +1 -1
  30. package/dist/{pipeline-BmWt-Nhb-Bos4TFXR.mjs → validate-environment-CEhUSEg2-ExABehBM.mjs} +330 -55
  31. package/dist/validate-environment-CEhUSEg2-ExABehBM.mjs.map +1 -0
  32. package/package.json +7 -7
  33. package/src/family/deploy-list.ts +17 -10
  34. package/src/family/deployed-nodes.ts +10 -10
  35. package/src/family/emulator-list.ts +7 -4
  36. package/src/family/list-deployed.ts +12 -12
  37. package/dist/container-transport-HcvNOGZL-CIoZc7Rs.mjs.map +0 -1
  38. package/dist/dev-current-BB02pfSh-vMKS1rYi.mjs.map +0 -1
  39. package/dist/execute-deploy-destroy-DwcoZIks-CiW-dlB1.mjs.map +0 -1
  40. package/dist/execute-dev-BHRWoEnd-DrGMSTD3.mjs.map +0 -1
  41. package/dist/execute-dev-current-D4RkOtPA-BFoZ0cXm.mjs.map +0 -1
  42. package/dist/family-xJ6y4fXc-CFBu6q4b.d.mts.map +0 -1
  43. package/dist/generate-dev-stack-CfneNj97-Yx3Z2-9u.mjs.map +0 -1
  44. package/dist/list-deployed-df3vxBbn.mjs.map +0 -1
  45. package/dist/local-target-CK8gvYV4.mjs +0 -48
  46. package/dist/local-target-CK8gvYV4.mjs.map +0 -1
  47. package/dist/pipeline-BmWt-Nhb-Bos4TFXR.mjs.map +0 -1
  48. package/dist/validate-stage-DxRW3MwT-DOWCXHa_.mjs +0 -13
  49. package/dist/validate-stage-DxRW3MwT-DOWCXHa_.mjs.map +0 -1
@@ -1,10 +1,12 @@
1
1
  import { m as noComposerExportMessage } from "./run-alchemy-Dl_MWw4g-DaWV9tkH.mjs";
2
+ import { n as devEnvironmentDir } from "./app-config-CErnR6NK-6QjHJ7q5.mjs";
2
3
  import * as fs from "node:fs";
3
4
  import * as path from "node:path";
4
- //#region ../../0-framework/3-tooling/cli/dist/generate-dev-stack-CfneNj97.mjs
5
+ //#region ../../0-framework/3-tooling/cli/dist/generate-dev-stack-BkkU2HLE.mjs
5
6
  /**
6
- * Local-dev spec § 6 `generate-dev-stack.ts`: like generate-stack.ts but at
7
- * `.prisma-composer/dev/alchemy.run.ts`, always Alchemy stage `dev`, using
7
+ * Local-dev spec § 6 `generate-dev-stack.ts`: like generate-stack.ts but in
8
+ * the environment's folder, `.prisma-composer/dev/<environment>/alchemy.run.ts`,
9
+ * at the Alchemy stage named by the environment, using
8
10
  * Composer's `devState()` (Alchemy's file store) and no `report` — dev prints its own front
9
11
  * door (run-dev.ts), so core's presentation-free lower() gets nothing to
10
12
  * call back into. The generated module IS the one orchestration point where
@@ -14,9 +16,12 @@ import * as path from "node:path";
14
16
  * `providers: localTargetProviders(...)` + `state: devState()` explicitly
15
17
  * — `lower()` learns nothing about dev.
16
18
  */
17
- const DEV_GENERATED_DIR = ".prisma-composer/dev";
18
19
  const DEV_GENERATED_FILE = "alchemy.run.ts";
19
- /** A relative import specifier from `.prisma-composer/dev/alchemy.run.ts` to `target` (posix separators). */
20
+ /** The stack file's path relative to the cwd. */
21
+ function devStackRelativePath(environment) {
22
+ return path.join(devEnvironmentDir(environment), DEV_GENERATED_FILE);
23
+ }
24
+ /** A relative import specifier from the stack file to `target` (posix separators). */
20
25
  function relativeImportSpecifier(generatedDir, target) {
21
26
  const rel = path.relative(generatedDir, target).split(path.sep).join("/");
22
27
  return rel.startsWith(".") ? rel : `./${rel}`;
@@ -30,6 +35,7 @@ function renderBundle(bundle) {
30
35
  function renderOptions(input) {
31
36
  const lines = [];
32
37
  lines.push(` name: ${quote(input.name)},`);
38
+ lines.push(` environment: ${quote(input.environment)},`);
33
39
  lines.push(" bundles: {");
34
40
  for (const [id, bundle] of Object.entries(input.assembled.bundles)) lines.push(` ${quote(id)}: ${renderBundle(bundle)},`);
35
41
  lines.push(" },");
@@ -41,13 +47,13 @@ function renderOptions(input) {
41
47
  }
42
48
  /** Renders the dev stack module's source (tests assert on it without touching disk). */
43
49
  function renderDevStackFile(input) {
44
- const generatedDir = path.join(input.cwd, DEV_GENERATED_DIR);
50
+ const generatedDir = path.join(input.cwd, devEnvironmentDir(input.environment));
45
51
  const appImport = relativeImportSpecifier(generatedDir, input.entryPath);
46
52
  const imports = [
47
53
  "import * as path from 'node:path';",
48
54
  "import { deserializeContainers } from '@prisma/composer/config';",
49
55
  "import { lower } from '@prisma/composer/deploy';",
50
- "import { DEV_DIR, devState, localTargetProviders, resolveLocalTargets } from '@prisma/composer/local-target';",
56
+ "import { devEnvironmentDir, devState, localTargetProviders, resolveLocalTargets } from '@prisma/composer/local-target';",
51
57
  `import prismaConfig from ${quote(relativeImportSpecifier(generatedDir, input.configFile))};`,
52
58
  `import app from ${quote(appImport)};`
53
59
  ].join("\n");
@@ -55,7 +61,7 @@ function renderDevStackFile(input) {
55
61
  // edit by hand. Independently runnable from ${quote(input.cwd)} by the
56
62
  // command Composer starts, which a failed run prints:
57
63
  //
58
- // <node> <bin of the alchemy @prisma/composer depends on> deploy ${DEV_GENERATED_DIR}/${DEV_GENERATED_FILE} --yes --stage dev
64
+ // <node> <bin of the alchemy @prisma/composer depends on> deploy ${devStackRelativePath(input.environment)} --yes --stage ${input.environment}
59
65
  //
60
66
  // bisects a CLI bug from an Alchemy bug (deploy-cli.md § Implementation decisions).
61
67
  ${imports}
@@ -67,7 +73,7 @@ if (config === undefined) {
67
73
 
68
74
  const containers = deserializeContainers(config.extensions, process.env);
69
75
  const resolved = await resolveLocalTargets(config);
70
- const devDir = path.join(process.cwd(), DEV_DIR);
76
+ const devDir = path.join(process.cwd(), devEnvironmentDir(${quote(input.environment)}));
71
77
 
72
78
  export default lower(app, config, {
73
79
  ${renderOptions(input)}
@@ -76,14 +82,13 @@ ${renderOptions(input)}
76
82
  }
77
83
  /** Writes the dev stack file, returning its absolute path. */
78
84
  function writeDevStackFile(input) {
79
- const generatedDir = path.join(input.cwd, DEV_GENERATED_DIR);
85
+ const generatedDir = path.join(input.cwd, devEnvironmentDir(input.environment));
80
86
  fs.mkdirSync(generatedDir, { recursive: true });
81
87
  const filePath = path.join(generatedDir, DEV_GENERATED_FILE);
82
88
  fs.writeFileSync(filePath, renderDevStackFile(input));
83
89
  return filePath;
84
90
  }
85
- const DEV_STACK_RELATIVE_PATH = path.join(DEV_GENERATED_DIR, DEV_GENERATED_FILE);
86
91
  //#endregion
87
- export { renderDevStackFile as n, writeDevStackFile as r, DEV_STACK_RELATIVE_PATH as t };
92
+ export { renderDevStackFile as n, writeDevStackFile as r, devStackRelativePath as t };
88
93
 
89
- //# sourceMappingURL=generate-dev-stack-CfneNj97-Yx3Z2-9u.mjs.map
94
+ //# sourceMappingURL=generate-dev-stack-BkkU2HLE-Dek3CkAQ.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-dev-stack-BkkU2HLE-Dek3CkAQ.mjs","names":[],"sources":["../../../0-framework/3-tooling/cli/dist/generate-dev-stack-BkkU2HLE.mjs"],"sourcesContent":["import { i as noComposerExportMessage } from \"./composer-config-ehUUVHtU.mjs\";\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport { devEnvironmentDir } from \"@internal/core/config\";\n//#region src/dev/generate-dev-stack.ts\n/**\n* Local-dev spec § 6 `generate-dev-stack.ts`: like generate-stack.ts but in\n* the environment's folder, `.prisma-composer/dev/<environment>/alchemy.run.ts`,\n* at the Alchemy stage named by the environment, using\n* Composer's `devState()` (Alchemy's file store) and no `report` — dev prints its own front\n* door (run-dev.ts), so core's presentation-free lower() gets nothing to\n* call back into. The generated module IS the one orchestration point where\n* dev provenance is resolved (spec § 3 REVISED): it deserializes the\n* containers, top-level-awaits `resolveLocalTargets(config)` (the lazy\n* `localTarget` thunks, ADR-0041), and passes\n* `providers: localTargetProviders(...)` + `state: devState()` explicitly\n* — `lower()` learns nothing about dev.\n*/\nconst DEV_GENERATED_FILE = \"alchemy.run.ts\";\n/** The stack file's path relative to the cwd. */\nfunction devStackRelativePath(environment) {\n\treturn path.join(devEnvironmentDir(environment), DEV_GENERATED_FILE);\n}\n/** A relative import specifier from the stack file to `target` (posix separators). */\nfunction relativeImportSpecifier(generatedDir, target) {\n\tconst rel = path.relative(generatedDir, target).split(path.sep).join(\"/\");\n\treturn rel.startsWith(\".\") ? rel : `./${rel}`;\n}\nfunction quote(value) {\n\treturn JSON.stringify(value);\n}\nfunction renderBundle(bundle) {\n\treturn `{ dir: ${quote(bundle.dir)}, entry: ${quote(bundle.entry)} }`;\n}\nfunction renderOptions(input) {\n\tconst lines = [];\n\tlines.push(` name: ${quote(input.name)},`);\n\tlines.push(` environment: ${quote(input.environment)},`);\n\tlines.push(\" bundles: {\");\n\tfor (const [id, bundle] of Object.entries(input.assembled.bundles)) lines.push(` ${quote(id)}: ${renderBundle(bundle)},`);\n\tlines.push(\" },\");\n\tconst unassembled = Object.keys(input.assembled.devServers);\n\tif (unassembled.length > 0) lines.push(` unassembled: [${unassembled.map(quote).join(\", \")}],`);\n\tlines.push(\" providers: localTargetProviders(resolved, containers, devDir),\");\n\tlines.push(\" state: devState(),\");\n\treturn lines.join(\"\\n\");\n}\n/** Renders the dev stack module's source (tests assert on it without touching disk). */\nfunction renderDevStackFile(input) {\n\tconst generatedDir = path.join(input.cwd, devEnvironmentDir(input.environment));\n\tconst appImport = relativeImportSpecifier(generatedDir, input.entryPath);\n\tconst imports = [\n\t\t\"import * as path from 'node:path';\",\n\t\t\"import { deserializeContainers } from '@prisma/composer/config';\",\n\t\t\"import { lower } from '@prisma/composer/deploy';\",\n\t\t\"import { devEnvironmentDir, devState, localTargetProviders, resolveLocalTargets } from '@prisma/composer/local-target';\",\n\t\t`import prismaConfig from ${quote(relativeImportSpecifier(generatedDir, input.configFile))};`,\n\t\t`import app from ${quote(appImport)};`\n\t].join(\"\\n\");\n\treturn `// Generated by \\`prisma dev\\` — overwritten on every run; do not\n// edit by hand. Independently runnable from ${quote(input.cwd)} by the\n// command Composer starts, which a failed run prints:\n//\n// <node> <bin of the alchemy @prisma/composer depends on> deploy ${devStackRelativePath(input.environment)} --yes --stage ${input.environment}\n//\n// bisects a CLI bug from an Alchemy bug (deploy-cli.md § Implementation decisions).\n${imports}\n\nconst config = prismaConfig.composer;\nif (config === undefined) {\n throw new Error(${quote(noComposerExportMessage(input.configFile))});\n}\n\nconst containers = deserializeContainers(config.extensions, process.env);\nconst resolved = await resolveLocalTargets(config);\nconst devDir = path.join(process.cwd(), devEnvironmentDir(${quote(input.environment)}));\n\nexport default lower(app, config, {\n${renderOptions(input)}\n});\n`;\n}\n/** Writes the dev stack file, returning its absolute path. */\nfunction writeDevStackFile(input) {\n\tconst generatedDir = path.join(input.cwd, devEnvironmentDir(input.environment));\n\tfs.mkdirSync(generatedDir, { recursive: true });\n\tconst filePath = path.join(generatedDir, DEV_GENERATED_FILE);\n\tfs.writeFileSync(filePath, renderDevStackFile(input));\n\treturn filePath;\n}\n//#endregion\nexport { renderDevStackFile as n, writeDevStackFile as r, devStackRelativePath as t };\n\n//# sourceMappingURL=generate-dev-stack-BkkU2HLE.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;AAkBA,MAAM,qBAAqB;;AAE3B,SAAS,qBAAqB,aAAa;CAC1C,OAAO,KAAK,KAAK,kBAAkB,WAAW,GAAG,kBAAkB;AACpE;;AAEA,SAAS,wBAAwB,cAAc,QAAQ;CACtD,MAAM,MAAM,KAAK,SAAS,cAAc,MAAM,CAAC,CAAC,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,GAAG;CACxE,OAAO,IAAI,WAAW,GAAG,IAAI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AAC,EAAE;;;;;4DAKT,MAAM,MAAM,WAAW,EAAE;;;EAGnF,cAAc,KAAK,EAAE;;;AAGvB;;AAEA,SAAS,kBAAkB,OAAO;CACjC,MAAM,eAAe,KAAK,KAAK,MAAM,KAAK,kBAAkB,MAAM,WAAW,CAAC;CAC9E,GAAG,UAAU,cAAc,EAAE,WAAW,KAAK,CAAC;CAC9C,MAAM,WAAW,KAAK,KAAK,cAAc,kBAAkB;CAC3D,GAAG,cAAc,UAAU,mBAAmB,KAAK,CAAC;CACpD,OAAO;AACR"}
@@ -1,6 +1,5 @@
1
1
  import { a as notOk, c as CliStructuredError, o as ok } from "./run-alchemy-Dl_MWw4g-DaWV9tkH.mjs";
2
- import { n as resolveAppIdentity } from "./pipeline-BmWt-Nhb-Bos4TFXR.mjs";
3
- import { t as validateStageName } from "./validate-stage-DxRW3MwT-DOWCXHa_.mjs";
2
+ import { i as validateEnvironmentName, n as resolveAppIdentity } from "./validate-environment-CEhUSEg2-ExABehBM.mjs";
4
3
  import "effect/Layer";
5
4
  import * as Context from "effect/Context";
6
5
  import * as Effect from "effect/Effect";
@@ -10,7 +9,7 @@ import "effect/Redacted";
10
9
  import * as Data from "effect/Data";
11
10
  Context.Service()("PrismaComposerCredentials");
12
11
  //#endregion
13
- //#region ../../1-prisma-cloud/0-lowering/lowering/dist/container-DOcyaUGR.mjs
12
+ //#region ../../1-prisma-cloud/0-lowering/lowering/dist/container-gq0YJpn0.mjs
14
13
  /**
15
14
  * The typed Prisma Management API client, built once from the resolved
16
15
  * credentials. Providers yield this in their outer Effect and call it inside
@@ -70,8 +69,20 @@ const drivePages = (description, fetchPage, onPage) => Effect.gen(function* () {
70
69
  cursor = next;
71
70
  }
72
71
  });
73
- /** Raised with `ensure: false` when the app's Project (or a named stage's Branch) doesn't exist. */
72
+ /** Raised with `ensure: false` when the app's Project (or a named environment's Branch) doesn't exist. */
74
73
  var ContainerNotFoundError = class extends Data.TaggedError("ContainerNotFoundError") {};
74
+ /** The environment that maps to the Project's default Branch. */
75
+ const PRODUCTION_ENVIRONMENT = "production";
76
+ /** Whether `environment` maps to the Project's default Branch rather than a Branch of its own. */
77
+ function isProductionEnvironment(environment) {
78
+ return environment === PRODUCTION_ENVIRONMENT;
79
+ }
80
+ /** Raised when a name other than `production` resolves to the Project's default Branch, which would make it production under a second name. */
81
+ var DefaultBranchUnderAnotherNameError = class extends Data.TaggedError("DefaultBranchUnderAnotherNameError") {
82
+ get message() {
83
+ return `The environment "${this.environment}" names the Branch ${this.branchId}, which is this Project's default Branch, so that Branch is production. Use the environment ${PRODUCTION_ENVIRONMENT} for it, and another name for a separate environment.`;
84
+ }
85
+ };
75
86
  const listAllProjects = (client) => collectPages("projects", (cursor) => call(() => client.GET("/v1/projects", { params: { query: cursor === void 0 ? {} : { cursor } } })));
76
87
  /**
77
88
  * Workspace ids circulate in two shapes: `wksp_`-prefixed and bare. Compare
@@ -134,51 +145,66 @@ const resolveDefaultBranchId = (client, projectId) => Effect.gen(function* () {
134
145
  message: `project ${projectId} has no default Branch — the platform guarantees every live Project owns one; contact support.`
135
146
  }));
136
147
  });
137
- const findBranchId = (client, projectId, gitName) => call(() => client.GET("/v1/projects/{projectId}/branches", { params: {
148
+ const findBranch = (client, projectId, gitName) => call(() => client.GET("/v1/projects/{projectId}/branches", { params: {
138
149
  path: { projectId },
139
150
  query: { gitName }
140
- } })).pipe(Effect.map((page) => page.data[0]?.id));
151
+ } })).pipe(Effect.map((page) => {
152
+ const branch = page.data[0];
153
+ return branch === void 0 ? void 0 : {
154
+ id: branch.id,
155
+ isDefault: branch.isDefault
156
+ };
157
+ }));
141
158
  /**
142
- * Finds the stage's Branch by its exact `gitName`, creating it if absent
159
+ * Finds the environment's Branch by its exact `gitName`, creating it if absent
143
160
  * unless `ensure` is `false` (find-only — `destroy`), in which case an
144
- * absent Branch fails with `ContainerNotFoundError`. The Management API has
161
+ * absent Branch fails with `ContainerNotFoundError`. A `gitName` that finds
162
+ * the default Branch fails with `DefaultBranchUnderAnotherNameError`. The Management API has
145
163
  * no server-side "create-or-return" idempotency (`POST
146
164
  * /v1/projects/:id/branches` 409s on a duplicate `gitName`, with no request
147
165
  * field to make that a no-op), so idempotency is client-side: observe
148
166
  * first, and on a racing 409 from create, re-observe rather than fail.
149
167
  */
150
168
  const resolveBranch = (client, projectId, gitName, appName, ensure) => Effect.gen(function* () {
151
- const existing = yield* findBranchId(client, projectId, gitName);
152
- if (existing !== void 0) return existing;
169
+ const existing = yield* findBranch(client, projectId, gitName);
170
+ if (existing !== void 0) return yield* refuseDefaultBranch(existing, gitName);
153
171
  if (!ensure) return yield* Effect.fail(new ContainerNotFoundError({
154
172
  appName,
155
- stage: gitName
173
+ environment: gitName
156
174
  }));
157
175
  return yield* call(() => client.POST("/v1/projects/{projectId}/branches", {
158
176
  params: { path: { projectId } },
159
177
  body: { gitName }
160
- })).pipe(Effect.map((r) => r.data.id), Effect.catch((err) => err.status === 409 ? findBranchId(client, projectId, gitName).pipe(Effect.flatMap((id) => id === void 0 ? Effect.fail(err) : Effect.succeed(id))) : Effect.fail(err)));
178
+ })).pipe(Effect.map((r) => r.data.id), Effect.catch((err) => err.status === 409 ? Effect.gen(function* () {
179
+ const found = yield* findBranch(client, projectId, gitName);
180
+ if (found === void 0) return yield* Effect.fail(err);
181
+ return yield* refuseDefaultBranch(found, gitName);
182
+ }) : Effect.fail(err)));
161
183
  });
184
+ const refuseDefaultBranch = (branch, gitName) => branch.isDefault === true ? Effect.fail(new DefaultBranchUnderAnotherNameError({
185
+ environment: gitName,
186
+ branchId: branch.id
187
+ })) : Effect.succeed(branch.id);
162
188
  /**
163
- * Resolves the two containers a stage's deploy runs into (ADR-0019): the
164
- * app's **Project**, found-or-created by name, and — for a named stage
165
- * only — its **Branch**, found-or-created by `gitName`. The default stage
166
- * (no `stage`) creates no Branch; `branchId` is omitted, and the project's
167
- * default Branch's id is read into `defaultBranchId` instead. With `ensure:
168
- * false` (`destroy`), nothing is created — an absent Project or Branch
169
- * fails with `ContainerNotFoundError` instead.
189
+ * Resolves the two containers an environment's deploy runs into (ADR-0019):
190
+ * the app's **Project**, found-or-created by name, and its **Branch**. The
191
+ * environment `production` is the Project's default Branch, read into
192
+ * `defaultBranchId` and never created; `branchId` is omitted. Any other name
193
+ * is the Branch with that `gitName`, found-or-created into `branchId`. With
194
+ * `ensure: false` (`destroy`), nothing is created — an absent Project or
195
+ * Branch fails with `ContainerNotFoundError` instead.
170
196
  */
171
197
  const resolveContainer = (opts) => Effect.gen(function* () {
172
198
  const client = yield* ManagementClient;
173
199
  const ensure = opts.ensure ?? true;
174
200
  const projectId = yield* resolveProject(client, opts.workspaceId, opts.appName, ensure, opts.region);
175
- if (opts.stage === void 0) return {
201
+ if (isProductionEnvironment(opts.environment)) return {
176
202
  projectId,
177
203
  defaultBranchId: yield* resolveDefaultBranchId(client, projectId)
178
204
  };
179
205
  return {
180
206
  projectId,
181
- branchId: yield* resolveBranch(client, projectId, opts.stage, opts.appName, ensure)
207
+ branchId: yield* resolveBranch(client, projectId, opts.environment, opts.appName, ensure)
182
208
  };
183
209
  });
184
210
  //#endregion
@@ -188,11 +214,11 @@ const program = (input) => Effect.gen(function* () {
188
214
  workspaceId: input.workspaceId,
189
215
  appName: input.appName,
190
216
  ensure: false,
191
- ...input.stage === void 0 ? {} : { stage: input.stage }
217
+ environment: input.environment
192
218
  });
193
219
  const { projectId } = container;
194
220
  const branchId = container.branchId ?? container.defaultBranchId;
195
- if (branchId === void 0) return yield* Effect.die(/* @__PURE__ */ new Error(`project ${projectId} resolved no stage Branch`));
221
+ if (branchId === void 0) return yield* Effect.die(/* @__PURE__ */ new Error(`project ${projectId} resolved no Branch`));
196
222
  const client = yield* ManagementClient;
197
223
  const topology = yield* callOptional(() => client.GET("/v1/projects/{projectId}/branches/{branchId}/application-topology", { params: { path: {
198
224
  projectId,
@@ -242,14 +268,14 @@ const program = (input) => Effect.gen(function* () {
242
268
  };
243
269
  });
244
270
  /**
245
- * Reads what a stage has deployed: its Project and Branch by the same
271
+ * Reads what an environment has deployed: its Project and Branch by the same
246
272
  * find-only lookup `destroy` uses, the application topology the last deploy
247
273
  * wrote, and the Branch's services, databases and buckets. `undefined` when
248
274
  * there is no Project or no Branch. Rejects on any other Management API
249
275
  * failure.
250
276
  */
251
- async function readDeployedStage(client, input) {
252
- return Effect.runPromise(program(input).pipe(Effect.catchTag("ContainerNotFoundError", () => Effect.succeed(void 0)), Effect.catchTag("PrismaApiError", (error) => Effect.fail(/* @__PURE__ */ new Error(`Prisma Management API error: ${error.message}.`))), Effect.provideService(ManagementClient, client)));
277
+ async function readDeployedEnvironment(client, input) {
278
+ return Effect.runPromise(program(input).pipe(Effect.catchTag("ContainerNotFoundError", () => Effect.succeed(void 0)), Effect.catchTag("DefaultBranchUnderAnotherNameError", (error) => Effect.fail(new Error(error.message))), Effect.catchTag("PrismaApiError", (error) => Effect.fail(/* @__PURE__ */ new Error(`Prisma Management API error: ${error.message}.`))), Effect.provideService(ManagementClient, client)));
253
279
  }
254
280
  /** The platform row each Prisma Cloud resource type deploys to. A type missing here, such as an S3 credentials resource, has no row. */
255
281
  const RESOURCE_ROW_KINDS = /* @__PURE__ */ new Map([
@@ -272,18 +298,18 @@ function kindOf(node) {
272
298
  function rowId(rows, logicalId) {
273
299
  return rows.find((row) => row.logicalId === logicalId)?.id ?? null;
274
300
  }
275
- function deployedNode(stage, node) {
301
+ function deployedNode(deployed, node) {
276
302
  const kind = kindOf(node);
277
303
  const address = node.logicalId;
278
304
  switch (kind) {
279
305
  case "project": return {
280
306
  address,
281
307
  kind,
282
- platformId: stage.projectId,
308
+ platformId: deployed.projectId,
283
309
  url: null
284
310
  };
285
311
  case "service": {
286
- const row = stage.services.find((service) => service.logicalId === address);
312
+ const row = deployed.services.find((service) => service.logicalId === address);
287
313
  return {
288
314
  address,
289
315
  kind,
@@ -294,13 +320,13 @@ function deployedNode(stage, node) {
294
320
  case "postgres": return {
295
321
  address,
296
322
  kind,
297
- platformId: rowId(stage.databases, address),
323
+ platformId: rowId(deployed.databases, address),
298
324
  url: null
299
325
  };
300
326
  case "bucket": return {
301
327
  address,
302
328
  kind,
303
- platformId: rowId(stage.buckets, address),
329
+ platformId: rowId(deployed.buckets, address),
304
330
  url: null
305
331
  };
306
332
  default: return {
@@ -311,44 +337,44 @@ function deployedNode(stage, node) {
311
337
  };
312
338
  }
313
339
  }
314
- /** Every node of the stage's topology, in topology order, joined by `logicalId` to the platform row it deployed to. The root's row is the Project. */
315
- function deployedNodes(stage) {
316
- return stage.nodes.map((node) => deployedNode(stage, node));
340
+ /** Every node of the environment's topology, in topology order, joined by `logicalId` to the platform row it deployed to. The root's row is the Project. */
341
+ function deployedNodes(deployed) {
342
+ return deployed.nodes.map((node) => deployedNode(deployed, node));
317
343
  }
318
344
  //#endregion
319
345
  //#region src/family/list-deployed.ts
320
- function notFound(app, stage) {
321
- return new CliStructuredError("DEPLOY.TARGET_NOT_FOUND", `Nothing deployed for ${app}${stage === void 0 ? "" : `/${stage}`}.`, { fix: "Deploy it first." });
346
+ function notFound(app, environment) {
347
+ return new CliStructuredError("DEPLOY.TARGET_NOT_FOUND", `Nothing deployed for ${app} in the environment ${environment}.`, { fix: "Deploy it first." });
322
348
  }
323
349
  function lookupFailed(error) {
324
350
  return new CliStructuredError("DEPLOY.CONTAINER_FAILED", error instanceof Error ? error.message : String(error), { cause: error });
325
351
  }
326
- /** Every node the app has deployed on the stage, or `DEPLOY.TARGET_NOT_FOUND` when the stage has no Project, Branch or topology. */
352
+ /** Every node the app has deployed in the environment, or `DEPLOY.TARGET_NOT_FOUND` when the environment has no Project, Branch or topology. */
327
353
  async function listDeployed(input) {
328
354
  let app;
329
355
  try {
330
- if (input.stage !== void 0) validateStageName(input.stage);
356
+ validateEnvironmentName(input.environment);
331
357
  app = (await resolveAppIdentity(input.entry, input.name, input.cwd, input.config)).name;
332
358
  } catch (error) {
333
359
  if (CliStructuredError.is(error)) return notOk(error);
334
360
  throw error;
335
361
  }
336
362
  if (input.workspaceId === void 0) return notOk(lookupFailed(/* @__PURE__ */ new Error("environment variable PRISMA_WORKSPACE_ID is required.")));
337
- let stage;
363
+ let deployed;
338
364
  try {
339
- stage = await readDeployedStage(input.client, {
365
+ deployed = await readDeployedEnvironment(input.client, {
340
366
  workspaceId: input.workspaceId,
341
367
  appName: app,
342
- stage: input.stage
368
+ environment: input.environment
343
369
  });
344
370
  } catch (error) {
345
371
  return notOk(lookupFailed(error));
346
372
  }
347
- const nodes = stage === void 0 ? [] : deployedNodes(stage);
348
- if (nodes.length === 0) return notOk(notFound(app, input.stage));
373
+ const nodes = deployed === void 0 ? [] : deployedNodes(deployed);
374
+ if (nodes.length === 0) return notOk(notFound(app, input.environment));
349
375
  return ok(nodes);
350
376
  }
351
377
  //#endregion
352
378
  export { listDeployed };
353
379
 
354
- //# sourceMappingURL=list-deployed-df3vxBbn.mjs.map
380
+ //# sourceMappingURL=list-deployed-GhPuf0RC.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list-deployed-GhPuf0RC.mjs","names":[],"sources":["../../../1-prisma-cloud/0-lowering/lowering/dist/credentials-D0SO8QC_.mjs","../../../1-prisma-cloud/0-lowering/lowering/dist/container-gq0YJpn0.mjs","../../../1-prisma-cloud/0-lowering/lowering/dist/deployed.mjs","../src/family/deployed-nodes.ts","../src/family/list-deployed.ts"],"sourcesContent":["import * as Context from \"effect/Context\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport * as Config from \"effect/Config\";\n//#region package.json\nvar version = \"0.36.0-dev.1\";\n//#endregion\n//#region src/credentials.ts\n/**\n* The Prisma service token used to authenticate Management API calls. Kept\n* as a Redacted value so it never lands in logs or error output.\n*/\nvar PrismaCredentials = class extends Context.Service()(\"PrismaComposerCredentials\") {};\n/** Resolve the token from the `PRISMA_SERVICE_TOKEN` environment variable. */\nconst fromEnv = () => Layer.effect(PrismaCredentials, Effect.gen(function* () {\n\treturn { token: yield* Config.Redacted(\"PRISMA_SERVICE_TOKEN\") };\n}));\nconst DEFAULT_BASE_URL = \"https://api.prisma.io\";\nconst isLoopbackHost = (hostname) => hostname === \"localhost\" || hostname.endsWith(\".localhost\") || hostname === \"127.0.0.1\" || hostname === \"[::1]\";\n/** Same validation as upstream alchemy's `PrismaEnvironment`: an HTTP(S) origin, HTTPS unless loopback, no credentials, no path/query/fragment. */\nconst normalizeBaseUrl = (value) => Effect.try({\n\ttry: () => {\n\t\tconst url = new URL(value);\n\t\tif (url.protocol !== \"https:\" && url.protocol !== \"http:\") throw new Error(\"Prisma Management API URL must use HTTP or HTTPS.\");\n\t\tif (url.username.length > 0 || url.password.length > 0) throw new Error(\"Prisma Management API URL must not contain credentials.\");\n\t\tif (url.protocol === \"http:\" && !isLoopbackHost(url.hostname)) throw new Error(\"Prisma Management API URL must use HTTPS unless it targets a loopback host.\");\n\t\tif (url.pathname !== \"/\" && url.pathname !== \"\" || url.search.length > 0 || url.hash.length > 0) throw new Error(\"Prisma Management API URL must be an origin without a path, query, or fragment.\");\n\t\treturn url.origin;\n\t},\n\tcatch: (cause) => cause instanceof Error ? cause : /* @__PURE__ */ new Error(`Invalid Prisma Management API URL: ${String(cause)}`)\n});\n/**\n* Headers the Management API records in its deploy analytics: which tool sent\n* the request, and whether it ran in GitHub Actions. The API behaves the same\n* without them.\n*/\nconst deploySourceHeaders = () => ({\n\t\"x-prisma-deploy-source\": process.env[\"GITHUB_ACTIONS\"] === \"true\" ? \"github-action\" : \"composer\",\n\t\"x-prisma-client-name\": \"composer\",\n\t\"x-prisma-client-version\": version\n});\n/**\n* The Management API origin every Prisma-Cloud client in this package uses —\n* Composer's own SDK client AND upstream alchemy's postgres providers resolve\n* it through this one function, so `PRISMA_API_URL` can never point them at\n* different hosts. Mirrors upstream alchemy's `PrismaEnvironment` resolution:\n* `PRISMA_API_URL`, then `PRISMA_MANAGEMENT_API_URL`, then the public origin,\n* normalized and validated identically.\n*/\nconst managementApiBaseUrl = (env) => env !== void 0 ? normalizeBaseUrl(env[\"PRISMA_API_URL\"] || env[\"PRISMA_MANAGEMENT_API_URL\"] || DEFAULT_BASE_URL) : Config.String(\"PRISMA_API_URL\").pipe(Config.orElse(() => Config.String(\"PRISMA_MANAGEMENT_API_URL\")), Config.withDefault(DEFAULT_BASE_URL), Effect.flatMap(normalizeBaseUrl));\n//#endregion\nexport { managementApiBaseUrl as i, deploySourceHeaders as n, fromEnv as r, PrismaCredentials as t };\n\n//# sourceMappingURL=credentials-D0SO8QC_.mjs.map","import { i as managementApiBaseUrl, n as deploySourceHeaders, t as PrismaCredentials } from \"./credentials-D0SO8QC_.mjs\";\nimport { createManagementApiClient } from \"@prisma/management-api-sdk\";\nimport * as Context from \"effect/Context\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport * as Redacted from \"effect/Redacted\";\nimport * as Data from \"effect/Data\";\n//#region src/client.ts\n/**\n* The typed Prisma Management API client, built once from the resolved\n* credentials. Providers yield this in their outer Effect and call it inside\n* `reconcile` / `delete`.\n*/\nvar ManagementClient = class extends Context.Service()(\"PrismaManagementClient\") {};\n/**\n* By default the base URL comes from `managementApiBaseUrl()` — the SAME\n* resolver upstream's providers use (see providers.ts), so `PRISMA_API_URL`\n* can never split the postgres family and the compute/bucket/state clients\n* across hosts. `apiOrigin` overrides it (tests point it at a fake).\n*/\nconst layer = (options) => Layer.effect(ManagementClient, Effect.gen(function* () {\n\tconst { token } = yield* PrismaCredentials;\n\tconst baseUrl = options?.apiOrigin ?? (yield* managementApiBaseUrl());\n\treturn createManagementApiClient({\n\t\ttoken: Redacted.value(token),\n\t\tbaseUrl,\n\t\theaders: deploySourceHeaders()\n\t});\n}));\n//#endregion\n//#region src/http.ts\n/** A non-2xx response from the Management API (or a transport failure). */\nvar PrismaApiError = class extends Data.TaggedError(\"PrismaApiError\") {};\nconst attempt = (f) => Effect.tryPromise({\n\ttry: f,\n\tcatch: (cause) => new PrismaApiError({\n\t\tstatus: 0,\n\t\tmessage: String(cause)\n\t})\n});\nconst fail = (r) => Effect.fail(new PrismaApiError({\n\tstatus: r.response.status,\n\tmessage: JSON.stringify(r.error)\n}));\n/** Unwrap `data`, failing on any API error. Preserves the SDK's response type. */\nconst call = (f) => attempt(f).pipe(Effect.flatMap((r) => r.error !== void 0 || r.data === void 0 ? fail(r) : Effect.succeed(r.data)));\n/** Unwrap `data`, mapping a 404 to `undefined` (resource gone / not found). */\nconst callOptional = (f) => attempt(f).pipe(Effect.flatMap((r) => r.response.status === 404 ? Effect.succeed(void 0) : r.error !== void 0 ? fail(r) : Effect.succeed(r.data)));\n/** Fire-and-forget a call, tolerating a 404 (already deleted). */\nconst callVoid = (f) => attempt(f).pipe(Effect.flatMap((r) => r.response.status === 404 || r.error === void 0 ? Effect.void : fail(r)));\n/**\n* Fire a CREATE call, tolerating a 409 (it already exists). Gives the caller\n* create-only semantics: the thing is created when absent, and an existing one\n* — whoever created it — is left exactly as it is.\n*/\nconst callCreateOnly = (f) => attempt(f).pipe(Effect.flatMap((r) => r.response.status === 409 || r.error === void 0 ? Effect.void : fail(r)));\n//#endregion\n//#region src/pagination.ts\n/** Far beyond any real collection size per listing; hitting it means the API's pagination is broken. */\nconst MAX_PAGES = 1e3;\nconst brokenPaginationError = (description, reason) => new PrismaApiError({\n\tstatus: 0,\n\tmessage: `listing ${description} ${reason} — the Management API pagination appears broken; refusing to continue with a possibly incomplete listing.`\n});\n/** {@link drivePages} in its most common shape: every page's rows, accumulated. */\nconst collectPages = (description, fetchPage) => Effect.gen(function* () {\n\tconst rows = [];\n\tyield* drivePages(description, fetchPage, (data) => {\n\t\trows.push(...data);\n\t\treturn false;\n\t});\n\treturn rows;\n});\n/**\n* Drives a cursor-paginated Management API listing with a guard against\n* broken pagination: a cursor that does not advance, more pages reported\n* without a cursor to fetch them with, or more than {@link MAX_PAGES} pages,\n* FAILS instead of hanging forever or returning a listing known to be\n* incomplete. `onPage` receives each page's rows as they arrive; returning\n* `true` stops early (the caller found what it wanted).\n*/\nconst drivePages = (description, fetchPage, onPage) => Effect.gen(function* () {\n\tlet cursor;\n\tfor (let pageCount = 0;; pageCount++) {\n\t\tif (pageCount >= MAX_PAGES) return yield* Effect.fail(brokenPaginationError(description, `did not finish within ${String(MAX_PAGES)} pages`));\n\t\tconst page = yield* fetchPage(cursor);\n\t\tif (onPage(page.data)) return;\n\t\tif (!page.pagination.hasMore) return;\n\t\tconst next = page.pagination.nextCursor;\n\t\tif (next === null) return yield* Effect.fail(brokenPaginationError(description, \"reported more pages but returned no cursor\"));\n\t\tif (next === cursor) return yield* Effect.fail(brokenPaginationError(description, \"returned a non-advancing cursor\"));\n\t\tcursor = next;\n\t}\n});\n/**\n* {@link drivePages} for Promise-based callers (e.g. target's preflight,\n* which speaks the SDK's `{data, error}` shape directly). Same guard, same\n* errors; deliberately a sibling loop rather than a wrapper, because routing\n* a Promise fetch through Effect and back (`Effect.tryPromise` +\n* `runPromise`) would re-wrap the caller's own thrown errors. `fetchPage`\n* rejections propagate untouched.\n*/\nasync function drivePagesAsync(description, fetchPage, onPage) {\n\tlet cursor;\n\tfor (let pageCount = 0;; pageCount++) {\n\t\tif (pageCount >= MAX_PAGES) throw brokenPaginationError(description, `did not finish within ${String(MAX_PAGES)} pages`);\n\t\tconst page = await fetchPage(cursor);\n\t\tif (onPage(page.data)) return;\n\t\tif (!page.pagination.hasMore) return;\n\t\tconst next = page.pagination.nextCursor;\n\t\tif (next === null) throw brokenPaginationError(description, \"reported more pages but returned no cursor\");\n\t\tif (next === cursor) throw brokenPaginationError(description, \"returned a non-advancing cursor\");\n\t\tcursor = next;\n\t}\n}\n//#endregion\n//#region src/container.ts\n/** Raised with `ensure: false` when the app's Project (or a named environment's Branch) doesn't exist. */\nvar ContainerNotFoundError = class extends Data.TaggedError(\"ContainerNotFoundError\") {};\n/** The environment that maps to the Project's default Branch. */\nconst PRODUCTION_ENVIRONMENT = \"production\";\n/** Whether `environment` maps to the Project's default Branch rather than a Branch of its own. */\nfunction isProductionEnvironment(environment) {\n\treturn environment === PRODUCTION_ENVIRONMENT;\n}\n/** Raised when a name other than `production` resolves to the Project's default Branch, which would make it production under a second name. */\nvar DefaultBranchUnderAnotherNameError = class extends Data.TaggedError(\"DefaultBranchUnderAnotherNameError\") {\n\tget message() {\n\t\treturn `The environment \"${this.environment}\" names the Branch ${this.branchId}, which is this Project's default Branch, so that Branch is production. Use the environment ${PRODUCTION_ENVIRONMENT} for it, and another name for a separate environment.`;\n\t}\n};\nconst listAllProjects = (client) => collectPages(\"projects\", (cursor) => call(() => client.GET(\"/v1/projects\", { params: { query: cursor === void 0 ? {} : { cursor } } })));\n/**\n* Workspace ids circulate in two shapes: `wksp_`-prefixed and bare. Compare\n* bare-to-bare so a `wksp_`-prefixed API id still matches a bare configured\n* one (the same normalization `state/bootstrap.ts` applies to the same\n* `/v1/projects` listing).\n*/\nconst bareWorkspaceId = (id) => id.startsWith(\"wksp_\") ? id.slice(5) : id;\n/**\n* Finds the app's Project by logical id or name in the workspace, creating\n* one if absent. Logical id match (exact, workspace-unique) is preferred over\n* display-name match (oldest-wins fallback for projects without a logical id).\n* Creates one if none match, unless `ensure` is `false` (find-only —\n* `destroy`), in which case an absent Project fails with\n* `ContainerNotFoundError`. No ownership marker and no `--project` override\n* (both deferred — see ADR-0019).\n*/\nconst resolveProject = (client, workspaceId, appName, ensure, region) => Effect.gen(function* () {\n\tconst workspaceProjects = (yield* listAllProjects(client)).filter((p) => bareWorkspaceId(p.workspace.id) === bareWorkspaceId(workspaceId));\n\tconst logicalIdMatch = workspaceProjects.find((p) => p.logicalId != null && p.logicalId === appName);\n\tif (logicalIdMatch !== void 0) return logicalIdMatch.id;\n\tconst nameMatch = workspaceProjects.filter((p) => p.name === appName).sort((a, b) => a.createdAt.localeCompare(b.createdAt))[0];\n\tif (nameMatch !== void 0) return nameMatch.id;\n\tif (!ensure) return yield* Effect.fail(new ContainerNotFoundError({ appName }));\n\tif (region === void 0) return yield* Effect.fail(new PrismaApiError({\n\t\tstatus: 0,\n\t\tmessage: `project \"${appName}\" does not exist yet and no deploy region is configured. Set the region via prismaCloud({ region: '<id>' }) in your config, or set the PRISMA_REGION environment variable`\n\t}));\n\treturn (yield* call(() => client.POST(\"/v1/projects\", { body: {\n\t\tname: appName,\n\t\tworkspaceId,\n\t\tcreateDatabase: false,\n\t\tlogicalId: appName,\n\t\tregion\n\t} })).pipe(Effect.catch((err) => err.status === 409 ? Effect.fail(new PrismaApiError({\n\t\tstatus: 409,\n\t\tmessage: \"a project with this name already exists in the workspace; rename your Composer module or free the name.\"\n\t})) : Effect.fail(err)))).data.id;\n});\n/**\n* The project's implicit default Branch — every live Project owns exactly\n* one (a platform invariant). The list endpoint has no `isDefault` filter,\n* so this pages through the Branches (bounded — drivePages) and returns as\n* soon as a page contains it. Never creates one: its absence means the\n* platform's invariant is broken, which is not something a deploy can\n* repair.\n*/\nconst resolveDefaultBranchId = (client, projectId) => Effect.gen(function* () {\n\tlet found;\n\tyield* drivePages(`branches of project ${projectId}`, (cursor) => call(() => client.GET(\"/v1/projects/{projectId}/branches\", { params: {\n\t\tpath: { projectId },\n\t\tquery: cursor === void 0 ? {} : { cursor }\n\t} })), (data) => {\n\t\tfound = data.find((b) => b.isDefault)?.id;\n\t\treturn found !== void 0;\n\t});\n\tif (found !== void 0) return found;\n\treturn yield* Effect.fail(new PrismaApiError({\n\t\tstatus: 0,\n\t\tmessage: `project ${projectId} has no default Branch — the platform guarantees every live Project owns one; contact support.`\n\t}));\n});\nconst findBranch = (client, projectId, gitName) => call(() => client.GET(\"/v1/projects/{projectId}/branches\", { params: {\n\tpath: { projectId },\n\tquery: { gitName }\n} })).pipe(Effect.map((page) => {\n\tconst branch = page.data[0];\n\treturn branch === void 0 ? void 0 : {\n\t\tid: branch.id,\n\t\tisDefault: branch.isDefault\n\t};\n}));\n/**\n* Finds the environment's Branch by its exact `gitName`, creating it if absent\n* unless `ensure` is `false` (find-only — `destroy`), in which case an\n* absent Branch fails with `ContainerNotFoundError`. A `gitName` that finds\n* the default Branch fails with `DefaultBranchUnderAnotherNameError`. The Management API has\n* no server-side \"create-or-return\" idempotency (`POST\n* /v1/projects/:id/branches` 409s on a duplicate `gitName`, with no request\n* field to make that a no-op), so idempotency is client-side: observe\n* first, and on a racing 409 from create, re-observe rather than fail.\n*/\nconst resolveBranch = (client, projectId, gitName, appName, ensure) => Effect.gen(function* () {\n\tconst existing = yield* findBranch(client, projectId, gitName);\n\tif (existing !== void 0) return yield* refuseDefaultBranch(existing, gitName);\n\tif (!ensure) return yield* Effect.fail(new ContainerNotFoundError({\n\t\tappName,\n\t\tenvironment: gitName\n\t}));\n\treturn yield* call(() => client.POST(\"/v1/projects/{projectId}/branches\", {\n\t\tparams: { path: { projectId } },\n\t\tbody: { gitName }\n\t})).pipe(Effect.map((r) => r.data.id), Effect.catch((err) => err.status === 409 ? Effect.gen(function* () {\n\t\tconst found = yield* findBranch(client, projectId, gitName);\n\t\tif (found === void 0) return yield* Effect.fail(err);\n\t\treturn yield* refuseDefaultBranch(found, gitName);\n\t}) : Effect.fail(err)));\n});\nconst refuseDefaultBranch = (branch, gitName) => branch.isDefault === true ? Effect.fail(new DefaultBranchUnderAnotherNameError({\n\tenvironment: gitName,\n\tbranchId: branch.id\n})) : Effect.succeed(branch.id);\n/**\n* Resolves the two containers an environment's deploy runs into (ADR-0019):\n* the app's **Project**, found-or-created by name, and its **Branch**. The\n* environment `production` is the Project's default Branch, read into\n* `defaultBranchId` and never created; `branchId` is omitted. Any other name\n* is the Branch with that `gitName`, found-or-created into `branchId`. With\n* `ensure: false` (`destroy`), nothing is created — an absent Project or\n* Branch fails with `ContainerNotFoundError` instead.\n*/\nconst resolveContainer = (opts) => Effect.gen(function* () {\n\tconst client = yield* ManagementClient;\n\tconst ensure = opts.ensure ?? true;\n\tconst projectId = yield* resolveProject(client, opts.workspaceId, opts.appName, ensure, opts.region);\n\tif (isProductionEnvironment(opts.environment)) return {\n\t\tprojectId,\n\t\tdefaultBranchId: yield* resolveDefaultBranchId(client, projectId)\n\t};\n\treturn {\n\t\tprojectId,\n\t\tbranchId: yield* resolveBranch(client, projectId, opts.environment, opts.appName, ensure)\n\t};\n});\n/**\n* Soft-deletes a Branch. Tolerates a 404 (already gone). The API refuses if\n* the Branch still has live members or is the production/default Branch —\n* that surfaces as a `PrismaApiError`.\n*/\nconst deleteBranch = (branchId) => Effect.gen(function* () {\n\tconst client = yield* ManagementClient;\n\tyield* callVoid(() => client.DELETE(\"/v1/branches/{branchId}\", { params: { path: { branchId } } }));\n});\n/**\n* Deletes a Project. Tolerates a 404 (already gone). The API refuses with a\n* 400 if the Project still has live dependencies (e.g. another environment's\n* Branch/resources) — that surfaces as a `PrismaApiError`.\n*/\nconst deleteProject = (projectId) => Effect.gen(function* () {\n\tconst client = yield* ManagementClient;\n\tyield* callVoid(() => client.DELETE(\"/v1/projects/{id}\", { params: { path: { id: projectId } } }));\n});\n//#endregion\nexport { layer as _, deleteProject as a, resolveDefaultBranchId as c, drivePagesAsync as d, PrismaApiError as f, ManagementClient as g, callOptional as h, deleteBranch as i, collectPages as l, callCreateOnly as m, DefaultBranchUnderAnotherNameError as n, isProductionEnvironment as o, call as p, PRODUCTION_ENVIRONMENT as r, resolveContainer as s, ContainerNotFoundError as t, drivePages as u };\n\n//# sourceMappingURL=container-gq0YJpn0.mjs.map","import { g as ManagementClient, h as callOptional, l as collectPages, p as call, s as resolveContainer } from \"./container-gq0YJpn0.mjs\";\nimport * as Effect from \"effect/Effect\";\n//#region src/deployed.ts\nconst program = (input) => Effect.gen(function* () {\n\tconst container = yield* resolveContainer({\n\t\tworkspaceId: input.workspaceId,\n\t\tappName: input.appName,\n\t\tensure: false,\n\t\tenvironment: input.environment\n\t});\n\tconst { projectId } = container;\n\tconst branchId = container.branchId ?? container.defaultBranchId;\n\tif (branchId === void 0) return yield* Effect.die(/* @__PURE__ */ new Error(`project ${projectId} resolved no Branch`));\n\tconst client = yield* ManagementClient;\n\tconst topology = yield* callOptional(() => client.GET(\"/v1/projects/{projectId}/branches/{branchId}/application-topology\", { params: { path: {\n\t\tprojectId,\n\t\tbranchId\n\t} } }));\n\tif (topology === void 0 || topology.data.nodes.length === 0) return {\n\t\tprojectId,\n\t\tbranchId,\n\t\tnodes: [],\n\t\tservices: [],\n\t\tdatabases: [],\n\t\tbuckets: []\n\t};\n\tconst query = (cursor) => cursor === void 0 ? {\n\t\tprojectId,\n\t\tbranchId\n\t} : {\n\t\tprojectId,\n\t\tbranchId,\n\t\tcursor\n\t};\n\tconst services = yield* collectPages(`services of branch ${branchId}`, (cursor) => call(() => client.GET(\"/v1/services\", { params: { query: query(cursor) } })));\n\tconst databases = yield* collectPages(`databases of branch ${branchId}`, (cursor) => call(() => client.GET(\"/v1/databases\", { params: { query: query(cursor) } })));\n\tconst buckets = yield* collectPages(`buckets of branch ${branchId}`, (cursor) => call(() => client.GET(\"/v1/buckets\", { params: { query: query(cursor) } })));\n\treturn {\n\t\tprojectId,\n\t\tbranchId,\n\t\tnodes: topology.data.nodes.map(({ logicalId, parentLogicalId, kind, type }) => ({\n\t\t\tlogicalId,\n\t\t\tparentLogicalId,\n\t\t\tkind,\n\t\t\t...type === void 0 ? {} : { type }\n\t\t})),\n\t\tservices: services.map(({ id, logicalId, appEndpointDomain }) => ({\n\t\t\tid,\n\t\t\tlogicalId,\n\t\t\tappEndpointDomain\n\t\t})),\n\t\tdatabases: databases.map(({ id, logicalId }) => ({\n\t\t\tid,\n\t\t\tlogicalId\n\t\t})),\n\t\tbuckets: buckets.map(({ id, logicalId }) => ({\n\t\t\tid,\n\t\t\tlogicalId\n\t\t}))\n\t};\n});\n/**\n* Reads what an environment has deployed: its Project and Branch by the same\n* find-only lookup `destroy` uses, the application topology the last deploy\n* wrote, and the Branch's services, databases and buckets. `undefined` when\n* there is no Project or no Branch. Rejects on any other Management API\n* failure.\n*/\nasync function readDeployedEnvironment(client, input) {\n\treturn Effect.runPromise(program(input).pipe(Effect.catchTag(\"ContainerNotFoundError\", () => Effect.succeed(void 0)), Effect.catchTag(\"DefaultBranchUnderAnotherNameError\", (error) => Effect.fail(new Error(error.message))), Effect.catchTag(\"PrismaApiError\", (error) => Effect.fail(/* @__PURE__ */ new Error(`Prisma Management API error: ${error.message}.`))), Effect.provideService(ManagementClient, client)));\n}\n//#endregion\n//#region src/resource-rows.ts\n/** The platform row each Prisma Cloud resource type deploys to. A type missing here, such as an S3 credentials resource, has no row. */\nconst RESOURCE_ROW_KINDS = /* @__PURE__ */ new Map([\n\t[\"postgres\", \"database\"],\n\t[\"raw-postgres\", \"database\"],\n\t[\"s3\", \"bucket\"]\n]);\n//#endregion\nexport { RESOURCE_ROW_KINDS, readDeployedEnvironment };\n\n//# sourceMappingURL=deployed.mjs.map","import { type DeployedEnvironment, RESOURCE_ROW_KINDS } from '@internal/lowering/deployed';\n\n/** One row of `deploy list`: a topology node and the platform row it deployed to. */\nexport interface DeployedNode {\n readonly address: string;\n readonly kind: string;\n readonly platformId: string | null;\n readonly url: string | null;\n}\n\ntype TopologyNode = DeployedEnvironment['nodes'][number];\n\nfunction kindOf(node: TopologyNode): string {\n if (node.parentLogicalId === null) return 'project';\n if (node.kind === 'resource') {\n if (node.type === undefined) return 'resource';\n const rowKind = RESOURCE_ROW_KINDS.get(node.type);\n if (rowKind === 'database') return 'postgres';\n return rowKind ?? node.type;\n }\n return node.kind;\n}\n\nfunction rowId(rows: readonly { id: string; logicalId: string | null }[], logicalId: string) {\n return rows.find((row) => row.logicalId === logicalId)?.id ?? null;\n}\n\nfunction deployedNode(deployed: DeployedEnvironment, node: TopologyNode): DeployedNode {\n const kind = kindOf(node);\n const address = node.logicalId;\n switch (kind) {\n case 'project':\n return { address, kind, platformId: deployed.projectId, url: null };\n case 'service': {\n const row = deployed.services.find((service) => service.logicalId === address);\n return {\n address,\n kind,\n platformId: row?.id ?? null,\n url: row?.appEndpointDomain ?? null,\n };\n }\n case 'postgres':\n return { address, kind, platformId: rowId(deployed.databases, address), url: null };\n case 'bucket':\n return { address, kind, platformId: rowId(deployed.buckets, address), url: null };\n default:\n return { address, kind, platformId: null, url: null };\n }\n}\n\n/** Every node of the environment's topology, in topology order, joined by `logicalId` to the platform row it deployed to. The root's row is the Project. */\nexport function deployedNodes(deployed: DeployedEnvironment): DeployedNode[] {\n return deployed.nodes.map((node) => deployedNode(deployed, node));\n}\n","import { resolveAppIdentity, validateEnvironmentName } from '@internal/cli/app-identity';\nimport type { ComposerConfigSource } from '@internal/cli/control';\nimport { CliStructuredError } from '@internal/foundation/errors';\nimport { notOk, ok, type Result } from '@internal/foundation/result';\nimport { readDeployedEnvironment } from '@internal/lowering/deployed';\nimport type { ManagementApiClient } from '@prisma/cli-engine';\nimport { type DeployedNode, deployedNodes } from './deployed-nodes.ts';\n\nexport interface ListDeployedInput {\n readonly config: ComposerConfigSource;\n readonly entry: string | undefined;\n readonly name: string | undefined;\n readonly environment: string;\n readonly cwd: string;\n readonly workspaceId: string | undefined;\n readonly client: ManagementApiClient;\n}\n\nfunction notFound(app: string, environment: string): CliStructuredError {\n return new CliStructuredError(\n 'DEPLOY.TARGET_NOT_FOUND',\n `Nothing deployed for ${app} in the environment ${environment}.`,\n { fix: 'Deploy it first.' },\n );\n}\n\nfunction lookupFailed(error: unknown): CliStructuredError {\n return new CliStructuredError(\n 'DEPLOY.CONTAINER_FAILED',\n error instanceof Error ? error.message : String(error),\n { cause: error },\n );\n}\n\n/** Every node the app has deployed in the environment, or `DEPLOY.TARGET_NOT_FOUND` when the environment has no Project, Branch or topology. */\nexport async function listDeployed(\n input: ListDeployedInput,\n): Promise<Result<readonly DeployedNode[], CliStructuredError>> {\n let app: string;\n try {\n validateEnvironmentName(input.environment);\n app = (await resolveAppIdentity(input.entry, input.name, input.cwd, input.config)).name;\n } catch (error) {\n if (CliStructuredError.is(error)) return notOk(error);\n throw error;\n }\n if (input.workspaceId === undefined) {\n return notOk(lookupFailed(new Error('environment variable PRISMA_WORKSPACE_ID is required.')));\n }\n\n let deployed: Awaited<ReturnType<typeof readDeployedEnvironment>>;\n try {\n deployed = await readDeployedEnvironment(input.client, {\n workspaceId: input.workspaceId,\n appName: app,\n environment: input.environment,\n });\n } catch (error) {\n return notOk(lookupFailed(error));\n }\n const nodes = deployed === undefined ? [] : deployedNodes(deployed);\n if (nodes.length === 0) return notOk(notFound(app, input.environment));\n return ok(nodes);\n}\n"],"mappings":";;;;;;;;;AAYsC,QAAQ,QAAQ,CAAC,CAAC,2BAA2B;;;;;;;;ACCnF,IAAI,mBAAmB,cAAc,QAAQ,QAAQ,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC;;AAmBlF,IAAI,iBAAiB,cAAc,KAAK,YAAY,gBAAgB,CAAC,CAAC,CAAC;AACvE,MAAM,WAAW,MAAM,OAAO,WAAW;CACxC,KAAK;CACL,QAAQ,UAAU,IAAI,eAAe;EACpC,QAAQ;EACR,SAAS,OAAO,KAAK;CACtB,CAAC;AACF,CAAC;AACD,MAAM,QAAQ,MAAM,OAAO,KAAK,IAAI,eAAe;CAClD,QAAQ,EAAE,SAAS;CACnB,SAAS,KAAK,UAAU,EAAE,KAAK;AAChC,CAAC,CAAC;;AAEF,MAAM,QAAQ,MAAM,QAAQ,CAAC,CAAC,CAAC,KAAK,OAAO,SAAS,MAAM,EAAE,UAAU,KAAK,KAAK,EAAE,SAAS,KAAK,IAAI,KAAK,CAAC,IAAI,OAAO,QAAQ,EAAE,IAAI,CAAC,CAAC;;AAErI,MAAM,gBAAgB,MAAM,QAAQ,CAAC,CAAC,CAAC,KAAK,OAAO,SAAS,MAAM,EAAE,SAAS,WAAW,MAAM,OAAO,QAAQ,KAAK,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,KAAK,CAAC,IAAI,OAAO,QAAQ,EAAE,IAAI,CAAC,CAAC;;AAY7K,MAAM,YAAY;AAClB,MAAM,yBAAyB,aAAa,WAAW,IAAI,eAAe;CACzE,QAAQ;CACR,SAAS,WAAW,YAAY,GAAG,OAAO;AAC3C,CAAC;;AAED,MAAM,gBAAgB,aAAa,cAAc,OAAO,IAAI,aAAa;CACxE,MAAM,OAAO,CAAC;CACd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a,UAAU,IAAI,CAAC;AAClE;;;ACpCA,SAAS,SAAS,KAAa,aAAyC;CACtE,OAAO,IAAI,mBACT,2BACA,wBAAwB,IAAI,sBAAsB,YAAY,IAC9D,EAAE,KAAK,mBAAmB,CAC5B;AACF;AAEA,SAAS,aAAa,OAAoC;CACxD,OAAO,IAAI,mBACT,2BACA,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GACrD,EAAE,OAAO,MAAM,CACjB;AACF;;AAGA,eAAsB,aACpB,OAC8D;CAC9D,IAAI;CACJ,IAAI;EACF,wBAAwB,MAAM,WAAW;EACzC,OAAO,MAAM,mBAAmB,MAAM,OAAO,MAAM,MAAM,MAAM,KAAK,MAAM,MAAM,EAAA,CAAG;CACrF,SAAS,OAAO;EACd,IAAI,mBAAmB,GAAG,KAAK,GAAG,OAAO,MAAM,KAAK;EACpD,MAAM;CACR;CACA,IAAI,MAAM,gBAAgB,KAAA,GACxB,OAAO,MAAM,6BAAa,IAAI,MAAM,uDAAuD,CAAC,CAAC;CAG/F,IAAI;CACJ,IAAI;EACF,WAAW,MAAM,wBAAwB,MAAM,QAAQ;GACrD,aAAa,MAAM;GACnB,SAAS;GACT,aAAa,MAAM;EACrB,CAAC;CACH,SAAS,OAAO;EACd,OAAO,MAAM,aAAa,KAAK,CAAC;CAClC;CACA,MAAM,QAAQ,aAAa,KAAA,IAAY,CAAC,IAAI,cAAc,QAAQ;CAClE,IAAI,MAAM,WAAW,GAAG,OAAO,MAAM,SAAS,KAAK,MAAM,WAAW,CAAC;CACrE,OAAO,GAAG,KAAK;AACjB"}
@@ -1,4 +1,4 @@
1
- import { _ as AssembledServices, a as DeployInput, c as DevInput, d as DevStopped, f as DevUrl, g as Result, h as ServiceEndpoint, i as DeployEvent, l as DevSession, m as OperationDeps, o as DeploySuccess, p as DevUrlInput, s as DevEvent, t as ComposerOperations, u as DevStopInput, y as CliStructuredError } from "./family-xJ6y4fXc-CFBu6q4b.mjs";
1
+ import { _ as Result, a as DeployEvent, b as CliStructuredError, c as DevEvent, d as DevStopInput, f as DevStopped, g as ServiceEndpoint, h as OperationDeps, l as DevInput, m as DevUrlInput, o as DeployInput, p as DevUrl, s as DeploySuccess, t as ComposerOperations, u as DevSession, v as AssembledServices } from "./family-B2JZ8O7U-P_rOUr4w.mjs";
2
2
  //#region ../../0-framework/3-tooling/cli/dist/testing.d.mts
3
3
  //#region src/dev/generate-dev-stack.d.ts
4
4
  interface DevStackFileInput {
@@ -6,6 +6,8 @@ interface DevStackFileInput {
6
6
  readonly entryPath: string;
7
7
  /** The process's cwd — where `.prisma-composer/dev/` is written. */
8
8
  readonly cwd: string;
9
+ /** The environment the app runs as locally; its folder holds the stack file. */
10
+ readonly environment: string;
9
11
  /** Absolute path to the `prisma.config.ts` that declared the `composer` section — imported by relative path. */
10
12
  readonly configFile: string;
11
13
  readonly name: string;
@@ -1 +1 @@
1
- {"version":3,"file":"testing.d.mts","names":[],"sources":["../../../0-framework/3-tooling/cli/dist/testing.d.mts"],"mappings":";;;UAMU;;WAEC;;WAEA;;WAEA;WACA;WACA,WAAW;;;iBAGL,mBAAmB,OAAO;;;UAGjC;;WAEC,SAAS,OAAO,eAAe;;WAE/B,wBAAwB;;;;;WAKxB,MAAM,OAAO,YAAY;;WAEzB,wBAAwB;;WAExB,qBAAqB;;WAErB,SAAS,OAAO,QAAQ;;WAExB,UAAU,OAAO,YAAY;;;;;;;;UAQ9B;WACC,iBAAiB;WACjB,cAAc;;;UAGf;WACC,iBAAiB;WACjB,cAAc;WACd,iBAAiB;WACjB,kBAAkB;WAClB,MAAM;;UAEP;;WAEC,YAAY;WACZ,OAAO;;iBAED,uBAAuB,WAAW,2BAA2B"}
1
+ {"version":3,"file":"testing.d.mts","names":[],"sources":["../../../0-framework/3-tooling/cli/dist/testing.d.mts"],"mappings":";;;UAMU;;WAEC;;WAEA;;WAEA;;WAEA;WACA;WACA,WAAW;;;iBAGL,mBAAmB,OAAO;;;UAGjC;;WAEC,SAAS,OAAO,eAAe;;WAE/B,wBAAwB;;;;;WAKxB,MAAM,OAAO,YAAY;;WAEzB,wBAAwB;;WAExB,qBAAqB;;WAErB,SAAS,OAAO,QAAQ;;WAExB,UAAU,OAAO,YAAY;;;;;;;;UAQ9B;WACC,iBAAiB;WACjB,cAAc;;;UAGf;WACC,iBAAiB;WACjB,cAAc;WACd,iBAAiB;WACjB,kBAAkB;WAClB,MAAM;;UAEP;;WAEC,YAAY;WACZ,OAAO;;iBAED,uBAAuB,WAAW,2BAA2B"}
package/dist/testing.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { a as notOk, c as CliStructuredError, o as ok, r as reproduceCommand } from "./run-alchemy-Dl_MWw4g-DaWV9tkH.mjs";
2
- import { n as renderDevStackFile } from "./generate-dev-stack-CfneNj97-Yx3Z2-9u.mjs";
2
+ import { n as renderDevStackFile } from "./generate-dev-stack-BkkU2HLE-Dek3CkAQ.mjs";
3
3
  //#region ../../0-framework/3-tooling/cli/dist/testing.mjs
4
4
  /**
5
5
  * The published operations double (`@prisma/composer-cli/testing`): the
@@ -139,6 +139,7 @@ function createOperationsDouble(fixtures = {}) {
139
139
  devStopCalls.push(input);
140
140
  return fixtures.devStop ?? ok({
141
141
  app: "app",
142
+ environment: input.environment ?? "dev",
142
143
  stopped: []
143
144
  });
144
145
  }
@@ -1 +1 @@
1
- {"version":3,"file":"testing.mjs","names":[],"sources":["../../../0-framework/3-tooling/cli/dist/testing.mjs"],"sourcesContent":["import { r as reproduceCommand } from \"./run-alchemy-Dl_MWw4g.mjs\";\nimport { n as renderDevStackFile } from \"./generate-dev-stack-CfneNj97.mjs\";\nimport { CliStructuredError } from \"@internal/foundation/errors\";\nimport { notOk, ok } from \"@internal/foundation/result\";\n//#region src/testing/operations-double.ts\n/**\n* The published operations double (`@prisma/composer-cli/testing`): the\n* operations the command family calls, `deploy`, `dev`, `devUrl` and\n* `devStop`, with their real\n* signatures and Result shapes, backed by fixtures instead of alchemy,\n* containers, or a network. It does not cover `destroy` and `log`, which no\n* command calls.\n*\n* Hosts that mount composer's command family — prisma-cli above all — test\n* against this instead of the real operations, so their suites never spawn a\n* converge and their typecheck never needs the alchemy/effect constellation.\n* The conformance guarantee is carried by the types: `ComposerOperations` is\n* defined as `typeof deployWithDeps` (etc.) of the REAL operations, and the\n* double is declared against it, so a drift in any real signature fails\n* `tsc --noEmit` right here. Every import of implementation modules is\n* type-only and erases at build — the built `testing` chunk must contain no path to the real\n* control implementation, which scripts/check-family-static-graph.mjs proves\n* against the packed tarball.\n*/\nfunction devSessionDouble(input, endpoints, events) {\n\tlet resolveClosed;\n\tconst closed = new Promise((resolve) => {\n\t\tresolveClosed = resolve;\n\t});\n\tlet stopped = false;\n\tinput.onEvent?.({\n\t\tkind: \"ready\",\n\t\tendpoints\n\t});\n\tfor (const event of events) input.onEvent?.(event);\n\treturn {\n\t\tendpoints,\n\t\tclosed,\n\t\tstop: async () => {\n\t\t\tif (stopped) return;\n\t\t\tstopped = true;\n\t\t\tinput.onEvent?.({ kind: \"stopping\" });\n\t\t\tinput.onEvent?.({ kind: \"stopped\" });\n\t\t\tresolveClosed();\n\t\t}\n\t};\n}\n/**\n* Runs the caller's converge adapter, when it supplied one, against a\n* synthetic invocation — no alchemy bin is resolved and no real child is\n* started; the adapter decides what the child does.\n*\n* This is what makes a host's tests cover the settlement rules rather than\n* just the grammar: a scripted fake child that exits non-zero, or is killed\n* by a signal, produces the same failure shape the real executor produces, so\n* the handler's settlement — and the engine's own child-status settlement\n* behind it — is genuinely exercised. Returns undefined when no adapter was\n* injected, leaving the fixture result untouched.\n*/\nasync function runConverge(deps, cwd) {\n\tif (deps.alchemy === void 0) return void 0;\n\tconst stackFilePath = \".prisma-composer/alchemy.run.ts\";\n\tconst workingDirectory = cwd ?? \".\";\n\tconst invocation = {\n\t\taction: \"deploy\",\n\t\tstackFileRelativePath: stackFilePath,\n\t\tcwd: workingDirectory,\n\t\tstage: \"test\",\n\t\tenv: {}\n\t};\n\tconst outcome = await deps.alchemy(invocation);\n\tconst reproduce = reproduceCommand(invocation, outcome);\n\tif (outcome.signal !== null) return notOk(new CliStructuredError(\"DEPLOY.ENGINE_FAILED\", `alchemy deploy was interrupted by ${outcome.signal}.`, { meta: {\n\t\tsignal: outcome.signal,\n\t\tdiagnostics: {\n\t\t\texitCode: void 0,\n\t\t\tsignal: outcome.signal,\n\t\t\tstackFilePath,\n\t\t\treproduceCommand: reproduce,\n\t\t\tcwd: workingDirectory\n\t\t}\n\t} }));\n\tconst status = outcome.exitCode ?? 1;\n\tif (status === 0) return void 0;\n\treturn notOk(new CliStructuredError(\"DEPLOY.ENGINE_FAILED\", `alchemy deploy exited with status ${status}.`, { meta: {\n\t\texitCode: status,\n\t\tdiagnostics: {\n\t\t\texitCode: status,\n\t\t\tstackFilePath,\n\t\t\treproduceCommand: reproduce,\n\t\t\tcwd: workingDirectory\n\t\t}\n\t} }));\n}\nfunction createOperationsDouble(fixtures = {}) {\n\tconst deployCalls = [];\n\tconst devCalls = [];\n\tconst deps = {\n\t\tdeploy: [],\n\t\tdev: []\n\t};\n\tconst devUrlCalls = [];\n\tconst devStopCalls = [];\n\tconst calls = {\n\t\tdeploy: deployCalls,\n\t\tdev: devCalls,\n\t\tdevUrl: devUrlCalls,\n\t\tdevStop: devStopCalls,\n\t\tdeps\n\t};\n\treturn {\n\t\toperations: {\n\t\t\tdeploy: async (input, operationDeps) => {\n\t\t\t\tcalls.deploy.push(input);\n\t\t\t\tdeps.deploy.push(operationDeps);\n\t\t\t\tfor (const event of fixtures.deployEvents ?? []) try {\n\t\t\t\t\tinput.onEvent?.(event);\n\t\t\t\t} catch {}\n\t\t\t\tconst converge = await runConverge(operationDeps, input.cwd);\n\t\t\t\tif (converge !== void 0) return converge;\n\t\t\t\treturn fixtures.deploy ?? ok({\n\t\t\t\t\tsummary: void 0,\n\t\t\t\t\tdurationMs: 0\n\t\t\t\t});\n\t\t\t},\n\t\t\tdev: async (input, operationDeps) => {\n\t\t\t\tcalls.dev.push(input);\n\t\t\t\tdeps.dev.push(operationDeps);\n\t\t\t\treturn fixtures.dev ?? ok(devSessionDouble(input, fixtures.devEndpoints ?? [], fixtures.devEvents ?? []));\n\t\t\t},\n\t\t\tdevUrl: async (input) => {\n\t\t\t\tdevUrlCalls.push(input);\n\t\t\t\treturn fixtures.devUrl ?? ok({\n\t\t\t\t\taddress: input.address,\n\t\t\t\t\tkind: \"service\",\n\t\t\t\t\turl: \"http://localhost:3000\",\n\t\t\t\t\tstate: \"running\"\n\t\t\t\t});\n\t\t\t},\n\t\t\tdevStop: async (input) => {\n\t\t\t\tdevStopCalls.push(input);\n\t\t\t\treturn fixtures.devStop ?? ok({\n\t\t\t\t\tapp: \"app\",\n\t\t\t\t\tstopped: []\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\tcalls\n\t};\n}\n//#endregion\nexport { createOperationsDouble, renderDevStackFile };\n\n//# sourceMappingURL=testing.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAwBA,SAAS,iBAAiB,OAAO,WAAW,QAAQ;CACnD,IAAI;CACJ,MAAM,SAAS,IAAI,SAAS,YAAY;EACvC,gBAAgB;CACjB,CAAC;CACD,IAAI,UAAU;CACd,MAAM,UAAU;EACf,MAAM;EACN;CACD,CAAC;CACD,KAAK,MAAM,SAAS,QAAQ,MAAM,UAAU,KAAK;CACjD,OAAO;EACN;EACA;EACA,MAAM,YAAY;GACjB,IAAI,SAAS;GACb,UAAU;GACV,MAAM,UAAU,EAAE,MAAM,WAAW,CAAC;GACpC,MAAM,UAAU,EAAE,MAAM,UAAU,CAAC;GACnC,cAAc;EACf;CACD;AACD;;;;;;;;;;;;;AAaA,eAAe,YAAY,MAAM,KAAK;CACrC,IAAI,KAAK,YAAY,KAAK,GAAG,OAAO,KAAK;CACzC,MAAM,gBAAgB;CACtB,MAAM,mBAAmB,OAAO;CAChC,MAAM,aAAa;EAClB,QAAQ;EACR,uBAAuB;EACvB,KAAK;EACL,OAAO;EACP,KAAK,CAAC;CACP;CACA,MAAM,U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AAI,KAAK,KAAK;IACpB,KAAK,IAAI,KAAK,aAAa;IAC3B,OAAO,SAAS,OAAO,GAAG,iBAAiB,OAAO,SAAS,gBAAgB,CAAC,GAAG,SAAS,aAAa,CAAC,CAAC,CAAC;GACzG;GACA,QAAQ,OAAO,UAAU;IACxB,YAAY,KAAK,KAAK;IACtB,OAAO,SAAS,UAAU,GAAG;KAC5B,SAAS,MAAM;KACf,MAAM;KACN,KAAK;KACL,OAAO;IACR,CAAC;GACF;GACA,SAAS,OAAO,UAAU;IACzB,aAAa,KAAK,KAAK;IACvB,OAAO,SAAS,WAAW,GAAG;KAC7B,KAAK;KACL,SAAS,CAAC;IACX,CAAC;GACF;EACD;EACA;CACD;AACD"}
1
+ {"version":3,"file":"testing.mjs","names":[],"sources":["../../../0-framework/3-tooling/cli/dist/testing.mjs"],"sourcesContent":["import { r as reproduceCommand } from \"./run-alchemy-Dl_MWw4g.mjs\";\nimport { n as renderDevStackFile } from \"./generate-dev-stack-BkkU2HLE.mjs\";\nimport { CliStructuredError } from \"@internal/foundation/errors\";\nimport { notOk, ok } from \"@internal/foundation/result\";\n//#region src/testing/operations-double.ts\n/**\n* The published operations double (`@prisma/composer-cli/testing`): the\n* operations the command family calls, `deploy`, `dev`, `devUrl` and\n* `devStop`, with their real\n* signatures and Result shapes, backed by fixtures instead of alchemy,\n* containers, or a network. It does not cover `destroy` and `log`, which no\n* command calls.\n*\n* Hosts that mount composer's command family — prisma-cli above all — test\n* against this instead of the real operations, so their suites never spawn a\n* converge and their typecheck never needs the alchemy/effect constellation.\n* The conformance guarantee is carried by the types: `ComposerOperations` is\n* defined as `typeof deployWithDeps` (etc.) of the REAL operations, and the\n* double is declared against it, so a drift in any real signature fails\n* `tsc --noEmit` right here. Every import of implementation modules is\n* type-only and erases at build — the built `testing` chunk must contain no path to the real\n* control implementation, which scripts/check-family-static-graph.mjs proves\n* against the packed tarball.\n*/\nfunction devSessionDouble(input, endpoints, events) {\n\tlet resolveClosed;\n\tconst closed = new Promise((resolve) => {\n\t\tresolveClosed = resolve;\n\t});\n\tlet stopped = false;\n\tinput.onEvent?.({\n\t\tkind: \"ready\",\n\t\tendpoints\n\t});\n\tfor (const event of events) input.onEvent?.(event);\n\treturn {\n\t\tendpoints,\n\t\tclosed,\n\t\tstop: async () => {\n\t\t\tif (stopped) return;\n\t\t\tstopped = true;\n\t\t\tinput.onEvent?.({ kind: \"stopping\" });\n\t\t\tinput.onEvent?.({ kind: \"stopped\" });\n\t\t\tresolveClosed();\n\t\t}\n\t};\n}\n/**\n* Runs the caller's converge adapter, when it supplied one, against a\n* synthetic invocation — no alchemy bin is resolved and no real child is\n* started; the adapter decides what the child does.\n*\n* This is what makes a host's tests cover the settlement rules rather than\n* just the grammar: a scripted fake child that exits non-zero, or is killed\n* by a signal, produces the same failure shape the real executor produces, so\n* the handler's settlement — and the engine's own child-status settlement\n* behind it — is genuinely exercised. Returns undefined when no adapter was\n* injected, leaving the fixture result untouched.\n*/\nasync function runConverge(deps, cwd) {\n\tif (deps.alchemy === void 0) return void 0;\n\tconst stackFilePath = \".prisma-composer/alchemy.run.ts\";\n\tconst workingDirectory = cwd ?? \".\";\n\tconst invocation = {\n\t\taction: \"deploy\",\n\t\tstackFileRelativePath: stackFilePath,\n\t\tcwd: workingDirectory,\n\t\tstage: \"test\",\n\t\tenv: {}\n\t};\n\tconst outcome = await deps.alchemy(invocation);\n\tconst reproduce = reproduceCommand(invocation, outcome);\n\tif (outcome.signal !== null) return notOk(new CliStructuredError(\"DEPLOY.ENGINE_FAILED\", `alchemy deploy was interrupted by ${outcome.signal}.`, { meta: {\n\t\tsignal: outcome.signal,\n\t\tdiagnostics: {\n\t\t\texitCode: void 0,\n\t\t\tsignal: outcome.signal,\n\t\t\tstackFilePath,\n\t\t\treproduceCommand: reproduce,\n\t\t\tcwd: workingDirectory\n\t\t}\n\t} }));\n\tconst status = outcome.exitCode ?? 1;\n\tif (status === 0) return void 0;\n\treturn notOk(new CliStructuredError(\"DEPLOY.ENGINE_FAILED\", `alchemy deploy exited with status ${status}.`, { meta: {\n\t\texitCode: status,\n\t\tdiagnostics: {\n\t\t\texitCode: status,\n\t\t\tstackFilePath,\n\t\t\treproduceCommand: reproduce,\n\t\t\tcwd: workingDirectory\n\t\t}\n\t} }));\n}\nfunction createOperationsDouble(fixtures = {}) {\n\tconst deployCalls = [];\n\tconst devCalls = [];\n\tconst deps = {\n\t\tdeploy: [],\n\t\tdev: []\n\t};\n\tconst devUrlCalls = [];\n\tconst devStopCalls = [];\n\tconst calls = {\n\t\tdeploy: deployCalls,\n\t\tdev: devCalls,\n\t\tdevUrl: devUrlCalls,\n\t\tdevStop: devStopCalls,\n\t\tdeps\n\t};\n\treturn {\n\t\toperations: {\n\t\t\tdeploy: async (input, operationDeps) => {\n\t\t\t\tcalls.deploy.push(input);\n\t\t\t\tdeps.deploy.push(operationDeps);\n\t\t\t\tfor (const event of fixtures.deployEvents ?? []) try {\n\t\t\t\t\tinput.onEvent?.(event);\n\t\t\t\t} catch {}\n\t\t\t\tconst converge = await runConverge(operationDeps, input.cwd);\n\t\t\t\tif (converge !== void 0) return converge;\n\t\t\t\treturn fixtures.deploy ?? ok({\n\t\t\t\t\tsummary: void 0,\n\t\t\t\t\tdurationMs: 0\n\t\t\t\t});\n\t\t\t},\n\t\t\tdev: async (input, operationDeps) => {\n\t\t\t\tcalls.dev.push(input);\n\t\t\t\tdeps.dev.push(operationDeps);\n\t\t\t\treturn fixtures.dev ?? ok(devSessionDouble(input, fixtures.devEndpoints ?? [], fixtures.devEvents ?? []));\n\t\t\t},\n\t\t\tdevUrl: async (input) => {\n\t\t\t\tdevUrlCalls.push(input);\n\t\t\t\treturn fixtures.devUrl ?? ok({\n\t\t\t\t\taddress: input.address,\n\t\t\t\t\tkind: \"service\",\n\t\t\t\t\turl: \"http://localhost:3000\",\n\t\t\t\t\tstate: \"running\"\n\t\t\t\t});\n\t\t\t},\n\t\t\tdevStop: async (input) => {\n\t\t\t\tdevStopCalls.push(input);\n\t\t\t\treturn fixtures.devStop ?? ok({\n\t\t\t\t\tapp: \"app\",\n\t\t\t\t\tenvironment: input.environment ?? \"dev\",\n\t\t\t\t\tstopped: []\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\tcalls\n\t};\n}\n//#endregion\nexport { createOperationsDouble, renderDevStackFile };\n\n//# sourceMappingURL=testing.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAwBA,SAAS,iBAAiB,OAAO,WAAW,QAAQ;CACnD,IAAI;CACJ,MAAM,SAAS,IAAI,SAAS,YAAY;EACvC,gBAAgB;CACjB,CAAC;CACD,IAAI,UAAU;CACd,MAAM,UAAU;EACf,MAAM;EACN;CACD,CAAC;CACD,KAAK,MAAM,SAAS,QAAQ,MAAM,UAAU,KAAK;CACjD,OAAO;EACN;EACA;EACA,MAAM,YAAY;GACjB,IAAI,SAAS;GACb,UAAU;GACV,MAAM,UAAU,EAAE,MAAM,WAAW,CAAC;GACpC,MAAM,UAAU,EAAE,MAAM,UAAU,CAAC;GACnC,cAAc;EACf;CACD;AACD;;;;;;;;;;;;;AAaA,eAAe,YAAY,MAAM,KAAK;CACrC,IAAI,KAAK,YAAY,KAAK,GAAG,OAAO,KAAK;CACzC,MAAM,gBAAgB;CACtB,MAAM,mBAAmB,OAAO;CAChC,MAAM,aAAa;EAClB,QAAQ;EACR,uBAAuB;EACvB,KAAK;EACL,OAAO;EACP,KAAK,CAAC;CACP;CACA,MAAM,UAAU,MAAM,KAAK,QAAQ,UAAU;CAC7C,MAAM,YAAY,iBAAiB,YAAY,OAAO;CACtD,IAAI,QAAQ,WAAW,MAAM,OAAO,MAAM,IAAI,mBAAmB,wBAAwB,qCAAqC,QAAQ,OAAO,IAAI,EAAE,MAAM;EACxJ,QAAQ,QAAQ;EAChB,aAAa;GACZ,UAAU,KAAK;GACf,QAAQ,QAAQ;GAChB;GACA,kBAAkB;GAClB,KAAK;EACN;CACD,EAAE,CAAC,CAAC;CACJ,MAAM,SAAS,QAAQ,YAA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