@modelform/react-native 0.10.0 → 0.12.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 CHANGED
@@ -13,9 +13,11 @@ same format. One JSON model describes both what an app records and how it charts
13
13
  - **Datasources:** a local one over recorded entries, and a Grafana one that runs panel queries through a Grafana
14
14
  instance's HTTP API. You can also implement your own.
15
15
  - **Configs:** a manifest format for whole apps (tabs, forms and dashboards), with JSON Schemas, validation that
16
- reports issues instead of throwing, and a loader with caching and last-good fallback.
16
+ reports issues instead of throwing, and a loader with caching and last-good fallback. A manifest's `version` is the
17
+ oldest format that can show it; an app older than that gets `needsUpdate` and keeps its last good config.
17
18
  - **AI assistants:** `templatePrompt()` writes a prompt for making a template with any assistant (Claude, ChatGPT…),
18
- and `readTemplateAnswer()` reads the template back out of its reply. Nothing calls a model.
19
+ and `readTemplateAnswer()` reads the template back out of its reply. `documentPrompt()` and `readDocumentAnswer()` do
20
+ the same for changing one form or dashboard, and `documentChanges()` lists what a change does. Nothing calls a model.
19
21
 
20
22
  modelform is not affiliated with or endorsed by Grafana Labs. It reads the dashboard JSON model that Grafana
21
23
  exports, and ignores keys it doesn't understand.
@@ -1981,8 +1981,9 @@ var app_schema_default = {
1981
1981
  type: "object",
1982
1982
  properties: {
1983
1983
  version: {
1984
- description: "Format version. Always 1 for now.",
1985
- const: 1
1984
+ type: "integer",
1985
+ description: "The oldest config format that can show this config: 1 unless it uses something newer (see MANIFEST_VERSION). An app that reads only older formats asks to be updated instead.",
1986
+ minimum: 1
1986
1987
  },
1987
1988
  title: {
1988
1989
  type: "string",
@@ -7452,8 +7453,9 @@ function validate11(data, { instancePath = "", parentData, parentDataProperty, r
7452
7453
  }
7453
7454
  }
7454
7455
  if (data.version !== void 0) {
7455
- if (1 !== data.version) {
7456
- const err5 = { instancePath: instancePath + "/version", schemaPath: "#/properties/version/const", keyword: "const", params: { allowedValue: 1 }, message: "must be equal to constant" };
7456
+ let data0 = data.version;
7457
+ if (!(typeof data0 == "number" && (!(data0 % 1) && !isNaN(data0)))) {
7458
+ const err5 = { instancePath: instancePath + "/version", schemaPath: "#/properties/version/type", keyword: "type", params: { type: "integer" }, message: "must be integer" };
7457
7459
  if (vErrors === null) {
7458
7460
  vErrors = [err5];
7459
7461
  } else {
@@ -7461,25 +7463,36 @@ function validate11(data, { instancePath = "", parentData, parentDataProperty, r
7461
7463
  }
7462
7464
  errors++;
7463
7465
  }
7466
+ if (typeof data0 == "number") {
7467
+ if (data0 < 1 || isNaN(data0)) {
7468
+ const err6 = { instancePath: instancePath + "/version", schemaPath: "#/properties/version/minimum", keyword: "minimum", params: { comparison: ">=", limit: 1 }, message: "must be >= 1" };
7469
+ if (vErrors === null) {
7470
+ vErrors = [err6];
7471
+ } else {
7472
+ vErrors.push(err6);
7473
+ }
7474
+ errors++;
7475
+ }
7476
+ }
7464
7477
  }
7465
7478
  if (data.title !== void 0) {
7466
7479
  let data1 = data.title;
7467
7480
  if (typeof data1 === "string") {
7468
7481
  if (func2(data1) < 1) {
7469
- const err6 = { instancePath: instancePath + "/title", schemaPath: "#/properties/title/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
7482
+ const err7 = { instancePath: instancePath + "/title", schemaPath: "#/properties/title/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters" };
7470
7483
  if (vErrors === null) {
7471
- vErrors = [err6];
7484
+ vErrors = [err7];
7472
7485
  } else {
7473
- vErrors.push(err6);
7486
+ vErrors.push(err7);
7474
7487
  }
7475
7488
  errors++;
7476
7489
  }
7477
7490
  } else {
7478
- const err7 = { instancePath: instancePath + "/title", schemaPath: "#/properties/title/type", keyword: "type", params: { type: "string" }, message: "must be string" };
7491
+ const err8 = { instancePath: instancePath + "/title", schemaPath: "#/properties/title/type", keyword: "type", params: { type: "string" }, message: "must be string" };
7479
7492
  if (vErrors === null) {
7480
- vErrors = [err7];
7493
+ vErrors = [err8];
7481
7494
  } else {
7482
- vErrors.push(err7);
7495
+ vErrors.push(err8);
7483
7496
  }
7484
7497
  errors++;
7485
7498
  }
@@ -7488,11 +7501,11 @@ function validate11(data, { instancePath = "", parentData, parentDataProperty, r
7488
7501
  let data2 = data.tabs;
7489
7502
  if (Array.isArray(data2)) {
7490
7503
  if (data2.length < 1) {
7491
- const err8 = { instancePath: instancePath + "/tabs", schemaPath: "#/properties/tabs/minItems", keyword: "minItems", params: { limit: 1 }, message: "must NOT have fewer than 1 items" };
7504
+ const err9 = { instancePath: instancePath + "/tabs", schemaPath: "#/properties/tabs/minItems", keyword: "minItems", params: { limit: 1 }, message: "must NOT have fewer than 1 items" };
7492
7505
  if (vErrors === null) {
7493
- vErrors = [err8];
7506
+ vErrors = [err9];
7494
7507
  } else {
7495
- vErrors.push(err8);
7508
+ vErrors.push(err9);
7496
7509
  }
7497
7510
  errors++;
7498
7511
  }
@@ -7504,11 +7517,11 @@ function validate11(data, { instancePath = "", parentData, parentDataProperty, r
7504
7517
  }
7505
7518
  }
7506
7519
  } else {
7507
- const err9 = { instancePath: instancePath + "/tabs", schemaPath: "#/properties/tabs/type", keyword: "type", params: { type: "array" }, message: "must be array" };
7520
+ const err10 = { instancePath: instancePath + "/tabs", schemaPath: "#/properties/tabs/type", keyword: "type", params: { type: "array" }, message: "must be array" };
7508
7521
  if (vErrors === null) {
7509
- vErrors = [err9];
7522
+ vErrors = [err10];
7510
7523
  } else {
7511
- vErrors.push(err9);
7524
+ vErrors.push(err10);
7512
7525
  }
7513
7526
  errors++;
7514
7527
  }
@@ -7518,42 +7531,42 @@ function validate11(data, { instancePath = "", parentData, parentDataProperty, r
7518
7531
  if (data4 && typeof data4 == "object" && !Array.isArray(data4)) {
7519
7532
  for (const key1 in data4) {
7520
7533
  let data5 = data4[key1];
7521
- const _errs12 = errors;
7522
- let valid4 = false;
7523
7534
  const _errs13 = errors;
7535
+ let valid4 = false;
7536
+ const _errs14 = errors;
7524
7537
  if (typeof data5 !== "string") {
7525
- const err10 = { instancePath: instancePath + "/documents/" + key1.replace(/~/g, "~0").replace(/\//g, "~1"), schemaPath: "#/properties/documents/additionalProperties/anyOf/0/type", keyword: "type", params: { type: "string" }, message: "must be string" };
7538
+ const err11 = { instancePath: instancePath + "/documents/" + key1.replace(/~/g, "~0").replace(/\//g, "~1"), schemaPath: "#/properties/documents/additionalProperties/anyOf/0/type", keyword: "type", params: { type: "string" }, message: "must be string" };
7526
7539
  if (vErrors === null) {
7527
- vErrors = [err10];
7540
+ vErrors = [err11];
7528
7541
  } else {
7529
- vErrors.push(err10);
7542
+ vErrors.push(err11);
7530
7543
  }
7531
7544
  errors++;
7532
7545
  }
7533
- var _valid0 = _errs13 === errors;
7546
+ var _valid0 = _errs14 === errors;
7534
7547
  valid4 = valid4 || _valid0;
7535
7548
  if (!valid4) {
7536
- const _errs15 = errors;
7549
+ const _errs16 = errors;
7537
7550
  if (!validate36(data5, { instancePath: instancePath + "/documents/" + key1.replace(/~/g, "~0").replace(/\//g, "~1"), parentData: data4, parentDataProperty: key1, rootData })) {
7538
7551
  vErrors = vErrors === null ? validate36.errors : vErrors.concat(validate36.errors);
7539
7552
  errors = vErrors.length;
7540
7553
  }
7541
- var _valid0 = _errs15 === errors;
7554
+ var _valid0 = _errs16 === errors;
7542
7555
  valid4 = valid4 || _valid0;
7543
7556
  }
7544
7557
  if (!valid4) {
7545
- const err11 = { instancePath: instancePath + "/documents/" + key1.replace(/~/g, "~0").replace(/\//g, "~1"), schemaPath: "#/properties/documents/additionalProperties/anyOf", keyword: "anyOf", params: {}, message: "must match a schema in anyOf" };
7558
+ const err12 = { instancePath: instancePath + "/documents/" + key1.replace(/~/g, "~0").replace(/\//g, "~1"), schemaPath: "#/properties/documents/additionalProperties/anyOf", keyword: "anyOf", params: {}, message: "must match a schema in anyOf" };
7546
7559
  if (vErrors === null) {
7547
- vErrors = [err11];
7560
+ vErrors = [err12];
7548
7561
  } else {
7549
- vErrors.push(err11);
7562
+ vErrors.push(err12);
7550
7563
  }
7551
7564
  errors++;
7552
7565
  } else {
7553
- errors = _errs12;
7566
+ errors = _errs13;
7554
7567
  if (vErrors !== null) {
7555
- if (_errs12) {
7556
- vErrors.length = _errs12;
7568
+ if (_errs13) {
7569
+ vErrors.length = _errs13;
7557
7570
  } else {
7558
7571
  vErrors = null;
7559
7572
  }
@@ -7561,21 +7574,21 @@ function validate11(data, { instancePath = "", parentData, parentDataProperty, r
7561
7574
  }
7562
7575
  }
7563
7576
  } else {
7564
- const err12 = { instancePath: instancePath + "/documents", schemaPath: "#/properties/documents/type", keyword: "type", params: { type: "object" }, message: "must be object" };
7577
+ const err13 = { instancePath: instancePath + "/documents", schemaPath: "#/properties/documents/type", keyword: "type", params: { type: "object" }, message: "must be object" };
7565
7578
  if (vErrors === null) {
7566
- vErrors = [err12];
7579
+ vErrors = [err13];
7567
7580
  } else {
7568
- vErrors.push(err12);
7581
+ vErrors.push(err13);
7569
7582
  }
7570
7583
  errors++;
7571
7584
  }
7572
7585
  }
7573
7586
  } else {
7574
- const err13 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
7587
+ const err14 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
7575
7588
  if (vErrors === null) {
7576
- vErrors = [err13];
7589
+ vErrors = [err14];
7577
7590
  } else {
7578
- vErrors.push(err13);
7591
+ vErrors.push(err14);
7579
7592
  }
7580
7593
  errors++;
7581
7594
  }
@@ -8559,10 +8572,16 @@ function setOverrides(panel, overrides) {
8559
8572
 
8560
8573
  // src/core/manifest.ts
8561
8574
  var MANIFEST_VERSION = 1;
8575
+ var FORMAT_CHANGES = [];
8576
+ function requiredManifestVersion(bundle) {
8577
+ return Math.max(1, ...FORMAT_CHANGES.filter((c) => c.uses(bundle)).map((c) => c.version));
8578
+ }
8562
8579
  var isObject3 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
8563
8580
  var nonEmptyString = (v) => typeof v === "string" && v.trim() !== "";
8564
8581
  function validateManifest(json, file = "manifest") {
8565
8582
  const error = (path, message) => ({ severity: "error", path: `${file}: ${path}`, message });
8583
+ if (isObject3(json) && typeof json.version === "number" && json.version > MANIFEST_VERSION)
8584
+ return [{ ...error("version", `needs config format ${json.version}, and this app shows up to ${MANIFEST_VERSION}. Update the app to open it.`), code: "newer-version" }];
8566
8585
  const shape = manifestSchemaIssues(json).filter((i) => !/^documents\.[^.[]+[.[]/.test(i.path));
8567
8586
  if (shape.length) return shape.map((i) => error(i.path, i.message));
8568
8587
  const issues = [];
@@ -8881,10 +8900,11 @@ var ConfigLoader = (_class2 = class {
8881
8900
  const { bundle, issues, revision, unreachable } = result;
8882
8901
  if (!bundle) {
8883
8902
  const errors = issues.filter((i) => i.severity === "error").length;
8884
- const error = unreachable ? _optionalChain([issues, 'access', _238 => _238[0], 'optionalAccess', _239 => _239.message]) : errors === 1 ? "1 error" : `${errors} errors`;
8903
+ const needsUpdate = issues.some((i) => i.code === "newer-version");
8904
+ const error = unreachable ? _optionalChain([issues, 'access', _238 => _238[0], 'optionalAccess', _239 => _239.message]) : needsUpdate ? "a newer format" : errors === 1 ? "1 error" : `${errors} errors`;
8885
8905
  return this.set(
8886
- { loading: false, error, unreachable: !!unreachable, issues },
8887
- this.snapshot.loading || error !== this.snapshot.error || !!unreachable !== !!this.snapshot.unreachable || !sameIssues(issues, this.snapshot.issues)
8906
+ { loading: false, error, unreachable: !!unreachable, needsUpdate, issues },
8907
+ this.snapshot.loading || error !== this.snapshot.error || !!unreachable !== !!this.snapshot.unreachable || needsUpdate !== !!this.snapshot.needsUpdate || !sameIssues(issues, this.snapshot.issues)
8888
8908
  );
8889
8909
  }
8890
8910
  const json = JSON.stringify(bundle);
@@ -8894,8 +8914,8 @@ var ConfigLoader = (_class2 = class {
8894
8914
  if (changed || revision !== this.snapshot.revision) _optionalChain([cache2, 'optionalAccess', _240 => _240.write, 'call', _241 => _241({ url, fetchedAt, bundle, revision }), 'access', _242 => _242.catch, 'call', _243 => _243(() => {
8895
8915
  })]);
8896
8916
  this.set(
8897
- { ...changed && { bundle }, source: "remote", fetchedAt, revision, loading: false, error: void 0, unreachable: void 0, issues },
8898
- changed || revision !== this.snapshot.revision || this.snapshot.source !== "remote" || !!this.snapshot.error || this.snapshot.loading || !sameIssues(issues, this.snapshot.issues)
8917
+ { ...changed && { bundle }, source: "remote", fetchedAt, revision, loading: false, error: void 0, unreachable: void 0, needsUpdate: void 0, issues },
8918
+ changed || revision !== this.snapshot.revision || this.snapshot.source !== "remote" || !!this.snapshot.error || !!this.snapshot.needsUpdate || this.snapshot.loading || !sameIssues(issues, this.snapshot.issues)
8899
8919
  );
8900
8920
  } finally {
8901
8921
  clearTimeout(timer);
@@ -11377,10 +11397,10 @@ function mergeVariables(existing, incoming) {
11377
11397
  const renamed = {};
11378
11398
  const out = [...existing];
11379
11399
  for (const v of incoming) {
11380
- const same = existing.find((e) => e.name === v.name);
11381
- if (same && sameVariable(same, v)) continue;
11400
+ const same2 = existing.find((e) => e.name === v.name);
11401
+ if (same2 && sameVariable(same2, v)) continue;
11382
11402
  let name = v.name;
11383
- if (same) {
11403
+ if (same2) {
11384
11404
  let n = 2;
11385
11405
  while (taken.has(`${v.name}_${n}`)) n++;
11386
11406
  name = `${v.name}_${n}`;
@@ -11568,24 +11588,9 @@ function applyTemplate(manifestText, paths, template, options = {}) {
11568
11588
  }
11569
11589
 
11570
11590
  // src/core/authoring.ts
11571
- var AUTHORING_GUIDE = `# modelform templates
11591
+ var DOCUMENT_GUIDE = `## Documents
11572
11592
 
11573
- A template is JSON that adds forms (for recording entries) and dashboards (for charting them) to an app, plus tabs to show them.
11574
-
11575
- \`\`\`
11576
- {
11577
- "$modelform": "template",
11578
- "version": 1,
11579
- "title": "Short name",
11580
- "description": "One sentence on what it's for.",
11581
- "documents": [ { "kind": "form" | "dashboard", "id": "letters-digits-dashes", "dashboard": { ...document } } ],
11582
- "tabs": [ ...tabs ]
11583
- }
11584
- \`\`\`
11585
-
11586
- ## Documents
11587
-
11588
- A document is a subset of Grafana's dashboard JSON: \`{ "kind": "form" | "dashboard", "title": "\u2026", "panels": [ \u2026 ] }\`, and dashboards add \`"time": { "from": "now-30d", "to": "now" }\`. Its \`kind\` matches its entry in \`documents\`.
11593
+ A document is a subset of Grafana's dashboard JSON: \`{ "kind": "form" | "dashboard", "title": "\u2026", "panels": [ \u2026 ] }\`, and dashboards add \`"time": { "from": "now-30d", "to": "now" }\`.
11589
11594
 
11590
11595
  Every panel has an \`id\` (a number, unique in its document), a \`type\`, a \`title\`, and a \`gridPos\` \`{ "x", "y", "w", "h" }\` on a 24-column grid: \`w: 24\` is full width, \`w: 12\` half. Stack panels top to bottom with no gaps or overlaps (each \`y\` is the previous \`y + h\` unless they sit side by side). On phones panels show full width in that order.
11591
11596
 
@@ -11632,7 +11637,25 @@ Units and ranges go in \`"fieldConfig": { "defaults": { "unit": "\u2026", "min",
11632
11637
 
11633
11638
  Charts can't do arithmetic across metrics (weight \xD7 reps, a ratio of two inputs). Chart what's recorded instead, or add an input for the combined value, and say which you did in the sentence before the JSON.
11634
11639
 
11635
- ## Tabs
11640
+ `;
11641
+ var AUTHORING_GUIDE = `# modelform templates
11642
+
11643
+ A template is JSON that adds forms (for recording entries) and dashboards (for charting them) to an app, plus tabs to show them.
11644
+
11645
+ \`\`\`
11646
+ {
11647
+ "$modelform": "template",
11648
+ "version": 1,
11649
+ "title": "Short name",
11650
+ "description": "One sentence on what it's for.",
11651
+ "documents": [ { "kind": "form" | "dashboard", "id": "letters-digits-dashes", "dashboard": { ...document } } ],
11652
+ "tabs": [ ...tabs ]
11653
+ }
11654
+ \`\`\`
11655
+
11656
+ Each document's \`kind\` matches its entry in \`documents\`.
11657
+
11658
+ ${DOCUMENT_GUIDE}## Tabs
11636
11659
 
11637
11660
  \`{ "id": "\u2026", "title": "\u2026", "icon": "\u2026", "screen": \u2026 }\`, where the screen is one of:
11638
11661
 
@@ -11789,6 +11812,94 @@ function fixTemplatePrompt(problems) {
11789
11812
  "Fix these and reply with the whole corrected template as one ```json code block."
11790
11813
  ].join("\n");
11791
11814
  }
11815
+ function documentPrompt(request, document, { recorded = [] } = {}) {
11816
+ const kind = _nullishCoalesce(document.kind, () => ( "dashboard"));
11817
+ return [
11818
+ `I\u2019m building an app with modelform studio. Change this ${kind} for me:`,
11819
+ "",
11820
+ request.trim().replace(/^/gm, "> "),
11821
+ "",
11822
+ recorded.length ? `The app records these metrics: ${recorded.map((m) => `\`${m}\``).join(", ")}. Charts can read any of them.` : "",
11823
+ "Keep the ids of panels you keep and give new panels ids not used yet. Don\u2019t change an existing input\u2019s metric unless I asked: entries saved under the old name would stop showing up.",
11824
+ `Keep \`"kind": "${kind}"\`. Reply with the whole changed ${kind} as one \`\`\`json code block, not just the parts that changed. A sentence before it is fine; nothing after it.`,
11825
+ "",
11826
+ `## The ${kind} now`,
11827
+ "",
11828
+ "```json",
11829
+ JSON.stringify(document, null, 2),
11830
+ "```",
11831
+ "",
11832
+ DOCUMENT_GUIDE
11833
+ ].filter((line, i, all) => line !== "" || all[i - 1] !== "").join("\n");
11834
+ }
11835
+ function readDocumentAnswer(text, kind) {
11836
+ let json;
11837
+ try {
11838
+ json = jsonFromAnswer(text);
11839
+ } catch (e) {
11840
+ return { error: e.message };
11841
+ }
11842
+ const wrapper = json;
11843
+ if (_optionalChain([wrapper, 'optionalAccess', _333 => _333.$modelform]) === "template") {
11844
+ if (!Array.isArray(wrapper.documents) || wrapper.documents.length !== 1) return { error: `That\u2019s a template, not one ${kind}` };
11845
+ json = _optionalChain([wrapper, 'access', _334 => _334.documents, 'access', _335 => _335[0], 'optionalAccess', _336 => _336.dashboard]);
11846
+ }
11847
+ if (!json || typeof json !== "object" || Array.isArray(json)) return { error: `That isn\u2019t a ${kind}` };
11848
+ const raw = json;
11849
+ const stated = _nullishCoalesce(raw.kind, () => ( (Array.isArray(raw.panels) ? documentKind(raw) : void 0)));
11850
+ if (stated !== void 0 && stated !== kind)
11851
+ return { error: raw.kind === void 0 ? kind === "form" ? "That has no inputs, so it isn\u2019t a form" : "That has inputs, so it\u2019s a form, not a dashboard" : `That\u2019s a ${String(raw.kind)}, not a ${kind}` };
11852
+ const { dashboard, issues } = prepareDashboard(raw, kind);
11853
+ if (!dashboard) return { error: issues.filter((i) => i.severity === "error").map((i) => `${i.path}: ${i.message}`).join("; ") || `That isn\u2019t a ${kind}` };
11854
+ const document = { kind, ...raw };
11855
+ return { document, warnings: issues.filter((i) => i.severity === "warning").map((i) => `${i.path}: ${i.message}`) };
11856
+ }
11857
+ function fixDocumentPrompt(problems, kind) {
11858
+ return [
11859
+ `modelform couldn\u2019t use that ${kind} as it was:`,
11860
+ "",
11861
+ ...problems.map((p) => `- ${p}`),
11862
+ "",
11863
+ `Fix these and reply with the whole corrected ${kind} as one \`\`\`json code block.`
11864
+ ].join("\n");
11865
+ }
11866
+ var same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
11867
+ var flat = (d) => (_nullishCoalesce(d.panels, () => ( []))).flatMap((p) => p.type === "row" && p.panels ? [p, ...p.panels] : [p]);
11868
+ function documentChanges(before, after) {
11869
+ const labels = [["kind", "kind"], ["title", "title"], ["description", "description"], ["time", "time range"], ["templating", "variables"], ["timezone", "time zone"], ["refresh", "refresh"]];
11870
+ const document = labels.filter(([key]) => !same(before[key], after[key])).map(([, label]) => label);
11871
+ const old = new Map(flat(before).map((p) => [p.id, p]));
11872
+ const now = new Map(flat(after).map((p) => [p.id, p]));
11873
+ const info = (p) => ({ id: p.id, title: p.title || p.type, type: p.type });
11874
+ const panels = [];
11875
+ for (const p of flat(after)) {
11876
+ const was = old.get(p.id);
11877
+ if (!was) {
11878
+ panels.push({ change: "added", ...info(p), what: [] });
11879
+ continue;
11880
+ }
11881
+ const what = [];
11882
+ if (was.title !== p.title) what.push("title");
11883
+ if (was.type !== p.type) what.push("type");
11884
+ if (_optionalChain([was, 'access', _337 => _337.gridPos, 'optionalAccess', _338 => _338.x]) !== _optionalChain([p, 'access', _339 => _339.gridPos, 'optionalAccess', _340 => _340.x]) || _optionalChain([was, 'access', _341 => _341.gridPos, 'optionalAccess', _342 => _342.y]) !== _optionalChain([p, 'access', _343 => _343.gridPos, 'optionalAccess', _344 => _344.y])) what.push("position");
11885
+ if (_optionalChain([was, 'access', _345 => _345.gridPos, 'optionalAccess', _346 => _346.w]) !== _optionalChain([p, 'access', _347 => _347.gridPos, 'optionalAccess', _348 => _348.w]) || _optionalChain([was, 'access', _349 => _349.gridPos, 'optionalAccess', _350 => _350.h]) !== _optionalChain([p, 'access', _351 => _351.gridPos, 'optionalAccess', _352 => _352.h])) what.push("size");
11886
+ if (!same(was.options, p.options)) what.push("options");
11887
+ if (!same(was.targets, p.targets) || !same(was.datasource, p.datasource) || !same(was.transformations, p.transformations)) what.push("queries");
11888
+ if (!same(was.fieldConfig, p.fieldConfig)) what.push("field config");
11889
+ const known = /* @__PURE__ */ new Set(["id", "title", "type", "gridPos", "options", "targets", "datasource", "transformations", "fieldConfig", "panels"]);
11890
+ const rest = (q) => Object.fromEntries(Object.entries(q).filter(([k]) => !known.has(k)).sort(([a], [b]) => a.localeCompare(b)));
11891
+ if (!same(rest(was), rest(p))) what.push("other");
11892
+ if (what.length) panels.push({ change: "changed", ...info(p), what });
11893
+ }
11894
+ for (const p of flat(before)) if (!now.has(p.id)) panels.push({ change: "removed", ...info(p), what: [] });
11895
+ return { document, panels };
11896
+ }
11897
+
11898
+
11899
+
11900
+
11901
+
11902
+
11792
11903
 
11793
11904
 
11794
11905
 
@@ -12020,4 +12131,4 @@ function fixTemplatePrompt(problems) {
12020
12131
 
12021
12132
 
12022
12133
 
12023
- 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.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.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.AUTHORING_GUIDE = AUTHORING_GUIDE; exports.EXAMPLE_TEMPLATE = EXAMPLE_TEMPLATE; exports.templatePrompt = templatePrompt; exports.jsonFromAnswer = jsonFromAnswer; exports.readTemplateAnswer = readTemplateAnswer; exports.fixTemplatePrompt = fixTemplatePrompt;
12134
+ 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.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;