@modelform/react-native 0.13.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 +24 -0
- package/dist/{chunk-OFXIKI2L.mjs → chunk-72OFPTDE.mjs} +244 -0
- package/dist/{chunk-CU4TMSZE.js → chunk-XWSPLZNC.js} +346 -102
- package/dist/core/formFill.d.ts +89 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.js +20 -2
- package/dist/core/index.mjs +19 -1
- package/dist/index.js +338 -175
- package/dist/index.mjs +187 -24
- package/dist/ui/inputs/Dictation.d.ts +8 -2
- package/dist/ui/inputs/InputForm.d.ts +8 -1
- package/dist/ui/inputs/VoiceFill.d.ts +28 -0
- package/dist/ui/inputs/formContext.d.ts +2 -0
- package/dist/ui/speech.d.ts +5 -0
- package/package.json +1 -1
|
@@ -1807,6 +1807,241 @@ function dictationHints(panel, choices2) {
|
|
|
1807
1807
|
return out;
|
|
1808
1808
|
}
|
|
1809
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
|
+
|
|
1810
2045
|
// src/core/local.ts
|
|
1811
2046
|
var LOCAL_DATASOURCE_TYPE = "modelform-local";
|
|
1812
2047
|
var LEGACY_LOCAL_DATASOURCE_TYPE = "dashkit-local";
|
|
@@ -1883,7 +2118,7 @@ function buildFrames(target, entries, request, label, siblings = []) {
|
|
|
1883
2118
|
const fill = _nullishCoalesce(target.fillZero, () => ( (aggregate === "sum" || aggregate === "count")));
|
|
1884
2119
|
({ times, values } = bucketize(rows, aggregate, bucket, request.range, fill));
|
|
1885
2120
|
}
|
|
1886
|
-
const display = group == null ? name : _nullishCoalesce(_optionalChain([label, 'optionalCall',
|
|
2121
|
+
const display = group == null ? name : _nullishCoalesce(_optionalChain([label, 'optionalCall', _158 => _158(labelKey, group)]), () => ( group));
|
|
1887
2122
|
return {
|
|
1888
2123
|
name,
|
|
1889
2124
|
refId: target.refId,
|
|
@@ -1939,7 +2174,7 @@ function bucketize(rows, aggregate, bucket, range, fillZero) {
|
|
|
1939
2174
|
const keys = fillZero ? step.range(range.from, range.to) : [...sums.keys()].sort((a, b) => a - b);
|
|
1940
2175
|
const values = keys.map((k) => {
|
|
1941
2176
|
const vs = sums.get(k);
|
|
1942
|
-
return _optionalChain([vs, 'optionalAccess',
|
|
2177
|
+
return _optionalChain([vs, 'optionalAccess', _159 => _159.length]) ? reduce2(vs, aggregate) : fillZero ? 0 : null;
|
|
1943
2178
|
});
|
|
1944
2179
|
return { times: keys, values };
|
|
1945
2180
|
}
|
|
@@ -2020,17 +2255,17 @@ function parseGazetteer(json) {
|
|
|
2020
2255
|
};
|
|
2021
2256
|
if (Array.isArray(json)) {
|
|
2022
2257
|
for (const item of json) {
|
|
2023
|
-
const lat = Number(_nullishCoalesce(_optionalChain([item, 'optionalAccess',
|
|
2024
|
-
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]))));
|
|
2025
2260
|
if (!Number.isFinite(lat) || !Number.isFinite(lon)) continue;
|
|
2026
2261
|
const p = { lon, lat };
|
|
2027
2262
|
add(item.key, p);
|
|
2028
2263
|
for (const k of [..._nullishCoalesce(item.keys, () => ( [])), ..._nullishCoalesce(item.keywords, () => ( []))]) add(k, p);
|
|
2029
2264
|
add(item.name, p);
|
|
2030
2265
|
}
|
|
2031
|
-
} else if (_optionalChain([json, 'optionalAccess',
|
|
2266
|
+
} else if (_optionalChain([json, 'optionalAccess', _165 => _165.type]) === "FeatureCollection") {
|
|
2032
2267
|
for (const f of _nullishCoalesce(json.features, () => ( []))) {
|
|
2033
|
-
const p = featurePoint(_optionalChain([f, 'optionalAccess',
|
|
2268
|
+
const p = featurePoint(_optionalChain([f, 'optionalAccess', _166 => _166.geometry]));
|
|
2034
2269
|
if (!p) continue;
|
|
2035
2270
|
add(f.id, p);
|
|
2036
2271
|
for (const v of Object.values(_nullishCoalesce(f.properties, () => ( {})))) if (typeof v === "string") add(v, p);
|
|
@@ -2039,7 +2274,7 @@ function parseGazetteer(json) {
|
|
|
2039
2274
|
return { find: (key) => _nullishCoalesce(exact.get(key), () => ( folded.get(key.toLowerCase()))) };
|
|
2040
2275
|
}
|
|
2041
2276
|
function featurePoint(geometry) {
|
|
2042
|
-
if (!_optionalChain([geometry, 'optionalAccess',
|
|
2277
|
+
if (!_optionalChain([geometry, 'optionalAccess', _167 => _167.coordinates])) return void 0;
|
|
2043
2278
|
if (geometry.type === "Point") {
|
|
2044
2279
|
const [lon, lat] = geometry.coordinates;
|
|
2045
2280
|
return Number.isFinite(lon) && Number.isFinite(lat) ? { lon, lat } : void 0;
|
|
@@ -2068,7 +2303,7 @@ function loadGazetteer(path, ds) {
|
|
|
2068
2303
|
const json = absolute ? fetch(path).then((r) => {
|
|
2069
2304
|
if (!r.ok) throw new Error(`${r.status} ${r.statusText}`);
|
|
2070
2305
|
return r.json();
|
|
2071
|
-
}) : _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`));
|
|
2072
2307
|
const run2 = json.then(parseGazetteer);
|
|
2073
2308
|
run2.catch(() => loaded.get(path) === run2 && loaded.delete(path));
|
|
2074
2309
|
loaded.set(path, run2);
|
|
@@ -2108,7 +2343,7 @@ function macro(path, format3, ctx) {
|
|
|
2108
2343
|
switch (head) {
|
|
2109
2344
|
case "__from":
|
|
2110
2345
|
case "__to": {
|
|
2111
|
-
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]);
|
|
2112
2347
|
if (ms == null) return void 0;
|
|
2113
2348
|
if (format3 === "date" || format3 === "date:iso") return new Date(ms).toISOString();
|
|
2114
2349
|
if (format3 === "date:seconds") return String(Math.floor(ms / 1e3));
|
|
@@ -2145,13 +2380,13 @@ function macro(path, format3, ctx) {
|
|
|
2145
2380
|
}
|
|
2146
2381
|
return void 0;
|
|
2147
2382
|
case "__series":
|
|
2148
|
-
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;
|
|
2149
2384
|
case "__data": {
|
|
2150
2385
|
const m = /^fields(?:\.([\w-]+)|\["([^"]*)"\]|\[(\d+)\])/.exec(rest.join("."));
|
|
2151
2386
|
if (!m || !d.frame || d.row == null) return void 0;
|
|
2152
2387
|
const key = _nullishCoalesce(m[1], () => ( m[2]));
|
|
2153
|
-
const f = key != null ? d.frame.fields.find((x) => x.name === key || _optionalChain([x, 'access',
|
|
2154
|
-
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]]);
|
|
2155
2390
|
if (v == null) return void 0;
|
|
2156
2391
|
return f.type === "time" ? String(toMillis(v)) : String(v);
|
|
2157
2392
|
}
|
|
@@ -2162,9 +2397,9 @@ function urlTime(raw, ms) {
|
|
|
2162
2397
|
return raw.trim().startsWith("now") ? encodeURIComponent(raw.trim()) : String(ms);
|
|
2163
2398
|
}
|
|
2164
2399
|
function allVariables(ctx) {
|
|
2165
|
-
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);
|
|
2166
2401
|
return (names.length ? names : Object.keys(ctx.values)).flatMap((n) => {
|
|
2167
|
-
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]));
|
|
2168
2403
|
return v == null ? [] : [queryParam(n, v)];
|
|
2169
2404
|
}).join("&");
|
|
2170
2405
|
}
|
|
@@ -2175,7 +2410,7 @@ function parseDashboardLink(href, grafanaUrl) {
|
|
|
2175
2410
|
const base = grafanaUrl ? /^(?:[a-z][a-z0-9+.-]*:)?\/\/([^/?#]+)([^?#]*)/i.exec(grafanaUrl.trim()) : null;
|
|
2176
2411
|
if (host && (!base || base[1].toLowerCase() !== host.toLowerCase())) return null;
|
|
2177
2412
|
if (scheme && !/^https?:$/i.test(scheme)) return null;
|
|
2178
|
-
const prefix = (_nullishCoalesce(_optionalChain([base, 'optionalAccess',
|
|
2413
|
+
const prefix = (_nullishCoalesce(_optionalChain([base, 'optionalAccess', _185 => _185[2]]), () => ( ""))).replace(/\/+$/, "");
|
|
2179
2414
|
const path = prefix && rawPath.startsWith(prefix + "/") ? rawPath.slice(prefix.length) : rawPath;
|
|
2180
2415
|
const p = /^\/d\/([^/]+)(?:\/[^/]*)?\/?$/.exec(path);
|
|
2181
2416
|
if (!p) return null;
|
|
@@ -2194,17 +2429,17 @@ function parseDashboardLink(href, grafanaUrl) {
|
|
|
2194
2429
|
function decode(s) {
|
|
2195
2430
|
try {
|
|
2196
2431
|
return decodeURIComponent(s.replace(/\+/g, " "));
|
|
2197
|
-
} catch (
|
|
2432
|
+
} catch (e13) {
|
|
2198
2433
|
return s;
|
|
2199
2434
|
}
|
|
2200
2435
|
}
|
|
2201
2436
|
function applyDashboardLink(dashboard, target) {
|
|
2202
|
-
const time = target.from || target.to ? { from: target.from || _optionalChain([dashboard, 'access',
|
|
2203
|
-
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) => {
|
|
2204
2439
|
const values = target.vars[v.name];
|
|
2205
|
-
if (!_optionalChain([values, 'optionalAccess',
|
|
2440
|
+
if (!_optionalChain([values, 'optionalAccess', _194 => _194.length])) return v;
|
|
2206
2441
|
const value = v.multi ? values : values[0];
|
|
2207
|
-
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)));
|
|
2208
2443
|
return { ...v, current: { text: v.multi ? text : text[0], value } };
|
|
2209
2444
|
})]);
|
|
2210
2445
|
return { ...dashboard, time, templating: list ? { ...dashboard.templating, list } : dashboard.templating };
|
|
@@ -8338,7 +8573,7 @@ function removeAt(root, pointer) {
|
|
|
8338
8573
|
const segs = pointer.split("/").slice(1).map((s) => s.replace(/~1/g, "/").replace(/~0/g, "~"));
|
|
8339
8574
|
const last = segs.pop();
|
|
8340
8575
|
let parent = root;
|
|
8341
|
-
for (const s of segs) parent = _optionalChain([parent, 'optionalAccess',
|
|
8576
|
+
for (const s of segs) parent = _optionalChain([parent, 'optionalAccess', _199 => _199[s]]);
|
|
8342
8577
|
if (Array.isArray(parent)) {
|
|
8343
8578
|
parent.splice(Number(last), 1);
|
|
8344
8579
|
return { array: parentOf(pointer), index: Number(last) };
|
|
@@ -8511,7 +8746,7 @@ var STANDARD = [
|
|
|
8511
8746
|
]
|
|
8512
8747
|
}
|
|
8513
8748
|
},
|
|
8514
|
-
{ 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" }
|
|
8515
8750
|
];
|
|
8516
8751
|
var THRESHOLDS = {
|
|
8517
8752
|
path: field("thresholds"),
|
|
@@ -8537,7 +8772,7 @@ var CALC = {
|
|
|
8537
8772
|
default: "lastNotNull",
|
|
8538
8773
|
control: { kind: "select", choices: Object.entries(REDUCER_LABELS).map(([value, label]) => ({ label, value })) },
|
|
8539
8774
|
stored: "string[]",
|
|
8540
|
-
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]]),
|
|
8541
8776
|
set: (p, v) => setOptionValue(p, "options.reduceOptions.calcs", v === void 0 ? void 0 : [v])
|
|
8542
8777
|
};
|
|
8543
8778
|
var LEGEND = {
|
|
@@ -8547,9 +8782,9 @@ var LEGEND = {
|
|
|
8547
8782
|
help: "When there are two or more series.",
|
|
8548
8783
|
default: true,
|
|
8549
8784
|
control: { kind: "boolean" },
|
|
8550
|
-
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",
|
|
8551
8786
|
// Grafana's older displayMode "hidden" would otherwise keep it hidden.
|
|
8552
|
-
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)
|
|
8553
8788
|
};
|
|
8554
8789
|
var AXIS_LABEL = { path: field("custom.axisLabel"), label: "Axis label", category: "Axis", control: { kind: "text" } };
|
|
8555
8790
|
var AXIS_PLACEMENT = {
|
|
@@ -8803,7 +9038,7 @@ function overrideProperties(type) {
|
|
|
8803
9038
|
return out;
|
|
8804
9039
|
}
|
|
8805
9040
|
function panelOverrides(panel) {
|
|
8806
|
-
const o = _optionalChain([panel, 'access',
|
|
9041
|
+
const o = _optionalChain([panel, 'access', _220 => _220.fieldConfig, 'optionalAccess', _221 => _221.overrides]);
|
|
8807
9042
|
return Array.isArray(o) ? o : [];
|
|
8808
9043
|
}
|
|
8809
9044
|
function setOverrides(panel, overrides) {
|
|
@@ -8851,7 +9086,7 @@ function prepareDashboard(json, file) {
|
|
|
8851
9086
|
});
|
|
8852
9087
|
dashboard.panels.forEach((p, i) => {
|
|
8853
9088
|
for (const r of cleanPanelOptions(p)) removed.push({ path: `panels[${i}]${r.path}`, message: r.message });
|
|
8854
|
-
_optionalChain([p, 'access',
|
|
9089
|
+
_optionalChain([p, 'access', _222 => _222.panels, 'optionalAccess', _223 => _223.forEach, 'call', _224 => _224((child, j) => {
|
|
8855
9090
|
for (const r of cleanPanelOptions(child)) removed.push({ path: `panels[${i}].panels[${j}]${r.path}`, message: r.message });
|
|
8856
9091
|
})]);
|
|
8857
9092
|
});
|
|
@@ -8874,7 +9109,7 @@ function groupIssues(dashboard) {
|
|
|
8874
9109
|
for (const { p, at } of located2) if (isInputPanel(p) && !recordedAt.has(p.options.metric)) recordedAt.set(p.options.metric, at);
|
|
8875
9110
|
for (const { p, at } of located2) {
|
|
8876
9111
|
if (p.type !== INPUT_GROUP) continue;
|
|
8877
|
-
const fields = _optionalChain([p, 'access',
|
|
9112
|
+
const fields = _optionalChain([p, 'access', _225 => _225.options, 'optionalAccess', _226 => _226.fields]);
|
|
8878
9113
|
if (!Array.isArray(fields) || !fields.length) {
|
|
8879
9114
|
out.push({ path: `${at}.options.fields`, message: "a group needs at least one field" });
|
|
8880
9115
|
continue;
|
|
@@ -8891,7 +9126,7 @@ function groupIssues(dashboard) {
|
|
|
8891
9126
|
else recordedAt.set(metric, fat);
|
|
8892
9127
|
mine.push(metric);
|
|
8893
9128
|
});
|
|
8894
|
-
const titleFrom = _optionalChain([p, 'access',
|
|
9129
|
+
const titleFrom = _optionalChain([p, 'access', _227 => _227.options, 'optionalAccess', _228 => _228.titleFrom]);
|
|
8895
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` });
|
|
8896
9131
|
}
|
|
8897
9132
|
return out;
|
|
@@ -8902,7 +9137,7 @@ function panelProblem(p) {
|
|
|
8902
9137
|
const g = p.gridPos;
|
|
8903
9138
|
if (!isObject3(g) || !["x", "y", "w", "h"].every((k) => typeof g[k] === "number"))
|
|
8904
9139
|
return { at: ".gridPos", message: "must have numeric x, y, w and h", summary: "has no usable gridPos" };
|
|
8905
|
-
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]))) {
|
|
8906
9141
|
const message = `${p.type} needs a metric to record to`;
|
|
8907
9142
|
return { at: ".options.metric", message, summary: message };
|
|
8908
9143
|
}
|
|
@@ -8978,17 +9213,17 @@ function resolveUrl(base, rel) {
|
|
|
8978
9213
|
function httpFetchJson(options = {}) {
|
|
8979
9214
|
const seen = /* @__PURE__ */ new Map();
|
|
8980
9215
|
return async (url, { accept = "application/json", signal } = {}) => {
|
|
8981
|
-
const extra = await _asyncNullishCoalesce(await _optionalChain([options, 'access',
|
|
9216
|
+
const extra = await _asyncNullishCoalesce(await _optionalChain([options, 'access', _231 => _231.headers, 'optionalCall', _232 => _232()]), async () => ( {}));
|
|
8982
9217
|
const key = JSON.stringify([url, accept, extra]);
|
|
8983
9218
|
const last = seen.get(key);
|
|
8984
9219
|
const get = (etag2) => fetch(url, { headers: { Accept: accept, ...extra, ...etag2 && { "If-None-Match": etag2 } }, cache: "no-store", signal });
|
|
8985
|
-
const res = await get(_optionalChain([last, 'optionalAccess',
|
|
8986
|
-
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;
|
|
8987
9222
|
seen.delete(key);
|
|
8988
9223
|
return get();
|
|
8989
9224
|
});
|
|
8990
9225
|
if (res.status === 304 && last) return last.json;
|
|
8991
|
-
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}`)));
|
|
8992
9227
|
const json = JSON.parse(await res.text());
|
|
8993
9228
|
const etag = res.headers.get("ETag");
|
|
8994
9229
|
if (etag) seen.set(key, { etag, json });
|
|
@@ -9077,7 +9312,7 @@ function revalidateBundle(bundle) {
|
|
|
9077
9312
|
}
|
|
9078
9313
|
const checked = { manifest, documents };
|
|
9079
9314
|
return validateBundle(checked).some((i) => i.severity === "error") ? void 0 : checked;
|
|
9080
|
-
} catch (
|
|
9315
|
+
} catch (e14) {
|
|
9081
9316
|
return void 0;
|
|
9082
9317
|
}
|
|
9083
9318
|
}
|
|
@@ -9110,8 +9345,8 @@ var ConfigLoader = (_class2 = class {
|
|
|
9110
9345
|
async start() {
|
|
9111
9346
|
const { url, cache: cache2 } = this.options;
|
|
9112
9347
|
if (!url) return;
|
|
9113
|
-
const cached = await _optionalChain([cache2, 'optionalAccess',
|
|
9114
|
-
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;
|
|
9115
9350
|
if (cached && bundle && !this.snapshot.fetchedAt) {
|
|
9116
9351
|
this.lastJson = JSON.stringify(bundle);
|
|
9117
9352
|
this.set({ bundle, source: "cache", fetchedAt: cached.fetchedAt, revision: cached.revision });
|
|
@@ -9141,7 +9376,7 @@ var ConfigLoader = (_class2 = class {
|
|
|
9141
9376
|
if (!bundle) {
|
|
9142
9377
|
const errors = issues.filter((i) => i.severity === "error").length;
|
|
9143
9378
|
const needsUpdate = issues.some((i) => i.code === "newer-version");
|
|
9144
|
-
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`;
|
|
9145
9380
|
return this.set(
|
|
9146
9381
|
{ loading: false, error, unreachable: !!unreachable, needsUpdate, issues },
|
|
9147
9382
|
this.snapshot.loading || error !== this.snapshot.error || !!unreachable !== !!this.snapshot.unreachable || needsUpdate !== !!this.snapshot.needsUpdate || !sameIssues(issues, this.snapshot.issues)
|
|
@@ -9151,7 +9386,7 @@ var ConfigLoader = (_class2 = class {
|
|
|
9151
9386
|
const changed = json !== this.lastJson;
|
|
9152
9387
|
this.lastJson = json;
|
|
9153
9388
|
const fetchedAt = Date.now();
|
|
9154
|
-
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(() => {
|
|
9155
9390
|
})]);
|
|
9156
9391
|
this.set(
|
|
9157
9392
|
{ ...changed && { bundle }, source: "remote", fetchedAt, revision, loading: false, error: void 0, unreachable: void 0, needsUpdate: void 0, issues },
|
|
@@ -9168,7 +9403,7 @@ var ConfigLoader = (_class2 = class {
|
|
|
9168
9403
|
/** Stops the loader: cancels a fetch in flight, and nothing it does afterwards changes the state or the cache. */
|
|
9169
9404
|
dispose() {
|
|
9170
9405
|
this.disposed = true;
|
|
9171
|
-
_optionalChain([this, 'access',
|
|
9406
|
+
_optionalChain([this, 'access', _248 => _248.controller, 'optionalAccess', _249 => _249.abort, 'call', _250 => _250()]);
|
|
9172
9407
|
this.listeners.clear();
|
|
9173
9408
|
}
|
|
9174
9409
|
/** `notify: false` drops the patch, so the snapshot only changes when listeners hear about it. */
|
|
@@ -9189,7 +9424,7 @@ function tabIdFor(title, taken) {
|
|
|
9189
9424
|
}
|
|
9190
9425
|
function screenOfType(type, from, docs) {
|
|
9191
9426
|
const shown = from ? screenDocuments(from) : [];
|
|
9192
|
-
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])), () => ( ""));
|
|
9193
9428
|
switch (type) {
|
|
9194
9429
|
case "dashboard":
|
|
9195
9430
|
return { type, dashboard: firstOf(docs.dashboards) };
|
|
@@ -9202,7 +9437,7 @@ function screenOfType(type, from, docs) {
|
|
|
9202
9437
|
}
|
|
9203
9438
|
}
|
|
9204
9439
|
function screenDocuments(screen) {
|
|
9205
|
-
switch (_optionalChain([screen, 'optionalAccess',
|
|
9440
|
+
switch (_optionalChain([screen, 'optionalAccess', _254 => _254.type])) {
|
|
9206
9441
|
case "dashboard":
|
|
9207
9442
|
return [{ id: screen.dashboard, kind: "dashboard" }];
|
|
9208
9443
|
case "forms":
|
|
@@ -10617,8 +10852,8 @@ function removeNode(text, path) {
|
|
|
10617
10852
|
const tree = parseTree2(text);
|
|
10618
10853
|
const value = tree && findNodeAtLocation2(tree, path);
|
|
10619
10854
|
if (!value) return text;
|
|
10620
|
-
const node = _optionalChain([value, 'access',
|
|
10621
|
-
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]), () => ( []));
|
|
10622
10857
|
const i = siblings.indexOf(node);
|
|
10623
10858
|
const next = siblings[i + 1];
|
|
10624
10859
|
const prev = siblings[i - 1];
|
|
@@ -10689,7 +10924,7 @@ function parseManifest(text) {
|
|
|
10689
10924
|
let value;
|
|
10690
10925
|
try {
|
|
10691
10926
|
value = JSON.parse(text);
|
|
10692
|
-
} catch (
|
|
10927
|
+
} catch (e15) {
|
|
10693
10928
|
throw new Error("The manifest isn\u2019t valid JSON");
|
|
10694
10929
|
}
|
|
10695
10930
|
if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("The manifest isn\u2019t an object");
|
|
@@ -10701,20 +10936,20 @@ function removeDocumentFromManifest(text, id) {
|
|
|
10701
10936
|
const edits = [];
|
|
10702
10937
|
const removedTabs = [];
|
|
10703
10938
|
for (let i = tabs.length - 1; i >= 0; i--) {
|
|
10704
|
-
const screen = _optionalChain([tabs, 'access',
|
|
10939
|
+
const screen = _optionalChain([tabs, 'access', _259 => _259[i], 'optionalAccess', _260 => _260.screen]);
|
|
10705
10940
|
const at = ["tabs", i, "screen"];
|
|
10706
10941
|
const removeTab = () => {
|
|
10707
10942
|
edits.push({ path: ["tabs", i], remove: true });
|
|
10708
10943
|
removedTabs.unshift(_nullishCoalesce(tabs[i].title, () => ( tabs[i].id)));
|
|
10709
10944
|
};
|
|
10710
|
-
if (_optionalChain([screen, 'optionalAccess',
|
|
10711
|
-
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)) {
|
|
10712
10947
|
if (screen.forms.every((f) => f === id)) removeTab();
|
|
10713
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 });
|
|
10714
|
-
} else if (_optionalChain([screen, 'optionalAccess',
|
|
10949
|
+
} else if (_optionalChain([screen, 'optionalAccess', _263 => _263.type]) === "menu" && Array.isArray(screen.items))
|
|
10715
10950
|
for (let j = screen.items.length - 1; j >= 0; j--) {
|
|
10716
10951
|
const item = screen.items[j];
|
|
10717
|
-
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 });
|
|
10718
10953
|
}
|
|
10719
10954
|
}
|
|
10720
10955
|
if (tabs.length && removedTabs.length === tabs.length) throw new Error(`Every tab shows only "${id}". Add another tab first`);
|
|
@@ -10727,21 +10962,21 @@ function renameDocumentInManifest(text, from, to, path) {
|
|
|
10727
10962
|
if (to !== from && to in manifest.documents) throw new Error(`There\u2019s already a document "${to}"`);
|
|
10728
10963
|
const edits = [];
|
|
10729
10964
|
(Array.isArray(manifest.tabs) ? manifest.tabs : []).forEach((tab, i) => {
|
|
10730
|
-
const screen = _optionalChain([tab, 'optionalAccess',
|
|
10965
|
+
const screen = _optionalChain([tab, 'optionalAccess', _266 => _266.screen]);
|
|
10731
10966
|
const at = ["tabs", i, "screen"];
|
|
10732
|
-
if (_optionalChain([screen, 'optionalAccess',
|
|
10733
|
-
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))
|
|
10734
10969
|
screen.forms.forEach((f, j) => f === from && edits.push({ path: [...at, "forms", j], value: to }));
|
|
10735
|
-
if (_optionalChain([screen, 'optionalAccess',
|
|
10970
|
+
if (_optionalChain([screen, 'optionalAccess', _269 => _269.type]) === "menu" && Array.isArray(screen.items))
|
|
10736
10971
|
screen.items.forEach((item, j) => {
|
|
10737
|
-
if (_optionalChain([item, 'optionalAccess',
|
|
10738
|
-
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 });
|
|
10739
10974
|
});
|
|
10740
10975
|
});
|
|
10741
10976
|
if (path !== void 0) edits.push({ path: ["documents", from], value: path });
|
|
10742
10977
|
let out = applyJsonEdits(text, edits);
|
|
10743
10978
|
if (to !== from) {
|
|
10744
|
-
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]]);
|
|
10745
10980
|
if (key) out = out.slice(0, key.offset) + JSON.stringify(to) + out.slice(key.offset + key.length);
|
|
10746
10981
|
}
|
|
10747
10982
|
return out;
|
|
@@ -10751,7 +10986,7 @@ function parse2(text) {
|
|
|
10751
10986
|
try {
|
|
10752
10987
|
const d = JSON.parse(text);
|
|
10753
10988
|
return d && Array.isArray(d.panels) && d.panels.every((p) => p && typeof p === "object") ? d : void 0;
|
|
10754
|
-
} catch (
|
|
10989
|
+
} catch (e16) {
|
|
10755
10990
|
return void 0;
|
|
10756
10991
|
}
|
|
10757
10992
|
}
|
|
@@ -10762,17 +10997,17 @@ function inputs(text) {
|
|
|
10762
10997
|
if (d)
|
|
10763
10998
|
for (const p of d.panels.flatMap((x) => x.type === "row" ? [x, ..._nullishCoalesce(x.panels, () => ( []))] : [x])) {
|
|
10764
10999
|
if (typeof p.id !== "number") continue;
|
|
10765
|
-
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 }));
|
|
10766
11001
|
else if (isInputPanel(p)) out.set(String(p.id), { metric: p.options.metric, title: p.title });
|
|
10767
11002
|
}
|
|
10768
|
-
} catch (
|
|
11003
|
+
} catch (e17) {
|
|
10769
11004
|
}
|
|
10770
11005
|
return out;
|
|
10771
11006
|
}
|
|
10772
11007
|
function reads(text, metric) {
|
|
10773
11008
|
const d = parse2(text);
|
|
10774
11009
|
const panels = d ? d.panels.flatMap((p) => p.type === "row" ? [p, ..._nullishCoalesce(p.panels, () => ( []))] : [p]) : [];
|
|
10775
|
-
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));
|
|
10776
11011
|
}
|
|
10777
11012
|
function metricChanges(before, after) {
|
|
10778
11013
|
const merged = { ...before, ...after };
|
|
@@ -10787,7 +11022,7 @@ function metricChanges(before, after) {
|
|
|
10787
11022
|
for (const [file, text] of Object.entries(after)) {
|
|
10788
11023
|
const old = inputs(before[file]);
|
|
10789
11024
|
for (const [id, input] of inputs(text))
|
|
10790
|
-
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 };
|
|
10791
11026
|
}
|
|
10792
11027
|
changes.push(_nullishCoalesce(rename, () => ( { metric, readBy })));
|
|
10793
11028
|
}
|
|
@@ -10827,14 +11062,14 @@ function variableWithType(v, type) {
|
|
|
10827
11062
|
}
|
|
10828
11063
|
function currentFor(v, value) {
|
|
10829
11064
|
const options = variableOptions({ ...v, current: void 0 });
|
|
10830
|
-
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));
|
|
10831
11066
|
return Array.isArray(value) ? { text: value.map(text), value } : { text: text(value), value };
|
|
10832
11067
|
}
|
|
10833
11068
|
function variableWithQuery(v, query) {
|
|
10834
11069
|
const { options: _, current, ...rest } = v;
|
|
10835
11070
|
const next = { ...rest, query };
|
|
10836
11071
|
if (v.type === "textbox" || v.type === "constant") return { ...next, current: { text: query, value: query } };
|
|
10837
|
-
const value = selectValue(next, _optionalChain([current, 'optionalAccess',
|
|
11072
|
+
const value = selectValue(next, _optionalChain([current, 'optionalAccess', _285 => _285.value]), variableOptions(next));
|
|
10838
11073
|
return { ...next, current: currentFor(next, value) };
|
|
10839
11074
|
}
|
|
10840
11075
|
function variableWithCurrent(v, value) {
|
|
@@ -10844,13 +11079,13 @@ function variableWithFlags(v, flags) {
|
|
|
10844
11079
|
const next = { ...v, ...flags };
|
|
10845
11080
|
if (!next.multi) delete next.multi;
|
|
10846
11081
|
if (!next.includeAll) delete next.includeAll;
|
|
10847
|
-
const raw = _optionalChain([v, 'access',
|
|
11082
|
+
const raw = _optionalChain([v, 'access', _286 => _286.current, 'optionalAccess', _287 => _287.value]);
|
|
10848
11083
|
const current = next.multi ? raw == null ? [] : Array.isArray(raw) ? raw : [raw] : Array.isArray(raw) ? raw[0] : raw;
|
|
10849
11084
|
return variableWithCurrent(next, selectValue(next, current, variableOptions({ ...next, current: void 0 })));
|
|
10850
11085
|
}
|
|
10851
11086
|
var refers = (name, flags) => new RegExp(`\\$${name}\\b|\\$\\{${name}(:\\w+)?\\}|\\[\\[${name}(:\\w+)?\\]\\]`, flags);
|
|
10852
11087
|
function allPanels2(dashboard) {
|
|
10853
|
-
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");
|
|
10854
11089
|
}
|
|
10855
11090
|
function variableUses(dashboard, name) {
|
|
10856
11091
|
const re = refers(name);
|
|
@@ -10922,7 +11157,7 @@ function locate(text, tree, path) {
|
|
|
10922
11157
|
for (let n = segs.length; n >= 0; n--) {
|
|
10923
11158
|
const node = findNodeAtLocation2(tree, segs.slice(0, n));
|
|
10924
11159
|
if (!node) continue;
|
|
10925
|
-
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;
|
|
10926
11161
|
if ((node.type === "object" || node.type === "array") && key) return located(text, key.offset, key.length);
|
|
10927
11162
|
if (node.type === "object" || node.type === "array") return located(text, node.offset, 1);
|
|
10928
11163
|
return located(text, node.offset, node.length);
|
|
@@ -11051,12 +11286,12 @@ async function errorText(res) {
|
|
|
11051
11286
|
const body = await res.text();
|
|
11052
11287
|
try {
|
|
11053
11288
|
return _nullishCoalesce(JSON.parse(body).error, () => ( body));
|
|
11054
|
-
} catch (
|
|
11289
|
+
} catch (e18) {
|
|
11055
11290
|
return body || `HTTP ${res.status}`;
|
|
11056
11291
|
}
|
|
11057
11292
|
}
|
|
11058
11293
|
async function authHeaders(token) {
|
|
11059
|
-
const t = await _optionalChain([token, 'optionalCall',
|
|
11294
|
+
const t = await _optionalChain([token, 'optionalCall', _294 => _294()]);
|
|
11060
11295
|
return t ? { Authorization: `Bearer ${t}` } : {};
|
|
11061
11296
|
}
|
|
11062
11297
|
var HttpConfigFiles = (_class3 = class {
|
|
@@ -11089,7 +11324,7 @@ var HttpConfigFiles = (_class3 = class {
|
|
|
11089
11324
|
let body;
|
|
11090
11325
|
try {
|
|
11091
11326
|
body = JSON.parse(await res.text());
|
|
11092
|
-
} catch (
|
|
11327
|
+
} catch (e19) {
|
|
11093
11328
|
return null;
|
|
11094
11329
|
}
|
|
11095
11330
|
if (!isBundleResponse(body)) return null;
|
|
@@ -11162,20 +11397,20 @@ function fetchJsonWithToken(token) {
|
|
|
11162
11397
|
return httpFetchJson({ headers: () => authHeaders(token), httpError: (status) => status === 401 ? "not signed in" : `HTTP ${status}` });
|
|
11163
11398
|
}
|
|
11164
11399
|
async function readConfigFiles(source) {
|
|
11165
|
-
const all = await _optionalChain([source, 'access',
|
|
11400
|
+
const all = await _optionalChain([source, 'access', _295 => _295.readAll, 'optionalCall', _296 => _296()]);
|
|
11166
11401
|
const read = all ? async (p) => {
|
|
11167
11402
|
if (!(p in all)) throw new Error(NOT_FOUND);
|
|
11168
11403
|
return all[p];
|
|
11169
11404
|
} : (p) => source.read(p);
|
|
11170
11405
|
const files = { [source.manifestPath]: await read(source.manifestPath) };
|
|
11171
11406
|
const { value } = parseJsonText(files[source.manifestPath]);
|
|
11172
|
-
const documents = _nullishCoalesce(_optionalChain([value, 'optionalAccess',
|
|
11407
|
+
const documents = _nullishCoalesce(_optionalChain([value, 'optionalAccess', _297 => _297.documents]), () => ( {}));
|
|
11173
11408
|
const paths = [...new Set(Object.values(documents).filter((d) => typeof d === "string"))];
|
|
11174
11409
|
await Promise.all(
|
|
11175
11410
|
paths.map(async (p) => {
|
|
11176
11411
|
try {
|
|
11177
11412
|
files[p] = await read(p);
|
|
11178
|
-
} catch (
|
|
11413
|
+
} catch (e20) {
|
|
11179
11414
|
}
|
|
11180
11415
|
})
|
|
11181
11416
|
);
|
|
@@ -11223,7 +11458,7 @@ var CANVAS_ROW_HEADER = 32;
|
|
|
11223
11458
|
function panelSize(panel, mode) {
|
|
11224
11459
|
const p = pos(panel);
|
|
11225
11460
|
if (mode === "grid") return { span: clampW(p.w), h: clampH(p.h) };
|
|
11226
|
-
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))) };
|
|
11227
11462
|
}
|
|
11228
11463
|
function layoutCanvas(panels, order, mode, width, override) {
|
|
11229
11464
|
return mode === "grid" ? layoutGridCanvas(panels, width, override) : layoutPhoneCanvas(panels, order, width, override);
|
|
@@ -11243,7 +11478,7 @@ function layoutGridCanvas(panels, width, override) {
|
|
|
11243
11478
|
boxes = [...boxes];
|
|
11244
11479
|
boxes[override.index] = b;
|
|
11245
11480
|
}
|
|
11246
|
-
const settled = settleBoxes(boxes, _optionalChain([override, 'optionalAccess',
|
|
11481
|
+
const settled = settleBoxes(boxes, _optionalChain([override, 'optionalAccess', _300 => _300.index]));
|
|
11247
11482
|
const items = settled.map((b, index) => {
|
|
11248
11483
|
const row = isRow(panels[index]);
|
|
11249
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 };
|
|
@@ -11287,12 +11522,12 @@ function layoutPhoneCanvas(panels, order, width, override) {
|
|
|
11287
11522
|
y += CANVAS_ROW_HEADER + CANVAS_GAP;
|
|
11288
11523
|
continue;
|
|
11289
11524
|
}
|
|
11290
|
-
if (mode === "phone" && _optionalChain([panel, 'access',
|
|
11525
|
+
if (mode === "phone" && _optionalChain([panel, 'access', _301 => _301.mobile, 'optionalAccess', _302 => _302.hidden])) {
|
|
11291
11526
|
hidden.push(index);
|
|
11292
11527
|
continue;
|
|
11293
11528
|
}
|
|
11294
11529
|
const natural = panelSize(panel, mode);
|
|
11295
|
-
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;
|
|
11296
11531
|
if (used + size.span > GRID_COLUMNS) flush();
|
|
11297
11532
|
line.push({ index, row: false, x: 0, y: 0, width: 0, height: 0, ...size });
|
|
11298
11533
|
used += size.span;
|
|
@@ -11310,7 +11545,7 @@ function dropTarget(canvas, x, y, dragging) {
|
|
|
11310
11545
|
for (const c of pool) if (distance(c) < distance(best)) best = c;
|
|
11311
11546
|
const after = best.row ? y > best.y + best.height / 2 : x > best.x + best.width / 2;
|
|
11312
11547
|
if (!after) return best.index;
|
|
11313
|
-
return _nullishCoalesce(_optionalChain([items, 'access',
|
|
11548
|
+
return _nullishCoalesce(_optionalChain([items, 'access', _304 => _304[items.indexOf(best) + 1], 'optionalAccess', _305 => _305.index]), () => ( null));
|
|
11314
11549
|
}
|
|
11315
11550
|
function movePanel(panels, index, before) {
|
|
11316
11551
|
if (before === index) return panels;
|
|
@@ -11522,9 +11757,9 @@ var refers2 = (name) => new RegExp(`\\$${name}\\b|\\$\\{${name}(:\\w+)?\\}|\\[\\
|
|
|
11522
11757
|
var withChildren = (p) => [p, ...isRow(p) ? _nullishCoalesce(p.panels, () => ( [])) : []];
|
|
11523
11758
|
function panelMetrics(p) {
|
|
11524
11759
|
const found = [];
|
|
11525
|
-
if (isInputType(p.type) && typeof _optionalChain([p, 'access',
|
|
11526
|
-
if (p.type === INPUT_GROUP && Array.isArray(_optionalChain([p, 'access',
|
|
11527
|
-
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);
|
|
11528
11763
|
}
|
|
11529
11764
|
for (const t of _nullishCoalesce(p.targets, () => ( []))) if (typeof t.metric === "string" && t.metric && !t.metric.startsWith("$")) found.push(t.metric);
|
|
11530
11765
|
return found;
|
|
@@ -11532,15 +11767,15 @@ function panelMetrics(p) {
|
|
|
11532
11767
|
function renameMetrics(panels, map) {
|
|
11533
11768
|
const rename = (p) => {
|
|
11534
11769
|
let out = p;
|
|
11535
|
-
if (isInputType(p.type) && typeof _optionalChain([p, 'access',
|
|
11536
|
-
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]))) {
|
|
11537
11772
|
const to = (m) => typeof m === "string" && map[m] || m;
|
|
11538
|
-
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);
|
|
11539
11774
|
const titleFrom = to(p.options.titleFrom);
|
|
11540
11775
|
out = { ...out, options: { ...out.options, fields, ...titleFrom !== void 0 && { titleFrom } } };
|
|
11541
11776
|
}
|
|
11542
|
-
if (_optionalChain([p, 'access',
|
|
11543
|
-
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) };
|
|
11544
11779
|
return out;
|
|
11545
11780
|
};
|
|
11546
11781
|
return panels.map(rename);
|
|
@@ -11560,7 +11795,7 @@ function copyPanels(dashboard, indices) {
|
|
|
11560
11795
|
}
|
|
11561
11796
|
}
|
|
11562
11797
|
const chosen = order.filter((i) => picked.has(i)).map((i) => panels[i]);
|
|
11563
|
-
return snippetOf(chosen, _nullishCoalesce(_optionalChain([dashboard, 'access',
|
|
11798
|
+
return snippetOf(chosen, _nullishCoalesce(_optionalChain([dashboard, 'access', _322 => _322.templating, 'optionalAccess', _323 => _323.list]), () => ( [])));
|
|
11564
11799
|
}
|
|
11565
11800
|
function snippetOf(panels, available) {
|
|
11566
11801
|
const left = Math.min(...panels.map((p) => pos2(p).x));
|
|
@@ -11600,7 +11835,7 @@ function parseSnippet(text) {
|
|
|
11600
11835
|
let json;
|
|
11601
11836
|
try {
|
|
11602
11837
|
json = JSON.parse(text);
|
|
11603
|
-
} catch (
|
|
11838
|
+
} catch (e21) {
|
|
11604
11839
|
return { error: "That isn\u2019t JSON" };
|
|
11605
11840
|
}
|
|
11606
11841
|
let panels;
|
|
@@ -11628,7 +11863,7 @@ var sameVariable = (a, b) => {
|
|
|
11628
11863
|
return strip(a) === strip(b);
|
|
11629
11864
|
};
|
|
11630
11865
|
function previewPaste(dashboard, snippet) {
|
|
11631
|
-
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);
|
|
11632
11867
|
return { added, renamed };
|
|
11633
11868
|
}
|
|
11634
11869
|
function mergeVariables(existing, incoming) {
|
|
@@ -11665,7 +11900,7 @@ function pasteSnippet(dashboard, snippet, options = {}) {
|
|
|
11665
11900
|
return true;
|
|
11666
11901
|
};
|
|
11667
11902
|
let incoming = snippet.panels.filter(keep).map((p) => p.panels ? { ...p, panels: p.panels.filter(keep) } : p);
|
|
11668
|
-
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);
|
|
11669
11904
|
for (const [from, to] of Object.entries(renamed)) incoming = renameVariableInPanels(incoming, from, to);
|
|
11670
11905
|
if (options.metrics) incoming = renameMetrics(incoming, options.metrics);
|
|
11671
11906
|
const after = options.after != null ? existing[options.after] : void 0;
|
|
@@ -11715,7 +11950,7 @@ function parseTemplate(text) {
|
|
|
11715
11950
|
let json;
|
|
11716
11951
|
try {
|
|
11717
11952
|
json = JSON.parse(text);
|
|
11718
|
-
} catch (
|
|
11953
|
+
} catch (e22) {
|
|
11719
11954
|
return { error: "That isn\u2019t JSON" };
|
|
11720
11955
|
}
|
|
11721
11956
|
if (!isObject5(json) || json.$modelform !== "template") return { error: "That isn\u2019t a template" };
|
|
@@ -11730,7 +11965,7 @@ function parseTemplate(text) {
|
|
|
11730
11965
|
if (seen.has(d.id)) return { error: `Two documents are called "${d.id}"` };
|
|
11731
11966
|
seen.add(d.id);
|
|
11732
11967
|
const { dashboard, issues } = prepareDashboard(d.dashboard, d.id);
|
|
11733
|
-
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"))}` };
|
|
11734
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}` };
|
|
11735
11970
|
documents.push({ kind: d.kind, id: d.id, dashboard });
|
|
11736
11971
|
}
|
|
@@ -11781,7 +12016,7 @@ function applyTemplate(manifestText, paths, template, options = {}) {
|
|
|
11781
12016
|
let manifest;
|
|
11782
12017
|
try {
|
|
11783
12018
|
manifest = JSON.parse(manifestText);
|
|
11784
|
-
} catch (
|
|
12019
|
+
} catch (e23) {
|
|
11785
12020
|
throw new Error("The manifest isn\u2019t valid JSON");
|
|
11786
12021
|
}
|
|
11787
12022
|
const taken = new Set(Object.keys(_nullishCoalesce(manifest.documents, () => ( {}))));
|
|
@@ -11808,9 +12043,9 @@ function applyTemplate(manifestText, paths, template, options = {}) {
|
|
|
11808
12043
|
}
|
|
11809
12044
|
const tabIds = (_nullishCoalesce(manifest.tabs, () => ( []))).map((t) => t.id);
|
|
11810
12045
|
const added = [];
|
|
11811
|
-
let at = _nullishCoalesce(_optionalChain([manifest, 'access',
|
|
12046
|
+
let at = _nullishCoalesce(_optionalChain([manifest, 'access', _331 => _331.tabs, 'optionalAccess', _332 => _332.length]), () => ( 0));
|
|
11812
12047
|
for (const tab of template.tabs) {
|
|
11813
|
-
if (!_optionalChain([options, 'access',
|
|
12048
|
+
if (!_optionalChain([options, 'access', _333 => _333.tabs, 'optionalAccess', _334 => _334.includes, 'call', _335 => _335(tab.id)])) continue;
|
|
11814
12049
|
const screen = retarget(tab.screen, ids);
|
|
11815
12050
|
if (!screen) continue;
|
|
11816
12051
|
const id = tabIdFor(tab.id, tabIds);
|
|
@@ -12011,7 +12246,7 @@ function jsonFromAnswer(text) {
|
|
|
12011
12246
|
for (const block of blocks.reverse()) {
|
|
12012
12247
|
try {
|
|
12013
12248
|
return JSON.parse(block);
|
|
12014
|
-
} catch (
|
|
12249
|
+
} catch (e24) {
|
|
12015
12250
|
}
|
|
12016
12251
|
}
|
|
12017
12252
|
throw new Error("There\u2019s no JSON in that answer");
|
|
@@ -12032,7 +12267,7 @@ function readTemplateAnswer(text) {
|
|
|
12032
12267
|
);
|
|
12033
12268
|
const kept = new Set(template.tabs.map((t) => t.id));
|
|
12034
12269
|
for (const [i, tab] of (Array.isArray(raw.tabs) ? raw.tabs : []).entries()) {
|
|
12035
|
-
const id = _optionalChain([tab, 'optionalAccess',
|
|
12270
|
+
const id = _optionalChain([tab, 'optionalAccess', _336 => _336.id]);
|
|
12036
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`);
|
|
12037
12272
|
}
|
|
12038
12273
|
const kinds = new Map(template.documents.map((d) => [d.id, d.kind]));
|
|
@@ -12080,9 +12315,9 @@ function readDocumentAnswer(text, kind) {
|
|
|
12080
12315
|
return { error: e.message };
|
|
12081
12316
|
}
|
|
12082
12317
|
const wrapper = json;
|
|
12083
|
-
if (_optionalChain([wrapper, 'optionalAccess',
|
|
12318
|
+
if (_optionalChain([wrapper, 'optionalAccess', _337 => _337.$modelform]) === "template") {
|
|
12084
12319
|
if (!Array.isArray(wrapper.documents) || wrapper.documents.length !== 1) return { error: `That\u2019s a template, not one ${kind}` };
|
|
12085
|
-
json = _optionalChain([wrapper, 'access',
|
|
12320
|
+
json = _optionalChain([wrapper, 'access', _338 => _338.documents, 'access', _339 => _339[0], 'optionalAccess', _340 => _340.dashboard]);
|
|
12086
12321
|
}
|
|
12087
12322
|
if (!json || typeof json !== "object" || Array.isArray(json)) return { error: `That isn\u2019t a ${kind}` };
|
|
12088
12323
|
const raw = json;
|
|
@@ -12121,8 +12356,8 @@ function documentChanges(before, after) {
|
|
|
12121
12356
|
const what = [];
|
|
12122
12357
|
if (was.title !== p.title) what.push("title");
|
|
12123
12358
|
if (was.type !== p.type) what.push("type");
|
|
12124
|
-
if (_optionalChain([was, 'access',
|
|
12125
|
-
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");
|
|
12126
12361
|
if (!same(was.options, p.options)) what.push("options");
|
|
12127
12362
|
if (!same(was.targets, p.targets) || !same(was.datasource, p.datasource) || !same(was.transformations, p.transformations)) what.push("queries");
|
|
12128
12363
|
if (!same(was.fieldConfig, p.fieldConfig)) what.push("field config");
|
|
@@ -12379,4 +12614,13 @@ function documentChanges(before, after) {
|
|
|
12379
12614
|
|
|
12380
12615
|
|
|
12381
12616
|
|
|
12382
|
-
|
|
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;
|