@prisma-next/cli 0.3.0-dev.34 → 0.3.0-dev.37
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/README.md +14 -13
- package/dist/cli.d.mts +1 -0
- package/dist/cli.js +1 -2910
- package/dist/cli.mjs +169 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/client-Lm9Q6aQM.mjs +694 -0
- package/dist/client-Lm9Q6aQM.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 +140 -0
- package/dist/commands/contract-emit.mjs.map +1 -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 +179 -0
- package/dist/commands/db-init.mjs.map +1 -0
- package/dist/commands/db-introspect.d.mts +7 -0
- package/dist/commands/db-introspect.d.mts.map +1 -0
- package/dist/commands/db-introspect.mjs +120 -0
- package/dist/commands/db-introspect.mjs.map +1 -0
- package/dist/commands/db-schema-verify.d.mts +7 -0
- package/dist/commands/db-schema-verify.d.mts.map +1 -0
- package/dist/commands/db-schema-verify.mjs +116 -0
- package/dist/commands/db-schema-verify.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 +138 -0
- package/dist/commands/db-sign.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 +129 -0
- package/dist/commands/db-verify.mjs.map +1 -0
- package/dist/config-loader-CnnWuluc.mjs +42 -0
- package/dist/config-loader-CnnWuluc.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/exports/config-types.d.mts +2 -0
- package/dist/exports/config-types.mjs +3 -0
- package/dist/exports/control-api.d.mts +451 -0
- package/dist/exports/control-api.d.mts.map +1 -0
- package/dist/exports/control-api.mjs +59 -0
- package/dist/exports/control-api.mjs.map +1 -0
- package/dist/{load-ts-contract.d.ts → exports/index.d.mts} +10 -5
- package/dist/exports/index.d.mts.map +1 -0
- package/dist/exports/index.mjs +132 -0
- package/dist/exports/index.mjs.map +1 -0
- package/dist/result-handler-BZPY7HX4.mjs +1029 -0
- package/dist/result-handler-BZPY7HX4.mjs.map +1 -0
- package/package.json +41 -34
- package/src/commands/contract-emit.ts +13 -5
- package/src/commands/db-init.ts +13 -18
- package/src/commands/db-verify.ts +3 -2
- package/src/control-api/client.ts +4 -2
- package/src/control-api/operations/contract-emit.ts +103 -0
- package/src/control-api/operations/db-init.ts +6 -6
- package/src/control-api/types.ts +44 -12
- package/src/exports/control-api.ts +5 -0
- package/src/load-ts-contract.ts +16 -11
- package/src/utils/output.ts +16 -10
- package/dist/chunk-AGOTG4L3.js +0 -965
- package/dist/chunk-AGOTG4L3.js.map +0 -1
- package/dist/chunk-HLLI4YL7.js +0 -180
- package/dist/chunk-HLLI4YL7.js.map +0 -1
- package/dist/chunk-HWYQOCAJ.js +0 -47
- package/dist/chunk-HWYQOCAJ.js.map +0 -1
- package/dist/chunk-VG2R7DGF.js +0 -735
- package/dist/chunk-VG2R7DGF.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 -10
- 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 -257
- 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 -155
- 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 -171
- 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 -195
- 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 -193
- 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 -387
- 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 -7
- 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 -176
- package/dist/exports/index.js.map +0 -1
- package/dist/load-ts-contract.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
|
@@ -119,7 +119,7 @@ export async function executeDbInit<TFamilyId extends string, TTargetId extends
|
|
|
119
119
|
const existingMarker = await familyInstance.readMarker({ driver });
|
|
120
120
|
if (existingMarker) {
|
|
121
121
|
const markerMatchesDestination =
|
|
122
|
-
existingMarker.
|
|
122
|
+
existingMarker.storageHash === migrationPlan.destination.storageHash &&
|
|
123
123
|
(!migrationPlan.destination.profileHash ||
|
|
124
124
|
existingMarker.profileHash === migrationPlan.destination.profileHash);
|
|
125
125
|
|
|
@@ -138,7 +138,7 @@ export async function executeDbInit<TFamilyId extends string, TTargetId extends
|
|
|
138
138
|
? {
|
|
139
139
|
execution: { operationsPlanned: 0, operationsExecuted: 0 },
|
|
140
140
|
marker: {
|
|
141
|
-
|
|
141
|
+
storageHash: existingMarker.storageHash,
|
|
142
142
|
profileHash: existingMarker.profileHash,
|
|
143
143
|
},
|
|
144
144
|
}
|
|
@@ -159,11 +159,11 @@ export async function executeDbInit<TFamilyId extends string, TTargetId extends
|
|
|
159
159
|
code: 'MARKER_ORIGIN_MISMATCH' as const,
|
|
160
160
|
summary: 'Existing contract marker does not match plan destination',
|
|
161
161
|
marker: {
|
|
162
|
-
|
|
162
|
+
storageHash: existingMarker.storageHash,
|
|
163
163
|
profileHash: existingMarker.profileHash,
|
|
164
164
|
},
|
|
165
165
|
destination: {
|
|
166
|
-
|
|
166
|
+
storageHash: migrationPlan.destination.storageHash,
|
|
167
167
|
profileHash: migrationPlan.destination.profileHash,
|
|
168
168
|
},
|
|
169
169
|
why: undefined,
|
|
@@ -271,10 +271,10 @@ export async function executeDbInit<TFamilyId extends string, TTargetId extends
|
|
|
271
271
|
},
|
|
272
272
|
marker: migrationPlan.destination.profileHash
|
|
273
273
|
? {
|
|
274
|
-
|
|
274
|
+
storageHash: migrationPlan.destination.storageHash,
|
|
275
275
|
profileHash: migrationPlan.destination.profileHash,
|
|
276
276
|
}
|
|
277
|
-
: {
|
|
277
|
+
: { storageHash: migrationPlan.destination.storageHash },
|
|
278
278
|
summary: `Applied ${execution.operationsExecuted} operation(s), marker written`,
|
|
279
279
|
};
|
|
280
280
|
return ok(result);
|
package/src/control-api/types.ts
CHANGED
|
@@ -236,14 +236,9 @@ export interface EmitContractConfig {
|
|
|
236
236
|
readonly source: EmitContractSource;
|
|
237
237
|
/**
|
|
238
238
|
* Output path for contract.json.
|
|
239
|
-
*
|
|
239
|
+
* The .d.ts types file will be colocated (e.g., contract.json → contract.d.ts).
|
|
240
240
|
*/
|
|
241
241
|
readonly output: string;
|
|
242
|
-
/**
|
|
243
|
-
* Output path for contract.d.ts.
|
|
244
|
-
* Should be an absolute or relative path.
|
|
245
|
-
*/
|
|
246
|
-
readonly types: string;
|
|
247
242
|
}
|
|
248
243
|
|
|
249
244
|
/**
|
|
@@ -279,7 +274,7 @@ export interface DbInitSuccess {
|
|
|
279
274
|
readonly operationsExecuted: number;
|
|
280
275
|
};
|
|
281
276
|
readonly marker?: {
|
|
282
|
-
readonly
|
|
277
|
+
readonly storageHash: string;
|
|
283
278
|
readonly profileHash?: string;
|
|
284
279
|
};
|
|
285
280
|
readonly summary: string;
|
|
@@ -300,11 +295,11 @@ export interface DbInitFailure {
|
|
|
300
295
|
readonly conflicts: ReadonlyArray<MigrationPlannerConflict> | undefined;
|
|
301
296
|
readonly meta: Record<string, unknown> | undefined;
|
|
302
297
|
readonly marker?: {
|
|
303
|
-
readonly
|
|
298
|
+
readonly storageHash?: string;
|
|
304
299
|
readonly profileHash?: string;
|
|
305
300
|
};
|
|
306
301
|
readonly destination?: {
|
|
307
|
-
readonly
|
|
302
|
+
readonly storageHash: string;
|
|
308
303
|
readonly profileHash?: string | undefined;
|
|
309
304
|
};
|
|
310
305
|
}
|
|
@@ -320,8 +315,10 @@ export type DbInitResult = Result<DbInitSuccess, DbInitFailure>;
|
|
|
320
315
|
* Contains the hashes and paths of emitted files.
|
|
321
316
|
*/
|
|
322
317
|
export interface EmitSuccess {
|
|
323
|
-
/**
|
|
324
|
-
readonly
|
|
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;
|
|
325
322
|
/** Profile hash of the emitted contract (target-specific) */
|
|
326
323
|
readonly profileHash: string;
|
|
327
324
|
/** The emitted contract as JSON string */
|
|
@@ -351,6 +348,41 @@ export interface EmitFailure {
|
|
|
351
348
|
*/
|
|
352
349
|
export type EmitResult = Result<EmitSuccess, EmitFailure>;
|
|
353
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
|
+
|
|
354
386
|
// ============================================================================
|
|
355
387
|
// Client Interface
|
|
356
388
|
// ============================================================================
|
|
@@ -397,7 +429,7 @@ export interface ControlClient {
|
|
|
397
429
|
|
|
398
430
|
/**
|
|
399
431
|
* Verifies database marker matches the contract.
|
|
400
|
-
* Compares
|
|
432
|
+
* Compares storageHash and profileHash.
|
|
401
433
|
*
|
|
402
434
|
* @returns Structured result (ok: false for mismatch, not throwing)
|
|
403
435
|
* @throws If not connected or infrastructure failure
|
|
@@ -18,8 +18,13 @@ export type {
|
|
|
18
18
|
// Client factory
|
|
19
19
|
export { createControlClient } from '../control-api/client';
|
|
20
20
|
|
|
21
|
+
// Standalone operations (for tooling that doesn't need full client)
|
|
22
|
+
export { executeContractEmit } from '../control-api/operations/contract-emit';
|
|
23
|
+
|
|
21
24
|
// CLI-specific types
|
|
22
25
|
export type {
|
|
26
|
+
ContractEmitOptions,
|
|
27
|
+
ContractEmitResult,
|
|
23
28
|
ContractSourceLoader,
|
|
24
29
|
ContractSourceValue,
|
|
25
30
|
ControlActionName,
|
package/src/load-ts-contract.ts
CHANGED
|
@@ -30,26 +30,31 @@ function validatePurity(value: unknown): void {
|
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
const
|
|
33
|
+
const path = new WeakSet();
|
|
34
|
+
|
|
34
35
|
function check(value: unknown): void {
|
|
35
36
|
if (value === null || typeof value !== 'object') {
|
|
36
37
|
return;
|
|
37
38
|
}
|
|
38
39
|
|
|
39
|
-
if (
|
|
40
|
+
if (path.has(value)) {
|
|
40
41
|
throw new Error('Contract export contains circular references');
|
|
41
42
|
}
|
|
42
|
-
|
|
43
|
+
path.add(value);
|
|
43
44
|
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
try {
|
|
46
|
+
for (const key in value) {
|
|
47
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
48
|
+
if (descriptor && (descriptor.get || descriptor.set)) {
|
|
49
|
+
throw new Error(`Contract export contains getter/setter at key "${key}"`);
|
|
50
|
+
}
|
|
51
|
+
if (descriptor && typeof descriptor.value === 'function') {
|
|
52
|
+
throw new Error(`Contract export contains function at key "${key}"`);
|
|
53
|
+
}
|
|
54
|
+
check((value as Record<string, unknown>)[key]);
|
|
51
55
|
}
|
|
52
|
-
|
|
56
|
+
} finally {
|
|
57
|
+
path.delete(value);
|
|
53
58
|
}
|
|
54
59
|
}
|
|
55
60
|
|
package/src/utils/output.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { relative } from 'node:path';
|
|
2
|
+
import { ifDefined } from '@prisma-next/utils/defined';
|
|
2
3
|
import { bgGreen, blue, bold, cyan, dim, green, magenta, red, yellow } from 'colorette';
|
|
3
4
|
import type { Command } from 'commander';
|
|
4
5
|
import stringWidth from 'string-width';
|
|
@@ -6,7 +7,8 @@ import stripAnsi from 'strip-ansi';
|
|
|
6
7
|
import wrapAnsi from 'wrap-ansi';
|
|
7
8
|
// EmitContractResult type for CLI output formatting (includes file paths)
|
|
8
9
|
export interface EmitContractResult {
|
|
9
|
-
readonly
|
|
10
|
+
readonly storageHash: string;
|
|
11
|
+
readonly executionHash?: string;
|
|
10
12
|
readonly profileHash: string;
|
|
11
13
|
readonly outDir: string;
|
|
12
14
|
readonly files: {
|
|
@@ -94,7 +96,10 @@ export function formatEmitOutput(result: EmitContractResult, flags: GlobalFlags)
|
|
|
94
96
|
|
|
95
97
|
lines.push(`${prefix}✔ Emitted contract.json → ${jsonPath}`);
|
|
96
98
|
lines.push(`${prefix}✔ Emitted contract.d.ts → ${dtsPath}`);
|
|
97
|
-
lines.push(`${prefix}
|
|
99
|
+
lines.push(`${prefix} storageHash: ${result.storageHash}`);
|
|
100
|
+
if (result.executionHash) {
|
|
101
|
+
lines.push(`${prefix} executionHash: ${result.executionHash}`);
|
|
102
|
+
}
|
|
98
103
|
if (result.profileHash) {
|
|
99
104
|
lines.push(`${prefix} profileHash: ${result.profileHash}`);
|
|
100
105
|
}
|
|
@@ -111,7 +116,8 @@ export function formatEmitOutput(result: EmitContractResult, flags: GlobalFlags)
|
|
|
111
116
|
export function formatEmitJson(result: EmitContractResult): string {
|
|
112
117
|
const output = {
|
|
113
118
|
ok: true,
|
|
114
|
-
|
|
119
|
+
storageHash: result.storageHash,
|
|
120
|
+
...ifDefined('executionHash', result.executionHash),
|
|
115
121
|
...(result.profileHash ? { profileHash: result.profileHash } : {}),
|
|
116
122
|
outDir: result.outDir,
|
|
117
123
|
files: result.files,
|
|
@@ -223,7 +229,7 @@ export function formatVerifyOutput(result: VerifyDatabaseResult, flags: GlobalFl
|
|
|
223
229
|
|
|
224
230
|
if (result.ok) {
|
|
225
231
|
lines.push(`${prefix}${formatGreen('✔')} ${result.summary}`);
|
|
226
|
-
lines.push(`${prefix}${formatDimText(`
|
|
232
|
+
lines.push(`${prefix}${formatDimText(` storageHash: ${result.contract.storageHash}`)}`);
|
|
227
233
|
if (result.contract.profileHash) {
|
|
228
234
|
lines.push(`${prefix}${formatDimText(` profileHash: ${result.contract.profileHash}`)}`);
|
|
229
235
|
}
|
|
@@ -772,8 +778,8 @@ export function formatSignOutput(result: SignDatabaseResult, flags: GlobalFlags)
|
|
|
772
778
|
lines.push(`${prefix}${formatGreen('✔')} Database signed`);
|
|
773
779
|
|
|
774
780
|
// Show from -> to hashes with clear labels
|
|
775
|
-
const previousHash = result.marker.previous?.
|
|
776
|
-
const currentHash = result.contract.
|
|
781
|
+
const previousHash = result.marker.previous?.storageHash ?? 'none';
|
|
782
|
+
const currentHash = result.contract.storageHash;
|
|
777
783
|
|
|
778
784
|
lines.push(`${prefix}${formatDimText(` from: ${previousHash}`)}`);
|
|
779
785
|
lines.push(`${prefix}${formatDimText(` to: ${currentHash}`)}`);
|
|
@@ -814,7 +820,7 @@ export interface DbInitResult {
|
|
|
814
820
|
readonly plan?: {
|
|
815
821
|
readonly targetId: string;
|
|
816
822
|
readonly destination: {
|
|
817
|
-
readonly
|
|
823
|
+
readonly storageHash: string;
|
|
818
824
|
readonly profileHash?: string;
|
|
819
825
|
};
|
|
820
826
|
readonly operations: readonly {
|
|
@@ -828,7 +834,7 @@ export interface DbInitResult {
|
|
|
828
834
|
readonly operationsExecuted: number;
|
|
829
835
|
};
|
|
830
836
|
readonly marker?: {
|
|
831
|
-
readonly
|
|
837
|
+
readonly storageHash: string;
|
|
832
838
|
readonly profileHash?: string;
|
|
833
839
|
};
|
|
834
840
|
readonly summary: string;
|
|
@@ -872,7 +878,7 @@ export function formatDbInitPlanOutput(result: DbInitResult, flags: GlobalFlags)
|
|
|
872
878
|
if (result.plan?.destination) {
|
|
873
879
|
lines.push(`${prefix}`);
|
|
874
880
|
lines.push(
|
|
875
|
-
`${prefix}${formatDimText(`Destination hash: ${result.plan.destination.
|
|
881
|
+
`${prefix}${formatDimText(`Destination hash: ${result.plan.destination.storageHash}`)}`,
|
|
876
882
|
);
|
|
877
883
|
}
|
|
878
884
|
|
|
@@ -910,7 +916,7 @@ export function formatDbInitApplyOutput(result: DbInitResult, flags: GlobalFlags
|
|
|
910
916
|
|
|
911
917
|
// Marker info
|
|
912
918
|
if (result.marker) {
|
|
913
|
-
lines.push(`${prefix}${formatDimText(` Marker written: ${result.marker.
|
|
919
|
+
lines.push(`${prefix}${formatDimText(` Marker written: ${result.marker.storageHash}`)}`);
|
|
914
920
|
if (result.marker.profileHash) {
|
|
915
921
|
lines.push(`${prefix}${formatDimText(` Profile hash: ${result.marker.profileHash}`)}`);
|
|
916
922
|
}
|