@prisma-next/cli 0.5.0-dev.11 → 0.5.0-dev.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/README.md +37 -3
  2. package/dist/cli.mjs +7 -14
  3. package/dist/cli.mjs.map +1 -1
  4. package/dist/{client-faKQqcix.mjs → client-enZIahga.mjs} +5 -5
  5. package/dist/{client-faKQqcix.mjs.map → client-enZIahga.mjs.map} +1 -1
  6. package/dist/commands/contract-emit.d.mts.map +1 -1
  7. package/dist/commands/contract-emit.mjs +2 -7
  8. package/dist/commands/contract-infer.mjs +2 -8
  9. package/dist/commands/db-init.mjs +7 -8
  10. package/dist/commands/db-init.mjs.map +1 -1
  11. package/dist/commands/db-schema.mjs +5 -8
  12. package/dist/commands/db-schema.mjs.map +1 -1
  13. package/dist/commands/db-sign.mjs +6 -7
  14. package/dist/commands/db-sign.mjs.map +1 -1
  15. package/dist/commands/db-update.mjs +7 -8
  16. package/dist/commands/db-update.mjs.map +1 -1
  17. package/dist/commands/db-verify.mjs +8 -9
  18. package/dist/commands/db-verify.mjs.map +1 -1
  19. package/dist/commands/migration-apply.mjs +6 -7
  20. package/dist/commands/migration-apply.mjs.map +1 -1
  21. package/dist/commands/migration-new.mjs +6 -6
  22. package/dist/commands/migration-plan.mjs +7 -7
  23. package/dist/commands/migration-ref.d.mts +1 -1
  24. package/dist/commands/migration-ref.mjs +3 -3
  25. package/dist/commands/migration-show.d.mts +1 -1
  26. package/dist/commands/migration-show.mjs +5 -5
  27. package/dist/commands/migration-status.mjs +2 -7
  28. package/dist/{config-loader-C25b63rJ.mjs → config-loader-ih8ViDb_.mjs} +2 -2
  29. package/dist/{config-loader-C25b63rJ.mjs.map → config-loader-ih8ViDb_.mjs.map} +1 -1
  30. package/dist/config-loader.mjs +1 -1
  31. package/dist/contract-emit-DWtGQYCD.mjs +150 -0
  32. package/dist/contract-emit-DWtGQYCD.mjs.map +1 -0
  33. package/dist/contract-emit-LjzCoicC.mjs +4 -0
  34. package/dist/contract-emit-RZBWzkop.mjs +329 -0
  35. package/dist/contract-emit-RZBWzkop.mjs.map +1 -0
  36. package/dist/{contract-enrichment-CAOELa-H.mjs → contract-enrichment-4Ptgw3Pe.mjs} +1 -1
  37. package/dist/{contract-enrichment-CAOELa-H.mjs.map → contract-enrichment-4Ptgw3Pe.mjs.map} +1 -1
  38. package/dist/{contract-infer-BgnsSkGp.mjs → contract-infer-BjzkcwQt.mjs} +5 -5
  39. package/dist/{contract-infer-BgnsSkGp.mjs.map → contract-infer-BjzkcwQt.mjs.map} +1 -1
  40. package/dist/exports/control-api.d.mts +41 -16
  41. package/dist/exports/control-api.d.mts.map +1 -1
  42. package/dist/exports/control-api.mjs +5 -7
  43. package/dist/exports/index.mjs +3 -8
  44. package/dist/exports/index.mjs.map +1 -1
  45. package/dist/exports/init-output.mjs +1 -1
  46. package/dist/{extract-operation-statements-DsFfxXVZ.mjs → extract-operation-statements-CU-Pp4-N.mjs} +2 -2
  47. package/dist/{extract-operation-statements-DsFfxXVZ.mjs.map → extract-operation-statements-CU-Pp4-N.mjs.map} +1 -1
  48. package/dist/{extract-sql-ddl-D9UbZDyz.mjs → extract-sql-ddl-Bm0Mm0IT.mjs} +1 -1
  49. package/dist/{extract-sql-ddl-D9UbZDyz.mjs.map → extract-sql-ddl-Bm0Mm0IT.mjs.map} +1 -1
  50. package/dist/{framework-components-C6el-5x_.mjs → framework-components-Bgcre3Z6.mjs} +1 -1
  51. package/dist/{framework-components-C6el-5x_.mjs.map → framework-components-Bgcre3Z6.mjs.map} +1 -1
  52. package/dist/{init-jf33mNQ6.mjs → init-BKgjxw6r.mjs} +5 -5
  53. package/dist/{init-jf33mNQ6.mjs.map → init-BKgjxw6r.mjs.map} +1 -1
  54. package/dist/{inspect-live-schema-yCu0JT0I.mjs → inspect-live-schema-QklSDLt_.mjs} +5 -5
  55. package/dist/{inspect-live-schema-yCu0JT0I.mjs.map → inspect-live-schema-QklSDLt_.mjs.map} +1 -1
  56. package/dist/migration-cli.mjs +2 -2
  57. package/dist/{migration-command-scaffold-B8HAEGhQ.mjs → migration-command-scaffold-BfloSWPZ.mjs} +6 -6
  58. package/dist/{migration-command-scaffold-B8HAEGhQ.mjs.map → migration-command-scaffold-BfloSWPZ.mjs.map} +1 -1
  59. package/dist/{migration-status-8QUxCJHE.mjs → migration-status-C5VYA5r9.mjs} +7 -7
  60. package/dist/{migration-status-8QUxCJHE.mjs.map → migration-status-C5VYA5r9.mjs.map} +1 -1
  61. package/dist/{migrations-CKRMAKka.mjs → migrations-CSaDHNpB.mjs} +2 -2
  62. package/dist/{migrations-CKRMAKka.mjs.map → migrations-CSaDHNpB.mjs.map} +1 -1
  63. package/dist/{output-BpcQrnnq.mjs → output-BiO7kt87.mjs} +1 -1
  64. package/dist/{output-BpcQrnnq.mjs.map → output-BiO7kt87.mjs.map} +1 -1
  65. package/dist/{progress-adapter-DvQWB1nK.mjs → progress-adapter-DgRGldpT.mjs} +1 -1
  66. package/dist/{progress-adapter-DvQWB1nK.mjs.map → progress-adapter-DgRGldpT.mjs.map} +1 -1
  67. package/dist/{result-handler-CuhZ3kNu.mjs → result-handler-BmVh8AeV.mjs} +4 -4
  68. package/dist/{result-handler-CuhZ3kNu.mjs.map → result-handler-BmVh8AeV.mjs.map} +1 -1
  69. package/dist/{terminal-ui-C3ZLwQxK.mjs → terminal-ui-u2YgKghu.mjs} +1 -1
  70. package/dist/{terminal-ui-C3ZLwQxK.mjs.map → terminal-ui-u2YgKghu.mjs.map} +1 -1
  71. package/dist/{verify-Bkycc-Tf.mjs → verify-BumcH6Ry.mjs} +2 -2
  72. package/dist/{verify-Bkycc-Tf.mjs.map → verify-BumcH6Ry.mjs.map} +1 -1
  73. package/package.json +16 -16
  74. package/src/commands/contract-emit.ts +67 -163
  75. package/src/control-api/operations/contract-emit.ts +198 -115
  76. package/src/control-api/types.ts +22 -3
  77. package/src/exports/control-api.ts +2 -1
  78. package/src/utils/emit-queue.ts +26 -0
  79. package/src/utils/publish-contract-artifact-pair.ts +134 -0
  80. package/dist/contract-emit-B9wkchud.mjs +0 -6
  81. package/dist/contract-emit-Cf3fjDL6.mjs +0 -195
  82. package/dist/contract-emit-Cf3fjDL6.mjs.map +0 -1
  83. package/dist/contract-emit-PeB96eHy.mjs +0 -122
  84. package/dist/contract-emit-PeB96eHy.mjs.map +0 -1
  85. package/dist/validate-contract-deps-B_Cs29TL.mjs +0 -37
  86. package/dist/validate-contract-deps-B_Cs29TL.mjs.map +0 -1
  87. /package/dist/{cli-errors-D2NPMaxW.d.mts → cli-errors-BJLUczXT.d.mts} +0 -0
@@ -0,0 +1,329 @@
1
+ import { t as loadConfig } from "./config-loader-ih8ViDb_.mjs";
2
+ import { i as errorContractConfigMissing, m as errorRuntime } from "./cli-errors-By1iVE3z.mjs";
3
+ import { t as assertFrameworkComponentsCompatible } from "./framework-components-Bgcre3Z6.mjs";
4
+ import { t as enrichContract } from "./contract-enrichment-4Ptgw3Pe.mjs";
5
+ import { createRequire } from "node:module";
6
+ import { emit, getEmittedArtifactPaths } from "@prisma-next/emitter";
7
+ import { ifDefined } from "@prisma-next/utils/defined";
8
+ import { basename, dirname, join } from "pathe";
9
+ import { mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
10
+ import { createControlStack } from "@prisma-next/framework-components/control";
11
+ import { abortable } from "@prisma-next/utils/abortable";
12
+
13
+ //#region src/utils/emit-queue.ts
14
+ /**
15
+ * Per-output FIFO queue for `executeContractEmit`.
16
+ *
17
+ * Ensures that at most one emit (load → resolve source → emit bytes → publish)
18
+ * runs per output JSON path at a time. Concurrent calls for the same path
19
+ * line up behind the in-flight one and run in submission order; the user-visible
20
+ * outcome is "last submission wins on disk" without any supersession bookkeeping.
21
+ *
22
+ * Long-lived hosts (Vite dev server, watch CLIs) must call `disposeEmitQueue`
23
+ * when they stop publishing to a path, otherwise the module-global `Map`
24
+ * accumulates one entry per unique output path for the lifetime of the process.
25
+ */
26
+ const emitQueues = /* @__PURE__ */ new Map();
27
+ function queueEmitByOutput(outputJsonPath, action) {
28
+ const next = (emitQueues.get(outputJsonPath) ?? Promise.resolve()).then(action, action);
29
+ emitQueues.set(outputJsonPath, next);
30
+ return next;
31
+ }
32
+ function disposeEmitQueue(outputJsonPath) {
33
+ emitQueues.delete(outputJsonPath);
34
+ }
35
+
36
+ //#endregion
37
+ //#region src/utils/publish-contract-artifact-pair.ts
38
+ function isRecord$1(value) {
39
+ return typeof value === "object" && value !== null;
40
+ }
41
+ function createTempArtifactPath(path, publicationToken, phase) {
42
+ return join(dirname(path), `.${basename(path)}.${process.pid}.${publicationToken}.${phase}.tmp`);
43
+ }
44
+ async function readExistingArtifact(path) {
45
+ try {
46
+ return { content: await readFile(path, "utf-8") };
47
+ } catch (error) {
48
+ if (isRecord$1(error) && error["code"] === "ENOENT") return "remove";
49
+ throw error;
50
+ }
51
+ }
52
+ async function restoreArtifact(path, previous, publicationToken) {
53
+ if (previous === "remove") {
54
+ await rm(path, { force: true });
55
+ return;
56
+ }
57
+ const restorePath = createTempArtifactPath(path, publicationToken, "rollback");
58
+ await writeFile(restorePath, previous.content, "utf-8");
59
+ try {
60
+ await rename(restorePath, path);
61
+ } finally {
62
+ await rm(restorePath, { force: true });
63
+ }
64
+ }
65
+ function withRollbackFailureCause(error, rollbackFailures) {
66
+ const rollbackCause = new AggregateError(rollbackFailures, "Failed to restore published artifacts");
67
+ if (error instanceof Error) {
68
+ Object.defineProperty(error, "cause", {
69
+ value: rollbackCause,
70
+ configurable: true,
71
+ writable: true
72
+ });
73
+ return error;
74
+ }
75
+ return new Error(String(error), { cause: rollbackCause });
76
+ }
77
+ async function publishPairWithRollback(entries, publicationToken) {
78
+ const replaced = [];
79
+ try {
80
+ for (const entry of entries) {
81
+ await rename(entry.tempPath, entry.outputPath);
82
+ replaced.push(entry);
83
+ }
84
+ } catch (error) {
85
+ const rollbackFailures = (await Promise.allSettled(replaced.map((entry) => restoreArtifact(entry.outputPath, entry.previous, publicationToken)))).flatMap((result) => result.status === "rejected" ? [result.reason] : []);
86
+ if (rollbackFailures.length > 0) throw withRollbackFailureCause(error, rollbackFailures);
87
+ throw error;
88
+ }
89
+ }
90
+ async function publishContractArtifactPair({ outputJsonPath, outputDtsPath, contractJson, contractDts, publicationToken, beforePublish }) {
91
+ const tempJsonPath = createTempArtifactPath(outputJsonPath, publicationToken, "next");
92
+ const tempDtsPath = createTempArtifactPath(outputDtsPath, publicationToken, "next");
93
+ try {
94
+ await writeFile(tempJsonPath, contractJson, "utf-8");
95
+ await writeFile(tempDtsPath, contractDts, "utf-8");
96
+ if (await beforePublish?.() === false) return false;
97
+ const previousJson = await readExistingArtifact(outputJsonPath);
98
+ await publishPairWithRollback([{
99
+ tempPath: tempDtsPath,
100
+ outputPath: outputDtsPath,
101
+ previous: await readExistingArtifact(outputDtsPath)
102
+ }, {
103
+ tempPath: tempJsonPath,
104
+ outputPath: outputJsonPath,
105
+ previous: previousJson
106
+ }], publicationToken);
107
+ return true;
108
+ } finally {
109
+ await Promise.allSettled([rm(tempJsonPath, { force: true }), rm(tempDtsPath, { force: true })]);
110
+ }
111
+ }
112
+
113
+ //#endregion
114
+ //#region src/utils/validate-contract-deps.ts
115
+ const IMPORT_PATTERN = /import\s+type\s+.*?\s+from\s+['"](@[^/]+\/[^/'"]+)/g;
116
+ function extractPackageSpecifiers(dtsContent) {
117
+ const packages = /* @__PURE__ */ new Set();
118
+ for (const match of dtsContent.matchAll(IMPORT_PATTERN)) {
119
+ const pkg = match[1];
120
+ if (pkg) packages.add(pkg);
121
+ }
122
+ return [...packages];
123
+ }
124
+ function validateContractDeps(dtsContent, projectRoot) {
125
+ const packages = extractPackageSpecifiers(dtsContent);
126
+ const resolve$1 = createRequire(`${projectRoot}/package.json`);
127
+ const missing = [];
128
+ for (const pkg of packages) try {
129
+ resolve$1.resolve(`${pkg}/package.json`);
130
+ } catch {
131
+ missing.push(pkg);
132
+ }
133
+ if (missing.length === 0) return { missing };
134
+ return {
135
+ missing,
136
+ warning: [
137
+ "contract.d.ts imports types from packages that are not installed:",
138
+ missing.map((p) => ` - ${p}`).join("\n"),
139
+ "",
140
+ "Install them with your package manager:",
141
+ ...missing.map((p) => ` ${p}`)
142
+ ].join("\n")
143
+ };
144
+ }
145
+
146
+ //#endregion
147
+ //#region src/control-api/operations/contract-emit.ts
148
+ const EMIT_ACTION = "emit";
149
+ function isRecord(value) {
150
+ return typeof value === "object" && value !== null;
151
+ }
152
+ function startSpan(onProgress, spanId, label) {
153
+ onProgress?.({
154
+ action: EMIT_ACTION,
155
+ kind: "spanStart",
156
+ spanId,
157
+ label
158
+ });
159
+ }
160
+ function endSpan(onProgress, spanId, outcome) {
161
+ onProgress?.({
162
+ action: EMIT_ACTION,
163
+ kind: "spanEnd",
164
+ spanId,
165
+ outcome
166
+ });
167
+ }
168
+ function failedToResolveContractSource(why, fix, meta) {
169
+ return errorRuntime("Failed to resolve contract source", {
170
+ why,
171
+ fix,
172
+ ...ifDefined("meta", meta)
173
+ });
174
+ }
175
+ function diagnosticLocationSuffix(diagnostic) {
176
+ const sourceId = typeof diagnostic["sourceId"] === "string" ? diagnostic["sourceId"] : void 0;
177
+ const span = isRecord(diagnostic["span"]) ? diagnostic["span"] : void 0;
178
+ const start = span && isRecord(span["start"]) ? span["start"] : void 0;
179
+ const line = start && typeof start["line"] === "number" ? start["line"] : void 0;
180
+ const column = start && typeof start["column"] === "number" ? start["column"] : void 0;
181
+ if (sourceId && line !== void 0 && column !== void 0) return ` (${sourceId}:${line}:${column})`;
182
+ if (sourceId) return ` (${sourceId})`;
183
+ return "";
184
+ }
185
+ function mapDiagnosticsToIssues(diagnostics) {
186
+ const issues = [];
187
+ for (const raw of diagnostics) {
188
+ if (!isRecord(raw)) continue;
189
+ const code = typeof raw["code"] === "string" ? raw["code"] : "diagnostic";
190
+ const message = typeof raw["message"] === "string" ? raw["message"] : "";
191
+ issues.push({
192
+ kind: code,
193
+ message: `${message}${diagnosticLocationSuffix(raw)}`
194
+ });
195
+ }
196
+ return issues;
197
+ }
198
+ function validateProviderResult(providerResult) {
199
+ if (!isRecord(providerResult) || typeof providerResult["ok"] !== "boolean") return {
200
+ ok: false,
201
+ error: failedToResolveContractSource("Contract source provider returned malformed result shape.", "Ensure contract.source.load resolves to ok(Contract) or notOk({ summary, diagnostics }).")
202
+ };
203
+ if (providerResult["ok"]) {
204
+ if (!("value" in providerResult)) return {
205
+ ok: false,
206
+ error: failedToResolveContractSource("Contract source provider returned malformed success result: missing value.", "Ensure contract.source.load success payload is ok(Contract).")
207
+ };
208
+ return {
209
+ ok: true,
210
+ value: providerResult["value"]
211
+ };
212
+ }
213
+ const failure = providerResult["failure"];
214
+ if (!isRecord(failure) || typeof failure["summary"] !== "string" || !Array.isArray(failure["diagnostics"])) return {
215
+ ok: false,
216
+ error: failedToResolveContractSource("Contract source provider returned malformed failure result: expected summary and diagnostics.", "Ensure contract.source.load failure payload is notOk({ summary, diagnostics, meta? }).")
217
+ };
218
+ return {
219
+ ok: false,
220
+ error: failedToResolveContractSource(String(failure["summary"]), "Fix contract source diagnostics and return ok(Contract).", {
221
+ diagnostics: failure["diagnostics"],
222
+ issues: mapDiagnosticsToIssues(failure["diagnostics"]),
223
+ ...ifDefined("providerMeta", failure["meta"])
224
+ })
225
+ };
226
+ }
227
+ /**
228
+ * Canonical contract emit operation.
229
+ *
230
+ * This is the SINGLE publication path used by both the CLI command
231
+ * (`prisma-next contract emit`) and the Vite plugin
232
+ * (`@prisma-next/vite-plugin-contract-emit`). New callers must go through this
233
+ * function rather than re-implementing load → emit → publish.
234
+ *
235
+ * The whole flow (load config → resolve source → emit bytes → atomic publish)
236
+ * is serialized per output JSON path via `queueEmitByOutput`. Concurrent calls
237
+ * for the same output line up FIFO; the user-visible outcome is "last
238
+ * submission wins on disk" without any supersession bookkeeping. Within a
239
+ * single emit, `publishContractArtifactPair` stages temp files, renames
240
+ * `contract.d.ts` before `contract.json`, and attempts to restore the previous
241
+ * pair if either rename fails — so type-only consumers never observe a
242
+ * mismatched pair.
243
+ *
244
+ * @throws {CliStructuredError} on config/source/validation problems
245
+ * @throws {DOMException} `AbortError` if cancelled via `signal`
246
+ */
247
+ async function executeContractEmit(options) {
248
+ const { configPath, signal = new AbortController().signal, onProgress } = options;
249
+ const unlessAborted = abortable(signal);
250
+ const config = await unlessAborted(loadConfig(configPath));
251
+ if (!config.contract) throw errorContractConfigMissing({ why: "Config.contract is required for emit. Define it in your config: contract: { source: ..., output: ... }" });
252
+ const contractConfig = config.contract;
253
+ if (!contractConfig.output) throw errorContractConfigMissing({ why: "Contract config must have output path. This should not happen if defineConfig() was used." });
254
+ if (typeof contractConfig.source?.load !== "function") throw errorContractConfigMissing({ why: "Contract config must include a valid source provider object" });
255
+ let outputPaths;
256
+ try {
257
+ outputPaths = getEmittedArtifactPaths(contractConfig.output);
258
+ } catch (error) {
259
+ throw errorContractConfigMissing({ why: error instanceof Error ? error.message : String(error) });
260
+ }
261
+ const { jsonPath: outputJsonPath, dtsPath: outputDtsPath } = outputPaths;
262
+ return queueEmitByOutput(outputJsonPath, async () => {
263
+ const stack = createControlStack(config);
264
+ const sourceContext = {
265
+ composedExtensionPacks: stack.extensionPacks.map((p) => p.id),
266
+ scalarTypeDescriptors: stack.scalarTypeDescriptors,
267
+ authoringContributions: stack.authoringContributions,
268
+ codecLookup: stack.codecLookup,
269
+ controlMutationDefaults: stack.controlMutationDefaults,
270
+ resolvedInputs: contractConfig.source.inputs ?? []
271
+ };
272
+ startSpan(onProgress, "resolveSource", "Resolving contract source...");
273
+ let providerResult;
274
+ try {
275
+ providerResult = await unlessAborted(contractConfig.source.load(sourceContext));
276
+ } catch (error) {
277
+ endSpan(onProgress, "resolveSource", "error");
278
+ if (signal.aborted || isRecord(error) && error["name"] === "AbortError") throw error;
279
+ throw failedToResolveContractSource(error instanceof Error ? error.message : String(error), "Ensure contract.source.load resolves to ok(Contract) or returns structured diagnostics.");
280
+ }
281
+ const validatedContract = validateProviderResult(providerResult);
282
+ if (!validatedContract.ok) {
283
+ endSpan(onProgress, "resolveSource", "error");
284
+ throw validatedContract.error;
285
+ }
286
+ endSpan(onProgress, "resolveSource", "ok");
287
+ startSpan(onProgress, "emit", "Emitting contract...");
288
+ let emitResult;
289
+ try {
290
+ const familyInstance = config.family.create(stack);
291
+ const rawComponents = [
292
+ config.target,
293
+ config.adapter,
294
+ ...config.extensionPacks ?? []
295
+ ];
296
+ const frameworkComponents = assertFrameworkComponentsCompatible(config.family.familyId, config.target.targetId, rawComponents);
297
+ const enrichedIR = enrichContract(validatedContract.value, frameworkComponents);
298
+ familyInstance.validateContract(enrichedIR);
299
+ emitResult = await unlessAborted(emit(enrichedIR, stack, config.family.emission, { outputJsonPath }));
300
+ } catch (error) {
301
+ endSpan(onProgress, "emit", "error");
302
+ throw error;
303
+ }
304
+ endSpan(onProgress, "emit", "ok");
305
+ await unlessAborted(mkdir(dirname(outputJsonPath), { recursive: true }));
306
+ await publishContractArtifactPair({
307
+ outputJsonPath,
308
+ outputDtsPath,
309
+ contractJson: emitResult.contractJson,
310
+ contractDts: emitResult.contractDts,
311
+ publicationToken: String(process.hrtime.bigint())
312
+ });
313
+ const validationWarning = validateContractDeps(emitResult.contractDts, dirname(outputDtsPath)).warning;
314
+ return {
315
+ storageHash: emitResult.storageHash,
316
+ ...ifDefined("executionHash", emitResult.executionHash),
317
+ profileHash: emitResult.profileHash,
318
+ files: {
319
+ json: outputJsonPath,
320
+ dts: outputDtsPath
321
+ },
322
+ ...ifDefined("validationWarning", validationWarning)
323
+ };
324
+ });
325
+ }
326
+
327
+ //#endregion
328
+ export { disposeEmitQueue as n, executeContractEmit as t };
329
+ //# sourceMappingURL=contract-emit-RZBWzkop.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contract-emit-RZBWzkop.mjs","names":["isRecord","replaced: PublishEntry[]","resolve","missing: string[]","EMIT_ACTION: ControlActionName","issues: { readonly kind: string; readonly message: string }[]","outputPaths: ReturnType<typeof getEmittedArtifactPaths>","providerResult: Awaited<ReturnType<typeof contractConfig.source.load>>","emitResult: Awaited<ReturnType<typeof emit>>"],"sources":["../src/utils/emit-queue.ts","../src/utils/publish-contract-artifact-pair.ts","../src/utils/validate-contract-deps.ts","../src/control-api/operations/contract-emit.ts"],"sourcesContent":["/**\n * Per-output FIFO queue for `executeContractEmit`.\n *\n * Ensures that at most one emit (load → resolve source → emit bytes → publish)\n * runs per output JSON path at a time. Concurrent calls for the same path\n * line up behind the in-flight one and run in submission order; the user-visible\n * outcome is \"last submission wins on disk\" without any supersession bookkeeping.\n *\n * Long-lived hosts (Vite dev server, watch CLIs) must call `disposeEmitQueue`\n * when they stop publishing to a path, otherwise the module-global `Map`\n * accumulates one entry per unique output path for the lifetime of the process.\n */\nconst emitQueues = new Map<string, Promise<unknown>>();\n\nexport function queueEmitByOutput<T>(outputJsonPath: string, action: () => Promise<T>): Promise<T> {\n const previous = emitQueues.get(outputJsonPath) ?? Promise.resolve();\n // Continue regardless of the previous task's outcome — a failed emit must not\n // block subsequent ones. The current task's outcome propagates via `next`.\n const next = previous.then(action, action);\n emitQueues.set(outputJsonPath, next);\n return next;\n}\n\nexport function disposeEmitQueue(outputJsonPath: string): void {\n emitQueues.delete(outputJsonPath);\n}\n","import { readFile, rename, rm, writeFile } from 'node:fs/promises';\nimport { basename, dirname, join } from 'pathe';\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null;\n}\n\nfunction createTempArtifactPath(path: string, publicationToken: string, phase: string): string {\n return join(dirname(path), `.${basename(path)}.${process.pid}.${publicationToken}.${phase}.tmp`);\n}\n\ntype PreviousArtifact = { readonly content: string } | 'remove';\n\nasync function readExistingArtifact(path: string): Promise<PreviousArtifact> {\n try {\n return { content: await readFile(path, 'utf-8') };\n } catch (error) {\n if (isRecord(error) && error['code'] === 'ENOENT') {\n return 'remove';\n }\n throw error;\n }\n}\n\nasync function restoreArtifact(\n path: string,\n previous: PreviousArtifact,\n publicationToken: string,\n): Promise<void> {\n if (previous === 'remove') {\n await rm(path, { force: true });\n return;\n }\n\n const restorePath = createTempArtifactPath(path, publicationToken, 'rollback');\n await writeFile(restorePath, previous.content, 'utf-8');\n try {\n await rename(restorePath, path);\n } finally {\n await rm(restorePath, { force: true });\n }\n}\n\ninterface PublishEntry {\n readonly tempPath: string;\n readonly outputPath: string;\n readonly previous: PreviousArtifact;\n}\n\nfunction withRollbackFailureCause(error: unknown, rollbackFailures: readonly unknown[]): Error {\n const rollbackCause = new AggregateError(\n rollbackFailures,\n 'Failed to restore published artifacts',\n );\n\n if (error instanceof Error) {\n Object.defineProperty(error, 'cause', {\n value: rollbackCause,\n configurable: true,\n writable: true,\n });\n return error;\n }\n\n return new Error(String(error), { cause: rollbackCause });\n}\n\nasync function publishPairWithRollback(\n entries: readonly PublishEntry[],\n publicationToken: string,\n): Promise<void> {\n const replaced: PublishEntry[] = [];\n try {\n for (const entry of entries) {\n await rename(entry.tempPath, entry.outputPath);\n replaced.push(entry);\n }\n } catch (error) {\n const rollbackResults = await Promise.allSettled(\n replaced.map((entry) => restoreArtifact(entry.outputPath, entry.previous, publicationToken)),\n );\n const rollbackFailures = rollbackResults.flatMap((result) =>\n result.status === 'rejected' ? [result.reason] : [],\n );\n\n if (rollbackFailures.length > 0) {\n throw withRollbackFailureCause(error, rollbackFailures);\n }\n\n throw error;\n }\n}\n\nexport async function publishContractArtifactPair({\n outputJsonPath,\n outputDtsPath,\n contractJson,\n contractDts,\n publicationToken,\n beforePublish,\n}: {\n readonly outputJsonPath: string;\n readonly outputDtsPath: string;\n readonly contractJson: string;\n readonly contractDts: string;\n readonly publicationToken: string;\n readonly beforePublish?: () => Promise<boolean> | boolean;\n}): Promise<boolean> {\n const tempJsonPath = createTempArtifactPath(outputJsonPath, publicationToken, 'next');\n const tempDtsPath = createTempArtifactPath(outputDtsPath, publicationToken, 'next');\n\n try {\n await writeFile(tempJsonPath, contractJson, 'utf-8');\n await writeFile(tempDtsPath, contractDts, 'utf-8');\n\n if ((await beforePublish?.()) === false) {\n return false;\n }\n\n const previousJson = await readExistingArtifact(outputJsonPath);\n const previousDts = await readExistingArtifact(outputDtsPath);\n\n await publishPairWithRollback(\n [\n { tempPath: tempDtsPath, outputPath: outputDtsPath, previous: previousDts },\n { tempPath: tempJsonPath, outputPath: outputJsonPath, previous: previousJson },\n ],\n publicationToken,\n );\n return true;\n } finally {\n await Promise.allSettled([rm(tempJsonPath, { force: true }), rm(tempDtsPath, { force: true })]);\n }\n}\n","import { createRequire } from 'node:module';\n\nconst IMPORT_PATTERN = /import\\s+type\\s+.*?\\s+from\\s+['\"](@[^/]+\\/[^/'\"]+)/g;\n\nexport function extractPackageSpecifiers(dtsContent: string): string[] {\n const packages = new Set<string>();\n for (const match of dtsContent.matchAll(IMPORT_PATTERN)) {\n const pkg = match[1];\n if (pkg) packages.add(pkg);\n }\n return [...packages];\n}\n\nexport interface ContractDepsValidation {\n readonly missing: readonly string[];\n readonly warning?: string;\n}\n\nexport function validateContractDeps(\n dtsContent: string,\n projectRoot: string,\n): ContractDepsValidation {\n const packages = extractPackageSpecifiers(dtsContent);\n const resolve = createRequire(`${projectRoot}/package.json`);\n\n const missing: string[] = [];\n for (const pkg of packages) {\n try {\n resolve.resolve(`${pkg}/package.json`);\n } catch {\n missing.push(pkg);\n }\n }\n\n if (missing.length === 0) {\n return { missing };\n }\n\n const list = missing.map((p) => ` - ${p}`).join('\\n');\n const warning = [\n 'contract.d.ts imports types from packages that are not installed:',\n list,\n '',\n 'Install them with your package manager:',\n ...missing.map((p) => ` ${p}`),\n ].join('\\n');\n\n return { missing, warning };\n}\n","import { mkdir } from 'node:fs/promises';\nimport type { Contract } from '@prisma-next/contract/types';\nimport { emit, getEmittedArtifactPaths } from '@prisma-next/emitter';\nimport { createControlStack } from '@prisma-next/framework-components/control';\nimport { abortable } from '@prisma-next/utils/abortable';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { dirname } from 'pathe';\nimport { loadConfig } from '../../config-loader';\nimport { errorContractConfigMissing, errorRuntime } from '../../utils/cli-errors';\nimport { queueEmitByOutput } from '../../utils/emit-queue';\nimport { assertFrameworkComponentsCompatible } from '../../utils/framework-components';\nimport { publishContractArtifactPair } from '../../utils/publish-contract-artifact-pair';\nimport { validateContractDeps } from '../../utils/validate-contract-deps';\nimport { enrichContract } from '../contract-enrichment';\nimport type {\n ContractEmitOptions,\n ContractEmitResult,\n ControlActionName,\n OnControlProgress,\n} from '../types';\n\nconst EMIT_ACTION: ControlActionName = 'emit';\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null;\n}\n\nfunction startSpan(onProgress: OnControlProgress | undefined, spanId: string, label: string): void {\n onProgress?.({ action: EMIT_ACTION, kind: 'spanStart', spanId, label });\n}\n\nfunction endSpan(\n onProgress: OnControlProgress | undefined,\n spanId: string,\n outcome: 'ok' | 'error',\n): void {\n onProgress?.({ action: EMIT_ACTION, kind: 'spanEnd', spanId, outcome });\n}\n\nfunction failedToResolveContractSource(why: string, fix: string, meta?: Record<string, unknown>) {\n return errorRuntime('Failed to resolve contract source', {\n why,\n fix,\n ...ifDefined('meta', meta),\n });\n}\n\ntype ValidatedProviderResult =\n | { readonly ok: true; readonly value: unknown }\n | { readonly ok: false; readonly error: ReturnType<typeof errorRuntime> };\n\nfunction diagnosticLocationSuffix(diagnostic: Record<string, unknown>): string {\n const sourceId = typeof diagnostic['sourceId'] === 'string' ? diagnostic['sourceId'] : undefined;\n const span = isRecord(diagnostic['span']) ? diagnostic['span'] : undefined;\n const start = span && isRecord(span['start']) ? span['start'] : undefined;\n const line = start && typeof start['line'] === 'number' ? start['line'] : undefined;\n const column = start && typeof start['column'] === 'number' ? start['column'] : undefined;\n if (sourceId && line !== undefined && column !== undefined) {\n return ` (${sourceId}:${line}:${column})`;\n }\n if (sourceId) {\n return ` (${sourceId})`;\n }\n return '';\n}\n\nfunction mapDiagnosticsToIssues(\n diagnostics: readonly unknown[],\n): ReadonlyArray<{ readonly kind: string; readonly message: string }> {\n const issues: { readonly kind: string; readonly message: string }[] = [];\n for (const raw of diagnostics) {\n if (!isRecord(raw)) continue;\n const code = typeof raw['code'] === 'string' ? raw['code'] : 'diagnostic';\n const message = typeof raw['message'] === 'string' ? raw['message'] : '';\n issues.push({ kind: code, message: `${message}${diagnosticLocationSuffix(raw)}` });\n }\n return issues;\n}\n\nfunction validateProviderResult(providerResult: unknown): ValidatedProviderResult {\n if (!isRecord(providerResult) || typeof providerResult['ok'] !== 'boolean') {\n return {\n ok: false,\n error: failedToResolveContractSource(\n 'Contract source provider returned malformed result shape.',\n 'Ensure contract.source.load resolves to ok(Contract) or notOk({ summary, diagnostics }).',\n ),\n };\n }\n\n if (providerResult['ok']) {\n if (!('value' in providerResult)) {\n return {\n ok: false,\n error: failedToResolveContractSource(\n 'Contract source provider returned malformed success result: missing value.',\n 'Ensure contract.source.load success payload is ok(Contract).',\n ),\n };\n }\n return { ok: true, value: providerResult['value'] };\n }\n\n const failure = providerResult['failure'];\n if (\n !isRecord(failure) ||\n typeof failure['summary'] !== 'string' ||\n !Array.isArray(failure['diagnostics'])\n ) {\n return {\n ok: false,\n error: failedToResolveContractSource(\n 'Contract source provider returned malformed failure result: expected summary and diagnostics.',\n 'Ensure contract.source.load failure payload is notOk({ summary, diagnostics, meta? }).',\n ),\n };\n }\n return {\n ok: false,\n error: failedToResolveContractSource(\n String(failure['summary']),\n 'Fix contract source diagnostics and return ok(Contract).',\n {\n diagnostics: failure['diagnostics'],\n issues: mapDiagnosticsToIssues(failure['diagnostics']),\n ...ifDefined('providerMeta', failure['meta']),\n },\n ),\n };\n}\n\n/**\n * Canonical contract emit operation.\n *\n * This is the SINGLE publication path used by both the CLI command\n * (`prisma-next contract emit`) and the Vite plugin\n * (`@prisma-next/vite-plugin-contract-emit`). New callers must go through this\n * function rather than re-implementing load → emit → publish.\n *\n * The whole flow (load config → resolve source → emit bytes → atomic publish)\n * is serialized per output JSON path via `queueEmitByOutput`. Concurrent calls\n * for the same output line up FIFO; the user-visible outcome is \"last\n * submission wins on disk\" without any supersession bookkeeping. Within a\n * single emit, `publishContractArtifactPair` stages temp files, renames\n * `contract.d.ts` before `contract.json`, and attempts to restore the previous\n * pair if either rename fails — so type-only consumers never observe a\n * mismatched pair.\n *\n * @throws {CliStructuredError} on config/source/validation problems\n * @throws {DOMException} `AbortError` if cancelled via `signal`\n */\nexport async function executeContractEmit(\n options: ContractEmitOptions,\n): Promise<ContractEmitResult> {\n const { configPath, signal = new AbortController().signal, onProgress } = options;\n const unlessAborted = abortable(signal);\n\n const config = await unlessAborted(loadConfig(configPath));\n\n if (!config.contract) {\n throw errorContractConfigMissing({\n why: 'Config.contract is required for emit. Define it in your config: contract: { source: ..., output: ... }',\n });\n }\n\n const contractConfig = config.contract;\n\n if (!contractConfig.output) {\n throw errorContractConfigMissing({\n why: 'Contract config must have output path. This should not happen if defineConfig() was used.',\n });\n }\n\n if (typeof contractConfig.source?.load !== 'function') {\n throw errorContractConfigMissing({\n why: 'Contract config must include a valid source provider object',\n });\n }\n\n let outputPaths: ReturnType<typeof getEmittedArtifactPaths>;\n try {\n outputPaths = getEmittedArtifactPaths(contractConfig.output);\n } catch (error) {\n throw errorContractConfigMissing({\n why: error instanceof Error ? error.message : String(error),\n });\n }\n const { jsonPath: outputJsonPath, dtsPath: outputDtsPath } = outputPaths;\n\n return queueEmitByOutput(outputJsonPath, async () => {\n const stack = createControlStack(config);\n\n const sourceContext = {\n composedExtensionPacks: stack.extensionPacks.map((p) => p.id),\n scalarTypeDescriptors: stack.scalarTypeDescriptors,\n authoringContributions: stack.authoringContributions,\n codecLookup: stack.codecLookup,\n controlMutationDefaults: stack.controlMutationDefaults,\n resolvedInputs: contractConfig.source.inputs ?? [],\n };\n\n startSpan(onProgress, 'resolveSource', 'Resolving contract source...');\n let providerResult: Awaited<ReturnType<typeof contractConfig.source.load>>;\n try {\n providerResult = await unlessAborted(contractConfig.source.load(sourceContext));\n } catch (error) {\n endSpan(onProgress, 'resolveSource', 'error');\n if (signal.aborted || (isRecord(error) && error['name'] === 'AbortError')) {\n throw error;\n }\n throw failedToResolveContractSource(\n error instanceof Error ? error.message : String(error),\n 'Ensure contract.source.load resolves to ok(Contract) or returns structured diagnostics.',\n );\n }\n\n const validatedContract = validateProviderResult(providerResult);\n if (!validatedContract.ok) {\n endSpan(onProgress, 'resolveSource', 'error');\n throw validatedContract.error;\n }\n endSpan(onProgress, 'resolveSource', 'ok');\n\n startSpan(onProgress, 'emit', 'Emitting contract...');\n let emitResult: Awaited<ReturnType<typeof emit>>;\n try {\n const familyInstance = config.family.create(stack);\n const rawComponents = [config.target, config.adapter, ...(config.extensionPacks ?? [])];\n const frameworkComponents = assertFrameworkComponentsCompatible(\n config.family.familyId,\n config.target.targetId,\n rawComponents,\n );\n const enrichedIR = enrichContract(validatedContract.value as Contract, frameworkComponents);\n familyInstance.validateContract(enrichedIR);\n emitResult = await unlessAborted(\n emit(enrichedIR, stack, config.family.emission, { outputJsonPath }),\n );\n } catch (error) {\n endSpan(onProgress, 'emit', 'error');\n throw error;\n }\n endSpan(onProgress, 'emit', 'ok');\n\n await unlessAborted(mkdir(dirname(outputJsonPath), { recursive: true }));\n await publishContractArtifactPair({\n outputJsonPath,\n outputDtsPath,\n contractJson: emitResult.contractJson,\n contractDts: emitResult.contractDts,\n publicationToken: String(process.hrtime.bigint()),\n });\n\n const validationWarning = validateContractDeps(\n emitResult.contractDts,\n dirname(outputDtsPath),\n ).warning;\n\n return {\n storageHash: emitResult.storageHash,\n ...ifDefined('executionHash', emitResult.executionHash),\n profileHash: emitResult.profileHash,\n files: {\n json: outputJsonPath,\n dts: outputDtsPath,\n },\n ...ifDefined('validationWarning', validationWarning),\n };\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAYA,MAAM,6BAAa,IAAI,KAA+B;AAEtD,SAAgB,kBAAqB,gBAAwB,QAAsC;CAIjG,MAAM,QAHW,WAAW,IAAI,eAAe,IAAI,QAAQ,SAAS,EAG9C,KAAK,QAAQ,OAAO;AA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AAO,OAAO,OAAO,MAAM;GAClD,MAAM,gBAAgB;IAAC,OAAO;IAAQ,OAAO;IAAS,GAAI,OAAO,kBAAkB,EAAE;IAAE;GACvF,MAAM,sBAAsB,oCAC1B,OAAO,OAAO,UACd,OAAO,OAAO,UACd,cACD;GACD,MAAM,aAAa,eAAe,kBAAkB,OAAmB,oBAAoB;AAC3F,kBAAe,iBAAiB,WAAW;AAC3C,gBAAa,MAAM,cACjB,KAAK,YAAY,OAAO,OAAO,OAAO,UAAU,EAAE,gBAAgB,CAAC,CACpE;WACM,OAAO;AACd,WAAQ,YAAY,QAAQ,QAAQ;AACpC,SAAM;;AAER,UAAQ,YAAY,QAAQ,KAAK;AAEjC,QAAM,cAAc,MAAM,QAAQ,eAAe,EAAE,EAAE,WAAW,MAAM,CAAC,CAAC;AACxE,QAAM,4BAA4B;GAChC;GACA;GACA,cAAc,WAAW;GACzB,aAAa,WAAW;GACxB,kBAAkB,OAAO,QAAQ,OAAO,QAAQ,CAAC;GAClD,CAAC;EAEF,MAAM,oBAAoB,qBACxB,WAAW,aACX,QAAQ,cAAc,CACvB,CAAC;AAEF,SAAO;GACL,aAAa,WAAW;GACxB,GAAG,UAAU,iBAAiB,WAAW,cAAc;GACvD,aAAa,WAAW;GACxB,OAAO;IACL,MAAM;IACN,KAAK;IACN;GACD,GAAG,UAAU,qBAAqB,kBAAkB;GACrD;GACD"}
@@ -76,4 +76,4 @@ function enrichContract(ir, components) {
76
76
 
77
77
  //#endregion
78
78
  export { enrichContract as t };
79
- //# sourceMappingURL=contract-enrichment-CAOELa-H.mjs.map
79
+ //# sourceMappingURL=contract-enrichment-4Ptgw3Pe.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"contract-enrichment-CAOELa-H.mjs","names":["next: Record<string, unknown>","out: CapabilityMatrix","caps: Record<string, boolean>","next: CapabilityMatrix","base: Record<string, unknown>","extensionPacksMeta: Record<string, unknown>"],"sources":["../src/control-api/contract-enrichment.ts"],"sourcesContent":["import type { Contract } from '@prisma-next/contract/types';\nimport type { TargetBoundComponentDescriptor } from '@prisma-next/framework-components/components';\n\ntype CapabilityMatrix = Record<string, Record<string, boolean>>;\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction sortDeep(value: unknown): unknown {\n if (Array.isArray(value)) {\n return value.map(sortDeep);\n }\n if (!isPlainObject(value)) {\n return value;\n }\n const entries = Object.entries(value).sort(([a], [b]) => a.localeCompare(b));\n const next: Record<string, unknown> = {};\n for (const [key, child] of entries) {\n next[key] = sortDeep(child);\n }\n return next;\n}\n\nfunction sortDeepTyped<T>(value: T): T {\n return sortDeep(value) as T;\n}\n\nfunction extractCapabilityMatrix(value: unknown): CapabilityMatrix {\n if (!isPlainObject(value)) return {};\n\n const out: CapabilityMatrix = {};\n for (const [namespace, maybeCaps] of Object.entries(value)) {\n if (!isPlainObject(maybeCaps)) continue;\n const caps: Record<string, boolean> = {};\n for (const [key, flag] of Object.entries(maybeCaps)) {\n if (typeof flag === 'boolean') {\n caps[key] = flag;\n }\n }\n if (Object.keys(caps).length > 0) {\n out[namespace] = caps;\n }\n }\n\n return out;\n}\n\nfunction mergeCapabilities(left: CapabilityMatrix, right: CapabilityMatrix): CapabilityMatrix {\n const next: CapabilityMatrix = { ...left };\n for (const [namespace, capabilities] of Object.entries(right)) {\n next[namespace] = {\n ...(left[namespace] ?? {}),\n ...capabilities,\n };\n }\n return next;\n}\n\nfunction extractExtensionPackMeta(\n component: TargetBoundComponentDescriptor<string, string>,\n): Record<string, unknown> {\n const { kind, id, version, capabilities, types } = component;\n const base: Record<string, unknown> = {\n kind,\n id,\n familyId: component.familyId,\n targetId: component.targetId,\n version,\n };\n if (capabilities) {\n base['capabilities'] = capabilities;\n }\n if (types) {\n if (types.codecTypes) {\n const { controlPlaneHooks: _, codecInstances: _ci, ...cleanedCodecTypes } = types.codecTypes;\n base['types'] = { ...types, codecTypes: cleanedCodecTypes };\n } else {\n base['types'] = types;\n }\n }\n return base;\n}\n\n/**\n * Enriches a raw contract with framework-derived metadata:\n * capabilities from all component descriptors and extension pack metadata\n * from extension descriptors. Produces deterministically sorted output.\n */\nexport function enrichContract(\n ir: Contract,\n components: ReadonlyArray<TargetBoundComponentDescriptor<string, string>>,\n): Contract {\n let mergedCapabilities = ir.capabilities;\n const extensionPacksMeta: Record<string, unknown> = {};\n\n for (const component of components) {\n if (component.capabilities) {\n mergedCapabilities = mergeCapabilities(\n mergedCapabilities,\n extractCapabilityMatrix(component.capabilities),\n );\n }\n if (component.kind === 'extension') {\n extensionPacksMeta[component.id] = extractExtensionPackMeta(component);\n }\n }\n\n const extensionPacks =\n Object.keys(extensionPacksMeta).length > 0\n ? { ...ir.extensionPacks, ...extensionPacksMeta }\n : ir.extensionPacks;\n\n return {\n ...ir,\n capabilities: sortDeepTyped(mergedCapabilities),\n extensionPacks: sortDeepTyped(extensionPacks),\n };\n}\n"],"mappings":";AAKA,SAAS,cAAc,OAAkD;AACvE,QAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,MAAM;;AAG7E,SAAS,SAAS,OAAyB;AACzC,KAAI,MAAM,QAAQ,MAAM,CACtB,QAAO,MAAM,IAAI,SAAS;AAE5B,KAAI,CAAC,cAAc,MAAM,CACvB,QAAO;CAET,MAAM,UAAU,OAAO,QAAQ,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,EAAE,CAAC;CAC5E,MAAMA,OAAgC,EAAE;AACxC,MAAK,MAAM,CAAC,KAAK,UAAU,QACzB,MAAK,OAAO,SAAS,MAAM;AAE7B,QAAO;;AAGT,SAAS,cAAiB,OAAa;AACrC,QAAO,SAAS,MAAM;;AAGxB,SAAS,wBAAwB,OAAkC;AACjE,KAAI,CAAC,cAAc,MAAM,CAAE,QAAO,EAAE;CAEpC,MAAMC,MAAwB,EAAE;AAChC,MAAK,MAAM,CAAC,WAAW,cAAc,OAAO,QAAQ,MAAM,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,mBAAmB;EAC/C,gBAAgB,cAAc,eAAe;EAC9C"}
1
+ {"version":3,"file":"contract-enrichment-4Ptgw3Pe.mjs","names":["next: Record<string, unknown>","out: CapabilityMatrix","caps: Record<string, boolean>","next: CapabilityMatrix","base: Record<string, unknown>","extensionPacksMeta: Record<string, unknown>"],"sources":["../src/control-api/contract-enrichment.ts"],"sourcesContent":["import type { Contract } from '@prisma-next/contract/types';\nimport type { TargetBoundComponentDescriptor } from '@prisma-next/framework-components/components';\n\ntype CapabilityMatrix = Record<string, Record<string, boolean>>;\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction sortDeep(value: unknown): unknown {\n if (Array.isArray(value)) {\n return value.map(sortDeep);\n }\n if (!isPlainObject(value)) {\n return value;\n }\n const entries = Object.entries(value).sort(([a], [b]) => a.localeCompare(b));\n const next: Record<string, unknown> = {};\n for (const [key, child] of entries) {\n next[key] = sortDeep(child);\n }\n return next;\n}\n\nfunction sortDeepTyped<T>(value: T): T {\n return sortDeep(value) as T;\n}\n\nfunction extractCapabilityMatrix(value: unknown): CapabilityMatrix {\n if (!isPlainObject(value)) return {};\n\n const out: CapabilityMatrix = {};\n for (const [namespace, maybeCaps] of Object.entries(value)) {\n if (!isPlainObject(maybeCaps)) continue;\n const caps: Record<string, boolean> = {};\n for (const [key, flag] of Object.entries(maybeCaps)) {\n if (typeof flag === 'boolean') {\n caps[key] = flag;\n }\n }\n if (Object.keys(caps).length > 0) {\n out[namespace] = caps;\n }\n }\n\n return out;\n}\n\nfunction mergeCapabilities(left: CapabilityMatrix, right: CapabilityMatrix): CapabilityMatrix {\n const next: CapabilityMatrix = { ...left };\n for (const [namespace, capabilities] of Object.entries(right)) {\n next[namespace] = {\n ...(left[namespace] ?? {}),\n ...capabilities,\n };\n }\n return next;\n}\n\nfunction extractExtensionPackMeta(\n component: TargetBoundComponentDescriptor<string, string>,\n): Record<string, unknown> {\n const { kind, id, version, capabilities, types } = component;\n const base: Record<string, unknown> = {\n kind,\n id,\n familyId: component.familyId,\n targetId: component.targetId,\n version,\n };\n if (capabilities) {\n base['capabilities'] = capabilities;\n }\n if (types) {\n if (types.codecTypes) {\n const { controlPlaneHooks: _, codecInstances: _ci, ...cleanedCodecTypes } = types.codecTypes;\n base['types'] = { ...types, codecTypes: cleanedCodecTypes };\n } else {\n base['types'] = types;\n }\n }\n return base;\n}\n\n/**\n * Enriches a raw contract with framework-derived metadata:\n * capabilities from all component descriptors and extension pack metadata\n * from extension descriptors. Produces deterministically sorted output.\n */\nexport function enrichContract(\n ir: Contract,\n components: ReadonlyArray<TargetBoundComponentDescriptor<string, string>>,\n): Contract {\n let mergedCapabilities = ir.capabilities;\n const extensionPacksMeta: Record<string, unknown> = {};\n\n for (const component of components) {\n if (component.capabilities) {\n mergedCapabilities = mergeCapabilities(\n mergedCapabilities,\n extractCapabilityMatrix(component.capabilities),\n );\n }\n if (component.kind === 'extension') {\n extensionPacksMeta[component.id] = extractExtensionPackMeta(component);\n }\n }\n\n const extensionPacks =\n Object.keys(extensionPacksMeta).length > 0\n ? { ...ir.extensionPacks, ...extensionPacksMeta }\n : ir.extensionPacks;\n\n return {\n ...ir,\n capabilities: sortDeepTyped(mergedCapabilities),\n extensionPacks: sortDeepTyped(extensionPacks),\n };\n}\n"],"mappings":";AAKA,SAAS,cAAc,OAAkD;AACvE,QAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,MAAM;;AAG7E,SAAS,SAAS,OAAyB;AACzC,KAAI,MAAM,QAAQ,MAAM,CACtB,QAAO,MAAM,IAAI,SAAS;AAE5B,KAAI,CAAC,cAAc,MAAM,CACvB,QAAO;CAET,MAAM,UAAU,OAAO,QAAQ,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,EAAE,CAAC;CAC5E,MAAMA,OAAgC,EAAE;AACxC,MAAK,MAAM,CAAC,KAAK,UAAU,QACzB,MAAK,OA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wBAAwB,UAAU,aAAa,CAChD;AAEH,MAAI,UAAU,SAAS,YACrB,oBAAmB,UAAU,MAAM,yBAAyB,UAAU;;CAI1E,MAAM,iBACJ,OAAO,KAAK,mBAAmB,CAAC,SAAS,IACrC;EAAE,GAAG,GAAG;EAAgB,GAAG;EAAoB,GAC/C,GAAG;AAET,QAAO;EACL,GAAG;EACH,cAAc,cAAc,mBAAmB;EAC/C,gBAAgB,cAAc,eAAe;EAC9C"}
@@ -1,11 +1,11 @@
1
- import { t as TerminalUI } from "./terminal-ui-C3ZLwQxK.mjs";
2
- import { d as setCommandExamples, m as parseGlobalFlags, n as addGlobalOptions, t as handleResult, u as setCommandDescriptions } from "./result-handler-CuhZ3kNu.mjs";
3
- import { t as inspectLiveSchema } from "./inspect-live-schema-yCu0JT0I.mjs";
1
+ import { t as TerminalUI } from "./terminal-ui-u2YgKghu.mjs";
2
+ import { d as setCommandExamples, m as parseGlobalFlags, n as addGlobalOptions, t as handleResult, u as setCommandDescriptions } from "./result-handler-BmVh8AeV.mjs";
3
+ import { t as inspectLiveSchema } from "./inspect-live-schema-QklSDLt_.mjs";
4
4
  import { Command } from "commander";
5
- import { existsSync, mkdirSync, writeFileSync } from "node:fs";
6
5
  import { notOk, ok } from "@prisma-next/utils/result";
7
6
  import { dirname, relative, resolve } from "pathe";
8
7
  import { errorRuntime } from "@prisma-next/errors/execution";
8
+ import { existsSync, mkdirSync, writeFileSync } from "node:fs";
9
9
  import { printPsl, validatePrintableSqlSchemaIR } from "@prisma-next/psl-printer";
10
10
  import { createPostgresDefaultMapping, createPostgresTypeMap, extractEnumInfo, parseRawDefault } from "@prisma-next/psl-printer/postgres";
11
11
 
@@ -87,4 +87,4 @@ function createContractInferCommand() {
87
87
 
88
88
  //#endregion
89
89
  export { createContractInferCommand as t };
90
- //# sourceMappingURL=contract-infer-BgnsSkGp.mjs.map
90
+ //# sourceMappingURL=contract-infer-BjzkcwQt.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"contract-infer-BgnsSkGp.mjs","names":[],"sources":["../src/commands/contract-infer-paths.ts","../src/commands/contract-infer.ts"],"sourcesContent":["import { dirname, resolve } from 'pathe';\n\ninterface ContractInferPathOptions {\n readonly output?: string;\n readonly config?: string;\n}\n\n/**\n * Resolves the output path for the inferred PSL contract.\n *\n * Priority:\n * 1. --output <path> flag (resolved relative to cwd)\n * 2. contract.prisma next to config.contract.output\n * 3. Canonical default: contract.prisma in the config directory\n */\nexport function resolveContractInferOutputPath(\n options: ContractInferPathOptions,\n contractOutput: string | undefined,\n): string {\n const configDir = options.config\n ? dirname(resolve(process.cwd(), options.config))\n : process.cwd();\n\n if (options.output) {\n return resolve(process.cwd(), options.output);\n }\n if (contractOutput) {\n const contractPath = resolve(configDir, contractOutput);\n return resolve(dirname(contractPath), 'contract.prisma');\n }\n return resolve(configDir, 'contract.prisma');\n}\n","import { existsSync, mkdirSync, writeFileSync } from 'node:fs';\nimport { errorRuntime } from '@prisma-next/errors/execution';\nimport { printPsl, validatePrintableSqlSchemaIR } from '@prisma-next/psl-printer';\nimport {\n createPostgresDefaultMapping,\n createPostgresTypeMap,\n extractEnumInfo,\n parseRawDefault,\n} from '@prisma-next/psl-printer/postgres';\nimport { notOk, ok, type Result } from '@prisma-next/utils/result';\nimport { Command } from 'commander';\nimport { dirname, relative } from 'pathe';\nimport type { CliStructuredError } from '../utils/cli-errors';\nimport {\n addGlobalOptions,\n setCommandDescriptions,\n setCommandExamples,\n} from '../utils/command-helpers';\nimport { parseGlobalFlags } from '../utils/global-flags';\nimport { handleResult } from '../utils/result-handler';\nimport { TerminalUI } from '../utils/terminal-ui';\nimport { resolveContractInferOutputPath } from './contract-infer-paths';\nimport {\n type InspectLiveSchemaOptions,\n type InspectLiveSchemaResult,\n inspectLiveSchema,\n} from './inspect-live-schema';\n\ninterface ContractInferOptions extends InspectLiveSchemaOptions {\n readonly output?: string;\n}\n\ninterface ContractInferSuccessResult {\n readonly ok: true;\n readonly summary: string;\n readonly target: InspectLiveSchemaResult['target'];\n readonly psl: {\n readonly path: string;\n };\n readonly meta: InspectLiveSchemaResult['meta'];\n readonly timings: {\n readonly total: number;\n };\n}\n\nasync function executeContractInferCommand(\n options: ContractInferOptions,\n ui: TerminalUI,\n startTime: number,\n): Promise<Result<ContractInferSuccessResult, CliStructuredError>> {\n const flags = parseGlobalFlags(options);\n const inspectResult = await inspectLiveSchema(options, flags, ui, startTime, {\n commandName: 'contract infer',\n description: 'Infer a PSL contract from the live database schema',\n url: 'https://pris.ly/contract-infer',\n });\n\n if (!inspectResult.ok) {\n return inspectResult;\n }\n\n const { config, target, meta } = inspectResult.value;\n\n if (target.familyId !== 'sql') {\n return notOk(\n errorRuntime(`contract infer is not supported for family \"${target.familyId}\"`, {\n why: 'contract infer currently supports SQL targets only',\n fix: 'Use an SQL target (e.g. Postgres) with this command',\n }),\n );\n }\n\n const schema = validatePrintableSqlSchemaIR(inspectResult.value.schema);\n const outputPath = resolveContractInferOutputPath(options, config.contract?.output);\n const enumInfo = extractEnumInfo(schema.annotations);\n const pslContent = printPsl(schema, {\n defaultMapping: createPostgresDefaultMapping(),\n typeMap: createPostgresTypeMap(enumInfo.typeNames),\n enumInfo,\n parseRawDefault,\n });\n\n if (existsSync(outputPath) && !flags.json && !flags.quiet) {\n ui.stderr(`\\u26A0 Overwriting existing file: ${relative(process.cwd(), outputPath)}`);\n }\n\n mkdirSync(dirname(outputPath), { recursive: true });\n writeFileSync(outputPath, pslContent, 'utf-8');\n\n const pslPath = relative(process.cwd(), outputPath);\n if (!flags.json && !flags.quiet) {\n ui.stderr(`\\u2714 Contract written to ${pslPath}`);\n }\n\n return ok({\n ok: true,\n summary: 'Contract inferred successfully',\n target,\n psl: {\n path: pslPath,\n },\n meta,\n timings: {\n total: Date.now() - startTime,\n },\n });\n}\n\nexport function createContractInferCommand(): Command {\n const command = new Command('infer');\n setCommandDescriptions(\n command,\n 'Infer a PSL contract from the live database schema',\n 'Reads the live database schema and writes an inferred PSL contract to disk.\\n' +\n 'This command stops at `contract.prisma`; follow it with `contract emit` and\\n' +\n '`db sign` as separate steps.',\n );\n setCommandExamples(command, [\n 'prisma-next contract infer --db $DATABASE_URL',\n 'prisma-next contract infer --db $DATABASE_URL --output ./prisma/contract.prisma',\n 'prisma-next contract infer --db $DATABASE_URL --json',\n ]);\n addGlobalOptions(command)\n .option('--db <url>', 'Database connection string')\n .option('--config <path>', 'Path to prisma-next.config.ts')\n .option('--output <path>', 'Write the inferred PSL contract to the specified path')\n .action(async (options: ContractInferOptions) => {\n const flags = parseGlobalFlags(options);\n const ui = new TerminalUI({ color: flags.color, interactive: flags.interactive });\n const startTime = Date.now();\n\n const result = await executeContractInferCommand(options, ui, startTime);\n const exitCode = handleResult(result, flags, ui, (value) => {\n if (flags.json) {\n ui.output(JSON.stringify(value, null, 2));\n }\n });\n\n process.exit(exitCode);\n });\n\n return command;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAeA,SAAgB,+BACd,SACA,gBACQ;CACR,MAAM,YAAY,QAAQ,SACtB,QAAQ,QAAQ,QAAQ,KAAK,EAAE,QAAQ,OAAO,CAAC,GAC/C,QAAQ,KAAK;AAEjB,KAAI,QAAQ,OACV,QAAO,QAAQ,QAAQ,KAAK,EAAE,QAAQ,OAAO;AAE/C,KAAI,eAEF,QAAO,QAAQ,QADM,QAAQ,WAAW,eAAe,CACnB,EAAE,kBAAkB;AAE1D,QAAO,QAAQ,WAAW,kBAAkB;;;;;ACe9C,eAAe,4BACb,SACA,IACA,WACiE;CACjE,MAAM,QAAQ,iBAAiB,QAAQ;CACvC,MAAM,gBAAgB,MAAM,kBAAkB,SAAS,OAAO,IAAI,WAAW;EAC3E,aAAa;EACb,aAAa;EACb,KAAK;EACN,CAAC;AAEF,KAAI,CAAC,cAAc,GACjB,QAAO;CAGT,MAAM,EAAE,QAAQ,QAAQ,SAAS,cAAc;AAE/C,KAAI,OAAO,aAAa,MACtB,QAAO,MACL,aAAa,+CAA+C,OAAO,SAAS,IAAI;EAC9E,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C1D,OAAI,MAAM,KACR,IAAG,OAAO,KAAK,UAAU,OAAO,MAAM,EAAE,CAAC;IAE3C;AAEF,UAAQ,KAAK,SAAS;GACtB;AAEJ,QAAO"}
1
+ {"version":3,"file":"contract-infer-BjzkcwQt.mjs","names":[],"sources":["../src/commands/contract-infer-paths.ts","../src/commands/contract-infer.ts"],"sourcesContent":["import { dirname, resolve } from 'pathe';\n\ninterface ContractInferPathOptions {\n readonly output?: string;\n readonly config?: string;\n}\n\n/**\n * Resolves the output path for the inferred PSL contract.\n *\n * Priority:\n * 1. --output <path> flag (resolved relative to cwd)\n * 2. contract.prisma next to config.contract.output\n * 3. Canonical default: contract.prisma in the config directory\n */\nexport function resolveContractInferOutputPath(\n options: ContractInferPathOptions,\n contractOutput: string | undefined,\n): string {\n const configDir = options.config\n ? dirname(resolve(process.cwd(), options.config))\n : process.cwd();\n\n if (options.output) {\n return resolve(process.cwd(), options.output);\n }\n if (contractOutput) {\n const contractPath = resolve(configDir, contractOutput);\n return resolve(dirname(contractPath), 'contract.prisma');\n }\n return resolve(configDir, 'contract.prisma');\n}\n","import { existsSync, mkdirSync, writeFileSync } from 'node:fs';\nimport { errorRuntime } from '@prisma-next/errors/execution';\nimport { printPsl, validatePrintableSqlSchemaIR } from '@prisma-next/psl-printer';\nimport {\n createPostgresDefaultMapping,\n createPostgresTypeMap,\n extractEnumInfo,\n parseRawDefault,\n} from '@prisma-next/psl-printer/postgres';\nimport { notOk, ok, type Result } from '@prisma-next/utils/result';\nimport { Command } from 'commander';\nimport { dirname, relative } from 'pathe';\nimport type { CliStructuredError } from '../utils/cli-errors';\nimport {\n addGlobalOptions,\n setCommandDescriptions,\n setCommandExamples,\n} from '../utils/command-helpers';\nimport { parseGlobalFlags } from '../utils/global-flags';\nimport { handleResult } from '../utils/result-handler';\nimport { TerminalUI } from '../utils/terminal-ui';\nimport { resolveContractInferOutputPath } from './contract-infer-paths';\nimport {\n type InspectLiveSchemaOptions,\n type InspectLiveSchemaResult,\n inspectLiveSchema,\n} from './inspect-live-schema';\n\ninterface ContractInferOptions extends InspectLiveSchemaOptions {\n readonly output?: string;\n}\n\ninterface ContractInferSuccessResult {\n readonly ok: true;\n readonly summary: string;\n readonly target: InspectLiveSchemaResult['target'];\n readonly psl: {\n readonly path: string;\n };\n readonly meta: InspectLiveSchemaResult['meta'];\n readonly timings: {\n readonly total: number;\n };\n}\n\nasync function executeContractInferCommand(\n options: ContractInferOptions,\n ui: TerminalUI,\n startTime: number,\n): Promise<Result<ContractInferSuccessResult, CliStructuredError>> {\n const flags = parseGlobalFlags(options);\n const inspectResult = await inspectLiveSchema(options, flags, ui, startTime, {\n commandName: 'contract infer',\n description: 'Infer a PSL contract from the live database schema',\n url: 'https://pris.ly/contract-infer',\n });\n\n if (!inspectResult.ok) {\n return inspectResult;\n }\n\n const { config, target, meta } = inspectResult.value;\n\n if (target.familyId !== 'sql') {\n return notOk(\n errorRuntime(`contract infer is not supported for family \"${target.familyId}\"`, {\n why: 'contract infer currently supports SQL targets only',\n fix: 'Use an SQL target (e.g. Postgres) with this command',\n }),\n );\n }\n\n const schema = validatePrintableSqlSchemaIR(inspectResult.value.schema);\n const outputPath = resolveContractInferOutputPath(options, config.contract?.output);\n const enumInfo = extractEnumInfo(schema.annotations);\n const pslContent = printPsl(schema, {\n defaultMapping: createPostgresDefaultMapping(),\n typeMap: createPostgresTypeMap(enumInfo.typeNames),\n enumInfo,\n parseRawDefault,\n });\n\n if (existsSync(outputPath) && !flags.json && !flags.quiet) {\n ui.stderr(`\\u26A0 Overwriting existing file: ${relative(process.cwd(), outputPath)}`);\n }\n\n mkdirSync(dirname(outputPath), { recursive: true });\n writeFileSync(outputPath, pslContent, 'utf-8');\n\n const pslPath = relative(process.cwd(), outputPath);\n if (!flags.json && !flags.quiet) {\n ui.stderr(`\\u2714 Contract written to ${pslPath}`);\n }\n\n return ok({\n ok: true,\n summary: 'Contract inferred successfully',\n target,\n psl: {\n path: pslPath,\n },\n meta,\n timings: {\n total: Date.now() - startTime,\n },\n });\n}\n\nexport function createContractInferCommand(): Command {\n const command = new Command('infer');\n setCommandDescriptions(\n command,\n 'Infer a PSL contract from the live database schema',\n 'Reads the live database schema and writes an inferred PSL contract to disk.\\n' +\n 'This command stops at `contract.prisma`; follow it with `contract emit` and\\n' +\n '`db sign` as separate steps.',\n );\n setCommandExamples(command, [\n 'prisma-next contract infer --db $DATABASE_URL',\n 'prisma-next contract infer --db $DATABASE_URL --output ./prisma/contract.prisma',\n 'prisma-next contract infer --db $DATABASE_URL --json',\n ]);\n addGlobalOptions(command)\n .option('--db <url>', 'Database connection string')\n .option('--config <path>', 'Path to prisma-next.config.ts')\n .option('--output <path>', 'Write the inferred PSL contract to the specified path')\n .action(async (options: ContractInferOptions) => {\n const flags = parseGlobalFlags(options);\n const ui = new TerminalUI({ color: flags.color, interactive: flags.interactive });\n const startTime = Date.now();\n\n const result = await executeContractInferCommand(options, ui, startTime);\n const exitCode = handleResult(result, flags, ui, (value) => {\n if (flags.json) {\n ui.output(JSON.stringify(value, null, 2));\n }\n });\n\n process.exit(exitCode);\n });\n\n return command;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAeA,SAAgB,+BACd,SACA,gBACQ;CACR,MAAM,YAAY,QAAQ,SACtB,QAAQ,QAAQ,QAAQ,KAAK,EAAE,QAAQ,OAAO,CAAC,GAC/C,QAAQ,KAAK;AAEjB,KAAI,QAAQ,OACV,QAAO,QAAQ,QAAQ,KAAK,EAAE,QAAQ,OAAO;AAE/C,KAAI,eAEF,QAAO,QAAQ,QADM,QAAQ,WAAW,eAAe,CACnB,EAAE,kBAAkB;AAE1D,QAAO,QAAQ,WAAW,kBAAkB;;;;;ACe9C,eAAe,4BACb,SACA,IACA,WACiE;CACjE,MAAM,QAAQ,iBAAiB,QAAQ;CACvC,MAAM,gBAAgB,MAAM,kBAAkB,SAAS,OAAO,IAAI,WAAW;EAC3E,aAAa;EACb,aAAa;EACb,KAAK;EACN,CAAC;AAEF,KAAI,CAAC,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AAE,OAAO,MAAM;GAAO,aAAa,MAAM;GAAa,CAAC;EAIjF,MAAM,WAAW,aADF,MAAM,4BAA4B,SAAS,IAFxC,KAAK,KAAK,CAE4C,EAClC,OAAO,KAAK,UAAU;AAC1D,OAAI,MAAM,KACR,IAAG,OAAO,KAAK,UAAU,OAAO,MAAM,EAAE,CAAC;IAE3C;AAEF,UAAQ,KAAK,SAAS;GACtB;AAEJ,QAAO"}
@@ -427,17 +427,30 @@ interface MigrationApplyFailure {
427
427
  type MigrationApplyResult = Result<MigrationApplySuccess, MigrationApplyFailure>;
428
428
  /**
429
429
  * Options for the standalone executeContractEmit function.
430
- * Used by tooling (e.g., Vite plugin) that needs to emit contracts
431
- * without the full ControlClient infrastructure.
430
+ *
431
+ * `executeContractEmit` is the canonical publication path for both the
432
+ * `prisma-next contract emit` CLI command and the `@prisma-next/vite-plugin-contract-emit`
433
+ * Vite plugin. Do not duplicate the load → emit → publish dance elsewhere; if a
434
+ * caller needs additional behavior, extend this options shape and update the
435
+ * single implementation rather than building a parallel publication path.
436
+ *
437
+ * Concurrent calls for the same output JSON path are serialized per-output via
438
+ * a FIFO queue; concurrent calls for distinct outputs run in parallel.
432
439
  */
433
440
  interface ContractEmitOptions {
434
441
  /** Path to the prisma-next.config.ts file */
435
442
  readonly configPath: string;
436
- /** Optional AbortSignal for cancellation support */
443
+ /** Optional AbortSignal for cancelling the in-flight emit */
437
444
  readonly signal?: AbortSignal;
445
+ /** Optional progress callback for observing source-resolution and emit spans */
446
+ readonly onProgress?: OnControlProgress;
438
447
  }
439
448
  /**
440
449
  * Result from the standalone executeContractEmit function.
450
+ *
451
+ * Always describes the bytes that were just published to disk. Failures throw
452
+ * (config / source-resolution / emit / publish) — callers do not need to
453
+ * branch on a result discriminator.
441
454
  */
442
455
  interface ContractEmitResult {
443
456
  /** Hash of the storage contract (schema-level) */
@@ -453,6 +466,12 @@ interface ContractEmitResult {
453
466
  /** Path to the emitted contract.d.ts file */
454
467
  readonly dts: string;
455
468
  };
469
+ /**
470
+ * Warning surfaced by `validateContractDeps` after a successful publication.
471
+ * Callers (CLI, Vite plugin) decide how to render this; the operation does
472
+ * not write to stderr itself. Undefined when no warning was raised.
473
+ */
474
+ readonly validationWarning?: string;
456
475
  }
457
476
  /**
458
477
  * Programmatic control client for Prisma Next operations.
@@ -602,23 +621,29 @@ declare function enrichContract(ir: Contract, components: ReadonlyArray<TargetBo
602
621
  //#endregion
603
622
  //#region src/control-api/operations/contract-emit.d.ts
604
623
  /**
605
- * Executes the contract emit operation.
624
+ * Canonical contract emit operation.
606
625
  *
607
- * This is an offline operation that:
608
- * 1. Loads the Prisma Next config from the specified path
609
- * 2. Resolves the contract source from config
610
- * 3. Creates a control plane stack and family instance
611
- * 4. Emits contract artifacts (JSON and DTS)
612
- * 5. Writes files to the paths specified in config
626
+ * This is the SINGLE publication path used by both the CLI command
627
+ * (`prisma-next contract emit`) and the Vite plugin
628
+ * (`@prisma-next/vite-plugin-contract-emit`). New callers must go through this
629
+ * function rather than re-implementing load emit publish.
613
630
  *
614
- * Supports AbortSignal for cancellation, enabling "last change wins" behavior.
631
+ * The whole flow (load config resolve source → emit bytes → atomic publish)
632
+ * is serialized per output JSON path via `queueEmitByOutput`. Concurrent calls
633
+ * for the same output line up FIFO; the user-visible outcome is "last
634
+ * submission wins on disk" without any supersession bookkeeping. Within a
635
+ * single emit, `publishContractArtifactPair` stages temp files, renames
636
+ * `contract.d.ts` before `contract.json`, and attempts to restore the previous
637
+ * pair if either rename fails — so type-only consumers never observe a
638
+ * mismatched pair.
615
639
  *
616
- * @param options - Options including configPath and optional signal
617
- * @returns File paths and hashes of emitted artifacts
618
- * @throws If config loading fails, contract is invalid, or file I/O fails
619
- * @throws signal.reason if cancelled via AbortSignal (typically DOMException with name 'AbortError')
640
+ * @throws {CliStructuredError} on config/source/validation problems
641
+ * @throws {DOMException} `AbortError` if cancelled via `signal`
620
642
  */
621
643
  declare function executeContractEmit(options: ContractEmitOptions): Promise<ContractEmitResult>;
622
644
  //#endregion
623
- export { type ContractEmitOptions, type ContractEmitResult, type ControlActionName, type ControlClient, type ControlClientOptions, type ControlProgressEvent, type ControlStack, type DbInitFailure, type DbInitFailureCode, type DbInitOptions, type DbInitResult, type DbInitSuccess, type DbUpdateFailure, type DbUpdateFailureCode, type DbUpdateOptions, type DbUpdateResult, type DbUpdateSuccess, type EmitContractConfig, type EmitFailure, type EmitFailureCode, type EmitOptions, type EmitResult, type EmitSuccess, type IntrospectOptions, type OnControlProgress, type SchemaVerifyOptions, type SignDatabaseResult, type SignOptions, type VerifyDatabaseResult, type VerifyDatabaseSchemaResult, type VerifyOptions, createControlClient, enrichContract, executeContractEmit };
645
+ //#region src/utils/emit-queue.d.ts
646
+ declare function disposeEmitQueue(outputJsonPath: string): void;
647
+ //#endregion
648
+ export { type ContractEmitOptions, type ContractEmitResult, type ControlActionName, type ControlClient, type ControlClientOptions, type ControlProgressEvent, type ControlStack, type DbInitFailure, type DbInitFailureCode, type DbInitOptions, type DbInitResult, type DbInitSuccess, type DbUpdateFailure, type DbUpdateFailureCode, type DbUpdateOptions, type DbUpdateResult, type DbUpdateSuccess, type EmitContractConfig, type EmitFailure, type EmitFailureCode, type EmitOptions, type EmitResult, type EmitSuccess, type IntrospectOptions, type OnControlProgress, type SchemaVerifyOptions, type SignDatabaseResult, type SignOptions, type VerifyDatabaseResult, type VerifyDatabaseSchemaResult, type VerifyOptions, createControlClient, disposeEmitQueue, enrichContract, executeContractEmit };
624
649
  //# sourceMappingURL=control-api.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"control-api.d.mts","names":[],"sources":["../../src/control-api/types.ts","../../src/control-api/client.ts","../../src/control-api/contract-enrichment.ts","../../src/control-api/operations/contract-emit.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;AAmCA;;;;;;;;AA2BY,UA3BK,oBAAA,CA2BY;EAuBjB,SAAA,MAAA,EAhDO,uBAkDI,CAAA,GAAA,EAAA,GAAA,CAAA;EAkBX,SAAA,MAAA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;iBACA;;;iBAGA;;;;;KAML,oBAAA,GAAuB,OAAO,uBAAuB;;;;;;UAWhD,mBAAA;;;;oBAIG;;;;;UAMH,kBAAA;;;;;;;;;;;;;;;;;;;;;;;;;UA8BA,aAAA;;;;;;;;;;;;;;;;;;;;iCAqBgB;;;;;;WAOtB;;;;;;;;kBASO,gBAAgB,QAAQ;;;;;;;;wBASlB,sBAAsB,QAAQ;;;;;;;;;gBAUtC,cAAc,QAAQ;;;;;;;;;kBAUpB,gBAAgB,QAAQ;;;;;;;;;;oBAWtB,kBAAkB,QAAQ;;;;;;;gBAQ9B,QAAQ;;;;;;;;;;;;0BAaE,wBAAwB,QAAQ;;;;;;;uBAQnC,oBAAoB;;;;;;;;mCASR;;;;;;;;gBASnB,cAAc,QAAQ;;;;;;;;;;AAtoBtC;;;;AASoB,iBCUJ,mBAAA,CDVI,OAAA,ECUyB,oBDVzB,CAAA,ECUgD,aDVhD;;;;;;;;AATH,iBEsDD,cAAA,CFtDqB,EAAA,EEuD/B,QFvD+B,EAAA,UAAA,EEwDvB,aFxDuB,CEwDT,8BFxDS,CAAA,MAAA,EAAA,MAAA,CAAA,CAAA,CAAA,EEyDlC,QFzDkC;;;;;;;;;AAArC;;;;;;;;AA2BA;AAuBA;AAoBA;AASiB,iBGhEK,mBAAA,CH0EE,OAAiB,EGzE9B,mBHyE8B,CAAA,EGxEtC,OHwEsC,CGxE9B,kBHwE8B,CAAA"}
1
+ {"version":3,"file":"control-api.d.mts","names":[],"sources":["../../src/control-api/types.ts","../../src/control-api/client.ts","../../src/control-api/contract-enrichment.ts","../../src/control-api/operations/contract-emit.ts","../../src/utils/emit-queue.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;AAmCA;;;;;;;;AA2BY,UA3BK,oBAAA,CA2BY;EAuBjB,SAAA,MAAA,EAhDO,uBAkDI,CAAA,GAAA,EAAA,GAAA,CAAA;EAkBX,SAAA,MAAA,EAlEO,uBAkEqB,CAAA,GAAA,EAAA,GAAA,EAAA,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AO,uBAAuB;;;;;;;;;;;;;UAkBhD,mBAAA;;;;oBAIG;;wBAEI;;;;;;;;;UAUP,kBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAoCA,aAAA;;;;;;;;;;;;;;;;;;;;iCAqBgB;;;;;;WAOtB;;;;;;;;kBASO,gBAAgB,QAAQ;;;;;;;;wBASlB,sBAAsB,QAAQ;;;;;;;;;gBAUtC,cAAc,QAAQ;;;;;;;;;kBAUpB,gBAAgB,QAAQ;;;;;;;;;;oBAWtB,kBAAkB,QAAQ;;;;;;;gBAQ9B,QAAQ;;;;;;;;;;;;0BAaE,wBAAwB,QAAQ;;;;;;;uBAQnC,oBAAoB;;;;;;;;mCASR;;;;;;;;gBASnB,cAAc,QAAQ;;;;;;;;;;AAzpBtC;;;;AASoB,iBCUJ,mBAAA,CDVI,OAAA,ECUyB,oBDVzB,CAAA,ECUgD,aDVhD;;;;;;;;AATH,iBEsDD,cAAA,CFtDqB,EAAA,EEuD/B,QFvD+B,EAAA,UAAA,EEwDvB,aFxDuB,CEwDT,8BFxDS,CAAA,MAAA,EAAA,MAAA,CAAA,CAAA,CAAA,EEyDlC,QFzDkC;;;;;;;;;AAArC;;;;;;;;AA2BA;AAuBA;AAoBA;AASA;AAgBA;AAsBA;AAwBiB,iBGzBK,mBAAA,CHyCE,OAAiB,EGxC9B,mBHwC8B,CAAA,EGvCtC,OHuCsC,CGvC9B,kBHuC8B,CAAA;;;iBIzKzB,gBAAA"}
@@ -1,8 +1,6 @@
1
- import "../config-loader-C25b63rJ.mjs";
2
- import "../cli-errors-By1iVE3z.mjs";
3
- import "../framework-components-C6el-5x_.mjs";
4
- import { t as enrichContract } from "../contract-enrichment-CAOELa-H.mjs";
5
- import { t as createControlClient } from "../client-faKQqcix.mjs";
6
- import { t as executeContractEmit } from "../contract-emit-PeB96eHy.mjs";
1
+ import "../config-loader-ih8ViDb_.mjs";
2
+ import { n as disposeEmitQueue, t as executeContractEmit } from "../contract-emit-RZBWzkop.mjs";
3
+ import { t as enrichContract } from "../contract-enrichment-4Ptgw3Pe.mjs";
4
+ import { t as createControlClient } from "../client-enZIahga.mjs";
7
5
 
8
- export { createControlClient, enrichContract, executeContractEmit };
6
+ export { createControlClient, disposeEmitQueue, enrichContract, executeContractEmit };
@@ -1,12 +1,7 @@
1
- import "../config-loader-C25b63rJ.mjs";
2
- import "../cli-errors-By1iVE3z.mjs";
3
- import "../framework-components-C6el-5x_.mjs";
4
- import "../client-faKQqcix.mjs";
5
- import "../terminal-ui-C3ZLwQxK.mjs";
6
- import "../result-handler-CuhZ3kNu.mjs";
7
- import { t as createContractEmitCommand } from "../contract-emit-Cf3fjDL6.mjs";
8
- import { existsSync, unlinkSync, writeFileSync } from "node:fs";
1
+ import "../config-loader-ih8ViDb_.mjs";
2
+ import { t as createContractEmitCommand } from "../contract-emit-DWtGQYCD.mjs";
9
3
  import { join } from "pathe";
4
+ import { existsSync, unlinkSync, writeFileSync } from "node:fs";
10
5
  import { tmpdir } from "node:os";
11
6
  import { pathToFileURL } from "node:url";
12
7
  import { build } from "esbuild";