@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.
Files changed (165) hide show
  1. package/README.md +56 -21
  2. package/dist/agent-skill-mongo.md +63 -31
  3. package/dist/agent-skill-postgres.md +1 -1
  4. package/dist/cli-errors-By1iVE3z.mjs +34 -0
  5. package/dist/cli-errors-By1iVE3z.mjs.map +1 -0
  6. package/dist/{cli-errors-C0JhVj0c.d.mts → cli-errors-DDeVsP2Y.d.mts} +1 -0
  7. package/dist/cli.mjs +123 -15
  8. package/dist/cli.mjs.map +1 -1
  9. package/dist/{client-TG7rbCWT.mjs → client-1JqqkiC7.mjs} +45 -20
  10. package/dist/client-1JqqkiC7.mjs.map +1 -0
  11. package/dist/commands/contract-emit.d.mts.map +1 -1
  12. package/dist/commands/contract-emit.mjs +2 -2
  13. package/dist/commands/contract-infer.d.mts.map +1 -1
  14. package/dist/commands/contract-infer.mjs +2 -2
  15. package/dist/commands/db-init.d.mts.map +1 -1
  16. package/dist/commands/db-init.mjs +10 -9
  17. package/dist/commands/db-init.mjs.map +1 -1
  18. package/dist/commands/db-schema.mjs +5 -5
  19. package/dist/commands/db-sign.mjs +7 -7
  20. package/dist/commands/db-update.mjs +9 -9
  21. package/dist/commands/db-update.mjs.map +1 -1
  22. package/dist/commands/db-verify.mjs +9 -9
  23. package/dist/commands/migration-apply.d.mts +5 -2
  24. package/dist/commands/migration-apply.d.mts.map +1 -1
  25. package/dist/commands/migration-apply.mjs +55 -56
  26. package/dist/commands/migration-apply.mjs.map +1 -1
  27. package/dist/commands/migration-new.d.mts.map +1 -1
  28. package/dist/commands/migration-new.mjs +26 -32
  29. package/dist/commands/migration-new.mjs.map +1 -1
  30. package/dist/commands/migration-plan.d.mts +14 -5
  31. package/dist/commands/migration-plan.d.mts.map +1 -1
  32. package/dist/commands/migration-plan.mjs +45 -48
  33. package/dist/commands/migration-plan.mjs.map +1 -1
  34. package/dist/commands/migration-ref.d.mts +1 -1
  35. package/dist/commands/migration-ref.d.mts.map +1 -1
  36. package/dist/commands/migration-ref.mjs +6 -10
  37. package/dist/commands/migration-ref.mjs.map +1 -1
  38. package/dist/commands/migration-show.d.mts +13 -7
  39. package/dist/commands/migration-show.d.mts.map +1 -1
  40. package/dist/commands/migration-show.mjs +27 -29
  41. package/dist/commands/migration-show.mjs.map +1 -1
  42. package/dist/commands/migration-status.d.mts +23 -5
  43. package/dist/commands/migration-status.d.mts.map +1 -1
  44. package/dist/commands/migration-status.mjs +3 -3
  45. package/dist/{config-loader-_W4T21X1.mjs → config-loader-ih8ViDb_.mjs} +2 -2
  46. package/dist/config-loader-ih8ViDb_.mjs.map +1 -0
  47. package/dist/config-loader.mjs +1 -1
  48. package/dist/contract-emit-LjzCoicC.mjs +4 -0
  49. package/dist/contract-emit-RZBWzkop.mjs +329 -0
  50. package/dist/contract-emit-RZBWzkop.mjs.map +1 -0
  51. package/dist/contract-emit-rt_Nmdwq.mjs +150 -0
  52. package/dist/contract-emit-rt_Nmdwq.mjs.map +1 -0
  53. package/dist/{contract-enrichment-CGW6mm-E.mjs → contract-enrichment-4Ptgw3Pe.mjs} +1 -1
  54. package/dist/{contract-enrichment-CGW6mm-E.mjs.map → contract-enrichment-4Ptgw3Pe.mjs.map} +1 -1
  55. package/dist/{contract-infer-BS4kIX9c.mjs → contract-infer-Cf5J2wVg.mjs} +11 -19
  56. package/dist/contract-infer-Cf5J2wVg.mjs.map +1 -0
  57. package/dist/exports/control-api.d.mts +86 -21
  58. package/dist/exports/control-api.d.mts.map +1 -1
  59. package/dist/exports/control-api.mjs +5 -5
  60. package/dist/exports/index.mjs +3 -3
  61. package/dist/exports/init-output.d.mts +39 -0
  62. package/dist/exports/init-output.d.mts.map +1 -0
  63. package/dist/exports/init-output.mjs +3 -0
  64. package/dist/{framework-components-DfZKQBQ2.mjs → framework-components-Bgcre3Z6.mjs} +2 -2
  65. package/dist/{framework-components-DfZKQBQ2.mjs.map → framework-components-Bgcre3Z6.mjs.map} +1 -1
  66. package/dist/init-C7dE9KOJ.mjs +2062 -0
  67. package/dist/init-C7dE9KOJ.mjs.map +1 -0
  68. package/dist/{inspect-live-schema-BsoFVoS1.mjs → inspect-live-schema-LWtXfxm_.mjs} +9 -9
  69. package/dist/inspect-live-schema-LWtXfxm_.mjs.map +1 -0
  70. package/dist/migration-cli.d.mts +41 -11
  71. package/dist/migration-cli.d.mts.map +1 -1
  72. package/dist/migration-cli.mjs +308 -84
  73. package/dist/migration-cli.mjs.map +1 -1
  74. package/dist/{migration-command-scaffold-DOXnheFa.mjs → migration-command-scaffold-CU452v9h.mjs} +7 -7
  75. package/dist/{migration-command-scaffold-DOXnheFa.mjs.map → migration-command-scaffold-CU452v9h.mjs.map} +1 -1
  76. package/dist/{migration-status-Ry3TnEya.mjs → migration-status-DoPrFIOQ.mjs} +114 -57
  77. package/dist/migration-status-DoPrFIOQ.mjs.map +1 -0
  78. package/dist/{migrations-fU0xoKjS.mjs → migrations-MEoKMiV5.mjs} +42 -21
  79. package/dist/migrations-MEoKMiV5.mjs.map +1 -0
  80. package/dist/output-BpcQrnnq.mjs +103 -0
  81. package/dist/output-BpcQrnnq.mjs.map +1 -0
  82. package/dist/{progress-adapter-B-YvmcDu.mjs → progress-adapter-DgRGldpT.mjs} +1 -1
  83. package/dist/{progress-adapter-B-YvmcDu.mjs.map → progress-adapter-DgRGldpT.mjs.map} +1 -1
  84. package/dist/quick-reference-mongo.md +34 -13
  85. package/dist/quick-reference-postgres.md +11 -9
  86. package/dist/{result-handler-BJwA7ufw.mjs → result-handler-Ch6hVnOo.mjs} +35 -93
  87. package/dist/result-handler-Ch6hVnOo.mjs.map +1 -0
  88. package/dist/{terminal-ui-C5k88MmW.mjs → terminal-ui-u2YgKghu.mjs} +76 -2
  89. package/dist/terminal-ui-u2YgKghu.mjs.map +1 -0
  90. package/dist/{verify-bl__PkXk.mjs → verify-BT9tgCOH.mjs} +2 -2
  91. package/dist/{verify-bl__PkXk.mjs.map → verify-BT9tgCOH.mjs.map} +1 -1
  92. package/package.json +22 -16
  93. package/src/cli.ts +32 -6
  94. package/src/commands/contract-emit.ts +67 -163
  95. package/src/commands/contract-infer.ts +7 -20
  96. package/src/commands/db-init.ts +1 -0
  97. package/src/commands/db-update.ts +1 -1
  98. package/src/commands/init/detect-pnpm-catalog.ts +141 -0
  99. package/src/commands/init/errors.ts +254 -0
  100. package/src/commands/init/exit-codes.ts +62 -0
  101. package/src/commands/init/hygiene-gitattributes.ts +97 -0
  102. package/src/commands/init/hygiene-gitignore.ts +48 -0
  103. package/src/commands/init/hygiene-package-scripts.ts +91 -0
  104. package/src/commands/init/index.ts +112 -7
  105. package/src/commands/init/init.ts +766 -144
  106. package/src/commands/init/inputs.ts +421 -0
  107. package/src/commands/init/output.ts +147 -0
  108. package/src/commands/init/probe-db.ts +308 -0
  109. package/src/commands/init/reinit-cleanup.ts +83 -0
  110. package/src/commands/init/templates/agent-skill-mongo.md +63 -31
  111. package/src/commands/init/templates/agent-skill-postgres.md +1 -1
  112. package/src/commands/init/templates/agent-skill.ts +25 -3
  113. package/src/commands/init/templates/code-templates.ts +125 -32
  114. package/src/commands/init/templates/env.ts +80 -0
  115. package/src/commands/init/templates/quick-reference-mongo.md +34 -13
  116. package/src/commands/init/templates/quick-reference-postgres.md +11 -9
  117. package/src/commands/init/templates/quick-reference.ts +42 -3
  118. package/src/commands/init/templates/tsconfig.ts +167 -5
  119. package/src/commands/inspect-live-schema.ts +10 -5
  120. package/src/commands/migration-apply.ts +84 -63
  121. package/src/commands/migration-new.ts +28 -34
  122. package/src/commands/migration-plan.ts +80 -56
  123. package/src/commands/migration-ref.ts +8 -7
  124. package/src/commands/migration-show.ts +53 -36
  125. package/src/commands/migration-status.ts +194 -58
  126. package/src/config-path-validation.ts +0 -1
  127. package/src/control-api/client.ts +21 -0
  128. package/src/control-api/operations/contract-emit.ts +198 -115
  129. package/src/control-api/operations/db-init.ts +10 -6
  130. package/src/control-api/operations/db-update.ts +10 -6
  131. package/src/control-api/operations/migration-apply.ts +30 -9
  132. package/src/control-api/types.ts +69 -7
  133. package/src/exports/control-api.ts +2 -1
  134. package/src/exports/init-output.ts +10 -0
  135. package/src/migration-cli.ts +445 -122
  136. package/src/utils/cli-errors.ts +49 -2
  137. package/src/utils/command-helpers.ts +45 -23
  138. package/src/utils/emit-queue.ts +26 -0
  139. package/src/utils/formatters/graph-migration-mapper.ts +7 -3
  140. package/src/utils/formatters/migrations.ts +62 -26
  141. package/src/utils/publish-contract-artifact-pair.ts +134 -0
  142. package/dist/cli-errors-DHq6GQGu.mjs +0 -5
  143. package/dist/client-TG7rbCWT.mjs.map +0 -1
  144. package/dist/config-loader-_W4T21X1.mjs.map +0 -1
  145. package/dist/contract-emit-CQfj7xJn.mjs +0 -122
  146. package/dist/contract-emit-CQfj7xJn.mjs.map +0 -1
  147. package/dist/contract-emit-DpPjuFy-.mjs +0 -195
  148. package/dist/contract-emit-DpPjuFy-.mjs.map +0 -1
  149. package/dist/contract-emit-fhNwwhkQ.mjs +0 -4
  150. package/dist/contract-infer-BS4kIX9c.mjs.map +0 -1
  151. package/dist/extract-operation-statements-DZUJNmL3.mjs +0 -13
  152. package/dist/extract-operation-statements-DZUJNmL3.mjs.map +0 -1
  153. package/dist/extract-sql-ddl-DDMX-9mz.mjs +0 -26
  154. package/dist/extract-sql-ddl-DDMX-9mz.mjs.map +0 -1
  155. package/dist/init-CQfo_4Ro.mjs +0 -430
  156. package/dist/init-CQfo_4Ro.mjs.map +0 -1
  157. package/dist/inspect-live-schema-BsoFVoS1.mjs.map +0 -1
  158. package/dist/migration-status-Ry3TnEya.mjs.map +0 -1
  159. package/dist/migrations-fU0xoKjS.mjs.map +0 -1
  160. package/dist/result-handler-BJwA7ufw.mjs.map +0 -1
  161. package/dist/terminal-ui-C5k88MmW.mjs.map +0 -1
  162. package/dist/validate-contract-deps-esa-VQ0h.mjs +0 -37
  163. package/dist/validate-contract-deps-esa-VQ0h.mjs.map +0 -1
  164. package/src/control-api/operations/extract-operation-statements.ts +0 -14
  165. package/src/control-api/operations/extract-sql-ddl.ts +0 -47
@@ -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
- readonly sql?: ReadonlyArray<string>;
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
- readonly sql?: ReadonlyArray<string>;
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
- * Used by tooling (e.g., Vite plugin) that needs to emit contracts
516
- * without the full ControlClient infrastructure.
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 cancellation support */
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';