prisma-next 0.11.0-dev.9 → 0.12.0-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +9 -10
- package/dist/cli.mjs.map +1 -1
- package/dist/{client-UnIveZxZ.mjs → client-KgJorIvG.mjs} +72 -60
- package/dist/client-KgJorIvG.mjs.map +1 -0
- package/dist/{command-helpers-CRfjbZRz.mjs → command-helpers-Bbw1GbwL.mjs} +642 -45
- package/dist/command-helpers-Bbw1GbwL.mjs.map +1 -0
- package/dist/commands/contract-emit.d.mts.map +1 -1
- package/dist/commands/contract-emit.mjs +1 -1
- package/dist/commands/contract-infer.d.mts.map +1 -1
- package/dist/commands/contract-infer.mjs +1 -1
- package/dist/commands/db-init.d.mts.map +1 -1
- package/dist/commands/db-init.mjs +5 -7
- package/dist/commands/db-init.mjs.map +1 -1
- package/dist/commands/db-schema.d.mts.map +1 -1
- package/dist/commands/db-schema.mjs +3 -4
- package/dist/commands/db-schema.mjs.map +1 -1
- package/dist/commands/db-sign.d.mts.map +1 -1
- package/dist/commands/db-sign.mjs +12 -10
- package/dist/commands/db-sign.mjs.map +1 -1
- package/dist/commands/db-update.d.mts.map +1 -1
- package/dist/commands/db-update.mjs +12 -11
- package/dist/commands/db-update.mjs.map +1 -1
- package/dist/commands/db-verify.d.mts.map +1 -1
- package/dist/commands/db-verify.mjs +1 -1
- package/dist/commands/migrate.d.mts +2 -2
- package/dist/commands/migrate.d.mts.map +1 -1
- package/dist/commands/migrate.mjs +68 -69
- package/dist/commands/migrate.mjs.map +1 -1
- package/dist/commands/migration-check.d.mts +4 -3
- package/dist/commands/migration-check.d.mts.map +1 -1
- package/dist/commands/migration-check.mjs +1 -280
- package/dist/commands/migration-graph.d.mts +13 -2
- package/dist/commands/migration-graph.d.mts.map +1 -1
- package/dist/commands/migration-graph.mjs +2 -137
- package/dist/commands/migration-list.d.mts +64 -4
- package/dist/commands/migration-list.d.mts.map +1 -1
- package/dist/commands/migration-list.mjs +143 -56
- package/dist/commands/migration-list.mjs.map +1 -1
- package/dist/commands/migration-log.d.mts +10 -1
- package/dist/commands/migration-log.d.mts.map +1 -1
- package/dist/commands/migration-log.mjs +10 -15
- package/dist/commands/migration-log.mjs.map +1 -1
- package/dist/commands/migration-new.d.mts.map +1 -1
- package/dist/commands/migration-new.mjs +32 -38
- package/dist/commands/migration-new.mjs.map +1 -1
- package/dist/commands/migration-plan.d.mts +2 -2
- package/dist/commands/migration-plan.d.mts.map +1 -1
- package/dist/commands/migration-plan.mjs +1 -1
- package/dist/commands/migration-show.d.mts +4 -55
- package/dist/commands/migration-show.d.mts.map +1 -1
- package/dist/commands/migration-show.mjs +61 -153
- package/dist/commands/migration-show.mjs.map +1 -1
- package/dist/commands/migration-status.d.mts +12 -49
- package/dist/commands/migration-status.d.mts.map +1 -1
- package/dist/commands/migration-status.mjs +84 -80
- package/dist/commands/migration-status.mjs.map +1 -1
- package/dist/commands/ref.d.mts +1 -1
- package/dist/commands/ref.d.mts.map +1 -1
- package/dist/commands/ref.mjs +10 -8
- package/dist/commands/ref.mjs.map +1 -1
- package/dist/config-loader-B6sJjXTv.mjs.map +1 -1
- package/dist/config-loader.d.mts.map +1 -1
- package/dist/contract-at-errors-BxP-TOMl.mjs +42 -0
- package/dist/contract-at-errors-BxP-TOMl.mjs.map +1 -0
- package/dist/{contract-emit-C6rlsljO.mjs → contract-emit-D-4jrNve.mjs} +21 -7
- package/dist/{contract-emit-C6rlsljO.mjs.map → contract-emit-D-4jrNve.mjs.map} +1 -1
- package/dist/{contract-emit-mqXmapxB.mjs → contract-emit-DxcGl4Uq.mjs} +4 -6
- package/dist/{contract-emit-mqXmapxB.mjs.map → contract-emit-DxcGl4Uq.mjs.map} +1 -1
- package/dist/{contract-enrichment-Dani0mMW.mjs → contract-enrichment-a0V5Y_mL.mjs} +4 -25
- package/dist/contract-enrichment-a0V5Y_mL.mjs.map +1 -0
- package/dist/{contract-infer-C4jxc1aZ.mjs → contract-infer-D8uEbJuu.mjs} +3 -4
- package/dist/{contract-infer-C4jxc1aZ.mjs.map → contract-infer-D8uEbJuu.mjs.map} +1 -1
- package/dist/contract-space-aggregate-loader-DvZwdkrr.mjs +247 -0
- package/dist/contract-space-aggregate-loader-DvZwdkrr.mjs.map +1 -0
- package/dist/{db-verify-1d8tDoFN.mjs → db-verify-v_vUKXTU.mjs} +5 -7
- package/dist/{db-verify-1d8tDoFN.mjs.map → db-verify-v_vUKXTU.mjs.map} +1 -1
- package/dist/exports/control-api.d.mts +3 -3
- package/dist/exports/control-api.d.mts.map +1 -1
- package/dist/exports/control-api.mjs +3 -3
- package/dist/exports/index.d.mts.map +1 -1
- package/dist/exports/index.mjs +1 -1
- package/dist/exports/index.mjs.map +1 -1
- package/dist/exports/init-output.d.mts.map +1 -1
- package/dist/exports/init-output.mjs +1 -1
- package/dist/extension-pack-inputs-IDvjRCi3.mjs +62 -0
- package/dist/extension-pack-inputs-IDvjRCi3.mjs.map +1 -0
- package/dist/{framework-components-Bexd0f4E.mjs → framework-components-fYXjz_in.mjs} +2 -2
- package/dist/{framework-components-Bexd0f4E.mjs.map → framework-components-fYXjz_in.mjs.map} +1 -1
- package/dist/global-flags-DEHjV8_s.d.mts +34 -0
- package/dist/global-flags-DEHjV8_s.d.mts.map +1 -0
- package/dist/{graph-render-BE8vmJ_7.mjs → graph-render-rFAqZujX.mjs} +2 -2
- package/dist/{graph-render-BE8vmJ_7.mjs.map → graph-render-rFAqZujX.mjs.map} +1 -1
- package/dist/{init-ByoeQphC.mjs → init-Cv9UzWL5.mjs} +17 -19
- package/dist/init-Cv9UzWL5.mjs.map +1 -0
- package/dist/{inspect-live-schema-B1Q49RF0.mjs → inspect-live-schema-C6ohV_oQ.mjs} +4 -5
- package/dist/{inspect-live-schema-B1Q49RF0.mjs.map → inspect-live-schema-C6ohV_oQ.mjs.map} +1 -1
- package/dist/migration-check-BiBJoYYW.mjs +341 -0
- package/dist/migration-check-BiBJoYYW.mjs.map +1 -0
- package/dist/migration-cli.d.mts.map +1 -1
- package/dist/migration-cli.mjs +4 -4
- package/dist/migration-cli.mjs.map +1 -1
- package/dist/{migration-command-scaffold-oY4P1Qto.mjs → migration-command-scaffold-CjvwO6at.mjs} +4 -5
- package/dist/{migration-command-scaffold-oY4P1Qto.mjs.map → migration-command-scaffold-CjvwO6at.mjs.map} +1 -1
- package/dist/migration-graph-D7DVUElV.mjs +1232 -0
- package/dist/migration-graph-D7DVUElV.mjs.map +1 -0
- package/dist/migration-list-styler-BRwF4-gy.mjs +399 -0
- package/dist/migration-list-styler-BRwF4-gy.mjs.map +1 -0
- package/dist/{migration-plan-jdAHg_gK.mjs → migration-plan-9DJ7q7_z.mjs} +169 -189
- package/dist/migration-plan-9DJ7q7_z.mjs.map +1 -0
- package/dist/{migration-types-BXWvz12q.d.mts → migration-types-D2FW63pr.d.mts} +1 -1
- package/dist/{migration-types-BXWvz12q.d.mts.map → migration-types-D2FW63pr.d.mts.map} +1 -1
- package/dist/{migrations-B7n518mT.mjs → migrations-Cv2jxNNK.mjs} +3 -13
- package/dist/migrations-Cv2jxNNK.mjs.map +1 -0
- package/dist/{output-CUIdfYo5.mjs → output-B60Gw5fu.mjs} +1 -1
- package/dist/{output-CUIdfYo5.mjs.map → output-B60Gw5fu.mjs.map} +1 -1
- package/dist/{progress-adapter-DFfvZcYL.mjs → progress-adapter-C644QK8l.mjs} +1 -1
- package/dist/{progress-adapter-DFfvZcYL.mjs.map → progress-adapter-C644QK8l.mjs.map} +1 -1
- package/dist/{ref-advancement-DRh5Nquq.mjs → ref-advancement-DUZqsue6.mjs} +1 -1
- package/dist/{ref-advancement-DRh5Nquq.mjs.map → ref-advancement-DUZqsue6.mjs.map} +1 -1
- package/dist/terminal-ui-5Y6mrg93.d.mts +133 -0
- package/dist/terminal-ui-5Y6mrg93.d.mts.map +1 -0
- package/dist/{types-UWB2-rrw.d.mts → types-Dt_SfqFm.d.mts} +18 -26
- package/dist/types-Dt_SfqFm.d.mts.map +1 -0
- package/dist/{verify-C5UvbrF1.mjs → verify-DCA9Sldu.mjs} +2 -2
- package/dist/{verify-C5UvbrF1.mjs.map → verify-DCA9Sldu.mjs.map} +1 -1
- package/package.json +27 -16
- package/dist/cli-errors-Bw2GlweY.mjs +0 -175
- package/dist/cli-errors-Bw2GlweY.mjs.map +0 -1
- package/dist/client-UnIveZxZ.mjs.map +0 -1
- package/dist/command-helpers-CRfjbZRz.mjs.map +0 -1
- package/dist/commands/migration-check.mjs.map +0 -1
- package/dist/commands/migration-graph.mjs.map +0 -1
- package/dist/contract-enrichment-Dani0mMW.mjs.map +0 -1
- package/dist/contract-space-aggregate-loader-CGakRlKM.mjs +0 -160
- package/dist/contract-space-aggregate-loader-CGakRlKM.mjs.map +0 -1
- package/dist/global-flags-CdE7M0d9.d.mts +0 -15
- package/dist/global-flags-CdE7M0d9.d.mts.map +0 -1
- package/dist/init-ByoeQphC.mjs.map +0 -1
- package/dist/migration-plan-jdAHg_gK.mjs.map +0 -1
- package/dist/migrations-B7n518mT.mjs.map +0 -1
- package/dist/rolldown-runtime-twds-ZHy.mjs +0 -14
- package/dist/terminal-ui-BiB_8KNo.mjs +0 -379
- package/dist/terminal-ui-BiB_8KNo.mjs.map +0 -1
- package/dist/types-UWB2-rrw.d.mts.map +0 -1
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
import { t as CliStructuredError } from "./cli-errors-Bw2GlweY.mjs";
|
|
2
|
-
import { notOk, ok } from "@prisma-next/utils/result";
|
|
3
|
-
import { loadContractSpaceAggregate } from "@prisma-next/migration-tools/aggregate";
|
|
4
|
-
//#region src/utils/extension-pack-inputs.ts
|
|
5
|
-
/**
|
|
6
|
-
* Project the CLI's `Config.extensionPacks` array into the canonical
|
|
7
|
-
* {@link ExtensionPackInput} shape. The single `as ExtensionPackLike`
|
|
8
|
-
* structural cast in the CLI lives inside this function.
|
|
9
|
-
*/
|
|
10
|
-
function toExtensionInputs(extensionPacks) {
|
|
11
|
-
return extensionPacks.map((raw) => {
|
|
12
|
-
const pack = raw;
|
|
13
|
-
if (pack.contractSpace === void 0) return {
|
|
14
|
-
id: pack.id,
|
|
15
|
-
targetId: pack.targetId
|
|
16
|
-
};
|
|
17
|
-
return {
|
|
18
|
-
id: pack.id,
|
|
19
|
-
targetId: pack.targetId,
|
|
20
|
-
contractSpace: {
|
|
21
|
-
contractJson: pack.contractSpace.contractJson,
|
|
22
|
-
headRef: pack.contractSpace.headRef,
|
|
23
|
-
migrations: pack.contractSpace.migrations ?? []
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Minimal aggregate-loader projection that extracts `id` + `targetId`
|
|
30
|
-
* from raw extension pack descriptors **without invoking any
|
|
31
|
-
* `contractSpace` accessor**. Inspects the own-property descriptor so
|
|
32
|
-
* that getter-backed `contractSpace` declarations are detected but
|
|
33
|
-
* never called.
|
|
34
|
-
*
|
|
35
|
-
* Inclusion semantics match {@link toDeclaredExtensions}: a data
|
|
36
|
-
* property whose value is explicitly `undefined` is treated as "no
|
|
37
|
-
* contract-space declaration" and skipped, mirroring the
|
|
38
|
-
* `pack.contractSpace === undefined` check used on canonicalised
|
|
39
|
-
* inputs. Prototype-chain `contractSpace` properties (no own
|
|
40
|
-
* descriptor) are also skipped.
|
|
41
|
-
*
|
|
42
|
-
* This variant must be used by `buildContractSpaceAggregate` so that
|
|
43
|
-
* the aggregate path (including `db verify`) never reads
|
|
44
|
-
* `contractSpace.contractJson` from extension descriptors — the loader
|
|
45
|
-
* always reads the contract from on-disk artefacts instead.
|
|
46
|
-
*/
|
|
47
|
-
function toDeclaredExtensionsFromRaw(extensionPacks) {
|
|
48
|
-
const entries = [];
|
|
49
|
-
for (const raw of extensionPacks) {
|
|
50
|
-
if (typeof raw !== "object" || raw === null) continue;
|
|
51
|
-
const descriptor = Object.getOwnPropertyDescriptor(raw, "contractSpace");
|
|
52
|
-
if (descriptor === void 0) continue;
|
|
53
|
-
if ("value" in descriptor && descriptor.value === void 0) continue;
|
|
54
|
-
const pack = raw;
|
|
55
|
-
entries.push({
|
|
56
|
-
id: pack.id,
|
|
57
|
-
targetId: pack.targetId
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
return entries;
|
|
61
|
-
}
|
|
62
|
-
//#endregion
|
|
63
|
-
//#region src/utils/contract-space-aggregate-loader.ts
|
|
64
|
-
/**
|
|
65
|
-
* Render a {@link LoadAggregateError} into a CLI structured-error
|
|
66
|
-
* envelope. Preserves error codes `5001` (layout) and `5002` (marker /
|
|
67
|
-
* disjointness / etc.) so existing integration tests and downstream
|
|
68
|
-
* tooling continue to assert on the same `meta.violations[]` shape
|
|
69
|
-
* they did under the old precheck/marker-check helpers.
|
|
70
|
-
*/
|
|
71
|
-
function mapLoadAggregateError(error) {
|
|
72
|
-
if (error.kind === "layoutViolation") {
|
|
73
|
-
const lines = error.violations.map((v) => `- [${v.kind}] ${v.spaceId}`);
|
|
74
|
-
return new CliStructuredError("5001", error.violations.length === 1 ? "Contract-space layout violation detected" : `Contract-space layout violations detected (${error.violations.length})`, {
|
|
75
|
-
domain: "MIG",
|
|
76
|
-
why: `The on-disk \`migrations/\` directory and your \`extensionPacks\` declaration are not in agreement.\n${lines.join("\n")}`,
|
|
77
|
-
fix: "Run `prisma-next migrate` to materialise on-disk artefacts for declared extensions, or remove the orphan directory.",
|
|
78
|
-
docsUrl: "https://pris.ly/contract-spaces",
|
|
79
|
-
meta: { violations: error.violations.map((v) => ({
|
|
80
|
-
kind: v.kind,
|
|
81
|
-
spaceId: v.spaceId
|
|
82
|
-
})) }
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
if (error.kind === "disjointnessViolation") return new CliStructuredError("5002", `Contract-space disjointness violation: storage element "${error.element}" claimed by multiple spaces`, {
|
|
86
|
-
domain: "MIG",
|
|
87
|
-
why: `Spaces ${error.claimedBy.map((s) => `"${s}"`).join(", ")} all claim the storage element "${error.element}". Each storage element must be owned by exactly one contract space.`,
|
|
88
|
-
fix: "Update the conflicting contracts so each storage element is claimed by exactly one space.",
|
|
89
|
-
docsUrl: "https://pris.ly/contract-spaces",
|
|
90
|
-
meta: { violations: [{
|
|
91
|
-
kind: "disjointness",
|
|
92
|
-
spaceId: error.claimedBy.join(","),
|
|
93
|
-
element: error.element,
|
|
94
|
-
claimedBy: error.claimedBy
|
|
95
|
-
}] }
|
|
96
|
-
});
|
|
97
|
-
if (error.kind === "integrityFailure") return new CliStructuredError("5002", `Contract-space integrity failure for "${error.spaceId}"`, {
|
|
98
|
-
domain: "MIG",
|
|
99
|
-
why: error.detail,
|
|
100
|
-
fix: "Run `prisma-next migrate` to refresh on-disk artefacts, or restore the on-disk `migrations/` directory from version control.",
|
|
101
|
-
docsUrl: "https://pris.ly/contract-spaces",
|
|
102
|
-
meta: { violations: [{
|
|
103
|
-
kind: "integrity",
|
|
104
|
-
spaceId: error.spaceId,
|
|
105
|
-
detail: error.detail
|
|
106
|
-
}] }
|
|
107
|
-
});
|
|
108
|
-
if (error.kind === "validationFailure") return new CliStructuredError("5002", `Contract-space contract validation failed for "${error.spaceId}"`, {
|
|
109
|
-
domain: "MIG",
|
|
110
|
-
why: error.detail,
|
|
111
|
-
fix: "Run `prisma-next migrate` to refresh on-disk artefacts, or fix the extension descriptor producing the invalid contract.",
|
|
112
|
-
meta: { violations: [{
|
|
113
|
-
kind: "validation",
|
|
114
|
-
spaceId: error.spaceId,
|
|
115
|
-
detail: error.detail
|
|
116
|
-
}] }
|
|
117
|
-
});
|
|
118
|
-
return new CliStructuredError("5002", `Contract-space target mismatch for "${error.spaceId}"`, {
|
|
119
|
-
domain: "MIG",
|
|
120
|
-
why: `Space "${error.spaceId}" targets "${error.actual}" but the project's adapter targets "${error.expected}".`,
|
|
121
|
-
fix: "Update the extension descriptor to target the configured database, or change the project adapter.",
|
|
122
|
-
meta: { violations: [{
|
|
123
|
-
kind: "targetMismatch",
|
|
124
|
-
spaceId: error.spaceId,
|
|
125
|
-
expected: error.expected,
|
|
126
|
-
actual: error.actual
|
|
127
|
-
}] }
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Run the aggregate loader at the CLI surface, mapping any
|
|
132
|
-
* {@link LoadAggregateError} into a {@link CliStructuredError} envelope.
|
|
133
|
-
*
|
|
134
|
-
* App-side migration packages flow through `inputs.appMigrationPackages`
|
|
135
|
-
* (defaulting to `[]`). `db init` / `db update` leave it empty: the
|
|
136
|
-
* planner's `synth` strategy is used for the app member (driven by
|
|
137
|
-
* `callerPolicy.ignoreGraphFor`), so the app's authored `migrations/`
|
|
138
|
-
* graph does not need to be walked. `migrate` threads the
|
|
139
|
-
* already-loaded app-space packages through so the graph-walk strategy
|
|
140
|
-
* can plot a path through them — replay forbids synth.
|
|
141
|
-
*
|
|
142
|
-
* @see specs/contract-space-aggregate-spec.md § Loader.
|
|
143
|
-
*/
|
|
144
|
-
async function buildContractSpaceAggregate(inputs) {
|
|
145
|
-
const declaredExtensions = toDeclaredExtensionsFromRaw(inputs.extensionPacks);
|
|
146
|
-
const result = await loadContractSpaceAggregate({
|
|
147
|
-
targetId: inputs.targetId,
|
|
148
|
-
migrationsDir: inputs.migrationsDir,
|
|
149
|
-
appContract: inputs.appContract,
|
|
150
|
-
declaredExtensions,
|
|
151
|
-
deserializeContract: inputs.deserializeContract,
|
|
152
|
-
appMigrationPackages: inputs.appMigrationPackages ?? []
|
|
153
|
-
});
|
|
154
|
-
if (!result.ok) return notOk(mapLoadAggregateError(result.failure));
|
|
155
|
-
return ok(result.value.aggregate);
|
|
156
|
-
}
|
|
157
|
-
//#endregion
|
|
158
|
-
export { toExtensionInputs as n, buildContractSpaceAggregate as t };
|
|
159
|
-
|
|
160
|
-
//# sourceMappingURL=contract-space-aggregate-loader-CGakRlKM.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contract-space-aggregate-loader-CGakRlKM.mjs","names":[],"sources":["../src/utils/extension-pack-inputs.ts","../src/utils/contract-space-aggregate-loader.ts"],"sourcesContent":["/**\n * Single descriptor-import boundary for CLI consumers of `Config.extensionPacks`.\n *\n * Every CLI command / utility that reads an extension descriptor's\n * `contractSpace` projection (loader, migrate-pass, extension-migrations\n * pass, migration commands) goes through {@link toExtensionInputs}. The\n * structural cast `pack as { contractSpace?: ... }` lives **only** here —\n * downstream code consumes the canonical shape and maps it to its own\n * narrower shape via the per-consumer adapters below.\n *\n * The CLI receives extension descriptors typed against the SQL family\n * (or any other family in the future); this helper only depends on the\n * structural shape of `contractSpace`. SQL-family callers pass the same\n * `contractJson` / `headRef.hash` value through unchanged.\n */\nimport type { DeclaredExtensionEntry } from '@prisma-next/migration-tools/aggregate';\nimport type { MigrationMetadata } from '@prisma-next/migration-tools/metadata';\nimport type { MigrationOps } from '@prisma-next/migration-tools/package';\n\n/**\n * In-memory authored migration package shipped by an extension descriptor.\n * Mirrors the `MigrationPackage` shape from\n * `@prisma-next/framework-components/control` minus `dirPath`; redeclared\n * structurally here so the helper does not couple to the SQL family's\n * `ExtensionMigrationPackage` type.\n */\nexport interface DescriptorMigrationPackage {\n readonly dirName: string;\n readonly metadata: MigrationMetadata;\n readonly ops: MigrationOps;\n}\n\n/**\n * The most-general projection of a single declared extension pack\n * needed by the CLI's descriptor-import boundary.\n *\n * - `id` / `targetId` are always present.\n * - `contractSpace` is present only when the extension declares one.\n * When present, it carries the canonical inputs every downstream\n * consumer needs — `contractJson`, `headRef`, and the descriptor's\n * pre-built migration packages.\n */\nexport interface ExtensionPackInput {\n readonly id: string;\n readonly targetId: string;\n readonly contractSpace?: {\n readonly contractJson: unknown;\n readonly headRef: {\n readonly hash: string;\n readonly invariants: readonly string[];\n };\n readonly migrations: readonly DescriptorMigrationPackage[];\n };\n}\n\n/**\n * Structural shape we read off each `Config.extensionPacks` entry.\n *\n * The CLI is the descriptor-import boundary; `extensionPacks` is the only\n * surface where the SQL-family-typed `ControlExtensionDescriptor` flows\n * into framework-neutral helpers. The structural cast lives here, and\n * here alone — every other CLI consumer reads the canonical\n * {@link ExtensionPackInput} shape produced by {@link toExtensionInputs}.\n */\ntype ExtensionPackLike = {\n readonly id: string;\n readonly targetId: string;\n readonly contractSpace?: {\n readonly contractJson: unknown;\n readonly headRef: {\n readonly hash: string;\n readonly invariants: readonly string[];\n };\n readonly migrations?: readonly DescriptorMigrationPackage[];\n };\n};\n\n/**\n * Project the CLI's `Config.extensionPacks` array into the canonical\n * {@link ExtensionPackInput} shape. The single `as ExtensionPackLike`\n * structural cast in the CLI lives inside this function.\n */\nexport function toExtensionInputs(\n extensionPacks: ReadonlyArray<unknown>,\n): readonly ExtensionPackInput[] {\n return extensionPacks.map((raw) => {\n const pack = raw as ExtensionPackLike;\n if (pack.contractSpace === undefined) {\n return { id: pack.id, targetId: pack.targetId };\n }\n return {\n id: pack.id,\n targetId: pack.targetId,\n contractSpace: {\n contractJson: pack.contractSpace.contractJson,\n headRef: pack.contractSpace.headRef,\n migrations: pack.contractSpace.migrations ?? [],\n },\n };\n });\n}\n\n// ---------------------------------------------------------------------------\n// Per-consumer adapters: take the canonical `ExtensionPackInput[]` and\n// project to whatever narrower shape the downstream primitive needs.\n// ---------------------------------------------------------------------------\n\n/**\n * Aggregate-loader projection. Surfaces `id` + `targetId` per\n * contract-space-bearing extension to\n * {@link import('./contract-space-aggregate-loader').buildContractSpaceAggregate}.\n *\n * Codec-only extensions (no `contractSpace` declaration) are filtered\n * out: they are not contract-space members, so the aggregate loader\n * has nothing to do with them. Filtering happens at this descriptor-\n * import boundary so the loader stays oblivious to that distinction —\n * every entry it sees expects an on-disk `migrations/<id>/` directory.\n */\nexport function toDeclaredExtensions(\n inputs: ReadonlyArray<ExtensionPackInput>,\n): readonly DeclaredExtensionEntry[] {\n const entries: DeclaredExtensionEntry[] = [];\n for (const pack of inputs) {\n if (pack.contractSpace === undefined) continue;\n entries.push({ id: pack.id, targetId: pack.targetId });\n }\n return entries;\n}\n\n/**\n * Minimal aggregate-loader projection that extracts `id` + `targetId`\n * from raw extension pack descriptors **without invoking any\n * `contractSpace` accessor**. Inspects the own-property descriptor so\n * that getter-backed `contractSpace` declarations are detected but\n * never called.\n *\n * Inclusion semantics match {@link toDeclaredExtensions}: a data\n * property whose value is explicitly `undefined` is treated as \"no\n * contract-space declaration\" and skipped, mirroring the\n * `pack.contractSpace === undefined` check used on canonicalised\n * inputs. Prototype-chain `contractSpace` properties (no own\n * descriptor) are also skipped.\n *\n * This variant must be used by `buildContractSpaceAggregate` so that\n * the aggregate path (including `db verify`) never reads\n * `contractSpace.contractJson` from extension descriptors — the loader\n * always reads the contract from on-disk artefacts instead.\n */\nexport function toDeclaredExtensionsFromRaw(\n extensionPacks: ReadonlyArray<unknown>,\n): readonly DeclaredExtensionEntry[] {\n const entries: DeclaredExtensionEntry[] = [];\n for (const raw of extensionPacks) {\n if (typeof raw !== 'object' || raw === null) continue;\n const descriptor = Object.getOwnPropertyDescriptor(raw, 'contractSpace');\n if (descriptor === undefined) continue;\n if ('value' in descriptor && descriptor.value === undefined) continue;\n const pack = raw as { readonly id: string; readonly targetId: string };\n entries.push({ id: pack.id, targetId: pack.targetId });\n }\n return entries;\n}\n","import type { Contract } from '@prisma-next/contract/types';\nimport type { ControlExtensionDescriptor } from '@prisma-next/framework-components/control';\nimport type {\n ContractSpaceAggregate,\n LoadAggregateError,\n LoadAggregateInput,\n LoadAggregateOutput,\n} from '@prisma-next/migration-tools/aggregate';\nimport { loadContractSpaceAggregate } from '@prisma-next/migration-tools/aggregate';\nimport type { OnDiskMigrationPackage } from '@prisma-next/migration-tools/package';\nimport { notOk, ok, type Result } from '@prisma-next/utils/result';\nimport { CliStructuredError } from './cli-errors';\nimport { toDeclaredExtensionsFromRaw } from './extension-pack-inputs';\n\n/**\n * Render a {@link LoadAggregateError} into a CLI structured-error\n * envelope. Preserves error codes `5001` (layout) and `5002` (marker /\n * disjointness / etc.) so existing integration tests and downstream\n * tooling continue to assert on the same `meta.violations[]` shape\n * they did under the old precheck/marker-check helpers.\n */\nexport function mapLoadAggregateError(error: LoadAggregateError): CliStructuredError {\n if (error.kind === 'layoutViolation') {\n const lines = error.violations.map((v) => `- [${v.kind}] ${v.spaceId}`);\n const summary =\n error.violations.length === 1\n ? 'Contract-space layout violation detected'\n : `Contract-space layout violations detected (${error.violations.length})`;\n return new CliStructuredError('5001', summary, {\n domain: 'MIG',\n why: `The on-disk \\`migrations/\\` directory and your \\`extensionPacks\\` declaration are not in agreement.\\n${lines.join('\\n')}`,\n fix: 'Run `prisma-next migrate` to materialise on-disk artefacts for declared extensions, or remove the orphan directory.',\n docsUrl: 'https://pris.ly/contract-spaces',\n meta: {\n violations: error.violations.map((v) => ({\n kind: v.kind,\n spaceId: v.spaceId,\n })),\n },\n });\n }\n if (error.kind === 'disjointnessViolation') {\n return new CliStructuredError(\n '5002',\n `Contract-space disjointness violation: storage element \"${error.element}\" claimed by multiple spaces`,\n {\n domain: 'MIG',\n why: `Spaces ${error.claimedBy.map((s) => `\"${s}\"`).join(', ')} all claim the storage element \"${error.element}\". Each storage element must be owned by exactly one contract space.`,\n fix: 'Update the conflicting contracts so each storage element is claimed by exactly one space.',\n docsUrl: 'https://pris.ly/contract-spaces',\n meta: {\n violations: [\n {\n kind: 'disjointness',\n spaceId: error.claimedBy.join(','),\n element: error.element,\n claimedBy: error.claimedBy,\n },\n ],\n },\n },\n );\n }\n if (error.kind === 'integrityFailure') {\n return new CliStructuredError(\n '5002',\n `Contract-space integrity failure for \"${error.spaceId}\"`,\n {\n domain: 'MIG',\n why: error.detail,\n fix: 'Run `prisma-next migrate` to refresh on-disk artefacts, or restore the on-disk `migrations/` directory from version control.',\n docsUrl: 'https://pris.ly/contract-spaces',\n meta: {\n violations: [{ kind: 'integrity', spaceId: error.spaceId, detail: error.detail }],\n },\n },\n );\n }\n if (error.kind === 'validationFailure') {\n return new CliStructuredError(\n '5002',\n `Contract-space contract validation failed for \"${error.spaceId}\"`,\n {\n domain: 'MIG',\n why: error.detail,\n fix: 'Run `prisma-next migrate` to refresh on-disk artefacts, or fix the extension descriptor producing the invalid contract.',\n meta: {\n violations: [{ kind: 'validation', spaceId: error.spaceId, detail: error.detail }],\n },\n },\n );\n }\n // targetMismatch\n return new CliStructuredError('5002', `Contract-space target mismatch for \"${error.spaceId}\"`, {\n domain: 'MIG',\n why: `Space \"${error.spaceId}\" targets \"${error.actual}\" but the project's adapter targets \"${error.expected}\".`,\n fix: 'Update the extension descriptor to target the configured database, or change the project adapter.',\n meta: {\n violations: [\n {\n kind: 'targetMismatch',\n spaceId: error.spaceId,\n expected: error.expected,\n actual: error.actual,\n },\n ],\n },\n });\n}\n\n/**\n * Inputs needed to compose the aggregate loader at the CLI surface.\n *\n * Keeps the loader framework-neutral (no `Config` import) by accepting\n * already-resolved structural inputs: validated app contract, target\n * id, migrations root directory, and the set of extension descriptors.\n */\nexport interface BuildAggregateInputs<TFamilyId extends string, TTargetId extends string> {\n readonly targetId: TTargetId;\n readonly migrationsDir: string;\n readonly appContract: Contract;\n readonly extensionPacks: ReadonlyArray<ControlExtensionDescriptor<TFamilyId, TTargetId>>;\n readonly deserializeContract: (contractJson: unknown) => Contract;\n /**\n * App-space migration packages to hydrate the app member's\n * migration graph with. Defaults to `[]` (matches the `db init` /\n * `db update` daily-driver behaviour, where the app's authored\n * `migrations/` graph is not walked — the planner uses the synth\n * strategy for the app member instead).\n *\n * `migrate` callers thread the user's authored app-space\n * packages (loaded via `loadMigrationPackages(appMigrationsDir)`)\n * through here so the graph-walk strategy can plot a path through\n * them — the prod-time replay path explicitly forbids synth.\n */\n readonly appMigrationPackages?: ReadonlyArray<OnDiskMigrationPackage>;\n}\n\n/**\n * Run the aggregate loader at the CLI surface, mapping any\n * {@link LoadAggregateError} into a {@link CliStructuredError} envelope.\n *\n * App-side migration packages flow through `inputs.appMigrationPackages`\n * (defaulting to `[]`). `db init` / `db update` leave it empty: the\n * planner's `synth` strategy is used for the app member (driven by\n * `callerPolicy.ignoreGraphFor`), so the app's authored `migrations/`\n * graph does not need to be walked. `migrate` threads the\n * already-loaded app-space packages through so the graph-walk strategy\n * can plot a path through them — replay forbids synth.\n *\n * @see specs/contract-space-aggregate-spec.md § Loader.\n */\nexport async function buildContractSpaceAggregate<\n TFamilyId extends string,\n TTargetId extends string,\n>(\n inputs: BuildAggregateInputs<TFamilyId, TTargetId>,\n): Promise<Result<ContractSpaceAggregate, CliStructuredError>> {\n const declaredExtensions = toDeclaredExtensionsFromRaw(\n inputs.extensionPacks as ReadonlyArray<unknown>,\n );\n\n const loadInput: LoadAggregateInput = {\n targetId: inputs.targetId,\n migrationsDir: inputs.migrationsDir,\n appContract: inputs.appContract,\n declaredExtensions,\n deserializeContract: inputs.deserializeContract,\n appMigrationPackages: inputs.appMigrationPackages ?? [],\n };\n\n const result: LoadAggregateOutput = await loadContractSpaceAggregate(loadInput);\n if (!result.ok) {\n return notOk(mapLoadAggregateError(result.failure));\n }\n return ok(result.value.aggregate);\n}\n"],"mappings":"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"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
//#region src/utils/global-flags.d.ts
|
|
2
|
-
type OutputFormat = 'pretty' | 'json';
|
|
3
|
-
interface GlobalFlags {
|
|
4
|
-
readonly format: OutputFormat;
|
|
5
|
-
readonly explicitFormat: boolean;
|
|
6
|
-
readonly json?: boolean;
|
|
7
|
-
readonly quiet?: boolean;
|
|
8
|
-
readonly verbose?: number;
|
|
9
|
-
readonly color?: boolean;
|
|
10
|
-
readonly interactive?: boolean;
|
|
11
|
-
readonly yes?: boolean;
|
|
12
|
-
}
|
|
13
|
-
//#endregion
|
|
14
|
-
export { GlobalFlags as t };
|
|
15
|
-
//# sourceMappingURL=global-flags-CdE7M0d9.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"global-flags-CdE7M0d9.d.mts","names":[],"sources":["../src/utils/global-flags.ts"],"mappings":";KAMY,YAAA;AAAA,UAEK,WAAA;EAAA,SACN,MAAA,EAAQ,YAAA;EAAA,SACR,cAAA;EAAA,SACA,IAAA;EAAA,SACA,KAAA;EAAA,SACA,OAAA;EAAA,SACA,KAAA;EAAA,SACA,WAAA;EAAA,SACA,GAAA;AAAA"}
|