@modelform/react-native 0.12.0 → 0.14.0
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/README.md +63 -0
- package/dist/{chunk-YUSXYDXG.mjs → chunk-72OFPTDE.mjs} +492 -0
- package/dist/{chunk-G67L7TFK.js → chunk-XWSPLZNC.js} +594 -102
- package/dist/core/formFill.d.ts +89 -0
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.js +36 -2
- package/dist/core/index.mjs +35 -1
- package/dist/core/speech.d.ts +36 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +861 -467
- package/dist/index.mjs +849 -455
- package/dist/ui/inputs/Dictation.d.ts +30 -0
- package/dist/ui/inputs/InputForm.d.ts +17 -1
- package/dist/ui/inputs/VoiceFill.d.ts +28 -0
- package/dist/ui/inputs/formContext.d.ts +7 -0
- package/dist/ui/speech.d.ts +34 -0
- package/package.json +1 -1
|
@@ -1567,6 +1567,481 @@ function queryErrors(results) {
|
|
|
1567
1567
|
return Object.entries(_nullishCoalesce(results, () => ( {}))).filter(([, r]) => r.error).map(([refId, r]) => `${refId}: ${r.error}`).join("\n");
|
|
1568
1568
|
}
|
|
1569
1569
|
|
|
1570
|
+
// src/core/speech.ts
|
|
1571
|
+
var UNITS = {
|
|
1572
|
+
zero: 0,
|
|
1573
|
+
oh: 0,
|
|
1574
|
+
nought: 0,
|
|
1575
|
+
one: 1,
|
|
1576
|
+
two: 2,
|
|
1577
|
+
three: 3,
|
|
1578
|
+
four: 4,
|
|
1579
|
+
five: 5,
|
|
1580
|
+
six: 6,
|
|
1581
|
+
seven: 7,
|
|
1582
|
+
eight: 8,
|
|
1583
|
+
nine: 9,
|
|
1584
|
+
ten: 10,
|
|
1585
|
+
eleven: 11,
|
|
1586
|
+
twelve: 12,
|
|
1587
|
+
thirteen: 13,
|
|
1588
|
+
fourteen: 14,
|
|
1589
|
+
fifteen: 15,
|
|
1590
|
+
sixteen: 16,
|
|
1591
|
+
seventeen: 17,
|
|
1592
|
+
eighteen: 18,
|
|
1593
|
+
nineteen: 19
|
|
1594
|
+
};
|
|
1595
|
+
var TENS = { twenty: 20, thirty: 30, forty: 40, fifty: 50, sixty: 60, seventy: 70, eighty: 80, ninety: 90 };
|
|
1596
|
+
var SCALES = { hundred: 100, thousand: 1e3, million: 1e6 };
|
|
1597
|
+
var NEGATIVE = /* @__PURE__ */ new Set(["minus", "negative"]);
|
|
1598
|
+
var isNumberWord = (w) => w in UNITS || w in TENS || w in SCALES;
|
|
1599
|
+
function words(text) {
|
|
1600
|
+
return text.toLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g, "").replace(/(\d),(\d{3})\b/g, "$1$2").replace(/(\d),(\d)/g, "$1.$2").replace(/[^a-z0-9.:\s-]/g, " ").replace(/(?<![\d])-(?=\d)/g, " minus ").replace(/-/g, " ").replace(/\.(?!\d)/g, " ").split(/\s+/).filter(Boolean);
|
|
1601
|
+
}
|
|
1602
|
+
function wordsToInteger(ws) {
|
|
1603
|
+
if (!ws.length) return null;
|
|
1604
|
+
if (ws.some((w) => w in SCALES)) {
|
|
1605
|
+
let total = 0;
|
|
1606
|
+
let current = 0;
|
|
1607
|
+
for (const w of ws) {
|
|
1608
|
+
if (w in UNITS) current += UNITS[w];
|
|
1609
|
+
else if (w in TENS) current += TENS[w];
|
|
1610
|
+
else if (w === "hundred") current = (current || 1) * 100;
|
|
1611
|
+
else if (w in SCALES) {
|
|
1612
|
+
total += (current || 1) * SCALES[w];
|
|
1613
|
+
current = 0;
|
|
1614
|
+
} else return null;
|
|
1615
|
+
}
|
|
1616
|
+
return total + current;
|
|
1617
|
+
}
|
|
1618
|
+
const groups = [];
|
|
1619
|
+
for (let i = 0; i < ws.length; i++) {
|
|
1620
|
+
const w = ws[i];
|
|
1621
|
+
const next = ws[i + 1];
|
|
1622
|
+
const nextUnit = next != null && next in UNITS && UNITS[next] > 0 && UNITS[next] < 10;
|
|
1623
|
+
if (w in TENS) {
|
|
1624
|
+
groups.push(String(TENS[w] + (nextUnit ? UNITS[next] : 0)));
|
|
1625
|
+
if (nextUnit) i++;
|
|
1626
|
+
} else if (w === "oh" && nextUnit) {
|
|
1627
|
+
groups.push(`0${UNITS[next]}`);
|
|
1628
|
+
i++;
|
|
1629
|
+
} else if (w in UNITS) groups.push(String(UNITS[w]));
|
|
1630
|
+
else return null;
|
|
1631
|
+
}
|
|
1632
|
+
return Number(groups.map((g, i) => i === 0 ? g : g.padStart(2, "0")).join(""));
|
|
1633
|
+
}
|
|
1634
|
+
function parseSpokenNumber(text) {
|
|
1635
|
+
const ws = words(text);
|
|
1636
|
+
let i = 0;
|
|
1637
|
+
let sign = 1;
|
|
1638
|
+
for (; i < ws.length; i++) {
|
|
1639
|
+
const w = ws[i];
|
|
1640
|
+
if (NEGATIVE.has(w)) sign = -1;
|
|
1641
|
+
else if (/^\d/.test(w) || isNumberWord(w) || w === "a" && ws[i + 1] in SCALES || w === "point" && ws[i + 1] && (/^\d/.test(ws[i + 1]) || ws[i + 1] in UNITS)) break;
|
|
1642
|
+
else if (w !== "and") sign = 1;
|
|
1643
|
+
}
|
|
1644
|
+
if (i >= ws.length) return null;
|
|
1645
|
+
const digits = /^(\d+(?:\.\d+)?)$/.exec(ws[i]);
|
|
1646
|
+
if (digits) {
|
|
1647
|
+
let n = Number(digits[1]);
|
|
1648
|
+
const rest = ws.slice(i + 1);
|
|
1649
|
+
if (!digits[1].includes(".") && rest[0] === "point") n = Number(`${digits[1]}.${_nullishCoalesce(fractionDigits(rest.slice(1)), () => ( 0))}`);
|
|
1650
|
+
else if (rest[0] === "and" && rest[1] === "a" && rest[2] === "half") n += 0.5;
|
|
1651
|
+
return sign * n;
|
|
1652
|
+
}
|
|
1653
|
+
const whole = [];
|
|
1654
|
+
for (; i < ws.length; i++) {
|
|
1655
|
+
const w = ws[i];
|
|
1656
|
+
if (isNumberWord(w)) whole.push(w);
|
|
1657
|
+
else if (w === "a" && ws[i + 1] in SCALES) whole.push("one");
|
|
1658
|
+
else if (w === "and" && ws[i + 1] && isNumberWord(ws[i + 1]) && whole.some((x) => x in SCALES)) continue;
|
|
1659
|
+
else break;
|
|
1660
|
+
}
|
|
1661
|
+
const intPart = whole.length ? wordsToInteger(whole) : 0;
|
|
1662
|
+
if (intPart == null) return null;
|
|
1663
|
+
if (ws[i] === "point") {
|
|
1664
|
+
const frac = fractionDigits(ws.slice(i + 1));
|
|
1665
|
+
return frac == null ? sign * intPart : sign * Number(`${intPart}.${frac}`);
|
|
1666
|
+
}
|
|
1667
|
+
if (ws[i] === "and" && ws[i + 1] === "a" && ws[i + 2] === "half") return sign * (intPart + 0.5);
|
|
1668
|
+
if (ws[i] === "and" && ws[i + 1] === "a" && ws[i + 2] === "quarter") return sign * (intPart + 0.25);
|
|
1669
|
+
if (!whole.length) return null;
|
|
1670
|
+
return sign * intPart;
|
|
1671
|
+
}
|
|
1672
|
+
function fractionDigits(ws) {
|
|
1673
|
+
if (ws[0] && /^\d+$/.test(ws[0])) return ws[0];
|
|
1674
|
+
let out = "";
|
|
1675
|
+
for (let i = 0; i < ws.length; i++) {
|
|
1676
|
+
const w = ws[i];
|
|
1677
|
+
if (w in UNITS && UNITS[w] < 10) out += UNITS[w];
|
|
1678
|
+
else if (w in TENS) {
|
|
1679
|
+
const next = ws[i + 1];
|
|
1680
|
+
if (next in UNITS && UNITS[next] > 0 && UNITS[next] < 10) {
|
|
1681
|
+
out += TENS[w] + UNITS[next];
|
|
1682
|
+
i++;
|
|
1683
|
+
} else out += TENS[w];
|
|
1684
|
+
} else if (w in UNITS) out += UNITS[w];
|
|
1685
|
+
else break;
|
|
1686
|
+
}
|
|
1687
|
+
return out || null;
|
|
1688
|
+
}
|
|
1689
|
+
function parseSpokenDuration(text) {
|
|
1690
|
+
const clock = /(?:(\d+):)?(\d+):(\d{1,2})(?:\.(\d+))?|(\d+):(\d{1,2})(?:\.(\d+))?/.exec(text);
|
|
1691
|
+
if (clock) {
|
|
1692
|
+
if (clock[3] != null) {
|
|
1693
|
+
const [h, m, s, f] = [Number(_nullishCoalesce(clock[1], () => ( 0))), Number(clock[2]), Number(clock[3]), _nullishCoalesce(clock[4], () => ( "0"))];
|
|
1694
|
+
return clock[1] != null ? h * 3600 + m * 60 + s + Number(`0.${f}`) : m * 60 + s + Number(`0.${f}`);
|
|
1695
|
+
}
|
|
1696
|
+
}
|
|
1697
|
+
const lower = text.toLowerCase().replace(/\ban hour\b/g, "one hour").replace(/\ba minute\b/g, "one minute").replace(/(\S+) (hours?|minutes?) and a half/g, "$1 and a half $2");
|
|
1698
|
+
const parts = lower.split(/\b(hours?|hrs?|minutes?|mins?|seconds?|secs?)\b/);
|
|
1699
|
+
const scale = (unit) => unit.startsWith("h") ? 3600 : unit.startsWith("m") ? 60 : 1;
|
|
1700
|
+
let total = 0;
|
|
1701
|
+
let found = false;
|
|
1702
|
+
let last = 0;
|
|
1703
|
+
for (let i = 0; i < parts.length; i += 2) {
|
|
1704
|
+
const n = parseSpokenNumber(parts[i]);
|
|
1705
|
+
const unit = parts[i + 1];
|
|
1706
|
+
const s = unit != null ? scale(unit) : last === 3600 ? 60 : last === 60 ? 1 : 0;
|
|
1707
|
+
if (unit != null) last = s;
|
|
1708
|
+
if (n == null || !s) continue;
|
|
1709
|
+
total += n * s;
|
|
1710
|
+
found = true;
|
|
1711
|
+
}
|
|
1712
|
+
if (found) return Math.round(total * 100) / 100;
|
|
1713
|
+
return null;
|
|
1714
|
+
}
|
|
1715
|
+
var normalize = (s) => words(s).join(" ");
|
|
1716
|
+
var singular = (w) => w.length > 3 && w.endsWith("s") && !w.endsWith("ss") ? w.slice(0, -1) : w;
|
|
1717
|
+
var loose = (s) => normalize(s).split(" ").map(singular).join(" ");
|
|
1718
|
+
function matchChoices(text, choices2) {
|
|
1719
|
+
const said = ` ${loose(text)} `;
|
|
1720
|
+
const hits = [];
|
|
1721
|
+
const byLength = [...choices2].sort((a, b) => b.label.length - a.label.length);
|
|
1722
|
+
for (const c of byLength) {
|
|
1723
|
+
const label = loose(c.label);
|
|
1724
|
+
if (!label) continue;
|
|
1725
|
+
let from = 0;
|
|
1726
|
+
for (; ; ) {
|
|
1727
|
+
const at = said.indexOf(` ${label} `, from);
|
|
1728
|
+
if (at < 0) break;
|
|
1729
|
+
const end = at + label.length + 1;
|
|
1730
|
+
if (!hits.some((h) => at < h.end && end > h.at)) hits.push({ at, end, value: c.value });
|
|
1731
|
+
from = at + 1;
|
|
1732
|
+
}
|
|
1733
|
+
}
|
|
1734
|
+
if (!hits.length) {
|
|
1735
|
+
const n = parseSpokenNumber(text);
|
|
1736
|
+
const c = n == null ? void 0 : choices2.find((x) => x.value === n || Number(x.label) === n || x.value === String(n));
|
|
1737
|
+
return c ? [c.value] : [];
|
|
1738
|
+
}
|
|
1739
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1740
|
+
return hits.sort((a, b) => a.at - b.at).map((h) => h.value).filter((v) => !seen.has(v) && seen.add(v));
|
|
1741
|
+
}
|
|
1742
|
+
var YES = /* @__PURE__ */ new Set(["yes", "yeah", "yep", "yup", "true", "on", "done", "did", "checked", "correct", "affirmative"]);
|
|
1743
|
+
var NO = /* @__PURE__ */ new Set(["no", "nope", "nah", "false", "off", "not", "didnt", "didn", "unchecked", "negative"]);
|
|
1744
|
+
function parseSpokenYesNo(text) {
|
|
1745
|
+
const ws = words(text.replace(/['’]/g, ""));
|
|
1746
|
+
if (ws.some((w) => NO.has(w))) return false;
|
|
1747
|
+
if (ws.some((w) => YES.has(w))) return true;
|
|
1748
|
+
return null;
|
|
1749
|
+
}
|
|
1750
|
+
function spokenValue(panel, said, current = null, choices2) {
|
|
1751
|
+
const text = said.trim();
|
|
1752
|
+
if (!text) return { problem: "Didn\u2019t hear anything" };
|
|
1753
|
+
const o = panel.options;
|
|
1754
|
+
const quoted = `\u201C${text}\u201D`;
|
|
1755
|
+
switch (panel.type) {
|
|
1756
|
+
case "input-text": {
|
|
1757
|
+
if (o.suggest || typeof current !== "string" || !current.trim()) return { value: text };
|
|
1758
|
+
return { value: `${current.trimEnd()} ${text}` };
|
|
1759
|
+
}
|
|
1760
|
+
case "input-number":
|
|
1761
|
+
case "input-rating": {
|
|
1762
|
+
const n = parseSpokenNumber(text);
|
|
1763
|
+
if (n == null) return { problem: `Heard ${quoted}, not a number` };
|
|
1764
|
+
const step = panel.type === "input-rating" ? 1 : _nullishCoalesce(o.step, () => ( 1));
|
|
1765
|
+
return { value: Number.isInteger(step) ? Math.round(n) : n };
|
|
1766
|
+
}
|
|
1767
|
+
case "input-slider": {
|
|
1768
|
+
const min = _nullishCoalesce(o.min, () => ( 0));
|
|
1769
|
+
const max = _nullishCoalesce(o.max, () => ( 10));
|
|
1770
|
+
const step = _nullishCoalesce(o.step, () => ( 1));
|
|
1771
|
+
if (_optionalChain([o, 'access', _154 => _154.labels, 'optionalAccess', _155 => _155.length])) {
|
|
1772
|
+
const [hit] = matchChoices(text, o.labels.map((label, i) => ({ label, value: i })));
|
|
1773
|
+
if (typeof hit === "number") {
|
|
1774
|
+
const raw = o.labels.length === 1 ? min : min + hit / (o.labels.length - 1) * (max - min);
|
|
1775
|
+
return { value: Number((Math.round((raw - min) / step) * step + min).toFixed((_nullishCoalesce(String(step).split(".")[1], () => ( ""))).length)) };
|
|
1776
|
+
}
|
|
1777
|
+
}
|
|
1778
|
+
const n = parseSpokenNumber(text);
|
|
1779
|
+
if (n == null) return { problem: `Heard ${quoted}, not a number` };
|
|
1780
|
+
return { value: Number.isInteger(step) ? Math.round(n) : n };
|
|
1781
|
+
}
|
|
1782
|
+
case "input-duration": {
|
|
1783
|
+
const s = _nullishCoalesce(parseSpokenDuration(text), () => ( parseSpokenNumber(text)));
|
|
1784
|
+
return s == null ? { problem: `Heard ${quoted}, not a time` } : { value: s };
|
|
1785
|
+
}
|
|
1786
|
+
case "input-select": {
|
|
1787
|
+
const options = _nullishCoalesce(_nullishCoalesce(choices2, () => ( o.choices)), () => ( []));
|
|
1788
|
+
const hits = matchChoices(text, options);
|
|
1789
|
+
if (!hits.length) return { problem: `Heard ${quoted}, not one of the choices` };
|
|
1790
|
+
if (!o.multi) return { value: hits[0] };
|
|
1791
|
+
const had = Array.isArray(current) ? current : current == null ? [] : [current];
|
|
1792
|
+
return { value: [...had, ...hits.filter((h) => !had.includes(h))] };
|
|
1793
|
+
}
|
|
1794
|
+
case "input-toggle": {
|
|
1795
|
+
const yes = parseSpokenYesNo(text);
|
|
1796
|
+
return yes == null ? { problem: `Heard ${quoted}, not yes or no` } : { value: yes };
|
|
1797
|
+
}
|
|
1798
|
+
default:
|
|
1799
|
+
return { problem: "This input doesn\u2019t take dictation" };
|
|
1800
|
+
}
|
|
1801
|
+
}
|
|
1802
|
+
var DICTATION_TYPES = ["input-number", "input-text", "input-select", "input-duration"];
|
|
1803
|
+
var takesDictation = (panel) => DICTATION_TYPES.includes(panel.type);
|
|
1804
|
+
function dictationHints(panel, choices2) {
|
|
1805
|
+
const out = (_nullishCoalesce(_nullishCoalesce(choices2, () => ( panel.options.choices)), () => ( []))).map((c) => c.label);
|
|
1806
|
+
if (panel.options.unit) out.push(panel.options.unit);
|
|
1807
|
+
return out;
|
|
1808
|
+
}
|
|
1809
|
+
|
|
1810
|
+
// src/core/formFill.ts
|
|
1811
|
+
var choicesOf = (p, runtime) => _nullishCoalesce((p.options.choicesFrom ? runtime[p.options.choicesFrom] : p.options.choices), () => ( []));
|
|
1812
|
+
function fillForm(dashboard, choices2 = {}) {
|
|
1813
|
+
const fields = [];
|
|
1814
|
+
const panels = {};
|
|
1815
|
+
for (const p of plainInputPanels(dashboard)) {
|
|
1816
|
+
const o = p.options;
|
|
1817
|
+
if (p.type === "input-counter" || panels[o.metric]) continue;
|
|
1818
|
+
const base = { key: o.metric, label: p.title || o.metric };
|
|
1819
|
+
let field2;
|
|
1820
|
+
switch (p.type) {
|
|
1821
|
+
case "input-number":
|
|
1822
|
+
field2 = { ...base, type: "number", unit: o.unit, min: o.min, max: o.max };
|
|
1823
|
+
break;
|
|
1824
|
+
case "input-rating":
|
|
1825
|
+
field2 = { ...base, type: "number", min: Math.round(_nullishCoalesce(o.min, () => ( 1))), max: Math.round(_nullishCoalesce(o.max, () => ( 5))) };
|
|
1826
|
+
break;
|
|
1827
|
+
case "input-slider":
|
|
1828
|
+
field2 = { ...base, type: "number", unit: o.unit, min: _nullishCoalesce(o.min, () => ( 0)), max: _nullishCoalesce(o.max, () => ( 10)), choices: _optionalChain([o, 'access', _156 => _156.labels, 'optionalAccess', _157 => _157.length]) ? o.labels : void 0 };
|
|
1829
|
+
break;
|
|
1830
|
+
case "input-duration":
|
|
1831
|
+
field2 = { ...base, type: "duration" };
|
|
1832
|
+
break;
|
|
1833
|
+
case "input-select": {
|
|
1834
|
+
const labels = choicesOf(p, choices2).map((c) => c.label);
|
|
1835
|
+
if (!labels.length) continue;
|
|
1836
|
+
field2 = { ...base, type: o.multi ? "choices" : "choice", choices: labels };
|
|
1837
|
+
break;
|
|
1838
|
+
}
|
|
1839
|
+
case "input-toggle":
|
|
1840
|
+
field2 = { ...base, type: "boolean" };
|
|
1841
|
+
break;
|
|
1842
|
+
case "input-text":
|
|
1843
|
+
field2 = { ...base, type: "text" };
|
|
1844
|
+
break;
|
|
1845
|
+
default:
|
|
1846
|
+
continue;
|
|
1847
|
+
}
|
|
1848
|
+
fields.push(Object.fromEntries(Object.entries(field2).filter(([, v]) => v !== void 0)));
|
|
1849
|
+
panels[o.metric] = p;
|
|
1850
|
+
}
|
|
1851
|
+
return { fields, panels, choices: choices2 };
|
|
1852
|
+
}
|
|
1853
|
+
function describe(f) {
|
|
1854
|
+
const range = f.min != null && f.max != null ? `, from ${f.min} to ${f.max}` : f.min != null ? `, ${f.min} or more` : f.max != null ? `, at most ${f.max}` : "";
|
|
1855
|
+
switch (f.type) {
|
|
1856
|
+
case "number":
|
|
1857
|
+
return `a number${f.unit ? ` in ${f.unit}` : ""}${range}${f.choices ? ` (${f.choices.join(" \u2026 ")} along the scale)` : ""}`;
|
|
1858
|
+
case "duration":
|
|
1859
|
+
return "a duration in seconds";
|
|
1860
|
+
case "choice":
|
|
1861
|
+
return `one of: ${f.choices.map((c) => JSON.stringify(c)).join(", ")}`;
|
|
1862
|
+
case "choices":
|
|
1863
|
+
return `a list of any of: ${f.choices.map((c) => JSON.stringify(c)).join(", ")}`;
|
|
1864
|
+
case "boolean":
|
|
1865
|
+
return "true or false";
|
|
1866
|
+
case "text":
|
|
1867
|
+
return "text, in the user\u2019s words";
|
|
1868
|
+
}
|
|
1869
|
+
}
|
|
1870
|
+
function fillSchema(form) {
|
|
1871
|
+
const properties = {};
|
|
1872
|
+
for (const f of form.fields) {
|
|
1873
|
+
const description = `${f.label}: ${describe(f)}`;
|
|
1874
|
+
switch (f.type) {
|
|
1875
|
+
case "number":
|
|
1876
|
+
case "duration":
|
|
1877
|
+
properties[f.key] = { type: "number", description, ...f.min != null && { minimum: f.min }, ...f.max != null && { maximum: f.max } };
|
|
1878
|
+
break;
|
|
1879
|
+
case "choice":
|
|
1880
|
+
properties[f.key] = { type: "string", enum: f.choices, description };
|
|
1881
|
+
break;
|
|
1882
|
+
case "choices":
|
|
1883
|
+
properties[f.key] = { type: "array", items: { type: "string", enum: f.choices }, description };
|
|
1884
|
+
break;
|
|
1885
|
+
case "boolean":
|
|
1886
|
+
properties[f.key] = { type: "boolean", description };
|
|
1887
|
+
break;
|
|
1888
|
+
case "text":
|
|
1889
|
+
properties[f.key] = { type: "string", description };
|
|
1890
|
+
break;
|
|
1891
|
+
}
|
|
1892
|
+
}
|
|
1893
|
+
return { type: "object", properties, required: [], additionalProperties: false };
|
|
1894
|
+
}
|
|
1895
|
+
function fillPrompt(form, said) {
|
|
1896
|
+
const instructions = [
|
|
1897
|
+
"You fill in a form from what the user said.",
|
|
1898
|
+
"Reply with one JSON object and nothing else. Its keys are field keys from the list below.",
|
|
1899
|
+
"Only include fields the user gave a value for; leave the others out. Never guess or make up values.",
|
|
1900
|
+
"Numbers are plain numbers without units. Choices use the exact text listed."
|
|
1901
|
+
].join(" ");
|
|
1902
|
+
const list = form.fields.map((f) => `- ${f.key}: ${f.label}, ${describe(f)}`).join("\n");
|
|
1903
|
+
const example = form.fields.find((f) => f.type === "number");
|
|
1904
|
+
const prompt = [
|
|
1905
|
+
`Fields:
|
|
1906
|
+
${list}`,
|
|
1907
|
+
example ? `Example: if the user said "${example.label.toLowerCase()} 3" the answer is {"${example.key}": 3}` : "",
|
|
1908
|
+
`The user said: "${said.replace(/"/g, "'")}"`,
|
|
1909
|
+
"JSON:"
|
|
1910
|
+
].filter(Boolean).join("\n\n");
|
|
1911
|
+
return { instructions, prompt };
|
|
1912
|
+
}
|
|
1913
|
+
function parseFillAnswer(answer) {
|
|
1914
|
+
if (answer && typeof answer === "object" && !Array.isArray(answer)) return answer;
|
|
1915
|
+
if (typeof answer !== "string") return null;
|
|
1916
|
+
const start = answer.indexOf("{");
|
|
1917
|
+
const end = answer.lastIndexOf("}");
|
|
1918
|
+
if (start < 0 || end <= start) return null;
|
|
1919
|
+
try {
|
|
1920
|
+
const v = JSON.parse(answer.slice(start, end + 1));
|
|
1921
|
+
return v && typeof v === "object" && !Array.isArray(v) ? v : null;
|
|
1922
|
+
} catch (e11) {
|
|
1923
|
+
return null;
|
|
1924
|
+
}
|
|
1925
|
+
}
|
|
1926
|
+
function asSaid(v) {
|
|
1927
|
+
if (v == null) return null;
|
|
1928
|
+
if (typeof v === "boolean") return v ? "yes" : "no";
|
|
1929
|
+
if (typeof v === "number") return Number.isFinite(v) ? String(v) : null;
|
|
1930
|
+
if (typeof v === "string") return v.trim() || null;
|
|
1931
|
+
if (Array.isArray(v)) return v.map(asSaid).filter(Boolean).join(", ") || null;
|
|
1932
|
+
return null;
|
|
1933
|
+
}
|
|
1934
|
+
function readFill(form, answer) {
|
|
1935
|
+
const result = { values: {}, problems: [] };
|
|
1936
|
+
const obj = parseFillAnswer(answer);
|
|
1937
|
+
if (!obj) return { values: {}, problems: [{ key: "", problem: "The answer wasn\u2019t a JSON object" }] };
|
|
1938
|
+
for (const f of form.fields) {
|
|
1939
|
+
const raw = obj[f.key];
|
|
1940
|
+
const panel = form.panels[f.key];
|
|
1941
|
+
const choices2 = choicesOf(panel, form.choices);
|
|
1942
|
+
if (panel.type === "input-select" && !panel.options.multi) {
|
|
1943
|
+
const byValue = choices2.find((c) => c.value === raw);
|
|
1944
|
+
if (byValue) {
|
|
1945
|
+
result.values[f.key] = byValue.value;
|
|
1946
|
+
continue;
|
|
1947
|
+
}
|
|
1948
|
+
}
|
|
1949
|
+
const said = asSaid(raw);
|
|
1950
|
+
if (said == null) continue;
|
|
1951
|
+
const r = spokenValue(panel, said, null, choices2);
|
|
1952
|
+
if ("value" in r) result.values[f.key] = r.value;
|
|
1953
|
+
else result.problems.push({ key: f.key, problem: r.problem });
|
|
1954
|
+
}
|
|
1955
|
+
return result;
|
|
1956
|
+
}
|
|
1957
|
+
var UNIT_WORDS = {
|
|
1958
|
+
kg: ["kg", "kgs", "kilo", "kilos", "kilogram", "kilograms"],
|
|
1959
|
+
lb: ["lb", "lbs", "pound", "pounds"],
|
|
1960
|
+
h: ["h", "hr", "hrs", "hour", "hours"],
|
|
1961
|
+
min: ["min", "mins", "minute", "minutes"],
|
|
1962
|
+
s: ["s", "sec", "secs", "second", "seconds"],
|
|
1963
|
+
km: ["km", "kms", "kilometer", "kilometers", "kilometre", "kilometres", "k"],
|
|
1964
|
+
mi: ["mi", "mile", "miles"],
|
|
1965
|
+
m: ["m", "meter", "meters", "metre", "metres"]
|
|
1966
|
+
};
|
|
1967
|
+
var NUMBER_WORD = "(?:-?\\d+(?:[.,]\\d+)?|zero|oh|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twenty|thirty|forty|fifty|sixty|seventy|eighty|ninety|hundred|thousand|point|and|a|half|quarter|minus)";
|
|
1968
|
+
var escape = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1969
|
+
function namesOf(f) {
|
|
1970
|
+
const names = /* @__PURE__ */ new Set([f.label.toLowerCase(), f.key.toLowerCase().replace(/[-_]+/g, " ")]);
|
|
1971
|
+
return [...names].filter((n) => n.trim().length > 1);
|
|
1972
|
+
}
|
|
1973
|
+
var LEAD = /^[\s,:;.-]*(?:(?:is|was|were|of|at|about|around|to|=)\b[\s,:;.-]*)*/i;
|
|
1974
|
+
function ruleFill(form, said) {
|
|
1975
|
+
const lower = said.toLowerCase();
|
|
1976
|
+
const hits = [];
|
|
1977
|
+
for (const f of form.fields)
|
|
1978
|
+
for (const name of namesOf(f)) {
|
|
1979
|
+
const re = new RegExp(`(?<![\\p{L}\\p{N}])${escape(name)}(?![\\p{L}\\p{N}])`, "gu");
|
|
1980
|
+
for (const m of lower.matchAll(re)) {
|
|
1981
|
+
const at = m.index;
|
|
1982
|
+
const end = at + m[0].length;
|
|
1983
|
+
if (!hits.some((h) => at < h.end && end > h.at)) hits.push({ key: f.key, at, end });
|
|
1984
|
+
}
|
|
1985
|
+
}
|
|
1986
|
+
hits.sort((a, b) => a.at - b.at);
|
|
1987
|
+
const segments = {};
|
|
1988
|
+
const used = [];
|
|
1989
|
+
hits.forEach((h, i) => {
|
|
1990
|
+
const stop = i + 1 < hits.length ? hits[i + 1].at : said.length;
|
|
1991
|
+
if (h.key in segments) return;
|
|
1992
|
+
segments[h.key] = said.slice(h.end, stop).replace(LEAD, "").replace(/[\s,;.]+$/, "");
|
|
1993
|
+
used.push([h.at, stop]);
|
|
1994
|
+
});
|
|
1995
|
+
const answer = {};
|
|
1996
|
+
for (const f of form.fields) if (segments[f.key]) answer[f.key] = segments[f.key];
|
|
1997
|
+
const rest = used.reduceRight((text, [a, b]) => text.slice(0, a) + " ".repeat(b - a) + text.slice(b), said);
|
|
1998
|
+
for (const f of form.fields) {
|
|
1999
|
+
if (f.key in answer) continue;
|
|
2000
|
+
if (f.type === "number" && f.unit) {
|
|
2001
|
+
const words2 = _nullishCoalesce(UNIT_WORDS[f.unit.toLowerCase()], () => ( [f.unit.toLowerCase()]));
|
|
2002
|
+
const unitRe = new RegExp(`(?<![\\p{L}\\p{N}])((?:${NUMBER_WORD}[\\s-]+)+)(?:${words2.map(escape).join("|")})(?![\\p{L}\\p{N}])`, "iu");
|
|
2003
|
+
const m = unitRe.exec(rest);
|
|
2004
|
+
if (m && m[1].trim()) answer[f.key] = m[1];
|
|
2005
|
+
} else if ((f.type === "choice" || f.type === "choices") && f.choices) {
|
|
2006
|
+
const options = f.choices.map((label) => ({ label, value: label }));
|
|
2007
|
+
const hits2 = matchChoices(rest, options);
|
|
2008
|
+
const shared = form.fields.some(
|
|
2009
|
+
(g) => g !== f && !(g.key in answer) && (g.type === "choice" || g.type === "choices") && matchChoices(rest, (_nullishCoalesce(g.choices, () => ( []))).map((l) => ({ label: l, value: l }))).length
|
|
2010
|
+
);
|
|
2011
|
+
if (hits2.length && !shared) answer[f.key] = f.type === "choices" ? hits2 : hits2[0];
|
|
2012
|
+
}
|
|
2013
|
+
}
|
|
2014
|
+
return readFill(form, answer);
|
|
2015
|
+
}
|
|
2016
|
+
var ruleFiller = async (form, said) => ruleFill(form, said);
|
|
2017
|
+
function modelFiller(generate, fallback) {
|
|
2018
|
+
return async (form, said) => {
|
|
2019
|
+
let result = null;
|
|
2020
|
+
try {
|
|
2021
|
+
const { instructions, prompt } = fillPrompt(form, said);
|
|
2022
|
+
result = readFill(form, await generate(instructions, prompt, fillSchema(form)));
|
|
2023
|
+
if (result.problems.some((p) => p.key === "")) result = null;
|
|
2024
|
+
} catch (e12) {
|
|
2025
|
+
result = null;
|
|
2026
|
+
}
|
|
2027
|
+
if (!fallback) return _nullishCoalesce(result, () => ( { values: {}, problems: [{ key: "", problem: "The model couldn\u2019t fill the form" }] }));
|
|
2028
|
+
const rules = await fallback(form, said);
|
|
2029
|
+
if (!result) return rules;
|
|
2030
|
+
const values = { ...rules.values, ...result.values };
|
|
2031
|
+
const problems = [...result.problems, ...rules.problems.filter((p) => !(p.key in values))];
|
|
2032
|
+
return { values, problems };
|
|
2033
|
+
};
|
|
2034
|
+
}
|
|
2035
|
+
function fillHints(form) {
|
|
2036
|
+
const out = /* @__PURE__ */ new Set();
|
|
2037
|
+
for (const f of form.fields) {
|
|
2038
|
+
out.add(f.label);
|
|
2039
|
+
if (f.unit) out.add(f.unit);
|
|
2040
|
+
for (const c of _nullishCoalesce(f.choices, () => ( []))) out.add(c);
|
|
2041
|
+
}
|
|
2042
|
+
return [...out];
|
|
2043
|
+
}
|
|
2044
|
+
|
|
1570
2045
|
// src/core/local.ts
|
|
1571
2046
|
var LOCAL_DATASOURCE_TYPE = "modelform-local";
|
|
1572
2047
|
var LEGACY_LOCAL_DATASOURCE_TYPE = "dashkit-local";
|
|
@@ -1643,7 +2118,7 @@ function buildFrames(target, entries, request, label, siblings = []) {
|
|
|
1643
2118
|
const fill = _nullishCoalesce(target.fillZero, () => ( (aggregate === "sum" || aggregate === "count")));
|
|
1644
2119
|
({ times, values } = bucketize(rows, aggregate, bucket, request.range, fill));
|
|
1645
2120
|
}
|
|
1646
|
-
const display = group == null ? name : _nullishCoalesce(_optionalChain([label, 'optionalCall',
|
|
2121
|
+
const display = group == null ? name : _nullishCoalesce(_optionalChain([label, 'optionalCall', _158 => _158(labelKey, group)]), () => ( group));
|
|
1647
2122
|
return {
|
|
1648
2123
|
name,
|
|
1649
2124
|
refId: target.refId,
|
|
@@ -1699,7 +2174,7 @@ function bucketize(rows, aggregate, bucket, range, fillZero) {
|
|
|
1699
2174
|
const keys = fillZero ? step.range(range.from, range.to) : [...sums.keys()].sort((a, b) => a - b);
|
|
1700
2175
|
const values = keys.map((k) => {
|
|
1701
2176
|
const vs = sums.get(k);
|
|
1702
|
-
return _optionalChain([vs, 'optionalAccess',
|
|
2177
|
+
return _optionalChain([vs, 'optionalAccess', _159 => _159.length]) ? reduce2(vs, aggregate) : fillZero ? 0 : null;
|
|
1703
2178
|
});
|
|
1704
2179
|
return { times: keys, values };
|
|
1705
2180
|
}
|
|
@@ -1780,17 +2255,17 @@ function parseGazetteer(json) {
|
|
|
1780
2255
|
};
|
|
1781
2256
|
if (Array.isArray(json)) {
|
|
1782
2257
|
for (const item of json) {
|
|
1783
|
-
const lat = Number(_nullishCoalesce(_optionalChain([item, 'optionalAccess',
|
|
1784
|
-
const lon = Number(_nullishCoalesce(_nullishCoalesce(_optionalChain([item, 'optionalAccess',
|
|
2258
|
+
const lat = Number(_nullishCoalesce(_optionalChain([item, 'optionalAccess', _160 => _160.latitude]), () => ( _optionalChain([item, 'optionalAccess', _161 => _161.lat]))));
|
|
2259
|
+
const lon = Number(_nullishCoalesce(_nullishCoalesce(_optionalChain([item, 'optionalAccess', _162 => _162.longitude]), () => ( _optionalChain([item, 'optionalAccess', _163 => _163.lon]))), () => ( _optionalChain([item, 'optionalAccess', _164 => _164.lng]))));
|
|
1785
2260
|
if (!Number.isFinite(lat) || !Number.isFinite(lon)) continue;
|
|
1786
2261
|
const p = { lon, lat };
|
|
1787
2262
|
add(item.key, p);
|
|
1788
2263
|
for (const k of [..._nullishCoalesce(item.keys, () => ( [])), ..._nullishCoalesce(item.keywords, () => ( []))]) add(k, p);
|
|
1789
2264
|
add(item.name, p);
|
|
1790
2265
|
}
|
|
1791
|
-
} else if (_optionalChain([json, 'optionalAccess',
|
|
2266
|
+
} else if (_optionalChain([json, 'optionalAccess', _165 => _165.type]) === "FeatureCollection") {
|
|
1792
2267
|
for (const f of _nullishCoalesce(json.features, () => ( []))) {
|
|
1793
|
-
const p = featurePoint(_optionalChain([f, 'optionalAccess',
|
|
2268
|
+
const p = featurePoint(_optionalChain([f, 'optionalAccess', _166 => _166.geometry]));
|
|
1794
2269
|
if (!p) continue;
|
|
1795
2270
|
add(f.id, p);
|
|
1796
2271
|
for (const v of Object.values(_nullishCoalesce(f.properties, () => ( {})))) if (typeof v === "string") add(v, p);
|
|
@@ -1799,7 +2274,7 @@ function parseGazetteer(json) {
|
|
|
1799
2274
|
return { find: (key) => _nullishCoalesce(exact.get(key), () => ( folded.get(key.toLowerCase()))) };
|
|
1800
2275
|
}
|
|
1801
2276
|
function featurePoint(geometry) {
|
|
1802
|
-
if (!_optionalChain([geometry, 'optionalAccess',
|
|
2277
|
+
if (!_optionalChain([geometry, 'optionalAccess', _167 => _167.coordinates])) return void 0;
|
|
1803
2278
|
if (geometry.type === "Point") {
|
|
1804
2279
|
const [lon, lat] = geometry.coordinates;
|
|
1805
2280
|
return Number.isFinite(lon) && Number.isFinite(lat) ? { lon, lat } : void 0;
|
|
@@ -1828,7 +2303,7 @@ function loadGazetteer(path, ds) {
|
|
|
1828
2303
|
const json = absolute ? fetch(path).then((r) => {
|
|
1829
2304
|
if (!r.ok) throw new Error(`${r.status} ${r.statusText}`);
|
|
1830
2305
|
return r.json();
|
|
1831
|
-
}) : _optionalChain([ds, 'optionalAccess',
|
|
2306
|
+
}) : _optionalChain([ds, 'optionalAccess', _168 => _168.publicFile]) ? ds.publicFile(path) : Promise.reject(new Error(`${path} is served by Grafana, and this dashboard has no Grafana connection`));
|
|
1832
2307
|
const run2 = json.then(parseGazetteer);
|
|
1833
2308
|
run2.catch(() => loaded.get(path) === run2 && loaded.delete(path));
|
|
1834
2309
|
loaded.set(path, run2);
|
|
@@ -1868,7 +2343,7 @@ function macro(path, format3, ctx) {
|
|
|
1868
2343
|
switch (head) {
|
|
1869
2344
|
case "__from":
|
|
1870
2345
|
case "__to": {
|
|
1871
|
-
const ms = head === "__from" ? _optionalChain([ctx, 'access',
|
|
2346
|
+
const ms = head === "__from" ? _optionalChain([ctx, 'access', _169 => _169.range, 'optionalAccess', _170 => _170.from]) : _optionalChain([ctx, 'access', _171 => _171.range, 'optionalAccess', _172 => _172.to]);
|
|
1872
2347
|
if (ms == null) return void 0;
|
|
1873
2348
|
if (format3 === "date" || format3 === "date:iso") return new Date(ms).toISOString();
|
|
1874
2349
|
if (format3 === "date:seconds") return String(Math.floor(ms / 1e3));
|
|
@@ -1905,13 +2380,13 @@ function macro(path, format3, ctx) {
|
|
|
1905
2380
|
}
|
|
1906
2381
|
return void 0;
|
|
1907
2382
|
case "__series":
|
|
1908
|
-
return rest[0] === "name" ? _nullishCoalesce(_nullishCoalesce(d.seriesName, () => ( _optionalChain([d, 'access',
|
|
2383
|
+
return rest[0] === "name" ? _nullishCoalesce(_nullishCoalesce(d.seriesName, () => ( _optionalChain([d, 'access', _173 => _173.frame, 'optionalAccess', _174 => _174.name]))), () => ( d.fieldName)) : void 0;
|
|
1909
2384
|
case "__data": {
|
|
1910
2385
|
const m = /^fields(?:\.([\w-]+)|\["([^"]*)"\]|\[(\d+)\])/.exec(rest.join("."));
|
|
1911
2386
|
if (!m || !d.frame || d.row == null) return void 0;
|
|
1912
2387
|
const key = _nullishCoalesce(m[1], () => ( m[2]));
|
|
1913
|
-
const f = key != null ? d.frame.fields.find((x) => x.name === key || _optionalChain([x, 'access',
|
|
1914
|
-
const v = _optionalChain([f, 'optionalAccess',
|
|
2388
|
+
const f = key != null ? d.frame.fields.find((x) => x.name === key || _optionalChain([x, 'access', _175 => _175.config, 'optionalAccess', _176 => _176.displayName]) === key) : d.frame.fields[Number(m[3])];
|
|
2389
|
+
const v = _optionalChain([f, 'optionalAccess', _177 => _177.values, 'access', _178 => _178[d.row]]);
|
|
1915
2390
|
if (v == null) return void 0;
|
|
1916
2391
|
return f.type === "time" ? String(toMillis(v)) : String(v);
|
|
1917
2392
|
}
|
|
@@ -1922,9 +2397,9 @@ function urlTime(raw, ms) {
|
|
|
1922
2397
|
return raw.trim().startsWith("now") ? encodeURIComponent(raw.trim()) : String(ms);
|
|
1923
2398
|
}
|
|
1924
2399
|
function allVariables(ctx) {
|
|
1925
|
-
const names = (_nullishCoalesce(_optionalChain([ctx, 'access',
|
|
2400
|
+
const names = (_nullishCoalesce(_optionalChain([ctx, 'access', _179 => _179.dashboard, 'optionalAccess', _180 => _180.templating, 'optionalAccess', _181 => _181.list]), () => ( []))).filter((v) => v.type !== "adhoc").map((v) => v.name);
|
|
1926
2401
|
return (names.length ? names : Object.keys(ctx.values)).flatMap((n) => {
|
|
1927
|
-
const v = _nullishCoalesce(_optionalChain([ctx, 'access',
|
|
2402
|
+
const v = _nullishCoalesce(_optionalChain([ctx, 'access', _182 => _182.scoped, 'optionalAccess', _183 => _183[n], 'optionalAccess', _184 => _184.value]), () => ( ctx.values[n]));
|
|
1928
2403
|
return v == null ? [] : [queryParam(n, v)];
|
|
1929
2404
|
}).join("&");
|
|
1930
2405
|
}
|
|
@@ -1935,7 +2410,7 @@ function parseDashboardLink(href, grafanaUrl) {
|
|
|
1935
2410
|
const base = grafanaUrl ? /^(?:[a-z][a-z0-9+.-]*:)?\/\/([^/?#]+)([^?#]*)/i.exec(grafanaUrl.trim()) : null;
|
|
1936
2411
|
if (host && (!base || base[1].toLowerCase() !== host.toLowerCase())) return null;
|
|
1937
2412
|
if (scheme && !/^https?:$/i.test(scheme)) return null;
|
|
1938
|
-
const prefix = (_nullishCoalesce(_optionalChain([base, 'optionalAccess',
|
|
2413
|
+
const prefix = (_nullishCoalesce(_optionalChain([base, 'optionalAccess', _185 => _185[2]]), () => ( ""))).replace(/\/+$/, "");
|
|
1939
2414
|
const path = prefix && rawPath.startsWith(prefix + "/") ? rawPath.slice(prefix.length) : rawPath;
|
|
1940
2415
|
const p = /^\/d\/([^/]+)(?:\/[^/]*)?\/?$/.exec(path);
|
|
1941
2416
|
if (!p) return null;
|
|
@@ -1954,17 +2429,17 @@ function parseDashboardLink(href, grafanaUrl) {
|
|
|
1954
2429
|
function decode(s) {
|
|
1955
2430
|
try {
|
|
1956
2431
|
return decodeURIComponent(s.replace(/\+/g, " "));
|
|
1957
|
-
} catch (
|
|
2432
|
+
} catch (e13) {
|
|
1958
2433
|
return s;
|
|
1959
2434
|
}
|
|
1960
2435
|
}
|
|
1961
2436
|
function applyDashboardLink(dashboard, target) {
|
|
1962
|
-
const time = target.from || target.to ? { from: target.from || _optionalChain([dashboard, 'access',
|
|
1963
|
-
const list = _optionalChain([dashboard, 'access',
|
|
2437
|
+
const time = target.from || target.to ? { from: target.from || _optionalChain([dashboard, 'access', _186 => _186.time, 'optionalAccess', _187 => _187.from]) || "now-6h", to: target.to || _optionalChain([dashboard, 'access', _188 => _188.time, 'optionalAccess', _189 => _189.to]) || "now" } : dashboard.time;
|
|
2438
|
+
const list = _optionalChain([dashboard, 'access', _190 => _190.templating, 'optionalAccess', _191 => _191.list, 'access', _192 => _192.map, 'call', _193 => _193((v) => {
|
|
1964
2439
|
const values = target.vars[v.name];
|
|
1965
|
-
if (!_optionalChain([values, 'optionalAccess',
|
|
2440
|
+
if (!_optionalChain([values, 'optionalAccess', _194 => _194.length])) return v;
|
|
1966
2441
|
const value = v.multi ? values : values[0];
|
|
1967
|
-
const text = (Array.isArray(value) ? value : [value]).map((x) => x === "$__all" ? "All" : _nullishCoalesce(_optionalChain([v, 'access',
|
|
2442
|
+
const text = (Array.isArray(value) ? value : [value]).map((x) => x === "$__all" ? "All" : _nullishCoalesce(_optionalChain([v, 'access', _195 => _195.options, 'optionalAccess', _196 => _196.find, 'call', _197 => _197((o) => o.value === x), 'optionalAccess', _198 => _198.text]), () => ( x)));
|
|
1968
2443
|
return { ...v, current: { text: v.multi ? text : text[0], value } };
|
|
1969
2444
|
})]);
|
|
1970
2445
|
return { ...dashboard, time, templating: list ? { ...dashboard.templating, list } : dashboard.templating };
|
|
@@ -8098,7 +8573,7 @@ function removeAt(root, pointer) {
|
|
|
8098
8573
|
const segs = pointer.split("/").slice(1).map((s) => s.replace(/~1/g, "/").replace(/~0/g, "~"));
|
|
8099
8574
|
const last = segs.pop();
|
|
8100
8575
|
let parent = root;
|
|
8101
|
-
for (const s of segs) parent = _optionalChain([parent, 'optionalAccess',
|
|
8576
|
+
for (const s of segs) parent = _optionalChain([parent, 'optionalAccess', _199 => _199[s]]);
|
|
8102
8577
|
if (Array.isArray(parent)) {
|
|
8103
8578
|
parent.splice(Number(last), 1);
|
|
8104
8579
|
return { array: parentOf(pointer), index: Number(last) };
|
|
@@ -8271,7 +8746,7 @@ var STANDARD = [
|
|
|
8271
8746
|
]
|
|
8272
8747
|
}
|
|
8273
8748
|
},
|
|
8274
|
-
{ path: field("color.fixedColor"), label: "Color", category: "Standard options", control: { kind: "color" }, showIf: (p) => _optionalChain([p, 'access',
|
|
8749
|
+
{ path: field("color.fixedColor"), label: "Color", category: "Standard options", control: { kind: "color" }, showIf: (p) => _optionalChain([p, 'access', _200 => _200.fieldConfig, 'optionalAccess', _201 => _201.defaults, 'optionalAccess', _202 => _202.color, 'optionalAccess', _203 => _203.mode]) === "fixed" }
|
|
8275
8750
|
];
|
|
8276
8751
|
var THRESHOLDS = {
|
|
8277
8752
|
path: field("thresholds"),
|
|
@@ -8297,7 +8772,7 @@ var CALC = {
|
|
|
8297
8772
|
default: "lastNotNull",
|
|
8298
8773
|
control: { kind: "select", choices: Object.entries(REDUCER_LABELS).map(([value, label]) => ({ label, value })) },
|
|
8299
8774
|
stored: "string[]",
|
|
8300
|
-
get: (p) => _optionalChain([p, 'access',
|
|
8775
|
+
get: (p) => _optionalChain([p, 'access', _204 => _204.options, 'optionalAccess', _205 => _205.reduceOptions, 'optionalAccess', _206 => _206.calcs, 'optionalAccess', _207 => _207[0]]),
|
|
8301
8776
|
set: (p, v) => setOptionValue(p, "options.reduceOptions.calcs", v === void 0 ? void 0 : [v])
|
|
8302
8777
|
};
|
|
8303
8778
|
var LEGEND = {
|
|
@@ -8307,9 +8782,9 @@ var LEGEND = {
|
|
|
8307
8782
|
help: "When there are two or more series.",
|
|
8308
8783
|
default: true,
|
|
8309
8784
|
control: { kind: "boolean" },
|
|
8310
|
-
get: (p) => _optionalChain([p, 'access',
|
|
8785
|
+
get: (p) => _optionalChain([p, 'access', _208 => _208.options, 'optionalAccess', _209 => _209.legend, 'optionalAccess', _210 => _210.showLegend]) !== false && _optionalChain([p, 'access', _211 => _211.options, 'optionalAccess', _212 => _212.legend, 'optionalAccess', _213 => _213.displayMode]) !== "hidden",
|
|
8311
8786
|
// Grafana's older displayMode "hidden" would otherwise keep it hidden.
|
|
8312
|
-
set: (p, v) => setOptionValue(v ? setOptionValue(p, "options.legend.displayMode", _optionalChain([p, 'access',
|
|
8787
|
+
set: (p, v) => setOptionValue(v ? setOptionValue(p, "options.legend.displayMode", _optionalChain([p, 'access', _214 => _214.options, 'optionalAccess', _215 => _215.legend, 'optionalAccess', _216 => _216.displayMode]) === "hidden" ? void 0 : _optionalChain([p, 'access', _217 => _217.options, 'optionalAccess', _218 => _218.legend, 'optionalAccess', _219 => _219.displayMode])) : p, "options.legend.showLegend", v ? void 0 : false)
|
|
8313
8788
|
};
|
|
8314
8789
|
var AXIS_LABEL = { path: field("custom.axisLabel"), label: "Axis label", category: "Axis", control: { kind: "text" } };
|
|
8315
8790
|
var AXIS_PLACEMENT = {
|
|
@@ -8563,7 +9038,7 @@ function overrideProperties(type) {
|
|
|
8563
9038
|
return out;
|
|
8564
9039
|
}
|
|
8565
9040
|
function panelOverrides(panel) {
|
|
8566
|
-
const o = _optionalChain([panel, 'access',
|
|
9041
|
+
const o = _optionalChain([panel, 'access', _220 => _220.fieldConfig, 'optionalAccess', _221 => _221.overrides]);
|
|
8567
9042
|
return Array.isArray(o) ? o : [];
|
|
8568
9043
|
}
|
|
8569
9044
|
function setOverrides(panel, overrides) {
|
|
@@ -8611,7 +9086,7 @@ function prepareDashboard(json, file) {
|
|
|
8611
9086
|
});
|
|
8612
9087
|
dashboard.panels.forEach((p, i) => {
|
|
8613
9088
|
for (const r of cleanPanelOptions(p)) removed.push({ path: `panels[${i}]${r.path}`, message: r.message });
|
|
8614
|
-
_optionalChain([p, 'access',
|
|
9089
|
+
_optionalChain([p, 'access', _222 => _222.panels, 'optionalAccess', _223 => _223.forEach, 'call', _224 => _224((child, j) => {
|
|
8615
9090
|
for (const r of cleanPanelOptions(child)) removed.push({ path: `panels[${i}].panels[${j}]${r.path}`, message: r.message });
|
|
8616
9091
|
})]);
|
|
8617
9092
|
});
|
|
@@ -8634,7 +9109,7 @@ function groupIssues(dashboard) {
|
|
|
8634
9109
|
for (const { p, at } of located2) if (isInputPanel(p) && !recordedAt.has(p.options.metric)) recordedAt.set(p.options.metric, at);
|
|
8635
9110
|
for (const { p, at } of located2) {
|
|
8636
9111
|
if (p.type !== INPUT_GROUP) continue;
|
|
8637
|
-
const fields = _optionalChain([p, 'access',
|
|
9112
|
+
const fields = _optionalChain([p, 'access', _225 => _225.options, 'optionalAccess', _226 => _226.fields]);
|
|
8638
9113
|
if (!Array.isArray(fields) || !fields.length) {
|
|
8639
9114
|
out.push({ path: `${at}.options.fields`, message: "a group needs at least one field" });
|
|
8640
9115
|
continue;
|
|
@@ -8651,7 +9126,7 @@ function groupIssues(dashboard) {
|
|
|
8651
9126
|
else recordedAt.set(metric, fat);
|
|
8652
9127
|
mine.push(metric);
|
|
8653
9128
|
});
|
|
8654
|
-
const titleFrom = _optionalChain([p, 'access',
|
|
9129
|
+
const titleFrom = _optionalChain([p, 'access', _227 => _227.options, 'optionalAccess', _228 => _228.titleFrom]);
|
|
8655
9130
|
if (titleFrom !== void 0 && !mine.includes(titleFrom)) out.push({ path: `${at}.options.titleFrom`, message: `must be the metric of one of the group\u2019s fields` });
|
|
8656
9131
|
}
|
|
8657
9132
|
return out;
|
|
@@ -8662,7 +9137,7 @@ function panelProblem(p) {
|
|
|
8662
9137
|
const g = p.gridPos;
|
|
8663
9138
|
if (!isObject3(g) || !["x", "y", "w", "h"].every((k) => typeof g[k] === "number"))
|
|
8664
9139
|
return { at: ".gridPos", message: "must have numeric x, y, w and h", summary: "has no usable gridPos" };
|
|
8665
|
-
if (p.type.startsWith("input-") && p.type !== INPUT_GROUP && !nonEmptyString(_optionalChain([p, 'access',
|
|
9140
|
+
if (p.type.startsWith("input-") && p.type !== INPUT_GROUP && !nonEmptyString(_optionalChain([p, 'access', _229 => _229.options, 'optionalAccess', _230 => _230.metric]))) {
|
|
8666
9141
|
const message = `${p.type} needs a metric to record to`;
|
|
8667
9142
|
return { at: ".options.metric", message, summary: message };
|
|
8668
9143
|
}
|
|
@@ -8738,17 +9213,17 @@ function resolveUrl(base, rel) {
|
|
|
8738
9213
|
function httpFetchJson(options = {}) {
|
|
8739
9214
|
const seen = /* @__PURE__ */ new Map();
|
|
8740
9215
|
return async (url, { accept = "application/json", signal } = {}) => {
|
|
8741
|
-
const extra = await _asyncNullishCoalesce(await _optionalChain([options, 'access',
|
|
9216
|
+
const extra = await _asyncNullishCoalesce(await _optionalChain([options, 'access', _231 => _231.headers, 'optionalCall', _232 => _232()]), async () => ( {}));
|
|
8742
9217
|
const key = JSON.stringify([url, accept, extra]);
|
|
8743
9218
|
const last = seen.get(key);
|
|
8744
9219
|
const get = (etag2) => fetch(url, { headers: { Accept: accept, ...extra, ...etag2 && { "If-None-Match": etag2 } }, cache: "no-store", signal });
|
|
8745
|
-
const res = await get(_optionalChain([last, 'optionalAccess',
|
|
8746
|
-
if (!last || _optionalChain([signal, 'optionalAccess',
|
|
9220
|
+
const res = await get(_optionalChain([last, 'optionalAccess', _233 => _233.etag])).catch((e) => {
|
|
9221
|
+
if (!last || _optionalChain([signal, 'optionalAccess', _234 => _234.aborted])) throw e;
|
|
8747
9222
|
seen.delete(key);
|
|
8748
9223
|
return get();
|
|
8749
9224
|
});
|
|
8750
9225
|
if (res.status === 304 && last) return last.json;
|
|
8751
|
-
if (!res.ok) throw new Error(_nullishCoalesce(_optionalChain([options, 'access',
|
|
9226
|
+
if (!res.ok) throw new Error(_nullishCoalesce(_optionalChain([options, 'access', _235 => _235.httpError, 'optionalCall', _236 => _236(res.status)]), () => ( `HTTP ${res.status}`)));
|
|
8752
9227
|
const json = JSON.parse(await res.text());
|
|
8753
9228
|
const etag = res.headers.get("ETag");
|
|
8754
9229
|
if (etag) seen.set(key, { etag, json });
|
|
@@ -8837,7 +9312,7 @@ function revalidateBundle(bundle) {
|
|
|
8837
9312
|
}
|
|
8838
9313
|
const checked = { manifest, documents };
|
|
8839
9314
|
return validateBundle(checked).some((i) => i.severity === "error") ? void 0 : checked;
|
|
8840
|
-
} catch (
|
|
9315
|
+
} catch (e14) {
|
|
8841
9316
|
return void 0;
|
|
8842
9317
|
}
|
|
8843
9318
|
}
|
|
@@ -8870,8 +9345,8 @@ var ConfigLoader = (_class2 = class {
|
|
|
8870
9345
|
async start() {
|
|
8871
9346
|
const { url, cache: cache2 } = this.options;
|
|
8872
9347
|
if (!url) return;
|
|
8873
|
-
const cached = await _optionalChain([cache2, 'optionalAccess',
|
|
8874
|
-
const bundle = _optionalChain([cached, 'optionalAccess',
|
|
9348
|
+
const cached = await _optionalChain([cache2, 'optionalAccess', _237 => _237.read, 'call', _238 => _238(), 'access', _239 => _239.catch, 'call', _240 => _240(() => null)]);
|
|
9349
|
+
const bundle = _optionalChain([cached, 'optionalAccess', _241 => _241.url]) === url ? revalidateBundle(cached.bundle) : void 0;
|
|
8875
9350
|
if (cached && bundle && !this.snapshot.fetchedAt) {
|
|
8876
9351
|
this.lastJson = JSON.stringify(bundle);
|
|
8877
9352
|
this.set({ bundle, source: "cache", fetchedAt: cached.fetchedAt, revision: cached.revision });
|
|
@@ -8901,7 +9376,7 @@ var ConfigLoader = (_class2 = class {
|
|
|
8901
9376
|
if (!bundle) {
|
|
8902
9377
|
const errors = issues.filter((i) => i.severity === "error").length;
|
|
8903
9378
|
const needsUpdate = issues.some((i) => i.code === "newer-version");
|
|
8904
|
-
const error = unreachable ? _optionalChain([issues, 'access',
|
|
9379
|
+
const error = unreachable ? _optionalChain([issues, 'access', _242 => _242[0], 'optionalAccess', _243 => _243.message]) : needsUpdate ? "a newer format" : errors === 1 ? "1 error" : `${errors} errors`;
|
|
8905
9380
|
return this.set(
|
|
8906
9381
|
{ loading: false, error, unreachable: !!unreachable, needsUpdate, issues },
|
|
8907
9382
|
this.snapshot.loading || error !== this.snapshot.error || !!unreachable !== !!this.snapshot.unreachable || needsUpdate !== !!this.snapshot.needsUpdate || !sameIssues(issues, this.snapshot.issues)
|
|
@@ -8911,7 +9386,7 @@ var ConfigLoader = (_class2 = class {
|
|
|
8911
9386
|
const changed = json !== this.lastJson;
|
|
8912
9387
|
this.lastJson = json;
|
|
8913
9388
|
const fetchedAt = Date.now();
|
|
8914
|
-
if (changed || revision !== this.snapshot.revision) _optionalChain([cache2, 'optionalAccess',
|
|
9389
|
+
if (changed || revision !== this.snapshot.revision) _optionalChain([cache2, 'optionalAccess', _244 => _244.write, 'call', _245 => _245({ url, fetchedAt, bundle, revision }), 'access', _246 => _246.catch, 'call', _247 => _247(() => {
|
|
8915
9390
|
})]);
|
|
8916
9391
|
this.set(
|
|
8917
9392
|
{ ...changed && { bundle }, source: "remote", fetchedAt, revision, loading: false, error: void 0, unreachable: void 0, needsUpdate: void 0, issues },
|
|
@@ -8928,7 +9403,7 @@ var ConfigLoader = (_class2 = class {
|
|
|
8928
9403
|
/** Stops the loader: cancels a fetch in flight, and nothing it does afterwards changes the state or the cache. */
|
|
8929
9404
|
dispose() {
|
|
8930
9405
|
this.disposed = true;
|
|
8931
|
-
_optionalChain([this, 'access',
|
|
9406
|
+
_optionalChain([this, 'access', _248 => _248.controller, 'optionalAccess', _249 => _249.abort, 'call', _250 => _250()]);
|
|
8932
9407
|
this.listeners.clear();
|
|
8933
9408
|
}
|
|
8934
9409
|
/** `notify: false` drops the patch, so the snapshot only changes when listeners hear about it. */
|
|
@@ -8949,7 +9424,7 @@ function tabIdFor(title, taken) {
|
|
|
8949
9424
|
}
|
|
8950
9425
|
function screenOfType(type, from, docs) {
|
|
8951
9426
|
const shown = from ? screenDocuments(from) : [];
|
|
8952
|
-
const firstOf = (ids) => _nullishCoalesce(_nullishCoalesce(_optionalChain([shown, 'access',
|
|
9427
|
+
const firstOf = (ids) => _nullishCoalesce(_nullishCoalesce(_optionalChain([shown, 'access', _251 => _251.find, 'call', _252 => _252((d) => ids.includes(d.id)), 'optionalAccess', _253 => _253.id]), () => ( ids[0])), () => ( ""));
|
|
8953
9428
|
switch (type) {
|
|
8954
9429
|
case "dashboard":
|
|
8955
9430
|
return { type, dashboard: firstOf(docs.dashboards) };
|
|
@@ -8962,7 +9437,7 @@ function screenOfType(type, from, docs) {
|
|
|
8962
9437
|
}
|
|
8963
9438
|
}
|
|
8964
9439
|
function screenDocuments(screen) {
|
|
8965
|
-
switch (_optionalChain([screen, 'optionalAccess',
|
|
9440
|
+
switch (_optionalChain([screen, 'optionalAccess', _254 => _254.type])) {
|
|
8966
9441
|
case "dashboard":
|
|
8967
9442
|
return [{ id: screen.dashboard, kind: "dashboard" }];
|
|
8968
9443
|
case "forms":
|
|
@@ -10377,8 +10852,8 @@ function removeNode(text, path) {
|
|
|
10377
10852
|
const tree = parseTree2(text);
|
|
10378
10853
|
const value = tree && findNodeAtLocation2(tree, path);
|
|
10379
10854
|
if (!value) return text;
|
|
10380
|
-
const node = _optionalChain([value, 'access',
|
|
10381
|
-
const siblings = _nullishCoalesce(_optionalChain([node, 'access',
|
|
10855
|
+
const node = _optionalChain([value, 'access', _255 => _255.parent, 'optionalAccess', _256 => _256.type]) === "property" ? value.parent : value;
|
|
10856
|
+
const siblings = _nullishCoalesce(_optionalChain([node, 'access', _257 => _257.parent, 'optionalAccess', _258 => _258.children]), () => ( []));
|
|
10382
10857
|
const i = siblings.indexOf(node);
|
|
10383
10858
|
const next = siblings[i + 1];
|
|
10384
10859
|
const prev = siblings[i - 1];
|
|
@@ -10449,7 +10924,7 @@ function parseManifest(text) {
|
|
|
10449
10924
|
let value;
|
|
10450
10925
|
try {
|
|
10451
10926
|
value = JSON.parse(text);
|
|
10452
|
-
} catch (
|
|
10927
|
+
} catch (e15) {
|
|
10453
10928
|
throw new Error("The manifest isn\u2019t valid JSON");
|
|
10454
10929
|
}
|
|
10455
10930
|
if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("The manifest isn\u2019t an object");
|
|
@@ -10461,20 +10936,20 @@ function removeDocumentFromManifest(text, id) {
|
|
|
10461
10936
|
const edits = [];
|
|
10462
10937
|
const removedTabs = [];
|
|
10463
10938
|
for (let i = tabs.length - 1; i >= 0; i--) {
|
|
10464
|
-
const screen = _optionalChain([tabs, 'access',
|
|
10939
|
+
const screen = _optionalChain([tabs, 'access', _259 => _259[i], 'optionalAccess', _260 => _260.screen]);
|
|
10465
10940
|
const at = ["tabs", i, "screen"];
|
|
10466
10941
|
const removeTab = () => {
|
|
10467
10942
|
edits.push({ path: ["tabs", i], remove: true });
|
|
10468
10943
|
removedTabs.unshift(_nullishCoalesce(tabs[i].title, () => ( tabs[i].id)));
|
|
10469
10944
|
};
|
|
10470
|
-
if (_optionalChain([screen, 'optionalAccess',
|
|
10471
|
-
else if (_optionalChain([screen, 'optionalAccess',
|
|
10945
|
+
if (_optionalChain([screen, 'optionalAccess', _261 => _261.type]) === "dashboard" && screen.dashboard === id) removeTab();
|
|
10946
|
+
else if (_optionalChain([screen, 'optionalAccess', _262 => _262.type]) === "forms" && Array.isArray(screen.forms) && screen.forms.includes(id)) {
|
|
10472
10947
|
if (screen.forms.every((f) => f === id)) removeTab();
|
|
10473
10948
|
else for (let j = screen.forms.length - 1; j >= 0; j--) if (screen.forms[j] === id) edits.push({ path: [...at, "forms", j], remove: true });
|
|
10474
|
-
} else if (_optionalChain([screen, 'optionalAccess',
|
|
10949
|
+
} else if (_optionalChain([screen, 'optionalAccess', _263 => _263.type]) === "menu" && Array.isArray(screen.items))
|
|
10475
10950
|
for (let j = screen.items.length - 1; j >= 0; j--) {
|
|
10476
10951
|
const item = screen.items[j];
|
|
10477
|
-
if (_optionalChain([item, 'optionalAccess',
|
|
10952
|
+
if (_optionalChain([item, 'optionalAccess', _264 => _264.dashboard]) === id || _optionalChain([item, 'optionalAccess', _265 => _265.form]) === id) edits.push({ path: [...at, "items", j], remove: true });
|
|
10478
10953
|
}
|
|
10479
10954
|
}
|
|
10480
10955
|
if (tabs.length && removedTabs.length === tabs.length) throw new Error(`Every tab shows only "${id}". Add another tab first`);
|
|
@@ -10487,21 +10962,21 @@ function renameDocumentInManifest(text, from, to, path) {
|
|
|
10487
10962
|
if (to !== from && to in manifest.documents) throw new Error(`There\u2019s already a document "${to}"`);
|
|
10488
10963
|
const edits = [];
|
|
10489
10964
|
(Array.isArray(manifest.tabs) ? manifest.tabs : []).forEach((tab, i) => {
|
|
10490
|
-
const screen = _optionalChain([tab, 'optionalAccess',
|
|
10965
|
+
const screen = _optionalChain([tab, 'optionalAccess', _266 => _266.screen]);
|
|
10491
10966
|
const at = ["tabs", i, "screen"];
|
|
10492
|
-
if (_optionalChain([screen, 'optionalAccess',
|
|
10493
|
-
if (_optionalChain([screen, 'optionalAccess',
|
|
10967
|
+
if (_optionalChain([screen, 'optionalAccess', _267 => _267.type]) === "dashboard" && screen.dashboard === from) edits.push({ path: [...at, "dashboard"], value: to });
|
|
10968
|
+
if (_optionalChain([screen, 'optionalAccess', _268 => _268.type]) === "forms" && Array.isArray(screen.forms))
|
|
10494
10969
|
screen.forms.forEach((f, j) => f === from && edits.push({ path: [...at, "forms", j], value: to }));
|
|
10495
|
-
if (_optionalChain([screen, 'optionalAccess',
|
|
10970
|
+
if (_optionalChain([screen, 'optionalAccess', _269 => _269.type]) === "menu" && Array.isArray(screen.items))
|
|
10496
10971
|
screen.items.forEach((item, j) => {
|
|
10497
|
-
if (_optionalChain([item, 'optionalAccess',
|
|
10498
|
-
if (_optionalChain([item, 'optionalAccess',
|
|
10972
|
+
if (_optionalChain([item, 'optionalAccess', _270 => _270.dashboard]) === from) edits.push({ path: [...at, "items", j, "dashboard"], value: to });
|
|
10973
|
+
if (_optionalChain([item, 'optionalAccess', _271 => _271.form]) === from) edits.push({ path: [...at, "items", j, "form"], value: to });
|
|
10499
10974
|
});
|
|
10500
10975
|
});
|
|
10501
10976
|
if (path !== void 0) edits.push({ path: ["documents", from], value: path });
|
|
10502
10977
|
let out = applyJsonEdits(text, edits);
|
|
10503
10978
|
if (to !== from) {
|
|
10504
|
-
const key = _optionalChain([findNodeAtLocation2, 'call',
|
|
10979
|
+
const key = _optionalChain([findNodeAtLocation2, 'call', _272 => _272(parseTree2(out), ["documents", from]), 'optionalAccess', _273 => _273.parent, 'optionalAccess', _274 => _274.children, 'optionalAccess', _275 => _275[0]]);
|
|
10505
10980
|
if (key) out = out.slice(0, key.offset) + JSON.stringify(to) + out.slice(key.offset + key.length);
|
|
10506
10981
|
}
|
|
10507
10982
|
return out;
|
|
@@ -10511,7 +10986,7 @@ function parse2(text) {
|
|
|
10511
10986
|
try {
|
|
10512
10987
|
const d = JSON.parse(text);
|
|
10513
10988
|
return d && Array.isArray(d.panels) && d.panels.every((p) => p && typeof p === "object") ? d : void 0;
|
|
10514
|
-
} catch (
|
|
10989
|
+
} catch (e16) {
|
|
10515
10990
|
return void 0;
|
|
10516
10991
|
}
|
|
10517
10992
|
}
|
|
@@ -10522,17 +10997,17 @@ function inputs(text) {
|
|
|
10522
10997
|
if (d)
|
|
10523
10998
|
for (const p of d.panels.flatMap((x) => x.type === "row" ? [x, ..._nullishCoalesce(x.panels, () => ( []))] : [x])) {
|
|
10524
10999
|
if (typeof p.id !== "number") continue;
|
|
10525
|
-
if (isInputGroup(p)) p.options.fields.forEach((f, i) => typeof _optionalChain([f, 'optionalAccess',
|
|
11000
|
+
if (isInputGroup(p)) p.options.fields.forEach((f, i) => typeof _optionalChain([f, 'optionalAccess', _276 => _276.options, 'optionalAccess', _277 => _277.metric]) === "string" && out.set(`${p.id}.${i}`, { metric: f.options.metric, title: f.title }));
|
|
10526
11001
|
else if (isInputPanel(p)) out.set(String(p.id), { metric: p.options.metric, title: p.title });
|
|
10527
11002
|
}
|
|
10528
|
-
} catch (
|
|
11003
|
+
} catch (e17) {
|
|
10529
11004
|
}
|
|
10530
11005
|
return out;
|
|
10531
11006
|
}
|
|
10532
11007
|
function reads(text, metric) {
|
|
10533
11008
|
const d = parse2(text);
|
|
10534
11009
|
const panels = d ? d.panels.flatMap((p) => p.type === "row" ? [p, ..._nullishCoalesce(p.panels, () => ( []))] : [p]) : [];
|
|
10535
|
-
return panels.some((p) => (_nullishCoalesce(_optionalChain([p, 'optionalAccess',
|
|
11010
|
+
return panels.some((p) => (_nullishCoalesce(_optionalChain([p, 'optionalAccess', _278 => _278.targets]), () => ( []))).some((t) => t.metric === metric));
|
|
10536
11011
|
}
|
|
10537
11012
|
function metricChanges(before, after) {
|
|
10538
11013
|
const merged = { ...before, ...after };
|
|
@@ -10547,7 +11022,7 @@ function metricChanges(before, after) {
|
|
|
10547
11022
|
for (const [file, text] of Object.entries(after)) {
|
|
10548
11023
|
const old = inputs(before[file]);
|
|
10549
11024
|
for (const [id, input] of inputs(text))
|
|
10550
|
-
if (_optionalChain([old, 'access',
|
|
11025
|
+
if (_optionalChain([old, 'access', _279 => _279.get, 'call', _280 => _280(id), 'optionalAccess', _281 => _281.metric]) === metric && input.metric !== metric) rename ??= { metric, renamedTo: input.metric, file, input: input.title, readBy };
|
|
10551
11026
|
}
|
|
10552
11027
|
changes.push(_nullishCoalesce(rename, () => ( { metric, readBy })));
|
|
10553
11028
|
}
|
|
@@ -10587,14 +11062,14 @@ function variableWithType(v, type) {
|
|
|
10587
11062
|
}
|
|
10588
11063
|
function currentFor(v, value) {
|
|
10589
11064
|
const options = variableOptions({ ...v, current: void 0 });
|
|
10590
|
-
const text = (x) => x === ALL ? "All" : _nullishCoalesce(_optionalChain([options, 'access',
|
|
11065
|
+
const text = (x) => x === ALL ? "All" : _nullishCoalesce(_optionalChain([options, 'access', _282 => _282.find, 'call', _283 => _283((o) => o.value === x), 'optionalAccess', _284 => _284.text]), () => ( x));
|
|
10591
11066
|
return Array.isArray(value) ? { text: value.map(text), value } : { text: text(value), value };
|
|
10592
11067
|
}
|
|
10593
11068
|
function variableWithQuery(v, query) {
|
|
10594
11069
|
const { options: _, current, ...rest } = v;
|
|
10595
11070
|
const next = { ...rest, query };
|
|
10596
11071
|
if (v.type === "textbox" || v.type === "constant") return { ...next, current: { text: query, value: query } };
|
|
10597
|
-
const value = selectValue(next, _optionalChain([current, 'optionalAccess',
|
|
11072
|
+
const value = selectValue(next, _optionalChain([current, 'optionalAccess', _285 => _285.value]), variableOptions(next));
|
|
10598
11073
|
return { ...next, current: currentFor(next, value) };
|
|
10599
11074
|
}
|
|
10600
11075
|
function variableWithCurrent(v, value) {
|
|
@@ -10604,13 +11079,13 @@ function variableWithFlags(v, flags) {
|
|
|
10604
11079
|
const next = { ...v, ...flags };
|
|
10605
11080
|
if (!next.multi) delete next.multi;
|
|
10606
11081
|
if (!next.includeAll) delete next.includeAll;
|
|
10607
|
-
const raw = _optionalChain([v, 'access',
|
|
11082
|
+
const raw = _optionalChain([v, 'access', _286 => _286.current, 'optionalAccess', _287 => _287.value]);
|
|
10608
11083
|
const current = next.multi ? raw == null ? [] : Array.isArray(raw) ? raw : [raw] : Array.isArray(raw) ? raw[0] : raw;
|
|
10609
11084
|
return variableWithCurrent(next, selectValue(next, current, variableOptions({ ...next, current: void 0 })));
|
|
10610
11085
|
}
|
|
10611
11086
|
var refers = (name, flags) => new RegExp(`\\$${name}\\b|\\$\\{${name}(:\\w+)?\\}|\\[\\[${name}(:\\w+)?\\]\\]`, flags);
|
|
10612
11087
|
function allPanels2(dashboard) {
|
|
10613
|
-
return (_nullishCoalesce(dashboard.panels, () => ( []))).flatMap((p) => _optionalChain([p, 'optionalAccess',
|
|
11088
|
+
return (_nullishCoalesce(dashboard.panels, () => ( []))).flatMap((p) => _optionalChain([p, 'optionalAccess', _288 => _288.type]) === "row" ? [p, ..._nullishCoalesce(p.panels, () => ( []))] : [p]).filter((p) => p && typeof p === "object");
|
|
10614
11089
|
}
|
|
10615
11090
|
function variableUses(dashboard, name) {
|
|
10616
11091
|
const re = refers(name);
|
|
@@ -10682,7 +11157,7 @@ function locate(text, tree, path) {
|
|
|
10682
11157
|
for (let n = segs.length; n >= 0; n--) {
|
|
10683
11158
|
const node = findNodeAtLocation2(tree, segs.slice(0, n));
|
|
10684
11159
|
if (!node) continue;
|
|
10685
|
-
const key = _optionalChain([node, 'access',
|
|
11160
|
+
const key = _optionalChain([node, 'access', _289 => _289.parent, 'optionalAccess', _290 => _290.type]) === "property" ? _optionalChain([node, 'access', _291 => _291.parent, 'access', _292 => _292.children, 'optionalAccess', _293 => _293[0]]) : void 0;
|
|
10686
11161
|
if ((node.type === "object" || node.type === "array") && key) return located(text, key.offset, key.length);
|
|
10687
11162
|
if (node.type === "object" || node.type === "array") return located(text, node.offset, 1);
|
|
10688
11163
|
return located(text, node.offset, node.length);
|
|
@@ -10811,12 +11286,12 @@ async function errorText(res) {
|
|
|
10811
11286
|
const body = await res.text();
|
|
10812
11287
|
try {
|
|
10813
11288
|
return _nullishCoalesce(JSON.parse(body).error, () => ( body));
|
|
10814
|
-
} catch (
|
|
11289
|
+
} catch (e18) {
|
|
10815
11290
|
return body || `HTTP ${res.status}`;
|
|
10816
11291
|
}
|
|
10817
11292
|
}
|
|
10818
11293
|
async function authHeaders(token) {
|
|
10819
|
-
const t = await _optionalChain([token, 'optionalCall',
|
|
11294
|
+
const t = await _optionalChain([token, 'optionalCall', _294 => _294()]);
|
|
10820
11295
|
return t ? { Authorization: `Bearer ${t}` } : {};
|
|
10821
11296
|
}
|
|
10822
11297
|
var HttpConfigFiles = (_class3 = class {
|
|
@@ -10849,7 +11324,7 @@ var HttpConfigFiles = (_class3 = class {
|
|
|
10849
11324
|
let body;
|
|
10850
11325
|
try {
|
|
10851
11326
|
body = JSON.parse(await res.text());
|
|
10852
|
-
} catch (
|
|
11327
|
+
} catch (e19) {
|
|
10853
11328
|
return null;
|
|
10854
11329
|
}
|
|
10855
11330
|
if (!isBundleResponse(body)) return null;
|
|
@@ -10922,20 +11397,20 @@ function fetchJsonWithToken(token) {
|
|
|
10922
11397
|
return httpFetchJson({ headers: () => authHeaders(token), httpError: (status) => status === 401 ? "not signed in" : `HTTP ${status}` });
|
|
10923
11398
|
}
|
|
10924
11399
|
async function readConfigFiles(source) {
|
|
10925
|
-
const all = await _optionalChain([source, 'access',
|
|
11400
|
+
const all = await _optionalChain([source, 'access', _295 => _295.readAll, 'optionalCall', _296 => _296()]);
|
|
10926
11401
|
const read = all ? async (p) => {
|
|
10927
11402
|
if (!(p in all)) throw new Error(NOT_FOUND);
|
|
10928
11403
|
return all[p];
|
|
10929
11404
|
} : (p) => source.read(p);
|
|
10930
11405
|
const files = { [source.manifestPath]: await read(source.manifestPath) };
|
|
10931
11406
|
const { value } = parseJsonText(files[source.manifestPath]);
|
|
10932
|
-
const documents = _nullishCoalesce(_optionalChain([value, 'optionalAccess',
|
|
11407
|
+
const documents = _nullishCoalesce(_optionalChain([value, 'optionalAccess', _297 => _297.documents]), () => ( {}));
|
|
10933
11408
|
const paths = [...new Set(Object.values(documents).filter((d) => typeof d === "string"))];
|
|
10934
11409
|
await Promise.all(
|
|
10935
11410
|
paths.map(async (p) => {
|
|
10936
11411
|
try {
|
|
10937
11412
|
files[p] = await read(p);
|
|
10938
|
-
} catch (
|
|
11413
|
+
} catch (e20) {
|
|
10939
11414
|
}
|
|
10940
11415
|
})
|
|
10941
11416
|
);
|
|
@@ -10983,7 +11458,7 @@ var CANVAS_ROW_HEADER = 32;
|
|
|
10983
11458
|
function panelSize(panel, mode) {
|
|
10984
11459
|
const p = pos(panel);
|
|
10985
11460
|
if (mode === "grid") return { span: clampW(p.w), h: clampH(p.h) };
|
|
10986
|
-
return { span: panelSpan(panel, "phone"), h: clampH(_nullishCoalesce(_optionalChain([panel, 'access',
|
|
11461
|
+
return { span: panelSpan(panel, "phone"), h: clampH(_nullishCoalesce(_optionalChain([panel, 'access', _298 => _298.mobile, 'optionalAccess', _299 => _299.h]), () => ( p.h))) };
|
|
10987
11462
|
}
|
|
10988
11463
|
function layoutCanvas(panels, order, mode, width, override) {
|
|
10989
11464
|
return mode === "grid" ? layoutGridCanvas(panels, width, override) : layoutPhoneCanvas(panels, order, width, override);
|
|
@@ -11003,7 +11478,7 @@ function layoutGridCanvas(panels, width, override) {
|
|
|
11003
11478
|
boxes = [...boxes];
|
|
11004
11479
|
boxes[override.index] = b;
|
|
11005
11480
|
}
|
|
11006
|
-
const settled = settleBoxes(boxes, _optionalChain([override, 'optionalAccess',
|
|
11481
|
+
const settled = settleBoxes(boxes, _optionalChain([override, 'optionalAccess', _300 => _300.index]));
|
|
11007
11482
|
const items = settled.map((b, index) => {
|
|
11008
11483
|
const row = isRow(panels[index]);
|
|
11009
11484
|
return { index, row, x: b.x * colW, y: gridOffsetPx(b.y), width: b.w * colW - CANVAS_GAP, height: row ? gridUnitsToPx(1) : gridUnitsToPx(b.h), span: b.w, h: b.h };
|
|
@@ -11047,12 +11522,12 @@ function layoutPhoneCanvas(panels, order, width, override) {
|
|
|
11047
11522
|
y += CANVAS_ROW_HEADER + CANVAS_GAP;
|
|
11048
11523
|
continue;
|
|
11049
11524
|
}
|
|
11050
|
-
if (mode === "phone" && _optionalChain([panel, 'access',
|
|
11525
|
+
if (mode === "phone" && _optionalChain([panel, 'access', _301 => _301.mobile, 'optionalAccess', _302 => _302.hidden])) {
|
|
11051
11526
|
hidden.push(index);
|
|
11052
11527
|
continue;
|
|
11053
11528
|
}
|
|
11054
11529
|
const natural = panelSize(panel, mode);
|
|
11055
|
-
const size = _optionalChain([override, 'optionalAccess',
|
|
11530
|
+
const size = _optionalChain([override, 'optionalAccess', _303 => _303.index]) === index ? { span: clampW(_nullishCoalesce(override.span, () => ( natural.span))), h: clampH(_nullishCoalesce(override.h, () => ( natural.h))) } : natural;
|
|
11056
11531
|
if (used + size.span > GRID_COLUMNS) flush();
|
|
11057
11532
|
line.push({ index, row: false, x: 0, y: 0, width: 0, height: 0, ...size });
|
|
11058
11533
|
used += size.span;
|
|
@@ -11070,7 +11545,7 @@ function dropTarget(canvas, x, y, dragging) {
|
|
|
11070
11545
|
for (const c of pool) if (distance(c) < distance(best)) best = c;
|
|
11071
11546
|
const after = best.row ? y > best.y + best.height / 2 : x > best.x + best.width / 2;
|
|
11072
11547
|
if (!after) return best.index;
|
|
11073
|
-
return _nullishCoalesce(_optionalChain([items, 'access',
|
|
11548
|
+
return _nullishCoalesce(_optionalChain([items, 'access', _304 => _304[items.indexOf(best) + 1], 'optionalAccess', _305 => _305.index]), () => ( null));
|
|
11074
11549
|
}
|
|
11075
11550
|
function movePanel(panels, index, before) {
|
|
11076
11551
|
if (before === index) return panels;
|
|
@@ -11282,9 +11757,9 @@ var refers2 = (name) => new RegExp(`\\$${name}\\b|\\$\\{${name}(:\\w+)?\\}|\\[\\
|
|
|
11282
11757
|
var withChildren = (p) => [p, ...isRow(p) ? _nullishCoalesce(p.panels, () => ( [])) : []];
|
|
11283
11758
|
function panelMetrics(p) {
|
|
11284
11759
|
const found = [];
|
|
11285
|
-
if (isInputType(p.type) && typeof _optionalChain([p, 'access',
|
|
11286
|
-
if (p.type === INPUT_GROUP && Array.isArray(_optionalChain([p, 'access',
|
|
11287
|
-
for (const f of p.options.fields) if (typeof _optionalChain([f, 'optionalAccess',
|
|
11760
|
+
if (isInputType(p.type) && typeof _optionalChain([p, 'access', _306 => _306.options, 'optionalAccess', _307 => _307.metric]) === "string") found.push(p.options.metric);
|
|
11761
|
+
if (p.type === INPUT_GROUP && Array.isArray(_optionalChain([p, 'access', _308 => _308.options, 'optionalAccess', _309 => _309.fields]))) {
|
|
11762
|
+
for (const f of p.options.fields) if (typeof _optionalChain([f, 'optionalAccess', _310 => _310.options, 'optionalAccess', _311 => _311.metric]) === "string") found.push(f.options.metric);
|
|
11288
11763
|
}
|
|
11289
11764
|
for (const t of _nullishCoalesce(p.targets, () => ( []))) if (typeof t.metric === "string" && t.metric && !t.metric.startsWith("$")) found.push(t.metric);
|
|
11290
11765
|
return found;
|
|
@@ -11292,15 +11767,15 @@ function panelMetrics(p) {
|
|
|
11292
11767
|
function renameMetrics(panels, map) {
|
|
11293
11768
|
const rename = (p) => {
|
|
11294
11769
|
let out = p;
|
|
11295
|
-
if (isInputType(p.type) && typeof _optionalChain([p, 'access',
|
|
11296
|
-
if (p.type === INPUT_GROUP && Array.isArray(_optionalChain([p, 'access',
|
|
11770
|
+
if (isInputType(p.type) && typeof _optionalChain([p, 'access', _312 => _312.options, 'optionalAccess', _313 => _313.metric]) === "string" && map[p.options.metric]) out = { ...out, options: { ...out.options, metric: map[p.options.metric] } };
|
|
11771
|
+
if (p.type === INPUT_GROUP && Array.isArray(_optionalChain([p, 'access', _314 => _314.options, 'optionalAccess', _315 => _315.fields]))) {
|
|
11297
11772
|
const to = (m) => typeof m === "string" && map[m] || m;
|
|
11298
|
-
const fields = p.options.fields.map((f) => _optionalChain([f, 'optionalAccess',
|
|
11773
|
+
const fields = p.options.fields.map((f) => _optionalChain([f, 'optionalAccess', _316 => _316.options]) && to(f.options.metric) !== f.options.metric ? { ...f, options: { ...f.options, metric: to(f.options.metric) } } : f);
|
|
11299
11774
|
const titleFrom = to(p.options.titleFrom);
|
|
11300
11775
|
out = { ...out, options: { ...out.options, fields, ...titleFrom !== void 0 && { titleFrom } } };
|
|
11301
11776
|
}
|
|
11302
|
-
if (_optionalChain([p, 'access',
|
|
11303
|
-
if (_optionalChain([p, 'access',
|
|
11777
|
+
if (_optionalChain([p, 'access', _317 => _317.targets, 'optionalAccess', _318 => _318.some, 'call', _319 => _319((t) => typeof t.metric === "string" && map[t.metric])])) out = { ...out, targets: p.targets.map((t) => typeof t.metric === "string" && map[t.metric] ? { ...t, metric: map[t.metric] } : t) };
|
|
11778
|
+
if (_optionalChain([p, 'access', _320 => _320.panels, 'optionalAccess', _321 => _321.length])) out = { ...out, panels: p.panels.map(rename) };
|
|
11304
11779
|
return out;
|
|
11305
11780
|
};
|
|
11306
11781
|
return panels.map(rename);
|
|
@@ -11320,7 +11795,7 @@ function copyPanels(dashboard, indices) {
|
|
|
11320
11795
|
}
|
|
11321
11796
|
}
|
|
11322
11797
|
const chosen = order.filter((i) => picked.has(i)).map((i) => panels[i]);
|
|
11323
|
-
return snippetOf(chosen, _nullishCoalesce(_optionalChain([dashboard, 'access',
|
|
11798
|
+
return snippetOf(chosen, _nullishCoalesce(_optionalChain([dashboard, 'access', _322 => _322.templating, 'optionalAccess', _323 => _323.list]), () => ( [])));
|
|
11324
11799
|
}
|
|
11325
11800
|
function snippetOf(panels, available) {
|
|
11326
11801
|
const left = Math.min(...panels.map((p) => pos2(p).x));
|
|
@@ -11360,7 +11835,7 @@ function parseSnippet(text) {
|
|
|
11360
11835
|
let json;
|
|
11361
11836
|
try {
|
|
11362
11837
|
json = JSON.parse(text);
|
|
11363
|
-
} catch (
|
|
11838
|
+
} catch (e21) {
|
|
11364
11839
|
return { error: "That isn\u2019t JSON" };
|
|
11365
11840
|
}
|
|
11366
11841
|
let panels;
|
|
@@ -11388,7 +11863,7 @@ var sameVariable = (a, b) => {
|
|
|
11388
11863
|
return strip(a) === strip(b);
|
|
11389
11864
|
};
|
|
11390
11865
|
function previewPaste(dashboard, snippet) {
|
|
11391
|
-
const { added, renamed } = mergeVariables(_nullishCoalesce(_optionalChain([dashboard, 'access',
|
|
11866
|
+
const { added, renamed } = mergeVariables(_nullishCoalesce(_optionalChain([dashboard, 'access', _324 => _324.templating, 'optionalAccess', _325 => _325.list]), () => ( [])), snippet.variables);
|
|
11392
11867
|
return { added, renamed };
|
|
11393
11868
|
}
|
|
11394
11869
|
function mergeVariables(existing, incoming) {
|
|
@@ -11425,7 +11900,7 @@ function pasteSnippet(dashboard, snippet, options = {}) {
|
|
|
11425
11900
|
return true;
|
|
11426
11901
|
};
|
|
11427
11902
|
let incoming = snippet.panels.filter(keep).map((p) => p.panels ? { ...p, panels: p.panels.filter(keep) } : p);
|
|
11428
|
-
const { variables, added, renamed } = mergeVariables(_nullishCoalesce(_optionalChain([dashboard, 'access',
|
|
11903
|
+
const { variables, added, renamed } = mergeVariables(_nullishCoalesce(_optionalChain([dashboard, 'access', _326 => _326.templating, 'optionalAccess', _327 => _327.list]), () => ( [])), snippet.variables);
|
|
11429
11904
|
for (const [from, to] of Object.entries(renamed)) incoming = renameVariableInPanels(incoming, from, to);
|
|
11430
11905
|
if (options.metrics) incoming = renameMetrics(incoming, options.metrics);
|
|
11431
11906
|
const after = options.after != null ? existing[options.after] : void 0;
|
|
@@ -11475,7 +11950,7 @@ function parseTemplate(text) {
|
|
|
11475
11950
|
let json;
|
|
11476
11951
|
try {
|
|
11477
11952
|
json = JSON.parse(text);
|
|
11478
|
-
} catch (
|
|
11953
|
+
} catch (e22) {
|
|
11479
11954
|
return { error: "That isn\u2019t JSON" };
|
|
11480
11955
|
}
|
|
11481
11956
|
if (!isObject5(json) || json.$modelform !== "template") return { error: "That isn\u2019t a template" };
|
|
@@ -11490,7 +11965,7 @@ function parseTemplate(text) {
|
|
|
11490
11965
|
if (seen.has(d.id)) return { error: `Two documents are called "${d.id}"` };
|
|
11491
11966
|
seen.add(d.id);
|
|
11492
11967
|
const { dashboard, issues } = prepareDashboard(d.dashboard, d.id);
|
|
11493
|
-
if (!dashboard) return { error: `"${d.id}" can\u2019t be shown: ${_nullishCoalesce(_optionalChain([issues, 'access',
|
|
11968
|
+
if (!dashboard) return { error: `"${d.id}" can\u2019t be shown: ${_nullishCoalesce(_optionalChain([issues, 'access', _328 => _328.find, 'call', _329 => _329((x) => x.severity === "error"), 'optionalAccess', _330 => _330.message]), () => ( "it isn\u2019t a dashboard"))}` };
|
|
11494
11969
|
if (dashboard.kind && dashboard.kind !== d.kind) return { error: `"${d.id}" is listed as a ${d.kind} but says it\u2019s a ${dashboard.kind}` };
|
|
11495
11970
|
documents.push({ kind: d.kind, id: d.id, dashboard });
|
|
11496
11971
|
}
|
|
@@ -11541,7 +12016,7 @@ function applyTemplate(manifestText, paths, template, options = {}) {
|
|
|
11541
12016
|
let manifest;
|
|
11542
12017
|
try {
|
|
11543
12018
|
manifest = JSON.parse(manifestText);
|
|
11544
|
-
} catch (
|
|
12019
|
+
} catch (e23) {
|
|
11545
12020
|
throw new Error("The manifest isn\u2019t valid JSON");
|
|
11546
12021
|
}
|
|
11547
12022
|
const taken = new Set(Object.keys(_nullishCoalesce(manifest.documents, () => ( {}))));
|
|
@@ -11568,9 +12043,9 @@ function applyTemplate(manifestText, paths, template, options = {}) {
|
|
|
11568
12043
|
}
|
|
11569
12044
|
const tabIds = (_nullishCoalesce(manifest.tabs, () => ( []))).map((t) => t.id);
|
|
11570
12045
|
const added = [];
|
|
11571
|
-
let at = _nullishCoalesce(_optionalChain([manifest, 'access',
|
|
12046
|
+
let at = _nullishCoalesce(_optionalChain([manifest, 'access', _331 => _331.tabs, 'optionalAccess', _332 => _332.length]), () => ( 0));
|
|
11572
12047
|
for (const tab of template.tabs) {
|
|
11573
|
-
if (!_optionalChain([options, 'access',
|
|
12048
|
+
if (!_optionalChain([options, 'access', _333 => _333.tabs, 'optionalAccess', _334 => _334.includes, 'call', _335 => _335(tab.id)])) continue;
|
|
11574
12049
|
const screen = retarget(tab.screen, ids);
|
|
11575
12050
|
if (!screen) continue;
|
|
11576
12051
|
const id = tabIdFor(tab.id, tabIds);
|
|
@@ -11771,7 +12246,7 @@ function jsonFromAnswer(text) {
|
|
|
11771
12246
|
for (const block of blocks.reverse()) {
|
|
11772
12247
|
try {
|
|
11773
12248
|
return JSON.parse(block);
|
|
11774
|
-
} catch (
|
|
12249
|
+
} catch (e24) {
|
|
11775
12250
|
}
|
|
11776
12251
|
}
|
|
11777
12252
|
throw new Error("There\u2019s no JSON in that answer");
|
|
@@ -11792,7 +12267,7 @@ function readTemplateAnswer(text) {
|
|
|
11792
12267
|
);
|
|
11793
12268
|
const kept = new Set(template.tabs.map((t) => t.id));
|
|
11794
12269
|
for (const [i, tab] of (Array.isArray(raw.tabs) ? raw.tabs : []).entries()) {
|
|
11795
|
-
const id = _optionalChain([tab, 'optionalAccess',
|
|
12270
|
+
const id = _optionalChain([tab, 'optionalAccess', _336 => _336.id]);
|
|
11796
12271
|
if (typeof id !== "string" || !kept.has(id)) warnings.push(`tabs[${i}] was left out: it needs an id, a title and a screen showing only this template\u2019s documents`);
|
|
11797
12272
|
}
|
|
11798
12273
|
const kinds = new Map(template.documents.map((d) => [d.id, d.kind]));
|
|
@@ -11840,9 +12315,9 @@ function readDocumentAnswer(text, kind) {
|
|
|
11840
12315
|
return { error: e.message };
|
|
11841
12316
|
}
|
|
11842
12317
|
const wrapper = json;
|
|
11843
|
-
if (_optionalChain([wrapper, 'optionalAccess',
|
|
12318
|
+
if (_optionalChain([wrapper, 'optionalAccess', _337 => _337.$modelform]) === "template") {
|
|
11844
12319
|
if (!Array.isArray(wrapper.documents) || wrapper.documents.length !== 1) return { error: `That\u2019s a template, not one ${kind}` };
|
|
11845
|
-
json = _optionalChain([wrapper, 'access',
|
|
12320
|
+
json = _optionalChain([wrapper, 'access', _338 => _338.documents, 'access', _339 => _339[0], 'optionalAccess', _340 => _340.dashboard]);
|
|
11846
12321
|
}
|
|
11847
12322
|
if (!json || typeof json !== "object" || Array.isArray(json)) return { error: `That isn\u2019t a ${kind}` };
|
|
11848
12323
|
const raw = json;
|
|
@@ -11881,8 +12356,8 @@ function documentChanges(before, after) {
|
|
|
11881
12356
|
const what = [];
|
|
11882
12357
|
if (was.title !== p.title) what.push("title");
|
|
11883
12358
|
if (was.type !== p.type) what.push("type");
|
|
11884
|
-
if (_optionalChain([was, 'access',
|
|
11885
|
-
if (_optionalChain([was, 'access',
|
|
12359
|
+
if (_optionalChain([was, 'access', _341 => _341.gridPos, 'optionalAccess', _342 => _342.x]) !== _optionalChain([p, 'access', _343 => _343.gridPos, 'optionalAccess', _344 => _344.x]) || _optionalChain([was, 'access', _345 => _345.gridPos, 'optionalAccess', _346 => _346.y]) !== _optionalChain([p, 'access', _347 => _347.gridPos, 'optionalAccess', _348 => _348.y])) what.push("position");
|
|
12360
|
+
if (_optionalChain([was, 'access', _349 => _349.gridPos, 'optionalAccess', _350 => _350.w]) !== _optionalChain([p, 'access', _351 => _351.gridPos, 'optionalAccess', _352 => _352.w]) || _optionalChain([was, 'access', _353 => _353.gridPos, 'optionalAccess', _354 => _354.h]) !== _optionalChain([p, 'access', _355 => _355.gridPos, 'optionalAccess', _356 => _356.h])) what.push("size");
|
|
11886
12361
|
if (!same(was.options, p.options)) what.push("options");
|
|
11887
12362
|
if (!same(was.targets, p.targets) || !same(was.datasource, p.datasource) || !same(was.transformations, p.transformations)) what.push("queries");
|
|
11888
12363
|
if (!same(was.fieldConfig, p.fieldConfig)) what.push("field config");
|
|
@@ -12131,4 +12606,21 @@ function documentChanges(before, after) {
|
|
|
12131
12606
|
|
|
12132
12607
|
|
|
12133
12608
|
|
|
12134
|
-
|
|
12609
|
+
|
|
12610
|
+
|
|
12611
|
+
|
|
12612
|
+
|
|
12613
|
+
|
|
12614
|
+
|
|
12615
|
+
|
|
12616
|
+
|
|
12617
|
+
|
|
12618
|
+
|
|
12619
|
+
|
|
12620
|
+
|
|
12621
|
+
|
|
12622
|
+
|
|
12623
|
+
|
|
12624
|
+
|
|
12625
|
+
|
|
12626
|
+
exports.frameLength = frameLength; exports.timeField = timeField; exports.numberFields = numberFields; exports.fieldDisplayName = fieldDisplayName; exports.toSeries = toSeries; exports.toXYSeries = toXYSeries; exports.uniqueNames = uniqueNames; exports.toMillis = toMillis; exports.parseTime = parseTime; exports.parseRange = parseRange; exports.addTime = addTime; exports.startOf = startOf; exports.parseDuration = parseDuration; exports.calculateInterval = calculateInterval; exports.formatDuration = formatDuration; exports.TIME_PRESETS = TIME_PRESETS; exports.RELATIVE_RANGES = RELATIVE_RANGES; exports.parseLocalDateTime = parseLocalDateTime; exports.formatLocalDateTime = formatLocalDateTime; exports.timeExprError = timeExprError; exports.describeRange = describeRange; exports.zoomRange = zoomRange; exports.ALL = ALL; exports.initialVariableValues = initialVariableValues; exports.variableOptions = variableOptions; exports.variableInfo = variableInfo; exports.visibleVariables = visibleVariables; exports.isSqlDatasource = isSqlDatasource; exports.framesToOptions = framesToOptions; exports.refineOptions = refineOptions; exports.selectValue = selectValue; exports.variableReferences = variableReferences; exports.interpolate = interpolate; exports.queryParam = queryParam; exports.interpolateDeep = interpolateDeep; exports.resolveTimezone = resolveTimezone; exports.valueText = valueText; exports.GRID_COLUMNS = GRID_COLUMNS; exports.gridUnitsToPx = gridUnitsToPx; exports.gridOffsetPx = gridOffsetPx; exports.compactGrid = compactGrid; exports.isRow = isRow; exports.layoutDashboard = layoutDashboard; exports.repeatOptions = repeatOptions; exports.panelKey = panelKey; exports.panelSpan = panelSpan; exports.applyTransformations = applyTransformations; exports.DASHBOARD_DS = DASHBOARD_DS; exports.dashboardSourceIds = dashboardSourceIds; exports.panelHasQueries = panelHasQueries; exports.queryPanel = queryPanel; exports.normalizeRef = normalizeRef; exports.refreshedVariables = refreshedVariables; exports.variableDependents = variableDependents; exports.variableOrder = variableOrder; exports.resolveVariables = resolveVariables; exports.REDUCER_LABELS = REDUCER_LABELS; exports.isReducer = isReducer; exports.reduce = reduce; exports.INPUT_OPTION_KEYS = INPUT_OPTION_KEYS; exports.INPUT_TYPES = INPUT_TYPES; exports.isInputType = isInputType; exports.isInputPanel = isInputPanel; exports.INPUT_GROUP = INPUT_GROUP; exports.isFormPanelType = isFormPanelType; exports.isInputGroup = isInputGroup; exports.GROUP_FIELD_TYPES = GROUP_FIELD_TYPES; exports.groupFields = groupFields; exports.inputPanels = inputPanels; exports.documentKind = documentKind; exports.inputGroups = inputGroups; exports.plainInputPanels = plainInputPanels; exports.parseClockDigits = parseClockDigits; exports.formatClock = formatClock; exports.toEntries = toEntries; exports.newSaveId = newSaveId; exports.isEmptyItem = isEmptyItem; exports.groupToEntries = groupToEntries; exports.entriesToItems = entriesToItems; exports.groupProblems = groupProblems; exports.sameSave = sameSave; exports.inputProblem = inputProblem; exports.entryToInputValue = entryToInputValue; exports.textSuggestions = textSuggestions; exports.entriesSavedWith = entriesSavedWith; exports.formatValue = formatValue; exports.thresholdStep = thresholdStep; exports.NAMED_COLORS = NAMED_COLORS; exports.resolveColor = resolveColor; exports.SERIES_PALETTE = SERIES_PALETTE; exports.seriesColor = seriesColor; exports.mappedResult = mappedResult; exports.formatDisplay = formatDisplay; exports.valueColor = valueColor; exports.resolveFieldConfig = resolveFieldConfig; exports.fieldMatches = fieldMatches; exports.GrafanaError = GrafanaError; exports.GrafanaClient = GrafanaClient; exports.GrafanaDataSource = GrafanaDataSource; exports.fromWire = fromWire; exports.parseSpokenNumber = parseSpokenNumber; exports.parseSpokenDuration = parseSpokenDuration; exports.matchChoices = matchChoices; exports.parseSpokenYesNo = parseSpokenYesNo; exports.spokenValue = spokenValue; exports.DICTATION_TYPES = DICTATION_TYPES; exports.takesDictation = takesDictation; exports.dictationHints = dictationHints; exports.fillForm = fillForm; exports.fillSchema = fillSchema; exports.fillPrompt = fillPrompt; exports.parseFillAnswer = parseFillAnswer; exports.readFill = readFill; exports.ruleFill = ruleFill; exports.ruleFiller = ruleFiller; exports.modelFiller = modelFiller; exports.fillHints = fillHints; exports.LOCAL_DATASOURCE_TYPE = LOCAL_DATASOURCE_TYPE; exports.isLocalDatasource = isLocalDatasource; exports.LocalDataSource = LocalDataSource; exports.groupField = groupField; exports.buildFrames = buildFrames; exports.MemoryEntryStore = MemoryEntryStore; exports.DEFAULT_GAZETTEER = DEFAULT_GAZETTEER; exports.parseGazetteer = parseGazetteer; exports.loadGazetteer = loadGazetteer; exports.resolveLinks = resolveLinks; exports.parseDashboardLink = parseDashboardLink; exports.applyDashboardLink = applyDashboardLink; exports.appSchema = appSchema; exports.dashboardSchema = dashboardSchema; exports.pointerToPath = pointerToPath; exports.manifestSchemaIssues = manifestSchemaIssues; exports.dashboardSchemaIssues = dashboardSchemaIssues; exports.cleanDashboard = cleanDashboard; exports.MAPPING_TYPES = MAPPING_TYPES; exports.SPECIAL_MATCHES = SPECIAL_MATCHES; exports.mappingRows = mappingRows; exports.rowsToMappings = rowsToMappings; exports.mappingRow = mappingRow; exports.mappingProblem = mappingProblem; exports.OPTION_CATEGORIES = OPTION_CATEGORIES; exports.UNIT_CHOICES = UNIT_CHOICES; exports.panelOptions = panelOptions; exports.getPath = getPath; exports.optionValue = optionValue; exports.setOption = setOption; exports.setOptionValue = setOptionValue; exports.cleanPanelOptions = cleanPanelOptions; exports.OVERRIDE_MATCHERS = OVERRIDE_MATCHERS; exports.overrideProperties = overrideProperties; exports.panelOverrides = panelOverrides; exports.setOverrides = setOverrides; exports.MANIFEST_VERSION = MANIFEST_VERSION; exports.requiredManifestVersion = requiredManifestVersion; exports.validateManifest = validateManifest; exports.prepareDashboard = prepareDashboard; exports.validateDashboard = validateDashboard2; exports.validateBundle = validateBundle; exports.resolveUrl = resolveUrl; exports.httpFetchJson = httpFetchJson; exports.defaultFetchJson = defaultFetchJson; exports.BUNDLE_TYPE = BUNDLE_TYPE; exports.BUNDLE_ACCEPT = BUNDLE_ACCEPT; exports.isBundleResponse = isBundleResponse; exports.bundleRoot = bundleRoot; exports.assembleFromResponse = assembleFromResponse; exports.assembleBundle = assembleBundle; exports.fetchBundle = fetchBundle; exports.revalidateBundle = revalidateBundle; exports.ConfigLoader = ConfigLoader; exports.tabIdFor = tabIdFor; exports.screenOfType = screenOfType; exports.screenDocuments = screenDocuments; exports.documentUses = documentUses; exports.stringifyCompact = stringifyCompact; exports.applyJsonEdits = applyJsonEdits; exports.diffJson = diffJson; exports.documentIdFor = documentIdFor; exports.removeDocumentFromManifest = removeDocumentFromManifest; exports.renameDocumentInManifest = renameDocumentInManifest; exports.metricChanges = metricChanges; exports.REFRESH_CHOICES = REFRESH_CHOICES; exports.EDITABLE_VARIABLE_TYPES = EDITABLE_VARIABLE_TYPES; exports.isEditableVariableType = isEditableVariableType; exports.variableNameError = variableNameError; exports.newVariable = newVariable; exports.variableWithType = variableWithType; exports.variableWithQuery = variableWithQuery; exports.variableWithCurrent = variableWithCurrent; exports.variableWithFlags = variableWithFlags; exports.variableUses = variableUses; exports.renameVariableInPanels = renameVariableInPanels; exports.lineColumn = lineColumn; exports.parseJsonText = parseJsonText; exports.splitPath = splitPath; exports.locate = locate; exports.checkFiles = checkFiles; exports.bundleFromFiles = bundleFromFiles; exports.formatJsonText = formatJsonText; exports.setJsonValue = setJsonValue; exports.PANEL_TYPES = PANEL_TYPES; exports.newPanel = newPanel; exports.newDocument = newDocument; exports.SaveConflictError = SaveConflictError; exports.HttpConfigFiles = HttpConfigFiles; exports.fetchJsonWithToken = fetchJsonWithToken; exports.readConfigFiles = readConfigFiles; exports.readingOrder = readingOrder; exports.repack = repack; exports.CANVAS_GAP = CANVAS_GAP; exports.CANVAS_ROW_HEADER = CANVAS_ROW_HEADER; exports.panelSize = panelSize; exports.layoutCanvas = layoutCanvas; exports.dropTarget = dropTarget; exports.movePanel = movePanel; exports.resizePanel = resizePanel; exports.setHiddenOnPhones = setHiddenOnPhones; exports.nextPanelId = nextPanelId; exports.insertPanel = insertPanel; exports.duplicatePanel = duplicatePanel; exports.removePanel = removePanel; exports.expandRow = expandRow; exports.collapseRow = collapseRow; exports.settleLayout = settleLayout; exports.placePanel = placePanel; exports.snapToGrid = snapToGrid; exports.panelEdits = panelEdits; exports.sampleEntries = sampleEntries; exports.SNIPPET_VERSION = SNIPPET_VERSION; exports.panelMetrics = panelMetrics; exports.renameMetrics = renameMetrics; exports.copyPanels = copyPanels; exports.parseSnippet = parseSnippet; exports.previewPaste = previewPaste; exports.pasteSnippet = pasteSnippet; exports.TEMPLATE_VERSION = TEMPLATE_VERSION; exports.makeTemplate = makeTemplate; exports.parseTemplate = parseTemplate; exports.templateNeeds = templateNeeds; exports.applyTemplate = applyTemplate; exports.DOCUMENT_GUIDE = DOCUMENT_GUIDE; exports.AUTHORING_GUIDE = AUTHORING_GUIDE; exports.EXAMPLE_TEMPLATE = EXAMPLE_TEMPLATE; exports.templatePrompt = templatePrompt; exports.jsonFromAnswer = jsonFromAnswer; exports.readTemplateAnswer = readTemplateAnswer; exports.fixTemplatePrompt = fixTemplatePrompt; exports.documentPrompt = documentPrompt; exports.readDocumentAnswer = readDocumentAnswer; exports.fixDocumentPrompt = fixDocumentPrompt; exports.documentChanges = documentChanges;
|