prisma-next 0.5.0-dev.9 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli-errors-B9OBbled.d.mts +3 -0
- package/dist/cli-errors-D3_sMh2K.mjs +33 -0
- package/dist/cli-errors-D3_sMh2K.mjs.map +1 -0
- package/dist/cli.mjs +16 -78
- package/dist/cli.mjs.map +1 -1
- package/dist/client-qVH-rEgd.mjs +1595 -0
- package/dist/client-qVH-rEgd.mjs.map +1 -0
- package/dist/{result-handler-Ba3zWQsI.mjs → command-helpers-BeZHkxV8.mjs} +70 -47
- package/dist/command-helpers-BeZHkxV8.mjs.map +1 -0
- package/dist/commands/contract-emit.d.mts.map +1 -1
- package/dist/commands/contract-emit.mjs +2 -4
- package/dist/commands/contract-infer.d.mts.map +1 -1
- package/dist/commands/contract-infer.mjs +2 -4
- package/dist/commands/db-init.d.mts.map +1 -1
- package/dist/commands/db-init.mjs +16 -13
- package/dist/commands/db-init.mjs.map +1 -1
- package/dist/commands/db-schema.d.mts.map +1 -1
- package/dist/commands/db-schema.mjs +6 -7
- package/dist/commands/db-schema.mjs.map +1 -1
- package/dist/commands/db-sign.d.mts.map +1 -1
- package/dist/commands/db-sign.mjs +9 -9
- package/dist/commands/db-sign.mjs.map +1 -1
- package/dist/commands/db-update.d.mts.map +1 -1
- package/dist/commands/db-update.mjs +15 -13
- package/dist/commands/db-update.mjs.map +1 -1
- package/dist/commands/db-verify.d.mts.map +1 -1
- package/dist/commands/db-verify.mjs +1 -321
- package/dist/commands/migration-apply.d.mts +28 -13
- package/dist/commands/migration-apply.d.mts.map +1 -1
- package/dist/commands/migration-apply.mjs +55 -151
- package/dist/commands/migration-apply.mjs.map +1 -1
- package/dist/commands/migration-new.d.mts +0 -1
- package/dist/commands/migration-new.d.mts.map +1 -1
- package/dist/commands/migration-new.mjs +34 -40
- package/dist/commands/migration-new.mjs.map +1 -1
- package/dist/commands/migration-plan.d.mts +33 -6
- package/dist/commands/migration-plan.d.mts.map +1 -1
- package/dist/commands/migration-plan.mjs +2 -348
- package/dist/commands/migration-ref.d.mts +1 -1
- package/dist/commands/migration-ref.d.mts.map +1 -1
- package/dist/commands/migration-ref.mjs +8 -12
- package/dist/commands/migration-ref.mjs.map +1 -1
- package/dist/commands/migration-show.d.mts +13 -7
- package/dist/commands/migration-show.d.mts.map +1 -1
- package/dist/commands/migration-show.mjs +35 -36
- package/dist/commands/migration-show.mjs.map +1 -1
- package/dist/commands/migration-status.d.mts +126 -5
- package/dist/commands/migration-status.d.mts.map +1 -1
- package/dist/commands/migration-status.mjs +2 -4
- package/dist/{config-loader-C25b63rJ.mjs → config-loader-B6sJjXTv.mjs} +3 -5
- package/dist/config-loader-B6sJjXTv.mjs.map +1 -0
- package/dist/config-loader.d.mts +0 -1
- package/dist/config-loader.d.mts.map +1 -1
- package/dist/config-loader.mjs +2 -3
- package/dist/contract-emit-9DBda5Ou.mjs +150 -0
- package/dist/contract-emit-9DBda5Ou.mjs.map +1 -0
- package/dist/contract-emit-B77TsJqf.mjs +327 -0
- package/dist/contract-emit-B77TsJqf.mjs.map +1 -0
- package/dist/{contract-enrichment-CAOELa-H.mjs → contract-enrichment-Dani0mMW.mjs} +4 -6
- package/dist/contract-enrichment-Dani0mMW.mjs.map +1 -0
- package/dist/{contract-infer-D9cC3rJm.mjs → contract-infer-BK9YFGEG.mjs} +13 -22
- package/dist/contract-infer-BK9YFGEG.mjs.map +1 -0
- package/dist/db-verify-C0y1PCO2.mjs +404 -0
- package/dist/db-verify-C0y1PCO2.mjs.map +1 -0
- package/dist/exports/config-types.mjs +1 -2
- package/dist/exports/control-api.d.mts +101 -586
- package/dist/exports/control-api.d.mts.map +1 -1
- package/dist/exports/control-api.mjs +4 -6
- package/dist/exports/index.d.mts.map +1 -1
- package/dist/exports/index.mjs +28 -30
- package/dist/exports/index.mjs.map +1 -1
- package/dist/exports/init-output.d.mts +2 -4
- package/dist/exports/init-output.d.mts.map +1 -1
- package/dist/exports/init-output.mjs +2 -3
- package/dist/extension-pack-inputs-C7xgE-vv.mjs +74 -0
- package/dist/extension-pack-inputs-C7xgE-vv.mjs.map +1 -0
- package/dist/{framework-components-Cr--XBKy.mjs → framework-components-ChqVUxR-.mjs} +3 -4
- package/dist/{framework-components-Cr--XBKy.mjs.map → framework-components-ChqVUxR-.mjs.map} +1 -1
- package/dist/global-flags-Icqpxk23.d.mts +12 -0
- package/dist/global-flags-Icqpxk23.d.mts.map +1 -0
- package/dist/helpers-eqdN8tH6.mjs +25 -0
- package/dist/helpers-eqdN8tH6.mjs.map +1 -0
- package/dist/{init-C5220SY9.mjs → init-DETSgw3h.mjs} +40 -49
- package/dist/init-DETSgw3h.mjs.map +1 -0
- package/dist/{inspect-live-schema-yrHAvG71.mjs → inspect-live-schema-CWYxGKlb.mjs} +10 -11
- package/dist/inspect-live-schema-CWYxGKlb.mjs.map +1 -0
- package/dist/migration-cli.d.mts +41 -12
- package/dist/migration-cli.d.mts.map +1 -1
- package/dist/migration-cli.mjs +309 -86
- package/dist/migration-cli.mjs.map +1 -1
- package/dist/{migration-command-scaffold-B3B09et6.mjs → migration-command-scaffold-B5dORFEv.mjs} +8 -9
- package/dist/migration-command-scaffold-B5dORFEv.mjs.map +1 -0
- package/dist/migration-plan-C6lVaHsO.mjs +554 -0
- package/dist/migration-plan-C6lVaHsO.mjs.map +1 -0
- package/dist/{migration-status-DUMiH8_G.mjs → migration-status-CZ-D5k7k.mjs} +272 -65
- package/dist/migration-status-CZ-D5k7k.mjs.map +1 -0
- package/dist/migrations-D_UJnpuW.mjs +216 -0
- package/dist/migrations-D_UJnpuW.mjs.map +1 -0
- package/dist/{output-BpcQrnnq.mjs → output-B16Kefzx.mjs} +9 -3
- package/dist/output-B16Kefzx.mjs.map +1 -0
- package/dist/{progress-adapter-DvQWB1nK.mjs → progress-adapter-DFfvZcYL.mjs} +2 -2
- package/dist/{progress-adapter-DvQWB1nK.mjs.map → progress-adapter-DFfvZcYL.mjs.map} +1 -1
- package/dist/result-handler-rmPVKIP2.mjs +25 -0
- package/dist/result-handler-rmPVKIP2.mjs.map +1 -0
- package/dist/rolldown-runtime-twds-ZHy.mjs +14 -0
- package/dist/{terminal-ui-C3ZLwQxK.mjs → terminal-ui-C_hFNbAn.mjs} +4 -28
- package/dist/terminal-ui-C_hFNbAn.mjs.map +1 -0
- package/dist/types-D7x-IFLO.d.mts +858 -0
- package/dist/types-D7x-IFLO.d.mts.map +1 -0
- package/dist/{verify-Bkycc-Tf.mjs → verify-CiwNWM9N.mjs} +3 -4
- package/dist/verify-CiwNWM9N.mjs.map +1 -0
- package/package.json +19 -17
- package/dist/cli-errors-BFYgBH3L.d.mts +0 -4
- package/dist/cli-errors-Cd79vmTH.mjs +0 -5
- package/dist/client-CrsnY58k.mjs +0 -997
- package/dist/client-CrsnY58k.mjs.map +0 -1
- package/dist/commands/db-verify.mjs.map +0 -1
- package/dist/commands/migration-plan.mjs.map +0 -1
- package/dist/config-loader-C25b63rJ.mjs.map +0 -1
- package/dist/contract-emit--feXyNd7.mjs +0 -4
- package/dist/contract-emit-NJ01hiiv.mjs +0 -195
- package/dist/contract-emit-NJ01hiiv.mjs.map +0 -1
- package/dist/contract-emit-V5SSitUT.mjs +0 -122
- package/dist/contract-emit-V5SSitUT.mjs.map +0 -1
- package/dist/contract-enrichment-CAOELa-H.mjs.map +0 -1
- package/dist/contract-infer-D9cC3rJm.mjs.map +0 -1
- package/dist/extract-operation-statements-DsFfxXVZ.mjs +0 -13
- package/dist/extract-operation-statements-DsFfxXVZ.mjs.map +0 -1
- package/dist/extract-sql-ddl-D9UbZDyz.mjs +0 -26
- package/dist/extract-sql-ddl-D9UbZDyz.mjs.map +0 -1
- package/dist/init-C5220SY9.mjs.map +0 -1
- package/dist/inspect-live-schema-yrHAvG71.mjs.map +0 -1
- package/dist/migration-command-scaffold-B3B09et6.mjs.map +0 -1
- package/dist/migration-status-DUMiH8_G.mjs.map +0 -1
- package/dist/migrations-Bo5WtTla.mjs +0 -153
- package/dist/migrations-Bo5WtTla.mjs.map +0 -1
- package/dist/output-BpcQrnnq.mjs.map +0 -1
- package/dist/result-handler-Ba3zWQsI.mjs.map +0 -1
- package/dist/terminal-ui-C3ZLwQxK.mjs.map +0 -1
- package/dist/validate-contract-deps-B_Cs29TL.mjs +0 -37
- package/dist/validate-contract-deps-B_Cs29TL.mjs.map +0 -1
- package/dist/verify-Bkycc-Tf.mjs.map +0 -1
|
@@ -0,0 +1,858 @@
|
|
|
1
|
+
import { t as CliStructuredError } from "./cli-errors-B9OBbled.mjs";
|
|
2
|
+
import { Result } from "@prisma-next/utils/result";
|
|
3
|
+
import { ContractSourceDiagnostics, ContractSourceProvider } from "@prisma-next/config/config-types";
|
|
4
|
+
import { ControlAdapterDescriptor, ControlDriverDescriptor, ControlDriverInstance, ControlExtensionDescriptor, ControlFamilyDescriptor, ControlFamilyInstance, ControlTargetDescriptor, CoreSchemaView, MigrationPlanOperation, MigrationPlannerConflict, OperationPreview, SignDatabaseResult, VerifyDatabaseResult, VerifyDatabaseSchemaResult } from "@prisma-next/framework-components/control";
|
|
5
|
+
import { TargetBoundComponentDescriptor } from "@prisma-next/framework-components/components";
|
|
6
|
+
import { Contract, ContractMarkerRecord } from "@prisma-next/contract/types";
|
|
7
|
+
import { PslDocumentAst } from "@prisma-next/framework-components/psl-ast";
|
|
8
|
+
import { OnDiskMigrationPackage } from "@prisma-next/migration-tools/package";
|
|
9
|
+
|
|
10
|
+
//#region src/control-api/operations/db-verify.d.ts
|
|
11
|
+
/**
|
|
12
|
+
* Inputs for the aggregate `db verify` operation.
|
|
13
|
+
*
|
|
14
|
+
* Loader → verifier pipeline. The loader (sole descriptor-import
|
|
15
|
+
* boundary) builds a {@link import('@prisma-next/migration-tools/aggregate').ContractSpaceAggregate};
|
|
16
|
+
* the aggregate verifier bundles `markerCheck` + per-space pre-projected
|
|
17
|
+
* `schemaCheck`. `mode: 'strict' | 'lenient'` maps directly to the user
|
|
18
|
+
* facing `--strict` flag.
|
|
19
|
+
*/
|
|
20
|
+
interface ExecuteDbVerifyOptions<TFamilyId extends string, TTargetId extends string> {
|
|
21
|
+
readonly driver: ControlDriverInstance<TFamilyId, TTargetId>;
|
|
22
|
+
readonly familyInstance: ControlFamilyInstance<TFamilyId, unknown>;
|
|
23
|
+
readonly contract: Contract;
|
|
24
|
+
readonly migrationsDir: string;
|
|
25
|
+
readonly targetId: TTargetId;
|
|
26
|
+
readonly extensionPacks: ReadonlyArray<ControlExtensionDescriptor<TFamilyId, TTargetId>>;
|
|
27
|
+
readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<TFamilyId, TTargetId>>;
|
|
28
|
+
readonly mode: 'strict' | 'lenient';
|
|
29
|
+
readonly skipSchema: boolean;
|
|
30
|
+
readonly skipMarker: boolean;
|
|
31
|
+
readonly onProgress?: OnControlProgress;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Result of the aggregate verify operation.
|
|
35
|
+
*
|
|
36
|
+
* Marker-check failures are surfaced as a {@link CliStructuredError}
|
|
37
|
+
* (same envelope code `5002` the legacy `runContractSpaceVerifierMarkerCheck`
|
|
38
|
+
* emitted, so downstream tooling and integration tests assert on the
|
|
39
|
+
* same shape).
|
|
40
|
+
*
|
|
41
|
+
* On success, the per-space schema results are returned for the CLI to
|
|
42
|
+
* render. When `skipSchema` is true (`--marker-only`), the schema map
|
|
43
|
+
* is empty.
|
|
44
|
+
*/
|
|
45
|
+
interface ExecuteDbVerifySuccess {
|
|
46
|
+
readonly schemaResults: ReadonlyMap<string, VerifyDatabaseSchemaResult>;
|
|
47
|
+
readonly memberOrder: readonly string[];
|
|
48
|
+
readonly appSpaceId: string;
|
|
49
|
+
}
|
|
50
|
+
type ExecuteDbVerifyResult = Result<ExecuteDbVerifySuccess, CliStructuredError>;
|
|
51
|
+
/**
|
|
52
|
+
* Loader → verifier pipeline shared by `db verify` modes (`full`,
|
|
53
|
+
* `marker-only`, `schema-only`).
|
|
54
|
+
*
|
|
55
|
+
* 1. **Load**: build a {@link import('@prisma-next/migration-tools/aggregate').ContractSpaceAggregate}
|
|
56
|
+
* from descriptors + on-disk on-disk artefacts. Layout / drift /
|
|
57
|
+
* integrity / disjointness violations short-circuit with a
|
|
58
|
+
* structured CLI error.
|
|
59
|
+
* 2. **Read DB state**: marker rows + (when `skipSchema` is `false`)
|
|
60
|
+
* schema introspection.
|
|
61
|
+
* 3. **Verify**: {@link verifyAggregate} returns per-space
|
|
62
|
+
* `markerCheck` + per-space pre-projected `schemaCheck` (closes F23).
|
|
63
|
+
* Marker mismatches map to `CliStructuredError` (code `5002`) so
|
|
64
|
+
* callers (CLI command) can render and exit. Schema results are
|
|
65
|
+
* returned to the caller verbatim.
|
|
66
|
+
*/
|
|
67
|
+
declare function executeDbVerify<TFamilyId extends string, TTargetId extends string>(options: ExecuteDbVerifyOptions<TFamilyId, TTargetId>): Promise<ExecuteDbVerifyResult>;
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region src/control-api/types.d.ts
|
|
70
|
+
/**
|
|
71
|
+
* Options for creating a control client.
|
|
72
|
+
*
|
|
73
|
+
* Note: This is NOT the same as CLI config. There's no `contract` field,
|
|
74
|
+
* no file paths. The client is config-agnostic.
|
|
75
|
+
*
|
|
76
|
+
* The descriptor types use permissive `any` because family-specific descriptors
|
|
77
|
+
* (e.g., SqlFamilyDescriptor) have more specific `create` method signatures that
|
|
78
|
+
* are not compatible with the base ControlFamilyDescriptor type due to TypeScript
|
|
79
|
+
* variance rules. The client implementation casts these internally.
|
|
80
|
+
*/
|
|
81
|
+
interface ControlClientOptions {
|
|
82
|
+
readonly family: ControlFamilyDescriptor<any, any>;
|
|
83
|
+
readonly target: ControlTargetDescriptor<any, any, any>;
|
|
84
|
+
readonly adapter: ControlAdapterDescriptor<any, any, any>;
|
|
85
|
+
/** Optional - control client can be created without driver for offline operations */
|
|
86
|
+
readonly driver?: ControlDriverDescriptor<any, any, any, any>;
|
|
87
|
+
readonly extensionPacks?: ReadonlyArray<ControlExtensionDescriptor<any, any, any>>;
|
|
88
|
+
/**
|
|
89
|
+
* Optional default connection for auto-connect.
|
|
90
|
+
* When provided, operations will auto-connect if not already connected.
|
|
91
|
+
* The type is driver-specific (e.g., string URL for Postgres).
|
|
92
|
+
*/
|
|
93
|
+
readonly connection?: unknown;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Action names for control-api operations that can emit progress events.
|
|
97
|
+
*/
|
|
98
|
+
type ControlActionName = 'dbInit' | 'dbUpdate' | 'dbVerify' | 'migrationApply' | 'verify' | 'schemaVerify' | 'sign' | 'introspect' | 'emit';
|
|
99
|
+
/**
|
|
100
|
+
* Progress event emitted during control-api operation execution.
|
|
101
|
+
*
|
|
102
|
+
* Events model operation progress using a span-based model:
|
|
103
|
+
* - `spanStart`: Begin a timed segment (supports nesting via parentSpanId)
|
|
104
|
+
* - `spanEnd`: Complete a timed segment
|
|
105
|
+
*
|
|
106
|
+
* All operation-specific progress (e.g., per-migration-operation) is modeled
|
|
107
|
+
* as nested spans rather than special event types.
|
|
108
|
+
*
|
|
109
|
+
* Events are delivered via an optional `onProgress` callback to avoid polluting
|
|
110
|
+
* return types. If the callback is absent, operations emit no events (zero overhead).
|
|
111
|
+
*/
|
|
112
|
+
type ControlProgressEvent = {
|
|
113
|
+
readonly action: ControlActionName;
|
|
114
|
+
readonly kind: 'spanStart';
|
|
115
|
+
readonly spanId: string;
|
|
116
|
+
readonly parentSpanId?: string;
|
|
117
|
+
readonly label: string;
|
|
118
|
+
} | {
|
|
119
|
+
readonly action: ControlActionName;
|
|
120
|
+
readonly kind: 'spanEnd';
|
|
121
|
+
readonly spanId: string;
|
|
122
|
+
readonly outcome: 'ok' | 'skipped' | 'error';
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Callback function for receiving progress events during control-api operations.
|
|
126
|
+
*
|
|
127
|
+
* @param event - The progress event emitted by the operation
|
|
128
|
+
*/
|
|
129
|
+
type OnControlProgress = (event: ControlProgressEvent) => void;
|
|
130
|
+
/**
|
|
131
|
+
* Options for the verify operation.
|
|
132
|
+
*/
|
|
133
|
+
interface VerifyOptions {
|
|
134
|
+
/** Contract or unvalidated JSON - validated at runtime via familyInstance.validateContract() */
|
|
135
|
+
readonly contract: unknown;
|
|
136
|
+
/**
|
|
137
|
+
* Database connection. If provided, verify will connect before executing.
|
|
138
|
+
* If omitted, the client must already be connected.
|
|
139
|
+
* The type is driver-specific (e.g., string URL for Postgres).
|
|
140
|
+
*/
|
|
141
|
+
readonly connection?: unknown;
|
|
142
|
+
/** Optional progress callback for observing operation progress */
|
|
143
|
+
readonly onProgress?: OnControlProgress;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Options for the schemaVerify operation.
|
|
147
|
+
*/
|
|
148
|
+
interface SchemaVerifyOptions {
|
|
149
|
+
/** Contract or unvalidated JSON - validated at runtime via familyInstance.validateContract() */
|
|
150
|
+
readonly contract: unknown;
|
|
151
|
+
/**
|
|
152
|
+
* Whether to use strict mode for schema verification.
|
|
153
|
+
* In strict mode, extra tables/columns are reported as issues.
|
|
154
|
+
* Default: false (tolerant mode - allows superset)
|
|
155
|
+
*/
|
|
156
|
+
readonly strict?: boolean;
|
|
157
|
+
/**
|
|
158
|
+
* Database connection. If provided, schemaVerify will connect before executing.
|
|
159
|
+
* If omitted, the client must already be connected.
|
|
160
|
+
* The type is driver-specific (e.g., string URL for Postgres).
|
|
161
|
+
*/
|
|
162
|
+
readonly connection?: unknown;
|
|
163
|
+
/** Optional progress callback for observing operation progress */
|
|
164
|
+
readonly onProgress?: OnControlProgress;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Options for the sign operation.
|
|
168
|
+
*/
|
|
169
|
+
interface SignOptions {
|
|
170
|
+
/** Contract or unvalidated JSON - validated at runtime via familyInstance.validateContract() */
|
|
171
|
+
readonly contract: unknown;
|
|
172
|
+
/**
|
|
173
|
+
* Path to the contract file (for metadata in the result).
|
|
174
|
+
*/
|
|
175
|
+
readonly contractPath?: string;
|
|
176
|
+
/**
|
|
177
|
+
* Path to the config file (for metadata in the result).
|
|
178
|
+
*/
|
|
179
|
+
readonly configPath?: string;
|
|
180
|
+
/**
|
|
181
|
+
* Database connection. If provided, sign will connect before executing.
|
|
182
|
+
* If omitted, the client must already be connected.
|
|
183
|
+
* The type is driver-specific (e.g., string URL for Postgres).
|
|
184
|
+
*/
|
|
185
|
+
readonly connection?: unknown;
|
|
186
|
+
/** Optional progress callback for observing operation progress */
|
|
187
|
+
readonly onProgress?: OnControlProgress;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Options for the dbInit operation.
|
|
191
|
+
*/
|
|
192
|
+
interface DbInitOptions {
|
|
193
|
+
/** Contract or unvalidated JSON - validated at runtime via familyInstance.validateContract() */
|
|
194
|
+
readonly contract: unknown;
|
|
195
|
+
/**
|
|
196
|
+
* Mode for the dbInit operation.
|
|
197
|
+
* - 'plan': Returns planned operations without applying
|
|
198
|
+
* - 'apply': Applies operations and writes marker
|
|
199
|
+
*/
|
|
200
|
+
readonly mode: 'plan' | 'apply';
|
|
201
|
+
/**
|
|
202
|
+
* Database connection. If provided, dbInit will connect before executing.
|
|
203
|
+
* If omitted, the client must already be connected.
|
|
204
|
+
* The type is driver-specific (e.g., string URL for Postgres).
|
|
205
|
+
*/
|
|
206
|
+
readonly connection?: unknown;
|
|
207
|
+
/**
|
|
208
|
+
* On-disk migrations directory. Always required — every `db init`
|
|
209
|
+
* routes through the per-space flow, which reads on-disk
|
|
210
|
+
* `refs/head.json` and extension destination contracts from this
|
|
211
|
+
* root.
|
|
212
|
+
*/
|
|
213
|
+
readonly migrationsDir: string;
|
|
214
|
+
/** Optional progress callback for observing operation progress */
|
|
215
|
+
readonly onProgress?: OnControlProgress;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Options for the dbUpdate operation.
|
|
219
|
+
*/
|
|
220
|
+
interface DbUpdateOptions {
|
|
221
|
+
/** Contract or unvalidated JSON - validated at runtime via familyInstance.validateContract() */
|
|
222
|
+
readonly contract: unknown;
|
|
223
|
+
/**
|
|
224
|
+
* Mode for the dbUpdate operation.
|
|
225
|
+
* - 'plan': Returns planned operations without applying
|
|
226
|
+
* - 'apply': Applies operations and writes marker/ledger
|
|
227
|
+
*/
|
|
228
|
+
readonly mode: 'plan' | 'apply';
|
|
229
|
+
/**
|
|
230
|
+
* Database connection. If provided, dbUpdate will connect before executing.
|
|
231
|
+
* If omitted, the client must already be connected.
|
|
232
|
+
* The type is driver-specific (e.g., string URL for Postgres).
|
|
233
|
+
*/
|
|
234
|
+
readonly connection?: unknown;
|
|
235
|
+
/**
|
|
236
|
+
* When true, allows applying plans that contain destructive operations
|
|
237
|
+
* (e.g., DROP TABLE, DROP COLUMN, ALTER TYPE).
|
|
238
|
+
* When false (default), the operation returns a failure if the plan
|
|
239
|
+
* includes destructive operations, prompting the user to confirm interactively
|
|
240
|
+
* or re-run with -y/--yes.
|
|
241
|
+
*/
|
|
242
|
+
readonly acceptDataLoss?: boolean;
|
|
243
|
+
/**
|
|
244
|
+
* On-disk migrations directory. Always required — every `db update`
|
|
245
|
+
* routes through the per-space flow, which reads on-disk
|
|
246
|
+
* `refs/head.json` and extension destination contracts from this
|
|
247
|
+
* root.
|
|
248
|
+
*/
|
|
249
|
+
readonly migrationsDir: string;
|
|
250
|
+
/** Optional progress callback for observing operation progress */
|
|
251
|
+
readonly onProgress?: OnControlProgress;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Options for the dbVerify operation.
|
|
255
|
+
*
|
|
256
|
+
* Drives the loader → aggregate-verifier pipeline. `strict` maps to
|
|
257
|
+
* `verifyAggregate({ mode: 'strict' | 'lenient' })`; `skipSchema`
|
|
258
|
+
* mirrors the `--marker-only` CLI flag and short-circuits the schema
|
|
259
|
+
* portion of the verifier.
|
|
260
|
+
*/
|
|
261
|
+
interface DbVerifyOptions {
|
|
262
|
+
readonly contract: unknown;
|
|
263
|
+
readonly migrationsDir: string;
|
|
264
|
+
readonly strict: boolean;
|
|
265
|
+
readonly skipSchema: boolean;
|
|
266
|
+
readonly skipMarker: boolean;
|
|
267
|
+
readonly connection?: unknown;
|
|
268
|
+
readonly onProgress?: OnControlProgress;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Options for the introspect operation.
|
|
272
|
+
*/
|
|
273
|
+
interface IntrospectOptions {
|
|
274
|
+
/**
|
|
275
|
+
* Optional schema name to introspect.
|
|
276
|
+
*/
|
|
277
|
+
readonly schema?: string;
|
|
278
|
+
/**
|
|
279
|
+
* Database connection. If provided, introspect will connect before executing.
|
|
280
|
+
* If omitted, the client must already be connected.
|
|
281
|
+
* The type is driver-specific (e.g., string URL for Postgres).
|
|
282
|
+
*/
|
|
283
|
+
readonly connection?: unknown;
|
|
284
|
+
/** Optional progress callback for observing operation progress */
|
|
285
|
+
readonly onProgress?: OnControlProgress;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Contract configuration for emit operation.
|
|
289
|
+
*/
|
|
290
|
+
interface EmitContractConfig {
|
|
291
|
+
/**
|
|
292
|
+
* Contract source provider.
|
|
293
|
+
*/
|
|
294
|
+
readonly source: ContractSourceProvider;
|
|
295
|
+
/**
|
|
296
|
+
* Output path for contract.json.
|
|
297
|
+
* The .d.ts types file will be colocated (e.g., contract.json → contract.d.ts).
|
|
298
|
+
*/
|
|
299
|
+
readonly output: string;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Options for the emit operation.
|
|
303
|
+
*/
|
|
304
|
+
interface EmitOptions {
|
|
305
|
+
/**
|
|
306
|
+
* Contract configuration containing source, output, and types paths.
|
|
307
|
+
*/
|
|
308
|
+
readonly contractConfig: EmitContractConfig;
|
|
309
|
+
/** Optional progress callback for observing operation progress */
|
|
310
|
+
readonly onProgress?: OnControlProgress;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Per-space breakdown of an aggregate plan / apply.
|
|
314
|
+
*
|
|
315
|
+
* Surfaces the canonical schedule shape — extensions alphabetically,
|
|
316
|
+
* then app — together with the operations attributed to each space and,
|
|
317
|
+
* when the run was applied, the resulting per-space marker hash.
|
|
318
|
+
*
|
|
319
|
+
* M6 sub-spec § Output shape contract — every space involved in a run
|
|
320
|
+
* is observable in the success summary, including its post-apply
|
|
321
|
+
* marker, so the per-space invariant is visible to the user (closing
|
|
322
|
+
* F4 / F7 from `e2e-verification.md`).
|
|
323
|
+
*/
|
|
324
|
+
interface AggregatePerSpaceExecutionEntry {
|
|
325
|
+
readonly spaceId: string;
|
|
326
|
+
/** `'app'` for the application's contract space; `'extension'` for any extension space. */
|
|
327
|
+
readonly kind: 'app' | 'extension';
|
|
328
|
+
/**
|
|
329
|
+
* Operations attributed to this space (display ops). In `mode: 'plan'`
|
|
330
|
+
* this is the planned set; in `mode: 'apply'` it is the same set
|
|
331
|
+
* (every op was executed in order, the runner does not skip).
|
|
332
|
+
*/
|
|
333
|
+
readonly operations: ReadonlyArray<{
|
|
334
|
+
readonly id: string;
|
|
335
|
+
readonly label: string;
|
|
336
|
+
readonly operationClass: string;
|
|
337
|
+
}>;
|
|
338
|
+
/**
|
|
339
|
+
* Post-apply marker hash for this space. Present only when the run
|
|
340
|
+
* was applied (i.e. `mode: 'apply'` and the runner returned ok).
|
|
341
|
+
* Equals the per-space plan's `destination.storageHash`.
|
|
342
|
+
*/
|
|
343
|
+
readonly marker?: {
|
|
344
|
+
readonly storageHash: string;
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Successful dbInit result.
|
|
349
|
+
*/
|
|
350
|
+
interface DbInitSuccess {
|
|
351
|
+
readonly mode: 'plan' | 'apply';
|
|
352
|
+
readonly plan: {
|
|
353
|
+
readonly operations: ReadonlyArray<{
|
|
354
|
+
readonly id: string;
|
|
355
|
+
readonly label: string;
|
|
356
|
+
readonly operationClass: string;
|
|
357
|
+
}>;
|
|
358
|
+
/**
|
|
359
|
+
* Family-agnostic textual preview of the planned operations, e.g.
|
|
360
|
+
* `language: 'sql'` for SQL families and `language: 'mongodb-shell'`
|
|
361
|
+
* for the Mongo family. Replaces the previous `sql?: readonly string[]`
|
|
362
|
+
* field; consumers that previously read `plan.sql` should read
|
|
363
|
+
* `plan.preview?.statements.map((s) => s.text)`.
|
|
364
|
+
*/
|
|
365
|
+
readonly preview?: OperationPreview;
|
|
366
|
+
};
|
|
367
|
+
readonly destination: {
|
|
368
|
+
readonly storageHash: string;
|
|
369
|
+
readonly profileHash?: string;
|
|
370
|
+
};
|
|
371
|
+
readonly execution?: {
|
|
372
|
+
readonly operationsPlanned: number;
|
|
373
|
+
readonly operationsExecuted: number;
|
|
374
|
+
};
|
|
375
|
+
readonly marker?: {
|
|
376
|
+
readonly storageHash: string;
|
|
377
|
+
readonly profileHash?: string;
|
|
378
|
+
};
|
|
379
|
+
/**
|
|
380
|
+
* Per-space breakdown in canonical schedule order (extensions
|
|
381
|
+
* alphabetically, then app). Present whenever the aggregate flow
|
|
382
|
+
* produced one — both `mode: 'plan'` and `mode: 'apply'`.
|
|
383
|
+
*
|
|
384
|
+
* See {@link AggregatePerSpaceExecutionEntry}.
|
|
385
|
+
*/
|
|
386
|
+
readonly perSpace?: ReadonlyArray<AggregatePerSpaceExecutionEntry>;
|
|
387
|
+
readonly summary: string;
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Failure codes for dbInit operation.
|
|
391
|
+
*/
|
|
392
|
+
type DbInitFailureCode = 'PLANNING_FAILED' | 'MARKER_ORIGIN_MISMATCH' | 'RUNNER_FAILED';
|
|
393
|
+
/**
|
|
394
|
+
* Failure details for dbInit operation.
|
|
395
|
+
*/
|
|
396
|
+
interface DbInitFailure {
|
|
397
|
+
readonly code: DbInitFailureCode;
|
|
398
|
+
readonly summary: string;
|
|
399
|
+
readonly why: string | undefined;
|
|
400
|
+
readonly conflicts: ReadonlyArray<MigrationPlannerConflict> | undefined;
|
|
401
|
+
readonly meta: Record<string, unknown> | undefined;
|
|
402
|
+
readonly marker?: {
|
|
403
|
+
readonly storageHash?: string;
|
|
404
|
+
readonly profileHash?: string;
|
|
405
|
+
};
|
|
406
|
+
readonly destination?: {
|
|
407
|
+
readonly storageHash: string;
|
|
408
|
+
readonly profileHash?: string | undefined;
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* Result type for dbInit operation.
|
|
413
|
+
* Uses Result pattern: success returns DbInitSuccess, failure returns DbInitFailure.
|
|
414
|
+
*/
|
|
415
|
+
type DbInitResult = Result<DbInitSuccess, DbInitFailure>;
|
|
416
|
+
/**
|
|
417
|
+
* Successful dbUpdate result.
|
|
418
|
+
*/
|
|
419
|
+
interface DbUpdateSuccess {
|
|
420
|
+
readonly mode: 'plan' | 'apply';
|
|
421
|
+
readonly plan: {
|
|
422
|
+
readonly operations: ReadonlyArray<{
|
|
423
|
+
readonly id: string;
|
|
424
|
+
readonly label: string;
|
|
425
|
+
readonly operationClass: string;
|
|
426
|
+
}>;
|
|
427
|
+
/**
|
|
428
|
+
* Family-agnostic textual preview of the planned operations, e.g.
|
|
429
|
+
* `language: 'sql'` for SQL families and `language: 'mongodb-shell'`
|
|
430
|
+
* for the Mongo family. Replaces the previous `sql?: readonly string[]`
|
|
431
|
+
* field; consumers that previously read `plan.sql` should read
|
|
432
|
+
* `plan.preview?.statements.map((s) => s.text)`.
|
|
433
|
+
*/
|
|
434
|
+
readonly preview?: OperationPreview;
|
|
435
|
+
};
|
|
436
|
+
readonly destination: {
|
|
437
|
+
readonly storageHash: string;
|
|
438
|
+
readonly profileHash?: string;
|
|
439
|
+
};
|
|
440
|
+
readonly execution?: {
|
|
441
|
+
readonly operationsPlanned: number;
|
|
442
|
+
readonly operationsExecuted: number;
|
|
443
|
+
};
|
|
444
|
+
readonly marker?: {
|
|
445
|
+
readonly storageHash: string;
|
|
446
|
+
readonly profileHash?: string;
|
|
447
|
+
};
|
|
448
|
+
/**
|
|
449
|
+
* Per-space breakdown in canonical schedule order (extensions
|
|
450
|
+
* alphabetically, then app). See {@link AggregatePerSpaceExecutionEntry}.
|
|
451
|
+
*/
|
|
452
|
+
readonly perSpace?: ReadonlyArray<AggregatePerSpaceExecutionEntry>;
|
|
453
|
+
readonly summary: string;
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* Failure codes for dbUpdate operation.
|
|
457
|
+
*/
|
|
458
|
+
type DbUpdateFailureCode = 'PLANNING_FAILED' | 'RUNNER_FAILED' | 'DESTRUCTIVE_CHANGES';
|
|
459
|
+
/**
|
|
460
|
+
* Failure details for dbUpdate operation.
|
|
461
|
+
*/
|
|
462
|
+
interface DbUpdateFailure {
|
|
463
|
+
readonly code: DbUpdateFailureCode;
|
|
464
|
+
readonly summary: string;
|
|
465
|
+
readonly why: string | undefined;
|
|
466
|
+
readonly conflicts: ReadonlyArray<MigrationPlannerConflict> | undefined;
|
|
467
|
+
readonly meta: Record<string, unknown> | undefined;
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* Result type for dbUpdate operation.
|
|
471
|
+
* Uses Result pattern: success returns DbUpdateSuccess, failure returns DbUpdateFailure.
|
|
472
|
+
*/
|
|
473
|
+
type DbUpdateResult = Result<DbUpdateSuccess, DbUpdateFailure>;
|
|
474
|
+
/**
|
|
475
|
+
* Successful emit result.
|
|
476
|
+
* Contains the hashes and paths of emitted files.
|
|
477
|
+
*/
|
|
478
|
+
interface EmitSuccess {
|
|
479
|
+
/** Storage hash of the emitted contract */
|
|
480
|
+
readonly storageHash: string;
|
|
481
|
+
/** Execution hash of the emitted contract (if execution section exists) */
|
|
482
|
+
readonly executionHash?: string;
|
|
483
|
+
/** Profile hash of the emitted contract (target-specific) */
|
|
484
|
+
readonly profileHash: string;
|
|
485
|
+
/** The emitted contract as JSON string */
|
|
486
|
+
readonly contractJson: string;
|
|
487
|
+
/** The emitted contract TypeScript declarations */
|
|
488
|
+
readonly contractDts: string;
|
|
489
|
+
}
|
|
490
|
+
/**
|
|
491
|
+
* Failure codes for emit operation.
|
|
492
|
+
*/
|
|
493
|
+
type EmitFailureCode = 'CONTRACT_SOURCE_INVALID' | 'CONTRACT_VALIDATION_FAILED' | 'EMIT_FAILED';
|
|
494
|
+
/**
|
|
495
|
+
* Failure details for emit operation.
|
|
496
|
+
*/
|
|
497
|
+
interface EmitFailure {
|
|
498
|
+
readonly code: EmitFailureCode;
|
|
499
|
+
readonly summary: string;
|
|
500
|
+
readonly why: string | undefined;
|
|
501
|
+
readonly meta: Record<string, unknown> | undefined;
|
|
502
|
+
readonly diagnostics?: ContractSourceDiagnostics;
|
|
503
|
+
}
|
|
504
|
+
/**
|
|
505
|
+
* Result type for emit operation.
|
|
506
|
+
* Uses Result pattern: success returns EmitSuccess, failure returns EmitFailure.
|
|
507
|
+
*/
|
|
508
|
+
type EmitResult = Result<EmitSuccess, EmitFailure>;
|
|
509
|
+
/**
|
|
510
|
+
* Options for the aggregate-walking `migrationApply` operation.
|
|
511
|
+
*
|
|
512
|
+
* The control-api operation is responsible for: loading the
|
|
513
|
+
* contract-space aggregate, reading per-space marker rows from the
|
|
514
|
+
* live database, plotting per-space paths via `graphWalkStrategy`
|
|
515
|
+
* (replay-only — no synth, no introspection), and dispatching
|
|
516
|
+
* through the shared `applyAggregate` primitive. The CLI command
|
|
517
|
+
* just resolves the descriptor surface (config, refs, contract
|
|
518
|
+
* envelope, app-space migration packages) and hands the inputs in.
|
|
519
|
+
*
|
|
520
|
+
* Sub-spec § `migration apply` semantics + § Required changes 1.
|
|
521
|
+
*/
|
|
522
|
+
interface MigrationApplyOptions {
|
|
523
|
+
/** Already-validated app contract (the canonical "where we are heading" hash). */
|
|
524
|
+
readonly contract: unknown;
|
|
525
|
+
/** Migrations root directory (`migrations/` under the project). */
|
|
526
|
+
readonly migrationsDir: string;
|
|
527
|
+
/**
|
|
528
|
+
* Already-loaded app-space migration packages. The CLI loads these
|
|
529
|
+
* via `loadMigrationPackages(appMigrationsDir)` before invoking
|
|
530
|
+
* `migrationApply`.
|
|
531
|
+
*/
|
|
532
|
+
readonly appMigrationPackages: ReadonlyArray<OnDiskMigrationPackage>;
|
|
533
|
+
/**
|
|
534
|
+
* Optional app-space ref override. When provided, the app member's
|
|
535
|
+
* graph-walk targets this hash instead of `contract.storage.storageHash`.
|
|
536
|
+
* Extension members always walk to their own `headRef.hash`.
|
|
537
|
+
*/
|
|
538
|
+
readonly refHash?: string;
|
|
539
|
+
/**
|
|
540
|
+
* Required invariants on the user-supplied app-space ref. Threaded
|
|
541
|
+
* into the graph-walk's `required` calculation so the planner picks
|
|
542
|
+
* an invariant-bearing path. Ignored when `refHash` is absent.
|
|
543
|
+
*/
|
|
544
|
+
readonly refInvariants?: readonly string[];
|
|
545
|
+
/**
|
|
546
|
+
* Resolved name of the user-supplied app-space ref (the literal the
|
|
547
|
+
* user passed to `--ref`). Decorates `pathDecision.refName` and any
|
|
548
|
+
* `MIGRATION.NO_INVARIANT_PATH` envelope raised during graph-walk.
|
|
549
|
+
* Ignored when `refHash` is absent.
|
|
550
|
+
*/
|
|
551
|
+
readonly refName?: string;
|
|
552
|
+
/**
|
|
553
|
+
* Database connection. If provided, migrationApply will connect before executing.
|
|
554
|
+
* If omitted, the client must already be connected.
|
|
555
|
+
*/
|
|
556
|
+
readonly connection?: unknown;
|
|
557
|
+
/** Optional progress callback for observing operation progress */
|
|
558
|
+
readonly onProgress?: OnControlProgress;
|
|
559
|
+
}
|
|
560
|
+
/**
|
|
561
|
+
* Record of a successfully applied per-space migration. One entry per
|
|
562
|
+
* contract space that had pending migrations — empty `applied` means
|
|
563
|
+
* every space was already at its head.
|
|
564
|
+
*/
|
|
565
|
+
/**
|
|
566
|
+
* One entry per authored migration package applied. Preserves the
|
|
567
|
+
* single-space `migrationsApplied` count semantics (each entry is
|
|
568
|
+
* one migration directory) so `applied.length === migrationsApplied`.
|
|
569
|
+
*
|
|
570
|
+
* Per-space aggregate detail (markers, ops grouped by space) lives
|
|
571
|
+
* on `perSpace[]`; this list is the per-edge view.
|
|
572
|
+
*/
|
|
573
|
+
interface MigrationApplyAppliedEntry {
|
|
574
|
+
readonly spaceId: string;
|
|
575
|
+
readonly dirName: string;
|
|
576
|
+
readonly migrationHash: string;
|
|
577
|
+
readonly from: string;
|
|
578
|
+
readonly to: string;
|
|
579
|
+
readonly operationsExecuted: number;
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* Successful migrationApply result. Carries both the legacy
|
|
583
|
+
* single-space fields (`markerHash` is the **app member's** post-apply
|
|
584
|
+
* marker, surfaced for back-compat with single-space callers) and the
|
|
585
|
+
* per-space breakdown (`perSpace` — markers / operations / canonical
|
|
586
|
+
* order, per M6 sub-spec § Output shape).
|
|
587
|
+
*/
|
|
588
|
+
/**
|
|
589
|
+
* Path-decision summary for the **app member** post-apply. Surfaced
|
|
590
|
+
* for back-compat with single-space callers (and the cli-journeys
|
|
591
|
+
* suite, which inspects `requiredInvariants`/`satisfiedInvariants`/
|
|
592
|
+
* `selectedPath` to validate invariant routing).
|
|
593
|
+
*
|
|
594
|
+
* Per-space path decisions for extension members are not surfaced —
|
|
595
|
+
* extensions own their own ref/invariant control.
|
|
596
|
+
*/
|
|
597
|
+
interface MigrationApplyPathDecision {
|
|
598
|
+
readonly fromHash: string;
|
|
599
|
+
readonly toHash: string;
|
|
600
|
+
readonly alternativeCount: number;
|
|
601
|
+
readonly tieBreakReasons: readonly string[];
|
|
602
|
+
readonly refName?: string;
|
|
603
|
+
readonly requiredInvariants: readonly string[];
|
|
604
|
+
readonly satisfiedInvariants: readonly string[];
|
|
605
|
+
readonly selectedPath: readonly {
|
|
606
|
+
readonly dirName: string;
|
|
607
|
+
readonly migrationHash: string;
|
|
608
|
+
readonly from: string;
|
|
609
|
+
readonly to: string;
|
|
610
|
+
readonly invariants: readonly string[];
|
|
611
|
+
}[];
|
|
612
|
+
}
|
|
613
|
+
interface MigrationApplySuccess {
|
|
614
|
+
readonly migrationsApplied: number;
|
|
615
|
+
readonly markerHash: string;
|
|
616
|
+
readonly applied: readonly MigrationApplyAppliedEntry[];
|
|
617
|
+
readonly summary: string;
|
|
618
|
+
/**
|
|
619
|
+
* Per-space breakdown in canonical schedule order (extensions
|
|
620
|
+
* alphabetically, then app). See {@link AggregatePerSpaceExecutionEntry}.
|
|
621
|
+
* Always present for the aggregate-walking operation.
|
|
622
|
+
*/
|
|
623
|
+
readonly perSpace: ReadonlyArray<AggregatePerSpaceExecutionEntry>;
|
|
624
|
+
/**
|
|
625
|
+
* Path-decision data for the app member. Present whenever the
|
|
626
|
+
* graph-walk strategy ran for the app (i.e. always for the
|
|
627
|
+
* aggregate-walking apply path). Absent only for the no-op
|
|
628
|
+
* "Already up to date" early return when the app has no plan.
|
|
629
|
+
*/
|
|
630
|
+
readonly pathDecision?: MigrationApplyPathDecision;
|
|
631
|
+
}
|
|
632
|
+
/**
|
|
633
|
+
* Failure codes for migrationApply operation.
|
|
634
|
+
*/
|
|
635
|
+
type MigrationApplyFailureCode = 'RUNNER_FAILED' | 'MIGRATION_PATH_NOT_FOUND';
|
|
636
|
+
/**
|
|
637
|
+
* Failure details for migrationApply operation.
|
|
638
|
+
*/
|
|
639
|
+
interface MigrationApplyFailure {
|
|
640
|
+
readonly code: MigrationApplyFailureCode;
|
|
641
|
+
readonly summary: string;
|
|
642
|
+
readonly why: string | undefined;
|
|
643
|
+
readonly meta: Record<string, unknown> | undefined;
|
|
644
|
+
}
|
|
645
|
+
/**
|
|
646
|
+
* Result type for migrationApply operation.
|
|
647
|
+
*/
|
|
648
|
+
type MigrationApplyResult = Result<MigrationApplySuccess, MigrationApplyFailure>;
|
|
649
|
+
/**
|
|
650
|
+
* Options for the standalone executeContractEmit function.
|
|
651
|
+
*
|
|
652
|
+
* `executeContractEmit` is the canonical publication path for both the
|
|
653
|
+
* `prisma-next contract emit` CLI command and the `@prisma-next/vite-plugin-contract-emit`
|
|
654
|
+
* Vite plugin. Do not duplicate the load → emit → publish dance elsewhere; if a
|
|
655
|
+
* caller needs additional behavior, extend this options shape and update the
|
|
656
|
+
* single implementation rather than building a parallel publication path.
|
|
657
|
+
*
|
|
658
|
+
* Concurrent calls for the same output JSON path are serialized per-output via
|
|
659
|
+
* a FIFO queue; concurrent calls for distinct outputs run in parallel.
|
|
660
|
+
*/
|
|
661
|
+
interface ContractEmitOptions {
|
|
662
|
+
/** Path to the prisma-next.config.ts file */
|
|
663
|
+
readonly configPath: string;
|
|
664
|
+
/** Optional AbortSignal for cancelling the in-flight emit */
|
|
665
|
+
readonly signal?: AbortSignal;
|
|
666
|
+
/** Optional progress callback for observing source-resolution and emit spans */
|
|
667
|
+
readonly onProgress?: OnControlProgress;
|
|
668
|
+
}
|
|
669
|
+
/**
|
|
670
|
+
* Result from the standalone executeContractEmit function.
|
|
671
|
+
*
|
|
672
|
+
* Always describes the bytes that were just published to disk. Failures throw
|
|
673
|
+
* (config / source-resolution / emit / publish) — callers do not need to
|
|
674
|
+
* branch on a result discriminator.
|
|
675
|
+
*/
|
|
676
|
+
interface ContractEmitResult {
|
|
677
|
+
/** Hash of the storage contract (schema-level) */
|
|
678
|
+
readonly storageHash: string;
|
|
679
|
+
/** Hash of the execution contract (if execution section exists) */
|
|
680
|
+
readonly executionHash?: string;
|
|
681
|
+
/** Hash of the profile (target+extensions) */
|
|
682
|
+
readonly profileHash: string;
|
|
683
|
+
/** Paths to the emitted files */
|
|
684
|
+
readonly files: {
|
|
685
|
+
/** Path to the emitted contract.json file */readonly json: string; /** Path to the emitted contract.d.ts file */
|
|
686
|
+
readonly dts: string;
|
|
687
|
+
};
|
|
688
|
+
/**
|
|
689
|
+
* Warning surfaced by `validateContractDeps` after a successful publication.
|
|
690
|
+
* Callers (CLI, Vite plugin) decide how to render this; the operation does
|
|
691
|
+
* not write to stderr itself. Undefined when no warning was raised.
|
|
692
|
+
*/
|
|
693
|
+
readonly validationWarning?: string;
|
|
694
|
+
}
|
|
695
|
+
/**
|
|
696
|
+
* Programmatic control client for Prisma Next operations.
|
|
697
|
+
*
|
|
698
|
+
* Lifecycle: `connect(connection)` before operations, `close()` when done.
|
|
699
|
+
* Both `init()` and `connect()` are auto-called by operations if needed,
|
|
700
|
+
* but `connect()` requires a connection so must be called explicitly first
|
|
701
|
+
* unless a default connection was provided in options.
|
|
702
|
+
*
|
|
703
|
+
* @see README.md "Programmatic Control API" section for usage examples
|
|
704
|
+
*/
|
|
705
|
+
interface ControlClient {
|
|
706
|
+
/**
|
|
707
|
+
* Initializes the client by creating the control plane stack,
|
|
708
|
+
* family instance, and validating framework components.
|
|
709
|
+
*
|
|
710
|
+
* Idempotent (safe to call multiple times).
|
|
711
|
+
* Called automatically by `connect()` if not already initialized.
|
|
712
|
+
*/
|
|
713
|
+
init(): void;
|
|
714
|
+
/**
|
|
715
|
+
* Establishes a database connection.
|
|
716
|
+
* Auto-calls `init()` if not already initialized.
|
|
717
|
+
* Must be called before any database operations unless a default connection
|
|
718
|
+
* was provided in options.
|
|
719
|
+
*
|
|
720
|
+
* @param connection - Driver-specific connection input (e.g., URL string for Postgres).
|
|
721
|
+
* If omitted, uses the default connection from options (if provided).
|
|
722
|
+
* @throws If connection fails, already connected, driver is not configured,
|
|
723
|
+
* or no connection provided and no default connection in options.
|
|
724
|
+
*/
|
|
725
|
+
connect(connection?: unknown): Promise<void>;
|
|
726
|
+
/**
|
|
727
|
+
* Closes the database connection.
|
|
728
|
+
* Idempotent (safe to call multiple times).
|
|
729
|
+
* After close(), can call `connect()` again with same or different URL.
|
|
730
|
+
*/
|
|
731
|
+
close(): Promise<void>;
|
|
732
|
+
/**
|
|
733
|
+
* Verifies database marker matches the contract.
|
|
734
|
+
* Compares storageHash and profileHash.
|
|
735
|
+
*
|
|
736
|
+
* @returns Structured result (ok: false for mismatch, not throwing)
|
|
737
|
+
* @throws If not connected or infrastructure failure
|
|
738
|
+
*/
|
|
739
|
+
verify(options: VerifyOptions): Promise<VerifyDatabaseResult>;
|
|
740
|
+
/**
|
|
741
|
+
* Verifies database schema satisfies the contract requirements.
|
|
742
|
+
*
|
|
743
|
+
* @param options.strict - If true, extra tables/columns are issues. Default: false
|
|
744
|
+
* @returns Structured result with schema issues
|
|
745
|
+
* @throws If not connected or infrastructure failure
|
|
746
|
+
*/
|
|
747
|
+
schemaVerify(options: SchemaVerifyOptions): Promise<VerifyDatabaseSchemaResult>;
|
|
748
|
+
/**
|
|
749
|
+
* Signs the database with a contract signature.
|
|
750
|
+
* Writes or updates the signature if schema verification passes.
|
|
751
|
+
* Idempotent (no-op if signature already matches).
|
|
752
|
+
*
|
|
753
|
+
* @returns Structured result
|
|
754
|
+
* @throws If not connected or infrastructure failure
|
|
755
|
+
*/
|
|
756
|
+
sign(options: SignOptions): Promise<SignDatabaseResult>;
|
|
757
|
+
/**
|
|
758
|
+
* Initializes database schema from contract.
|
|
759
|
+
* Uses additive-only policy (no destructive changes).
|
|
760
|
+
*
|
|
761
|
+
* @param options.mode - 'plan' to preview, 'apply' to execute
|
|
762
|
+
* @returns Result pattern: Ok with planned/executed operations, NotOk with failure details
|
|
763
|
+
* @throws If not connected, target doesn't support migrations, or infrastructure failure
|
|
764
|
+
*/
|
|
765
|
+
dbInit(options: DbInitOptions): Promise<DbInitResult>;
|
|
766
|
+
/**
|
|
767
|
+
* Updates a database schema to match the current contract.
|
|
768
|
+
* Creates the signature table if it does not exist. No preconditions required.
|
|
769
|
+
* Allows additive, widening, and destructive operation classes.
|
|
770
|
+
*
|
|
771
|
+
* @param options.mode - 'plan' to preview, 'apply' to execute
|
|
772
|
+
* @returns Result pattern: Ok with planned/executed operations, NotOk with failure details
|
|
773
|
+
* @throws If not connected, target doesn't support migrations, or infrastructure failure
|
|
774
|
+
*/
|
|
775
|
+
dbUpdate(options: DbUpdateOptions): Promise<DbUpdateResult>;
|
|
776
|
+
/**
|
|
777
|
+
* Verifies the database against every contract space (app + extensions).
|
|
778
|
+
*
|
|
779
|
+
* Loader → aggregate-verifier pipeline:
|
|
780
|
+
* - The loader catches layout / drift / disjointness violations.
|
|
781
|
+
* - The aggregate verifier surfaces marker-vs-on-disk drift and orphan
|
|
782
|
+
* markers, and (unless `skipSchema` is true) per-space schema
|
|
783
|
+
* verification with pre-projection (closes F23).
|
|
784
|
+
*
|
|
785
|
+
* @returns Result pattern: per-space schema results on success;
|
|
786
|
+
* structured CLI error on marker / loader failure.
|
|
787
|
+
* @throws If not connected or infrastructure failure
|
|
788
|
+
*/
|
|
789
|
+
dbVerify(options: DbVerifyOptions): Promise<ExecuteDbVerifyResult>;
|
|
790
|
+
/**
|
|
791
|
+
* Reads the contract marker from the database.
|
|
792
|
+
* Returns null if no marker exists (fresh database).
|
|
793
|
+
*
|
|
794
|
+
* @throws If not connected or infrastructure failure
|
|
795
|
+
*/
|
|
796
|
+
readMarker(): Promise<ContractMarkerRecord | null>;
|
|
797
|
+
/**
|
|
798
|
+
* Reads every marker row (one per contract space). Used by the
|
|
799
|
+
* per-space verifier to detect orphan marker rows and marker-vs-on-disk
|
|
800
|
+
* drift after a database connection has been established.
|
|
801
|
+
*/
|
|
802
|
+
readAllMarkers(): Promise<ReadonlyMap<string, ContractMarkerRecord>>;
|
|
803
|
+
/**
|
|
804
|
+
* Applies pre-planned on-disk migrations to the database.
|
|
805
|
+
* Each migration runs in its own transaction with full execution checks.
|
|
806
|
+
* Resume-safe: re-running after failure picks up from the last applied migration.
|
|
807
|
+
*
|
|
808
|
+
* @param options.originHash - Explicit source hash for the apply path
|
|
809
|
+
* @param options.destinationHash - Explicit destination hash for the apply path
|
|
810
|
+
* @param options.pendingMigrations - Ordered migrations to execute
|
|
811
|
+
* @returns Result pattern: Ok with applied details, NotOk with failure details
|
|
812
|
+
* @throws If not connected, target doesn't support migrations, or infrastructure failure
|
|
813
|
+
*/
|
|
814
|
+
migrationApply(options: MigrationApplyOptions): Promise<MigrationApplyResult>;
|
|
815
|
+
/**
|
|
816
|
+
* Introspects the database schema.
|
|
817
|
+
*
|
|
818
|
+
* @returns Raw schema IR
|
|
819
|
+
* @throws If not connected or infrastructure failure
|
|
820
|
+
*/
|
|
821
|
+
introspect(options?: IntrospectOptions): Promise<unknown>;
|
|
822
|
+
/**
|
|
823
|
+
* Converts a schema IR to a schema view for CLI tree rendering.
|
|
824
|
+
* Delegates to the family instance's toSchemaView method.
|
|
825
|
+
*
|
|
826
|
+
* @param schemaIR - The schema IR from introspect()
|
|
827
|
+
* @returns CoreSchemaView if the family supports it, undefined otherwise
|
|
828
|
+
*/
|
|
829
|
+
toSchemaView(schemaIR: unknown): CoreSchemaView | undefined;
|
|
830
|
+
/**
|
|
831
|
+
* Infers a PSL contract AST from an introspected schema IR.
|
|
832
|
+
* Delegates to the family instance's inferPslContract method.
|
|
833
|
+
*
|
|
834
|
+
* @param schemaIR - The schema IR from introspect()
|
|
835
|
+
* @returns PslDocumentAst if the family supports the capability, undefined otherwise
|
|
836
|
+
*/
|
|
837
|
+
inferPslContract(schemaIR: unknown): PslDocumentAst | undefined;
|
|
838
|
+
/**
|
|
839
|
+
* Renders a textual preview of a migration plan's operations for the CLI's
|
|
840
|
+
* "DDL preview" output. Delegates to the family instance's
|
|
841
|
+
* `toOperationPreview` method.
|
|
842
|
+
*
|
|
843
|
+
* @param operations - The migration plan operations to render
|
|
844
|
+
* @returns OperationPreview if the family supports the capability, undefined otherwise
|
|
845
|
+
*/
|
|
846
|
+
toOperationPreview(operations: readonly MigrationPlanOperation[]): OperationPreview | undefined;
|
|
847
|
+
/**
|
|
848
|
+
* Emits the contract to JSON and TypeScript declarations.
|
|
849
|
+
* This is an offline operation that does NOT require a database connection.
|
|
850
|
+
* Uses `init()` to create the stack but does NOT call `connect()`.
|
|
851
|
+
*
|
|
852
|
+
* @returns Result pattern: Ok with emit details, NotOk with failure details
|
|
853
|
+
*/
|
|
854
|
+
emit(options: EmitOptions): Promise<EmitResult>;
|
|
855
|
+
}
|
|
856
|
+
//#endregion
|
|
857
|
+
export { ExecuteDbVerifyOptions as A, EmitSuccess as C, SchemaVerifyOptions as D, OnControlProgress as E, executeDbVerify as M, SignOptions as O, EmitResult as S, MigrationApplyPathDecision as T, DbUpdateSuccess as _, ControlClient as a, EmitFailureCode as b, DbInitFailure as c, DbInitResult as d, DbInitSuccess as f, DbUpdateResult as g, DbUpdateOptions as h, ControlActionName as i, ExecuteDbVerifyResult as j, VerifyOptions as k, DbInitFailureCode as l, DbUpdateFailureCode as m, ContractEmitOptions as n, ControlClientOptions as o, DbUpdateFailure as p, ContractEmitResult as r, ControlProgressEvent as s, AggregatePerSpaceExecutionEntry as t, DbInitOptions as u, EmitContractConfig as v, IntrospectOptions as w, EmitOptions as x, EmitFailure as y };
|
|
858
|
+
//# sourceMappingURL=types-D7x-IFLO.d.mts.map
|