@prisma/composer 0.6.0-dev.14 → 0.6.0-dev.16

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 (110) hide show
  1. package/dist/{app-config-CFsSXEVj-B242oUnm.d.mts → app-config-aIrriqVU-D6lJHzh2.d.mts} +42 -17
  2. package/dist/app-config-aIrriqVU-D6lJHzh2.d.mts.map +1 -0
  3. package/dist/bin.mjs +1337 -12
  4. package/dist/bin.mjs.map +1 -1
  5. package/dist/config-CL7Jbve2.d.mts +1 -0
  6. package/dist/config.d.mts +3 -3
  7. package/dist/container-transport-DKmKg5JQ-CoY4XPma.mjs +30 -0
  8. package/dist/container-transport-DKmKg5JQ-CoY4XPma.mjs.map +1 -0
  9. package/dist/control.d.mts +3 -216
  10. package/dist/control.mjs +1 -69
  11. package/dist/deploy-CL7Jbve2.d.mts +1 -0
  12. package/dist/deploy.d.mts +2 -2
  13. package/dist/deploy.mjs +1 -1
  14. package/dist/{deployment-summary-r47O6kFr-CcMYVOn5.mjs → deployment-summary-DswOl_9E-C03NJ98H.mjs} +2 -2
  15. package/dist/{deployment-summary-r47O6kFr-CcMYVOn5.mjs.map → deployment-summary-DswOl_9E-C03NJ98H.mjs.map} +1 -1
  16. package/dist/{dist-C5rZnr4n.mjs → dist-C0dNEgS-.mjs} +2 -2
  17. package/dist/{dist-C5rZnr4n.mjs.map → dist-C0dNEgS-.mjs.map} +1 -1
  18. package/dist/{errors-0e8IVwzi.mjs → errors-DkXcnjPx.mjs} +3 -2
  19. package/dist/{errors-0e8IVwzi.mjs.map → errors-DkXcnjPx.mjs.map} +1 -1
  20. package/dist/{execute-deploy-destroy-IT4vGkMc-oO8yjHPH.mjs → execute-deploy-destroy-DfVJUICu-AMM8CwgV.mjs} +30 -19
  21. package/dist/execute-deploy-destroy-DfVJUICu-AMM8CwgV.mjs.map +1 -0
  22. package/dist/{execute-deploy-destroy-IT4vGkMc-YM1Cv6cu.mjs → execute-deploy-destroy-DfVJUICu-quUQ08T8.mjs} +29 -19
  23. package/dist/execute-deploy-destroy-DfVJUICu-quUQ08T8.mjs.map +1 -0
  24. package/dist/{execute-dev-DLYyduEM-88uyvrbj.mjs → execute-dev-BMTFWfFc-B1whS-Rr.mjs} +25 -23
  25. package/dist/{execute-dev-DLYyduEM-88uyvrbj.mjs.map → execute-dev-BMTFWfFc-B1whS-Rr.mjs.map} +1 -1
  26. package/dist/{execute-dev-DLYyduEM-BuUGTm0g.mjs → execute-dev-BMTFWfFc-BoKbcFVF.mjs} +29 -20
  27. package/dist/{execute-dev-DLYyduEM-BuUGTm0g.mjs.map → execute-dev-BMTFWfFc-BoKbcFVF.mjs.map} +1 -1
  28. package/dist/{execute-log-VIOL4DBz-DBPH8By4.mjs → execute-log-Cay9hlKW-B0tmRtrY.mjs} +11 -7
  29. package/dist/execute-log-Cay9hlKW-B0tmRtrY.mjs.map +1 -0
  30. package/dist/{execute-log-VIOL4DBz-DKodBrxS.mjs → execute-log-Cay9hlKW-DrMeVOXq.mjs} +9 -7
  31. package/dist/execute-log-Cay9hlKW-DrMeVOXq.mjs.map +1 -0
  32. package/dist/family-DkH0si4D-Uov_MuHV.d.mts +27 -0
  33. package/dist/family-DkH0si4D-Uov_MuHV.d.mts.map +1 -0
  34. package/dist/family.d.mts +53 -0
  35. package/dist/family.d.mts.map +1 -0
  36. package/dist/family.mjs +1226 -0
  37. package/dist/family.mjs.map +1 -0
  38. package/dist/{graph-BJgUfGB0-kvgFzT4q.mjs → graph-BJgUfGB0-7fmubS_y.mjs} +2 -2
  39. package/dist/{graph-BJgUfGB0-kvgFzT4q.mjs.map → graph-BJgUfGB0-7fmubS_y.mjs.map} +1 -1
  40. package/dist/{graph-types-N6brq1zY-1VMNwtkJ.d.mts → graph-DqklX5Sf-CdNH3lA7.d.mts} +17 -2
  41. package/dist/graph-DqklX5Sf-CdNH3lA7.d.mts.map +1 -0
  42. package/dist/{index-DryPyF9U.d.mts → index-DuF5iI3i.d.mts} +2 -3
  43. package/dist/index-DuF5iI3i.d.mts.map +1 -0
  44. package/dist/index.d.mts +2 -3
  45. package/dist/index.mjs +2 -2
  46. package/dist/{local-target-DnA2E8IN.mjs → local-target-D3u_wuNF.mjs} +2 -2
  47. package/dist/{local-target-DnA2E8IN.mjs.map → local-target-D3u_wuNF.mjs.map} +1 -1
  48. package/dist/{local-target-DuSyWeYc.mjs → local-target-H0IWu_FM.mjs} +2 -2
  49. package/dist/{local-target-DuSyWeYc.mjs.map → local-target-H0IWu_FM.mjs.map} +1 -1
  50. package/dist/local-target.d.mts +1 -1
  51. package/dist/local-target.mjs +1 -1
  52. package/dist/log-DRnnWupy-9jbzL64M.d.mts +324 -0
  53. package/dist/log-DRnnWupy-9jbzL64M.d.mts.map +1 -0
  54. package/dist/{result-CzGChwbZ.mjs → log-DfT2hHqi-CDp9nfI5.mjs} +85 -90
  55. package/dist/log-DfT2hHqi-CDp9nfI5.mjs.map +1 -0
  56. package/dist/{nextjs-DLyeRR7M-DZODs9tk.d.mts → nextjs-DLyeRR7M-BfUbLXwr.d.mts} +3 -3
  57. package/dist/{nextjs-DLyeRR7M-DZODs9tk.d.mts.map → nextjs-DLyeRR7M-BfUbLXwr.d.mts.map} +1 -1
  58. package/dist/nextjs-control.d.mts +4 -4
  59. package/dist/nextjs.d.mts +1 -1
  60. package/dist/node-control.d.mts +3 -3
  61. package/dist/node.d.mts +2 -2
  62. package/dist/{pipeline-D3QoVzAB-D_ufjg3N.mjs → pipeline-AoW8zq4I-C6Qe0VaZ.mjs} +161 -42
  63. package/dist/{pipeline-D3QoVzAB-D_ufjg3N.mjs.map → pipeline-AoW8zq4I-C6Qe0VaZ.mjs.map} +1 -1
  64. package/dist/{pipeline-D3QoVzAB-Ci2aJ2mE.mjs → pipeline-AoW8zq4I-DM74ygtH.mjs} +164 -43
  65. package/dist/pipeline-AoW8zq4I-DM74ygtH.mjs.map +1 -0
  66. package/dist/report.d.mts +2 -2
  67. package/dist/report.mjs +1 -1
  68. package/dist/report.mjs.map +1 -1
  69. package/dist/{shared-CCaR42wo-BvegvmA_.mjs → result-B4XjxVK6.mjs} +127 -8
  70. package/dist/result-B4XjxVK6.mjs.map +1 -0
  71. package/dist/{result-CFqJKiqg.mjs → result-wonf1deB.mjs} +4 -18
  72. package/dist/result-wonf1deB.mjs.map +1 -0
  73. package/dist/run-alchemy-D44OZlyB-DA7s331N.mjs +93 -0
  74. package/dist/run-alchemy-D44OZlyB-DA7s331N.mjs.map +1 -0
  75. package/dist/run-alchemy-D44OZlyB-DeDTFsB6.mjs +93 -0
  76. package/dist/run-alchemy-D44OZlyB-DeDTFsB6.mjs.map +1 -0
  77. package/dist/service-rpc.d.mts +2 -2
  78. package/dist/service-rpc.mjs +2 -2
  79. package/dist/testing.d.mts +54 -2
  80. package/dist/testing.d.mts.map +1 -1
  81. package/dist/testing.mjs +150 -1
  82. package/dist/testing.mjs.map +1 -1
  83. package/package.json +13 -12
  84. package/src/exports/family.ts +14 -0
  85. package/src/exports/testing.ts +1 -0
  86. package/dist/app-config-CFsSXEVj-B242oUnm.d.mts.map +0 -1
  87. package/dist/cli-B3sWzFlb-CxEIzKsQ.mjs +0 -401
  88. package/dist/cli-B3sWzFlb-CxEIzKsQ.mjs.map +0 -1
  89. package/dist/config-ku5b_2YD.d.mts +0 -1
  90. package/dist/container-transport-DKmKg5JQ-BMRhx5w-.mjs +0 -75
  91. package/dist/container-transport-DKmKg5JQ-BMRhx5w-.mjs.map +0 -1
  92. package/dist/control.d.mts.map +0 -1
  93. package/dist/control.mjs.map +0 -1
  94. package/dist/deploy-ku5b_2YD.d.mts +0 -1
  95. package/dist/execute-deploy-destroy-IT4vGkMc-YM1Cv6cu.mjs.map +0 -1
  96. package/dist/execute-deploy-destroy-IT4vGkMc-oO8yjHPH.mjs.map +0 -1
  97. package/dist/execute-log-VIOL4DBz-DBPH8By4.mjs.map +0 -1
  98. package/dist/execute-log-VIOL4DBz-DKodBrxS.mjs.map +0 -1
  99. package/dist/graph-DqklX5Sf-BNS2aO1j.d.mts +0 -18
  100. package/dist/graph-DqklX5Sf-BNS2aO1j.d.mts.map +0 -1
  101. package/dist/graph-types-N6brq1zY-1VMNwtkJ.d.mts.map +0 -1
  102. package/dist/index-DryPyF9U.d.mts.map +0 -1
  103. package/dist/pipeline-D3QoVzAB-Ci2aJ2mE.mjs.map +0 -1
  104. package/dist/render-error-DsPN5qfr-CkVGj9uP.mjs +0 -30
  105. package/dist/render-error-DsPN5qfr-CkVGj9uP.mjs.map +0 -1
  106. package/dist/result-CFqJKiqg.mjs.map +0 -1
  107. package/dist/result-CzGChwbZ.mjs.map +0 -1
  108. package/dist/run-alchemy-hghRtddF-CQHOzlrW.mjs +0 -48
  109. package/dist/run-alchemy-hghRtddF-CQHOzlrW.mjs.map +0 -1
  110. package/dist/shared-CCaR42wo-BvegvmA_.mjs.map +0 -1
@@ -0,0 +1,1226 @@
1
+ import { n as DOCS_BASE } from "./errors-DkXcnjPx.mjs";
2
+ import { c as logWithDeps, i as destroyWithDeps, n as deployWithDeps, o as devWithDeps, u as executionDiagnostics } from "./log-DfT2hHqi-CDp9nfI5.mjs";
3
+ import { t as alchemyCommandLine } from "./run-alchemy-D44OZlyB-DeDTFsB6.mjs";
4
+ import "node:module";
5
+ import { spawn } from "node:child_process";
6
+ import { EnvironmentCredentialManager, createCli, defineCommand, defineCommandFamily, defineConfigSection, defineSessionCommand, exitWithChildStatus, flag, loadConfig, positional } from "@prisma/cli-engine";
7
+ import { CliStructuredError, notOk, ok } from "@prisma/cli-engine/protocol";
8
+ //#region \0rolldown/runtime.js
9
+ var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
10
+ //#endregion
11
+ //#region ../../../node_modules/ci-info/vendors.json
12
+ var require_vendors = /* @__PURE__ */ __commonJSMin(((exports, module) => {
13
+ module.exports = [
14
+ {
15
+ "name": "Agola CI",
16
+ "constant": "AGOLA",
17
+ "env": "AGOLA_GIT_REF",
18
+ "pr": "AGOLA_PULL_REQUEST_ID"
19
+ },
20
+ {
21
+ "name": "Alpic",
22
+ "constant": "ALPIC",
23
+ "env": "ALPIC_HOST"
24
+ },
25
+ {
26
+ "name": "Appcircle",
27
+ "constant": "APPCIRCLE",
28
+ "env": "AC_APPCIRCLE",
29
+ "pr": {
30
+ "env": "AC_GIT_PR",
31
+ "ne": "false"
32
+ }
33
+ },
34
+ {
35
+ "name": "AppVeyor",
36
+ "constant": "APPVEYOR",
37
+ "env": "APPVEYOR",
38
+ "pr": "APPVEYOR_PULL_REQUEST_NUMBER"
39
+ },
40
+ {
41
+ "name": "AWS CodeBuild",
42
+ "constant": "CODEBUILD",
43
+ "env": "CODEBUILD_BUILD_ARN",
44
+ "pr": {
45
+ "env": "CODEBUILD_WEBHOOK_EVENT",
46
+ "any": [
47
+ "PULL_REQUEST_CREATED",
48
+ "PULL_REQUEST_UPDATED",
49
+ "PULL_REQUEST_REOPENED"
50
+ ]
51
+ }
52
+ },
53
+ {
54
+ "name": "Azure Pipelines",
55
+ "constant": "AZURE_PIPELINES",
56
+ "env": "TF_BUILD",
57
+ "pr": { "BUILD_REASON": "PullRequest" }
58
+ },
59
+ {
60
+ "name": "Bamboo",
61
+ "constant": "BAMBOO",
62
+ "env": "bamboo_planKey"
63
+ },
64
+ {
65
+ "name": "Bitbucket Pipelines",
66
+ "constant": "BITBUCKET",
67
+ "env": "BITBUCKET_COMMIT",
68
+ "pr": "BITBUCKET_PR_ID"
69
+ },
70
+ {
71
+ "name": "Bitrise",
72
+ "constant": "BITRISE",
73
+ "env": "BITRISE_IO",
74
+ "pr": "BITRISE_PULL_REQUEST"
75
+ },
76
+ {
77
+ "name": "Buddy",
78
+ "constant": "BUDDY",
79
+ "env": "BUDDY_WORKSPACE_ID",
80
+ "pr": "BUDDY_EXECUTION_PULL_REQUEST_ID"
81
+ },
82
+ {
83
+ "name": "Buildkite",
84
+ "constant": "BUILDKITE",
85
+ "env": "BUILDKITE",
86
+ "pr": {
87
+ "env": "BUILDKITE_PULL_REQUEST",
88
+ "ne": "false"
89
+ }
90
+ },
91
+ {
92
+ "name": "CircleCI",
93
+ "constant": "CIRCLE",
94
+ "env": "CIRCLECI",
95
+ "pr": "CIRCLE_PULL_REQUEST"
96
+ },
97
+ {
98
+ "name": "Cirrus CI",
99
+ "constant": "CIRRUS",
100
+ "env": "CIRRUS_CI",
101
+ "pr": "CIRRUS_PR"
102
+ },
103
+ {
104
+ "name": "Cloudflare Pages",
105
+ "constant": "CLOUDFLARE_PAGES",
106
+ "env": "CF_PAGES"
107
+ },
108
+ {
109
+ "name": "Cloudflare Workers",
110
+ "constant": "CLOUDFLARE_WORKERS",
111
+ "env": "WORKERS_CI"
112
+ },
113
+ {
114
+ "name": "Codefresh",
115
+ "constant": "CODEFRESH",
116
+ "env": "CF_BUILD_ID",
117
+ "pr": { "any": ["CF_PULL_REQUEST_NUMBER", "CF_PULL_REQUEST_ID"] }
118
+ },
119
+ {
120
+ "name": "Codemagic",
121
+ "constant": "CODEMAGIC",
122
+ "env": "CM_BUILD_ID",
123
+ "pr": "CM_PULL_REQUEST"
124
+ },
125
+ {
126
+ "name": "Codeship",
127
+ "constant": "CODESHIP",
128
+ "env": { "CI_NAME": "codeship" }
129
+ },
130
+ {
131
+ "name": "Drone",
132
+ "constant": "DRONE",
133
+ "env": "DRONE",
134
+ "pr": { "DRONE_BUILD_EVENT": "pull_request" }
135
+ },
136
+ {
137
+ "name": "dsari",
138
+ "constant": "DSARI",
139
+ "env": "DSARI"
140
+ },
141
+ {
142
+ "name": "Earthly",
143
+ "constant": "EARTHLY",
144
+ "env": "EARTHLY_CI"
145
+ },
146
+ {
147
+ "name": "Expo Application Services",
148
+ "constant": "EAS",
149
+ "env": "EAS_BUILD"
150
+ },
151
+ {
152
+ "name": "Gerrit",
153
+ "constant": "GERRIT",
154
+ "env": "GERRIT_PROJECT"
155
+ },
156
+ {
157
+ "name": "Gitea Actions",
158
+ "constant": "GITEA_ACTIONS",
159
+ "env": "GITEA_ACTIONS"
160
+ },
161
+ {
162
+ "name": "GitHub Actions",
163
+ "constant": "GITHUB_ACTIONS",
164
+ "env": "GITHUB_ACTIONS",
165
+ "pr": { "GITHUB_EVENT_NAME": "pull_request" }
166
+ },
167
+ {
168
+ "name": "GitLab CI",
169
+ "constant": "GITLAB",
170
+ "env": "GITLAB_CI",
171
+ "pr": "CI_MERGE_REQUEST_ID"
172
+ },
173
+ {
174
+ "name": "GoCD",
175
+ "constant": "GOCD",
176
+ "env": "GO_PIPELINE_LABEL"
177
+ },
178
+ {
179
+ "name": "Google Cloud Build",
180
+ "constant": "GOOGLE_CLOUD_BUILD",
181
+ "env": "BUILDER_OUTPUT"
182
+ },
183
+ {
184
+ "name": "Harness CI",
185
+ "constant": "HARNESS",
186
+ "env": "HARNESS_BUILD_ID"
187
+ },
188
+ {
189
+ "name": "Heroku",
190
+ "constant": "HEROKU",
191
+ "env": {
192
+ "env": "NODE",
193
+ "includes": "/app/.heroku/node/bin/node"
194
+ }
195
+ },
196
+ {
197
+ "name": "Hudson",
198
+ "constant": "HUDSON",
199
+ "env": "HUDSON_URL"
200
+ },
201
+ {
202
+ "name": "Jenkins",
203
+ "constant": "JENKINS",
204
+ "env": ["JENKINS_URL", "BUILD_ID"],
205
+ "pr": { "any": ["ghprbPullId", "CHANGE_ID"] }
206
+ },
207
+ {
208
+ "name": "LayerCI",
209
+ "constant": "LAYERCI",
210
+ "env": "LAYERCI",
211
+ "pr": "LAYERCI_PULL_REQUEST"
212
+ },
213
+ {
214
+ "name": "Magnum CI",
215
+ "constant": "MAGNUM",
216
+ "env": "MAGNUM"
217
+ },
218
+ {
219
+ "name": "Netlify CI",
220
+ "constant": "NETLIFY",
221
+ "env": "NETLIFY",
222
+ "pr": {
223
+ "env": "PULL_REQUEST",
224
+ "ne": "false"
225
+ }
226
+ },
227
+ {
228
+ "name": "Nevercode",
229
+ "constant": "NEVERCODE",
230
+ "env": "NEVERCODE",
231
+ "pr": {
232
+ "env": "NEVERCODE_PULL_REQUEST",
233
+ "ne": "false"
234
+ }
235
+ },
236
+ {
237
+ "name": "Prow",
238
+ "constant": "PROW",
239
+ "env": "PROW_JOB_ID"
240
+ },
241
+ {
242
+ "name": "ReleaseHub",
243
+ "constant": "RELEASEHUB",
244
+ "env": "RELEASE_BUILD_ID"
245
+ },
246
+ {
247
+ "name": "Render",
248
+ "constant": "RENDER",
249
+ "env": "RENDER",
250
+ "pr": { "IS_PULL_REQUEST": "true" }
251
+ },
252
+ {
253
+ "name": "Sail CI",
254
+ "constant": "SAIL",
255
+ "env": "SAILCI",
256
+ "pr": "SAIL_PULL_REQUEST_NUMBER"
257
+ },
258
+ {
259
+ "name": "Screwdriver",
260
+ "constant": "SCREWDRIVER",
261
+ "env": "SCREWDRIVER",
262
+ "pr": {
263
+ "env": "SD_PULL_REQUEST",
264
+ "ne": "false"
265
+ }
266
+ },
267
+ {
268
+ "name": "Semaphore",
269
+ "constant": "SEMAPHORE",
270
+ "env": "SEMAPHORE",
271
+ "pr": "PULL_REQUEST_NUMBER"
272
+ },
273
+ {
274
+ "name": "Sourcehut",
275
+ "constant": "SOURCEHUT",
276
+ "env": { "CI_NAME": "sourcehut" }
277
+ },
278
+ {
279
+ "name": "Strider CD",
280
+ "constant": "STRIDER",
281
+ "env": "STRIDER"
282
+ },
283
+ {
284
+ "name": "TaskCluster",
285
+ "constant": "TASKCLUSTER",
286
+ "env": ["TASK_ID", "RUN_ID"]
287
+ },
288
+ {
289
+ "name": "TeamCity",
290
+ "constant": "TEAMCITY",
291
+ "env": "TEAMCITY_VERSION"
292
+ },
293
+ {
294
+ "name": "Travis CI",
295
+ "constant": "TRAVIS",
296
+ "env": "TRAVIS",
297
+ "pr": {
298
+ "env": "TRAVIS_PULL_REQUEST",
299
+ "ne": "false"
300
+ }
301
+ },
302
+ {
303
+ "name": "Vela",
304
+ "constant": "VELA",
305
+ "env": "VELA",
306
+ "pr": { "VELA_PULL_REQUEST": "1" }
307
+ },
308
+ {
309
+ "name": "Vercel",
310
+ "constant": "VERCEL",
311
+ "env": { "any": ["NOW_BUILDER", "VERCEL"] },
312
+ "pr": "VERCEL_GIT_PULL_REQUEST_ID"
313
+ },
314
+ {
315
+ "name": "Visual Studio App Center",
316
+ "constant": "APPCENTER",
317
+ "env": "APPCENTER_BUILD_ID"
318
+ },
319
+ {
320
+ "name": "Woodpecker",
321
+ "constant": "WOODPECKER",
322
+ "env": { "CI": "woodpecker" },
323
+ "pr": { "CI_BUILD_EVENT": "pull_request" }
324
+ },
325
+ {
326
+ "name": "Xcode Cloud",
327
+ "constant": "XCODE_CLOUD",
328
+ "env": "CI_XCODE_PROJECT",
329
+ "pr": "CI_PULL_REQUEST_NUMBER"
330
+ },
331
+ {
332
+ "name": "Xcode Server",
333
+ "constant": "XCODE_SERVER",
334
+ "env": "XCS"
335
+ }
336
+ ];
337
+ }));
338
+ //#endregion
339
+ //#region ../../0-framework/3-tooling/cli/dist/engine-cli-BXXH4fM-.mjs
340
+ var import_ci_info = (/* @__PURE__ */ __commonJSMin(((exports) => {
341
+ const vendors = require_vendors();
342
+ const env = process.env;
343
+ Object.defineProperty(exports, "_vendors", { value: vendors.map(function(v) {
344
+ return v.constant;
345
+ }) });
346
+ exports.name = null;
347
+ exports.isPR = null;
348
+ exports.id = null;
349
+ if (env.CI !== "false") vendors.forEach(function(vendor) {
350
+ const isCI = (Array.isArray(vendor.env) ? vendor.env : [vendor.env]).every(function(obj) {
351
+ return checkEnv(obj);
352
+ });
353
+ exports[vendor.constant] = isCI;
354
+ if (!isCI) return;
355
+ exports.name = vendor.name;
356
+ exports.isPR = checkPR(vendor);
357
+ exports.id = vendor.constant;
358
+ });
359
+ exports.isCI = !!(env.CI !== "false" && (env.BUILD_ID || env.BUILD_NUMBER || env.CI || env.CI_APP_ID || env.CI_BUILD_ID || env.CI_BUILD_NUMBER || env.CI_NAME || env.CONTINUOUS_INTEGRATION || env.RUN_ID || exports.name || false));
360
+ function checkEnv(obj) {
361
+ if (typeof obj === "string") return !!env[obj];
362
+ if ("env" in obj) return env[obj.env] && env[obj.env].includes(obj.includes);
363
+ if ("any" in obj) return obj.any.some(function(k) {
364
+ return !!env[k];
365
+ });
366
+ return Object.keys(obj).every(function(k) {
367
+ return env[k] === obj[k];
368
+ });
369
+ }
370
+ function checkPR(vendor) {
371
+ switch (typeof vendor.pr) {
372
+ case "string": return !!env[vendor.pr];
373
+ case "object": if ("env" in vendor.pr) if ("any" in vendor.pr) return vendor.pr.any.some(function(key) {
374
+ return env[vendor.pr.env] === key;
375
+ });
376
+ else return vendor.pr.env in env && env[vendor.pr.env] !== vendor.pr.ne;
377
+ else if ("any" in vendor.pr) return vendor.pr.any.some(function(key) {
378
+ return !!env[key];
379
+ });
380
+ else return checkEnv(vendor.pr);
381
+ default: return null;
382
+ }
383
+ }
384
+ })))();
385
+ /**
386
+ * The family boundary's error translation.
387
+ *
388
+ * Composer and the engine each carry a class called `CliStructuredError`, both
389
+ * descended from the same prisma/prisma foundation, and both recognize errors
390
+ * by duck-typing on `name === 'CliStructuredError'`. That means a composer
391
+ * error handed to the engine untranslated is ACCEPTED — it does not fail
392
+ * loudly, it renders. What it loses is its `fix`: composer's foundation
393
+ * carries remediation as one prose string on that field, the engine carries it
394
+ * as a `nextActions` list and has no `fix` at all, so the fix text is dropped
395
+ * silently and the user is told what broke with no word on what to do about
396
+ * it. Nothing about that failure is visible without a test that looks for the
397
+ * fix on the other side, which is why there is one.
398
+ *
399
+ * Everything else on the envelope survives as-is; only remediation changes
400
+ * representation.
401
+ */
402
+ /**
403
+ * Composer's `fix` is free prose — "add this overrides block and reinstall",
404
+ * "run the build, then retry" — with no machine-readable command inside it.
405
+ * `user-choice` is the engine's own kind for exactly that (it is what the
406
+ * engine uses for its own config and prompt failures), so the text carries
407
+ * over verbatim as one action rather than being parsed into a command the
408
+ * author never wrote.
409
+ */
410
+ function fixAsNextActions(fix) {
411
+ return fix === void 0 ? [] : [{
412
+ kind: "user-choice",
413
+ label: fix
414
+ }];
415
+ }
416
+ /** Translates a composer failure into the engine's error type. Composer-side detail — `meta`, `where`, `docsUrl` — rides along untouched. */
417
+ function toEngineError(error) {
418
+ return new CliStructuredError(error.code, error.message, {
419
+ severity: error.severity,
420
+ nextActions: fixAsNextActions(error.fix),
421
+ ...error.why === void 0 ? {} : { why: error.why },
422
+ ...error.where === void 0 ? {} : { where: error.where },
423
+ ...error.meta === void 0 ? {} : { meta: error.meta },
424
+ ...error.docsUrl === void 0 ? {} : { docsUrl: error.docsUrl },
425
+ cause: error
426
+ });
427
+ }
428
+ /** The adapter the operations call, backed by the engine's `ctx.spawn` so the
429
+ * terminal reaches alchemy natively and the engine owns signal policy. */
430
+ function convergeSpawn(ctx) {
431
+ return async (invocation) => {
432
+ const line = alchemyCommandLine(invocation);
433
+ return await ctx.spawn({
434
+ command: line.command,
435
+ args: line.args,
436
+ cwd: line.cwd,
437
+ env: line.env
438
+ });
439
+ };
440
+ }
441
+ /** The in-process leg's deps: composer's existing seam, carrying the engine's
442
+ * own client and workspace id rather than anything read from the env. */
443
+ function operationDeps(spec) {
444
+ return {
445
+ alchemy: spec.alchemy,
446
+ configPath: spec.configPath,
447
+ credentials: {
448
+ workspaceId: spec.workspaceId,
449
+ client: spec.client
450
+ }
451
+ };
452
+ }
453
+ /**
454
+ * The reproduce hint a failed converge carries. Deliberately absent for an
455
+ * aborted one: the user stopped it, so there is nothing to reproduce.
456
+ */
457
+ function reproduceHint(failure) {
458
+ const diagnostics = executionDiagnostics(failure);
459
+ if (diagnostics === void 0) return [];
460
+ return [{
461
+ kind: "run-command",
462
+ label: `Run the converge directly from ${diagnostics.cwd} to reproduce this`,
463
+ command: diagnostics.reproduceCommand,
464
+ reason: `Generated stack file: ${diagnostics.stackFilePath}`
465
+ }];
466
+ }
467
+ /**
468
+ * How a FAILED converge settles. `deploy`, `destroy` and `dev` all end this
469
+ * way and must not drift apart, so the decision lives here once rather than
470
+ * inline in each handler.
471
+ *
472
+ * A failure that reached the child exits with the child's status verbatim and
473
+ * carries the reproduce hint; a failure that never reached the child is an
474
+ * ordinary structured error and gets the normal envelope. Nothing here reads
475
+ * `signal` — see settleConverge.
476
+ */
477
+ function settleConvergeFailure(failure, ctx) {
478
+ const child = ctx.lastChild();
479
+ if (child !== void 0 && child.exitCode !== 0) return ok(exitWithChildStatus({ nextActions: reproduceHint(failure) }));
480
+ return notOk(toEngineError(failure));
481
+ }
482
+ /**
483
+ * How a converge settles, now that the engine owns the child's status.
484
+ *
485
+ * Nothing here reads `signal`. `exitWithChildStatus` settles from the engine's
486
+ * own record of the child, and a signal-killed one overrules whatever this
487
+ * function asked for: 128 + the signal, no failure envelope, and the reproduce
488
+ * hint dropped, because the user stopped the run and there is nothing to
489
+ * reproduce.
490
+ *
491
+ * What is left is the operation's own verdict. A failure that reached the
492
+ * child exits with the child's status verbatim and carries the reproduce hint;
493
+ * a failure that never reached the child is an ordinary structured error and
494
+ * gets the normal envelope.
495
+ *
496
+ * A SUCCESS presents its result even when the child was signal-killed. No
497
+ * composer operation produces that pair today — each one reports a
498
+ * signal-killed converge as a failure — and an operation that ever did would
499
+ * have a real result worth showing. The run still exits 130, because the
500
+ * engine settles a signal-terminated run from its own record of the signal
501
+ * whatever the handler returns.
502
+ */
503
+ function settleConverge(result, ctx, present) {
504
+ if (!result.ok) return settleConvergeFailure(result.failure, ctx);
505
+ return ok(present(result.value));
506
+ }
507
+ /**
508
+ * Composer's projection into `prisma.config.ts` — the `composer` section.
509
+ *
510
+ * The section is deliberately tiny. Composer's real configuration lives in
511
+ * `prisma-composer.config.ts`, which holds executable values (Effect layers,
512
+ * provider factories, container lifecycles) and can only be understood by
513
+ * evaluating it inside a running command. A config-section validator loads
514
+ * with the command tree at start-up and must be dependency-light and total,
515
+ * so it is the wrong place to evaluate any of that. What the section carries
516
+ * is therefore only the one fact the engine can usefully know before a
517
+ * command runs: WHERE that file is, when the user wants to say so.
518
+ *
519
+ * Its fields grow only by amending the slice contract.
520
+ */
521
+ const KNOWN_FIELDS = ["configPath"];
522
+ function diagnostic(spec) {
523
+ return {
524
+ code: spec.code,
525
+ severity: spec.severity,
526
+ summary: spec.summary,
527
+ ...spec.why === void 0 ? {} : { why: spec.why },
528
+ nextActions: spec.fix === void 0 ? [] : [{
529
+ kind: "edit-file",
530
+ label: spec.fix
531
+ }]
532
+ };
533
+ }
534
+ function validate(raw) {
535
+ if (raw === void 0) return {
536
+ ok: true,
537
+ value: {},
538
+ diagnostics: []
539
+ };
540
+ if (typeof raw !== "object" || raw === null || Array.isArray(raw)) return {
541
+ ok: false,
542
+ diagnostics: [diagnostic({
543
+ code: "CONFIG.FIELD_INVALID",
544
+ severity: "error",
545
+ summary: "The `composer` section of prisma.config.ts must be an object.",
546
+ fix: "Write `composer: { configPath: \"./prisma-composer.config.ts\" }`, or remove the section entirely."
547
+ })]
548
+ };
549
+ let record;
550
+ try {
551
+ record = { ...raw };
552
+ } catch {
553
+ return {
554
+ ok: false,
555
+ diagnostics: [diagnostic({
556
+ code: "CONFIG.FIELD_INVALID",
557
+ severity: "error",
558
+ summary: "The `composer` section of prisma.config.ts could not be read.",
559
+ why: "Reading its fields threw, so nothing in it can be trusted.",
560
+ fix: "Write it as a plain object literal, e.g. `composer: { configPath: \"./prisma-composer.config.ts\" }`."
561
+ })]
562
+ };
563
+ }
564
+ const configPath = record["configPath"];
565
+ if (configPath !== void 0 && (typeof configPath !== "string" || configPath.length === 0)) return {
566
+ ok: false,
567
+ diagnostics: [diagnostic({
568
+ code: "CONFIG.FIELD_INVALID",
569
+ severity: "error",
570
+ summary: "`composer.configPath` must be a non-empty string.",
571
+ why: "It names the prisma-composer.config.ts file to load.",
572
+ fix: "Set it to a path, or remove it to search upward from the entry."
573
+ })]
574
+ };
575
+ const unknown = Object.keys(record).filter((key) => !KNOWN_FIELDS.includes(key));
576
+ return {
577
+ ok: true,
578
+ value: configPath === void 0 ? {} : { configPath },
579
+ diagnostics: unknown.map((key) => diagnostic({
580
+ code: "CONFIG.FIELD_UNKNOWN",
581
+ severity: "warn",
582
+ summary: `The \`composer\` section has no field \`${key}\`; it is ignored.`,
583
+ fix: `Remove \`${key}\`, or check it against the version of @prisma/composer you have installed.`
584
+ }))
585
+ };
586
+ }
587
+ const composerSection = defineConfigSection({
588
+ name: "composer",
589
+ validate
590
+ });
591
+ /**
592
+ * The workspace the in-process leg acts in, from the engine's credential
593
+ * read. Handlers never decode a token and never read PRISMA_WORKSPACE_ID:
594
+ * whether the credential came from a stored session or the environment, the
595
+ * engine has already resolved it, and branching on where it came from is a
596
+ * defect by the credential-manager design.
597
+ *
598
+ * Undefined when the active credential names no workspace — an environment
599
+ * token whose claims carry none. The container descriptors raise their own
600
+ * "workspace required" error in that case, which is the error the user needs.
601
+ */
602
+ async function workspaceIdOf(ctx) {
603
+ return (await ctx.activeCredential())?.workspaceId;
604
+ }
605
+ /**
606
+ * `deploy <entry>` — a result command that hands the terminal to alchemy.
607
+ *
608
+ * `--production` is gone. It was accepted and then always errored ("only
609
+ * valid with destroy"), so no invocation using it could ever have succeeded;
610
+ * deploy targets production by default when no `--stage` is given.
611
+ */
612
+ const createDeployCommand = (operations) => defineCommand({
613
+ help: {
614
+ summary: "Deploy the application whose root node is <entry>'s default export.",
615
+ examples: ["{bin} deploy src/service.ts", "{bin} deploy src/service.ts --stage feat-auth"]
616
+ },
617
+ args: {
618
+ positionals: { entry: positional.string({
619
+ brief: "The module whose default export is the application root.",
620
+ placeholder: "entry"
621
+ }) },
622
+ flags: {
623
+ name: flag.string({
624
+ brief: "Override the root node's name — the deploy's application name.",
625
+ placeholder: "name"
626
+ }),
627
+ stage: flag.string({
628
+ brief: "Deploy scope to target; omit for production.",
629
+ placeholder: "stage"
630
+ })
631
+ }
632
+ },
633
+ needs: {
634
+ config: composerSection,
635
+ credentials: "child"
636
+ },
637
+ maySpawn: true,
638
+ handler: async (args, ctx) => {
639
+ const alchemy = convergeSpawn(ctx);
640
+ return settleConverge(await operations.deploy({
641
+ entry: args.positionals.entry,
642
+ name: args.flags.name,
643
+ stage: args.flags.stage,
644
+ cwd: ctx.cwd
645
+ }, operationDeps({
646
+ alchemy,
647
+ configPath: ctx.config.configPath,
648
+ workspaceId: await workspaceIdOf(ctx),
649
+ client: ctx.api
650
+ })), ctx, ({ summary }) => ctx.present({ data: { summary: summary ?? null } }, {
651
+ human: (ui) => summary === void 0 ? [{
652
+ kind: "summary",
653
+ status: "ok",
654
+ text: "Deployed."
655
+ }] : [{
656
+ kind: "summary",
657
+ status: "ok",
658
+ text: `Deployed ${ui.emphasize(summary.app)}.`
659
+ }, {
660
+ kind: "table",
661
+ columns: ["Address", "Deployed"],
662
+ rows: summary.nodes.map((node) => [node.address, node.entities.map((entity) => `${entity.kind} ${entity.id}`).join(", ")])
663
+ }],
664
+ json: () => ({ summary: summary ?? null })
665
+ }));
666
+ }
667
+ });
668
+ /**
669
+ * `destroy`'s target, from its two mutually exclusive flags. Kept out of the
670
+ * grammar because the engine's flag layer has no "exactly one of these"
671
+ * construct — and because both wrong shapes need their own remedy, which a
672
+ * generic arity error could not give.
673
+ */
674
+ function targetOf(stage, production) {
675
+ if (stage !== void 0 && production) return notOk(new CliStructuredError("DEPLOY.TARGET_CONFLICT", "Pass either --stage <name> or --production to `destroy`, not both."));
676
+ if (stage === void 0 && !production) return notOk(new CliStructuredError("DEPLOY.TARGET_MISSING", "`destroy` requires an explicit target.", { nextActions: [{
677
+ kind: "user-choice",
678
+ label: "Pass --stage <name> to tear down a branch environment, or --production to tear down the production environment."
679
+ }] }));
680
+ return ok(stage !== void 0 ? {
681
+ kind: "stage",
682
+ stage
683
+ } : { kind: "production" });
684
+ }
685
+ /**
686
+ * `destroy <entry>` — deploy's mirror: same derivation, alchemy destroy.
687
+ *
688
+ * No confirmation prompt, matching the CLI this replaces. The front door
689
+ * cannot know what the child will tear down, so a consent step here would be
690
+ * asking the user to approve a list nobody has computed yet; if destroy
691
+ * deserves one it belongs in composer's own operation, not in the grammar.
692
+ */
693
+ const createDestroyCommand = (operations) => defineCommand({
694
+ help: {
695
+ summary: "Tear down the application whose root node is <entry>'s default export.",
696
+ description: "Same derivation as deploy. Requires an explicit target: --stage <name> for a branch environment, or --production for the production environment.",
697
+ examples: ["{bin} destroy src/service.ts --stage feat-auth", "{bin} destroy src/service.ts --production"]
698
+ },
699
+ args: {
700
+ positionals: { entry: positional.string({
701
+ brief: "The module whose default export is the application root.",
702
+ placeholder: "entry"
703
+ }) },
704
+ flags: {
705
+ name: flag.string({
706
+ brief: "Override the root node's name — the application name to tear down.",
707
+ placeholder: "name"
708
+ }),
709
+ stage: flag.string({
710
+ brief: "Tear down this branch environment.",
711
+ placeholder: "stage"
712
+ }),
713
+ production: flag.boolean({ brief: "Tear down the project-level production environment." })
714
+ }
715
+ },
716
+ needs: {
717
+ config: composerSection,
718
+ credentials: "child"
719
+ },
720
+ maySpawn: true,
721
+ handler: async (args, ctx) => {
722
+ const target = targetOf(args.flags.stage, args.flags.production);
723
+ if (!target.ok) return target;
724
+ const alchemy = convergeSpawn(ctx);
725
+ return settleConverge(await operations.destroy({
726
+ entry: args.positionals.entry,
727
+ name: args.flags.name,
728
+ target: target.value,
729
+ cwd: ctx.cwd,
730
+ onEvent: (event) => {
731
+ if (event.kind !== "no-local-deploy-state") return;
732
+ ctx.report({
733
+ kind: "message",
734
+ severity: "warn",
735
+ text: `No prior deploy state under ${event.cwd} — if you deployed from a different directory, run destroy from there; otherwise this is a no-op.`
736
+ });
737
+ }
738
+ }, operationDeps({
739
+ alchemy,
740
+ configPath: ctx.config.configPath,
741
+ workspaceId: await workspaceIdOf(ctx),
742
+ client: ctx.api
743
+ })), ctx, () => ctx.present({ data: void 0 }, { human: () => [{
744
+ kind: "summary",
745
+ status: "ok",
746
+ text: "Destroyed."
747
+ }] }));
748
+ }
749
+ });
750
+ const STOP_STEP = "Stopping the app's services — emulators and data stay up";
751
+ /** Resolves when the run is asked to stop. */
752
+ function stopRequested(signal) {
753
+ if (signal.aborted) return Promise.resolve();
754
+ return new Promise((resolve) => {
755
+ signal.addEventListener("abort", () => resolve(), { once: true });
756
+ });
757
+ }
758
+ /**
759
+ * One converge at a time. `ctx.spawn` refuses a second live child, and the
760
+ * watch loop can well fire a rebuild while the previous converge is still
761
+ * running — so a request that arrives during a live converge joins the single
762
+ * queued follow-up instead of starting its own. That extends the coalescing
763
+ * the watcher already does across a burst of edits to cover the converge
764
+ * itself, and it is sound because every dev converge is the SAME invocation:
765
+ * one stack file at one fixed path, rewritten in place before each request.
766
+ */
767
+ function coalescedConverge(run) {
768
+ let live;
769
+ let queued;
770
+ const start = (invocation) => {
771
+ const outcome = run(invocation);
772
+ const settled = outcome.then(() => void 0, () => void 0);
773
+ live = settled;
774
+ settled.then(() => {
775
+ if (live === settled) live = void 0;
776
+ });
777
+ return outcome;
778
+ };
779
+ return (invocation) => {
780
+ const running = live;
781
+ if (running === void 0) return start(invocation);
782
+ queued ??= running.then(() => {
783
+ queued = void 0;
784
+ return start(invocation);
785
+ });
786
+ return queued;
787
+ };
788
+ }
789
+ /** The front door, ordered by address depth (fewest dots first) then lexicographically. */
790
+ function frontDoorOrder(endpoints) {
791
+ return [...endpoints].sort((a, b) => {
792
+ const depth = a.address.split(".").length - b.address.split(".").length;
793
+ if (depth !== 0) return depth;
794
+ return a.address < b.address ? -1 : a.address > b.address ? 1 : 0;
795
+ });
796
+ }
797
+ /**
798
+ * The operation's events as engine events. The legacy `[dev]` console prefix
799
+ * is gone: these are commentary the engine renders and frames.
800
+ */
801
+ function reportDevEvent(report, lastChild) {
802
+ let stopFailed = false;
803
+ return (event) => {
804
+ switch (event.kind) {
805
+ case "ready":
806
+ report({
807
+ kind: "status",
808
+ subject: "dev",
809
+ status: "ready"
810
+ });
811
+ for (const endpoint of frontDoorOrder(event.endpoints)) report({
812
+ kind: "endpoint",
813
+ name: endpoint.address,
814
+ url: endpoint.url
815
+ });
816
+ return;
817
+ case "unwatchable":
818
+ report({
819
+ kind: "message",
820
+ severity: "warn",
821
+ text: `${event.address} has no watchable inputs.`
822
+ });
823
+ return;
824
+ case "rebuild-failed":
825
+ report({
826
+ kind: "message",
827
+ severity: "warn",
828
+ text: `Rebuild failed: ${event.message}`
829
+ });
830
+ return;
831
+ case "watch-error":
832
+ report({
833
+ kind: "message",
834
+ severity: "warn",
835
+ text: `Watch error: ${event.message}`
836
+ });
837
+ return;
838
+ case "converge-failed": {
839
+ const child = lastChild();
840
+ if (child !== void 0 && child.signal !== null) return;
841
+ report({
842
+ kind: "message",
843
+ severity: "warn",
844
+ text: `Converge failed — the running app is untouched; still watching.
845
+ Generated stack file: ${event.stackFilePath}\nRun \`${event.reproduceCommand}\` from ${event.cwd} to reproduce this directly.`
846
+ });
847
+ report({
848
+ kind: "remediation",
849
+ action: {
850
+ kind: "run-command",
851
+ label: `Run the converge directly from ${event.cwd} to reproduce this`,
852
+ command: event.reproduceCommand,
853
+ reason: `Generated stack file: ${event.stackFilePath}`
854
+ }
855
+ });
856
+ return;
857
+ }
858
+ case "stopping":
859
+ report({
860
+ kind: "step-started",
861
+ step: STOP_STEP,
862
+ id: "dev-stop"
863
+ });
864
+ return;
865
+ case "stop-error":
866
+ stopFailed = true;
867
+ report({
868
+ kind: "message",
869
+ severity: "warn",
870
+ text: `A service refused to stop: ${event.message}`
871
+ });
872
+ return;
873
+ case "stopped":
874
+ report({
875
+ kind: "step-finished",
876
+ step: STOP_STEP,
877
+ id: "dev-stop",
878
+ outcome: stopFailed ? "warning" : "ok"
879
+ });
880
+ return;
881
+ }
882
+ };
883
+ }
884
+ const createDevCommand = (operations) => defineSessionCommand({
885
+ help: {
886
+ summary: "Bring up the application whose root node is <entry>'s default export, entirely on this machine.",
887
+ description: "Runs credential-free and watches the app for changes, reconverging on every edit. Logs are a separate command; run `log <entry>` to tail them.",
888
+ examples: ["{bin} dev src/service.ts", "{bin} dev src/service.ts --fresh"]
889
+ },
890
+ args: {
891
+ positionals: { entry: positional.string({
892
+ brief: "The module whose default export is the application root.",
893
+ placeholder: "entry"
894
+ }) },
895
+ flags: {
896
+ name: flag.string({
897
+ brief: "Override the root node's name — the dev instance's application name.",
898
+ placeholder: "name"
899
+ }),
900
+ fresh: flag.boolean({ brief: "Destroy the dev stack and wipe the dev state directory before starting." })
901
+ }
902
+ },
903
+ needs: { config: composerSection },
904
+ maySpawn: true,
905
+ handler: async (args, ctx) => {
906
+ const alchemy = convergeSpawn(ctx);
907
+ const result = await operations.dev({
908
+ entry: args.positionals.entry,
909
+ name: args.flags.name,
910
+ fresh: args.flags.fresh,
911
+ cwd: ctx.cwd,
912
+ onEvent: reportDevEvent(ctx.report, ctx.lastChild)
913
+ }, {
914
+ alchemy: coalescedConverge(alchemy),
915
+ configPath: ctx.config.configPath
916
+ });
917
+ if (!result.ok) return settleConvergeFailure(result.failure, ctx);
918
+ await stopRequested(ctx.signal);
919
+ await result.value.stop();
920
+ return ok(void 0);
921
+ }
922
+ });
923
+ /**
924
+ * `log <entry> [address]` — a session command that tails the merged logs of
925
+ * the app running locally on this machine.
926
+ *
927
+ * It reads the LOCAL dev-emulator daemon, not the platform's logs surface, so
928
+ * it is credential-free. It hands the terminal to nothing, which is why it
929
+ * does not declare `maySpawn` and keeps json support: the log lines ARE its
930
+ * json surface.
931
+ *
932
+ * Windows is refused inside the operation itself (LOG.PLATFORM_UNSUPPORTED),
933
+ * which is why nothing here reads the platform.
934
+ */
935
+ /** An empty screen reads as broken, so show a little recent history before going live. */
936
+ const DEFAULT_TAIL = 20;
937
+ const createLogCommand = (operations) => defineSessionCommand({
938
+ help: {
939
+ summary: "Tail the merged logs of the locally-running application whose root node is <entry>'s default export.",
940
+ examples: ["{bin} log src/service.ts", "{bin} log src/service.ts catalog.service"]
941
+ },
942
+ args: {
943
+ positionals: {
944
+ entry: positional.string({
945
+ brief: "The module whose default export is the application root.",
946
+ placeholder: "entry"
947
+ }),
948
+ address: positional.optionalString({
949
+ brief: "Only this service's lines, by its dotted address (catalog.service); every service when absent.",
950
+ placeholder: "address"
951
+ })
952
+ },
953
+ flags: {
954
+ name: flag.string({
955
+ brief: "Override the root node's name — the dev instance's application name.",
956
+ placeholder: "name"
957
+ }),
958
+ tail: flag.number({
959
+ brief: `How many trailing history lines to show before live output (default ${String(DEFAULT_TAIL)}).`,
960
+ placeholder: "lines",
961
+ default: DEFAULT_TAIL
962
+ })
963
+ }
964
+ },
965
+ needs: { config: composerSection },
966
+ handler: async (args, ctx) => {
967
+ const reportLogEvent = (event) => {
968
+ ctx.report({
969
+ kind: "message",
970
+ severity: "warn",
971
+ text: event.kind === "stream-failed" ? `Stream failed: ${event.message}` : `Falling behind — dropped the ${String(event.count)} oldest lines.`
972
+ });
973
+ };
974
+ const result = await operations.log({
975
+ entry: args.positionals.entry,
976
+ name: args.flags.name,
977
+ address: args.positionals.address,
978
+ tail: args.flags.tail ?? DEFAULT_TAIL,
979
+ cwd: ctx.cwd,
980
+ signal: ctx.signal,
981
+ onEvent: reportLogEvent
982
+ }, { configPath: ctx.config.configPath });
983
+ if (!result.ok) return notOk(toEngineError(result.failure));
984
+ const attached = result.value;
985
+ if (attached.services.length === 0) {
986
+ ctx.report({
987
+ kind: "message",
988
+ severity: "warn",
989
+ text: `No running services for "${attached.appName}" — start it first with \`dev ${args.positionals.entry}\`.`
990
+ });
991
+ return ok(void 0);
992
+ }
993
+ for await (const { service, line } of attached.lines) ctx.report({
994
+ kind: "output",
995
+ source: service,
996
+ channel: "data",
997
+ line: `[${service}] ${line}`
998
+ });
999
+ return ok(void 0);
1000
+ }
1001
+ });
1002
+ /**
1003
+ * Composer's `CommandFamily` — the unit the engine mounts, whether the process
1004
+ * is composer's own CLI or the `prisma` bin.
1005
+ *
1006
+ * This module and everything it reaches statically must stay free of alchemy
1007
+ * and of effect VALUE imports: the `prisma` bin imports the family directly,
1008
+ * so anything in this static graph loads on `prisma --version`. The mechanism
1009
+ * that holds it is the existing lazy boundary inside the operation modules —
1010
+ * `operations/deploy.ts`, `destroy.ts`, `dev.ts` and `log.ts` each `await
1011
+ * import()` their executor, and it is the executors that reach the provider
1012
+ * tree. Importing the operations here is therefore free; importing an
1013
+ * executor, or flattening one of those dynamic imports, is not.
1014
+ * scripts/check-family-static-graph.mjs enforces this against BUILT output,
1015
+ * where type-only imports have already been erased.
1016
+ *
1017
+ * The four commands close over the operations they are given, so a host can
1018
+ * mount this family against the test double and exercise real grammar, real
1019
+ * arg validation and real handlers with no alchemy behind them.
1020
+ */
1021
+ const realOperations = {
1022
+ deploy: deployWithDeps,
1023
+ destroy: destroyWithDeps,
1024
+ dev: devWithDeps,
1025
+ log: logWithDeps
1026
+ };
1027
+ function createComposerFamily(options = {}) {
1028
+ const operations = options.operations ?? realOperations;
1029
+ return defineCommandFamily({
1030
+ configSection: composerSection,
1031
+ commands: {
1032
+ deploy: createDeployCommand(operations),
1033
+ destroy: createDestroyCommand(operations),
1034
+ dev: createDevCommand(operations),
1035
+ log: createLogCommand(operations)
1036
+ },
1037
+ docsBaseUrl: DOCS_BASE
1038
+ });
1039
+ }
1040
+ /**
1041
+ * Everything environmental the engine needs, assembled from a host process.
1042
+ *
1043
+ * The engine takes no globals: streams, cwd, env, TTY-ness, exit and signal
1044
+ * subscription all arrive through `Runtime`, which is what lets a test drive a
1045
+ * whole run without touching `process`. Composing one is the substantive part
1046
+ * of hosting the engine — `createCli` and `Cli.run` are two calls.
1047
+ *
1048
+ * Credentials come from the engine's own environment-only manager, which
1049
+ * composes a session from PRISMA_SERVICE_TOKEN / PRISMA_WORKSPACE_ID and
1050
+ * refuses every mutation. That is the whole of composer's standalone auth
1051
+ * story: this CLI has no login flow and mounts no auth commands, so there is
1052
+ * nothing to store — the two variables ARE the credential.
1053
+ */
1054
+ /** Where the management API lives. Matches the lowering client's default origin; the env var is the escape hatch for staging. */
1055
+ const DEFAULT_MANAGEMENT_API_BASE_URL = "https://api.prisma.io";
1056
+ const DEFAULT_AUTH_BASE_URL = "https://auth.prisma.io";
1057
+ /**
1058
+ * Starts the converge child: inherited stdio, this process's own group, no
1059
+ * `detached` and no new console — which is what lets the terminal deliver
1060
+ * Ctrl-C to the child natively instead of the CLI forwarding it. The engine
1061
+ * never imports node:child_process; this adapter is the whole of the host's
1062
+ * side of that seam.
1063
+ */
1064
+ const spawnChild = (request) => {
1065
+ const child = spawn(request.command, [...request.args], {
1066
+ cwd: request.cwd,
1067
+ stdio: "inherit",
1068
+ env: request.env
1069
+ });
1070
+ return {
1071
+ ended: new Promise((resolve, reject) => {
1072
+ child.on("error", reject);
1073
+ child.on("close", (exitCode, signal) => {
1074
+ resolve({
1075
+ exitCode,
1076
+ signal
1077
+ });
1078
+ });
1079
+ }),
1080
+ kill: (signal) => {
1081
+ child.kill(signal);
1082
+ }
1083
+ };
1084
+ };
1085
+ /**
1086
+ * The SDK's client construction config. The engine requires all four fields
1087
+ * whenever a credential manager is wired, but this host reaches none of the
1088
+ * login paths: an environment credential carries no refresh token, so nothing
1089
+ * ever refreshes and `clientId`/`redirectUri` are never read. They are
1090
+ * env-overridable rather than hard-coded so a staging run can point the whole
1091
+ * client somewhere else in one place.
1092
+ */
1093
+ function clientConfig(env, apiBaseUrl) {
1094
+ return {
1095
+ clientId: env["PRISMA_CLIENT_ID"] ?? "prisma-composer-cli",
1096
+ redirectUri: env["PRISMA_REDIRECT_URI"] ?? "http://127.0.0.1/callback",
1097
+ apiBaseUrl,
1098
+ authBaseUrl: env["PRISMA_AUTH_URL"] ?? DEFAULT_AUTH_BASE_URL
1099
+ };
1100
+ }
1101
+ /**
1102
+ * Which package manager invoked us, read from the `npm_config_user_agent`
1103
+ * every major manager sets (`pnpm/10.27.0 npm/? node/v24.16.0 darwin arm64`).
1104
+ * `undefined` when the CLI was run directly rather than through a manager — a
1105
+ * normal case, not a failure, so nothing is inferred from the filesystem, and
1106
+ * the engine falls back to its own detection from the project at cwd.
1107
+ */
1108
+ function detectPackageManager(env) {
1109
+ const agent = env["npm_config_user_agent"];
1110
+ if (agent === void 0) return void 0;
1111
+ const name = agent.split("/")[0];
1112
+ switch (name) {
1113
+ case "npm":
1114
+ case "pnpm":
1115
+ case "yarn":
1116
+ case "bun":
1117
+ case "deno": return name;
1118
+ default: return;
1119
+ }
1120
+ }
1121
+ /**
1122
+ * The config loader arrives as a function rather than an already-loaded config
1123
+ * because the engine reads `prisma.config.ts` on demand — only when the command
1124
+ * it is about to run declares a config section, and with whatever file
1125
+ * `--config` named. A host that loaded the file up front would read it for runs
1126
+ * that never needed it, and would have nowhere to put `--config`.
1127
+ *
1128
+ * `inCI` is the one thing here not derived from the host: `ci-info` answers it
1129
+ * from the real `process.env` at import, which is what the engine's `isCI` doc
1130
+ * asks a host to wire and what the `prisma` bin already does. Production passes
1131
+ * nothing. It is a parameter so a test can still drive CI state without
1132
+ * touching a process global.
1133
+ */
1134
+ function createRuntime(host, loadConfig, inCI = import_ci_info.isCI) {
1135
+ const env = host.env;
1136
+ const apiBaseUrl = env["PRISMA_MANAGEMENT_API_URL"] ?? DEFAULT_MANAGEMENT_API_BASE_URL;
1137
+ const packageManager = detectPackageManager(env);
1138
+ return {
1139
+ stdout: host.stdout,
1140
+ stderr: host.stderr,
1141
+ stdin: host.stdin,
1142
+ cwd: host.cwd(),
1143
+ env,
1144
+ isTty: {
1145
+ stdin: host.stdin.isTTY === true,
1146
+ stdout: host.stdout.isTTY === true,
1147
+ stderr: host.stderr.isTTY === true
1148
+ },
1149
+ exit: (code) => host.exit(code),
1150
+ onSignal: (cb) => {
1151
+ const onSigint = () => {
1152
+ cb("SIGINT");
1153
+ };
1154
+ const onSigterm = () => {
1155
+ cb("SIGTERM");
1156
+ };
1157
+ host.on("SIGINT", onSigint);
1158
+ host.on("SIGTERM", onSigterm);
1159
+ return () => {
1160
+ host.off("SIGINT", onSigint);
1161
+ host.off("SIGTERM", onSigterm);
1162
+ };
1163
+ },
1164
+ loadConfig,
1165
+ credentialManager: new EnvironmentCredentialManager({ env }),
1166
+ managementApiClientConfig: clientConfig(env, apiBaseUrl),
1167
+ spawn: spawnChild,
1168
+ managementApi: { baseUrl: apiBaseUrl },
1169
+ ...packageManager !== void 0 && { packageManager },
1170
+ isCI: inCI
1171
+ };
1172
+ }
1173
+ /**
1174
+ * Composer's own CLI, rebuilt as a thin composition of the family it
1175
+ * publishes: `createCli` over `createComposerFamily()`, `Cli.run` with a
1176
+ * Runtime. Grammar, help, arg validation, output framing, exit codes and
1177
+ * signal ownership all belong to the engine now — this module contributes the
1178
+ * family and the environment, and nothing else.
1179
+ *
1180
+ * Running composer's commands through the same path an external host uses is
1181
+ * the point: it is what proves the family works standalone before the `prisma`
1182
+ * bin mounts it.
1183
+ *
1184
+ * This IS composer's CLI. The clipanion shell it replaced, and the bespoke
1185
+ * runner that shelled out to alchemy, are gone; `bin.ts` is a call into here.
1186
+ */
1187
+ const BINARY_NAME = "prisma-composer";
1188
+ /**
1189
+ * Composer's commands mount at the top level of its own CLI (`prisma-composer
1190
+ * deploy`); under the `prisma` bin the same family mounts one level down
1191
+ * (`prisma composer deploy`). The family is identical either way — only the
1192
+ * mount paths differ, which is exactly the split `createCli` draws between
1193
+ * `commandFamilies` and `commands`.
1194
+ */
1195
+ function mountedTree(family) {
1196
+ return { ...family.commands };
1197
+ }
1198
+ function createComposerCli(spec) {
1199
+ const family = createComposerFamily({ operations: spec.operations });
1200
+ return createCli({
1201
+ name: BINARY_NAME,
1202
+ version: spec.version,
1203
+ commandFamilies: [family],
1204
+ groups: {},
1205
+ commands: mountedTree(family)
1206
+ });
1207
+ }
1208
+ /**
1209
+ * Composes the Runtime and runs one invocation. Returns the exit code rather
1210
+ * than exiting, so the caller owns the process — a bin assigns it to
1211
+ * `process.exitCode` and lets the streams drain, as composer's CLI has always
1212
+ * done.
1213
+ *
1214
+ * `prisma.config.ts` is not read here. The loader goes in as a function, and the
1215
+ * engine calls it only when the command it is about to run declares a config
1216
+ * section, passing it the file `--config` named; the loader resolves that
1217
+ * against the host's cwd.
1218
+ */
1219
+ function runComposerCli(argv, host, spec, hooks) {
1220
+ const runtime = createRuntime(host, (configPath) => loadConfig(host.cwd(), configPath));
1221
+ return createComposerCli(spec).run(argv, runtime, hooks);
1222
+ }
1223
+ //#endregion
1224
+ export { BINARY_NAME, composerSection, createComposerCli, createComposerFamily, realOperations, runComposerCli, toEngineError };
1225
+
1226
+ //# sourceMappingURL=family.mjs.map