@prisma/orm-toolchain 8.0.0-rc.14-dev.35 → 8.0.0-rc.14-dev.36

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.
Files changed (38) hide show
  1. package/dist/{aggregate-C_e9y2vI.d.mts → aggregate-5NMLDtcl.d.mts} +7 -5
  2. package/dist/aggregate-5NMLDtcl.d.mts.map +1 -0
  3. package/dist/{aggregate-By_e1Dsq.mjs → aggregate-qXuJ6w_I.mjs} +11 -8
  4. package/dist/aggregate-qXuJ6w_I.mjs.map +1 -0
  5. package/dist/{caught-errors-DnAEn1BF-QuHW5lCN.mjs → caught-errors-DUIDd-Vm-RNMiEz4x.mjs} +35 -3
  6. package/dist/caught-errors-DUIDd-Vm-RNMiEz4x.mjs.map +1 -0
  7. package/dist/cli.mjs +266 -141
  8. package/dist/cli.mjs.map +1 -1
  9. package/dist/cli__control-api.d.mts +4 -4
  10. package/dist/cli__control-api.mjs +3 -3
  11. package/dist/cli__control-api__testing.d.mts +3 -3
  12. package/dist/cli__control-api__testing.d.mts.map +1 -1
  13. package/dist/cli__control-api__testing.mjs +11 -14
  14. package/dist/cli__control-api__testing.mjs.map +1 -1
  15. package/dist/cli__migration-cli.mjs +1 -1
  16. package/dist/cli__migration-cli.mjs.map +1 -1
  17. package/dist/{db-verify-DoVihHM8-BrpF-Rnr.d.mts → db-sign-BxYV7wMQ-BB1hlVbH.d.mts} +115 -96
  18. package/dist/db-sign-BxYV7wMQ-BB1hlVbH.d.mts.map +1 -0
  19. package/dist/{import-roots-BB3GzIi-.mjs → import-roots-BeAYfehL.mjs} +2 -2
  20. package/dist/{import-roots-BB3GzIi-.mjs.map → import-roots-BeAYfehL.mjs.map} +1 -1
  21. package/dist/migration-tools.d.mts +2 -2
  22. package/dist/migration-tools.mjs +2 -2
  23. package/dist/migration-tools__aggregate.d.mts +2 -2
  24. package/dist/migration-tools__aggregate.mjs +2 -2
  25. package/dist/publish-surface.mjs +2 -2
  26. package/dist/publish-surface__import-roots.mjs +1 -1
  27. package/dist/publish-surface__shells.mjs +1 -1
  28. package/dist/{ref-DMcFtzRN-B1ralPE1.mjs → ref-Bcy3ShDD-S7NKefbN.mjs} +221 -136
  29. package/dist/ref-Bcy3ShDD-S7NKefbN.mjs.map +1 -0
  30. package/dist/{shells-nviMkCdc.mjs → shells-D8mbojP8.mjs} +2 -1
  31. package/dist/{shells-nviMkCdc.mjs.map → shells-D8mbojP8.mjs.map} +1 -1
  32. package/dist/vite-plugin-contract-emit.mjs +1 -1
  33. package/package.json +12 -12
  34. package/dist/aggregate-By_e1Dsq.mjs.map +0 -1
  35. package/dist/aggregate-C_e9y2vI.d.mts.map +0 -1
  36. package/dist/caught-errors-DnAEn1BF-QuHW5lCN.mjs.map +0 -1
  37. package/dist/db-verify-DoVihHM8-BrpF-Rnr.d.mts.map +0 -1
  38. package/dist/ref-DMcFtzRN-B1ralPE1.mjs.map +0 -1
@@ -8,12 +8,12 @@ import { t as EMPTY_CONTRACT_HASH } from "./constants-CM-w38DQ-Cz_EXbOc.mjs";
8
8
  import { i as findPathWithDecision, r as findPath } from "./migration-graph-BoiiZAaU-DLht12k7.mjs";
9
9
  import { a as isValidSpaceId, c as spaceMigrationDirectory, l as spaceRefsDirectory, o as listContractSpaceDirectories, s as readContractSpaceHeadRef, t as APP_SPACE_ID$1 } from "./verify-contract-spaces-CYjc343k-FXABEJZE.mjs";
10
10
  import { i as emitContractSpaceArtifacts, o as planAllSpaces } from "./spaces-CzLQQYa9.mjs";
11
- import { A as errorRefSetBundleNotFound, B as getTargetMigrations, D as errorPathUnreachable, F as errorSnapshotMissing, G as requireLiveDatabase, I as errorSpaceNotFound, J as runCommandAction, K as resolveContractPath, L as errorTargetMigrationNotSupported, M as errorRefSetHashNotInGraph, O as errorPlanForgotTheFlag, P as errorRuntime, S as errorMarkerMismatch, T as errorMigrationPlanningFailed, U as readContractEnvelope, V as mapRefResolutionError, X as toStructuralEdge, _ as errorFileNotFound, a as closeQuietly, b as errorInvalidSpaceId, c as errorAmbiguousMigrationRef, f as errorContractConfigMissing, h as errorDestructiveChanges, i as chooseAction, j as errorRefSetEmptySentinel, k as errorPlanOriginUnknown, l as errorConfigValidation$1, m as errorDatabaseConnectionRequired, n as CliStructuredError$1, o as collectDeclaredInvariants, p as errorContractValidationFailed, q as resolveMigrationPaths, u as errorConsentPlanMismatch, v as errorFromCaught, z as errorUnexpected } from "./caught-errors-DnAEn1BF-QuHW5lCN.mjs";
11
+ import { A as errorRefSetBundleNotFound, B as errorUnexpected, D as errorPathUnreachable, H as mapRefResolutionError, I as errorSnapshotMissing, J as resolveMigrationPaths, K as requireLiveDatabase, L as errorSpaceNotFound, M as errorRefSetHashNotInGraph, O as errorPlanForgotTheFlag, P as errorRuntime, R as errorTargetMigrationNotSupported, S as errorMarkerMismatch, T as errorMigrationPlanningFailed, V as getTargetMigrations, W as readContractEnvelope, Y as runCommandAction, Z as toStructuralEdge, _ as errorFileNotFound, a as closeQuietly, b as errorInvalidSpaceId, c as errorAmbiguousMigrationRef, f as errorContractConfigMissing, h as errorDestructiveChanges, i as chooseAction, j as errorRefSetEmptySentinel, k as errorPlanOriginUnknown, l as errorConfigValidation$1, m as errorDatabaseConnectionRequired, n as CliStructuredError$1, o as collectDeclaredInvariants, p as errorContractValidationFailed, q as resolveContractPath, u as errorConsentPlanMismatch, v as errorFromCaught } from "./caught-errors-DUIDd-Vm-RNMiEz4x.mjs";
12
12
  import { r as getEmittedArtifactPaths, t as emit } from "./exports-B41NJHCo-BaEu3TXy.mjs";
13
13
  import { n as isGraphNode, t as assertHashIsGraphNode } from "./graph-membership-BQ43lP4A-i4Ov419-.mjs";
14
14
  import { d as writeRef, i as readRefs, l as validateRefName, n as deleteRef, o as refsByContractHash, t as HEAD_REF_NAME, u as validateRefValue } from "./refs-qwvw4_dV-X8sR92eT.mjs";
15
- import { d as resolveRecordedPath, f as verifyMigration, l as planMigration, n as buildFabricatedMigrationEdge, r as collectAggregateNamespaces, s as loadContractSpaceAggregate, t as allStorageElementsExternal, u as requireHeadRef } from "./aggregate-By_e1Dsq.mjs";
16
- import { c as internalImportRoot, o as importRootForDependencies, r as createImportSpecifierResolver, t as ImportRootError } from "./import-roots-BB3GzIi-.mjs";
15
+ import { d as resolveRecordedPath, f as spacesInApplyOrder, l as planMigration, n as buildFabricatedMigrationEdge, p as verifyMigration, r as collectAggregateNamespaces, s as loadContractSpaceAggregate, t as allStorageElementsExternal, u as requireHeadRef } from "./aggregate-qXuJ6w_I.mjs";
16
+ import { c as internalImportRoot, o as importRootForDependencies, r as createImportSpecifierResolver, t as ImportRootError } from "./import-roots-BeAYfehL.mjs";
17
17
  import { n as parseContractRef, r as parseMigrationRef } from "./ref-resolution-CoHoeFT7.mjs";
18
18
  import { i as writeMigrationTs } from "./migration-ts-BQuIba9e.mjs";
19
19
  import { createRequire } from "node:module";
@@ -33,7 +33,7 @@ import { notOk, ok } from "@prisma/orm-framework/utils/result";
33
33
  import { mergeCapabilityMatrices } from "@prisma/orm-framework/components/components";
34
34
  import { abortable } from "@prisma/orm-framework/utils/abortable";
35
35
  import { resolve as resolve$1 } from "node:path";
36
- //#region ../../../1-framework/3-tooling/cli/dist/ref-DMcFtzRN.mjs
36
+ //#region ../../../1-framework/3-tooling/cli/dist/ref-Bcy3ShDD.mjs
37
37
  /**
38
38
  * Asserts that all framework components are compatible with the expected family and target.
39
39
  *
@@ -118,6 +118,15 @@ function sortDeep(value) {
118
118
  function sortDeepTyped(value) {
119
119
  return sortDeep(value);
120
120
  }
121
+ /**
122
+ * The keys of a pack's `types` metadata that a contract carries. Any other key stays out of the contract, such as the `storage` list that a pack built for an earlier framework still declares.
123
+ */
124
+ const CONTRACT_TYPES_KEYS = /* @__PURE__ */ new Set([
125
+ "aggregateDescriptors",
126
+ "codecTypes",
127
+ "operationTypes",
128
+ "queryOperationTypes"
129
+ ]);
121
130
  function extractExtensionPackMeta(component) {
122
131
  const { kind, id, version, capabilities, types } = component;
123
132
  const base = {
@@ -128,13 +137,16 @@ function extractExtensionPackMeta(component) {
128
137
  version
129
138
  };
130
139
  if (capabilities) base["capabilities"] = capabilities;
131
- if (types) if (types.codecTypes) {
132
- const { controlPlaneHooks: _, codecDescriptors: _cd, ...cleanedCodecTypes } = types.codecTypes;
133
- base["types"] = {
134
- ...types,
135
- codecTypes: cleanedCodecTypes
136
- };
137
- } else base["types"] = types;
140
+ if (types) {
141
+ const carried = Object.fromEntries(Object.entries(types).filter(([key]) => CONTRACT_TYPES_KEYS.has(key)));
142
+ if (types.codecTypes) {
143
+ const { controlPlaneHooks: _, codecDescriptors: _cd, ...cleanedCodecTypes } = types.codecTypes;
144
+ base["types"] = {
145
+ ...carried,
146
+ codecTypes: cleanedCodecTypes
147
+ };
148
+ } else base["types"] = carried;
149
+ }
138
150
  return base;
139
151
  }
140
152
  /**
@@ -910,82 +922,6 @@ async function executeDbInit(options) {
910
922
  ...ifDefined("onProgress", options.onProgress)
911
923
  });
912
924
  }
913
- const DB_UPDATE_POLICY = { allowedOperationClasses: [
914
- "additive",
915
- "widening",
916
- "destructive"
917
- ] };
918
- /**
919
- * Execute `db update` against the configured contract.
920
- *
921
- * Routes through the loader → planner → runner pipeline. Destructive
922
- * operations require either `acceptDataLoss: true` or a prior
923
- * `mode: 'plan'` invocation that surfaces the destructive ops; the
924
- * confirmation gate is implemented here so the lower-level applier
925
- * remains policy-agnostic.
926
- */
927
- async function executeDbUpdate(options) {
928
- const sharedInputs = {
929
- driver: options.driver,
930
- adapter: options.adapter,
931
- familyInstance: options.familyInstance,
932
- contract: options.contract,
933
- migrations: options.migrations,
934
- frameworkComponents: options.frameworkComponents,
935
- migrationsDir: options.migrationsDir,
936
- targetId: options.targetId,
937
- extensions: options.extensions ?? [],
938
- policy: DB_UPDATE_POLICY,
939
- action: "dbUpdate",
940
- ...ifDefined("verifySnapshotContent", options.verifySnapshotContent),
941
- ...ifDefined("onProgress", options.onProgress)
942
- };
943
- if (options.mode === "apply" && !options.acceptDataLoss && options.consent === void 0) {
944
- const refusal = await guardDestructiveChanges(sharedInputs);
945
- if (refusal !== null) return refusal;
946
- }
947
- return await executeRun({
948
- ...sharedInputs,
949
- mode: options.mode,
950
- ...ifDefined("consentedPlanHash", options.consent?.planHash)
951
- });
952
- }
953
- /**
954
- * Pre-plan once when running `db update apply` without `acceptDataLoss`.
955
- * Surfaces destructive operations across every space; if any are
956
- * planned, returns a `DESTRUCTIVE_CHANGES` failure that the CLI shows
957
- * as a confirmation prompt. Returns `null` when the apply is safe to
958
- * run.
959
- */
960
- async function guardDestructiveChanges(sharedInputs) {
961
- const planResult = await executeRun({
962
- ...sharedInputs,
963
- mode: "plan"
964
- });
965
- if (!planResult.ok) return planResult;
966
- const destructiveOps = planResult.value.plan.operations.filter((op) => op.operationClass === "destructive").map((op) => ({
967
- id: op.id,
968
- label: op.label
969
- }));
970
- if (destructiveOps.length === 0) return null;
971
- const databaseName = await sharedInputs.driver.databaseName?.();
972
- return notOk({
973
- code: "DESTRUCTIVE_CHANGES",
974
- summary: `Planned ${destructiveOps.length} destructive operation(s) that require confirmation`,
975
- why: "Destructive operations require explicit consent, which the caller has not given",
976
- conflicts: void 0,
977
- meta: void 0,
978
- destructiveChanges: {
979
- destructiveOperations: destructiveOps,
980
- databaseName,
981
- planHash: computePlanHash({
982
- operations: planResult.value.plan.operations,
983
- destination: planResult.value.destination
984
- })
985
- },
986
- ...ifDefined("warnings", planResult.value.warnings)
987
- });
988
- }
989
925
  /**
990
926
  * Span IDs emitted via `onProgress` during the aggregate verify flow.
991
927
  * Mirrors the span identifiers used by the legacy precheck / marker-check
@@ -1018,6 +954,7 @@ async function executeDbVerify(options) {
1018
954
  const aggregate = loaded.value;
1019
955
  const markersBySpaceId = await familyInstance.readAllMarkers({ driver });
1020
956
  const schemaIntrospection = skipSchema ? null : await runIntrospection({
957
+ action: "dbVerify",
1021
958
  driver,
1022
959
  familyInstance,
1023
960
  onProgress,
@@ -1053,9 +990,9 @@ function buildLoadInputs(options) {
1053
990
  };
1054
991
  }
1055
992
  async function runIntrospection(args) {
1056
- const { driver, familyInstance, onProgress, contract } = args;
993
+ const { action, driver, familyInstance, onProgress, contract } = args;
1057
994
  onProgress?.({
1058
- action: "dbVerify",
995
+ action,
1059
996
  kind: "spanStart",
1060
997
  spanId: SPAN_IDS.introspect,
1061
998
  label: "Introspecting database schema"
@@ -1066,7 +1003,7 @@ async function runIntrospection(args) {
1066
1003
  contract
1067
1004
  });
1068
1005
  onProgress?.({
1069
- action: "dbVerify",
1006
+ action,
1070
1007
  kind: "spanEnd",
1071
1008
  spanId: SPAN_IDS.introspect,
1072
1009
  outcome: "ok"
@@ -1074,7 +1011,7 @@ async function runIntrospection(args) {
1074
1011
  return result;
1075
1012
  } catch (error) {
1076
1013
  onProgress?.({
1077
- action: "dbVerify",
1014
+ action,
1078
1015
  kind: "spanEnd",
1079
1016
  spanId: SPAN_IDS.introspect,
1080
1017
  outcome: "error"
@@ -1196,6 +1133,179 @@ function mapMarkerCheckFailures(appSpaceId, section, migrationsDir) {
1196
1133
  meta: { violations }
1197
1134
  });
1198
1135
  }
1136
+ /**
1137
+ * Loads the contract-space aggregate and signs it with {@link signContractSpaces}.
1138
+ */
1139
+ async function executeDbSign(options) {
1140
+ const { familyInstance } = options;
1141
+ const loaded = await buildContractSpaceAggregate({
1142
+ targetId: options.targetId,
1143
+ migrationsDir: options.migrationsDir,
1144
+ appContract: options.contract,
1145
+ extensions: options.extensions,
1146
+ deserializeContract: (json) => familyInstance.deserializeContract(json),
1147
+ ...ifDefined("verifySnapshotContent", options.verifySnapshotContent)
1148
+ });
1149
+ if (!loaded.ok) return notOk(loaded.failure);
1150
+ return signContractSpaces({
1151
+ driver: options.driver,
1152
+ familyInstance,
1153
+ aggregate: loaded.value,
1154
+ frameworkComponents: options.frameworkComponents,
1155
+ ...ifDefined("onProgress", options.onProgress)
1156
+ });
1157
+ }
1158
+ function markerHashes(marker) {
1159
+ return marker === void 0 ? null : {
1160
+ storageHash: marker.storageHash,
1161
+ profileHash: marker.profileHash
1162
+ };
1163
+ }
1164
+ /**
1165
+ * Reads every space's marker, verifies every contract space of the aggregate against the live schema without strict mode, then writes the marker of every space that verified in one call to the family, each only while it still holds the hashes read here. A space that fails verification is reported with its schema result and keeps its marker; a space whose marker another process wrote in the meantime is reported as a conflict and keeps that marker. The family gets the spaces in the order `migrate` applies them ({@link spacesInApplyOrder}).
1166
+ */
1167
+ async function signContractSpaces(options) {
1168
+ const { driver, familyInstance, aggregate, frameworkComponents, onProgress } = options;
1169
+ const markers = await familyInstance.readAllMarkers({ driver });
1170
+ const verified = verifyMigration({
1171
+ aggregate,
1172
+ markersBySpaceId: markers,
1173
+ schemaIntrospection: await runIntrospection({
1174
+ action: "dbSign",
1175
+ driver,
1176
+ familyInstance,
1177
+ onProgress,
1178
+ contract: collectAggregateNamespaces(aggregate)
1179
+ }),
1180
+ mode: "lenient",
1181
+ verifySchemaForSpace: (schema, space) => familyInstance.verifySchema({
1182
+ contract: space.contract(),
1183
+ schema,
1184
+ strict: false,
1185
+ frameworkComponents
1186
+ })
1187
+ });
1188
+ if (!verified.ok) return notOk(new CliStructuredError$1("MIGRATION.CONTRACT_SPACE_VIOLATION", "Aggregate verifier failed", {
1189
+ why: verified.failure.detail,
1190
+ fix: "Check database connectivity and the introspection tooling.",
1191
+ docsUrl: "https://pris.ly/contract-spaces"
1192
+ }));
1193
+ const schemaOf = (space) => {
1194
+ const schema = verified.value.schemaCheck.perSpace.get(space.spaceId);
1195
+ if (schema === void 0) throw new InternalError(`the aggregate verifier returned no schema result for contract space "${space.spaceId}"`);
1196
+ return schema;
1197
+ };
1198
+ const toSign = spacesInApplyOrder(aggregate).filter((space) => schemaOf(space).ok).map((space) => ({
1199
+ space: space.spaceId,
1200
+ contract: space.contract(),
1201
+ expected: markerHashes(markers.get(space.spaceId))
1202
+ }));
1203
+ onProgress?.({
1204
+ action: "dbSign",
1205
+ kind: "spanStart",
1206
+ spanId: "sign",
1207
+ label: "Signing database"
1208
+ });
1209
+ const signatures = await familyInstance.signSpaces({
1210
+ driver,
1211
+ spaces: toSign
1212
+ });
1213
+ onProgress?.({
1214
+ action: "dbSign",
1215
+ kind: "spanEnd",
1216
+ spanId: "sign",
1217
+ outcome: "ok"
1218
+ });
1219
+ const signatureOf = new Map(signatures.map((signature) => [signature.space, signature]));
1220
+ return ok({ spaces: [aggregate.app, ...aggregate.extensions].map((space) => {
1221
+ const contract = space.contract();
1222
+ return signatureOf.get(space.spaceId) ?? {
1223
+ space: space.spaceId,
1224
+ status: "failed",
1225
+ contract: {
1226
+ storageHash: contract.storage.storageHash,
1227
+ profileHash: contract.profileHash
1228
+ },
1229
+ schema: schemaOf(space)
1230
+ };
1231
+ }) });
1232
+ }
1233
+ const DB_UPDATE_POLICY = { allowedOperationClasses: [
1234
+ "additive",
1235
+ "widening",
1236
+ "destructive"
1237
+ ] };
1238
+ /**
1239
+ * Execute `db update` against the configured contract.
1240
+ *
1241
+ * Routes through the loader → planner → runner pipeline. Destructive
1242
+ * operations require either `acceptDataLoss: true` or a prior
1243
+ * `mode: 'plan'` invocation that surfaces the destructive ops; the
1244
+ * confirmation gate is implemented here so the lower-level applier
1245
+ * remains policy-agnostic.
1246
+ */
1247
+ async function executeDbUpdate(options) {
1248
+ const sharedInputs = {
1249
+ driver: options.driver,
1250
+ adapter: options.adapter,
1251
+ familyInstance: options.familyInstance,
1252
+ contract: options.contract,
1253
+ migrations: options.migrations,
1254
+ frameworkComponents: options.frameworkComponents,
1255
+ migrationsDir: options.migrationsDir,
1256
+ targetId: options.targetId,
1257
+ extensions: options.extensions ?? [],
1258
+ policy: DB_UPDATE_POLICY,
1259
+ action: "dbUpdate",
1260
+ ...ifDefined("verifySnapshotContent", options.verifySnapshotContent),
1261
+ ...ifDefined("onProgress", options.onProgress)
1262
+ };
1263
+ if (options.mode === "apply" && !options.acceptDataLoss && options.consent === void 0) {
1264
+ const refusal = await guardDestructiveChanges(sharedInputs);
1265
+ if (refusal !== null) return refusal;
1266
+ }
1267
+ return await executeRun({
1268
+ ...sharedInputs,
1269
+ mode: options.mode,
1270
+ ...ifDefined("consentedPlanHash", options.consent?.planHash)
1271
+ });
1272
+ }
1273
+ /**
1274
+ * Pre-plan once when running `db update apply` without `acceptDataLoss`.
1275
+ * Surfaces destructive operations across every space; if any are
1276
+ * planned, returns a `DESTRUCTIVE_CHANGES` failure that the CLI shows
1277
+ * as a confirmation prompt. Returns `null` when the apply is safe to
1278
+ * run.
1279
+ */
1280
+ async function guardDestructiveChanges(sharedInputs) {
1281
+ const planResult = await executeRun({
1282
+ ...sharedInputs,
1283
+ mode: "plan"
1284
+ });
1285
+ if (!planResult.ok) return planResult;
1286
+ const destructiveOps = planResult.value.plan.operations.filter((op) => op.operationClass === "destructive").map((op) => ({
1287
+ id: op.id,
1288
+ label: op.label
1289
+ }));
1290
+ if (destructiveOps.length === 0) return null;
1291
+ const databaseName = await sharedInputs.driver.databaseName?.();
1292
+ return notOk({
1293
+ code: "DESTRUCTIVE_CHANGES",
1294
+ summary: `Planned ${destructiveOps.length} destructive operation(s) that require confirmation`,
1295
+ why: "Destructive operations require explicit consent, which the caller has not given",
1296
+ conflicts: void 0,
1297
+ meta: void 0,
1298
+ destructiveChanges: {
1299
+ destructiveOperations: destructiveOps,
1300
+ databaseName,
1301
+ planHash: computePlanHash({
1302
+ operations: planResult.value.plan.operations,
1303
+ destination: planResult.value.destination
1304
+ })
1305
+ },
1306
+ ...ifDefined("warnings", planResult.value.warnings)
1307
+ });
1308
+ }
1199
1309
  function isRecord$2(value) {
1200
1310
  return typeof value === "object" && value !== null;
1201
1311
  }
@@ -1485,7 +1595,7 @@ async function executeMigrate(options) {
1485
1595
  }
1486
1596
  perSpacePlans.set(space.spaceId, outcome.plan);
1487
1597
  }
1488
- const canonicalOrder = [...aggregate.extensions.map((m) => m.spaceId), aggregate.app.spaceId];
1598
+ const canonicalOrder = spacesInApplyOrder(aggregate).map((space) => space.spaceId);
1489
1599
  const applyOrder = canonicalOrder.filter((spaceId) => perSpacePlans.has(spaceId));
1490
1600
  if (!applyOrder.some((spaceId) => {
1491
1601
  const entry = perSpacePlans.get(spaceId);
@@ -1969,46 +2079,6 @@ var ControlClientImpl = class {
1969
2079
  throw error;
1970
2080
  }
1971
2081
  }
1972
- async sign(options) {
1973
- const { onProgress } = options;
1974
- await this.connectWithProgress(options.connection, "sign", onProgress);
1975
- const { driver, familyInstance } = await this.ensureConnected();
1976
- let contract;
1977
- try {
1978
- contract = familyInstance.deserializeContract(options.contract);
1979
- } catch (error) {
1980
- throw structuredError("CONTRACT.VALIDATION_FAILED", error instanceof Error ? error.message : String(error), { cause: error });
1981
- }
1982
- onProgress?.({
1983
- action: "sign",
1984
- kind: "spanStart",
1985
- spanId: "sign",
1986
- label: "Signing database..."
1987
- });
1988
- try {
1989
- const result = await familyInstance.sign({
1990
- driver,
1991
- contract,
1992
- contractPath: options.contractPath ?? "",
1993
- ...ifDefined("configPath", options.configPath)
1994
- });
1995
- onProgress?.({
1996
- action: "sign",
1997
- kind: "spanEnd",
1998
- spanId: "sign",
1999
- outcome: "ok"
2000
- });
2001
- return result;
2002
- } catch (error) {
2003
- onProgress?.({
2004
- action: "sign",
2005
- kind: "spanEnd",
2006
- spanId: "sign",
2007
- outcome: "error"
2008
- });
2009
- throw error;
2010
- }
2011
- }
2012
2082
  async dbInit(options) {
2013
2083
  const { onProgress } = options;
2014
2084
  await this.connectWithProgress(options.connection, "dbInit", onProgress);
@@ -2084,6 +2154,22 @@ var ControlClientImpl = class {
2084
2154
  ...ifDefined("onProgress", onProgress)
2085
2155
  });
2086
2156
  }
2157
+ async dbSign(options) {
2158
+ const { onProgress } = options;
2159
+ await this.connectWithProgress(options.connection, "dbSign", onProgress);
2160
+ const { driver, familyInstance, frameworkComponents } = await this.ensureConnected();
2161
+ return executeDbSign({
2162
+ driver,
2163
+ familyInstance,
2164
+ contract: options.contract,
2165
+ migrationsDir: options.migrationsDir,
2166
+ targetId: this.options.target.targetId,
2167
+ extensions: this.options.extensions ?? [],
2168
+ frameworkComponents,
2169
+ ...ifDefined("verifySnapshotContent", this.snapshotVerifier),
2170
+ ...ifDefined("onProgress", onProgress)
2171
+ });
2172
+ }
2087
2173
  async readMarker() {
2088
2174
  const { driver, familyInstance } = await this.ensureConnected();
2089
2175
  return familyInstance.readMarker({
@@ -3060,9 +3146,8 @@ async function executeMigrateShowPlan(options) {
3060
3146
  await closeQuietly(client);
3061
3147
  }
3062
3148
  }
3063
- const canonicalOrderSpaces = [...aggregate.extensions, aggregate.app];
3064
3149
  const orderedMigrations = [];
3065
- for (const space of canonicalOrderSpaces) {
3150
+ for (const space of spacesInApplyOrder(aggregate)) {
3066
3151
  const isAppSpace = space.spaceId === aggregate.app.spaceId;
3067
3152
  const headRef = requireHeadRef(space);
3068
3153
  const outcome = planSpacePath({
@@ -4591,6 +4676,6 @@ async function executeRefListCommand(options) {
4591
4676
  }
4592
4677
  }
4593
4678
  //#endregion
4594
- export { resolveFromForPlan as $, hasMigrationPath as A, migrationSpaceListEntriesFromAggregate as B, executeMigrationPlanCommand as C, executeRefSetCommand as D, executeRefListCommand as E, loadContractSourceWithStack as F, refuseDeclaredExtensionTargetMismatch as G, preflightRefAdvancement as H, loadContractSpaceAggregateForCli as I, refusePackageCorruptionOnAggregate as J, refuseMarkerOutsideGraph as K, looksLikePath as L, loadAggregateIntegrityViolations as M, loadContractRawSafely as N, findPackageByDirPath as O, loadContractSource as P, resolveContractRefToSnapshot as Q, mapContractAtError as R, executeMigrationNewCommand as S, executeRefDeleteCommand as T, readMigrationRefs as U, originHashForStatus as V, refuseContractSpaceIntegrity as W, resolveAppTargetPath as X, refuseUnknownInvariants as Y, resolveContractRef$1 as Z, executeContractEmit as _, appliedHashesFromLedger as a, snapshotVerifierFor as at, executeDbVerify as b, buildReadAggregate as c, toDeclaredExtensionsFromRaw as ct, computeRefAdvancementName as d, resolveMigrationRef as et, createControlClient as f, enumerateCheckSpaces as g, enrichContract as h, appContractStandInFromIdentity as i, runMigrationList as it, listRefsByContractHash as j, formatSourceDiagnostic as k, buildRefAdvancementFields as l, validateLoadedContract as lt, disposeEmitQueue as m, NO_REF_ADVANCEMENT as n, runContractSpaceSeedPhase as nt, buildContractSpaceAggregate as o, sourceWarningDiagnostic as ot, deriveStatusEdgeAnnotations as p, refuseMissingInvariantPath as q, advanceRefSafely as r, runMigrationCheck as rt, buildMigrationSpaceGraphEntries as s, statusForMigrationHash as st, DB_UPDATE_POLICY as t, resolveToForPlan as tt, checkSingleTarget as u, executeDbInit as v, executeRefAdvancement as w, executeMigrateShowPlan as x, executeDbUpdate as y, mapIntegrityViolations as z };
4679
+ export { resolveContractRefToSnapshot as $, formatSourceDiagnostic as A, mapIntegrityViolations as B, executeMigrationNewCommand as C, executeRefListCommand as D, executeRefDeleteCommand as E, loadContractSource as F, refuseContractSpaceIntegrity as G, originHashForStatus as H, loadContractSourceWithStack as I, refuseMissingInvariantPath as J, refuseDeclaredExtensionTargetMismatch as K, loadContractSpaceAggregateForCli as L, listRefsByContractHash as M, loadAggregateIntegrityViolations as N, executeRefSetCommand as O, loadContractRawSafely as P, resolveContractRef$1 as Q, looksLikePath as R, executeMigrateShowPlan as S, executeRefAdvancement as T, preflightRefAdvancement as U, migrationSpaceListEntriesFromAggregate as V, readMigrationRefs as W, refuseUnknownInvariants as X, refusePackageCorruptionOnAggregate as Y, resolveAppTargetPath as Z, executeContractEmit as _, appliedHashesFromLedger as a, runMigrationList as at, executeDbUpdate as b, buildReadAggregate as c, statusForMigrationHash as ct, computeRefAdvancementName as d, resolveFromForPlan as et, createControlClient as f, enumerateCheckSpaces as g, enrichContract as h, appContractStandInFromIdentity as i, runMigrationCheck as it, hasMigrationPath as j, findPackageByDirPath as k, buildRefAdvancementFields as l, toDeclaredExtensionsFromRaw as lt, disposeEmitQueue as m, NO_REF_ADVANCEMENT as n, resolveToForPlan as nt, buildContractSpaceAggregate as o, snapshotVerifierFor as ot, deriveStatusEdgeAnnotations as p, refuseMarkerOutsideGraph as q, advanceRefSafely as r, runContractSpaceSeedPhase as rt, buildMigrationSpaceGraphEntries as s, sourceWarningDiagnostic as st, DB_UPDATE_POLICY as t, resolveMigrationRef as tt, checkSingleTarget as u, validateLoadedContract as ut, executeDbInit as v, executeMigrationPlanCommand as w, executeDbVerify as x, executeDbSign as y, mapContractAtError as z };
4595
4680
 
4596
- //# sourceMappingURL=ref-DMcFtzRN-B1ralPE1.mjs.map
4681
+ //# sourceMappingURL=ref-Bcy3ShDD-S7NKefbN.mjs.map