@prisma/cli-engine 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  The execution engine of the unified Prisma CLI: it owns the path from argv to exit code — parsing, execution, rendering, and error handling.
4
4
 
5
- Every command describes its output once, as blocks, and the engine renders it in one of three formats chosen by `--format`: `human` for a person at a terminal (padded, aligned, coloured, on stderr, with the machine-usable data lines on stdout), `json` for a program (a stream of frames ending in a result envelope on stdout), and `markdown` for an agent that reads the output as text (plain Markdown with every value labelled, everything on stdout, nothing on stderr). A terminal gets `human` and a pipe gets `json` unless a format is named; `markdown` is only ever explicit.
5
+ Every command describes its output once, as blocks, and the engine renders it in one of three formats chosen by `--format`: `human` for a person at a terminal (padded, aligned, coloured, on stderr, with the machine-usable data lines on stdout), `json` for a program (a stream of frames ending in a result envelope on stdout), and `markdown` for an agent that reads the output as text (plain Markdown with every value labelled, everything on stdout, nothing on stderr). Without a format flag the format is `human`, whether stdout is a terminal or a pipe: a pipe receives the command's data lines and nothing else. `json` and `markdown` are only ever explicit.
6
6
 
7
7
  ## Entry points
8
8
 
@@ -1230,6 +1230,12 @@ function runCommand(manager, request) {
1230
1230
  //#endregion
1231
1231
  //#region src/presentation.ts
1232
1232
  const PRESENTED = Symbol.for("prisma.cli-engine.presented");
1233
+ /** The `stdout` of a command whose only result is that it succeeded,
1234
+ * such as a delete. The reason says why the command has no data, where
1235
+ * its presentation is defined. */
1236
+ function noDataLines(_reason) {
1237
+ return () => [];
1238
+ }
1233
1239
  //#endregion
1234
1240
  //#region src/credential-manager.ts
1235
1241
  /** The environment variables that supply a credential to a process: a
@@ -2110,12 +2116,13 @@ const SHARED_ALIASES = {
2110
2116
  };
2111
2117
  /** The pre-parse format decision: json framing must be in effect before
2112
2118
  * stricli parses (its own failure output is framed too), so the format
2113
- * flags are read from raw argv and a TTY stdout decides the rest. */
2114
- function sniffFormat(argv, runtime) {
2115
- return formatFlagGiven(argv) ?? (runtime.isTty.stdout ? "human" : "json");
2119
+ * flags are read from raw argv. Where stdout goes never picks the
2120
+ * format: a pipe gets human output, whose stdout is the data lines. */
2121
+ function sniffFormat(argv) {
2122
+ return formatFlagGiven(argv) ?? "human";
2116
2123
  }
2117
2124
  function applySharedFlags(state, shared, runtime) {
2118
- state.format = shared.format ?? resolveAutoFormat(shared, runtime);
2125
+ state.format = shared.format ?? (shared.json === true ? "json" : "human");
2119
2126
  state.yes = shared.yes === true;
2120
2127
  state.confirmValues = [...shared.confirm ?? []];
2121
2128
  state.interactive = shared.interactive ?? defaultInteractive(runtime);
@@ -2146,10 +2153,6 @@ function resolveColorEnabled(shared, runtime) {
2146
2153
  function defaultInteractive(runtime) {
2147
2154
  return runtime.isTty.stdin && !resolveIsCI(runtime);
2148
2155
  }
2149
- function resolveAutoFormat(shared, runtime) {
2150
- if (shared.json === true) return "json";
2151
- return runtime.isTty.stdout ? "human" : "json";
2152
- }
2153
2156
  /** --quiet and --verbose are log-level shorthands; either one beats an
2154
2157
  * explicit --log-level given alongside it. */
2155
2158
  function resolveLogLevel(shared) {
@@ -2454,11 +2457,15 @@ function addFlagRedirect(spec, table, redirect, flag) {
2454
2457
  if (table.has(key)) throw constructionError(`redirect for flag '${flag}' on '${redirect.from}' is declared twice`);
2455
2458
  table.set(key, redirect);
2456
2459
  }
2460
+ function describeRedirect(redirect) {
2461
+ return redirect.flag === void 0 ? `redirect '${redirect.from}'` : `redirect for flag '${redirect.flag}' on '${redirect.from}'`;
2462
+ }
2457
2463
  function buildRedirectTable(spec) {
2458
2464
  const byPath = /* @__PURE__ */ new Map();
2459
2465
  const byFlag = /* @__PURE__ */ new Map();
2460
2466
  for (const commandFamily of spec.commandFamilies) for (const redirect of commandFamily.redirects) {
2461
2467
  if (redirect.from === "") throw constructionError("redirect declares an empty path, so no invocation can produce it");
2468
+ if (redirect.replacement.length === 0 && redirect.help === void 0 && redirect.docsUrl === void 0) throw constructionError(`${describeRedirect(redirect)} names no replacement, help, or docs URL, so it gives the user nowhere to go`);
2462
2469
  if (redirect.flag === void 0) addVerbRedirect(spec, byPath, redirect);
2463
2470
  else addFlagRedirect(spec, byFlag, redirect, redirect.flag);
2464
2471
  }
@@ -5661,30 +5668,46 @@ function retiredInvocation(redirect) {
5661
5668
  if (redirect.flag === void 0) return `\`${redirect.from}\``;
5662
5669
  return `\`--${kebabCase(redirect.flag)}\` on \`${redirect.from}\``;
5663
5670
  }
5664
- /** A retired invocation the redirect table claims: the run names its
5665
- * replacement instead of failing as an unknown command or flag. A
5666
- * retired flag can name a server command, whose stdout belongs to a
5671
+ function redirectNextActions(redirect, cliName) {
5672
+ const steps = redirect.replacement.map((step, index) => ({
5673
+ kind: "run-command",
5674
+ label: redirect.replacement.length === 1 ? "Use the replacement" : `Step ${index + 1}`,
5675
+ command: resolveExample(step, cliName)
5676
+ }));
5677
+ const help = redirect.help === void 0 ? [] : [{
5678
+ kind: "run-command",
5679
+ label: "Read its help",
5680
+ command: resolveExample(`${redirect.help} --help`, cliName)
5681
+ }];
5682
+ const docs = redirect.docsUrl === void 0 ? [] : [{
5683
+ kind: "open-url",
5684
+ label: "Read the docs",
5685
+ url: redirect.docsUrl
5686
+ }];
5687
+ return [
5688
+ ...steps,
5689
+ ...help,
5690
+ ...docs
5691
+ ];
5692
+ }
5693
+ /** A retired flag can name a server command, whose stdout belongs to a
5667
5694
  * foreign client — so this settlement renders to stderr for the same
5668
5695
  * reason settleUnhandled does. */
5669
5696
  function settleCommandMoved(spec, invocation, redirect, commandId) {
5670
5697
  if (spec.commands[redirect.from]?.kind === "server-command") invocation.state.format = "human";
5671
- const useReplacement = {
5672
- kind: "run-command",
5673
- label: "Use the replacement",
5674
- command: resolveExample(redirect.replacement, spec.name)
5675
- };
5698
+ const nextActions = redirectNextActions(redirect, spec.name);
5676
5699
  emitErrored(invocation, {
5677
5700
  ok: false,
5678
5701
  commandId,
5679
5702
  error: {
5680
- code: "CLI.COMMAND_MOVED",
5703
+ code: redirect.code ?? "CLI.COMMAND_MOVED",
5681
5704
  severity: "error",
5682
- summary: `${retiredInvocation(redirect)} has been replaced`,
5705
+ summary: redirect.summary === void 0 ? `${retiredInvocation(redirect)} has been replaced` : substituteBinName(redirect.summary, spec.name),
5683
5706
  ...redirect.reason === void 0 ? {} : { why: redirect.reason },
5684
- nextActions: [useReplacement]
5707
+ nextActions
5685
5708
  },
5686
5709
  diagnostics: [],
5687
- nextActions: [useReplacement]
5710
+ nextActions
5688
5711
  });
5689
5712
  return 2;
5690
5713
  }
@@ -5811,7 +5834,7 @@ var EngineImpl = class {
5811
5834
  this.redirects = buildRedirectTable(spec);
5812
5835
  }
5813
5836
  async execute(argv, runtime, hooks) {
5814
- const format = sniffFormat(argv, runtime);
5837
+ const format = sniffFormat(argv);
5815
5838
  const state = {
5816
5839
  commandId: "",
5817
5840
  docsBaseUrl: void 0,
@@ -5985,9 +6008,7 @@ var EngineImpl = class {
5985
6008
  const redirect = matchVerbRedirect(this.redirects, attemptedPath(argv));
5986
6009
  return redirect !== void 0 && redirect.from.split(" ").length > routed.id.split(".").length ? redirect : void 0;
5987
6010
  }
5988
- /** stricli routed or parsed nothing runnable. When the redirect table
5989
- * claims the invocation the user typed, the run names its
5990
- * replacement; otherwise it settles as the usage error it is. */
6011
+ /** stricli routed or parsed nothing runnable. */
5991
6012
  settleRouting(invocation, stricliExitCode) {
5992
6013
  const matched = this.matchRedirect(invocation.state, stricliExitCode);
5993
6014
  if (matched === void 0) return settleUnhandled(this.spec, invocation, stricliExitCode);
@@ -6228,4 +6249,4 @@ function distributePositionals(def, values) {
6228
6249
  return positionals;
6229
6250
  }
6230
6251
  //#endregion
6231
- export { credentialWorkspaceId as C, credentialsRequiredError as D, credentialWorkspaceMismatchError as E, emptyServiceTokenError as O, claimedIdentity as S, credentialRejectedError as T, detectCI as _, definePrismaConfig as a, readActiveAccessToken as b, PRISMA_CONFIG_VERSION as c, PRESENTED as d, readUserConfig as f, exitWithChildStatus as g, resolveGating as h, CONFIG_FILE_NAME as i, noSessionForWorkspaceError as k, SERVICE_TOKEN_ENV_VAR as l, writeUserConfig as m, resolveSectionOverChain as n, loadConfig as o, userConfigPath as p, resolveSectionPath as r, realpathOr as s, buildEngine as t, WORKSPACE_ID_ENV_VAR as u, flag as v, authServiceError as w, claimedExpiresAt as x, positional as y };
6252
+ export { noSessionForWorkspaceError as A, claimedIdentity as C, credentialWorkspaceMismatchError as D, credentialRejectedError as E, credentialsRequiredError as O, claimedExpiresAt as S, authServiceError as T, exitWithChildStatus as _, definePrismaConfig as a, positional as b, PRISMA_CONFIG_VERSION as c, PRESENTED as d, noDataLines as f, resolveGating as g, writeUserConfig as h, CONFIG_FILE_NAME as i, emptyServiceTokenError as k, SERVICE_TOKEN_ENV_VAR as l, userConfigPath as m, resolveSectionOverChain as n, loadConfig as o, readUserConfig as p, resolveSectionPath as r, realpathOr as s, buildEngine as t, WORKSPACE_ID_ENV_VAR as u, detectCI as v, credentialWorkspaceId as w, readActiveAccessToken as x, flag as y };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as defineConfigSection, $t as ManagementApiClientConfig, A as StatementAnswer, At as PackageManagerRunResult, B as PresentedResult, Bt as positional, C as defineServerCommand, Ct as SpawnChild, D as OpenUrlOutcome, Dt as exitWithChildStatus, E as CommandContext, Et as SpawnedChild, F as Block, Ft as Char, G as TreeNode, Gt as CredentialManager, H as Status, Ht as ActiveCredential, I as Format, It as CommandArgs, J as Severity, Jt as Session, K as Ui, Kt as CredentialOrigin, L as Outcome, Lt as FlagSpec, M as StatementQuestion, Mt as PackageOperations, N as StatementSurface, Nt as Args, O as OpenUrlRequest, Ot as PackageManagerId, P as StatementsOptions, Pt as ArgsSpec, Q as SectionValidation, Qt as ManagementApiClient, R as PRESENTED, Rt as PositionalSpec, S as defineCommand, St as ExitWithChildStatusOptions, T as BrowserWaitRequest, Tt as SpawnRequest, U as Text, Ut as Credential, V as Span, Vt as ActiveAccessTokenOptions, W as Tone, Wt as CredentialIdentity, X as StreamMeta, Xt as CredentialRefreshResult, Y as StreamEvent, Yt as StoredSessions, Z as ConfigSection, Zt as CredentialRefresher, _ as ServerCommandDefinition, _t as TelemetryPayload, a as RedirectSpec, at as ResolvedSection, b as StatementSpec, bt as ChildResult, c as CommandDefinition, ct as resolveSectionPath, d as CommandNeeds, dt as InputStream, en as TokenStorage, et as ConfigSchema, f as CompletedEnvelope, ft as LoadedConfig, g as NeedsSpec, gt as Runtime, h as HelpSpec, ht as PRISMA_CONFIG_VERSION, i as MountedTree, it as validateSectionWithSchema, j as StatementOptions, jt as PackageManagerRunner, k as PromptSurface, kt as PackageManagerRunRequest, l as CommandHandler, lt as Host, m as Handler, mt as OutputStream, n as CommandFamily, nt as configSchema, o as defineCommandFamily, ot as SectionProvenance, p as ErroredEnvelope, pt as LoadedConfigFile, q as EngineEvent, qt as SERVICE_TOKEN_ENV_VAR, r as CommandRedirect, rt as reference, s as AnyCommand, st as resolveSectionOverChain, t as TelemetryDeclaration, tt as ConfigSchemaValue, u as CommandHelp, ut as HostProcess, v as SessionCommandDefinition, vt as EngineCommandSnapshot, w as defineSessionCommand, wt as SpawnOptions, x as WorkflowStep, xt as ChildStatusSettlement, y as SpawnDeclarations, yt as RunSummary, z as Presentations, zt as flag } from "./report-CQ30sy_e.js";
1
+ import { $ as SectionValidation, $t as ManagementApiClient, A as StatementAnswer, At as PackageManagerRunRequest, B as PresentedResult, Bt as flag, C as defineServerCommand, Ct as ExitWithChildStatusOptions, D as OpenUrlOutcome, Dt as SpawnedChild, E as CommandContext, Et as SpawnRequest, F as Block, Ft as ArgsSpec, G as TreeNode, Gt as CredentialIdentity, H as Status, Ht as ActiveAccessTokenOptions, I as Format, It as Char, J as EngineEvent, Jt as SERVICE_TOKEN_ENV_VAR, K as Ui, Kt as CredentialManager, L as Outcome, Lt as CommandArgs, M as StatementQuestion, Mt as PackageManagerRunner, N as StatementSurface, Nt as PackageOperations, O as OpenUrlRequest, Ot as exitWithChildStatus, P as StatementsOptions, Pt as Args, Q as ConfigSection, Qt as CredentialRefresher, R as PRESENTED, Rt as FlagSpec, S as defineCommand, St as ChildStatusSettlement, T as BrowserWaitRequest, Tt as SpawnOptions, U as Text, Ut as ActiveCredential, V as Span, Vt as positional, W as Tone, Wt as Credential, X as StreamEvent, Xt as StoredSessions, Y as Severity, Yt as Session, Z as StreamMeta, Zt as CredentialRefreshResult, _ as ServerCommandDefinition, _t as Runtime, a as RedirectSpec, at as validateSectionWithSchema, b as StatementSpec, bt as RunSummary, c as CommandDefinition, ct as resolveSectionOverChain, d as CommandNeeds, dt as HostProcess, en as ManagementApiClientConfig, et as defineConfigSection, f as CompletedEnvelope, ft as InputStream, g as NeedsSpec, gt as PRISMA_CONFIG_VERSION, h as HelpSpec, ht as OutputStream, i as MountedTree, it as reference, j as StatementOptions, jt as PackageManagerRunResult, k as PromptSurface, kt as PackageManagerId, l as CommandHandler, lt as resolveSectionPath, m as Handler, mt as LoadedConfigFile, n as CommandFamily, nt as ConfigSchemaValue, o as defineCommandFamily, ot as ResolvedSection, p as ErroredEnvelope, pt as LoadedConfig, q as noDataLines, qt as CredentialOrigin, r as CommandRedirect, rt as configSchema, s as AnyCommand, st as SectionProvenance, t as TelemetryDeclaration, tn as TokenStorage, tt as ConfigSchema, u as CommandHelp, ut as Host, v as SessionCommandDefinition, vt as TelemetryPayload, w as defineSessionCommand, wt as SpawnChild, x as WorkflowStep, xt as ChildResult, y as SpawnDeclarations, yt as EngineCommandSnapshot, z as Presentations, zt as PositionalSpec } from "./report-JfFs29QS.js";
2
2
  import { n as CliStructuredError } from "./protocol-YjqPCCOG.js";
3
3
 
4
4
  //#region src/active-access-token.d.ts
@@ -227,4 +227,4 @@ declare function claimedExpiresAt(token: string): Date | undefined;
227
227
  */
228
228
  declare function claimedIdentity(token: string): CredentialIdentity | undefined;
229
229
  //#endregion
230
- export { type ActiveAccessTokenOptions, type ActiveCredential, type AnyCommand, type Args, type ArgsSpec, type Block, type BrowserWaitRequest, type Char, type ChildResult, type ChildStatusSettlement, type Cli, type CliRunHooks, type CommandArgs, type CommandContext, type CommandDefinition, type CommandFamily, type CommandHandler, type CommandHelp, type CommandNeeds, type CommandRedirect, type CompletedEnvelope, type ConfigSchema, type ConfigSchemaValue, type ConfigSection, type Credential, type CredentialIdentity, type CredentialManager, type CredentialOrigin, type CredentialRefreshResult, type CredentialRefresher, type CredentialsRequiredReason, type EngineCommandSnapshot, type EngineEvent, EnvironmentCredentialManager, type ErroredEnvelope, type ExitWithChildStatusOptions, type FlagSpec, type Format, type Handler, type HelpSpec, type Host, type HostProcess, type InputStream, type LoadedConfig, type LoadedConfigFile, type ManagementApiClient, type ManagementApiClientConfig, type MountedTree, type NeedsSpec, type OpenUrlOutcome, type OpenUrlRequest, type Outcome, type OutputStream, PRESENTED, PRISMA_CONFIG_VERSION, type PackageManagerId, type PackageManagerRunRequest, type PackageManagerRunResult, type PackageManagerRunner, type PackageOperations, type PositionalSpec, type Presentations, type PresentedResult, type PromptSurface, type RedirectSpec, type ResolvedSection, type RunSummary, type Runtime, SERVICE_TOKEN_ENV_VAR, type SectionProvenance, type SectionValidation, type ServerCommandDefinition, type Session, type SessionCommandDefinition, type Severity, type Span, type SpawnChild, type SpawnDeclarations, type SpawnOptions, type SpawnRequest, type SpawnedChild, type StatementAnswer, type StatementOptions, type StatementQuestion, type StatementSpec, type StatementSurface, type StatementsOptions, type Status, type StoredSessions, type StreamEvent, type StreamMeta, type TelemetryDeclaration, type TelemetryPayload, type TelemetryStatus, type TelemetryStatusReason, type Text, type TokenStorage, type Tone, type TreeNode, type Ui, type WorkflowStep, authServiceError, claimedExpiresAt, claimedIdentity, configSchema, createCli, credentialRejectedError, credentialWorkspaceId, credentialWorkspaceMismatchError, credentialsRequiredError, defineCommand, defineCommandFamily, defineConfigSection, definePrismaConfig, defineServerCommand, defineSessionCommand, detectCI, emptyServiceTokenError, exitWithChildStatus, flag, loadConfig, noSessionForWorkspaceError, positional, readActiveAccessToken, realpathOr, reference, resolveSectionOverChain, resolveSectionPath, telemetryCommandGroup, validateSectionWithSchema };
230
+ export { type ActiveAccessTokenOptions, type ActiveCredential, type AnyCommand, type Args, type ArgsSpec, type Block, type BrowserWaitRequest, type Char, type ChildResult, type ChildStatusSettlement, type Cli, type CliRunHooks, type CommandArgs, type CommandContext, type CommandDefinition, type CommandFamily, type CommandHandler, type CommandHelp, type CommandNeeds, type CommandRedirect, type CompletedEnvelope, type ConfigSchema, type ConfigSchemaValue, type ConfigSection, type Credential, type CredentialIdentity, type CredentialManager, type CredentialOrigin, type CredentialRefreshResult, type CredentialRefresher, type CredentialsRequiredReason, type EngineCommandSnapshot, type EngineEvent, EnvironmentCredentialManager, type ErroredEnvelope, type ExitWithChildStatusOptions, type FlagSpec, type Format, type Handler, type HelpSpec, type Host, type HostProcess, type InputStream, type LoadedConfig, type LoadedConfigFile, type ManagementApiClient, type ManagementApiClientConfig, type MountedTree, type NeedsSpec, type OpenUrlOutcome, type OpenUrlRequest, type Outcome, type OutputStream, PRESENTED, PRISMA_CONFIG_VERSION, type PackageManagerId, type PackageManagerRunRequest, type PackageManagerRunResult, type PackageManagerRunner, type PackageOperations, type PositionalSpec, type Presentations, type PresentedResult, type PromptSurface, type RedirectSpec, type ResolvedSection, type RunSummary, type Runtime, SERVICE_TOKEN_ENV_VAR, type SectionProvenance, type SectionValidation, type ServerCommandDefinition, type Session, type SessionCommandDefinition, type Severity, type Span, type SpawnChild, type SpawnDeclarations, type SpawnOptions, type SpawnRequest, type SpawnedChild, type StatementAnswer, type StatementOptions, type StatementQuestion, type StatementSpec, type StatementSurface, type StatementsOptions, type Status, type StoredSessions, type StreamEvent, type StreamMeta, type TelemetryDeclaration, type TelemetryPayload, type TelemetryStatus, type TelemetryStatusReason, type Text, type TokenStorage, type Tone, type TreeNode, type Ui, type WorkflowStep, authServiceError, claimedExpiresAt, claimedIdentity, configSchema, createCli, credentialRejectedError, credentialWorkspaceId, credentialWorkspaceMismatchError, credentialsRequiredError, defineCommand, defineCommandFamily, defineConfigSection, definePrismaConfig, defineServerCommand, defineSessionCommand, detectCI, emptyServiceTokenError, exitWithChildStatus, flag, loadConfig, noDataLines, noSessionForWorkspaceError, positional, readActiveAccessToken, realpathOr, reference, resolveSectionOverChain, resolveSectionPath, telemetryCommandGroup, validateSectionWithSchema };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { i as ok, r as notOk, t as CliStructuredError } from "./protocol-TtNVkeVS.js";
2
- import { C as credentialWorkspaceId, D as credentialsRequiredError, E as credentialWorkspaceMismatchError, O as emptyServiceTokenError, S as claimedIdentity, T as credentialRejectedError, _ as detectCI, a as definePrismaConfig, b as readActiveAccessToken, c as PRISMA_CONFIG_VERSION, d as PRESENTED, f as readUserConfig, g as exitWithChildStatus, h as resolveGating, k as noSessionForWorkspaceError, l as SERVICE_TOKEN_ENV_VAR, m as writeUserConfig, n as resolveSectionOverChain, o as loadConfig, p as userConfigPath, r as resolveSectionPath, s as realpathOr, t as buildEngine, u as WORKSPACE_ID_ENV_VAR, v as flag, w as authServiceError, x as claimedExpiresAt, y as positional } from "./engine-BE7WKK2X.js";
2
+ import { A as noSessionForWorkspaceError, C as claimedIdentity, D as credentialWorkspaceMismatchError, E as credentialRejectedError, O as credentialsRequiredError, S as claimedExpiresAt, T as authServiceError, _ as exitWithChildStatus, a as definePrismaConfig, b as positional, c as PRISMA_CONFIG_VERSION, d as PRESENTED, f as noDataLines, g as resolveGating, h as writeUserConfig, k as emptyServiceTokenError, l as SERVICE_TOKEN_ENV_VAR, m as userConfigPath, n as resolveSectionOverChain, o as loadConfig, p as readUserConfig, r as resolveSectionPath, s as realpathOr, t as buildEngine, u as WORKSPACE_ID_ENV_VAR, v as detectCI, w as credentialWorkspaceId, x as readActiveAccessToken, y as flag } from "./engine-BevOmYu6.js";
3
3
  import { dirname, isAbsolute, resolve } from "node:path";
4
4
  import { scope, type } from "arktype";
5
5
  //#region src/cli.ts
@@ -22,12 +22,21 @@ function createCli(spec) {
22
22
  function normalizePath(from) {
23
23
  return from.trim().replace(/\s+/g, " ");
24
24
  }
25
+ function replacementSteps(replacement) {
26
+ if (replacement === void 0) return [];
27
+ if (typeof replacement === "string") return [replacement];
28
+ return [...replacement];
29
+ }
25
30
  function normalizeRedirect(spec) {
26
31
  return Object.freeze({
27
32
  from: normalizePath(spec.from),
28
33
  flag: spec.flag,
29
- replacement: spec.replacement,
30
- reason: spec.reason
34
+ replacement: Object.freeze(replacementSteps(spec.replacement)),
35
+ reason: spec.reason,
36
+ code: spec.code,
37
+ summary: spec.summary,
38
+ help: spec.help,
39
+ docsUrl: spec.docsUrl
31
40
  });
32
41
  }
33
42
  function defineCommandFamily(spec) {
@@ -474,11 +483,14 @@ const REASON_EXPLANATION = {
474
483
  function statusSummaryLine(status) {
475
484
  return `Telemetry is ${status.enabled ? "enabled" : "disabled"}: ${REASON_EXPLANATION[status.reason]}`;
476
485
  }
486
+ /** `key<TAB>value` data lines; the reason is its code, such as
487
+ * `stored-opt-out`, which is what a script compares against. */
477
488
  function formatTelemetryStatusLines(status) {
478
489
  return [
479
- statusSummaryLine(status),
480
- `Config file: ${status.configPath}`,
481
- `Installation ID: ${status.installationIdStored ? "stored" : "not stored"}`
490
+ `enabled\t${status.enabled}`,
491
+ `reason\t${status.reason}`,
492
+ `config file\t${status.configPath}`,
493
+ `installation id stored\t${status.installationIdStored}`
482
494
  ];
483
495
  }
484
496
  function statusPresentations(status) {
@@ -502,8 +514,7 @@ function statusPresentations(status) {
502
514
  next: () => []
503
515
  };
504
516
  }
505
- /** One confirmation line, echoed on stdout, with the stored decision as
506
- * the json result. */
517
+ /** One confirmation line, with the stored decision as the json result. */
507
518
  function consentPresentations(line, json) {
508
519
  return {
509
520
  human: () => [{
@@ -511,7 +522,7 @@ function consentPresentations(line, json) {
511
522
  status: "ok",
512
523
  text: line
513
524
  }],
514
- stdout: () => [line],
525
+ stdout: noDataLines("Storing a preference has no data; telemetry status reports it."),
515
526
  json: () => json,
516
527
  next: () => []
517
528
  };
@@ -597,4 +608,4 @@ Telemetry is on by default (opt-out); see ${options.docsUrl}\nfor what is collec
597
608
  };
598
609
  }
599
610
  //#endregion
600
- export { EnvironmentCredentialManager, PRESENTED, PRISMA_CONFIG_VERSION, SERVICE_TOKEN_ENV_VAR, authServiceError, claimedExpiresAt, claimedIdentity, configSchema, createCli, credentialRejectedError, credentialWorkspaceId, credentialWorkspaceMismatchError, credentialsRequiredError, defineCommand, defineCommandFamily, defineConfigSection, definePrismaConfig, defineServerCommand, defineSessionCommand, detectCI, emptyServiceTokenError, exitWithChildStatus, flag, loadConfig, noSessionForWorkspaceError, positional, readActiveAccessToken, realpathOr, reference, resolveSectionOverChain, resolveSectionPath, telemetryCommandGroup, validateSectionWithSchema };
611
+ export { EnvironmentCredentialManager, PRESENTED, PRISMA_CONFIG_VERSION, SERVICE_TOKEN_ENV_VAR, authServiceError, claimedExpiresAt, claimedIdentity, configSchema, createCli, credentialRejectedError, credentialWorkspaceId, credentialWorkspaceMismatchError, credentialsRequiredError, defineCommand, defineCommandFamily, defineConfigSection, definePrismaConfig, defineServerCommand, defineSessionCommand, detectCI, emptyServiceTokenError, exitWithChildStatus, flag, loadConfig, noDataLines, noSessionForWorkspaceError, positional, readActiveAccessToken, realpathOr, reference, resolveSectionOverChain, resolveSectionPath, telemetryCommandGroup, validateSectionWithSchema };
@@ -1078,6 +1078,10 @@ interface Presentations {
1078
1078
  readonly json: () => unknown;
1079
1079
  readonly next: () => readonly NextAction[];
1080
1080
  }
1081
+ /** The `stdout` of a command whose only result is that it succeeded,
1082
+ * such as a delete. The reason says why the command has no data, where
1083
+ * its presentation is defined. */
1084
+ declare function noDataLines(_reason: string): () => readonly string[];
1081
1085
  /**
1082
1086
  * What happened: it selects the glyph (✔ ✘ ⚠ ℹ) and carries a default
1083
1087
  * Tone of the same name. Separate from Tone because a failure can be
@@ -1761,10 +1765,9 @@ interface ErroredEnvelope {
1761
1765
  //#endregion
1762
1766
  //#region src/command-family.d.ts
1763
1767
  /**
1764
- * A retired invocation and the invocation that replaced it. Redirects
1765
- * are metadata, never commands: they stay out of help and out of the
1766
- * command tree, and are consulted only when an invocation fails to
1767
- * resolve.
1768
+ * A retired invocation. Redirects are metadata, never commands: they
1769
+ * stay out of help and out of the command tree, and are consulted only
1770
+ * when an invocation fails to resolve.
1768
1771
  */
1769
1772
  interface RedirectSpec {
1770
1773
  /**
@@ -1780,21 +1783,24 @@ interface RedirectSpec {
1780
1783
  * (rendered --kebab-case, as flag declarations are).
1781
1784
  */
1782
1785
  readonly flag?: string;
1783
- /**
1784
- * The replacement invocation, written the way help examples are
1785
- * written: no binary name, `{bin}` available when the name has to sit
1786
- * mid-string. Placeholder arguments use angle brackets (`<ref>`).
1787
- */
1788
- readonly replacement: string;
1786
+ readonly replacement?: string | readonly string[];
1789
1787
  /** One sentence of context, surfaced as the error's `why`. */
1790
1788
  readonly reason?: string;
1789
+ readonly code?: `${string}.${string}`;
1790
+ readonly summary?: string;
1791
+ readonly help?: string;
1792
+ readonly docsUrl?: string;
1791
1793
  }
1792
1794
  /** The normalized redirect a command family carries. */
1793
1795
  interface CommandRedirect {
1794
1796
  readonly from: string;
1795
1797
  readonly flag: string | undefined;
1796
- readonly replacement: string;
1798
+ readonly replacement: readonly string[];
1797
1799
  readonly reason: string | undefined;
1800
+ readonly code: `${string}.${string}` | undefined;
1801
+ readonly summary: string | undefined;
1802
+ readonly help: string | undefined;
1803
+ readonly docsUrl: string | undefined;
1798
1804
  }
1799
1805
  /**
1800
1806
  * The unit of contribution and ownership a package exports for CLI
@@ -1835,4 +1841,4 @@ interface TelemetryDeclaration {
1835
1841
  readonly docsUrl: string;
1836
1842
  }
1837
1843
  //#endregion
1838
- export { defineConfigSection as $, ManagementApiClientConfig as $t, StatementAnswer as A, PackageManagerRunResult as At, PresentedResult as B, positional as Bt, defineServerCommand as C, SpawnChild as Ct, OpenUrlOutcome as D, exitWithChildStatus as Dt, CommandContext as E, SpawnedChild as Et, Block as F, Char as Ft, TreeNode as G, CredentialManager as Gt, Status as H, ActiveCredential as Ht, Format as I, CommandArgs as It, Severity as J, Session as Jt, Ui as K, CredentialOrigin as Kt, Outcome as L, FlagSpec as Lt, StatementQuestion as M, PackageOperations as Mt, StatementSurface as N, Args as Nt, OpenUrlRequest as O, PackageManagerId as Ot, StatementsOptions as P, ArgsSpec as Pt, SectionValidation as Q, ManagementApiClient$1 as Qt, PRESENTED as R, PositionalSpec as Rt, defineCommand as S, ExitWithChildStatusOptions as St, BrowserWaitRequest as T, SpawnRequest as Tt, Text as U, Credential as Ut, Span as V, ActiveAccessTokenOptions as Vt, Tone as W, CredentialIdentity as Wt, StreamMeta as X, CredentialRefreshResult as Xt, StreamEvent as Y, StoredSessions as Yt, ConfigSection as Z, CredentialRefresher as Zt, ServerCommandDefinition as _, TelemetryPayload as _t, RedirectSpec as a, ResolvedSection as at, StatementSpec as b, ChildResult as bt, CommandDefinition as c, resolveSectionPath as ct, CommandNeeds as d, InputStream as dt, TokenStorage$1 as en, ConfigSchema as et, CompletedEnvelope as f, LoadedConfig as ft, NeedsSpec as g, Runtime as gt, HelpSpec as h, PRISMA_CONFIG_VERSION as ht, MountedTree as i, validateSectionWithSchema as it, StatementOptions as j, PackageManagerRunner as jt, PromptSurface as k, PackageManagerRunRequest as kt, CommandHandler as l, Host as lt, Handler as m, OutputStream as mt, CommandFamily as n, configSchema as nt, defineCommandFamily as o, SectionProvenance as ot, ErroredEnvelope as p, LoadedConfigFile as pt, EngineEvent as q, SERVICE_TOKEN_ENV_VAR as qt, CommandRedirect as r, reference as rt, AnyCommand as s, resolveSectionOverChain as st, TelemetryDeclaration as t, ConfigSchemaValue as tt, CommandHelp as u, HostProcess as ut, SessionCommandDefinition as v, EngineCommandSnapshot as vt, defineSessionCommand as w, SpawnOptions as wt, WorkflowStep as x, ChildStatusSettlement as xt, SpawnDeclarations as y, RunSummary as yt, Presentations as z, flag as zt };
1844
+ export { SectionValidation as $, ManagementApiClient$1 as $t, StatementAnswer as A, PackageManagerRunRequest as At, PresentedResult as B, flag as Bt, defineServerCommand as C, ExitWithChildStatusOptions as Ct, OpenUrlOutcome as D, SpawnedChild as Dt, CommandContext as E, SpawnRequest as Et, Block as F, ArgsSpec as Ft, TreeNode as G, CredentialIdentity as Gt, Status as H, ActiveAccessTokenOptions as Ht, Format as I, Char as It, EngineEvent as J, SERVICE_TOKEN_ENV_VAR as Jt, Ui as K, CredentialManager as Kt, Outcome as L, CommandArgs as Lt, StatementQuestion as M, PackageManagerRunner as Mt, StatementSurface as N, PackageOperations as Nt, OpenUrlRequest as O, exitWithChildStatus as Ot, StatementsOptions as P, Args as Pt, ConfigSection as Q, CredentialRefresher as Qt, PRESENTED as R, FlagSpec as Rt, defineCommand as S, ChildStatusSettlement as St, BrowserWaitRequest as T, SpawnOptions as Tt, Text as U, ActiveCredential as Ut, Span as V, positional as Vt, Tone as W, Credential as Wt, StreamEvent as X, StoredSessions as Xt, Severity as Y, Session as Yt, StreamMeta as Z, CredentialRefreshResult as Zt, ServerCommandDefinition as _, Runtime as _t, RedirectSpec as a, validateSectionWithSchema as at, StatementSpec as b, RunSummary as bt, CommandDefinition as c, resolveSectionOverChain as ct, CommandNeeds as d, HostProcess as dt, ManagementApiClientConfig as en, defineConfigSection as et, CompletedEnvelope as f, InputStream as ft, NeedsSpec as g, PRISMA_CONFIG_VERSION as gt, HelpSpec as h, OutputStream as ht, MountedTree as i, reference as it, StatementOptions as j, PackageManagerRunResult as jt, PromptSurface as k, PackageManagerId as kt, CommandHandler as l, resolveSectionPath as lt, Handler as m, LoadedConfigFile as mt, CommandFamily as n, ConfigSchemaValue as nt, defineCommandFamily as o, ResolvedSection as ot, ErroredEnvelope as p, LoadedConfig as pt, noDataLines as q, CredentialOrigin as qt, CommandRedirect as r, configSchema as rt, AnyCommand as s, SectionProvenance as st, TelemetryDeclaration as t, TokenStorage$1 as tn, ConfigSchema as tt, CommandHelp as u, Host as ut, SessionCommandDefinition as v, TelemetryPayload as vt, defineSessionCommand as w, SpawnChild as wt, WorkflowStep as x, ChildResult as xt, SpawnDeclarations as y, EngineCommandSnapshot as yt, Presentations as z, PositionalSpec as zt };
package/dist/testing.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { $t as ManagementApiClientConfig, B as PresentedResult, Ct as SpawnChild, Gt as CredentialManager, Ht as ActiveCredential, Jt as Session, Ot as PackageManagerId, Qt as ManagementApiClient, Tt as SpawnRequest, Ut as Credential, Vt as ActiveAccessTokenOptions, Y as StreamEvent, Yt as StoredSessions, Zt as CredentialRefresher, _t as TelemetryPayload, bt as ChildResult, en as TokenStorage, gt as Runtime, i as MountedTree, jt as PackageManagerRunner, lt as Host, n as CommandFamily, q as EngineEvent, t as TelemetryDeclaration, x as WorkflowStep, yt as RunSummary } from "./report-CQ30sy_e.js";
1
+ import { $t as ManagementApiClient, B as PresentedResult, Et as SpawnRequest, Ht as ActiveAccessTokenOptions, J as EngineEvent, Kt as CredentialManager, Mt as PackageManagerRunner, Qt as CredentialRefresher, Ut as ActiveCredential, Wt as Credential, X as StreamEvent, Xt as StoredSessions, Yt as Session, _t as Runtime, bt as RunSummary, en as ManagementApiClientConfig, i as MountedTree, kt as PackageManagerId, n as CommandFamily, t as TelemetryDeclaration, tn as TokenStorage, ut as Host, vt as TelemetryPayload, wt as SpawnChild, x as WorkflowStep, xt as ChildResult } from "./report-JfFs29QS.js";
2
2
 
3
3
  //#region src/in-memory-credential-manager.d.ts
4
4
  /** A stored session with its credential material — what the manager
package/dist/testing.js CHANGED
@@ -1,4 +1,4 @@
1
- import { C as credentialWorkspaceId, D as credentialsRequiredError, E as credentialWorkspaceMismatchError, S as claimedIdentity, b as readActiveAccessToken, k as noSessionForWorkspaceError, t as buildEngine, x as claimedExpiresAt } from "./engine-BE7WKK2X.js";
1
+ import { A as noSessionForWorkspaceError, C as claimedIdentity, D as credentialWorkspaceMismatchError, O as credentialsRequiredError, S as claimedExpiresAt, t as buildEngine, w as credentialWorkspaceId, x as readActiveAccessToken } from "./engine-BevOmYu6.js";
2
2
  import { Buffer } from "node:buffer";
3
3
  import { resolve } from "node:path";
4
4
  //#region src/in-memory-credential-manager.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/cli-engine",
3
- "version": "0.8.0",
3
+ "version": "0.10.0",
4
4
  "description": "The execution engine of the unified Prisma CLI.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -53,8 +53,8 @@
53
53
  },
54
54
  "devDependencies": {
55
55
  "@prisma/management-api-sdk": "1.80.0",
56
- "@repo/cli-conformance": "8.0.0-rc.23-dev.152",
57
- "@repo/tsconfig": "8.0.0-rc.23-dev.152",
56
+ "@repo/cli-conformance": "8.0.0-rc.33-dev.186",
57
+ "@repo/tsconfig": "8.0.0-rc.33-dev.186",
58
58
  "@types/node": "^22.19.19",
59
59
  "ci-info": "^4.3.1",
60
60
  "tsdown": "^0.21.10",