@prisma-next/cli 0.3.0-dev.15 → 0.3.0-dev.162

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 (236) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +381 -128
  3. package/dist/cli-errors-BDCYR5ap.mjs +4 -0
  4. package/dist/cli-errors-Dzs7Oxz7.d.mts +3 -0
  5. package/dist/cli.d.mts +1 -0
  6. package/dist/cli.js +1 -2346
  7. package/dist/cli.mjs +245 -0
  8. package/dist/cli.mjs.map +1 -0
  9. package/dist/client-yYtotiSX.mjs +1063 -0
  10. package/dist/client-yYtotiSX.mjs.map +1 -0
  11. package/dist/commands/contract-emit.d.mts +7 -0
  12. package/dist/commands/contract-emit.d.mts.map +1 -0
  13. package/dist/commands/contract-emit.mjs +8 -0
  14. package/dist/commands/contract-infer.d.mts +7 -0
  15. package/dist/commands/contract-infer.d.mts.map +1 -0
  16. package/dist/commands/contract-infer.mjs +9 -0
  17. package/dist/commands/db-init.d.mts +7 -0
  18. package/dist/commands/db-init.d.mts.map +1 -0
  19. package/dist/commands/db-init.mjs +125 -0
  20. package/dist/commands/db-init.mjs.map +1 -0
  21. package/dist/commands/db-schema.d.mts +7 -0
  22. package/dist/commands/db-schema.d.mts.map +1 -0
  23. package/dist/commands/db-schema.mjs +55 -0
  24. package/dist/commands/db-schema.mjs.map +1 -0
  25. package/dist/commands/db-sign.d.mts +7 -0
  26. package/dist/commands/db-sign.d.mts.map +1 -0
  27. package/dist/commands/db-sign.mjs +136 -0
  28. package/dist/commands/db-sign.mjs.map +1 -0
  29. package/dist/commands/db-update.d.mts +7 -0
  30. package/dist/commands/db-update.d.mts.map +1 -0
  31. package/dist/commands/db-update.mjs +122 -0
  32. package/dist/commands/db-update.mjs.map +1 -0
  33. package/dist/commands/db-verify.d.mts +7 -0
  34. package/dist/commands/db-verify.d.mts.map +1 -0
  35. package/dist/commands/db-verify.mjs +322 -0
  36. package/dist/commands/db-verify.mjs.map +1 -0
  37. package/dist/commands/migration-apply.d.mts +36 -0
  38. package/dist/commands/migration-apply.d.mts.map +1 -0
  39. package/dist/commands/migration-apply.mjs +244 -0
  40. package/dist/commands/migration-apply.mjs.map +1 -0
  41. package/dist/commands/migration-new.d.mts +8 -0
  42. package/dist/commands/migration-new.d.mts.map +1 -0
  43. package/dist/commands/migration-new.mjs +151 -0
  44. package/dist/commands/migration-new.mjs.map +1 -0
  45. package/dist/commands/migration-plan.d.mts +47 -0
  46. package/dist/commands/migration-plan.d.mts.map +1 -0
  47. package/dist/commands/migration-plan.mjs +312 -0
  48. package/dist/commands/migration-plan.mjs.map +1 -0
  49. package/dist/commands/migration-ref.d.mts +43 -0
  50. package/dist/commands/migration-ref.d.mts.map +1 -0
  51. package/dist/commands/migration-ref.mjs +194 -0
  52. package/dist/commands/migration-ref.mjs.map +1 -0
  53. package/dist/commands/migration-show.d.mts +28 -0
  54. package/dist/commands/migration-show.d.mts.map +1 -0
  55. package/dist/commands/migration-show.mjs +139 -0
  56. package/dist/commands/migration-show.mjs.map +1 -0
  57. package/dist/commands/migration-status.d.mts +86 -0
  58. package/dist/commands/migration-status.d.mts.map +1 -0
  59. package/dist/commands/migration-status.mjs +8 -0
  60. package/dist/commands/migration-verify.d.mts +16 -0
  61. package/dist/commands/migration-verify.d.mts.map +1 -0
  62. package/dist/commands/migration-verify.mjs +109 -0
  63. package/dist/commands/migration-verify.mjs.map +1 -0
  64. package/dist/config-loader-C4VXKl8f.mjs +43 -0
  65. package/dist/config-loader-C4VXKl8f.mjs.map +1 -0
  66. package/dist/{config-loader.d.ts → config-loader.d.mts} +8 -3
  67. package/dist/config-loader.d.mts.map +1 -0
  68. package/dist/config-loader.mjs +3 -0
  69. package/dist/contract-emit-Bk_eEDKu.mjs +187 -0
  70. package/dist/contract-emit-Bk_eEDKu.mjs.map +1 -0
  71. package/dist/contract-infer-suMDmFSG.mjs +89 -0
  72. package/dist/contract-infer-suMDmFSG.mjs.map +1 -0
  73. package/dist/exports/config-types.d.mts +2 -0
  74. package/dist/exports/config-types.mjs +3 -0
  75. package/dist/exports/control-api.d.mts +624 -0
  76. package/dist/exports/control-api.d.mts.map +1 -0
  77. package/dist/exports/control-api.mjs +109 -0
  78. package/dist/exports/control-api.mjs.map +1 -0
  79. package/dist/{load-ts-contract.d.ts → exports/index.d.mts} +12 -7
  80. package/dist/exports/index.d.mts.map +1 -0
  81. package/dist/exports/index.mjs +141 -0
  82. package/dist/exports/index.mjs.map +1 -0
  83. package/dist/extract-operation-statements-BVlb3jxp.mjs +13 -0
  84. package/dist/extract-operation-statements-BVlb3jxp.mjs.map +1 -0
  85. package/dist/extract-sql-ddl-6EVSOThm.mjs +26 -0
  86. package/dist/extract-sql-ddl-6EVSOThm.mjs.map +1 -0
  87. package/dist/framework-components-BAsliT4V.mjs +59 -0
  88. package/dist/framework-components-BAsliT4V.mjs.map +1 -0
  89. package/dist/inspect-live-schema-HMutsJYh.mjs +91 -0
  90. package/dist/inspect-live-schema-HMutsJYh.mjs.map +1 -0
  91. package/dist/migration-command-scaffold-Dg7CKKCg.mjs +105 -0
  92. package/dist/migration-command-scaffold-Dg7CKKCg.mjs.map +1 -0
  93. package/dist/migration-status-BqfVmC0w.mjs +1582 -0
  94. package/dist/migration-status-BqfVmC0w.mjs.map +1 -0
  95. package/dist/migrations-Bv8oeiY_.mjs +173 -0
  96. package/dist/migrations-Bv8oeiY_.mjs.map +1 -0
  97. package/dist/progress-adapter-D4x8SbJa.mjs +43 -0
  98. package/dist/progress-adapter-D4x8SbJa.mjs.map +1 -0
  99. package/dist/terminal-ui-N5tR-ob5.mjs +967 -0
  100. package/dist/terminal-ui-N5tR-ob5.mjs.map +1 -0
  101. package/dist/verify-WARh5TjK.mjs +385 -0
  102. package/dist/verify-WARh5TjK.mjs.map +1 -0
  103. package/package.json +87 -41
  104. package/src/cli.ts +113 -58
  105. package/src/commands/contract-emit.ts +237 -144
  106. package/src/commands/contract-infer-paths.ts +32 -0
  107. package/src/commands/contract-infer.ts +143 -0
  108. package/src/commands/db-init.ts +211 -426
  109. package/src/commands/db-schema.ts +77 -0
  110. package/src/commands/db-sign.ts +208 -229
  111. package/src/commands/db-update.ts +236 -0
  112. package/src/commands/db-verify.ts +504 -184
  113. package/src/commands/inspect-live-schema.ts +170 -0
  114. package/src/commands/migration-apply.ts +427 -0
  115. package/src/commands/migration-new.ts +260 -0
  116. package/src/commands/migration-plan.ts +519 -0
  117. package/src/commands/migration-ref.ts +305 -0
  118. package/src/commands/migration-show.ts +246 -0
  119. package/src/commands/migration-status.ts +864 -0
  120. package/src/commands/migration-verify.ts +180 -0
  121. package/src/config-loader.ts +13 -3
  122. package/src/control-api/client.ts +428 -46
  123. package/src/control-api/contract-enrichment.ts +119 -0
  124. package/src/control-api/errors.ts +9 -0
  125. package/src/control-api/operations/contract-emit.ts +174 -0
  126. package/src/control-api/operations/db-init.ts +144 -26
  127. package/src/control-api/operations/db-update.ts +220 -0
  128. package/src/control-api/operations/extract-operation-statements.ts +14 -0
  129. package/src/control-api/operations/extract-sql-ddl.ts +47 -0
  130. package/src/control-api/operations/migration-apply.ts +191 -0
  131. package/src/control-api/operations/migration-helpers.ts +49 -0
  132. package/src/control-api/types.ts +450 -18
  133. package/src/exports/config-types.ts +4 -3
  134. package/src/exports/control-api.ts +24 -2
  135. package/src/load-ts-contract.ts +30 -19
  136. package/src/utils/cli-errors.ts +14 -8
  137. package/src/utils/command-helpers.ts +302 -3
  138. package/src/utils/formatters/emit.ts +67 -0
  139. package/src/utils/formatters/errors.ts +82 -0
  140. package/src/utils/formatters/graph-migration-mapper.ts +240 -0
  141. package/src/utils/formatters/graph-render.ts +1323 -0
  142. package/src/utils/formatters/graph-types.ts +120 -0
  143. package/src/utils/formatters/help.ts +380 -0
  144. package/src/utils/formatters/helpers.ts +28 -0
  145. package/src/utils/formatters/migrations.ts +346 -0
  146. package/src/utils/formatters/styled.ts +212 -0
  147. package/src/utils/formatters/verify.ts +621 -0
  148. package/src/utils/framework-components.ts +13 -10
  149. package/src/utils/global-flags.ts +41 -23
  150. package/src/utils/migration-command-scaffold.ts +184 -0
  151. package/src/utils/migration-types.ts +12 -0
  152. package/src/utils/progress-adapter.ts +75 -0
  153. package/src/utils/result-handler.ts +12 -13
  154. package/src/utils/shutdown.ts +92 -0
  155. package/src/utils/suggest-command.ts +31 -0
  156. package/src/utils/terminal-ui.ts +276 -0
  157. package/dist/chunk-6EPKRATC.js +0 -91
  158. package/dist/chunk-6EPKRATC.js.map +0 -1
  159. package/dist/chunk-DIJPT5TZ.js +0 -967
  160. package/dist/chunk-DIJPT5TZ.js.map +0 -1
  161. package/dist/chunk-HWYQOCAJ.js +0 -47
  162. package/dist/chunk-HWYQOCAJ.js.map +0 -1
  163. package/dist/chunk-MG7PBERL.js +0 -131
  164. package/dist/chunk-MG7PBERL.js.map +0 -1
  165. package/dist/chunk-VI2YETW7.js +0 -38
  166. package/dist/chunk-VI2YETW7.js.map +0 -1
  167. package/dist/cli.d.ts +0 -2
  168. package/dist/cli.d.ts.map +0 -1
  169. package/dist/cli.js.map +0 -1
  170. package/dist/commands/contract-emit.d.ts +0 -3
  171. package/dist/commands/contract-emit.d.ts.map +0 -1
  172. package/dist/commands/contract-emit.js +0 -10
  173. package/dist/commands/contract-emit.js.map +0 -1
  174. package/dist/commands/db-init.d.ts +0 -3
  175. package/dist/commands/db-init.d.ts.map +0 -1
  176. package/dist/commands/db-init.js +0 -339
  177. package/dist/commands/db-init.js.map +0 -1
  178. package/dist/commands/db-introspect.d.ts +0 -3
  179. package/dist/commands/db-introspect.d.ts.map +0 -1
  180. package/dist/commands/db-introspect.js +0 -183
  181. package/dist/commands/db-introspect.js.map +0 -1
  182. package/dist/commands/db-schema-verify.d.ts +0 -3
  183. package/dist/commands/db-schema-verify.d.ts.map +0 -1
  184. package/dist/commands/db-schema-verify.js +0 -161
  185. package/dist/commands/db-schema-verify.js.map +0 -1
  186. package/dist/commands/db-sign.d.ts +0 -3
  187. package/dist/commands/db-sign.d.ts.map +0 -1
  188. package/dist/commands/db-sign.js +0 -196
  189. package/dist/commands/db-sign.js.map +0 -1
  190. package/dist/commands/db-verify.d.ts +0 -3
  191. package/dist/commands/db-verify.d.ts.map +0 -1
  192. package/dist/commands/db-verify.js +0 -170
  193. package/dist/commands/db-verify.js.map +0 -1
  194. package/dist/config-loader.d.ts.map +0 -1
  195. package/dist/config-loader.js +0 -7
  196. package/dist/config-loader.js.map +0 -1
  197. package/dist/control-api/client.d.ts +0 -13
  198. package/dist/control-api/client.d.ts.map +0 -1
  199. package/dist/control-api/operations/db-init.d.ts +0 -27
  200. package/dist/control-api/operations/db-init.d.ts.map +0 -1
  201. package/dist/control-api/types.d.ts +0 -203
  202. package/dist/control-api/types.d.ts.map +0 -1
  203. package/dist/exports/config-types.d.ts +0 -3
  204. package/dist/exports/config-types.d.ts.map +0 -1
  205. package/dist/exports/config-types.js +0 -6
  206. package/dist/exports/config-types.js.map +0 -1
  207. package/dist/exports/control-api.d.ts +0 -13
  208. package/dist/exports/control-api.d.ts.map +0 -1
  209. package/dist/exports/control-api.js +0 -240
  210. package/dist/exports/control-api.js.map +0 -1
  211. package/dist/exports/index.d.ts +0 -4
  212. package/dist/exports/index.d.ts.map +0 -1
  213. package/dist/exports/index.js +0 -176
  214. package/dist/exports/index.js.map +0 -1
  215. package/dist/load-ts-contract.d.ts.map +0 -1
  216. package/dist/utils/action.d.ts +0 -16
  217. package/dist/utils/action.d.ts.map +0 -1
  218. package/dist/utils/cli-errors.d.ts +0 -7
  219. package/dist/utils/cli-errors.d.ts.map +0 -1
  220. package/dist/utils/command-helpers.d.ts +0 -12
  221. package/dist/utils/command-helpers.d.ts.map +0 -1
  222. package/dist/utils/framework-components.d.ts +0 -70
  223. package/dist/utils/framework-components.d.ts.map +0 -1
  224. package/dist/utils/global-flags.d.ts +0 -25
  225. package/dist/utils/global-flags.d.ts.map +0 -1
  226. package/dist/utils/output.d.ts +0 -142
  227. package/dist/utils/output.d.ts.map +0 -1
  228. package/dist/utils/result-handler.d.ts +0 -15
  229. package/dist/utils/result-handler.d.ts.map +0 -1
  230. package/dist/utils/spinner.d.ts +0 -29
  231. package/dist/utils/spinner.d.ts.map +0 -1
  232. package/src/commands/db-introspect.ts +0 -254
  233. package/src/commands/db-schema-verify.ts +0 -231
  234. package/src/utils/action.ts +0 -43
  235. package/src/utils/output.ts +0 -1471
  236. package/src/utils/spinner.ts +0 -67
@@ -1,14 +1,21 @@
1
+ import type {
2
+ ContractSourceDiagnostics,
3
+ ContractSourceProvider,
4
+ } from '@prisma-next/config/config-types';
5
+ import type { Contract, ContractMarkerRecord } from '@prisma-next/contract/types';
1
6
  import type {
2
7
  ControlAdapterDescriptor,
3
8
  ControlDriverDescriptor,
4
9
  ControlExtensionDescriptor,
5
10
  ControlFamilyDescriptor,
6
11
  ControlTargetDescriptor,
12
+ CoreSchemaView,
7
13
  MigrationPlannerConflict,
14
+ MigrationPlanOperation,
8
15
  SignDatabaseResult,
9
16
  VerifyDatabaseResult,
10
17
  VerifyDatabaseSchemaResult,
11
- } from '@prisma-next/core-control-plane/types';
18
+ } from '@prisma-next/framework-components/control';
12
19
  import type { Result } from '@prisma-next/utils/result';
13
20
 
14
21
  // ============================================================================
@@ -30,7 +37,7 @@ export interface ControlClientOptions {
30
37
  // biome-ignore lint/suspicious/noExplicitAny: required for contravariance - SqlFamilyDescriptor.create has specific parameter types
31
38
  readonly family: ControlFamilyDescriptor<any, any>;
32
39
  // biome-ignore lint/suspicious/noExplicitAny: required for contravariance - SqlControlTargetDescriptor extends with additional methods
33
- readonly target: ControlTargetDescriptor<any, any, any, any>;
40
+ readonly target: ControlTargetDescriptor<any, any, any>;
34
41
  // biome-ignore lint/suspicious/noExplicitAny: required for contravariance in adapter.create()
35
42
  readonly adapter: ControlAdapterDescriptor<any, any, any>;
36
43
  /** Optional - control client can be created without driver for offline operations */
@@ -46,6 +53,58 @@ export interface ControlClientOptions {
46
53
  readonly connection?: unknown;
47
54
  }
48
55
 
56
+ // ============================================================================
57
+ // Progress Events
58
+ // ============================================================================
59
+
60
+ /**
61
+ * Action names for control-api operations that can emit progress events.
62
+ */
63
+ export type ControlActionName =
64
+ | 'dbInit'
65
+ | 'dbUpdate'
66
+ | 'migrationApply'
67
+ | 'verify'
68
+ | 'schemaVerify'
69
+ | 'sign'
70
+ | 'introspect'
71
+ | 'emit';
72
+
73
+ /**
74
+ * Progress event emitted during control-api operation execution.
75
+ *
76
+ * Events model operation progress using a span-based model:
77
+ * - `spanStart`: Begin a timed segment (supports nesting via parentSpanId)
78
+ * - `spanEnd`: Complete a timed segment
79
+ *
80
+ * All operation-specific progress (e.g., per-migration-operation) is modeled
81
+ * as nested spans rather than special event types.
82
+ *
83
+ * Events are delivered via an optional `onProgress` callback to avoid polluting
84
+ * return types. If the callback is absent, operations emit no events (zero overhead).
85
+ */
86
+ export type ControlProgressEvent =
87
+ | {
88
+ readonly action: ControlActionName;
89
+ readonly kind: 'spanStart';
90
+ readonly spanId: string;
91
+ readonly parentSpanId?: string;
92
+ readonly label: string;
93
+ }
94
+ | {
95
+ readonly action: ControlActionName;
96
+ readonly kind: 'spanEnd';
97
+ readonly spanId: string;
98
+ readonly outcome: 'ok' | 'skipped' | 'error';
99
+ };
100
+
101
+ /**
102
+ * Callback function for receiving progress events during control-api operations.
103
+ *
104
+ * @param event - The progress event emitted by the operation
105
+ */
106
+ export type OnControlProgress = (event: ControlProgressEvent) => void;
107
+
49
108
  // ============================================================================
50
109
  // Operation Options
51
110
  // ============================================================================
@@ -54,44 +113,114 @@ export interface ControlClientOptions {
54
113
  * Options for the verify operation.
55
114
  */
56
115
  export interface VerifyOptions {
57
- /** Contract IR or unvalidated JSON - validated at runtime via familyInstance.validateContractIR() */
58
- readonly contractIR: unknown;
116
+ /** Contract or unvalidated JSON - validated at runtime via familyInstance.validateContract() */
117
+ readonly contract: unknown;
118
+ /**
119
+ * Database connection. If provided, verify will connect before executing.
120
+ * If omitted, the client must already be connected.
121
+ * The type is driver-specific (e.g., string URL for Postgres).
122
+ */
123
+ readonly connection?: unknown;
124
+ /** Optional progress callback for observing operation progress */
125
+ readonly onProgress?: OnControlProgress;
59
126
  }
60
127
 
61
128
  /**
62
129
  * Options for the schemaVerify operation.
63
130
  */
64
131
  export interface SchemaVerifyOptions {
65
- /** Contract IR or unvalidated JSON - validated at runtime via familyInstance.validateContractIR() */
66
- readonly contractIR: unknown;
132
+ /** Contract or unvalidated JSON - validated at runtime via familyInstance.validateContract() */
133
+ readonly contract: unknown;
67
134
  /**
68
135
  * Whether to use strict mode for schema verification.
69
136
  * In strict mode, extra tables/columns are reported as issues.
70
137
  * Default: false (tolerant mode - allows superset)
71
138
  */
72
139
  readonly strict?: boolean;
140
+ /**
141
+ * Database connection. If provided, schemaVerify will connect before executing.
142
+ * If omitted, the client must already be connected.
143
+ * The type is driver-specific (e.g., string URL for Postgres).
144
+ */
145
+ readonly connection?: unknown;
146
+ /** Optional progress callback for observing operation progress */
147
+ readonly onProgress?: OnControlProgress;
73
148
  }
74
149
 
75
150
  /**
76
151
  * Options for the sign operation.
77
152
  */
78
153
  export interface SignOptions {
79
- /** Contract IR or unvalidated JSON - validated at runtime via familyInstance.validateContractIR() */
80
- readonly contractIR: unknown;
154
+ /** Contract or unvalidated JSON - validated at runtime via familyInstance.validateContract() */
155
+ readonly contract: unknown;
156
+ /**
157
+ * Path to the contract file (for metadata in the result).
158
+ */
159
+ readonly contractPath?: string;
160
+ /**
161
+ * Path to the config file (for metadata in the result).
162
+ */
163
+ readonly configPath?: string;
164
+ /**
165
+ * Database connection. If provided, sign will connect before executing.
166
+ * If omitted, the client must already be connected.
167
+ * The type is driver-specific (e.g., string URL for Postgres).
168
+ */
169
+ readonly connection?: unknown;
170
+ /** Optional progress callback for observing operation progress */
171
+ readonly onProgress?: OnControlProgress;
81
172
  }
82
173
 
83
174
  /**
84
175
  * Options for the dbInit operation.
85
176
  */
86
177
  export interface DbInitOptions {
87
- /** Contract IR or unvalidated JSON - validated at runtime via familyInstance.validateContractIR() */
88
- readonly contractIR: unknown;
178
+ /** Contract or unvalidated JSON - validated at runtime via familyInstance.validateContract() */
179
+ readonly contract: unknown;
89
180
  /**
90
181
  * Mode for the dbInit operation.
91
182
  * - 'plan': Returns planned operations without applying
92
183
  * - 'apply': Applies operations and writes marker
93
184
  */
94
185
  readonly mode: 'plan' | 'apply';
186
+ /**
187
+ * Database connection. If provided, dbInit will connect before executing.
188
+ * If omitted, the client must already be connected.
189
+ * The type is driver-specific (e.g., string URL for Postgres).
190
+ */
191
+ readonly connection?: unknown;
192
+ /** Optional progress callback for observing operation progress */
193
+ readonly onProgress?: OnControlProgress;
194
+ }
195
+
196
+ /**
197
+ * Options for the dbUpdate operation.
198
+ */
199
+ export interface DbUpdateOptions {
200
+ /** Contract or unvalidated JSON - validated at runtime via familyInstance.validateContract() */
201
+ readonly contract: unknown;
202
+ /**
203
+ * Mode for the dbUpdate operation.
204
+ * - 'plan': Returns planned operations without applying
205
+ * - 'apply': Applies operations and writes marker/ledger
206
+ */
207
+ readonly mode: 'plan' | 'apply';
208
+ /**
209
+ * Database connection. If provided, dbUpdate will connect before executing.
210
+ * If omitted, the client must already be connected.
211
+ * The type is driver-specific (e.g., string URL for Postgres).
212
+ */
213
+ readonly connection?: unknown;
214
+ /**
215
+ * When true, allows applying plans that contain destructive operations
216
+ * (e.g., DROP TABLE, DROP COLUMN, ALTER TYPE).
217
+ * When false (default), the operation returns a failure if the plan
218
+ * includes destructive operations, prompting the user to confirm interactively
219
+ * or re-run with -y/--yes.
220
+ */
221
+ readonly acceptDataLoss?: boolean;
222
+ /** Optional progress callback for observing operation progress */
223
+ readonly onProgress?: OnControlProgress;
95
224
  }
96
225
 
97
226
  /**
@@ -102,6 +231,41 @@ export interface IntrospectOptions {
102
231
  * Optional schema name to introspect.
103
232
  */
104
233
  readonly schema?: string;
234
+ /**
235
+ * Database connection. If provided, introspect will connect before executing.
236
+ * If omitted, the client must already be connected.
237
+ * The type is driver-specific (e.g., string URL for Postgres).
238
+ */
239
+ readonly connection?: unknown;
240
+ /** Optional progress callback for observing operation progress */
241
+ readonly onProgress?: OnControlProgress;
242
+ }
243
+
244
+ /**
245
+ * Contract configuration for emit operation.
246
+ */
247
+ export interface EmitContractConfig {
248
+ /**
249
+ * Contract source provider.
250
+ */
251
+ readonly sourceProvider: ContractSourceProvider;
252
+ /**
253
+ * Output path for contract.json.
254
+ * The .d.ts types file will be colocated (e.g., contract.json → contract.d.ts).
255
+ */
256
+ readonly output: string;
257
+ }
258
+
259
+ /**
260
+ * Options for the emit operation.
261
+ */
262
+ export interface EmitOptions {
263
+ /**
264
+ * Contract configuration containing source, output, and types paths.
265
+ */
266
+ readonly contractConfig: EmitContractConfig;
267
+ /** Optional progress callback for observing operation progress */
268
+ readonly onProgress?: OnControlProgress;
105
269
  }
106
270
 
107
271
  // ============================================================================
@@ -119,13 +283,18 @@ export interface DbInitSuccess {
119
283
  readonly label: string;
120
284
  readonly operationClass: string;
121
285
  }>;
286
+ readonly sql?: ReadonlyArray<string>;
287
+ };
288
+ readonly destination: {
289
+ readonly storageHash: string;
290
+ readonly profileHash?: string;
122
291
  };
123
292
  readonly execution?: {
124
293
  readonly operationsPlanned: number;
125
294
  readonly operationsExecuted: number;
126
295
  };
127
296
  readonly marker?: {
128
- readonly coreHash: string;
297
+ readonly storageHash: string;
129
298
  readonly profileHash?: string;
130
299
  };
131
300
  readonly summary: string;
@@ -142,13 +311,15 @@ export type DbInitFailureCode = 'PLANNING_FAILED' | 'MARKER_ORIGIN_MISMATCH' | '
142
311
  export interface DbInitFailure {
143
312
  readonly code: DbInitFailureCode;
144
313
  readonly summary: string;
145
- readonly conflicts?: ReadonlyArray<MigrationPlannerConflict>;
314
+ readonly why: string | undefined;
315
+ readonly conflicts: ReadonlyArray<MigrationPlannerConflict> | undefined;
316
+ readonly meta: Record<string, unknown> | undefined;
146
317
  readonly marker?: {
147
- readonly coreHash?: string;
318
+ readonly storageHash?: string;
148
319
  readonly profileHash?: string;
149
320
  };
150
321
  readonly destination?: {
151
- readonly coreHash: string;
322
+ readonly storageHash: string;
152
323
  readonly profileHash?: string | undefined;
153
324
  };
154
325
  }
@@ -159,6 +330,217 @@ export interface DbInitFailure {
159
330
  */
160
331
  export type DbInitResult = Result<DbInitSuccess, DbInitFailure>;
161
332
 
333
+ /**
334
+ * Successful dbUpdate result.
335
+ */
336
+ export interface DbUpdateSuccess {
337
+ readonly mode: 'plan' | 'apply';
338
+ readonly plan: {
339
+ readonly operations: ReadonlyArray<{
340
+ readonly id: string;
341
+ readonly label: string;
342
+ readonly operationClass: string;
343
+ }>;
344
+ readonly sql?: ReadonlyArray<string>;
345
+ };
346
+ readonly destination: {
347
+ readonly storageHash: string;
348
+ readonly profileHash?: string;
349
+ };
350
+ readonly execution?: {
351
+ readonly operationsPlanned: number;
352
+ readonly operationsExecuted: number;
353
+ };
354
+ readonly marker?: {
355
+ readonly storageHash: string;
356
+ readonly profileHash?: string;
357
+ };
358
+ readonly summary: string;
359
+ }
360
+
361
+ /**
362
+ * Failure codes for dbUpdate operation.
363
+ */
364
+ export type DbUpdateFailureCode = 'PLANNING_FAILED' | 'RUNNER_FAILED' | 'DESTRUCTIVE_CHANGES';
365
+
366
+ /**
367
+ * Failure details for dbUpdate operation.
368
+ */
369
+ export interface DbUpdateFailure {
370
+ readonly code: DbUpdateFailureCode;
371
+ readonly summary: string;
372
+ readonly why: string | undefined;
373
+ readonly conflicts: ReadonlyArray<MigrationPlannerConflict> | undefined;
374
+ readonly meta: Record<string, unknown> | undefined;
375
+ }
376
+
377
+ /**
378
+ * Result type for dbUpdate operation.
379
+ * Uses Result pattern: success returns DbUpdateSuccess, failure returns DbUpdateFailure.
380
+ */
381
+ export type DbUpdateResult = Result<DbUpdateSuccess, DbUpdateFailure>;
382
+
383
+ /**
384
+ * Successful emit result.
385
+ * Contains the hashes and paths of emitted files.
386
+ */
387
+ export interface EmitSuccess {
388
+ /** Storage hash of the emitted contract */
389
+ readonly storageHash: string;
390
+ /** Execution hash of the emitted contract (if execution section exists) */
391
+ readonly executionHash?: string;
392
+ /** Profile hash of the emitted contract (target-specific) */
393
+ readonly profileHash: string;
394
+ /** The emitted contract as JSON string */
395
+ readonly contractJson: string;
396
+ /** The emitted contract TypeScript declarations */
397
+ readonly contractDts: string;
398
+ }
399
+
400
+ /**
401
+ * Failure codes for emit operation.
402
+ */
403
+ export type EmitFailureCode =
404
+ | 'CONTRACT_SOURCE_INVALID'
405
+ | 'CONTRACT_VALIDATION_FAILED'
406
+ | 'EMIT_FAILED';
407
+
408
+ /**
409
+ * Failure details for emit operation.
410
+ */
411
+ export interface EmitFailure {
412
+ readonly code: EmitFailureCode;
413
+ readonly summary: string;
414
+ readonly why: string | undefined;
415
+ readonly meta: Record<string, unknown> | undefined;
416
+ readonly diagnostics?: ContractSourceDiagnostics;
417
+ }
418
+
419
+ /**
420
+ * Result type for emit operation.
421
+ * Uses Result pattern: success returns EmitSuccess, failure returns EmitFailure.
422
+ */
423
+ export type EmitResult = Result<EmitSuccess, EmitFailure>;
424
+
425
+ // ============================================================================
426
+ // Migration Apply Types
427
+ // ============================================================================
428
+
429
+ /**
430
+ * A pre-planned migration step ready for execution.
431
+ * Contains the manifest metadata and the serialized operations from ops.json.
432
+ */
433
+ export interface MigrationApplyStep {
434
+ readonly dirName: string;
435
+ readonly from: string;
436
+ readonly to: string;
437
+ readonly toContract: Contract;
438
+ readonly operations: readonly MigrationPlanOperation[];
439
+ }
440
+
441
+ /**
442
+ * Options for the migrationApply operation.
443
+ */
444
+ export interface MigrationApplyOptions {
445
+ /**
446
+ * Hash of the database state this apply path starts from.
447
+ * This is resolved by the caller (typically the CLI orchestration layer).
448
+ */
449
+ readonly originHash: string;
450
+ /**
451
+ * Hash of the target contract this apply path must reach.
452
+ * This is resolved by the caller (typically the CLI orchestration layer).
453
+ */
454
+ readonly destinationHash: string;
455
+ /**
456
+ * Ordered list of migrations to execute from originHash to destinationHash.
457
+ * The execution layer does not choose defaults; it only executes this explicit path.
458
+ */
459
+ readonly pendingMigrations: readonly MigrationApplyStep[];
460
+ /**
461
+ * Database connection. If provided, migrationApply will connect before executing.
462
+ * If omitted, the client must already be connected.
463
+ */
464
+ readonly connection?: unknown;
465
+ /** Optional progress callback for observing operation progress */
466
+ readonly onProgress?: OnControlProgress;
467
+ }
468
+
469
+ /**
470
+ * Record of a successfully applied migration.
471
+ */
472
+ export interface MigrationApplyAppliedEntry {
473
+ readonly dirName: string;
474
+ readonly from: string;
475
+ readonly to: string;
476
+ readonly operationsExecuted: number;
477
+ }
478
+
479
+ /**
480
+ * Successful migrationApply result.
481
+ */
482
+ export interface MigrationApplySuccess {
483
+ readonly migrationsApplied: number;
484
+ readonly markerHash: string;
485
+ readonly applied: readonly MigrationApplyAppliedEntry[];
486
+ readonly summary: string;
487
+ }
488
+
489
+ /**
490
+ * Failure codes for migrationApply operation.
491
+ */
492
+ export type MigrationApplyFailureCode = 'RUNNER_FAILED' | 'MIGRATION_PATH_NOT_FOUND';
493
+
494
+ /**
495
+ * Failure details for migrationApply operation.
496
+ */
497
+ export interface MigrationApplyFailure {
498
+ readonly code: MigrationApplyFailureCode;
499
+ readonly summary: string;
500
+ readonly why: string | undefined;
501
+ readonly meta: Record<string, unknown> | undefined;
502
+ }
503
+
504
+ /**
505
+ * Result type for migrationApply operation.
506
+ */
507
+ export type MigrationApplyResult = Result<MigrationApplySuccess, MigrationApplyFailure>;
508
+
509
+ // ============================================================================
510
+ // Standalone Contract Emit Types
511
+ // ============================================================================
512
+
513
+ /**
514
+ * Options for the standalone executeContractEmit function.
515
+ * Used by tooling (e.g., Vite plugin) that needs to emit contracts
516
+ * without the full ControlClient infrastructure.
517
+ */
518
+ export interface ContractEmitOptions {
519
+ /** Path to the prisma-next.config.ts file */
520
+ readonly configPath: string;
521
+ /** Optional AbortSignal for cancellation support */
522
+ readonly signal?: AbortSignal;
523
+ }
524
+
525
+ /**
526
+ * Result from the standalone executeContractEmit function.
527
+ */
528
+ export interface ContractEmitResult {
529
+ /** Hash of the storage contract (schema-level) */
530
+ readonly storageHash: string;
531
+ /** Hash of the execution contract (if execution section exists) */
532
+ readonly executionHash?: string;
533
+ /** Hash of the profile (target+extensions) */
534
+ readonly profileHash: string;
535
+ /** Paths to the emitted files */
536
+ readonly files: {
537
+ /** Path to the emitted contract.json file */
538
+ readonly json: string;
539
+ /** Path to the emitted contract.d.ts file */
540
+ readonly dts: string;
541
+ };
542
+ }
543
+
162
544
  // ============================================================================
163
545
  // Client Interface
164
546
  // ============================================================================
@@ -205,7 +587,7 @@ export interface ControlClient {
205
587
 
206
588
  /**
207
589
  * Verifies database marker matches the contract.
208
- * Compares coreHash and profileHash.
590
+ * Compares storageHash and profileHash.
209
591
  *
210
592
  * @returns Structured result (ok: false for mismatch, not throwing)
211
593
  * @throws If not connected or infrastructure failure
@@ -222,9 +604,9 @@ export interface ControlClient {
222
604
  schemaVerify(options: SchemaVerifyOptions): Promise<VerifyDatabaseSchemaResult>;
223
605
 
224
606
  /**
225
- * Signs the database with a contract marker.
226
- * Writes or updates the contract marker if schema verification passes.
227
- * Idempotent (no-op if marker already matches).
607
+ * Signs the database with a contract signature.
608
+ * Writes or updates the signature if schema verification passes.
609
+ * Idempotent (no-op if signature already matches).
228
610
  *
229
611
  * @returns Structured result
230
612
  * @throws If not connected or infrastructure failure
@@ -241,6 +623,38 @@ export interface ControlClient {
241
623
  */
242
624
  dbInit(options: DbInitOptions): Promise<DbInitResult>;
243
625
 
626
+ /**
627
+ * Updates a database schema to match the current contract.
628
+ * Creates the signature table if it does not exist. No preconditions required.
629
+ * Allows additive, widening, and destructive operation classes.
630
+ *
631
+ * @param options.mode - 'plan' to preview, 'apply' to execute
632
+ * @returns Result pattern: Ok with planned/executed operations, NotOk with failure details
633
+ * @throws If not connected, target doesn't support migrations, or infrastructure failure
634
+ */
635
+ dbUpdate(options: DbUpdateOptions): Promise<DbUpdateResult>;
636
+
637
+ /**
638
+ * Reads the contract marker from the database.
639
+ * Returns null if no marker exists (fresh database).
640
+ *
641
+ * @throws If not connected or infrastructure failure
642
+ */
643
+ readMarker(): Promise<ContractMarkerRecord | null>;
644
+
645
+ /**
646
+ * Applies pre-planned on-disk migrations to the database.
647
+ * Each migration runs in its own transaction with full execution checks.
648
+ * Resume-safe: re-running after failure picks up from the last applied migration.
649
+ *
650
+ * @param options.originHash - Explicit source hash for the apply path
651
+ * @param options.destinationHash - Explicit destination hash for the apply path
652
+ * @param options.pendingMigrations - Ordered migrations to execute
653
+ * @returns Result pattern: Ok with applied details, NotOk with failure details
654
+ * @throws If not connected, target doesn't support migrations, or infrastructure failure
655
+ */
656
+ migrationApply(options: MigrationApplyOptions): Promise<MigrationApplyResult>;
657
+
244
658
  /**
245
659
  * Introspects the database schema.
246
660
  *
@@ -248,4 +662,22 @@ export interface ControlClient {
248
662
  * @throws If not connected or infrastructure failure
249
663
  */
250
664
  introspect(options?: IntrospectOptions): Promise<unknown>;
665
+
666
+ /**
667
+ * Converts a schema IR to a schema view for CLI tree rendering.
668
+ * Delegates to the family instance's toSchemaView method.
669
+ *
670
+ * @param schemaIR - The schema IR from introspect()
671
+ * @returns CoreSchemaView if the family supports it, undefined otherwise
672
+ */
673
+ toSchemaView(schemaIR: unknown): CoreSchemaView | undefined;
674
+
675
+ /**
676
+ * Emits the contract to JSON and TypeScript declarations.
677
+ * This is an offline operation that does NOT require a database connection.
678
+ * Uses `init()` to create the stack but does NOT call `connect()`.
679
+ *
680
+ * @returns Result pattern: Ok with emit details, NotOk with failure details
681
+ */
682
+ emit(options: EmitOptions): Promise<EmitResult>;
251
683
  }
@@ -1,6 +1,7 @@
1
- // Re-export core-control-plane config types for convenience
1
+ // Re-export config package types for convenience
2
2
  export type {
3
3
  ContractConfig,
4
+ ContractSourceContext,
4
5
  PrismaNextConfig,
5
- } from '@prisma-next/core-control-plane/config-types';
6
- export { defineConfig } from '@prisma-next/core-control-plane/config-types';
6
+ } from '@prisma-next/config/config-types';
7
+ export { defineConfig } from '@prisma-next/config/config-types';
@@ -10,24 +10,46 @@
10
10
 
11
11
  // Re-export core control plane types for consumer convenience
12
12
  export type {
13
- ControlPlaneStack,
13
+ ControlStack,
14
14
  SignDatabaseResult,
15
15
  VerifyDatabaseResult,
16
16
  VerifyDatabaseSchemaResult,
17
- } from '@prisma-next/core-control-plane/types';
17
+ } from '@prisma-next/framework-components/control';
18
18
  // Client factory
19
19
  export { createControlClient } from '../control-api/client';
20
20
 
21
+ // Contract enrichment (merges framework-derived capabilities and extension pack metadata)
22
+ export { enrichContract } from '../control-api/contract-enrichment';
23
+
24
+ // Standalone operations (for tooling that doesn't need full client)
25
+ export { executeContractEmit } from '../control-api/operations/contract-emit';
26
+
21
27
  // CLI-specific types
22
28
  export type {
29
+ ContractEmitOptions,
30
+ ContractEmitResult,
31
+ ControlActionName,
23
32
  ControlClient,
24
33
  ControlClientOptions,
34
+ ControlProgressEvent,
25
35
  DbInitFailure,
26
36
  DbInitFailureCode,
27
37
  DbInitOptions,
28
38
  DbInitResult,
29
39
  DbInitSuccess,
40
+ DbUpdateFailure,
41
+ DbUpdateFailureCode,
42
+ DbUpdateOptions,
43
+ DbUpdateResult,
44
+ DbUpdateSuccess,
45
+ EmitContractConfig,
46
+ EmitFailure,
47
+ EmitFailureCode,
48
+ EmitOptions,
49
+ EmitResult,
50
+ EmitSuccess,
30
51
  IntrospectOptions,
52
+ OnControlProgress,
31
53
  SchemaVerifyOptions,
32
54
  SignOptions,
33
55
  VerifyOptions,