@prisma-next/cli 0.5.0-dev.4 → 0.5.0-dev.41
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 +123 -15
- package/dist/cli.mjs.map +1 -1
- package/dist/{client-TG7rbCWT.mjs → client-1JqqkiC7.mjs} +45 -20
- package/dist/client-1JqqkiC7.mjs.map +1 -0
- package/dist/commands/contract-emit.d.mts.map +1 -1
- package/dist/commands/contract-emit.mjs +2 -2
- package/dist/commands/contract-infer.d.mts.map +1 -1
- package/dist/commands/contract-infer.mjs +2 -2
- package/dist/commands/db-init.d.mts.map +1 -1
- package/dist/commands/db-init.mjs +10 -9
- package/dist/commands/db-init.mjs.map +1 -1
- package/dist/commands/db-schema.mjs +5 -5
- package/dist/commands/db-sign.mjs +7 -7
- package/dist/commands/db-update.mjs +9 -9
- package/dist/commands/db-update.mjs.map +1 -1
- package/dist/commands/db-verify.mjs +9 -9
- package/dist/commands/migration-apply.d.mts +5 -2
- package/dist/commands/migration-apply.d.mts.map +1 -1
- package/dist/commands/migration-apply.mjs +55 -56
- 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 +26 -32
- 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 -48
- package/dist/commands/migration-plan.mjs.map +1 -1
- 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 +6 -10
- 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 +27 -29
- package/dist/commands/migration-show.mjs.map +1 -1
- package/dist/commands/migration-status.d.mts +23 -5
- package/dist/commands/migration-status.d.mts.map +1 -1
- package/dist/commands/migration-status.mjs +3 -3
- 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-LjzCoicC.mjs +4 -0
- package/dist/contract-emit-RZBWzkop.mjs +329 -0
- package/dist/contract-emit-RZBWzkop.mjs.map +1 -0
- package/dist/contract-emit-rt_Nmdwq.mjs +150 -0
- package/dist/contract-emit-rt_Nmdwq.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-BS4kIX9c.mjs → contract-infer-Cf5J2wVg.mjs} +11 -19
- package/dist/contract-infer-Cf5J2wVg.mjs.map +1 -0
- package/dist/exports/control-api.d.mts +86 -21
- package/dist/exports/control-api.d.mts.map +1 -1
- package/dist/exports/control-api.mjs +5 -5
- package/dist/exports/index.mjs +3 -3
- 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-C7dE9KOJ.mjs +2062 -0
- package/dist/init-C7dE9KOJ.mjs.map +1 -0
- package/dist/{inspect-live-schema-BsoFVoS1.mjs → inspect-live-schema-LWtXfxm_.mjs} +9 -9
- package/dist/inspect-live-schema-LWtXfxm_.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-DOXnheFa.mjs → migration-command-scaffold-CU452v9h.mjs} +7 -7
- package/dist/{migration-command-scaffold-DOXnheFa.mjs.map → migration-command-scaffold-CU452v9h.mjs.map} +1 -1
- package/dist/{migration-status-Ry3TnEya.mjs → migration-status-DoPrFIOQ.mjs} +114 -57
- package/dist/migration-status-DoPrFIOQ.mjs.map +1 -0
- package/dist/{migrations-fU0xoKjS.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-BJwA7ufw.mjs → result-handler-Ch6hVnOo.mjs} +35 -93
- package/dist/result-handler-Ch6hVnOo.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-bl__PkXk.mjs → verify-BT9tgCOH.mjs} +2 -2
- package/dist/{verify-bl__PkXk.mjs.map → verify-BT9tgCOH.mjs.map} +1 -1
- package/package.json +22 -16
- 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 +84 -63
- package/src/commands/migration-new.ts +28 -34
- package/src/commands/migration-plan.ts +80 -56
- package/src/commands/migration-ref.ts +8 -7
- package/src/commands/migration-show.ts +53 -36
- package/src/commands/migration-status.ts +194 -58
- 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 +10 -6
- package/src/control-api/operations/db-update.ts +10 -6
- package/src/control-api/operations/migration-apply.ts +30 -9
- package/src/control-api/types.ts +69 -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 +45 -23
- package/src/utils/emit-queue.ts +26 -0
- package/src/utils/formatters/graph-migration-mapper.ts +7 -3
- 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-CQfj7xJn.mjs +0 -122
- package/dist/contract-emit-CQfj7xJn.mjs.map +0 -1
- package/dist/contract-emit-DpPjuFy-.mjs +0 -195
- package/dist/contract-emit-DpPjuFy-.mjs.map +0 -1
- package/dist/contract-emit-fhNwwhkQ.mjs +0 -4
- package/dist/contract-infer-BS4kIX9c.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-BsoFVoS1.mjs.map +0 -1
- package/dist/migration-status-Ry3TnEya.mjs.map +0 -1
- package/dist/migrations-fU0xoKjS.mjs.map +0 -1
- package/dist/result-handler-BJwA7ufw.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,10 +448,18 @@ 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[];
|
|
455
|
+
/**
|
|
456
|
+
* Sorted, deduplicated invariant ids from `migration.json.providedInvariants`.
|
|
457
|
+
* Verified at load time by `readMigrationPackage` (manifest copy must equal
|
|
458
|
+
* the value derived from `ops.json`). The control-api passes this through
|
|
459
|
+
* to the runner via `MigrationPlan.providedInvariants` so target runners
|
|
460
|
+
* read the canonical set instead of re-deriving from `operations`.
|
|
461
|
+
*/
|
|
462
|
+
readonly providedInvariants: readonly string[];
|
|
439
463
|
}
|
|
440
464
|
|
|
441
465
|
/**
|
|
@@ -471,7 +495,7 @@ export interface MigrationApplyOptions {
|
|
|
471
495
|
*/
|
|
472
496
|
export interface MigrationApplyAppliedEntry {
|
|
473
497
|
readonly dirName: string;
|
|
474
|
-
readonly from: string;
|
|
498
|
+
readonly from: string | null;
|
|
475
499
|
readonly to: string;
|
|
476
500
|
readonly operationsExecuted: number;
|
|
477
501
|
}
|
|
@@ -512,18 +536,31 @@ export type MigrationApplyResult = Result<MigrationApplySuccess, MigrationApplyF
|
|
|
512
536
|
|
|
513
537
|
/**
|
|
514
538
|
* Options for the standalone executeContractEmit function.
|
|
515
|
-
*
|
|
516
|
-
*
|
|
539
|
+
*
|
|
540
|
+
* `executeContractEmit` is the canonical publication path for both the
|
|
541
|
+
* `prisma-next contract emit` CLI command and the `@prisma-next/vite-plugin-contract-emit`
|
|
542
|
+
* Vite plugin. Do not duplicate the load → emit → publish dance elsewhere; if a
|
|
543
|
+
* caller needs additional behavior, extend this options shape and update the
|
|
544
|
+
* single implementation rather than building a parallel publication path.
|
|
545
|
+
*
|
|
546
|
+
* Concurrent calls for the same output JSON path are serialized per-output via
|
|
547
|
+
* a FIFO queue; concurrent calls for distinct outputs run in parallel.
|
|
517
548
|
*/
|
|
518
549
|
export interface ContractEmitOptions {
|
|
519
550
|
/** Path to the prisma-next.config.ts file */
|
|
520
551
|
readonly configPath: string;
|
|
521
|
-
/** Optional AbortSignal for
|
|
552
|
+
/** Optional AbortSignal for cancelling the in-flight emit */
|
|
522
553
|
readonly signal?: AbortSignal;
|
|
554
|
+
/** Optional progress callback for observing source-resolution and emit spans */
|
|
555
|
+
readonly onProgress?: OnControlProgress;
|
|
523
556
|
}
|
|
524
557
|
|
|
525
558
|
/**
|
|
526
559
|
* Result from the standalone executeContractEmit function.
|
|
560
|
+
*
|
|
561
|
+
* Always describes the bytes that were just published to disk. Failures throw
|
|
562
|
+
* (config / source-resolution / emit / publish) — callers do not need to
|
|
563
|
+
* branch on a result discriminator.
|
|
527
564
|
*/
|
|
528
565
|
export interface ContractEmitResult {
|
|
529
566
|
/** Hash of the storage contract (schema-level) */
|
|
@@ -539,6 +576,12 @@ export interface ContractEmitResult {
|
|
|
539
576
|
/** Path to the emitted contract.d.ts file */
|
|
540
577
|
readonly dts: string;
|
|
541
578
|
};
|
|
579
|
+
/**
|
|
580
|
+
* Warning surfaced by `validateContractDeps` after a successful publication.
|
|
581
|
+
* Callers (CLI, Vite plugin) decide how to render this; the operation does
|
|
582
|
+
* not write to stderr itself. Undefined when no warning was raised.
|
|
583
|
+
*/
|
|
584
|
+
readonly validationWarning?: string;
|
|
542
585
|
}
|
|
543
586
|
|
|
544
587
|
// ============================================================================
|
|
@@ -672,6 +715,25 @@ export interface ControlClient {
|
|
|
672
715
|
*/
|
|
673
716
|
toSchemaView(schemaIR: unknown): CoreSchemaView | undefined;
|
|
674
717
|
|
|
718
|
+
/**
|
|
719
|
+
* Infers a PSL contract AST from an introspected schema IR.
|
|
720
|
+
* Delegates to the family instance's inferPslContract method.
|
|
721
|
+
*
|
|
722
|
+
* @param schemaIR - The schema IR from introspect()
|
|
723
|
+
* @returns PslDocumentAst if the family supports the capability, undefined otherwise
|
|
724
|
+
*/
|
|
725
|
+
inferPslContract(schemaIR: unknown): PslDocumentAst | undefined;
|
|
726
|
+
|
|
727
|
+
/**
|
|
728
|
+
* Renders a textual preview of a migration plan's operations for the CLI's
|
|
729
|
+
* "DDL preview" output. Delegates to the family instance's
|
|
730
|
+
* `toOperationPreview` method.
|
|
731
|
+
*
|
|
732
|
+
* @param operations - The migration plan operations to render
|
|
733
|
+
* @returns OperationPreview if the family supports the capability, undefined otherwise
|
|
734
|
+
*/
|
|
735
|
+
toOperationPreview(operations: readonly MigrationPlanOperation[]): OperationPreview | undefined;
|
|
736
|
+
|
|
675
737
|
/**
|
|
676
738
|
* Emits the contract to JSON and TypeScript declarations.
|
|
677
739
|
* 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';
|