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,15 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as assertFrameworkComponentsCompatible } from "./framework-components-
|
|
3
|
-
import { t as enrichContract } from "./contract-enrichment-
|
|
4
|
-
import {
|
|
1
|
+
import { A as CliStructuredError } from "./command-helpers-Bbw1GbwL.mjs";
|
|
2
|
+
import { t as assertFrameworkComponentsCompatible } from "./framework-components-fYXjz_in.mjs";
|
|
3
|
+
import { t as enrichContract } from "./contract-enrichment-a0V5Y_mL.mjs";
|
|
4
|
+
import { n as buildContractSpaceAggregate } from "./contract-space-aggregate-loader-DvZwdkrr.mjs";
|
|
5
5
|
import { emit } from "@prisma-next/emitter";
|
|
6
6
|
import { ifDefined } from "@prisma-next/utils/defined";
|
|
7
7
|
import { notOk, ok } from "@prisma-next/utils/result";
|
|
8
|
-
import { APP_SPACE_ID, createControlStack, hasMigrations,
|
|
9
|
-
import {
|
|
10
|
-
import { graphWalkStrategy, planAggregate, verifyAggregate } from "@prisma-next/migration-tools/aggregate";
|
|
8
|
+
import { APP_SPACE_ID, createControlStack, hasMigrations, hasOperationPreview, hasPslContractInfer, hasSchemaView } from "@prisma-next/framework-components/control";
|
|
9
|
+
import { graphWalkStrategy, planMigration, requireHeadRef, verifyMigration } from "@prisma-next/migration-tools/aggregate";
|
|
11
10
|
import { EMPTY_CONTRACT_HASH } from "@prisma-next/migration-tools/constants";
|
|
12
11
|
import { errorNoInvariantPath } from "@prisma-next/migration-tools/errors";
|
|
12
|
+
import { castAs } from "@prisma-next/utils/casts";
|
|
13
|
+
import { findPathWithDecision } from "@prisma-next/migration-tools/migration-graph";
|
|
13
14
|
//#region src/control-api/errors.ts
|
|
14
15
|
var ContractValidationError = class extends Error {
|
|
15
16
|
cause;
|
|
@@ -20,33 +21,32 @@ var ContractValidationError = class extends Error {
|
|
|
20
21
|
}
|
|
21
22
|
};
|
|
22
23
|
//#endregion
|
|
23
|
-
//#region src/control-api/operations/apply
|
|
24
|
+
//#region src/control-api/operations/apply.ts
|
|
24
25
|
/**
|
|
25
26
|
* Span id emitted via `onProgress` for the apply phase. Stable
|
|
26
27
|
* identifier consumed by the structured-output renderer and by tests.
|
|
27
28
|
*/
|
|
28
29
|
const APPLY_SPAN_ID = "apply";
|
|
29
30
|
/**
|
|
30
|
-
* Runner-driving tail shared by every
|
|
31
|
+
* Runner-driving tail shared by every apply caller — `db init`,
|
|
31
32
|
* `db update`, and `migrate`. Consumes already-resolved per-space
|
|
32
33
|
* plans (the planner-vs-replay distinction is owned by the caller) and
|
|
33
|
-
* dispatches them to the
|
|
34
|
+
* dispatches them to the runner in canonical order.
|
|
34
35
|
*
|
|
35
36
|
* Marker advancement is part of the runner's per-space transaction
|
|
36
37
|
* (the SQL family runner writes the marker as the last step of each
|
|
37
38
|
* space's transaction), so this primitive does not advance markers
|
|
38
|
-
* separately — by the time `
|
|
39
|
+
* separately — by the time `execute` returns ok, every
|
|
39
40
|
* space's marker has been advanced to its plan's destination.
|
|
40
41
|
*
|
|
41
42
|
* Span emission (`spanStart 'apply'` / `spanEnd 'apply'`) is owned here
|
|
42
43
|
* so callers don't have to duplicate it; the `action` field on each
|
|
43
44
|
* progress event is taken from the caller's `action` argument.
|
|
44
45
|
*/
|
|
45
|
-
async function
|
|
46
|
+
async function applyMigration(inputs) {
|
|
46
47
|
const { aggregate, perSpacePlans, applyOrder, driver, familyInstance, migrations, frameworkComponents, policy, action, onProgress } = inputs;
|
|
47
48
|
const orderedResolutions = collectOrdered(applyOrder, perSpacePlans);
|
|
48
49
|
const runner = migrations.createRunner(familyInstance);
|
|
49
|
-
if (!hasMultiSpaceRunner(runner)) throw errorRunnerFailed(`Runner for target "${aggregate.targetId}" does not implement \`executeAcrossSpaces\``, { why: `${labelForAction(action)} requires multi-space-capable runners (today: every SQL family runner).` });
|
|
50
50
|
onProgress?.({
|
|
51
51
|
action,
|
|
52
52
|
kind: "spanStart",
|
|
@@ -62,7 +62,7 @@ async function applyAggregate(inputs) {
|
|
|
62
62
|
frameworkComponents,
|
|
63
63
|
strictVerification: false
|
|
64
64
|
}));
|
|
65
|
-
const runnerResult = await runner.
|
|
65
|
+
const runnerResult = await runner.execute({
|
|
66
66
|
driver,
|
|
67
67
|
perSpaceOptions
|
|
68
68
|
});
|
|
@@ -98,14 +98,14 @@ async function applyAggregate(inputs) {
|
|
|
98
98
|
}
|
|
99
99
|
/**
|
|
100
100
|
* Project the planner's per-space resolutions into the
|
|
101
|
-
* `
|
|
101
|
+
* `PerSpaceExecutionEntry[]` shape the CLI surfaces.
|
|
102
102
|
*
|
|
103
103
|
* `includeMarkers` is `true` for apply-mode (each space's marker is
|
|
104
104
|
* the `destination.storageHash` of its plan, which the runner
|
|
105
105
|
* advances as the last step of each space's transaction) and `false`
|
|
106
106
|
* for plan-mode (no marker has been written yet).
|
|
107
107
|
*
|
|
108
|
-
* Exported alongside {@link
|
|
108
|
+
* Exported alongside {@link applyMigration} so plan-mode callers can
|
|
109
109
|
* assemble the same per-space block without going through the runner.
|
|
110
110
|
*/
|
|
111
111
|
function buildPerSpaceBreakdown(orderedResolutions, appSpaceId, options) {
|
|
@@ -138,7 +138,7 @@ function buildPerSpaceBreakdown(orderedResolutions, appSpaceId, options) {
|
|
|
138
138
|
function collectOrdered(applyOrder, perSpace) {
|
|
139
139
|
return applyOrder.map((spaceId) => {
|
|
140
140
|
const entry = perSpace.get(spaceId);
|
|
141
|
-
if (!entry) throw new Error(`
|
|
141
|
+
if (!entry) throw new Error(`planner output missing per-space plan for "${spaceId}"`);
|
|
142
142
|
return {
|
|
143
143
|
spaceId,
|
|
144
144
|
entry
|
|
@@ -147,7 +147,7 @@ function collectOrdered(applyOrder, perSpace) {
|
|
|
147
147
|
}
|
|
148
148
|
/**
|
|
149
149
|
* Action-appropriate label for the `spanStart` event the apply
|
|
150
|
-
* primitive emits. `
|
|
150
|
+
* primitive emits. `applyMigration` is shared by `db init`, `db update`,
|
|
151
151
|
* and `migrate`; the span label tracks the user-visible action
|
|
152
152
|
* so structured-progress output reads naturally for each surface.
|
|
153
153
|
*/
|
|
@@ -158,13 +158,6 @@ function progressLabelForAction(action) {
|
|
|
158
158
|
case "migrationApply": return "Applying migration plan across spaces";
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
|
-
function labelForAction(action) {
|
|
162
|
-
switch (action) {
|
|
163
|
-
case "dbInit": return "db init";
|
|
164
|
-
case "dbUpdate": return "db update";
|
|
165
|
-
case "migrationApply": return "migrate";
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
161
|
//#endregion
|
|
169
162
|
//#region src/control-api/operations/migration-helpers.ts
|
|
170
163
|
/**
|
|
@@ -179,12 +172,12 @@ function stripOperations(operations) {
|
|
|
179
172
|
}));
|
|
180
173
|
}
|
|
181
174
|
//#endregion
|
|
182
|
-
//#region src/control-api/operations/db-apply
|
|
175
|
+
//#region src/control-api/operations/db-apply.ts
|
|
183
176
|
/**
|
|
184
|
-
* Span IDs emitted via `onProgress` during the
|
|
177
|
+
* Span IDs emitted via `onProgress` during the apply flow.
|
|
185
178
|
* Stable identifiers consumed by the structured-output renderer and by
|
|
186
179
|
* tests asserting on span ids. The `apply` span itself is owned by
|
|
187
|
-
* the {@link
|
|
180
|
+
* the {@link applyMigration} primitive — only the introspect / plan
|
|
188
181
|
* spans are emitted directly here.
|
|
189
182
|
*/
|
|
190
183
|
const SPAN_IDS$1 = {
|
|
@@ -201,16 +194,16 @@ const SPAN_IDS$1 = {
|
|
|
201
194
|
* integrity violation short-circuits with a structured error.
|
|
202
195
|
* 2. **Read DB state**: marker rows (`familyInstance.readAllMarkers`)
|
|
203
196
|
* + introspected schema (`familyInstance.introspect`).
|
|
204
|
-
* 3. **Plan**: {@link
|
|
197
|
+
* 3. **Plan**: {@link planMigration} chooses graph-walk vs synth per
|
|
205
198
|
* member according to `callerPolicy.ignoreGraphFor`. The app member
|
|
206
199
|
* is forced through synth (today's daily-driver behaviour); every
|
|
207
200
|
* extension member walks its on-disk graph.
|
|
208
201
|
* 4. **Apply** (when `mode === 'apply'`): every per-space `MigrationPlan`
|
|
209
|
-
* feeds into the runner's `
|
|
202
|
+
* feeds into the runner's `execute` — one outer
|
|
210
203
|
* transaction across every space; failure on any space rolls back
|
|
211
204
|
* every space's writes.
|
|
212
205
|
*/
|
|
213
|
-
async function
|
|
206
|
+
async function executeApply(options) {
|
|
214
207
|
const { driver, familyInstance, contract, mode, migrations, frameworkComponents, migrationsDir, extensionPacks, targetId, policy, action, onProgress } = options;
|
|
215
208
|
const loaded = await buildContractSpaceAggregate({
|
|
216
209
|
targetId,
|
|
@@ -245,7 +238,7 @@ async function executeAggregateApply(options) {
|
|
|
245
238
|
spanId: SPAN_IDS$1.plan,
|
|
246
239
|
label: "Planning migration"
|
|
247
240
|
});
|
|
248
|
-
const planResult = await
|
|
241
|
+
const planResult = await planMigration({
|
|
249
242
|
aggregate,
|
|
250
243
|
currentDBState: {
|
|
251
244
|
markersBySpaceId: markerRows,
|
|
@@ -289,7 +282,7 @@ async function executeAggregateApply(options) {
|
|
|
289
282
|
summary
|
|
290
283
|
});
|
|
291
284
|
}
|
|
292
|
-
const applied = await
|
|
285
|
+
const applied = await applyMigration({
|
|
293
286
|
aggregate,
|
|
294
287
|
perSpacePlans: planResult.value.perSpace,
|
|
295
288
|
applyOrder: planResult.value.applyOrder,
|
|
@@ -432,7 +425,7 @@ function buildRunnerFailure(args) {
|
|
|
432
425
|
* changes belong to `db update`.
|
|
433
426
|
*/
|
|
434
427
|
async function executeDbInit(options) {
|
|
435
|
-
return await
|
|
428
|
+
return await executeApply({
|
|
436
429
|
driver: options.driver,
|
|
437
430
|
familyInstance: options.familyInstance,
|
|
438
431
|
contract: options.contract,
|
|
@@ -481,7 +474,7 @@ async function executeDbUpdate(options) {
|
|
|
481
474
|
const gate = await guardDestructiveChanges(sharedInputs);
|
|
482
475
|
if (gate !== null) return gate;
|
|
483
476
|
}
|
|
484
|
-
return await
|
|
477
|
+
return await executeApply({
|
|
485
478
|
...sharedInputs,
|
|
486
479
|
mode: options.mode
|
|
487
480
|
});
|
|
@@ -494,7 +487,7 @@ async function executeDbUpdate(options) {
|
|
|
494
487
|
* run.
|
|
495
488
|
*/
|
|
496
489
|
async function guardDestructiveChanges(sharedInputs) {
|
|
497
|
-
const planResult = await
|
|
490
|
+
const planResult = await executeApply({
|
|
498
491
|
...sharedInputs,
|
|
499
492
|
mode: "plan"
|
|
500
493
|
});
|
|
@@ -533,7 +526,7 @@ const SPAN_IDS = {
|
|
|
533
526
|
* structured CLI error.
|
|
534
527
|
* 2. **Read DB state**: marker rows + (when `skipSchema` is `false`)
|
|
535
528
|
* schema introspection.
|
|
536
|
-
* 3. **Verify**: {@link
|
|
529
|
+
* 3. **Verify**: {@link verifyMigration} returns per-space
|
|
537
530
|
* `markerCheck` + per-space pre-projected `schemaCheck` (closes F23).
|
|
538
531
|
* Marker mismatches map to `CliStructuredError` (code `5002`) so
|
|
539
532
|
* callers (CLI command) can render and exit. Schema results are
|
|
@@ -552,7 +545,7 @@ async function executeDbVerify(options) {
|
|
|
552
545
|
});
|
|
553
546
|
emitVerifySpan(onProgress, "spanStart");
|
|
554
547
|
return finaliseVerifyResult({
|
|
555
|
-
verifyResult:
|
|
548
|
+
verifyResult: verifyMigration({
|
|
556
549
|
aggregate,
|
|
557
550
|
markersBySpaceId,
|
|
558
551
|
schemaIntrospection,
|
|
@@ -611,7 +604,7 @@ function createPerMemberVerifier(options) {
|
|
|
611
604
|
return (projectedSchema, member, verifyMode) => {
|
|
612
605
|
if (skipSchema) return buildSkippedSchemaResult(member);
|
|
613
606
|
return familyInstance.verifySchema({
|
|
614
|
-
contract: member.contract,
|
|
607
|
+
contract: member.contract(),
|
|
615
608
|
schema: projectedSchema,
|
|
616
609
|
strict: verifyMode === "strict",
|
|
617
610
|
frameworkComponents
|
|
@@ -636,7 +629,7 @@ function emitVerifySpan(onProgress, kind) {
|
|
|
636
629
|
});
|
|
637
630
|
}
|
|
638
631
|
/**
|
|
639
|
-
* Map an {@link
|
|
632
|
+
* Map an {@link VerifierOutput} to the operation's
|
|
640
633
|
* {@link ExecuteDbVerifyResult}, applying the `skipMarker` policy used
|
|
641
634
|
* by the CLI's `--schema-only` mode.
|
|
642
635
|
*/
|
|
@@ -664,15 +657,17 @@ function finaliseVerifyResult(args) {
|
|
|
664
657
|
});
|
|
665
658
|
}
|
|
666
659
|
function buildSkippedSchemaResult(member) {
|
|
667
|
-
const
|
|
660
|
+
const contract = member.contract();
|
|
661
|
+
const headRef = requireHeadRef(member);
|
|
662
|
+
const profileHash = castAs(contract).profileHash;
|
|
668
663
|
return {
|
|
669
664
|
ok: true,
|
|
670
665
|
summary: "Schema verification skipped",
|
|
671
666
|
contract: {
|
|
672
|
-
storageHash:
|
|
667
|
+
storageHash: headRef.hash,
|
|
673
668
|
...profileHash ? { profileHash } : {}
|
|
674
669
|
},
|
|
675
|
-
target: { expected:
|
|
670
|
+
target: { expected: contract.target },
|
|
676
671
|
schema: {
|
|
677
672
|
issues: [],
|
|
678
673
|
root: {
|
|
@@ -750,7 +745,7 @@ function mapMarkerCheckFailures(appSpaceId, section) {
|
|
|
750
745
|
* marker to `member.headRef.hash` (or `refHash` for the app
|
|
751
746
|
* member when provided). Empty-graph members fail loudly — a
|
|
752
747
|
* "never planned" space is a user-error condition for replay.
|
|
753
|
-
* 4. Hand off to {@link
|
|
748
|
+
* 4. Hand off to {@link applyMigration} (the runner-driving tail
|
|
754
749
|
* shared with `db init` / `db update`). Marker advancement is
|
|
755
750
|
* inside the per-space transaction.
|
|
756
751
|
*
|
|
@@ -758,14 +753,13 @@ function mapMarkerCheckFailures(appSpaceId, section) {
|
|
|
758
753
|
* authored migration graph on disk before this operation can advance it.
|
|
759
754
|
*/
|
|
760
755
|
async function executeMigrationApply(options) {
|
|
761
|
-
const { driver, familyInstance, contract, migrations, frameworkComponents, migrationsDir, extensionPacks, targetId,
|
|
756
|
+
const { driver, familyInstance, contract, migrations, frameworkComponents, migrationsDir, extensionPacks, targetId, refHash, refInvariants, refName, onProgress } = options;
|
|
762
757
|
const loaded = await buildContractSpaceAggregate({
|
|
763
758
|
targetId,
|
|
764
759
|
migrationsDir,
|
|
765
760
|
appContract: contract,
|
|
766
761
|
extensionPacks,
|
|
767
|
-
deserializeContract: (json) => familyInstance.deserializeContract(json)
|
|
768
|
-
appMigrationPackages
|
|
762
|
+
deserializeContract: (json) => familyInstance.deserializeContract(json)
|
|
769
763
|
});
|
|
770
764
|
if (!loaded.ok) throw loaded.failure;
|
|
771
765
|
const aggregate = loaded.value;
|
|
@@ -775,9 +769,10 @@ async function executeMigrationApply(options) {
|
|
|
775
769
|
const atHeadResolutions = /* @__PURE__ */ new Map();
|
|
776
770
|
for (const member of allMembers) {
|
|
777
771
|
const isAppMember = member.spaceId === aggregate.app.spaceId;
|
|
778
|
-
const
|
|
772
|
+
const headRef = requireHeadRef(member);
|
|
773
|
+
const targetHash = isAppMember && refHash !== void 0 ? refHash : headRef.hash;
|
|
779
774
|
const liveMarker = markerRows.get(member.spaceId) ?? null;
|
|
780
|
-
if (member.
|
|
775
|
+
if (member.graph().nodes.size === 0) {
|
|
781
776
|
const liveHash = liveMarker?.storageHash;
|
|
782
777
|
if (targetHash === liveHash || liveHash === void 0 && targetHash === EMPTY_CONTRACT_HASH) {
|
|
783
778
|
atHeadResolutions.set(member.spaceId, buildAtHeadResolution({
|
|
@@ -790,8 +785,8 @@ async function executeMigrationApply(options) {
|
|
|
790
785
|
}
|
|
791
786
|
return notOk(buildNeverPlannedFailure(member.spaceId, targetHash));
|
|
792
787
|
}
|
|
793
|
-
const targetInvariants = isAppMember && refHash !== void 0 && refInvariants !== void 0 ? refInvariants :
|
|
794
|
-
const targetMember = targetHash ===
|
|
788
|
+
const targetInvariants = isAppMember && refHash !== void 0 && refInvariants !== void 0 ? refInvariants : headRef.invariants;
|
|
789
|
+
const targetMember = targetHash === headRef.hash && targetInvariants === headRef.invariants ? member : {
|
|
795
790
|
...member,
|
|
796
791
|
headRef: {
|
|
797
792
|
hash: targetHash,
|
|
@@ -807,7 +802,7 @@ async function executeMigrationApply(options) {
|
|
|
807
802
|
if (walked.kind === "unreachable") return notOk(buildPathNotFoundFailure(member.spaceId, liveMarker, targetHash));
|
|
808
803
|
if (walked.kind === "unsatisfiable") {
|
|
809
804
|
const fromHash = liveMarker?.storageHash ?? EMPTY_CONTRACT_HASH;
|
|
810
|
-
const structural = findPathWithDecision(targetMember.
|
|
805
|
+
const structural = findPathWithDecision(targetMember.graph(), fromHash, targetHash, { required: /* @__PURE__ */ new Set() });
|
|
811
806
|
const structuralPath = structural.kind === "ok" ? structural.decision.selectedPath.map((edge) => ({
|
|
812
807
|
dirName: edge.dirName,
|
|
813
808
|
migrationHash: edge.migrationHash,
|
|
@@ -845,7 +840,7 @@ async function executeMigrationApply(options) {
|
|
|
845
840
|
summary: totalSpaces === 0 ? "Already up to date — no contract spaces are loaded" : totalSpaces === 1 ? "Already up to date" : `Already up to date across ${totalSpaces} space(s)`
|
|
846
841
|
}));
|
|
847
842
|
}
|
|
848
|
-
const applied = await
|
|
843
|
+
const applied = await applyMigration({
|
|
849
844
|
aggregate,
|
|
850
845
|
perSpacePlans,
|
|
851
846
|
applyOrder,
|
|
@@ -891,7 +886,7 @@ async function executeMigrationApply(options) {
|
|
|
891
886
|
}));
|
|
892
887
|
}
|
|
893
888
|
/**
|
|
894
|
-
* Build a zero-op {@link
|
|
889
|
+
* Build a zero-op {@link PerSpacePlan} for an empty-graph
|
|
895
890
|
* member whose live marker already matches the target. Lets the apply
|
|
896
891
|
* pipeline thread the member through `perSpacePlans` -> `applyOrder`
|
|
897
892
|
* -> the success envelope's `perSpace[]` block so the result reflects
|
|
@@ -909,7 +904,7 @@ function buildAtHeadResolution(args) {
|
|
|
909
904
|
providedInvariants: []
|
|
910
905
|
},
|
|
911
906
|
displayOps: [],
|
|
912
|
-
destinationContract: member.contract,
|
|
907
|
+
destinationContract: member.contract(),
|
|
913
908
|
strategy: "graph-walk",
|
|
914
909
|
migrationEdges: []
|
|
915
910
|
};
|
|
@@ -925,7 +920,7 @@ function sumPlannedOps(applyOrder, perSpacePlans) {
|
|
|
925
920
|
}
|
|
926
921
|
function buildSuccess(args) {
|
|
927
922
|
const appResolution = args.orderedResolutions.find((r) => r.spaceId === args.aggregate.app.spaceId);
|
|
928
|
-
const appMarkerHash = appResolution?.entry.plan.destination.storageHash ?? args.aggregate.app.
|
|
923
|
+
const appMarkerHash = appResolution?.entry.plan.destination.storageHash ?? requireHeadRef(args.aggregate.app).hash;
|
|
929
924
|
const applied = args.orderedResolutions.flatMap((r) => {
|
|
930
925
|
return (r.entry.migrationEdges ?? []).map((edge) => ({
|
|
931
926
|
spaceId: r.spaceId,
|
|
@@ -962,11 +957,19 @@ function buildSuccess(args) {
|
|
|
962
957
|
...pathDecision !== void 0 ? { pathDecision } : {}
|
|
963
958
|
};
|
|
964
959
|
}
|
|
960
|
+
/**
|
|
961
|
+
* Build the `neverPlanned` failure raised when a contract space has no on-disk
|
|
962
|
+
* migration graph but migrate was asked to reach a target hash. The `why`
|
|
963
|
+
* states only the condition; the recovery sequence is composed by
|
|
964
|
+
* `errorPathUnreachable`'s `fix`.
|
|
965
|
+
*
|
|
966
|
+
* @internal Exported for testing only.
|
|
967
|
+
*/
|
|
965
968
|
function buildNeverPlannedFailure(spaceId, targetHash) {
|
|
966
969
|
return {
|
|
967
970
|
code: "MIGRATION_PATH_NOT_FOUND",
|
|
968
971
|
summary: `No on-disk migrations for contract space "${spaceId}"`,
|
|
969
|
-
why: `migrate is replay-only: every contract space must have an authored migration graph on disk. Space "${spaceId}" has no migrations under \`migrations/${spaceId}/\` but its head ref targets "${targetHash}"
|
|
972
|
+
why: `migrate is replay-only: every contract space must have an authored migration graph on disk. Space "${spaceId}" has no migrations under \`migrations/${spaceId}/\` but its head ref targets "${targetHash}".`,
|
|
970
973
|
meta: {
|
|
971
974
|
spaceId,
|
|
972
975
|
target: targetHash,
|
|
@@ -974,12 +977,22 @@ function buildNeverPlannedFailure(spaceId, targetHash) {
|
|
|
974
977
|
}
|
|
975
978
|
};
|
|
976
979
|
}
|
|
980
|
+
/**
|
|
981
|
+
* Build the `pathUnreachable` failure raised when an emitted contract has no
|
|
982
|
+
* on-disk migration edge from the current marker to the target. The `why`
|
|
983
|
+
* states only the condition (no edge between the two named states, and migrate
|
|
984
|
+
* replays edges rather than inventing them); the recovery sequence — plan the
|
|
985
|
+
* edge, then re-apply — is composed by `errorPathUnreachable`'s `fix`, so the
|
|
986
|
+
* two read as one non-redundant plan-then-apply story.
|
|
987
|
+
*
|
|
988
|
+
* @internal Exported for testing only.
|
|
989
|
+
*/
|
|
977
990
|
function buildPathNotFoundFailure(spaceId, marker, targetHash) {
|
|
978
991
|
const fromHash = marker?.storageHash ?? "<empty>";
|
|
979
992
|
return {
|
|
980
993
|
code: "MIGRATION_PATH_NOT_FOUND",
|
|
981
994
|
summary: spaceId === "app" ? "Current contract has no planned migration path" : `Current contract has no planned migration path for contract space "${spaceId}"`,
|
|
982
|
-
why: `
|
|
995
|
+
why: `No migration edge connects the current state "${fromHash}" to the target "${targetHash}" in contract space "${spaceId}". The on-disk migration graph does not join the two, and migrate replays existing edges — it never invents one.`,
|
|
983
996
|
meta: {
|
|
984
997
|
spaceId,
|
|
985
998
|
fromHash,
|
|
@@ -1309,7 +1322,6 @@ var ControlClientImpl = class {
|
|
|
1309
1322
|
migrationsDir: options.migrationsDir,
|
|
1310
1323
|
extensionPacks: this.options.extensionPacks ?? [],
|
|
1311
1324
|
targetId: this.options.target.targetId,
|
|
1312
|
-
appMigrationPackages: options.appMigrationPackages,
|
|
1313
1325
|
...ifDefined("refHash", options.refHash),
|
|
1314
1326
|
...ifDefined("refInvariants", options.refInvariants),
|
|
1315
1327
|
...ifDefined("refName", options.refName),
|
|
@@ -1481,4 +1493,4 @@ var ControlClientImpl = class {
|
|
|
1481
1493
|
//#endregion
|
|
1482
1494
|
export { ContractValidationError as a, executeDbInit as i, executeDbVerify as n, executeDbUpdate as r, createControlClient as t };
|
|
1483
1495
|
|
|
1484
|
-
//# sourceMappingURL=client-
|
|
1496
|
+
//# sourceMappingURL=client-KgJorIvG.mjs.map
|