@prisma-next/cli 0.1.0-pr.57.2 → 0.1.0-pr.57.3
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/{chunk-XS2KZ6CJ.js → chunk-VWAVGWUP.js} +2 -2
- package/dist/chunk-YDE4ILKH.js +55 -0
- package/dist/chunk-YDE4ILKH.js.map +1 -0
- package/dist/{chunk-JLA4BH74.js → chunk-ZKEJZ3NU.js} +2 -1
- package/dist/cli.js +67 -3
- package/dist/cli.js.map +1 -1
- package/dist/commands/contract-emit.js +2 -2
- package/dist/commands/db-init.js +10 -2
- package/dist/commands/db-init.js.map +1 -1
- package/dist/commands/db-introspect.js +1 -1
- package/dist/commands/db-schema-verify.js +10 -2
- package/dist/commands/db-schema-verify.js.map +1 -1
- package/dist/commands/db-sign.js +10 -2
- package/dist/commands/db-sign.js.map +1 -1
- package/dist/commands/db-verify.js +1 -1
- package/dist/index.js +2 -2
- package/package.json +10 -10
- /package/dist/{chunk-XS2KZ6CJ.js.map → chunk-VWAVGWUP.js.map} +0 -0
- /package/dist/{chunk-JLA4BH74.js.map → chunk-ZKEJZ3NU.js.map} +0 -0
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
performAction,
|
|
10
10
|
setCommandDescriptions,
|
|
11
11
|
withSpinner
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-ZKEJZ3NU.js";
|
|
13
13
|
import {
|
|
14
14
|
loadConfig
|
|
15
15
|
} from "./chunk-HWYQOCAJ.js";
|
|
@@ -131,4 +131,4 @@ function createContractEmitCommand() {
|
|
|
131
131
|
export {
|
|
132
132
|
createContractEmitCommand
|
|
133
133
|
};
|
|
134
|
-
//# sourceMappingURL=chunk-
|
|
134
|
+
//# sourceMappingURL=chunk-VWAVGWUP.js.map
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import {
|
|
2
|
+
errorConfigValidation
|
|
3
|
+
} from "./chunk-ZKEJZ3NU.js";
|
|
4
|
+
|
|
5
|
+
// src/utils/framework-components.ts
|
|
6
|
+
function assertFrameworkComponentsCompatible(expectedFamilyId, expectedTargetId, frameworkComponents) {
|
|
7
|
+
for (let i = 0; i < frameworkComponents.length; i++) {
|
|
8
|
+
const component = frameworkComponents[i];
|
|
9
|
+
if (typeof component !== "object" || component === null) {
|
|
10
|
+
throw errorConfigValidation("frameworkComponents[]", {
|
|
11
|
+
why: `Framework component at index ${i} must be an object`
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
const record = component;
|
|
15
|
+
if (!Object.hasOwn(record, "kind")) {
|
|
16
|
+
throw errorConfigValidation("frameworkComponents[].kind", {
|
|
17
|
+
why: `Framework component at index ${i} must have 'kind' property`
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
const kind = record["kind"];
|
|
21
|
+
if (kind !== "target" && kind !== "adapter" && kind !== "extension" && kind !== "driver") {
|
|
22
|
+
throw errorConfigValidation("frameworkComponents[].kind", {
|
|
23
|
+
why: `Framework component at index ${i} has invalid kind '${String(kind)}' (must be 'target', 'adapter', 'extension', or 'driver')`
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
if (!Object.hasOwn(record, "familyId")) {
|
|
27
|
+
throw errorConfigValidation("frameworkComponents[].familyId", {
|
|
28
|
+
why: `Framework component at index ${i} (kind: ${String(kind)}) must have 'familyId' property`
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
const familyId = record["familyId"];
|
|
32
|
+
if (familyId !== expectedFamilyId) {
|
|
33
|
+
throw errorConfigValidation("frameworkComponents[].familyId", {
|
|
34
|
+
why: `Framework component at index ${i} (kind: ${String(kind)}) has familyId '${String(familyId)}' but expected '${expectedFamilyId}'`
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
if (!Object.hasOwn(record, "targetId")) {
|
|
38
|
+
throw errorConfigValidation("frameworkComponents[].targetId", {
|
|
39
|
+
why: `Framework component at index ${i} (kind: ${String(kind)}) must have 'targetId' property`
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
const targetId = record["targetId"];
|
|
43
|
+
if (targetId !== expectedTargetId) {
|
|
44
|
+
throw errorConfigValidation("frameworkComponents[].targetId", {
|
|
45
|
+
why: `Framework component at index ${i} (kind: ${String(kind)}) has targetId '${String(targetId)}' but expected '${expectedTargetId}'`
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return frameworkComponents;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export {
|
|
53
|
+
assertFrameworkComponentsCompatible
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=chunk-YDE4ILKH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/framework-components.ts"],"sourcesContent":["import type { TargetBoundComponentDescriptor } from '@prisma-next/contract/framework-components';\nimport { errorConfigValidation } from './cli-errors';\n\n/**\n * Asserts that all framework components are compatible with the expected family and target.\n *\n * This function validates that each component in the framework components array:\n * - Has kind 'target', 'adapter', 'extension', or 'driver'\n * - Has familyId matching expectedFamilyId\n * - Has targetId matching expectedTargetId\n *\n * This validation happens at the CLI composition boundary, before passing components\n * to typed planner/runner instances. It fills the gap between runtime validation\n * (via `validateConfig()`) and compile-time type enforcement.\n *\n * @param expectedFamilyId - The expected family ID (e.g., 'sql')\n * @param expectedTargetId - The expected target ID (e.g., 'postgres')\n * @param frameworkComponents - Array of framework components to validate\n * @returns The same array typed as TargetBoundComponentDescriptor\n * @throws CliStructuredError if any component is incompatible\n *\n * @example\n * ```ts\n * const config = await loadConfig();\n * const frameworkComponents = [config.target, config.adapter, ...(config.extensions ?? [])];\n *\n * // Validate and type-narrow components before passing to planner\n * const typedComponents = assertFrameworkComponentsCompatible(\n * config.family.familyId,\n * config.target.targetId,\n * frameworkComponents\n * );\n *\n * const planner = target.migrations.createPlanner(familyInstance);\n * planner.plan({ contract, schema, policy, frameworkComponents: typedComponents });\n * ```\n */\nexport function assertFrameworkComponentsCompatible<\n TFamilyId extends string,\n TTargetId extends string,\n>(\n expectedFamilyId: TFamilyId,\n expectedTargetId: TTargetId,\n frameworkComponents: ReadonlyArray<unknown>,\n): ReadonlyArray<TargetBoundComponentDescriptor<TFamilyId, TTargetId>> {\n for (let i = 0; i < frameworkComponents.length; i++) {\n const component = frameworkComponents[i];\n\n // Check that component is an object\n if (typeof component !== 'object' || component === null) {\n throw errorConfigValidation('frameworkComponents[]', {\n why: `Framework component at index ${i} must be an object`,\n });\n }\n\n const record = component as Record<string, unknown>;\n\n // Check kind\n if (!Object.hasOwn(record, 'kind')) {\n throw errorConfigValidation('frameworkComponents[].kind', {\n why: `Framework component at index ${i} must have 'kind' property`,\n });\n }\n\n const kind = record['kind'];\n if (kind !== 'target' && kind !== 'adapter' && kind !== 'extension' && kind !== 'driver') {\n throw errorConfigValidation('frameworkComponents[].kind', {\n why: `Framework component at index ${i} has invalid kind '${String(kind)}' (must be 'target', 'adapter', 'extension', or 'driver')`,\n });\n }\n\n // Check familyId\n if (!Object.hasOwn(record, 'familyId')) {\n throw errorConfigValidation('frameworkComponents[].familyId', {\n why: `Framework component at index ${i} (kind: ${String(kind)}) must have 'familyId' property`,\n });\n }\n\n const familyId = record['familyId'];\n if (familyId !== expectedFamilyId) {\n throw errorConfigValidation('frameworkComponents[].familyId', {\n why: `Framework component at index ${i} (kind: ${String(kind)}) has familyId '${String(familyId)}' but expected '${expectedFamilyId}'`,\n });\n }\n\n // Check targetId\n if (!Object.hasOwn(record, 'targetId')) {\n throw errorConfigValidation('frameworkComponents[].targetId', {\n why: `Framework component at index ${i} (kind: ${String(kind)}) must have 'targetId' property`,\n });\n }\n\n const targetId = record['targetId'];\n if (targetId !== expectedTargetId) {\n throw errorConfigValidation('frameworkComponents[].targetId', {\n why: `Framework component at index ${i} (kind: ${String(kind)}) has targetId '${String(targetId)}' but expected '${expectedTargetId}'`,\n });\n }\n }\n\n // Type assertion is safe because we've validated all components above\n return frameworkComponents as ReadonlyArray<T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,UAAM,WAAW,OAAO,UAAU;AAClC,QAAI,aAAa,kBAAkB;AACjC,YAAM,sBAAsB,kCAAkC;AAAA,QAC5D,KAAK,gCAAgC,CAAC,WAAW,OAAO,IAAI,CAAC,mBAAmB,OAAO,QAAQ,CAAC,mBAAmB,gBAAgB;AAAA,MACrI,CAAC;AAAA,IACH;AAAA,EACF;AAGA,SAAO;AACT;","names":[]}
|
|
@@ -961,6 +961,7 @@ export {
|
|
|
961
961
|
formatStyledHeader,
|
|
962
962
|
formatSuccessMessage,
|
|
963
963
|
formatCommandHelp,
|
|
964
|
+
errorConfigValidation,
|
|
964
965
|
errorDatabaseUrlRequired,
|
|
965
966
|
errorDriverRequired,
|
|
966
967
|
errorFileNotFound,
|
|
@@ -972,4 +973,4 @@ export {
|
|
|
972
973
|
handleResult,
|
|
973
974
|
withSpinner
|
|
974
975
|
};
|
|
975
|
-
//# sourceMappingURL=chunk-
|
|
976
|
+
//# sourceMappingURL=chunk-ZKEJZ3NU.js.map
|
package/dist/cli.js
CHANGED
|
@@ -1176,6 +1176,55 @@ function createContractEmitCommand() {
|
|
|
1176
1176
|
import { readFile } from "fs/promises";
|
|
1177
1177
|
import { relative as relative3, resolve as resolve3 } from "path";
|
|
1178
1178
|
import { Command as Command2 } from "commander";
|
|
1179
|
+
|
|
1180
|
+
// src/utils/framework-components.ts
|
|
1181
|
+
function assertFrameworkComponentsCompatible(expectedFamilyId, expectedTargetId, frameworkComponents) {
|
|
1182
|
+
for (let i = 0; i < frameworkComponents.length; i++) {
|
|
1183
|
+
const component = frameworkComponents[i];
|
|
1184
|
+
if (typeof component !== "object" || component === null) {
|
|
1185
|
+
throw errorConfigValidation("frameworkComponents[]", {
|
|
1186
|
+
why: `Framework component at index ${i} must be an object`
|
|
1187
|
+
});
|
|
1188
|
+
}
|
|
1189
|
+
const record = component;
|
|
1190
|
+
if (!Object.hasOwn(record, "kind")) {
|
|
1191
|
+
throw errorConfigValidation("frameworkComponents[].kind", {
|
|
1192
|
+
why: `Framework component at index ${i} must have 'kind' property`
|
|
1193
|
+
});
|
|
1194
|
+
}
|
|
1195
|
+
const kind = record["kind"];
|
|
1196
|
+
if (kind !== "target" && kind !== "adapter" && kind !== "extension" && kind !== "driver") {
|
|
1197
|
+
throw errorConfigValidation("frameworkComponents[].kind", {
|
|
1198
|
+
why: `Framework component at index ${i} has invalid kind '${String(kind)}' (must be 'target', 'adapter', 'extension', or 'driver')`
|
|
1199
|
+
});
|
|
1200
|
+
}
|
|
1201
|
+
if (!Object.hasOwn(record, "familyId")) {
|
|
1202
|
+
throw errorConfigValidation("frameworkComponents[].familyId", {
|
|
1203
|
+
why: `Framework component at index ${i} (kind: ${String(kind)}) must have 'familyId' property`
|
|
1204
|
+
});
|
|
1205
|
+
}
|
|
1206
|
+
const familyId = record["familyId"];
|
|
1207
|
+
if (familyId !== expectedFamilyId) {
|
|
1208
|
+
throw errorConfigValidation("frameworkComponents[].familyId", {
|
|
1209
|
+
why: `Framework component at index ${i} (kind: ${String(kind)}) has familyId '${String(familyId)}' but expected '${expectedFamilyId}'`
|
|
1210
|
+
});
|
|
1211
|
+
}
|
|
1212
|
+
if (!Object.hasOwn(record, "targetId")) {
|
|
1213
|
+
throw errorConfigValidation("frameworkComponents[].targetId", {
|
|
1214
|
+
why: `Framework component at index ${i} (kind: ${String(kind)}) must have 'targetId' property`
|
|
1215
|
+
});
|
|
1216
|
+
}
|
|
1217
|
+
const targetId = record["targetId"];
|
|
1218
|
+
if (targetId !== expectedTargetId) {
|
|
1219
|
+
throw errorConfigValidation("frameworkComponents[].targetId", {
|
|
1220
|
+
why: `Framework component at index ${i} (kind: ${String(kind)}) has targetId '${String(targetId)}' but expected '${expectedTargetId}'`
|
|
1221
|
+
});
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
1224
|
+
return frameworkComponents;
|
|
1225
|
+
}
|
|
1226
|
+
|
|
1227
|
+
// src/commands/db-init.ts
|
|
1179
1228
|
function createDbInitCommand() {
|
|
1180
1229
|
const command = new Command2("init");
|
|
1181
1230
|
setCommandDescriptions(
|
|
@@ -1262,7 +1311,12 @@ function createDbInitCommand() {
|
|
|
1262
1311
|
driver: driverDescriptor,
|
|
1263
1312
|
extensions: config.extensions ?? []
|
|
1264
1313
|
});
|
|
1265
|
-
const
|
|
1314
|
+
const rawComponents = [config.target, config.adapter, ...config.extensions ?? []];
|
|
1315
|
+
const frameworkComponents = assertFrameworkComponentsCompatible(
|
|
1316
|
+
config.family.familyId,
|
|
1317
|
+
config.target.targetId,
|
|
1318
|
+
rawComponents
|
|
1319
|
+
);
|
|
1266
1320
|
const contractIR = familyInstance.validateContractIR(contractJson);
|
|
1267
1321
|
const planner = migrations.createPlanner(familyInstance);
|
|
1268
1322
|
const runner = migrations.createRunner(familyInstance);
|
|
@@ -1619,7 +1673,12 @@ function createDbSchemaVerifyCommand() {
|
|
|
1619
1673
|
driver: driverDescriptor,
|
|
1620
1674
|
extensions: config.extensions ?? []
|
|
1621
1675
|
});
|
|
1622
|
-
const
|
|
1676
|
+
const rawComponents = [config.target, config.adapter, ...config.extensions ?? []];
|
|
1677
|
+
const frameworkComponents = assertFrameworkComponentsCompatible(
|
|
1678
|
+
config.family.familyId,
|
|
1679
|
+
config.target.targetId,
|
|
1680
|
+
rawComponents
|
|
1681
|
+
);
|
|
1623
1682
|
const contractIR = familyInstance.validateContractIR(contractJson);
|
|
1624
1683
|
let schemaVerifyResult;
|
|
1625
1684
|
try {
|
|
@@ -1746,7 +1805,12 @@ function createDbSignCommand() {
|
|
|
1746
1805
|
driver: driverDescriptor,
|
|
1747
1806
|
extensions: config.extensions ?? []
|
|
1748
1807
|
});
|
|
1749
|
-
const
|
|
1808
|
+
const rawComponents = [config.target, config.adapter, ...config.extensions ?? []];
|
|
1809
|
+
const frameworkComponents = assertFrameworkComponentsCompatible(
|
|
1810
|
+
config.family.familyId,
|
|
1811
|
+
config.target.targetId,
|
|
1812
|
+
rawComponents
|
|
1813
|
+
);
|
|
1750
1814
|
const contractIR = familyInstance.validateContractIR(contractJson);
|
|
1751
1815
|
let schemaVerifyResult;
|
|
1752
1816
|
try {
|