@prisma/orm-toolchain 8.0.0-rc.12-dev.13 → 8.0.0-rc.12-dev.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{aggregate-CZyUi3Gt.mjs → aggregate-BsI5y36e.mjs} +9 -9
- package/dist/{aggregate-CZyUi3Gt.mjs.map → aggregate-BsI5y36e.mjs.map} +1 -1
- package/dist/{aggregate-DwZNs0oH.d.mts → aggregate-C_e9y2vI.d.mts} +2 -2
- package/dist/{aggregate-DwZNs0oH.d.mts.map → aggregate-C_e9y2vI.d.mts.map} +1 -1
- package/dist/cli-telemetry.mjs +3 -3
- package/dist/cli.d.mts +2 -2
- package/dist/cli.mjs +377 -48
- package/dist/cli.mjs.map +1 -1
- package/dist/cli__control-api.d.mts +25 -21
- package/dist/cli__control-api.d.mts.map +1 -1
- package/dist/cli__control-api.mjs +1 -1
- package/dist/cli__control-api__testing.d.mts +2 -2
- package/dist/cli__control-api__testing.mjs +1 -1
- package/dist/cli__migration-cli.mjs +5 -5
- package/dist/cli__migration-cli.mjs.map +1 -1
- package/dist/config-loader.d.mts +2 -2
- package/dist/config-loader.mjs +2 -2
- package/dist/{contract-snapshot-store-1S_6vaGt-mzFobPtq.mjs → contract-snapshot-store-1S_6vaGt-FrXDiBEd.mjs} +4 -4
- package/dist/{contract-snapshot-store-1S_6vaGt-mzFobPtq.mjs.map → contract-snapshot-store-1S_6vaGt-FrXDiBEd.mjs.map} +1 -1
- package/dist/{db-verify-D4Y9yGyX-Df6oIwYg.d.mts → db-verify-DoVihHM8-QNzdRseL.d.mts} +4 -4
- package/dist/{db-verify-D4Y9yGyX-Df6oIwYg.d.mts.map → db-verify-DoVihHM8-QNzdRseL.d.mts.map} +1 -1
- package/dist/emitter.mjs +1 -1
- package/dist/{errors-DD6iLGXk-B4Q4tIha.mjs → errors-DD6iLGXk-6I9PqjpZ.mjs} +2 -2
- package/dist/{errors-DD6iLGXk-B4Q4tIha.mjs.map → errors-DD6iLGXk-6I9PqjpZ.mjs.map} +1 -1
- package/dist/{exports-4SvYVqSf.mjs → exports-BB9aU4zk.mjs} +4 -4
- package/dist/{exports-4SvYVqSf.mjs.map → exports-BB9aU4zk.mjs.map} +1 -1
- package/dist/{exports-DI1kMms6--e9LdT9A.mjs → exports-Bx-2JeW0-BHlN6Av7.mjs} +4 -3
- package/dist/exports-Bx-2JeW0-BHlN6Av7.mjs.map +1 -0
- package/dist/{exports-BOv2LgXz.mjs → exports-C2kyulLb.mjs} +19 -10
- package/dist/exports-C2kyulLb.mjs.map +1 -0
- package/dist/{graph-membership-BQ43lP4A-B8rZC7rC.mjs → graph-membership-BQ43lP4A-i4Ov419-.mjs} +2 -2
- package/dist/{graph-membership-BQ43lP4A-B8rZC7rC.mjs.map → graph-membership-BQ43lP4A-i4Ov419-.mjs.map} +1 -1
- package/dist/{import-roots-CR-pnC1n.mjs → import-roots-BB3GzIi-.mjs} +2 -2
- package/dist/{import-roots-CR-pnC1n.mjs.map → import-roots-BB3GzIi-.mjs.map} +1 -1
- package/dist/{index-D_KaEMoL.d.mts → index-CQm4jQjG.d.mts} +8 -3
- package/dist/index-CQm4jQjG.d.mts.map +1 -0
- package/dist/{invariants-C0lpc60l-MH7CqDAw.mjs → invariants-C0lpc60l-CMUCvk4O.mjs} +2 -2
- package/dist/{invariants-C0lpc60l-MH7CqDAw.mjs.map → invariants-C0lpc60l-CMUCvk4O.mjs.map} +1 -1
- package/dist/{io-xKnQrxIC-D_C_lwGm.mjs → io-xKnQrxIC-BZHUkAeY.mjs} +4 -4
- package/dist/{io-xKnQrxIC-D_C_lwGm.mjs.map → io-xKnQrxIC-BZHUkAeY.mjs.map} +1 -1
- package/dist/{migration-CkACVhgz.mjs → migration-CTBcGs-o.mjs} +4 -4
- package/dist/{migration-CkACVhgz.mjs.map → migration-CTBcGs-o.mjs.map} +1 -1
- package/dist/migration-tools.d.mts +1 -1
- package/dist/migration-tools.mjs +12 -12
- package/dist/migration-tools__aggregate.d.mts +1 -1
- package/dist/migration-tools__aggregate.mjs +1 -1
- package/dist/migration-tools__contract-snapshot-store.mjs +1 -1
- package/dist/migration-tools__errors.mjs +1 -1
- package/dist/migration-tools__invariants.mjs +1 -1
- package/dist/migration-tools__io.mjs +1 -1
- package/dist/migration-tools__migration-graph.mjs +1 -1
- package/dist/migration-tools__migration-ts.mjs +1 -1
- package/dist/migration-tools__migration.mjs +1 -1
- package/dist/migration-tools__ref-resolution.mjs +1 -1
- package/dist/migration-tools__refs.mjs +1 -1
- package/dist/migration-tools__spaces.mjs +2 -2
- package/dist/{migration-ts-FyF55c4M.mjs → migration-ts-DdVm0rws.mjs} +2 -2
- package/dist/{migration-ts-FyF55c4M.mjs.map → migration-ts-DdVm0rws.mjs.map} +1 -1
- package/dist/publish-surface.mjs +2 -2
- package/dist/publish-surface__import-roots.mjs +1 -1
- package/dist/publish-surface__shells.mjs +1 -1
- package/dist/{ref-jhp3BGZM-CI91tliC.mjs → ref-DZuzAvuD-BYpisYJp.mjs} +269 -270
- package/dist/ref-DZuzAvuD-BYpisYJp.mjs.map +1 -0
- package/dist/{ref-resolution-be3JMf5X.mjs → ref-resolution-CyyiVwzz.mjs} +2 -2
- package/dist/{ref-resolution-be3JMf5X.mjs.map → ref-resolution-CyyiVwzz.mjs.map} +1 -1
- package/dist/{refs-qwvw4_dV-Bk9tl756.mjs → refs-qwvw4_dV-DNg_7WTD.mjs} +2 -2
- package/dist/{refs-qwvw4_dV-Bk9tl756.mjs.map → refs-qwvw4_dV-DNg_7WTD.mjs.map} +1 -1
- package/dist/{shells-B05MST_L.mjs → shells-nviMkCdc.mjs} +2 -1
- package/dist/shells-nviMkCdc.mjs.map +1 -0
- package/dist/{spaces-D1-7OKid.mjs → spaces-CcU9rbeZ.mjs} +7 -7
- package/dist/{spaces-D1-7OKid.mjs.map → spaces-CcU9rbeZ.mjs.map} +1 -1
- package/dist/{verify-contract-spaces-CYjc343k-9_2GpPRg.mjs → verify-contract-spaces-CYjc343k-DHy5xtKR.mjs} +4 -4
- package/dist/{verify-contract-spaces-CYjc343k-9_2GpPRg.mjs.map → verify-contract-spaces-CYjc343k-DHy5xtKR.mjs.map} +1 -1
- package/dist/vite-plugin-contract-emit.mjs +3 -3
- package/package.json +12 -12
- package/dist/exports-BOv2LgXz.mjs.map +0 -1
- package/dist/exports-DI1kMms6--e9LdT9A.mjs.map +0 -1
- package/dist/index-D_KaEMoL.d.mts.map +0 -1
- package/dist/ref-jhp3BGZM-CI91tliC.mjs.map +0 -1
- package/dist/shells-B05MST_L.mjs.map +0 -1
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import { i as expandContractInputs } from "./exports-
|
|
2
|
-
import { r as getEmittedArtifactPaths, t as emit } from "./exports-
|
|
3
|
-
import { D as errorNoInvariantPath, M as errorUnknownInvariant, b as errorInvalidRefName, r as errorContractDeserializationFailed, t as MigrationToolsError } from "./errors-DD6iLGXk-
|
|
1
|
+
import { i as expandContractInputs } from "./exports-C2kyulLb.mjs";
|
|
2
|
+
import { r as getEmittedArtifactPaths, t as emit } from "./exports-Bx-2JeW0-BHlN6Av7.mjs";
|
|
3
|
+
import { D as errorNoInvariantPath, M as errorUnknownInvariant, b as errorInvalidRefName, r as errorContractDeserializationFailed, t as MigrationToolsError } from "./errors-DD6iLGXk-6I9PqjpZ.mjs";
|
|
4
4
|
import { r as verifyMigrationHash, t as computeMigrationHash } from "./hash-BAZVWU4a-BdynTmar.mjs";
|
|
5
|
-
import { a as snapshotsImportPathFrom, n as createSnapshotContentVerifier, o as writeContractSnapshot, r as readContractSnapshotJson, t as contractSnapshotDir } from "./contract-snapshot-store-1S_6vaGt-
|
|
6
|
-
import { t as deriveProvidedInvariants } from "./invariants-C0lpc60l-
|
|
7
|
-
import { i as materialiseExtensionMigrationPackageIfMissing, r as formatMigrationDirName, u as writeMigrationPackage } from "./io-xKnQrxIC-
|
|
5
|
+
import { a as snapshotsImportPathFrom, n as createSnapshotContentVerifier, o as writeContractSnapshot, r as readContractSnapshotJson, t as contractSnapshotDir } from "./contract-snapshot-store-1S_6vaGt-FrXDiBEd.mjs";
|
|
6
|
+
import { t as deriveProvidedInvariants } from "./invariants-C0lpc60l-CMUCvk4O.mjs";
|
|
7
|
+
import { i as materialiseExtensionMigrationPackageIfMissing, r as formatMigrationDirName, u as writeMigrationPackage } from "./io-xKnQrxIC-BZHUkAeY.mjs";
|
|
8
8
|
import { t as EMPTY_CONTRACT_HASH } from "./constants-CM-w38DQ-Cz_EXbOc.mjs";
|
|
9
|
-
import { n as isGraphNode, t as assertHashIsGraphNode } from "./graph-membership-BQ43lP4A-
|
|
9
|
+
import { n as isGraphNode, t as assertHashIsGraphNode } from "./graph-membership-BQ43lP4A-i4Ov419-.mjs";
|
|
10
10
|
import { i as findPathWithDecision, r as findPath } from "./migration-graph-BoiiZAaU-DLht12k7.mjs";
|
|
11
|
-
import { d as writeRef, i as readRefs, l as validateRefName, n as deleteRef, o as refsByContractHash, t as HEAD_REF_NAME, u as validateRefValue } from "./refs-qwvw4_dV-
|
|
12
|
-
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-CYjc343k-
|
|
13
|
-
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-
|
|
14
|
-
import { i as emitContractSpaceArtifacts, o as planAllSpaces } from "./spaces-
|
|
15
|
-
import { c as internalImportRoot, o as importRootForDependencies, r as createImportSpecifierResolver, t as ImportRootError } from "./import-roots-
|
|
16
|
-
import { n as parseContractRef, r as parseMigrationRef } from "./ref-resolution-
|
|
17
|
-
import { i as writeMigrationTs } from "./migration-ts-
|
|
11
|
+
import { d as writeRef, i as readRefs, l as validateRefName, n as deleteRef, o as refsByContractHash, t as HEAD_REF_NAME, u as validateRefValue } from "./refs-qwvw4_dV-DNg_7WTD.mjs";
|
|
12
|
+
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-CYjc343k-DHy5xtKR.mjs";
|
|
13
|
+
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-BsI5y36e.mjs";
|
|
14
|
+
import { i as emitContractSpaceArtifacts, o as planAllSpaces } from "./spaces-CcU9rbeZ.mjs";
|
|
15
|
+
import { c as internalImportRoot, o as importRootForDependencies, r as createImportSpecifierResolver, t as ImportRootError } from "./import-roots-BB3GzIi-.mjs";
|
|
16
|
+
import { n as parseContractRef, r as parseMigrationRef } from "./ref-resolution-CyyiVwzz.mjs";
|
|
17
|
+
import { i as writeMigrationTs } from "./migration-ts-DdVm0rws.mjs";
|
|
18
18
|
import { createRequire } from "node:module";
|
|
19
19
|
import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
|
|
20
20
|
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
21
|
-
import { basename, dirname, isAbsolute, join, relative, resolve } from "pathe";
|
|
22
|
-
import { mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
|
|
23
21
|
import { isStructuredErrorCode, structuredError } from "@prisma/orm-framework/utils/structured-error";
|
|
24
22
|
import { keepInternalSpecifiers } from "@prisma/orm-framework/components/emission";
|
|
25
23
|
import { blindCast, castAs } from "@prisma/orm-framework/utils/casts";
|
|
26
24
|
import { InternalError } from "@prisma/orm-framework/utils/internal-error";
|
|
27
25
|
import { CliStructuredError, CliStructuredError as CliStructuredError$1, errorConfigValidation as errorConfigValidation$1, errorContractConfigMissing, errorContractValidationFailed, errorDatabaseConnectionRequired, errorDriverRequired, errorFileNotFound, errorMigrationPlanningFailed, errorTargetMigrationNotSupported, errorUnexpected } from "@prisma/orm-framework/errors/control";
|
|
28
|
-
import { notOk, ok } from "@prisma/orm-framework/utils/result";
|
|
29
26
|
import { APP_SPACE_ID, createControlStack, hasMigrations, hasOperationPreview, hasPslContractInfer, hasSchemaSubjectClassifier, hasSchemaView } from "@prisma/orm-framework/components/control";
|
|
27
|
+
import { notOk, ok } from "@prisma/orm-framework/utils/result";
|
|
30
28
|
import { mergeCapabilityMatrices } from "@prisma/orm-framework/components/components";
|
|
31
29
|
import { ERROR_CODE_DESTRUCTIVE_CHANGES, errorConsentPlanMismatch, errorDestructiveChanges, errorHashMismatch, errorMarkerMissing, errorRunnerFailed, errorRuntime, errorTargetMismatch } from "@prisma/orm-framework/errors/execution";
|
|
32
30
|
import "@prisma/orm-framework/errors/migration";
|
|
31
|
+
import { basename, dirname, isAbsolute, join, relative, resolve } from "pathe";
|
|
33
32
|
import { createHash } from "node:crypto";
|
|
34
33
|
import { canonicalizeJson } from "@prisma/orm-framework/components/utils";
|
|
34
|
+
import { mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
|
|
35
35
|
import { abortable } from "@prisma/orm-framework/utils/abortable";
|
|
36
36
|
import { resolve as resolve$1 } from "node:path";
|
|
37
|
-
//#region ../../../1-framework/3-tooling/cli/dist/ref-
|
|
37
|
+
//#region ../../../1-framework/3-tooling/cli/dist/ref-DZuzAvuD.mjs
|
|
38
38
|
/**
|
|
39
39
|
* The typed remediation the CLI attaches to its own errors and findings.
|
|
40
40
|
* Constructors live here rather than in any library the CLI calls: naming a
|
|
@@ -1770,6 +1770,194 @@ function mapMarkerCheckFailures(appSpaceId, section, migrationsDir) {
|
|
|
1770
1770
|
meta: { violations }
|
|
1771
1771
|
});
|
|
1772
1772
|
}
|
|
1773
|
+
function isRecord$2(value) {
|
|
1774
|
+
return typeof value === "object" && value !== null;
|
|
1775
|
+
}
|
|
1776
|
+
function failedToResolveContractSource(why, fix, meta, cause, diagnostics) {
|
|
1777
|
+
return errorRuntime("CONTRACT.SOURCE_LOAD_FAILED", "Failed to resolve contract source", {
|
|
1778
|
+
why,
|
|
1779
|
+
fix,
|
|
1780
|
+
...ifDefined("diagnostics", diagnostics),
|
|
1781
|
+
...ifDefined("meta", meta),
|
|
1782
|
+
...ifDefined("cause", cause)
|
|
1783
|
+
});
|
|
1784
|
+
}
|
|
1785
|
+
function diagnosticLocation(diagnostic) {
|
|
1786
|
+
const sourceId = typeof diagnostic["sourceId"] === "string" ? diagnostic["sourceId"] : void 0;
|
|
1787
|
+
const span = isRecord$2(diagnostic["span"]) ? diagnostic["span"] : void 0;
|
|
1788
|
+
const start = span && isRecord$2(span["start"]) ? span["start"] : void 0;
|
|
1789
|
+
return {
|
|
1790
|
+
sourceId,
|
|
1791
|
+
line: start && typeof start["line"] === "number" ? start["line"] : void 0,
|
|
1792
|
+
character: start && typeof start["column"] === "number" ? start["column"] : void 0
|
|
1793
|
+
};
|
|
1794
|
+
}
|
|
1795
|
+
function formatLocation({ sourceId, line, character }) {
|
|
1796
|
+
if (sourceId === void 0) return void 0;
|
|
1797
|
+
return line !== void 0 && character !== void 0 ? `${sourceId}:${line}:${character}` : sourceId;
|
|
1798
|
+
}
|
|
1799
|
+
/** One source diagnostic as a line of text: `<sourceId>:<line>:<column> <code> <message>`. */
|
|
1800
|
+
function formatSourceDiagnostic(raw) {
|
|
1801
|
+
if (!isRecord$2(raw)) return String(raw);
|
|
1802
|
+
const code = typeof raw["code"] === "string" ? raw["code"] : "diagnostic";
|
|
1803
|
+
const message = typeof raw["message"] === "string" ? raw["message"] : "";
|
|
1804
|
+
return [
|
|
1805
|
+
formatLocation(diagnosticLocation(raw)),
|
|
1806
|
+
code,
|
|
1807
|
+
message
|
|
1808
|
+
].filter((part) => part !== void 0 && part !== "").join(" ");
|
|
1809
|
+
}
|
|
1810
|
+
/**
|
|
1811
|
+
* The finding the CLI prints under the error, one per source diagnostic. The
|
|
1812
|
+
* terminal renderer prints a finding's code and summary and nothing of its
|
|
1813
|
+
* `where`, so the summary starts with the location. A source code that is not
|
|
1814
|
+
* yet dotted is wrapped as `CONTRACT.SOURCE_DIAGNOSTIC` and named in the summary.
|
|
1815
|
+
*/
|
|
1816
|
+
function sourceDiagnosticToFinding(raw) {
|
|
1817
|
+
if (!isRecord$2(raw)) return void 0;
|
|
1818
|
+
const code = typeof raw["code"] === "string" ? raw["code"] : "diagnostic";
|
|
1819
|
+
const message = typeof raw["message"] === "string" ? raw["message"] : "";
|
|
1820
|
+
const location = diagnosticLocation(raw);
|
|
1821
|
+
const formatted = formatLocation(location);
|
|
1822
|
+
const locatedSummary = (text) => formatted === void 0 ? text : `${formatted} ${text}`;
|
|
1823
|
+
const finding = {
|
|
1824
|
+
severity: "error",
|
|
1825
|
+
nextActions: [],
|
|
1826
|
+
...ifDefined("where", location.sourceId === void 0 ? void 0 : {
|
|
1827
|
+
path: location.sourceId,
|
|
1828
|
+
...ifDefined("line", location.line)
|
|
1829
|
+
})
|
|
1830
|
+
};
|
|
1831
|
+
return isStructuredErrorCode(code) ? {
|
|
1832
|
+
code,
|
|
1833
|
+
summary: locatedSummary(message),
|
|
1834
|
+
...finding
|
|
1835
|
+
} : {
|
|
1836
|
+
code: "CONTRACT.SOURCE_DIAGNOSTIC",
|
|
1837
|
+
summary: locatedSummary(`${code}: ${message}`),
|
|
1838
|
+
...finding,
|
|
1839
|
+
meta: { code }
|
|
1840
|
+
};
|
|
1841
|
+
}
|
|
1842
|
+
function sourceDiagnosticsToFindings(diagnostics) {
|
|
1843
|
+
const findings = [];
|
|
1844
|
+
for (const raw of diagnostics) {
|
|
1845
|
+
const finding = sourceDiagnosticToFinding(raw);
|
|
1846
|
+
if (finding !== void 0) findings.push(finding);
|
|
1847
|
+
}
|
|
1848
|
+
return findings;
|
|
1849
|
+
}
|
|
1850
|
+
function diagnosticLocationSuffix(diagnostic) {
|
|
1851
|
+
const formatted = formatLocation(diagnosticLocation(diagnostic));
|
|
1852
|
+
return formatted === void 0 ? "" : ` (${formatted})`;
|
|
1853
|
+
}
|
|
1854
|
+
function mapDiagnosticsToIssues(diagnostics) {
|
|
1855
|
+
const issues = [];
|
|
1856
|
+
for (const raw of diagnostics) {
|
|
1857
|
+
if (!isRecord$2(raw)) continue;
|
|
1858
|
+
const code = typeof raw["code"] === "string" ? raw["code"] : "diagnostic";
|
|
1859
|
+
const message = typeof raw["message"] === "string" ? raw["message"] : "";
|
|
1860
|
+
issues.push({
|
|
1861
|
+
kind: code,
|
|
1862
|
+
message: `${message}${diagnosticLocationSuffix(raw)}`
|
|
1863
|
+
});
|
|
1864
|
+
}
|
|
1865
|
+
return issues;
|
|
1866
|
+
}
|
|
1867
|
+
function failedWith(error) {
|
|
1868
|
+
return notOk({ error });
|
|
1869
|
+
}
|
|
1870
|
+
/**
|
|
1871
|
+
* Checks the shape of what `load` returned. A source may be plain JavaScript,
|
|
1872
|
+
* so its declared type is not trusted.
|
|
1873
|
+
*/
|
|
1874
|
+
function validateProviderResult(providerResult) {
|
|
1875
|
+
const raw = providerResult;
|
|
1876
|
+
if (!isRecord$2(raw) || typeof raw["ok"] !== "boolean") return failedWith(failedToResolveContractSource("Contract source provider returned malformed result shape.", "Ensure contract.source.load resolves to ok(Contract) or notOk({ summary, diagnostics })."));
|
|
1877
|
+
if (providerResult.ok) {
|
|
1878
|
+
const value = providerResult.value;
|
|
1879
|
+
if (value === void 0 || value === null) return failedWith(failedToResolveContractSource("Contract source provider returned malformed success result: missing value.", "Ensure contract.source.load success payload is ok(Contract)."));
|
|
1880
|
+
return ok(providerResult.value);
|
|
1881
|
+
}
|
|
1882
|
+
const failure = providerResult.failure;
|
|
1883
|
+
if (!isRecord$2(failure) || typeof failure["summary"] !== "string" || !Array.isArray(failure["diagnostics"])) return failedWith(failedToResolveContractSource("Contract source provider returned malformed failure result: expected summary and diagnostics.", "Ensure contract.source.load failure payload is notOk({ summary, diagnostics, meta? })."));
|
|
1884
|
+
if (failure["diagnostics"].some((diagnostic) => !isRecord$2(diagnostic) || typeof diagnostic["sourceId"] !== "string")) return failedWith(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."));
|
|
1885
|
+
return notOk({
|
|
1886
|
+
error: failedToResolveContractSource(failure["summary"], "Edit the source where each finding points, then run the command again.", {
|
|
1887
|
+
diagnostics: failure["diagnostics"],
|
|
1888
|
+
issues: mapDiagnosticsToIssues(failure["diagnostics"]),
|
|
1889
|
+
...ifDefined("providerMeta", failure["meta"])
|
|
1890
|
+
}, void 0, sourceDiagnosticsToFindings(failure["diagnostics"])),
|
|
1891
|
+
sourceDiagnostics: providerResult.failure
|
|
1892
|
+
});
|
|
1893
|
+
}
|
|
1894
|
+
/**
|
|
1895
|
+
* Asks the configured contract source for the contract, with a source context
|
|
1896
|
+
* built from `stack`, and turns every failure into `CONTRACT.SOURCE_LOAD_FAILED`.
|
|
1897
|
+
* Every command that loads a contract source goes through here, so each
|
|
1898
|
+
* reports a bad source the same way.
|
|
1899
|
+
*
|
|
1900
|
+
* @throws {DOMException} `AbortError` if cancelled via `signal`
|
|
1901
|
+
*/
|
|
1902
|
+
async function loadContractSourceWithStack(inputs) {
|
|
1903
|
+
const { stack, source } = inputs;
|
|
1904
|
+
const signal = inputs.signal ?? new AbortController().signal;
|
|
1905
|
+
const unlessAborted = abortable(signal);
|
|
1906
|
+
const sourceContext = {
|
|
1907
|
+
...ifDefined("reportWarning", inputs.reportWarning),
|
|
1908
|
+
composedExtensions: stack.extensions.map((p) => p.id),
|
|
1909
|
+
composedExtensionContracts: stack.extensionContracts,
|
|
1910
|
+
authoringContributions: stack.authoringContributions,
|
|
1911
|
+
codecLookup: stack.codecLookup,
|
|
1912
|
+
controlMutationDefaults: stack.controlMutationDefaults,
|
|
1913
|
+
dataTypeLookup: stack.dataTypeLookup,
|
|
1914
|
+
resolvedInputs: await unlessAborted(expandContractInputs(source.inputs)),
|
|
1915
|
+
capabilities: stack.capabilities
|
|
1916
|
+
};
|
|
1917
|
+
let providerResult;
|
|
1918
|
+
try {
|
|
1919
|
+
providerResult = await unlessAborted(source.load(sourceContext));
|
|
1920
|
+
} catch (error) {
|
|
1921
|
+
if (signal.aborted || isRecord$2(error) && error["name"] === "AbortError") throw error;
|
|
1922
|
+
return failedWith(failedToResolveContractSource(error instanceof Error ? error.message : String(error), "Ensure contract.source.load resolves to ok(Contract) or returns structured diagnostics.", void 0, error));
|
|
1923
|
+
}
|
|
1924
|
+
return validateProviderResult(providerResult);
|
|
1925
|
+
}
|
|
1926
|
+
/** @throws {CliStructuredError} `CONFIG.CONTRACT_MISSING` when the config has no contract section */
|
|
1927
|
+
function requireContractConfig(config) {
|
|
1928
|
+
if (!config.contract) throw errorContractConfigMissing({ why: "Config.contract is required for emit. Define it in your config: contract: { source: ..., output: ... }" });
|
|
1929
|
+
return config.contract;
|
|
1930
|
+
}
|
|
1931
|
+
/** @throws {CliStructuredError} `CONFIG.CONTRACT_MISSING` when the contract source has no `load` function */
|
|
1932
|
+
function requireSourceProvider(contractConfig) {
|
|
1933
|
+
if (typeof contractConfig.source?.load !== "function") throw errorContractConfigMissing({ why: "Contract config must include a valid source provider object" });
|
|
1934
|
+
}
|
|
1935
|
+
/**
|
|
1936
|
+
* Runs the config's contract source and stops there: nothing is emitted or
|
|
1937
|
+
* written. A source that reports diagnostics is a `notOk` carrying them.
|
|
1938
|
+
*
|
|
1939
|
+
* @throws {CliStructuredError} the error `contract emit` raises, when the
|
|
1940
|
+
* config has no contract source or the source is malformed or throws
|
|
1941
|
+
* @throws {DOMException} `AbortError` if cancelled via `signal`
|
|
1942
|
+
*/
|
|
1943
|
+
async function loadContractSource(config, options = {}) {
|
|
1944
|
+
const contractConfig = requireContractConfig(config);
|
|
1945
|
+
requireSourceProvider(contractConfig);
|
|
1946
|
+
const loaded = await loadContractSourceWithStack({
|
|
1947
|
+
stack: createControlStack(config),
|
|
1948
|
+
source: contractConfig.source,
|
|
1949
|
+
...ifDefined("signal", options.signal),
|
|
1950
|
+
...ifDefined("reportWarning", options.onWarning)
|
|
1951
|
+
});
|
|
1952
|
+
if (loaded.ok) return loaded;
|
|
1953
|
+
const { error, sourceDiagnostics } = loaded.failure;
|
|
1954
|
+
if (sourceDiagnostics === void 0) throw error;
|
|
1955
|
+
return notOk({
|
|
1956
|
+
summary: sourceDiagnostics.summary,
|
|
1957
|
+
diagnostics: sourceDiagnostics.diagnostics,
|
|
1958
|
+
meta: sourceDiagnostics.meta
|
|
1959
|
+
});
|
|
1960
|
+
}
|
|
1773
1961
|
/**
|
|
1774
1962
|
* Apply pending migrations across every contract space (app +
|
|
1775
1963
|
* extensions). Replay-only: graph-walk against the on-disk graph for
|
|
@@ -2542,7 +2730,6 @@ var ControlClientImpl = class {
|
|
|
2542
2730
|
const { onProgress, contractConfig } = options;
|
|
2543
2731
|
this.init();
|
|
2544
2732
|
if (!this.familyInstance) throw new InternalError("Family instance was not initialized. This is a bug.");
|
|
2545
|
-
let contractRaw;
|
|
2546
2733
|
const sourceWarnings = [];
|
|
2547
2734
|
onProgress?.({
|
|
2548
2735
|
action: "emit",
|
|
@@ -2550,56 +2737,27 @@ var ControlClientImpl = class {
|
|
|
2550
2737
|
spanId: "resolveSource",
|
|
2551
2738
|
label: "Resolving contract source..."
|
|
2552
2739
|
});
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
authoringContributions: stack.authoringContributions,
|
|
2559
|
-
codecLookup: stack.codecLookup,
|
|
2560
|
-
controlMutationDefaults: stack.controlMutationDefaults,
|
|
2561
|
-
dataTypeLookup: stack.dataTypeLookup,
|
|
2562
|
-
resolvedInputs: await expandContractInputs(contractConfig.source.inputs),
|
|
2563
|
-
capabilities: stack.capabilities,
|
|
2564
|
-
reportWarning: (diagnostic) => {
|
|
2565
|
-
sourceWarnings.push(diagnostic);
|
|
2566
|
-
}
|
|
2567
|
-
};
|
|
2568
|
-
const providerResult = await contractConfig.source.load(sourceContext);
|
|
2569
|
-
if (!providerResult.ok) {
|
|
2570
|
-
onProgress?.({
|
|
2571
|
-
action: "emit",
|
|
2572
|
-
kind: "spanEnd",
|
|
2573
|
-
spanId: "resolveSource",
|
|
2574
|
-
outcome: "error"
|
|
2575
|
-
});
|
|
2576
|
-
return notOk({
|
|
2577
|
-
code: "CONTRACT_SOURCE_INVALID",
|
|
2578
|
-
summary: providerResult.failure.summary,
|
|
2579
|
-
why: providerResult.failure.summary,
|
|
2580
|
-
meta: providerResult.failure.meta,
|
|
2581
|
-
diagnostics: providerResult.failure
|
|
2582
|
-
});
|
|
2740
|
+
const loaded = await loadContractSourceWithStack({
|
|
2741
|
+
stack: this.stack,
|
|
2742
|
+
source: contractConfig.source,
|
|
2743
|
+
reportWarning: (diagnostic) => {
|
|
2744
|
+
sourceWarnings.push(diagnostic);
|
|
2583
2745
|
}
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
action: "emit",
|
|
2594
|
-
kind: "spanEnd",
|
|
2595
|
-
spanId: "resolveSource",
|
|
2596
|
-
outcome: "error"
|
|
2597
|
-
});
|
|
2746
|
+
});
|
|
2747
|
+
onProgress?.({
|
|
2748
|
+
action: "emit",
|
|
2749
|
+
kind: "spanEnd",
|
|
2750
|
+
spanId: "resolveSource",
|
|
2751
|
+
outcome: loaded.ok ? "ok" : "error"
|
|
2752
|
+
});
|
|
2753
|
+
if (!loaded.ok) {
|
|
2754
|
+
const { error, sourceDiagnostics } = loaded.failure;
|
|
2598
2755
|
return notOk({
|
|
2599
2756
|
code: "CONTRACT_SOURCE_INVALID",
|
|
2600
|
-
summary:
|
|
2601
|
-
why: error
|
|
2602
|
-
meta:
|
|
2757
|
+
summary: sourceDiagnostics?.summary ?? error.message,
|
|
2758
|
+
why: error.why,
|
|
2759
|
+
meta: sourceDiagnostics?.meta,
|
|
2760
|
+
...ifDefined("diagnostics", sourceDiagnostics)
|
|
2603
2761
|
});
|
|
2604
2762
|
}
|
|
2605
2763
|
onProgress?.({
|
|
@@ -2609,7 +2767,7 @@ var ControlClientImpl = class {
|
|
|
2609
2767
|
label: "Emitting contract..."
|
|
2610
2768
|
});
|
|
2611
2769
|
try {
|
|
2612
|
-
const enrichedIR = enrichContract(
|
|
2770
|
+
const enrichedIR = enrichContract(loaded.value, this.frameworkComponents ?? []);
|
|
2613
2771
|
const rawContractJson = this.options.target.contractSerializer.serializeContract(enrichedIR);
|
|
2614
2772
|
let deserializedContract;
|
|
2615
2773
|
try {
|
|
@@ -2730,13 +2888,13 @@ function disposeEmitQueue(outputJsonPath) {
|
|
|
2730
2888
|
* configuration that could disagree with what is installed.
|
|
2731
2889
|
*/
|
|
2732
2890
|
const DEPENDENCY_FIELDS = ["dependencies", "devDependencies"];
|
|
2733
|
-
function isRecord$
|
|
2891
|
+
function isRecord$1(value) {
|
|
2734
2892
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2735
2893
|
}
|
|
2736
2894
|
/** The error codes that mean "no manifest here", as opposed to "cannot read it". */
|
|
2737
2895
|
const MANIFEST_ABSENT_CODES = /* @__PURE__ */ new Set(["ENOENT", "ENOTDIR"]);
|
|
2738
2896
|
function errorCode(error) {
|
|
2739
|
-
if (!isRecord$
|
|
2897
|
+
if (!isRecord$1(error)) return void 0;
|
|
2740
2898
|
const code = error["code"];
|
|
2741
2899
|
return typeof code === "string" ? code : void 0;
|
|
2742
2900
|
}
|
|
@@ -2780,7 +2938,7 @@ function nearestManifest(from) {
|
|
|
2780
2938
|
cause
|
|
2781
2939
|
});
|
|
2782
2940
|
}
|
|
2783
|
-
if (!isRecord$
|
|
2941
|
+
if (!isRecord$1(parsed)) throw errorRuntime("CLI.PROJECT_MANIFEST_INVALID", `Failed to read ${path}`, {
|
|
2784
2942
|
why: `\`${path}\` is valid JSON but not a JSON object, so it states no dependencies.`,
|
|
2785
2943
|
fix: `Make \`${path}\` a JSON object with the usual manifest fields, then re-run the command. Emission reads it to decide which package names generated files should import.`,
|
|
2786
2944
|
meta: { path }
|
|
@@ -2794,7 +2952,7 @@ function nearestManifest(from) {
|
|
|
2794
2952
|
function declaredDependencies(manifest) {
|
|
2795
2953
|
return DEPENDENCY_FIELDS.flatMap((field) => {
|
|
2796
2954
|
const value = manifest[field];
|
|
2797
|
-
return isRecord$
|
|
2955
|
+
return isRecord$1(value) ? Object.keys(value) : [];
|
|
2798
2956
|
});
|
|
2799
2957
|
}
|
|
2800
2958
|
/**
|
|
@@ -2824,7 +2982,7 @@ function projectImportRoot(projectDir) {
|
|
|
2824
2982
|
function createProjectSpecifierResolver(projectDir) {
|
|
2825
2983
|
return createImportSpecifierResolver(projectImportRoot(projectDir));
|
|
2826
2984
|
}
|
|
2827
|
-
function isRecord
|
|
2985
|
+
function isRecord(value) {
|
|
2828
2986
|
return typeof value === "object" && value !== null;
|
|
2829
2987
|
}
|
|
2830
2988
|
function createTempArtifactPath(path, publicationToken, phase) {
|
|
@@ -2834,7 +2992,7 @@ async function readExistingArtifact(path) {
|
|
|
2834
2992
|
try {
|
|
2835
2993
|
return { content: await readFile(path, "utf-8") };
|
|
2836
2994
|
} catch (error) {
|
|
2837
|
-
if (isRecord
|
|
2995
|
+
if (isRecord(error) && error["code"] === "ENOENT") return "remove";
|
|
2838
2996
|
throw error;
|
|
2839
2997
|
}
|
|
2840
2998
|
}
|
|
@@ -2928,11 +3086,27 @@ function validateContractDeps(dtsContent, projectRoot) {
|
|
|
2928
3086
|
].join("\n")
|
|
2929
3087
|
};
|
|
2930
3088
|
}
|
|
3089
|
+
/**
|
|
3090
|
+
* Validates a contract its source loaded, as `contract emit` and `contract print` both do before
|
|
3091
|
+
* they write anything: the contract is enriched with what the configured components declare,
|
|
3092
|
+
* serialized by the target, and read back through the family instance, which checks its structure.
|
|
3093
|
+
* Returns the contract that comes back.
|
|
3094
|
+
*
|
|
3095
|
+
* @throws {CliStructuredError} when a configured component does not match the family and target
|
|
3096
|
+
* @throws the family instance's error for a contract whose structure it rejects
|
|
3097
|
+
*/
|
|
3098
|
+
function validateLoadedContract(input) {
|
|
3099
|
+
const { config } = input;
|
|
3100
|
+
const frameworkComponents = assertFrameworkComponentsCompatible(config.family.familyId, config.target.targetId, [
|
|
3101
|
+
config.target,
|
|
3102
|
+
config.adapter,
|
|
3103
|
+
...config.extensions ?? []
|
|
3104
|
+
]);
|
|
3105
|
+
const enriched = enrichContract(input.contract, frameworkComponents);
|
|
3106
|
+
return input.familyInstance.deserializeContract(config.target.contractSerializer.serializeContract(enriched));
|
|
3107
|
+
}
|
|
2931
3108
|
const EMIT_ACTION = "emit";
|
|
2932
3109
|
const defaultContractEmitDependencies = { emit };
|
|
2933
|
-
function isRecord(value) {
|
|
2934
|
-
return typeof value === "object" && value !== null;
|
|
2935
|
-
}
|
|
2936
3110
|
function startSpan(onProgress, spanId, label) {
|
|
2937
3111
|
onProgress?.({
|
|
2938
3112
|
action: EMIT_ACTION,
|
|
@@ -2949,181 +3123,6 @@ function endSpan(onProgress, spanId, outcome) {
|
|
|
2949
3123
|
outcome
|
|
2950
3124
|
});
|
|
2951
3125
|
}
|
|
2952
|
-
function failedToResolveContractSource(why, fix, meta, cause, diagnostics) {
|
|
2953
|
-
return errorRuntime("CONTRACT.SOURCE_LOAD_FAILED", "Failed to resolve contract source", {
|
|
2954
|
-
why,
|
|
2955
|
-
fix,
|
|
2956
|
-
...ifDefined("diagnostics", diagnostics),
|
|
2957
|
-
...ifDefined("meta", meta),
|
|
2958
|
-
...ifDefined("cause", cause)
|
|
2959
|
-
});
|
|
2960
|
-
}
|
|
2961
|
-
function diagnosticLocation(diagnostic) {
|
|
2962
|
-
const sourceId = typeof diagnostic["sourceId"] === "string" ? diagnostic["sourceId"] : void 0;
|
|
2963
|
-
const span = isRecord(diagnostic["span"]) ? diagnostic["span"] : void 0;
|
|
2964
|
-
const start = span && isRecord(span["start"]) ? span["start"] : void 0;
|
|
2965
|
-
return {
|
|
2966
|
-
sourceId,
|
|
2967
|
-
line: start && typeof start["line"] === "number" ? start["line"] : void 0,
|
|
2968
|
-
character: start && typeof start["column"] === "number" ? start["column"] : void 0
|
|
2969
|
-
};
|
|
2970
|
-
}
|
|
2971
|
-
function formatLocation({ sourceId, line, character }) {
|
|
2972
|
-
if (sourceId === void 0) return void 0;
|
|
2973
|
-
return line !== void 0 && character !== void 0 ? `${sourceId}:${line}:${character}` : sourceId;
|
|
2974
|
-
}
|
|
2975
|
-
/** One source diagnostic as a line of text: `<sourceId>:<line>:<column> <code> <message>`. */
|
|
2976
|
-
function formatSourceDiagnostic(raw) {
|
|
2977
|
-
if (!isRecord(raw)) return String(raw);
|
|
2978
|
-
const code = typeof raw["code"] === "string" ? raw["code"] : "diagnostic";
|
|
2979
|
-
const message = typeof raw["message"] === "string" ? raw["message"] : "";
|
|
2980
|
-
return [
|
|
2981
|
-
formatLocation(diagnosticLocation(raw)),
|
|
2982
|
-
code,
|
|
2983
|
-
message
|
|
2984
|
-
].filter((part) => part !== void 0 && part !== "").join(" ");
|
|
2985
|
-
}
|
|
2986
|
-
/**
|
|
2987
|
-
* The finding the CLI prints under the error, one per source diagnostic. The
|
|
2988
|
-
* terminal renderer prints a finding's code and summary and nothing of its
|
|
2989
|
-
* `where`, so the summary starts with the location. A source code that is not
|
|
2990
|
-
* yet dotted is wrapped as `CONTRACT.SOURCE_DIAGNOSTIC` and named in the summary.
|
|
2991
|
-
*/
|
|
2992
|
-
function sourceDiagnosticToFinding(raw) {
|
|
2993
|
-
if (!isRecord(raw)) return void 0;
|
|
2994
|
-
const code = typeof raw["code"] === "string" ? raw["code"] : "diagnostic";
|
|
2995
|
-
const message = typeof raw["message"] === "string" ? raw["message"] : "";
|
|
2996
|
-
const location = diagnosticLocation(raw);
|
|
2997
|
-
const formatted = formatLocation(location);
|
|
2998
|
-
const locatedSummary = (text) => formatted === void 0 ? text : `${formatted} ${text}`;
|
|
2999
|
-
const finding = {
|
|
3000
|
-
severity: "error",
|
|
3001
|
-
nextActions: [],
|
|
3002
|
-
...ifDefined("where", location.sourceId === void 0 ? void 0 : {
|
|
3003
|
-
path: location.sourceId,
|
|
3004
|
-
...ifDefined("line", location.line)
|
|
3005
|
-
})
|
|
3006
|
-
};
|
|
3007
|
-
return isStructuredErrorCode(code) ? {
|
|
3008
|
-
code,
|
|
3009
|
-
summary: locatedSummary(message),
|
|
3010
|
-
...finding
|
|
3011
|
-
} : {
|
|
3012
|
-
code: "CONTRACT.SOURCE_DIAGNOSTIC",
|
|
3013
|
-
summary: locatedSummary(`${code}: ${message}`),
|
|
3014
|
-
...finding,
|
|
3015
|
-
meta: { code }
|
|
3016
|
-
};
|
|
3017
|
-
}
|
|
3018
|
-
function sourceDiagnosticsToFindings(diagnostics) {
|
|
3019
|
-
const findings = [];
|
|
3020
|
-
for (const raw of diagnostics) {
|
|
3021
|
-
const finding = sourceDiagnosticToFinding(raw);
|
|
3022
|
-
if (finding !== void 0) findings.push(finding);
|
|
3023
|
-
}
|
|
3024
|
-
return findings;
|
|
3025
|
-
}
|
|
3026
|
-
function diagnosticLocationSuffix(diagnostic) {
|
|
3027
|
-
const formatted = formatLocation(diagnosticLocation(diagnostic));
|
|
3028
|
-
return formatted === void 0 ? "" : ` (${formatted})`;
|
|
3029
|
-
}
|
|
3030
|
-
function mapDiagnosticsToIssues(diagnostics) {
|
|
3031
|
-
const issues = [];
|
|
3032
|
-
for (const raw of diagnostics) {
|
|
3033
|
-
if (!isRecord(raw)) continue;
|
|
3034
|
-
const code = typeof raw["code"] === "string" ? raw["code"] : "diagnostic";
|
|
3035
|
-
const message = typeof raw["message"] === "string" ? raw["message"] : "";
|
|
3036
|
-
issues.push({
|
|
3037
|
-
kind: code,
|
|
3038
|
-
message: `${message}${diagnosticLocationSuffix(raw)}`
|
|
3039
|
-
});
|
|
3040
|
-
}
|
|
3041
|
-
return issues;
|
|
3042
|
-
}
|
|
3043
|
-
function validateProviderResult(providerResult) {
|
|
3044
|
-
if (!isRecord(providerResult) || typeof providerResult["ok"] !== "boolean") return {
|
|
3045
|
-
kind: "malformed",
|
|
3046
|
-
error: failedToResolveContractSource("Contract source provider returned malformed result shape.", "Ensure contract.source.load resolves to ok(Contract) or notOk({ summary, diagnostics }).")
|
|
3047
|
-
};
|
|
3048
|
-
if (providerResult["ok"]) {
|
|
3049
|
-
if (!("value" in providerResult)) return {
|
|
3050
|
-
kind: "malformed",
|
|
3051
|
-
error: failedToResolveContractSource("Contract source provider returned malformed success result: missing value.", "Ensure contract.source.load success payload is ok(Contract).")
|
|
3052
|
-
};
|
|
3053
|
-
return {
|
|
3054
|
-
kind: "ok",
|
|
3055
|
-
value: providerResult["value"]
|
|
3056
|
-
};
|
|
3057
|
-
}
|
|
3058
|
-
const failure = providerResult["failure"];
|
|
3059
|
-
if (!isRecord(failure) || typeof failure["summary"] !== "string" || !Array.isArray(failure["diagnostics"])) return {
|
|
3060
|
-
kind: "malformed",
|
|
3061
|
-
error: failedToResolveContractSource("Contract source provider returned malformed failure result: expected summary and diagnostics.", "Ensure contract.source.load failure payload is notOk({ summary, diagnostics, meta? }).")
|
|
3062
|
-
};
|
|
3063
|
-
if (failure["diagnostics"].some((diagnostic) => !isRecord(diagnostic) || typeof diagnostic["sourceId"] !== "string")) return {
|
|
3064
|
-
kind: "malformed",
|
|
3065
|
-
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.")
|
|
3066
|
-
};
|
|
3067
|
-
return {
|
|
3068
|
-
kind: "failed",
|
|
3069
|
-
failure: {
|
|
3070
|
-
summary: failure["summary"],
|
|
3071
|
-
diagnostics: failure["diagnostics"],
|
|
3072
|
-
meta: failure["meta"]
|
|
3073
|
-
}
|
|
3074
|
-
};
|
|
3075
|
-
}
|
|
3076
|
-
function sourceFailureError(failure) {
|
|
3077
|
-
return failedToResolveContractSource(failure.summary, "Edit the schema where each finding points, then run contract emit again.", {
|
|
3078
|
-
diagnostics: failure.diagnostics,
|
|
3079
|
-
issues: mapDiagnosticsToIssues(failure.diagnostics),
|
|
3080
|
-
...ifDefined("providerMeta", failure.meta)
|
|
3081
|
-
}, void 0, sourceDiagnosticsToFindings(failure.diagnostics));
|
|
3082
|
-
}
|
|
3083
|
-
function requireContractConfig(config) {
|
|
3084
|
-
if (!config.contract) throw errorContractConfigMissing({ why: "Config.contract is required for emit. Define it in your config: contract: { source: ..., output: ... }" });
|
|
3085
|
-
return config.contract;
|
|
3086
|
-
}
|
|
3087
|
-
function requireSourceProvider(contractConfig) {
|
|
3088
|
-
if (typeof contractConfig.source?.load !== "function") throw errorContractConfigMissing({ why: "Contract config must include a valid source provider object" });
|
|
3089
|
-
}
|
|
3090
|
-
async function resolveContractSource(contractConfig, stack, signal, reportWarning) {
|
|
3091
|
-
const sourceContext = {
|
|
3092
|
-
...ifDefined("reportWarning", reportWarning),
|
|
3093
|
-
composedExtensions: stack.extensions.map((p) => p.id),
|
|
3094
|
-
composedExtensionContracts: stack.extensionContracts,
|
|
3095
|
-
authoringContributions: stack.authoringContributions,
|
|
3096
|
-
codecLookup: stack.codecLookup,
|
|
3097
|
-
controlMutationDefaults: stack.controlMutationDefaults,
|
|
3098
|
-
dataTypeLookup: stack.dataTypeLookup,
|
|
3099
|
-
resolvedInputs: await abortable(signal)(expandContractInputs(contractConfig.source.inputs)),
|
|
3100
|
-
capabilities: stack.capabilities
|
|
3101
|
-
};
|
|
3102
|
-
let providerResult;
|
|
3103
|
-
try {
|
|
3104
|
-
providerResult = await abortable(signal)(contractConfig.source.load(sourceContext));
|
|
3105
|
-
} catch (error) {
|
|
3106
|
-
if (signal.aborted || isRecord(error) && error["name"] === "AbortError") throw error;
|
|
3107
|
-
throw failedToResolveContractSource(error instanceof Error ? error.message : String(error), "Ensure contract.source.load resolves to ok(Contract) or returns structured diagnostics.", void 0, error);
|
|
3108
|
-
}
|
|
3109
|
-
const validated = validateProviderResult(providerResult);
|
|
3110
|
-
switch (validated.kind) {
|
|
3111
|
-
case "malformed": throw validated.error;
|
|
3112
|
-
case "failed": return notOk(validated.failure);
|
|
3113
|
-
case "ok": return ok(validated.value);
|
|
3114
|
-
}
|
|
3115
|
-
}
|
|
3116
|
-
/**
|
|
3117
|
-
* Runs the config's contract source the way `executeContractEmit` does and
|
|
3118
|
-
* stops there: nothing is emitted or written. A source that reports
|
|
3119
|
-
* diagnostics is a `notOk`; a malformed or throwing source raises the same
|
|
3120
|
-
* error emit raises.
|
|
3121
|
-
*/
|
|
3122
|
-
async function loadContractSource(config, options = {}) {
|
|
3123
|
-
const contractConfig = requireContractConfig(config);
|
|
3124
|
-
requireSourceProvider(contractConfig);
|
|
3125
|
-
return resolveContractSource(contractConfig, createControlStack(config), options.signal ?? new AbortController().signal, options.onWarning);
|
|
3126
|
-
}
|
|
3127
3126
|
/**
|
|
3128
3127
|
* Canonical contract emit operation.
|
|
3129
3128
|
*
|
|
@@ -3159,36 +3158,36 @@ async function executeContractEmit(options, dependencies = defaultContractEmitDe
|
|
|
3159
3158
|
}
|
|
3160
3159
|
const { jsonPath: outputJsonPath, dtsPath: outputDtsPath } = outputPaths;
|
|
3161
3160
|
return queueEmitByOutput(outputJsonPath, async () => {
|
|
3162
|
-
const stack = createControlStack(config);
|
|
3163
3161
|
startSpan(onProgress, "resolveSource", "Resolving contract source...");
|
|
3164
3162
|
const sourceWarnings = [];
|
|
3165
|
-
let
|
|
3163
|
+
let stack;
|
|
3164
|
+
let contract;
|
|
3166
3165
|
try {
|
|
3167
|
-
|
|
3168
|
-
|
|
3166
|
+
stack = createControlStack(config);
|
|
3167
|
+
const loaded = await loadContractSourceWithStack({
|
|
3168
|
+
stack,
|
|
3169
|
+
source: contractConfig.source,
|
|
3170
|
+
signal,
|
|
3171
|
+
reportWarning: (diagnostic) => {
|
|
3172
|
+
sourceWarnings.push(diagnostic);
|
|
3173
|
+
}
|
|
3169
3174
|
});
|
|
3175
|
+
if (!loaded.ok) throw loaded.failure.error;
|
|
3176
|
+
contract = loaded.value;
|
|
3170
3177
|
} catch (error) {
|
|
3171
3178
|
endSpan(onProgress, "resolveSource", "error");
|
|
3172
3179
|
throw error;
|
|
3173
3180
|
}
|
|
3174
|
-
if (!resolved.ok) {
|
|
3175
|
-
endSpan(onProgress, "resolveSource", "error");
|
|
3176
|
-
throw sourceFailureError(resolved.failure);
|
|
3177
|
-
}
|
|
3178
3181
|
endSpan(onProgress, "resolveSource", "ok");
|
|
3179
3182
|
startSpan(onProgress, "emit", "Emitting contract...");
|
|
3180
3183
|
let emitResult;
|
|
3181
3184
|
try {
|
|
3182
3185
|
const familyInstance = config.family.create(stack);
|
|
3183
|
-
const
|
|
3184
|
-
config
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
const frameworkComponents = assertFrameworkComponentsCompatible(config.family.familyId, config.target.targetId, rawComponents);
|
|
3189
|
-
const enrichedIR = enrichContract(blindCast(resolved.value), frameworkComponents);
|
|
3190
|
-
const rawContractJson = config.target.contractSerializer.serializeContract(enrichedIR);
|
|
3191
|
-
const deserializedContract = familyInstance.deserializeContract(rawContractJson);
|
|
3186
|
+
const deserializedContract = validateLoadedContract({
|
|
3187
|
+
config,
|
|
3188
|
+
familyInstance,
|
|
3189
|
+
contract
|
|
3190
|
+
});
|
|
3192
3191
|
const { contractSerializer } = config.target;
|
|
3193
3192
|
const serializeContract = (c) => contractSerializer.serializeContract(c);
|
|
3194
3193
|
emitResult = await unlessAborted(dependencies.emit(deserializedContract, stack, config.family.emission, {
|
|
@@ -5165,6 +5164,6 @@ async function executeRefListCommand(options) {
|
|
|
5165
5164
|
}
|
|
5166
5165
|
}
|
|
5167
5166
|
//#endregion
|
|
5168
|
-
export {
|
|
5167
|
+
export { findPackageByDirPath as $, errorHashMismatch as A, resolveMigrationRef as At, errorTargetMismatch as B, toDeclaredExtensionsFromRaw as Bt, errorContractArgConflict as C, refusePackageCorruptionOnAggregate as Ct, errorDestructiveChanges as D, resolveContractRef$1 as Dt, errorDatabaseConnectionRequired as E, resolveAppTargetPath as Et, errorNoMigrations as F, runMigrationList as Ft, executeDbVerify as G, executeContractEmit as H, errorPathUnreachable as I, sanitizeErrorMessage as It, executeMigrationPlanCommand as J, executeMigrateShowPlan as K, errorRunnerFailed as L, snapshotVerifierFor as Lt, errorMarkerMissing as M, runCommandAction as Mt, errorMigrationPackageNotFound as N, runContractSpaceSeedPhase as Nt, errorDriverRequired as O, resolveContractRefToSnapshot as Ot, errorMigrationPlanningFailed as P, runMigrationCheck as Pt, executeRefSetCommand as Q, errorRuntime as R, statusForMigrationHash as Rt, errorConsentPlanMismatch as S, refuseMissingInvariantPath as St, errorContractValidationFailed as T, requireLiveDatabase as Tt, executeDbInit as U, errorUnexpected as V, validateLoadedContract as Vt, executeDbUpdate as W, executeRefDeleteCommand as X, executeRefAdvancement as Y, executeRefListCommand as Z, disposeEmitQueue as _, readMigrationRefs as _t, appContractStandInFromIdentity as a, loadContractSource as at, errorAdvanceRefArgConflict as b, refuseDeclaredExtensionTargetMismatch as bt, buildMigrationSpaceGraphEntries as c, looksLikePath as ct, checkSingleTarget as d, mapIntegrityViolations as dt, formatSourceDiagnostic as et, chooseAction as f, maskConnectionUrl as ft, deriveStatusEdgeAnnotations as g, readContractEnvelope as gt, createControlClient as h, preflightRefAdvancement as ht, advanceRefSafely as i, loadContractRawSafely as it, errorLegendHumanOnly as j, resolveToForPlan as jt, errorFileNotFound as k, resolveFromForPlan as kt, buildReadAggregate as l, mapCaughtMigrationError as lt, computeRefAdvancementName as m, originHashForStatus as mt, ERROR_CODE_DESTRUCTIVE_CHANGES as n, listRefsByContractHash as nt, appliedHashesFromLedger as o, loadContractSourceWithStack as ot, closeQuietly as p, migrationSpaceListEntriesFromAggregate as pt, executeMigrationNewCommand as q, NO_REF_ADVANCEMENT as r, loadAggregateIntegrityViolations as rt, buildContractSpaceAggregate as s, loadContractSpaceAggregateForCli as st, CliStructuredError$1 as t, hasMigrationPath as tt, buildRefAdvancementFields as u, mapContractAtError as ut, enrichContract as v, redactUrlCredentials as vt, errorContractConfigMissing as w, refuseUnknownInvariants as wt, errorConfigValidation$1 as x, refuseMarkerOutsideGraph as xt, enumerateCheckSpaces as y, refuseContractSpaceIntegrity as yt, errorTargetMigrationNotSupported as z, targetSupportsMigrations as zt };
|
|
5169
5168
|
|
|
5170
|
-
//# sourceMappingURL=ref-
|
|
5169
|
+
//# sourceMappingURL=ref-DZuzAvuD-BYpisYJp.mjs.map
|