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