@prisma-next/cli 0.14.0-dev.5 → 0.14.0-dev.50
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 +14 -14
- package/dist/cli.mjs.map +1 -1
- package/dist/{client-EnAjSmZg.mjs → client-DL6KE_c0.mjs} +88 -99
- package/dist/client-DL6KE_c0.mjs.map +1 -0
- package/dist/{command-helpers-6cNJZ863.mjs → command-helpers-DMG0RsR1.mjs} +3 -3
- package/dist/command-helpers-DMG0RsR1.mjs.map +1 -0
- package/dist/commands/contract-emit.mjs +1 -1
- package/dist/commands/contract-infer.mjs +1 -1
- package/dist/commands/db-init.mjs +3 -3
- package/dist/commands/db-schema.mjs +3 -3
- package/dist/commands/db-sign.mjs +4 -4
- package/dist/commands/db-update.mjs +4 -4
- 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 +35 -35
- 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 +7 -7
- 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-new.mjs +3 -3
- package/dist/commands/migration-plan.d.mts.map +1 -1
- package/dist/commands/migration-plan.mjs +1 -1
- package/dist/commands/migration-show.mjs +3 -3
- 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/commands/ref.mjs +2 -2
- package/dist/commands/telemetry/index.mjs +1 -1
- package/dist/{contract-at-errors-DdxWRjMc.mjs → contract-at-errors-bF4CGDl0.mjs} +2 -2
- package/dist/{contract-at-errors-DdxWRjMc.mjs.map → contract-at-errors-bF4CGDl0.mjs.map} +1 -1
- package/dist/{contract-emit-fz6pDR2n.mjs → contract-emit-BM7oxYIG.mjs} +7 -5
- package/dist/{contract-emit-fz6pDR2n.mjs.map → contract-emit-BM7oxYIG.mjs.map} +1 -1
- package/dist/{contract-emit-D4xDDFkO.mjs → contract-emit-DnCG2JaQ.mjs} +3 -3
- package/dist/{contract-emit-D4xDDFkO.mjs.map → contract-emit-DnCG2JaQ.mjs.map} +1 -1
- package/dist/{contract-infer-Ars4yjBv.mjs → contract-infer-Dq9XNQCx.mjs} +3 -3
- package/dist/{contract-infer-Ars4yjBv.mjs.map → contract-infer-Dq9XNQCx.mjs.map} +1 -1
- package/dist/{contract-space-aggregate-loader-Bu2fjSWV.mjs → contract-space-aggregate-loader-DAa8u6bi.mjs} +2 -2
- package/dist/{contract-space-aggregate-loader-Bu2fjSWV.mjs.map → contract-space-aggregate-loader-DAa8u6bi.mjs.map} +1 -1
- package/dist/{db-verify-CZxRV_er.mjs → db-verify-BpfJvC8O.mjs} +56 -60
- package/dist/db-verify-BpfJvC8O.mjs.map +1 -0
- package/dist/exports/control-api.d.mts +3 -3
- package/dist/exports/control-api.mjs +2 -2
- package/dist/exports/index.mjs +2 -2
- package/dist/extension-pack-inputs-1ySHqxKG.mjs.map +1 -1
- package/dist/{format-C3XdaDuA.mjs → format-DrUSkdqR.mjs} +2 -2
- package/dist/{format-C3XdaDuA.mjs.map → format-DrUSkdqR.mjs.map} +1 -1
- package/dist/{framework-components-5RljWT7Q.mjs → framework-components-BdmVlRSS.mjs} +2 -2
- package/dist/{framework-components-5RljWT7Q.mjs.map → framework-components-BdmVlRSS.mjs.map} +1 -1
- package/dist/{init-C79Yb97u.mjs → init-C0YyVoGj.mjs} +3 -3
- package/dist/{init-C79Yb97u.mjs.map → init-C0YyVoGj.mjs.map} +1 -1
- package/dist/{inspect-live-schema-DR8Eyt29.mjs → inspect-live-schema-Bs_0M6z8.mjs} +3 -3
- package/dist/{inspect-live-schema-DR8Eyt29.mjs.map → inspect-live-schema-Bs_0M6z8.mjs.map} +1 -1
- package/dist/{migration-check-CTcJfCC4.mjs → migration-check-DYxrNfK-.mjs} +9 -9
- package/dist/migration-check-DYxrNfK-.mjs.map +1 -0
- package/dist/{migration-command-scaffold-6OT_Q-3Y.mjs → migration-command-scaffold-DB5DQLvF.mjs} +3 -3
- package/dist/{migration-command-scaffold-6OT_Q-3Y.mjs.map → migration-command-scaffold-DB5DQLvF.mjs.map} +1 -1
- package/dist/{migration-list-DVHVmMrf.mjs → migration-list-BX5w9HAn.mjs} +14 -14
- package/dist/migration-list-BX5w9HAn.mjs.map +1 -0
- package/dist/{migration-log-CQpc9JoL.mjs → migration-log-CB1KzVOG.mjs} +3 -3
- package/dist/{migration-log-CQpc9JoL.mjs.map → migration-log-CB1KzVOG.mjs.map} +1 -1
- package/dist/{migration-path-target-zK6RG6JY.mjs → migration-path-target-CEFRK2Q7.mjs} +2 -2
- package/dist/{migration-path-target-zK6RG6JY.mjs.map → migration-path-target-CEFRK2Q7.mjs.map} +1 -1
- package/dist/{migration-plan-o2aqjnfd.mjs → migration-plan-DMKl_HnV.mjs} +29 -28
- package/dist/migration-plan-DMKl_HnV.mjs.map +1 -0
- package/dist/{migration-status-2aXGtYMW.mjs → migration-status-BeNAmEju.mjs} +12 -12
- package/dist/migration-status-BeNAmEju.mjs.map +1 -0
- package/dist/{telemetry-BckOSUWG.mjs → telemetry-_19qtfXp.mjs} +2 -2
- package/dist/{telemetry-BckOSUWG.mjs.map → telemetry-_19qtfXp.mjs.map} +1 -1
- package/dist/{types-qETCCNbe.d.mts → types-DFoqNIcQ.d.mts} +26 -20
- package/dist/types-DFoqNIcQ.d.mts.map +1 -0
- package/dist/{verify-DLqhL2LU.mjs → verify-Djo-Jep_.mjs} +57 -159
- package/dist/verify-Djo-Jep_.mjs.map +1 -0
- package/package.json +21 -21
- package/src/commands/db-verify.ts +31 -19
- package/src/commands/lsp.ts +3 -1
- package/src/commands/migrate.ts +46 -43
- 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 +14 -3
- package/src/commands/migration-status.ts +9 -9
- package/src/control-api/client.ts +5 -3
- package/src/control-api/operations/contract-emit.ts +7 -6
- package/src/control-api/operations/db-init.ts +2 -2
- package/src/control-api/operations/db-run.ts +18 -17
- package/src/control-api/operations/db-verify.ts +52 -44
- package/src/control-api/operations/migrate.ts +72 -72
- package/src/control-api/operations/run-migration.ts +6 -5
- package/src/control-api/types.ts +8 -8
- package/src/utils/combine-verify-results.ts +94 -0
- package/src/utils/extension-pack-inputs.ts +1 -1
- package/src/utils/formatters/errors.ts +12 -4
- package/src/utils/formatters/verify.ts +88 -227
- package/src/utils/plan-resolution.ts +18 -18
- package/dist/client-EnAjSmZg.mjs.map +0 -1
- package/dist/command-helpers-6cNJZ863.mjs.map +0 -1
- package/dist/db-verify-CZxRV_er.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-2aXGtYMW.mjs.map +0 -1
- package/dist/types-qETCCNbe.d.mts.map +0 -1
- package/dist/verify-DLqhL2LU.mjs.map +0 -1
- package/src/utils/combine-schema-results.ts +0 -84
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { F as CliStructuredError } from "./command-helpers-
|
|
1
|
+
import { F as CliStructuredError } from "./command-helpers-DMG0RsR1.mjs";
|
|
2
2
|
import { n as toExtensionInputs } from "./extension-pack-inputs-1ySHqxKG.mjs";
|
|
3
|
-
import { t as assertFrameworkComponentsCompatible } from "./framework-components-
|
|
3
|
+
import { t as assertFrameworkComponentsCompatible } from "./framework-components-BdmVlRSS.mjs";
|
|
4
4
|
import { t as enrichContract } from "./contract-enrichment-gn9sWbPw.mjs";
|
|
5
|
-
import { t as buildContractSpaceAggregate } from "./contract-space-aggregate-loader-
|
|
5
|
+
import { t as buildContractSpaceAggregate } from "./contract-space-aggregate-loader-DAa8u6bi.mjs";
|
|
6
6
|
import { emit } from "@prisma-next/emitter";
|
|
7
7
|
import { ifDefined } from "@prisma-next/utils/defined";
|
|
8
8
|
import { notOk, ok } from "@prisma-next/utils/result";
|
|
9
|
-
import { APP_SPACE_ID, createControlStack, hasMigrations, hasOperationPreview, hasPslContractInfer, hasSchemaView } from "@prisma-next/framework-components/control";
|
|
9
|
+
import { APP_SPACE_ID, createControlStack, hasMigrations, hasOperationPreview, hasPslContractInfer, hasSchemaSubjectClassifier, hasSchemaView } from "@prisma-next/framework-components/control";
|
|
10
10
|
import { blindCast, castAs } from "@prisma-next/utils/casts";
|
|
11
|
-
import {
|
|
11
|
+
import { buildFabricatedMigrationEdge, collectAggregateNamespaces, planMigration, requireHeadRef, resolveRecordedPath, verifyMigration } from "@prisma-next/migration-tools/aggregate";
|
|
12
12
|
import { EMPTY_CONTRACT_HASH } from "@prisma-next/migration-tools/constants";
|
|
13
13
|
import { errorNoInvariantPath } from "@prisma-next/migration-tools/errors";
|
|
14
14
|
import { findPathWithDecision } from "@prisma-next/migration-tools/migration-graph";
|
|
@@ -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
|
|
@@ -196,10 +196,11 @@ const SPAN_IDS$1 = {
|
|
|
196
196
|
* integrity violation short-circuits with a structured error.
|
|
197
197
|
* 2. **Read DB state**: marker rows (`familyInstance.readAllMarkers`)
|
|
198
198
|
* + introspected schema (`familyInstance.introspect`).
|
|
199
|
-
* 3. **Plan**: {@link planMigration} chooses
|
|
200
|
-
*
|
|
201
|
-
* is forced through
|
|
202
|
-
* extension
|
|
199
|
+
* 3. **Plan**: {@link planMigration} chooses `resolveRecordedPath` vs
|
|
200
|
+
* `planFromDiff` per space according to `callerPolicy.ignoreGraphFor`.
|
|
201
|
+
* The app space is forced through `planFromDiff` (today's daily-driver
|
|
202
|
+
* behaviour); every extension space walks its on-disk graph via
|
|
203
|
+
* `resolveRecordedPath`.
|
|
203
204
|
* 4. **Apply** (when `mode === 'apply'`): every per-space `MigrationPlan`
|
|
204
205
|
* feeds into the runner's `execute` — one outer
|
|
205
206
|
* transaction across every space; failure on any space rolls back
|
|
@@ -273,7 +274,7 @@ async function executeRun(options) {
|
|
|
273
274
|
const orderedResolutions = collectOrdered(planResult.value.applyOrder, planResult.value.perSpace);
|
|
274
275
|
const plannerWarnings = aggregatePlannerWarnings(orderedResolutions);
|
|
275
276
|
const appResolution = orderedResolutions.find((r) => r.spaceId === aggregate.app.spaceId);
|
|
276
|
-
if (!appResolution) throw new Error("Aggregate planner returned no plan for the app
|
|
277
|
+
if (!appResolution) throw new Error("Aggregate planner returned no plan for the app space — the planner is supposed to always emit one.");
|
|
277
278
|
const appPlan = appResolution.entry.plan;
|
|
278
279
|
if (mode === "plan") {
|
|
279
280
|
const aggregateOps = orderedResolutions.flatMap((r) => r.entry.displayOps);
|
|
@@ -325,22 +326,22 @@ function aggregatePlannerWarnings(orderedResolutions) {
|
|
|
325
326
|
}
|
|
326
327
|
/**
|
|
327
328
|
* Compare the live `_prisma_marker` rows against the aggregate's
|
|
328
|
-
* declared
|
|
329
|
+
* declared contract spaces. Any marker row whose `space` is not a space of
|
|
329
330
|
* the aggregate is an "orphan" — typically a marker left behind by
|
|
330
331
|
* an extension that was removed from `extensionPacks` without first
|
|
331
332
|
* cleaning up its on-disk migrations / database tables.
|
|
332
333
|
*
|
|
333
334
|
* Returns a {@link CliStructuredError} envelope (code `5002`,
|
|
334
335
|
* `kind: 'orphanMarker'`) for the first orphan it finds, or `null`
|
|
335
|
-
* when every marker row maps to a declared
|
|
336
|
+
* when every marker row maps to a declared contract space. Mirrors the M2
|
|
336
337
|
* `runContractSpaceVerifierMarkerCheck` envelope so downstream
|
|
337
338
|
* tooling (integration tests, JSON consumers) keeps asserting on the
|
|
338
339
|
* same shape.
|
|
339
340
|
*/
|
|
340
341
|
function detectOrphanMarkers(aggregate, markerRows) {
|
|
341
|
-
const
|
|
342
|
+
const aggregateSpaceIds = new Set([aggregate.app.spaceId, ...aggregate.extensions.map((m) => m.spaceId)]);
|
|
342
343
|
const orphans = [];
|
|
343
|
-
for (const [spaceId, row] of markerRows) if (row !== null && row !== void 0 && !
|
|
344
|
+
for (const [spaceId, row] of markerRows) if (row !== null && row !== void 0 && !aggregateSpaceIds.has(spaceId)) orphans.push(spaceId);
|
|
344
345
|
if (orphans.length === 0) return null;
|
|
345
346
|
orphans.sort((a, b) => a.localeCompare(b));
|
|
346
347
|
return new CliStructuredError("5002", orphans.length === 1 ? `Orphan contract-space marker detected for "${orphans[0]}"` : `Orphan contract-space markers detected for ${orphans.length} spaces`, {
|
|
@@ -355,7 +356,7 @@ function detectOrphanMarkers(aggregate, markerRows) {
|
|
|
355
356
|
});
|
|
356
357
|
}
|
|
357
358
|
function mapPlannerError(error) {
|
|
358
|
-
if (error.kind === "
|
|
359
|
+
if (error.kind === "planFromDiffFailed") return blindCast(notOk({
|
|
359
360
|
code: "PLANNING_FAILED",
|
|
360
361
|
summary: "Migration planning failed due to conflicts",
|
|
361
362
|
conflicts: error.conflicts,
|
|
@@ -544,11 +545,11 @@ const SPAN_IDS = {
|
|
|
544
545
|
* structured CLI error.
|
|
545
546
|
* 2. **Read DB state**: marker rows + (when `skipSchema` is `false`)
|
|
546
547
|
* schema introspection.
|
|
547
|
-
* 3. **Verify**: {@link verifyMigration} returns per-space
|
|
548
|
-
*
|
|
549
|
-
*
|
|
550
|
-
* callers (CLI command) can render
|
|
551
|
-
* returned to the caller verbatim.
|
|
548
|
+
* 3. **Verify**: {@link verifyMigration} returns per-space `markerCheck` +
|
|
549
|
+
* per-space `schemaCheck` (each contract space verified against the full schema,
|
|
550
|
+
* then scoped to its own contract space). Marker mismatches map to
|
|
551
|
+
* `CliStructuredError` (code `5002`) so callers (CLI command) can render
|
|
552
|
+
* and exit. Verify results are returned to the caller verbatim.
|
|
552
553
|
*/
|
|
553
554
|
async function executeDbVerify(options) {
|
|
554
555
|
const { driver, familyInstance, onProgress, skipSchema, skipMarker } = options;
|
|
@@ -562,6 +563,8 @@ async function executeDbVerify(options) {
|
|
|
562
563
|
onProgress,
|
|
563
564
|
contract: collectAggregateNamespaces(aggregate)
|
|
564
565
|
});
|
|
566
|
+
const classifySubjectGranularity = hasSchemaSubjectClassifier(familyInstance) ? (issue) => familyInstance.classifySubjectGranularity(issue) : void 0;
|
|
567
|
+
const classifyEntityKind = hasSchemaSubjectClassifier(familyInstance) ? (issue) => familyInstance.classifyEntityKind(issue) : void 0;
|
|
565
568
|
emitVerifySpan(onProgress, "spanStart");
|
|
566
569
|
return finaliseVerifyResult({
|
|
567
570
|
verifyResult: verifyMigration({
|
|
@@ -569,7 +572,9 @@ async function executeDbVerify(options) {
|
|
|
569
572
|
markersBySpaceId,
|
|
570
573
|
schemaIntrospection,
|
|
571
574
|
mode: options.mode,
|
|
572
|
-
|
|
575
|
+
verifySchemaForSpace: createPerSpaceVerifier(options),
|
|
576
|
+
...ifDefined("classifySubjectGranularity", classifySubjectGranularity),
|
|
577
|
+
...ifDefined("classifyEntityKind", classifyEntityKind)
|
|
573
578
|
}),
|
|
574
579
|
aggregate,
|
|
575
580
|
skipMarker,
|
|
@@ -616,18 +621,18 @@ async function runIntrospection(args) {
|
|
|
616
621
|
}
|
|
617
622
|
}
|
|
618
623
|
/**
|
|
619
|
-
* Build the per-
|
|
624
|
+
* Build the per-space schema callback handed to the aggregate verifier.
|
|
620
625
|
* When `skipSchema` is true the callback short-circuits with a synthetic
|
|
621
626
|
* `ok` result so the verifier still runs the (cheap) schemaCheck loop
|
|
622
627
|
* without invoking the family's verification path.
|
|
623
628
|
*/
|
|
624
|
-
function
|
|
629
|
+
function createPerSpaceVerifier(options) {
|
|
625
630
|
const { skipSchema, familyInstance, frameworkComponents } = options;
|
|
626
|
-
return (
|
|
627
|
-
if (skipSchema) return buildSkippedSchemaResult(
|
|
631
|
+
return (schema, space, verifyMode) => {
|
|
632
|
+
if (skipSchema) return buildSkippedSchemaResult(space);
|
|
628
633
|
return familyInstance.verifySchema({
|
|
629
|
-
contract:
|
|
630
|
-
schema
|
|
634
|
+
contract: space.contract(),
|
|
635
|
+
schema,
|
|
631
636
|
strict: verifyMode === "strict",
|
|
632
637
|
frameworkComponents
|
|
633
638
|
});
|
|
@@ -674,13 +679,14 @@ function finaliseVerifyResult(args) {
|
|
|
674
679
|
emitVerifySpan(onProgress, "spanEndOk");
|
|
675
680
|
return ok({
|
|
676
681
|
schemaResults: verifyResult.value.schemaCheck.perSpace,
|
|
677
|
-
|
|
682
|
+
unclaimed: verifyResult.value.schemaCheck.unclaimed,
|
|
683
|
+
spaceOrder: [aggregate.app.spaceId, ...aggregate.extensions.map((e) => e.spaceId)],
|
|
678
684
|
appSpaceId: aggregate.app.spaceId
|
|
679
685
|
});
|
|
680
686
|
}
|
|
681
|
-
function buildSkippedSchemaResult(
|
|
682
|
-
const contract =
|
|
683
|
-
const headRef = requireHeadRef(
|
|
687
|
+
function buildSkippedSchemaResult(space) {
|
|
688
|
+
const contract = space.contract();
|
|
689
|
+
const headRef = requireHeadRef(space);
|
|
684
690
|
const profileHash = castAs(contract).profileHash;
|
|
685
691
|
return {
|
|
686
692
|
ok: true,
|
|
@@ -690,26 +696,7 @@ function buildSkippedSchemaResult(member) {
|
|
|
690
696
|
...profileHash ? { profileHash } : {}
|
|
691
697
|
},
|
|
692
698
|
target: { expected: contract.target },
|
|
693
|
-
schema: {
|
|
694
|
-
issues: [],
|
|
695
|
-
root: {
|
|
696
|
-
status: "pass",
|
|
697
|
-
kind: "skipped",
|
|
698
|
-
name: member.spaceId,
|
|
699
|
-
contractPath: "",
|
|
700
|
-
code: "SKIPPED",
|
|
701
|
-
message: "Schema verification skipped",
|
|
702
|
-
expected: void 0,
|
|
703
|
-
actual: void 0,
|
|
704
|
-
children: []
|
|
705
|
-
},
|
|
706
|
-
counts: {
|
|
707
|
-
pass: 0,
|
|
708
|
-
warn: 0,
|
|
709
|
-
fail: 0,
|
|
710
|
-
totalNodes: 0
|
|
711
|
-
}
|
|
712
|
-
},
|
|
699
|
+
schema: { issues: [] },
|
|
713
700
|
timings: { total: 0 }
|
|
714
701
|
};
|
|
715
702
|
}
|
|
@@ -756,16 +743,16 @@ function mapMarkerCheckFailures(appSpaceId, section) {
|
|
|
756
743
|
/**
|
|
757
744
|
* Apply pending migrations across every contract space (app +
|
|
758
745
|
* extensions). Replay-only: graph-walk against the on-disk graph for
|
|
759
|
-
* every
|
|
746
|
+
* every contract space; no synth, no introspection.
|
|
760
747
|
*
|
|
761
748
|
* Pipeline:
|
|
762
749
|
*
|
|
763
750
|
* 1. Load aggregate from disk (loader hydrates extension graphs;
|
|
764
751
|
* caller provides app-space packages).
|
|
765
752
|
* 2. Read live marker rows per space (`familyInstance.readAllMarkers`).
|
|
766
|
-
* 3. Per
|
|
767
|
-
* marker to `
|
|
768
|
-
*
|
|
753
|
+
* 3. Per space: `resolveRecordedPath` plots the path from the live
|
|
754
|
+
* marker to `space.headRef.hash` (or `refHash` for the app
|
|
755
|
+
* space when provided). Empty-graph spaces fail loudly — a
|
|
769
756
|
* "never planned" space is a user-error condition for replay.
|
|
770
757
|
* 4. Hand off to {@link runMigration} (the runner-driving tail
|
|
771
758
|
* shared with `db init` / `db update`). Marker advancement is
|
|
@@ -786,29 +773,29 @@ async function executeMigrate(options) {
|
|
|
786
773
|
if (!loaded.ok) throw loaded.failure;
|
|
787
774
|
const aggregate = loaded.value;
|
|
788
775
|
const markerRows = await familyInstance.readAllMarkers({ driver });
|
|
789
|
-
const
|
|
776
|
+
const allSpaces = [aggregate.app, ...aggregate.extensions];
|
|
790
777
|
const perSpacePlans = /* @__PURE__ */ new Map();
|
|
791
778
|
const atHeadResolutions = /* @__PURE__ */ new Map();
|
|
792
|
-
for (const
|
|
793
|
-
const
|
|
794
|
-
const headRef = requireHeadRef(
|
|
795
|
-
const
|
|
796
|
-
const outcome =
|
|
797
|
-
|
|
779
|
+
for (const space of allSpaces) {
|
|
780
|
+
const isAppSpace = space.spaceId === aggregate.app.spaceId;
|
|
781
|
+
const headRef = requireHeadRef(space);
|
|
782
|
+
const spaceTargetHash = isAppSpace && refHash !== void 0 ? refHash : headRef.hash;
|
|
783
|
+
const outcome = planSpacePath({
|
|
784
|
+
space,
|
|
798
785
|
aggregate,
|
|
799
|
-
targetHash:
|
|
800
|
-
refInvariants:
|
|
801
|
-
liveMarker: markerRows.get(
|
|
802
|
-
...
|
|
786
|
+
targetHash: spaceTargetHash,
|
|
787
|
+
refInvariants: isAppSpace && refHash !== void 0 ? refInvariants : void 0,
|
|
788
|
+
liveMarker: markerRows.get(space.spaceId) ?? null,
|
|
789
|
+
...isAppSpace ? { refName } : {}
|
|
803
790
|
});
|
|
804
791
|
if (outcome.kind === "at-head") {
|
|
805
|
-
atHeadResolutions.set(
|
|
792
|
+
atHeadResolutions.set(space.spaceId, outcome.plan);
|
|
806
793
|
continue;
|
|
807
794
|
}
|
|
808
795
|
if (outcome.kind === "never-planned") return notOk(buildNeverPlannedFailure(outcome.spaceId, outcome.targetHash));
|
|
809
796
|
if (outcome.kind === "unreachable") return notOk(buildPathNotFoundFailure(outcome.spaceId, outcome.liveMarker, outcome.targetHash));
|
|
810
797
|
if (outcome.kind === "unsatisfiable") {
|
|
811
|
-
const structural = findPathWithDecision(outcome.
|
|
798
|
+
const structural = findPathWithDecision(outcome.targetSpace.graph(), outcome.liveHash, spaceTargetHash, { required: /* @__PURE__ */ new Set() });
|
|
812
799
|
const structuralPath = structural.kind === "ok" ? structural.decision.selectedPath.map((edge) => ({
|
|
813
800
|
dirName: edge.dirName,
|
|
814
801
|
migrationHash: edge.migrationHash,
|
|
@@ -823,7 +810,7 @@ async function executeMigrate(options) {
|
|
|
823
810
|
structuralPath
|
|
824
811
|
});
|
|
825
812
|
}
|
|
826
|
-
perSpacePlans.set(
|
|
813
|
+
perSpacePlans.set(space.spaceId, outcome.plan);
|
|
827
814
|
}
|
|
828
815
|
const canonicalOrder = [...aggregate.extensions.map((m) => m.spaceId), aggregate.app.spaceId];
|
|
829
816
|
const applyOrder = canonicalOrder.filter((spaceId) => perSpacePlans.has(spaceId));
|
|
@@ -892,7 +879,7 @@ async function executeMigrate(options) {
|
|
|
892
879
|
}));
|
|
893
880
|
}
|
|
894
881
|
/**
|
|
895
|
-
* Compute the graph-walk path for one contract
|
|
882
|
+
* Compute the graph-walk path for one contract space.
|
|
896
883
|
*
|
|
897
884
|
* Encapsulates the invariant-correct input assembly that both
|
|
898
885
|
* `executeMigrate` and `executeMigrateShowCommand` must use:
|
|
@@ -901,48 +888,48 @@ async function executeMigrate(options) {
|
|
|
901
888
|
* - `targetInvariants` uses the caller-supplied `refInvariants` when a
|
|
902
889
|
* `--to` ref was resolved (not always the file head ref's invariants).
|
|
903
890
|
*
|
|
904
|
-
* Both callers map the returned `
|
|
891
|
+
* Both callers map the returned `SpacePathOutcome` to their own error
|
|
905
892
|
* representation; the path-compute logic is shared and identical.
|
|
906
893
|
*
|
|
907
894
|
* @internal Exported for `executeMigrateShowCommand`.
|
|
908
895
|
*/
|
|
909
|
-
function
|
|
910
|
-
const
|
|
911
|
-
const headRef = requireHeadRef(
|
|
912
|
-
if (
|
|
896
|
+
function planSpacePath({ space, aggregate, targetHash, refInvariants, liveMarker, refName }) {
|
|
897
|
+
const isAppSpace = space.spaceId === aggregate.app.spaceId;
|
|
898
|
+
const headRef = requireHeadRef(space);
|
|
899
|
+
if (space.graph().nodes.size === 0) {
|
|
913
900
|
const liveHash = liveMarker?.storageHash;
|
|
914
901
|
if (targetHash === liveHash || liveHash === void 0 && targetHash === EMPTY_CONTRACT_HASH) return {
|
|
915
902
|
kind: "at-head",
|
|
916
903
|
plan: buildAtHeadResolution({
|
|
917
904
|
aggregateTargetId: aggregate.targetId,
|
|
918
|
-
|
|
905
|
+
space,
|
|
919
906
|
targetHash,
|
|
920
907
|
liveMarker
|
|
921
908
|
})
|
|
922
909
|
};
|
|
923
910
|
return {
|
|
924
911
|
kind: "never-planned",
|
|
925
|
-
spaceId:
|
|
912
|
+
spaceId: space.spaceId,
|
|
926
913
|
targetHash
|
|
927
914
|
};
|
|
928
915
|
}
|
|
929
|
-
const targetInvariants =
|
|
930
|
-
const
|
|
931
|
-
...
|
|
916
|
+
const targetInvariants = isAppSpace && refInvariants !== void 0 ? refInvariants : headRef.invariants;
|
|
917
|
+
const targetSpace = targetHash === headRef.hash && targetInvariants === headRef.invariants ? space : {
|
|
918
|
+
...space,
|
|
932
919
|
headRef: {
|
|
933
920
|
hash: targetHash,
|
|
934
921
|
invariants: targetInvariants
|
|
935
922
|
}
|
|
936
923
|
};
|
|
937
|
-
const walked =
|
|
924
|
+
const walked = resolveRecordedPath({
|
|
938
925
|
aggregateTargetId: aggregate.targetId,
|
|
939
|
-
|
|
926
|
+
space: targetSpace,
|
|
940
927
|
currentMarker: liveMarker,
|
|
941
|
-
...
|
|
928
|
+
...isAppSpace && refName !== void 0 ? { refName } : {}
|
|
942
929
|
});
|
|
943
930
|
if (walked.kind === "unreachable") return {
|
|
944
931
|
kind: "unreachable",
|
|
945
|
-
spaceId:
|
|
932
|
+
spaceId: space.spaceId,
|
|
946
933
|
liveMarker,
|
|
947
934
|
targetHash
|
|
948
935
|
};
|
|
@@ -950,11 +937,11 @@ function planMemberPath({ member, aggregate, targetHash, refInvariants, liveMark
|
|
|
950
937
|
const liveHash = liveMarker?.storageHash ?? EMPTY_CONTRACT_HASH;
|
|
951
938
|
return {
|
|
952
939
|
kind: "unsatisfiable",
|
|
953
|
-
spaceId:
|
|
954
|
-
|
|
940
|
+
spaceId: space.spaceId,
|
|
941
|
+
isAppSpace,
|
|
955
942
|
missing: walked.missing,
|
|
956
943
|
targetInvariants,
|
|
957
|
-
|
|
944
|
+
targetSpace,
|
|
958
945
|
liveHash,
|
|
959
946
|
refName
|
|
960
947
|
};
|
|
@@ -966,26 +953,26 @@ function planMemberPath({ member, aggregate, targetHash, refInvariants, liveMark
|
|
|
966
953
|
}
|
|
967
954
|
/**
|
|
968
955
|
* Build a zero-op {@link PerSpacePlan} for an empty-graph
|
|
969
|
-
*
|
|
970
|
-
* pipeline thread the
|
|
956
|
+
* space whose live marker already matches the target. Lets the apply
|
|
957
|
+
* pipeline thread the space through `perSpacePlans` -> `applyOrder`
|
|
971
958
|
* -> the success envelope's `perSpace[]` block so the result reflects
|
|
972
959
|
* every loaded space, even when there is nothing to execute.
|
|
973
960
|
*/
|
|
974
961
|
function buildAtHeadResolution(args) {
|
|
975
|
-
const { aggregateTargetId,
|
|
962
|
+
const { aggregateTargetId, space, targetHash, liveMarker } = args;
|
|
976
963
|
return {
|
|
977
964
|
plan: {
|
|
978
965
|
targetId: aggregateTargetId,
|
|
979
|
-
spaceId:
|
|
966
|
+
spaceId: space.spaceId,
|
|
980
967
|
origin: liveMarker === null ? null : { storageHash: liveMarker.storageHash },
|
|
981
968
|
destination: { storageHash: targetHash },
|
|
982
969
|
operations: [],
|
|
983
970
|
providedInvariants: []
|
|
984
971
|
},
|
|
985
972
|
displayOps: [],
|
|
986
|
-
destinationContract:
|
|
987
|
-
strategy: "
|
|
988
|
-
migrationEdges: [
|
|
973
|
+
destinationContract: space.contract(),
|
|
974
|
+
strategy: "declared-state",
|
|
975
|
+
migrationEdges: [buildFabricatedMigrationEdge({
|
|
989
976
|
currentMarkerStorageHash: liveMarker?.storageHash,
|
|
990
977
|
destinationStorageHash: targetHash,
|
|
991
978
|
operationCount: 0
|
|
@@ -1503,7 +1490,8 @@ var ControlClientImpl = class {
|
|
|
1503
1490
|
authoringContributions: stack.authoringContributions,
|
|
1504
1491
|
codecLookup: stack.codecLookup,
|
|
1505
1492
|
controlMutationDefaults: stack.controlMutationDefaults,
|
|
1506
|
-
resolvedInputs: contractConfig.source.inputs ?? []
|
|
1493
|
+
resolvedInputs: contractConfig.source.inputs ?? [],
|
|
1494
|
+
capabilities: stack.capabilities
|
|
1507
1495
|
};
|
|
1508
1496
|
const providerResult = await contractConfig.source.load(sourceContext);
|
|
1509
1497
|
if (!providerResult.ok) {
|
|
@@ -1558,9 +1546,10 @@ var ControlClientImpl = class {
|
|
|
1558
1546
|
});
|
|
1559
1547
|
try {
|
|
1560
1548
|
const enrichedIR = enrichContract(contractRaw, this.frameworkComponents ?? []);
|
|
1549
|
+
const rawContractJson = this.options.target.contractSerializer.serializeContract(enrichedIR);
|
|
1561
1550
|
let deserializedContract;
|
|
1562
1551
|
try {
|
|
1563
|
-
deserializedContract = this.familyInstance.deserializeContract(
|
|
1552
|
+
deserializedContract = this.familyInstance.deserializeContract(rawContractJson);
|
|
1564
1553
|
} catch (error) {
|
|
1565
1554
|
onProgress?.({
|
|
1566
1555
|
action: "emit",
|
|
@@ -1606,6 +1595,6 @@ var ControlClientImpl = class {
|
|
|
1606
1595
|
}
|
|
1607
1596
|
};
|
|
1608
1597
|
//#endregion
|
|
1609
|
-
export { executeDbInit as a, executeDbUpdate as i,
|
|
1598
|
+
export { executeDbInit as a, executeDbUpdate as i, planSpacePath as n, ContractValidationError as o, executeDbVerify as r, createControlClient as t };
|
|
1610
1599
|
|
|
1611
|
-
//# sourceMappingURL=client-
|
|
1600
|
+
//# sourceMappingURL=client-DL6KE_c0.mjs.map
|