prisma-next 0.5.0-dev.8 → 0.5.0-dev.81
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-errors-B9OBbled.d.mts +3 -0
- package/dist/cli-errors-D3_sMh2K.mjs +33 -0
- package/dist/cli-errors-D3_sMh2K.mjs.map +1 -0
- package/dist/cli.mjs +16 -78
- package/dist/cli.mjs.map +1 -1
- package/dist/client-qVH-rEgd.mjs +1595 -0
- package/dist/client-qVH-rEgd.mjs.map +1 -0
- package/dist/{result-handler-Ba3zWQsI.mjs → command-helpers-BeZHkxV8.mjs} +70 -47
- package/dist/command-helpers-BeZHkxV8.mjs.map +1 -0
- package/dist/commands/contract-emit.d.mts.map +1 -1
- package/dist/commands/contract-emit.mjs +2 -4
- package/dist/commands/contract-infer.d.mts.map +1 -1
- package/dist/commands/contract-infer.mjs +2 -4
- package/dist/commands/db-init.d.mts.map +1 -1
- package/dist/commands/db-init.mjs +16 -13
- 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 +6 -7
- 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 +9 -9
- 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 +15 -13
- 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 -321
- package/dist/commands/migration-apply.d.mts +28 -13
- package/dist/commands/migration-apply.d.mts.map +1 -1
- package/dist/commands/migration-apply.mjs +55 -151
- package/dist/commands/migration-apply.mjs.map +1 -1
- package/dist/commands/migration-new.d.mts +0 -1
- package/dist/commands/migration-new.d.mts.map +1 -1
- package/dist/commands/migration-new.mjs +34 -40
- package/dist/commands/migration-new.mjs.map +1 -1
- package/dist/commands/migration-plan.d.mts +33 -6
- package/dist/commands/migration-plan.d.mts.map +1 -1
- package/dist/commands/migration-plan.mjs +2 -348
- package/dist/commands/migration-ref.d.mts +1 -1
- package/dist/commands/migration-ref.d.mts.map +1 -1
- package/dist/commands/migration-ref.mjs +8 -12
- package/dist/commands/migration-ref.mjs.map +1 -1
- package/dist/commands/migration-show.d.mts +13 -7
- package/dist/commands/migration-show.d.mts.map +1 -1
- package/dist/commands/migration-show.mjs +35 -36
- package/dist/commands/migration-show.mjs.map +1 -1
- package/dist/commands/migration-status.d.mts +126 -5
- package/dist/commands/migration-status.d.mts.map +1 -1
- package/dist/commands/migration-status.mjs +2 -4
- package/dist/{config-loader-C25b63rJ.mjs → config-loader-B6sJjXTv.mjs} +3 -5
- package/dist/config-loader-B6sJjXTv.mjs.map +1 -0
- package/dist/config-loader.d.mts +0 -1
- package/dist/config-loader.d.mts.map +1 -1
- package/dist/config-loader.mjs +2 -3
- package/dist/contract-emit-9DBda5Ou.mjs +150 -0
- package/dist/contract-emit-9DBda5Ou.mjs.map +1 -0
- package/dist/contract-emit-B77TsJqf.mjs +327 -0
- package/dist/contract-emit-B77TsJqf.mjs.map +1 -0
- package/dist/{contract-enrichment-CAOELa-H.mjs → contract-enrichment-Dani0mMW.mjs} +4 -6
- package/dist/contract-enrichment-Dani0mMW.mjs.map +1 -0
- package/dist/{contract-infer-D9cC3rJm.mjs → contract-infer-BK9YFGEG.mjs} +13 -22
- package/dist/contract-infer-BK9YFGEG.mjs.map +1 -0
- package/dist/db-verify-C0y1PCO2.mjs +404 -0
- package/dist/db-verify-C0y1PCO2.mjs.map +1 -0
- package/dist/exports/config-types.mjs +1 -2
- package/dist/exports/control-api.d.mts +101 -586
- package/dist/exports/control-api.d.mts.map +1 -1
- package/dist/exports/control-api.mjs +4 -6
- package/dist/exports/index.d.mts.map +1 -1
- package/dist/exports/index.mjs +28 -30
- package/dist/exports/index.mjs.map +1 -1
- package/dist/exports/init-output.d.mts +2 -4
- package/dist/exports/init-output.d.mts.map +1 -1
- package/dist/exports/init-output.mjs +2 -3
- package/dist/extension-pack-inputs-C7xgE-vv.mjs +74 -0
- package/dist/extension-pack-inputs-C7xgE-vv.mjs.map +1 -0
- package/dist/{framework-components-Cr--XBKy.mjs → framework-components-ChqVUxR-.mjs} +3 -4
- package/dist/{framework-components-Cr--XBKy.mjs.map → framework-components-ChqVUxR-.mjs.map} +1 -1
- package/dist/global-flags-Icqpxk23.d.mts +12 -0
- package/dist/global-flags-Icqpxk23.d.mts.map +1 -0
- package/dist/helpers-eqdN8tH6.mjs +25 -0
- package/dist/helpers-eqdN8tH6.mjs.map +1 -0
- package/dist/{init-C5220SY9.mjs → init-CoDVPvQ4.mjs} +26 -35
- package/dist/init-CoDVPvQ4.mjs.map +1 -0
- package/dist/{inspect-live-schema-yrHAvG71.mjs → inspect-live-schema-CWYxGKlb.mjs} +10 -11
- package/dist/inspect-live-schema-CWYxGKlb.mjs.map +1 -0
- package/dist/migration-cli.d.mts +41 -12
- package/dist/migration-cli.d.mts.map +1 -1
- package/dist/migration-cli.mjs +309 -86
- package/dist/migration-cli.mjs.map +1 -1
- package/dist/{migration-command-scaffold-B3B09et6.mjs → migration-command-scaffold-B5dORFEv.mjs} +8 -9
- package/dist/migration-command-scaffold-B5dORFEv.mjs.map +1 -0
- package/dist/migration-plan-C6lVaHsO.mjs +554 -0
- package/dist/migration-plan-C6lVaHsO.mjs.map +1 -0
- package/dist/{migration-status-DUMiH8_G.mjs → migration-status-CZ-D5k7k.mjs} +272 -65
- package/dist/migration-status-CZ-D5k7k.mjs.map +1 -0
- package/dist/migrations-D_UJnpuW.mjs +216 -0
- package/dist/migrations-D_UJnpuW.mjs.map +1 -0
- package/dist/{output-BpcQrnnq.mjs → output-B16Kefzx.mjs} +9 -3
- package/dist/output-B16Kefzx.mjs.map +1 -0
- package/dist/{progress-adapter-DvQWB1nK.mjs → progress-adapter-DFfvZcYL.mjs} +2 -2
- package/dist/{progress-adapter-DvQWB1nK.mjs.map → progress-adapter-DFfvZcYL.mjs.map} +1 -1
- package/dist/result-handler-rmPVKIP2.mjs +25 -0
- package/dist/result-handler-rmPVKIP2.mjs.map +1 -0
- package/dist/rolldown-runtime-twds-ZHy.mjs +14 -0
- package/dist/{terminal-ui-C3ZLwQxK.mjs → terminal-ui-C_hFNbAn.mjs} +4 -28
- package/dist/terminal-ui-C_hFNbAn.mjs.map +1 -0
- package/dist/types-D7x-IFLO.d.mts +858 -0
- package/dist/types-D7x-IFLO.d.mts.map +1 -0
- package/dist/{verify-Bkycc-Tf.mjs → verify-CiwNWM9N.mjs} +3 -4
- package/dist/verify-CiwNWM9N.mjs.map +1 -0
- package/package.json +19 -17
- package/dist/cli-errors-BFYgBH3L.d.mts +0 -4
- package/dist/cli-errors-Cd79vmTH.mjs +0 -5
- package/dist/client-CrsnY58k.mjs +0 -997
- package/dist/client-CrsnY58k.mjs.map +0 -1
- package/dist/commands/db-verify.mjs.map +0 -1
- package/dist/commands/migration-plan.mjs.map +0 -1
- package/dist/config-loader-C25b63rJ.mjs.map +0 -1
- package/dist/contract-emit--feXyNd7.mjs +0 -4
- package/dist/contract-emit-NJ01hiiv.mjs +0 -195
- package/dist/contract-emit-NJ01hiiv.mjs.map +0 -1
- package/dist/contract-emit-V5SSitUT.mjs +0 -122
- package/dist/contract-emit-V5SSitUT.mjs.map +0 -1
- package/dist/contract-enrichment-CAOELa-H.mjs.map +0 -1
- package/dist/contract-infer-D9cC3rJm.mjs.map +0 -1
- package/dist/extract-operation-statements-DsFfxXVZ.mjs +0 -13
- package/dist/extract-operation-statements-DsFfxXVZ.mjs.map +0 -1
- package/dist/extract-sql-ddl-D9UbZDyz.mjs +0 -26
- package/dist/extract-sql-ddl-D9UbZDyz.mjs.map +0 -1
- package/dist/init-C5220SY9.mjs.map +0 -1
- package/dist/inspect-live-schema-yrHAvG71.mjs.map +0 -1
- package/dist/migration-command-scaffold-B3B09et6.mjs.map +0 -1
- package/dist/migration-status-DUMiH8_G.mjs.map +0 -1
- package/dist/migrations-Bo5WtTla.mjs +0 -153
- package/dist/migrations-Bo5WtTla.mjs.map +0 -1
- package/dist/output-BpcQrnnq.mjs.map +0 -1
- package/dist/result-handler-Ba3zWQsI.mjs.map +0 -1
- package/dist/terminal-ui-C3ZLwQxK.mjs.map +0 -1
- package/dist/validate-contract-deps-B_Cs29TL.mjs +0 -37
- package/dist/validate-contract-deps-B_Cs29TL.mjs.map +0 -1
- package/dist/verify-Bkycc-Tf.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"control-api.d.mts","names":[],"sources":["../../src/control-api/
|
|
1
|
+
{"version":3,"file":"control-api.d.mts","names":[],"sources":["../../src/control-api/client.ts","../../src/control-api/contract-enrichment.ts","../../src/control-api/operations/contract-emit.ts","../../src/control-api/operations/db-init.ts","../../src/control-api/operations/db-update.ts","../../src/utils/emit-queue.ts"],"mappings":";;;;;;;;;;;AA+DA;;;;;iBAAgB,mBAAA,CAAoB,OAAA,EAAS,oBAAA,GAAuB,aAAA;;;;;;iBC4BpD,cAAA,CACd,EAAA,EAAI,QAAA,EACJ,UAAA,EAAY,aAAA,CAAc,8BAAA,oBACzB,QAAA;;;;;;;;AD/BH;;;;;;;;;;;;AC4BA;;;iBC4DsB,mBAAA,CACpB,OAAA,EAAS,mBAAA,GACR,OAAA,CAAQ,kBAAA;;;;;AF1FX;;;;;;;;;;;;AC4BA;;;UE9DiB,oBAAA;EAAA,SACN,MAAA,EAAQ,qBAAA,CAAsB,SAAA,EAAW,SAAA;EAAA,SACzC,cAAA,EAAgB,qBAAA,CAAsB,SAAA;EAAA,SACtC,QAAA,EAAU,QAAA;EAAA,SACV,IAAA;EAAA,SACA,UAAA,EAAY,0BAAA,CACnB,SAAA,EACA,SAAA,EACA,qBAAA,CAAsB,SAAA;EAAA,SAEf,mBAAA,EAAqB,aAAA,CAAc,8BAAA,CAA+B,SAAA,EAAW,SAAA;EFqDtF;;;;EAAA,SEhDS,aAAA;EFkDA;;;;EAAA,SE7CA,QAAA,EAAU,SAAA;EDsGC;;;;;EAAA,SChGX,cAAA,GAAiB,aAAA,CAAc,0BAAA,CAA2B,SAAA,EAAW,SAAA;EDkGtE;EAAA,SChGC,UAAA,GAAa,iBAAA;AAAA;;;;;;;;iBAUF,aAAA,oDAAA,CACpB,OAAA,EAAS,oBAAA,CAAqB,SAAA,EAAW,SAAA,IACxC,OAAA,CAAQ,YAAA;;;;;AHNX;;;;;;;UIrCiB,sBAAA;EAAA,SACN,MAAA,EAAQ,qBAAA,CAAsB,SAAA,EAAW,SAAA;EAAA,SACzC,cAAA,EAAgB,qBAAA,CAAsB,SAAA;EAAA,SACtC,QAAA,EAAU,QAAA;EAAA,SACV,IAAA;EAAA,SACA,UAAA,EAAY,0BAAA,CACnB,SAAA,EACA,SAAA,EACA,qBAAA,CAAsB,SAAA;EAAA,SAEf,mBAAA,EAAqB,aAAA,CAAc,8BAAA,CAA+B,SAAA,EAAW,SAAA;EAAA,SAC7E,cAAA;EAAA,SACA,aAAA;EAAA,SACA,QAAA,EAAU,SAAA;EAAA,SACV,cAAA,GAAiB,aAAA,CAAc,0BAAA,CAA2B,SAAA,EAAW,SAAA;EAAA,SACrE,UAAA,GAAa,iBAAA;AAAA;;;;;;;;;;iBAYF,eAAA,oDAAA,CACpB,OAAA,EAAS,sBAAA,CAAuB,SAAA,EAAW,SAAA,IAC1C,OAAA,CAAQ,cAAA;;;iBChCK,gBAAA,CAAiB,cAAA"}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import "../
|
|
2
|
-
import { t as enrichContract } from "../contract-enrichment-
|
|
3
|
-
import { t as createControlClient } from "../client-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export { createControlClient, enrichContract, executeContractEmit };
|
|
1
|
+
import { n as executeContractEmit, r as disposeEmitQueue } from "../contract-emit-B77TsJqf.mjs";
|
|
2
|
+
import { t as enrichContract } from "../contract-enrichment-Dani0mMW.mjs";
|
|
3
|
+
import { i as executeDbInit, n as executeDbVerify, r as executeDbUpdate, t as createControlClient } from "../client-qVH-rEgd.mjs";
|
|
4
|
+
export { createControlClient, disposeEmitQueue, enrichContract, executeContractEmit, executeDbInit, executeDbUpdate, executeDbVerify };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/load-ts-contract.ts"],"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/load-ts-contract.ts"],"mappings":";;;;UAQiB,qBAAA;EAAA,SACN,SAAA,GAAY,aAAA;AAAA;AADvB;;;;;AA6HA;;;;;;;;;;AA7HA,iBA6HsB,kBAAA,CACpB,SAAA,UACA,OAAA,GAAU,qBAAA,GACT,OAAA,CAAQ,QAAA"}
|
package/dist/exports/index.mjs
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import "../
|
|
2
|
-
import {
|
|
1
|
+
import { t as createContractEmitCommand } from "../contract-emit-9DBda5Ou.mjs";
|
|
2
|
+
import { join, resolve } from "pathe";
|
|
3
3
|
import { existsSync, unlinkSync, writeFileSync } from "node:fs";
|
|
4
|
-
import { join } from "pathe";
|
|
5
4
|
import { tmpdir } from "node:os";
|
|
6
5
|
import { pathToFileURL } from "node:url";
|
|
7
6
|
import { build } from "esbuild";
|
|
8
|
-
|
|
9
7
|
//#region src/load-ts-contract.ts
|
|
10
8
|
const DEFAULT_ALLOWLIST = ["@prisma-next/*", "node:crypto"];
|
|
11
9
|
function isAllowedImport(importPath, allowlist) {
|
|
@@ -21,19 +19,19 @@ function isAllowedImport(importPath, allowlist) {
|
|
|
21
19
|
function validatePurity(value) {
|
|
22
20
|
if (typeof value !== "object" || value === null) return;
|
|
23
21
|
const path = /* @__PURE__ */ new WeakSet();
|
|
24
|
-
function check(value
|
|
25
|
-
if (value
|
|
26
|
-
if (path.has(value
|
|
27
|
-
path.add(value
|
|
22
|
+
function check(value) {
|
|
23
|
+
if (value === null || typeof value !== "object") return;
|
|
24
|
+
if (path.has(value)) throw new Error("Contract export contains circular references");
|
|
25
|
+
path.add(value);
|
|
28
26
|
try {
|
|
29
|
-
for (const key in value
|
|
30
|
-
const descriptor = Object.getOwnPropertyDescriptor(value
|
|
27
|
+
for (const key in value) {
|
|
28
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
31
29
|
if (descriptor && (descriptor.get || descriptor.set)) throw new Error(`Contract export contains getter/setter at key "${key}"`);
|
|
32
30
|
if (descriptor && typeof descriptor.value === "function") throw new Error(`Contract export contains function at key "${key}"`);
|
|
33
|
-
check(value
|
|
31
|
+
check(value[key]);
|
|
34
32
|
}
|
|
35
33
|
} finally {
|
|
36
|
-
path.delete(value
|
|
34
|
+
path.delete(value);
|
|
37
35
|
}
|
|
38
36
|
}
|
|
39
37
|
try {
|
|
@@ -47,17 +45,24 @@ function validatePurity(value) {
|
|
|
47
45
|
throw new Error("Contract export is not JSON-serializable");
|
|
48
46
|
}
|
|
49
47
|
}
|
|
50
|
-
function createImportAllowlistPlugin(allowlist, entryPath) {
|
|
48
|
+
function createImportAllowlistPlugin(allowlist, entryPath, collected) {
|
|
49
|
+
const entryAbs = resolve(entryPath);
|
|
50
|
+
function isFromEntry(importer) {
|
|
51
|
+
return importer === entryAbs || importer === entryPath || importer === "<stdin>";
|
|
52
|
+
}
|
|
51
53
|
return {
|
|
52
54
|
name: "import-allowlist",
|
|
53
|
-
setup(build
|
|
54
|
-
build
|
|
55
|
+
setup(build) {
|
|
56
|
+
build.onResolve({ filter: /.*/ }, (args) => {
|
|
55
57
|
if (args.kind === "entry-point") return;
|
|
56
58
|
if (args.path.startsWith(".") || args.path.startsWith("/")) return;
|
|
57
|
-
if ((args.importer
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
if (isFromEntry(args.importer) && !isAllowedImport(args.path, allowlist)) {
|
|
60
|
+
collected.add(args.path);
|
|
61
|
+
return {
|
|
62
|
+
path: args.path,
|
|
63
|
+
external: true
|
|
64
|
+
};
|
|
65
|
+
}
|
|
61
66
|
});
|
|
62
67
|
}
|
|
63
68
|
};
|
|
@@ -81,6 +86,7 @@ async function loadContractFromTs(entryPath, options) {
|
|
|
81
86
|
const allowlist = options?.allowlist ?? DEFAULT_ALLOWLIST;
|
|
82
87
|
if (!existsSync(entryPath)) throw new Error(`Contract file not found: ${entryPath}`);
|
|
83
88
|
const tempFile = join(tmpdir(), `prisma-next-contract-${Date.now()}-${Math.random().toString(36).slice(2)}.mjs`);
|
|
89
|
+
const disallowedFromEntry = /* @__PURE__ */ new Set();
|
|
84
90
|
try {
|
|
85
91
|
const result = await build({
|
|
86
92
|
entryPoints: [entryPath],
|
|
@@ -91,7 +97,7 @@ async function loadContractFromTs(entryPath, options) {
|
|
|
91
97
|
outfile: tempFile,
|
|
92
98
|
write: false,
|
|
93
99
|
metafile: true,
|
|
94
|
-
plugins: [createImportAllowlistPlugin(allowlist, entryPath)],
|
|
100
|
+
plugins: [createImportAllowlistPlugin(allowlist, entryPath, disallowedFromEntry)],
|
|
95
101
|
logLevel: "error"
|
|
96
102
|
});
|
|
97
103
|
if (result.errors.length > 0) {
|
|
@@ -99,15 +105,7 @@ async function loadContractFromTs(entryPath, options) {
|
|
|
99
105
|
throw new Error(`Failed to bundle contract file: ${errorMessages}`);
|
|
100
106
|
}
|
|
101
107
|
if (!result.outputFiles || result.outputFiles.length === 0) throw new Error("No output files generated from bundling");
|
|
102
|
-
|
|
103
|
-
if (result.metafile) {
|
|
104
|
-
const inputs = result.metafile.inputs;
|
|
105
|
-
for (const [, inputData] of Object.entries(inputs)) {
|
|
106
|
-
const imports = inputData.imports || [];
|
|
107
|
-
for (const imp of imports) if (imp.external && !imp.path.startsWith(".") && !imp.path.startsWith("/") && !isAllowedImport(imp.path, allowlist)) disallowedImports.push(imp.path);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
if (disallowedImports.length > 0) throw new Error(`Disallowed imports detected. Only imports matching the allowlist are permitted:\n Allowlist: ${allowlist.join(", ")}\n Disallowed imports: ${disallowedImports.join(", ")}\n\nOnly @prisma-next/* packages are allowed in contract files.`);
|
|
108
|
+
if (disallowedFromEntry.size > 0) throw new Error(`Disallowed imports detected. Only imports matching the allowlist are permitted:\n Allowlist: ${allowlist.join(", ")}\n Disallowed imports: ${[...disallowedFromEntry].join(", ")}`);
|
|
111
109
|
const bundleContent = result.outputFiles[0]?.text;
|
|
112
110
|
if (bundleContent === void 0) throw new Error("Bundle content is undefined");
|
|
113
111
|
writeFileSync(tempFile, bundleContent, "utf-8");
|
|
@@ -131,7 +129,7 @@ async function loadContractFromTs(entryPath, options) {
|
|
|
131
129
|
throw new Error(`Failed to load contract from ${entryPath}: ${String(error)}`);
|
|
132
130
|
}
|
|
133
131
|
}
|
|
134
|
-
|
|
135
132
|
//#endregion
|
|
136
133
|
export { createContractEmitCommand, loadContractFromTs };
|
|
134
|
+
|
|
137
135
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["value","disallowedImports: string[]","contract: unknown"],"sources":["../../src/load-ts-contract.ts"],"sourcesContent":["import { existsSync, unlinkSync, writeFileSync } from 'node:fs';\nimport { tmpdir } from 'node:os';\nimport { pathToFileURL } from 'node:url';\nimport type { Contract } from '@prisma-next/contract/types';\nimport type { Plugin } from 'esbuild';\nimport { build } from 'esbuild';\nimport { join } from 'pathe';\n\nexport interface LoadTsContractOptions {\n readonly allowlist?: ReadonlyArray<string>;\n}\n\nconst DEFAULT_ALLOWLIST = ['@prisma-next/*', 'node:crypto'];\n\nfunction isAllowedImport(importPath: string, allowlist: ReadonlyArray<string>): boolean {\n for (const pattern of allowlist) {\n if (pattern.endsWith('/*')) {\n const prefix = pattern.slice(0, -2);\n if (importPath === prefix || importPath.startsWith(`${prefix}/`)) {\n return true;\n }\n } else if (pattern.endsWith('*')) {\n const prefix = pattern.slice(0, -1);\n if (importPath.startsWith(prefix)) {\n return true;\n }\n } else if (importPath === pattern) {\n return true;\n }\n }\n return false;\n}\n\nfunction validatePurity(value: unknown): void {\n if (typeof value !== 'object' || value === null) {\n return;\n }\n\n const path = new WeakSet();\n\n function check(value: unknown): void {\n if (value === null || typeof value !== 'object') {\n return;\n }\n\n if (path.has(value)) {\n throw new Error('Contract export contains circular references');\n }\n path.add(value);\n\n try {\n for (const key in value) {\n const descriptor = Object.getOwnPropertyDescriptor(value, key);\n if (descriptor && (descriptor.get || descriptor.set)) {\n throw new Error(`Contract export contains getter/setter at key \"${key}\"`);\n }\n if (descriptor && typeof descriptor.value === 'function') {\n throw new Error(`Contract export contains function at key \"${key}\"`);\n }\n check((value as Record<string, unknown>)[key]);\n }\n } finally {\n path.delete(value);\n }\n }\n\n try {\n check(value);\n JSON.stringify(value);\n } catch (error) {\n if (error instanceof Error) {\n if (error.message.includes('getter') || error.message.includes('circular')) {\n throw error;\n }\n throw new Error(`Contract export is not JSON-serializable: ${error.message}`);\n }\n throw new Error('Contract export is not JSON-serializable');\n }\n}\n\nfunction createImportAllowlistPlugin(allowlist: ReadonlyArray<string>, entryPath: string): Plugin {\n return {\n name: 'import-allowlist',\n setup(build) {\n build.onResolve({ filter: /.*/ }, (args) => {\n if (args.kind === 'entry-point') {\n return undefined;\n }\n if (args.path.startsWith('.') || args.path.startsWith('/')) {\n return undefined;\n }\n const isFromEntryPoint = args.importer === entryPath || args.importer === '<stdin>';\n if (isFromEntryPoint && !isAllowedImport(args.path, allowlist)) {\n return {\n path: args.path,\n external: true,\n };\n }\n return undefined;\n });\n },\n };\n}\n\n/**\n * Loads a contract from a TypeScript file and returns it as Contract.\n *\n * **Responsibility: Parsing Only**\n * This function loads and parses a TypeScript contract file. It does NOT normalize the contract.\n * The contract should already be normalized if it was built using the contract builder.\n *\n * Normalization must happen in the contract builder when the contract is created.\n * This function only validates that the contract is JSON-serializable and returns it as-is.\n *\n * @param entryPath - Path to the TypeScript contract file\n * @param options - Optional configuration (import allowlist)\n * @returns The contract as Contract (should already be normalized)\n * @throws Error if the contract cannot be loaded or is not JSON-serializable\n */\nexport async function loadContractFromTs(\n entryPath: string,\n options?: LoadTsContractOptions,\n): Promise<Contract> {\n const allowlist = options?.allowlist ?? DEFAULT_ALLOWLIST;\n\n if (!existsSync(entryPath)) {\n throw new Error(`Contract file not found: ${entryPath}`);\n }\n\n const tempFile = join(\n tmpdir(),\n `prisma-next-contract-${Date.now()}-${Math.random().toString(36).slice(2)}.mjs`,\n );\n\n try {\n const result = await build({\n entryPoints: [entryPath],\n bundle: true,\n format: 'esm',\n platform: 'node',\n target: 'es2022',\n outfile: tempFile,\n write: false,\n metafile: true,\n plugins: [createImportAllowlistPlugin(allowlist, entryPath)],\n logLevel: 'error',\n });\n\n if (result.errors.length > 0) {\n const errorMessages = result.errors.map((e: { text: string }) => e.text).join('\\n');\n throw new Error(`Failed to bundle contract file: ${errorMessages}`);\n }\n\n if (!result.outputFiles || result.outputFiles.length === 0) {\n throw new Error('No output files generated from bundling');\n }\n\n const disallowedImports: string[] = [];\n if (result.metafile) {\n const inputs = result.metafile.inputs;\n for (const [, inputData] of Object.entries(inputs)) {\n const imports =\n (inputData as { imports?: Array<{ path: string; external?: boolean }> }).imports || [];\n for (const imp of imports) {\n if (\n imp.external &&\n !imp.path.startsWith('.') &&\n !imp.path.startsWith('/') &&\n !isAllowedImport(imp.path, allowlist)\n ) {\n disallowedImports.push(imp.path);\n }\n }\n }\n }\n\n if (disallowedImports.length > 0) {\n throw new Error(\n `Disallowed imports detected. Only imports matching the allowlist are permitted:\\n Allowlist: ${allowlist.join(', ')}\\n Disallowed imports: ${disallowedImports.join(', ')}\\n\\nOnly @prisma-next/* packages are allowed in contract files.`,\n );\n }\n\n const bundleContent = result.outputFiles[0]?.text;\n if (bundleContent === undefined) {\n throw new Error('Bundle content is undefined');\n }\n writeFileSync(tempFile, bundleContent, 'utf-8');\n\n const module = (await import(/* @vite-ignore */ pathToFileURL(tempFile).href)) as {\n default?: unknown;\n contract?: unknown;\n };\n unlinkSync(tempFile);\n\n let contract: unknown;\n\n if (module.default !== undefined) {\n contract = module.default;\n } else if (module.contract !== undefined) {\n contract = module.contract;\n } else {\n throw new Error(\n `Contract file must export a contract as default export or named export 'contract'. Found exports: ${Object.keys(module as Record<string, unknown>).join(', ') || 'none'}`,\n );\n }\n\n if (typeof contract !== 'object' || contract === null) {\n throw new Error(`Contract export must be an object, got ${typeof contract}`);\n }\n\n validatePurity(contract);\n\n return contract as Contract;\n } catch (error) {\n try {\n if (tempFile) {\n unlinkSync(tempFile);\n }\n } catch {\n // Ignore cleanup errors\n }\n\n if (error instanceof Error) {\n throw error;\n }\n throw new Error(`Failed to load contract from ${entryPath}: ${String(error)}`);\n }\n}\n"],"mappings":";;;;;;;;;AAYA,MAAM,oBAAoB,CAAC,kBAAkB,cAAc;AAE3D,SAAS,gBAAgB,YAAoB,WAA2C;AACtF,MAAK,MAAM,WAAW,UACpB,KAAI,QAAQ,SAAS,KAAK,EAAE;EAC1B,MAAM,SAAS,QAAQ,MAAM,GAAG,GAAG;AACnC,MAAI,eAAe,UAAU,WAAW,WAAW,GAAG,OAAO,GAAG,CAC9D,QAAO;YAEA,QAAQ,SAAS,IAAI,EAAE;EAChC,MAAM,SAAS,QAAQ,MAAM,GAAG,GAAG;AACnC,MAAI,WAAW,WAAW,OAAO,CAC/B,QAAO;YAEA,eAAe,QACxB,QAAO;AAGX,QAAO;;AAGT,SAAS,eAAe,OAAsB;AAC5C,KAAI,OAAO,UAAU,YAAY,UAAU,KACzC;CAGF,MAAM,uBAAO,IAAI,SAAS;CAE1B,SAAS,MAAM,SAAsB;AACnC,MAAIA,YAAU,QAAQ,OAAOA,YAAU,SACrC;AAGF,MAAI,KAAK,IAAIA,QAAM,CACjB,OAAM,IAAI,MAAM,+CAA+C;AAEjE,OAAK,IAAIA,QAAM;AAEf,MAAI;AACF,QAAK,MAAM,OAAOA,SAAO;IACvB,MAAM,aAAa,OAAO,yBAAyBA,SAAO,IAAI;AAC9D,QAAI,eAAe,WAAW,OAAO,WAAW,KAC9C,OAAM,IAAI,MAAM,kDAAkD,I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AAS;AAExB,SAAO;UACA,OAAO;AACd,MAAI;AACF,OAAI,SACF,YAAW,SAAS;UAEhB;AAIR,MAAI,iBAAiB,MACnB,OAAM;AAER,QAAM,IAAI,MAAM,gCAAgC,UAAU,IAAI,OAAO,MAAM,GAAG"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["resolvePath"],"sources":["../../src/load-ts-contract.ts"],"sourcesContent":["import { existsSync, unlinkSync, writeFileSync } from 'node:fs';\nimport { tmpdir } from 'node:os';\nimport { pathToFileURL } from 'node:url';\nimport type { Contract } from '@prisma-next/contract/types';\nimport type { Plugin } from 'esbuild';\nimport { build } from 'esbuild';\nimport { join, resolve as resolvePath } from 'pathe';\n\nexport interface LoadTsContractOptions {\n readonly allowlist?: ReadonlyArray<string>;\n}\n\nconst DEFAULT_ALLOWLIST = ['@prisma-next/*', 'node:crypto'];\n\nfunction isAllowedImport(importPath: string, allowlist: ReadonlyArray<string>): boolean {\n for (const pattern of allowlist) {\n if (pattern.endsWith('/*')) {\n const prefix = pattern.slice(0, -2);\n if (importPath === prefix || importPath.startsWith(`${prefix}/`)) {\n return true;\n }\n } else if (pattern.endsWith('*')) {\n const prefix = pattern.slice(0, -1);\n if (importPath.startsWith(prefix)) {\n return true;\n }\n } else if (importPath === pattern) {\n return true;\n }\n }\n return false;\n}\n\nfunction validatePurity(value: unknown): void {\n if (typeof value !== 'object' || value === null) {\n return;\n }\n\n const path = new WeakSet();\n\n function check(value: unknown): void {\n if (value === null || typeof value !== 'object') {\n return;\n }\n\n if (path.has(value)) {\n throw new Error('Contract export contains circular references');\n }\n path.add(value);\n\n try {\n for (const key in value) {\n const descriptor = Object.getOwnPropertyDescriptor(value, key);\n if (descriptor && (descriptor.get || descriptor.set)) {\n throw new Error(`Contract export contains getter/setter at key \"${key}\"`);\n }\n if (descriptor && typeof descriptor.value === 'function') {\n throw new Error(`Contract export contains function at key \"${key}\"`);\n }\n check((value as Record<string, unknown>)[key]);\n }\n } finally {\n path.delete(value);\n }\n }\n\n try {\n check(value);\n JSON.stringify(value);\n } catch (error) {\n if (error instanceof Error) {\n if (error.message.includes('getter') || error.message.includes('circular')) {\n throw error;\n }\n throw new Error(`Contract export is not JSON-serializable: ${error.message}`);\n }\n throw new Error('Contract export is not JSON-serializable');\n }\n}\n\nfunction createImportAllowlistPlugin(\n allowlist: ReadonlyArray<string>,\n entryPath: string,\n collected: Set<string>,\n): Plugin {\n // Match against several path forms that esbuild may use as the importer:\n // the absolute resolved entry, the value the caller passed (which may be\n // relative), and the conventional `<stdin>` placeholder. This is more\n // forgiving than `===` against a single form, which broke when esbuild\n // resolved the entry to an absolute path while the caller passed a\n // relative one (or vice versa).\n const entryAbs = resolvePath(entryPath);\n function isFromEntry(importer: string): boolean {\n return importer === entryAbs || importer === entryPath || importer === '<stdin>';\n }\n return {\n name: 'import-allowlist',\n setup(build) {\n build.onResolve({ filter: /.*/ }, (args) => {\n if (args.kind === 'entry-point') {\n return undefined;\n }\n if (args.path.startsWith('.') || args.path.startsWith('/')) {\n return undefined;\n }\n if (isFromEntry(args.importer) && !isAllowedImport(args.path, allowlist)) {\n collected.add(args.path);\n return {\n path: args.path,\n external: true,\n };\n }\n return undefined;\n });\n },\n };\n}\n\n/**\n * Loads a contract from a TypeScript file and returns it as Contract.\n *\n * **Responsibility: Parsing Only**\n * This function loads and parses a TypeScript contract file. It does NOT normalize the contract.\n * The contract should already be normalized if it was built using the contract builder.\n *\n * Normalization must happen in the contract builder when the contract is created.\n * This function only validates that the contract is JSON-serializable and returns it as-is.\n *\n * @param entryPath - Path to the TypeScript contract file\n * @param options - Optional configuration (import allowlist)\n * @returns The contract as Contract (should already be normalized)\n * @throws Error if the contract cannot be loaded or is not JSON-serializable\n */\nexport async function loadContractFromTs(\n entryPath: string,\n options?: LoadTsContractOptions,\n): Promise<Contract> {\n const allowlist = options?.allowlist ?? DEFAULT_ALLOWLIST;\n\n if (!existsSync(entryPath)) {\n throw new Error(`Contract file not found: ${entryPath}`);\n }\n\n const tempFile = join(\n tmpdir(),\n `prisma-next-contract-${Date.now()}-${Math.random().toString(36).slice(2)}.mjs`,\n );\n\n // Disallowed imports are collected by the allowlist resolver plugin itself,\n // which has the `importer` context to distinguish entry-direct imports from\n // transitive imports made inside allowlisted (`@prisma-next/*`) dependencies.\n // The metafile is intentionally not re-walked: it would surface internal\n // `node:*` imports inside framework code as false positives.\n const disallowedFromEntry = new Set<string>();\n\n try {\n const result = await build({\n entryPoints: [entryPath],\n bundle: true,\n format: 'esm',\n platform: 'node',\n target: 'es2022',\n outfile: tempFile,\n write: false,\n metafile: true,\n plugins: [createImportAllowlistPlugin(allowlist, entryPath, disallowedFromEntry)],\n logLevel: 'error',\n });\n\n if (result.errors.length > 0) {\n const errorMessages = result.errors.map((e: { text: string }) => e.text).join('\\n');\n throw new Error(`Failed to bundle contract file: ${errorMessages}`);\n }\n\n if (!result.outputFiles || result.outputFiles.length === 0) {\n throw new Error('No output files generated from bundling');\n }\n\n if (disallowedFromEntry.size > 0) {\n throw new Error(\n `Disallowed imports detected. Only imports matching the allowlist are permitted:\\n Allowlist: ${allowlist.join(', ')}\\n Disallowed imports: ${[...disallowedFromEntry].join(', ')}`,\n );\n }\n\n const bundleContent = result.outputFiles[0]?.text;\n if (bundleContent === undefined) {\n throw new Error('Bundle content is undefined');\n }\n writeFileSync(tempFile, bundleContent, 'utf-8');\n\n const module = (await import(/* @vite-ignore */ pathToFileURL(tempFile).href)) as {\n default?: unknown;\n contract?: unknown;\n };\n unlinkSync(tempFile);\n\n let contract: unknown;\n\n if (module.default !== undefined) {\n contract = module.default;\n } else if (module.contract !== undefined) {\n contract = module.contract;\n } else {\n throw new Error(\n `Contract file must export a contract as default export or named export 'contract'. Found exports: ${Object.keys(module as Record<string, unknown>).join(', ') || 'none'}`,\n );\n }\n\n if (typeof contract !== 'object' || contract === null) {\n throw new Error(`Contract export must be an object, got ${typeof contract}`);\n }\n\n validatePurity(contract);\n\n return contract as Contract;\n } catch (error) {\n try {\n if (tempFile) {\n unlinkSync(tempFile);\n }\n } catch {\n // Ignore cleanup errors\n }\n\n if (error instanceof Error) {\n throw error;\n }\n throw new Error(`Failed to load contract from ${entryPath}: ${String(error)}`);\n }\n}\n"],"mappings":";;;;;;;AAYA,MAAM,oBAAoB,CAAC,kBAAkB,cAAc;AAE3D,SAAS,gBAAgB,YAAoB,WAA2C;CACtF,KAAK,MAAM,WAAW,WACpB,IAAI,QAAQ,SAAS,KAAK,EAAE;EAC1B,MAAM,SAAS,QAAQ,MAAM,GAAG,GAAG;EACnC,IAAI,eAAe,UAAU,WAAW,WAAW,GAAG,OAAO,GAAG,EAC9D,OAAO;QAEJ,IAAI,QAAQ,SAAS,IAAI,EAAE;EAChC,MAAM,SAAS,QAAQ,MAAM,GAAG,GAAG;EACnC,IAAI,WAAW,WAAW,OAAO,EAC/B,OAAO;QAEJ,IAAI,eAAe,SACxB,OAAO;CAGX,OAAO;;AAGT,SAAS,eAAe,OAAsB;CAC5C,IAAI,OAAO,UAAU,YAAY,UAAU,MACzC;CAGF,MAAM,uBAAO,IAAI,SAAS;CAE1B,SAAS,MAAM,OAAsB;EACnC,IAAI,UAAU,QAAQ,OAAO,UAAU,UACrC;EAGF,IAAI,KAAK,IAAI,MAAM,EACjB,MAAM,IAAI,MAAM,+CAA+C;EAEjE,KAAK,IAAI,MAAM;EAEf,IAAI;GACF,KAAK,MAAM,OAAO,OAAO;IACvB,MAAM,aAAa,OAAO,yBAAyB,OAAO,IAAI;IAC9D,IAAI,eAAe,WAAW,OAAO,WAAW,MAC9C,MAAM,IAAI,MAAM,kDAAkD,IAAI,GAAG;IAE3E,IAAI,cAAc,OAAO,WAAW,UAAU,YAC5C,MAAM,IAAI,MAAM,6CAA6C,IAAI,GAAG;IAEtE,MAAO,MAAkC,KAAK;;YAExC;GACR,KAAK,OAAO,MAAM;;;CAItB,IAAI;EACF,MAAM,MAAM;EACZ,KAAK,UAAU,MAAM;UACd,OAAO;EACd,IAAI,iBAAiB,OAAO;GAC1B,IAAI,MAA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AAO,OAAO,KAAK,MAAwB,EAAE,KAAK,CAAC,KAAK,KAAK;GACnF,MAAM,IAAI,MAAM,mCAAmC,gBAAgB;;EAGrE,IAAI,CAAC,OAAO,eAAe,OAAO,YAAY,WAAW,GACvD,MAAM,IAAI,MAAM,0CAA0C;EAG5D,IAAI,oBAAoB,OAAO,GAC7B,MAAM,IAAI,MACR,iGAAiG,UAAU,KAAK,KAAK,CAAC,0BAA0B,CAAC,GAAG,oBAAoB,CAAC,KAAK,KAAK,GACpL;EAGH,MAAM,gBAAgB,OAAO,YAAY,IAAI;EAC7C,IAAI,kBAAkB,KAAA,GACpB,MAAM,IAAI,MAAM,8BAA8B;EAEhD,cAAc,UAAU,eAAe,QAAQ;EAE/C,MAAM,SAAU,MAAM;;GAA0B,cAAc,SAAS,CAAC;;EAIxE,WAAW,SAAS;EAEpB,IAAI;EAEJ,IAAI,OAAO,YAAY,KAAA,GACrB,WAAW,OAAO;OACb,IAAI,OAAO,aAAa,KAAA,GAC7B,WAAW,OAAO;OAElB,MAAM,IAAI,MACR,qGAAqG,OAAO,KAAK,OAAkC,CAAC,KAAK,KAAK,IAAI,SACnK;EAGH,IAAI,OAAO,aAAa,YAAY,aAAa,MAC/C,MAAM,IAAI,MAAM,0CAA0C,OAAO,WAAW;EAG9E,eAAe,SAAS;EAExB,OAAO;UACA,OAAO;EACd,IAAI;GACF,IAAI,UACF,WAAW,SAAS;UAEhB;EAIR,IAAI,iBAAiB,OACnB,MAAM;EAER,MAAM,IAAI,MAAM,gCAAgC,UAAU,IAAI,OAAO,MAAM,GAAG"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import "
|
|
2
|
-
import * as arktype_internal_variants_object_ts0 from "arktype/internal/variants/object.ts";
|
|
1
|
+
import * as _$arktype_internal_variants_object_ts0 from "arktype/internal/variants/object.ts";
|
|
3
2
|
|
|
4
3
|
//#region src/commands/init/output.d.ts
|
|
5
|
-
|
|
6
4
|
/**
|
|
7
5
|
* arktype schema for the structured success document `init --json` writes
|
|
8
6
|
* to stdout (FR1.5). The same shape backs the human-readable outro
|
|
@@ -17,7 +15,7 @@ import * as arktype_internal_variants_object_ts0 from "arktype/internal/variants
|
|
|
17
15
|
* Error envelopes (`CliErrorEnvelope`) carry `ok: false` so consumers can
|
|
18
16
|
* branch with `if (doc.ok)` without inspecting the rest of the structure.
|
|
19
17
|
*/
|
|
20
|
-
declare const InitOutputSchema: arktype_internal_variants_object_ts0.ObjectType<{
|
|
18
|
+
declare const InitOutputSchema: _$arktype_internal_variants_object_ts0.ObjectType<{
|
|
21
19
|
ok: true;
|
|
22
20
|
target: "postgres" | "mongodb";
|
|
23
21
|
authoring: "psl" | "typescript";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init-output.d.mts","names":[],"sources":["../../src/commands/init/output.ts"],"
|
|
1
|
+
{"version":3,"file":"init-output.d.mts","names":[],"sources":["../../src/commands/init/output.ts"],"mappings":";;;;;AAkBA;;;;;;;;;;;;cAAa,gBAAA,EAsBX,sCAAA,CAtB2B,UAAA;;;;;;;;;;;;;;;;KAwBjB,UAAA,UAAoB,gBAAA,CAAiB,KAAA"}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { t as InitOutputSchema } from "../output-
|
|
2
|
-
|
|
3
|
-
export { InitOutputSchema };
|
|
1
|
+
import { t as InitOutputSchema } from "../output-B16Kefzx.mjs";
|
|
2
|
+
export { InitOutputSchema };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
//#region src/utils/extension-pack-inputs.ts
|
|
2
|
+
/**
|
|
3
|
+
* Project the CLI's `Config.extensionPacks` array into the canonical
|
|
4
|
+
* {@link ExtensionPackInput} shape. The single `as ExtensionPackLike`
|
|
5
|
+
* structural cast in the CLI lives inside this function.
|
|
6
|
+
*/
|
|
7
|
+
function toExtensionInputs(extensionPacks) {
|
|
8
|
+
return extensionPacks.map((raw) => {
|
|
9
|
+
const pack = raw;
|
|
10
|
+
if (pack.contractSpace === void 0) return {
|
|
11
|
+
id: pack.id,
|
|
12
|
+
targetId: pack.targetId
|
|
13
|
+
};
|
|
14
|
+
return {
|
|
15
|
+
id: pack.id,
|
|
16
|
+
targetId: pack.targetId,
|
|
17
|
+
contractSpace: {
|
|
18
|
+
contractJson: pack.contractSpace.contractJson,
|
|
19
|
+
headRef: pack.contractSpace.headRef,
|
|
20
|
+
migrations: pack.contractSpace.migrations ?? []
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Aggregate-loader projection: surfaces `targetId` + `contractSpace.contractJson`
|
|
27
|
+
* to {@link import('./contract-space-aggregate-loader').buildContractSpaceAggregate}
|
|
28
|
+
* and a `hashByContractJson` map keyed by the same `contractJson` reference
|
|
29
|
+
* the loader hands to its hash callback.
|
|
30
|
+
*/
|
|
31
|
+
function toDeclaredExtensions(inputs) {
|
|
32
|
+
const entries = [];
|
|
33
|
+
const hashByContractJson = /* @__PURE__ */ new Map();
|
|
34
|
+
for (const pack of inputs) if (pack.contractSpace) {
|
|
35
|
+
entries.push({
|
|
36
|
+
id: pack.id,
|
|
37
|
+
targetId: pack.targetId,
|
|
38
|
+
contractSpace: { contractJson: pack.contractSpace.contractJson }
|
|
39
|
+
});
|
|
40
|
+
hashByContractJson.set(pack.contractSpace.contractJson, pack.contractSpace.headRef.hash);
|
|
41
|
+
} else entries.push({
|
|
42
|
+
id: pack.id,
|
|
43
|
+
targetId: pack.targetId
|
|
44
|
+
});
|
|
45
|
+
return {
|
|
46
|
+
entries,
|
|
47
|
+
hashByContractJson
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/** Migrate-time per-space pass projection. */
|
|
51
|
+
function toMigratePassInputs(inputs) {
|
|
52
|
+
return inputs.map((pack) => pack.contractSpace ? {
|
|
53
|
+
id: pack.id,
|
|
54
|
+
contractSpace: {
|
|
55
|
+
contractJson: pack.contractSpace.contractJson,
|
|
56
|
+
headRef: pack.contractSpace.headRef
|
|
57
|
+
}
|
|
58
|
+
} : { id: pack.id });
|
|
59
|
+
}
|
|
60
|
+
/** Extension-migrations materialisation pass projection. */
|
|
61
|
+
function toExtensionMigrationsInputs(inputs) {
|
|
62
|
+
return inputs.map((pack) => pack.contractSpace ? {
|
|
63
|
+
id: pack.id,
|
|
64
|
+
contractSpace: {
|
|
65
|
+
contractJson: pack.contractSpace.contractJson,
|
|
66
|
+
headRef: pack.contractSpace.headRef,
|
|
67
|
+
migrations: pack.contractSpace.migrations
|
|
68
|
+
}
|
|
69
|
+
} : { id: pack.id });
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
export { toMigratePassInputs as i, toExtensionInputs as n, toExtensionMigrationsInputs as r, toDeclaredExtensions as t };
|
|
73
|
+
|
|
74
|
+
//# sourceMappingURL=extension-pack-inputs-C7xgE-vv.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extension-pack-inputs-C7xgE-vv.mjs","names":[],"sources":["../src/utils/extension-pack-inputs.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';\nimport type { ExtensionMigrationsExtensionInput } from './contract-space-extension-migrations-pass';\nimport type { MigrateExtensionInput } from './contract-space-migrate-pass';\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 `targetId` + `contractSpace.contractJson`\n * to {@link import('./contract-space-aggregate-loader').buildContractSpaceAggregate}\n * and a `hashByContractJson` map keyed by the same `contractJson` reference\n * the loader hands to its hash callback.\n */\nexport function toDeclaredExtensions(inputs: ReadonlyArray<ExtensionPackInput>): {\n readonly entries: ReadonlyArray<DeclaredExtensionEntry>;\n readonly hashByContractJson: Map<unknown, string>;\n} {\n const entries: DeclaredExtensionEntry[] = [];\n const hashByContractJson = new Map<unknown, string>();\n for (const pack of inputs) {\n if (pack.contractSpace) {\n entries.push({\n id: pack.id,\n targetId: pack.targetId,\n contractSpace: { contractJson: pack.contractSpace.contractJson },\n });\n hashByContractJson.set(pack.contractSpace.contractJson, pack.contractSpace.headRef.hash);\n } else {\n entries.push({ id: pack.id, targetId: pack.targetId });\n }\n }\n return { entries, hashByContractJson };\n}\n\n/** Migrate-time per-space pass projection. */\nexport function toMigratePassInputs(\n inputs: ReadonlyArray<ExtensionPackInput>,\n): readonly MigrateExtensionInput[] {\n return inputs.map((pack) =>\n pack.contractSpace\n ? {\n id: pack.id,\n contractSpace: {\n contractJson: pack.contractSpace.contractJson,\n headRef: pack.contractSpace.headRef,\n },\n }\n : { id: pack.id },\n );\n}\n\n/** Extension-migrations materialisation pass projection. */\nexport function toExtensionMigrationsInputs(\n inputs: ReadonlyArray<ExtensionPackInput>,\n): readonly ExtensionMigrationsExtensionInput[] {\n return inputs.map((pack) =>\n pack.contractSpace\n ? {\n id: pack.id,\n contractSpace: {\n contractJson: pack.contractSpace.contractJson,\n headRef: pack.contractSpace.headRef,\n migrations: pack.contractSpace.migrations,\n },\n }\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orConfigValidation } from "./cli-errors-
|
|
1
|
+
import { r as errorConfigValidation } from "./cli-errors-D3_sMh2K.mjs";
|
|
2
2
|
import "@prisma-next/framework-components/components";
|
|
3
|
-
|
|
4
3
|
//#region src/utils/framework-components.ts
|
|
5
4
|
/**
|
|
6
5
|
* Asserts that all framework components are compatible with the expected family and target.
|
|
@@ -53,7 +52,7 @@ function assertFrameworkComponentsCompatible(expectedFamilyId, expectedTargetId,
|
|
|
53
52
|
}
|
|
54
53
|
return frameworkComponents;
|
|
55
54
|
}
|
|
56
|
-
|
|
57
55
|
//#endregion
|
|
58
56
|
export { assertFrameworkComponentsCompatible as t };
|
|
59
|
-
|
|
57
|
+
|
|
58
|
+
//# sourceMappingURL=framework-components-ChqVUxR-.mjs.map
|
package/dist/{framework-components-Cr--XBKy.mjs.map → framework-components-ChqVUxR-.mjs.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"framework-components-
|
|
1
|
+
{"version":3,"file":"framework-components-ChqVUxR-.mjs","names":[],"sources":["../src/utils/framework-components.ts"],"sourcesContent":["import type { Contract } from '@prisma-next/contract/types';\nimport {\n checkContractComponentRequirements,\n type TargetBoundComponentDescriptor,\n} from '@prisma-next/framework-components/components';\nimport type { ControlStack } from '@prisma-next/framework-components/control';\nimport { errorConfigValidation, errorContractMissingExtensionPacks } 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.extensionPacks ?? [])];\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<TargetBoundComponentDescriptor<TFamilyId, TTargetId>>;\n}\n\n/**\n * Validates that a contract is compatible with the configured target, adapter,\n * and extension packs. Throws on family/target mismatches or missing extension packs.\n *\n * This check ensures the emitted contract matches the CLI config before running\n * commands that depend on the contract (e.g., db verify, db sign).\n *\n * @param contract - The contract to validate (must include targetFamily, target, extensionPacks).\n * @param stack - The control plane stack (target, adapter, driver, extensionPacks).\n *\n * @throws {CliStructuredError} errorConfigValidation when contract.targetFamily or contract.target\n * doesn't match the configured family/target.\n * @throws {CliStructuredError} errorContractMissingExtensionPacks when the contract requires\n * extension packs that are not provided in the config (includes all missing packs in error.meta).\n *\n * @example\n * ```ts\n * import { assertContractRequirementsSatisfied } from './framework-components';\n *\n * const config = await loadConfig();\n * const contract = await loadContractJson(config.contract.output);\n * const stack = createControlStack({ family: config.family, target: config.target, adapter: config.adapter, ... });\n *\n * // Throws if contract is incompatible with config\n * assertContractRequirementsSatisfied({ contract, stack });\n * ```\n */\nexport function assertContractRequirementsSatisfied<\n TFamilyId extends string,\n TTargetId extends string,\n>({\n contract,\n stack,\n}: {\n readonly contract: Pick<Contract, 'targetFamily' | 'target' | 'extensionPacks'>;\n readonly stack: ControlStack<TFamilyId, TTargetId>;\n}): void {\n const providedComponentIds = new Set<string>([\n stack.target.id,\n ...(stack.adapter ? [stack.adapter.id] : []),\n ]);\n for (const extension of stack.extensionPacks) {\n providedComponentIds.add(extension.id);\n }\n\n const result = checkContractComponentRequirements({\n contract,\n expectedTargetFamily: stack.target.familyId,\n expectedTargetId: stack.target.targetId,\n providedComponentIds,\n });\n\n if (result.familyMismatch) {\n throw errorConfigValidation('contract.targetFamily', {\n why: `Contract was emitted for family '${result.familyMismatch.actual}' but CLI config is wired to '${result.familyMismatch.expected}'.`,\n });\n }\n\n if (result.targetMismatch) {\n throw errorConfigValidation('contract.target', {\n why: `Contract target '${result.targetMismatch.actual}' does not match CLI target '${result.targetMismatch.expected}'.`,\n });\n }\n\n if (result.missingExtensionPackIds.length > 0) {\n throw errorContractMissingExtensionPacks({\n missingExtensionPacks: result.missingExtensionPackIds,\n providedComponentIds: [...providedComponentIds],\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,SAAgB,oCAId,kBACA,kBACA,qBACqE;CACrE,KAAK,IAAI,IAAI,GAAG,IAAI,oBAAoB,QAAQ,KAAK;EACnD,MAAM,YAAY,oBAAoB;EAGtC,IAAI,OAAO,cAAc,YAAY,cAAc,MACjD,MAAM,sBAAsB,yBAAyB,EACnD,KAAK,gCAAgC,EAAE,qBACxC,CAAC;EAGJ,MAAM,SAAS;EAGf,IAAI,CAAC,OAAO,OAAO,QAAQ,OAAO,EAChC,MAAM,sBAAsB,8BAA8B,EACxD,KAAK,gCAAgC,EAAE,6BACxC,CAAC;EAGJ,MAAM,OAAO,OAAO;EACpB,IAAI,SAAS,YAAY,SAAS,aAAa,SAAS,eAAe,SAAS,UAC9E,MAAM,sBAAsB,8BAA8B,EACxD,KAAK,gCAAgC,EAAE,qBAAqB,OAAO,KAAK,CAAC,4DAC1E,CAAC;EAIJ,IAAI,CAAC,OAAO,OAAO,QAAQ,WAAW,EACpC,MAAM,sBAAsB,kCAAkC,EAC5D,KAAK,gCAAgC,EAAE,UAAU,OAAO,KAAK,CAAC,kCAC/D,CAAC;EAGJ,MAAM,WAAW,OAAO;EACxB,IAAI,aAAa,kBACf,MAAM,sBAAsB,kCAAkC,EAC5D,KAAK,gCAAgC,EAAE,UAAU,OAAO,KAAK,CAAC,kBAAkB,OAAO,SAAS,CAAC,kBAAkB,iBAAiB,IACrI,CAAC;EAIJ,IAAI,CAAC,OAAO,OAAO,QAAQ,WAAW,EACpC,MAAM,sBAAsB,kCAAkC,EAC5D,KAAK,gCAAgC,EAAE,UAAU,OAAO,KAAK,CAAC,kCAC/D,CAAC;EAGJ,MAAM,WAAW,OAAO;EACxB,IAAI,aAAa,kBACf,MAAM,sBAAsB,kCAAkC,EAC5D,KAAK,gCAAgC,EAAE,UAAU,OAAO,KAAK,CAAC,kBAAkB,OAAO,SAAS,CAAC,kBAAkB,iBAAiB,IACrI,CAAC;;CAKN,OAAO"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/utils/global-flags.d.ts
|
|
2
|
+
interface GlobalFlags {
|
|
3
|
+
readonly json?: boolean;
|
|
4
|
+
readonly quiet?: boolean;
|
|
5
|
+
readonly verbose?: number;
|
|
6
|
+
readonly color?: boolean;
|
|
7
|
+
readonly interactive?: boolean;
|
|
8
|
+
readonly yes?: boolean;
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { GlobalFlags as t };
|
|
12
|
+
//# sourceMappingURL=global-flags-Icqpxk23.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global-flags-Icqpxk23.d.mts","names":[],"sources":["../src/utils/global-flags.ts"],"mappings":";UAAiB,WAAA;EAAA,SACN,IAAA;EAAA,SACA,KAAA;EAAA,SACA,OAAA;EAAA,SACA,KAAA;EAAA,SACA,WAAA;EAAA,SACA,GAAA;AAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { dim } from "colorette";
|
|
2
|
+
//#region src/utils/formatters/helpers.ts
|
|
3
|
+
/**
|
|
4
|
+
* Checks if verbose output is enabled at the specified level.
|
|
5
|
+
*/
|
|
6
|
+
function isVerbose(flags, level) {
|
|
7
|
+
return (flags.verbose ?? 0) >= level;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Creates a color-aware formatter function.
|
|
11
|
+
* Returns a function that applies the color only if colors are enabled.
|
|
12
|
+
*/
|
|
13
|
+
function createColorFormatter(useColor, colorFn) {
|
|
14
|
+
return useColor ? colorFn : (text) => text;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Formats text with dim styling if colors are enabled.
|
|
18
|
+
*/
|
|
19
|
+
function formatDim(useColor, text) {
|
|
20
|
+
return useColor ? dim(text) : text;
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { formatDim as n, isVerbose as r, createColorFormatter as t };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=helpers-eqdN8tH6.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers-eqdN8tH6.mjs","names":[],"sources":["../src/utils/formatters/helpers.ts"],"sourcesContent":["import { dim } from 'colorette';\n\nimport type { GlobalFlags } from '../global-flags';\n\n/**\n * Checks if verbose output is enabled at the specified level.\n */\nexport function isVerbose(flags: GlobalFlags, level: 1 | 2): boolean {\n return (flags.verbose ?? 0) >= level;\n}\n\n/**\n * Creates a color-aware formatter function.\n * Returns a function that applies the color only if colors are enabled.\n */\nexport function createColorFormatter<T extends (text: string) => string>(\n useColor: boolean,\n colorFn: T,\n): (text: string) => string {\n return useColor ? colorFn : (text: string) => text;\n}\n\n/**\n * Formats text with dim styling if colors are enabled.\n */\nexport function formatDim(useColor: boolean, text: string): string {\n return useColor ? dim(text) : text;\n}\n"],"mappings":";;;;;AAOA,SAAgB,UAAU,OAAoB,OAAuB;CACnE,QAAQ,MAAM,WAAW,MAAM;;;;;;AAOjC,SAAgB,qBACd,UACA,SAC0B;CAC1B,OAAO,WAAW,WAAW,SAAiB;;;;;AAMhD,SAAgB,UAAU,UAAmB,MAAsB;CACjE,OAAO,WAAW,IAAI,KAAK,GAAG"}
|