@prisma-next/cli 0.3.0-dev.16 → 0.3.0-dev.163
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/LICENSE +201 -0
- package/README.md +381 -128
- package/dist/cli-errors-BDCYR5ap.mjs +4 -0
- package/dist/cli-errors-Dzs7Oxz7.d.mts +3 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.js +1 -2671
- package/dist/cli.mjs +238 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/client-yYtotiSX.mjs +1063 -0
- package/dist/client-yYtotiSX.mjs.map +1 -0
- package/dist/commands/contract-emit.d.mts +7 -0
- package/dist/commands/contract-emit.d.mts.map +1 -0
- package/dist/commands/contract-emit.mjs +4 -0
- package/dist/commands/contract-infer.d.mts +7 -0
- package/dist/commands/contract-infer.d.mts.map +1 -0
- package/dist/commands/contract-infer.mjs +4 -0
- package/dist/commands/db-init.d.mts +7 -0
- package/dist/commands/db-init.d.mts.map +1 -0
- package/dist/commands/db-init.mjs +124 -0
- package/dist/commands/db-init.mjs.map +1 -0
- package/dist/commands/db-schema.d.mts +7 -0
- package/dist/commands/db-schema.d.mts.map +1 -0
- package/dist/commands/db-schema.mjs +52 -0
- package/dist/commands/db-schema.mjs.map +1 -0
- package/dist/commands/db-sign.d.mts +7 -0
- package/dist/commands/db-sign.d.mts.map +1 -0
- package/dist/commands/db-sign.mjs +135 -0
- package/dist/commands/db-sign.mjs.map +1 -0
- package/dist/commands/db-update.d.mts +7 -0
- package/dist/commands/db-update.d.mts.map +1 -0
- package/dist/commands/db-update.mjs +121 -0
- package/dist/commands/db-update.mjs.map +1 -0
- package/dist/commands/db-verify.d.mts +7 -0
- package/dist/commands/db-verify.d.mts.map +1 -0
- package/dist/commands/db-verify.mjs +321 -0
- package/dist/commands/db-verify.mjs.map +1 -0
- package/dist/commands/migration-apply.d.mts +36 -0
- package/dist/commands/migration-apply.d.mts.map +1 -0
- package/dist/commands/migration-apply.mjs +243 -0
- package/dist/commands/migration-apply.mjs.map +1 -0
- package/dist/commands/migration-new.d.mts +8 -0
- package/dist/commands/migration-new.d.mts.map +1 -0
- package/dist/commands/migration-new.mjs +151 -0
- package/dist/commands/migration-new.mjs.map +1 -0
- package/dist/commands/migration-plan.d.mts +47 -0
- package/dist/commands/migration-plan.d.mts.map +1 -0
- package/dist/commands/migration-plan.mjs +312 -0
- package/dist/commands/migration-plan.mjs.map +1 -0
- package/dist/commands/migration-ref.d.mts +43 -0
- package/dist/commands/migration-ref.d.mts.map +1 -0
- package/dist/commands/migration-ref.mjs +194 -0
- package/dist/commands/migration-ref.mjs.map +1 -0
- package/dist/commands/migration-show.d.mts +28 -0
- package/dist/commands/migration-show.d.mts.map +1 -0
- package/dist/commands/migration-show.mjs +139 -0
- package/dist/commands/migration-show.mjs.map +1 -0
- package/dist/commands/migration-status.d.mts +86 -0
- package/dist/commands/migration-status.d.mts.map +1 -0
- package/dist/commands/migration-status.mjs +4 -0
- package/dist/commands/migration-verify.d.mts +16 -0
- package/dist/commands/migration-verify.d.mts.map +1 -0
- package/dist/commands/migration-verify.mjs +109 -0
- package/dist/commands/migration-verify.mjs.map +1 -0
- package/dist/config-loader-C4VXKl8f.mjs +43 -0
- package/dist/config-loader-C4VXKl8f.mjs.map +1 -0
- package/dist/{config-loader.d.ts → config-loader.d.mts} +8 -3
- package/dist/config-loader.d.mts.map +1 -0
- package/dist/config-loader.mjs +3 -0
- package/dist/contract-emit-Bk_eEDKu.mjs +187 -0
- package/dist/contract-emit-Bk_eEDKu.mjs.map +1 -0
- package/dist/contract-infer-suMDmFSG.mjs +89 -0
- package/dist/contract-infer-suMDmFSG.mjs.map +1 -0
- package/dist/exports/config-types.d.mts +2 -0
- package/dist/exports/config-types.mjs +3 -0
- package/dist/exports/control-api.d.mts +624 -0
- package/dist/exports/control-api.d.mts.map +1 -0
- package/dist/exports/control-api.mjs +109 -0
- package/dist/exports/control-api.mjs.map +1 -0
- package/dist/{load-ts-contract.d.ts → exports/index.d.mts} +12 -7
- package/dist/exports/index.d.mts.map +1 -0
- package/dist/exports/index.mjs +137 -0
- package/dist/exports/index.mjs.map +1 -0
- package/dist/extract-operation-statements-BVlb3jxp.mjs +13 -0
- package/dist/extract-operation-statements-BVlb3jxp.mjs.map +1 -0
- package/dist/extract-sql-ddl-6EVSOThm.mjs +26 -0
- package/dist/extract-sql-ddl-6EVSOThm.mjs.map +1 -0
- package/dist/framework-components-BAsliT4V.mjs +59 -0
- package/dist/framework-components-BAsliT4V.mjs.map +1 -0
- package/dist/inspect-live-schema-HMutsJYh.mjs +91 -0
- package/dist/inspect-live-schema-HMutsJYh.mjs.map +1 -0
- package/dist/migration-command-scaffold-Dg7CKKCg.mjs +105 -0
- package/dist/migration-command-scaffold-Dg7CKKCg.mjs.map +1 -0
- package/dist/migration-status-BqfVmC0w.mjs +1582 -0
- package/dist/migration-status-BqfVmC0w.mjs.map +1 -0
- package/dist/migrations-Bv8oeiY_.mjs +173 -0
- package/dist/migrations-Bv8oeiY_.mjs.map +1 -0
- package/dist/progress-adapter-D4x8SbJa.mjs +43 -0
- package/dist/progress-adapter-D4x8SbJa.mjs.map +1 -0
- package/dist/terminal-ui-N5tR-ob5.mjs +967 -0
- package/dist/terminal-ui-N5tR-ob5.mjs.map +1 -0
- package/dist/verify-WARh5TjK.mjs +385 -0
- package/dist/verify-WARh5TjK.mjs.map +1 -0
- package/package.json +88 -42
- package/src/cli.ts +113 -58
- package/src/commands/contract-emit.ts +237 -144
- package/src/commands/contract-infer-paths.ts +32 -0
- package/src/commands/contract-infer.ts +143 -0
- package/src/commands/db-init.ts +97 -219
- package/src/commands/db-schema.ts +77 -0
- package/src/commands/db-sign.ts +208 -229
- package/src/commands/db-update.ts +236 -0
- package/src/commands/db-verify.ts +504 -184
- package/src/commands/inspect-live-schema.ts +170 -0
- package/src/commands/migration-apply.ts +427 -0
- package/src/commands/migration-new.ts +260 -0
- package/src/commands/migration-plan.ts +519 -0
- package/src/commands/migration-ref.ts +305 -0
- package/src/commands/migration-show.ts +246 -0
- package/src/commands/migration-status.ts +864 -0
- package/src/commands/migration-verify.ts +180 -0
- package/src/config-loader.ts +13 -3
- package/src/control-api/client.ts +424 -72
- package/src/control-api/contract-enrichment.ts +119 -0
- package/src/control-api/errors.ts +9 -0
- package/src/control-api/operations/contract-emit.ts +174 -0
- package/src/control-api/operations/db-init.ts +53 -49
- package/src/control-api/operations/db-update.ts +220 -0
- package/src/control-api/operations/extract-operation-statements.ts +14 -0
- package/src/control-api/operations/extract-sql-ddl.ts +47 -0
- package/src/control-api/operations/migration-apply.ts +191 -0
- package/src/control-api/operations/migration-helpers.ts +49 -0
- package/src/control-api/types.ts +388 -18
- package/src/exports/config-types.ts +4 -3
- package/src/exports/control-api.ts +21 -2
- package/src/load-ts-contract.ts +30 -19
- package/src/utils/cli-errors.ts +14 -8
- package/src/utils/command-helpers.ts +302 -3
- package/src/utils/formatters/emit.ts +67 -0
- package/src/utils/formatters/errors.ts +82 -0
- package/src/utils/formatters/graph-migration-mapper.ts +240 -0
- package/src/utils/formatters/graph-render.ts +1323 -0
- package/src/utils/formatters/graph-types.ts +120 -0
- package/src/utils/formatters/help.ts +380 -0
- package/src/utils/formatters/helpers.ts +28 -0
- package/src/utils/formatters/migrations.ts +346 -0
- package/src/utils/formatters/styled.ts +212 -0
- package/src/utils/formatters/verify.ts +621 -0
- package/src/utils/framework-components.ts +13 -10
- package/src/utils/global-flags.ts +41 -23
- package/src/utils/migration-command-scaffold.ts +184 -0
- package/src/utils/migration-types.ts +12 -0
- package/src/utils/progress-adapter.ts +18 -29
- package/src/utils/result-handler.ts +12 -13
- package/src/utils/shutdown.ts +92 -0
- package/src/utils/suggest-command.ts +31 -0
- package/src/utils/terminal-ui.ts +276 -0
- package/dist/chunk-5MPKZYVI.js +0 -47
- package/dist/chunk-5MPKZYVI.js.map +0 -1
- package/dist/chunk-6EPKRATC.js +0 -91
- package/dist/chunk-6EPKRATC.js.map +0 -1
- package/dist/chunk-74IELXRA.js +0 -371
- package/dist/chunk-74IELXRA.js.map +0 -1
- package/dist/chunk-HWYQOCAJ.js +0 -47
- package/dist/chunk-HWYQOCAJ.js.map +0 -1
- package/dist/chunk-U6QI3AZ3.js +0 -133
- package/dist/chunk-U6QI3AZ3.js.map +0 -1
- package/dist/chunk-VI2YETW7.js +0 -38
- package/dist/chunk-VI2YETW7.js.map +0 -1
- package/dist/chunk-ZG5T6OB5.js +0 -923
- package/dist/chunk-ZG5T6OB5.js.map +0 -1
- package/dist/cli.d.ts +0 -2
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/commands/contract-emit.d.ts +0 -3
- package/dist/commands/contract-emit.d.ts.map +0 -1
- package/dist/commands/contract-emit.js +0 -11
- package/dist/commands/contract-emit.js.map +0 -1
- package/dist/commands/db-init.d.ts +0 -3
- package/dist/commands/db-init.d.ts.map +0 -1
- package/dist/commands/db-init.js +0 -302
- package/dist/commands/db-init.js.map +0 -1
- package/dist/commands/db-introspect.d.ts +0 -3
- package/dist/commands/db-introspect.d.ts.map +0 -1
- package/dist/commands/db-introspect.js +0 -185
- package/dist/commands/db-introspect.js.map +0 -1
- package/dist/commands/db-schema-verify.d.ts +0 -3
- package/dist/commands/db-schema-verify.d.ts.map +0 -1
- package/dist/commands/db-schema-verify.js +0 -163
- package/dist/commands/db-schema-verify.js.map +0 -1
- package/dist/commands/db-sign.d.ts +0 -3
- package/dist/commands/db-sign.d.ts.map +0 -1
- package/dist/commands/db-sign.js +0 -198
- package/dist/commands/db-sign.js.map +0 -1
- package/dist/commands/db-verify.d.ts +0 -3
- package/dist/commands/db-verify.d.ts.map +0 -1
- package/dist/commands/db-verify.js +0 -172
- package/dist/commands/db-verify.js.map +0 -1
- package/dist/config-loader.d.ts.map +0 -1
- package/dist/config-loader.js +0 -7
- package/dist/config-loader.js.map +0 -1
- package/dist/control-api/client.d.ts +0 -13
- package/dist/control-api/client.d.ts.map +0 -1
- package/dist/control-api/operations/db-init.d.ts +0 -29
- package/dist/control-api/operations/db-init.d.ts.map +0 -1
- package/dist/control-api/types.d.ts +0 -256
- package/dist/control-api/types.d.ts.map +0 -1
- package/dist/exports/config-types.d.ts +0 -3
- package/dist/exports/config-types.d.ts.map +0 -1
- package/dist/exports/config-types.js +0 -6
- package/dist/exports/config-types.js.map +0 -1
- package/dist/exports/control-api.d.ts +0 -13
- package/dist/exports/control-api.d.ts.map +0 -1
- package/dist/exports/control-api.js +0 -9
- package/dist/exports/control-api.js.map +0 -1
- package/dist/exports/index.d.ts +0 -4
- package/dist/exports/index.d.ts.map +0 -1
- package/dist/exports/index.js +0 -177
- package/dist/exports/index.js.map +0 -1
- package/dist/load-ts-contract.d.ts.map +0 -1
- package/dist/utils/action.d.ts +0 -16
- package/dist/utils/action.d.ts.map +0 -1
- package/dist/utils/cli-errors.d.ts +0 -7
- package/dist/utils/cli-errors.d.ts.map +0 -1
- package/dist/utils/command-helpers.d.ts +0 -12
- package/dist/utils/command-helpers.d.ts.map +0 -1
- package/dist/utils/framework-components.d.ts +0 -70
- package/dist/utils/framework-components.d.ts.map +0 -1
- package/dist/utils/global-flags.d.ts +0 -25
- package/dist/utils/global-flags.d.ts.map +0 -1
- package/dist/utils/output.d.ts +0 -142
- package/dist/utils/output.d.ts.map +0 -1
- package/dist/utils/progress-adapter.d.ts +0 -26
- package/dist/utils/progress-adapter.d.ts.map +0 -1
- package/dist/utils/result-handler.d.ts +0 -15
- package/dist/utils/result-handler.d.ts.map +0 -1
- package/dist/utils/spinner.d.ts +0 -29
- package/dist/utils/spinner.d.ts.map +0 -1
- package/src/commands/db-introspect.ts +0 -254
- package/src/commands/db-schema-verify.ts +0 -231
- package/src/utils/action.ts +0 -43
- package/src/utils/output.ts +0 -1471
- package/src/utils/spinner.ts +0 -67
package/src/control-api/types.ts
CHANGED
|
@@ -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/
|
|
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
|
|
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 */
|
|
@@ -53,7 +60,15 @@ export interface ControlClientOptions {
|
|
|
53
60
|
/**
|
|
54
61
|
* Action names for control-api operations that can emit progress events.
|
|
55
62
|
*/
|
|
56
|
-
export type ControlActionName =
|
|
63
|
+
export type ControlActionName =
|
|
64
|
+
| 'dbInit'
|
|
65
|
+
| 'dbUpdate'
|
|
66
|
+
| 'migrationApply'
|
|
67
|
+
| 'verify'
|
|
68
|
+
| 'schemaVerify'
|
|
69
|
+
| 'sign'
|
|
70
|
+
| 'introspect'
|
|
71
|
+
| 'emit';
|
|
57
72
|
|
|
58
73
|
/**
|
|
59
74
|
* Progress event emitted during control-api operation execution.
|
|
@@ -98,8 +113,14 @@ export type OnControlProgress = (event: ControlProgressEvent) => void;
|
|
|
98
113
|
* Options for the verify operation.
|
|
99
114
|
*/
|
|
100
115
|
export interface VerifyOptions {
|
|
101
|
-
/** Contract
|
|
102
|
-
readonly
|
|
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;
|
|
103
124
|
/** Optional progress callback for observing operation progress */
|
|
104
125
|
readonly onProgress?: OnControlProgress;
|
|
105
126
|
}
|
|
@@ -108,14 +129,20 @@ export interface VerifyOptions {
|
|
|
108
129
|
* Options for the schemaVerify operation.
|
|
109
130
|
*/
|
|
110
131
|
export interface SchemaVerifyOptions {
|
|
111
|
-
/** Contract
|
|
112
|
-
readonly
|
|
132
|
+
/** Contract or unvalidated JSON - validated at runtime via familyInstance.validateContract() */
|
|
133
|
+
readonly contract: unknown;
|
|
113
134
|
/**
|
|
114
135
|
* Whether to use strict mode for schema verification.
|
|
115
136
|
* In strict mode, extra tables/columns are reported as issues.
|
|
116
137
|
* Default: false (tolerant mode - allows superset)
|
|
117
138
|
*/
|
|
118
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;
|
|
119
146
|
/** Optional progress callback for observing operation progress */
|
|
120
147
|
readonly onProgress?: OnControlProgress;
|
|
121
148
|
}
|
|
@@ -124,8 +151,22 @@ export interface SchemaVerifyOptions {
|
|
|
124
151
|
* Options for the sign operation.
|
|
125
152
|
*/
|
|
126
153
|
export interface SignOptions {
|
|
127
|
-
/** Contract
|
|
128
|
-
readonly
|
|
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;
|
|
129
170
|
/** Optional progress callback for observing operation progress */
|
|
130
171
|
readonly onProgress?: OnControlProgress;
|
|
131
172
|
}
|
|
@@ -134,8 +175,8 @@ export interface SignOptions {
|
|
|
134
175
|
* Options for the dbInit operation.
|
|
135
176
|
*/
|
|
136
177
|
export interface DbInitOptions {
|
|
137
|
-
/** Contract
|
|
138
|
-
readonly
|
|
178
|
+
/** Contract or unvalidated JSON - validated at runtime via familyInstance.validateContract() */
|
|
179
|
+
readonly contract: unknown;
|
|
139
180
|
/**
|
|
140
181
|
* Mode for the dbInit operation.
|
|
141
182
|
* - 'plan': Returns planned operations without applying
|
|
@@ -152,6 +193,36 @@ export interface DbInitOptions {
|
|
|
152
193
|
readonly onProgress?: OnControlProgress;
|
|
153
194
|
}
|
|
154
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;
|
|
224
|
+
}
|
|
225
|
+
|
|
155
226
|
/**
|
|
156
227
|
* Options for the introspect operation.
|
|
157
228
|
*/
|
|
@@ -160,6 +231,39 @@ export interface IntrospectOptions {
|
|
|
160
231
|
* Optional schema name to introspect.
|
|
161
232
|
*/
|
|
162
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;
|
|
163
267
|
/** Optional progress callback for observing operation progress */
|
|
164
268
|
readonly onProgress?: OnControlProgress;
|
|
165
269
|
}
|
|
@@ -179,13 +283,18 @@ export interface DbInitSuccess {
|
|
|
179
283
|
readonly label: string;
|
|
180
284
|
readonly operationClass: string;
|
|
181
285
|
}>;
|
|
286
|
+
readonly sql?: ReadonlyArray<string>;
|
|
287
|
+
};
|
|
288
|
+
readonly destination: {
|
|
289
|
+
readonly storageHash: string;
|
|
290
|
+
readonly profileHash?: string;
|
|
182
291
|
};
|
|
183
292
|
readonly execution?: {
|
|
184
293
|
readonly operationsPlanned: number;
|
|
185
294
|
readonly operationsExecuted: number;
|
|
186
295
|
};
|
|
187
296
|
readonly marker?: {
|
|
188
|
-
readonly
|
|
297
|
+
readonly storageHash: string;
|
|
189
298
|
readonly profileHash?: string;
|
|
190
299
|
};
|
|
191
300
|
readonly summary: string;
|
|
@@ -206,11 +315,11 @@ export interface DbInitFailure {
|
|
|
206
315
|
readonly conflicts: ReadonlyArray<MigrationPlannerConflict> | undefined;
|
|
207
316
|
readonly meta: Record<string, unknown> | undefined;
|
|
208
317
|
readonly marker?: {
|
|
209
|
-
readonly
|
|
318
|
+
readonly storageHash?: string;
|
|
210
319
|
readonly profileHash?: string;
|
|
211
320
|
};
|
|
212
321
|
readonly destination?: {
|
|
213
|
-
readonly
|
|
322
|
+
readonly storageHash: string;
|
|
214
323
|
readonly profileHash?: string | undefined;
|
|
215
324
|
};
|
|
216
325
|
}
|
|
@@ -221,6 +330,217 @@ export interface DbInitFailure {
|
|
|
221
330
|
*/
|
|
222
331
|
export type DbInitResult = Result<DbInitSuccess, DbInitFailure>;
|
|
223
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
|
+
|
|
224
544
|
// ============================================================================
|
|
225
545
|
// Client Interface
|
|
226
546
|
// ============================================================================
|
|
@@ -267,7 +587,7 @@ export interface ControlClient {
|
|
|
267
587
|
|
|
268
588
|
/**
|
|
269
589
|
* Verifies database marker matches the contract.
|
|
270
|
-
* Compares
|
|
590
|
+
* Compares storageHash and profileHash.
|
|
271
591
|
*
|
|
272
592
|
* @returns Structured result (ok: false for mismatch, not throwing)
|
|
273
593
|
* @throws If not connected or infrastructure failure
|
|
@@ -284,9 +604,9 @@ export interface ControlClient {
|
|
|
284
604
|
schemaVerify(options: SchemaVerifyOptions): Promise<VerifyDatabaseSchemaResult>;
|
|
285
605
|
|
|
286
606
|
/**
|
|
287
|
-
* Signs the database with a contract
|
|
288
|
-
* Writes or updates the
|
|
289
|
-
* Idempotent (no-op if
|
|
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).
|
|
290
610
|
*
|
|
291
611
|
* @returns Structured result
|
|
292
612
|
* @throws If not connected or infrastructure failure
|
|
@@ -303,6 +623,38 @@ export interface ControlClient {
|
|
|
303
623
|
*/
|
|
304
624
|
dbInit(options: DbInitOptions): Promise<DbInitResult>;
|
|
305
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
|
+
|
|
306
658
|
/**
|
|
307
659
|
* Introspects the database schema.
|
|
308
660
|
*
|
|
@@ -310,4 +662,22 @@ export interface ControlClient {
|
|
|
310
662
|
* @throws If not connected or infrastructure failure
|
|
311
663
|
*/
|
|
312
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>;
|
|
313
683
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
// Re-export
|
|
1
|
+
// Re-export config package types for convenience
|
|
2
2
|
export type {
|
|
3
3
|
ContractConfig,
|
|
4
|
+
ContractSourceContext,
|
|
4
5
|
PrismaNextConfig,
|
|
5
|
-
} from '@prisma-next/
|
|
6
|
-
export { defineConfig } from '@prisma-next/
|
|
6
|
+
} from '@prisma-next/config/config-types';
|
|
7
|
+
export { defineConfig } from '@prisma-next/config/config-types';
|
|
@@ -10,16 +10,24 @@
|
|
|
10
10
|
|
|
11
11
|
// Re-export core control plane types for consumer convenience
|
|
12
12
|
export type {
|
|
13
|
-
|
|
13
|
+
ControlStack,
|
|
14
14
|
SignDatabaseResult,
|
|
15
15
|
VerifyDatabaseResult,
|
|
16
16
|
VerifyDatabaseSchemaResult,
|
|
17
|
-
} from '@prisma-next/
|
|
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,
|
|
23
31
|
ControlActionName,
|
|
24
32
|
ControlClient,
|
|
25
33
|
ControlClientOptions,
|
|
@@ -29,6 +37,17 @@ export type {
|
|
|
29
37
|
DbInitOptions,
|
|
30
38
|
DbInitResult,
|
|
31
39
|
DbInitSuccess,
|
|
40
|
+
DbUpdateFailure,
|
|
41
|
+
DbUpdateFailureCode,
|
|
42
|
+
DbUpdateOptions,
|
|
43
|
+
DbUpdateResult,
|
|
44
|
+
DbUpdateSuccess,
|
|
45
|
+
EmitContractConfig,
|
|
46
|
+
EmitFailure,
|
|
47
|
+
EmitFailureCode,
|
|
48
|
+
EmitOptions,
|
|
49
|
+
EmitResult,
|
|
50
|
+
EmitSuccess,
|
|
32
51
|
IntrospectOptions,
|
|
33
52
|
OnControlProgress,
|
|
34
53
|
SchemaVerifyOptions,
|