@prisma-next/cli 0.14.0 → 0.15.0-dev.1
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/README.md +2 -2
- package/dist/cli.mjs +33 -14
- package/dist/cli.mjs.map +1 -1
- package/dist/{client-CJzuo5wX.mjs → client-DigVI8zX.mjs} +90 -104
- package/dist/client-DigVI8zX.mjs.map +1 -0
- package/dist/{command-helpers-DGMvGBeX.mjs → command-helpers-CUoKYTlG.mjs} +13 -10
- package/dist/command-helpers-CUoKYTlG.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 +5 -5
- package/dist/commands/db-sign.mjs.map +1 -1
- package/dist/commands/db-update.mjs +4 -4
- package/dist/commands/db-verify.d.mts.map +1 -1
- 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 +37 -38
- 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 +9 -9
- 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 +4 -4
- package/dist/commands/migration-new.mjs.map +1 -1
- package/dist/commands/migration-plan.d.mts.map +1 -1
- package/dist/commands/migration-plan.mjs +1 -1
- package/dist/commands/migration-show.mjs +4 -4
- package/dist/commands/migration-show.mjs.map +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/commands/ref.mjs +3 -3
- package/dist/commands/ref.mjs.map +1 -1
- package/dist/commands/telemetry/index.mjs +1 -1
- package/dist/{contract-at-errors-CFXsstzm.mjs → contract-at-errors-D8CNDD7g.mjs} +2 -2
- package/dist/{contract-at-errors-CFXsstzm.mjs.map → contract-at-errors-D8CNDD7g.mjs.map} +1 -1
- package/dist/{contract-emit-C8HmtboH.mjs → contract-emit-sYrqzsdN.mjs} +9 -11
- package/dist/contract-emit-sYrqzsdN.mjs.map +1 -0
- package/dist/{contract-emit-B_qriF8B.mjs → contract-emit-wgqrOXUI.mjs} +6 -6
- package/dist/contract-emit-wgqrOXUI.mjs.map +1 -0
- package/dist/{contract-infer-BYT_ra_U.mjs → contract-infer-6SQnnVj7.mjs} +3 -3
- package/dist/{contract-infer-BYT_ra_U.mjs.map → contract-infer-6SQnnVj7.mjs.map} +1 -1
- package/dist/{contract-space-aggregate-loader-ClI1KN6d.mjs → contract-space-aggregate-loader-DpB4x97a.mjs} +63 -5
- package/dist/contract-space-aggregate-loader-DpB4x97a.mjs.map +1 -0
- package/dist/{db-verify-C24FKhb7.mjs → db-verify-CEsG5Gek.mjs} +57 -61
- package/dist/db-verify-CEsG5Gek.mjs.map +1 -0
- 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 +2 -2
- package/dist/exports/index.d.mts +5 -1
- package/dist/exports/index.d.mts.map +1 -1
- package/dist/exports/index.mjs +4 -3
- package/dist/exports/index.mjs.map +1 -1
- package/dist/format-CjongNb1.mjs +102 -0
- package/dist/format-CjongNb1.mjs.map +1 -0
- package/dist/{framework-components-YVQHhPH7.mjs → framework-components-BbnM1RYm.mjs} +2 -2
- package/dist/{framework-components-YVQHhPH7.mjs.map → framework-components-BbnM1RYm.mjs.map} +1 -1
- package/dist/{init-0HwB-Vh8.mjs → init-D8YFfaD6.mjs} +27 -19
- package/dist/init-D8YFfaD6.mjs.map +1 -0
- package/dist/{inspect-live-schema-DF6IwcDl.mjs → inspect-live-schema-CEt_ztBJ.mjs} +4 -4
- package/dist/inspect-live-schema-CEt_ztBJ.mjs.map +1 -0
- package/dist/{migration-check-VwM8xCZV.mjs → migration-check-ByeQHOhK.mjs} +10 -12
- package/dist/migration-check-ByeQHOhK.mjs.map +1 -0
- package/dist/migration-cli.mjs +1 -1
- package/dist/migration-cli.mjs.map +1 -1
- package/dist/{migration-command-scaffold-DA-Lhx6o.mjs → migration-command-scaffold-CJO3tjiR.mjs} +4 -4
- package/dist/migration-command-scaffold-CJO3tjiR.mjs.map +1 -0
- package/dist/{migration-graph-command-render-CEez7YUK.mjs → migration-graph-command-render-B83xrnNy.mjs} +24 -24
- package/dist/{migration-graph-command-render-CEez7YUK.mjs.map → migration-graph-command-render-B83xrnNy.mjs.map} +1 -1
- package/dist/{migration-list-DlJJ_38Z.mjs → migration-list-DTYM8xvm.mjs} +16 -16
- package/dist/migration-list-DTYM8xvm.mjs.map +1 -0
- package/dist/{migration-log-CG0qQAFm.mjs → migration-log-qZ8LpQIl.mjs} +5 -5
- package/dist/migration-log-qZ8LpQIl.mjs.map +1 -0
- package/dist/{migration-path-target-Ce6OZImp.mjs → migration-path-target-DmNwsDgs.mjs} +2 -2
- package/dist/{migration-path-target-Ce6OZImp.mjs.map → migration-path-target-DmNwsDgs.mjs.map} +1 -1
- package/dist/{migration-plan-W_E8FQOk.mjs → migration-plan-CfPrB80t.mjs} +30 -30
- package/dist/migration-plan-CfPrB80t.mjs.map +1 -0
- package/dist/{migration-status-CD-LC2Ip.mjs → migration-status-DRuS-rP5.mjs} +14 -15
- package/dist/migration-status-DRuS-rP5.mjs.map +1 -0
- package/dist/{telemetry-BIM4beEO.mjs → telemetry-DHBBq5wT.mjs} +2 -2
- package/dist/{telemetry-BIM4beEO.mjs.map → telemetry-DHBBq5wT.mjs.map} +1 -1
- package/dist/{types-C_tYiJYx.d.mts → types-DFoqNIcQ.d.mts} +27 -21
- package/dist/types-DFoqNIcQ.d.mts.map +1 -0
- package/dist/{verify-DcOYZ1tH.mjs → verify-DDCb0R2r.mjs} +57 -159
- package/dist/verify-DDCb0R2r.mjs.map +1 -0
- package/package.json +28 -30
- package/src/cli.ts +7 -0
- package/src/commands/contract-emit.ts +1 -1
- package/src/commands/db-sign.ts +1 -1
- package/src/commands/db-verify.ts +34 -20
- package/src/commands/format.ts +75 -0
- package/src/commands/init/detect-package-manager.ts +8 -4
- package/src/commands/init/hygiene-package-scripts.ts +16 -3
- package/src/commands/inspect-live-schema.ts +1 -1
- package/src/commands/lsp.ts +32 -0
- package/src/commands/migrate.ts +47 -44
- package/src/commands/migration-check.ts +6 -6
- package/src/commands/migration-graph.ts +5 -5
- package/src/commands/migration-list.ts +13 -13
- package/src/commands/migration-log.ts +1 -1
- package/src/commands/migration-new.ts +1 -1
- package/src/commands/migration-plan.ts +15 -4
- package/src/commands/migration-show.ts +1 -1
- package/src/commands/migration-status.ts +10 -10
- package/src/commands/ref.ts +1 -1
- package/src/control-api/client.ts +8 -23
- package/src/control-api/operations/contract-emit.ts +9 -27
- 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/format.ts +98 -0
- 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/exports/index.ts +1 -0
- package/src/migration-cli.ts +1 -1
- package/src/utils/combine-verify-results.ts +94 -0
- package/src/utils/extension-pack-inputs.ts +1 -1
- package/src/utils/formatters/errors.ts +13 -5
- package/src/utils/formatters/verify.ts +88 -227
- package/src/utils/migration-command-scaffold.ts +1 -1
- package/src/utils/plan-resolution.ts +18 -18
- package/dist/client-CJzuo5wX.mjs.map +0 -1
- package/dist/command-helpers-DGMvGBeX.mjs.map +0 -1
- package/dist/config-loader-p9JMrekQ.mjs +0 -88
- package/dist/config-loader-p9JMrekQ.mjs.map +0 -1
- package/dist/config-loader.d.mts +0 -16
- package/dist/config-loader.d.mts.map +0 -1
- package/dist/config-loader.mjs +0 -2
- package/dist/contract-emit-B_qriF8B.mjs.map +0 -1
- package/dist/contract-emit-C8HmtboH.mjs.map +0 -1
- package/dist/contract-space-aggregate-loader-ClI1KN6d.mjs.map +0 -1
- package/dist/db-verify-C24FKhb7.mjs.map +0 -1
- package/dist/extension-pack-inputs-1ySHqxKG.mjs +0 -62
- package/dist/extension-pack-inputs-1ySHqxKG.mjs.map +0 -1
- package/dist/init-0HwB-Vh8.mjs.map +0 -1
- package/dist/inspect-live-schema-DF6IwcDl.mjs.map +0 -1
- package/dist/migration-check-VwM8xCZV.mjs.map +0 -1
- package/dist/migration-command-scaffold-DA-Lhx6o.mjs.map +0 -1
- package/dist/migration-list-DlJJ_38Z.mjs.map +0 -1
- package/dist/migration-log-CG0qQAFm.mjs.map +0 -1
- package/dist/migration-plan-W_E8FQOk.mjs.map +0 -1
- package/dist/migration-status-CD-LC2Ip.mjs.map +0 -1
- package/dist/types-C_tYiJYx.d.mts.map +0 -1
- package/dist/verify-DcOYZ1tH.mjs.map +0 -1
- package/src/config-loader.ts +0 -92
- package/src/config-path-validation.ts +0 -74
- package/src/utils/combine-schema-results.ts +0 -84
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { F as CliStructuredError } from "./command-helpers-
|
|
2
|
-
import {
|
|
3
|
-
import { t as assertFrameworkComponentsCompatible } from "./framework-components-YVQHhPH7.mjs";
|
|
1
|
+
import { F as CliStructuredError } from "./command-helpers-CUoKYTlG.mjs";
|
|
2
|
+
import { t as assertFrameworkComponentsCompatible } from "./framework-components-BbnM1RYm.mjs";
|
|
4
3
|
import { t as enrichContract } from "./contract-enrichment-gn9sWbPw.mjs";
|
|
5
|
-
import { t as buildContractSpaceAggregate } from "./contract-space-aggregate-loader-
|
|
4
|
+
import { t as buildContractSpaceAggregate } from "./contract-space-aggregate-loader-DpB4x97a.mjs";
|
|
6
5
|
import { emit } from "@prisma-next/emitter";
|
|
7
6
|
import { ifDefined } from "@prisma-next/utils/defined";
|
|
8
7
|
import { notOk, ok } from "@prisma-next/utils/result";
|
|
9
|
-
import { APP_SPACE_ID, createControlStack, hasMigrations, hasOperationPreview, hasPslContractInfer, hasSchemaView } from "@prisma-next/framework-components/control";
|
|
8
|
+
import { APP_SPACE_ID, createControlStack, hasMigrations, hasOperationPreview, hasPslContractInfer, hasSchemaSubjectClassifier, hasSchemaView } from "@prisma-next/framework-components/control";
|
|
10
9
|
import { blindCast, castAs } from "@prisma-next/utils/casts";
|
|
11
|
-
import {
|
|
10
|
+
import { buildFabricatedMigrationEdge, collectAggregateNamespaces, planMigration, requireHeadRef, resolveRecordedPath, verifyMigration } from "@prisma-next/migration-tools/aggregate";
|
|
12
11
|
import { EMPTY_CONTRACT_HASH } from "@prisma-next/migration-tools/constants";
|
|
13
12
|
import { errorNoInvariantPath } from "@prisma-next/migration-tools/errors";
|
|
14
13
|
import { findPathWithDecision } from "@prisma-next/migration-tools/migration-graph";
|
|
@@ -144,7 +143,7 @@ function buildPerSpaceBreakdown(orderedResolutions, appSpaceId, options) {
|
|
|
144
143
|
}
|
|
145
144
|
/**
|
|
146
145
|
* Materialise the `applyOrder` ordering into resolved per-space
|
|
147
|
-
* entries. Throws if the planner output is missing a
|
|
146
|
+
* entries. Throws if the planner output is missing a contract space listed
|
|
148
147
|
* in `applyOrder` — a wiring bug that should never reach runtime.
|
|
149
148
|
*
|
|
150
149
|
* Exported so callers building their own success envelopes after a
|
|
@@ -196,10 +195,11 @@ const SPAN_IDS$1 = {
|
|
|
196
195
|
* integrity violation short-circuits with a structured error.
|
|
197
196
|
* 2. **Read DB state**: marker rows (`familyInstance.readAllMarkers`)
|
|
198
197
|
* + introspected schema (`familyInstance.introspect`).
|
|
199
|
-
* 3. **Plan**: {@link planMigration} chooses
|
|
200
|
-
*
|
|
201
|
-
* is forced through
|
|
202
|
-
* extension
|
|
198
|
+
* 3. **Plan**: {@link planMigration} chooses `resolveRecordedPath` vs
|
|
199
|
+
* `planFromDiff` per space according to `callerPolicy.ignoreGraphFor`.
|
|
200
|
+
* The app space is forced through `planFromDiff` (today's daily-driver
|
|
201
|
+
* behaviour); every extension space walks its on-disk graph via
|
|
202
|
+
* `resolveRecordedPath`.
|
|
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
|
|
@@ -252,7 +252,7 @@ async function executeRun(options) {
|
|
|
252
252
|
adapter,
|
|
253
253
|
migrations,
|
|
254
254
|
frameworkComponents,
|
|
255
|
-
callerPolicy: { ignoreGraphFor: new Set([aggregate.app.spaceId]) },
|
|
255
|
+
callerPolicy: { ignoreGraphFor: /* @__PURE__ */ new Set([aggregate.app.spaceId]) },
|
|
256
256
|
operationPolicy: policy
|
|
257
257
|
});
|
|
258
258
|
if (!planResult.ok) {
|
|
@@ -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 = /* @__PURE__ */ 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`, {
|
|
@@ -355,7 +355,7 @@ function detectOrphanMarkers(aggregate, markerRows) {
|
|
|
355
355
|
});
|
|
356
356
|
}
|
|
357
357
|
function mapPlannerError(error) {
|
|
358
|
-
if (error.kind === "
|
|
358
|
+
if (error.kind === "planFromDiffFailed") return blindCast(notOk({
|
|
359
359
|
code: "PLANNING_FAILED",
|
|
360
360
|
summary: "Migration planning failed due to conflicts",
|
|
361
361
|
conflicts: error.conflicts,
|
|
@@ -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;
|
|
@@ -562,6 +562,8 @@ async function executeDbVerify(options) {
|
|
|
562
562
|
onProgress,
|
|
563
563
|
contract: collectAggregateNamespaces(aggregate)
|
|
564
564
|
});
|
|
565
|
+
const classifySubjectGranularity = hasSchemaSubjectClassifier(familyInstance) ? (issue) => familyInstance.classifySubjectGranularity(issue) : void 0;
|
|
566
|
+
const classifyEntityKind = hasSchemaSubjectClassifier(familyInstance) ? (issue) => familyInstance.classifyEntityKind(issue) : void 0;
|
|
565
567
|
emitVerifySpan(onProgress, "spanStart");
|
|
566
568
|
return finaliseVerifyResult({
|
|
567
569
|
verifyResult: verifyMigration({
|
|
@@ -569,7 +571,9 @@ async function executeDbVerify(options) {
|
|
|
569
571
|
markersBySpaceId,
|
|
570
572
|
schemaIntrospection,
|
|
571
573
|
mode: options.mode,
|
|
572
|
-
|
|
574
|
+
verifySchemaForSpace: createPerSpaceVerifier(options),
|
|
575
|
+
...ifDefined("classifySubjectGranularity", classifySubjectGranularity),
|
|
576
|
+
...ifDefined("classifyEntityKind", classifyEntityKind)
|
|
573
577
|
}),
|
|
574
578
|
aggregate,
|
|
575
579
|
skipMarker,
|
|
@@ -616,18 +620,18 @@ async function runIntrospection(args) {
|
|
|
616
620
|
}
|
|
617
621
|
}
|
|
618
622
|
/**
|
|
619
|
-
* Build the per-
|
|
623
|
+
* Build the per-space schema callback handed to the aggregate verifier.
|
|
620
624
|
* When `skipSchema` is true the callback short-circuits with a synthetic
|
|
621
625
|
* `ok` result so the verifier still runs the (cheap) schemaCheck loop
|
|
622
626
|
* without invoking the family's verification path.
|
|
623
627
|
*/
|
|
624
|
-
function
|
|
628
|
+
function createPerSpaceVerifier(options) {
|
|
625
629
|
const { skipSchema, familyInstance, frameworkComponents } = options;
|
|
626
|
-
return (
|
|
627
|
-
if (skipSchema) return buildSkippedSchemaResult(
|
|
630
|
+
return (schema, space, verifyMode) => {
|
|
631
|
+
if (skipSchema) return buildSkippedSchemaResult(space);
|
|
628
632
|
return familyInstance.verifySchema({
|
|
629
|
-
contract:
|
|
630
|
-
schema
|
|
633
|
+
contract: space.contract(),
|
|
634
|
+
schema,
|
|
631
635
|
strict: verifyMode === "strict",
|
|
632
636
|
frameworkComponents
|
|
633
637
|
});
|
|
@@ -674,13 +678,14 @@ function finaliseVerifyResult(args) {
|
|
|
674
678
|
emitVerifySpan(onProgress, "spanEndOk");
|
|
675
679
|
return ok({
|
|
676
680
|
schemaResults: verifyResult.value.schemaCheck.perSpace,
|
|
677
|
-
|
|
681
|
+
unclaimed: verifyResult.value.schemaCheck.unclaimed,
|
|
682
|
+
spaceOrder: [aggregate.app.spaceId, ...aggregate.extensions.map((e) => e.spaceId)],
|
|
678
683
|
appSpaceId: aggregate.app.spaceId
|
|
679
684
|
});
|
|
680
685
|
}
|
|
681
|
-
function buildSkippedSchemaResult(
|
|
682
|
-
const contract =
|
|
683
|
-
const headRef = requireHeadRef(
|
|
686
|
+
function buildSkippedSchemaResult(space) {
|
|
687
|
+
const contract = space.contract();
|
|
688
|
+
const headRef = requireHeadRef(space);
|
|
684
689
|
const profileHash = castAs(contract).profileHash;
|
|
685
690
|
return {
|
|
686
691
|
ok: true,
|
|
@@ -690,26 +695,7 @@ function buildSkippedSchemaResult(member) {
|
|
|
690
695
|
...profileHash ? { profileHash } : {}
|
|
691
696
|
},
|
|
692
697
|
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
|
-
},
|
|
698
|
+
schema: { issues: [] },
|
|
713
699
|
timings: { total: 0 }
|
|
714
700
|
};
|
|
715
701
|
}
|
|
@@ -756,16 +742,16 @@ function mapMarkerCheckFailures(appSpaceId, section) {
|
|
|
756
742
|
/**
|
|
757
743
|
* Apply pending migrations across every contract space (app +
|
|
758
744
|
* extensions). Replay-only: graph-walk against the on-disk graph for
|
|
759
|
-
* every
|
|
745
|
+
* every contract space; no synth, no introspection.
|
|
760
746
|
*
|
|
761
747
|
* Pipeline:
|
|
762
748
|
*
|
|
763
749
|
* 1. Load aggregate from disk (loader hydrates extension graphs;
|
|
764
750
|
* caller provides app-space packages).
|
|
765
751
|
* 2. Read live marker rows per space (`familyInstance.readAllMarkers`).
|
|
766
|
-
* 3. Per
|
|
767
|
-
* marker to `
|
|
768
|
-
*
|
|
752
|
+
* 3. Per space: `resolveRecordedPath` plots the path from the live
|
|
753
|
+
* marker to `space.headRef.hash` (or `refHash` for the app
|
|
754
|
+
* space when provided). Empty-graph spaces fail loudly — a
|
|
769
755
|
* "never planned" space is a user-error condition for replay.
|
|
770
756
|
* 4. Hand off to {@link runMigration} (the runner-driving tail
|
|
771
757
|
* shared with `db init` / `db update`). Marker advancement is
|
|
@@ -786,29 +772,29 @@ async function executeMigrate(options) {
|
|
|
786
772
|
if (!loaded.ok) throw loaded.failure;
|
|
787
773
|
const aggregate = loaded.value;
|
|
788
774
|
const markerRows = await familyInstance.readAllMarkers({ driver });
|
|
789
|
-
const
|
|
775
|
+
const allSpaces = [aggregate.app, ...aggregate.extensions];
|
|
790
776
|
const perSpacePlans = /* @__PURE__ */ new Map();
|
|
791
777
|
const atHeadResolutions = /* @__PURE__ */ new Map();
|
|
792
|
-
for (const
|
|
793
|
-
const
|
|
794
|
-
const headRef = requireHeadRef(
|
|
795
|
-
const
|
|
796
|
-
const outcome =
|
|
797
|
-
|
|
778
|
+
for (const space of allSpaces) {
|
|
779
|
+
const isAppSpace = space.spaceId === aggregate.app.spaceId;
|
|
780
|
+
const headRef = requireHeadRef(space);
|
|
781
|
+
const spaceTargetHash = isAppSpace && refHash !== void 0 ? refHash : headRef.hash;
|
|
782
|
+
const outcome = planSpacePath({
|
|
783
|
+
space,
|
|
798
784
|
aggregate,
|
|
799
|
-
targetHash:
|
|
800
|
-
refInvariants:
|
|
801
|
-
liveMarker: markerRows.get(
|
|
802
|
-
...
|
|
785
|
+
targetHash: spaceTargetHash,
|
|
786
|
+
refInvariants: isAppSpace && refHash !== void 0 ? refInvariants : void 0,
|
|
787
|
+
liveMarker: markerRows.get(space.spaceId) ?? null,
|
|
788
|
+
...isAppSpace ? { refName } : {}
|
|
803
789
|
});
|
|
804
790
|
if (outcome.kind === "at-head") {
|
|
805
|
-
atHeadResolutions.set(
|
|
791
|
+
atHeadResolutions.set(space.spaceId, outcome.plan);
|
|
806
792
|
continue;
|
|
807
793
|
}
|
|
808
794
|
if (outcome.kind === "never-planned") return notOk(buildNeverPlannedFailure(outcome.spaceId, outcome.targetHash));
|
|
809
795
|
if (outcome.kind === "unreachable") return notOk(buildPathNotFoundFailure(outcome.spaceId, outcome.liveMarker, outcome.targetHash));
|
|
810
796
|
if (outcome.kind === "unsatisfiable") {
|
|
811
|
-
const structural = findPathWithDecision(outcome.
|
|
797
|
+
const structural = findPathWithDecision(outcome.targetSpace.graph(), outcome.liveHash, spaceTargetHash, { required: /* @__PURE__ */ new Set() });
|
|
812
798
|
const structuralPath = structural.kind === "ok" ? structural.decision.selectedPath.map((edge) => ({
|
|
813
799
|
dirName: edge.dirName,
|
|
814
800
|
migrationHash: edge.migrationHash,
|
|
@@ -823,7 +809,7 @@ async function executeMigrate(options) {
|
|
|
823
809
|
structuralPath
|
|
824
810
|
});
|
|
825
811
|
}
|
|
826
|
-
perSpacePlans.set(
|
|
812
|
+
perSpacePlans.set(space.spaceId, outcome.plan);
|
|
827
813
|
}
|
|
828
814
|
const canonicalOrder = [...aggregate.extensions.map((m) => m.spaceId), aggregate.app.spaceId];
|
|
829
815
|
const applyOrder = canonicalOrder.filter((spaceId) => perSpacePlans.has(spaceId));
|
|
@@ -892,7 +878,7 @@ async function executeMigrate(options) {
|
|
|
892
878
|
}));
|
|
893
879
|
}
|
|
894
880
|
/**
|
|
895
|
-
* Compute the graph-walk path for one contract
|
|
881
|
+
* Compute the graph-walk path for one contract space.
|
|
896
882
|
*
|
|
897
883
|
* Encapsulates the invariant-correct input assembly that both
|
|
898
884
|
* `executeMigrate` and `executeMigrateShowCommand` must use:
|
|
@@ -901,48 +887,48 @@ async function executeMigrate(options) {
|
|
|
901
887
|
* - `targetInvariants` uses the caller-supplied `refInvariants` when a
|
|
902
888
|
* `--to` ref was resolved (not always the file head ref's invariants).
|
|
903
889
|
*
|
|
904
|
-
* Both callers map the returned `
|
|
890
|
+
* Both callers map the returned `SpacePathOutcome` to their own error
|
|
905
891
|
* representation; the path-compute logic is shared and identical.
|
|
906
892
|
*
|
|
907
893
|
* @internal Exported for `executeMigrateShowCommand`.
|
|
908
894
|
*/
|
|
909
|
-
function
|
|
910
|
-
const
|
|
911
|
-
const headRef = requireHeadRef(
|
|
912
|
-
if (
|
|
895
|
+
function planSpacePath({ space, aggregate, targetHash, refInvariants, liveMarker, refName }) {
|
|
896
|
+
const isAppSpace = space.spaceId === aggregate.app.spaceId;
|
|
897
|
+
const headRef = requireHeadRef(space);
|
|
898
|
+
if (space.graph().nodes.size === 0) {
|
|
913
899
|
const liveHash = liveMarker?.storageHash;
|
|
914
900
|
if (targetHash === liveHash || liveHash === void 0 && targetHash === EMPTY_CONTRACT_HASH) return {
|
|
915
901
|
kind: "at-head",
|
|
916
902
|
plan: buildAtHeadResolution({
|
|
917
903
|
aggregateTargetId: aggregate.targetId,
|
|
918
|
-
|
|
904
|
+
space,
|
|
919
905
|
targetHash,
|
|
920
906
|
liveMarker
|
|
921
907
|
})
|
|
922
908
|
};
|
|
923
909
|
return {
|
|
924
910
|
kind: "never-planned",
|
|
925
|
-
spaceId:
|
|
911
|
+
spaceId: space.spaceId,
|
|
926
912
|
targetHash
|
|
927
913
|
};
|
|
928
914
|
}
|
|
929
|
-
const targetInvariants =
|
|
930
|
-
const
|
|
931
|
-
...
|
|
915
|
+
const targetInvariants = isAppSpace && refInvariants !== void 0 ? refInvariants : headRef.invariants;
|
|
916
|
+
const targetSpace = targetHash === headRef.hash && targetInvariants === headRef.invariants ? space : {
|
|
917
|
+
...space,
|
|
932
918
|
headRef: {
|
|
933
919
|
hash: targetHash,
|
|
934
920
|
invariants: targetInvariants
|
|
935
921
|
}
|
|
936
922
|
};
|
|
937
|
-
const walked =
|
|
923
|
+
const walked = resolveRecordedPath({
|
|
938
924
|
aggregateTargetId: aggregate.targetId,
|
|
939
|
-
|
|
925
|
+
space: targetSpace,
|
|
940
926
|
currentMarker: liveMarker,
|
|
941
|
-
...
|
|
927
|
+
...isAppSpace && refName !== void 0 ? { refName } : {}
|
|
942
928
|
});
|
|
943
929
|
if (walked.kind === "unreachable") return {
|
|
944
930
|
kind: "unreachable",
|
|
945
|
-
spaceId:
|
|
931
|
+
spaceId: space.spaceId,
|
|
946
932
|
liveMarker,
|
|
947
933
|
targetHash
|
|
948
934
|
};
|
|
@@ -950,11 +936,11 @@ function planMemberPath({ member, aggregate, targetHash, refInvariants, liveMark
|
|
|
950
936
|
const liveHash = liveMarker?.storageHash ?? EMPTY_CONTRACT_HASH;
|
|
951
937
|
return {
|
|
952
938
|
kind: "unsatisfiable",
|
|
953
|
-
spaceId:
|
|
954
|
-
|
|
939
|
+
spaceId: space.spaceId,
|
|
940
|
+
isAppSpace,
|
|
955
941
|
missing: walked.missing,
|
|
956
942
|
targetInvariants,
|
|
957
|
-
|
|
943
|
+
targetSpace,
|
|
958
944
|
liveHash,
|
|
959
945
|
refName
|
|
960
946
|
};
|
|
@@ -966,26 +952,26 @@ function planMemberPath({ member, aggregate, targetHash, refInvariants, liveMark
|
|
|
966
952
|
}
|
|
967
953
|
/**
|
|
968
954
|
* Build a zero-op {@link PerSpacePlan} for an empty-graph
|
|
969
|
-
*
|
|
970
|
-
* pipeline thread the
|
|
955
|
+
* space whose live marker already matches the target. Lets the apply
|
|
956
|
+
* pipeline thread the space through `perSpacePlans` -> `applyOrder`
|
|
971
957
|
* -> the success envelope's `perSpace[]` block so the result reflects
|
|
972
958
|
* every loaded space, even when there is nothing to execute.
|
|
973
959
|
*/
|
|
974
960
|
function buildAtHeadResolution(args) {
|
|
975
|
-
const { aggregateTargetId,
|
|
961
|
+
const { aggregateTargetId, space, targetHash, liveMarker } = args;
|
|
976
962
|
return {
|
|
977
963
|
plan: {
|
|
978
964
|
targetId: aggregateTargetId,
|
|
979
|
-
spaceId:
|
|
965
|
+
spaceId: space.spaceId,
|
|
980
966
|
origin: liveMarker === null ? null : { storageHash: liveMarker.storageHash },
|
|
981
967
|
destination: { storageHash: targetHash },
|
|
982
968
|
operations: [],
|
|
983
969
|
providedInvariants: []
|
|
984
970
|
},
|
|
985
971
|
displayOps: [],
|
|
986
|
-
destinationContract:
|
|
987
|
-
strategy: "
|
|
988
|
-
migrationEdges: [
|
|
972
|
+
destinationContract: space.contract(),
|
|
973
|
+
strategy: "declared-state",
|
|
974
|
+
migrationEdges: [buildFabricatedMigrationEdge({
|
|
989
975
|
currentMarkerStorageHash: liveMarker?.storageHash,
|
|
990
976
|
destinationStorageHash: targetHash,
|
|
991
977
|
operationCount: 0
|
|
@@ -1494,16 +1480,15 @@ var ControlClientImpl = class {
|
|
|
1494
1480
|
});
|
|
1495
1481
|
try {
|
|
1496
1482
|
const stack = this.stack;
|
|
1497
|
-
const extensionInputs = toExtensionInputs(blindCast(stack.extensionPacks));
|
|
1498
|
-
const composedExtensionContracts = new Map(extensionInputs.filter((p) => p.contractSpace !== void 0).map((p) => [p.id, blindCast(p.contractSpace.contractJson)]));
|
|
1499
1483
|
const sourceContext = {
|
|
1500
1484
|
composedExtensionPacks: stack.extensionPacks.map((p) => p.id),
|
|
1501
|
-
composedExtensionContracts,
|
|
1485
|
+
composedExtensionContracts: stack.extensionContracts,
|
|
1502
1486
|
scalarTypeDescriptors: stack.scalarTypeDescriptors,
|
|
1503
1487
|
authoringContributions: stack.authoringContributions,
|
|
1504
1488
|
codecLookup: stack.codecLookup,
|
|
1505
1489
|
controlMutationDefaults: stack.controlMutationDefaults,
|
|
1506
|
-
resolvedInputs: contractConfig.source.inputs ?? []
|
|
1490
|
+
resolvedInputs: contractConfig.source.inputs ?? [],
|
|
1491
|
+
capabilities: stack.capabilities
|
|
1507
1492
|
};
|
|
1508
1493
|
const providerResult = await contractConfig.source.load(sourceContext);
|
|
1509
1494
|
if (!providerResult.ok) {
|
|
@@ -1558,9 +1543,10 @@ var ControlClientImpl = class {
|
|
|
1558
1543
|
});
|
|
1559
1544
|
try {
|
|
1560
1545
|
const enrichedIR = enrichContract(contractRaw, this.frameworkComponents ?? []);
|
|
1546
|
+
const rawContractJson = this.options.target.contractSerializer.serializeContract(enrichedIR);
|
|
1561
1547
|
let deserializedContract;
|
|
1562
1548
|
try {
|
|
1563
|
-
deserializedContract = this.familyInstance.deserializeContract(
|
|
1549
|
+
deserializedContract = this.familyInstance.deserializeContract(rawContractJson);
|
|
1564
1550
|
} catch (error) {
|
|
1565
1551
|
onProgress?.({
|
|
1566
1552
|
action: "emit",
|
|
@@ -1606,6 +1592,6 @@ var ControlClientImpl = class {
|
|
|
1606
1592
|
}
|
|
1607
1593
|
};
|
|
1608
1594
|
//#endregion
|
|
1609
|
-
export { executeDbInit as a, executeDbUpdate as i,
|
|
1595
|
+
export { executeDbInit as a, executeDbUpdate as i, planSpacePath as n, ContractValidationError as o, executeDbVerify as r, createControlClient as t };
|
|
1610
1596
|
|
|
1611
|
-
//# sourceMappingURL=client-
|
|
1597
|
+
//# sourceMappingURL=client-DigVI8zX.mjs.map
|