@prisma-next/cli 0.3.0-dev.4 → 0.3.0-dev.40

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 (106) hide show
  1. package/README.md +125 -40
  2. package/dist/cli.d.mts +1 -0
  3. package/dist/cli.js +1 -2376
  4. package/dist/cli.mjs +169 -0
  5. package/dist/cli.mjs.map +1 -0
  6. package/dist/client-Lm9Q6aQM.mjs +694 -0
  7. package/dist/client-Lm9Q6aQM.mjs.map +1 -0
  8. package/dist/commands/contract-emit.d.mts +7 -0
  9. package/dist/commands/contract-emit.d.mts.map +1 -0
  10. package/dist/commands/contract-emit.mjs +140 -0
  11. package/dist/commands/contract-emit.mjs.map +1 -0
  12. package/dist/commands/db-init.d.mts +7 -0
  13. package/dist/commands/db-init.d.mts.map +1 -0
  14. package/dist/commands/db-init.mjs +179 -0
  15. package/dist/commands/db-init.mjs.map +1 -0
  16. package/dist/commands/db-introspect.d.mts +7 -0
  17. package/dist/commands/db-introspect.d.mts.map +1 -0
  18. package/dist/commands/db-introspect.mjs +120 -0
  19. package/dist/commands/db-introspect.mjs.map +1 -0
  20. package/dist/commands/db-schema-verify.d.mts +7 -0
  21. package/dist/commands/db-schema-verify.d.mts.map +1 -0
  22. package/dist/commands/db-schema-verify.mjs +116 -0
  23. package/dist/commands/db-schema-verify.mjs.map +1 -0
  24. package/dist/commands/db-sign.d.mts +7 -0
  25. package/dist/commands/db-sign.d.mts.map +1 -0
  26. package/dist/commands/db-sign.mjs +138 -0
  27. package/dist/commands/db-sign.mjs.map +1 -0
  28. package/dist/commands/db-verify.d.mts +7 -0
  29. package/dist/commands/db-verify.d.mts.map +1 -0
  30. package/dist/commands/db-verify.mjs +129 -0
  31. package/dist/commands/db-verify.mjs.map +1 -0
  32. package/dist/config-loader-CnnWuluc.mjs +42 -0
  33. package/dist/config-loader-CnnWuluc.mjs.map +1 -0
  34. package/dist/{config-loader.d.ts → config-loader.d.mts} +5 -2
  35. package/dist/config-loader.d.mts.map +1 -0
  36. package/dist/config-loader.mjs +3 -0
  37. package/dist/exports/config-types.d.mts +2 -0
  38. package/dist/exports/config-types.mjs +3 -0
  39. package/dist/exports/control-api.d.mts +451 -0
  40. package/dist/exports/control-api.d.mts.map +1 -0
  41. package/dist/exports/control-api.mjs +59 -0
  42. package/dist/exports/control-api.mjs.map +1 -0
  43. package/dist/{index.d.ts → exports/index.d.mts} +7 -6
  44. package/dist/exports/index.d.mts.map +1 -0
  45. package/dist/exports/index.mjs +132 -0
  46. package/dist/exports/index.mjs.map +1 -0
  47. package/dist/result-handler-BZPY7HX4.mjs +1029 -0
  48. package/dist/result-handler-BZPY7HX4.mjs.map +1 -0
  49. package/package.json +50 -38
  50. package/src/cli.ts +260 -0
  51. package/src/commands/contract-emit.ts +267 -0
  52. package/src/commands/db-init.ts +355 -0
  53. package/src/commands/db-introspect.ts +227 -0
  54. package/src/commands/db-schema-verify.ts +238 -0
  55. package/src/commands/db-sign.ts +279 -0
  56. package/src/commands/db-verify.ts +259 -0
  57. package/src/config-loader.ts +76 -0
  58. package/src/control-api/client.ts +591 -0
  59. package/src/control-api/operations/contract-emit.ts +103 -0
  60. package/src/control-api/operations/db-init.ts +281 -0
  61. package/src/control-api/types.ts +493 -0
  62. package/src/exports/config-types.ts +6 -0
  63. package/src/exports/control-api.ts +51 -0
  64. package/src/exports/index.ts +4 -0
  65. package/src/load-ts-contract.ts +222 -0
  66. package/src/utils/cli-errors.ts +26 -0
  67. package/src/utils/command-helpers.ts +26 -0
  68. package/src/utils/framework-components.ts +177 -0
  69. package/src/utils/global-flags.ts +75 -0
  70. package/src/utils/output.ts +1477 -0
  71. package/src/utils/progress-adapter.ts +86 -0
  72. package/src/utils/result-handler.ts +44 -0
  73. package/dist/chunk-464LNZCE.js +0 -134
  74. package/dist/chunk-464LNZCE.js.map +0 -1
  75. package/dist/chunk-BZMBKEEQ.js +0 -997
  76. package/dist/chunk-BZMBKEEQ.js.map +0 -1
  77. package/dist/chunk-HWYQOCAJ.js +0 -47
  78. package/dist/chunk-HWYQOCAJ.js.map +0 -1
  79. package/dist/chunk-ZKYEJROM.js +0 -94
  80. package/dist/chunk-ZKYEJROM.js.map +0 -1
  81. package/dist/cli.js.map +0 -1
  82. package/dist/commands/contract-emit.d.ts +0 -5
  83. package/dist/commands/contract-emit.js +0 -9
  84. package/dist/commands/contract-emit.js.map +0 -1
  85. package/dist/commands/db-init.d.ts +0 -5
  86. package/dist/commands/db-init.js +0 -341
  87. package/dist/commands/db-init.js.map +0 -1
  88. package/dist/commands/db-introspect.d.ts +0 -5
  89. package/dist/commands/db-introspect.js +0 -190
  90. package/dist/commands/db-introspect.js.map +0 -1
  91. package/dist/commands/db-schema-verify.d.ts +0 -5
  92. package/dist/commands/db-schema-verify.js +0 -164
  93. package/dist/commands/db-schema-verify.js.map +0 -1
  94. package/dist/commands/db-sign.d.ts +0 -5
  95. package/dist/commands/db-sign.js +0 -199
  96. package/dist/commands/db-sign.js.map +0 -1
  97. package/dist/commands/db-verify.d.ts +0 -5
  98. package/dist/commands/db-verify.js +0 -173
  99. package/dist/commands/db-verify.js.map +0 -1
  100. package/dist/config-loader.js +0 -7
  101. package/dist/config-loader.js.map +0 -1
  102. package/dist/config-types.d.ts +0 -1
  103. package/dist/config-types.js +0 -6
  104. package/dist/config-types.js.map +0 -1
  105. package/dist/index.js +0 -175
  106. package/dist/index.js.map +0 -1
@@ -0,0 +1,493 @@
1
+ import type { CoreSchemaView } from '@prisma-next/core-control-plane/schema-view';
2
+ import type {
3
+ ControlAdapterDescriptor,
4
+ ControlDriverDescriptor,
5
+ ControlExtensionDescriptor,
6
+ ControlFamilyDescriptor,
7
+ ControlTargetDescriptor,
8
+ MigrationPlannerConflict,
9
+ SignDatabaseResult,
10
+ VerifyDatabaseResult,
11
+ VerifyDatabaseSchemaResult,
12
+ } from '@prisma-next/core-control-plane/types';
13
+ import type { Result } from '@prisma-next/utils/result';
14
+
15
+ // ============================================================================
16
+ // Client Options
17
+ // ============================================================================
18
+
19
+ /**
20
+ * Options for creating a control client.
21
+ *
22
+ * Note: This is NOT the same as CLI config. There's no `contract` field,
23
+ * no file paths. The client is config-agnostic.
24
+ *
25
+ * The descriptor types use permissive `any` because family-specific descriptors
26
+ * (e.g., SqlFamilyDescriptor) have more specific `create` method signatures that
27
+ * are not compatible with the base ControlFamilyDescriptor type due to TypeScript
28
+ * variance rules. The client implementation casts these internally.
29
+ */
30
+ export interface ControlClientOptions {
31
+ // biome-ignore lint/suspicious/noExplicitAny: required for contravariance - SqlFamilyDescriptor.create has specific parameter types
32
+ readonly family: ControlFamilyDescriptor<any, any>;
33
+ // biome-ignore lint/suspicious/noExplicitAny: required for contravariance - SqlControlTargetDescriptor extends with additional methods
34
+ readonly target: ControlTargetDescriptor<any, any, any, any>;
35
+ // biome-ignore lint/suspicious/noExplicitAny: required for contravariance in adapter.create()
36
+ readonly adapter: ControlAdapterDescriptor<any, any, any>;
37
+ /** Optional - control client can be created without driver for offline operations */
38
+ // biome-ignore lint/suspicious/noExplicitAny: required for contravariance in driver.create()
39
+ readonly driver?: ControlDriverDescriptor<any, any, any, any>;
40
+ // biome-ignore lint/suspicious/noExplicitAny: required for contravariance in extension.create()
41
+ readonly extensionPacks?: ReadonlyArray<ControlExtensionDescriptor<any, any, any>>;
42
+ /**
43
+ * Optional default connection for auto-connect.
44
+ * When provided, operations will auto-connect if not already connected.
45
+ * The type is driver-specific (e.g., string URL for Postgres).
46
+ */
47
+ readonly connection?: unknown;
48
+ }
49
+
50
+ // ============================================================================
51
+ // Progress Events
52
+ // ============================================================================
53
+
54
+ /**
55
+ * Action names for control-api operations that can emit progress events.
56
+ */
57
+ export type ControlActionName =
58
+ | 'dbInit'
59
+ | 'verify'
60
+ | 'schemaVerify'
61
+ | 'sign'
62
+ | 'introspect'
63
+ | 'emit';
64
+
65
+ /**
66
+ * Progress event emitted during control-api operation execution.
67
+ *
68
+ * Events model operation progress using a span-based model:
69
+ * - `spanStart`: Begin a timed segment (supports nesting via parentSpanId)
70
+ * - `spanEnd`: Complete a timed segment
71
+ *
72
+ * All operation-specific progress (e.g., per-migration-operation) is modeled
73
+ * as nested spans rather than special event types.
74
+ *
75
+ * Events are delivered via an optional `onProgress` callback to avoid polluting
76
+ * return types. If the callback is absent, operations emit no events (zero overhead).
77
+ */
78
+ export type ControlProgressEvent =
79
+ | {
80
+ readonly action: ControlActionName;
81
+ readonly kind: 'spanStart';
82
+ readonly spanId: string;
83
+ readonly parentSpanId?: string;
84
+ readonly label: string;
85
+ }
86
+ | {
87
+ readonly action: ControlActionName;
88
+ readonly kind: 'spanEnd';
89
+ readonly spanId: string;
90
+ readonly outcome: 'ok' | 'skipped' | 'error';
91
+ };
92
+
93
+ /**
94
+ * Callback function for receiving progress events during control-api operations.
95
+ *
96
+ * @param event - The progress event emitted by the operation
97
+ */
98
+ export type OnControlProgress = (event: ControlProgressEvent) => void;
99
+
100
+ // ============================================================================
101
+ // Operation Options
102
+ // ============================================================================
103
+
104
+ /**
105
+ * Options for the verify operation.
106
+ */
107
+ export interface VerifyOptions {
108
+ /** Contract IR or unvalidated JSON - validated at runtime via familyInstance.validateContractIR() */
109
+ readonly contractIR: unknown;
110
+ /**
111
+ * Database connection. If provided, verify will connect before executing.
112
+ * If omitted, the client must already be connected.
113
+ * The type is driver-specific (e.g., string URL for Postgres).
114
+ */
115
+ readonly connection?: unknown;
116
+ /** Optional progress callback for observing operation progress */
117
+ readonly onProgress?: OnControlProgress;
118
+ }
119
+
120
+ /**
121
+ * Options for the schemaVerify operation.
122
+ */
123
+ export interface SchemaVerifyOptions {
124
+ /** Contract IR or unvalidated JSON - validated at runtime via familyInstance.validateContractIR() */
125
+ readonly contractIR: unknown;
126
+ /**
127
+ * Whether to use strict mode for schema verification.
128
+ * In strict mode, extra tables/columns are reported as issues.
129
+ * Default: false (tolerant mode - allows superset)
130
+ */
131
+ readonly strict?: boolean;
132
+ /**
133
+ * Database connection. If provided, schemaVerify will connect before executing.
134
+ * If omitted, the client must already be connected.
135
+ * The type is driver-specific (e.g., string URL for Postgres).
136
+ */
137
+ readonly connection?: unknown;
138
+ /** Optional progress callback for observing operation progress */
139
+ readonly onProgress?: OnControlProgress;
140
+ }
141
+
142
+ /**
143
+ * Options for the sign operation.
144
+ */
145
+ export interface SignOptions {
146
+ /** Contract IR or unvalidated JSON - validated at runtime via familyInstance.validateContractIR() */
147
+ readonly contractIR: unknown;
148
+ /**
149
+ * Path to the contract file (for metadata in the result).
150
+ */
151
+ readonly contractPath?: string;
152
+ /**
153
+ * Path to the config file (for metadata in the result).
154
+ */
155
+ readonly configPath?: string;
156
+ /**
157
+ * Database connection. If provided, sign will connect before executing.
158
+ * If omitted, the client must already be connected.
159
+ * The type is driver-specific (e.g., string URL for Postgres).
160
+ */
161
+ readonly connection?: unknown;
162
+ /** Optional progress callback for observing operation progress */
163
+ readonly onProgress?: OnControlProgress;
164
+ }
165
+
166
+ /**
167
+ * Options for the dbInit operation.
168
+ */
169
+ export interface DbInitOptions {
170
+ /** Contract IR or unvalidated JSON - validated at runtime via familyInstance.validateContractIR() */
171
+ readonly contractIR: unknown;
172
+ /**
173
+ * Mode for the dbInit operation.
174
+ * - 'plan': Returns planned operations without applying
175
+ * - 'apply': Applies operations and writes marker
176
+ */
177
+ readonly mode: 'plan' | 'apply';
178
+ /**
179
+ * Database connection. If provided, dbInit will connect before executing.
180
+ * If omitted, the client must already be connected.
181
+ * The type is driver-specific (e.g., string URL for Postgres).
182
+ */
183
+ readonly connection?: unknown;
184
+ /** Optional progress callback for observing operation progress */
185
+ readonly onProgress?: OnControlProgress;
186
+ }
187
+
188
+ /**
189
+ * Options for the introspect operation.
190
+ */
191
+ export interface IntrospectOptions {
192
+ /**
193
+ * Optional schema name to introspect.
194
+ */
195
+ readonly schema?: string;
196
+ /**
197
+ * Database connection. If provided, introspect will connect before executing.
198
+ * If omitted, the client must already be connected.
199
+ * The type is driver-specific (e.g., string URL for Postgres).
200
+ */
201
+ readonly connection?: unknown;
202
+ /** Optional progress callback for observing operation progress */
203
+ readonly onProgress?: OnControlProgress;
204
+ }
205
+
206
+ /**
207
+ * Contract source as a raw value (any JSON-serializable value).
208
+ */
209
+ export interface ContractSourceValue {
210
+ readonly kind: 'value';
211
+ readonly value: unknown;
212
+ }
213
+
214
+ /**
215
+ * Contract source as a lazy loader function.
216
+ */
217
+ export interface ContractSourceLoader {
218
+ readonly kind: 'loader';
219
+ readonly load: () => unknown | Promise<unknown>;
220
+ }
221
+
222
+ /**
223
+ * Discriminated union for contract source.
224
+ * Use `kind` to determine how to resolve the contract.
225
+ */
226
+ export type EmitContractSource = ContractSourceValue | ContractSourceLoader;
227
+
228
+ /**
229
+ * Contract configuration for emit operation.
230
+ */
231
+ export interface EmitContractConfig {
232
+ /**
233
+ * Contract source - either a raw value or a loader function.
234
+ * Switch on `source.kind` to determine how to resolve.
235
+ */
236
+ readonly source: EmitContractSource;
237
+ /**
238
+ * Output path for contract.json.
239
+ * The .d.ts types file will be colocated (e.g., contract.json → contract.d.ts).
240
+ */
241
+ readonly output: string;
242
+ }
243
+
244
+ /**
245
+ * Options for the emit operation.
246
+ */
247
+ export interface EmitOptions {
248
+ /**
249
+ * Contract configuration containing source, output, and types paths.
250
+ */
251
+ readonly contractConfig: EmitContractConfig;
252
+ /** Optional progress callback for observing operation progress */
253
+ readonly onProgress?: OnControlProgress;
254
+ }
255
+
256
+ // ============================================================================
257
+ // Result Types
258
+ // ============================================================================
259
+
260
+ /**
261
+ * Successful dbInit result.
262
+ */
263
+ export interface DbInitSuccess {
264
+ readonly mode: 'plan' | 'apply';
265
+ readonly plan: {
266
+ readonly operations: ReadonlyArray<{
267
+ readonly id: string;
268
+ readonly label: string;
269
+ readonly operationClass: string;
270
+ }>;
271
+ };
272
+ readonly execution?: {
273
+ readonly operationsPlanned: number;
274
+ readonly operationsExecuted: number;
275
+ };
276
+ readonly marker?: {
277
+ readonly storageHash: string;
278
+ readonly profileHash?: string;
279
+ };
280
+ readonly summary: string;
281
+ }
282
+
283
+ /**
284
+ * Failure codes for dbInit operation.
285
+ */
286
+ export type DbInitFailureCode = 'PLANNING_FAILED' | 'MARKER_ORIGIN_MISMATCH' | 'RUNNER_FAILED';
287
+
288
+ /**
289
+ * Failure details for dbInit operation.
290
+ */
291
+ export interface DbInitFailure {
292
+ readonly code: DbInitFailureCode;
293
+ readonly summary: string;
294
+ readonly why: string | undefined;
295
+ readonly conflicts: ReadonlyArray<MigrationPlannerConflict> | undefined;
296
+ readonly meta: Record<string, unknown> | undefined;
297
+ readonly marker?: {
298
+ readonly storageHash?: string;
299
+ readonly profileHash?: string;
300
+ };
301
+ readonly destination?: {
302
+ readonly storageHash: string;
303
+ readonly profileHash?: string | undefined;
304
+ };
305
+ }
306
+
307
+ /**
308
+ * Result type for dbInit operation.
309
+ * Uses Result pattern: success returns DbInitSuccess, failure returns DbInitFailure.
310
+ */
311
+ export type DbInitResult = Result<DbInitSuccess, DbInitFailure>;
312
+
313
+ /**
314
+ * Successful emit result.
315
+ * Contains the hashes and paths of emitted files.
316
+ */
317
+ export interface EmitSuccess {
318
+ /** Storage hash of the emitted contract */
319
+ readonly storageHash: string;
320
+ /** Execution hash of the emitted contract (if execution section exists) */
321
+ readonly executionHash?: string;
322
+ /** Profile hash of the emitted contract (target-specific) */
323
+ readonly profileHash: string;
324
+ /** The emitted contract as JSON string */
325
+ readonly contractJson: string;
326
+ /** The emitted contract TypeScript declarations */
327
+ readonly contractDts: string;
328
+ }
329
+
330
+ /**
331
+ * Failure codes for emit operation.
332
+ */
333
+ export type EmitFailureCode = 'CONTRACT_SOURCE_INVALID' | 'EMIT_FAILED';
334
+
335
+ /**
336
+ * Failure details for emit operation.
337
+ */
338
+ export interface EmitFailure {
339
+ readonly code: EmitFailureCode;
340
+ readonly summary: string;
341
+ readonly why: string | undefined;
342
+ readonly meta: Record<string, unknown> | undefined;
343
+ }
344
+
345
+ /**
346
+ * Result type for emit operation.
347
+ * Uses Result pattern: success returns EmitSuccess, failure returns EmitFailure.
348
+ */
349
+ export type EmitResult = Result<EmitSuccess, EmitFailure>;
350
+
351
+ // ============================================================================
352
+ // Standalone Contract Emit Types
353
+ // ============================================================================
354
+
355
+ /**
356
+ * Options for the standalone executeContractEmit function.
357
+ * Used by tooling (e.g., Vite plugin) that needs to emit contracts
358
+ * without the full ControlClient infrastructure.
359
+ */
360
+ export interface ContractEmitOptions {
361
+ /** Path to the prisma-next.config.ts file */
362
+ readonly configPath: string;
363
+ /** Optional AbortSignal for cancellation support */
364
+ readonly signal?: AbortSignal;
365
+ }
366
+
367
+ /**
368
+ * Result from the standalone executeContractEmit function.
369
+ */
370
+ export interface ContractEmitResult {
371
+ /** Hash of the storage contract (schema-level) */
372
+ readonly storageHash: string;
373
+ /** Hash of the execution contract (if execution section exists) */
374
+ readonly executionHash?: string;
375
+ /** Hash of the profile (target+extensions) */
376
+ readonly profileHash: string;
377
+ /** Paths to the emitted files */
378
+ readonly files: {
379
+ /** Path to the emitted contract.json file */
380
+ readonly json: string;
381
+ /** Path to the emitted contract.d.ts file */
382
+ readonly dts: string;
383
+ };
384
+ }
385
+
386
+ // ============================================================================
387
+ // Client Interface
388
+ // ============================================================================
389
+
390
+ /**
391
+ * Programmatic control client for Prisma Next operations.
392
+ *
393
+ * Lifecycle: `connect(connection)` before operations, `close()` when done.
394
+ * Both `init()` and `connect()` are auto-called by operations if needed,
395
+ * but `connect()` requires a connection so must be called explicitly first
396
+ * unless a default connection was provided in options.
397
+ *
398
+ * @see README.md "Programmatic Control API" section for usage examples
399
+ */
400
+ export interface ControlClient {
401
+ /**
402
+ * Initializes the client by creating the control plane stack,
403
+ * family instance, and validating framework components.
404
+ *
405
+ * Idempotent (safe to call multiple times).
406
+ * Called automatically by `connect()` if not already initialized.
407
+ */
408
+ init(): void;
409
+
410
+ /**
411
+ * Establishes a database connection.
412
+ * Auto-calls `init()` if not already initialized.
413
+ * Must be called before any database operations unless a default connection
414
+ * was provided in options.
415
+ *
416
+ * @param connection - Driver-specific connection input (e.g., URL string for Postgres).
417
+ * If omitted, uses the default connection from options (if provided).
418
+ * @throws If connection fails, already connected, driver is not configured,
419
+ * or no connection provided and no default connection in options.
420
+ */
421
+ connect(connection?: unknown): Promise<void>;
422
+
423
+ /**
424
+ * Closes the database connection.
425
+ * Idempotent (safe to call multiple times).
426
+ * After close(), can call `connect()` again with same or different URL.
427
+ */
428
+ close(): Promise<void>;
429
+
430
+ /**
431
+ * Verifies database marker matches the contract.
432
+ * Compares storageHash and profileHash.
433
+ *
434
+ * @returns Structured result (ok: false for mismatch, not throwing)
435
+ * @throws If not connected or infrastructure failure
436
+ */
437
+ verify(options: VerifyOptions): Promise<VerifyDatabaseResult>;
438
+
439
+ /**
440
+ * Verifies database schema satisfies the contract requirements.
441
+ *
442
+ * @param options.strict - If true, extra tables/columns are issues. Default: false
443
+ * @returns Structured result with schema issues
444
+ * @throws If not connected or infrastructure failure
445
+ */
446
+ schemaVerify(options: SchemaVerifyOptions): Promise<VerifyDatabaseSchemaResult>;
447
+
448
+ /**
449
+ * Signs the database with a contract marker.
450
+ * Writes or updates the contract marker if schema verification passes.
451
+ * Idempotent (no-op if marker already matches).
452
+ *
453
+ * @returns Structured result
454
+ * @throws If not connected or infrastructure failure
455
+ */
456
+ sign(options: SignOptions): Promise<SignDatabaseResult>;
457
+
458
+ /**
459
+ * Initializes database schema from contract.
460
+ * Uses additive-only policy (no destructive changes).
461
+ *
462
+ * @param options.mode - 'plan' to preview, 'apply' to execute
463
+ * @returns Result pattern: Ok with planned/executed operations, NotOk with failure details
464
+ * @throws If not connected, target doesn't support migrations, or infrastructure failure
465
+ */
466
+ dbInit(options: DbInitOptions): Promise<DbInitResult>;
467
+
468
+ /**
469
+ * Introspects the database schema.
470
+ *
471
+ * @returns Raw schema IR
472
+ * @throws If not connected or infrastructure failure
473
+ */
474
+ introspect(options?: IntrospectOptions): Promise<unknown>;
475
+
476
+ /**
477
+ * Converts a schema IR to a schema view for CLI tree rendering.
478
+ * Delegates to the family instance's toSchemaView method.
479
+ *
480
+ * @param schemaIR - The schema IR from introspect()
481
+ * @returns CoreSchemaView if the family supports it, undefined otherwise
482
+ */
483
+ toSchemaView(schemaIR: unknown): CoreSchemaView | undefined;
484
+
485
+ /**
486
+ * Emits the contract to JSON and TypeScript declarations.
487
+ * This is an offline operation that does NOT require a database connection.
488
+ * Uses `init()` to create the stack but does NOT call `connect()`.
489
+ *
490
+ * @returns Result pattern: Ok with emit details, NotOk with failure details
491
+ */
492
+ emit(options: EmitOptions): Promise<EmitResult>;
493
+ }
@@ -0,0 +1,6 @@
1
+ // Re-export core-control-plane config types for convenience
2
+ export type {
3
+ ContractConfig,
4
+ PrismaNextConfig,
5
+ } from '@prisma-next/core-control-plane/config-types';
6
+ export { defineConfig } from '@prisma-next/core-control-plane/config-types';
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Programmatic Control API for Prisma Next.
3
+ *
4
+ * This module exports the control client factory and types for programmatic
5
+ * access to control-plane operations without using the CLI.
6
+ *
7
+ * @see README.md "Programmatic Control API" section for usage examples
8
+ * @module
9
+ */
10
+
11
+ // Re-export core control plane types for consumer convenience
12
+ export type {
13
+ ControlPlaneStack,
14
+ SignDatabaseResult,
15
+ VerifyDatabaseResult,
16
+ VerifyDatabaseSchemaResult,
17
+ } from '@prisma-next/core-control-plane/types';
18
+ // Client factory
19
+ export { createControlClient } from '../control-api/client';
20
+
21
+ // Standalone operations (for tooling that doesn't need full client)
22
+ export { executeContractEmit } from '../control-api/operations/contract-emit';
23
+
24
+ // CLI-specific types
25
+ export type {
26
+ ContractEmitOptions,
27
+ ContractEmitResult,
28
+ ContractSourceLoader,
29
+ ContractSourceValue,
30
+ ControlActionName,
31
+ ControlClient,
32
+ ControlClientOptions,
33
+ ControlProgressEvent,
34
+ DbInitFailure,
35
+ DbInitFailureCode,
36
+ DbInitOptions,
37
+ DbInitResult,
38
+ DbInitSuccess,
39
+ EmitContractConfig,
40
+ EmitContractSource,
41
+ EmitFailure,
42
+ EmitFailureCode,
43
+ EmitOptions,
44
+ EmitResult,
45
+ EmitSuccess,
46
+ IntrospectOptions,
47
+ OnControlProgress,
48
+ SchemaVerifyOptions,
49
+ SignOptions,
50
+ VerifyOptions,
51
+ } from '../control-api/types';
@@ -0,0 +1,4 @@
1
+ // CLI-specific exports
2
+ export { createContractEmitCommand } from '../commands/contract-emit';
3
+ export type { LoadTsContractOptions } from '../load-ts-contract';
4
+ export { loadContractFromTs } from '../load-ts-contract';