tina4-nodejs 3.13.165 → 3.13.166
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/CLAUDE.md +12 -5
- package/package.json +1 -1
- package/packages/cli/dist/bin.js +596 -342
- package/packages/cli/src/commands/seed.ts +10 -11
- package/packages/core/dist/index.js +586 -328
- package/packages/core/src/connectionUrl.ts +242 -0
- package/packages/core/src/devAdmin.ts +18 -3
- package/packages/core/src/fakeData.ts +47 -12
- package/packages/core/src/index.ts +1 -1
- package/packages/core/src/mqtt.ts +24 -48
- package/packages/core/src/queueBackends/rabbitmqBackend.ts +32 -20
- package/packages/core/src/router.ts +44 -30
- package/packages/core/src/server.ts +35 -18
- package/packages/core/src/urlRedaction.ts +252 -0
- package/packages/core/src/websocketBackplane.ts +15 -3
- package/packages/orm/dist/index.js +577 -320
- package/packages/orm/src/database.ts +7 -1
- package/packages/orm/src/databaseUrl.ts +73 -190
- package/packages/orm/src/docstore.ts +8 -1
- package/packages/orm/src/graph/graphUrl.ts +43 -7
- package/types/core/src/connectionUrl.d.ts +61 -0
- package/types/core/src/fakeData.d.ts +11 -2
- package/types/core/src/index.d.ts +1 -1
- package/types/core/src/queueBackends/rabbitmqBackend.d.ts +0 -7
- package/types/core/src/router.d.ts +17 -2
- package/types/core/src/server.d.ts +13 -0
- package/types/core/src/urlRedaction.d.ts +61 -0
- package/types/orm/src/databaseUrl.d.ts +18 -19
- package/types/orm/src/graph/graphUrl.d.ts +18 -0
package/packages/cli/dist/bin.js
CHANGED
|
@@ -1424,10 +1424,10 @@ var init_databaseResult = __esm({
|
|
|
1424
1424
|
_adapter;
|
|
1425
1425
|
_sql;
|
|
1426
1426
|
_columnInfoCache;
|
|
1427
|
-
constructor(records, columns,
|
|
1427
|
+
constructor(records, columns, count2, limit, offset, adapter, sql) {
|
|
1428
1428
|
this.records = records ?? [];
|
|
1429
1429
|
this.columns = columns ?? (this.records.length > 0 ? Object.keys(this.records[0]) : []);
|
|
1430
|
-
this.count =
|
|
1430
|
+
this.count = count2 ?? this.records.length;
|
|
1431
1431
|
this.limit = limit ?? this.records.length;
|
|
1432
1432
|
this.offset = offset ?? 0;
|
|
1433
1433
|
this._adapter = adapter;
|
|
@@ -1720,36 +1720,28 @@ var init_modelCollection = __esm({
|
|
|
1720
1720
|
}
|
|
1721
1721
|
});
|
|
1722
1722
|
|
|
1723
|
-
// ../
|
|
1724
|
-
import { inspect } from "node:util";
|
|
1725
|
-
function stripOneSlash(path9) {
|
|
1726
|
-
return path9.startsWith("/") ? path9.slice(1) : path9;
|
|
1727
|
-
}
|
|
1728
|
-
function decode(value) {
|
|
1729
|
-
if (value === void 0 || value === "") return null;
|
|
1730
|
-
return decodeURIComponent(value);
|
|
1731
|
-
}
|
|
1723
|
+
// ../core/src/urlRedaction.ts
|
|
1732
1724
|
function endOfKeywordValue(text, start2) {
|
|
1733
1725
|
const open = text[start2];
|
|
1734
1726
|
if (open === "{") {
|
|
1735
1727
|
const close = text.indexOf("}", start2 + 1);
|
|
1736
1728
|
return close === -1 ? text.length : close + 1;
|
|
1737
1729
|
}
|
|
1738
|
-
if (open === "'" || open === '"')
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1730
|
+
if (open === "'" || open === '"') return endOfQuoted(text, start2, open);
|
|
1731
|
+
const end = text.slice(start2).search(/[;&]/);
|
|
1732
|
+
return end === -1 ? text.length : start2 + end;
|
|
1733
|
+
}
|
|
1734
|
+
function endOfQuoted(text, start2, quote) {
|
|
1735
|
+
let i = start2 + 1;
|
|
1736
|
+
while (i < text.length) {
|
|
1737
|
+
if (text[i] === "\\") {
|
|
1738
|
+
i += 2;
|
|
1739
|
+
continue;
|
|
1747
1740
|
}
|
|
1748
|
-
return
|
|
1741
|
+
if (text[i] === quote) return i + 1;
|
|
1742
|
+
i++;
|
|
1749
1743
|
}
|
|
1750
|
-
|
|
1751
|
-
while (i < text.length && text[i] !== ";" && text[i] !== "&") i++;
|
|
1752
|
-
return i;
|
|
1744
|
+
return text.length;
|
|
1753
1745
|
}
|
|
1754
1746
|
function redactKeywordValues(text) {
|
|
1755
1747
|
const pattern = new RegExp(SECRET_KEYWORD_PATTERN.source, SECRET_KEYWORD_PATTERN.flags);
|
|
@@ -1764,57 +1756,258 @@ function redactKeywordValues(text) {
|
|
|
1764
1756
|
}
|
|
1765
1757
|
return out + text.slice(cursor);
|
|
1766
1758
|
}
|
|
1767
|
-
function
|
|
1768
|
-
const
|
|
1769
|
-
|
|
1770
|
-
const
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
}
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1759
|
+
function credentialSpans(line) {
|
|
1760
|
+
const spans = [];
|
|
1761
|
+
const marker = new RegExp(SCHEME_MARKER.source, "g");
|
|
1762
|
+
const lastAt = line.lastIndexOf("@");
|
|
1763
|
+
let match;
|
|
1764
|
+
while ((match = marker.exec(line)) !== null) {
|
|
1765
|
+
const start2 = match.index + match[0].length;
|
|
1766
|
+
const withAt = userinfoSpan(line, start2, lastAt);
|
|
1767
|
+
if (withAt !== null) {
|
|
1768
|
+
spans.push(withAt);
|
|
1769
|
+
marker.lastIndex = lastAt + 1;
|
|
1770
|
+
continue;
|
|
1771
|
+
}
|
|
1772
|
+
const portShaped = portShapedSpan(line, start2);
|
|
1773
|
+
if (portShaped !== null) {
|
|
1774
|
+
spans.push(portShaped);
|
|
1775
|
+
break;
|
|
1776
|
+
}
|
|
1777
|
+
}
|
|
1778
|
+
return spans;
|
|
1779
|
+
}
|
|
1780
|
+
function userinfoSpan(line, start2, lastAt) {
|
|
1781
|
+
if (lastAt < start2) return null;
|
|
1782
|
+
const colon = line.indexOf(":", start2);
|
|
1783
|
+
if (colon === -1 || colon >= lastAt || /[/?#]/.test(line.slice(start2, colon))) return null;
|
|
1784
|
+
return { authorityStart: start2, at: lastAt, passwordStart: colon + 1, passwordEnd: lastAt };
|
|
1785
|
+
}
|
|
1786
|
+
function portShapedSpan(line, start2) {
|
|
1787
|
+
const rest = line.slice(start2);
|
|
1788
|
+
const authorityEnd = rest.search(/[/?#\s]/);
|
|
1789
|
+
const authority = authorityEnd === -1 ? rest : rest.slice(0, authorityEnd);
|
|
1790
|
+
const colon = authority.indexOf(":", authority.startsWith("[") ? authority.indexOf("]") + 1 : 0);
|
|
1791
|
+
if (colon === -1) return null;
|
|
1792
|
+
const port = authority.slice(colon + 1);
|
|
1793
|
+
if (port === "") return null;
|
|
1794
|
+
if (/^\d+$/.test(port) && !digitLedPassword(rest.slice(authority.length))) return null;
|
|
1795
|
+
const maskStart = start2 + colon + 1;
|
|
1796
|
+
return { authorityStart: start2, at: -1, passwordStart: maskStart, passwordEnd: keptQueryStart(line, maskStart) };
|
|
1797
|
+
}
|
|
1798
|
+
function keptQueryStart(line, from) {
|
|
1799
|
+
const query = line.indexOf("?", from);
|
|
1800
|
+
return query !== -1 && KEPT_QUERY.test(line.slice(query)) ? query : line.length;
|
|
1801
|
+
}
|
|
1802
|
+
function digitLedPassword(afterPort) {
|
|
1803
|
+
if (afterPort.startsWith("#")) return true;
|
|
1804
|
+
return afterPort.startsWith("?") && !KEPT_QUERY.test(afterPort.split(/\s/, 1)[0]);
|
|
1805
|
+
}
|
|
1806
|
+
function rewriteLines(text, render2) {
|
|
1807
|
+
return text.split(/(\r?\n)/).map((part) => part === "\n" || part === "\r\n" ? part : render2(part, credentialSpans(part))).join("");
|
|
1789
1808
|
}
|
|
1790
1809
|
function redactCredentials(raw) {
|
|
1791
1810
|
if (typeof raw !== "string" || raw === "") return raw;
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1811
|
+
const masked = rewriteLines(raw, (line, spans) => {
|
|
1812
|
+
let out = "";
|
|
1813
|
+
let cursor = 0;
|
|
1814
|
+
for (const span of spans) {
|
|
1815
|
+
out += line.slice(cursor, span.passwordStart) + REDACTED;
|
|
1816
|
+
cursor = span.passwordEnd;
|
|
1817
|
+
}
|
|
1818
|
+
return out + line.slice(cursor);
|
|
1819
|
+
});
|
|
1820
|
+
return redactKeywordValues(masked);
|
|
1821
|
+
}
|
|
1822
|
+
function stripCredentials(raw) {
|
|
1823
|
+
if (typeof raw !== "string" || raw === "") return raw;
|
|
1824
|
+
const stripped = rewriteLines(raw, (line, spans) => {
|
|
1825
|
+
let out = "";
|
|
1826
|
+
let cursor = 0;
|
|
1827
|
+
for (const span of spans) {
|
|
1828
|
+
if (span.at === -1) {
|
|
1829
|
+
out += line.slice(cursor, span.passwordStart) + REDACTED;
|
|
1830
|
+
cursor = span.passwordEnd;
|
|
1831
|
+
} else {
|
|
1832
|
+
out += line.slice(cursor, span.authorityStart);
|
|
1833
|
+
cursor = span.at + 1;
|
|
1834
|
+
}
|
|
1835
|
+
}
|
|
1836
|
+
return out + line.slice(cursor);
|
|
1837
|
+
});
|
|
1838
|
+
return redactKeywordValues(stripped);
|
|
1839
|
+
}
|
|
1840
|
+
var REDACTED, SCHEME_MARKER, KEPT_QUERY, SECRET_KEYWORD_PATTERN;
|
|
1841
|
+
var init_urlRedaction = __esm({
|
|
1842
|
+
"../core/src/urlRedaction.ts"() {
|
|
1843
|
+
"use strict";
|
|
1844
|
+
REDACTED = "***";
|
|
1845
|
+
SCHEME_MARKER = /(?<![A-Za-z0-9+.\-/])([A-Za-z][A-Za-z0-9+.-]*)(:\/\/|:\/|\/\/)/g;
|
|
1846
|
+
KEPT_QUERY = /^\?[^\s=&#?]+=[^\s&#?]*(?:&[^\s=&#?]+=[^\s&#?]*)*(?:#\S*)?$/;
|
|
1847
|
+
SECRET_KEYWORD_PATTERN = /(^|[;&?\s])(pwd|password|passwd)(\s*=\s*)/gi;
|
|
1848
|
+
}
|
|
1849
|
+
});
|
|
1850
|
+
|
|
1851
|
+
// ../core/src/connectionUrl.ts
|
|
1852
|
+
function decodeComponent(value) {
|
|
1853
|
+
try {
|
|
1854
|
+
return decodeURIComponent(value);
|
|
1855
|
+
} catch {
|
|
1856
|
+
return value.replace(/(?:%[0-9A-Fa-f]{2})+/g, (seq) => {
|
|
1857
|
+
try {
|
|
1858
|
+
return decodeURIComponent(seq);
|
|
1859
|
+
} catch {
|
|
1860
|
+
return seq;
|
|
1861
|
+
}
|
|
1862
|
+
});
|
|
1863
|
+
}
|
|
1864
|
+
}
|
|
1865
|
+
function splitHostPort(hostPort) {
|
|
1866
|
+
if (hostPort.startsWith("[")) {
|
|
1867
|
+
const close = hostPort.indexOf("]");
|
|
1868
|
+
if (close === -1) return null;
|
|
1869
|
+
const after = hostPort.slice(close + 1);
|
|
1870
|
+
if (after !== "" && !after.startsWith(":")) return null;
|
|
1871
|
+
return [hostPort.slice(1, close), after === "" ? null : after.slice(1)];
|
|
1872
|
+
}
|
|
1873
|
+
const colon = hostPort.indexOf(":");
|
|
1874
|
+
if (colon === -1) return [hostPort, null];
|
|
1875
|
+
return [hostPort.slice(0, colon), hostPort.slice(colon + 1)];
|
|
1876
|
+
}
|
|
1877
|
+
function splitConnectionUrl(raw, options) {
|
|
1878
|
+
const refuse = refuser(raw, options);
|
|
1879
|
+
const { scheme, rest } = schemeAndRest(raw, refuse);
|
|
1880
|
+
const { userinfo, afterUserinfo } = splitUserinfo(rest, refuse);
|
|
1881
|
+
const { hostPort, tail } = hostPortAndTail(afterUserinfo, userinfo !== null, refuse);
|
|
1882
|
+
const { host, port } = firstHost(hostPort, options.allowHostList === true, refuse, userinfo !== null ? hostPort : void 0);
|
|
1883
|
+
refuseDigitLedPassword(userinfo, port, tail, refuse);
|
|
1884
|
+
const { rawUsername, rawPassword } = userinfoParts(userinfo);
|
|
1885
|
+
return {
|
|
1886
|
+
scheme,
|
|
1887
|
+
userinfo,
|
|
1888
|
+
rawUsername,
|
|
1889
|
+
rawPassword,
|
|
1890
|
+
username: decodeOrNull(rawUsername),
|
|
1891
|
+
password: decodeOrNull(rawPassword),
|
|
1892
|
+
hostPort,
|
|
1893
|
+
host,
|
|
1894
|
+
port,
|
|
1895
|
+
tail
|
|
1896
|
+
};
|
|
1897
|
+
}
|
|
1898
|
+
function refuser(raw, options) {
|
|
1899
|
+
const expected = options.expected ?? "scheme://[user[:password]@]host[:port]/path";
|
|
1900
|
+
const named = SCHEME_PREFIX.exec(String(raw ?? ""))?.[1]?.toLowerCase();
|
|
1901
|
+
const subject = `${options.label}: invalid ${named ? `${named} ` : ""}URL`;
|
|
1902
|
+
return (why, hostPort) => new ConnectionUrlError(
|
|
1903
|
+
`${subject}${hostPort ? ` at '${hostPort}'` : ""} (${why}) - expected ${expected}. The URL itself is not shown because it may contain a password.`
|
|
1904
|
+
);
|
|
1905
|
+
}
|
|
1906
|
+
function schemeAndRest(raw, refuse) {
|
|
1907
|
+
if (typeof raw !== "string") throw refuse("not a string");
|
|
1908
|
+
const head = /^([A-Za-z][A-Za-z0-9+.-]*):\/\//.exec(raw);
|
|
1909
|
+
if (!head) throw refuse(SCHEME_PREFIX.test(raw) ? "the scheme must be followed by ://" : "no scheme:// found");
|
|
1910
|
+
return { scheme: head[1].toLowerCase(), rest: raw.slice(head[0].length) };
|
|
1911
|
+
}
|
|
1912
|
+
function splitUserinfo(rest, refuse) {
|
|
1913
|
+
const totalAt = count(rest, "@");
|
|
1914
|
+
if (totalAt === 0) return { userinfo: null, afterUserinfo: rest };
|
|
1915
|
+
const rfcEnd = rest.search(/[/?#]/);
|
|
1916
|
+
const rfcAt = count(rfcEnd === -1 ? rest : rest.slice(0, rfcEnd), "@");
|
|
1917
|
+
const lastAt = rest.lastIndexOf("@");
|
|
1918
|
+
const candidate = rest.slice(0, lastAt);
|
|
1919
|
+
const agrees = rfcAt === totalAt || rfcAt === 0 && hasCleanUser(candidate);
|
|
1920
|
+
if (!agrees) throw refuse(AT_OUTSIDE_USERINFO);
|
|
1921
|
+
return { userinfo: candidate, afterUserinfo: rest.slice(lastAt + 1) };
|
|
1922
|
+
}
|
|
1923
|
+
function hasCleanUser(userinfo) {
|
|
1924
|
+
const colon = userinfo.indexOf(":");
|
|
1925
|
+
return colon !== -1 && !/[/?#]/.test(userinfo.slice(0, colon));
|
|
1926
|
+
}
|
|
1927
|
+
function hostPortAndTail(afterUserinfo, hasUserinfo, refuse) {
|
|
1928
|
+
const hostEnd = afterUserinfo.search(/[/?#]/);
|
|
1929
|
+
const hostPort = hostEnd === -1 ? afterUserinfo : afterUserinfo.slice(0, hostEnd);
|
|
1930
|
+
if (/\s/.test(hostPort)) throw refuse("whitespace in the host");
|
|
1931
|
+
if (hasUserinfo && hostPort === "") throw refuse("no host after the credentials");
|
|
1932
|
+
return { hostPort, tail: afterUserinfo.slice(hostPort.length) };
|
|
1933
|
+
}
|
|
1934
|
+
function firstHost(hostPort, allowHostList, refuse, nameable) {
|
|
1935
|
+
const hosts = allowHostList ? hostPort.split(",") : [hostPort];
|
|
1936
|
+
return hosts.map((piece) => oneHost(piece, refuse, nameable))[0];
|
|
1937
|
+
}
|
|
1938
|
+
function oneHost(piece, refuse, nameable) {
|
|
1939
|
+
const split2 = splitHostPort(piece);
|
|
1940
|
+
if (split2 === null) throw refuse("a malformed IPv6 host", nameable);
|
|
1941
|
+
const [host, port] = split2;
|
|
1942
|
+
if (port === null || port === "") return { host, port: null };
|
|
1943
|
+
if (!/^\d+$/.test(port)) throw refuse("the port must be numeric", nameable);
|
|
1944
|
+
return { host, port: parseInt(port, 10) };
|
|
1945
|
+
}
|
|
1946
|
+
function refuseDigitLedPassword(userinfo, port, tail, refuse) {
|
|
1947
|
+
if (userinfo !== null || port === null) return;
|
|
1948
|
+
if (digitLedPassword(tail)) throw refuse("a port followed by a fragment or a query that is not key=value");
|
|
1949
|
+
}
|
|
1950
|
+
function userinfoParts(userinfo) {
|
|
1951
|
+
if (userinfo === null) return { rawUsername: null, rawPassword: null };
|
|
1952
|
+
const colon = userinfo.indexOf(":");
|
|
1953
|
+
if (colon === -1) return { rawUsername: userinfo, rawPassword: null };
|
|
1954
|
+
return { rawUsername: userinfo.slice(0, colon), rawPassword: userinfo.slice(colon + 1) };
|
|
1955
|
+
}
|
|
1956
|
+
function canonicalConnectionUrl(parts) {
|
|
1957
|
+
let auth = "";
|
|
1958
|
+
if (parts.userinfo !== null) {
|
|
1959
|
+
auth = encodeURIComponent(parts.username ?? "");
|
|
1960
|
+
if (parts.password !== null) auth += `:${encodeURIComponent(parts.password)}`;
|
|
1961
|
+
auth += "@";
|
|
1962
|
+
}
|
|
1963
|
+
return `${parts.scheme}://${auth}${parts.hostPort}${parts.tail}`;
|
|
1964
|
+
}
|
|
1965
|
+
var ConnectionUrlError, count, SCHEME_PREFIX, AT_OUTSIDE_USERINFO, decodeOrNull;
|
|
1966
|
+
var init_connectionUrl = __esm({
|
|
1967
|
+
"../core/src/connectionUrl.ts"() {
|
|
1968
|
+
"use strict";
|
|
1969
|
+
init_urlRedaction();
|
|
1970
|
+
ConnectionUrlError = class extends Error {
|
|
1971
|
+
constructor(message) {
|
|
1972
|
+
super(message);
|
|
1973
|
+
this.name = "ConnectionUrlError";
|
|
1974
|
+
}
|
|
1975
|
+
};
|
|
1976
|
+
count = (text, ch) => text.split(ch).length - 1;
|
|
1977
|
+
SCHEME_PREFIX = /^([A-Za-z][A-Za-z0-9+.-]*):/;
|
|
1978
|
+
AT_OUTSIDE_USERINFO = "an @ outside the user:password part - percent-encode it as %40";
|
|
1979
|
+
decodeOrNull = (value) => value === null ? null : decodeComponent(value);
|
|
1980
|
+
}
|
|
1981
|
+
});
|
|
1982
|
+
|
|
1983
|
+
// ../orm/src/databaseUrl.ts
|
|
1984
|
+
import { inspect } from "node:util";
|
|
1985
|
+
function stripOneSlash(path9) {
|
|
1986
|
+
return path9.startsWith("/") ? path9.slice(1) : path9;
|
|
1987
|
+
}
|
|
1988
|
+
function invalidUrlError(raw, engine, why) {
|
|
1989
|
+
let hostPort;
|
|
1990
|
+
try {
|
|
1991
|
+
const parts = splitConnectionUrl(raw, { label: "DatabaseUrl" });
|
|
1992
|
+
if (parts.userinfo !== null && parts.hostPort !== "") hostPort = parts.hostPort;
|
|
1993
|
+
} catch {
|
|
1994
|
+
}
|
|
1995
|
+
return new ConnectionUrlError(
|
|
1996
|
+
`DatabaseUrl: invalid ${engine} URL${hostPort ? ` at '${hostPort}'` : ""} (${why}) - expected scheme://[user[:password]@]host[:port]/database. The URL itself is not shown because it may contain a password.`
|
|
1812
1997
|
);
|
|
1813
1998
|
}
|
|
1814
|
-
|
|
1999
|
+
function split(url) {
|
|
2000
|
+
return splitConnectionUrl(url, {
|
|
2001
|
+
label: "DatabaseUrl",
|
|
2002
|
+
expected: "scheme://[user[:password]@]host[:port]/database"
|
|
2003
|
+
});
|
|
2004
|
+
}
|
|
2005
|
+
var ENGINE_ALIASES, DEFAULT_PORTS, DatabaseUrl;
|
|
1815
2006
|
var init_databaseUrl = __esm({
|
|
1816
2007
|
"../orm/src/databaseUrl.ts"() {
|
|
1817
2008
|
"use strict";
|
|
2009
|
+
init_urlRedaction();
|
|
2010
|
+
init_connectionUrl();
|
|
1818
2011
|
ENGINE_ALIASES = {
|
|
1819
2012
|
sqlite: "sqlite",
|
|
1820
2013
|
sqlite3: "sqlite",
|
|
@@ -1836,8 +2029,6 @@ var init_databaseUrl = __esm({
|
|
|
1836
2029
|
firebird: 3050,
|
|
1837
2030
|
mongodb: 27017
|
|
1838
2031
|
};
|
|
1839
|
-
REDACTED = "***";
|
|
1840
|
-
SECRET_KEYWORD_PATTERN = /(^|[;&?\s])(pwd|password|passwd)(\s*=\s*)/gi;
|
|
1841
2032
|
DatabaseUrl = class _DatabaseUrl {
|
|
1842
2033
|
engine;
|
|
1843
2034
|
/** Null for sqlite and odbc - a file or a DSN string has no host. */
|
|
@@ -1955,13 +2146,14 @@ var init_databaseUrl = __esm({
|
|
|
1955
2146
|
if (url.startsWith("odbc:///")) {
|
|
1956
2147
|
return { engine: "odbc", connectionString: url.slice("odbc:///".length) };
|
|
1957
2148
|
}
|
|
1958
|
-
|
|
1959
|
-
|
|
2149
|
+
const parts = split(url);
|
|
2150
|
+
if (parts.scheme === "mssql" || parts.scheme === "sqlserver") {
|
|
2151
|
+
return _DatabaseUrl.parsePathForm(url, parts, "mssql");
|
|
1960
2152
|
}
|
|
1961
|
-
if (
|
|
1962
|
-
return _DatabaseUrl.
|
|
2153
|
+
if (parts.scheme === "firebird") {
|
|
2154
|
+
return _DatabaseUrl.parsePathForm(url, parts, "firebird");
|
|
1963
2155
|
}
|
|
1964
|
-
return _DatabaseUrl.parseStandard(url);
|
|
2156
|
+
return _DatabaseUrl.parseStandard(url, parts);
|
|
1965
2157
|
}
|
|
1966
2158
|
/**
|
|
1967
2159
|
* sqlite is parsed on the RAW string. The URL class collapses `sqlite:/x` and
|
|
@@ -1987,52 +2179,62 @@ var init_databaseUrl = __esm({
|
|
|
1987
2179
|
return { engine: "sqlite", database: normalised.slice("sqlite:".length) };
|
|
1988
2180
|
}
|
|
1989
2181
|
/**
|
|
1990
|
-
* mssql and firebird:
|
|
1991
|
-
*
|
|
2182
|
+
* mssql and firebird: `host[:port]/database`, split by the shared splitter.
|
|
2183
|
+
*
|
|
2184
|
+
* These used to be one regex each that split userinfo at the FIRST `@` and
|
|
2185
|
+
* the password at the first `/`, so `mssql://u:p@ss@h/db` connected to a host
|
|
2186
|
+
* named `ss@h` and printed it in the driver's error.
|
|
1992
2187
|
*
|
|
1993
|
-
* The
|
|
2188
|
+
* The database keeps its own leading slash when the URL had two, which is
|
|
1994
2189
|
* how the documented absolute Firebird form survives. The old code did
|
|
1995
2190
|
* `"/" + match[5]`, ADDING a slash - so an absolute path came back with two
|
|
1996
2191
|
* and a relative path was silently made absolute. Verified against live
|
|
1997
2192
|
* Firebird 5.0.4: the driver takes one or two leading slashes and rejects a
|
|
1998
2193
|
* relative path outright.
|
|
1999
2194
|
*/
|
|
2000
|
-
static
|
|
2001
|
-
|
|
2002
|
-
|
|
2195
|
+
static parsePathForm(url, parts, engine) {
|
|
2196
|
+
if (parts.host === "" || /[:/]/.test(parts.host) || parts.hostPort.startsWith("[")) {
|
|
2197
|
+
throw invalidUrlError(url, engine, "a host is required");
|
|
2198
|
+
}
|
|
2199
|
+
if (!parts.tail.startsWith("/")) throw invalidUrlError(url, engine, "a /database is required");
|
|
2003
2200
|
return {
|
|
2004
2201
|
engine,
|
|
2005
|
-
username:
|
|
2006
|
-
password:
|
|
2007
|
-
host:
|
|
2008
|
-
port:
|
|
2009
|
-
database:
|
|
2202
|
+
username: parts.username === "" ? null : parts.username,
|
|
2203
|
+
password: parts.password,
|
|
2204
|
+
host: parts.host,
|
|
2205
|
+
port: parts.port ?? void 0,
|
|
2206
|
+
database: parts.tail.slice(1)
|
|
2010
2207
|
};
|
|
2011
2208
|
}
|
|
2012
|
-
/**
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2209
|
+
/**
|
|
2210
|
+
* postgres / mysql / mongodb.
|
|
2211
|
+
*
|
|
2212
|
+
* Userinfo comes from the shared splitter (the last-`@` rule), never from the
|
|
2213
|
+
* URL class: `new URL()` cuts a password at its first `/`, `?` or `#`, reads
|
|
2214
|
+
* `postgres:/u:pw@h` as a path, and throws a TypeError whose `.input` is the
|
|
2215
|
+
* whole URL. The class only sees a credential-free rebuild, for the host,
|
|
2216
|
+
* port and path it already normalises the way every corpus row expects.
|
|
2217
|
+
*/
|
|
2218
|
+
static parseStandard(url, parts) {
|
|
2219
|
+
const engine = ENGINE_ALIASES[parts.scheme];
|
|
2022
2220
|
if (engine === void 0) {
|
|
2023
2221
|
throw new Error(
|
|
2024
|
-
`DatabaseUrl: Unsupported database scheme '${scheme}'. Supported: ${Object.keys(ENGINE_ALIASES).join(", ")}`
|
|
2222
|
+
`DatabaseUrl: Unsupported database scheme '${parts.scheme}'. Supported: ${Object.keys(ENGINE_ALIASES).join(", ")}`
|
|
2025
2223
|
);
|
|
2026
2224
|
}
|
|
2225
|
+
let parsed;
|
|
2226
|
+
try {
|
|
2227
|
+
parsed = new URL(`${parts.scheme}://${parts.hostPort}${parts.tail}`);
|
|
2228
|
+
} catch {
|
|
2229
|
+
throw invalidUrlError(url, engine, "the host, port or path is malformed");
|
|
2230
|
+
}
|
|
2027
2231
|
const database = stripOneSlash(parsed.pathname);
|
|
2028
|
-
const userinfo = rawUserinfo(url);
|
|
2029
|
-
const passwordWasWritten = userinfo !== null && userinfo.includes(":");
|
|
2030
2232
|
return {
|
|
2031
2233
|
engine,
|
|
2032
2234
|
host: parsed.hostname || void 0,
|
|
2033
2235
|
port: parsed.port ? parseInt(parsed.port, 10) : void 0,
|
|
2034
|
-
username:
|
|
2035
|
-
password:
|
|
2236
|
+
username: parts.username === "" ? null : parts.username,
|
|
2237
|
+
password: parts.password,
|
|
2036
2238
|
database: engine === "mongodb" ? database || "tina4" : database
|
|
2037
2239
|
};
|
|
2038
2240
|
}
|
|
@@ -7578,7 +7780,9 @@ async function buildAdapterFromUrl(url, username, password) {
|
|
|
7578
7780
|
}
|
|
7579
7781
|
case "mongodb": {
|
|
7580
7782
|
const { MongodbAdapter: MongodbAdapter2 } = await Promise.resolve().then(() => (init_mongodb(), mongodb_exports));
|
|
7581
|
-
const adapter = new MongodbAdapter2(
|
|
7783
|
+
const adapter = new MongodbAdapter2(
|
|
7784
|
+
canonicalConnectionUrl(splitConnectionUrl(url, { label: "DatabaseUrl", allowHostList: true }))
|
|
7785
|
+
);
|
|
7582
7786
|
await adapter.connect();
|
|
7583
7787
|
return adapter;
|
|
7584
7788
|
}
|
|
@@ -7717,6 +7921,7 @@ var init_database = __esm({
|
|
|
7717
7921
|
"use strict";
|
|
7718
7922
|
init_databaseResult();
|
|
7719
7923
|
init_databaseUrl();
|
|
7924
|
+
init_connectionUrl();
|
|
7720
7925
|
init_cachedDatabase();
|
|
7721
7926
|
init_sqlTranslator();
|
|
7722
7927
|
init_sqlDialect();
|
|
@@ -10859,9 +11064,9 @@ function splitArithmetic(expr) {
|
|
|
10859
11064
|
return null;
|
|
10860
11065
|
}
|
|
10861
11066
|
function evalArithmeticExpression(expr, context) {
|
|
10862
|
-
const
|
|
10863
|
-
if (!
|
|
10864
|
-
const [pos, op] =
|
|
11067
|
+
const split2 = splitArithmetic(expr);
|
|
11068
|
+
if (!split2) return EXPR_NOT_MATCHED;
|
|
11069
|
+
const [pos, op] = split2;
|
|
10865
11070
|
const lVal = evalExpr(expr.slice(0, pos).trim(), context);
|
|
10866
11071
|
const rVal = evalExpr(expr.slice(pos + op.length).trim(), context);
|
|
10867
11072
|
let lNum = lVal != null ? Number(lVal) : 0;
|
|
@@ -14285,8 +14490,8 @@ var init_queryBuilder = __esm({
|
|
|
14285
14490
|
* @param offset - Number of rows to skip.
|
|
14286
14491
|
* @returns this for chaining.
|
|
14287
14492
|
*/
|
|
14288
|
-
limit(
|
|
14289
|
-
this.limitVal =
|
|
14493
|
+
limit(count2, offset) {
|
|
14494
|
+
this.limitVal = count2;
|
|
14290
14495
|
if (offset !== void 0) {
|
|
14291
14496
|
this.offsetVal = offset;
|
|
14292
14497
|
}
|
|
@@ -14302,8 +14507,8 @@ var init_queryBuilder = __esm({
|
|
|
14302
14507
|
* @param count - Number of rows to skip.
|
|
14303
14508
|
* @returns this for chaining.
|
|
14304
14509
|
*/
|
|
14305
|
-
offset(
|
|
14306
|
-
this.offsetVal =
|
|
14510
|
+
offset(count2) {
|
|
14511
|
+
this.offsetVal = count2;
|
|
14307
14512
|
return this;
|
|
14308
14513
|
}
|
|
14309
14514
|
/**
|
|
@@ -14315,8 +14520,8 @@ var init_queryBuilder = __esm({
|
|
|
14315
14520
|
* @param count - Number of rows to skip.
|
|
14316
14521
|
* @returns this for chaining.
|
|
14317
14522
|
*/
|
|
14318
|
-
skip(
|
|
14319
|
-
return this.offset(
|
|
14523
|
+
skip(count2) {
|
|
14524
|
+
return this.offset(count2);
|
|
14320
14525
|
}
|
|
14321
14526
|
/**
|
|
14322
14527
|
* Alias for `limit()` -- the Eloquent name; pairs with `skip()`.
|
|
@@ -14324,8 +14529,8 @@ var init_queryBuilder = __esm({
|
|
|
14324
14529
|
* @param count - Maximum rows to return.
|
|
14325
14530
|
* @returns this for chaining.
|
|
14326
14531
|
*/
|
|
14327
|
-
take(
|
|
14328
|
-
return this.limit(
|
|
14532
|
+
take(count2) {
|
|
14533
|
+
return this.limit(count2);
|
|
14329
14534
|
}
|
|
14330
14535
|
/**
|
|
14331
14536
|
* Build and return the SQL string without executing.
|
|
@@ -16073,8 +16278,18 @@ var init_baseModel = __esm({
|
|
|
16073
16278
|
// ../core/src/fakeData.ts
|
|
16074
16279
|
import { randomInt, randomUUID } from "node:crypto";
|
|
16075
16280
|
import { existsSync as existsSync8, readdirSync as readdirSync3 } from "node:fs";
|
|
16076
|
-
import { resolve as resolve6, join as join9 } from "node:path";
|
|
16281
|
+
import { resolve as resolve6, join as join9, basename as basename3 } from "node:path";
|
|
16077
16282
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
16283
|
+
function errorText(error2) {
|
|
16284
|
+
return error2 instanceof Error ? error2.message : String(error2);
|
|
16285
|
+
}
|
|
16286
|
+
function isSeedFile(name) {
|
|
16287
|
+
return (name.endsWith(".ts") || name.endsWith(".js")) && !name.startsWith("_");
|
|
16288
|
+
}
|
|
16289
|
+
function seedEntry(mod) {
|
|
16290
|
+
const entry = typeof mod.default === "function" ? mod.default : mod.run;
|
|
16291
|
+
return typeof entry === "function" ? entry : void 0;
|
|
16292
|
+
}
|
|
16078
16293
|
function mulberry32(seed) {
|
|
16079
16294
|
let s = seed | 0;
|
|
16080
16295
|
return () => {
|
|
@@ -16084,10 +16299,21 @@ function mulberry32(seed) {
|
|
|
16084
16299
|
return ((t ^ t >>> 14) >>> 0) / 4294967296;
|
|
16085
16300
|
};
|
|
16086
16301
|
}
|
|
16087
|
-
var FIRST_NAMES, LAST_NAMES, DOMAINS, WORDS, CITIES, COUNTRIES, STREETS, JOB_TITLES, CURRENCIES, PRODUCT_ADJECTIVES, PRODUCT_NOUNS, FakeData;
|
|
16302
|
+
var SeedError, FIRST_NAMES, LAST_NAMES, DOMAINS, WORDS, CITIES, COUNTRIES, STREETS, JOB_TITLES, CURRENCIES, PRODUCT_ADJECTIVES, PRODUCT_NOUNS, FakeData;
|
|
16088
16303
|
var init_fakeData = __esm({
|
|
16089
16304
|
"../core/src/fakeData.ts"() {
|
|
16090
16305
|
"use strict";
|
|
16306
|
+
init_logger();
|
|
16307
|
+
SeedError = class extends Error {
|
|
16308
|
+
seedFile;
|
|
16309
|
+
completed;
|
|
16310
|
+
constructor(seedFile, completed, cause) {
|
|
16311
|
+
super(`Seed file failed: ${basename3(seedFile)}: ${errorText(cause)}`, { cause });
|
|
16312
|
+
this.name = "SeedError";
|
|
16313
|
+
this.seedFile = seedFile;
|
|
16314
|
+
this.completed = [...completed];
|
|
16315
|
+
}
|
|
16316
|
+
};
|
|
16091
16317
|
FIRST_NAMES = [
|
|
16092
16318
|
"Alice",
|
|
16093
16319
|
"Bob",
|
|
@@ -16567,33 +16793,37 @@ var init_fakeData = __esm({
|
|
|
16567
16793
|
return items[this.randInt(0, items.length)];
|
|
16568
16794
|
}
|
|
16569
16795
|
/**
|
|
16570
|
-
* Run seed files
|
|
16571
|
-
*
|
|
16796
|
+
* Run the seed files in a directory in name order, skipping files whose name
|
|
16797
|
+
* starts with "_". A file's default export, or else the named run() that
|
|
16798
|
+
* `generate seeder` writes, is awaited when it is a function.
|
|
16799
|
+
* Returns the executed file paths in order ([] when the directory is missing).
|
|
16800
|
+
* A seed file that throws stops the run: it is logged and a SeedError naming
|
|
16801
|
+
* it is thrown, and no later file runs (ADR-0108).
|
|
16572
16802
|
*/
|
|
16573
16803
|
async seedDir(seedDir) {
|
|
16574
16804
|
const dir = resolve6(seedDir ?? "src/seeds");
|
|
16575
16805
|
if (!existsSync8(dir)) return [];
|
|
16576
|
-
const files = readdirSync3(dir).filter(
|
|
16806
|
+
const files = readdirSync3(dir).filter(isSeedFile).sort();
|
|
16577
16807
|
const executed = [];
|
|
16578
16808
|
for (const file of files) {
|
|
16579
16809
|
const fullPath = join9(dir, file);
|
|
16580
16810
|
try {
|
|
16581
16811
|
const mod = await import(pathToFileURL2(fullPath).href);
|
|
16582
|
-
|
|
16583
|
-
|
|
16584
|
-
}
|
|
16585
|
-
|
|
16586
|
-
} catch {
|
|
16812
|
+
await seedEntry(mod)?.();
|
|
16813
|
+
} catch (error2) {
|
|
16814
|
+
Log.error(`Seeder: ${file} failed, seeding stopped: ${errorText(error2)}`);
|
|
16815
|
+
throw new SeedError(fullPath, executed, error2);
|
|
16587
16816
|
}
|
|
16817
|
+
executed.push(fullPath);
|
|
16588
16818
|
}
|
|
16589
16819
|
return executed;
|
|
16590
16820
|
}
|
|
16591
16821
|
/**
|
|
16592
16822
|
* Run a generator function `count` times and return the results.
|
|
16593
16823
|
*/
|
|
16594
|
-
run(fn,
|
|
16824
|
+
run(fn, count2 = 1) {
|
|
16595
16825
|
const results = [];
|
|
16596
|
-
for (let i = 0; i <
|
|
16826
|
+
for (let i = 0; i < count2; i++) {
|
|
16597
16827
|
results.push(fn());
|
|
16598
16828
|
}
|
|
16599
16829
|
return results;
|
|
@@ -16765,7 +16995,7 @@ async function autoFieldMap(db, table2, fake = new FakeData2()) {
|
|
|
16765
16995
|
}
|
|
16766
16996
|
return fieldMap;
|
|
16767
16997
|
}
|
|
16768
|
-
async function seedTable(db, tableName,
|
|
16998
|
+
async function seedTable(db, tableName, count2 = 10, fieldMap, overrides, opts) {
|
|
16769
16999
|
if (opts?.seed !== void 0) {
|
|
16770
17000
|
throw new Error(
|
|
16771
17001
|
"seedTable() no longer accepts opts.seed: it has no generators of its own to seed (fieldMap callables are opaque). Build a seeded FakeData yourself and close over it in fieldMap, e.g. const fake = new FakeData(42); seedTable(db, table, count, { name: () => fake.name() })."
|
|
@@ -16777,7 +17007,7 @@ async function seedTable(db, tableName, count = 10, fieldMap, overrides, opts) {
|
|
|
16777
17007
|
let seeded = 0;
|
|
16778
17008
|
let failed = 0;
|
|
16779
17009
|
const errors = [];
|
|
16780
|
-
for (let i = 0; i <
|
|
17010
|
+
for (let i = 0; i < count2; i++) {
|
|
16781
17011
|
try {
|
|
16782
17012
|
const row = {};
|
|
16783
17013
|
for (const [column2, generator] of Object.entries(fieldMap)) {
|
|
@@ -16864,7 +17094,7 @@ function pkFieldOf(fields) {
|
|
|
16864
17094
|
}
|
|
16865
17095
|
return "id";
|
|
16866
17096
|
}
|
|
16867
|
-
async function seedOrm(ormClass,
|
|
17097
|
+
async function seedOrm(ormClass, count2 = 10, overrides, seed, opts, fkPools) {
|
|
16868
17098
|
const merged = { ...opts ?? {} };
|
|
16869
17099
|
const effectiveOverrides = merged.overrides ?? overrides;
|
|
16870
17100
|
const effectiveSeed = merged.seed ?? seed;
|
|
@@ -16894,7 +17124,7 @@ async function seedOrm(ormClass, count = 10, overrides, seed, opts, fkPools) {
|
|
|
16894
17124
|
let seeded = 0;
|
|
16895
17125
|
let failed = 0;
|
|
16896
17126
|
const errors = [];
|
|
16897
|
-
for (let i = 0; i <
|
|
17127
|
+
for (let i = 0; i < count2; i++) {
|
|
16898
17128
|
try {
|
|
16899
17129
|
const attrs = {};
|
|
16900
17130
|
for (const [name, def] of Object.entries(fields)) {
|
|
@@ -16975,7 +17205,7 @@ function topoSortModels(ormClasses) {
|
|
|
16975
17205
|
ordered.push(...remaining);
|
|
16976
17206
|
return ordered;
|
|
16977
17207
|
}
|
|
16978
|
-
async function seedModels(ormClasses,
|
|
17208
|
+
async function seedModels(ormClasses, count2 = 10, opts) {
|
|
16979
17209
|
const clear = opts?.clear ?? false;
|
|
16980
17210
|
const seed = opts?.seed;
|
|
16981
17211
|
const strict = opts?.strict ?? false;
|
|
@@ -17003,7 +17233,7 @@ async function seedModels(ormClasses, count = 10, opts) {
|
|
|
17003
17233
|
}
|
|
17004
17234
|
const summary = await seedOrm(
|
|
17005
17235
|
model,
|
|
17006
|
-
|
|
17236
|
+
count2,
|
|
17007
17237
|
void 0,
|
|
17008
17238
|
void 0,
|
|
17009
17239
|
{ overrides: modelOverrides, clear: false, seed, strict },
|
|
@@ -17351,7 +17581,9 @@ function mongoConnection(uri, dbName) {
|
|
|
17351
17581
|
if (!pending) {
|
|
17352
17582
|
pending = (async () => {
|
|
17353
17583
|
const { MongoClient } = await importMongoDriver();
|
|
17354
|
-
const client = new MongoClient(
|
|
17584
|
+
const client = new MongoClient(
|
|
17585
|
+
canonicalConnectionUrl(splitConnectionUrl(uri, { label: "DocStore", allowHostList: true }))
|
|
17586
|
+
);
|
|
17355
17587
|
await client.connect();
|
|
17356
17588
|
return { client, db: client.db(dbName) };
|
|
17357
17589
|
})();
|
|
@@ -17381,6 +17613,7 @@ var InvalidId, OID_RE, ISO_RE, ObjectId, COMPARATORS, SAFE_PATH_SEGMENT, Cursor,
|
|
|
17381
17613
|
var init_docstore = __esm({
|
|
17382
17614
|
"../orm/src/docstore.ts"() {
|
|
17383
17615
|
"use strict";
|
|
17616
|
+
init_connectionUrl();
|
|
17384
17617
|
InvalidId = class extends Error {
|
|
17385
17618
|
constructor(message) {
|
|
17386
17619
|
super(message);
|
|
@@ -17722,11 +17955,13 @@ var init_docstore = __esm({
|
|
|
17722
17955
|
});
|
|
17723
17956
|
|
|
17724
17957
|
// ../orm/src/graph/graphUrl.ts
|
|
17958
|
+
import { inspect as inspect2 } from "node:util";
|
|
17725
17959
|
var SCHEME_ENGINE, ENGINE_DEFAULT_PORT, GraphUrl;
|
|
17726
17960
|
var init_graphUrl = __esm({
|
|
17727
17961
|
"../orm/src/graph/graphUrl.ts"() {
|
|
17728
17962
|
"use strict";
|
|
17729
|
-
|
|
17963
|
+
init_urlRedaction();
|
|
17964
|
+
init_connectionUrl();
|
|
17730
17965
|
SCHEME_ENGINE = {
|
|
17731
17966
|
ultipa: "ultipa",
|
|
17732
17967
|
ultipas: "ultipa",
|
|
@@ -17758,12 +17993,14 @@ var init_graphUrl = __esm({
|
|
|
17758
17993
|
useTls;
|
|
17759
17994
|
constructor(url) {
|
|
17760
17995
|
this.raw = url;
|
|
17996
|
+
const expected = "scheme://[user[:password]@]host[:port]/graph (e.g. ultipa://host:60061/mygraph)";
|
|
17997
|
+
const parts = splitConnectionUrl(url, { label: "GraphUrl", expected });
|
|
17761
17998
|
let parsed;
|
|
17762
17999
|
try {
|
|
17763
|
-
parsed = new URL(
|
|
18000
|
+
parsed = new URL(`${parts.scheme}://${parts.hostPort}${parts.tail}`);
|
|
17764
18001
|
} catch {
|
|
17765
|
-
throw new
|
|
17766
|
-
`
|
|
18002
|
+
throw new ConnectionUrlError(
|
|
18003
|
+
`GraphUrl: invalid ${parts.scheme} URL - expected ${expected}. The URL itself is not shown because it may contain a password.`
|
|
17767
18004
|
);
|
|
17768
18005
|
}
|
|
17769
18006
|
const scheme = parsed.protocol.replace(/:$/, "").toLowerCase();
|
|
@@ -17779,14 +18016,38 @@ var init_graphUrl = __esm({
|
|
|
17779
18016
|
this.port = parsed.port ? parseInt(parsed.port, 10) : ENGINE_DEFAULT_PORT[engine];
|
|
17780
18017
|
const path9 = (parsed.pathname || "").replace(/^\//, "");
|
|
17781
18018
|
this.graph = path9 === "" ? null : path9;
|
|
17782
|
-
this.username =
|
|
17783
|
-
this.password =
|
|
18019
|
+
this.username = parts.username ? parts.username : null;
|
|
18020
|
+
this.password = parts.password ? parts.password : null;
|
|
17784
18021
|
this.params = {};
|
|
17785
18022
|
for (const [key, value] of parsed.searchParams) {
|
|
17786
18023
|
if (!(key in this.params)) this.params[key] = value;
|
|
17787
18024
|
}
|
|
17788
18025
|
this.useTls = scheme.endsWith("s") || this.params.tls === "1" || this.params.tls === "true";
|
|
17789
18026
|
}
|
|
18027
|
+
/**
|
|
18028
|
+
* What `JSON.stringify` emits, directly or as one field of a logged object.
|
|
18029
|
+
* `password` and `raw` both hold the secret, so the default dump printed it
|
|
18030
|
+
* twice (GHSA-h2mr-m3v3-cq8c). DatabaseUrl guards the same way; PHP has
|
|
18031
|
+
* __debugInfo/jsonSerialize and Ruby a redacted #inspect.
|
|
18032
|
+
*/
|
|
18033
|
+
toJSON() {
|
|
18034
|
+
return {
|
|
18035
|
+
raw: redactCredentials(this.raw),
|
|
18036
|
+
scheme: this.scheme,
|
|
18037
|
+
engine: this.engine,
|
|
18038
|
+
host: this.host,
|
|
18039
|
+
port: this.port,
|
|
18040
|
+
graph: this.graph,
|
|
18041
|
+
username: this.username,
|
|
18042
|
+
password: this.password === null ? null : "***",
|
|
18043
|
+
params: this.params,
|
|
18044
|
+
useTls: this.useTls
|
|
18045
|
+
};
|
|
18046
|
+
}
|
|
18047
|
+
/** What `console.log(url)` / `util.inspect(url)` print. */
|
|
18048
|
+
[inspect2.custom]() {
|
|
18049
|
+
return `GraphUrl('${redactCredentials(this.raw)}')`;
|
|
18050
|
+
}
|
|
17790
18051
|
/** host:port/graph — for messages, never carrying credentials. */
|
|
17791
18052
|
getDsn() {
|
|
17792
18053
|
const target = this.port ? `${this.host}:${this.port}` : this.host;
|
|
@@ -19899,11 +20160,11 @@ ${s}\r
|
|
|
19899
20160
|
return { value: str, next: after + len + 2 };
|
|
19900
20161
|
}
|
|
19901
20162
|
case 42: {
|
|
19902
|
-
const
|
|
19903
|
-
if (
|
|
20163
|
+
const count2 = parseInt(line, 10);
|
|
20164
|
+
if (count2 === -1) return { value: null, next: after };
|
|
19904
20165
|
const arr = [];
|
|
19905
20166
|
let pos = after;
|
|
19906
|
-
for (let i = 0; i <
|
|
20167
|
+
for (let i = 0; i < count2; i++) {
|
|
19907
20168
|
const el = _RespClient.parse(buf, pos);
|
|
19908
20169
|
if (!el) return null;
|
|
19909
20170
|
arr.push(el.value);
|
|
@@ -20204,7 +20465,7 @@ ${s}\r
|
|
|
20204
20465
|
}
|
|
20205
20466
|
async stats() {
|
|
20206
20467
|
const now = Date.now() / 1e3;
|
|
20207
|
-
let
|
|
20468
|
+
let count2 = 0;
|
|
20208
20469
|
try {
|
|
20209
20470
|
const files = fs.readdirSync(this.dir).filter((f) => f.endsWith(".json"));
|
|
20210
20471
|
for (const f of files) {
|
|
@@ -20213,14 +20474,14 @@ ${s}\r
|
|
|
20213
20474
|
if (data.expiresAt && now > data.expiresAt) {
|
|
20214
20475
|
fs.unlinkSync(path.join(this.dir, f));
|
|
20215
20476
|
} else {
|
|
20216
|
-
|
|
20477
|
+
count2++;
|
|
20217
20478
|
}
|
|
20218
20479
|
} catch {
|
|
20219
20480
|
}
|
|
20220
20481
|
}
|
|
20221
20482
|
} catch {
|
|
20222
20483
|
}
|
|
20223
|
-
return { hits: this.hits, misses: this.misses, size:
|
|
20484
|
+
return { hits: this.hits, misses: this.misses, size: count2, backend: "file" };
|
|
20224
20485
|
}
|
|
20225
20486
|
/**
|
|
20226
20487
|
* Delete expired cache files and count them. `expiresAt > 0` is load-bearing:
|
|
@@ -21021,18 +21282,18 @@ var init_router = __esm({
|
|
|
21021
21282
|
}
|
|
21022
21283
|
};
|
|
21023
21284
|
RouteRef = class {
|
|
21285
|
+
routes;
|
|
21024
21286
|
constructor(route) {
|
|
21025
|
-
this.
|
|
21287
|
+
this.routes = Array.isArray(route) ? route : [route];
|
|
21026
21288
|
}
|
|
21027
|
-
route;
|
|
21028
21289
|
/** Mark this route as requiring bearer-token authentication. */
|
|
21029
21290
|
secure() {
|
|
21030
|
-
this.route.secure = true;
|
|
21291
|
+
for (const route of this.routes) route.secure = true;
|
|
21031
21292
|
return this;
|
|
21032
21293
|
}
|
|
21033
21294
|
/** Opt out of secure-by-default auth (for public write routes). */
|
|
21034
21295
|
noAuth() {
|
|
21035
|
-
this.route.noAuth = true;
|
|
21296
|
+
for (const route of this.routes) route.noAuth = true;
|
|
21036
21297
|
return this;
|
|
21037
21298
|
}
|
|
21038
21299
|
/**
|
|
@@ -21042,7 +21303,7 @@ var init_router = __esm({
|
|
|
21042
21303
|
* (identity) are orthogonal — chain `.noAuth().noCsrf()` for a public webhook.
|
|
21043
21304
|
*/
|
|
21044
21305
|
noCsrf() {
|
|
21045
|
-
this.route.noCsrf = true;
|
|
21306
|
+
for (const route of this.routes) route.noCsrf = true;
|
|
21046
21307
|
return this;
|
|
21047
21308
|
}
|
|
21048
21309
|
/**
|
|
@@ -21050,12 +21311,7 @@ var init_router = __esm({
|
|
|
21050
21311
|
* claim. Chain .role()/.can() for AND. Implies auth. Feature 138 / ADR-0058.
|
|
21051
21312
|
*/
|
|
21052
21313
|
role(...names) {
|
|
21053
|
-
|
|
21054
|
-
if (clean.length > 0) {
|
|
21055
|
-
(this.route.requiredRoles ??= []).push(clean);
|
|
21056
|
-
this.route.secure = true;
|
|
21057
|
-
}
|
|
21058
|
-
return this;
|
|
21314
|
+
return this.guard("requiredRoles", names);
|
|
21059
21315
|
}
|
|
21060
21316
|
/**
|
|
21061
21317
|
* RBAC: require ONE of the named permissions (OR). Reads the verified JWT
|
|
@@ -21063,16 +21319,26 @@ var init_router = __esm({
|
|
|
21063
21319
|
* concrete requirement. Chain for AND. Implies auth. Feature 138.
|
|
21064
21320
|
*/
|
|
21065
21321
|
can(...permissions) {
|
|
21066
|
-
|
|
21322
|
+
return this.guard("requiredPerms", permissions);
|
|
21323
|
+
}
|
|
21324
|
+
/**
|
|
21325
|
+
* Add one OR-group of roles or permissions to every route this ref covers,
|
|
21326
|
+
* and secure them (a guard implies auth). Empty names are dropped; a call
|
|
21327
|
+
* with none left changes nothing.
|
|
21328
|
+
*/
|
|
21329
|
+
guard(key, names) {
|
|
21330
|
+
const clean = names.filter((n) => n !== "");
|
|
21067
21331
|
if (clean.length > 0) {
|
|
21068
|
-
(
|
|
21069
|
-
|
|
21332
|
+
for (const route of this.routes) {
|
|
21333
|
+
(route[key] ??= []).push(clean);
|
|
21334
|
+
route.secure = true;
|
|
21335
|
+
}
|
|
21070
21336
|
}
|
|
21071
21337
|
return this;
|
|
21072
21338
|
}
|
|
21073
21339
|
/** Mark this route's response as cacheable. */
|
|
21074
21340
|
cache() {
|
|
21075
|
-
this.route.cached = true;
|
|
21341
|
+
for (const route of this.routes) route.cached = true;
|
|
21076
21342
|
return this;
|
|
21077
21343
|
}
|
|
21078
21344
|
/**
|
|
@@ -21080,7 +21346,9 @@ var init_router = __esm({
|
|
|
21080
21346
|
* string specs (e.g. `"ResponseCache:300"`), resolved when the route runs.
|
|
21081
21347
|
*/
|
|
21082
21348
|
middleware(...middlewareClasses) {
|
|
21083
|
-
|
|
21349
|
+
for (const route of this.routes) {
|
|
21350
|
+
route.middlewares = [...route.middlewares ?? [], ...middlewareClasses];
|
|
21351
|
+
}
|
|
21084
21352
|
return this;
|
|
21085
21353
|
}
|
|
21086
21354
|
};
|
|
@@ -21112,6 +21380,10 @@ var init_router = __esm({
|
|
|
21112
21380
|
* Add a raw route definition (used internally and by file-based routing).
|
|
21113
21381
|
*/
|
|
21114
21382
|
addRoute(definition) {
|
|
21383
|
+
return new RouteRef(this.registerRoute(definition));
|
|
21384
|
+
}
|
|
21385
|
+
/** Compile and store one route definition; returns the stored route. */
|
|
21386
|
+
registerRoute(definition) {
|
|
21115
21387
|
const method = definition.method.toUpperCase();
|
|
21116
21388
|
const { regex, paramNames, paramTypes } = this.compilePattern(definition.pattern);
|
|
21117
21389
|
if (!this.routes.has(method)) {
|
|
@@ -21143,7 +21415,7 @@ var init_router = __esm({
|
|
|
21143
21415
|
requiredPerms: definition.requiredPerms
|
|
21144
21416
|
};
|
|
21145
21417
|
routes.push(compiled);
|
|
21146
|
-
return
|
|
21418
|
+
return compiled;
|
|
21147
21419
|
}
|
|
21148
21420
|
/**
|
|
21149
21421
|
* Register a GET route programmatically.
|
|
@@ -21197,13 +21469,16 @@ var init_router = __esm({
|
|
|
21197
21469
|
}
|
|
21198
21470
|
/**
|
|
21199
21471
|
* Register a route that matches ANY HTTP method.
|
|
21472
|
+
*
|
|
21473
|
+
* One route is stored per method; the returned ref covers all of them, so
|
|
21474
|
+
* `any(...).secure()` / `.role()` / `.noAuth()` apply to every method.
|
|
21200
21475
|
*/
|
|
21201
21476
|
any(path9, handler, middlewares, meta) {
|
|
21202
|
-
|
|
21477
|
+
const compiled = [];
|
|
21203
21478
|
for (const method of ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"]) {
|
|
21204
|
-
|
|
21479
|
+
compiled.push(this.registerRoute({ method, pattern: path9, handler, middlewares, meta }));
|
|
21205
21480
|
}
|
|
21206
|
-
return
|
|
21481
|
+
return new RouteRef(compiled);
|
|
21207
21482
|
}
|
|
21208
21483
|
/**
|
|
21209
21484
|
* Create a route group with a shared prefix and optional middlewares.
|
|
@@ -21628,17 +21903,7 @@ var init_router = __esm({
|
|
|
21628
21903
|
});
|
|
21629
21904
|
}
|
|
21630
21905
|
any(path9, handler, middlewares, meta) {
|
|
21631
|
-
|
|
21632
|
-
for (const method of ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"]) {
|
|
21633
|
-
lastRef = this.router.addRoute({
|
|
21634
|
-
method,
|
|
21635
|
-
pattern: joinGroupPath(this.prefix, path9),
|
|
21636
|
-
handler,
|
|
21637
|
-
middlewares: this.mergeMiddlewares(middlewares),
|
|
21638
|
-
meta
|
|
21639
|
-
});
|
|
21640
|
-
}
|
|
21641
|
-
return lastRef;
|
|
21906
|
+
return this.router.any(joinGroupPath(this.prefix, path9), handler, this.mergeMiddlewares(middlewares), meta);
|
|
21642
21907
|
}
|
|
21643
21908
|
/**
|
|
21644
21909
|
* Nested groups.
|
|
@@ -23395,9 +23660,9 @@ function nestFormFields(pairs) {
|
|
|
23395
23660
|
return params;
|
|
23396
23661
|
};
|
|
23397
23662
|
const tooDeep = (name) => {
|
|
23398
|
-
let
|
|
23663
|
+
let count2 = 0;
|
|
23399
23664
|
for (let at = name.indexOf("["); at !== -1; at = name.indexOf("[", at + 1)) {
|
|
23400
|
-
if (++
|
|
23665
|
+
if (++count2 >= FORM_DEPTH_LIMIT) return true;
|
|
23401
23666
|
}
|
|
23402
23667
|
return false;
|
|
23403
23668
|
};
|
|
@@ -23821,7 +24086,7 @@ __export(routeDiscovery_exports, {
|
|
|
23821
24086
|
rediscoverRoutes: () => rediscoverRoutes
|
|
23822
24087
|
});
|
|
23823
24088
|
import { readdirSync as readdirSync5, statSync as statSync7, mkdirSync as mkdirSync9, writeFileSync as writeFileSync6, existsSync as existsSync10 } from "node:fs";
|
|
23824
|
-
import { join as join13, relative, basename as
|
|
24089
|
+
import { join as join13, relative, basename as basename4, extname as extname2 } from "node:path";
|
|
23825
24090
|
import { pathToFileURL as pathToFileURL3 } from "node:url";
|
|
23826
24091
|
function boolExport(value) {
|
|
23827
24092
|
return typeof value === "boolean" ? value : void 0;
|
|
@@ -23835,7 +24100,7 @@ async function discoverRoutes(routesDir) {
|
|
|
23835
24100
|
for (const filePath of files) {
|
|
23836
24101
|
const ext = extname2(filePath);
|
|
23837
24102
|
if (ext !== ".ts" && ext !== ".js") continue;
|
|
23838
|
-
const name =
|
|
24103
|
+
const name = basename4(filePath, ext).toLowerCase();
|
|
23839
24104
|
if (!VALID_METHODS.has(name)) continue;
|
|
23840
24105
|
routeFileCount++;
|
|
23841
24106
|
const currentMtime = statSync7(filePath).mtimeMs;
|
|
@@ -24535,11 +24800,11 @@ var init_memcachedHandler = __esm({
|
|
|
24535
24800
|
const resp = this.command(`get ${this.key(sessionId)}\r
|
|
24536
24801
|
`, ["END\r\n"]);
|
|
24537
24802
|
if (!resp.startsWith("VALUE")) return null;
|
|
24538
|
-
const
|
|
24539
|
-
if (
|
|
24540
|
-
const header = resp.slice(0,
|
|
24803
|
+
const split2 = resp.indexOf("\r\n");
|
|
24804
|
+
if (split2 === -1) return null;
|
|
24805
|
+
const header = resp.slice(0, split2).split(" ");
|
|
24541
24806
|
const bytes = parseInt(header[3] ?? "0", 10);
|
|
24542
|
-
const body = Buffer.from(resp.slice(
|
|
24807
|
+
const body = Buffer.from(resp.slice(split2 + 2), "utf-8").subarray(0, bytes).toString("utf-8");
|
|
24543
24808
|
try {
|
|
24544
24809
|
return JSON.parse(body);
|
|
24545
24810
|
} catch {
|
|
@@ -25168,7 +25433,7 @@ function column(row, name) {
|
|
|
25168
25433
|
if (name in row) return row[name];
|
|
25169
25434
|
return row[name.toUpperCase()];
|
|
25170
25435
|
}
|
|
25171
|
-
function
|
|
25436
|
+
function schemeOf(url) {
|
|
25172
25437
|
const match = url.match(/^([a-zA-Z][a-zA-Z0-9+.-]*):/);
|
|
25173
25438
|
return match ? match[1].toLowerCase() : "unknown";
|
|
25174
25439
|
}
|
|
@@ -25359,7 +25624,7 @@ var init_databaseHandler = __esm({
|
|
|
25359
25624
|
process.env.TINA4_DATABASE_PASSWORD
|
|
25360
25625
|
);
|
|
25361
25626
|
} catch {
|
|
25362
|
-
throw this.unsupportedEngine(
|
|
25627
|
+
throw this.unsupportedEngine(schemeOf(url));
|
|
25363
25628
|
}
|
|
25364
25629
|
if (!SQL_SESSION_ENGINES.includes(parsed.engine)) {
|
|
25365
25630
|
throw this.unsupportedEngine(parsed.engine);
|
|
@@ -27100,19 +27365,19 @@ var init_devMailbox = __esm({
|
|
|
27100
27365
|
*/
|
|
27101
27366
|
unreadCount() {
|
|
27102
27367
|
const dir = this.ensureFolder("inbox");
|
|
27103
|
-
let
|
|
27368
|
+
let count2 = 0;
|
|
27104
27369
|
try {
|
|
27105
27370
|
const files = readdirSync7(dir).filter((f) => f.endsWith(".json"));
|
|
27106
27371
|
for (const file of files) {
|
|
27107
27372
|
try {
|
|
27108
27373
|
const msg = JSON.parse(readFileSync11(join18(dir, file), "utf-8"));
|
|
27109
|
-
if (!msg.read)
|
|
27374
|
+
if (!msg.read) count2++;
|
|
27110
27375
|
} catch {
|
|
27111
27376
|
}
|
|
27112
27377
|
}
|
|
27113
27378
|
} catch {
|
|
27114
27379
|
}
|
|
27115
|
-
return
|
|
27380
|
+
return count2;
|
|
27116
27381
|
}
|
|
27117
27382
|
/**
|
|
27118
27383
|
* Delete a message by ID. Removes from all folders.
|
|
@@ -27153,7 +27418,7 @@ var init_devMailbox = __esm({
|
|
|
27153
27418
|
/**
|
|
27154
27419
|
* Seed the mailbox with sample messages for development.
|
|
27155
27420
|
*/
|
|
27156
|
-
seed(
|
|
27421
|
+
seed(count2 = 5) {
|
|
27157
27422
|
const subjects = [
|
|
27158
27423
|
"Welcome to Tina4",
|
|
27159
27424
|
"Your account has been created",
|
|
@@ -27173,7 +27438,7 @@ var init_devMailbox = __esm({
|
|
|
27173
27438
|
"billing@service.io",
|
|
27174
27439
|
"alerts@monitoring.dev"
|
|
27175
27440
|
];
|
|
27176
|
-
for (let i = 0; i <
|
|
27441
|
+
for (let i = 0; i < count2; i++) {
|
|
27177
27442
|
const subject = subjects[i % subjects.length];
|
|
27178
27443
|
const from = senders[i % senders.length];
|
|
27179
27444
|
const date = new Date(Date.now() - i * 36e5).toISOString();
|
|
@@ -30715,12 +30980,12 @@ function registerDevTools(server) {
|
|
|
30715
30980
|
return { error: "No database connection" };
|
|
30716
30981
|
}
|
|
30717
30982
|
if (!adapter) return { error: "No database connection" };
|
|
30718
|
-
const
|
|
30983
|
+
const count2 = args.count || 10;
|
|
30719
30984
|
const fieldMap = await orm.autoFieldMap(adapter, args.table);
|
|
30720
30985
|
if (!fieldMap || Object.keys(fieldMap).length === 0) {
|
|
30721
30986
|
return { error: `Table '${args.table}' not found or has no seedable columns` };
|
|
30722
30987
|
}
|
|
30723
|
-
const summary = await orm.seedTable(adapter, args.table,
|
|
30988
|
+
const summary = await orm.seedTable(adapter, args.table, count2, fieldMap);
|
|
30724
30989
|
return { table: args.table, inserted: summary.seeded, failed: summary.failed };
|
|
30725
30990
|
} catch (e) {
|
|
30726
30991
|
return { error: e.message };
|
|
@@ -30892,7 +31157,7 @@ function registerDevTools(server) {
|
|
|
30892
31157
|
let rel = args.path || "";
|
|
30893
31158
|
const oldStr = args.old_string || "";
|
|
30894
31159
|
const newStr = args.new_string || "";
|
|
30895
|
-
const
|
|
31160
|
+
const count2 = args.count || 1;
|
|
30896
31161
|
const projectRoot4 = path3.resolve(process.cwd());
|
|
30897
31162
|
const proseErr = looksLikeProse(rel);
|
|
30898
31163
|
if (proseErr) {
|
|
@@ -30913,13 +31178,13 @@ function registerDevTools(server) {
|
|
|
30913
31178
|
let idx = -1;
|
|
30914
31179
|
while ((idx = original.indexOf(oldStr, idx + 1)) !== -1) occurrences++;
|
|
30915
31180
|
if (occurrences === 0) return { error: `old_string not found in ${rel}` };
|
|
30916
|
-
if (occurrences !==
|
|
31181
|
+
if (occurrences !== count2) {
|
|
30917
31182
|
return {
|
|
30918
|
-
error: `old_string appears ${occurrences} times, expected ${
|
|
31183
|
+
error: `old_string appears ${occurrences} times, expected ${count2}. Expand old_string to make it unique, or set count explicitly.`
|
|
30919
31184
|
};
|
|
30920
31185
|
}
|
|
30921
31186
|
let updated = original;
|
|
30922
|
-
for (let i = 0; i <
|
|
31187
|
+
for (let i = 0; i < count2; i++) updated = updated.replace(oldStr, newStr);
|
|
30923
31188
|
const backupRel = agentBackup(projectRoot4, resolved);
|
|
30924
31189
|
fs4.writeFileSync(resolved, updated, "utf-8");
|
|
30925
31190
|
try {
|
|
@@ -30931,11 +31196,11 @@ function registerDevTools(server) {
|
|
|
30931
31196
|
agentLog(
|
|
30932
31197
|
projectRoot4,
|
|
30933
31198
|
"patch.ok",
|
|
30934
|
-
`${rel} (replaced ${
|
|
31199
|
+
`${rel} (replaced ${count2}\xD7 old_string, ${oldSize}B \u2192 ${newSize}B, backup: ${backupRel || "(none)"})`
|
|
30935
31200
|
);
|
|
30936
31201
|
const result = {
|
|
30937
31202
|
patched: rel,
|
|
30938
|
-
replacements:
|
|
31203
|
+
replacements: count2,
|
|
30939
31204
|
bytes: newSize
|
|
30940
31205
|
};
|
|
30941
31206
|
if (backupRel) {
|
|
@@ -32145,12 +32410,12 @@ var init_graphql = __esm({
|
|
|
32145
32410
|
*/
|
|
32146
32411
|
assertComplexity(selections, fragments) {
|
|
32147
32412
|
const depthCap = this.maxDepth > 0 ? this.maxDepth : 1e3;
|
|
32148
|
-
let
|
|
32413
|
+
let count2 = 0;
|
|
32149
32414
|
const walk2 = (sels, depth) => {
|
|
32150
32415
|
if (depth > depthCap) return;
|
|
32151
32416
|
for (const sel of sels) {
|
|
32152
|
-
|
|
32153
|
-
if (
|
|
32417
|
+
count2++;
|
|
32418
|
+
if (count2 > this.maxNodes) {
|
|
32154
32419
|
throw new ComplexityError(`Query exceeds maximum complexity of ${this.maxNodes} nodes`);
|
|
32155
32420
|
}
|
|
32156
32421
|
if (sel.kind === "fragment_spread") {
|
|
@@ -32620,8 +32885,8 @@ var init_graphql = __esm({
|
|
|
32620
32885
|
|
|
32621
32886
|
// ../core/src/context/chunker.ts
|
|
32622
32887
|
function fold(text) {
|
|
32623
|
-
const
|
|
32624
|
-
return
|
|
32888
|
+
const split2 = text.replace(NUM_COMMA, "").replace(CAMEL, " ").toLowerCase();
|
|
32889
|
+
return split2.normalize("NFKD").replace(/[^\x00-\x7f]/g, "");
|
|
32625
32890
|
}
|
|
32626
32891
|
function lightStem(token) {
|
|
32627
32892
|
if (token.length > 3 && token.endsWith("s") && !/(?:ss|us|is)$/.test(token)) {
|
|
@@ -32728,7 +32993,7 @@ __export(context_exports, {
|
|
|
32728
32993
|
});
|
|
32729
32994
|
import { DatabaseSync as DatabaseSync4 } from "node:sqlite";
|
|
32730
32995
|
import { existsSync as existsSync20, mkdirSync as mkdirSync15, readFileSync as readFileSync15, readdirSync as readdirSync11, realpathSync as realpathSync5 } from "node:fs";
|
|
32731
|
-
import { basename as
|
|
32996
|
+
import { basename as basename6, dirname as dirname13, extname as extname6, isAbsolute as isAbsolute6, join as join25, relative as relative4, resolve as resolve13 } from "node:path";
|
|
32732
32997
|
function fts5Supported() {
|
|
32733
32998
|
try {
|
|
32734
32999
|
const conn = new DatabaseSync4(":memory:");
|
|
@@ -32751,7 +33016,7 @@ function realResolve(abs) {
|
|
|
32751
33016
|
} catch {
|
|
32752
33017
|
}
|
|
32753
33018
|
try {
|
|
32754
|
-
return join25(realpathSync5(dirname13(abs)),
|
|
33019
|
+
return join25(realpathSync5(dirname13(abs)), basename6(abs));
|
|
32755
33020
|
} catch {
|
|
32756
33021
|
return abs;
|
|
32757
33022
|
}
|
|
@@ -32864,7 +33129,7 @@ var init_context = __esm({
|
|
|
32864
33129
|
// ── indexing ───────────────────────────────────────────────
|
|
32865
33130
|
static chunksFor(label, text) {
|
|
32866
33131
|
const ext = extname6(label).toLowerCase();
|
|
32867
|
-
const special = SPECIAL_FILES.has(
|
|
33132
|
+
const special = SPECIAL_FILES.has(basename6(label).toLowerCase());
|
|
32868
33133
|
if (CODE_EXTS.has(ext) || CONFIG_EXTS.has(ext) || special) {
|
|
32869
33134
|
return chunkCode(text, label);
|
|
32870
33135
|
}
|
|
@@ -32961,7 +33226,7 @@ var init_context = __esm({
|
|
|
32961
33226
|
if (parts.some((seg) => SKIP_DIRS.has(seg)) || dirParts.some((seg) => seg.startsWith("."))) {
|
|
32962
33227
|
return -1;
|
|
32963
33228
|
}
|
|
32964
|
-
if (!_Context.eligible(
|
|
33229
|
+
if (!_Context.eligible(basename6(rel))) return -1;
|
|
32965
33230
|
const stored = rel;
|
|
32966
33231
|
if (!existsSync20(abs)) {
|
|
32967
33232
|
this.conn.prepare("DELETE FROM chunks WHERE path = ?").run(stored);
|
|
@@ -33057,6 +33322,9 @@ import { randomUUID as randomUUID3 } from "node:crypto";
|
|
|
33057
33322
|
function logConnected(backplaneName, url) {
|
|
33058
33323
|
console.log(`[Tina4] ${backplaneName} connected to ${redactCredentials(url)}`);
|
|
33059
33324
|
}
|
|
33325
|
+
function driverUrl(backplaneName, url) {
|
|
33326
|
+
return canonicalConnectionUrl(splitConnectionUrl(url, { label: backplaneName, allowHostList: true }));
|
|
33327
|
+
}
|
|
33060
33328
|
function observeConnectFailure(ready, backplaneName) {
|
|
33061
33329
|
ready.catch((error2) => {
|
|
33062
33330
|
console.error(`[Tina4] ${backplaneName} could not connect: ${error2 instanceof Error ? error2.message : String(error2)}`);
|
|
@@ -33098,14 +33366,15 @@ var init_websocketBackplane = __esm({
|
|
|
33098
33366
|
"../core/src/websocketBackplane.ts"() {
|
|
33099
33367
|
"use strict";
|
|
33100
33368
|
init_optionalPackage();
|
|
33101
|
-
|
|
33369
|
+
init_urlRedaction();
|
|
33370
|
+
init_connectionUrl();
|
|
33102
33371
|
RedisBackplane = class {
|
|
33103
33372
|
publisher;
|
|
33104
33373
|
subscriber;
|
|
33105
33374
|
url;
|
|
33106
33375
|
ready;
|
|
33107
33376
|
constructor(url) {
|
|
33108
|
-
const resolvedUrl = url ?? process.env.TINA4_WS_BACKPLANE_URL ?? "redis://localhost:6379";
|
|
33377
|
+
const resolvedUrl = driverUrl("RedisBackplane", url ?? process.env.TINA4_WS_BACKPLANE_URL ?? "redis://localhost:6379");
|
|
33109
33378
|
this.url = resolvedUrl;
|
|
33110
33379
|
const redisModuleUrl = resolveOptionalPackage("redis", "RedisBackplane");
|
|
33111
33380
|
this.ready = (async () => {
|
|
@@ -33146,7 +33415,7 @@ var init_websocketBackplane = __esm({
|
|
|
33146
33415
|
ready;
|
|
33147
33416
|
natsModuleUrl;
|
|
33148
33417
|
constructor(url) {
|
|
33149
|
-
const resolvedUrl = url ?? process.env.TINA4_WS_BACKPLANE_URL ?? "nats://localhost:4222";
|
|
33418
|
+
const resolvedUrl = driverUrl("NATSBackplane", url ?? process.env.TINA4_WS_BACKPLANE_URL ?? "nats://localhost:4222");
|
|
33150
33419
|
this.url = resolvedUrl;
|
|
33151
33420
|
const natsModuleUrl = resolveOptionalPackage("nats", "NATSBackplane");
|
|
33152
33421
|
this.natsModuleUrl = natsModuleUrl;
|
|
@@ -36031,13 +36300,13 @@ var init_liteBackend = __esm({
|
|
|
36031
36300
|
}
|
|
36032
36301
|
return null;
|
|
36033
36302
|
}
|
|
36034
|
-
popBatch(queue, bridge,
|
|
36303
|
+
popBatch(queue, bridge, count2) {
|
|
36035
36304
|
const dir = this.ensureDir(queue);
|
|
36036
36305
|
this.reclaimExpired(queue, bridge.getMaxRetries(), this.nowIso());
|
|
36037
36306
|
const now = this.nowIso();
|
|
36038
36307
|
const results = [];
|
|
36039
36308
|
for (const [filename, job] of this.availableCandidates(queue, now)) {
|
|
36040
|
-
if (results.length >=
|
|
36309
|
+
if (results.length >= count2) break;
|
|
36041
36310
|
const filePath = join26(dir, filename);
|
|
36042
36311
|
job.topic = queue;
|
|
36043
36312
|
job.priority = job.priority ?? 0;
|
|
@@ -36088,24 +36357,24 @@ var init_liteBackend = __esm({
|
|
|
36088
36357
|
if (isDead || isReserved) {
|
|
36089
36358
|
return files.length;
|
|
36090
36359
|
}
|
|
36091
|
-
let
|
|
36360
|
+
let count2 = 0;
|
|
36092
36361
|
for (const file of files) {
|
|
36093
36362
|
try {
|
|
36094
36363
|
const job = JSON.parse(readFileSync16(join26(scanDir, file), "utf-8"));
|
|
36095
|
-
if (job.status === status2)
|
|
36364
|
+
if (job.status === status2) count2++;
|
|
36096
36365
|
} catch {
|
|
36097
36366
|
}
|
|
36098
36367
|
}
|
|
36099
|
-
return
|
|
36368
|
+
return count2;
|
|
36100
36369
|
}
|
|
36101
36370
|
clear(queue) {
|
|
36102
36371
|
const dir = this.ensureDir(queue);
|
|
36103
|
-
let
|
|
36372
|
+
let count2 = 0;
|
|
36104
36373
|
try {
|
|
36105
36374
|
const files = readdirSync12(dir).filter((f) => f.endsWith(".queue-data"));
|
|
36106
36375
|
for (const file of files) {
|
|
36107
36376
|
unlinkSync8(join26(dir, file));
|
|
36108
|
-
|
|
36377
|
+
count2++;
|
|
36109
36378
|
}
|
|
36110
36379
|
} catch {
|
|
36111
36380
|
}
|
|
@@ -36115,7 +36384,7 @@ var init_liteBackend = __esm({
|
|
|
36115
36384
|
const files = readdirSync12(failedDir).filter((f) => f.endsWith(".queue-data"));
|
|
36116
36385
|
for (const file of files) {
|
|
36117
36386
|
unlinkSync8(join26(failedDir, file));
|
|
36118
|
-
|
|
36387
|
+
count2++;
|
|
36119
36388
|
}
|
|
36120
36389
|
}
|
|
36121
36390
|
} catch {
|
|
@@ -36126,12 +36395,12 @@ var init_liteBackend = __esm({
|
|
|
36126
36395
|
const files = readdirSync12(reservedDir).filter((f) => f.endsWith(".queue-data"));
|
|
36127
36396
|
for (const file of files) {
|
|
36128
36397
|
unlinkSync8(join26(reservedDir, file));
|
|
36129
|
-
|
|
36398
|
+
count2++;
|
|
36130
36399
|
}
|
|
36131
36400
|
}
|
|
36132
36401
|
} catch {
|
|
36133
36402
|
}
|
|
36134
|
-
return
|
|
36403
|
+
return count2;
|
|
36135
36404
|
}
|
|
36136
36405
|
/**
|
|
36137
36406
|
* Jobs that have failed at least once but are still being retried.
|
|
@@ -36211,7 +36480,7 @@ var init_liteBackend = __esm({
|
|
|
36211
36480
|
return results;
|
|
36212
36481
|
}
|
|
36213
36482
|
purge(queue, status2, maxRetries = 3) {
|
|
36214
|
-
let
|
|
36483
|
+
let count2 = 0;
|
|
36215
36484
|
const isDead = _LiteBackend.DEAD_STATES.includes(status2);
|
|
36216
36485
|
if (isDead) {
|
|
36217
36486
|
const failedDir = this.ensureFailedDir(queue);
|
|
@@ -36220,7 +36489,7 @@ var init_liteBackend = __esm({
|
|
|
36220
36489
|
for (const file of files) {
|
|
36221
36490
|
try {
|
|
36222
36491
|
unlinkSync8(join26(failedDir, file));
|
|
36223
|
-
|
|
36492
|
+
count2++;
|
|
36224
36493
|
} catch {
|
|
36225
36494
|
}
|
|
36226
36495
|
}
|
|
@@ -36235,7 +36504,7 @@ var init_liteBackend = __esm({
|
|
|
36235
36504
|
const job = JSON.parse(readFileSync16(join26(dir, file), "utf-8"));
|
|
36236
36505
|
if (job.status === status2) {
|
|
36237
36506
|
unlinkSync8(join26(dir, file));
|
|
36238
|
-
|
|
36507
|
+
count2++;
|
|
36239
36508
|
}
|
|
36240
36509
|
} catch {
|
|
36241
36510
|
}
|
|
@@ -36243,7 +36512,7 @@ var init_liteBackend = __esm({
|
|
|
36243
36512
|
} catch {
|
|
36244
36513
|
}
|
|
36245
36514
|
}
|
|
36246
|
-
return
|
|
36515
|
+
return count2;
|
|
36247
36516
|
}
|
|
36248
36517
|
/**
|
|
36249
36518
|
* Re-queue dead-letter jobs that are under the (possibly raised) limit back
|
|
@@ -36253,7 +36522,7 @@ var init_liteBackend = __esm({
|
|
|
36253
36522
|
retryFailed(queue, maxRetries = 3) {
|
|
36254
36523
|
const failedDir = this.ensureFailedDir(queue);
|
|
36255
36524
|
const queueDir = this.ensureDir(queue);
|
|
36256
|
-
let
|
|
36525
|
+
let count2 = 0;
|
|
36257
36526
|
try {
|
|
36258
36527
|
const files = readdirSync12(failedDir).filter((f) => f.endsWith(".queue-data"));
|
|
36259
36528
|
for (const file of files) {
|
|
@@ -36270,13 +36539,13 @@ var init_liteBackend = __esm({
|
|
|
36270
36539
|
const prefix = this.nextPrefix();
|
|
36271
36540
|
writeFileSync12(join26(queueDir, `${prefix}_${job.id}.queue-data`), JSON.stringify(job, null, 2));
|
|
36272
36541
|
unlinkSync8(filePath);
|
|
36273
|
-
|
|
36542
|
+
count2++;
|
|
36274
36543
|
} catch {
|
|
36275
36544
|
}
|
|
36276
36545
|
}
|
|
36277
36546
|
} catch {
|
|
36278
36547
|
}
|
|
36279
|
-
return
|
|
36548
|
+
return count2;
|
|
36280
36549
|
}
|
|
36281
36550
|
popById(queue, id) {
|
|
36282
36551
|
const dir = this.ensureDir(queue);
|
|
@@ -36548,17 +36817,17 @@ var init_queue = __esm({
|
|
|
36548
36817
|
/**
|
|
36549
36818
|
* Pop up to count jobs at once. Returns a partial batch if fewer available.
|
|
36550
36819
|
*/
|
|
36551
|
-
popBatch(
|
|
36820
|
+
popBatch(count2) {
|
|
36552
36821
|
if (this.externalBackend) {
|
|
36553
36822
|
const jobs = [];
|
|
36554
|
-
for (let i = 0; i <
|
|
36823
|
+
for (let i = 0; i < count2; i++) {
|
|
36555
36824
|
const job = this.pop();
|
|
36556
36825
|
if (!job) break;
|
|
36557
36826
|
jobs.push(job);
|
|
36558
36827
|
}
|
|
36559
36828
|
return jobs;
|
|
36560
36829
|
}
|
|
36561
|
-
return this.liteBackend.popBatch(this.topic, this,
|
|
36830
|
+
return this.liteBackend.popBatch(this.topic, this, count2);
|
|
36562
36831
|
}
|
|
36563
36832
|
/**
|
|
36564
36833
|
* Process jobs from a queue with a handler function.
|
|
@@ -39085,7 +39354,7 @@ ${end}
|
|
|
39085
39354
|
// ../core/src/devAdmin.ts
|
|
39086
39355
|
import { cpus as osCpus } from "node:os";
|
|
39087
39356
|
import { readFileSync as readFileSync20, writeFileSync as writeFileSync16, existsSync as existsSync25, readdirSync as readdirSync16, mkdirSync as mkdirSync19, copyFileSync as copyFileSync3, statSync as statSync19, openSync as openSync5, closeSync as closeSync5, fstatSync as fstatSync3, fchmodSync as fchmodSync2, ftruncateSync as ftruncateSync2, constants as constants4, realpathSync as realpathSync6, lstatSync as lstatSync3 } from "node:fs";
|
|
39088
|
-
import { join as join30, dirname as dirname15, resolve as resolve17, relative as relative8, sep as sep9, basename as
|
|
39357
|
+
import { join as join30, dirname as dirname15, resolve as resolve17, relative as relative8, sep as sep9, basename as basename7 } from "node:path";
|
|
39089
39358
|
import { fileURLToPath as fileURLToPath9 } from "node:url";
|
|
39090
39359
|
import { timingSafeEqual as timingSafeEqual2 } from "node:crypto";
|
|
39091
39360
|
import net2 from "node:net";
|
|
@@ -39286,12 +39555,12 @@ function quoteTableRef(name) {
|
|
|
39286
39555
|
function parseSeedRequest(url, body) {
|
|
39287
39556
|
const b = body ?? {};
|
|
39288
39557
|
const table2 = String(url.searchParams.get("table") ?? b.table ?? "");
|
|
39289
|
-
const
|
|
39558
|
+
const count2 = parseInt(String(url.searchParams.get("count") ?? b.count ?? "10"), 10) || 10;
|
|
39290
39559
|
const seedRaw = url.searchParams.get("seed") ?? b.seed;
|
|
39291
39560
|
const seed = seedRaw !== void 0 && seedRaw !== null && String(seedRaw) !== "" ? Number.isNaN(parseInt(String(seedRaw), 10)) ? void 0 : parseInt(String(seedRaw), 10) : void 0;
|
|
39292
39561
|
const clear = String(url.searchParams.get("clear") ?? b.clear ?? "") === "true" || b.clear === true;
|
|
39293
39562
|
const strict = String(url.searchParams.get("strict") ?? b.strict ?? "") === "true" || b.strict === true;
|
|
39294
|
-
return { table: table2, count, seed, clear, strict };
|
|
39563
|
+
return { table: table2, count: count2, seed, clear, strict };
|
|
39295
39564
|
}
|
|
39296
39565
|
function buildSeedFieldMap(columns, fake) {
|
|
39297
39566
|
const rules = [
|
|
@@ -39460,6 +39729,11 @@ function parseEnvFile() {
|
|
|
39460
39729
|
}
|
|
39461
39730
|
return result;
|
|
39462
39731
|
}
|
|
39732
|
+
function savedUrlIfRedacted(posted) {
|
|
39733
|
+
const current = parseEnvFile().TINA4_DATABASE_URL ?? "";
|
|
39734
|
+
if (posted === "" || current === "" || posted === current) return posted;
|
|
39735
|
+
return posted === redactCredentials(current) ? current : posted;
|
|
39736
|
+
}
|
|
39463
39737
|
function walkDirRecursive(dir) {
|
|
39464
39738
|
const results = [];
|
|
39465
39739
|
if (!existsSync25(dir)) return results;
|
|
@@ -39525,7 +39799,7 @@ function realPathOf2(target) {
|
|
|
39525
39799
|
} catch {
|
|
39526
39800
|
}
|
|
39527
39801
|
if (present || dirname15(existing) === existing) break;
|
|
39528
|
-
tail.unshift(
|
|
39802
|
+
tail.unshift(basename7(existing));
|
|
39529
39803
|
existing = dirname15(existing);
|
|
39530
39804
|
}
|
|
39531
39805
|
return join30(realpathSync6(existing), ...tail);
|
|
@@ -39889,6 +40163,7 @@ var init_devAdmin = __esm({
|
|
|
39889
40163
|
init_feedback();
|
|
39890
40164
|
init_mcp();
|
|
39891
40165
|
init_version();
|
|
40166
|
+
init_urlRedaction();
|
|
39892
40167
|
cpuCount = osCpus().length;
|
|
39893
40168
|
DEV_MCP_PREFIXES = ["/__dev/api/mcp", "/__dev/mcp"];
|
|
39894
40169
|
DEV_PUBLIC_ASSETS = /* @__PURE__ */ new Set(["/__dev/toolbar.css", "/__dev/toolbar.js"]);
|
|
@@ -40077,8 +40352,8 @@ var init_devAdmin = __esm({
|
|
|
40077
40352
|
static read(id) {
|
|
40078
40353
|
return this.mailbox.read(id);
|
|
40079
40354
|
}
|
|
40080
|
-
static seed(
|
|
40081
|
-
this.mailbox.seed(
|
|
40355
|
+
static seed(count2 = 5) {
|
|
40356
|
+
this.mailbox.seed(count2);
|
|
40082
40357
|
}
|
|
40083
40358
|
static clear(folder) {
|
|
40084
40359
|
this.mailbox.clear(folder);
|
|
@@ -40111,15 +40386,15 @@ var init_devAdmin = __esm({
|
|
|
40111
40386
|
return job;
|
|
40112
40387
|
}
|
|
40113
40388
|
static retryFailed() {
|
|
40114
|
-
let
|
|
40389
|
+
let count2 = 0;
|
|
40115
40390
|
for (const job of this.jobs) {
|
|
40116
40391
|
if (job.status === "failed") {
|
|
40117
40392
|
job.status = "pending";
|
|
40118
40393
|
job.error = void 0;
|
|
40119
|
-
|
|
40394
|
+
count2++;
|
|
40120
40395
|
}
|
|
40121
40396
|
}
|
|
40122
|
-
return
|
|
40397
|
+
return count2;
|
|
40123
40398
|
}
|
|
40124
40399
|
static purgeCompleted() {
|
|
40125
40400
|
const before = this.jobs.length;
|
|
@@ -40626,12 +40901,12 @@ var init_devAdmin = __esm({
|
|
|
40626
40901
|
}
|
|
40627
40902
|
};
|
|
40628
40903
|
handleQueueRetry = (_req, res) => {
|
|
40629
|
-
const
|
|
40630
|
-
res.json({ retried:
|
|
40904
|
+
const count2 = DevQueue.retryFailed();
|
|
40905
|
+
res.json({ retried: count2 });
|
|
40631
40906
|
};
|
|
40632
40907
|
handleQueuePurge = (_req, res) => {
|
|
40633
|
-
const
|
|
40634
|
-
res.json({ purged:
|
|
40908
|
+
const count2 = DevQueue.purgeCompleted();
|
|
40909
|
+
res.json({ purged: count2 });
|
|
40635
40910
|
};
|
|
40636
40911
|
handleQueueReplay = (req2, res) => {
|
|
40637
40912
|
const url = new URL(req2.url ?? "/", "http://localhost");
|
|
@@ -40667,9 +40942,9 @@ var init_devAdmin = __esm({
|
|
|
40667
40942
|
};
|
|
40668
40943
|
handleMailboxSeed = (req2, res) => {
|
|
40669
40944
|
const url = new URL(req2.url ?? "/", "http://localhost");
|
|
40670
|
-
const
|
|
40671
|
-
DevMailboxStore.seed(
|
|
40672
|
-
res.json({ seeded:
|
|
40945
|
+
const count2 = parseInt(url.searchParams.get("count") ?? "5", 10);
|
|
40946
|
+
DevMailboxStore.seed(count2);
|
|
40947
|
+
res.json({ seeded: count2 });
|
|
40673
40948
|
};
|
|
40674
40949
|
handleMailboxClear = (req2, res) => {
|
|
40675
40950
|
const url = new URL(req2.url ?? "/", "http://localhost");
|
|
@@ -40720,7 +40995,7 @@ var init_devAdmin = __esm({
|
|
|
40720
40995
|
};
|
|
40721
40996
|
handleSeed = async (req2, res) => {
|
|
40722
40997
|
const url = new URL(req2.url ?? "/", "http://localhost");
|
|
40723
|
-
const { table: table2, count, seed, clear, strict } = parseSeedRequest(url, req2.body);
|
|
40998
|
+
const { table: table2, count: count2, seed, clear, strict } = parseSeedRequest(url, req2.body);
|
|
40724
40999
|
if (!table2) {
|
|
40725
41000
|
res.json({ error: "Missing table parameter" });
|
|
40726
41001
|
return;
|
|
@@ -40736,7 +41011,7 @@ var init_devAdmin = __esm({
|
|
|
40736
41011
|
return;
|
|
40737
41012
|
}
|
|
40738
41013
|
const fieldMap = buildSeedFieldMap(columns, fake);
|
|
40739
|
-
const summary = await seedTable2(db, table2,
|
|
41014
|
+
const summary = await seedTable2(db, table2, count2, fieldMap, void 0, { clear, strict });
|
|
40740
41015
|
res.json({ seeded: summary.seeded, failed: summary.failed, errors: summary.errors, table: table2 });
|
|
40741
41016
|
} catch (e) {
|
|
40742
41017
|
res.json({ error: e?.message ?? "Database not connected" });
|
|
@@ -40883,7 +41158,7 @@ var init_devAdmin = __esm({
|
|
|
40883
41158
|
};
|
|
40884
41159
|
handleSeedRun = async (req2, res) => {
|
|
40885
41160
|
const body = req2.body || {};
|
|
40886
|
-
const
|
|
41161
|
+
const count2 = parseInt(String(body.count ?? "10"), 10) || 10;
|
|
40887
41162
|
try {
|
|
40888
41163
|
const orm = await Promise.resolve().then(() => (init_src(), src_exports));
|
|
40889
41164
|
const dirs = ["src/orm", "src/models"].map((d) => resolve17(process.cwd(), d)).filter((d) => existsSync25(d));
|
|
@@ -40895,7 +41170,7 @@ var init_devAdmin = __esm({
|
|
|
40895
41170
|
res.json({ ok: false, error: "No models found in src/orm/ or src/models/" }, 400);
|
|
40896
41171
|
return;
|
|
40897
41172
|
}
|
|
40898
|
-
const summaries = await orm.seedModels(classes,
|
|
41173
|
+
const summaries = await orm.seedModels(classes, count2);
|
|
40899
41174
|
let seeded = 0, failed = 0;
|
|
40900
41175
|
for (const s of Object.values(summaries)) {
|
|
40901
41176
|
seeded += s.seeded;
|
|
@@ -40961,14 +41236,17 @@ var init_devAdmin = __esm({
|
|
|
40961
41236
|
handleConnections = (_req, res) => {
|
|
40962
41237
|
const env = parseEnvFile();
|
|
40963
41238
|
res.json({
|
|
40964
|
-
|
|
41239
|
+
// Redacted like the password field below: this used to hand the raw .env
|
|
41240
|
+
// URL - password and all - to any page that could reach the dev API
|
|
41241
|
+
// (GHSA-h2mr-m3v3-cq8c). Save recognises this form and keeps the real URL.
|
|
41242
|
+
url: redactCredentials(env.TINA4_DATABASE_URL ?? ""),
|
|
40965
41243
|
username: env.TINA4_DATABASE_USERNAME ?? "",
|
|
40966
41244
|
password: env.TINA4_DATABASE_PASSWORD ? "***" : ""
|
|
40967
41245
|
});
|
|
40968
41246
|
};
|
|
40969
41247
|
handleConnectionsTest = async (req2, res) => {
|
|
40970
41248
|
const body = req2.body;
|
|
40971
|
-
const url = body?.url ?? "";
|
|
41249
|
+
const url = savedUrlIfRedacted(body?.url ?? "");
|
|
40972
41250
|
const username = body?.username ?? "";
|
|
40973
41251
|
const password = body?.password ?? "";
|
|
40974
41252
|
if (!url) {
|
|
@@ -41019,7 +41297,7 @@ var init_devAdmin = __esm({
|
|
|
41019
41297
|
};
|
|
41020
41298
|
handleConnectionsSave = (req2, res) => {
|
|
41021
41299
|
const body = req2.body;
|
|
41022
|
-
const url = body?.url ?? "";
|
|
41300
|
+
const url = savedUrlIfRedacted(body?.url ?? "");
|
|
41023
41301
|
const username = body?.username ?? "";
|
|
41024
41302
|
const password = body?.password ?? "";
|
|
41025
41303
|
if (!url) {
|
|
@@ -43468,6 +43746,7 @@ __export(server_exports, {
|
|
|
43468
43746
|
resolveTemplate: () => resolveTemplate,
|
|
43469
43747
|
runDispatch: () => runDispatch,
|
|
43470
43748
|
shouldOpenBrowser: () => shouldOpenBrowser,
|
|
43749
|
+
shutdownSignals: () => shutdownSignals,
|
|
43471
43750
|
shutdownTimeoutSeconds: () => shutdownTimeoutSeconds,
|
|
43472
43751
|
start: () => start,
|
|
43473
43752
|
startServer: () => startServer,
|
|
@@ -43497,6 +43776,9 @@ function shutdownTimeoutSeconds() {
|
|
|
43497
43776
|
}
|
|
43498
43777
|
return parsed;
|
|
43499
43778
|
}
|
|
43779
|
+
function shutdownSignals(platform = process.platform) {
|
|
43780
|
+
return platform === "win32" ? ["SIGTERM", "SIGINT", "SIGBREAK"] : ["SIGTERM", "SIGINT"];
|
|
43781
|
+
}
|
|
43500
43782
|
function bannerSurfaceLines(port, opts) {
|
|
43501
43783
|
return [
|
|
43502
43784
|
opts.swaggerEnabled ? `
|
|
@@ -43514,7 +43796,7 @@ function swaggerAdvertised() {
|
|
|
43514
43796
|
return TRUTHY3.includes(raw);
|
|
43515
43797
|
}
|
|
43516
43798
|
function stripUrlCredentials(text) {
|
|
43517
|
-
return text
|
|
43799
|
+
return stripCredentials(text);
|
|
43518
43800
|
}
|
|
43519
43801
|
function isModuleNotFound(err) {
|
|
43520
43802
|
const code = err?.code;
|
|
@@ -44784,21 +45066,19 @@ ${reset2}
|
|
|
44784
45066
|
}
|
|
44785
45067
|
process.exit(0);
|
|
44786
45068
|
};
|
|
44787
|
-
const
|
|
44788
|
-
|
|
44789
|
-
|
|
44790
|
-
|
|
44791
|
-
|
|
44792
|
-
};
|
|
44793
|
-
process.on(
|
|
44794
|
-
process.on("SIGINT", onSigint);
|
|
45069
|
+
const signalListeners = shutdownSignals().map((signal) => ({
|
|
45070
|
+
signal,
|
|
45071
|
+
listener: () => {
|
|
45072
|
+
void gracefulShutdown(signal).catch(() => process.exit(0));
|
|
45073
|
+
}
|
|
45074
|
+
}));
|
|
45075
|
+
signalListeners.forEach(({ signal, listener }) => process.on(signal, listener));
|
|
44795
45076
|
await startAllTcpServices(host);
|
|
44796
45077
|
const loopWatchdog = startLoopWatchdog();
|
|
44797
45078
|
resolvePromise({
|
|
44798
45079
|
close: () => {
|
|
44799
45080
|
loopWatchdog.stop();
|
|
44800
|
-
process.off(
|
|
44801
|
-
process.off("SIGINT", onSigint);
|
|
45081
|
+
signalListeners.forEach(({ signal, listener }) => process.off(signal, listener));
|
|
44802
45082
|
stopAllBackgroundTasks();
|
|
44803
45083
|
stopAcceptingAllTcpServices();
|
|
44804
45084
|
void drainAllTcpServices();
|
|
@@ -44935,6 +45215,7 @@ var init_server = __esm({
|
|
|
44935
45215
|
init_background();
|
|
44936
45216
|
init_tcp();
|
|
44937
45217
|
init_version();
|
|
45218
|
+
init_urlRedaction();
|
|
44938
45219
|
__filename = fileURLToPath10(import.meta.url);
|
|
44939
45220
|
__dirname = dirname16(__filename);
|
|
44940
45221
|
BUILTIN_ERROR_TEMPLATES_DIR = resolve20(__dirname, "..", "templates");
|
|
@@ -45186,6 +45467,7 @@ var init_mqtt = __esm({
|
|
|
45186
45467
|
init_logger();
|
|
45187
45468
|
init_background();
|
|
45188
45469
|
init_mqttMessage();
|
|
45470
|
+
init_connectionUrl();
|
|
45189
45471
|
MqttError = class extends Error {
|
|
45190
45472
|
constructor(message) {
|
|
45191
45473
|
super(message);
|
|
@@ -45291,59 +45573,34 @@ var init_mqtt = __esm({
|
|
|
45291
45573
|
if (raw === "") {
|
|
45292
45574
|
throw new Error(`MQTT url is empty -- set TINA4_MQTT_URL (e.g. ${DEFAULT_URL})`);
|
|
45293
45575
|
}
|
|
45294
|
-
let scheme = null;
|
|
45295
|
-
let rest = raw;
|
|
45296
45576
|
const schemeMatch = raw.match(/^([A-Za-z][A-Za-z0-9+.-]*):\/\//);
|
|
45577
|
+
let target = raw;
|
|
45297
45578
|
if (schemeMatch) {
|
|
45298
|
-
scheme = schemeMatch[1].toLowerCase();
|
|
45579
|
+
const scheme = schemeMatch[1].toLowerCase();
|
|
45299
45580
|
if (!["mqtt", "tcp", "mqtts"].includes(scheme)) {
|
|
45300
45581
|
throw new Error(
|
|
45301
|
-
`unsupported MQTT url scheme '${scheme}'
|
|
45582
|
+
`unsupported MQTT url scheme '${scheme}' -- this client speaks mqtt://, tcp:// or mqtts:// (TLS). WebSocket transports are not implemented.`
|
|
45302
45583
|
);
|
|
45303
45584
|
}
|
|
45304
|
-
|
|
45305
|
-
|
|
45306
|
-
const tlsFlag = scheme === "mqtts";
|
|
45307
|
-
let username = null;
|
|
45308
|
-
let password = null;
|
|
45309
|
-
const atPos = rest.lastIndexOf("@");
|
|
45310
|
-
if (atPos !== -1) {
|
|
45311
|
-
const userinfo = rest.slice(0, atPos);
|
|
45312
|
-
rest = rest.slice(atPos + 1);
|
|
45313
|
-
const colon = userinfo.indexOf(":");
|
|
45314
|
-
if (colon === -1) {
|
|
45315
|
-
username = _Mqtt.percentDecode(userinfo);
|
|
45316
|
-
} else {
|
|
45317
|
-
username = _Mqtt.percentDecode(userinfo.slice(0, colon));
|
|
45318
|
-
password = _Mqtt.percentDecode(userinfo.slice(colon + 1));
|
|
45319
|
-
}
|
|
45320
|
-
}
|
|
45321
|
-
const hostPort = rest.split("/", 1)[0];
|
|
45322
|
-
let host = hostPort;
|
|
45323
|
-
let portStr = null;
|
|
45324
|
-
if (hostPort.startsWith("[")) {
|
|
45325
|
-
const close = hostPort.indexOf("]");
|
|
45326
|
-
if (close === -1) throw new Error(`malformed MQTT url '${raw}' -- unclosed IPv6 bracket`);
|
|
45327
|
-
host = hostPort.slice(1, close);
|
|
45328
|
-
const after = hostPort.slice(close + 1);
|
|
45329
|
-
if (after.startsWith(":")) portStr = after.slice(1);
|
|
45330
|
-
} else {
|
|
45331
|
-
const colon = hostPort.indexOf(":");
|
|
45332
|
-
if (colon !== -1) {
|
|
45333
|
-
host = hostPort.slice(0, colon);
|
|
45334
|
-
portStr = hostPort.slice(colon + 1);
|
|
45335
|
-
}
|
|
45585
|
+
} else if (/^(\[[^\]\s]*\]|[^\s:/@?#[\]]+)(:\d*)?$/.test(raw)) {
|
|
45586
|
+
target = `mqtt://${raw}`;
|
|
45336
45587
|
}
|
|
45337
|
-
|
|
45338
|
-
|
|
45339
|
-
|
|
45588
|
+
let parts;
|
|
45589
|
+
try {
|
|
45590
|
+
parts = splitConnectionUrl(target, { label: "Mqtt", expected: "mqtt://[user[:password]@]host[:port]" });
|
|
45591
|
+
} catch (err) {
|
|
45592
|
+
throw new MqttError(`malformed MQTT url -- ${err.message.replace(/^Mqtt: /, "")}`);
|
|
45593
|
+
}
|
|
45594
|
+
if (parts.host === "") {
|
|
45595
|
+
throw new MqttError("malformed MQTT url -- expected mqtt://host:port. The url is not shown because it may contain a password.");
|
|
45340
45596
|
}
|
|
45597
|
+
const tlsFlag = parts.scheme === "mqtts";
|
|
45341
45598
|
return {
|
|
45342
|
-
host,
|
|
45343
|
-
port:
|
|
45599
|
+
host: parts.host,
|
|
45600
|
+
port: parts.port !== null ? parts.port : tlsFlag ? DEFAULT_TLS_PORT : DEFAULT_PORT,
|
|
45344
45601
|
tls: tlsFlag,
|
|
45345
|
-
username:
|
|
45346
|
-
password
|
|
45602
|
+
username: parts.rawUsername !== null && parts.rawUsername !== "" ? _Mqtt.percentDecode(parts.rawUsername) : null,
|
|
45603
|
+
password: parts.rawPassword !== null ? _Mqtt.percentDecode(parts.rawPassword) : null
|
|
45347
45604
|
};
|
|
45348
45605
|
}
|
|
45349
45606
|
/**
|
|
@@ -46380,7 +46637,7 @@ import https from "node:https";
|
|
|
46380
46637
|
import { URL as URL2 } from "node:url";
|
|
46381
46638
|
import { randomBytes as randomBytes11 } from "node:crypto";
|
|
46382
46639
|
import { promises as fsp, createWriteStream } from "node:fs";
|
|
46383
|
-
import { basename as
|
|
46640
|
+
import { basename as basename8 } from "node:path";
|
|
46384
46641
|
import { pipeline } from "node:stream/promises";
|
|
46385
46642
|
function keepCrossOriginHeaders(headers) {
|
|
46386
46643
|
const out = {};
|
|
@@ -46781,7 +47038,7 @@ var init_api = __esm({
|
|
|
46781
47038
|
error: err instanceof Error ? err.message : String(err)
|
|
46782
47039
|
};
|
|
46783
47040
|
}
|
|
46784
|
-
uploadName = filename ||
|
|
47041
|
+
uploadName = filename || basename8(filePath);
|
|
46785
47042
|
} else {
|
|
46786
47043
|
return { http_code: null, body: null, headers: {}, error: "upload requires filePath or fileBytes" };
|
|
46787
47044
|
}
|
|
@@ -47292,7 +47549,7 @@ var init_api = __esm({
|
|
|
47292
47549
|
import net4 from "node:net";
|
|
47293
47550
|
import tls2 from "node:tls";
|
|
47294
47551
|
import { readFileSync as readFileSync25 } from "node:fs";
|
|
47295
|
-
import { basename as
|
|
47552
|
+
import { basename as basename9 } from "node:path";
|
|
47296
47553
|
import { randomUUID as randomUUID8 } from "node:crypto";
|
|
47297
47554
|
function normaliseEncryption(value, kind) {
|
|
47298
47555
|
const normalised = value.trim().toLowerCase();
|
|
@@ -47455,7 +47712,7 @@ function buildMimeMessage(options) {
|
|
|
47455
47712
|
lines.push(options.body);
|
|
47456
47713
|
}
|
|
47457
47714
|
for (const filePath of options.attachments) {
|
|
47458
|
-
const fileName =
|
|
47715
|
+
const fileName = basename9(filePath);
|
|
47459
47716
|
const fileData = readFileSync25(filePath);
|
|
47460
47717
|
const base64Data = fileData.toString("base64");
|
|
47461
47718
|
lines.push("");
|
|
@@ -50786,26 +51043,25 @@ var init_aiClient = __esm({
|
|
|
50786
51043
|
// ../core/src/queueBackends/rabbitmqBackend.ts
|
|
50787
51044
|
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
50788
51045
|
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
51046
|
+
function amqpTarget(url) {
|
|
51047
|
+
return /^[A-Za-z][A-Za-z0-9+.-]*(:\/|\/\/)|[@\s]/.test(url) ? url : `amqp://${url}`;
|
|
51048
|
+
}
|
|
51049
|
+
function amqpCredentials(username, password) {
|
|
51050
|
+
const creds = {};
|
|
51051
|
+
if (username !== null) creds.username = username;
|
|
51052
|
+
if (password !== null) creds.password = password;
|
|
51053
|
+
return creds;
|
|
51054
|
+
}
|
|
50789
51055
|
function parseAmqpUrl(url) {
|
|
50790
51056
|
const config = {};
|
|
50791
|
-
|
|
50792
|
-
|
|
50793
|
-
|
|
50794
|
-
|
|
50795
|
-
|
|
50796
|
-
|
|
50797
|
-
|
|
50798
|
-
|
|
50799
|
-
config.password = creds.slice(colonIndex + 1);
|
|
50800
|
-
} else {
|
|
50801
|
-
config.username = creds;
|
|
50802
|
-
}
|
|
50803
|
-
}
|
|
50804
|
-
let hostport = rest;
|
|
50805
|
-
const slashIndex = rest.indexOf("/");
|
|
50806
|
-
if (slashIndex !== -1) {
|
|
50807
|
-
hostport = rest.slice(0, slashIndex);
|
|
50808
|
-
const vhost = rest.slice(slashIndex + 1);
|
|
51057
|
+
const parts = splitConnectionUrl(amqpTarget(url), {
|
|
51058
|
+
label: "parseAmqpUrl",
|
|
51059
|
+
expected: "amqp://[user[:password]@]host[:port][/vhost]"
|
|
51060
|
+
});
|
|
51061
|
+
Object.assign(config, amqpCredentials(parts.rawUsername, parts.rawPassword));
|
|
51062
|
+
const hostport = parts.hostPort;
|
|
51063
|
+
if (parts.tail.startsWith("/")) {
|
|
51064
|
+
const vhost = parts.tail.slice(1);
|
|
50809
51065
|
if (vhost) {
|
|
50810
51066
|
config.vhost = decodeURIComponent(vhost);
|
|
50811
51067
|
}
|
|
@@ -50823,6 +51079,7 @@ var AMQP_PROTOCOL_HEADER, CONNECTION_START, CONNECTION_START_OK, CONNECTION_TUNE
|
|
|
50823
51079
|
var init_rabbitmqBackend = __esm({
|
|
50824
51080
|
"../core/src/queueBackends/rabbitmqBackend.ts"() {
|
|
50825
51081
|
"use strict";
|
|
51082
|
+
init_connectionUrl();
|
|
50826
51083
|
AMQP_PROTOCOL_HEADER = Buffer.from([65, 77, 81, 80, 0, 0, 9, 1]);
|
|
50827
51084
|
CONNECTION_START = 10 << 16 | 10;
|
|
50828
51085
|
CONNECTION_START_OK = 10 << 16 | 11;
|
|
@@ -52101,6 +52358,7 @@ __export(src_exports3, {
|
|
|
52101
52358
|
SSO: () => Sso,
|
|
52102
52359
|
SafeString: () => SafeString2,
|
|
52103
52360
|
SecurityHeadersMiddleware: () => SecurityHeadersMiddleware,
|
|
52361
|
+
SeedError: () => SeedError,
|
|
52104
52362
|
ServiceRunner: () => ServiceRunner,
|
|
52105
52363
|
Session: () => Session,
|
|
52106
52364
|
Sso: () => Sso,
|
|
@@ -52972,8 +53230,8 @@ async function runTests(testPath) {
|
|
|
52972
53230
|
console.log(` Found ${testFiles.length} test file(s)
|
|
52973
53231
|
`);
|
|
52974
53232
|
for (const file of testFiles) {
|
|
52975
|
-
const
|
|
52976
|
-
console.log(` Running: ${
|
|
53233
|
+
const relative13 = file.replace(cwd + "/", "");
|
|
53234
|
+
console.log(` Running: ${relative13}`);
|
|
52977
53235
|
try {
|
|
52978
53236
|
execSync3(`npx tsx "${file}"`, { cwd, stdio: "inherit" });
|
|
52979
53237
|
} catch {
|
|
@@ -53189,7 +53447,7 @@ init_generate();
|
|
|
53189
53447
|
|
|
53190
53448
|
// src/commands/seed.ts
|
|
53191
53449
|
import { existsSync as existsSync36, readdirSync as readdirSync22 } from "node:fs";
|
|
53192
|
-
import { resolve as resolve28, join as join38 } from "node:path";
|
|
53450
|
+
import { resolve as resolve28, join as join38, relative as relative12, basename as basename10 } from "node:path";
|
|
53193
53451
|
import { execSync as execSync4 } from "node:child_process";
|
|
53194
53452
|
async function runSeeds(seedPath) {
|
|
53195
53453
|
const cwd = process.cwd();
|
|
@@ -53216,7 +53474,7 @@ async function runSeeds(seedPath) {
|
|
|
53216
53474
|
}
|
|
53217
53475
|
let seedFiles;
|
|
53218
53476
|
try {
|
|
53219
|
-
seedFiles = readdirSync22(seedDir).filter((f) => f.endsWith(".ts")).sort().map((f) => join38(seedDir, f));
|
|
53477
|
+
seedFiles = readdirSync22(seedDir).filter((f) => (f.endsWith(".ts") || f.endsWith(".js")) && !f.startsWith("_")).sort().map((f) => join38(seedDir, f));
|
|
53220
53478
|
} catch {
|
|
53221
53479
|
console.log(" Could not read src/seeds/ directory.");
|
|
53222
53480
|
return;
|
|
@@ -53227,20 +53485,16 @@ async function runSeeds(seedPath) {
|
|
|
53227
53485
|
}
|
|
53228
53486
|
console.log(` Found ${seedFiles.length} seed file(s)
|
|
53229
53487
|
`);
|
|
53230
|
-
let failed = false;
|
|
53231
53488
|
for (const file of seedFiles) {
|
|
53232
|
-
|
|
53233
|
-
console.log(` Seeding: ${relative12}`);
|
|
53489
|
+
console.log(` Seeding: ${relative12(cwd, file)}`);
|
|
53234
53490
|
try {
|
|
53235
53491
|
execSync4(`npx tsx "${file}"`, { cwd, stdio: "inherit" });
|
|
53236
53492
|
} catch {
|
|
53237
|
-
|
|
53493
|
+
console.error(`
|
|
53494
|
+
Seed file failed: ${basename10(file)} - seeding stopped.`);
|
|
53495
|
+
process.exit(1);
|
|
53238
53496
|
}
|
|
53239
53497
|
}
|
|
53240
|
-
if (failed) {
|
|
53241
|
-
console.error("\n Some seeds failed.");
|
|
53242
|
-
process.exit(1);
|
|
53243
|
-
}
|
|
53244
53498
|
console.log("\n All seeds completed.");
|
|
53245
53499
|
}
|
|
53246
53500
|
|
|
@@ -53425,7 +53679,7 @@ async function queueCommand(args = []) {
|
|
|
53425
53679
|
// src/commands/build.ts
|
|
53426
53680
|
init_util();
|
|
53427
53681
|
import { accessSync as accessSync2, constants as constants5, existsSync as existsSync37, statSync as statSync25 } from "node:fs";
|
|
53428
|
-
import { basename as
|
|
53682
|
+
import { basename as basename11, delimiter as delimiter4, join as join40 } from "node:path";
|
|
53429
53683
|
import { spawnSync as spawnSync4 } from "node:child_process";
|
|
53430
53684
|
function parseFlags3(args) {
|
|
53431
53685
|
return parseFlags(args).flags;
|
|
@@ -53451,7 +53705,7 @@ function buildImage(args) {
|
|
|
53451
53705
|
const flags = parseFlags3(args);
|
|
53452
53706
|
let tag = typeof flags.tag === "string" ? flags.tag : "";
|
|
53453
53707
|
if (!tag) {
|
|
53454
|
-
const dirName =
|
|
53708
|
+
const dirName = basename11(process.cwd()).toLowerCase();
|
|
53455
53709
|
tag = `${dirName || "tina4app"}:latest`;
|
|
53456
53710
|
}
|
|
53457
53711
|
const dockerfile = typeof flags.file === "string" && flags.file ? flags.file : "Dockerfile";
|