@modelform/react-native 0.17.0 → 0.18.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/dist/{chunk-24ABPZKO.js → chunk-IHOP6IEA.js} +223 -139
- package/dist/{chunk-IMXL2SZA.mjs → chunk-WABOXGET.mjs} +85 -1
- package/dist/core/authoring.d.ts +2 -2
- package/dist/core/index.js +2 -2
- package/dist/core/index.mjs +1 -1
- package/dist/index.js +162 -162
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
|
@@ -664,7 +664,80 @@ function formatDate(ms, format3 = "YYYY-MM-DD HH:mm:ss") {
|
|
|
664
664
|
};
|
|
665
665
|
return format3.replace(/YYYY|YY|MM|DD|HH|mm|ss|SSS/g, (t) => tokens[t]);
|
|
666
666
|
}
|
|
667
|
+
var operandName = (o) => o == null ? void 0 : typeof o === "object" ? _optionalChain([(_nullishCoalesce(_optionalChain([o, 'access', _70 => _70.matcher, 'optionalAccess', _71 => _71.options]), () => ( o.fixed))), 'optionalAccess', _72 => _72.toString, 'call', _73 => _73()]) : String(o);
|
|
668
|
+
var OPERATORS = {
|
|
669
|
+
"+": (a, b) => a + b,
|
|
670
|
+
"-": (a, b) => a - b,
|
|
671
|
+
"*": (a, b) => a * b,
|
|
672
|
+
"/": (a, b) => a / b,
|
|
673
|
+
"%": (a, b) => a % b,
|
|
674
|
+
"^": (a, b) => a ** b
|
|
675
|
+
};
|
|
676
|
+
var ROW_REDUCERS = {
|
|
677
|
+
sum: { label: "Total", fn: (vs) => vs.length ? vs.reduce((a, b) => a + b, 0) : null },
|
|
678
|
+
mean: { label: "Mean", fn: (vs) => vs.length ? vs.reduce((a, b) => a + b, 0) / vs.length : null },
|
|
679
|
+
min: { label: "Min", fn: (vs) => vs.length ? Math.min(...vs) : null },
|
|
680
|
+
max: { label: "Max", fn: (vs) => vs.length ? Math.max(...vs) : null },
|
|
681
|
+
first: { label: "First", fn: (vs) => _nullishCoalesce(vs[0], () => ( null)) },
|
|
682
|
+
last: { label: "Last", fn: (vs) => _nullishCoalesce(vs.at(-1), () => ( null)) },
|
|
683
|
+
count: { label: "Count", fn: (vs) => vs.length },
|
|
684
|
+
range: { label: "Range", fn: (vs) => vs.length ? Math.max(...vs) - Math.min(...vs) : null }
|
|
685
|
+
};
|
|
686
|
+
var asNumber = (v) => {
|
|
687
|
+
if (v == null || v === "" || typeof v === "boolean") return v === true ? 1 : v === false ? 0 : null;
|
|
688
|
+
const n = Number(v);
|
|
689
|
+
return Number.isFinite(n) ? n : null;
|
|
690
|
+
};
|
|
691
|
+
function calculate(frame, multiple, options) {
|
|
692
|
+
const rows = _nullishCoalesce(_optionalChain([frame, 'access', _74 => _74.fields, 'access', _75 => _75[0], 'optionalAccess', _76 => _76.values, 'access', _77 => _77.length]), () => ( 0));
|
|
693
|
+
const find = (name) => frame.fields.find((f) => f.name === name || fieldDisplayName(f, frame, multiple) === name);
|
|
694
|
+
const mode = _nullishCoalesce(options.mode, () => ( "reduceRow"));
|
|
695
|
+
if (mode === "binary") {
|
|
696
|
+
const { left, right, operator = "*" } = _nullishCoalesce(options.binary, () => ( {}));
|
|
697
|
+
const op = OPERATORS[operator];
|
|
698
|
+
const [l, r] = [operandName(left), operandName(right)];
|
|
699
|
+
if (!op || l == null || r == null) return;
|
|
700
|
+
const side = (name) => {
|
|
701
|
+
const f = find(name);
|
|
702
|
+
if (f) return (i) => asNumber(f.values[i]);
|
|
703
|
+
const n = asNumber(name);
|
|
704
|
+
return n == null ? void 0 : () => n;
|
|
705
|
+
};
|
|
706
|
+
const [a, b] = [side(l), side(r)];
|
|
707
|
+
if (!a || !b) return;
|
|
708
|
+
const values = Array.from({ length: rows }, (_, i) => {
|
|
709
|
+
const [x, y] = [a(i), b(i)];
|
|
710
|
+
if (x == null || y == null) return null;
|
|
711
|
+
const v = op(x, y);
|
|
712
|
+
return Number.isFinite(v) ? v : null;
|
|
713
|
+
});
|
|
714
|
+
return { name: options.alias || `${l} ${operator} ${r}`, type: "number", values };
|
|
715
|
+
}
|
|
716
|
+
if (mode === "reduceRow") {
|
|
717
|
+
const { reducer = "sum", include } = _nullishCoalesce(options.reduce, () => ( {}));
|
|
718
|
+
const red = ROW_REDUCERS[reducer];
|
|
719
|
+
if (!red) return;
|
|
720
|
+
const fields = _optionalChain([include, 'optionalAccess', _78 => _78.length]) ? include.map(find).filter((f) => !!f) : frame.fields.filter((f) => f.type === "number");
|
|
721
|
+
if (!fields.length) return;
|
|
722
|
+
const values = Array.from({ length: rows }, (_, i) => red.fn(fields.map((f) => asNumber(f.values[i])).filter((v) => v != null)));
|
|
723
|
+
return { name: options.alias || red.label, type: "number", values };
|
|
724
|
+
}
|
|
725
|
+
}
|
|
667
726
|
var TRANSFORMERS = {
|
|
727
|
+
// A field computed per row: from two fields, or a field and a number (binary), or across fields
|
|
728
|
+
// (reduceRow). Several frames are joined on time first, as Grafana does, so the entries of one
|
|
729
|
+
// Save (which share a time) meet in one row: yield ÷ dose per shot. A row missing a value, or a
|
|
730
|
+
// division by zero, gives null.
|
|
731
|
+
calculateField: (frames, options) => {
|
|
732
|
+
const joined = frames.length > 1 ? TRANSFORMERS.joinByField(frames, {}) : frames;
|
|
733
|
+
const multiple = joined.length > 1;
|
|
734
|
+
return joined.map((frame) => {
|
|
735
|
+
const field2 = calculate(frame, multiple, options);
|
|
736
|
+
if (!field2) return frame;
|
|
737
|
+
const time = frame.fields.find((f) => f.type === "time");
|
|
738
|
+
return { ...frame, fields: options.replaceFields ? [...time ? [time] : [], field2] : [...frame.fields, field2] };
|
|
739
|
+
});
|
|
740
|
+
},
|
|
668
741
|
convertFieldType: (frames, { conversions = [] }) => frames.map((frame) => ({
|
|
669
742
|
...frame,
|
|
670
743
|
fields: frame.fields.map((f) => {
|
|
@@ -672,7 +745,7 @@ var TRANSFORMERS = {
|
|
|
672
745
|
const c = conversions.find(
|
|
673
746
|
(c2) => c2.targetField === f.name || c2.targetField === name
|
|
674
747
|
);
|
|
675
|
-
return _optionalChain([c, 'optionalAccess',
|
|
748
|
+
return _optionalChain([c, 'optionalAccess', _79 => _79.destinationType]) ? convert(f, c.destinationType, c) : f;
|
|
676
749
|
})
|
|
677
750
|
})),
|
|
678
751
|
// Long rows (row, column, value) to a table with one row per row value and one column per column value, each
|
|
@@ -734,7 +807,7 @@ var TRANSFORMERS = {
|
|
|
734
807
|
filterFieldsByName: (frames, { include, exclude }) => {
|
|
735
808
|
const inc = nameMatcher(include);
|
|
736
809
|
const exc = nameMatcher(exclude);
|
|
737
|
-
return mapFields(frames, (fields) => fields.filter((f) => (!inc || inc(f.name)) && !_optionalChain([exc, 'optionalCall',
|
|
810
|
+
return mapFields(frames, (fields) => fields.filter((f) => (!inc || inc(f.name)) && !_optionalChain([exc, 'optionalCall', _80 => _80(f.name)])));
|
|
738
811
|
},
|
|
739
812
|
organize: (frames, { excludeByName = {}, indexByName = {}, renameByName = {} }) => mapFields(
|
|
740
813
|
frames,
|
|
@@ -753,7 +826,7 @@ function applyTransformations(frames, transformations) {
|
|
|
753
826
|
// src/core/datasource.ts
|
|
754
827
|
var MIXED = "-- Mixed --";
|
|
755
828
|
var DASHBOARD_DS = "-- Dashboard --";
|
|
756
|
-
var isDashboardRef = (ref) => _optionalChain([ref, 'optionalAccess',
|
|
829
|
+
var isDashboardRef = (ref) => _optionalChain([ref, 'optionalAccess', _81 => _81.uid]) === DASHBOARD_DS;
|
|
757
830
|
function dashboardSourceIds(dashboard) {
|
|
758
831
|
const ids = /* @__PURE__ */ new Set();
|
|
759
832
|
for (const p of allPanels(dashboard.panels))
|
|
@@ -766,7 +839,7 @@ function* allPanels(panels) {
|
|
|
766
839
|
yield* allPanels(_nullishCoalesce(p.panels, () => ( [])));
|
|
767
840
|
}
|
|
768
841
|
}
|
|
769
|
-
var panelHasQueries = (panel) => !!_optionalChain([panel, 'access',
|
|
842
|
+
var panelHasQueries = (panel) => !!_optionalChain([panel, 'access', _82 => _82.targets, 'optionalAccess', _83 => _83.some, 'call', _84 => _84((t) => !t.hide)]) && panel.type !== "text" && panel.type !== "row";
|
|
770
843
|
async function queryPanel(panel, ctx, signal) {
|
|
771
844
|
return applyTransformations(await sharedQuery(panel, ctx, signal), panel.transformations);
|
|
772
845
|
}
|
|
@@ -788,20 +861,20 @@ async function rawQuery(panel, ctx, signal, seen) {
|
|
|
788
861
|
const maxDataPoints = _nullishCoalesce(panel.maxDataPoints, () => ( Math.max(100, Math.round(ctx.widthPx))));
|
|
789
862
|
const minInterval = typeof panel.interval === "string" && panel.interval ? safeDuration(panel.interval) : void 0;
|
|
790
863
|
const intervalMs = calculateInterval(ctx.range, maxDataPoints, minInterval);
|
|
791
|
-
const interp = { values: ctx.variables, info: ctx.variableInfo, scoped: panel.scopedVars, range: ctx.range, intervalMs, timezone: _nullishCoalesce(ctx.timezone, () => ( _optionalChain([ctx, 'access',
|
|
864
|
+
const interp = { values: ctx.variables, info: ctx.variableInfo, scoped: panel.scopedVars, range: ctx.range, intervalMs, timezone: _nullishCoalesce(ctx.timezone, () => ( _optionalChain([ctx, 'access', _85 => _85.dashboard, 'optionalAccess', _86 => _86.timezone]))) };
|
|
792
865
|
const panelRef = normalizeRef(panel.datasource);
|
|
793
866
|
const groups = /* @__PURE__ */ new Map();
|
|
794
867
|
const reused = [];
|
|
795
868
|
for (const target of _nullishCoalesce(panel.targets, () => ( []))) {
|
|
796
869
|
if (target.hide) continue;
|
|
797
|
-
const fallback = _optionalChain([panelRef, 'optionalAccess',
|
|
870
|
+
const fallback = _optionalChain([panelRef, 'optionalAccess', _87 => _87.uid]) === MIXED ? void 0 : panelRef;
|
|
798
871
|
const ref = interpolateDeep(_nullishCoalesce(normalizeRef(target.datasource), () => ( fallback)), interp);
|
|
799
872
|
if (isDashboardRef(ref)) {
|
|
800
873
|
reused.push(reusePanel(panel, target, ctx, signal, seen));
|
|
801
874
|
continue;
|
|
802
875
|
}
|
|
803
876
|
const ds = ctx.resolve(ref);
|
|
804
|
-
const resolved = { ...interpolateDeep(target, { ...interp, datasourceType: _optionalChain([ref, 'optionalAccess',
|
|
877
|
+
const resolved = { ...interpolateDeep(target, { ...interp, datasourceType: _optionalChain([ref, 'optionalAccess', _88 => _88.type]) }), datasource: ref };
|
|
805
878
|
groups.set(ds, [..._nullishCoalesce(groups.get(ds), () => ( [])), resolved]);
|
|
806
879
|
}
|
|
807
880
|
const results = await Promise.all([
|
|
@@ -834,10 +907,10 @@ function safeDuration(s) {
|
|
|
834
907
|
|
|
835
908
|
// src/core/resolveVariables.ts
|
|
836
909
|
function refreshedVariables(dashboard, on) {
|
|
837
|
-
return (_nullishCoalesce(_optionalChain([dashboard, 'access',
|
|
910
|
+
return (_nullishCoalesce(_optionalChain([dashboard, 'access', _89 => _89.templating, 'optionalAccess', _90 => _90.list]), () => ( []))).filter((v) => v.type === "query" && (on === "load" ? (_nullishCoalesce(v.refresh, () => ( 0))) >= 1 : v.refresh === 2)).map((v) => v.name);
|
|
838
911
|
}
|
|
839
912
|
function variableDependents(dashboard, names) {
|
|
840
|
-
const list = _nullishCoalesce(_optionalChain([dashboard, 'access',
|
|
913
|
+
const list = _nullishCoalesce(_optionalChain([dashboard, 'access', _91 => _91.templating, 'optionalAccess', _92 => _92.list]), () => ( []));
|
|
841
914
|
const all = list.map((v) => v.name);
|
|
842
915
|
const refs = new Map(list.map((v) => [v.name, variableReferences(v, all)]));
|
|
843
916
|
const out = /* @__PURE__ */ new Set();
|
|
@@ -854,7 +927,7 @@ function variableDependents(dashboard, names) {
|
|
|
854
927
|
return out;
|
|
855
928
|
}
|
|
856
929
|
function variableOrder(dashboard) {
|
|
857
|
-
const list = _nullishCoalesce(_optionalChain([dashboard, 'access',
|
|
930
|
+
const list = _nullishCoalesce(_optionalChain([dashboard, 'access', _93 => _93.templating, 'optionalAccess', _94 => _94.list]), () => ( []));
|
|
858
931
|
const all = list.map((v) => v.name);
|
|
859
932
|
const deps = new Map(list.map((v) => [v.name, variableReferences(v, all)]));
|
|
860
933
|
const order = [];
|
|
@@ -884,13 +957,13 @@ async function resolveVariables(dashboard, opts) {
|
|
|
884
957
|
const ref = interpolateDeep(normalizeRef(v.datasource), { values, info });
|
|
885
958
|
const ds = opts.resolve(ref);
|
|
886
959
|
if (!ds.variableOptions) continue;
|
|
887
|
-
const query = interpolateDeep(v.query, { values, info, range: opts.range, datasourceType: _optionalChain([ref, 'optionalAccess',
|
|
960
|
+
const query = interpolateDeep(v.query, { values, info, range: opts.range, datasourceType: _optionalChain([ref, 'optionalAccess', _95 => _95.type]), timezone: dashboard.timezone });
|
|
888
961
|
let raw;
|
|
889
962
|
try {
|
|
890
963
|
raw = await ds.variableOptions({ query, datasource: ref, range: opts.range }, opts.signal);
|
|
891
964
|
} catch (e) {
|
|
892
|
-
if (_optionalChain([opts, 'access',
|
|
893
|
-
errors[v.name] = String(_nullishCoalesce(_optionalChain([e, 'optionalAccess',
|
|
965
|
+
if (_optionalChain([opts, 'access', _96 => _96.signal, 'optionalAccess', _97 => _97.aborted])) throw e;
|
|
966
|
+
errors[v.name] = String(_nullishCoalesce(_optionalChain([e, 'optionalAccess', _98 => _98.message]), () => ( e)));
|
|
894
967
|
continue;
|
|
895
968
|
}
|
|
896
969
|
if (!raw) continue;
|
|
@@ -989,13 +1062,13 @@ var INPUT_OPTION_KEYS = {
|
|
|
989
1062
|
};
|
|
990
1063
|
var INPUT_TYPES = Object.keys(INPUT_OPTION_KEYS);
|
|
991
1064
|
var isInputType = (type) => type in INPUT_OPTION_KEYS;
|
|
992
|
-
var isInputPanel = (p) => p.type.startsWith("input-") && !!_optionalChain([p, 'access',
|
|
1065
|
+
var isInputPanel = (p) => p.type.startsWith("input-") && !!_optionalChain([p, 'access', _99 => _99.options, 'optionalAccess', _100 => _100.metric]);
|
|
993
1066
|
var INPUT_GROUP = "input-group";
|
|
994
1067
|
var isFormPanelType = (type) => isInputType(type) || type === INPUT_GROUP;
|
|
995
|
-
var isInputGroup = (p) => p.type === INPUT_GROUP && Array.isArray(_optionalChain([p, 'access',
|
|
1068
|
+
var isInputGroup = (p) => p.type === INPUT_GROUP && Array.isArray(_optionalChain([p, 'access', _101 => _101.options, 'optionalAccess', _102 => _102.fields]));
|
|
996
1069
|
var GROUP_FIELD_TYPES = INPUT_TYPES.filter((t) => t !== "input-counter");
|
|
997
1070
|
function groupFields(group) {
|
|
998
|
-
return group.options.fields.filter((f) => f && isInputType(f.type) && f.type !== "input-counter" && typeof _optionalChain([f, 'access',
|
|
1071
|
+
return group.options.fields.filter((f) => f && isInputType(f.type) && f.type !== "input-counter" && typeof _optionalChain([f, 'access', _103 => _103.options, 'optionalAccess', _104 => _104.metric]) === "string" && f.options.metric).map(({ span, ...f }) => ({ ...f, gridPos: { x: 0, y: 0, w: _nullishCoalesce(span, () => ( 24)), h: 3 } }));
|
|
999
1072
|
}
|
|
1000
1073
|
var panelsOf = (dashboard) => dashboard.panels.flatMap((p) => p.type === "row" ? [p, ..._nullishCoalesce(p.panels, () => ( []))] : [p]);
|
|
1001
1074
|
function inputPanels(dashboard) {
|
|
@@ -1087,7 +1160,7 @@ function sameSave(entry, candidates) {
|
|
|
1087
1160
|
function inputProblem(panel, value) {
|
|
1088
1161
|
const o = panel.options;
|
|
1089
1162
|
const empty = value == null || value === "" || Array.isArray(value) && !value.length;
|
|
1090
|
-
if (empty) return o.required && _optionalChain([INPUT_OPTION_KEYS, 'access',
|
|
1163
|
+
if (empty) return o.required && _optionalChain([INPUT_OPTION_KEYS, 'access', _105 => _105[panel.type], 'optionalAccess', _106 => _106.includes, 'call', _107 => _107("required")]) ? "Required" : void 0;
|
|
1091
1164
|
if ((panel.type === "input-number" || panel.type === "input-slider") && typeof value === "number") {
|
|
1092
1165
|
const unit = o.unit ? ` ${o.unit}` : "";
|
|
1093
1166
|
if (typeof o.min === "number" && value < o.min) return `At least ${o.min}${unit}`;
|
|
@@ -1105,8 +1178,8 @@ function textSuggestions(entries, query, limit = 8) {
|
|
|
1105
1178
|
const seen = /* @__PURE__ */ new Set();
|
|
1106
1179
|
const out = [];
|
|
1107
1180
|
for (const e of [...entries].sort((a, b) => b.ts - a.ts)) {
|
|
1108
|
-
const text = _optionalChain([e, 'access',
|
|
1109
|
-
const key = _optionalChain([text, 'optionalAccess',
|
|
1181
|
+
const text = _optionalChain([e, 'access', _108 => _108.text, 'optionalAccess', _109 => _109.trim, 'call', _110 => _110()]);
|
|
1182
|
+
const key = _optionalChain([text, 'optionalAccess', _111 => _111.toLowerCase, 'call', _112 => _112()]);
|
|
1110
1183
|
if (!text || !key || seen.has(key)) continue;
|
|
1111
1184
|
seen.add(key);
|
|
1112
1185
|
if (key === q) continue;
|
|
@@ -1118,7 +1191,7 @@ function textSuggestions(entries, query, limit = 8) {
|
|
|
1118
1191
|
}
|
|
1119
1192
|
function entriesSavedWith(entries, metric, withMetric, withText) {
|
|
1120
1193
|
const want = withText.trim().toLowerCase();
|
|
1121
|
-
const matches = entries.filter((e) => e.metric === withMetric && _optionalChain([e, 'access',
|
|
1194
|
+
const matches = entries.filter((e) => e.metric === withMetric && _optionalChain([e, 'access', _113 => _113.text, 'optionalAccess', _114 => _114.trim, 'call', _115 => _115(), 'access', _116 => _116.toLowerCase, 'call', _117 => _117()]) === want);
|
|
1122
1195
|
const saves = new Set(matches.map((e) => e.save).filter(Boolean));
|
|
1123
1196
|
const times = new Set(matches.filter((e) => !e.save).map((e) => e.ts));
|
|
1124
1197
|
return entries.filter((e) => e.metric === metric && (e.save ? saves.has(e.save) : times.has(e.ts)));
|
|
@@ -1227,11 +1300,11 @@ function fromNow(t) {
|
|
|
1227
1300
|
return diff >= 0 ? `${text} ago` : `in ${text}`;
|
|
1228
1301
|
}
|
|
1229
1302
|
function thresholdStep(value, config = {}) {
|
|
1230
|
-
const steps = _optionalChain([config, 'access',
|
|
1231
|
-
if (!_optionalChain([steps, 'optionalAccess',
|
|
1303
|
+
const steps = _optionalChain([config, 'access', _118 => _118.thresholds, 'optionalAccess', _119 => _119.steps]);
|
|
1304
|
+
if (!_optionalChain([steps, 'optionalAccess', _120 => _120.length])) return void 0;
|
|
1232
1305
|
if (value == null) return steps[0];
|
|
1233
1306
|
let v = value;
|
|
1234
|
-
if (_optionalChain([config, 'access',
|
|
1307
|
+
if (_optionalChain([config, 'access', _121 => _121.thresholds, 'optionalAccess', _122 => _122.mode]) === "percentage") {
|
|
1235
1308
|
const min = _nullishCoalesce(config.min, () => ( 0));
|
|
1236
1309
|
const max = _nullishCoalesce(config.max, () => ( 100));
|
|
1237
1310
|
v = (value - min) / (max - min || 1) * 100;
|
|
@@ -1291,12 +1364,12 @@ var SERIES_PALETTE = {
|
|
|
1291
1364
|
function seriesColor(index, scheme, config) {
|
|
1292
1365
|
const palette = SERIES_PALETTE[scheme];
|
|
1293
1366
|
const color = palette[index % palette.length];
|
|
1294
|
-
if (_optionalChain([config, 'optionalAccess',
|
|
1367
|
+
if (_optionalChain([config, 'optionalAccess', _123 => _123.color, 'optionalAccess', _124 => _124.mode]) === "fixed") return resolveColor(config.color.fixedColor, color);
|
|
1295
1368
|
return color;
|
|
1296
1369
|
}
|
|
1297
1370
|
function mappedResult(value, config = {}) {
|
|
1298
1371
|
for (const m of _nullishCoalesce(config.mappings, () => ( []))) {
|
|
1299
|
-
if (!_optionalChain([m, 'optionalAccess',
|
|
1372
|
+
if (!_optionalChain([m, 'optionalAccess', _125 => _125.options]) || typeof m.options !== "object") continue;
|
|
1300
1373
|
if (m.type === "value") {
|
|
1301
1374
|
const hit = m.options[String(value)];
|
|
1302
1375
|
if (hit) return hit;
|
|
@@ -1309,7 +1382,7 @@ function mappedResult(value, config = {}) {
|
|
|
1309
1382
|
if (value == null) continue;
|
|
1310
1383
|
const re = regexOf(pattern);
|
|
1311
1384
|
const match = re && String(value).match(re);
|
|
1312
|
-
if (match) return { ...result, text: _optionalChain([result, 'access',
|
|
1385
|
+
if (match) return { ...result, text: _optionalChain([result, 'access', _126 => _126.text, 'optionalAccess', _127 => _127.replace, 'call', _128 => _128(/\$(\d+)/g, (_, n) => _nullishCoalesce(match[Number(n)], () => ( "")))]) };
|
|
1313
1386
|
} else if (m.type === "special") {
|
|
1314
1387
|
const { match, result } = m.options;
|
|
1315
1388
|
const isNull = value == null;
|
|
@@ -1329,7 +1402,7 @@ function regexOf(pattern) {
|
|
|
1329
1402
|
}
|
|
1330
1403
|
}
|
|
1331
1404
|
function formatDisplay(value, config = {}) {
|
|
1332
|
-
return _nullishCoalesce(_optionalChain([mappedResult, 'call',
|
|
1405
|
+
return _nullishCoalesce(_optionalChain([mappedResult, 'call', _129 => _129(value, config), 'optionalAccess', _130 => _130.text]), () => ( formatValue(value, config)));
|
|
1333
1406
|
}
|
|
1334
1407
|
var CONTINUOUS = {
|
|
1335
1408
|
"continuous-GrYlRd": ["#73BF69", "#FADE2A", "#F2495C"],
|
|
@@ -1349,14 +1422,14 @@ function mix(a, b, t) {
|
|
|
1349
1422
|
return `#${out.map((v) => v.toString(16).padStart(2, "0")).join("")}`;
|
|
1350
1423
|
}
|
|
1351
1424
|
function valueColor(value, config, fallback, extent) {
|
|
1352
|
-
const mapped = _optionalChain([mappedResult, 'call',
|
|
1425
|
+
const mapped = _optionalChain([mappedResult, 'call', _131 => _131(value, config), 'optionalAccess', _132 => _132.color]);
|
|
1353
1426
|
if (mapped) return resolveColor(mapped, fallback);
|
|
1354
|
-
const mode = _optionalChain([config, 'access',
|
|
1355
|
-
if (mode === "fixed") return resolveColor(_optionalChain([config, 'access',
|
|
1427
|
+
const mode = _optionalChain([config, 'access', _133 => _133.color, 'optionalAccess', _134 => _134.mode]);
|
|
1428
|
+
if (mode === "fixed") return resolveColor(_optionalChain([config, 'access', _135 => _135.color, 'optionalAccess', _136 => _136.fixedColor]), fallback);
|
|
1356
1429
|
const stops = mode ? CONTINUOUS[mode] : void 0;
|
|
1357
1430
|
if (stops) {
|
|
1358
|
-
const min = _nullishCoalesce(_nullishCoalesce(config.min, () => ( _optionalChain([extent, 'optionalAccess',
|
|
1359
|
-
const max = _nullishCoalesce(_nullishCoalesce(config.max, () => ( _optionalChain([extent, 'optionalAccess',
|
|
1431
|
+
const min = _nullishCoalesce(_nullishCoalesce(config.min, () => ( _optionalChain([extent, 'optionalAccess', _137 => _137[0]]))), () => ( 0));
|
|
1432
|
+
const max = _nullishCoalesce(_nullishCoalesce(config.max, () => ( _optionalChain([extent, 'optionalAccess', _138 => _138[1]]))), () => ( 1));
|
|
1360
1433
|
const t = value == null ? 0 : Math.min(1, Math.max(0, (value - min) / (max - min || 1)));
|
|
1361
1434
|
const at = t * (stops.length - 1);
|
|
1362
1435
|
const i = Math.min(Math.floor(at), stops.length - 2);
|
|
@@ -1371,8 +1444,8 @@ function valueColor(value, config, fallback, extent) {
|
|
|
1371
1444
|
|
|
1372
1445
|
// src/core/fieldconfig.ts
|
|
1373
1446
|
function resolveFieldConfig(panel, field2, frame, displayName) {
|
|
1374
|
-
let config = mergeConfig(_nullishCoalesce(_optionalChain([panel, 'access',
|
|
1375
|
-
for (const o of _nullishCoalesce(_optionalChain([panel, 'access',
|
|
1447
|
+
let config = mergeConfig(_nullishCoalesce(_optionalChain([panel, 'access', _139 => _139.fieldConfig, 'optionalAccess', _140 => _140.defaults]), () => ( {})), _nullishCoalesce(field2.config, () => ( {})));
|
|
1448
|
+
for (const o of _nullishCoalesce(_optionalChain([panel, 'access', _141 => _141.fieldConfig, 'optionalAccess', _142 => _142.overrides]), () => ( []))) {
|
|
1376
1449
|
if (!fieldMatches(o.matcher, field2, frame, displayName)) continue;
|
|
1377
1450
|
for (const p of o.properties) if (p.value !== void 0) config = setPath(config, p.id, p.value);
|
|
1378
1451
|
}
|
|
@@ -1457,7 +1530,7 @@ var GrafanaClient = class {
|
|
|
1457
1530
|
}
|
|
1458
1531
|
search(query = "", options = {}) {
|
|
1459
1532
|
const params = new URLSearchParams({ type: _nullishCoalesce(options.type, () => ( "dash-db")), query, limit: String(_nullishCoalesce(options.limit, () => ( 100))) });
|
|
1460
|
-
_optionalChain([options, 'access',
|
|
1533
|
+
_optionalChain([options, 'access', _143 => _143.tag, 'optionalAccess', _144 => _144.forEach, 'call', _145 => _145((t) => params.append("tag", t))]);
|
|
1461
1534
|
return this.request(`/api/search?${params}`);
|
|
1462
1535
|
}
|
|
1463
1536
|
async dashboard(uid) {
|
|
@@ -1466,7 +1539,7 @@ var GrafanaClient = class {
|
|
|
1466
1539
|
}
|
|
1467
1540
|
/** Resolve name / "${DS_X}" placeholder / missing refs to a concrete {type, uid}. */
|
|
1468
1541
|
async resolveRef(ref) {
|
|
1469
|
-
if (_optionalChain([ref, 'optionalAccess',
|
|
1542
|
+
if (_optionalChain([ref, 'optionalAccess', _146 => _146.uid]) && !isPlaceholder(ref.uid) && ref.uid !== "default") {
|
|
1470
1543
|
if (ref.type) return ref;
|
|
1471
1544
|
}
|
|
1472
1545
|
this.settings ??= this.request("/api/frontend/settings");
|
|
@@ -1478,11 +1551,11 @@ var GrafanaClient = class {
|
|
|
1478
1551
|
throw e;
|
|
1479
1552
|
}
|
|
1480
1553
|
const all = Object.values(settings.datasources);
|
|
1481
|
-
const sameType = (type) => type === _optionalChain([ref, 'optionalAccess',
|
|
1482
|
-
const found = _optionalChain([ref, 'optionalAccess',
|
|
1483
|
-
(_optionalChain([ref, 'optionalAccess',
|
|
1554
|
+
const sameType = (type) => type === _optionalChain([ref, 'optionalAccess', _147 => _147.type]) || TYPE_ALIASES[type] === _optionalChain([ref, 'optionalAccess', _148 => _148.type]) || TYPE_ALIASES[_nullishCoalesce(_optionalChain([ref, 'optionalAccess', _149 => _149.type]), () => ( ""))] === type;
|
|
1555
|
+
const found = _optionalChain([ref, 'optionalAccess', _150 => _150.uid]) && !isPlaceholder(ref.uid) && all.find((d) => d.uid === ref.uid || d.name === ref.uid) || _optionalChain([ref, 'optionalAccess', _151 => _151.type]) && all.find((d) => sameType(d.type) && d.isDefault) || _optionalChain([ref, 'optionalAccess', _152 => _152.type]) && all.find((d) => sameType(d.type)) || // A ref that names a type this Grafana doesn't have must not run against some other datasource.
|
|
1556
|
+
(_optionalChain([ref, 'optionalAccess', _153 => _153.type]) ? void 0 : settings.datasources[settings.defaultDatasource]);
|
|
1484
1557
|
if (!found) {
|
|
1485
|
-
throw new GrafanaError(_optionalChain([ref, 'optionalAccess',
|
|
1558
|
+
throw new GrafanaError(_optionalChain([ref, 'optionalAccess', _154 => _154.type]) ? `No ${ref.type} datasource in this Grafana` : `No datasource matches ${JSON.stringify(ref)}`);
|
|
1486
1559
|
}
|
|
1487
1560
|
return { uid: found.uid, type: found.type };
|
|
1488
1561
|
}
|
|
@@ -1544,11 +1617,11 @@ var GrafanaDataSource = class {
|
|
|
1544
1617
|
};
|
|
1545
1618
|
var FIELD_TYPES = ["time", "number", "string", "boolean"];
|
|
1546
1619
|
function fromWire(frame) {
|
|
1547
|
-
const fields = _nullishCoalesce(_optionalChain([frame, 'access',
|
|
1548
|
-
const values = _nullishCoalesce(_optionalChain([frame, 'access',
|
|
1620
|
+
const fields = _nullishCoalesce(_optionalChain([frame, 'access', _155 => _155.schema, 'optionalAccess', _156 => _156.fields]), () => ( []));
|
|
1621
|
+
const values = _nullishCoalesce(_optionalChain([frame, 'access', _157 => _157.data, 'optionalAccess', _158 => _158.values]), () => ( []));
|
|
1549
1622
|
return {
|
|
1550
|
-
name: _optionalChain([frame, 'access',
|
|
1551
|
-
refId: _optionalChain([frame, 'access',
|
|
1623
|
+
name: _optionalChain([frame, 'access', _159 => _159.schema, 'optionalAccess', _160 => _160.name]),
|
|
1624
|
+
refId: _optionalChain([frame, 'access', _161 => _161.schema, 'optionalAccess', _162 => _162.refId]),
|
|
1552
1625
|
fields: fields.map((f, i) => ({
|
|
1553
1626
|
name: f.name,
|
|
1554
1627
|
type: FIELD_TYPES.includes(f.type) ? f.type : "other",
|
|
@@ -1771,7 +1844,7 @@ function spokenValue(panel, said, current = null, choices2) {
|
|
|
1771
1844
|
const min = _nullishCoalesce(o.min, () => ( 0));
|
|
1772
1845
|
const max = _nullishCoalesce(o.max, () => ( 10));
|
|
1773
1846
|
const step = _nullishCoalesce(o.step, () => ( 1));
|
|
1774
|
-
if (_optionalChain([o, 'access',
|
|
1847
|
+
if (_optionalChain([o, 'access', _163 => _163.labels, 'optionalAccess', _164 => _164.length])) {
|
|
1775
1848
|
const [hit] = matchChoices(text, o.labels.map((label, i) => ({ label, value: i })));
|
|
1776
1849
|
if (typeof hit === "number") {
|
|
1777
1850
|
const raw = o.labels.length === 1 ? min : min + hit / (o.labels.length - 1) * (max - min);
|
|
@@ -1828,7 +1901,7 @@ function fillForm(dashboard, choices2 = {}) {
|
|
|
1828
1901
|
field2 = { ...base, type: "number", min: Math.round(_nullishCoalesce(o.min, () => ( 1))), max: Math.round(_nullishCoalesce(o.max, () => ( 5))), step: 1 };
|
|
1829
1902
|
break;
|
|
1830
1903
|
case "input-slider":
|
|
1831
|
-
field2 = { ...base, type: "number", unit: o.unit, min: _nullishCoalesce(o.min, () => ( 0)), max: _nullishCoalesce(o.max, () => ( 10)), step: _nullishCoalesce(o.step, () => ( 1)), choices: _optionalChain([o, 'access',
|
|
1904
|
+
field2 = { ...base, type: "number", unit: o.unit, min: _nullishCoalesce(o.min, () => ( 0)), max: _nullishCoalesce(o.max, () => ( 10)), step: _nullishCoalesce(o.step, () => ( 1)), choices: _optionalChain([o, 'access', _165 => _165.labels, 'optionalAccess', _166 => _166.length]) ? o.labels : void 0 };
|
|
1832
1905
|
break;
|
|
1833
1906
|
case "input-duration":
|
|
1834
1907
|
field2 = { ...base, type: "duration" };
|
|
@@ -2206,7 +2279,7 @@ function scaleValue(f, tokens, from, to) {
|
|
|
2206
2279
|
if (!(w in SCALE_WORDS)) continue;
|
|
2207
2280
|
if (is(tokens[j - 1], "not") || is(tokens[j - 2], "not")) return null;
|
|
2208
2281
|
let x = SCALE_WORDS[w];
|
|
2209
|
-
if (INTENSIFIERS.has(_nullishCoalesce(_optionalChain([tokens, 'access',
|
|
2282
|
+
if (INTENSIFIERS.has(_nullishCoalesce(_optionalChain([tokens, 'access', _167 => _167[j - 1], 'optionalAccess', _168 => _168.text]), () => ( ""))) && x !== 0.5) x = x < 0.5 ? Math.max(0, x - 0.25) : Math.min(1, x + 0.25);
|
|
2210
2283
|
return { value: Math.round(f.min + x * (f.max - f.min)), at: j };
|
|
2211
2284
|
}
|
|
2212
2285
|
return null;
|
|
@@ -2223,7 +2296,7 @@ var CORRECTIONS = [["no", "wait"], ["wait"], ["sorry"], ["actually"], ["i", "mea
|
|
|
2223
2296
|
function lastCorrection(tokens, from, to) {
|
|
2224
2297
|
let last = null;
|
|
2225
2298
|
for (let j = from; j < to; j++)
|
|
2226
|
-
for (const c of CORRECTIONS) if (c.every((w, n) => _optionalChain([tokens, 'access',
|
|
2299
|
+
for (const c of CORRECTIONS) if (c.every((w, n) => _optionalChain([tokens, 'access', _169 => _169[j + n], 'optionalAccess', _170 => _170.text]) === w) && j + c.length <= to) last = j + c.length;
|
|
2227
2300
|
return last;
|
|
2228
2301
|
}
|
|
2229
2302
|
var LEAD = /^[\s,:;.-]*(?:(?:is|was|were|of|at|about|around|to|=)\b[\s,:;.-]*)*/i;
|
|
@@ -2295,7 +2368,7 @@ function ruleFill(form, said) {
|
|
|
2295
2368
|
for (const f of form.fields) {
|
|
2296
2369
|
const mine = named.map((h, i) => ({ h, i })).filter(({ h }) => h.key === f.key);
|
|
2297
2370
|
for (const { h, i } of mine.reverse()) {
|
|
2298
|
-
const stop = _nullishCoalesce(_optionalChain([named, 'access',
|
|
2371
|
+
const stop = _nullishCoalesce(_optionalChain([named, 'access', _171 => _171[i + 1], 'optionalAccess', _172 => _172.start]), () => ( tokens.length));
|
|
2299
2372
|
const nextIsToggle = !!named[i + 1] && fieldOf(named[i + 1].key).type === "boolean";
|
|
2300
2373
|
const found = valueAfter(said, f, h, tokens, stop, free, nextIsToggle);
|
|
2301
2374
|
if (!found) continue;
|
|
@@ -2416,7 +2489,7 @@ function buildFrames(target, entries, request, label, siblings = []) {
|
|
|
2416
2489
|
const fill = _nullishCoalesce(target.fillZero, () => ( (aggregate === "sum" || aggregate === "count")));
|
|
2417
2490
|
({ times, values } = bucketize(rows, aggregate, bucket, request.range, fill));
|
|
2418
2491
|
}
|
|
2419
|
-
const display = group == null ? name : _nullishCoalesce(_optionalChain([label, 'optionalCall',
|
|
2492
|
+
const display = group == null ? name : _nullishCoalesce(_optionalChain([label, 'optionalCall', _173 => _173(labelKey, group)]), () => ( group));
|
|
2420
2493
|
return {
|
|
2421
2494
|
name,
|
|
2422
2495
|
refId: target.refId,
|
|
@@ -2472,7 +2545,7 @@ function bucketize(rows, aggregate, bucket, range, fillZero) {
|
|
|
2472
2545
|
const keys = fillZero ? step.range(range.from, range.to) : [...sums.keys()].sort((a, b) => a - b);
|
|
2473
2546
|
const values = keys.map((k) => {
|
|
2474
2547
|
const vs = sums.get(k);
|
|
2475
|
-
return _optionalChain([vs, 'optionalAccess',
|
|
2548
|
+
return _optionalChain([vs, 'optionalAccess', _174 => _174.length]) ? reduce2(vs, aggregate) : fillZero ? 0 : null;
|
|
2476
2549
|
});
|
|
2477
2550
|
return { times: keys, values };
|
|
2478
2551
|
}
|
|
@@ -2553,17 +2626,17 @@ function parseGazetteer(json) {
|
|
|
2553
2626
|
};
|
|
2554
2627
|
if (Array.isArray(json)) {
|
|
2555
2628
|
for (const item of json) {
|
|
2556
|
-
const lat = Number(_nullishCoalesce(_optionalChain([item, 'optionalAccess',
|
|
2557
|
-
const lon = Number(_nullishCoalesce(_nullishCoalesce(_optionalChain([item, 'optionalAccess',
|
|
2629
|
+
const lat = Number(_nullishCoalesce(_optionalChain([item, 'optionalAccess', _175 => _175.latitude]), () => ( _optionalChain([item, 'optionalAccess', _176 => _176.lat]))));
|
|
2630
|
+
const lon = Number(_nullishCoalesce(_nullishCoalesce(_optionalChain([item, 'optionalAccess', _177 => _177.longitude]), () => ( _optionalChain([item, 'optionalAccess', _178 => _178.lon]))), () => ( _optionalChain([item, 'optionalAccess', _179 => _179.lng]))));
|
|
2558
2631
|
if (!Number.isFinite(lat) || !Number.isFinite(lon)) continue;
|
|
2559
2632
|
const p = { lon, lat };
|
|
2560
2633
|
add(item.key, p);
|
|
2561
2634
|
for (const k of [..._nullishCoalesce(item.keys, () => ( [])), ..._nullishCoalesce(item.keywords, () => ( []))]) add(k, p);
|
|
2562
2635
|
add(item.name, p);
|
|
2563
2636
|
}
|
|
2564
|
-
} else if (_optionalChain([json, 'optionalAccess',
|
|
2637
|
+
} else if (_optionalChain([json, 'optionalAccess', _180 => _180.type]) === "FeatureCollection") {
|
|
2565
2638
|
for (const f of _nullishCoalesce(json.features, () => ( []))) {
|
|
2566
|
-
const p = featurePoint(_optionalChain([f, 'optionalAccess',
|
|
2639
|
+
const p = featurePoint(_optionalChain([f, 'optionalAccess', _181 => _181.geometry]));
|
|
2567
2640
|
if (!p) continue;
|
|
2568
2641
|
add(f.id, p);
|
|
2569
2642
|
for (const v of Object.values(_nullishCoalesce(f.properties, () => ( {})))) if (typeof v === "string") add(v, p);
|
|
@@ -2572,7 +2645,7 @@ function parseGazetteer(json) {
|
|
|
2572
2645
|
return { find: (key) => _nullishCoalesce(exact.get(key), () => ( folded.get(key.toLowerCase()))) };
|
|
2573
2646
|
}
|
|
2574
2647
|
function featurePoint(geometry) {
|
|
2575
|
-
if (!_optionalChain([geometry, 'optionalAccess',
|
|
2648
|
+
if (!_optionalChain([geometry, 'optionalAccess', _182 => _182.coordinates])) return void 0;
|
|
2576
2649
|
if (geometry.type === "Point") {
|
|
2577
2650
|
const [lon, lat] = geometry.coordinates;
|
|
2578
2651
|
return Number.isFinite(lon) && Number.isFinite(lat) ? { lon, lat } : void 0;
|
|
@@ -2601,7 +2674,7 @@ function loadGazetteer(path, ds) {
|
|
|
2601
2674
|
const json = absolute ? fetch(path).then((r) => {
|
|
2602
2675
|
if (!r.ok) throw new Error(`${r.status} ${r.statusText}`);
|
|
2603
2676
|
return r.json();
|
|
2604
|
-
}) : _optionalChain([ds, 'optionalAccess',
|
|
2677
|
+
}) : _optionalChain([ds, 'optionalAccess', _183 => _183.publicFile]) ? ds.publicFile(path) : Promise.reject(new Error(`${path} is served by Grafana, and this dashboard has no Grafana connection`));
|
|
2605
2678
|
const run2 = json.then(parseGazetteer);
|
|
2606
2679
|
run2.catch(() => loaded.get(path) === run2 && loaded.delete(path));
|
|
2607
2680
|
loaded.set(path, run2);
|
|
@@ -2641,7 +2714,7 @@ function macro(path, format3, ctx) {
|
|
|
2641
2714
|
switch (head) {
|
|
2642
2715
|
case "__from":
|
|
2643
2716
|
case "__to": {
|
|
2644
|
-
const ms = head === "__from" ? _optionalChain([ctx, 'access',
|
|
2717
|
+
const ms = head === "__from" ? _optionalChain([ctx, 'access', _184 => _184.range, 'optionalAccess', _185 => _185.from]) : _optionalChain([ctx, 'access', _186 => _186.range, 'optionalAccess', _187 => _187.to]);
|
|
2645
2718
|
if (ms == null) return void 0;
|
|
2646
2719
|
if (format3 === "date" || format3 === "date:iso") return new Date(ms).toISOString();
|
|
2647
2720
|
if (format3 === "date:seconds") return String(Math.floor(ms / 1e3));
|
|
@@ -2678,13 +2751,13 @@ function macro(path, format3, ctx) {
|
|
|
2678
2751
|
}
|
|
2679
2752
|
return void 0;
|
|
2680
2753
|
case "__series":
|
|
2681
|
-
return rest[0] === "name" ? _nullishCoalesce(_nullishCoalesce(d.seriesName, () => ( _optionalChain([d, 'access',
|
|
2754
|
+
return rest[0] === "name" ? _nullishCoalesce(_nullishCoalesce(d.seriesName, () => ( _optionalChain([d, 'access', _188 => _188.frame, 'optionalAccess', _189 => _189.name]))), () => ( d.fieldName)) : void 0;
|
|
2682
2755
|
case "__data": {
|
|
2683
2756
|
const m = /^fields(?:\.([\w-]+)|\["([^"]*)"\]|\[(\d+)\])/.exec(rest.join("."));
|
|
2684
2757
|
if (!m || !d.frame || d.row == null) return void 0;
|
|
2685
2758
|
const key = _nullishCoalesce(m[1], () => ( m[2]));
|
|
2686
|
-
const f = key != null ? d.frame.fields.find((x) => x.name === key || _optionalChain([x, 'access',
|
|
2687
|
-
const v = _optionalChain([f, 'optionalAccess',
|
|
2759
|
+
const f = key != null ? d.frame.fields.find((x) => x.name === key || _optionalChain([x, 'access', _190 => _190.config, 'optionalAccess', _191 => _191.displayName]) === key) : d.frame.fields[Number(m[3])];
|
|
2760
|
+
const v = _optionalChain([f, 'optionalAccess', _192 => _192.values, 'access', _193 => _193[d.row]]);
|
|
2688
2761
|
if (v == null) return void 0;
|
|
2689
2762
|
return f.type === "time" ? String(toMillis(v)) : String(v);
|
|
2690
2763
|
}
|
|
@@ -2695,9 +2768,9 @@ function urlTime(raw, ms) {
|
|
|
2695
2768
|
return raw.trim().startsWith("now") ? encodeURIComponent(raw.trim()) : String(ms);
|
|
2696
2769
|
}
|
|
2697
2770
|
function allVariables(ctx) {
|
|
2698
|
-
const names = (_nullishCoalesce(_optionalChain([ctx, 'access',
|
|
2771
|
+
const names = (_nullishCoalesce(_optionalChain([ctx, 'access', _194 => _194.dashboard, 'optionalAccess', _195 => _195.templating, 'optionalAccess', _196 => _196.list]), () => ( []))).filter((v) => v.type !== "adhoc").map((v) => v.name);
|
|
2699
2772
|
return (names.length ? names : Object.keys(ctx.values)).flatMap((n) => {
|
|
2700
|
-
const v = _nullishCoalesce(_optionalChain([ctx, 'access',
|
|
2773
|
+
const v = _nullishCoalesce(_optionalChain([ctx, 'access', _197 => _197.scoped, 'optionalAccess', _198 => _198[n], 'optionalAccess', _199 => _199.value]), () => ( ctx.values[n]));
|
|
2701
2774
|
return v == null ? [] : [queryParam(n, v)];
|
|
2702
2775
|
}).join("&");
|
|
2703
2776
|
}
|
|
@@ -2708,7 +2781,7 @@ function parseDashboardLink(href, grafanaUrl) {
|
|
|
2708
2781
|
const base = grafanaUrl ? /^(?:[a-z][a-z0-9+.-]*:)?\/\/([^/?#]+)([^?#]*)/i.exec(grafanaUrl.trim()) : null;
|
|
2709
2782
|
if (host && (!base || base[1].toLowerCase() !== host.toLowerCase())) return null;
|
|
2710
2783
|
if (scheme && !/^https?:$/i.test(scheme)) return null;
|
|
2711
|
-
const prefix = (_nullishCoalesce(_optionalChain([base, 'optionalAccess',
|
|
2784
|
+
const prefix = (_nullishCoalesce(_optionalChain([base, 'optionalAccess', _200 => _200[2]]), () => ( ""))).replace(/\/+$/, "");
|
|
2712
2785
|
const path = prefix && rawPath.startsWith(prefix + "/") ? rawPath.slice(prefix.length) : rawPath;
|
|
2713
2786
|
const p = /^\/d\/([^/]+)(?:\/[^/]*)?\/?$/.exec(path);
|
|
2714
2787
|
if (!p) return null;
|
|
@@ -2732,12 +2805,12 @@ function decode(s) {
|
|
|
2732
2805
|
}
|
|
2733
2806
|
}
|
|
2734
2807
|
function applyDashboardLink(dashboard, target) {
|
|
2735
|
-
const time = target.from || target.to ? { from: target.from || _optionalChain([dashboard, 'access',
|
|
2736
|
-
const list = _optionalChain([dashboard, 'access',
|
|
2808
|
+
const time = target.from || target.to ? { from: target.from || _optionalChain([dashboard, 'access', _201 => _201.time, 'optionalAccess', _202 => _202.from]) || "now-6h", to: target.to || _optionalChain([dashboard, 'access', _203 => _203.time, 'optionalAccess', _204 => _204.to]) || "now" } : dashboard.time;
|
|
2809
|
+
const list = _optionalChain([dashboard, 'access', _205 => _205.templating, 'optionalAccess', _206 => _206.list, 'access', _207 => _207.map, 'call', _208 => _208((v) => {
|
|
2737
2810
|
const values = target.vars[v.name];
|
|
2738
|
-
if (!_optionalChain([values, 'optionalAccess',
|
|
2811
|
+
if (!_optionalChain([values, 'optionalAccess', _209 => _209.length])) return v;
|
|
2739
2812
|
const value = v.multi ? values : values[0];
|
|
2740
|
-
const text = (Array.isArray(value) ? value : [value]).map((x) => x === "$__all" ? "All" : _nullishCoalesce(_optionalChain([v, 'access',
|
|
2813
|
+
const text = (Array.isArray(value) ? value : [value]).map((x) => x === "$__all" ? "All" : _nullishCoalesce(_optionalChain([v, 'access', _210 => _210.options, 'optionalAccess', _211 => _211.find, 'call', _212 => _212((o) => o.value === x), 'optionalAccess', _213 => _213.text]), () => ( x)));
|
|
2741
2814
|
return { ...v, current: { text: v.multi ? text : text[0], value } };
|
|
2742
2815
|
})]);
|
|
2743
2816
|
return { ...dashboard, time, templating: list ? { ...dashboard.templating, list } : dashboard.templating };
|
|
@@ -8898,7 +8971,7 @@ function removeAt(root, pointer) {
|
|
|
8898
8971
|
const segs = pointer.split("/").slice(1).map((s) => s.replace(/~1/g, "/").replace(/~0/g, "~"));
|
|
8899
8972
|
const last = segs.pop();
|
|
8900
8973
|
let parent = root;
|
|
8901
|
-
for (const s of segs) parent = _optionalChain([parent, 'optionalAccess',
|
|
8974
|
+
for (const s of segs) parent = _optionalChain([parent, 'optionalAccess', _214 => _214[s]]);
|
|
8902
8975
|
if (Array.isArray(parent)) {
|
|
8903
8976
|
parent.splice(Number(last), 1);
|
|
8904
8977
|
return { array: parentOf(pointer), index: Number(last) };
|
|
@@ -9071,7 +9144,7 @@ var STANDARD = [
|
|
|
9071
9144
|
]
|
|
9072
9145
|
}
|
|
9073
9146
|
},
|
|
9074
|
-
{ path: field("color.fixedColor"), label: "Color", category: "Standard options", control: { kind: "color" }, showIf: (p) => _optionalChain([p, 'access',
|
|
9147
|
+
{ path: field("color.fixedColor"), label: "Color", category: "Standard options", control: { kind: "color" }, showIf: (p) => _optionalChain([p, 'access', _215 => _215.fieldConfig, 'optionalAccess', _216 => _216.defaults, 'optionalAccess', _217 => _217.color, 'optionalAccess', _218 => _218.mode]) === "fixed" }
|
|
9075
9148
|
];
|
|
9076
9149
|
var THRESHOLDS = {
|
|
9077
9150
|
path: field("thresholds"),
|
|
@@ -9097,7 +9170,7 @@ var CALC = {
|
|
|
9097
9170
|
default: "lastNotNull",
|
|
9098
9171
|
control: { kind: "select", choices: Object.entries(REDUCER_LABELS).map(([value, label]) => ({ label, value })) },
|
|
9099
9172
|
stored: "string[]",
|
|
9100
|
-
get: (p) => _optionalChain([p, 'access',
|
|
9173
|
+
get: (p) => _optionalChain([p, 'access', _219 => _219.options, 'optionalAccess', _220 => _220.reduceOptions, 'optionalAccess', _221 => _221.calcs, 'optionalAccess', _222 => _222[0]]),
|
|
9101
9174
|
set: (p, v) => setOptionValue(p, "options.reduceOptions.calcs", v === void 0 ? void 0 : [v])
|
|
9102
9175
|
};
|
|
9103
9176
|
var LEGEND = {
|
|
@@ -9107,9 +9180,9 @@ var LEGEND = {
|
|
|
9107
9180
|
help: "When there are two or more series.",
|
|
9108
9181
|
default: true,
|
|
9109
9182
|
control: { kind: "boolean" },
|
|
9110
|
-
get: (p) => _optionalChain([p, 'access',
|
|
9183
|
+
get: (p) => _optionalChain([p, 'access', _223 => _223.options, 'optionalAccess', _224 => _224.legend, 'optionalAccess', _225 => _225.showLegend]) !== false && _optionalChain([p, 'access', _226 => _226.options, 'optionalAccess', _227 => _227.legend, 'optionalAccess', _228 => _228.displayMode]) !== "hidden",
|
|
9111
9184
|
// Grafana's older displayMode "hidden" would otherwise keep it hidden.
|
|
9112
|
-
set: (p, v) => setOptionValue(v ? setOptionValue(p, "options.legend.displayMode", _optionalChain([p, 'access',
|
|
9185
|
+
set: (p, v) => setOptionValue(v ? setOptionValue(p, "options.legend.displayMode", _optionalChain([p, 'access', _229 => _229.options, 'optionalAccess', _230 => _230.legend, 'optionalAccess', _231 => _231.displayMode]) === "hidden" ? void 0 : _optionalChain([p, 'access', _232 => _232.options, 'optionalAccess', _233 => _233.legend, 'optionalAccess', _234 => _234.displayMode])) : p, "options.legend.showLegend", v ? void 0 : false)
|
|
9113
9186
|
};
|
|
9114
9187
|
var AXIS_LABEL = { path: field("custom.axisLabel"), label: "Axis label", category: "Axis", control: { kind: "text" } };
|
|
9115
9188
|
var AXIS_PLACEMENT = {
|
|
@@ -9363,7 +9436,7 @@ function overrideProperties(type) {
|
|
|
9363
9436
|
return out;
|
|
9364
9437
|
}
|
|
9365
9438
|
function panelOverrides(panel) {
|
|
9366
|
-
const o = _optionalChain([panel, 'access',
|
|
9439
|
+
const o = _optionalChain([panel, 'access', _235 => _235.fieldConfig, 'optionalAccess', _236 => _236.overrides]);
|
|
9367
9440
|
return Array.isArray(o) ? o : [];
|
|
9368
9441
|
}
|
|
9369
9442
|
function setOverrides(panel, overrides) {
|
|
@@ -9411,7 +9484,7 @@ function prepareDashboard(json, file) {
|
|
|
9411
9484
|
});
|
|
9412
9485
|
dashboard.panels.forEach((p, i) => {
|
|
9413
9486
|
for (const r of cleanPanelOptions(p)) removed.push({ path: `panels[${i}]${r.path}`, message: r.message });
|
|
9414
|
-
_optionalChain([p, 'access',
|
|
9487
|
+
_optionalChain([p, 'access', _237 => _237.panels, 'optionalAccess', _238 => _238.forEach, 'call', _239 => _239((child, j) => {
|
|
9415
9488
|
for (const r of cleanPanelOptions(child)) removed.push({ path: `panels[${i}].panels[${j}]${r.path}`, message: r.message });
|
|
9416
9489
|
})]);
|
|
9417
9490
|
});
|
|
@@ -9434,7 +9507,7 @@ function groupIssues(dashboard) {
|
|
|
9434
9507
|
for (const { p, at } of located2) if (isInputPanel(p) && !recordedAt.has(p.options.metric)) recordedAt.set(p.options.metric, at);
|
|
9435
9508
|
for (const { p, at } of located2) {
|
|
9436
9509
|
if (p.type !== INPUT_GROUP) continue;
|
|
9437
|
-
const fields = _optionalChain([p, 'access',
|
|
9510
|
+
const fields = _optionalChain([p, 'access', _240 => _240.options, 'optionalAccess', _241 => _241.fields]);
|
|
9438
9511
|
if (!Array.isArray(fields) || !fields.length) {
|
|
9439
9512
|
out.push({ path: `${at}.options.fields`, message: "a group needs at least one field" });
|
|
9440
9513
|
continue;
|
|
@@ -9451,7 +9524,7 @@ function groupIssues(dashboard) {
|
|
|
9451
9524
|
else recordedAt.set(metric, fat);
|
|
9452
9525
|
mine.push(metric);
|
|
9453
9526
|
});
|
|
9454
|
-
const titleFrom = _optionalChain([p, 'access',
|
|
9527
|
+
const titleFrom = _optionalChain([p, 'access', _242 => _242.options, 'optionalAccess', _243 => _243.titleFrom]);
|
|
9455
9528
|
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` });
|
|
9456
9529
|
}
|
|
9457
9530
|
return out;
|
|
@@ -9462,7 +9535,7 @@ function panelProblem(p) {
|
|
|
9462
9535
|
const g = p.gridPos;
|
|
9463
9536
|
if (!isObject3(g) || !["x", "y", "w", "h"].every((k) => typeof g[k] === "number"))
|
|
9464
9537
|
return { at: ".gridPos", message: "must have numeric x, y, w and h", summary: "has no usable gridPos" };
|
|
9465
|
-
if (p.type.startsWith("input-") && p.type !== INPUT_GROUP && !nonEmptyString(_optionalChain([p, 'access',
|
|
9538
|
+
if (p.type.startsWith("input-") && p.type !== INPUT_GROUP && !nonEmptyString(_optionalChain([p, 'access', _244 => _244.options, 'optionalAccess', _245 => _245.metric]))) {
|
|
9466
9539
|
const message = `${p.type} needs a metric to record to`;
|
|
9467
9540
|
return { at: ".options.metric", message, summary: message };
|
|
9468
9541
|
}
|
|
@@ -9538,17 +9611,17 @@ function resolveUrl(base, rel) {
|
|
|
9538
9611
|
function httpFetchJson(options = {}) {
|
|
9539
9612
|
const seen = /* @__PURE__ */ new Map();
|
|
9540
9613
|
return async (url, { accept = "application/json", signal } = {}) => {
|
|
9541
|
-
const extra = await _asyncNullishCoalesce(await _optionalChain([options, 'access',
|
|
9614
|
+
const extra = await _asyncNullishCoalesce(await _optionalChain([options, 'access', _246 => _246.headers, 'optionalCall', _247 => _247()]), async () => ( {}));
|
|
9542
9615
|
const key = JSON.stringify([url, accept, extra]);
|
|
9543
9616
|
const last = seen.get(key);
|
|
9544
9617
|
const get = (etag2) => fetch(url, { headers: { Accept: accept, ...extra, ...etag2 && { "If-None-Match": etag2 } }, cache: "no-store", signal });
|
|
9545
|
-
const res = await get(_optionalChain([last, 'optionalAccess',
|
|
9546
|
-
if (!last || _optionalChain([signal, 'optionalAccess',
|
|
9618
|
+
const res = await get(_optionalChain([last, 'optionalAccess', _248 => _248.etag])).catch((e) => {
|
|
9619
|
+
if (!last || _optionalChain([signal, 'optionalAccess', _249 => _249.aborted])) throw e;
|
|
9547
9620
|
seen.delete(key);
|
|
9548
9621
|
return get();
|
|
9549
9622
|
});
|
|
9550
9623
|
if (res.status === 304 && last) return last.json;
|
|
9551
|
-
if (!res.ok) throw new Error(_nullishCoalesce(_optionalChain([options, 'access',
|
|
9624
|
+
if (!res.ok) throw new Error(_nullishCoalesce(_optionalChain([options, 'access', _250 => _250.httpError, 'optionalCall', _251 => _251(res.status)]), () => ( `HTTP ${res.status}`)));
|
|
9552
9625
|
const json = JSON.parse(await res.text());
|
|
9553
9626
|
const etag = res.headers.get("ETag");
|
|
9554
9627
|
if (etag) seen.set(key, { etag, json });
|
|
@@ -9670,8 +9743,8 @@ var ConfigLoader = (_class2 = class {
|
|
|
9670
9743
|
async start() {
|
|
9671
9744
|
const { url, cache: cache2 } = this.options;
|
|
9672
9745
|
if (!url) return;
|
|
9673
|
-
const cached = await _optionalChain([cache2, 'optionalAccess',
|
|
9674
|
-
const bundle = _optionalChain([cached, 'optionalAccess',
|
|
9746
|
+
const cached = await _optionalChain([cache2, 'optionalAccess', _252 => _252.read, 'call', _253 => _253(), 'access', _254 => _254.catch, 'call', _255 => _255(() => null)]);
|
|
9747
|
+
const bundle = _optionalChain([cached, 'optionalAccess', _256 => _256.url]) === url ? revalidateBundle(cached.bundle) : void 0;
|
|
9675
9748
|
if (cached && bundle && !this.snapshot.fetchedAt) {
|
|
9676
9749
|
this.lastJson = JSON.stringify(bundle);
|
|
9677
9750
|
this.set({ bundle, source: "cache", fetchedAt: cached.fetchedAt, revision: cached.revision });
|
|
@@ -9701,7 +9774,7 @@ var ConfigLoader = (_class2 = class {
|
|
|
9701
9774
|
if (!bundle) {
|
|
9702
9775
|
const errors = issues.filter((i) => i.severity === "error").length;
|
|
9703
9776
|
const needsUpdate = issues.some((i) => i.code === "newer-version");
|
|
9704
|
-
const error = unreachable ? _optionalChain([issues, 'access',
|
|
9777
|
+
const error = unreachable ? _optionalChain([issues, 'access', _257 => _257[0], 'optionalAccess', _258 => _258.message]) : needsUpdate ? "a newer format" : errors === 1 ? "1 error" : `${errors} errors`;
|
|
9705
9778
|
return this.set(
|
|
9706
9779
|
{ loading: false, error, unreachable: !!unreachable, needsUpdate, issues },
|
|
9707
9780
|
this.snapshot.loading || error !== this.snapshot.error || !!unreachable !== !!this.snapshot.unreachable || needsUpdate !== !!this.snapshot.needsUpdate || !sameIssues(issues, this.snapshot.issues)
|
|
@@ -9711,7 +9784,7 @@ var ConfigLoader = (_class2 = class {
|
|
|
9711
9784
|
const changed = json !== this.lastJson;
|
|
9712
9785
|
this.lastJson = json;
|
|
9713
9786
|
const fetchedAt = Date.now();
|
|
9714
|
-
if (changed || revision !== this.snapshot.revision) _optionalChain([cache2, 'optionalAccess',
|
|
9787
|
+
if (changed || revision !== this.snapshot.revision) _optionalChain([cache2, 'optionalAccess', _259 => _259.write, 'call', _260 => _260({ url, fetchedAt, bundle, revision }), 'access', _261 => _261.catch, 'call', _262 => _262(() => {
|
|
9715
9788
|
})]);
|
|
9716
9789
|
this.set(
|
|
9717
9790
|
{ ...changed && { bundle }, source: "remote", fetchedAt, revision, loading: false, error: void 0, unreachable: void 0, needsUpdate: void 0, issues },
|
|
@@ -9728,7 +9801,7 @@ var ConfigLoader = (_class2 = class {
|
|
|
9728
9801
|
/** Stops the loader: cancels a fetch in flight, and nothing it does afterwards changes the state or the cache. */
|
|
9729
9802
|
dispose() {
|
|
9730
9803
|
this.disposed = true;
|
|
9731
|
-
_optionalChain([this, 'access',
|
|
9804
|
+
_optionalChain([this, 'access', _263 => _263.controller, 'optionalAccess', _264 => _264.abort, 'call', _265 => _265()]);
|
|
9732
9805
|
this.listeners.clear();
|
|
9733
9806
|
}
|
|
9734
9807
|
/** `notify: false` drops the patch, so the snapshot only changes when listeners hear about it. */
|
|
@@ -9749,7 +9822,7 @@ function tabIdFor(title, taken) {
|
|
|
9749
9822
|
}
|
|
9750
9823
|
function screenOfType(type, from, docs) {
|
|
9751
9824
|
const shown = from ? screenDocuments(from) : [];
|
|
9752
|
-
const firstOf = (ids) => _nullishCoalesce(_nullishCoalesce(_optionalChain([shown, 'access',
|
|
9825
|
+
const firstOf = (ids) => _nullishCoalesce(_nullishCoalesce(_optionalChain([shown, 'access', _266 => _266.find, 'call', _267 => _267((d) => ids.includes(d.id)), 'optionalAccess', _268 => _268.id]), () => ( ids[0])), () => ( ""));
|
|
9753
9826
|
switch (type) {
|
|
9754
9827
|
case "dashboard":
|
|
9755
9828
|
return { type, dashboard: firstOf(docs.dashboards) };
|
|
@@ -9762,7 +9835,7 @@ function screenOfType(type, from, docs) {
|
|
|
9762
9835
|
}
|
|
9763
9836
|
}
|
|
9764
9837
|
function screenDocuments(screen) {
|
|
9765
|
-
switch (_optionalChain([screen, 'optionalAccess',
|
|
9838
|
+
switch (_optionalChain([screen, 'optionalAccess', _269 => _269.type])) {
|
|
9766
9839
|
case "dashboard":
|
|
9767
9840
|
return [{ id: screen.dashboard, kind: "dashboard" }];
|
|
9768
9841
|
case "forms":
|
|
@@ -11177,8 +11250,8 @@ function removeNode(text, path) {
|
|
|
11177
11250
|
const tree = parseTree2(text);
|
|
11178
11251
|
const value = tree && findNodeAtLocation2(tree, path);
|
|
11179
11252
|
if (!value) return text;
|
|
11180
|
-
const node = _optionalChain([value, 'access',
|
|
11181
|
-
const siblings = _nullishCoalesce(_optionalChain([node, 'access',
|
|
11253
|
+
const node = _optionalChain([value, 'access', _270 => _270.parent, 'optionalAccess', _271 => _271.type]) === "property" ? value.parent : value;
|
|
11254
|
+
const siblings = _nullishCoalesce(_optionalChain([node, 'access', _272 => _272.parent, 'optionalAccess', _273 => _273.children]), () => ( []));
|
|
11182
11255
|
const i = siblings.indexOf(node);
|
|
11183
11256
|
const next = siblings[i + 1];
|
|
11184
11257
|
const prev = siblings[i - 1];
|
|
@@ -11261,20 +11334,20 @@ function removeDocumentFromManifest(text, id) {
|
|
|
11261
11334
|
const edits = [];
|
|
11262
11335
|
const removedTabs = [];
|
|
11263
11336
|
for (let i = tabs.length - 1; i >= 0; i--) {
|
|
11264
|
-
const screen = _optionalChain([tabs, 'access',
|
|
11337
|
+
const screen = _optionalChain([tabs, 'access', _274 => _274[i], 'optionalAccess', _275 => _275.screen]);
|
|
11265
11338
|
const at = ["tabs", i, "screen"];
|
|
11266
11339
|
const removeTab = () => {
|
|
11267
11340
|
edits.push({ path: ["tabs", i], remove: true });
|
|
11268
11341
|
removedTabs.unshift(_nullishCoalesce(tabs[i].title, () => ( tabs[i].id)));
|
|
11269
11342
|
};
|
|
11270
|
-
if (_optionalChain([screen, 'optionalAccess',
|
|
11271
|
-
else if (_optionalChain([screen, 'optionalAccess',
|
|
11343
|
+
if (_optionalChain([screen, 'optionalAccess', _276 => _276.type]) === "dashboard" && screen.dashboard === id) removeTab();
|
|
11344
|
+
else if (_optionalChain([screen, 'optionalAccess', _277 => _277.type]) === "forms" && Array.isArray(screen.forms) && screen.forms.includes(id)) {
|
|
11272
11345
|
if (screen.forms.every((f) => f === id)) removeTab();
|
|
11273
11346
|
else for (let j = screen.forms.length - 1; j >= 0; j--) if (screen.forms[j] === id) edits.push({ path: [...at, "forms", j], remove: true });
|
|
11274
|
-
} else if (_optionalChain([screen, 'optionalAccess',
|
|
11347
|
+
} else if (_optionalChain([screen, 'optionalAccess', _278 => _278.type]) === "menu" && Array.isArray(screen.items))
|
|
11275
11348
|
for (let j = screen.items.length - 1; j >= 0; j--) {
|
|
11276
11349
|
const item = screen.items[j];
|
|
11277
|
-
if (_optionalChain([item, 'optionalAccess',
|
|
11350
|
+
if (_optionalChain([item, 'optionalAccess', _279 => _279.dashboard]) === id || _optionalChain([item, 'optionalAccess', _280 => _280.form]) === id) edits.push({ path: [...at, "items", j], remove: true });
|
|
11278
11351
|
}
|
|
11279
11352
|
}
|
|
11280
11353
|
if (tabs.length && removedTabs.length === tabs.length) throw new Error(`Every tab shows only "${id}". Add another tab first`);
|
|
@@ -11287,21 +11360,21 @@ function renameDocumentInManifest(text, from, to, path) {
|
|
|
11287
11360
|
if (to !== from && to in manifest.documents) throw new Error(`There\u2019s already a document "${to}"`);
|
|
11288
11361
|
const edits = [];
|
|
11289
11362
|
(Array.isArray(manifest.tabs) ? manifest.tabs : []).forEach((tab, i) => {
|
|
11290
|
-
const screen = _optionalChain([tab, 'optionalAccess',
|
|
11363
|
+
const screen = _optionalChain([tab, 'optionalAccess', _281 => _281.screen]);
|
|
11291
11364
|
const at = ["tabs", i, "screen"];
|
|
11292
|
-
if (_optionalChain([screen, 'optionalAccess',
|
|
11293
|
-
if (_optionalChain([screen, 'optionalAccess',
|
|
11365
|
+
if (_optionalChain([screen, 'optionalAccess', _282 => _282.type]) === "dashboard" && screen.dashboard === from) edits.push({ path: [...at, "dashboard"], value: to });
|
|
11366
|
+
if (_optionalChain([screen, 'optionalAccess', _283 => _283.type]) === "forms" && Array.isArray(screen.forms))
|
|
11294
11367
|
screen.forms.forEach((f, j) => f === from && edits.push({ path: [...at, "forms", j], value: to }));
|
|
11295
|
-
if (_optionalChain([screen, 'optionalAccess',
|
|
11368
|
+
if (_optionalChain([screen, 'optionalAccess', _284 => _284.type]) === "menu" && Array.isArray(screen.items))
|
|
11296
11369
|
screen.items.forEach((item, j) => {
|
|
11297
|
-
if (_optionalChain([item, 'optionalAccess',
|
|
11298
|
-
if (_optionalChain([item, 'optionalAccess',
|
|
11370
|
+
if (_optionalChain([item, 'optionalAccess', _285 => _285.dashboard]) === from) edits.push({ path: [...at, "items", j, "dashboard"], value: to });
|
|
11371
|
+
if (_optionalChain([item, 'optionalAccess', _286 => _286.form]) === from) edits.push({ path: [...at, "items", j, "form"], value: to });
|
|
11299
11372
|
});
|
|
11300
11373
|
});
|
|
11301
11374
|
if (path !== void 0) edits.push({ path: ["documents", from], value: path });
|
|
11302
11375
|
let out = applyJsonEdits(text, edits);
|
|
11303
11376
|
if (to !== from) {
|
|
11304
|
-
const key = _optionalChain([findNodeAtLocation2, 'call',
|
|
11377
|
+
const key = _optionalChain([findNodeAtLocation2, 'call', _287 => _287(parseTree2(out), ["documents", from]), 'optionalAccess', _288 => _288.parent, 'optionalAccess', _289 => _289.children, 'optionalAccess', _290 => _290[0]]);
|
|
11305
11378
|
if (key) out = out.slice(0, key.offset) + JSON.stringify(to) + out.slice(key.offset + key.length);
|
|
11306
11379
|
}
|
|
11307
11380
|
return out;
|
|
@@ -11322,7 +11395,7 @@ function inputs(text) {
|
|
|
11322
11395
|
if (d)
|
|
11323
11396
|
for (const p of d.panels.flatMap((x) => x.type === "row" ? [x, ..._nullishCoalesce(x.panels, () => ( []))] : [x])) {
|
|
11324
11397
|
if (typeof p.id !== "number") continue;
|
|
11325
|
-
if (isInputGroup(p)) p.options.fields.forEach((f, i) => typeof _optionalChain([f, 'optionalAccess',
|
|
11398
|
+
if (isInputGroup(p)) p.options.fields.forEach((f, i) => typeof _optionalChain([f, 'optionalAccess', _291 => _291.options, 'optionalAccess', _292 => _292.metric]) === "string" && out.set(`${p.id}.${i}`, { metric: f.options.metric, title: f.title }));
|
|
11326
11399
|
else if (isInputPanel(p)) out.set(String(p.id), { metric: p.options.metric, title: p.title });
|
|
11327
11400
|
}
|
|
11328
11401
|
} catch (e17) {
|
|
@@ -11332,7 +11405,7 @@ function inputs(text) {
|
|
|
11332
11405
|
function reads(text, metric) {
|
|
11333
11406
|
const d = parse2(text);
|
|
11334
11407
|
const panels = d ? d.panels.flatMap((p) => p.type === "row" ? [p, ..._nullishCoalesce(p.panels, () => ( []))] : [p]) : [];
|
|
11335
|
-
return panels.some((p) => (_nullishCoalesce(_optionalChain([p, 'optionalAccess',
|
|
11408
|
+
return panels.some((p) => (_nullishCoalesce(_optionalChain([p, 'optionalAccess', _293 => _293.targets]), () => ( []))).some((t) => t.metric === metric));
|
|
11336
11409
|
}
|
|
11337
11410
|
function metricChanges(before, after) {
|
|
11338
11411
|
const merged = { ...before, ...after };
|
|
@@ -11347,7 +11420,7 @@ function metricChanges(before, after) {
|
|
|
11347
11420
|
for (const [file, text] of Object.entries(after)) {
|
|
11348
11421
|
const old = inputs(before[file]);
|
|
11349
11422
|
for (const [id, input] of inputs(text))
|
|
11350
|
-
if (_optionalChain([old, 'access',
|
|
11423
|
+
if (_optionalChain([old, 'access', _294 => _294.get, 'call', _295 => _295(id), 'optionalAccess', _296 => _296.metric]) === metric && input.metric !== metric) rename ??= { metric, renamedTo: input.metric, file, input: input.title, readBy };
|
|
11351
11424
|
}
|
|
11352
11425
|
changes.push(_nullishCoalesce(rename, () => ( { metric, readBy })));
|
|
11353
11426
|
}
|
|
@@ -11387,14 +11460,14 @@ function variableWithType(v, type) {
|
|
|
11387
11460
|
}
|
|
11388
11461
|
function currentFor(v, value) {
|
|
11389
11462
|
const options = variableOptions({ ...v, current: void 0 });
|
|
11390
|
-
const text = (x) => x === ALL ? "All" : _nullishCoalesce(_optionalChain([options, 'access',
|
|
11463
|
+
const text = (x) => x === ALL ? "All" : _nullishCoalesce(_optionalChain([options, 'access', _297 => _297.find, 'call', _298 => _298((o) => o.value === x), 'optionalAccess', _299 => _299.text]), () => ( x));
|
|
11391
11464
|
return Array.isArray(value) ? { text: value.map(text), value } : { text: text(value), value };
|
|
11392
11465
|
}
|
|
11393
11466
|
function variableWithQuery(v, query) {
|
|
11394
11467
|
const { options: _, current, ...rest } = v;
|
|
11395
11468
|
const next = { ...rest, query };
|
|
11396
11469
|
if (v.type === "textbox" || v.type === "constant") return { ...next, current: { text: query, value: query } };
|
|
11397
|
-
const value = selectValue(next, _optionalChain([current, 'optionalAccess',
|
|
11470
|
+
const value = selectValue(next, _optionalChain([current, 'optionalAccess', _300 => _300.value]), variableOptions(next));
|
|
11398
11471
|
return { ...next, current: currentFor(next, value) };
|
|
11399
11472
|
}
|
|
11400
11473
|
function variableWithCurrent(v, value) {
|
|
@@ -11404,13 +11477,13 @@ function variableWithFlags(v, flags) {
|
|
|
11404
11477
|
const next = { ...v, ...flags };
|
|
11405
11478
|
if (!next.multi) delete next.multi;
|
|
11406
11479
|
if (!next.includeAll) delete next.includeAll;
|
|
11407
|
-
const raw = _optionalChain([v, 'access',
|
|
11480
|
+
const raw = _optionalChain([v, 'access', _301 => _301.current, 'optionalAccess', _302 => _302.value]);
|
|
11408
11481
|
const current = next.multi ? raw == null ? [] : Array.isArray(raw) ? raw : [raw] : Array.isArray(raw) ? raw[0] : raw;
|
|
11409
11482
|
return variableWithCurrent(next, selectValue(next, current, variableOptions({ ...next, current: void 0 })));
|
|
11410
11483
|
}
|
|
11411
11484
|
var refers = (name, flags) => new RegExp(`\\$${name}\\b|\\$\\{${name}(:\\w+)?\\}|\\[\\[${name}(:\\w+)?\\]\\]`, flags);
|
|
11412
11485
|
function allPanels2(dashboard) {
|
|
11413
|
-
return (_nullishCoalesce(dashboard.panels, () => ( []))).flatMap((p) => _optionalChain([p, 'optionalAccess',
|
|
11486
|
+
return (_nullishCoalesce(dashboard.panels, () => ( []))).flatMap((p) => _optionalChain([p, 'optionalAccess', _303 => _303.type]) === "row" ? [p, ..._nullishCoalesce(p.panels, () => ( []))] : [p]).filter((p) => p && typeof p === "object");
|
|
11414
11487
|
}
|
|
11415
11488
|
function variableUses(dashboard, name) {
|
|
11416
11489
|
const re = refers(name);
|
|
@@ -11482,7 +11555,7 @@ function locate(text, tree, path) {
|
|
|
11482
11555
|
for (let n = segs.length; n >= 0; n--) {
|
|
11483
11556
|
const node = findNodeAtLocation2(tree, segs.slice(0, n));
|
|
11484
11557
|
if (!node) continue;
|
|
11485
|
-
const key = _optionalChain([node, 'access',
|
|
11558
|
+
const key = _optionalChain([node, 'access', _304 => _304.parent, 'optionalAccess', _305 => _305.type]) === "property" ? _optionalChain([node, 'access', _306 => _306.parent, 'access', _307 => _307.children, 'optionalAccess', _308 => _308[0]]) : void 0;
|
|
11486
11559
|
if ((node.type === "object" || node.type === "array") && key) return located(text, key.offset, key.length);
|
|
11487
11560
|
if (node.type === "object" || node.type === "array") return located(text, node.offset, 1);
|
|
11488
11561
|
return located(text, node.offset, node.length);
|
|
@@ -11616,7 +11689,7 @@ async function errorText(res) {
|
|
|
11616
11689
|
}
|
|
11617
11690
|
}
|
|
11618
11691
|
async function authHeaders(token) {
|
|
11619
|
-
const t = await _optionalChain([token, 'optionalCall',
|
|
11692
|
+
const t = await _optionalChain([token, 'optionalCall', _309 => _309()]);
|
|
11620
11693
|
return t ? { Authorization: `Bearer ${t}` } : {};
|
|
11621
11694
|
}
|
|
11622
11695
|
var HttpConfigFiles = (_class3 = class {
|
|
@@ -11722,14 +11795,14 @@ function fetchJsonWithToken(token) {
|
|
|
11722
11795
|
return httpFetchJson({ headers: () => authHeaders(token), httpError: (status) => status === 401 ? "not signed in" : `HTTP ${status}` });
|
|
11723
11796
|
}
|
|
11724
11797
|
async function readConfigFiles(source) {
|
|
11725
|
-
const all = await _optionalChain([source, 'access',
|
|
11798
|
+
const all = await _optionalChain([source, 'access', _310 => _310.readAll, 'optionalCall', _311 => _311()]);
|
|
11726
11799
|
const read = all ? async (p) => {
|
|
11727
11800
|
if (!(p in all)) throw new Error(NOT_FOUND);
|
|
11728
11801
|
return all[p];
|
|
11729
11802
|
} : (p) => source.read(p);
|
|
11730
11803
|
const files = { [source.manifestPath]: await read(source.manifestPath) };
|
|
11731
11804
|
const { value } = parseJsonText(files[source.manifestPath]);
|
|
11732
|
-
const documents = _nullishCoalesce(_optionalChain([value, 'optionalAccess',
|
|
11805
|
+
const documents = _nullishCoalesce(_optionalChain([value, 'optionalAccess', _312 => _312.documents]), () => ( {}));
|
|
11733
11806
|
const paths = [...new Set(Object.values(documents).filter((d) => typeof d === "string"))];
|
|
11734
11807
|
await Promise.all(
|
|
11735
11808
|
paths.map(async (p) => {
|
|
@@ -11783,7 +11856,7 @@ var CANVAS_ROW_HEADER = 32;
|
|
|
11783
11856
|
function panelSize(panel, mode) {
|
|
11784
11857
|
const p = pos(panel);
|
|
11785
11858
|
if (mode === "grid") return { span: clampW(p.w), h: clampH(p.h) };
|
|
11786
|
-
return { span: panelSpan(panel, "phone"), h: clampH(_nullishCoalesce(_optionalChain([panel, 'access',
|
|
11859
|
+
return { span: panelSpan(panel, "phone"), h: clampH(_nullishCoalesce(_optionalChain([panel, 'access', _313 => _313.mobile, 'optionalAccess', _314 => _314.h]), () => ( p.h))) };
|
|
11787
11860
|
}
|
|
11788
11861
|
function layoutCanvas(panels, order, mode, width, override) {
|
|
11789
11862
|
return mode === "grid" ? layoutGridCanvas(panels, width, override) : layoutPhoneCanvas(panels, order, width, override);
|
|
@@ -11803,7 +11876,7 @@ function layoutGridCanvas(panels, width, override) {
|
|
|
11803
11876
|
boxes = [...boxes];
|
|
11804
11877
|
boxes[override.index] = b;
|
|
11805
11878
|
}
|
|
11806
|
-
const settled = settleBoxes(boxes, _optionalChain([override, 'optionalAccess',
|
|
11879
|
+
const settled = settleBoxes(boxes, _optionalChain([override, 'optionalAccess', _315 => _315.index]));
|
|
11807
11880
|
const items = settled.map((b, index) => {
|
|
11808
11881
|
const row = isRow(panels[index]);
|
|
11809
11882
|
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 };
|
|
@@ -11847,12 +11920,12 @@ function layoutPhoneCanvas(panels, order, width, override) {
|
|
|
11847
11920
|
y += CANVAS_ROW_HEADER + CANVAS_GAP;
|
|
11848
11921
|
continue;
|
|
11849
11922
|
}
|
|
11850
|
-
if (mode === "phone" && _optionalChain([panel, 'access',
|
|
11923
|
+
if (mode === "phone" && _optionalChain([panel, 'access', _316 => _316.mobile, 'optionalAccess', _317 => _317.hidden])) {
|
|
11851
11924
|
hidden.push(index);
|
|
11852
11925
|
continue;
|
|
11853
11926
|
}
|
|
11854
11927
|
const natural = panelSize(panel, mode);
|
|
11855
|
-
const size = _optionalChain([override, 'optionalAccess',
|
|
11928
|
+
const size = _optionalChain([override, 'optionalAccess', _318 => _318.index]) === index ? { span: clampW(_nullishCoalesce(override.span, () => ( natural.span))), h: clampH(_nullishCoalesce(override.h, () => ( natural.h))) } : natural;
|
|
11856
11929
|
if (used + size.span > GRID_COLUMNS) flush();
|
|
11857
11930
|
line.push({ index, row: false, x: 0, y: 0, width: 0, height: 0, ...size });
|
|
11858
11931
|
used += size.span;
|
|
@@ -11870,7 +11943,7 @@ function dropTarget(canvas, x, y, dragging) {
|
|
|
11870
11943
|
for (const c of pool) if (distance(c) < distance(best)) best = c;
|
|
11871
11944
|
const after = best.row ? y > best.y + best.height / 2 : x > best.x + best.width / 2;
|
|
11872
11945
|
if (!after) return best.index;
|
|
11873
|
-
return _nullishCoalesce(_optionalChain([items, 'access',
|
|
11946
|
+
return _nullishCoalesce(_optionalChain([items, 'access', _319 => _319[items.indexOf(best) + 1], 'optionalAccess', _320 => _320.index]), () => ( null));
|
|
11874
11947
|
}
|
|
11875
11948
|
function movePanel(panels, index, before) {
|
|
11876
11949
|
if (before === index) return panels;
|
|
@@ -12082,9 +12155,9 @@ var refers2 = (name) => new RegExp(`\\$${name}\\b|\\$\\{${name}(:\\w+)?\\}|\\[\\
|
|
|
12082
12155
|
var withChildren = (p) => [p, ...isRow(p) ? _nullishCoalesce(p.panels, () => ( [])) : []];
|
|
12083
12156
|
function panelMetrics(p) {
|
|
12084
12157
|
const found = [];
|
|
12085
|
-
if (isInputType(p.type) && typeof _optionalChain([p, 'access',
|
|
12086
|
-
if (p.type === INPUT_GROUP && Array.isArray(_optionalChain([p, 'access',
|
|
12087
|
-
for (const f of p.options.fields) if (typeof _optionalChain([f, 'optionalAccess',
|
|
12158
|
+
if (isInputType(p.type) && typeof _optionalChain([p, 'access', _321 => _321.options, 'optionalAccess', _322 => _322.metric]) === "string") found.push(p.options.metric);
|
|
12159
|
+
if (p.type === INPUT_GROUP && Array.isArray(_optionalChain([p, 'access', _323 => _323.options, 'optionalAccess', _324 => _324.fields]))) {
|
|
12160
|
+
for (const f of p.options.fields) if (typeof _optionalChain([f, 'optionalAccess', _325 => _325.options, 'optionalAccess', _326 => _326.metric]) === "string") found.push(f.options.metric);
|
|
12088
12161
|
}
|
|
12089
12162
|
for (const t of _nullishCoalesce(p.targets, () => ( []))) if (typeof t.metric === "string" && t.metric && !t.metric.startsWith("$")) found.push(t.metric);
|
|
12090
12163
|
return found;
|
|
@@ -12092,15 +12165,15 @@ function panelMetrics(p) {
|
|
|
12092
12165
|
function renameMetrics(panels, map) {
|
|
12093
12166
|
const rename = (p) => {
|
|
12094
12167
|
let out = p;
|
|
12095
|
-
if (isInputType(p.type) && typeof _optionalChain([p, 'access',
|
|
12096
|
-
if (p.type === INPUT_GROUP && Array.isArray(_optionalChain([p, 'access',
|
|
12168
|
+
if (isInputType(p.type) && typeof _optionalChain([p, 'access', _327 => _327.options, 'optionalAccess', _328 => _328.metric]) === "string" && map[p.options.metric]) out = { ...out, options: { ...out.options, metric: map[p.options.metric] } };
|
|
12169
|
+
if (p.type === INPUT_GROUP && Array.isArray(_optionalChain([p, 'access', _329 => _329.options, 'optionalAccess', _330 => _330.fields]))) {
|
|
12097
12170
|
const to = (m) => typeof m === "string" && map[m] || m;
|
|
12098
|
-
const fields = p.options.fields.map((f) => _optionalChain([f, 'optionalAccess',
|
|
12171
|
+
const fields = p.options.fields.map((f) => _optionalChain([f, 'optionalAccess', _331 => _331.options]) && to(f.options.metric) !== f.options.metric ? { ...f, options: { ...f.options, metric: to(f.options.metric) } } : f);
|
|
12099
12172
|
const titleFrom = to(p.options.titleFrom);
|
|
12100
12173
|
out = { ...out, options: { ...out.options, fields, ...titleFrom !== void 0 && { titleFrom } } };
|
|
12101
12174
|
}
|
|
12102
|
-
if (_optionalChain([p, 'access',
|
|
12103
|
-
if (_optionalChain([p, 'access',
|
|
12175
|
+
if (_optionalChain([p, 'access', _332 => _332.targets, 'optionalAccess', _333 => _333.some, 'call', _334 => _334((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) };
|
|
12176
|
+
if (_optionalChain([p, 'access', _335 => _335.panels, 'optionalAccess', _336 => _336.length])) out = { ...out, panels: p.panels.map(rename) };
|
|
12104
12177
|
return out;
|
|
12105
12178
|
};
|
|
12106
12179
|
return panels.map(rename);
|
|
@@ -12120,7 +12193,7 @@ function copyPanels(dashboard, indices) {
|
|
|
12120
12193
|
}
|
|
12121
12194
|
}
|
|
12122
12195
|
const chosen = order.filter((i) => picked.has(i)).map((i) => panels[i]);
|
|
12123
|
-
return snippetOf(chosen, _nullishCoalesce(_optionalChain([dashboard, 'access',
|
|
12196
|
+
return snippetOf(chosen, _nullishCoalesce(_optionalChain([dashboard, 'access', _337 => _337.templating, 'optionalAccess', _338 => _338.list]), () => ( [])));
|
|
12124
12197
|
}
|
|
12125
12198
|
function snippetOf(panels, available) {
|
|
12126
12199
|
const left = Math.min(...panels.map((p) => pos2(p).x));
|
|
@@ -12188,7 +12261,7 @@ var sameVariable = (a, b) => {
|
|
|
12188
12261
|
return strip(a) === strip(b);
|
|
12189
12262
|
};
|
|
12190
12263
|
function previewPaste(dashboard, snippet) {
|
|
12191
|
-
const { added, renamed } = mergeVariables(_nullishCoalesce(_optionalChain([dashboard, 'access',
|
|
12264
|
+
const { added, renamed } = mergeVariables(_nullishCoalesce(_optionalChain([dashboard, 'access', _339 => _339.templating, 'optionalAccess', _340 => _340.list]), () => ( [])), snippet.variables);
|
|
12192
12265
|
return { added, renamed };
|
|
12193
12266
|
}
|
|
12194
12267
|
function mergeVariables(existing, incoming) {
|
|
@@ -12225,7 +12298,7 @@ function pasteSnippet(dashboard, snippet, options = {}) {
|
|
|
12225
12298
|
return true;
|
|
12226
12299
|
};
|
|
12227
12300
|
let incoming = snippet.panels.filter(keep).map((p) => p.panels ? { ...p, panels: p.panels.filter(keep) } : p);
|
|
12228
|
-
const { variables, added, renamed } = mergeVariables(_nullishCoalesce(_optionalChain([dashboard, 'access',
|
|
12301
|
+
const { variables, added, renamed } = mergeVariables(_nullishCoalesce(_optionalChain([dashboard, 'access', _341 => _341.templating, 'optionalAccess', _342 => _342.list]), () => ( [])), snippet.variables);
|
|
12229
12302
|
for (const [from, to] of Object.entries(renamed)) incoming = renameVariableInPanels(incoming, from, to);
|
|
12230
12303
|
if (options.metrics) incoming = renameMetrics(incoming, options.metrics);
|
|
12231
12304
|
const after = options.after != null ? existing[options.after] : void 0;
|
|
@@ -12290,7 +12363,7 @@ function parseTemplate(text) {
|
|
|
12290
12363
|
if (seen.has(d.id)) return { error: `Two documents are called "${d.id}"` };
|
|
12291
12364
|
seen.add(d.id);
|
|
12292
12365
|
const { dashboard, issues } = prepareDashboard(d.dashboard, d.id);
|
|
12293
|
-
if (!dashboard) return { error: `"${d.id}" can\u2019t be shown: ${_nullishCoalesce(_optionalChain([issues, 'access',
|
|
12366
|
+
if (!dashboard) return { error: `"${d.id}" can\u2019t be shown: ${_nullishCoalesce(_optionalChain([issues, 'access', _343 => _343.find, 'call', _344 => _344((x) => x.severity === "error"), 'optionalAccess', _345 => _345.message]), () => ( "it isn\u2019t a dashboard"))}` };
|
|
12294
12367
|
if (dashboard.kind && dashboard.kind !== d.kind) return { error: `"${d.id}" is listed as a ${d.kind} but says it\u2019s a ${dashboard.kind}` };
|
|
12295
12368
|
documents.push({ kind: d.kind, id: d.id, dashboard });
|
|
12296
12369
|
}
|
|
@@ -12368,9 +12441,9 @@ function applyTemplate(manifestText, paths, template, options = {}) {
|
|
|
12368
12441
|
}
|
|
12369
12442
|
const tabIds = (_nullishCoalesce(manifest.tabs, () => ( []))).map((t) => t.id);
|
|
12370
12443
|
const added = [];
|
|
12371
|
-
let at = _nullishCoalesce(_optionalChain([manifest, 'access',
|
|
12444
|
+
let at = _nullishCoalesce(_optionalChain([manifest, 'access', _346 => _346.tabs, 'optionalAccess', _347 => _347.length]), () => ( 0));
|
|
12372
12445
|
for (const tab of template.tabs) {
|
|
12373
|
-
if (!_optionalChain([options, 'access',
|
|
12446
|
+
if (!_optionalChain([options, 'access', _348 => _348.tabs, 'optionalAccess', _349 => _349.includes, 'call', _350 => _350(tab.id)])) continue;
|
|
12374
12447
|
const screen = retarget(tab.screen, ids);
|
|
12375
12448
|
if (!screen) continue;
|
|
12376
12449
|
const id = tabIdFor(tab.id, tabIds);
|
|
@@ -12437,7 +12510,18 @@ Chart panels read the app's entries with \`"datasource": { "type": "modelform-lo
|
|
|
12437
12510
|
|
|
12438
12511
|
Units and ranges go in \`"fieldConfig": { "defaults": { "unit": "\u2026", "min", "max", "decimals" } }\`. Units are Grafana's, e.g. "percent", "masskg", "lengthkm", "s", or "suffix: <text>" for anything else (\`"suffix: glasses"\`). Don't use trend, xychart or geomap panels.
|
|
12439
12512
|
|
|
12440
|
-
|
|
12513
|
+
To chart a value worked out from inputs saved together on one form, e.g. a ratio, query each input as its own target and add a \`calculateField\` transformation. Series are joined on time first, so the values of one save meet in one row:
|
|
12514
|
+
|
|
12515
|
+
\`\`\`
|
|
12516
|
+
"targets": [ { "refId": "A", "metric": "yield" }, { "refId": "B", "metric": "dose" } ],
|
|
12517
|
+
"transformations": [ { "id": "calculateField", "options": { "mode": "binary", "alias": "Ratio", "replaceFields": true,
|
|
12518
|
+
"binary": { "left": "yield", "operator": "/", "right": "dose" } } } ]
|
|
12519
|
+
\`\`\`
|
|
12520
|
+
|
|
12521
|
+
- \`left\` and \`right\` are a target's metric (its \`alias\` if it has one) or a number; operators are + - * / % ^. \`"replaceFields": true\` keeps only the result; leave it out to chart the inputs beside it.
|
|
12522
|
+
- \`"mode": "reduceRow"\` with \`"reduce": { "reducer": "sum" | "mean" | "min" | "max", "include": ["<metric>", \u2026] }\` combines several inputs instead, e.g. a total of three scores.
|
|
12523
|
+
- Give both targets the same \`aggregate\` and \`bucket\`, or neither. A save missing either value has no result.
|
|
12524
|
+
- It doesn't work for fields inside an input-group (weight \xD7 reps per set): every item of a save shares one time. Chart what's recorded there instead, or add a field for the combined value, and say which you did in the sentence before the JSON.
|
|
12441
12525
|
|
|
12442
12526
|
`;
|
|
12443
12527
|
var AUTHORING_GUIDE = `# modelform templates
|
|
@@ -12594,7 +12678,7 @@ function readTemplateAnswer(text) {
|
|
|
12594
12678
|
);
|
|
12595
12679
|
const kept = new Set(template.tabs.map((t) => t.id));
|
|
12596
12680
|
for (const [i, tab] of (Array.isArray(raw.tabs) ? raw.tabs : []).entries()) {
|
|
12597
|
-
const id = _optionalChain([tab, 'optionalAccess',
|
|
12681
|
+
const id = _optionalChain([tab, 'optionalAccess', _351 => _351.id]);
|
|
12598
12682
|
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`);
|
|
12599
12683
|
}
|
|
12600
12684
|
const kinds = new Map(template.documents.map((d) => [d.id, d.kind]));
|
|
@@ -12642,9 +12726,9 @@ function readDocumentAnswer(text, kind) {
|
|
|
12642
12726
|
return { error: e.message };
|
|
12643
12727
|
}
|
|
12644
12728
|
const wrapper = json;
|
|
12645
|
-
if (_optionalChain([wrapper, 'optionalAccess',
|
|
12729
|
+
if (_optionalChain([wrapper, 'optionalAccess', _352 => _352.$modelform]) === "template") {
|
|
12646
12730
|
if (!Array.isArray(wrapper.documents) || wrapper.documents.length !== 1) return { error: `That\u2019s a template, not one ${kind}` };
|
|
12647
|
-
json = _optionalChain([wrapper, 'access',
|
|
12731
|
+
json = _optionalChain([wrapper, 'access', _353 => _353.documents, 'access', _354 => _354[0], 'optionalAccess', _355 => _355.dashboard]);
|
|
12648
12732
|
}
|
|
12649
12733
|
if (!json || typeof json !== "object" || Array.isArray(json)) return { error: `That isn\u2019t a ${kind}` };
|
|
12650
12734
|
const raw = json;
|
|
@@ -12683,8 +12767,8 @@ function documentChanges(before, after) {
|
|
|
12683
12767
|
const what = [];
|
|
12684
12768
|
if (was.title !== p.title) what.push("title");
|
|
12685
12769
|
if (was.type !== p.type) what.push("type");
|
|
12686
|
-
if (_optionalChain([was, 'access',
|
|
12687
|
-
if (_optionalChain([was, 'access',
|
|
12770
|
+
if (_optionalChain([was, 'access', _356 => _356.gridPos, 'optionalAccess', _357 => _357.x]) !== _optionalChain([p, 'access', _358 => _358.gridPos, 'optionalAccess', _359 => _359.x]) || _optionalChain([was, 'access', _360 => _360.gridPos, 'optionalAccess', _361 => _361.y]) !== _optionalChain([p, 'access', _362 => _362.gridPos, 'optionalAccess', _363 => _363.y])) what.push("position");
|
|
12771
|
+
if (_optionalChain([was, 'access', _364 => _364.gridPos, 'optionalAccess', _365 => _365.w]) !== _optionalChain([p, 'access', _366 => _366.gridPos, 'optionalAccess', _367 => _367.w]) || _optionalChain([was, 'access', _368 => _368.gridPos, 'optionalAccess', _369 => _369.h]) !== _optionalChain([p, 'access', _370 => _370.gridPos, 'optionalAccess', _371 => _371.h])) what.push("size");
|
|
12688
12772
|
if (!same(was.options, p.options)) what.push("options");
|
|
12689
12773
|
if (!same(was.targets, p.targets) || !same(was.datasource, p.datasource) || !same(was.transformations, p.transformations)) what.push("queries");
|
|
12690
12774
|
if (!same(was.fieldConfig, p.fieldConfig)) what.push("field config");
|