@prisma/orm-toolchain 8.0.0-rc.19-dev.9 → 8.0.0-rc.19-dev.11

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/dist/cli.mjs CHANGED
@@ -9,9 +9,9 @@ import { r as getEmittedArtifactPaths } from "./exports-BCIlMjIW-DkUBVDzl.mjs";
9
9
  import { r as isInSpaceHistory } from "./graph-membership-DxpNgxfZ-BfqA-H7V.mjs";
10
10
  import { d as writeRef, r as readRef } from "./refs-DM3q3IZC-BC6H6P0X.mjs";
11
11
  import { a as contractHashAtMarker } from "./aggregate-T_HG6gq6.mjs";
12
- import { i as createScaffoldSpecifierResolver } from "./import-roots-DXD7fung.mjs";
12
+ import { i as createScaffoldSpecifierResolver } from "./import-roots-BPn2s_fq.mjs";
13
13
  import { o as isLiveMarkerRef } from "./ref-resolution-Eo0QHp4f.mjs";
14
- import { $ as refuseMarkerOutsideGraph, A as executeRefDeleteCommand, B as loadContractRawSafely, D as executeMigrationNewCommand, E as executeMigrateShowPlan, F as hasMigrationPath, G as mapContractAtError, H as loadContractSourceWithStack, I as isStatementVerb, J as migrationSpaceListEntriesFromAggregate, L as listRefsByContractHash, M as executeRefSetCommand, N as findPackageByDirPath, O as executeMigrationPlanCommand, P as formatSourceDiagnostic, R as liveMarkerUse, U as loadContractSpaceAggregateForCli, V as loadContractSource, W as looksLikePath, X as readMigrationRefs, Y as preflightRefAdvancement, Z as refuseContractSpaceIntegrity, _ as deriveStatusEdgeAnnotations, _t as statusForMigrationHash, a as advanceRefSafely, at as resolveContractRef$1, b as enumerateCheckSpaces, ct as resolveMigrationRef, d as buildRefAdvancementFields, dt as retryCommandFor, et as refuseMissingInvariantPath, f as checkSingleTarget, g as createControlClient, gt as sourceWarningDiagnostic, h as convertAndDelete, ht as snapshotVerifierFor, i as RECORDED_OR_EMPTY_CONTRACT_REF_FORMS, it as resolveAppTargetPath, j as executeRefListCommand, l as buildMigrationSpaceGraphEntries, m as contractValidationMeta, mt as runMigrationList, n as NO_REF_ADVANCEMENT, nt as refuseUnknownInvariants, ot as resolveContractRefToSnapshot, p as computeRefAdvancementName, pt as runMigrationCheck, q as matchConsents, r as RECORDED_CONTRACT_REF_FORMS, rt as requireDatabaseForLiveMarkerUse, s as appliedHashesFromLedger, t as ALL_CONTRACT_REF_FORMS, tt as refusePackageCorruptionOnAggregate, u as buildReadAggregate, vt as toDeclaredExtensionsFromRaw, x as executeContractEmit, yt as validateLoadedContract, z as loadAggregateIntegrityViolations } from "./ref-DEiY2Cbd-Bt7yXfOO.mjs";
14
+ import { $ as refuseMarkerOutsideGraph, A as executeRefDeleteCommand, B as loadContractRawSafely, D as executeMigrationNewCommand, E as executeMigrateShowPlan, F as hasMigrationPath, G as mapContractAtError, H as loadContractSourceWithStack, I as isStatementVerb, J as migrationSpaceListEntriesFromAggregate, L as listRefsByContractHash, M as executeRefSetCommand, N as findPackageByDirPath, O as executeMigrationPlanCommand, P as formatSourceDiagnostic, R as liveMarkerUse, U as loadContractSpaceAggregateForCli, V as loadContractSource, W as looksLikePath, X as readMigrationRefs, Y as preflightRefAdvancement, Z as refuseContractSpaceIntegrity, _ as deriveStatusEdgeAnnotations, _t as statusForMigrationHash, a as advanceRefSafely, at as resolveContractRef$1, b as enumerateCheckSpaces, ct as resolveMigrationRef, d as buildRefAdvancementFields, dt as retryCommandFor, et as refuseMissingInvariantPath, f as checkSingleTarget, g as createControlClient, gt as sourceWarningDiagnostic, h as convertAndDelete, ht as snapshotVerifierFor, i as RECORDED_OR_EMPTY_CONTRACT_REF_FORMS, it as resolveAppTargetPath, j as executeRefListCommand, l as buildMigrationSpaceGraphEntries, m as contractValidationMeta, mt as runMigrationList, n as NO_REF_ADVANCEMENT, nt as refuseUnknownInvariants, ot as resolveContractRefToSnapshot, p as computeRefAdvancementName, pt as runMigrationCheck, q as matchConsents, r as RECORDED_CONTRACT_REF_FORMS, rt as requireDatabaseForLiveMarkerUse, s as appliedHashesFromLedger, t as ALL_CONTRACT_REF_FORMS, tt as refusePackageCorruptionOnAggregate, u as buildReadAggregate, vt as toDeclaredExtensionsFromRaw, x as executeContractEmit, yt as validateLoadedContract, z as loadAggregateIntegrityViolations } from "./ref-DEiY2Cbd-1ZImpUEN.mjs";
15
15
  import { a as PRISMA7_QUICK_REFERENCE_STEP, i as PRISMA7_LOOP_STEP, n as InitOutputSchema, o as buildNextSteps, r as NEXT_STEPS_BEFORE_SCAFFOLD, t as DB_SIGN_STEP } from "./output-BcC8eB0h-C5bRd-aC.mjs";
16
16
  import { createRequire } from "node:module";
17
17
  import { ifDefined } from "@prisma/orm-framework/utils/defined";
@@ -27,7 +27,7 @@ import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, unl
27
27
  import { keepInternalSpecifiers } from "@prisma/orm-framework/components/emission";
28
28
  import { notOk, ok } from "@prisma/orm-framework/utils/result";
29
29
  import { pathToFileURL } from "node:url";
30
- import { defineCommand, defineCommandFamily, defineServerCommand, flag, positional } from "@prisma/cli-engine";
30
+ import { defineCommand, defineCommandFamily, defineServerCommand, flag, noDataLines, positional } from "@prisma/cli-engine";
31
31
  import { CliStructuredError as CliStructuredError$1, notOk as notOk$1, ok as ok$1 } from "@prisma/cli-engine/protocol";
32
32
  import { printPsl } from "@prisma/orm-framework/psl-printer";
33
33
  import { DEFAULT_CONTRACT_SOURCE_DIR, defaultContractOutputPath } from "@prisma/orm-framework/config/config-types";
@@ -40,7 +40,33 @@ import { applyEdits, modify, parse, printParseErrorCode } from "jsonc-parser";
40
40
  import stringWidth from "string-width";
41
41
  import { bold, createColors, cyan, cyanBright, dim, green, yellow } from "colorette";
42
42
  import { build } from "esbuild";
43
- //#region ../../../1-framework/3-tooling/cli/dist/load-config-8vRcnzNe.mjs
43
+ //#region ../../../1-framework/3-tooling/cli/dist/load-config-DjVZj4AV.mjs
44
+ const ESCAPES = {
45
+ "\\": "\\\\",
46
+ " ": "\\t",
47
+ "\n": "\\n",
48
+ "\r": "\\r"
49
+ };
50
+ function fieldText(field) {
51
+ if (field === null || field === void 0) return "";
52
+ return String(field).replace(/[\\\t\n\r]/g, (character) => ESCAPES[character] ?? character);
53
+ }
54
+ /**
55
+ * One data line: the fields tab-separated, an absent field left empty so a
56
+ * script reads the columns by position. A backslash, tab, newline or carriage
57
+ * return inside a field is escaped as `\\`, `\t`, `\n` or `\r`.
58
+ */
59
+ function dataLine(fields) {
60
+ return fields.map(fieldText).join(" ");
61
+ }
62
+ /** `key<TAB>value` lines for a single record; a field whose value is absent is left out. */
63
+ function fieldLines(rows) {
64
+ return rows.filter(([, value]) => value !== null && value !== void 0).map(([key, value]) => dataLine([key, value]));
65
+ }
66
+ /** One data line per value, each escaped as a single-field line. */
67
+ function valueLines(values) {
68
+ return values.map((value) => dataLine([value]));
69
+ }
44
70
  /**
45
71
  * `isStructuredError` is the repo's own check, and it is the one that matters here: it holds the
46
72
  * regular expression for a dotted `NAMESPACE.SUBCODE`, so only a code the protocol accepts
@@ -230,7 +256,7 @@ function emitPresentations(inputs) {
230
256
  },
231
257
  hashRows(document)
232
258
  ],
233
- stdout: () => [document.files.json, document.files.dts],
259
+ stdout: () => valueLines([relative(cwd, document.files.json), relative(cwd, document.files.dts)]),
234
260
  json: () => document
235
261
  };
236
262
  }
@@ -383,7 +409,7 @@ async function filePathKey(path) {
383
409
  function inferPresentations(inputs) {
384
410
  const { document, database } = inputs;
385
411
  return {
386
- stdout: () => [],
412
+ stdout: () => valueLines([document.psl.path]),
387
413
  next: () => [],
388
414
  human: () => [...database === void 0 ? [] : [{
389
415
  kind: "fields",
@@ -1148,7 +1174,7 @@ async function prepareMigrationRun(inputs) {
1148
1174
  function initPresentations$1(inputs) {
1149
1175
  const { document, database, dryRun } = inputs;
1150
1176
  return {
1151
- stdout: () => [],
1177
+ stdout: noDataLines("Data lines are not defined: this command applies a plan, not migrations, so the db migrate fields do not fit. --json carries the plan and what ran."),
1152
1178
  human: () => [{
1153
1179
  kind: "fields",
1154
1180
  rail: true,
@@ -1424,7 +1450,7 @@ function treeNode(node) {
1424
1450
  function schemaPresentations$1(inputs) {
1425
1451
  const { document, schemaView, database } = inputs;
1426
1452
  return {
1427
- stdout: () => [],
1453
+ stdout: noDataLines("Data lines are not defined: the schema is a tree whose shape depends on the database family. --json carries it."),
1428
1454
  next: () => [],
1429
1455
  human: () => [...database === void 0 ? [] : [{
1430
1456
  kind: "fields",
@@ -1802,7 +1828,11 @@ function advancedRefSpans(advanced) {
1802
1828
  function signPresentations(inputs) {
1803
1829
  const { document } = inputs;
1804
1830
  return {
1805
- stdout: () => [],
1831
+ stdout: () => document.spaces.map((space) => dataLine([
1832
+ space.space,
1833
+ space.status,
1834
+ space.contract.storageHash
1835
+ ])),
1806
1836
  next: () => [],
1807
1837
  human: () => [
1808
1838
  inputs.header,
@@ -2260,7 +2290,7 @@ const dbUpdateStatementVerbs = {
2260
2290
  function updatePresentations(inputs) {
2261
2291
  const { document, database, dryRun } = inputs;
2262
2292
  return {
2263
- stdout: () => [],
2293
+ stdout: noDataLines("Data lines are not defined: this command applies a plan, not migrations, so the db migrate fields do not fit. --json carries the plan and what ran."),
2264
2294
  human: () => [{
2265
2295
  kind: "fields",
2266
2296
  rail: true,
@@ -2804,7 +2834,7 @@ function verifyPresentations(inputs) {
2804
2834
  const warnings = document.schema?.warnings ?? [];
2805
2835
  const unclaimed = document.unclaimed ?? [];
2806
2836
  return {
2807
- stdout: () => [],
2837
+ stdout: noDataLines("The exit code is the result of a verification; --json carries the findings."),
2808
2838
  next: () => [],
2809
2839
  human: () => [
2810
2840
  inputs.header,
@@ -2852,7 +2882,7 @@ function verifyPresentations(inputs) {
2852
2882
  }
2853
2883
  function schemaPresentations(inputs) {
2854
2884
  return {
2855
- stdout: () => [],
2885
+ stdout: noDataLines("The exit code is the result of a verification; --json carries the findings."),
2856
2886
  next: () => [],
2857
2887
  human: () => [
2858
2888
  inputs.header,
@@ -3208,7 +3238,7 @@ function formattedBlock(path, cwd) {
3208
3238
  }
3209
3239
  function formatPresentations(document, cwd) {
3210
3240
  return {
3211
- stdout: () => [],
3241
+ stdout: () => document.formatted ? valueLines(document.paths.map((path) => relative(cwd, path))) : [],
3212
3242
  next: () => [],
3213
3243
  human: () => document.formatted ? document.paths.map((path) => formattedBlock(path, cwd)) : [{
3214
3244
  kind: "summary",
@@ -4576,14 +4606,10 @@ function buildInitNextActions(inputs) {
4576
4606
  }
4577
4607
  const DONE_TEXT = "Done. Open prisma-8.md to get started.";
4578
4608
  const INCOMPLETE_TEXT = "Scaffold written. Finish the steps above to complete setup.";
4579
- /**
4580
- * `init` writes files rather than data another program reads, so it supplies
4581
- * no `stdout` payload: human mode writes nothing to stdout.
4582
- */
4583
4609
  function initPresentations(inputs) {
4584
4610
  const { document } = inputs;
4585
4611
  return {
4586
- stdout: () => [],
4612
+ stdout: () => valueLines(document.filesWritten),
4587
4613
  human: () => [
4588
4614
  {
4589
4615
  kind: "fields",
@@ -6288,7 +6314,7 @@ function scaffoldProject(ctx) {
6288
6314
  });
6289
6315
  }
6290
6316
  for (const file of plan.files) {
6291
- const target = join(ctx.cwd, file.path);
6317
+ const target = isAbsolute(file.path) ? file.path : join(ctx.cwd, file.path);
6292
6318
  try {
6293
6319
  mkdirSync(dirname(target), { recursive: true });
6294
6320
  writeFileSync(target, file.content, "utf-8");
@@ -6300,7 +6326,7 @@ function scaffoldProject(ctx) {
6300
6326
  filesRenamed
6301
6327
  });
6302
6328
  }
6303
- filesWritten.push(file.path);
6329
+ filesWritten.push(relative(ctx.cwd, target));
6304
6330
  if (file.note !== void 0) notes.push(file.note);
6305
6331
  }
6306
6332
  for (const rel of plan.filesToDelete) {
@@ -9331,6 +9357,9 @@ function migrateShowRunListRows(migrations, rendering, options) {
9331
9357
  function statusAction(invocation) {
9332
9358
  return runCommandAction("Check every space against the database", cliCommand(invocation, "migration status"));
9333
9359
  }
9360
+ function fromField(from) {
9361
+ return from === "empty" ? void 0 : from;
9362
+ }
9334
9363
  /**
9335
9364
  * The route the migration will take. The graph is a drawing — the engine cannot
9336
9365
  * derive a lane gutter — and the ordered list under it is drawn with the same
@@ -9340,7 +9369,12 @@ function showPresentations$1(inputs) {
9340
9369
  const { document, graph, runList } = inputs;
9341
9370
  const count = document.migrations.length;
9342
9371
  return {
9343
- stdout: () => [],
9372
+ stdout: () => document.migrations.map((migration) => dataLine([
9373
+ migration.spaceId,
9374
+ migration.dirName,
9375
+ fromField(migration.from),
9376
+ migration.to
9377
+ ])),
9344
9378
  next: () => [],
9345
9379
  human: () => [
9346
9380
  {
@@ -9389,7 +9423,13 @@ function applyPresentations(inputs) {
9389
9423
  const { document } = inputs;
9390
9424
  const advanced = document.advancedRef;
9391
9425
  return {
9392
- stdout: () => [],
9426
+ stdout: () => document.applied.map((migration) => dataLine([
9427
+ migration.spaceId,
9428
+ migration.dirName,
9429
+ fromField(migration.from),
9430
+ migration.to,
9431
+ migration.operationsExecuted
9432
+ ])),
9393
9433
  human: () => [
9394
9434
  {
9395
9435
  kind: "fields",
@@ -9837,7 +9877,11 @@ function failureDiagnostic(failure) {
9837
9877
  function checkPresentations(inputs) {
9838
9878
  const summary = inputs.resolvedSpaceId === void 0 ? inputs.document.summary : `${inputs.document.summary} (space: ${inputs.resolvedSpaceId})`;
9839
9879
  return {
9840
- stdout: () => [],
9880
+ stdout: () => inputs.document.failures.map((failure) => dataLine([
9881
+ failure.space,
9882
+ failure.code,
9883
+ failure.where
9884
+ ])),
9841
9885
  next: () => [],
9842
9886
  human: () => [{
9843
9887
  kind: "fields",
@@ -10023,7 +10067,12 @@ function renderMigrationGraphDot(graph) {
10023
10067
  function graphPresentations(inputs) {
10024
10068
  const { tree, dot, legend } = inputs;
10025
10069
  return {
10026
- stdout: () => [],
10070
+ stdout: () => dot === void 0 ? inputs.document.spaces.flatMap((space) => space.migrations.map((migration) => dataLine([
10071
+ space.space,
10072
+ migration.name,
10073
+ migration.fromContract,
10074
+ migration.toContract
10075
+ ]))) : dot.split("\n"),
10027
10076
  next: () => [],
10028
10077
  human: () => [
10029
10078
  {
@@ -10050,7 +10099,6 @@ function graphPresentations(inputs) {
10050
10099
  lines: toneDrawing(legend)
10051
10100
  }]
10052
10101
  ],
10053
- ...dot === void 0 ? {} : { stdout: () => dot.split("\n") },
10054
10102
  json: () => inputs.document
10055
10103
  };
10056
10104
  }
@@ -10139,7 +10187,13 @@ const migrationGraphCommand = defineOrmCommand({
10139
10187
  function listPresentations$1(inputs) {
10140
10188
  const legend = inputs.legend;
10141
10189
  return {
10142
- stdout: () => [],
10190
+ stdout: () => inputs.list.spaces.flatMap((space) => space.migrations.map((migration) => dataLine([
10191
+ space.space,
10192
+ migration.name,
10193
+ migration.fromContract,
10194
+ migration.toContract,
10195
+ migration.operationCount
10196
+ ]))),
10143
10197
  next: () => [],
10144
10198
  human: () => [
10145
10199
  {
@@ -10286,7 +10340,14 @@ function ledgerGrid(entries, options) {
10286
10340
  function logPresentations(inputs) {
10287
10341
  const grid = inputs.grid;
10288
10342
  return {
10289
- stdout: () => [],
10343
+ stdout: () => inputs.document.records.map((record) => dataLine([
10344
+ record.appliedAt,
10345
+ record.space,
10346
+ record.name,
10347
+ record.fromContract,
10348
+ record.toContract,
10349
+ record.operationCount
10350
+ ])),
10290
10351
  next: () => [],
10291
10352
  human: () => [...inputs.database === void 0 ? [] : [{
10292
10353
  kind: "fields",
@@ -10371,7 +10432,7 @@ function newPresentations(inputs) {
10371
10432
  const { document } = inputs;
10372
10433
  const migrationTs = join(document.dir, "migration.ts");
10373
10434
  return {
10374
- stdout: () => [],
10435
+ stdout: () => valueLines([document.dir]),
10375
10436
  human: () => [
10376
10437
  {
10377
10438
  kind: "fields",
@@ -10619,6 +10680,14 @@ function planBlocks(result, migrationsRelative) {
10619
10680
  ...previewBlocks$1(result)
10620
10681
  ];
10621
10682
  }
10683
+ function writtenDirs(result, migrationsRelative) {
10684
+ const dirs = [
10685
+ ...result.baselineDir === void 0 ? [] : [result.baselineDir],
10686
+ ...result.dir === void 0 ? [] : [result.dir],
10687
+ ...result.emittedExtensionDirs.map((entry) => join(migrationsRelative, entry.spaceId, entry.dirName))
10688
+ ];
10689
+ return [...new Set(dirs)];
10690
+ }
10622
10691
  function planNextActions(result, migrationsRelative, invocation) {
10623
10692
  if (result.pendingPlaceholders === true) {
10624
10693
  const stubFiles = (result.placeholderDirs ?? []).map((dir) => join(dir, "migration.ts"));
@@ -10628,11 +10697,7 @@ function planNextActions(result, migrationsRelative, invocation) {
10628
10697
  label: `Replace each placeholder(...) call in ${stubFiles.join(" and ") || migrationTs} with your query`
10629
10698
  }, runCommandAction("Run it to self-emit ops.json and attest the package", selfEmitCommand(invocation, resolve(invocation.cwd, migrationTs)))];
10630
10699
  }
10631
- const written = [
10632
- ...result.baselineDir === void 0 ? [] : [result.baselineDir],
10633
- ...result.dir === void 0 ? [] : [result.dir],
10634
- ...result.emittedExtensionDirs.map((entry) => join(migrationsRelative, entry.spaceId, entry.dirName))
10635
- ];
10700
+ const written = writtenDirs(result, migrationsRelative);
10636
10701
  if (written.length === 0) return [];
10637
10702
  return [{
10638
10703
  kind: "edit-file",
@@ -10641,7 +10706,7 @@ function planNextActions(result, migrationsRelative, invocation) {
10641
10706
  }
10642
10707
  function planPresentations(inputs) {
10643
10708
  return {
10644
- stdout: () => [],
10709
+ stdout: () => valueLines(writtenDirs(inputs.document, inputs.migrationsRelative)),
10645
10710
  human: () => [{
10646
10711
  kind: "fields",
10647
10712
  rail: true,
@@ -10818,7 +10883,19 @@ function previewBlocks(migration) {
10818
10883
  function showPresentations(inputs) {
10819
10884
  const migration = inputs.document.migration;
10820
10885
  return {
10821
- stdout: () => [],
10886
+ stdout: () => [...fieldLines([
10887
+ ["name", migration.name],
10888
+ ["space", migration.space],
10889
+ ["from", migration.fromContract],
10890
+ ["to", migration.toContract],
10891
+ ["hash", migration.hash],
10892
+ ["created", migration.createdAt]
10893
+ ]), ...migration.operations.map((operation) => dataLine([
10894
+ "operation",
10895
+ operation.id,
10896
+ operation.operationClass,
10897
+ operation.label
10898
+ ]))],
10822
10899
  next: () => [],
10823
10900
  human: () => [
10824
10901
  {
@@ -11143,7 +11220,14 @@ function sectionBlock(section) {
11143
11220
  function statusPresentations(inputs) {
11144
11221
  const legend = inputs.legend;
11145
11222
  return {
11146
- stdout: () => [],
11223
+ stdout: () => inputs.document.spaces.flatMap((space) => space.migrations.map((migration) => dataLine([
11224
+ space.space,
11225
+ migration.name,
11226
+ migration.fromContract,
11227
+ migration.toContract,
11228
+ migration.operationCount,
11229
+ migration.status
11230
+ ]))),
11147
11231
  next: () => [],
11148
11232
  human: () => [
11149
11233
  {
@@ -11462,7 +11546,7 @@ const migrationStatusCommand = defineOrmCommand({
11462
11546
  });
11463
11547
  function deletePresentations(document) {
11464
11548
  return {
11465
- stdout: () => [],
11549
+ stdout: noDataLines("Deleting a ref has no data; the exit code says whether it worked."),
11466
11550
  next: () => [],
11467
11551
  human: () => [{
11468
11552
  kind: "summary",
@@ -11535,7 +11619,11 @@ function refsGrid(refs) {
11535
11619
  }
11536
11620
  function listPresentations(document) {
11537
11621
  return {
11538
- stdout: () => [],
11622
+ stdout: () => Object.entries(document.refs).map(([name, entry]) => dataLine([
11623
+ name,
11624
+ entry.hash,
11625
+ entry.invariants.join(",")
11626
+ ])),
11539
11627
  next: () => [],
11540
11628
  human: () => Object.keys(document.refs).length === 0 ? [{
11541
11629
  kind: "summary",
@@ -11566,7 +11654,7 @@ function createRefListCommand(execute = executeRefListCommand) {
11566
11654
  const refListCommand = createRefListCommand();
11567
11655
  function setPresentations(document) {
11568
11656
  return {
11569
- stdout: () => [],
11657
+ stdout: () => valueLines([document.hash]),
11570
11658
  next: () => [],
11571
11659
  human: () => [{
11572
11660
  kind: "summary",