@prisma/orm-toolchain 8.0.0-rc.24-dev.43 → 8.0.0-rc.24-dev.44
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/{aggregate-D7dLfF9a.mjs → aggregate-B2D5REGs.mjs} +9 -9
- package/dist/{aggregate-D7dLfF9a.mjs.map → aggregate-B2D5REGs.mjs.map} +1 -1
- package/dist/{aggregate-BMh4SLep.d.mts → aggregate-CvDNKQbR.d.mts} +5 -5
- package/dist/{aggregate-BMh4SLep.d.mts.map → aggregate-CvDNKQbR.d.mts.map} +1 -1
- package/dist/{caught-errors-D8Hn_D5h-C4BJDZ5y.mjs → caught-errors-DZXnK8Ls-zVmM4nr3.mjs} +577 -49
- package/dist/caught-errors-DZXnK8Ls-zVmM4nr3.mjs.map +1 -0
- package/dist/cli-telemetry.mjs +1 -1
- package/dist/cli.d.mts +1 -1
- package/dist/cli.mjs +189 -70
- package/dist/cli.mjs.map +1 -1
- package/dist/cli__control-api.d.mts +12 -59
- package/dist/cli__control-api.d.mts.map +1 -1
- package/dist/cli__control-api.mjs +2 -2
- package/dist/cli__control-api__testing.d.mts +1 -1
- package/dist/cli__migration-cli.mjs +4 -4
- package/dist/cli__migration-cli.mjs.map +1 -1
- package/dist/config-loader.mjs +1 -1
- package/dist/contract-snapshot-store-D-s2aKZY.d.mts +2 -0
- package/dist/{contract-snapshot-store-DRAG5XXy-DOvf98Np.d.mts → contract-snapshot-store-DRAG5XXy-ChW4hBLb.d.mts} +2 -2
- package/dist/{contract-snapshot-store-DRAG5XXy-DOvf98Np.d.mts.map → contract-snapshot-store-DRAG5XXy-ChW4hBLb.d.mts.map} +1 -1
- package/dist/{contract-snapshot-store-Ds7lE7vL-Dn444yIq.mjs → contract-snapshot-store-Dl6v-Uxr-CwhnMsgc.mjs} +4 -4
- package/dist/{contract-snapshot-store-Ds7lE7vL-Dn444yIq.mjs.map → contract-snapshot-store-Dl6v-Uxr-CwhnMsgc.mjs.map} +1 -1
- package/dist/{db-sign-DLIR5swa-CMgFrBoH.d.mts → db-sign-BQMw6RX9-Stp7Gjj7.d.mts} +187 -18
- package/dist/db-sign-BQMw6RX9-Stp7Gjj7.d.mts.map +1 -0
- package/dist/{domain-type-generation-BGcbGgHJ-Cdw5RNaZ.mjs → domain-type-generation-BGcbGgHJ-SB6n89eE.mjs} +3 -3
- package/dist/{domain-type-generation-BGcbGgHJ-Cdw5RNaZ.mjs.map → domain-type-generation-BGcbGgHJ-SB6n89eE.mjs.map} +1 -1
- package/dist/emitter.mjs +2 -2
- package/dist/emitter__domain-type-generation.mjs +1 -1
- package/dist/{errors-BMq40nYH-Cg8PBect.mjs → errors-BlaB9AFz-CZDOC0mV.mjs} +8 -10
- package/dist/{errors-BMq40nYH-Cg8PBect.mjs.map → errors-BlaB9AFz-CZDOC0mV.mjs.map} +1 -1
- package/dist/{exports-BiXPktAF.mjs → exports-B0yFVod3.mjs} +3 -3
- package/dist/{exports-BiXPktAF.mjs.map → exports-B0yFVod3.mjs.map} +1 -1
- package/dist/{exports-CCuYD8dO-yw1GizAT.mjs → exports-CCuYD8dO-fFXwpizm.mjs} +3 -3
- package/dist/{exports-CCuYD8dO-yw1GizAT.mjs.map → exports-CCuYD8dO-fFXwpizm.mjs.map} +1 -1
- package/dist/{exports-CZ6dPu-O.mjs → exports-DNFYCa6U.mjs} +3 -3
- package/dist/{exports-CZ6dPu-O.mjs.map → exports-DNFYCa6U.mjs.map} +1 -1
- package/dist/{graph-membership-D7m41lWA-B68g1CRS.mjs → graph-membership-ClCmhVjf-8XCns4rf.mjs} +3 -3
- package/dist/{graph-membership-D7m41lWA-B68g1CRS.mjs.map → graph-membership-ClCmhVjf-8XCns4rf.mjs.map} +1 -1
- package/dist/hash-DcBt3lpO.d.mts +1 -0
- package/dist/{hash-DclMqd7S-WBvXJ_4C.d.mts → hash-DclMqd7S-Dddl_NeA.d.mts} +2 -2
- package/dist/{hash-DclMqd7S-WBvXJ_4C.d.mts.map → hash-DclMqd7S-Dddl_NeA.d.mts.map} +1 -1
- package/dist/{invariants-DxCj82g2-DhGkStla.mjs → invariants-c9W7-6DY-CzSdi8Vp.mjs} +3 -3
- package/dist/{invariants-DxCj82g2-DhGkStla.mjs.map → invariants-c9W7-6DY-CzSdi8Vp.mjs.map} +1 -1
- package/dist/io-BalYebmm.d.mts +1 -0
- package/dist/{io-D51jgF31-RTnIqw4C.mjs → io-DUsSXBRO-BqRNb69U.mjs} +5 -5
- package/dist/{io-D51jgF31-RTnIqw4C.mjs.map → io-DUsSXBRO-BqRNb69U.mjs.map} +1 -1
- package/dist/{io-DpAplMzQ-oLyfXvz-.d.mts → io-DpAplMzQ-ZTJi-tTr.d.mts} +2 -2
- package/dist/{io-DpAplMzQ-oLyfXvz-.d.mts.map → io-DpAplMzQ-ZTJi-tTr.d.mts.map} +1 -1
- package/dist/{migration-DTmtOJ0n.mjs → migration-C1l4_CWi.mjs} +3 -3
- package/dist/{migration-DTmtOJ0n.mjs.map → migration-C1l4_CWi.mjs.map} +1 -1
- package/dist/{migration-graph-BoiiZAaU-DLht12k7.mjs → migration-graph-DBJAol1y-DX61Ss3X.mjs} +19 -3
- package/dist/{migration-graph-BoiiZAaU-DLht12k7.mjs.map → migration-graph-DBJAol1y-DX61Ss3X.mjs.map} +1 -1
- package/dist/{migration-graph-D8IuOkZb-pSI7-k4_.d.mts → migration-graph-DCIdjMtC-CAs3pm1A.d.mts} +10 -3
- package/dist/{migration-graph-D8IuOkZb-pSI7-k4_.d.mts.map → migration-graph-DCIdjMtC-CAs3pm1A.d.mts.map} +1 -1
- package/dist/{migration-graph-Dra4CcyN.d.mts → migration-graph-GiSYbAc8.d.mts} +2 -2
- package/dist/{migration-graph-Dra4CcyN.d.mts.map → migration-graph-GiSYbAc8.d.mts.map} +1 -1
- package/dist/migration-tools.d.mts +14 -14
- package/dist/migration-tools.mjs +13 -13
- package/dist/migration-tools__aggregate.d.mts +1 -1
- package/dist/migration-tools__aggregate.mjs +1 -1
- package/dist/migration-tools__contract-snapshot-store.d.mts +3 -3
- package/dist/migration-tools__contract-snapshot-store.mjs +1 -1
- package/dist/migration-tools__errors.mjs +1 -1
- package/dist/migration-tools__hash.d.mts +2 -2
- package/dist/migration-tools__invariants.mjs +1 -1
- package/dist/migration-tools__io.d.mts +2 -2
- package/dist/migration-tools__io.mjs +1 -1
- package/dist/migration-tools__migration-graph.d.mts +3 -3
- package/dist/migration-tools__migration-graph.mjs +3 -3
- package/dist/migration-tools__migration.mjs +1 -1
- package/dist/migration-tools__ref-resolution.mjs +1 -1
- package/dist/migration-tools__refs.mjs +1 -1
- package/dist/migration-tools__spaces.mjs +2 -2
- package/dist/{ref-BrtKINun-CRtoeAmD.mjs → ref-C7TozKnq-C4UYYbRT.mjs} +362 -160
- package/dist/ref-C7TozKnq-C4UYYbRT.mjs.map +1 -0
- package/dist/{ref-resolution-C0xsiRig.mjs → ref-resolution-533MGMov.mjs} +2 -2
- package/dist/{ref-resolution-C0xsiRig.mjs.map → ref-resolution-533MGMov.mjs.map} +1 -1
- package/dist/{refs-t_JbIjGo-BVCqKpXd.mjs → refs-BE6yEgSV-CbpqGnbl.mjs} +3 -3
- package/dist/{refs-t_JbIjGo-BVCqKpXd.mjs.map → refs-BE6yEgSV-CbpqGnbl.mjs.map} +1 -1
- package/dist/{spaces-qTjiPqw0.mjs → spaces-Cj_GYpmM.mjs} +7 -7
- package/dist/{spaces-qTjiPqw0.mjs.map → spaces-Cj_GYpmM.mjs.map} +1 -1
- package/dist/{verify-contract-spaces-BZV67Pqk-DhswS52A.mjs → verify-contract-spaces-DvU9lE0Y-Y1WwEsPA.mjs} +4 -4
- package/dist/{verify-contract-spaces-BZV67Pqk-DhswS52A.mjs.map → verify-contract-spaces-DvU9lE0Y-Y1WwEsPA.mjs.map} +1 -1
- package/dist/vite-plugin-contract-emit.mjs +3 -3
- package/package.json +11 -11
- package/dist/caught-errors-D8Hn_D5h-C4BJDZ5y.mjs.map +0 -1
- package/dist/contract-snapshot-store-CtlOZtzJ.d.mts +0 -2
- package/dist/db-sign-DLIR5swa-CMgFrBoH.d.mts.map +0 -1
- package/dist/hash-CwWGlFWV.d.mts +0 -1
- package/dist/io-CpR7fgmB.d.mts +0 -1
- package/dist/ref-BrtKINun-CRtoeAmD.mjs.map +0 -1
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { t as MigrationMetadata$1 } from "./metadata-2nbOAGsV-uYNeq2Cp.mjs";
|
|
2
1
|
import { n as OnDiskMigrationPackage, t as MigrationOps } from "./package-CfWiDNrr-ZR4HM_Iz.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import "./contract-snapshot-store-
|
|
2
|
+
import { t as MigrationMetadata$1 } from "./metadata-2nbOAGsV-uYNeq2Cp.mjs";
|
|
3
|
+
import { n as SnapshotContentVerifier } from "./contract-snapshot-store-DRAG5XXy-ChW4hBLb.mjs";
|
|
5
4
|
import { a as Refs, n as NamedRef, r as RefEntry } from "./refs-CkGjbosE-CLkrSkQ4.mjs";
|
|
6
|
-
import "./refs-B5N_vHH7.mjs";
|
|
7
5
|
import { n as MigrationGraph } from "./graph-bDjJ4GL9-BhFevsJS.mjs";
|
|
6
|
+
import { f as IntegrityQueryOptions, l as ContractSpaceAggregate, m as IntegrityViolation, t as AggregateContractSpace } from "./aggregate-CvDNKQbR.mjs";
|
|
7
|
+
import "./contract-snapshot-store-D-s2aKZY.mjs";
|
|
8
|
+
import "./refs-B5N_vHH7.mjs";
|
|
8
9
|
import { a as MigrationRef, t as ContractRef } from "./ref-resolution-UwnXbc9M.mjs";
|
|
9
|
-
import { A as ExecuteDbSignOptions, B as
|
|
10
|
+
import { $ as StatementVerb, A as ExecuteDbSignOptions, B as OnControlProgress, C as DbUpdateSuccess, D as EmitOptions, E as EmitFailureCode, F as IntrospectOptions, G as RenderContractDtsFailure, H as PlanQuestion, J as RenderContractDtsResult, K as RenderContractDtsFailureCode, L as MigrationPlanArgument, M as ExecuteDbVerifyOptions, N as ExecuteDbVerifyResult, O as EmitResult, P as FromResolution, Q as StatementText, R as MigrationPlanArguments, S as DbUpdateResult, T as EmitFailure, U as PlanQuestionVerb, V as PlanAnswer, W as PlannerWarningsListener, X as ResolvedContractRef, Y as RenderContractDtsSuccess, Z as SchemaVerifyOptions, _ as DbInitSuccess, a as ChangedStorageEntity, at as resolveFromForPlan, b as DbSignSpaceOutcome, c as ContractEmitOptions, d as ControlClient, et as TemporaryValueReport, f as ControlClientOptions, g as DbInitResult, h as DbInitOptions, i as AskedSubject, it as hasMigrationPath, j as ExecuteDbSignResult, k as EmitSuccess, l as ContractEmitResult, m as CreateControlClient, n as AppliedStatementReport, nt as executeDbSign, o as CliInvocation, ot as resolveToForPlan, p as ControlProgressEvent, q as RenderContractDtsOptions, r as AskedDataLoss, rt as executeDbVerify, s as CliStructuredError$2, t as AnswerPlanQuestions, tt as VerifyOptions, u as ControlActionName, v as DbSignOptions, w as EmitContractConfig, x as DbUpdateOptions, y as DbSignSpaceFailure, z as MigrationPlanTargetArgument } from "./db-sign-BQMw6RX9-Stp7Gjj7.mjs";
|
|
10
11
|
import { s as PrismaConfig$1 } from "./index-C3KtOcBP.mjs";
|
|
11
12
|
import { a as emit } from "./index-C09OeJjf.mjs";
|
|
12
|
-
import { f as IntegrityQueryOptions, l as ContractSpaceAggregate, m as IntegrityViolation, t as AggregateContractSpace } from "./aggregate-BMh4SLep.mjs";
|
|
13
|
-
import "./metadata-BtscDay2.mjs";
|
|
14
13
|
import "./package-N9PPdFV_.mjs";
|
|
14
|
+
import "./metadata-BtscDay2.mjs";
|
|
15
15
|
import { CliStructuredError } from "@prisma/orm-framework/errors/control";
|
|
16
16
|
import { ControlAdapterInstance, ControlDriverInstance, ControlExtensionDescriptor, ControlFamilyInstance, ControlStack, DeclaredDatabasePolicies, MigrationAccessChange, MigrationOperationSubject, MigrationPlanOperation, MigrationPlanSubjects, MigrationPlannerConflict, MigrationSubject, OperationPreview, ResolvedMigrationStatement, ResolvedMigrationStatement as ResolvedMigrationStatement$1, TargetMigrationsCapability, VerifyDatabaseResult, VerifyDatabaseSchemaResult } from "@prisma/orm-framework/components/control";
|
|
17
17
|
import { Result } from "@prisma/orm-framework/utils/result";
|
|
@@ -378,6 +378,8 @@ interface ExecuteDbUpdateOptions<TFamilyId extends string, TTargetId extends str
|
|
|
378
378
|
readonly ref?: NamedRef;
|
|
379
379
|
/** See {@link DbUpdateOptions.permitPolicyChange}. */
|
|
380
380
|
readonly permitPolicyChange?: boolean;
|
|
381
|
+
/** See {@link DbUpdateOptions.emittedContractHash}. */
|
|
382
|
+
readonly emittedContractHash?: string;
|
|
381
383
|
readonly migrationsDir: string;
|
|
382
384
|
readonly targetId: TTargetId;
|
|
383
385
|
readonly extensions?: ReadonlyArray<ControlExtensionDescriptor<TFamilyId, TTargetId>>;
|
|
@@ -399,10 +401,6 @@ interface ExecuteDbUpdateOptions<TFamilyId extends string, TTargetId extends str
|
|
|
399
401
|
/** Execute `db update` against the configured contract. */
|
|
400
402
|
declare function executeDbUpdate<TFamilyId extends string, TTargetId extends string>(options: ExecuteDbUpdateOptions<TFamilyId, TTargetId>): Promise<DbUpdateResult>;
|
|
401
403
|
//#endregion
|
|
402
|
-
//#region src/control-api/operations/graph-queries.d.ts
|
|
403
|
-
/** True when the on-disk graph contains a path fromHash → toHash. */
|
|
404
|
-
declare function hasMigrationPath(graph: MigrationGraph, fromHash: string, toHash: string): boolean;
|
|
405
|
-
//#endregion
|
|
406
404
|
//#region src/control-api/operations/invariants.d.ts
|
|
407
405
|
/** Refuses ref invariants neither declared on any graph edge nor present on the live marker. */
|
|
408
406
|
declare function refuseUnknownInvariants(args: {
|
|
@@ -720,6 +718,8 @@ interface MigrationNewOptions {
|
|
|
720
718
|
readonly config: PrismaConfig;
|
|
721
719
|
/** Directory the command was invoked from. */
|
|
722
720
|
readonly cwd: string;
|
|
721
|
+
/** The `--config` the command was given, which the commands its errors print repeat. */
|
|
722
|
+
readonly configPath?: string;
|
|
723
723
|
readonly name?: string;
|
|
724
724
|
readonly from?: string;
|
|
725
725
|
/** Renders the declarations of the destination snapshot from its `contract.json`. */
|
|
@@ -881,53 +881,6 @@ declare function appliedHashesFromLedger(ledgerEntries: ReadonlyArray<{
|
|
|
881
881
|
}>): ReadonlySet<string>;
|
|
882
882
|
declare function statusForMigrationHash(migrationHash: string, annotations: ReadonlyMap<string, MigrationEdgeAnnotation>): 'applied' | 'pending' | null;
|
|
883
883
|
//#endregion
|
|
884
|
-
//#region src/control-api/operations/plan-resolution.d.ts
|
|
885
|
-
/**
|
|
886
|
-
* Set when the origin was derived from the `db` ref by default (no `--from`)
|
|
887
|
-
* and that node already has outgoing edges. Planning from it forks the
|
|
888
|
-
* graph, so the caller must surface it to the user.
|
|
889
|
-
*/
|
|
890
|
-
interface DefaultOriginForks {
|
|
891
|
-
readonly refName: string;
|
|
892
|
-
readonly refHash: string;
|
|
893
|
-
readonly outgoingTo: readonly string[];
|
|
894
|
-
}
|
|
895
|
-
type FromResolution = {
|
|
896
|
-
kind: 'greenfield';
|
|
897
|
-
fromHash: null;
|
|
898
|
-
fromContract: null;
|
|
899
|
-
defaulted: boolean;
|
|
900
|
-
} | {
|
|
901
|
-
kind: 'graph-node';
|
|
902
|
-
fromHash: string;
|
|
903
|
-
fromContract: Contract;
|
|
904
|
-
defaultOriginForks?: DefaultOriginForks;
|
|
905
|
-
} | {
|
|
906
|
-
kind: 'ref';
|
|
907
|
-
fromHash: string;
|
|
908
|
-
fromContract: Contract;
|
|
909
|
-
defaultOriginForks?: DefaultOriginForks;
|
|
910
|
-
} | {
|
|
911
|
-
kind: 'auto-baseline';
|
|
912
|
-
fromHash: string;
|
|
913
|
-
fromContract: Contract;
|
|
914
|
-
};
|
|
915
|
-
interface ResolveFromForPlanInput {
|
|
916
|
-
readonly optionsFrom?: string | undefined;
|
|
917
|
-
readonly space: AggregateContractSpace;
|
|
918
|
-
}
|
|
919
|
-
declare function resolveFromForPlan(input: ResolveFromForPlanInput): Promise<Result<FromResolution, CliStructuredError$2>>;
|
|
920
|
-
interface ResolveToForPlanInput {
|
|
921
|
-
readonly space: AggregateContractSpace;
|
|
922
|
-
}
|
|
923
|
-
interface ResolvedContractRef {
|
|
924
|
-
readonly hash: string;
|
|
925
|
-
readonly contract: Contract;
|
|
926
|
-
/** The ref `--to` named, with the policies it declares; `undefined` when `--to` named no ref. */
|
|
927
|
-
readonly ref: NamedRef | undefined;
|
|
928
|
-
}
|
|
929
|
-
declare function resolveToForPlan(optionsTo: string, input: ResolveToForPlanInput): Promise<Result<ResolvedContractRef, CliStructuredError$2>>;
|
|
930
|
-
//#endregion
|
|
931
884
|
//#region src/control-api/operations/ref.d.ts
|
|
932
885
|
interface RefSetResult {
|
|
933
886
|
readonly ok: true;
|
|
@@ -1078,5 +1031,5 @@ declare function resolveStatements(input: ResolveStatementsInput): Result<readon
|
|
|
1078
1031
|
//#region src/utils/emit-queue.d.ts
|
|
1079
1032
|
declare function disposeEmitQueue(outputJsonPath: string): void;
|
|
1080
1033
|
//#endregion
|
|
1081
|
-
export { type AnswerPlanQuestions, type AppliedStatementReport, type AskedDataLoss, type AskedSubject, type BuildAggregateInputs, type CheckSpace, type CliInvocation, type ContractEmitOptions, type ContractEmitResult, type ContractIR, type ContractSourceFailure, type ContractSpaceSeedPhaseInputs, type ContractSpaceSeedPhaseRecord, type ContractSpaceSeedPhaseResult, type ControlActionName, type ControlClient, type ControlClientOptions, type ControlProgressEvent, type ControlStack, type DbInitOptions, type DbInitResult, type DbInitSuccess, type DbSignOptions, type DbSignSpaceFailure, type DbSignSpaceOutcome, type DbUpdateOptions, type DbUpdateResult, type DbUpdateSuccess, type EmitContractConfig, type EmitFailure, type EmitFailureCode, type EmitOptions, type EmitResult, type EmitSuccess, type ExecuteDbInitOptions, type ExecuteDbSignOptions, type ExecuteDbSignResult, type ExecuteDbUpdateOptions, type ExecuteDbVerifyOptions, type ExecuteDbVerifyResult, type ExecuteMigrateShowPlanOptions, type FromResolution, type IntrospectOptions, type MigrateShowMigration, type MigrateShowPlanSuccess, type MigrationCheckOutcome, type MigrationOperationSubject, type MigrationPlanResult, type MigrationPlanSubjects, type MigrationSubject, NO_REF_ADVANCEMENT, type OnControlProgress, type PlanAnswer, type PlanQuestion, type PlanQuestionVerb, type RefAdvancementFields, type RenderContractDtsFailure, type RenderContractDtsFailureCode, type RenderContractDtsOptions, type RenderContractDtsResult, type RenderContractDtsSuccess, type ResolveContractRefToSnapshotOptions, type ResolveContractRefToSnapshotSuccess, type ResolveStatementsInput, type ResolvedContractRef, type ResolvedMigrationStatement, type RunMigrationCheckInputs, type RunMigrationListInputs, type SchemaVerifyOptions, type StatementOrigin, type StatementText, type StatementVerb, type VerifyDatabaseResult, type VerifyDatabaseSchemaResult, type VerifyOptions, advanceRefSafely, appContractStandInFromIdentity, appliedHashesFromLedger, buildContractSpaceAggregate, buildMigrationSpaceGraphEntries, buildReadAggregate, buildRefAdvancementFields, checkSingleTarget, computeRefAdvancementName, createControlClient, deriveStatusEdgeAnnotations, disposeEmitQueue, enrichContract, enumerateCheckSpaces, errorFromCaught, executeContractEmit, executeDbInit, executeDbSign, executeDbUpdate, executeDbVerify, executeMigrateShowPlan, executeMigrationNewCommand, executeMigrationPlanCommand, executeRefAdvancement, executeRefDeleteCommand, executeRefListCommand, executeRefSetCommand, hasMigrationPath, listRefsByContractHash, loadAggregateIntegrityViolations, loadContractRawSafely, loadContractSource, loadContractSpaceAggregateForCli, mapContractAtError, mapIntegrityViolations, migrationSpaceListEntriesFromAggregate, preflightRefAdvancement, readMigrationRefs, refuseContractSpaceIntegrity, refuseDeclaredExtensionTargetMismatch, refuseMissingInvariantPath, refusePackageCorruptionOnAggregate, refuseUnknownInvariants, resolveContractRef, resolveContractRefToSnapshot, resolveFromForPlan, resolveMigrationRef, resolveStatements, resolveToForPlan, runContractSpaceSeedPhase, runMigrationCheck, runMigrationList, statusForMigrationHash };
|
|
1034
|
+
export { type AnswerPlanQuestions, type AppliedStatementReport, type AskedDataLoss, type AskedSubject, type BuildAggregateInputs, type CheckSpace, type CliInvocation, type ContractEmitOptions, type ContractEmitResult, type ContractIR, type ContractSourceFailure, type ContractSpaceSeedPhaseInputs, type ContractSpaceSeedPhaseRecord, type ContractSpaceSeedPhaseResult, type ControlActionName, type ControlClient, type ControlClientOptions, type ControlProgressEvent, type ControlStack, type DbInitOptions, type DbInitResult, type DbInitSuccess, type DbSignOptions, type DbSignSpaceFailure, type DbSignSpaceOutcome, type DbUpdateOptions, type DbUpdateResult, type DbUpdateSuccess, type EmitContractConfig, type EmitFailure, type EmitFailureCode, type EmitOptions, type EmitResult, type EmitSuccess, type ExecuteDbInitOptions, type ExecuteDbSignOptions, type ExecuteDbSignResult, type ExecuteDbUpdateOptions, type ExecuteDbVerifyOptions, type ExecuteDbVerifyResult, type ExecuteMigrateShowPlanOptions, type FromResolution, type IntrospectOptions, type MigrateShowMigration, type MigrateShowPlanSuccess, type MigrationCheckOutcome, type MigrationOperationSubject, type MigrationPlanArgument, type MigrationPlanArguments, type MigrationPlanResult, type MigrationPlanSubjects, type MigrationPlanTargetArgument, type MigrationSubject, NO_REF_ADVANCEMENT, type OnControlProgress, type PlanAnswer, type PlanQuestion, type PlanQuestionVerb, type RefAdvancementFields, type RenderContractDtsFailure, type RenderContractDtsFailureCode, type RenderContractDtsOptions, type RenderContractDtsResult, type RenderContractDtsSuccess, type ResolveContractRefToSnapshotOptions, type ResolveContractRefToSnapshotSuccess, type ResolveStatementsInput, type ResolvedContractRef, type ResolvedMigrationStatement, type RunMigrationCheckInputs, type RunMigrationListInputs, type SchemaVerifyOptions, type StatementOrigin, type StatementText, type StatementVerb, type VerifyDatabaseResult, type VerifyDatabaseSchemaResult, type VerifyOptions, advanceRefSafely, appContractStandInFromIdentity, appliedHashesFromLedger, buildContractSpaceAggregate, buildMigrationSpaceGraphEntries, buildReadAggregate, buildRefAdvancementFields, checkSingleTarget, computeRefAdvancementName, createControlClient, deriveStatusEdgeAnnotations, disposeEmitQueue, enrichContract, enumerateCheckSpaces, errorFromCaught, executeContractEmit, executeDbInit, executeDbSign, executeDbUpdate, executeDbVerify, executeMigrateShowPlan, executeMigrationNewCommand, executeMigrationPlanCommand, executeRefAdvancement, executeRefDeleteCommand, executeRefListCommand, executeRefSetCommand, hasMigrationPath, listRefsByContractHash, loadAggregateIntegrityViolations, loadContractRawSafely, loadContractSource, loadContractSpaceAggregateForCli, mapContractAtError, mapIntegrityViolations, migrationSpaceListEntriesFromAggregate, preflightRefAdvancement, readMigrationRefs, refuseContractSpaceIntegrity, refuseDeclaredExtensionTargetMismatch, refuseMissingInvariantPath, refusePackageCorruptionOnAggregate, refuseUnknownInvariants, resolveContractRef, resolveContractRefToSnapshot, resolveFromForPlan, resolveMigrationRef, resolveStatements, resolveToForPlan, runContractSpaceSeedPhase, runMigrationCheck, runMigrationList, statusForMigrationHash };
|
|
1082
1035
|
//# sourceMappingURL=cli__control-api.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli__control-api.d.mts","names":[],"sources":["../../../../1-framework/3-tooling/cli/dist/exports/control-api.d.mts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;iBAkBiB,oBAAoB,SAAS,uBAAuB;;;;;;iBAMpD,eAAe,IAAI,UAAU,YAAY,cAAc,kDAAkD;;;;;;;;iBAQzG,gBAAgB,gBAAgB,MAAM,4BAA4B;WACxE;IACP;;;iBAGa,mBAAmB,gBAAgB;WACzC;IACP,cAAc;;;KAGb;WACM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA4BP,oBAAoB,SAAS,qBAAqB,eAAe,2BAA2B,QAAQ;;;UAG3G;WACC,QAAQ;WACR;;WAEA;;WAEA;;;;;;;KAON,sCAAsC;WAChC;;WAEA;;WAEA;;UAED;WACC;WACA,cAAc;;WAEd;WACA;;WAEA,MAAM;;iBAEA,6BAA6B,SAAS,sCAAsC,QAAQ,OAAO,qCAAqC;;;iBAGhI,uBAAuB,qBAAqB,sBAAsB,wBAAwB;;;;;;;;UAQjG,qBAAqB,0BAA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aACE;eACE;;;WAGJ,QAAQ,KAAK;IACpB,QAAQ,OAAO,YAAY;iBACd,sBAAsB,iBAAiB,uBAAuB,cAAc,cAAc,YAAY,aAAa;EAClI;EACA;;;;;;;iBAOe,0BAA0B;WAChC;WACA;WACA;WACA,YAAY;WACZ;WACA;IACP,QAAQ,OAAO,sBAAsB;;;;;iBAKxB,iBAAiB;WACvB;WACA;WACA;WACA;WACA,YAAY;IACnB,QAAQ;WACD;WACA;GACR;;;UAGO;WACC,OAAO;WACP,MAAM;WACN;;iBAEM,mBAAmB,eAAe,SAAS,uBAAuB,OAAO,aAAa;iBACtF,oBAAoB,eAAe;WACzC,OAAO;WACP,MAAM;IACb,OAAO,cAAc;;;;iBAIR,kBAAkB,kBAAkB,QAAQ,OAAO,MAAM;;;;;;;KAOrE;WACM;WACA,UAAU;;WAEV;WACA;WACA;;WAEA;;;;;;UAMD;;WAEC,qBAAqB;WACrB,QAAQ;WACR,aAAa;;;;;;;;;iBASP,kBAAkB,OAAO,yBAAyB,gBAAgB,gCAAgC;;;iBAGlG,iBAAiB"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { A as executeMigrationNewCommand,
|
|
1
|
+
import { F as errorFromCaught, ft as hasMigrationPath } from "./caught-errors-DZXnK8Ls-zVmM4nr3.mjs";
|
|
2
|
+
import { $ as preflightRefAdvancement, A as executeMigrationNewCommand, B as listRefsByContractHash, D as executeDbUpdate, E as executeDbSign, F as executeRefSetCommand, H as loadAggregateIntegrityViolations, J as mapContractAtError, K as loadContractSpaceAggregateForCli, M as executeRefAdvancement, N as executeRefDeleteCommand, O as executeDbVerify, P as executeRefListCommand, S as enumerateCheckSpaces, St as statusForMigrationHash, T as executeDbInit, U as loadContractRawSafely, W as loadContractSource, Y as mapIntegrityViolations, Z as migrationSpaceListEntriesFromAggregate, _t as runMigrationCheck, a as advanceRefSafely, at as refuseUnknownInvariants, b as disposeEmitQueue, c as buildContractSpaceAggregate, d as buildRefAdvancementFields, dt as resolveFromForPlan, et as readMigrationRefs, f as checkSingleTarget, ft as resolveMigrationRef, g as createControlClient, gt as runContractSpaceSeedPhase, it as refusePackageCorruptionOnAggregate, j as executeMigrationPlanCommand, k as executeMigrateShowPlan, l as buildMigrationSpaceGraphEntries, lt as resolveContractRef$1, mt as resolveToForPlan, n as NO_REF_ADVANCEMENT, nt as refuseDeclaredExtensionTargetMismatch, o as appContractStandInFromIdentity, p as computeRefAdvancementName, pt as resolveStatements, rt as refuseMissingInvariantPath, s as appliedHashesFromLedger, tt as refuseContractSpaceIntegrity, u as buildReadAggregate, ut as resolveContractRefToSnapshot, vt as runMigrationList, w as executeContractEmit, x as enrichContract, y as deriveStatusEdgeAnnotations } from "./ref-C7TozKnq-C4UYYbRT.mjs";
|
|
3
3
|
export { NO_REF_ADVANCEMENT, advanceRefSafely, appContractStandInFromIdentity, appliedHashesFromLedger, buildContractSpaceAggregate, buildMigrationSpaceGraphEntries, buildReadAggregate, buildRefAdvancementFields, checkSingleTarget, computeRefAdvancementName, createControlClient, deriveStatusEdgeAnnotations, disposeEmitQueue, enrichContract, enumerateCheckSpaces, errorFromCaught, executeContractEmit, executeDbInit, executeDbSign, executeDbUpdate, executeDbVerify, executeMigrateShowPlan, executeMigrationNewCommand, executeMigrationPlanCommand, executeRefAdvancement, executeRefDeleteCommand, executeRefListCommand, executeRefSetCommand, hasMigrationPath, listRefsByContractHash, loadAggregateIntegrityViolations, loadContractRawSafely, loadContractSource, loadContractSpaceAggregateForCli, mapContractAtError, mapIntegrityViolations, migrationSpaceListEntriesFromAggregate, preflightRefAdvancement, readMigrationRefs, refuseContractSpaceIntegrity, refuseDeclaredExtensionTargetMismatch, refuseMissingInvariantPath, refusePackageCorruptionOnAggregate, refuseUnknownInvariants, resolveContractRef$1 as resolveContractRef, resolveContractRefToSnapshot, resolveFromForPlan, resolveMigrationRef, resolveStatements, resolveToForPlan, runContractSpaceSeedPhase, runMigrationCheck, runMigrationList, statusForMigrationHash };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { I as MigrateResult, J as RenderContractDtsResult, N as ExecuteDbVerifyResult, O as EmitResult, S as DbUpdateResult, d as ControlClient, g as DbInitResult, j as ExecuteDbSignResult } from "./db-sign-BQMw6RX9-Stp7Gjj7.mjs";
|
|
2
2
|
import { CoreSchemaView, OperationPreview, VerifyDatabaseResult, VerifyDatabaseSchemaResult } from "@prisma/orm-framework/components/control";
|
|
3
3
|
import { ContractMarkerRecord, LedgerEntryRecord } from "@prisma/orm-framework/contract/types";
|
|
4
4
|
import { PslDocumentAst } from "@prisma/orm-framework/components/psl-ast";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { g as requireConfigSections, p as loadConfigForSections, s as findNearestConfigPathForFile, t as CONFIG_FILENAME, u as loadConfig } from "./exports-
|
|
2
|
-
import { g as errorInvalidJson } from "./errors-
|
|
3
|
-
import {
|
|
4
|
-
import { r as buildMigrationArtifacts } from "./migration-
|
|
1
|
+
import { g as requireConfigSections, p as loadConfigForSections, s as findNearestConfigPathForFile, t as CONFIG_FILENAME, u as loadConfig } from "./exports-DNFYCa6U.mjs";
|
|
2
|
+
import { g as errorInvalidJson } from "./errors-BlaB9AFz-CZDOC0mV.mjs";
|
|
3
|
+
import { F as errorFromCaught, St as migrationsDirFor } from "./caught-errors-DZXnK8Ls-zVmM4nr3.mjs";
|
|
4
|
+
import { r as buildMigrationArtifacts } from "./migration-C1l4_CWi.mjs";
|
|
5
5
|
import { errorMigrationCliConfigNotFound, errorMigrationCliInvalidConfigArg, errorMigrationCliUnknownFlag } from "@prisma/orm-framework/errors/control";
|
|
6
6
|
import { createControlStack } from "@prisma/orm-framework/components/control";
|
|
7
7
|
import { notOk, ok } from "@prisma/orm-framework/utils/result";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli__migration-cli.mjs","names":[],"sources":["../../../../1-framework/3-tooling/cli/dist/migration-cli.mjs"],"sourcesContent":["import { b as migrationsDirFor, n as errorFromCaught } from \"./caught-errors-D8Hn_D5h.mjs\";\nimport { existsSync, readFileSync, realpathSync, writeFileSync } from \"node:fs\";\nimport { errorMigrationCliConfigNotFound, errorMigrationCliInvalidConfigArg, errorMigrationCliUnknownFlag } from \"@internal/errors/control\";\nimport { createControlStack } from \"@internal/framework-components/control\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { isStructuredError } from \"@internal/utils/structured-error\";\nimport { dirname, isAbsolute, join, relative } from \"pathe\";\nimport { errorMigrationTargetMismatch } from \"@internal/errors/migration\";\nimport { errorInvalidJson } from \"@internal/migration-tools/errors\";\nimport { CONFIG_FILENAME, findNearestConfigPathForFile, loadConfig, loadConfigForSections, requireConfigSections } from \"@internal/config-loader\";\nimport { fileURLToPath } from \"node:url\";\nimport { buildMigrationArtifacts } from \"@internal/migration-tools/migration\";\nimport { Cli, Command, Option, UsageError } from \"clipanion\";\n//#region src/utils/migration-file-config.ts\n/**\n* The config a `migration.ts` runs with. `--config` names it outright. Without it, the config is the one that owns the migration, whose migrations directory holds the file: the nearest `prisma.config.ts` above the migration, else the one in the working directory.\n*/\nasync function loadMigrationFileConfig(options) {\n\tconst { configPath, migrationFile, cwd, sections } = options;\n\tif (configPath !== void 0) return loadConfigForSections(configPath, sections);\n\tconst workingDirectoryConfig = join(cwd, CONFIG_FILENAME);\n\tconst candidates = [.../* @__PURE__ */ new Set([await findNearestConfigPathForFile(migrationFile), existsSync(workingDirectoryConfig) ? workingDirectoryConfig : void 0])].filter((candidate) => candidate !== void 0);\n\tconst checked = [];\n\tfor (const candidate of candidates) {\n\t\tconst loaded = await loadConfig(candidate);\n\t\tconst config = loaded.ok ? requireConfigSections(loaded.value, [...sections, \"migrations\"]) : loaded;\n\t\tif (!config.ok) {\n\t\t\tchecked.push({\n\t\t\t\tconfigPath: candidate,\n\t\t\t\tloadFailure: config.failure.message\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tif (ownsMigration(config.value, candidate, migrationFile)) return ok(config.value);\n\t\tchecked.push({\n\t\t\tconfigPath: candidate,\n\t\t\tmigrationsDir: migrationsDirFor(config.value, dirname(candidate))\n\t\t});\n\t}\n\treturn notOk(errorMigrationCliConfigNotFound({\n\t\tmigrationDir: dirname(migrationFile),\n\t\tchecked\n\t}));\n}\n/** Whether `migrationFile` is inside the migrations directory of the config at `configPath`. */\nfunction ownsMigration(config, configPath, migrationFile) {\n\tconst path = relative(realPath(migrationsDirFor(config, dirname(configPath))), realPath(migrationFile));\n\treturn path !== \"\" && !path.startsWith(\"..\") && !isAbsolute(path);\n}\nfunction realPath(path) {\n\treturn existsSync(path) ? realpathSync(path) : path;\n}\n//#endregion\n//#region src/migration-cli.ts\n/**\n* The migration-file CLI interface: the actor invoked when the author runs\n* `node migration.ts` directly.\n*\n* Naming: this is *not* a \"migration runner\" in the apply-time sense. The\n* apply-time runner is the thing `prisma db migrate` uses to\n* execute migration JSON ops against a database. `MigrationCLI` is the\n* tiny CLI surface owned by an authored `migration.ts` file: parse the\n* file's argv, load the project's `prisma.config.ts`, assemble a\n* `ControlStack`, instantiate the migration class, and serialize.\n*\n* The user authors a migration class, then calls\n* `MigrationCLI.run(import.meta.url, MigrationClass)` at module scope\n* after the class definition. When the file is invoked as a node\n* entrypoint (`node migration.ts`), the CLI:\n*\n* 1. Detects whether the file is the direct entrypoint (no-op when imported).\n* 2. Parses CLI args (`--help`, `--dry-run`, `--config <path>`) via\n* [clipanion](https://github.com/arcanis/clipanion).\n* 3. Loads the config `--config` names. Without it, loads the config that\n* owns the migration (see `loadMigrationFileConfig`).\n* 4. Probe-instantiates the migration class without a stack so it can read\n* `targetId` and verify it matches `config.target.targetId`\n* (`MIGRATION.TARGET_MISMATCH` on mismatch) before any stack-driven adapter\n* construction runs.\n* 5. Assembles a `ControlStack` from the loaded config descriptors and\n* constructs the migration with that stack.\n* 6. Reads any previously-scaffolded `migration.json`, then calls\n* `buildMigrationArtifacts` from `@internal/migration-tools` to\n* produce in-memory `ops.json` + `migration.json` content. Persists\n* the result to disk (or prints in dry-run mode).\n*\n* File I/O lives here, in `@internal/cli`: this is the only place\n* that legitimately combines config loading, stack assembly, and\n* on-disk persistence. `@internal/migration-tools` owns the pure\n* conversion from a `Migration` instance to artifact strings; `Migration`\n* stays a pure abstract class.\n*\n* Parser library: clipanion (chosen over Commander/citty/`node:util.parseArgs`\n* for its in-process testability and runtime-agnostic execution surface; see\n* `docs/architecture docs/research/commander-friction-points.md` for the\n* evaluation rubric and the durable rationale that drove the choice).\n*/\n/**\n* Flags exposed by the migration-file CLI.\n*\n* Must stay in sync with the `Option` declarations on\n* `MigrationFileCommand` below. This list is rendered in the\n* `errorMigrationCliUnknownFlag` envelope's `fix` text and `meta`,\n* so order matters for user-visible output (declaration order is the\n* order users see when they run `--help`).\n*/\nconst KNOWN_FLAGS = [\n\t\"--help\",\n\t\"--dry-run\",\n\t\"--config\"\n];\n/**\n* The clipanion command that owns the migration-file CLI's option\n* declarations. The class is internal — `MigrationCLI.run` is the\n* stable public surface. Adding a flag here automatically updates\n* `--help` rendering and the `KNOWN_FLAGS` list (the latter must be\n* updated in tandem).\n*/\nvar MigrationFileCommand = class extends Command {\n\tstatic paths = [Command.Default];\n\tstatic usage = Command.Usage({\n\t\tdescription: \"Self-emit ops.json and migration.json from a class-flow migration\",\n\t\tdetails: `\n Loads the project's prisma.config.ts, assembles a ControlStack\n from the configured target/adapter/extensions, and serializes the\n migration's operations + metadata next to this file.\n `,\n\t\texamples: [\n\t\t\t[\"Self-emit ops.json + migration.json next to migration.ts\", \"$0\"],\n\t\t\t[\"Preview without writing files\", \"$0 --dry-run\"],\n\t\t\t[\"Use a non-default config path\", \"$0 --config ./custom.config.ts\"]\n\t\t]\n\t});\n\tdryRun = Option.Boolean(\"--dry-run\", false, { description: \"Print operations to stdout without writing files\" });\n\tconfig = Option.String(\"--config\", { description: \"Path to prisma.config.ts\" });\n\t/**\n\t* Unused: orchestration runs inside `MigrationCLI.run` so error\n\t* routing stays under our control (clipanion's `cli.run` writes\n\t* error output to `context.stdout`, but our contract requires\n\t* structured errors on stderr). `cli.process` is used to parse\n\t* argv into a populated `MigrationFileCommand` instance whose\n\t* fields drive the orchestration directly.\n\t*/\n\tasync execute() {\n\t\treturn 0;\n\t}\n};\n/**\n* The CLI surface invoked by an authored `migration.ts` file. Exposed as\n* a class with a static `run` method (rather than a free function) to\n* give the concept a stable identity in the ubiquitous language: this is\n* the \"migration-file CLI\", distinct from the apply-time runner that\n* executes migration JSON ops.\n*\n* Currently a single static method. Future surface (e.g. a programmatic\n* `MigrationCLI.serializeOnly(...)` for tests, or extra subcommands) can\n* land here without changing the import shape used by every authored\n* migration.\n*/\nvar MigrationCLI = class {\n\t/**\n\t* Orchestrates a class-flow `migration.ts` script run.\n\t*\n\t* The third argument is the in-process testability surface: callers\n\t* (and tests) may inject `argv`, `stdout`, and `stderr` instead of\n\t* relying on `process.argv` / `process.stdout` / `process.stderr`.\n\t* Each option defaults to its `process` global when omitted, so\n\t* existing two-argument call sites\n\t* (`MigrationCLI.run(import.meta.url, MyMigration)`) continue to\n\t* compile and behave identically.\n\t*\n\t* Returns the exit code so the caller can branch on it. Also writes\n\t* the same code to `process.exitCode` so script-style callers that\n\t* don't await the return value still surface a non-zero exit when\n\t* something fails.\n\t*\n\t* Exit codes:\n\t* - 0 — success, or `--help`, or imported-not-entrypoint no-op.\n\t* - 1 — runtime/orchestration error (config not found, target\n\t* mismatch, etc.).\n\t* - 2 — usage error (unknown flag, malformed `--config`). Aligns\n\t* with `docs/CLI Style Guide.md` § Exit Codes.\n\t*/\n\tstatic async run(importMetaUrl, MigrationClass, options = {}) {\n\t\tif (!importMetaUrl) return 0;\n\t\tconst argv = options.argv ?? process.argv;\n\t\tconst stdout = options.stdout ?? process.stdout;\n\t\tconst stderr = options.stderr ?? process.stderr;\n\t\tif (!isDirectEntrypoint(importMetaUrl, argv)) return 0;\n\t\tconst exitCode = await orchestrate(importMetaUrl, MigrationClass, {\n\t\t\targv,\n\t\t\tstdout,\n\t\t\tstderr\n\t\t});\n\t\tif (exitCode !== 0 || !process.exitCode) process.exitCode = exitCode;\n\t\treturn exitCode;\n\t}\n};\n/**\n* Argv-aware variant of the entrypoint guard. The shared\n* `@internal/migration-tools` helper of the same name reads\n* `process.argv[1]` directly, which doesn't compose with the new\n* in-process testability surface (tests inject `argv` without mutating\n* the process global). Inlined here so the migration-file CLI's check\n* follows the injected `argv[1]` consistently.\n*/\nfunction isDirectEntrypoint(importMetaUrl, argv) {\n\tconst argv1 = argv[1];\n\tif (!argv1) return false;\n\ttry {\n\t\treturn realpathSync(fileURLToPath(importMetaUrl)) === realpathSync(argv1);\n\t} catch {\n\t\treturn false;\n\t}\n}\n/**\n* Argv-and-stream-driven orchestration body. Pulled out of the static\n* method so the entrypoint guard / process-default plumbing stays\n* separate from the parse + load + serialize steps.\n*/\nasync function orchestrate(importMetaUrl, MigrationClass, ctx) {\n\tconst cli = Cli.from([MigrationFileCommand], {\n\t\tbinaryName: \"migration.ts\",\n\t\tbinaryLabel: \"Migration file CLI\"\n\t});\n\tconst input = ctx.argv.slice(2);\n\tconst configError = detectInvalidConfig(input);\n\tif (configError) {\n\t\twriteStructuredError(ctx.stderr, configError);\n\t\treturn 2;\n\t}\n\tlet parsed;\n\ttry {\n\t\tconst command = cli.process({\n\t\t\tinput: [...input],\n\t\t\tcontext: {\n\t\t\t\tstdout: ctx.stdout,\n\t\t\t\tstderr: ctx.stderr\n\t\t\t}\n\t\t});\n\t\tif (!(command instanceof MigrationFileCommand)) {\n\t\t\tctx.stdout.write(cli.usage(MigrationFileCommand, { detailed: true }));\n\t\t\treturn 0;\n\t\t}\n\t\tparsed = command;\n\t} catch (err) {\n\t\treturn renderParseError(err, input, ctx.stderr);\n\t}\n\tif (parsed.help) {\n\t\tctx.stdout.write(cli.usage(MigrationFileCommand, { detailed: true }));\n\t\treturn 0;\n\t}\n\ttry {\n\t\tawait runMigration(importMetaUrl, MigrationClass, parsed, ctx);\n\t\treturn 0;\n\t} catch (err) {\n\t\tif (isStructuredError(err)) writeStructuredError(ctx.stderr, errorFromCaught(err, (message) => message));\n\t\telse ctx.stderr.write(`${err instanceof Error ? err.message : String(err)}\\n`);\n\t\treturn 1;\n\t}\n}\n/**\n* Returns an `errorMigrationCliInvalidConfigArg` envelope when `input`\n* contains a malformed `--config`:\n*\n* - `--config` as the last token (no value follows).\n* - `--config <flag>` where `<flag>` starts with `-` (silently\n* consuming the next flag would either drop the flag or serialize\n* against the wrong project).\n* - `--config <empty>` where the value is the empty string. Shells\n* expand `--config \"\"` (or `--config \"$UNSET_VAR\"`) into a real\n* empty argv token; treating that as a usage error here surfaces\n* `CLI.CONFIG_ARG_MISSING_PATH` instead of a less actionable loader error on an\n* empty path.\n* - `--config=` (the equals form with an empty value). Same shape as\n* the empty-string case above; the user expressed intent to override\n* the config path but the override is empty.\n*\n* `--config=<value>` and `--config <value>` with a non-empty value are\n* both valid (and the equals form's value is allowed to start with\n* `-` — the `=` makes the binding explicit).\n*/\nfunction detectInvalidConfig(input) {\n\tfor (let i = 0; i < input.length; i++) {\n\t\tconst token = input[i];\n\t\tif (token === \"--config\") {\n\t\t\tconst next = input[i + 1];\n\t\t\tif (next === void 0 || next === \"\") return errorMigrationCliInvalidConfigArg();\n\t\t\tif (next.startsWith(\"-\")) return errorMigrationCliInvalidConfigArg({ nextToken: next });\n\t\t\tcontinue;\n\t\t}\n\t\tif (token === \"--config=\") return errorMigrationCliInvalidConfigArg();\n\t}\n\treturn null;\n}\n/**\n* Translate clipanion's parse-time errors into the project's structured\n* error envelopes.\n*\n* - `UnknownSyntaxError` covers both unknown flags (`--frobnicate`) and\n* the bare-trailing `--config` case (where arity-1 needs a value but\n* none was supplied). Distinguished by inspecting the input array.\n* - `UsageError` covers schema/validator failures from typanion. None\n* of the migration-file CLI's options have validators today, but we\n* still translate it as a usage error (exit 2) for forward-compat.\n* - Anything else re-throws — caller's outer catch will surface it as\n* exit 1 (runtime error).\n*/\nfunction renderParseError(err, input, stderr) {\n\tif (isUnknownSyntaxError(err)) {\n\t\twriteStructuredError(stderr, errorMigrationCliUnknownFlag({\n\t\t\tflag: findOffendingFlag(input),\n\t\t\tknownFlags: KNOWN_FLAGS\n\t\t}));\n\t\treturn 2;\n\t}\n\tif (err instanceof UsageError) {\n\t\twriteStructuredError(stderr, errorMigrationCliInvalidConfigArg({ nextToken: err.message }));\n\t\treturn 2;\n\t}\n\tthrow err;\n}\n/**\n* Duck-type check for clipanion's `UnknownSyntaxError`: the class is\n* thrown by the parser but is not re-exported from the package's main\n* entry (only `UsageError` is — see clipanion's `advanced/index.d.ts`).\n* Identified by `name === 'UnknownSyntaxError'` and the\n* `clipanion.type === 'none'` discriminator that clipanion's\n* `ErrorWithMeta` interface guarantees.\n*/\nfunction isUnknownSyntaxError(err) {\n\tif (!(err instanceof Error) || err.name !== \"UnknownSyntaxError\") return false;\n\tconst meta = err.clipanion;\n\treturn typeof meta === \"object\" && meta !== null && meta.type === \"none\";\n}\n/**\n* Best-effort: pull the first input token that doesn't match a known\n* flag. Falls back to the first token when we can't pinpoint it. The\n* returned name is rendered into the user-visible CLI.UNKNOWN_FLAG envelope\n* (`Unknown flag \\`<name>\\``) and round-tripped via `meta.flag` so\n* agent consumers can render their own \"did you mean\" suggestions.\n*/\nfunction findOffendingFlag(input) {\n\tfor (const token of input) {\n\t\tif (!token.startsWith(\"-\")) continue;\n\t\tconst head = token.split(\"=\", 1)[0] ?? token;\n\t\tif (!KNOWN_FLAGS.includes(head) && head !== \"-h\") return head;\n\t}\n\treturn input[0] ?? \"\";\n}\n/**\n* Write a `CliStructuredError` envelope to the given stream: the code and\n* summary, then the why when it says more than the summary, then the fix. The\n* full PN code (`PN-<domain>-<code>`) is included so consumers can\n* grep for stable identifiers.\n*/\nfunction writeStructuredError(stream, err) {\n\tconst envelope = err.toEnvelope();\n\tconst why = envelope.why === void 0 || envelope.why === envelope.summary ? \"\" : `\\n${envelope.why}`;\n\tconst fix = envelope.fix ? `\\n${envelope.fix}` : \"\";\n\tstream.write(`${envelope.code}: ${envelope.summary}${why}${fix}\\n`);\n}\n/**\n* Read a previously-scaffolded `migration.json` from disk, returning\n* `null` when the file is missing and throwing `MIGRATION.INVALID_JSON`\n* when the file is present but cannot be parsed as JSON. The CLI feeds\n* this into `buildMigrationArtifacts` so the pure builder can preserve\n* fields owned by `migration plan` (contract bookends, `createdAt`) across\n* re-emits.\n*\n* Author-time path: this loader still does not verify the manifest hash\n* or schema — that is the apply-time loader's job. Hash mismatch is the\n* *expected* outcome of a re-author (the developer's source changes\n* invalidate the prior hash by construction), and verification here\n* would block legitimate regenerations. Syntactic JSON-parse failure,\n* however, is now surfaced rather than swallowed: a malformed\n* `migration.json` indicates either a hand-edit gone wrong or partial\n* write, and silently rebuilding from `describe()` would discard the\n* user's on-disk content (preserved bookends, `createdAt`) without any\n* indication something was wrong on disk.\n* Apply-time consumers always route through the verifying\n* `readMigrationPackage` in `@internal/migration-tools/io` instead.\n*/\nfunction readExistingMetadata(metadataPath) {\n\tlet raw;\n\ttry {\n\t\traw = readFileSync(metadataPath, \"utf-8\");\n\t} catch {\n\t\treturn null;\n\t}\n\ttry {\n\t\treturn JSON.parse(raw);\n\t} catch (e) {\n\t\tthrow errorInvalidJson(metadataPath, e instanceof Error ? e.message : String(e));\n\t}\n}\n/**\n* Persist a migration instance's artifacts to `migrationDir`. In\n* `dryRun` mode the artifacts are printed to stdout (with the same\n* `--- migration.json --- / --- ops.json ---` framing the legacy\n* `serializeMigration` helper used) and no files are written. Otherwise\n* `ops.json` and `migration.json` are written next to `migration.ts` and\n* a confirmation line is printed.\n*\n* File I/O lives in the CLI rather than `@internal/migration-tools`\n* so the migration-tools package stays focused on the pure\n* `Migration` → in-memory artifact conversion. The CLI is the only\n* legitimate site for combining config loading, stack assembly, and\n* filesystem persistence.\n*/\nasync function serializeMigrationToDisk(instance, migrationDir, dryRun, stdout) {\n\tconst metadataPath = join(migrationDir, \"migration.json\");\n\tconst { opsJson, metadataJson } = await buildMigrationArtifacts(instance, readExistingMetadata(metadataPath));\n\tif (dryRun) {\n\t\tstdout.write(`--- migration.json ---\\n${metadataJson}\\n`);\n\t\tstdout.write(\"--- ops.json ---\\n\");\n\t\tstdout.write(`${opsJson}\\n`);\n\t\treturn;\n\t}\n\twriteFileSync(join(migrationDir, \"ops.json\"), opsJson);\n\twriteFileSync(metadataPath, metadataJson);\n\tstdout.write(`Wrote ops.json + migration.json to ${migrationDir}\\n`);\n}\n/**\n* Inner orchestration: load config, probe-construct the migration,\n* verify target, assemble the stack, construct with the stack, persist.\n*\n* Throws `CliStructuredError` for known failure modes (config not\n* found, target mismatch); the outer `orchestrate` translates those to\n* exit 1.\n*/\nasync function runMigration(importMetaUrl, MigrationClass, parsed, ctx) {\n\tconst migrationFile = fileURLToPath(importMetaUrl);\n\tconst migrationDir = dirname(migrationFile);\n\tconst configResult = await loadMigrationFileConfig({\n\t\tconfigPath: parsed.config,\n\t\tmigrationFile,\n\t\tcwd: process.cwd(),\n\t\tsections: [\n\t\t\t\"family\",\n\t\t\t\"target\",\n\t\t\t\"adapter\",\n\t\t\t\"driver\",\n\t\t\t\"extensions\"\n\t\t]\n\t});\n\tif (!configResult.ok) throw configResult.failure;\n\tconst config = configResult.value;\n\tconst probe = new MigrationClass();\n\tif (probe.targetId !== config.target.targetId) throw errorMigrationTargetMismatch({\n\t\tmigrationTargetId: probe.targetId,\n\t\tconfigTargetId: config.target.targetId\n\t});\n\tawait serializeMigrationToDisk(new MigrationClass(createControlStack(config)), migrationDir, parsed.dryRun, ctx.stdout);\n\tctx.stderr;\n}\n//#endregion\nexport { MigrationCLI };\n\n//# sourceMappingURL=migration-cli.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,eAAe,wBAAwB,SAAS;CAC/C,MAAM,EAAE,YAAY,eAAe,KAAK,aAAa;CACrD,IAAI,eAAe,KAAK,GAAG,OAAO,sBAAsB,YAAY,QAAQ;CAC5E,MAAM,yBAAyB,KAAK,KAAK,eAAe;CACxD,MAAM,aAAa,CAA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AyB,UAAU,cAAc,QAAQ,QAAQ;CAC/E,MAAM,eAAe,KAAK,cAAc,gBAAgB;CACxD,MAAM,EAAE,SAAS,iBAAiB,MAAM,wBAAwB,UAAU,qBAAqB,YAAY,CAAC;CAC5G,IAAI,QAAQ;EACX,OAAO,MAAM,2BAA2B,aAAa,GAAG;EACxD,OAAO,MAAM,oBAAoB;EACjC,OAAO,MAAM,GAAG,QAAQ,GAAG;EAC3B;CACD;CACA,cAAc,KAAK,cAAc,UAAU,GAAG,OAAO;CACrD,cAAc,cAAc,YAAY;CACxC,OAAO,MAAM,sCAAsC,aAAa,GAAG;AACpE;;;;;;;;;AASA,eAAe,aAAa,eAAe,gBAAgB,QAAQ,KAAK;CACvE,MAAM,gBAAgB,cAAc,aAAa;CACjD,MAAM,eAAe,QAAQ,aAAa;CAC1C,MAAM,eAAe,MAAM,wBAAwB;EAClD,YAAY,OAAO;EACnB;EACA,KAAK,QAAQ,IAAI;EACjB,UAAU;GACT;GACA;GACA;GACA;GACA;EACD;CACD,CAAC;CACD,IAAI,CAAC,aAAa,IAAI,MAAM,aAAa;CACzC,MAAM,SAAS,aAAa;CAC5B,MAAM,QAAQ,IAAI,eAAe;CACjC,IAAI,MAAM,aAAa,OAAO,OAAO,UAAU,MAAM,6BAA6B;EACjF,mBAAmB,MAAM;EACzB,gBAAgB,OAAO,OAAO;CAC/B,CAAC;CACD,MAAM,yBAAyB,IAAI,eAAe,mBAAmB,MAAM,CAAC,GAAG,cAAc,OAAO,QAAQ,IAAI,MAAM;CACtH,IAAI;AACL"}
|
|
1
|
+
{"version":3,"file":"cli__migration-cli.mjs","names":[],"sources":["../../../../1-framework/3-tooling/cli/dist/migration-cli.mjs"],"sourcesContent":["import { b as migrationsDirFor, n as errorFromCaught } from \"./caught-errors-DZXnK8Ls.mjs\";\nimport { existsSync, readFileSync, realpathSync, writeFileSync } from \"node:fs\";\nimport { errorMigrationCliConfigNotFound, errorMigrationCliInvalidConfigArg, errorMigrationCliUnknownFlag } from \"@internal/errors/control\";\nimport { createControlStack } from \"@internal/framework-components/control\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { isStructuredError } from \"@internal/utils/structured-error\";\nimport { dirname, isAbsolute, join, relative } from \"pathe\";\nimport { errorMigrationTargetMismatch } from \"@internal/errors/migration\";\nimport { errorInvalidJson } from \"@internal/migration-tools/errors\";\nimport { CONFIG_FILENAME, findNearestConfigPathForFile, loadConfig, loadConfigForSections, requireConfigSections } from \"@internal/config-loader\";\nimport { fileURLToPath } from \"node:url\";\nimport { buildMigrationArtifacts } from \"@internal/migration-tools/migration\";\nimport { Cli, Command, Option, UsageError } from \"clipanion\";\n//#region src/utils/migration-file-config.ts\n/**\n* The config a `migration.ts` runs with. `--config` names it outright. Without it, the config is the one that owns the migration, whose migrations directory holds the file: the nearest `prisma.config.ts` above the migration, else the one in the working directory.\n*/\nasync function loadMigrationFileConfig(options) {\n\tconst { configPath, migrationFile, cwd, sections } = options;\n\tif (configPath !== void 0) return loadConfigForSections(configPath, sections);\n\tconst workingDirectoryConfig = join(cwd, CONFIG_FILENAME);\n\tconst candidates = [.../* @__PURE__ */ new Set([await findNearestConfigPathForFile(migrationFile), existsSync(workingDirectoryConfig) ? workingDirectoryConfig : void 0])].filter((candidate) => candidate !== void 0);\n\tconst checked = [];\n\tfor (const candidate of candidates) {\n\t\tconst loaded = await loadConfig(candidate);\n\t\tconst config = loaded.ok ? requireConfigSections(loaded.value, [...sections, \"migrations\"]) : loaded;\n\t\tif (!config.ok) {\n\t\t\tchecked.push({\n\t\t\t\tconfigPath: candidate,\n\t\t\t\tloadFailure: config.failure.message\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tif (ownsMigration(config.value, candidate, migrationFile)) return ok(config.value);\n\t\tchecked.push({\n\t\t\tconfigPath: candidate,\n\t\t\tmigrationsDir: migrationsDirFor(config.value, dirname(candidate))\n\t\t});\n\t}\n\treturn notOk(errorMigrationCliConfigNotFound({\n\t\tmigrationDir: dirname(migrationFile),\n\t\tchecked\n\t}));\n}\n/** Whether `migrationFile` is inside the migrations directory of the config at `configPath`. */\nfunction ownsMigration(config, configPath, migrationFile) {\n\tconst path = relative(realPath(migrationsDirFor(config, dirname(configPath))), realPath(migrationFile));\n\treturn path !== \"\" && !path.startsWith(\"..\") && !isAbsolute(path);\n}\nfunction realPath(path) {\n\treturn existsSync(path) ? realpathSync(path) : path;\n}\n//#endregion\n//#region src/migration-cli.ts\n/**\n* The migration-file CLI interface: the actor invoked when the author runs\n* `node migration.ts` directly.\n*\n* Naming: this is *not* a \"migration runner\" in the apply-time sense. The\n* apply-time runner is the thing `prisma db migrate` uses to\n* execute migration JSON ops against a database. `MigrationCLI` is the\n* tiny CLI surface owned by an authored `migration.ts` file: parse the\n* file's argv, load the project's `prisma.config.ts`, assemble a\n* `ControlStack`, instantiate the migration class, and serialize.\n*\n* The user authors a migration class, then calls\n* `MigrationCLI.run(import.meta.url, MigrationClass)` at module scope\n* after the class definition. When the file is invoked as a node\n* entrypoint (`node migration.ts`), the CLI:\n*\n* 1. Detects whether the file is the direct entrypoint (no-op when imported).\n* 2. Parses CLI args (`--help`, `--dry-run`, `--config <path>`) via\n* [clipanion](https://github.com/arcanis/clipanion).\n* 3. Loads the config `--config` names. Without it, loads the config that\n* owns the migration (see `loadMigrationFileConfig`).\n* 4. Probe-instantiates the migration class without a stack so it can read\n* `targetId` and verify it matches `config.target.targetId`\n* (`MIGRATION.TARGET_MISMATCH` on mismatch) before any stack-driven adapter\n* construction runs.\n* 5. Assembles a `ControlStack` from the loaded config descriptors and\n* constructs the migration with that stack.\n* 6. Reads any previously-scaffolded `migration.json`, then calls\n* `buildMigrationArtifacts` from `@internal/migration-tools` to\n* produce in-memory `ops.json` + `migration.json` content. Persists\n* the result to disk (or prints in dry-run mode).\n*\n* File I/O lives here, in `@internal/cli`: this is the only place\n* that legitimately combines config loading, stack assembly, and\n* on-disk persistence. `@internal/migration-tools` owns the pure\n* conversion from a `Migration` instance to artifact strings; `Migration`\n* stays a pure abstract class.\n*\n* Parser library: clipanion (chosen over Commander/citty/`node:util.parseArgs`\n* for its in-process testability and runtime-agnostic execution surface; see\n* `docs/architecture docs/research/commander-friction-points.md` for the\n* evaluation rubric and the durable rationale that drove the choice).\n*/\n/**\n* Flags exposed by the migration-file CLI.\n*\n* Must stay in sync with the `Option` declarations on\n* `MigrationFileCommand` below. This list is rendered in the\n* `errorMigrationCliUnknownFlag` envelope's `fix` text and `meta`,\n* so order matters for user-visible output (declaration order is the\n* order users see when they run `--help`).\n*/\nconst KNOWN_FLAGS = [\n\t\"--help\",\n\t\"--dry-run\",\n\t\"--config\"\n];\n/**\n* The clipanion command that owns the migration-file CLI's option\n* declarations. The class is internal — `MigrationCLI.run` is the\n* stable public surface. Adding a flag here automatically updates\n* `--help` rendering and the `KNOWN_FLAGS` list (the latter must be\n* updated in tandem).\n*/\nvar MigrationFileCommand = class extends Command {\n\tstatic paths = [Command.Default];\n\tstatic usage = Command.Usage({\n\t\tdescription: \"Self-emit ops.json and migration.json from a class-flow migration\",\n\t\tdetails: `\n Loads the project's prisma.config.ts, assembles a ControlStack\n from the configured target/adapter/extensions, and serializes the\n migration's operations + metadata next to this file.\n `,\n\t\texamples: [\n\t\t\t[\"Self-emit ops.json + migration.json next to migration.ts\", \"$0\"],\n\t\t\t[\"Preview without writing files\", \"$0 --dry-run\"],\n\t\t\t[\"Use a non-default config path\", \"$0 --config ./custom.config.ts\"]\n\t\t]\n\t});\n\tdryRun = Option.Boolean(\"--dry-run\", false, { description: \"Print operations to stdout without writing files\" });\n\tconfig = Option.String(\"--config\", { description: \"Path to prisma.config.ts\" });\n\t/**\n\t* Unused: orchestration runs inside `MigrationCLI.run` so error\n\t* routing stays under our control (clipanion's `cli.run` writes\n\t* error output to `context.stdout`, but our contract requires\n\t* structured errors on stderr). `cli.process` is used to parse\n\t* argv into a populated `MigrationFileCommand` instance whose\n\t* fields drive the orchestration directly.\n\t*/\n\tasync execute() {\n\t\treturn 0;\n\t}\n};\n/**\n* The CLI surface invoked by an authored `migration.ts` file. Exposed as\n* a class with a static `run` method (rather than a free function) to\n* give the concept a stable identity in the ubiquitous language: this is\n* the \"migration-file CLI\", distinct from the apply-time runner that\n* executes migration JSON ops.\n*\n* Currently a single static method. Future surface (e.g. a programmatic\n* `MigrationCLI.serializeOnly(...)` for tests, or extra subcommands) can\n* land here without changing the import shape used by every authored\n* migration.\n*/\nvar MigrationCLI = class {\n\t/**\n\t* Orchestrates a class-flow `migration.ts` script run.\n\t*\n\t* The third argument is the in-process testability surface: callers\n\t* (and tests) may inject `argv`, `stdout`, and `stderr` instead of\n\t* relying on `process.argv` / `process.stdout` / `process.stderr`.\n\t* Each option defaults to its `process` global when omitted, so\n\t* existing two-argument call sites\n\t* (`MigrationCLI.run(import.meta.url, MyMigration)`) continue to\n\t* compile and behave identically.\n\t*\n\t* Returns the exit code so the caller can branch on it. Also writes\n\t* the same code to `process.exitCode` so script-style callers that\n\t* don't await the return value still surface a non-zero exit when\n\t* something fails.\n\t*\n\t* Exit codes:\n\t* - 0 — success, or `--help`, or imported-not-entrypoint no-op.\n\t* - 1 — runtime/orchestration error (config not found, target\n\t* mismatch, etc.).\n\t* - 2 — usage error (unknown flag, malformed `--config`). Aligns\n\t* with `docs/CLI Style Guide.md` § Exit Codes.\n\t*/\n\tstatic async run(importMetaUrl, MigrationClass, options = {}) {\n\t\tif (!importMetaUrl) return 0;\n\t\tconst argv = options.argv ?? process.argv;\n\t\tconst stdout = options.stdout ?? process.stdout;\n\t\tconst stderr = options.stderr ?? process.stderr;\n\t\tif (!isDirectEntrypoint(importMetaUrl, argv)) return 0;\n\t\tconst exitCode = await orchestrate(importMetaUrl, MigrationClass, {\n\t\t\targv,\n\t\t\tstdout,\n\t\t\tstderr\n\t\t});\n\t\tif (exitCode !== 0 || !process.exitCode) process.exitCode = exitCode;\n\t\treturn exitCode;\n\t}\n};\n/**\n* Argv-aware variant of the entrypoint guard. The shared\n* `@internal/migration-tools` helper of the same name reads\n* `process.argv[1]` directly, which doesn't compose with the new\n* in-process testability surface (tests inject `argv` without mutating\n* the process global). Inlined here so the migration-file CLI's check\n* follows the injected `argv[1]` consistently.\n*/\nfunction isDirectEntrypoint(importMetaUrl, argv) {\n\tconst argv1 = argv[1];\n\tif (!argv1) return false;\n\ttry {\n\t\treturn realpathSync(fileURLToPath(importMetaUrl)) === realpathSync(argv1);\n\t} catch {\n\t\treturn false;\n\t}\n}\n/**\n* Argv-and-stream-driven orchestration body. Pulled out of the static\n* method so the entrypoint guard / process-default plumbing stays\n* separate from the parse + load + serialize steps.\n*/\nasync function orchestrate(importMetaUrl, MigrationClass, ctx) {\n\tconst cli = Cli.from([MigrationFileCommand], {\n\t\tbinaryName: \"migration.ts\",\n\t\tbinaryLabel: \"Migration file CLI\"\n\t});\n\tconst input = ctx.argv.slice(2);\n\tconst configError = detectInvalidConfig(input);\n\tif (configError) {\n\t\twriteStructuredError(ctx.stderr, configError);\n\t\treturn 2;\n\t}\n\tlet parsed;\n\ttry {\n\t\tconst command = cli.process({\n\t\t\tinput: [...input],\n\t\t\tcontext: {\n\t\t\t\tstdout: ctx.stdout,\n\t\t\t\tstderr: ctx.stderr\n\t\t\t}\n\t\t});\n\t\tif (!(command instanceof MigrationFileCommand)) {\n\t\t\tctx.stdout.write(cli.usage(MigrationFileCommand, { detailed: true }));\n\t\t\treturn 0;\n\t\t}\n\t\tparsed = command;\n\t} catch (err) {\n\t\treturn renderParseError(err, input, ctx.stderr);\n\t}\n\tif (parsed.help) {\n\t\tctx.stdout.write(cli.usage(MigrationFileCommand, { detailed: true }));\n\t\treturn 0;\n\t}\n\ttry {\n\t\tawait runMigration(importMetaUrl, MigrationClass, parsed, ctx);\n\t\treturn 0;\n\t} catch (err) {\n\t\tif (isStructuredError(err)) writeStructuredError(ctx.stderr, errorFromCaught(err, (message) => message));\n\t\telse ctx.stderr.write(`${err instanceof Error ? err.message : String(err)}\\n`);\n\t\treturn 1;\n\t}\n}\n/**\n* Returns an `errorMigrationCliInvalidConfigArg` envelope when `input`\n* contains a malformed `--config`:\n*\n* - `--config` as the last token (no value follows).\n* - `--config <flag>` where `<flag>` starts with `-` (silently\n* consuming the next flag would either drop the flag or serialize\n* against the wrong project).\n* - `--config <empty>` where the value is the empty string. Shells\n* expand `--config \"\"` (or `--config \"$UNSET_VAR\"`) into a real\n* empty argv token; treating that as a usage error here surfaces\n* `CLI.CONFIG_ARG_MISSING_PATH` instead of a less actionable loader error on an\n* empty path.\n* - `--config=` (the equals form with an empty value). Same shape as\n* the empty-string case above; the user expressed intent to override\n* the config path but the override is empty.\n*\n* `--config=<value>` and `--config <value>` with a non-empty value are\n* both valid (and the equals form's value is allowed to start with\n* `-` — the `=` makes the binding explicit).\n*/\nfunction detectInvalidConfig(input) {\n\tfor (let i = 0; i < input.length; i++) {\n\t\tconst token = input[i];\n\t\tif (token === \"--config\") {\n\t\t\tconst next = input[i + 1];\n\t\t\tif (next === void 0 || next === \"\") return errorMigrationCliInvalidConfigArg();\n\t\t\tif (next.startsWith(\"-\")) return errorMigrationCliInvalidConfigArg({ nextToken: next });\n\t\t\tcontinue;\n\t\t}\n\t\tif (token === \"--config=\") return errorMigrationCliInvalidConfigArg();\n\t}\n\treturn null;\n}\n/**\n* Translate clipanion's parse-time errors into the project's structured\n* error envelopes.\n*\n* - `UnknownSyntaxError` covers both unknown flags (`--frobnicate`) and\n* the bare-trailing `--config` case (where arity-1 needs a value but\n* none was supplied). Distinguished by inspecting the input array.\n* - `UsageError` covers schema/validator failures from typanion. None\n* of the migration-file CLI's options have validators today, but we\n* still translate it as a usage error (exit 2) for forward-compat.\n* - Anything else re-throws — caller's outer catch will surface it as\n* exit 1 (runtime error).\n*/\nfunction renderParseError(err, input, stderr) {\n\tif (isUnknownSyntaxError(err)) {\n\t\twriteStructuredError(stderr, errorMigrationCliUnknownFlag({\n\t\t\tflag: findOffendingFlag(input),\n\t\t\tknownFlags: KNOWN_FLAGS\n\t\t}));\n\t\treturn 2;\n\t}\n\tif (err instanceof UsageError) {\n\t\twriteStructuredError(stderr, errorMigrationCliInvalidConfigArg({ nextToken: err.message }));\n\t\treturn 2;\n\t}\n\tthrow err;\n}\n/**\n* Duck-type check for clipanion's `UnknownSyntaxError`: the class is\n* thrown by the parser but is not re-exported from the package's main\n* entry (only `UsageError` is — see clipanion's `advanced/index.d.ts`).\n* Identified by `name === 'UnknownSyntaxError'` and the\n* `clipanion.type === 'none'` discriminator that clipanion's\n* `ErrorWithMeta` interface guarantees.\n*/\nfunction isUnknownSyntaxError(err) {\n\tif (!(err instanceof Error) || err.name !== \"UnknownSyntaxError\") return false;\n\tconst meta = err.clipanion;\n\treturn typeof meta === \"object\" && meta !== null && meta.type === \"none\";\n}\n/**\n* Best-effort: pull the first input token that doesn't match a known\n* flag. Falls back to the first token when we can't pinpoint it. The\n* returned name is rendered into the user-visible CLI.UNKNOWN_FLAG envelope\n* (`Unknown flag \\`<name>\\``) and round-tripped via `meta.flag` so\n* agent consumers can render their own \"did you mean\" suggestions.\n*/\nfunction findOffendingFlag(input) {\n\tfor (const token of input) {\n\t\tif (!token.startsWith(\"-\")) continue;\n\t\tconst head = token.split(\"=\", 1)[0] ?? token;\n\t\tif (!KNOWN_FLAGS.includes(head) && head !== \"-h\") return head;\n\t}\n\treturn input[0] ?? \"\";\n}\n/**\n* Write a `CliStructuredError` envelope to the given stream: the code and\n* summary, then the why when it says more than the summary, then the fix. The\n* full PN code (`PN-<domain>-<code>`) is included so consumers can\n* grep for stable identifiers.\n*/\nfunction writeStructuredError(stream, err) {\n\tconst envelope = err.toEnvelope();\n\tconst why = envelope.why === void 0 || envelope.why === envelope.summary ? \"\" : `\\n${envelope.why}`;\n\tconst fix = envelope.fix ? `\\n${envelope.fix}` : \"\";\n\tstream.write(`${envelope.code}: ${envelope.summary}${why}${fix}\\n`);\n}\n/**\n* Read a previously-scaffolded `migration.json` from disk, returning\n* `null` when the file is missing and throwing `MIGRATION.INVALID_JSON`\n* when the file is present but cannot be parsed as JSON. The CLI feeds\n* this into `buildMigrationArtifacts` so the pure builder can preserve\n* fields owned by `migration plan` (contract bookends, `createdAt`) across\n* re-emits.\n*\n* Author-time path: this loader still does not verify the manifest hash\n* or schema — that is the apply-time loader's job. Hash mismatch is the\n* *expected* outcome of a re-author (the developer's source changes\n* invalidate the prior hash by construction), and verification here\n* would block legitimate regenerations. Syntactic JSON-parse failure,\n* however, is now surfaced rather than swallowed: a malformed\n* `migration.json` indicates either a hand-edit gone wrong or partial\n* write, and silently rebuilding from `describe()` would discard the\n* user's on-disk content (preserved bookends, `createdAt`) without any\n* indication something was wrong on disk.\n* Apply-time consumers always route through the verifying\n* `readMigrationPackage` in `@internal/migration-tools/io` instead.\n*/\nfunction readExistingMetadata(metadataPath) {\n\tlet raw;\n\ttry {\n\t\traw = readFileSync(metadataPath, \"utf-8\");\n\t} catch {\n\t\treturn null;\n\t}\n\ttry {\n\t\treturn JSON.parse(raw);\n\t} catch (e) {\n\t\tthrow errorInvalidJson(metadataPath, e instanceof Error ? e.message : String(e));\n\t}\n}\n/**\n* Persist a migration instance's artifacts to `migrationDir`. In\n* `dryRun` mode the artifacts are printed to stdout (with the same\n* `--- migration.json --- / --- ops.json ---` framing the legacy\n* `serializeMigration` helper used) and no files are written. Otherwise\n* `ops.json` and `migration.json` are written next to `migration.ts` and\n* a confirmation line is printed.\n*\n* File I/O lives in the CLI rather than `@internal/migration-tools`\n* so the migration-tools package stays focused on the pure\n* `Migration` → in-memory artifact conversion. The CLI is the only\n* legitimate site for combining config loading, stack assembly, and\n* filesystem persistence.\n*/\nasync function serializeMigrationToDisk(instance, migrationDir, dryRun, stdout) {\n\tconst metadataPath = join(migrationDir, \"migration.json\");\n\tconst { opsJson, metadataJson } = await buildMigrationArtifacts(instance, readExistingMetadata(metadataPath));\n\tif (dryRun) {\n\t\tstdout.write(`--- migration.json ---\\n${metadataJson}\\n`);\n\t\tstdout.write(\"--- ops.json ---\\n\");\n\t\tstdout.write(`${opsJson}\\n`);\n\t\treturn;\n\t}\n\twriteFileSync(join(migrationDir, \"ops.json\"), opsJson);\n\twriteFileSync(metadataPath, metadataJson);\n\tstdout.write(`Wrote ops.json + migration.json to ${migrationDir}\\n`);\n}\n/**\n* Inner orchestration: load config, probe-construct the migration,\n* verify target, assemble the stack, construct with the stack, persist.\n*\n* Throws `CliStructuredError` for known failure modes (config not\n* found, target mismatch); the outer `orchestrate` translates those to\n* exit 1.\n*/\nasync function runMigration(importMetaUrl, MigrationClass, parsed, ctx) {\n\tconst migrationFile = fileURLToPath(importMetaUrl);\n\tconst migrationDir = dirname(migrationFile);\n\tconst configResult = await loadMigrationFileConfig({\n\t\tconfigPath: parsed.config,\n\t\tmigrationFile,\n\t\tcwd: process.cwd(),\n\t\tsections: [\n\t\t\t\"family\",\n\t\t\t\"target\",\n\t\t\t\"adapter\",\n\t\t\t\"driver\",\n\t\t\t\"extensions\"\n\t\t]\n\t});\n\tif (!configResult.ok) throw configResult.failure;\n\tconst config = configResult.value;\n\tconst probe = new MigrationClass();\n\tif (probe.targetId !== config.target.targetId) throw errorMigrationTargetMismatch({\n\t\tmigrationTargetId: probe.targetId,\n\t\tconfigTargetId: config.target.targetId\n\t});\n\tawait serializeMigrationToDisk(new MigrationClass(createControlStack(config)), migrationDir, parsed.dryRun, ctx.stdout);\n\tctx.stderr;\n}\n//#endregion\nexport { MigrationCLI };\n\n//# sourceMappingURL=migration-cli.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,eAAe,wBAAwB,SAAS;CAC/C,MAAM,EAAE,YAAY,eAAe,KAAK,aAAa;CACrD,IAAI,eAAe,KAAK,GAAG,OAAO,sBAAsB,YAAY,QAAQ;CAC5E,MAAM,yBAAyB,KAAK,KAAK,eAAe;CACxD,MAAM,aAAa,CAAC,mBAAmB,IAAI,IAAI,CAAC,MAAM,6BAA6B,aAAa,GAAG,WAAW,sBAAsB,IAAI,yBAAyB,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,cAAc,cAAc,KAAK,CAAC;CACrN,MAAM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;EACX,OAAO,MAAM,2BAA2B,aAAa,GAAG;EACxD,OAAO,MAAM,oBAAoB;EACjC,OAAO,MAAM,GAAG,QAAQ,GAAG;EAC3B;CACD;CACA,cAAc,KAAK,cAAc,UAAU,GAAG,OAAO;CACrD,cAAc,cAAc,YAAY;CACxC,OAAO,MAAM,sCAAsC,aAAa,GAAG;AACpE;;;;;;;;;AASA,eAAe,aAAa,eAAe,gBAAgB,QAAQ,KAAK;CACvE,MAAM,gBAAgB,cAAc,aAAa;CACjD,MAAM,eAAe,QAAQ,aAAa;CAC1C,MAAM,eAAe,MAAM,wBAAwB;EAClD,YAAY,OAAO;EACnB;EACA,KAAK,QAAQ,IAAI;EACjB,UAAU;GACT;GACA;GACA;GACA;GACA;EACD;CACD,CAAC;CACD,IAAI,CAAC,aAAa,IAAI,MAAM,aAAa;CACzC,MAAM,SAAS,aAAa;CAC5B,MAAM,QAAQ,IAAI,eAAe;CACjC,IAAI,MAAM,aAAa,OAAO,OAAO,UAAU,MAAM,6BAA6B;EACjF,mBAAmB,MAAM;EACzB,gBAAgB,OAAO,OAAO;CAC/B,CAAC;CACD,MAAM,yBAAyB,IAAI,eAAe,mBAAmB,MAAM,CAAC,GAAG,cAAc,OAAO,QAAQ,IAAI,MAAM;CACtH,IAAI;AACL"}
|
package/dist/config-loader.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as validateOrmSection, a as expandContractInputs, c as globContractInputMatching, d as loadConfigFiles, f as loadConfigForFile, g as requireConfigSections, h as ormConfigSection, i as evaluateConfigModule, l as isConfigSection, m as ormConfigSchema, n as ORM_CONFIG_SECTION_NAME, p as loadConfigForSections, r as buildLoadedConfig, s as findNearestConfigPathForFile, t as CONFIG_FILENAME, u as loadConfig } from "./exports-
|
|
1
|
+
import { _ as validateOrmSection, a as expandContractInputs, c as globContractInputMatching, d as loadConfigFiles, f as loadConfigForFile, g as requireConfigSections, h as ormConfigSection, i as evaluateConfigModule, l as isConfigSection, m as ormConfigSchema, n as ORM_CONFIG_SECTION_NAME, p as loadConfigForSections, r as buildLoadedConfig, s as findNearestConfigPathForFile, t as CONFIG_FILENAME, u as loadConfig } from "./exports-DNFYCa6U.mjs";
|
|
2
2
|
export { CONFIG_FILENAME, ORM_CONFIG_SECTION_NAME, buildLoadedConfig, evaluateConfigModule, expandContractInputs, findNearestConfigPathForFile, globContractInputMatching, isConfigSection, loadConfig, loadConfigFiles, loadConfigForFile, loadConfigForSections, ormConfigSchema, ormConfigSection, requireConfigSections, validateOrmSection };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as SnapshotCanonicalizationHooks } from "./hash-DclMqd7S-
|
|
1
|
+
import { t as SnapshotCanonicalizationHooks } from "./hash-DclMqd7S-Dddl_NeA.mjs";
|
|
2
2
|
//#region ../../../1-framework/3-tooling/migration/dist/contract-snapshot-store-DRAG5XXy.d.mts
|
|
3
3
|
//#region src/contract-snapshot-store.d.ts
|
|
4
4
|
declare function contractSnapshotDir(migrationsDir: string, storageHash: string): string;
|
|
@@ -69,4 +69,4 @@ declare function readContractSnapshotJsonTolerant(migrationsDir: string, storage
|
|
|
69
69
|
declare function snapshotsImportPathFrom(packageDir: string, migrationsDir: string): string;
|
|
70
70
|
//#endregion
|
|
71
71
|
export { createSnapshotContentVerifier as a, readContractSnapshotJsonTolerant as c, writeContractSnapshot as d, contractSnapshotFiles as i, singleLineDeclarations as l, SnapshotContentVerifier as n, hasContractSnapshot as o, contractSnapshotDir as r, readContractSnapshotJson as s, ContractSnapshotInput as t, snapshotsImportPathFrom as u };
|
|
72
|
-
//# sourceMappingURL=contract-snapshot-store-DRAG5XXy-
|
|
72
|
+
//# sourceMappingURL=contract-snapshot-store-DRAG5XXy-ChW4hBLb.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract-snapshot-store-DRAG5XXy-
|
|
1
|
+
{"version":3,"file":"contract-snapshot-store-DRAG5XXy-ChW4hBLb.d.mts","names":[],"sources":["../../../../1-framework/3-tooling/migration/dist/contract-snapshot-store-DRAG5XXy.d.mts"],"mappings":";;;iBAEiB,oBAAoB,uBAAuB;;iBAE3C,oBAAoB,uBAAuB,sBAAsB;;;;;;;;;;;;;;UAcxE;;;;;;EAMR,6BAA6B,uBAAuB,qBAAqB;;iBAE1D,8BAA8B,QAAQ,gCAAgC;UAC7E;WACC;WACA;;;;;;;iBAOM,uBAAuB;;iBAEvB,sBAAsB,OAAO;WACnC;WACA;;iBAEM,sBAAsB,uBAAuB,qBAAqB,OAAO,wBAAwB;WACvG;WACA;;;;;;;;iBAQM,yBAAyB,uBAAuB,qBAAqB,gBAAgB,0BAA0B;;;;;;;;;;;;;;iBAc/G,iCAAiC,uBAAuB,qBAAqB,gBAAgB,0BAA0B;iBACvH,wBAAwB,oBAAoB"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { a as errorContractSnapshotHashMismatch, g as errorInvalidJson, i as errorContractSnapshotContentMismatch, o as errorContractSnapshotMissing, t as MigrationToolsError } from "./errors-
|
|
1
|
+
import { a as errorContractSnapshotHashMismatch, g as errorInvalidJson, i as errorContractSnapshotContentMismatch, o as errorContractSnapshotMissing, t as MigrationToolsError } from "./errors-BlaB9AFz-CZDOC0mV.mjs";
|
|
2
2
|
import { n as recomputePublishedStorageHash } from "./hash-BAZVWU4a-BQovI7hF.mjs";
|
|
3
3
|
import { CONTRACT_SNAPSHOTS_DIRNAME, storageHashHex } from "@prisma/orm-framework/components/control";
|
|
4
4
|
import { InternalError } from "@prisma/orm-framework/utils/internal-error";
|
|
5
5
|
import { join, relative } from "pathe";
|
|
6
|
-
import { mkdir, readFile, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
7
6
|
import { randomBytes } from "node:crypto";
|
|
8
7
|
import { canonicalizeJson } from "@prisma/orm-framework/components/utils";
|
|
9
8
|
import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
10
|
-
|
|
9
|
+
import { mkdir, readFile, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
10
|
+
//#region ../../../1-framework/3-tooling/migration/dist/contract-snapshot-store-Dl6v-Uxr.mjs
|
|
11
11
|
const CONTRACT_JSON_FILE = "contract.json";
|
|
12
12
|
const CONTRACT_DTS_FILE = "contract.d.ts";
|
|
13
13
|
function hasErrnoCode(error, code) {
|
|
@@ -194,4 +194,4 @@ function snapshotsImportPathFrom(packageDir, migrationsDir) {
|
|
|
194
194
|
//#endregion
|
|
195
195
|
export { readContractSnapshotJson as a, snapshotsImportPathFrom as c, hasContractSnapshot as i, writeContractSnapshot as l, contractSnapshotFiles as n, readContractSnapshotJsonTolerant as o, createSnapshotContentVerifier as r, singleLineDeclarations as s, contractSnapshotDir as t };
|
|
196
196
|
|
|
197
|
-
//# sourceMappingURL=contract-snapshot-store-
|
|
197
|
+
//# sourceMappingURL=contract-snapshot-store-Dl6v-Uxr-CwhnMsgc.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract-snapshot-store-Ds7lE7vL-Dn444yIq.mjs","names":[],"sources":["../../../../1-framework/3-tooling/migration/dist/contract-snapshot-store-Ds7lE7vL.mjs"],"sourcesContent":["import { a as errorContractSnapshotHashMismatch, g as errorInvalidJson, i as errorContractSnapshotContentMismatch, o as errorContractSnapshotMissing, t as MigrationToolsError } from \"./errors-BMq40nYH.mjs\";\nimport { n as recomputePublishedStorageHash } from \"./hash-BAZVWU4a.mjs\";\nimport { CONTRACT_SNAPSHOTS_DIRNAME, storageHashHex } from \"@internal/framework-components/control\";\nimport { join, relative } from \"pathe\";\nimport { mkdir, readFile, rename, rm, stat, writeFile } from \"node:fs/promises\";\nimport { randomBytes } from \"node:crypto\";\nimport { canonicalizeJson } from \"@internal/framework-components/utils\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { InternalError } from \"@internal/utils/internal-error\";\n//#region src/contract-snapshot-store.ts\nconst CONTRACT_JSON_FILE = \"contract.json\";\nconst CONTRACT_DTS_FILE = \"contract.d.ts\";\nfunction hasErrnoCode(error, code) {\n\treturn error instanceof Error && blindCast(error).code === code;\n}\nasync function directoryExists(p) {\n\ttry {\n\t\treturn (await stat(p)).isDirectory();\n\t} catch (error) {\n\t\tif (hasErrnoCode(error, \"ENOENT\")) return false;\n\t\tthrow error;\n\t}\n}\nfunction contractSnapshotDir(migrationsDir, storageHash) {\n\treturn join(migrationsDir, CONTRACT_SNAPSHOTS_DIRNAME, storageHashHex(storageHash));\n}\n/** Whether the store holds a snapshot for `storageHash`, so `writeContractSnapshot` would write nothing. */\nfunction hasContractSnapshot(migrationsDir, storageHash) {\n\treturn directoryExists(contractSnapshotDir(migrationsDir, storageHash));\n}\nfunction createSnapshotContentVerifier(hooks) {\n\treturn { assertSnapshotContentMatches(contractJson, storageHash, jsonPath) {\n\t\tconst record = blindCast(contractJson ?? {});\n\t\tconst computedHash = recomputePublishedStorageHash({\n\t\t\ttarget: record.target,\n\t\t\ttargetFamily: record.targetFamily,\n\t\t\tstorage: record.storage,\n\t\t\thooks\n\t\t});\n\t\tif (computedHash !== storageHash) throw errorContractSnapshotContentMismatch({\n\t\t\tstorageHash,\n\t\t\tcomputedHash,\n\t\t\tjsonPath\n\t\t});\n\t} };\n}\n/**\n* `text` on one line ending in a newline: leading `//` comment lines become one block comment, and every other line\n* break with the indentation that follows it becomes one space. Throws `InternalError` for text it cannot join\n* without changing its meaning.\n*/\nfunction singleLineDeclarations(text) {\n\tconst lines = text.split(/\\r?\\n/).map((line) => line.trim());\n\tconst firstCodeLine = lines.findIndex((line) => line !== \"\" && !line.startsWith(\"//\"));\n\tconst headerLength = firstCodeLine === -1 ? lines.length : firstCodeLine;\n\tconst headerLines = lines.slice(0, headerLength).filter((line) => line !== \"\");\n\tconst codeLines = lines.slice(headerLength).filter((line) => line !== \"\");\n\tconst directive = headerLines.find((line) => line.startsWith(\"///\"));\n\tif (directive !== void 0) throw new InternalError(`Cannot join declarations onto one line: the triple-slash directive \"${directive}\" would become a comment`);\n\tconst closingHeaderLine = headerLines.find((line) => line.includes(\"*/\"));\n\tif (closingHeaderLine !== void 0) throw new InternalError(`Cannot join declarations onto one line: the header line \"${closingHeaderLine}\" contains \"*/\"`);\n\tconst lineComment = lineWithLineComment(codeLines);\n\tif (lineComment !== void 0) throw new InternalError(`Cannot join declarations onto one line: the line comment in \"${lineComment}\" after the header would hide the code after it`);\n\tconst header = headerLines.map((line) => line.slice(2).trim()).filter((line) => line !== \"\");\n\treturn `${(header.length > 0 ? [`/* ${header.join(\" \")} */`, ...codeLines] : codeLines).join(\" \")}\\n`;\n}\nfunction lineWithLineComment(lines) {\n\tlet inBlockComment = false;\n\tlet quote;\n\tfor (const line of lines) for (let i = 0; i < line.length; i++) {\n\t\tconst pair = line.slice(i, i + 2);\n\t\tif (inBlockComment) {\n\t\t\tif (pair === \"*/\") {\n\t\t\t\tinBlockComment = false;\n\t\t\t\ti++;\n\t\t\t}\n\t\t} else if (quote !== void 0) {\n\t\t\tif (line[i] === \"\\\\\") i++;\n\t\t\telse if (line[i] === quote) quote = void 0;\n\t\t} else if (pair === \"/*\") {\n\t\t\tinBlockComment = true;\n\t\t\ti++;\n\t\t} else if (pair === \"//\") return line;\n\t\telse if (line[i] === \"'\" || line[i] === \"\\\"\" || line[i] === \"`\") quote = line[i];\n\t}\n}\n/** The bytes the store writes for `input`: `contract.json` and `contract.d.ts`. */\nfunction contractSnapshotFiles(input) {\n\treturn {\n\t\tcontractJson: `${canonicalizeJson(input.contractJson)}\\n`,\n\t\tcontractDts: singleLineDeclarations(input.contractDts)\n\t};\n}\nasync function writeContractSnapshot(migrationsDir, storageHash, input) {\n\tconst dir = contractSnapshotDir(migrationsDir, storageHash);\n\tconst actualStorageHash = blindCast(input.contractJson).storage?.storageHash;\n\tif (actualStorageHash !== storageHash) throw errorContractSnapshotHashMismatch(storageHash, typeof actualStorageHash === \"string\" ? actualStorageHash : String(actualStorageHash), dir);\n\tif (await hasContractSnapshot(migrationsDir, storageHash)) return {\n\t\twritten: false,\n\t\tdir\n\t};\n\tconst tmpDir = join(join(migrationsDir, CONTRACT_SNAPSHOTS_DIRNAME), `.tmp-${storageHashHex(storageHash)}-${Date.now()}-${randomBytes(4).toString(\"hex\")}`);\n\tawait mkdir(tmpDir, { recursive: true });\n\tconst files = contractSnapshotFiles(input);\n\ttry {\n\t\tawait writeFile(join(tmpDir, CONTRACT_JSON_FILE), files.contractJson);\n\t\tawait writeFile(join(tmpDir, CONTRACT_DTS_FILE), files.contractDts);\n\t\tawait rename(tmpDir, dir);\n\t} catch (error) {\n\t\tawait rm(tmpDir, {\n\t\t\trecursive: true,\n\t\t\tforce: true\n\t\t});\n\t\tif (hasErrnoCode(error, \"EEXIST\") || hasErrnoCode(error, \"ENOTEMPTY\")) return {\n\t\t\twritten: false,\n\t\t\tdir\n\t\t};\n\t\tthrow error;\n\t}\n\treturn {\n\t\twritten: true,\n\t\tdir\n\t};\n}\n/**\n* When `verifyContent` is supplied, the parsed snapshot's content is checked\n* against the hash it was addressed by before being returned — the store is\n* content-addressed, and a snapshot edited in place under an unchanged hash\n* would otherwise flow into planning as if it were the recorded contract.\n*/\nasync function readContractSnapshotJson(migrationsDir, storageHash, verifyContent) {\n\tconst jsonPath = join(contractSnapshotDir(migrationsDir, storageHash), CONTRACT_JSON_FILE);\n\tlet raw;\n\ttry {\n\t\traw = await readFile(jsonPath, \"utf-8\");\n\t} catch (error) {\n\t\tif (hasErrnoCode(error, \"ENOENT\")) throw errorContractSnapshotMissing(storageHash, jsonPath);\n\t\tthrow error;\n\t}\n\tlet parsed;\n\ttry {\n\t\tparsed = JSON.parse(raw);\n\t} catch (e) {\n\t\tthrow errorInvalidJson(jsonPath, e instanceof Error ? e.message : String(e));\n\t}\n\tverifyContent?.assertSnapshotContentMatches(parsed, storageHash, jsonPath);\n\treturn parsed;\n}\n/**\n* Tolerant read: a missing store entry (ENOENT), an unparseable\n* `contract.json`, the JSON literal `null`, or a `storageHash` that isn't a\n* well-formed 64-hex value all resolve to `undefined` rather than\n* throwing — parity with the catch-all tolerance of the pre-store\n* `readEndContractJson` (`io.ts`), which never validated the hash it was\n* keyed by either. Any other fs error (e.g. `EACCES` on a present-but-\n* unreadable file) propagates rather than silently loading a contract-less\n* package. When `verifyContent` is supplied, an entry whose content does not\n* recompute to its address also resolves to `undefined` — tampered content\n* must not flow onward, and the strict store reads report the same file\n* loudly as `MIGRATION.CONTRACT_SNAPSHOT_CONTENT_MISMATCH`.\n*/\nasync function readContractSnapshotJsonTolerant(migrationsDir, storageHash, verifyContent) {\n\tlet jsonPath;\n\ttry {\n\t\tjsonPath = join(contractSnapshotDir(migrationsDir, storageHash), CONTRACT_JSON_FILE);\n\t} catch {\n\t\treturn;\n\t}\n\tlet raw;\n\ttry {\n\t\traw = await readFile(jsonPath, \"utf-8\");\n\t} catch (error) {\n\t\tif (hasErrnoCode(error, \"ENOENT\")) return;\n\t\tthrow error;\n\t}\n\tlet parsed;\n\ttry {\n\t\tparsed = JSON.parse(raw);\n\t} catch {\n\t\treturn;\n\t}\n\tif (parsed === null) return;\n\ttry {\n\t\tverifyContent?.assertSnapshotContentMatches(parsed, storageHash, jsonPath);\n\t} catch (error) {\n\t\tif (MigrationToolsError.is(error) && error.code === \"MIGRATION.CONTRACT_SNAPSHOT_CONTENT_MISMATCH\") return;\n\t\tthrow error;\n\t}\n\treturn parsed;\n}\nfunction snapshotsImportPathFrom(packageDir, migrationsDir) {\n\treturn relative(packageDir, join(migrationsDir, CONTRACT_SNAPSHOTS_DIRNAME)).split(\"\\\\\").join(\"/\");\n}\n//#endregion\nexport { readContractSnapshotJson as a, snapshotsImportPathFrom as c, hasContractSnapshot as i, writeContractSnapshot as l, contractSnapshotFiles as n, readContractSnapshotJsonTolerant as o, createSnapshotContentVerifier as r, singleLineDeclarations as s, contractSnapshotDir as t };\n\n//# sourceMappingURL=contract-snapshot-store-Ds7lE7vL.mjs.map"],"mappings":";;;;;;;;;;AAUA,MAAM,qBAAqB;AAC3B,MAAM,oBAAoB;AAC1B,SAAS,aAAa,OAAO,MAAM;CAClC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A,eAAe,6BAA6B,QAAQ,aAAa,QAAQ;CACzE,OAAO;AACR;;;;;;;;;;;;;;AAcA,eAAe,iCAAiC,eAAe,aAAa,eAAe;CAC1F,IAAI;CACJ,IAAI;EACH,WAAW,KAAK,oBAAoB,eAAe,WAAW,GAAG,kBAAkB;CACpF,QAAQ;EACP;CACD;CACA,IAAI;CACJ,IAAI;EACH,MAAM,MAAM,SAAS,UAAU,OAAO;CACvC,SAAS,OAAO;EACf,IAAI,aAAa,OAAO,QAAQ,GAAG;EACnC,MAAM;CACP;CACA,IAAI;CACJ,IAAI;EACH,SAAS,KAAK,MAAM,GAAG;CACxB,QAAQ;EACP;CACD;CACA,IAAI,WAAW,MAAM;CACrB,IAAI;EACH,eAAe,6BAA6B,QAAQ,aAAa,QAAQ;CAC1E,SAAS,OAAO;EACf,IAAI,oBAAoB,GAAG,KAAK,KAAK,MAAM,SAAS,gDAAgD;EACpG,MAAM;CACP;CACA,OAAO;AACR;AACA,SAAS,wBAAwB,YAAY,eAAe;CAC3D,OAAO,SAAS,YAAY,KAAK,eAAe,0BAA0B,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,KAAK,GAAG;AAClG"}
|
|
1
|
+
{"version":3,"file":"contract-snapshot-store-Dl6v-Uxr-CwhnMsgc.mjs","names":[],"sources":["../../../../1-framework/3-tooling/migration/dist/contract-snapshot-store-Dl6v-Uxr.mjs"],"sourcesContent":["import { a as errorContractSnapshotHashMismatch, g as errorInvalidJson, i as errorContractSnapshotContentMismatch, o as errorContractSnapshotMissing, t as MigrationToolsError } from \"./errors-BlaB9AFz.mjs\";\nimport { n as recomputePublishedStorageHash } from \"./hash-BAZVWU4a.mjs\";\nimport { CONTRACT_SNAPSHOTS_DIRNAME, storageHashHex } from \"@internal/framework-components/control\";\nimport { join, relative } from \"pathe\";\nimport { mkdir, readFile, rename, rm, stat, writeFile } from \"node:fs/promises\";\nimport { randomBytes } from \"node:crypto\";\nimport { canonicalizeJson } from \"@internal/framework-components/utils\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { InternalError } from \"@internal/utils/internal-error\";\n//#region src/contract-snapshot-store.ts\nconst CONTRACT_JSON_FILE = \"contract.json\";\nconst CONTRACT_DTS_FILE = \"contract.d.ts\";\nfunction hasErrnoCode(error, code) {\n\treturn error instanceof Error && blindCast(error).code === code;\n}\nasync function directoryExists(p) {\n\ttry {\n\t\treturn (await stat(p)).isDirectory();\n\t} catch (error) {\n\t\tif (hasErrnoCode(error, \"ENOENT\")) return false;\n\t\tthrow error;\n\t}\n}\nfunction contractSnapshotDir(migrationsDir, storageHash) {\n\treturn join(migrationsDir, CONTRACT_SNAPSHOTS_DIRNAME, storageHashHex(storageHash));\n}\n/** Whether the store holds a snapshot for `storageHash`, so `writeContractSnapshot` would write nothing. */\nfunction hasContractSnapshot(migrationsDir, storageHash) {\n\treturn directoryExists(contractSnapshotDir(migrationsDir, storageHash));\n}\nfunction createSnapshotContentVerifier(hooks) {\n\treturn { assertSnapshotContentMatches(contractJson, storageHash, jsonPath) {\n\t\tconst record = blindCast(contractJson ?? {});\n\t\tconst computedHash = recomputePublishedStorageHash({\n\t\t\ttarget: record.target,\n\t\t\ttargetFamily: record.targetFamily,\n\t\t\tstorage: record.storage,\n\t\t\thooks\n\t\t});\n\t\tif (computedHash !== storageHash) throw errorContractSnapshotContentMismatch({\n\t\t\tstorageHash,\n\t\t\tcomputedHash,\n\t\t\tjsonPath\n\t\t});\n\t} };\n}\n/**\n* `text` on one line ending in a newline: leading `//` comment lines become one block comment, and every other line\n* break with the indentation that follows it becomes one space. Throws `InternalError` for text it cannot join\n* without changing its meaning.\n*/\nfunction singleLineDeclarations(text) {\n\tconst lines = text.split(/\\r?\\n/).map((line) => line.trim());\n\tconst firstCodeLine = lines.findIndex((line) => line !== \"\" && !line.startsWith(\"//\"));\n\tconst headerLength = firstCodeLine === -1 ? lines.length : firstCodeLine;\n\tconst headerLines = lines.slice(0, headerLength).filter((line) => line !== \"\");\n\tconst codeLines = lines.slice(headerLength).filter((line) => line !== \"\");\n\tconst directive = headerLines.find((line) => line.startsWith(\"///\"));\n\tif (directive !== void 0) throw new InternalError(`Cannot join declarations onto one line: the triple-slash directive \"${directive}\" would become a comment`);\n\tconst closingHeaderLine = headerLines.find((line) => line.includes(\"*/\"));\n\tif (closingHeaderLine !== void 0) throw new InternalError(`Cannot join declarations onto one line: the header line \"${closingHeaderLine}\" contains \"*/\"`);\n\tconst lineComment = lineWithLineComment(codeLines);\n\tif (lineComment !== void 0) throw new InternalError(`Cannot join declarations onto one line: the line comment in \"${lineComment}\" after the header would hide the code after it`);\n\tconst header = headerLines.map((line) => line.slice(2).trim()).filter((line) => line !== \"\");\n\treturn `${(header.length > 0 ? [`/* ${header.join(\" \")} */`, ...codeLines] : codeLines).join(\" \")}\\n`;\n}\nfunction lineWithLineComment(lines) {\n\tlet inBlockComment = false;\n\tlet quote;\n\tfor (const line of lines) for (let i = 0; i < line.length; i++) {\n\t\tconst pair = line.slice(i, i + 2);\n\t\tif (inBlockComment) {\n\t\t\tif (pair === \"*/\") {\n\t\t\t\tinBlockComment = false;\n\t\t\t\ti++;\n\t\t\t}\n\t\t} else if (quote !== void 0) {\n\t\t\tif (line[i] === \"\\\\\") i++;\n\t\t\telse if (line[i] === quote) quote = void 0;\n\t\t} else if (pair === \"/*\") {\n\t\t\tinBlockComment = true;\n\t\t\ti++;\n\t\t} else if (pair === \"//\") return line;\n\t\telse if (line[i] === \"'\" || line[i] === \"\\\"\" || line[i] === \"`\") quote = line[i];\n\t}\n}\n/** The bytes the store writes for `input`: `contract.json` and `contract.d.ts`. */\nfunction contractSnapshotFiles(input) {\n\treturn {\n\t\tcontractJson: `${canonicalizeJson(input.contractJson)}\\n`,\n\t\tcontractDts: singleLineDeclarations(input.contractDts)\n\t};\n}\nasync function writeContractSnapshot(migrationsDir, storageHash, input) {\n\tconst dir = contractSnapshotDir(migrationsDir, storageHash);\n\tconst actualStorageHash = blindCast(input.contractJson).storage?.storageHash;\n\tif (actualStorageHash !== storageHash) throw errorContractSnapshotHashMismatch(storageHash, typeof actualStorageHash === \"string\" ? actualStorageHash : String(actualStorageHash), dir);\n\tif (await hasContractSnapshot(migrationsDir, storageHash)) return {\n\t\twritten: false,\n\t\tdir\n\t};\n\tconst tmpDir = join(join(migrationsDir, CONTRACT_SNAPSHOTS_DIRNAME), `.tmp-${storageHashHex(storageHash)}-${Date.now()}-${randomBytes(4).toString(\"hex\")}`);\n\tawait mkdir(tmpDir, { recursive: true });\n\tconst files = contractSnapshotFiles(input);\n\ttry {\n\t\tawait writeFile(join(tmpDir, CONTRACT_JSON_FILE), files.contractJson);\n\t\tawait writeFile(join(tmpDir, CONTRACT_DTS_FILE), files.contractDts);\n\t\tawait rename(tmpDir, dir);\n\t} catch (error) {\n\t\tawait rm(tmpDir, {\n\t\t\trecursive: true,\n\t\t\tforce: true\n\t\t});\n\t\tif (hasErrnoCode(error, \"EEXIST\") || hasErrnoCode(error, \"ENOTEMPTY\")) return {\n\t\t\twritten: false,\n\t\t\tdir\n\t\t};\n\t\tthrow error;\n\t}\n\treturn {\n\t\twritten: true,\n\t\tdir\n\t};\n}\n/**\n* When `verifyContent` is supplied, the parsed snapshot's content is checked\n* against the hash it was addressed by before being returned — the store is\n* content-addressed, and a snapshot edited in place under an unchanged hash\n* would otherwise flow into planning as if it were the recorded contract.\n*/\nasync function readContractSnapshotJson(migrationsDir, storageHash, verifyContent) {\n\tconst jsonPath = join(contractSnapshotDir(migrationsDir, storageHash), CONTRACT_JSON_FILE);\n\tlet raw;\n\ttry {\n\t\traw = await readFile(jsonPath, \"utf-8\");\n\t} catch (error) {\n\t\tif (hasErrnoCode(error, \"ENOENT\")) throw errorContractSnapshotMissing(storageHash, jsonPath);\n\t\tthrow error;\n\t}\n\tlet parsed;\n\ttry {\n\t\tparsed = JSON.parse(raw);\n\t} catch (e) {\n\t\tthrow errorInvalidJson(jsonPath, e instanceof Error ? e.message : String(e));\n\t}\n\tverifyContent?.assertSnapshotContentMatches(parsed, storageHash, jsonPath);\n\treturn parsed;\n}\n/**\n* Tolerant read: a missing store entry (ENOENT), an unparseable\n* `contract.json`, the JSON literal `null`, or a `storageHash` that isn't a\n* well-formed 64-hex value all resolve to `undefined` rather than\n* throwing — parity with the catch-all tolerance of the pre-store\n* `readEndContractJson` (`io.ts`), which never validated the hash it was\n* keyed by either. Any other fs error (e.g. `EACCES` on a present-but-\n* unreadable file) propagates rather than silently loading a contract-less\n* package. When `verifyContent` is supplied, an entry whose content does not\n* recompute to its address also resolves to `undefined` — tampered content\n* must not flow onward, and the strict store reads report the same file\n* loudly as `MIGRATION.CONTRACT_SNAPSHOT_CONTENT_MISMATCH`.\n*/\nasync function readContractSnapshotJsonTolerant(migrationsDir, storageHash, verifyContent) {\n\tlet jsonPath;\n\ttry {\n\t\tjsonPath = join(contractSnapshotDir(migrationsDir, storageHash), CONTRACT_JSON_FILE);\n\t} catch {\n\t\treturn;\n\t}\n\tlet raw;\n\ttry {\n\t\traw = await readFile(jsonPath, \"utf-8\");\n\t} catch (error) {\n\t\tif (hasErrnoCode(error, \"ENOENT\")) return;\n\t\tthrow error;\n\t}\n\tlet parsed;\n\ttry {\n\t\tparsed = JSON.parse(raw);\n\t} catch {\n\t\treturn;\n\t}\n\tif (parsed === null) return;\n\ttry {\n\t\tverifyContent?.assertSnapshotContentMatches(parsed, storageHash, jsonPath);\n\t} catch (error) {\n\t\tif (MigrationToolsError.is(error) && error.code === \"MIGRATION.CONTRACT_SNAPSHOT_CONTENT_MISMATCH\") return;\n\t\tthrow error;\n\t}\n\treturn parsed;\n}\nfunction snapshotsImportPathFrom(packageDir, migrationsDir) {\n\treturn relative(packageDir, join(migrationsDir, CONTRACT_SNAPSHOTS_DIRNAME)).split(\"\\\\\").join(\"/\");\n}\n//#endregion\nexport { readContractSnapshotJson as a, snapshotsImportPathFrom as c, hasContractSnapshot as i, writeContractSnapshot as l, contractSnapshotFiles as n, readContractSnapshotJsonTolerant as o, createSnapshotContentVerifier as r, singleLineDeclar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