@prisma-next/cli 0.12.0 → 0.13.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 (213) hide show
  1. package/README.md +2 -2
  2. package/dist/cli.mjs +180 -163
  3. package/dist/cli.mjs.map +1 -1
  4. package/dist/{client-KgJorIvG.mjs → client-CJzuo5wX.mjs} +222 -107
  5. package/dist/client-CJzuo5wX.mjs.map +1 -0
  6. package/dist/{command-helpers-Bbw1GbwL.mjs → command-helpers-DGMvGBeX.mjs} +318 -25
  7. package/dist/command-helpers-DGMvGBeX.mjs.map +1 -0
  8. package/dist/commands/contract-emit.d.mts.map +1 -1
  9. package/dist/commands/contract-emit.mjs +1 -1
  10. package/dist/commands/contract-infer.d.mts.map +1 -1
  11. package/dist/commands/contract-infer.mjs +1 -1
  12. package/dist/commands/db-init.d.mts.map +1 -1
  13. package/dist/commands/db-init.mjs +4 -5
  14. package/dist/commands/db-init.mjs.map +1 -1
  15. package/dist/commands/db-schema.d.mts.map +1 -1
  16. package/dist/commands/db-schema.mjs +3 -3
  17. package/dist/commands/db-schema.mjs.map +1 -1
  18. package/dist/commands/db-sign.d.mts.map +1 -1
  19. package/dist/commands/db-sign.mjs +6 -6
  20. package/dist/commands/db-sign.mjs.map +1 -1
  21. package/dist/commands/db-update.d.mts.map +1 -1
  22. package/dist/commands/db-update.mjs +10 -7
  23. package/dist/commands/db-update.mjs.map +1 -1
  24. package/dist/commands/db-verify.d.mts.map +1 -1
  25. package/dist/commands/db-verify.mjs +1 -1
  26. package/dist/commands/migrate.d.mts +37 -3
  27. package/dist/commands/migrate.d.mts.map +1 -1
  28. package/dist/commands/migrate.mjs +298 -12
  29. package/dist/commands/migrate.mjs.map +1 -1
  30. package/dist/commands/migration-check.d.mts +55 -13
  31. package/dist/commands/migration-check.d.mts.map +1 -1
  32. package/dist/commands/migration-check.mjs +3 -2
  33. package/dist/commands/migration-graph.d.mts +17 -8
  34. package/dist/commands/migration-graph.d.mts.map +1 -1
  35. package/dist/commands/migration-graph.mjs +185 -2
  36. package/dist/commands/migration-graph.mjs.map +1 -0
  37. package/dist/commands/migration-list.d.mts +26 -27
  38. package/dist/commands/migration-list.d.mts.map +1 -1
  39. package/dist/commands/migration-list.mjs +2 -190
  40. package/dist/commands/migration-log.d.mts +9 -19
  41. package/dist/commands/migration-log.d.mts.map +1 -1
  42. package/dist/commands/migration-log.mjs +1 -137
  43. package/dist/commands/migration-new.d.mts.map +1 -1
  44. package/dist/commands/migration-new.mjs +6 -5
  45. package/dist/commands/migration-new.mjs.map +1 -1
  46. package/dist/commands/migration-plan.d.mts +1 -1
  47. package/dist/commands/migration-plan.d.mts.map +1 -1
  48. package/dist/commands/migration-plan.mjs +1 -1
  49. package/dist/commands/migration-show.d.mts +17 -21
  50. package/dist/commands/migration-show.d.mts.map +1 -1
  51. package/dist/commands/migration-show.mjs +24 -36
  52. package/dist/commands/migration-show.mjs.map +1 -1
  53. package/dist/commands/migration-status.d.mts +42 -144
  54. package/dist/commands/migration-status.d.mts.map +1 -1
  55. package/dist/commands/migration-status.mjs +3 -759
  56. package/dist/commands/ref.d.mts +1 -1
  57. package/dist/commands/ref.d.mts.map +1 -1
  58. package/dist/commands/ref.mjs +4 -4
  59. package/dist/commands/ref.mjs.map +1 -1
  60. package/dist/commands/telemetry/index.d.mts +7 -0
  61. package/dist/commands/telemetry/index.d.mts.map +1 -0
  62. package/dist/commands/telemetry/index.mjs +2 -0
  63. package/dist/{config-loader-B6sJjXTv.mjs → config-loader-p9JMrekQ.mjs} +1 -1
  64. package/dist/{config-loader-B6sJjXTv.mjs.map → config-loader-p9JMrekQ.mjs.map} +1 -1
  65. package/dist/config-loader.mjs +1 -1
  66. package/dist/{contract-at-errors-BxP-TOMl.mjs → contract-at-errors-CFXsstzm.mjs} +2 -2
  67. package/dist/{contract-at-errors-BxP-TOMl.mjs.map → contract-at-errors-CFXsstzm.mjs.map} +1 -1
  68. package/dist/{contract-emit-DxcGl4Uq.mjs → contract-emit-B_qriF8B.mjs} +5 -5
  69. package/dist/{contract-emit-DxcGl4Uq.mjs.map → contract-emit-B_qriF8B.mjs.map} +1 -1
  70. package/dist/{contract-emit-D-4jrNve.mjs → contract-emit-C8HmtboH.mjs} +12 -7
  71. package/dist/contract-emit-C8HmtboH.mjs.map +1 -0
  72. package/dist/{contract-enrichment-a0V5Y_mL.mjs → contract-enrichment-gn9sWbPw.mjs} +1 -1
  73. package/dist/{contract-enrichment-a0V5Y_mL.mjs.map → contract-enrichment-gn9sWbPw.mjs.map} +1 -1
  74. package/dist/{contract-infer-D8uEbJuu.mjs → contract-infer-BYT_ra_U.mjs} +5 -5
  75. package/dist/contract-infer-BYT_ra_U.mjs.map +1 -0
  76. package/dist/{contract-space-aggregate-loader-DvZwdkrr.mjs → contract-space-aggregate-loader-ClI1KN6d.mjs} +5 -5
  77. package/dist/{contract-space-aggregate-loader-DvZwdkrr.mjs.map → contract-space-aggregate-loader-ClI1KN6d.mjs.map} +1 -1
  78. package/dist/{db-verify-v_vUKXTU.mjs → db-verify-C24FKhb7.mjs} +6 -6
  79. package/dist/{db-verify-v_vUKXTU.mjs.map → db-verify-C24FKhb7.mjs.map} +1 -1
  80. package/dist/exports/control-api.d.mts +5 -3
  81. package/dist/exports/control-api.d.mts.map +1 -1
  82. package/dist/exports/control-api.mjs +3 -3
  83. package/dist/exports/index.mjs +1 -1
  84. package/dist/exports/index.mjs.map +1 -1
  85. package/dist/exports/init-output.d.mts +1 -3
  86. package/dist/exports/init-output.d.mts.map +1 -1
  87. package/dist/exports/init-output.mjs +1 -1
  88. package/dist/{extension-pack-inputs-IDvjRCi3.mjs → extension-pack-inputs-1ySHqxKG.mjs} +1 -1
  89. package/dist/{extension-pack-inputs-IDvjRCi3.mjs.map → extension-pack-inputs-1ySHqxKG.mjs.map} +1 -1
  90. package/dist/{framework-components-fYXjz_in.mjs → framework-components-YVQHhPH7.mjs} +2 -2
  91. package/dist/{framework-components-fYXjz_in.mjs.map → framework-components-YVQHhPH7.mjs.map} +1 -1
  92. package/dist/{global-flags-DEHjV8_s.d.mts → global-flags-BpoOYtNZ.d.mts} +1 -1
  93. package/dist/{global-flags-DEHjV8_s.d.mts.map → global-flags-BpoOYtNZ.d.mts.map} +1 -1
  94. package/dist/{init-Cv9UzWL5.mjs → init-0HwB-Vh8.mjs} +5 -58
  95. package/dist/init-0HwB-Vh8.mjs.map +1 -0
  96. package/dist/{inspect-live-schema-C6ohV_oQ.mjs → inspect-live-schema-DF6IwcDl.mjs} +7 -5
  97. package/dist/inspect-live-schema-DF6IwcDl.mjs.map +1 -0
  98. package/dist/migration-check-soB5uZEQ.mjs +573 -0
  99. package/dist/migration-check-soB5uZEQ.mjs.map +1 -0
  100. package/dist/migration-cli.mjs +1 -1
  101. package/dist/migration-cli.mjs.map +1 -1
  102. package/dist/{migration-command-scaffold-CjvwO6at.mjs → migration-command-scaffold-DA-Lhx6o.mjs} +5 -5
  103. package/dist/{migration-command-scaffold-CjvwO6at.mjs.map → migration-command-scaffold-DA-Lhx6o.mjs.map} +1 -1
  104. package/dist/migration-graph-command-render-CEez7YUK.mjs +1960 -0
  105. package/dist/migration-graph-command-render-CEez7YUK.mjs.map +1 -0
  106. package/dist/migration-list-DlJJ_38Z.mjs +230 -0
  107. package/dist/migration-list-DlJJ_38Z.mjs.map +1 -0
  108. package/dist/migration-log-CG0qQAFm.mjs +222 -0
  109. package/dist/migration-log-CG0qQAFm.mjs.map +1 -0
  110. package/dist/migration-path-target-Ce6OZImp.mjs +38 -0
  111. package/dist/migration-path-target-Ce6OZImp.mjs.map +1 -0
  112. package/dist/{migration-plan-9DJ7q7_z.mjs → migration-plan-z5Ing-TD.mjs} +9 -8
  113. package/dist/migration-plan-z5Ing-TD.mjs.map +1 -0
  114. package/dist/migration-status-CgWSoI_g.mjs +446 -0
  115. package/dist/migration-status-CgWSoI_g.mjs.map +1 -0
  116. package/dist/{output-B60Gw5fu.mjs → output-mEQ74_nd.mjs} +1 -1
  117. package/dist/{output-B60Gw5fu.mjs.map → output-mEQ74_nd.mjs.map} +1 -1
  118. package/dist/{progress-adapter-C644QK8l.mjs → progress-adapter-CjAeTxY_.mjs} +1 -1
  119. package/dist/{progress-adapter-C644QK8l.mjs.map → progress-adapter-CjAeTxY_.mjs.map} +1 -1
  120. package/dist/{ref-advancement-DUZqsue6.mjs → ref-advancement-BkXlikCA.mjs} +1 -1
  121. package/dist/{ref-advancement-DUZqsue6.mjs.map → ref-advancement-BkXlikCA.mjs.map} +1 -1
  122. package/dist/schemas-CeGMYFYX.d.mts +191 -0
  123. package/dist/schemas-CeGMYFYX.d.mts.map +1 -0
  124. package/dist/schemas-KhXMzNA_.mjs +112 -0
  125. package/dist/schemas-KhXMzNA_.mjs.map +1 -0
  126. package/dist/telemetry-BIM4beEO.mjs +122 -0
  127. package/dist/telemetry-BIM4beEO.mjs.map +1 -0
  128. package/dist/{terminal-ui-5Y6mrg93.d.mts → terminal-ui-DGRNFWna.d.mts} +1 -1
  129. package/dist/terminal-ui-DGRNFWna.d.mts.map +1 -0
  130. package/dist/{types-Dt_SfqFm.d.mts → types-C_tYiJYx.d.mts} +53 -31
  131. package/dist/types-C_tYiJYx.d.mts.map +1 -0
  132. package/dist/{verify-DCA9Sldu.mjs → verify-DcOYZ1tH.mjs} +2 -2
  133. package/dist/{verify-DCA9Sldu.mjs.map → verify-DcOYZ1tH.mjs.map} +1 -1
  134. package/package.json +26 -22
  135. package/src/cli.ts +5 -0
  136. package/src/commands/contract-infer.ts +2 -2
  137. package/src/commands/db-update.ts +7 -1
  138. package/src/commands/init/index.ts +6 -35
  139. package/src/commands/init/init.ts +1 -14
  140. package/src/commands/init/inputs.ts +0 -75
  141. package/src/commands/inspect-live-schema.ts +10 -0
  142. package/src/commands/json/schemas.ts +195 -0
  143. package/src/commands/migrate.ts +527 -8
  144. package/src/commands/migration-check.ts +469 -134
  145. package/src/commands/migration-graph.ts +164 -91
  146. package/src/commands/migration-list.ts +72 -39
  147. package/src/commands/migration-log.ts +52 -102
  148. package/src/commands/migration-new.ts +2 -1
  149. package/src/commands/migration-plan.ts +2 -1
  150. package/src/commands/migration-show.ts +31 -66
  151. package/src/commands/migration-status-overlay.ts +61 -0
  152. package/src/commands/migration-status.ts +458 -1066
  153. package/src/commands/telemetry/index.ts +107 -0
  154. package/src/commands/telemetry/status.ts +67 -0
  155. package/src/control-api/client.ts +70 -9
  156. package/src/control-api/operations/contract-emit.ts +22 -2
  157. package/src/control-api/operations/db-init.ts +6 -3
  158. package/src/control-api/operations/{db-apply.ts → db-run.ts} +55 -14
  159. package/src/control-api/operations/db-update.ts +7 -4
  160. package/src/control-api/operations/db-verify.ts +15 -5
  161. package/src/control-api/operations/{migration-apply.ts → migrate.ts} +181 -80
  162. package/src/control-api/operations/{apply.ts → run-migration.ts} +33 -27
  163. package/src/control-api/types.ts +56 -29
  164. package/src/utils/cli-errors.ts +70 -2
  165. package/src/utils/formatters/errors.ts +11 -0
  166. package/src/utils/formatters/migration-graph-command-render.ts +239 -0
  167. package/src/utils/formatters/migration-graph-grid-layout.ts +1134 -0
  168. package/src/utils/formatters/migration-graph-labels.ts +408 -0
  169. package/src/utils/formatters/migration-graph-model.ts +103 -0
  170. package/src/utils/formatters/migration-graph-occlusion-render.ts +258 -0
  171. package/src/utils/formatters/migration-graph-rows.ts +128 -15
  172. package/src/utils/formatters/migration-graph-space-render.ts +188 -0
  173. package/src/utils/formatters/migration-list-data-column.ts +4 -91
  174. package/src/utils/formatters/migration-list-graph-topology.ts +72 -94
  175. package/src/utils/formatters/migration-list-render.ts +135 -71
  176. package/src/utils/formatters/migration-list-styler.ts +46 -5
  177. package/src/utils/formatters/migration-list-types.ts +5 -21
  178. package/src/utils/formatters/migration-log-table.ts +205 -0
  179. package/src/utils/formatters/migrations.ts +33 -11
  180. package/src/utils/global-flags.ts +35 -0
  181. package/src/utils/integrity-violation-to-check-failure.ts +28 -19
  182. package/src/utils/legend.ts +38 -0
  183. package/src/utils/migration-path-target.ts +60 -0
  184. package/src/utils/telemetry.ts +68 -32
  185. package/dist/client-KgJorIvG.mjs.map +0 -1
  186. package/dist/command-helpers-Bbw1GbwL.mjs.map +0 -1
  187. package/dist/commands/migration-list.mjs.map +0 -1
  188. package/dist/commands/migration-log.mjs.map +0 -1
  189. package/dist/commands/migration-status.mjs.map +0 -1
  190. package/dist/contract-emit-D-4jrNve.mjs.map +0 -1
  191. package/dist/contract-infer-D8uEbJuu.mjs.map +0 -1
  192. package/dist/graph-render-rFAqZujX.mjs +0 -1081
  193. package/dist/graph-render-rFAqZujX.mjs.map +0 -1
  194. package/dist/init-Cv9UzWL5.mjs.map +0 -1
  195. package/dist/inspect-live-schema-C6ohV_oQ.mjs.map +0 -1
  196. package/dist/migration-check-BiBJoYYW.mjs +0 -341
  197. package/dist/migration-check-BiBJoYYW.mjs.map +0 -1
  198. package/dist/migration-graph-D7DVUElV.mjs +0 -1232
  199. package/dist/migration-graph-D7DVUElV.mjs.map +0 -1
  200. package/dist/migration-list-styler-BRwF4-gy.mjs +0 -399
  201. package/dist/migration-list-styler-BRwF4-gy.mjs.map +0 -1
  202. package/dist/migration-plan-9DJ7q7_z.mjs.map +0 -1
  203. package/dist/migration-types-D2FW63pr.d.mts +0 -15
  204. package/dist/migration-types-D2FW63pr.d.mts.map +0 -1
  205. package/dist/migrations-Cv2jxNNK.mjs +0 -228
  206. package/dist/migrations-Cv2jxNNK.mjs.map +0 -1
  207. package/dist/terminal-ui-5Y6mrg93.d.mts.map +0 -1
  208. package/dist/types-Dt_SfqFm.d.mts.map +0 -1
  209. package/src/utils/formatters/graph-migration-mapper.ts +0 -235
  210. package/src/utils/formatters/graph-render.ts +0 -1323
  211. package/src/utils/formatters/graph-types.ts +0 -120
  212. package/src/utils/formatters/migration-graph-layout.ts +0 -1119
  213. package/src/utils/formatters/migration-graph-tree-render.ts +0 -459
@@ -4,8 +4,11 @@ import {
4
4
  setCommandDescriptions,
5
5
  setCommandExamples,
6
6
  } from '../../utils/command-helpers';
7
- import { type CommonCommandOptions, parseGlobalFlagsOrExit } from '../../utils/global-flags';
8
- import { fireTelemetryAfterInitConsent } from '../../utils/telemetry';
7
+ import {
8
+ type CommonCommandOptions,
9
+ deriveCanPrompt,
10
+ parseGlobalFlagsOrExit,
11
+ } from '../../utils/global-flags';
9
12
  import {
10
13
  INIT_EXIT_EMIT_FAILED,
11
14
  INIT_EXIT_INSTALL_FAILED,
@@ -93,7 +96,7 @@ export function createInitCommand(): Command {
93
96
  '--no-skill',
94
97
  'Skip Prisma Next skills install (air-gapped CI, restricted registries, etc.)',
95
98
  )
96
- .action(async (options: InitCommandOptions, actionCommand: Command) => {
99
+ .action(async (options: InitCommandOptions) => {
97
100
  const { runInit } = await import('./init');
98
101
  const flags = parseGlobalFlagsOrExit(options);
99
102
  const canPrompt = deriveCanPrompt({
@@ -105,39 +108,7 @@ export function createInitCommand(): Command {
105
108
  options,
106
109
  flags,
107
110
  canPrompt,
108
- afterFirstTelemetryConsent: (inputs) => {
109
- fireTelemetryAfterInitConsent(actionCommand, { databaseTarget: inputs.target });
110
- },
111
111
  });
112
112
  process.exit(exitCode);
113
113
  });
114
114
  }
115
-
116
- /**
117
- * Bridges the action handler's two TTY checks (stdout via `flags`, stdin
118
- * via `process.stdin.isTTY`) into the `canPrompt` boolean `runInit`
119
- * consumes.
120
- *
121
- * Per the [Style Guide § Interactivity](../../../../../../../docs/CLI%20Style%20Guide.md#interactivity):
122
- *
123
- * - `flags.interactive` governs *decoration* (TerminalUI, intro/outro,
124
- * spinners) and is derived from stdout-TTY by `parseGlobalFlags`,
125
- * honouring `--interactive` / `--no-interactive`.
126
- * - Prompting additionally requires a stdin TTY — closing stdin is a
127
- * common signal in CI / agent environments even when stdout stays
128
- * attached.
129
- * - `--interactive` is the explicit override: when the user passes it,
130
- * we honour it (e.g. testing flows where stdin is stubbed).
131
- *
132
- * Exported so callers and tests can derive the same value without
133
- * touching `process` globals.
134
- */
135
- export function deriveCanPrompt(opts: {
136
- readonly flagsInteractive: boolean | undefined;
137
- readonly optionInteractive: boolean | undefined;
138
- readonly stdinIsTTY: boolean;
139
- }): boolean {
140
- if (opts.optionInteractive === true) return true;
141
- if (opts.flagsInteractive === false) return false;
142
- return opts.stdinIsTTY;
143
- }
@@ -113,11 +113,6 @@ export async function runInit(
113
113
  * mode) — see [Style Guide § Interactivity](../../../../../../../docs/CLI%20Style%20Guide.md#interactivity).
114
114
  */
115
115
  readonly canPrompt: boolean;
116
- /**
117
- * Called once after the first affirmative telemetry consent is persisted.
118
- * Failures are swallowed by the caller; init success must not depend on telemetry.
119
- */
120
- readonly afterFirstTelemetryConsent?: (inputs: ResolvedInitInputs) => void | Promise<void>;
121
116
  /**
122
117
  * FR8.3 — test-only seam for the optional database version probe.
123
118
  * Production callers omit this; tests inject stub `probePostgres` /
@@ -129,7 +124,7 @@ export async function runInit(
129
124
  readonly probeOverrides?: ProbeOverrides;
130
125
  },
131
126
  ): Promise<number> {
132
- const { options, flags, canPrompt, probeOverrides, afterFirstTelemetryConsent } = runOptions;
127
+ const { options, flags, canPrompt, probeOverrides } = runOptions;
133
128
  const ui = createTerminalUI(flags);
134
129
  const warnings: string[] = [];
135
130
  const filesWritten: string[] = [];
@@ -149,14 +144,6 @@ export async function runInit(
149
144
  throw error;
150
145
  }
151
146
 
152
- if (inputs.enableTelemetry === true && afterFirstTelemetryConsent !== undefined) {
153
- try {
154
- await afterFirstTelemetryConsent(inputs);
155
- } catch {
156
- // telemetry is best-effort and must never affect init
157
- }
158
- }
159
-
160
147
  const pm = await detectPackageManager(baseDir);
161
148
  const pkgRun = formatRunCommand(pm, 'prisma-next', '').trimEnd();
162
149
 
@@ -1,9 +1,7 @@
1
1
  import { existsSync, readFileSync } from 'node:fs';
2
2
  import * as clack from '@clack/prompts';
3
- import { readUserConfig, resolveGating, writeUserConfig } from '@prisma-next/cli-telemetry';
4
3
  import { extname, join, normalize } from 'pathe';
5
4
  import type { GlobalFlags } from '../../utils/global-flags';
6
- import { isCI } from '../../utils/is-ci';
7
5
  import {
8
6
  errorInitAuthoringSchemaPathMismatch,
9
7
  errorInitInvalidFlagValue,
@@ -71,18 +69,6 @@ export interface ResolvedInitInputs {
71
69
  * is added separately via the install step.
72
70
  */
73
71
  readonly removePreviousFacade: string | null;
74
- /**
75
- * Telemetry consent answer recorded during this `init` run, or `null`
76
- * when no prompt was shown. The prompt fires only on the
77
- * canPrompt + !autoAcceptPrompts + no env/CI opt-out +
78
- * `enableTelemetry === undefined` intersection; outside that window
79
- * the field is `null` and the stored preference (if any) stays
80
- * unchanged. The answer has already been persisted to
81
- * `$XDG_CONFIG_HOME/prisma-next/config.json` by
82
- * the time `runInit` sees this value — it's surfaced here purely so
83
- * the post-init summary can mention what the user chose.
84
- */
85
- readonly enableTelemetry: boolean | null;
86
72
  /**
87
73
  * Whether to run `npx skills add prisma/prisma-next#v<version>` at the
88
74
  * project level after install + emit. True by default; `--no-skill`
@@ -106,12 +92,6 @@ const AUTHORING_VALUES: ReadonlyMap<string, AuthoringId> = new Map([
106
92
  ['ts', 'typescript'],
107
93
  ]);
108
94
 
109
- export const TELEMETRY_CONSENT_MESSAGE = [
110
- 'Help us prioritize features by sharing anonymous CLI usage data?',
111
- 'The telemetry implementation is open source and fully transparent.',
112
- '(packages/1-framework/3-tooling/cli-telemetry and apps/telemetry-backend).',
113
- ].join(' ');
114
-
115
95
  /**
116
96
  * Resolves every required input for `runInit`. In interactive mode, missing
117
97
  * inputs are prompted via clack; in non-interactive mode, missing required
@@ -197,11 +177,6 @@ export async function resolveInitInputs(ctx: {
197
177
  autoAcceptPrompts,
198
178
  });
199
179
 
200
- const enableTelemetry = await resolveTelemetryConsent({
201
- canPrompt,
202
- autoAcceptPrompts,
203
- });
204
-
205
180
  // Skill-install gating. `--no-skill` (commander parses
206
181
  // `options.skill === false`) is the only escape hatch; otherwise
207
182
  // project-level install is unconditional. The skill is always
@@ -219,60 +194,10 @@ export async function resolveInitInputs(ctx: {
219
194
  strictProbe: Boolean(options.strictProbe),
220
195
  reinit,
221
196
  removePreviousFacade,
222
- enableTelemetry,
223
197
  installProjectSkill,
224
198
  };
225
199
  }
226
200
 
227
- /**
228
- * The interactive telemetry consent prompt. Shown as the last
229
- * question of the `init` sequence iff:
230
- * 1. `canPrompt === true` (interactive stdin / stdout combo),
231
- * 2. `autoAcceptPrompts === false` (the user did not pass `--yes`),
232
- * 3. neither telemetry env opt-out is active,
233
- * 4. the process is not running in CI,
234
- * 5. the stored `enableTelemetry` value is `undefined` (the user
235
- * has never been asked, or skipped the prompt previously).
236
- *
237
- * Outside that intersection the function returns `null` and leaves the
238
- * stored preference untouched. Inside it, the user's answer is
239
- * persisted via `writeUserConfig({ enableTelemetry })` before this
240
- * function returns; on an affirmative answer `writeUserConfig`
241
- * generates and stores the v4 `installationId` in the same write.
242
- *
243
- * The wording names CLI usage data and points to the open-source
244
- * client/backend paths. Default value is `true` to match precedent
245
- * and to make the consent answer a single keystroke once it's been
246
- * disclosed.
247
- */
248
- async function resolveTelemetryConsent(opts: {
249
- readonly canPrompt: boolean;
250
- readonly autoAcceptPrompts: boolean;
251
- }): Promise<boolean | null> {
252
- if (!opts.canPrompt || opts.autoAcceptPrompts || isCI()) {
253
- return null;
254
- }
255
- const config = readUserConfig();
256
- const gating = resolveGating({ env: process.env, config });
257
- if (!gating.enabled && gating.reason === 'env-override') {
258
- return null;
259
- }
260
- const stored = config.enableTelemetry;
261
- if (stored !== undefined) {
262
- return null;
263
- }
264
- const result = await clack.confirm({
265
- message: TELEMETRY_CONSENT_MESSAGE,
266
- initialValue: true,
267
- output: process.stderr,
268
- });
269
- if (clack.isCancel(result)) {
270
- throw errorInitUserAborted();
271
- }
272
- writeUserConfig({ enableTelemetry: Boolean(result) });
273
- return Boolean(result);
274
- }
275
-
276
201
  async function resolveWriteEnv(opts: {
277
202
  readonly flag: boolean | undefined;
278
203
  readonly canPrompt: boolean;
@@ -1,3 +1,4 @@
1
+ import type { AuthoringPslBlockDescriptorNamespace } from '@prisma-next/framework-components/authoring';
1
2
  import type { CoreSchemaView } from '@prisma-next/framework-components/control';
2
3
  import type { PslDocumentAst } from '@prisma-next/framework-components/psl-ast';
3
4
  import { notOk, ok, type Result } from '@prisma-next/utils/result';
@@ -39,6 +40,13 @@ export interface InspectLiveSchemaResult {
39
40
  * support inference (e.g. Mongo today).
40
41
  */
41
42
  readonly pslContractAst: PslDocumentAst | undefined;
43
+ /**
44
+ * The assembled PSL block descriptors from the control stack — the full set of
45
+ * extension-contributed top-level block descriptors. Downstream commands pass
46
+ * this through to `printPsl` so contributed-block AST nodes round-trip back to
47
+ * source.
48
+ */
49
+ readonly pslBlockDescriptors: AuthoringPslBlockDescriptorNamespace;
42
50
  readonly target: {
43
51
  readonly familyId: string;
44
52
  readonly id: string;
@@ -134,6 +142,7 @@ export async function inspectLiveSchema(
134
142
  });
135
143
  const schemaView = client.toSchemaView(schema);
136
144
  const pslContractAst = client.inferPslContract(schema);
145
+ const pslBlockDescriptors = client.getPslBlockDescriptors();
137
146
 
138
147
  const dbUrl = typeof dbConnection === 'string' ? maskConnectionUrl(dbConnection) : undefined;
139
148
 
@@ -142,6 +151,7 @@ export async function inspectLiveSchema(
142
151
  schema,
143
152
  schemaView,
144
153
  pslContractAst,
154
+ pslBlockDescriptors,
145
155
  target: {
146
156
  familyId: config.family.familyId,
147
157
  id: config.target.targetId,
@@ -0,0 +1,195 @@
1
+ import { type } from 'arktype';
2
+
3
+ export const migrationEntrySchema = type({
4
+ name: 'string',
5
+ hash: 'string',
6
+ fromContract: 'string | null',
7
+ toContract: 'string',
8
+ operationCount: 'number',
9
+ createdAt: 'string',
10
+ refs: 'string[]',
11
+ providedInvariants: 'string[]',
12
+ });
13
+
14
+ export type MigrationEntry = typeof migrationEntrySchema.infer;
15
+
16
+ export const contractRefSchema = type({
17
+ hash: 'string',
18
+ refs: 'string[]',
19
+ });
20
+
21
+ export type ContractRef = typeof contractRefSchema.infer;
22
+
23
+ export const successEnvelopeBaseSchema = type({
24
+ ok: 'true',
25
+ summary: 'string',
26
+ });
27
+
28
+ export type SuccessEnvelopeBase = typeof successEnvelopeBaseSchema.infer;
29
+
30
+ export const migrationSpaceListEntrySchema = type({
31
+ space: 'string',
32
+ migrations: migrationEntrySchema.array(),
33
+ });
34
+
35
+ export type MigrationSpaceListEntry = typeof migrationSpaceListEntrySchema.infer;
36
+
37
+ export const migrationListResultSchema = successEnvelopeBaseSchema.and(
38
+ type({
39
+ spaces: migrationSpaceListEntrySchema.array(),
40
+ }),
41
+ );
42
+
43
+ export type MigrationListResult = typeof migrationListResultSchema.infer;
44
+
45
+ export const graphMigrationSchema = type({
46
+ name: 'string',
47
+ hash: 'string',
48
+ fromContract: 'string | null',
49
+ toContract: 'string',
50
+ });
51
+
52
+ export type GraphMigration = typeof graphMigrationSchema.infer;
53
+
54
+ export const migrationSpaceGraphEntrySchema = type({
55
+ space: 'string',
56
+ contracts: contractRefSchema.array(),
57
+ migrations: graphMigrationSchema.array(),
58
+ });
59
+
60
+ export type MigrationSpaceGraphEntry = typeof migrationSpaceGraphEntrySchema.infer;
61
+
62
+ export const migrationGraphJsonResultSchema = successEnvelopeBaseSchema.and(
63
+ type({
64
+ spaces: migrationSpaceGraphEntrySchema.array(),
65
+ }),
66
+ );
67
+
68
+ export type MigrationGraphJsonResult = typeof migrationGraphJsonResultSchema.infer;
69
+
70
+ export const migrationStatusEntrySchema = migrationEntrySchema.and(
71
+ type({
72
+ status: '"applied" | "pending" | null',
73
+ }),
74
+ );
75
+
76
+ export type MigrationStatusEntry = typeof migrationStatusEntrySchema.infer;
77
+
78
+ const contractUnreadableDiagnosticSchema = type({
79
+ code: '"CONTRACT.UNREADABLE"',
80
+ severity: '"warn" | "info"',
81
+ message: 'string',
82
+ hints: 'string[]',
83
+ });
84
+
85
+ const markerNotInHistoryDiagnosticSchema = type({
86
+ code: '"MIGRATION.MARKER_NOT_IN_HISTORY"',
87
+ severity: '"warn" | "info"',
88
+ message: 'string',
89
+ hints: 'string[]',
90
+ });
91
+
92
+ const missingInvariantsDiagnosticSchema = type({
93
+ code: '"MIGRATION.MISSING_INVARIANTS"',
94
+ 'ref?': 'string',
95
+ invariants: 'string[]',
96
+ message: 'string',
97
+ });
98
+
99
+ export const statusDiagnosticSchema = contractUnreadableDiagnosticSchema
100
+ .or(markerNotInHistoryDiagnosticSchema)
101
+ .or(missingInvariantsDiagnosticSchema);
102
+
103
+ export type StatusDiagnosticJson = typeof statusDiagnosticSchema.infer;
104
+
105
+ export const migrationStatusSpaceSchema = type({
106
+ space: 'string',
107
+ currentContract: 'string | null',
108
+ targetContract: 'string',
109
+ migrations: migrationStatusEntrySchema.array(),
110
+ });
111
+
112
+ export type MigrationStatusSpace = typeof migrationStatusSpaceSchema.infer;
113
+
114
+ export const migrationStatusJsonResultSchema = successEnvelopeBaseSchema.and(
115
+ type({
116
+ spaces: migrationStatusSpaceSchema.array(),
117
+ diagnostics: statusDiagnosticSchema.array(),
118
+ }),
119
+ );
120
+
121
+ export type MigrationStatusResult = typeof migrationStatusJsonResultSchema.infer;
122
+
123
+ export const ledgerRecordSchema = type({
124
+ space: 'string',
125
+ name: 'string',
126
+ hash: 'string',
127
+ fromContract: 'string | null',
128
+ toContract: 'string',
129
+ appliedAt: 'string',
130
+ operationCount: 'number',
131
+ });
132
+
133
+ export type LedgerRecord = typeof ledgerRecordSchema.infer;
134
+
135
+ export const migrationLogResultSchema = successEnvelopeBaseSchema.and(
136
+ type({
137
+ records: ledgerRecordSchema.array(),
138
+ }),
139
+ );
140
+
141
+ export type MigrationLogResult = typeof migrationLogResultSchema.infer;
142
+
143
+ export const showOperationSchema = type({
144
+ id: 'string',
145
+ label: 'string',
146
+ operationClass: 'string',
147
+ });
148
+
149
+ export type ShowOperation = typeof showOperationSchema.infer;
150
+
151
+ export const showPreviewStatementSchema = type({
152
+ text: 'string',
153
+ language: 'string',
154
+ });
155
+
156
+ export const showMigrationSchema = type({
157
+ space: 'string',
158
+ name: 'string',
159
+ hash: 'string',
160
+ fromContract: 'string | null',
161
+ toContract: 'string',
162
+ createdAt: 'string',
163
+ operations: showOperationSchema.array(),
164
+ preview: type({
165
+ statements: showPreviewStatementSchema.array(),
166
+ }),
167
+ });
168
+
169
+ export type ShowMigration = typeof showMigrationSchema.infer;
170
+
171
+ export const migrationShowResultSchema = successEnvelopeBaseSchema.and(
172
+ type({
173
+ migration: showMigrationSchema,
174
+ }),
175
+ );
176
+
177
+ export type MigrationShowResult = typeof migrationShowResultSchema.infer;
178
+
179
+ export const checkFailureSchema = type({
180
+ space: 'string',
181
+ code: 'string',
182
+ where: 'string',
183
+ why: 'string',
184
+ fix: 'string',
185
+ });
186
+
187
+ export type CheckFailure = typeof checkFailureSchema.infer;
188
+
189
+ export const migrationCheckResultSchema = type({
190
+ ok: 'boolean',
191
+ failures: checkFailureSchema.array(),
192
+ summary: 'string',
193
+ });
194
+
195
+ export type MigrationCheckResult = typeof migrationCheckResultSchema.infer;