@prisma-next/cli 0.5.0-dev.74 → 0.5.0-dev.76
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-0ZX24FXF.mjs → client-qVH-rEgd.mjs} +433 -236
- package/dist/client-qVH-rEgd.mjs.map +1 -0
- package/dist/{result-handler-DWb1rFS-.mjs → command-helpers-BeZHkxV8.mjs} +22 -24
- package/dist/command-helpers-BeZHkxV8.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.d.mts.map +1 -1
- package/dist/commands/db-init.mjs +7 -5
- package/dist/commands/db-init.mjs.map +1 -1
- package/dist/commands/db-schema.mjs +5 -4
- package/dist/commands/db-schema.mjs.map +1 -1
- package/dist/commands/db-sign.mjs +6 -5
- 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 +7 -5
- package/dist/commands/db-update.mjs.map +1 -1
- package/dist/commands/db-verify.mjs +1 -1
- package/dist/commands/migration-apply.d.mts +29 -17
- package/dist/commands/migration-apply.d.mts.map +1 -1
- package/dist/commands/migration-apply.mjs +35 -129
- package/dist/commands/migration-apply.mjs.map +1 -1
- package/dist/commands/migration-new.mjs +4 -3
- package/dist/commands/migration-new.mjs.map +1 -1
- package/dist/commands/migration-plan.d.mts +19 -1
- package/dist/commands/migration-plan.d.mts.map +1 -1
- package/dist/commands/migration-plan.mjs +2 -2
- package/dist/commands/migration-ref.d.mts +1 -1
- package/dist/commands/migration-ref.mjs +3 -2
- package/dist/commands/migration-ref.mjs.map +1 -1
- package/dist/commands/migration-show.d.mts +1 -1
- package/dist/commands/migration-show.mjs +5 -4
- package/dist/commands/migration-show.mjs.map +1 -1
- package/dist/commands/migration-status.d.mts +104 -1
- package/dist/commands/migration-status.d.mts.map +1 -1
- package/dist/commands/migration-status.mjs +2 -2
- package/dist/{contract-emit-DkMqO7f2.mjs → contract-emit-9DBda5Ou.mjs} +7 -5
- package/dist/{contract-emit-DkMqO7f2.mjs.map → contract-emit-9DBda5Ou.mjs.map} +1 -1
- package/dist/{contract-emit-B3ChISB_.mjs → contract-emit-B77TsJqf.mjs} +4 -15
- package/dist/{contract-emit-B3ChISB_.mjs.map → contract-emit-B77TsJqf.mjs.map} +1 -1
- package/dist/{contract-enrichment-CF6ogEJ_.mjs → contract-enrichment-Dani0mMW.mjs} +1 -1
- package/dist/{contract-enrichment-CF6ogEJ_.mjs.map → contract-enrichment-Dani0mMW.mjs.map} +1 -1
- package/dist/{contract-infer-BDKAE0B0.mjs → contract-infer-BK9YFGEG.mjs} +5 -4
- package/dist/{contract-infer-BDKAE0B0.mjs.map → contract-infer-BK9YFGEG.mjs.map} +1 -1
- package/dist/{db-verify-B4TdDKOI.mjs → db-verify-C0y1PCO2.mjs} +7 -6
- package/dist/{db-verify-B4TdDKOI.mjs.map → db-verify-C0y1PCO2.mjs.map} +1 -1
- package/dist/exports/control-api.d.mts +3 -746
- package/dist/exports/control-api.d.mts.map +1 -1
- package/dist/exports/control-api.mjs +3 -3
- package/dist/exports/index.mjs +1 -1
- package/dist/exports/init-output.mjs +1 -1
- package/dist/extension-pack-inputs-C7xgE-vv.mjs +74 -0
- package/dist/extension-pack-inputs-C7xgE-vv.mjs.map +1 -0
- package/dist/{framework-components-gwAHl7ml.mjs → framework-components-ChqVUxR-.mjs} +1 -1
- package/dist/{framework-components-gwAHl7ml.mjs.map → framework-components-ChqVUxR-.mjs.map} +1 -1
- package/dist/global-flags-Icqpxk23.d.mts +12 -0
- package/dist/global-flags-Icqpxk23.d.mts.map +1 -0
- package/dist/helpers-eqdN8tH6.mjs +25 -0
- package/dist/helpers-eqdN8tH6.mjs.map +1 -0
- package/dist/{init-Deo7U8_U.mjs → init-CoDVPvQ4.mjs} +4 -4
- package/dist/{init-Deo7U8_U.mjs.map → init-CoDVPvQ4.mjs.map} +1 -1
- package/dist/{inspect-live-schema-BAgQMYpD.mjs → inspect-live-schema-CWYxGKlb.mjs} +4 -4
- package/dist/{inspect-live-schema-BAgQMYpD.mjs.map → inspect-live-schema-CWYxGKlb.mjs.map} +1 -1
- package/dist/{migration-command-scaffold-B8J702Uh.mjs → migration-command-scaffold-B5dORFEv.mjs} +4 -4
- package/dist/{migration-command-scaffold-B8J702Uh.mjs.map → migration-command-scaffold-B5dORFEv.mjs.map} +1 -1
- package/dist/{migration-plan-BcKNnTM7.mjs → migration-plan-C6lVaHsO.mjs} +47 -23
- package/dist/migration-plan-C6lVaHsO.mjs.map +1 -0
- package/dist/{migration-status-CjwB2of-.mjs → migration-status-CZ-D5k7k.mjs} +161 -7
- package/dist/migration-status-CZ-D5k7k.mjs.map +1 -0
- package/dist/{migrations-CIK94AJf.mjs → migrations-D_UJnpuW.mjs} +67 -24
- package/dist/migrations-D_UJnpuW.mjs.map +1 -0
- package/dist/{output-DnjfCC_u.mjs → output-B16Kefzx.mjs} +1 -1
- package/dist/{output-DnjfCC_u.mjs.map → output-B16Kefzx.mjs.map} +1 -1
- package/dist/{progress-adapter-xASh41wr.mjs → progress-adapter-DFfvZcYL.mjs} +1 -1
- package/dist/{progress-adapter-xASh41wr.mjs.map → progress-adapter-DFfvZcYL.mjs.map} +1 -1
- package/dist/result-handler-rmPVKIP2.mjs +25 -0
- package/dist/result-handler-rmPVKIP2.mjs.map +1 -0
- package/dist/rolldown-runtime-twds-ZHy.mjs +14 -0
- package/dist/{terminal-ui-zaRDhJnP.mjs → terminal-ui-C_hFNbAn.mjs} +3 -23
- package/dist/terminal-ui-C_hFNbAn.mjs.map +1 -0
- package/dist/types-D7x-IFLO.d.mts +858 -0
- package/dist/types-D7x-IFLO.d.mts.map +1 -0
- package/dist/{verify-BEIa9638.mjs → verify-CiwNWM9N.mjs} +2 -2
- package/dist/{verify-BEIa9638.mjs.map → verify-CiwNWM9N.mjs.map} +1 -1
- package/package.json +14 -14
- package/src/commands/db-init.ts +1 -0
- package/src/commands/db-update.ts +1 -0
- package/src/commands/migration-apply.ts +94 -213
- package/src/commands/migration-plan.ts +89 -32
- package/src/commands/migration-status.ts +288 -5
- package/src/control-api/client.ts +16 -4
- package/src/control-api/operations/apply-aggregate.ts +290 -0
- package/src/control-api/operations/db-apply-aggregate.ts +42 -91
- package/src/control-api/operations/migration-apply.ts +420 -155
- package/src/control-api/types.ts +165 -32
- package/src/utils/contract-space-aggregate-loader.ts +24 -56
- package/src/utils/extension-pack-inputs.ts +170 -0
- package/src/utils/formatters/migrations.ts +135 -35
- package/dist/client-0ZX24FXF.mjs.map +0 -1
- package/dist/migration-plan-BcKNnTM7.mjs.map +0 -1
- package/dist/migration-status-CjwB2of-.mjs.map +0 -1
- package/dist/migrations-CIK94AJf.mjs.map +0 -1
- package/dist/result-handler-DWb1rFS-.mjs.map +0 -1
- package/dist/terminal-ui-zaRDhJnP.mjs.map +0 -1
- /package/dist/{cli-errors-QH8kf-C2.d.mts → cli-errors-B9OBbled.d.mts} +0 -0
|
@@ -6,29 +6,24 @@ import type {
|
|
|
6
6
|
ControlFamilyInstance,
|
|
7
7
|
MigrationOperationPolicy,
|
|
8
8
|
MigrationPlanOperation,
|
|
9
|
-
MultiSpaceCapableRunner,
|
|
10
|
-
MultiSpaceRunnerPerSpaceOptions,
|
|
11
9
|
OperationPreview,
|
|
12
10
|
TargetMigrationsCapability,
|
|
13
11
|
} from '@prisma-next/framework-components/control';
|
|
12
|
+
import { hasOperationPreview } from '@prisma-next/framework-components/control';
|
|
14
13
|
import {
|
|
15
|
-
hasMultiSpaceRunner,
|
|
16
|
-
hasOperationPreview,
|
|
17
|
-
} from '@prisma-next/framework-components/control';
|
|
18
|
-
import {
|
|
19
|
-
type AggregatePerSpacePlan,
|
|
20
14
|
type AggregatePlannerError,
|
|
21
15
|
type ContractSpaceAggregate,
|
|
22
16
|
planAggregate,
|
|
23
17
|
} from '@prisma-next/migration-tools/aggregate';
|
|
24
18
|
import { ifDefined } from '@prisma-next/utils/defined';
|
|
25
19
|
import { notOk, ok } from '@prisma-next/utils/result';
|
|
26
|
-
import { CliStructuredError
|
|
20
|
+
import { CliStructuredError } from '../../utils/cli-errors';
|
|
27
21
|
import {
|
|
28
22
|
type BuildAggregateInputs,
|
|
29
23
|
buildContractSpaceAggregate,
|
|
30
24
|
} from '../../utils/contract-space-aggregate-loader';
|
|
31
25
|
import type {
|
|
26
|
+
AggregatePerSpaceExecutionEntry,
|
|
32
27
|
DbInitFailure,
|
|
33
28
|
DbInitResult,
|
|
34
29
|
DbInitSuccess,
|
|
@@ -37,17 +32,19 @@ import type {
|
|
|
37
32
|
DbUpdateSuccess,
|
|
38
33
|
OnControlProgress,
|
|
39
34
|
} from '../types';
|
|
35
|
+
import { applyAggregate, buildPerSpaceBreakdown, collectOrdered } from './apply-aggregate';
|
|
40
36
|
import { stripOperations } from './migration-helpers';
|
|
41
37
|
|
|
42
38
|
/**
|
|
43
39
|
* Span IDs emitted via `onProgress` during the aggregate apply flow.
|
|
44
40
|
* Stable identifiers consumed by the structured-output renderer and by
|
|
45
|
-
* tests asserting on span ids.
|
|
41
|
+
* tests asserting on span ids. The `apply` span itself is owned by
|
|
42
|
+
* the {@link applyAggregate} primitive — only the introspect / plan
|
|
43
|
+
* spans are emitted directly here.
|
|
46
44
|
*/
|
|
47
45
|
const SPAN_IDS = {
|
|
48
46
|
introspect: 'introspect',
|
|
49
47
|
plan: 'plan',
|
|
50
|
-
apply: 'apply',
|
|
51
48
|
} as const;
|
|
52
49
|
|
|
53
50
|
/**
|
|
@@ -193,90 +190,58 @@ export async function executeAggregateApply<TFamilyId extends string, TTargetId
|
|
|
193
190
|
const preview = hasOperationPreview(familyInstance)
|
|
194
191
|
? familyInstance.toOperationPreview(aggregateOps)
|
|
195
192
|
: undefined;
|
|
193
|
+
const perSpace = buildPerSpaceBreakdown(orderedResolutions, aggregate.app.spaceId, {
|
|
194
|
+
includeMarkers: false,
|
|
195
|
+
});
|
|
196
196
|
const summary = `Planned ${aggregateOps.length} operation(s) across ${orderedResolutions.length} space(s)`;
|
|
197
197
|
return wrapPlanResult({
|
|
198
198
|
operations: aggregateOps,
|
|
199
199
|
destination: appPlan.destination,
|
|
200
200
|
preview,
|
|
201
|
+
perSpace,
|
|
201
202
|
summary,
|
|
202
203
|
});
|
|
203
204
|
}
|
|
204
205
|
|
|
205
|
-
// 5. Apply mode:
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
206
|
+
// 5. Apply mode: hand off to the shared `applyAggregate` primitive.
|
|
207
|
+
// The runner-driving tail is identical for `db init` / `db update` /
|
|
208
|
+
// `migration apply` — only how each caller produces `perSpacePlans`
|
|
209
|
+
// differs (synth + graph-walk via planAggregate here; graph-walk
|
|
210
|
+
// only for migration apply). See M6 sub-spec § Required changes 1.
|
|
211
|
+
const applied = await applyAggregate({
|
|
212
|
+
aggregate,
|
|
213
|
+
perSpacePlans: planResult.value.perSpace,
|
|
214
|
+
applyOrder: planResult.value.applyOrder,
|
|
215
|
+
driver,
|
|
216
|
+
familyInstance,
|
|
217
|
+
migrations,
|
|
218
|
+
frameworkComponents,
|
|
219
|
+
policy,
|
|
217
220
|
action,
|
|
218
|
-
|
|
219
|
-
spanId: SPAN_IDS.apply,
|
|
220
|
-
label: 'Applying migration plan across spaces',
|
|
221
|
+
...ifDefined('onProgress', onProgress),
|
|
221
222
|
});
|
|
222
|
-
|
|
223
|
-
const perSpaceOptions: MultiSpaceRunnerPerSpaceOptions<TFamilyId, TTargetId>[] =
|
|
224
|
-
orderedResolutions.map((r) => ({
|
|
225
|
-
space: r.spaceId,
|
|
226
|
-
plan: r.entry.plan,
|
|
227
|
-
driver,
|
|
228
|
-
destinationContract: r.entry.destinationContract,
|
|
229
|
-
policy,
|
|
230
|
-
executionChecks: { prechecks: false, postchecks: false, idempotencyChecks: false },
|
|
231
|
-
frameworkComponents,
|
|
232
|
-
// Per-space post-apply schema verification is non-strict: each
|
|
233
|
-
// space's `destinationContract` describes only its own slice; a
|
|
234
|
-
// strict verifier would treat every other space's tables as
|
|
235
|
-
// `extras`. Tolerant mode still catches missing tables / columns.
|
|
236
|
-
// SQL family runners read `strictVerification` via structural
|
|
237
|
-
// typing.
|
|
238
|
-
strictVerification: false,
|
|
239
|
-
})) as MultiSpaceRunnerPerSpaceOptions<TFamilyId, TTargetId>[];
|
|
240
|
-
|
|
241
|
-
const runnerResult = await (
|
|
242
|
-
runner as MultiSpaceCapableRunner<TFamilyId, TTargetId>
|
|
243
|
-
).executeAcrossSpaces({ driver, perSpaceOptions });
|
|
244
|
-
|
|
245
|
-
if (!runnerResult.ok) {
|
|
246
|
-
onProgress?.({ action, kind: 'spanEnd', spanId: SPAN_IDS.apply, outcome: 'error' });
|
|
223
|
+
if (!applied.ok) {
|
|
247
224
|
return buildRunnerFailure({
|
|
248
|
-
summary:
|
|
249
|
-
...ifDefined('why',
|
|
250
|
-
meta:
|
|
251
|
-
...(runnerResult.failure.meta ?? {}),
|
|
252
|
-
failingSpace: runnerResult.failure.failingSpace,
|
|
253
|
-
},
|
|
225
|
+
summary: applied.failure.summary,
|
|
226
|
+
...ifDefined('why', applied.failure.why),
|
|
227
|
+
meta: applied.failure.meta,
|
|
254
228
|
});
|
|
255
229
|
}
|
|
256
|
-
onProgress?.({ action, kind: 'spanEnd', spanId: SPAN_IDS.apply, outcome: 'ok' });
|
|
257
|
-
|
|
258
|
-
const totalOpsPlanned = runnerResult.value.perSpaceResults.reduce(
|
|
259
|
-
(sum, r) => sum + r.value.operationsPlanned,
|
|
260
|
-
0,
|
|
261
|
-
);
|
|
262
|
-
const totalOpsExecuted = runnerResult.value.perSpaceResults.reduce(
|
|
263
|
-
(sum, r) => sum + r.value.operationsExecuted,
|
|
264
|
-
0,
|
|
265
|
-
);
|
|
266
230
|
|
|
267
|
-
const aggregateOps = orderedResolutions.flatMap((r) => r.entry.displayOps);
|
|
231
|
+
const aggregateOps = applied.value.orderedResolutions.flatMap((r) => r.entry.displayOps);
|
|
268
232
|
const summary =
|
|
269
233
|
action === 'dbInit'
|
|
270
|
-
? `Applied ${totalOpsExecuted} operation(s) across ${orderedResolutions.length} space(s), database signed`
|
|
271
|
-
: totalOpsExecuted === 0
|
|
272
|
-
? `Database already matches contract across ${orderedResolutions.length} space(s), signature updated`
|
|
273
|
-
: `Applied ${totalOpsExecuted} operation(s) across ${orderedResolutions.length} space(s), signature updated`;
|
|
234
|
+
? `Applied ${applied.value.totalOpsExecuted} operation(s) across ${applied.value.orderedResolutions.length} space(s), database signed`
|
|
235
|
+
: applied.value.totalOpsExecuted === 0
|
|
236
|
+
? `Database already matches contract across ${applied.value.orderedResolutions.length} space(s), signature updated`
|
|
237
|
+
: `Applied ${applied.value.totalOpsExecuted} operation(s) across ${applied.value.orderedResolutions.length} space(s), signature updated`;
|
|
274
238
|
|
|
275
239
|
return wrapApplyResult({
|
|
276
240
|
operations: aggregateOps,
|
|
277
241
|
destination: appPlan.destination,
|
|
278
|
-
operationsPlanned: totalOpsPlanned,
|
|
279
|
-
operationsExecuted: totalOpsExecuted,
|
|
242
|
+
operationsPlanned: applied.value.totalOpsPlanned,
|
|
243
|
+
operationsExecuted: applied.value.totalOpsExecuted,
|
|
244
|
+
perSpace: applied.value.perSpace,
|
|
280
245
|
summary,
|
|
281
246
|
});
|
|
282
247
|
}
|
|
@@ -330,24 +295,6 @@ function detectOrphanMarkers(
|
|
|
330
295
|
});
|
|
331
296
|
}
|
|
332
297
|
|
|
333
|
-
interface OrderedResolution {
|
|
334
|
-
readonly spaceId: string;
|
|
335
|
-
readonly entry: AggregatePerSpacePlan;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
function collectOrdered(
|
|
339
|
-
applyOrder: readonly string[],
|
|
340
|
-
perSpace: ReadonlyMap<string, AggregatePerSpacePlan>,
|
|
341
|
-
): readonly OrderedResolution[] {
|
|
342
|
-
return applyOrder.map((spaceId) => {
|
|
343
|
-
const entry = perSpace.get(spaceId);
|
|
344
|
-
if (!entry) {
|
|
345
|
-
throw new Error(`Aggregate planner output missing per-space plan for "${spaceId}"`);
|
|
346
|
-
}
|
|
347
|
-
return { spaceId, entry };
|
|
348
|
-
});
|
|
349
|
-
}
|
|
350
|
-
|
|
351
298
|
function mapPlannerError(error: AggregatePlannerError): DbInitResult | DbUpdateResult {
|
|
352
299
|
if (error.kind === 'appSynthFailure') {
|
|
353
300
|
const failure: DbInitFailure | DbUpdateFailure = {
|
|
@@ -387,6 +334,7 @@ function wrapPlanResult(args: {
|
|
|
387
334
|
readonly operations: readonly MigrationPlanOperation[];
|
|
388
335
|
readonly destination: { readonly storageHash: string; readonly profileHash?: string };
|
|
389
336
|
readonly preview: OperationPreview | undefined;
|
|
337
|
+
readonly perSpace: readonly AggregatePerSpaceExecutionEntry[];
|
|
390
338
|
readonly summary: string;
|
|
391
339
|
}): DbInitResult | DbUpdateResult {
|
|
392
340
|
const success: DbInitSuccess | DbUpdateSuccess = {
|
|
@@ -399,6 +347,7 @@ function wrapPlanResult(args: {
|
|
|
399
347
|
storageHash: args.destination.storageHash,
|
|
400
348
|
...ifDefined('profileHash', args.destination.profileHash),
|
|
401
349
|
},
|
|
350
|
+
perSpace: args.perSpace,
|
|
402
351
|
summary: args.summary,
|
|
403
352
|
};
|
|
404
353
|
return ok(success);
|
|
@@ -409,6 +358,7 @@ function wrapApplyResult(args: {
|
|
|
409
358
|
readonly destination: { readonly storageHash: string; readonly profileHash?: string };
|
|
410
359
|
readonly operationsPlanned: number;
|
|
411
360
|
readonly operationsExecuted: number;
|
|
361
|
+
readonly perSpace: readonly AggregatePerSpaceExecutionEntry[];
|
|
412
362
|
readonly summary: string;
|
|
413
363
|
}): DbInitResult | DbUpdateResult {
|
|
414
364
|
const success: DbInitSuccess | DbUpdateSuccess = {
|
|
@@ -425,6 +375,7 @@ function wrapApplyResult(args: {
|
|
|
425
375
|
marker: args.destination.profileHash
|
|
426
376
|
? { storageHash: args.destination.storageHash, profileHash: args.destination.profileHash }
|
|
427
377
|
: { storageHash: args.destination.storageHash },
|
|
378
|
+
perSpace: args.perSpace,
|
|
428
379
|
summary: args.summary,
|
|
429
380
|
};
|
|
430
381
|
return ok(success);
|