@prisma/orm-toolchain 8.0.0-rc.11-dev.51 → 8.0.0-rc.11-dev.53

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 (35) hide show
  1. package/dist/cli.mjs +1476 -269
  2. package/dist/cli.mjs.map +1 -1
  3. package/dist/cli__control-api.d.mts +17 -2
  4. package/dist/cli__control-api.d.mts.map +1 -1
  5. package/dist/cli__control-api.mjs +2 -2
  6. package/dist/cli__init-output.d.mts +11 -1
  7. package/dist/cli__init-output.d.mts.map +1 -1
  8. package/dist/cli__init-output.mjs +1 -1
  9. package/dist/cli__migration-cli.mjs +1 -1
  10. package/dist/config-loader.d.mts +2 -2
  11. package/dist/config-loader.mjs +2 -2
  12. package/dist/{exports-uepvbfMs.mjs → exports-BiGALu6k.mjs} +2 -2
  13. package/dist/{exports-uepvbfMs.mjs.map → exports-BiGALu6k.mjs.map} +1 -1
  14. package/dist/{exports-DJ4RhlW4.mjs → exports-ClG6amXs.mjs} +49 -13
  15. package/dist/exports-ClG6amXs.mjs.map +1 -0
  16. package/dist/{import-roots-CYGb9VeC.mjs → import-roots-CYpOz1XZ.mjs} +2 -2
  17. package/dist/{import-roots-CYGb9VeC.mjs.map → import-roots-CYpOz1XZ.mjs.map} +1 -1
  18. package/dist/{index-u5RdrumF.d.mts → index-CjMp0WzN.d.mts} +27 -2
  19. package/dist/index-CjMp0WzN.d.mts.map +1 -0
  20. package/dist/output-BcC8eB0h-C5bRd-aC.mjs +129 -0
  21. package/dist/output-BcC8eB0h-C5bRd-aC.mjs.map +1 -0
  22. package/dist/publish-surface.mjs +2 -2
  23. package/dist/publish-surface__import-roots.mjs +1 -1
  24. package/dist/publish-surface__shells.mjs +1 -1
  25. package/dist/quick-reference-prisma7.md +80 -0
  26. package/dist/{ref-g7LrevBG-DgO9ywms.mjs → ref-DL4C2p9T-B6EVNIhl.mjs} +83 -35
  27. package/dist/{ref-g7LrevBG-DgO9ywms.mjs.map → ref-DL4C2p9T-B6EVNIhl.mjs.map} +1 -1
  28. package/dist/{shells-C_vvtity.mjs → shells-DQaV4Fdt.mjs} +2 -1
  29. package/dist/{shells-C_vvtity.mjs.map → shells-DQaV4Fdt.mjs.map} +1 -1
  30. package/dist/vite-plugin-contract-emit.mjs +2 -2
  31. package/package.json +12 -12
  32. package/dist/exports-DJ4RhlW4.mjs.map +0 -1
  33. package/dist/index-u5RdrumF.d.mts.map +0 -1
  34. package/dist/output-D83nTTpC-XlvN30yS.mjs +0 -77
  35. package/dist/output-D83nTTpC-XlvN30yS.mjs.map +0 -1
@@ -11,7 +11,7 @@ import { d as writeRef, i as readRefs, l as validateRefName, n as deleteRef, o a
11
11
  import { a as isValidSpaceId, c as spaceMigrationDirectory, l as spaceRefsDirectory, o as listContractSpaceDirectories, s as readContractSpaceHeadRef, t as APP_SPACE_ID$1 } from "./verify-contract-spaces-BLkC9r9l-CJIppNL8.mjs";
12
12
  import { d as resolveRecordedPath, f as verifyMigration, l as planMigration, n as buildFabricatedMigrationEdge, r as collectAggregateNamespaces, s as loadContractSpaceAggregate, t as allStorageElementsExternal, u as requireHeadRef } from "./aggregate-D1pUq5oA.mjs";
13
13
  import { i as emitContractSpaceArtifacts, o as planAllSpaces } from "./spaces-Bk9Q5fMp.mjs";
14
- import { c as internalImportRoot, o as importRootForDependencies, r as createImportSpecifierResolver, t as ImportRootError } from "./import-roots-CYGb9VeC.mjs";
14
+ import { c as internalImportRoot, o as importRootForDependencies, r as createImportSpecifierResolver, t as ImportRootError } from "./import-roots-CYpOz1XZ.mjs";
15
15
  import { n as parseContractRef, r as parseMigrationRef } from "./ref-resolution-BwWLoU7C.mjs";
16
16
  import { i as writeMigrationTs } from "./migration-ts-DdVm0rws.mjs";
17
17
  import { createRequire } from "node:module";
@@ -33,7 +33,7 @@ import { canonicalizeJson } from "@prisma/orm-framework/components/utils";
33
33
  import { mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
34
34
  import { abortable } from "@prisma/orm-framework/utils/abortable";
35
35
  import { resolve as resolve$1 } from "node:path";
36
- //#region ../../../1-framework/3-tooling/cli/dist/ref-g7LrevBG.mjs
36
+ //#region ../../../1-framework/3-tooling/cli/dist/ref-DL4C2p9T.mjs
37
37
  /**
38
38
  * The typed remediation the CLI attaches to its own errors and findings.
39
39
  * Constructors live here rather than in any library the CLI calls: naming a
@@ -2910,6 +2910,17 @@ function formatLocation({ sourceId, line, character }) {
2910
2910
  if (sourceId === void 0) return void 0;
2911
2911
  return line !== void 0 && character !== void 0 ? `${sourceId}:${line}:${character}` : sourceId;
2912
2912
  }
2913
+ /** One source diagnostic as a line of text: `<sourceId>:<line>:<column> <code> <message>`. */
2914
+ function formatSourceDiagnostic(raw) {
2915
+ if (!isRecord(raw)) return String(raw);
2916
+ const code = typeof raw["code"] === "string" ? raw["code"] : "diagnostic";
2917
+ const message = typeof raw["message"] === "string" ? raw["message"] : "";
2918
+ return [
2919
+ formatLocation(diagnosticLocation(raw)),
2920
+ code,
2921
+ message
2922
+ ].filter((part) => part !== void 0 && part !== "").join(" ");
2923
+ }
2913
2924
  /**
2914
2925
  * The finding the CLI prints under the error, one per source diagnostic. The
2915
2926
  * terminal renderer prints a finding's code and summary and nothing of its
@@ -2969,36 +2980,86 @@ function mapDiagnosticsToIssues(diagnostics) {
2969
2980
  }
2970
2981
  function validateProviderResult(providerResult) {
2971
2982
  if (!isRecord(providerResult) || typeof providerResult["ok"] !== "boolean") return {
2972
- ok: false,
2983
+ kind: "malformed",
2973
2984
  error: failedToResolveContractSource("Contract source provider returned malformed result shape.", "Ensure contract.source.load resolves to ok(Contract) or notOk({ summary, diagnostics }).")
2974
2985
  };
2975
2986
  if (providerResult["ok"]) {
2976
2987
  if (!("value" in providerResult)) return {
2977
- ok: false,
2988
+ kind: "malformed",
2978
2989
  error: failedToResolveContractSource("Contract source provider returned malformed success result: missing value.", "Ensure contract.source.load success payload is ok(Contract).")
2979
2990
  };
2980
2991
  return {
2981
- ok: true,
2992
+ kind: "ok",
2982
2993
  value: providerResult["value"]
2983
2994
  };
2984
2995
  }
2985
2996
  const failure = providerResult["failure"];
2986
2997
  if (!isRecord(failure) || typeof failure["summary"] !== "string" || !Array.isArray(failure["diagnostics"])) return {
2987
- ok: false,
2998
+ kind: "malformed",
2988
2999
  error: failedToResolveContractSource("Contract source provider returned malformed failure result: expected summary and diagnostics.", "Ensure contract.source.load failure payload is notOk({ summary, diagnostics, meta? }).")
2989
3000
  };
2990
3001
  if (failure["diagnostics"].some((diagnostic) => !isRecord(diagnostic) || typeof diagnostic["sourceId"] !== "string")) return {
2991
- ok: false,
3002
+ kind: "malformed",
2992
3003
  error: failedToResolveContractSource("Contract source provider returned malformed failure result: each diagnostic must include a string sourceId.", "Include the source filename in each diagnostic returned by contract.source.load.")
2993
3004
  };
2994
3005
  return {
2995
- ok: false,
2996
- error: failedToResolveContractSource(String(failure["summary"]), "Edit the schema where each finding points, then run contract emit again.", {
3006
+ kind: "failed",
3007
+ failure: {
3008
+ summary: failure["summary"],
2997
3009
  diagnostics: failure["diagnostics"],
2998
- issues: mapDiagnosticsToIssues(failure["diagnostics"]),
2999
- ...ifDefined("providerMeta", failure["meta"])
3000
- }, void 0, sourceDiagnosticsToFindings(failure["diagnostics"]))
3010
+ meta: failure["meta"]
3011
+ }
3012
+ };
3013
+ }
3014
+ function sourceFailureError(failure) {
3015
+ return failedToResolveContractSource(failure.summary, "Edit the schema where each finding points, then run contract emit again.", {
3016
+ diagnostics: failure.diagnostics,
3017
+ issues: mapDiagnosticsToIssues(failure.diagnostics),
3018
+ ...ifDefined("providerMeta", failure.meta)
3019
+ }, void 0, sourceDiagnosticsToFindings(failure.diagnostics));
3020
+ }
3021
+ function requireContractConfig(config) {
3022
+ if (!config.contract) throw errorContractConfigMissing({ why: "Config.contract is required for emit. Define it in your config: contract: { source: ..., output: ... }" });
3023
+ return config.contract;
3024
+ }
3025
+ function requireSourceProvider(contractConfig) {
3026
+ if (typeof contractConfig.source?.load !== "function") throw errorContractConfigMissing({ why: "Contract config must include a valid source provider object" });
3027
+ }
3028
+ async function resolveContractSource(contractConfig, stack, signal) {
3029
+ const sourceContext = {
3030
+ composedExtensions: stack.extensions.map((p) => p.id),
3031
+ composedExtensionContracts: stack.extensionContracts,
3032
+ authoringContributions: stack.authoringContributions,
3033
+ codecLookup: stack.codecLookup,
3034
+ controlMutationDefaults: stack.controlMutationDefaults,
3035
+ dataTypeLookup: stack.dataTypeLookup,
3036
+ resolvedInputs: contractConfig.source.inputs ?? [],
3037
+ capabilities: stack.capabilities
3001
3038
  };
3039
+ let providerResult;
3040
+ try {
3041
+ providerResult = await abortable(signal)(contractConfig.source.load(sourceContext));
3042
+ } catch (error) {
3043
+ if (signal.aborted || isRecord(error) && error["name"] === "AbortError") throw error;
3044
+ throw failedToResolveContractSource(error instanceof Error ? error.message : String(error), "Ensure contract.source.load resolves to ok(Contract) or returns structured diagnostics.", void 0, error);
3045
+ }
3046
+ const validated = validateProviderResult(providerResult);
3047
+ switch (validated.kind) {
3048
+ case "malformed": throw validated.error;
3049
+ case "failed": return notOk(validated.failure);
3050
+ case "ok": return ok(validated.value);
3051
+ }
3052
+ }
3053
+ /**
3054
+ * Runs the config's contract source the way `executeContractEmit` does and
3055
+ * stops there: nothing is emitted or written. A source that reports
3056
+ * diagnostics is a `notOk`; a malformed or throwing source raises the same
3057
+ * error emit raises.
3058
+ */
3059
+ async function loadContractSource(config, options = {}) {
3060
+ const contractConfig = requireContractConfig(config);
3061
+ requireSourceProvider(contractConfig);
3062
+ return resolveContractSource(contractConfig, createControlStack(config), options.signal ?? new AbortController().signal);
3002
3063
  }
3003
3064
  /**
3004
3065
  * Canonical contract emit operation.
@@ -3023,11 +3084,10 @@ function validateProviderResult(providerResult) {
3023
3084
  async function executeContractEmit(options, dependencies = defaultContractEmitDependencies) {
3024
3085
  const { config, configPath, outputPath, signal = new AbortController().signal, onProgress } = options;
3025
3086
  const unlessAborted = abortable(signal);
3026
- if (!config.contract) throw errorContractConfigMissing({ why: "Config.contract is required for emit. Define it in your config: contract: { source: ..., output: ... }" });
3027
- const contractConfig = config.contract;
3087
+ const contractConfig = requireContractConfig(config);
3028
3088
  const effectiveOutput = outputPath !== void 0 ? join(outputPath, "contract.json") : contractConfig.output;
3029
3089
  if (!effectiveOutput) throw errorContractConfigMissing({ why: "Contract config must have output path. This should not happen if defineConfig() was used." });
3030
- if (typeof contractConfig.source?.load !== "function") throw errorContractConfigMissing({ why: "Contract config must include a valid source provider object" });
3090
+ requireSourceProvider(contractConfig);
3031
3091
  let outputPaths;
3032
3092
  try {
3033
3093
  outputPaths = getEmittedArtifactPaths(effectiveOutput);
@@ -3037,29 +3097,17 @@ async function executeContractEmit(options, dependencies = defaultContractEmitDe
3037
3097
  const { jsonPath: outputJsonPath, dtsPath: outputDtsPath } = outputPaths;
3038
3098
  return queueEmitByOutput(outputJsonPath, async () => {
3039
3099
  const stack = createControlStack(config);
3040
- const sourceContext = {
3041
- composedExtensions: stack.extensions.map((p) => p.id),
3042
- composedExtensionContracts: stack.extensionContracts,
3043
- authoringContributions: stack.authoringContributions,
3044
- codecLookup: stack.codecLookup,
3045
- controlMutationDefaults: stack.controlMutationDefaults,
3046
- dataTypeLookup: stack.dataTypeLookup,
3047
- resolvedInputs: contractConfig.source.inputs ?? [],
3048
- capabilities: stack.capabilities
3049
- };
3050
3100
  startSpan(onProgress, "resolveSource", "Resolving contract source...");
3051
- let providerResult;
3101
+ let resolved;
3052
3102
  try {
3053
- providerResult = await unlessAborted(contractConfig.source.load(sourceContext));
3103
+ resolved = await resolveContractSource(contractConfig, stack, signal);
3054
3104
  } catch (error) {
3055
3105
  endSpan(onProgress, "resolveSource", "error");
3056
- if (signal.aborted || isRecord(error) && error["name"] === "AbortError") throw error;
3057
- throw failedToResolveContractSource(error instanceof Error ? error.message : String(error), "Ensure contract.source.load resolves to ok(Contract) or returns structured diagnostics.", void 0, error);
3106
+ throw error;
3058
3107
  }
3059
- const validatedContract = validateProviderResult(providerResult);
3060
- if (!validatedContract.ok) {
3108
+ if (!resolved.ok) {
3061
3109
  endSpan(onProgress, "resolveSource", "error");
3062
- throw validatedContract.error;
3110
+ throw sourceFailureError(resolved.failure);
3063
3111
  }
3064
3112
  endSpan(onProgress, "resolveSource", "ok");
3065
3113
  startSpan(onProgress, "emit", "Emitting contract...");
@@ -3072,7 +3120,7 @@ async function executeContractEmit(options, dependencies = defaultContractEmitDe
3072
3120
  ...config.extensions ?? []
3073
3121
  ];
3074
3122
  const frameworkComponents = assertFrameworkComponentsCompatible(config.family.familyId, config.target.targetId, rawComponents);
3075
- const enrichedIR = enrichContract(blindCast(validatedContract.value), frameworkComponents);
3123
+ const enrichedIR = enrichContract(blindCast(resolved.value), frameworkComponents);
3076
3124
  const rawContractJson = config.target.contractSerializer.serializeContract(enrichedIR);
3077
3125
  const deserializedContract = familyInstance.deserializeContract(rawContractJson);
3078
3126
  const { contractSerializer } = config.target;
@@ -5023,6 +5071,6 @@ async function executeRefListCommand(options) {
5023
5071
  }
5024
5072
  }
5025
5073
  //#endregion
5026
- export { hasMigrationPath as $, errorLegendHumanOnly as A, runMigrationList as At, errorUnexpected as B, errorContractArgConflict as C, resolveContractRefToSnapshot as Ct, errorDriverRequired as D, runCommandAction as Dt, errorDestructiveChanges as E, resolveToForPlan as Et, errorPathUnreachable as F, toDeclaredExtensionsFromRaw as Ft, executeMigrateShowPlan as G, executeDbInit as H, errorRunnerFailed as I, executeRefAdvancement as J, executeMigrationNewCommand as K, errorRuntime as L, errorMigrationPackageNotFound as M, snapshotVerifierFor as Mt, errorMigrationPlanningFailed as N, statusForMigrationHash as Nt, errorFileNotFound as O, runContractSpaceSeedPhase as Ot, errorNoMigrations as P, targetSupportsMigrations as Pt, findPackageByDirPath as Q, errorTargetMigrationNotSupported as R, errorConsentPlanMismatch as S, resolveContractRef$1 as St, errorDatabaseConnectionRequired as T, resolveMigrationRef as Tt, executeDbUpdate as U, executeContractEmit as V, executeDbVerify as W, executeRefListCommand as X, executeRefDeleteCommand as Y, executeRefSetCommand as Z, disposeEmitQueue as _, refuseMissingInvariantPath as _t, appContractStandInFromIdentity as a, mapCaughtMigrationError as at, errorAdvanceRefArgConflict as b, requireLiveDatabase as bt, buildMigrationSpaceGraphEntries as c, maskConnectionUrl as ct, checkSingleTarget as d, preflightRefAdvancement as dt, listRefsByContractHash as et, chooseAction as f, readContractEnvelope as ft, deriveStatusEdgeAnnotations as g, refuseMarkerOutsideGraph as gt, createControlClient as h, refuseDeclaredExtensionTargetMismatch as ht, advanceRefSafely as i, looksLikePath as it, errorMarkerMissing as j, sanitizeErrorMessage as jt, errorHashMismatch as k, runMigrationCheck as kt, buildReadAggregate as l, migrationSpaceListEntriesFromAggregate as lt, computeRefAdvancementName as m, refuseContractSpaceIntegrity as mt, ERROR_CODE_DESTRUCTIVE_CHANGES as n, loadContractRawSafely as nt, appliedHashesFromLedger as o, mapContractAtError as ot, closeQuietly as p, readMigrationRefs as pt, executeMigrationPlanCommand as q, NO_REF_ADVANCEMENT as r, loadContractSpaceAggregateForCli as rt, buildContractSpaceAggregate as s, mapIntegrityViolations as st, CliStructuredError$1 as t, loadAggregateIntegrityViolations as tt, buildRefAdvancementFields as u, originHashForStatus as ut, enrichContract as v, refusePackageCorruptionOnAggregate as vt, errorContractValidationFailed as w, resolveFromForPlan as wt, errorConfigValidation$1 as x, resolveAppTargetPath as xt, enumerateCheckSpaces as y, refuseUnknownInvariants as yt, errorTargetMismatch as z };
5074
+ export { formatSourceDiagnostic as $, errorLegendHumanOnly as A, runContractSpaceSeedPhase as At, errorUnexpected as B, errorContractArgConflict as C, resolveAppTargetPath as Ct, errorDriverRequired as D, resolveMigrationRef as Dt, errorDestructiveChanges as E, resolveFromForPlan as Et, errorPathUnreachable as F, statusForMigrationHash as Ft, executeMigrateShowPlan as G, executeDbInit as H, errorRunnerFailed as I, targetSupportsMigrations as It, executeRefAdvancement as J, executeMigrationNewCommand as K, errorRuntime as L, toDeclaredExtensionsFromRaw as Lt, errorMigrationPackageNotFound as M, runMigrationList as Mt, errorMigrationPlanningFailed as N, sanitizeErrorMessage as Nt, errorFileNotFound as O, resolveToForPlan as Ot, errorNoMigrations as P, snapshotVerifierFor as Pt, findPackageByDirPath as Q, errorTargetMigrationNotSupported as R, errorConsentPlanMismatch as S, requireLiveDatabase as St, errorDatabaseConnectionRequired as T, resolveContractRefToSnapshot as Tt, executeDbUpdate as U, executeContractEmit as V, executeDbVerify as W, executeRefListCommand as X, executeRefDeleteCommand as Y, executeRefSetCommand as Z, disposeEmitQueue as _, refuseDeclaredExtensionTargetMismatch as _t, appContractStandInFromIdentity as a, loadContractSpaceAggregateForCli as at, errorAdvanceRefArgConflict as b, refusePackageCorruptionOnAggregate as bt, buildMigrationSpaceGraphEntries as c, mapContractAtError as ct, checkSingleTarget as d, migrationSpaceListEntriesFromAggregate as dt, hasMigrationPath as et, chooseAction as f, originHashForStatus as ft, deriveStatusEdgeAnnotations as g, refuseContractSpaceIntegrity as gt, createControlClient as h, readMigrationRefs as ht, advanceRefSafely as i, loadContractSource as it, errorMarkerMissing as j, runMigrationCheck as jt, errorHashMismatch as k, runCommandAction as kt, buildReadAggregate as l, mapIntegrityViolations as lt, computeRefAdvancementName as m, readContractEnvelope as mt, ERROR_CODE_DESTRUCTIVE_CHANGES as n, loadAggregateIntegrityViolations as nt, appliedHashesFromLedger as o, looksLikePath as ot, closeQuietly as p, preflightRefAdvancement as pt, executeMigrationPlanCommand as q, NO_REF_ADVANCEMENT as r, loadContractRawSafely as rt, buildContractSpaceAggregate as s, mapCaughtMigrationError as st, CliStructuredError$1 as t, listRefsByContractHash as tt, buildRefAdvancementFields as u, maskConnectionUrl as ut, enrichContract as v, refuseMarkerOutsideGraph as vt, errorContractValidationFailed as w, resolveContractRef$1 as wt, errorConfigValidation$1 as x, refuseUnknownInvariants as xt, enumerateCheckSpaces as y, refuseMissingInvariantPath as yt, errorTargetMismatch as z };
5027
5075
 
5028
- //# sourceMappingURL=ref-g7LrevBG-DgO9ywms.mjs.map
5076
+ //# sourceMappingURL=ref-DL4C2p9T-B6EVNIhl.mjs.map