@grafana/viz-contract 1.3.0 → 1.4.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grafana/viz-contract",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "Contract between a Grafana query source, the host that shows the chart, and the Renderer",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -68,12 +68,12 @@
68
68
  "refresh": [
69
69
  {
70
70
  "code": "refresh-failed",
71
- "when": "The App calls setRefreshed(false, error) with an error text, or onRefresh throws",
71
+ "when": "The App calls setRefreshed(id, false, error) with an error text, or onRefresh throws",
72
72
  "message": "Refresh failed: <error>"
73
73
  },
74
74
  {
75
75
  "code": "refresh-failed-no-detail",
76
- "when": "The App calls setRefreshed(false) with no error text",
76
+ "when": "The App calls setRefreshed(id, false) with no error text",
77
77
  "message": "Refresh failed."
78
78
  },
79
79
  {
package/renderer-api.d.ts CHANGED
@@ -34,8 +34,11 @@ export interface RenderOptions {
34
34
  export interface RenderHandle {
35
35
  /** Draws a new viz spec in the same element. */
36
36
  update(spec: unknown): void;
37
- /** Gives the result of the last refresh. With ok false, error is the text that the Renderer shows. */
38
- setRefreshed(ok: boolean, error?: string): void;
37
+ /**
38
+ * Gives the result of the refresh with this id. id is the id of the RefreshRequest. With ok false, error is the
39
+ * text that the Renderer shows.
40
+ */
41
+ setRefreshed(id: string, ok: boolean, error?: string): void;
39
42
  /** Removes the chart and its listeners. */
40
43
  destroy(): void;
41
44
  }
@@ -64,7 +67,11 @@ export interface Notice {
64
67
  }
65
68
 
66
69
  /**
67
- * The cause of a refresh. For timeRange, from and to are the range that the user picked. A relative range, for
68
- * example now-6h to now, stays relative. An absolute range is in epoch milliseconds.
70
+ * A refresh. id is a new value for each call of onRefresh. The App gives it to setRefreshed. For timeRange, from
71
+ * and to are the range that the user picked. A relative range, for example now-6h to now, stays relative. An
72
+ * absolute range is in epoch milliseconds.
69
73
  */
70
- export type RefreshRequest = { cause: 'refresh' } | { cause: 'timeRange'; from: string; to: string };
74
+ export type RefreshRequest = { id: string } & (
75
+ | { cause: 'refresh' }
76
+ | { cause: 'timeRange'; from: string; to: string }
77
+ );