@prisma-next/cli 0.5.0-dev.3 → 0.5.0-dev.30
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 +56 -21
- package/dist/agent-skill-mongo.md +63 -31
- package/dist/agent-skill-postgres.md +1 -1
- package/dist/cli-errors-By1iVE3z.mjs +34 -0
- package/dist/cli-errors-By1iVE3z.mjs.map +1 -0
- package/dist/{cli-errors-C0JhVj0c.d.mts → cli-errors-DDeVsP2Y.d.mts} +1 -0
- package/dist/cli.mjs +131 -15
- package/dist/cli.mjs.map +1 -1
- package/dist/{client-TG7rbCWT.mjs → client-keSCAgjW.mjs} +43 -19
- package/dist/client-keSCAgjW.mjs.map +1 -0
- package/dist/commands/contract-emit.d.mts.map +1 -1
- package/dist/commands/contract-emit.mjs +7 -2
- package/dist/commands/contract-infer.d.mts.map +1 -1
- package/dist/commands/contract-infer.mjs +8 -2
- package/dist/commands/db-init.d.mts.map +1 -1
- package/dist/commands/db-init.mjs +11 -9
- package/dist/commands/db-init.mjs.map +1 -1
- package/dist/commands/db-schema.mjs +8 -5
- package/dist/commands/db-schema.mjs.map +1 -1
- package/dist/commands/db-sign.mjs +8 -7
- package/dist/commands/db-sign.mjs.map +1 -1
- package/dist/commands/db-update.mjs +10 -9
- package/dist/commands/db-update.mjs.map +1 -1
- package/dist/commands/db-verify.mjs +10 -9
- package/dist/commands/db-verify.mjs.map +1 -1
- package/dist/commands/migration-apply.d.mts +2 -2
- package/dist/commands/migration-apply.d.mts.map +1 -1
- package/dist/commands/migration-apply.mjs +15 -38
- package/dist/commands/migration-apply.mjs.map +1 -1
- package/dist/commands/migration-new.d.mts.map +1 -1
- package/dist/commands/migration-new.mjs +24 -30
- package/dist/commands/migration-new.mjs.map +1 -1
- package/dist/commands/migration-plan.d.mts +14 -5
- package/dist/commands/migration-plan.d.mts.map +1 -1
- package/dist/commands/migration-plan.mjs +45 -47
- package/dist/commands/migration-plan.mjs.map +1 -1
- package/dist/commands/migration-ref.d.mts +6 -4
- package/dist/commands/migration-ref.d.mts.map +1 -1
- package/dist/commands/migration-ref.mjs +31 -40
- 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 +28 -29
- package/dist/commands/migration-show.mjs.map +1 -1
- package/dist/commands/migration-status.d.mts +5 -4
- package/dist/commands/migration-status.d.mts.map +1 -1
- package/dist/commands/migration-status.mjs +7 -2
- package/dist/{config-loader-_W4T21X1.mjs → config-loader-ih8ViDb_.mjs} +2 -2
- package/dist/config-loader-ih8ViDb_.mjs.map +1 -0
- package/dist/config-loader.mjs +1 -1
- package/dist/contract-emit-DS5NzZh2.mjs +6 -0
- package/dist/contract-emit-DWtGQYCD.mjs +150 -0
- package/dist/contract-emit-DWtGQYCD.mjs.map +1 -0
- package/dist/contract-emit-RZBWzkop.mjs +329 -0
- package/dist/contract-emit-RZBWzkop.mjs.map +1 -0
- package/dist/{contract-enrichment-CGW6mm-E.mjs → contract-enrichment-4Ptgw3Pe.mjs} +1 -1
- package/dist/{contract-enrichment-CGW6mm-E.mjs.map → contract-enrichment-4Ptgw3Pe.mjs.map} +1 -1
- package/dist/{contract-infer-BP3DrGgz.mjs → contract-infer-GztVCOCJ.mjs} +11 -19
- package/dist/contract-infer-GztVCOCJ.mjs.map +1 -0
- package/dist/exports/control-api.d.mts +78 -21
- package/dist/exports/control-api.d.mts.map +1 -1
- package/dist/exports/control-api.mjs +7 -5
- package/dist/exports/index.mjs +8 -3
- package/dist/exports/index.mjs.map +1 -1
- package/dist/exports/init-output.d.mts +39 -0
- package/dist/exports/init-output.d.mts.map +1 -0
- package/dist/exports/init-output.mjs +3 -0
- package/dist/{framework-components-DfZKQBQ2.mjs → framework-components-Bgcre3Z6.mjs} +2 -2
- package/dist/{framework-components-DfZKQBQ2.mjs.map → framework-components-Bgcre3Z6.mjs.map} +1 -1
- package/dist/init-DAbQMxIR.mjs +2062 -0
- package/dist/init-DAbQMxIR.mjs.map +1 -0
- package/dist/{inspect-live-schema-DWzf4Q_m.mjs → inspect-live-schema-BaR9ISwa.mjs} +9 -9
- package/dist/inspect-live-schema-BaR9ISwa.mjs.map +1 -0
- package/dist/migration-cli.d.mts +41 -11
- package/dist/migration-cli.d.mts.map +1 -1
- package/dist/migration-cli.mjs +308 -84
- package/dist/migration-cli.mjs.map +1 -1
- package/dist/{migration-command-scaffold-CLMD302g.mjs → migration-command-scaffold-D1dWuEWQ.mjs} +7 -7
- package/dist/{migration-command-scaffold-CLMD302g.mjs.map → migration-command-scaffold-D1dWuEWQ.mjs.map} +1 -1
- package/dist/{migration-status-B0HLF7So.mjs → migration-status-CP5k8O5i.mjs} +21 -35
- package/dist/migration-status-CP5k8O5i.mjs.map +1 -0
- package/dist/{migrations-B0dOQlk0.mjs → migrations-MEoKMiV5.mjs} +42 -21
- package/dist/migrations-MEoKMiV5.mjs.map +1 -0
- package/dist/output-BpcQrnnq.mjs +103 -0
- package/dist/output-BpcQrnnq.mjs.map +1 -0
- package/dist/{progress-adapter-B-YvmcDu.mjs → progress-adapter-DgRGldpT.mjs} +1 -1
- package/dist/{progress-adapter-B-YvmcDu.mjs.map → progress-adapter-DgRGldpT.mjs.map} +1 -1
- package/dist/quick-reference-mongo.md +34 -13
- package/dist/quick-reference-postgres.md +11 -9
- package/dist/{result-handler-CIyu0Pdt.mjs → result-handler-BmVh8AeV.mjs} +12 -93
- package/dist/result-handler-BmVh8AeV.mjs.map +1 -0
- package/dist/{terminal-ui-C5k88MmW.mjs → terminal-ui-u2YgKghu.mjs} +76 -2
- package/dist/terminal-ui-u2YgKghu.mjs.map +1 -0
- package/dist/{verify-BxiVp50b.mjs → verify-BT9tgCOH.mjs} +2 -2
- package/dist/{verify-BxiVp50b.mjs.map → verify-BT9tgCOH.mjs.map} +1 -1
- package/package.json +21 -15
- package/src/cli.ts +32 -6
- package/src/commands/contract-emit.ts +67 -163
- package/src/commands/contract-infer.ts +7 -20
- package/src/commands/db-init.ts +1 -0
- package/src/commands/db-update.ts +1 -1
- package/src/commands/init/detect-pnpm-catalog.ts +141 -0
- package/src/commands/init/errors.ts +254 -0
- package/src/commands/init/exit-codes.ts +62 -0
- package/src/commands/init/hygiene-gitattributes.ts +97 -0
- package/src/commands/init/hygiene-gitignore.ts +48 -0
- package/src/commands/init/hygiene-package-scripts.ts +91 -0
- package/src/commands/init/index.ts +112 -7
- package/src/commands/init/init.ts +766 -144
- package/src/commands/init/inputs.ts +421 -0
- package/src/commands/init/output.ts +147 -0
- package/src/commands/init/probe-db.ts +308 -0
- package/src/commands/init/reinit-cleanup.ts +83 -0
- package/src/commands/init/templates/agent-skill-mongo.md +63 -31
- package/src/commands/init/templates/agent-skill-postgres.md +1 -1
- package/src/commands/init/templates/agent-skill.ts +25 -3
- package/src/commands/init/templates/code-templates.ts +125 -32
- package/src/commands/init/templates/env.ts +80 -0
- package/src/commands/init/templates/quick-reference-mongo.md +34 -13
- package/src/commands/init/templates/quick-reference-postgres.md +11 -9
- package/src/commands/init/templates/quick-reference.ts +42 -3
- package/src/commands/init/templates/tsconfig.ts +167 -5
- package/src/commands/inspect-live-schema.ts +10 -5
- package/src/commands/migration-apply.ts +16 -51
- package/src/commands/migration-new.ts +26 -32
- package/src/commands/migration-plan.ts +80 -55
- package/src/commands/migration-ref.ts +40 -54
- package/src/commands/migration-show.ts +53 -36
- package/src/commands/migration-status.ts +33 -50
- package/src/config-path-validation.ts +0 -1
- package/src/control-api/client.ts +21 -0
- package/src/control-api/operations/contract-emit.ts +198 -115
- package/src/control-api/operations/db-init.ts +8 -5
- package/src/control-api/operations/db-update.ts +8 -5
- package/src/control-api/operations/migration-apply.ts +29 -9
- package/src/control-api/types.ts +61 -7
- package/src/exports/control-api.ts +2 -1
- package/src/exports/init-output.ts +10 -0
- package/src/migration-cli.ts +445 -122
- package/src/utils/cli-errors.ts +49 -2
- package/src/utils/command-helpers.ts +13 -26
- package/src/utils/emit-queue.ts +26 -0
- package/src/utils/formatters/graph-migration-mapper.ts +2 -2
- package/src/utils/formatters/migrations.ts +62 -26
- package/src/utils/publish-contract-artifact-pair.ts +134 -0
- package/dist/cli-errors-DHq6GQGu.mjs +0 -5
- package/dist/client-TG7rbCWT.mjs.map +0 -1
- package/dist/config-loader-_W4T21X1.mjs.map +0 -1
- package/dist/contract-emit-CNYyzJwF.mjs +0 -195
- package/dist/contract-emit-CNYyzJwF.mjs.map +0 -1
- package/dist/contract-emit-CQfj7xJn.mjs +0 -122
- package/dist/contract-emit-CQfj7xJn.mjs.map +0 -1
- package/dist/contract-emit-fhNwwhkQ.mjs +0 -4
- package/dist/contract-infer-BP3DrGgz.mjs.map +0 -1
- package/dist/extract-operation-statements-DZUJNmL3.mjs +0 -13
- package/dist/extract-operation-statements-DZUJNmL3.mjs.map +0 -1
- package/dist/extract-sql-ddl-DDMX-9mz.mjs +0 -26
- package/dist/extract-sql-ddl-DDMX-9mz.mjs.map +0 -1
- package/dist/init-CQfo_4Ro.mjs +0 -430
- package/dist/init-CQfo_4Ro.mjs.map +0 -1
- package/dist/inspect-live-schema-DWzf4Q_m.mjs.map +0 -1
- package/dist/migration-status-B0HLF7So.mjs.map +0 -1
- package/dist/migrations-B0dOQlk0.mjs.map +0 -1
- package/dist/result-handler-CIyu0Pdt.mjs.map +0 -1
- package/dist/terminal-ui-C5k88MmW.mjs.map +0 -1
- package/dist/validate-contract-deps-esa-VQ0h.mjs +0 -37
- package/dist/validate-contract-deps-esa-VQ0h.mjs.map +0 -1
- package/src/control-api/operations/extract-operation-statements.ts +0 -14
- package/src/control-api/operations/extract-sql-ddl.ts +0 -47
package/src/control-api/types.ts
CHANGED
|
@@ -12,10 +12,12 @@ import type {
|
|
|
12
12
|
CoreSchemaView,
|
|
13
13
|
MigrationPlannerConflict,
|
|
14
14
|
MigrationPlanOperation,
|
|
15
|
+
OperationPreview,
|
|
15
16
|
SignDatabaseResult,
|
|
16
17
|
VerifyDatabaseResult,
|
|
17
18
|
VerifyDatabaseSchemaResult,
|
|
18
19
|
} from '@prisma-next/framework-components/control';
|
|
20
|
+
import type { PslDocumentAst } from '@prisma-next/framework-components/psl-ast';
|
|
19
21
|
import type { Result } from '@prisma-next/utils/result';
|
|
20
22
|
|
|
21
23
|
// ============================================================================
|
|
@@ -283,7 +285,14 @@ export interface DbInitSuccess {
|
|
|
283
285
|
readonly label: string;
|
|
284
286
|
readonly operationClass: string;
|
|
285
287
|
}>;
|
|
286
|
-
|
|
288
|
+
/**
|
|
289
|
+
* Family-agnostic textual preview of the planned operations, e.g.
|
|
290
|
+
* `language: 'sql'` for SQL families and `language: 'mongodb-shell'`
|
|
291
|
+
* for the Mongo family. Replaces the previous `sql?: readonly string[]`
|
|
292
|
+
* field; consumers that previously read `plan.sql` should read
|
|
293
|
+
* `plan.preview?.statements.map((s) => s.text)`.
|
|
294
|
+
*/
|
|
295
|
+
readonly preview?: OperationPreview;
|
|
287
296
|
};
|
|
288
297
|
readonly destination: {
|
|
289
298
|
readonly storageHash: string;
|
|
@@ -341,7 +350,14 @@ export interface DbUpdateSuccess {
|
|
|
341
350
|
readonly label: string;
|
|
342
351
|
readonly operationClass: string;
|
|
343
352
|
}>;
|
|
344
|
-
|
|
353
|
+
/**
|
|
354
|
+
* Family-agnostic textual preview of the planned operations, e.g.
|
|
355
|
+
* `language: 'sql'` for SQL families and `language: 'mongodb-shell'`
|
|
356
|
+
* for the Mongo family. Replaces the previous `sql?: readonly string[]`
|
|
357
|
+
* field; consumers that previously read `plan.sql` should read
|
|
358
|
+
* `plan.preview?.statements.map((s) => s.text)`.
|
|
359
|
+
*/
|
|
360
|
+
readonly preview?: OperationPreview;
|
|
345
361
|
};
|
|
346
362
|
readonly destination: {
|
|
347
363
|
readonly storageHash: string;
|
|
@@ -432,7 +448,7 @@ export type EmitResult = Result<EmitSuccess, EmitFailure>;
|
|
|
432
448
|
*/
|
|
433
449
|
export interface MigrationApplyStep {
|
|
434
450
|
readonly dirName: string;
|
|
435
|
-
readonly from: string;
|
|
451
|
+
readonly from: string | null;
|
|
436
452
|
readonly to: string;
|
|
437
453
|
readonly toContract: Contract;
|
|
438
454
|
readonly operations: readonly MigrationPlanOperation[];
|
|
@@ -471,7 +487,7 @@ export interface MigrationApplyOptions {
|
|
|
471
487
|
*/
|
|
472
488
|
export interface MigrationApplyAppliedEntry {
|
|
473
489
|
readonly dirName: string;
|
|
474
|
-
readonly from: string;
|
|
490
|
+
readonly from: string | null;
|
|
475
491
|
readonly to: string;
|
|
476
492
|
readonly operationsExecuted: number;
|
|
477
493
|
}
|
|
@@ -512,18 +528,31 @@ export type MigrationApplyResult = Result<MigrationApplySuccess, MigrationApplyF
|
|
|
512
528
|
|
|
513
529
|
/**
|
|
514
530
|
* Options for the standalone executeContractEmit function.
|
|
515
|
-
*
|
|
516
|
-
*
|
|
531
|
+
*
|
|
532
|
+
* `executeContractEmit` is the canonical publication path for both the
|
|
533
|
+
* `prisma-next contract emit` CLI command and the `@prisma-next/vite-plugin-contract-emit`
|
|
534
|
+
* Vite plugin. Do not duplicate the load → emit → publish dance elsewhere; if a
|
|
535
|
+
* caller needs additional behavior, extend this options shape and update the
|
|
536
|
+
* single implementation rather than building a parallel publication path.
|
|
537
|
+
*
|
|
538
|
+
* Concurrent calls for the same output JSON path are serialized per-output via
|
|
539
|
+
* a FIFO queue; concurrent calls for distinct outputs run in parallel.
|
|
517
540
|
*/
|
|
518
541
|
export interface ContractEmitOptions {
|
|
519
542
|
/** Path to the prisma-next.config.ts file */
|
|
520
543
|
readonly configPath: string;
|
|
521
|
-
/** Optional AbortSignal for
|
|
544
|
+
/** Optional AbortSignal for cancelling the in-flight emit */
|
|
522
545
|
readonly signal?: AbortSignal;
|
|
546
|
+
/** Optional progress callback for observing source-resolution and emit spans */
|
|
547
|
+
readonly onProgress?: OnControlProgress;
|
|
523
548
|
}
|
|
524
549
|
|
|
525
550
|
/**
|
|
526
551
|
* Result from the standalone executeContractEmit function.
|
|
552
|
+
*
|
|
553
|
+
* Always describes the bytes that were just published to disk. Failures throw
|
|
554
|
+
* (config / source-resolution / emit / publish) — callers do not need to
|
|
555
|
+
* branch on a result discriminator.
|
|
527
556
|
*/
|
|
528
557
|
export interface ContractEmitResult {
|
|
529
558
|
/** Hash of the storage contract (schema-level) */
|
|
@@ -539,6 +568,12 @@ export interface ContractEmitResult {
|
|
|
539
568
|
/** Path to the emitted contract.d.ts file */
|
|
540
569
|
readonly dts: string;
|
|
541
570
|
};
|
|
571
|
+
/**
|
|
572
|
+
* Warning surfaced by `validateContractDeps` after a successful publication.
|
|
573
|
+
* Callers (CLI, Vite plugin) decide how to render this; the operation does
|
|
574
|
+
* not write to stderr itself. Undefined when no warning was raised.
|
|
575
|
+
*/
|
|
576
|
+
readonly validationWarning?: string;
|
|
542
577
|
}
|
|
543
578
|
|
|
544
579
|
// ============================================================================
|
|
@@ -672,6 +707,25 @@ export interface ControlClient {
|
|
|
672
707
|
*/
|
|
673
708
|
toSchemaView(schemaIR: unknown): CoreSchemaView | undefined;
|
|
674
709
|
|
|
710
|
+
/**
|
|
711
|
+
* Infers a PSL contract AST from an introspected schema IR.
|
|
712
|
+
* Delegates to the family instance's inferPslContract method.
|
|
713
|
+
*
|
|
714
|
+
* @param schemaIR - The schema IR from introspect()
|
|
715
|
+
* @returns PslDocumentAst if the family supports the capability, undefined otherwise
|
|
716
|
+
*/
|
|
717
|
+
inferPslContract(schemaIR: unknown): PslDocumentAst | undefined;
|
|
718
|
+
|
|
719
|
+
/**
|
|
720
|
+
* Renders a textual preview of a migration plan's operations for the CLI's
|
|
721
|
+
* "DDL preview" output. Delegates to the family instance's
|
|
722
|
+
* `toOperationPreview` method.
|
|
723
|
+
*
|
|
724
|
+
* @param operations - The migration plan operations to render
|
|
725
|
+
* @returns OperationPreview if the family supports the capability, undefined otherwise
|
|
726
|
+
*/
|
|
727
|
+
toOperationPreview(operations: readonly MigrationPlanOperation[]): OperationPreview | undefined;
|
|
728
|
+
|
|
675
729
|
/**
|
|
676
730
|
* Emits the contract to JSON and TypeScript declarations.
|
|
677
731
|
* This is an offline operation that does NOT require a database connection.
|
|
@@ -23,7 +23,6 @@ export { enrichContract } from '../control-api/contract-enrichment';
|
|
|
23
23
|
|
|
24
24
|
// Standalone operations (for tooling that doesn't need full client)
|
|
25
25
|
export { executeContractEmit } from '../control-api/operations/contract-emit';
|
|
26
|
-
|
|
27
26
|
// CLI-specific types
|
|
28
27
|
export type {
|
|
29
28
|
ContractEmitOptions,
|
|
@@ -54,3 +53,5 @@ export type {
|
|
|
54
53
|
SignOptions,
|
|
55
54
|
VerifyOptions,
|
|
56
55
|
} from '../control-api/types';
|
|
56
|
+
// Lifecycle helpers for hosts that publish to many output paths
|
|
57
|
+
export { disposeEmitQueue } from '../utils/emit-queue';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public re-export of the `init --json` success-document schema (FR1.5).
|
|
3
|
+
*
|
|
4
|
+
* Imported as `@prisma-next/cli/init-output`. The shared error envelope is
|
|
5
|
+
* exported separately from `@prisma-next/errors`; consumers should branch
|
|
6
|
+
* on the `ok` discriminator (success documents carry `ok: true`, error
|
|
7
|
+
* envelopes carry `ok: false`) per the
|
|
8
|
+
* [Style Guide § JSON Semantics](../../../../../../../docs/CLI%20Style%20Guide.md#json-semantics).
|
|
9
|
+
*/
|
|
10
|
+
export { type InitOutput, InitOutputSchema } from '../commands/init/output';
|