prisma-next 0.11.0 → 0.12.0
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 +259 -12
- package/dist/cli.mjs.map +1 -1
- package/dist/{client-oXO2WCPD.mjs → client-KgJorIvG.mjs} +72 -60
- package/dist/client-KgJorIvG.mjs.map +1 -0
- package/dist/{command-helpers-BSb0tRC8.mjs → command-helpers-Bbw1GbwL.mjs} +646 -46
- package/dist/command-helpers-Bbw1GbwL.mjs.map +1 -0
- package/dist/commands/contract-emit.d.mts.map +1 -1
- package/dist/commands/contract-emit.mjs +1 -1
- package/dist/commands/contract-infer.d.mts.map +1 -1
- package/dist/commands/contract-infer.mjs +1 -1
- package/dist/commands/db-init.d.mts.map +1 -1
- package/dist/commands/db-init.mjs +32 -7
- package/dist/commands/db-init.mjs.map +1 -1
- package/dist/commands/db-schema.d.mts.map +1 -1
- package/dist/commands/db-schema.mjs +3 -4
- package/dist/commands/db-schema.mjs.map +1 -1
- package/dist/commands/db-sign.d.mts.map +1 -1
- package/dist/commands/db-sign.mjs +12 -10
- package/dist/commands/db-sign.mjs.map +1 -1
- package/dist/commands/db-update.d.mts.map +1 -1
- package/dist/commands/db-update.mjs +41 -11
- package/dist/commands/db-update.mjs.map +1 -1
- package/dist/commands/db-verify.d.mts.map +1 -1
- package/dist/commands/db-verify.mjs +1 -1
- package/dist/commands/migrate.d.mts +6 -2
- package/dist/commands/migrate.d.mts.map +1 -1
- package/dist/commands/migrate.mjs +75 -40
- package/dist/commands/migrate.mjs.map +1 -1
- package/dist/commands/migration-check.d.mts +4 -3
- package/dist/commands/migration-check.d.mts.map +1 -1
- package/dist/commands/migration-check.mjs +1 -280
- package/dist/commands/migration-graph.d.mts +13 -2
- package/dist/commands/migration-graph.d.mts.map +1 -1
- package/dist/commands/migration-graph.mjs +2 -137
- package/dist/commands/migration-list.d.mts +64 -4
- package/dist/commands/migration-list.d.mts.map +1 -1
- package/dist/commands/migration-list.mjs +143 -56
- package/dist/commands/migration-list.mjs.map +1 -1
- package/dist/commands/migration-log.d.mts +10 -1
- package/dist/commands/migration-log.d.mts.map +1 -1
- package/dist/commands/migration-log.mjs +10 -15
- package/dist/commands/migration-log.mjs.map +1 -1
- package/dist/commands/migration-new.d.mts.map +1 -1
- package/dist/commands/migration-new.mjs +32 -38
- package/dist/commands/migration-new.mjs.map +1 -1
- package/dist/commands/migration-plan.d.mts +3 -2
- package/dist/commands/migration-plan.d.mts.map +1 -1
- package/dist/commands/migration-plan.mjs +1 -1
- package/dist/commands/migration-show.d.mts +4 -55
- package/dist/commands/migration-show.d.mts.map +1 -1
- package/dist/commands/migration-show.mjs +61 -153
- package/dist/commands/migration-show.mjs.map +1 -1
- package/dist/commands/migration-status.d.mts +12 -49
- package/dist/commands/migration-status.d.mts.map +1 -1
- package/dist/commands/migration-status.mjs +85 -81
- package/dist/commands/migration-status.mjs.map +1 -1
- package/dist/commands/ref.d.mts +1 -1
- package/dist/commands/ref.d.mts.map +1 -1
- package/dist/commands/ref.mjs +38 -10
- package/dist/commands/ref.mjs.map +1 -1
- package/dist/config-loader-B6sJjXTv.mjs.map +1 -1
- package/dist/config-loader.d.mts.map +1 -1
- package/dist/contract-at-errors-BxP-TOMl.mjs +42 -0
- package/dist/contract-at-errors-BxP-TOMl.mjs.map +1 -0
- package/dist/{contract-emit-bcrpT-wD.mjs → contract-emit-D-4jrNve.mjs} +25 -10
- package/dist/contract-emit-D-4jrNve.mjs.map +1 -0
- package/dist/{contract-emit-r4y8Zhf1.mjs → contract-emit-DxcGl4Uq.mjs} +19 -14
- package/dist/contract-emit-DxcGl4Uq.mjs.map +1 -0
- package/dist/{contract-enrichment-Dani0mMW.mjs → contract-enrichment-a0V5Y_mL.mjs} +4 -25
- package/dist/contract-enrichment-a0V5Y_mL.mjs.map +1 -0
- package/dist/{contract-infer-BmySmqVT.mjs → contract-infer-D8uEbJuu.mjs} +4 -5
- package/dist/{contract-infer-BmySmqVT.mjs.map → contract-infer-D8uEbJuu.mjs.map} +1 -1
- package/dist/contract-space-aggregate-loader-DvZwdkrr.mjs +247 -0
- package/dist/contract-space-aggregate-loader-DvZwdkrr.mjs.map +1 -0
- package/dist/{db-verify-BClPs3ph.mjs → db-verify-v_vUKXTU.mjs} +5 -7
- package/dist/{db-verify-BClPs3ph.mjs.map → db-verify-v_vUKXTU.mjs.map} +1 -1
- package/dist/exports/control-api.d.mts +3 -3
- package/dist/exports/control-api.d.mts.map +1 -1
- package/dist/exports/control-api.mjs +3 -3
- package/dist/exports/index.d.mts.map +1 -1
- package/dist/exports/index.mjs +1 -1
- package/dist/exports/index.mjs.map +1 -1
- package/dist/exports/init-output.d.mts.map +1 -1
- package/dist/exports/init-output.mjs +1 -1
- package/dist/extension-pack-inputs-IDvjRCi3.mjs +62 -0
- package/dist/extension-pack-inputs-IDvjRCi3.mjs.map +1 -0
- package/dist/{framework-components-65gOHkHB.mjs → framework-components-fYXjz_in.mjs} +2 -2
- package/dist/{framework-components-65gOHkHB.mjs.map → framework-components-fYXjz_in.mjs.map} +1 -1
- package/dist/global-flags-DEHjV8_s.d.mts +34 -0
- package/dist/global-flags-DEHjV8_s.d.mts.map +1 -0
- package/dist/{graph-render-DJVv0_uf.mjs → graph-render-rFAqZujX.mjs} +2 -2
- package/dist/{graph-render-DJVv0_uf.mjs.map → graph-render-rFAqZujX.mjs.map} +1 -1
- package/dist/{init-BCJZPWE1.mjs → init-Cv9UzWL5.mjs} +20 -269
- package/dist/init-Cv9UzWL5.mjs.map +1 -0
- package/dist/{inspect-live-schema-DSRbFoOL.mjs → inspect-live-schema-C6ohV_oQ.mjs} +4 -5
- package/dist/{inspect-live-schema-DSRbFoOL.mjs.map → inspect-live-schema-C6ohV_oQ.mjs.map} +1 -1
- package/dist/migration-check-BiBJoYYW.mjs +341 -0
- package/dist/migration-check-BiBJoYYW.mjs.map +1 -0
- package/dist/migration-cli.d.mts.map +1 -1
- package/dist/migration-cli.mjs +4 -4
- package/dist/migration-cli.mjs.map +1 -1
- package/dist/{migration-command-scaffold-Bzd9La5c.mjs → migration-command-scaffold-CjvwO6at.mjs} +4 -5
- package/dist/{migration-command-scaffold-Bzd9La5c.mjs.map → migration-command-scaffold-CjvwO6at.mjs.map} +1 -1
- package/dist/migration-graph-D7DVUElV.mjs +1232 -0
- package/dist/migration-graph-D7DVUElV.mjs.map +1 -0
- package/dist/migration-list-styler-BRwF4-gy.mjs +399 -0
- package/dist/migration-list-styler-BRwF4-gy.mjs.map +1 -0
- package/dist/{migration-plan-CFwqw3Gk.mjs → migration-plan-9DJ7q7_z.mjs} +372 -133
- package/dist/migration-plan-9DJ7q7_z.mjs.map +1 -0
- package/dist/{migration-types-BXWvz12q.d.mts → migration-types-D2FW63pr.d.mts} +1 -1
- package/dist/{migration-types-BXWvz12q.d.mts.map → migration-types-D2FW63pr.d.mts.map} +1 -1
- package/dist/{migrations-CwZMa1Ck.mjs → migrations-Cv2jxNNK.mjs} +12 -13
- package/dist/migrations-Cv2jxNNK.mjs.map +1 -0
- package/dist/{output-BlsrGMEF.mjs → output-B60Gw5fu.mjs} +1 -1
- package/dist/{output-BlsrGMEF.mjs.map → output-B60Gw5fu.mjs.map} +1 -1
- package/dist/{progress-adapter-DFfvZcYL.mjs → progress-adapter-C644QK8l.mjs} +1 -1
- package/dist/{progress-adapter-DFfvZcYL.mjs.map → progress-adapter-C644QK8l.mjs.map} +1 -1
- package/dist/ref-advancement-DUZqsue6.mjs +50 -0
- package/dist/ref-advancement-DUZqsue6.mjs.map +1 -0
- package/dist/terminal-ui-5Y6mrg93.d.mts +133 -0
- package/dist/terminal-ui-5Y6mrg93.d.mts.map +1 -0
- package/dist/{types--CqjMdk0.d.mts → types-Dt_SfqFm.d.mts} +28 -28
- package/dist/types-Dt_SfqFm.d.mts.map +1 -0
- package/dist/{verify-Bom75OYI.mjs → verify-DCA9Sldu.mjs} +2 -2
- package/dist/{verify-Bom75OYI.mjs.map → verify-DCA9Sldu.mjs.map} +1 -1
- package/package.json +28 -17
- package/dist/cli-errors-Czmx92Zy.d.mts +0 -3
- package/dist/cli-errors-Djtz98Vm.mjs +0 -71
- package/dist/cli-errors-Djtz98Vm.mjs.map +0 -1
- package/dist/client-oXO2WCPD.mjs.map +0 -1
- package/dist/command-helpers-BSb0tRC8.mjs.map +0 -1
- package/dist/commands/migration-check.mjs.map +0 -1
- package/dist/commands/migration-graph.mjs.map +0 -1
- package/dist/contract-emit-bcrpT-wD.mjs.map +0 -1
- package/dist/contract-emit-r4y8Zhf1.mjs.map +0 -1
- package/dist/contract-enrichment-Dani0mMW.mjs.map +0 -1
- package/dist/contract-space-aggregate-loader-BmNQwlws.mjs +0 -160
- package/dist/contract-space-aggregate-loader-BmNQwlws.mjs.map +0 -1
- package/dist/global-flags-CdE7M0d9.d.mts +0 -15
- package/dist/global-flags-CdE7M0d9.d.mts.map +0 -1
- package/dist/init-BCJZPWE1.mjs.map +0 -1
- package/dist/migration-plan-CFwqw3Gk.mjs.map +0 -1
- package/dist/migrations-CwZMa1Ck.mjs.map +0 -1
- package/dist/rolldown-runtime-twds-ZHy.mjs +0 -14
- package/dist/terminal-ui-BiB_8KNo.mjs +0 -379
- package/dist/terminal-ui-BiB_8KNo.mjs.map +0 -1
- package/dist/types--CqjMdk0.d.mts.map +0 -1
|
@@ -1,41 +1,9 @@
|
|
|
1
|
-
import { n as StatusRef, t as StatusDiagnostic } from "../migration-types-
|
|
1
|
+
import { n as StatusRef, t as StatusDiagnostic } from "../migration-types-D2FW63pr.mjs";
|
|
2
2
|
import { Command } from "commander";
|
|
3
|
-
import {
|
|
4
|
-
import { ControlExtensionDescriptor } from "@prisma-next/framework-components/control";
|
|
5
|
-
import { ContractMarkerRecordLike } from "@prisma-next/migration-tools/aggregate";
|
|
6
|
-
import { Contract } from "@prisma-next/contract/types";
|
|
7
|
-
import { OnDiskMigrationPackage } from "@prisma-next/migration-tools/package";
|
|
3
|
+
import { ContractMarkerRecordLike, ContractSpaceAggregate } from "@prisma-next/migration-tools/aggregate";
|
|
8
4
|
import { MigrationGraph } from "@prisma-next/migration-tools/graph";
|
|
5
|
+
import { OnDiskMigrationPackage } from "@prisma-next/migration-tools/package";
|
|
9
6
|
|
|
10
|
-
//#region src/utils/contract-space-aggregate-loader.d.ts
|
|
11
|
-
/**
|
|
12
|
-
* Inputs needed to compose the aggregate loader at the CLI surface.
|
|
13
|
-
*
|
|
14
|
-
* Keeps the loader framework-neutral (no `Config` import) by accepting
|
|
15
|
-
* already-resolved structural inputs: validated app contract, target
|
|
16
|
-
* id, migrations root directory, and the set of extension descriptors.
|
|
17
|
-
*/
|
|
18
|
-
interface BuildAggregateInputs<TFamilyId extends string, TTargetId extends string> {
|
|
19
|
-
readonly targetId: TTargetId;
|
|
20
|
-
readonly migrationsDir: string;
|
|
21
|
-
readonly appContract: Contract;
|
|
22
|
-
readonly extensionPacks: ReadonlyArray<ControlExtensionDescriptor<TFamilyId, TTargetId>>;
|
|
23
|
-
readonly deserializeContract: (contractJson: unknown) => Contract;
|
|
24
|
-
/**
|
|
25
|
-
* App-space migration packages to hydrate the app member's
|
|
26
|
-
* migration graph with. Defaults to `[]` (matches the `db init` /
|
|
27
|
-
* `db update` daily-driver behaviour, where the app's authored
|
|
28
|
-
* `migrations/` graph is not walked — the planner uses the synth
|
|
29
|
-
* strategy for the app member instead).
|
|
30
|
-
*
|
|
31
|
-
* `migrate` callers thread the user's authored app-space
|
|
32
|
-
* packages (loaded via `loadMigrationPackages(appMigrationsDir)`)
|
|
33
|
-
* through here so the graph-walk strategy can plot a path through
|
|
34
|
-
* them — the prod-time replay path explicitly forbids synth.
|
|
35
|
-
*/
|
|
36
|
-
readonly appMigrationPackages?: ReadonlyArray<OnDiskMigrationPackage>;
|
|
37
|
-
}
|
|
38
|
-
//#endregion
|
|
39
7
|
//#region src/utils/formatters/graph-migration-mapper.d.ts
|
|
40
8
|
type EdgeStatusKind = 'applied' | 'pending' | 'unreachable';
|
|
41
9
|
/** Minimal per-edge status from the CLI's status result. */
|
|
@@ -137,10 +105,9 @@ interface MigrationStatusResult {
|
|
|
137
105
|
* migrations directory) where the existing diagnostics already
|
|
138
106
|
* surface the failure.
|
|
139
107
|
*
|
|
140
|
-
* The
|
|
141
|
-
* `
|
|
142
|
-
*
|
|
143
|
-
* detail for extension members lives only on this list.
|
|
108
|
+
* The top-level fields (`migrations`, `markerHash`, `targetHash`,
|
|
109
|
+
* `pathDecision`, …) describe the **app member** specifically.
|
|
110
|
+
* Per-space detail for extension members lives only on this list.
|
|
144
111
|
*/
|
|
145
112
|
readonly spaces?: readonly MigrationStatusSpaceEntry[];
|
|
146
113
|
/** Cross-space pending-migration total (sum of `spaces[].pendingCount`). Present when `spaces` is. */
|
|
@@ -171,20 +138,16 @@ declare function deriveEdgeStatuses(graph: MigrationGraph, targetHash: string, c
|
|
|
171
138
|
/**
|
|
172
139
|
* Build the aggregate enumeration of contract spaces for the status
|
|
173
140
|
* output. Loads the aggregate from disk (lossy on failure — extension
|
|
174
|
-
* spaces are simply omitted, the
|
|
175
|
-
*
|
|
141
|
+
* spaces are simply omitted, the app member's output keeps working),
|
|
142
|
+
* reads per-space marker rows when online, and uses
|
|
176
143
|
* {@link graphWalkStrategy} to compute each space's pending count.
|
|
177
144
|
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
* cross-space totals.
|
|
145
|
+
* The aggregate-walking status reports per-space marker + pending
|
|
146
|
+
* state alongside the cross-space totals.
|
|
181
147
|
*/
|
|
182
148
|
declare function loadAggregateStatusSpaces(args: {
|
|
183
|
-
readonly
|
|
184
|
-
readonly
|
|
185
|
-
readonly appContractRaw: unknown;
|
|
186
|
-
readonly extensionPacks: BuildAggregateInputs<string, string>['extensionPacks'];
|
|
187
|
-
readonly deserializeContract: BuildAggregateInputs<string, string>['deserializeContract'];
|
|
149
|
+
readonly aggregate: ContractSpaceAggregate;
|
|
150
|
+
readonly extensionPacks: ReadonlyArray<unknown>;
|
|
188
151
|
readonly markersBySpace: ReadonlyMap<string, ContractMarkerRecordLike> | null;
|
|
189
152
|
}): Promise<readonly MigrationStatusSpaceEntry[]>;
|
|
190
153
|
declare function createMigrationStatusCommand(): Command;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration-status.d.mts","names":[],"sources":["../../src/utils/
|
|
1
|
+
{"version":3,"file":"migration-status.d.mts","names":[],"sources":["../../src/utils/formatters/graph-migration-mapper.ts","../../src/commands/migration-status.ts"],"mappings":";;;;;;;KAiBY,cAAA;;UAmBK,UAAA;EAAA,SACN,OAAA;EAAA,SACA,MAAA,EAAQ,cAAc;AAAA;;;UC+ChB,oBAAA;EAAA,SACN,OAAA;EAAA,SACA,IAAA;EAAA,SACA,EAAA;EAAA,SACA,aAAA;EAAA,SACA,cAAA;EAAA,SACA,gBAAA;EAAA,SACA,cAAA;EAAA,SACA,MAAA,EAAQ,cAAc;AAAA;;;;;ADvDA;;;;AC+CjC;;;;;;;;;;;UA8BiB,yBAAA;EAAA,SACN,OAAA;EAAA,SACA,IAAA;EAAA,SACA,QAAA;EAAA,SACA,UAAA;EAAA,SACA,YAAA;EAAA,SACA,MAAA;AAAA;;;;;;;;iBAUK,+BAAA,CACd,MAA4C,WAA3B,yBAAyB;AAAA,UAa3B,qBAAA;EAAA,SACN,EAAA;EAAA,SACA,IAAA;EAAA,SACA,UAAA,WAAqB,oBAAA;EAAA,SACrB,UAAA;EAAA,SACA,UAAA;EAAA,SACA,YAAA;EAAA,SACA,IAAA,YAAgB,SAAA;EAAA;EAAA,SAEhB,kBAAA;EA0CkB;;;;;;;;EAAA,SAjClB,iBAAA;EAfqB;EAAA,SAiBrB,iBAAA;EAAA,SACA,YAAA;IAAA,SACE,QAAA;IAAA,SACA,MAAA;IAAA,SACA,gBAAA;IAAA,SACA,eAAA;IAAA,SACA,OAAA;IAAA,SACA,kBAAA;IAAA,SACA,mBAAA;IAAA,SACA,YAAA;MAAA,SACE,OAAA;MAAA,SACA,aAAA;MAAA,SACA,IAAA;MAAA,SACA,EAAA;MAAA,SACA,UAAA;IAAA;EAAA;EAAA,SAGJ,OAAA;EAAA,SACA,WAAA,WAAsB,gBAAA;EANlB;;;;;;;;;;;;EAAA,SAmBJ,MAAA,YAAkB,yBAAA;EAKlB;EAAA,SAHA,wBAAA;EAAA,SACA,KAAA,GAAQ,cAAA;EAAA,SACR,OAAA,YAAmB,sBAAA;EAAA,SACnB,YAAA,YAAwB,UAAA;EAAA,SACxB,aAAA;EAAA,SACA,aAAA;EAAA,SACA,QAAA;AAAA;;;;;;;;;;;AAqDE;AAqLb;;;;iBA3LgB,kBAAA,CACd,KAAA,EAAO,cAAA,EACP,UAAA,UACA,YAAA,UACA,UAAA,sBACA,IAAA,yBACC,UAAU;;;;;;;;;;;iBAqLS,yBAAA,CAA0B,IAAA;EAAA,SACrC,SAAA,EAAW,sBAAA;EAAA,SACX,cAAA,EAAgB,aAAA;EAAA,SAChB,cAAA,EAAgB,WAAA,SAAoB,wBAAA;AAAA,IAC3C,OAAA,UAAiB,yBAAA;AAAA,iBA+pBL,4BAAA,CAAA,GAAgC,OAAO;AAAA,iBAoGvC,mBAAA,CAAoB,MAAA,EAAQ,qBAAqB,EAAE,QAAA"}
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import { t as loadConfig } from "../config-loader-B6sJjXTv.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { t as
|
|
4
|
-
import {
|
|
5
|
-
import { t as
|
|
6
|
-
import { t as
|
|
7
|
-
import { i as migrationGraphToRenderInput, n as graphRenderer, r as isLinearGraph, t as extractRelevantSubgraph } from "../graph-render-DJVv0_uf.mjs";
|
|
2
|
+
import { A as CliStructuredError, T as formatStyledHeader, X as errorRuntime, _ as createTerminalUI, a as readContractEnvelope, d as setCommandSeeAlso, g as parseGlobalFlagsOrExit, i as maskConnectionUrl, l as setCommandDescriptions, m as toStructuralEdge, n as collectDeclaredInvariants, nt as mapMigrationToolsError, p as toPathDecisionResult, rt as mapRefResolutionError, s as resolveMigrationPaths, t as addGlobalOptions, tt as errorUnexpected, u as setCommandExamples, y as handleResult } from "../command-helpers-Bbw1GbwL.mjs";
|
|
3
|
+
import { t as createControlClient } from "../client-KgJorIvG.mjs";
|
|
4
|
+
import { t as toDeclaredExtensionsFromRaw } from "../extension-pack-inputs-IDvjRCi3.mjs";
|
|
5
|
+
import { i as loadContractRawSafely, o as refuseContractSpaceIntegrity, s as refusePackageCorruptionOnAggregate, t as appContractStandInFromIdentity } from "../contract-space-aggregate-loader-DvZwdkrr.mjs";
|
|
6
|
+
import { i as migrationGraphToRenderInput, n as graphRenderer, r as isLinearGraph, t as extractRelevantSubgraph } from "../graph-render-rFAqZujX.mjs";
|
|
8
7
|
import { Command } from "commander";
|
|
9
8
|
import { ifDefined } from "@prisma-next/utils/defined";
|
|
10
9
|
import { notOk, ok } from "@prisma-next/utils/result";
|
|
11
10
|
import { createControlStack } from "@prisma-next/framework-components/control";
|
|
12
|
-
import { findPath, findPathWithDecision, findReachableLeaves } from "@prisma-next/migration-tools/migration-graph";
|
|
13
11
|
import { cyan, dim, magenta, yellow } from "colorette";
|
|
14
|
-
import { graphWalkStrategy } from "@prisma-next/migration-tools/aggregate";
|
|
12
|
+
import { graphWalkStrategy, loadContractSpaceAggregate, requireHeadRef } from "@prisma-next/migration-tools/aggregate";
|
|
15
13
|
import { EMPTY_CONTRACT_HASH } from "@prisma-next/migration-tools/constants";
|
|
16
14
|
import { MigrationToolsError, errorNoInvariantPath, errorUnknownInvariant } from "@prisma-next/migration-tools/errors";
|
|
17
|
-
import {
|
|
15
|
+
import { findPath, findPathWithDecision, findReachableLeaves } from "@prisma-next/migration-tools/migration-graph";
|
|
18
16
|
import { readRefs } from "@prisma-next/migration-tools/refs";
|
|
17
|
+
import { parseContractRef } from "@prisma-next/migration-tools/ref-resolution";
|
|
19
18
|
//#region src/commands/migration-status.ts
|
|
20
19
|
/**
|
|
21
20
|
* Sum per-space `pendingCount` into a cross-space total, but only when
|
|
@@ -178,37 +177,34 @@ function resolveDisplayChain(graph, targetHash, markerHash) {
|
|
|
178
177
|
/**
|
|
179
178
|
* Build the aggregate enumeration of contract spaces for the status
|
|
180
179
|
* output. Loads the aggregate from disk (lossy on failure — extension
|
|
181
|
-
* spaces are simply omitted, the
|
|
182
|
-
*
|
|
180
|
+
* spaces are simply omitted, the app member's output keeps working),
|
|
181
|
+
* reads per-space marker rows when online, and uses
|
|
183
182
|
* {@link graphWalkStrategy} to compute each space's pending count.
|
|
184
183
|
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
* cross-space totals.
|
|
184
|
+
* The aggregate-walking status reports per-space marker + pending
|
|
185
|
+
* state alongside the cross-space totals.
|
|
188
186
|
*/
|
|
189
187
|
async function loadAggregateStatusSpaces(args) {
|
|
190
|
-
const
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
});
|
|
197
|
-
if (!loaded.ok) return [];
|
|
198
|
-
const aggregate = loaded.value;
|
|
188
|
+
const declaredExtensions = toDeclaredExtensionsFromRaw(args.extensionPacks);
|
|
189
|
+
if (refuseContractSpaceIntegrity(args.aggregate, {
|
|
190
|
+
declaredExtensions,
|
|
191
|
+
checkContracts: true
|
|
192
|
+
})) return [];
|
|
193
|
+
const aggregate = args.aggregate;
|
|
199
194
|
const orderedMembers = [...aggregate.extensions, aggregate.app];
|
|
200
195
|
const rows = [];
|
|
201
196
|
for (const member of orderedMembers) {
|
|
202
197
|
const liveMarker = args.markersBySpace?.get(member.spaceId) ?? null;
|
|
203
198
|
const isApp = member.spaceId === aggregate.app.spaceId;
|
|
204
|
-
|
|
199
|
+
const headRef = requireHeadRef(member);
|
|
200
|
+
if (member.graph().nodes.size === 0) {
|
|
205
201
|
rows.push({
|
|
206
202
|
spaceId: member.spaceId,
|
|
207
203
|
kind: isApp ? "app" : "extension",
|
|
208
|
-
headHash:
|
|
204
|
+
headHash: headRef.hash,
|
|
209
205
|
...args.markersBySpace !== null ? {
|
|
210
206
|
markerHash: liveMarker?.storageHash ?? null,
|
|
211
|
-
status:
|
|
207
|
+
status: headRef.hash === EMPTY_CONTRACT_HASH ? "up-to-date" : "never-planned",
|
|
212
208
|
pendingCount: 0
|
|
213
209
|
} : {}
|
|
214
210
|
});
|
|
@@ -218,7 +214,7 @@ async function loadAggregateStatusSpaces(args) {
|
|
|
218
214
|
rows.push({
|
|
219
215
|
spaceId: member.spaceId,
|
|
220
216
|
kind: isApp ? "app" : "extension",
|
|
221
|
-
headHash:
|
|
217
|
+
headHash: headRef.hash
|
|
222
218
|
});
|
|
223
219
|
continue;
|
|
224
220
|
}
|
|
@@ -237,7 +233,7 @@ async function loadAggregateStatusSpaces(args) {
|
|
|
237
233
|
rows.push({
|
|
238
234
|
spaceId: member.spaceId,
|
|
239
235
|
kind: isApp ? "app" : "extension",
|
|
240
|
-
headHash:
|
|
236
|
+
headHash: headRef.hash,
|
|
241
237
|
markerHash: liveMarker?.storageHash ?? null,
|
|
242
238
|
pendingCount,
|
|
243
239
|
...status ? { status } : {}
|
|
@@ -251,15 +247,6 @@ async function loadAggregateStatusSpaces(args) {
|
|
|
251
247
|
* the existing `readContractEnvelope` path will report the same
|
|
252
248
|
* problem via a status diagnostic, no need to double-surface.
|
|
253
249
|
*/
|
|
254
|
-
async function loadContractRawSafely(config) {
|
|
255
|
-
try {
|
|
256
|
-
const path = (await import("../command-helpers-BSb0tRC8.mjs").then((n) => n.r)).resolveContractPath(config);
|
|
257
|
-
const raw = await (await import("node:fs/promises")).readFile(path, "utf-8");
|
|
258
|
-
return JSON.parse(raw);
|
|
259
|
-
} catch {
|
|
260
|
-
return null;
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
250
|
async function validateOnlineMarkerRead(config, dbConnection) {
|
|
264
251
|
const driver = config.driver;
|
|
265
252
|
if (!driver) return ok(void 0);
|
|
@@ -283,7 +270,7 @@ async function validateOnlineMarkerRead(config, dbConnection) {
|
|
|
283
270
|
}
|
|
284
271
|
async function executeMigrationStatusCommand(options, flags, ui) {
|
|
285
272
|
const config = await loadConfig(options.config);
|
|
286
|
-
const { configPath,
|
|
273
|
+
const { configPath, appMigrationsRelative, migrationsDir, refsDir } = resolveMigrationPaths(options.config, config);
|
|
287
274
|
const dbConnection = options.db ?? config.db?.connection;
|
|
288
275
|
const hasDriver = !!config.driver;
|
|
289
276
|
let activeRefName;
|
|
@@ -296,12 +283,58 @@ async function executeMigrationStatusCommand(options, flags, ui) {
|
|
|
296
283
|
if (MigrationToolsError.is(error)) return notOk(mapMigrationToolsError(error));
|
|
297
284
|
throw error;
|
|
298
285
|
}
|
|
286
|
+
const diagnostics = [];
|
|
287
|
+
let contractHash = EMPTY_CONTRACT_HASH;
|
|
288
|
+
try {
|
|
289
|
+
contractHash = (await readContractEnvelope(config)).storageHash;
|
|
290
|
+
} catch (error) {
|
|
291
|
+
diagnostics.push({
|
|
292
|
+
code: "CONTRACT.UNREADABLE",
|
|
293
|
+
severity: "warn",
|
|
294
|
+
message: `Could not read contract: ${error instanceof Error ? error.message : "unknown error"}`,
|
|
295
|
+
hints: ["Run 'prisma-next contract emit' to generate a valid contract"]
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
const contractRawForAggregate = await loadContractRawSafely(config);
|
|
299
|
+
const stack = createControlStack(config);
|
|
300
|
+
const familyInstance = config.family.create(stack);
|
|
301
|
+
const deserializeContract = (json) => familyInstance.deserializeContract(json);
|
|
302
|
+
let appContractForLoad = appContractStandInFromIdentity({
|
|
303
|
+
contractHash,
|
|
304
|
+
targetId: config.target.id,
|
|
305
|
+
targetFamily: config.target.familyId
|
|
306
|
+
});
|
|
307
|
+
if (contractRawForAggregate !== null) try {
|
|
308
|
+
appContractForLoad = deserializeContract(contractRawForAggregate);
|
|
309
|
+
} catch (error) {
|
|
310
|
+
diagnostics.push({
|
|
311
|
+
code: "CONTRACT.UNREADABLE",
|
|
312
|
+
severity: "warn",
|
|
313
|
+
message: `Could not deserialize contract: ${error instanceof Error ? error.message : "unknown error"}`,
|
|
314
|
+
hints: ["Run 'prisma-next contract emit' to generate a valid contract"]
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
let aggregate;
|
|
318
|
+
try {
|
|
319
|
+
aggregate = await loadContractSpaceAggregate({
|
|
320
|
+
migrationsDir,
|
|
321
|
+
deserializeContract,
|
|
322
|
+
appContract: appContractForLoad
|
|
323
|
+
});
|
|
324
|
+
} catch (error) {
|
|
325
|
+
if (MigrationToolsError.is(error)) return notOk(mapMigrationToolsError(error));
|
|
326
|
+
return notOk(errorUnexpected(error instanceof Error ? error.message : String(error), { why: `Failed to read migrations directory: ${error instanceof Error ? error.message : String(error)}` }));
|
|
327
|
+
}
|
|
328
|
+
if (contractRawForAggregate !== null) {
|
|
329
|
+
const corruptionFailure = refusePackageCorruptionOnAggregate(aggregate);
|
|
330
|
+
if (corruptionFailure) return notOk(corruptionFailure);
|
|
331
|
+
}
|
|
332
|
+
const appGraph = aggregate.app.graph();
|
|
299
333
|
let fromOverrideHash;
|
|
300
|
-
if (options.to || options.from)
|
|
301
|
-
const { graph: earlyGraph } = await loadMigrationPackages(appMigrationsDir);
|
|
334
|
+
if (options.to || options.from) {
|
|
302
335
|
if (options.to) {
|
|
303
336
|
const refResult = parseContractRef(options.to, {
|
|
304
|
-
graph:
|
|
337
|
+
graph: appGraph,
|
|
305
338
|
refs: allRefs
|
|
306
339
|
});
|
|
307
340
|
if (!refResult.ok) return notOk(mapRefResolutionError(refResult.failure));
|
|
@@ -314,15 +347,12 @@ async function executeMigrationStatusCommand(options, flags, ui) {
|
|
|
314
347
|
}
|
|
315
348
|
if (options.from) {
|
|
316
349
|
const fromResult = parseContractRef(options.from, {
|
|
317
|
-
graph:
|
|
350
|
+
graph: appGraph,
|
|
318
351
|
refs: allRefs
|
|
319
352
|
});
|
|
320
353
|
if (!fromResult.ok) return notOk(mapRefResolutionError(fromResult.failure));
|
|
321
354
|
fromOverrideHash = fromResult.value.hash;
|
|
322
355
|
}
|
|
323
|
-
} catch (error) {
|
|
324
|
-
if (MigrationToolsError.is(error)) return notOk(mapMigrationToolsError(error));
|
|
325
|
-
throw error;
|
|
326
356
|
}
|
|
327
357
|
const requiredInvariants = [...activeRefEntry?.invariants ?? []].sort();
|
|
328
358
|
const statusRefs = Object.entries(allRefs).map(([name, entry]) => ({
|
|
@@ -362,26 +392,8 @@ async function executeMigrationStatusCommand(options, flags, ui) {
|
|
|
362
392
|
});
|
|
363
393
|
ui.stderr(header);
|
|
364
394
|
}
|
|
365
|
-
const
|
|
366
|
-
|
|
367
|
-
try {
|
|
368
|
-
contractHash = (await readContractEnvelope(config)).storageHash;
|
|
369
|
-
} catch (error) {
|
|
370
|
-
diagnostics.push({
|
|
371
|
-
code: "CONTRACT.UNREADABLE",
|
|
372
|
-
severity: "warn",
|
|
373
|
-
message: `Could not read contract: ${error instanceof Error ? error.message : "unknown error"}`,
|
|
374
|
-
hints: ["Run 'prisma-next contract emit' to generate a valid contract"]
|
|
375
|
-
});
|
|
376
|
-
}
|
|
377
|
-
let bundles;
|
|
378
|
-
let graph;
|
|
379
|
-
try {
|
|
380
|
-
({bundles, graph} = await loadMigrationPackages(appMigrationsDir));
|
|
381
|
-
} catch (error) {
|
|
382
|
-
if (MigrationToolsError.is(error)) return notOk(mapMigrationToolsError(error));
|
|
383
|
-
return notOk(errorUnexpected(error instanceof Error ? error.message : String(error), { why: `Failed to read migrations directory: ${error instanceof Error ? error.message : String(error)}` }));
|
|
384
|
-
}
|
|
395
|
+
const bundles = aggregate.app.packages;
|
|
396
|
+
const graph = appGraph;
|
|
385
397
|
if (bundles.length === 0) {
|
|
386
398
|
if (dbConnection && hasDriver) {
|
|
387
399
|
const markerProbe = await validateOnlineMarkerRead(config, dbConnection);
|
|
@@ -449,23 +461,15 @@ async function executeMigrationStatusCommand(options, flags, ui) {
|
|
|
449
461
|
mode = "offline";
|
|
450
462
|
allMarkers = null;
|
|
451
463
|
}
|
|
452
|
-
const contractRawForAggregate = await loadContractRawSafely(config);
|
|
453
464
|
let aggregateSpaces = [];
|
|
454
|
-
if (contractRawForAggregate !== null) {
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
extensionPacks: config.extensionPacks ?? [],
|
|
463
|
-
deserializeContract: (json) => familyInstance.deserializeContract(json),
|
|
464
|
-
markersBySpace: allMarkers
|
|
465
|
-
});
|
|
466
|
-
} catch {
|
|
467
|
-
aggregateSpaces = [];
|
|
468
|
-
}
|
|
465
|
+
if (contractRawForAggregate !== null) try {
|
|
466
|
+
aggregateSpaces = await loadAggregateStatusSpaces({
|
|
467
|
+
aggregate,
|
|
468
|
+
extensionPacks: config.extensionPacks ?? [],
|
|
469
|
+
markersBySpace: allMarkers
|
|
470
|
+
});
|
|
471
|
+
} catch {
|
|
472
|
+
aggregateSpaces = [];
|
|
469
473
|
}
|
|
470
474
|
const totalPendingAcrossSpaces = computeTotalPendingAcrossSpaces(aggregateSpaces);
|
|
471
475
|
if (activeRefEntry && activeRefEntry.invariants.length > 0) {
|