@prisma-next/cli 0.14.0-dev.39 → 0.14.0-dev.40
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 +8 -8
- package/dist/{client-VA66WgBx.mjs → client-CWTNqJdj.mjs} +68 -67
- package/dist/client-CWTNqJdj.mjs.map +1 -0
- package/dist/commands/contract-infer.mjs +1 -1
- package/dist/commands/db-init.mjs +2 -2
- package/dist/commands/db-schema.mjs +2 -2
- package/dist/commands/db-sign.mjs +2 -2
- package/dist/commands/db-update.mjs +2 -2
- package/dist/commands/db-verify.mjs +1 -1
- package/dist/commands/migrate.d.mts +1 -1
- package/dist/commands/migrate.d.mts.map +1 -1
- package/dist/commands/migrate.mjs +31 -31
- package/dist/commands/migrate.mjs.map +1 -1
- package/dist/commands/migration-check.d.mts +1 -1
- package/dist/commands/migration-check.mjs +1 -1
- package/dist/commands/migration-graph.d.mts +1 -1
- package/dist/commands/migration-graph.mjs +5 -5
- package/dist/commands/migration-graph.mjs.map +1 -1
- package/dist/commands/migration-list.d.mts +6 -6
- package/dist/commands/migration-list.d.mts.map +1 -1
- package/dist/commands/migration-list.mjs +1 -1
- package/dist/commands/migration-log.d.mts +1 -1
- package/dist/commands/migration-log.mjs +1 -1
- package/dist/commands/migration-plan.mjs +1 -1
- package/dist/commands/migration-show.mjs +1 -1
- package/dist/commands/migration-status.d.mts +1 -1
- package/dist/commands/migration-status.mjs +1 -1
- package/dist/commands/ref.d.mts +1 -1
- package/dist/{contract-infer-Bmq_szvX.mjs → contract-infer-B__56PGb.mjs} +2 -2
- package/dist/{contract-infer-Bmq_szvX.mjs.map → contract-infer-B__56PGb.mjs.map} +1 -1
- package/dist/{db-verify-r157atLp.mjs → db-verify-DlqHvkkA.mjs} +65 -48
- package/dist/db-verify-DlqHvkkA.mjs.map +1 -0
- package/dist/exports/control-api.d.mts +3 -3
- package/dist/exports/control-api.mjs +1 -1
- package/dist/extension-pack-inputs-1ySHqxKG.mjs.map +1 -1
- package/dist/{inspect-live-schema-DBF3Rx17.mjs → inspect-live-schema-Dd1Ft0dw.mjs} +2 -2
- package/dist/{inspect-live-schema-DBF3Rx17.mjs.map → inspect-live-schema-Dd1Ft0dw.mjs.map} +1 -1
- package/dist/{migration-check-CTcJfCC4.mjs → migration-check-UoHMvsP3.mjs} +6 -6
- package/dist/migration-check-UoHMvsP3.mjs.map +1 -0
- package/dist/{migration-command-scaffold-bxooJ8Jl.mjs → migration-command-scaffold-DW2BpjZW.mjs} +2 -2
- package/dist/{migration-command-scaffold-bxooJ8Jl.mjs.map → migration-command-scaffold-DW2BpjZW.mjs.map} +1 -1
- package/dist/{migration-list-DVHVmMrf.mjs → migration-list-BOzQzJK4.mjs} +12 -12
- package/dist/migration-list-BOzQzJK4.mjs.map +1 -0
- package/dist/{migration-log-CBYftWK1.mjs → migration-log-q50rqMiU.mjs} +2 -2
- package/dist/{migration-log-CBYftWK1.mjs.map → migration-log-q50rqMiU.mjs.map} +1 -1
- package/dist/{migration-plan-o2aqjnfd.mjs → migration-plan-BwJLPkwV.mjs} +19 -19
- package/dist/migration-plan-BwJLPkwV.mjs.map +1 -0
- package/dist/{migration-status-BLa0SheI.mjs → migration-status-27NzO2SC.mjs} +10 -10
- package/dist/migration-status-27NzO2SC.mjs.map +1 -0
- package/dist/{types-qETCCNbe.d.mts → types-CKgJmH02.d.mts} +25 -19
- package/dist/types-CKgJmH02.d.mts.map +1 -0
- package/dist/{verify-CLw3YRbl.mjs → verify-DC14_nPu.mjs} +23 -5
- package/dist/verify-DC14_nPu.mjs.map +1 -0
- package/package.json +21 -21
- package/src/commands/db-verify.ts +31 -19
- package/src/commands/migrate.ts +44 -41
- package/src/commands/migration-check.ts +5 -5
- package/src/commands/migration-graph.ts +4 -4
- package/src/commands/migration-list.ts +12 -12
- package/src/commands/migration-plan.ts +3 -3
- package/src/commands/migration-status.ts +9 -9
- package/src/control-api/operations/db-init.ts +2 -2
- package/src/control-api/operations/db-run.ts +7 -7
- package/src/control-api/operations/db-verify.ts +37 -33
- package/src/control-api/operations/migrate.ts +66 -66
- package/src/control-api/operations/run-migration.ts +2 -2
- package/src/control-api/types.ts +7 -7
- package/src/utils/combine-verify-results.ts +113 -0
- package/src/utils/extension-pack-inputs.ts +1 -1
- package/src/utils/formatters/verify.ts +36 -3
- package/src/utils/plan-resolution.ts +18 -18
- package/dist/client-VA66WgBx.mjs.map +0 -1
- package/dist/db-verify-r157atLp.mjs.map +0 -1
- package/dist/migration-check-CTcJfCC4.mjs.map +0 -1
- package/dist/migration-list-DVHVmMrf.mjs.map +0 -1
- package/dist/migration-plan-o2aqjnfd.mjs.map +0 -1
- package/dist/migration-status-BLa0SheI.mjs.map +0 -1
- package/dist/types-qETCCNbe.d.mts.map +0 -1
- package/dist/verify-CLw3YRbl.mjs.map +0 -1
- package/src/utils/combine-schema-results.ts +0 -87
package/dist/cli.mjs
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { D as isCI, O as formatCommandHelp, g as parseGlobalFlagsOrExit, h as parseGlobalFlags, k as formatRootHelp, l as setCommandDescriptions, m as deriveCanPrompt, t as addGlobalOptions, u as setCommandExamples, v as installShutdownHandlers } from "./command-helpers-6cNJZ863.mjs";
|
|
3
3
|
import { t as createContractEmitCommand } from "./contract-emit-klH7zzaV.mjs";
|
|
4
|
-
import { t as createContractInferCommand } from "./contract-infer-
|
|
4
|
+
import { t as createContractInferCommand } from "./contract-infer-B__56PGb.mjs";
|
|
5
5
|
import { createDbInitCommand } from "./commands/db-init.mjs";
|
|
6
6
|
import { createDbSchemaCommand } from "./commands/db-schema.mjs";
|
|
7
7
|
import { createDbSignCommand } from "./commands/db-sign.mjs";
|
|
8
8
|
import { createDbUpdateCommand } from "./commands/db-update.mjs";
|
|
9
|
-
import { t as createDbVerifyCommand } from "./db-verify-
|
|
9
|
+
import { t as createDbVerifyCommand } from "./db-verify-DlqHvkkA.mjs";
|
|
10
10
|
import { t as createFormatCommand } from "./format-C3XdaDuA.mjs";
|
|
11
|
-
import { t as createMigrationListCommand } from "./migration-list-
|
|
11
|
+
import { t as createMigrationListCommand } from "./migration-list-BOzQzJK4.mjs";
|
|
12
12
|
import { createMigrateCommand } from "./commands/migrate.mjs";
|
|
13
|
-
import { t as createMigrationCheckCommand } from "./migration-check-
|
|
13
|
+
import { t as createMigrationCheckCommand } from "./migration-check-UoHMvsP3.mjs";
|
|
14
14
|
import { createMigrationGraphCommand } from "./commands/migration-graph.mjs";
|
|
15
|
-
import { t as createMigrationLogCommand } from "./migration-log-
|
|
15
|
+
import { t as createMigrationLogCommand } from "./migration-log-q50rqMiU.mjs";
|
|
16
16
|
import { createMigrationNewCommand } from "./commands/migration-new.mjs";
|
|
17
|
-
import { t as createMigrationPlanCommand } from "./migration-plan-
|
|
17
|
+
import { t as createMigrationPlanCommand } from "./migration-plan-BwJLPkwV.mjs";
|
|
18
18
|
import { createMigrationShowCommand } from "./commands/migration-show.mjs";
|
|
19
|
-
import { r as createMigrationStatusCommand } from "./migration-status-
|
|
19
|
+
import { r as createMigrationStatusCommand } from "./migration-status-27NzO2SC.mjs";
|
|
20
20
|
import { createRefCommand } from "./commands/ref.mjs";
|
|
21
21
|
import { t as createTelemetryCommand } from "./telemetry-BckOSUWG.mjs";
|
|
22
22
|
import { Command } from "commander";
|
|
@@ -25,7 +25,7 @@ import { ensureInstallationId, readUserConfig, resolveGating, runTelemetry, user
|
|
|
25
25
|
import { distance } from "closest-match";
|
|
26
26
|
import { fileURLToPath } from "node:url";
|
|
27
27
|
//#region package.json
|
|
28
|
-
var version = "0.14.0-dev.
|
|
28
|
+
var version = "0.14.0-dev.40";
|
|
29
29
|
//#endregion
|
|
30
30
|
//#region src/commands/init/templates/code-templates.ts
|
|
31
31
|
function targetPackageName(target) {
|
|
@@ -144,7 +144,7 @@ function buildPerSpaceBreakdown(orderedResolutions, appSpaceId, options) {
|
|
|
144
144
|
}
|
|
145
145
|
/**
|
|
146
146
|
* Materialise the `applyOrder` ordering into resolved per-space
|
|
147
|
-
* entries. Throws if the planner output is missing a
|
|
147
|
+
* entries. Throws if the planner output is missing a contract space listed
|
|
148
148
|
* in `applyOrder` — a wiring bug that should never reach runtime.
|
|
149
149
|
*
|
|
150
150
|
* Exported so callers building their own success envelopes after a
|
|
@@ -197,9 +197,9 @@ const SPAN_IDS$1 = {
|
|
|
197
197
|
* 2. **Read DB state**: marker rows (`familyInstance.readAllMarkers`)
|
|
198
198
|
* + introspected schema (`familyInstance.introspect`).
|
|
199
199
|
* 3. **Plan**: {@link planMigration} chooses graph-walk vs synth per
|
|
200
|
-
*
|
|
200
|
+
* space according to `callerPolicy.ignoreGraphFor`. The app space
|
|
201
201
|
* is forced through synth (today's daily-driver behaviour); every
|
|
202
|
-
* extension
|
|
202
|
+
* extension space walks its on-disk graph.
|
|
203
203
|
* 4. **Apply** (when `mode === 'apply'`): every per-space `MigrationPlan`
|
|
204
204
|
* feeds into the runner's `execute` — one outer
|
|
205
205
|
* transaction across every space; failure on any space rolls back
|
|
@@ -273,7 +273,7 @@ async function executeRun(options) {
|
|
|
273
273
|
const orderedResolutions = collectOrdered(planResult.value.applyOrder, planResult.value.perSpace);
|
|
274
274
|
const plannerWarnings = aggregatePlannerWarnings(orderedResolutions);
|
|
275
275
|
const appResolution = orderedResolutions.find((r) => r.spaceId === aggregate.app.spaceId);
|
|
276
|
-
if (!appResolution) throw new Error("Aggregate planner returned no plan for the app
|
|
276
|
+
if (!appResolution) throw new Error("Aggregate planner returned no plan for the app space — the planner is supposed to always emit one.");
|
|
277
277
|
const appPlan = appResolution.entry.plan;
|
|
278
278
|
if (mode === "plan") {
|
|
279
279
|
const aggregateOps = orderedResolutions.flatMap((r) => r.entry.displayOps);
|
|
@@ -325,22 +325,22 @@ function aggregatePlannerWarnings(orderedResolutions) {
|
|
|
325
325
|
}
|
|
326
326
|
/**
|
|
327
327
|
* Compare the live `_prisma_marker` rows against the aggregate's
|
|
328
|
-
* declared
|
|
328
|
+
* declared contract spaces. Any marker row whose `space` is not a space of
|
|
329
329
|
* the aggregate is an "orphan" — typically a marker left behind by
|
|
330
330
|
* an extension that was removed from `extensionPacks` without first
|
|
331
331
|
* cleaning up its on-disk migrations / database tables.
|
|
332
332
|
*
|
|
333
333
|
* Returns a {@link CliStructuredError} envelope (code `5002`,
|
|
334
334
|
* `kind: 'orphanMarker'`) for the first orphan it finds, or `null`
|
|
335
|
-
* when every marker row maps to a declared
|
|
335
|
+
* when every marker row maps to a declared contract space. Mirrors the M2
|
|
336
336
|
* `runContractSpaceVerifierMarkerCheck` envelope so downstream
|
|
337
337
|
* tooling (integration tests, JSON consumers) keeps asserting on the
|
|
338
338
|
* same shape.
|
|
339
339
|
*/
|
|
340
340
|
function detectOrphanMarkers(aggregate, markerRows) {
|
|
341
|
-
const
|
|
341
|
+
const aggregateSpaceIds = new Set([aggregate.app.spaceId, ...aggregate.extensions.map((m) => m.spaceId)]);
|
|
342
342
|
const orphans = [];
|
|
343
|
-
for (const [spaceId, row] of markerRows) if (row !== null && row !== void 0 && !
|
|
343
|
+
for (const [spaceId, row] of markerRows) if (row !== null && row !== void 0 && !aggregateSpaceIds.has(spaceId)) orphans.push(spaceId);
|
|
344
344
|
if (orphans.length === 0) return null;
|
|
345
345
|
orphans.sort((a, b) => a.localeCompare(b));
|
|
346
346
|
return new CliStructuredError("5002", orphans.length === 1 ? `Orphan contract-space marker detected for "${orphans[0]}"` : `Orphan contract-space markers detected for ${orphans.length} spaces`, {
|
|
@@ -544,11 +544,11 @@ const SPAN_IDS = {
|
|
|
544
544
|
* structured CLI error.
|
|
545
545
|
* 2. **Read DB state**: marker rows + (when `skipSchema` is `false`)
|
|
546
546
|
* schema introspection.
|
|
547
|
-
* 3. **Verify**: {@link verifyMigration} returns per-space
|
|
548
|
-
*
|
|
549
|
-
*
|
|
550
|
-
* callers (CLI command) can render
|
|
551
|
-
* returned to the caller verbatim.
|
|
547
|
+
* 3. **Verify**: {@link verifyMigration} returns per-space `markerCheck` +
|
|
548
|
+
* per-space `schemaCheck` (each contract space verified against the full schema,
|
|
549
|
+
* then scoped to its own contract space). Marker mismatches map to
|
|
550
|
+
* `CliStructuredError` (code `5002`) so callers (CLI command) can render
|
|
551
|
+
* and exit. Verify results are returned to the caller verbatim.
|
|
552
552
|
*/
|
|
553
553
|
async function executeDbVerify(options) {
|
|
554
554
|
const { driver, familyInstance, onProgress, skipSchema, skipMarker } = options;
|
|
@@ -569,7 +569,7 @@ async function executeDbVerify(options) {
|
|
|
569
569
|
markersBySpaceId,
|
|
570
570
|
schemaIntrospection,
|
|
571
571
|
mode: options.mode,
|
|
572
|
-
|
|
572
|
+
verifySchemaForSpace: createPerSpaceVerifier(options)
|
|
573
573
|
}),
|
|
574
574
|
aggregate,
|
|
575
575
|
skipMarker,
|
|
@@ -616,18 +616,18 @@ async function runIntrospection(args) {
|
|
|
616
616
|
}
|
|
617
617
|
}
|
|
618
618
|
/**
|
|
619
|
-
* Build the per-
|
|
619
|
+
* Build the per-space schema callback handed to the aggregate verifier.
|
|
620
620
|
* When `skipSchema` is true the callback short-circuits with a synthetic
|
|
621
621
|
* `ok` result so the verifier still runs the (cheap) schemaCheck loop
|
|
622
622
|
* without invoking the family's verification path.
|
|
623
623
|
*/
|
|
624
|
-
function
|
|
624
|
+
function createPerSpaceVerifier(options) {
|
|
625
625
|
const { skipSchema, familyInstance, frameworkComponents } = options;
|
|
626
|
-
return (
|
|
627
|
-
if (skipSchema) return buildSkippedSchemaResult(
|
|
626
|
+
return (schema, space, verifyMode) => {
|
|
627
|
+
if (skipSchema) return buildSkippedSchemaResult(space);
|
|
628
628
|
return familyInstance.verifySchema({
|
|
629
|
-
contract:
|
|
630
|
-
schema
|
|
629
|
+
contract: space.contract(),
|
|
630
|
+
schema,
|
|
631
631
|
strict: verifyMode === "strict",
|
|
632
632
|
frameworkComponents
|
|
633
633
|
});
|
|
@@ -674,13 +674,14 @@ function finaliseVerifyResult(args) {
|
|
|
674
674
|
emitVerifySpan(onProgress, "spanEndOk");
|
|
675
675
|
return ok({
|
|
676
676
|
schemaResults: verifyResult.value.schemaCheck.perSpace,
|
|
677
|
-
|
|
677
|
+
unclaimed: verifyResult.value.schemaCheck.unclaimed,
|
|
678
|
+
spaceOrder: [aggregate.app.spaceId, ...aggregate.extensions.map((e) => e.spaceId)],
|
|
678
679
|
appSpaceId: aggregate.app.spaceId
|
|
679
680
|
});
|
|
680
681
|
}
|
|
681
|
-
function buildSkippedSchemaResult(
|
|
682
|
-
const contract =
|
|
683
|
-
const headRef = requireHeadRef(
|
|
682
|
+
function buildSkippedSchemaResult(space) {
|
|
683
|
+
const contract = space.contract();
|
|
684
|
+
const headRef = requireHeadRef(space);
|
|
684
685
|
const profileHash = castAs(contract).profileHash;
|
|
685
686
|
return {
|
|
686
687
|
ok: true,
|
|
@@ -696,7 +697,7 @@ function buildSkippedSchemaResult(member) {
|
|
|
696
697
|
root: {
|
|
697
698
|
status: "pass",
|
|
698
699
|
kind: "skipped",
|
|
699
|
-
name:
|
|
700
|
+
name: space.spaceId,
|
|
700
701
|
contractPath: "",
|
|
701
702
|
code: "SKIPPED",
|
|
702
703
|
message: "Schema verification skipped",
|
|
@@ -757,16 +758,16 @@ function mapMarkerCheckFailures(appSpaceId, section) {
|
|
|
757
758
|
/**
|
|
758
759
|
* Apply pending migrations across every contract space (app +
|
|
759
760
|
* extensions). Replay-only: graph-walk against the on-disk graph for
|
|
760
|
-
* every
|
|
761
|
+
* every contract space; no synth, no introspection.
|
|
761
762
|
*
|
|
762
763
|
* Pipeline:
|
|
763
764
|
*
|
|
764
765
|
* 1. Load aggregate from disk (loader hydrates extension graphs;
|
|
765
766
|
* caller provides app-space packages).
|
|
766
767
|
* 2. Read live marker rows per space (`familyInstance.readAllMarkers`).
|
|
767
|
-
* 3. Per
|
|
768
|
-
* marker to `
|
|
769
|
-
*
|
|
768
|
+
* 3. Per space: `graphWalkStrategy` plots the path from the live
|
|
769
|
+
* marker to `space.headRef.hash` (or `refHash` for the app
|
|
770
|
+
* space when provided). Empty-graph spaces fail loudly — a
|
|
770
771
|
* "never planned" space is a user-error condition for replay.
|
|
771
772
|
* 4. Hand off to {@link runMigration} (the runner-driving tail
|
|
772
773
|
* shared with `db init` / `db update`). Marker advancement is
|
|
@@ -787,29 +788,29 @@ async function executeMigrate(options) {
|
|
|
787
788
|
if (!loaded.ok) throw loaded.failure;
|
|
788
789
|
const aggregate = loaded.value;
|
|
789
790
|
const markerRows = await familyInstance.readAllMarkers({ driver });
|
|
790
|
-
const
|
|
791
|
+
const allSpaces = [aggregate.app, ...aggregate.extensions];
|
|
791
792
|
const perSpacePlans = /* @__PURE__ */ new Map();
|
|
792
793
|
const atHeadResolutions = /* @__PURE__ */ new Map();
|
|
793
|
-
for (const
|
|
794
|
-
const
|
|
795
|
-
const headRef = requireHeadRef(
|
|
796
|
-
const
|
|
797
|
-
const outcome =
|
|
798
|
-
|
|
794
|
+
for (const space of allSpaces) {
|
|
795
|
+
const isAppSpace = space.spaceId === aggregate.app.spaceId;
|
|
796
|
+
const headRef = requireHeadRef(space);
|
|
797
|
+
const spaceTargetHash = isAppSpace && refHash !== void 0 ? refHash : headRef.hash;
|
|
798
|
+
const outcome = planSpacePath({
|
|
799
|
+
space,
|
|
799
800
|
aggregate,
|
|
800
|
-
targetHash:
|
|
801
|
-
refInvariants:
|
|
802
|
-
liveMarker: markerRows.get(
|
|
803
|
-
...
|
|
801
|
+
targetHash: spaceTargetHash,
|
|
802
|
+
refInvariants: isAppSpace && refHash !== void 0 ? refInvariants : void 0,
|
|
803
|
+
liveMarker: markerRows.get(space.spaceId) ?? null,
|
|
804
|
+
...isAppSpace ? { refName } : {}
|
|
804
805
|
});
|
|
805
806
|
if (outcome.kind === "at-head") {
|
|
806
|
-
atHeadResolutions.set(
|
|
807
|
+
atHeadResolutions.set(space.spaceId, outcome.plan);
|
|
807
808
|
continue;
|
|
808
809
|
}
|
|
809
810
|
if (outcome.kind === "never-planned") return notOk(buildNeverPlannedFailure(outcome.spaceId, outcome.targetHash));
|
|
810
811
|
if (outcome.kind === "unreachable") return notOk(buildPathNotFoundFailure(outcome.spaceId, outcome.liveMarker, outcome.targetHash));
|
|
811
812
|
if (outcome.kind === "unsatisfiable") {
|
|
812
|
-
const structural = findPathWithDecision(outcome.
|
|
813
|
+
const structural = findPathWithDecision(outcome.targetSpace.graph(), outcome.liveHash, spaceTargetHash, { required: /* @__PURE__ */ new Set() });
|
|
813
814
|
const structuralPath = structural.kind === "ok" ? structural.decision.selectedPath.map((edge) => ({
|
|
814
815
|
dirName: edge.dirName,
|
|
815
816
|
migrationHash: edge.migrationHash,
|
|
@@ -824,7 +825,7 @@ async function executeMigrate(options) {
|
|
|
824
825
|
structuralPath
|
|
825
826
|
});
|
|
826
827
|
}
|
|
827
|
-
perSpacePlans.set(
|
|
828
|
+
perSpacePlans.set(space.spaceId, outcome.plan);
|
|
828
829
|
}
|
|
829
830
|
const canonicalOrder = [...aggregate.extensions.map((m) => m.spaceId), aggregate.app.spaceId];
|
|
830
831
|
const applyOrder = canonicalOrder.filter((spaceId) => perSpacePlans.has(spaceId));
|
|
@@ -893,7 +894,7 @@ async function executeMigrate(options) {
|
|
|
893
894
|
}));
|
|
894
895
|
}
|
|
895
896
|
/**
|
|
896
|
-
* Compute the graph-walk path for one contract
|
|
897
|
+
* Compute the graph-walk path for one contract space.
|
|
897
898
|
*
|
|
898
899
|
* Encapsulates the invariant-correct input assembly that both
|
|
899
900
|
* `executeMigrate` and `executeMigrateShowCommand` must use:
|
|
@@ -902,34 +903,34 @@ async function executeMigrate(options) {
|
|
|
902
903
|
* - `targetInvariants` uses the caller-supplied `refInvariants` when a
|
|
903
904
|
* `--to` ref was resolved (not always the file head ref's invariants).
|
|
904
905
|
*
|
|
905
|
-
* Both callers map the returned `
|
|
906
|
+
* Both callers map the returned `SpacePathOutcome` to their own error
|
|
906
907
|
* representation; the path-compute logic is shared and identical.
|
|
907
908
|
*
|
|
908
909
|
* @internal Exported for `executeMigrateShowCommand`.
|
|
909
910
|
*/
|
|
910
|
-
function
|
|
911
|
-
const
|
|
912
|
-
const headRef = requireHeadRef(
|
|
913
|
-
if (
|
|
911
|
+
function planSpacePath({ space, aggregate, targetHash, refInvariants, liveMarker, refName }) {
|
|
912
|
+
const isAppSpace = space.spaceId === aggregate.app.spaceId;
|
|
913
|
+
const headRef = requireHeadRef(space);
|
|
914
|
+
if (space.graph().nodes.size === 0) {
|
|
914
915
|
const liveHash = liveMarker?.storageHash;
|
|
915
916
|
if (targetHash === liveHash || liveHash === void 0 && targetHash === EMPTY_CONTRACT_HASH) return {
|
|
916
917
|
kind: "at-head",
|
|
917
918
|
plan: buildAtHeadResolution({
|
|
918
919
|
aggregateTargetId: aggregate.targetId,
|
|
919
|
-
|
|
920
|
+
space,
|
|
920
921
|
targetHash,
|
|
921
922
|
liveMarker
|
|
922
923
|
})
|
|
923
924
|
};
|
|
924
925
|
return {
|
|
925
926
|
kind: "never-planned",
|
|
926
|
-
spaceId:
|
|
927
|
+
spaceId: space.spaceId,
|
|
927
928
|
targetHash
|
|
928
929
|
};
|
|
929
930
|
}
|
|
930
|
-
const targetInvariants =
|
|
931
|
-
const
|
|
932
|
-
...
|
|
931
|
+
const targetInvariants = isAppSpace && refInvariants !== void 0 ? refInvariants : headRef.invariants;
|
|
932
|
+
const targetSpace = targetHash === headRef.hash && targetInvariants === headRef.invariants ? space : {
|
|
933
|
+
...space,
|
|
933
934
|
headRef: {
|
|
934
935
|
hash: targetHash,
|
|
935
936
|
invariants: targetInvariants
|
|
@@ -937,13 +938,13 @@ function planMemberPath({ member, aggregate, targetHash, refInvariants, liveMark
|
|
|
937
938
|
};
|
|
938
939
|
const walked = graphWalkStrategy({
|
|
939
940
|
aggregateTargetId: aggregate.targetId,
|
|
940
|
-
|
|
941
|
+
space: targetSpace,
|
|
941
942
|
currentMarker: liveMarker,
|
|
942
|
-
...
|
|
943
|
+
...isAppSpace && refName !== void 0 ? { refName } : {}
|
|
943
944
|
});
|
|
944
945
|
if (walked.kind === "unreachable") return {
|
|
945
946
|
kind: "unreachable",
|
|
946
|
-
spaceId:
|
|
947
|
+
spaceId: space.spaceId,
|
|
947
948
|
liveMarker,
|
|
948
949
|
targetHash
|
|
949
950
|
};
|
|
@@ -951,11 +952,11 @@ function planMemberPath({ member, aggregate, targetHash, refInvariants, liveMark
|
|
|
951
952
|
const liveHash = liveMarker?.storageHash ?? EMPTY_CONTRACT_HASH;
|
|
952
953
|
return {
|
|
953
954
|
kind: "unsatisfiable",
|
|
954
|
-
spaceId:
|
|
955
|
-
|
|
955
|
+
spaceId: space.spaceId,
|
|
956
|
+
isAppSpace,
|
|
956
957
|
missing: walked.missing,
|
|
957
958
|
targetInvariants,
|
|
958
|
-
|
|
959
|
+
targetSpace,
|
|
959
960
|
liveHash,
|
|
960
961
|
refName
|
|
961
962
|
};
|
|
@@ -967,24 +968,24 @@ function planMemberPath({ member, aggregate, targetHash, refInvariants, liveMark
|
|
|
967
968
|
}
|
|
968
969
|
/**
|
|
969
970
|
* Build a zero-op {@link PerSpacePlan} for an empty-graph
|
|
970
|
-
*
|
|
971
|
-
* pipeline thread the
|
|
971
|
+
* space whose live marker already matches the target. Lets the apply
|
|
972
|
+
* pipeline thread the space through `perSpacePlans` -> `applyOrder`
|
|
972
973
|
* -> the success envelope's `perSpace[]` block so the result reflects
|
|
973
974
|
* every loaded space, even when there is nothing to execute.
|
|
974
975
|
*/
|
|
975
976
|
function buildAtHeadResolution(args) {
|
|
976
|
-
const { aggregateTargetId,
|
|
977
|
+
const { aggregateTargetId, space, targetHash, liveMarker } = args;
|
|
977
978
|
return {
|
|
978
979
|
plan: {
|
|
979
980
|
targetId: aggregateTargetId,
|
|
980
|
-
spaceId:
|
|
981
|
+
spaceId: space.spaceId,
|
|
981
982
|
origin: liveMarker === null ? null : { storageHash: liveMarker.storageHash },
|
|
982
983
|
destination: { storageHash: targetHash },
|
|
983
984
|
operations: [],
|
|
984
985
|
providedInvariants: []
|
|
985
986
|
},
|
|
986
987
|
displayOps: [],
|
|
987
|
-
destinationContract:
|
|
988
|
+
destinationContract: space.contract(),
|
|
988
989
|
strategy: "graph-walk",
|
|
989
990
|
migrationEdges: [buildSynthMigrationEdge({
|
|
990
991
|
currentMarkerStorageHash: liveMarker?.storageHash,
|
|
@@ -1609,6 +1610,6 @@ var ControlClientImpl = class {
|
|
|
1609
1610
|
}
|
|
1610
1611
|
};
|
|
1611
1612
|
//#endregion
|
|
1612
|
-
export { executeDbInit as a, executeDbUpdate as i,
|
|
1613
|
+
export { executeDbInit as a, executeDbUpdate as i, planSpacePath as n, ContractValidationError as o, executeDbVerify as r, createControlClient as t };
|
|
1613
1614
|
|
|
1614
|
-
//# sourceMappingURL=client-
|
|
1615
|
+
//# sourceMappingURL=client-CWTNqJdj.mjs.map
|