@prisma/orm-toolchain 8.0.0-rc.12-dev.1 → 8.0.0-rc.12-dev.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +4 -17
- package/dist/cli.mjs.map +1 -1
- package/dist/cli__control-api.mjs +1 -1
- package/dist/{ref-BK7yr-IT-Dk0sxEcL.mjs → ref-J_U8k_jN-BbJ39q0M.mjs} +79 -13
- package/dist/ref-J_U8k_jN-BbJ39q0M.mjs.map +1 -0
- package/dist/vite-plugin-contract-emit.mjs +1 -1
- package/package.json +12 -12
- package/dist/ref-BK7yr-IT-Dk0sxEcL.mjs.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Dt as resolveFromForPlan, Et as resolveContractRefToSnapshot, G as executeMigrateShowPlan, H as executeDbInit, It as statusForMigrationHash, J as executeRefAdvancement, K as executeMigrationNewCommand, Mt as runMigrationCheck, Nt as runMigrationList, Ot as resolveMigrationRef, St as refuseUnknownInvariants, Tt as resolveContractRef$1, U as executeDbUpdate, V as executeContractEmit, W as executeDbVerify, X as executeRefListCommand, Y as executeRefDeleteCommand, Z as executeRefSetCommand, _ as disposeEmitQueue, _t as refuseContractSpaceIntegrity, a as appContractStandInFromIdentity, at as loadContractSpaceAggregateForCli, bt as refuseMissingInvariantPath, c as buildMigrationSpaceGraphEntries, ct as mapContractAtError, d as checkSingleTarget, dt as migrationSpaceListEntriesFromAggregate, et as hasMigrationPath, ft as originHashForStatus, g as deriveStatusEdgeAnnotations, h as createControlClient, ht as readMigrationRefs, i as advanceRefSafely, it as loadContractSource, jt as runContractSpaceSeedPhase, kt as resolveToForPlan, l as buildReadAggregate, lt as mapIntegrityViolations, m as computeRefAdvancementName, nt as loadAggregateIntegrityViolations, o as appliedHashesFromLedger, pt as preflightRefAdvancement, q as executeMigrationPlanCommand, r as NO_REF_ADVANCEMENT, rt as loadContractRawSafely, s as buildContractSpaceAggregate, st as mapCaughtMigrationError, tt as listRefsByContractHash, u as buildRefAdvancementFields, v as enrichContract, vt as refuseDeclaredExtensionTargetMismatch, xt as refusePackageCorruptionOnAggregate, y as enumerateCheckSpaces, yt as refuseMarkerOutsideGraph } from "./ref-J_U8k_jN-BbJ39q0M.mjs";
|
|
2
2
|
export { NO_REF_ADVANCEMENT, advanceRefSafely, appContractStandInFromIdentity, appliedHashesFromLedger, buildContractSpaceAggregate, buildMigrationSpaceGraphEntries, buildReadAggregate, buildRefAdvancementFields, checkSingleTarget, computeRefAdvancementName, createControlClient, deriveStatusEdgeAnnotations, disposeEmitQueue, enrichContract, enumerateCheckSpaces, executeContractEmit, executeDbInit, executeDbUpdate, executeDbVerify, executeMigrateShowPlan, executeMigrationNewCommand, executeMigrationPlanCommand, executeRefAdvancement, executeRefDeleteCommand, executeRefListCommand, executeRefSetCommand, hasMigrationPath, listRefsByContractHash, loadAggregateIntegrityViolations, loadContractRawSafely, loadContractSource, loadContractSpaceAggregateForCli, mapCaughtMigrationError, mapContractAtError, mapIntegrityViolations, migrationSpaceListEntriesFromAggregate, originHashForStatus, preflightRefAdvancement, readMigrationRefs, refuseContractSpaceIntegrity, refuseDeclaredExtensionTargetMismatch, refuseMarkerOutsideGraph, refuseMissingInvariantPath, refusePackageCorruptionOnAggregate, refuseUnknownInvariants, resolveContractRef$1 as resolveContractRef, resolveContractRefToSnapshot, resolveFromForPlan, resolveMigrationRef, resolveToForPlan, runContractSpaceSeedPhase, runMigrationCheck, runMigrationList, statusForMigrationHash };
|
|
@@ -34,7 +34,7 @@ import { createHash } from "node:crypto";
|
|
|
34
34
|
import { canonicalizeJson } from "@prisma/orm-framework/components/utils";
|
|
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-J_U8k_jN.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
|
|
@@ -525,6 +525,52 @@ function enrichContract(ir, components) {
|
|
|
525
525
|
extensions: sortDeepTyped(extensions)
|
|
526
526
|
};
|
|
527
527
|
}
|
|
528
|
+
const MASK = "****";
|
|
529
|
+
const URL_SCHEME = /^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//;
|
|
530
|
+
const LEADING_URL_USERINFO = /^[a-zA-Z][a-zA-Z0-9+.-]*:\/\/([^/?#\s]+)@/;
|
|
531
|
+
const URL_USERINFO = /([a-zA-Z][a-zA-Z0-9+.-]*:\/\/)([^/?#\s]+)@/g;
|
|
532
|
+
const PASSWORD_QUERY_PARAMETER = /([?&][^=&#\s]*password[^=&#\s]*=)([^&#\s]*)/gi;
|
|
533
|
+
function hasUrlScheme(text) {
|
|
534
|
+
return URL_SCHEME.test(text);
|
|
535
|
+
}
|
|
536
|
+
/**
|
|
537
|
+
* Reads the userinfo of a URL without parsing its hosts, so it works for URLs `new URL` rejects,
|
|
538
|
+
* such as a seed list of several `host:port` pairs. The userinfo ends at the last `@` before the
|
|
539
|
+
* first `/`, `?` or `#`.
|
|
540
|
+
*/
|
|
541
|
+
function urlUserinfo(url) {
|
|
542
|
+
return splitUserinfo(url.match(LEADING_URL_USERINFO)?.[1] ?? "");
|
|
543
|
+
}
|
|
544
|
+
/**
|
|
545
|
+
* Reads the values of the query parameters whose key contains `password`, the same ones
|
|
546
|
+
* `redactUrlCredentials` masks, without parsing hosts.
|
|
547
|
+
*/
|
|
548
|
+
function passwordQueryValues(url) {
|
|
549
|
+
return [...url.matchAll(PASSWORD_QUERY_PARAMETER)].map((match) => match[2] ?? "");
|
|
550
|
+
}
|
|
551
|
+
/**
|
|
552
|
+
* Masks the userinfo and any password query parameter of every URL in `text`, without parsing
|
|
553
|
+
* hosts. The masked form matches what `new URL` gives when its username and password are set to
|
|
554
|
+
* `****`.
|
|
555
|
+
*/
|
|
556
|
+
function redactUrlCredentials(text) {
|
|
557
|
+
return text.replace(URL_USERINFO, (_match, scheme, userinfo) => `${scheme}${maskUserinfo(splitUserinfo(userinfo))}@`).replace(PASSWORD_QUERY_PARAMETER, `$1${MASK}`);
|
|
558
|
+
}
|
|
559
|
+
function splitUserinfo(userinfo) {
|
|
560
|
+
const colon = userinfo.indexOf(":");
|
|
561
|
+
if (colon === -1) return {
|
|
562
|
+
username: userinfo,
|
|
563
|
+
password: ""
|
|
564
|
+
};
|
|
565
|
+
return {
|
|
566
|
+
username: userinfo.slice(0, colon),
|
|
567
|
+
password: userinfo.slice(colon + 1)
|
|
568
|
+
};
|
|
569
|
+
}
|
|
570
|
+
function maskUserinfo({ username, password }) {
|
|
571
|
+
return `${username ? MASK : ""}${password ? `:${MASK}` : ""}`;
|
|
572
|
+
}
|
|
573
|
+
const PASSWORD_QUERY_KEY = /password/i;
|
|
528
574
|
/**
|
|
529
575
|
* Resolves the absolute path to contract.json from the config.
|
|
530
576
|
*/
|
|
@@ -631,17 +677,18 @@ async function readContractEnvelope(config) {
|
|
|
631
677
|
}
|
|
632
678
|
/**
|
|
633
679
|
* Masks credentials in a database connection URL.
|
|
634
|
-
* Handles standard URLs (username + password + query params)
|
|
680
|
+
* Handles standard URLs (username + password + query params), URLs `new URL` rejects (such as
|
|
681
|
+
* multi-host URLs), and libpq-style key=value strings.
|
|
635
682
|
*/
|
|
636
683
|
function maskConnectionUrl(url) {
|
|
637
684
|
try {
|
|
638
685
|
const parsed = new URL(url);
|
|
639
686
|
if (parsed.username) parsed.username = "****";
|
|
640
687
|
if (parsed.password) parsed.password = "****";
|
|
641
|
-
for (const key of [...parsed.searchParams.keys()]) if (
|
|
688
|
+
for (const key of [...parsed.searchParams.keys()]) if (PASSWORD_QUERY_KEY.test(key)) parsed.searchParams.set(key, "****");
|
|
642
689
|
return parsed.toString();
|
|
643
690
|
} catch {
|
|
644
|
-
return url
|
|
691
|
+
return hasUrlScheme(url) ? redactUrlCredentials(url) : maskKeyValueCredentials(url);
|
|
645
692
|
}
|
|
646
693
|
}
|
|
647
694
|
/**
|
|
@@ -650,17 +697,36 @@ function maskConnectionUrl(url) {
|
|
|
650
697
|
*/
|
|
651
698
|
function sanitizeErrorMessage(message, connectionUrl) {
|
|
652
699
|
if (!connectionUrl) return message;
|
|
700
|
+
const secrets = connectionUrlSecrets(connectionUrl);
|
|
701
|
+
if (secrets === void 0) return maskKeyValueCredentials(message);
|
|
702
|
+
let sanitized = message.replaceAll(connectionUrl, maskConnectionUrl(connectionUrl));
|
|
703
|
+
for (const secret of secrets.filter(Boolean).sort(longestFirst)) sanitized = sanitized.replaceAll(secret, "****");
|
|
704
|
+
return sanitized;
|
|
705
|
+
}
|
|
706
|
+
function connectionUrlSecrets(connectionUrl) {
|
|
653
707
|
try {
|
|
654
|
-
const
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
708
|
+
const { username, password, searchParams } = new URL(connectionUrl);
|
|
709
|
+
return [
|
|
710
|
+
username,
|
|
711
|
+
password,
|
|
712
|
+
...[...searchParams].filter(([key]) => PASSWORD_QUERY_KEY.test(key)).map(([, value]) => value)
|
|
713
|
+
];
|
|
660
714
|
} catch {
|
|
661
|
-
|
|
715
|
+
if (!hasUrlScheme(connectionUrl)) return;
|
|
716
|
+
const { username, password } = urlUserinfo(connectionUrl);
|
|
717
|
+
return [
|
|
718
|
+
username,
|
|
719
|
+
password,
|
|
720
|
+
...passwordQueryValues(connectionUrl)
|
|
721
|
+
];
|
|
662
722
|
}
|
|
663
723
|
}
|
|
724
|
+
function longestFirst(a, b) {
|
|
725
|
+
return b.length - a.length;
|
|
726
|
+
}
|
|
727
|
+
function maskKeyValueCredentials(text) {
|
|
728
|
+
return text.replace(/password\s*=\s*\S+/gi, "password=****").replace(/user\s*=\s*\S+/gi, "user=****");
|
|
729
|
+
}
|
|
664
730
|
/**
|
|
665
731
|
* Project the CLI's `Config.extensions` array into the canonical
|
|
666
732
|
* {@link ExtensionPackInput} shape. The single `as ExtensionPackLike`
|
|
@@ -5089,6 +5155,6 @@ async function executeRefListCommand(options) {
|
|
|
5089
5155
|
}
|
|
5090
5156
|
}
|
|
5091
5157
|
//#endregion
|
|
5092
|
-
export { formatSourceDiagnostic as $, errorLegendHumanOnly as A,
|
|
5158
|
+
export { formatSourceDiagnostic as $, errorLegendHumanOnly as A, runCommandAction as At, errorUnexpected as B, errorContractArgConflict as C, requireLiveDatabase as Ct, errorDriverRequired as D, resolveFromForPlan as Dt, errorDestructiveChanges as E, resolveContractRefToSnapshot as Et, errorPathUnreachable as F, snapshotVerifierFor as Ft, executeMigrateShowPlan as G, executeDbInit as H, errorRunnerFailed as I, statusForMigrationHash as It, executeRefAdvancement as J, executeMigrationNewCommand as K, errorRuntime as L, targetSupportsMigrations as Lt, errorMigrationPackageNotFound as M, runMigrationCheck as Mt, errorMigrationPlanningFailed as N, runMigrationList as Nt, errorFileNotFound as O, resolveMigrationRef as Ot, errorNoMigrations as P, sanitizeErrorMessage as Pt, findPackageByDirPath as Q, errorTargetMigrationNotSupported as R, toDeclaredExtensionsFromRaw as Rt, errorConsentPlanMismatch as S, refuseUnknownInvariants as St, errorDatabaseConnectionRequired as T, resolveContractRef$1 as Tt, executeDbUpdate as U, executeContractEmit as V, executeDbVerify as W, executeRefListCommand as X, executeRefDeleteCommand as Y, executeRefSetCommand as Z, disposeEmitQueue as _, refuseContractSpaceIntegrity as _t, appContractStandInFromIdentity as a, loadContractSpaceAggregateForCli as at, errorAdvanceRefArgConflict as b, refuseMissingInvariantPath 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, redactUrlCredentials as gt, createControlClient as h, readMigrationRefs as ht, advanceRefSafely as i, loadContractSource as it, errorMarkerMissing as j, runContractSpaceSeedPhase as jt, errorHashMismatch as k, resolveToForPlan 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, refuseDeclaredExtensionTargetMismatch as vt, errorContractValidationFailed as w, resolveAppTargetPath as wt, errorConfigValidation$1 as x, refusePackageCorruptionOnAggregate as xt, enumerateCheckSpaces as y, refuseMarkerOutsideGraph as yt, errorTargetMismatch as z };
|
|
5093
5159
|
|
|
5094
|
-
//# sourceMappingURL=ref-
|
|
5160
|
+
//# sourceMappingURL=ref-J_U8k_jN-BbJ39q0M.mjs.map
|