@kong-ui-public/dashboard-renderer 10.5.1 → 10.5.2-pr.4084.dcaa723dd.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.
Files changed (35) hide show
  1. package/README.md +88 -0
  2. package/dist/{GeoMapRenderer-sfj8cOX0.js → GeoMapRenderer-KORPRZ3X.js} +28 -26
  3. package/dist/dashboard-renderer.es.js +1 -1
  4. package/dist/dashboard-renderer.umd.js +14 -14
  5. package/dist/{index-C9j3O5jK.js → index-CRo0c_oi.js} +3429 -3321
  6. package/dist/style.css +1 -1
  7. package/dist/types/components/BarChartRenderer.vue.d.ts.map +1 -1
  8. package/dist/types/components/BaseAnalyticsChartRenderer.vue.d.ts.map +1 -1
  9. package/dist/types/components/DashboardTile.vue.d.ts +6 -1
  10. package/dist/types/components/DashboardTile.vue.d.ts.map +1 -1
  11. package/dist/types/components/DashboardTilePreview.vue.d.ts +6 -1
  12. package/dist/types/components/DashboardTilePreview.vue.d.ts.map +1 -1
  13. package/dist/types/components/DonutChartRenderer.vue.d.ts.map +1 -1
  14. package/dist/types/components/GeoMapRenderer.vue.d.ts.map +1 -1
  15. package/dist/types/components/HeatmapRenderer.vue.d.ts.map +1 -1
  16. package/dist/types/components/QueryDataProvider.vue.d.ts +5 -3
  17. package/dist/types/components/QueryDataProvider.vue.d.ts.map +1 -1
  18. package/dist/types/components/ScatterChartRenderer.vue.d.ts.map +1 -1
  19. package/dist/types/components/SimpleChartRenderer.vue.d.ts.map +1 -1
  20. package/dist/types/components/TableDataGridRenderer.vue.d.ts +2 -0
  21. package/dist/types/components/TableDataGridRenderer.vue.d.ts.map +1 -1
  22. package/dist/types/components/TimeseriesChartRenderer.vue.d.ts.map +1 -1
  23. package/dist/types/components/TopNTableRenderer.vue.d.ts.map +1 -1
  24. package/dist/types/components/TreemapRenderer.vue.d.ts.map +1 -1
  25. package/dist/types/composables/index.d.ts +2 -0
  26. package/dist/types/composables/index.d.ts.map +1 -1
  27. package/dist/types/composables/useIsPropPassed.d.ts +12 -0
  28. package/dist/types/composables/useIsPropPassed.d.ts.map +1 -0
  29. package/dist/types/types/renderer-types.d.ts +19 -1
  30. package/dist/types/types/renderer-types.d.ts.map +1 -1
  31. package/dist/types/utils/supplied-tile-data.d.ts +32 -0
  32. package/dist/types/utils/supplied-tile-data.d.ts.map +1 -0
  33. package/dist/types/utils/table-data-grid-renderer.d.ts +9 -1
  34. package/dist/types/utils/table-data-grid-renderer.d.ts.map +1 -1
  35. package/package.json +2 -2
package/README.md CHANGED
@@ -3,6 +3,7 @@
3
3
  Render Analytics charts on a page from a JSON definition.
4
4
 
5
5
  - [Consumer entry points](#consumer-entry-points)
6
+ - [Render a tile from supplied data](#render-a-tile-from-supplied-data)
6
7
  - [Requirements](#requirements)
7
8
  - [Usage](#usage)
8
9
  - [Props](#props)
@@ -77,6 +78,93 @@ For a metric selector, set the tile query's `metrics` to the selected metric.
77
78
  series; ungrouped results keep all queried metrics. Do not combine requests,
78
79
  tokens, latency, and cost on a single axis and rely on that prop to select one.
79
80
 
81
+ ### Render a tile from supplied data
82
+
83
+ Pass the `data` prop to `DashboardTilePreview` to render data the host already
84
+ has. When `data` is passed, the tile doesn't run a query. The definition still
85
+ sets the chart type and options.
86
+
87
+ The tile type sets the data shape. All three types are exported from
88
+ `@kong-ui-public/analytics-utilities`, and the union is exported as `TileData`.
89
+
90
+ | Tile | Data |
91
+ |------|------|
92
+ | `table` | `PlatformTabularResponse` |
93
+ | `scatter` with the `requests` datasource | `ApiRequestsResult` |
94
+ | Other chart tiles | `ExploreResultV4` |
95
+
96
+ The value sets the state:
97
+
98
+ | Value | State |
99
+ |-------|-------|
100
+ | `undefined` | Loading skeleton |
101
+ | `null` | Empty state |
102
+ | An `Error` | Error state with the error message |
103
+ | Data | The chart. Data that doesn't match the tile type shows the error state. |
104
+
105
+ Pass `undefined` while the host loads, not an omitted prop. Without `data`,
106
+ the tile queries through the `AnalyticsBridge`.
107
+
108
+ With `data`:
109
+
110
+ - The refresh action and the "Jump to Explore" and "Jump to Requests" links
111
+ are hidden.
112
+ - Zoom emits `tile-time-range-zoom`. Fetch data for the new time range and
113
+ pass it to `data`.
114
+ - Chart tiles that take `ExploreResultV4` emit the supplied data in
115
+ `chart-data`, and CSV export uses it.
116
+ - The renderer checks only the top-level shape of the data, such as its
117
+ `data` and `meta` fields.
118
+ - `golden_signals` and `top_talkers` tiles don't support `data`. They run
119
+ their queries.
120
+
121
+ ```vue
122
+ <template>
123
+ <DashboardTilePreview
124
+ :context="context"
125
+ :data="data"
126
+ :definition="definition"
127
+ @tile-time-range-zoom="onZoom"
128
+ />
129
+ </template>
130
+
131
+ <script setup lang="ts">
132
+ import { ref } from 'vue'
133
+ import { DashboardTilePreview } from '@kong-ui-public/dashboard-renderer'
134
+ import type { DashboardRendererContext, TileData, TileZoomEvent } from '@kong-ui-public/dashboard-renderer'
135
+ import type { ChartTileDefinition, TimeRangeV4 } from '@kong-ui-public/analytics-utilities'
136
+
137
+ const context: DashboardRendererContext = {
138
+ filters: [],
139
+ timeSpec: { type: 'relative', time_range: '7d' },
140
+ }
141
+ const definition: ChartTileDefinition = {
142
+ chart: { type: 'timeseries_line' },
143
+ query: {
144
+ datasource: 'api_usage',
145
+ metrics: ['request_count'],
146
+ dimensions: ['time'],
147
+ },
148
+ }
149
+
150
+ // `undefined` shows the loading skeleton until the host's request settles.
151
+ const data = ref<TileData | null | Error>()
152
+
153
+ const load = async (timeRange: TimeRangeV4) => {
154
+ data.value = undefined
155
+ try {
156
+ data.value = await fetchRequestCounts(timeRange) // The host's own request, which returns ExploreResultV4.
157
+ } catch (error) {
158
+ data.value = error instanceof Error ? error : new Error(String(error))
159
+ }
160
+ }
161
+
162
+ const onZoom = ({ timeRange }: TileZoomEvent) => load(timeRange)
163
+
164
+ load(context.timeSpec!)
165
+ </script>
166
+ ```
167
+
80
168
  ## Requirements
81
169
 
82
170
  - `vue` must be initialized in the host application
@@ -1,8 +1,8 @@
1
- import { defineComponent as v, ref as p, computed as o, openBlock as q, createBlock as C, withCtx as g, createVNode as x, unref as _ } from "vue";
2
- import { _ as M } from "./index-C9j3O5jK.js";
3
- import { exploreResultToCountryMetrics as E, AnalyticsGeoMap as O } from "@kong-ui-public/analytics-geo-map";
4
- import { COUNTRIES as R } from "@kong-ui-public/analytics-utilities";
5
- const U = /* @__PURE__ */ v({
1
+ import { defineComponent as p, ref as v, computed as o, openBlock as q, createBlock as C, withCtx as g, createVNode as x, unref as M } from "vue";
2
+ import { _ as E } from "./index-CRo0c_oi.js";
3
+ import { exploreResultToCountryMetrics as O, AnalyticsGeoMap as R } from "@kong-ui-public/analytics-geo-map";
4
+ import { COUNTRIES as _ } from "@kong-ui-public/analytics-utilities";
5
+ const U = /* @__PURE__ */ p({
6
6
  __name: "GeoMapRenderer",
7
7
  props: {
8
8
  query: {},
@@ -15,11 +15,12 @@ const U = /* @__PURE__ */ v({
15
15
  headerDescription: {},
16
16
  requestsLink: {},
17
17
  exploreLink: {},
18
- zoomConfiguration: {}
18
+ zoomConfiguration: {},
19
+ suppliedData: {}
19
20
  },
20
21
  emits: ["bounds-change"],
21
- setup(r, { emit: c }) {
22
- const n = r, e = p(void 0), s = o(() => e.value ? E(e.value) : {}), a = o(() => e.value ? e.value?.meta.metric_names && e.value.meta.metric_names[0] : ""), m = o(() => n.query.limit !== void 0 && n.query.limit > 0 ? n.query.limit : R.length), l = o(() => {
22
+ setup(t, { emit: c }) {
23
+ const n = t, e = v(void 0), a = o(() => e.value ? O(e.value) : {}), s = o(() => e.value ? e.value?.meta.metric_names && e.value.meta.metric_names[0] : ""), m = o(() => n.query.limit !== void 0 && n.query.limit > 0 ? n.query.limit : _.length), l = o(() => {
23
24
  if (!n.query.filters?.find(({ field: i, operator: u }) => i === "country_code" && (u === "not_empty" || u === "empty" || u === "in"))) {
24
25
  const i = {
25
26
  field: "country_code",
@@ -37,34 +38,35 @@ const U = /* @__PURE__ */ v({
37
38
  }), y = o(() => {
38
39
  if (!e.value)
39
40
  return "";
40
- const t = e?.value?.meta.metric_units, i = e?.value?.meta?.metric_names;
41
- return t && i && t[i[0]];
42
- }), f = (t) => {
43
- e.value = t;
44
- }, d = c, h = (t) => {
45
- d("bounds-change", t);
41
+ const r = e?.value?.meta.metric_units, i = e?.value?.meta?.metric_names;
42
+ return r && i && r[i[0]];
43
+ }), d = (r) => {
44
+ e.value = r;
45
+ }, f = c, h = (r) => {
46
+ f("bounds-change", r);
46
47
  };
47
- return (t, i) => (q(), C(M, {
48
- context: r.context,
48
+ return (r, i) => (q(), C(E, {
49
+ context: t.context,
49
50
  "limit-override": m.value,
50
51
  query: l.value,
51
- "query-ready": r.queryReady,
52
- "refresh-counter": r.refreshCounter,
53
- onChartData: f
52
+ "query-ready": t.queryReady,
53
+ "refresh-counter": t.refreshCounter,
54
+ "supplied-data": t.suppliedData,
55
+ onChartData: d
54
56
  }, {
55
57
  default: g(() => [
56
- x(_(O), {
57
- bounds: r.chartOptions.bounds,
58
- "country-metrics": s.value,
59
- "fit-to-country": r.chartOptions.fit_to_country,
60
- metric: a.value,
58
+ x(M(R), {
59
+ bounds: t.chartOptions.bounds,
60
+ "country-metrics": a.value,
61
+ "fit-to-country": t.chartOptions.fit_to_country,
62
+ metric: s.value,
61
63
  "metric-unit": y.value,
62
- "with-legend": r.chartOptions.legend || !1,
64
+ "with-legend": t.chartOptions.legend || !1,
63
65
  onBoundsChange: h
64
66
  }, null, 8, ["bounds", "country-metrics", "fit-to-country", "metric", "metric-unit", "with-legend"])
65
67
  ]),
66
68
  _: 1
67
- }, 8, ["context", "limit-override", "query", "query-ready", "refresh-counter"]));
69
+ }, 8, ["context", "limit-override", "query", "query-ready", "refresh-counter", "supplied-data"]));
68
70
  }
69
71
  });
70
72
  export {
@@ -1,4 +1,4 @@
1
- import { C as s, a as R, b as _, D as T, c as e, d as i, e as D, f as I, E as L, F as N, g as O, I as S, h as o, T as r, i as A, j as C, k as n, l as F, m } from "./index-C9j3O5jK.js";
1
+ import { C as s, a as R, b as _, D as T, c as e, d as i, e as D, f as I, E as L, F as N, g as O, I as S, h as o, T as r, i as A, j as C, k as n, l as F, m } from "./index-CRo0c_oi.js";
2
2
  export {
3
3
  s as CELLS_PER_ROW,
4
4
  R as CP_ID_TOKEN,