@flanksource/clicky-ui 0.3.84 → 0.3.85

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 (219) hide show
  1. package/dist/components/Combobox.cjs +8 -6
  2. package/dist/components/Combobox.cjs.map +1 -1
  3. package/dist/components/Combobox.d.ts.map +1 -1
  4. package/dist/components/Combobox.js +8 -6
  5. package/dist/components/Combobox.js.map +1 -1
  6. package/dist/components/ComboboxMenu.cjs +7 -4
  7. package/dist/components/ComboboxMenu.cjs.map +1 -1
  8. package/dist/components/ComboboxMenu.d.ts +3 -2
  9. package/dist/components/ComboboxMenu.d.ts.map +1 -1
  10. package/dist/components/ComboboxMenu.js +7 -4
  11. package/dist/components/ComboboxMenu.js.map +1 -1
  12. package/dist/components/FilterBar.cjs +64 -47
  13. package/dist/components/FilterBar.cjs.map +1 -1
  14. package/dist/components/FilterBar.d.ts +20 -2
  15. package/dist/components/FilterBar.d.ts.map +1 -1
  16. package/dist/components/FilterBar.js +63 -46
  17. package/dist/components/FilterBar.js.map +1 -1
  18. package/dist/components/TimeRange.cjs +156 -128
  19. package/dist/components/TimeRange.cjs.map +1 -1
  20. package/dist/components/TimeRange.d.ts +8 -1
  21. package/dist/components/TimeRange.d.ts.map +1 -1
  22. package/dist/components/TimeRange.js +156 -128
  23. package/dist/components/TimeRange.js.map +1 -1
  24. package/dist/components/combobox-types.d.ts +5 -0
  25. package/dist/components/combobox-types.d.ts.map +1 -1
  26. package/dist/components/filter-bar-context.cjs.map +1 -1
  27. package/dist/components/filter-bar-context.d.ts +2 -0
  28. package/dist/components/filter-bar-context.d.ts.map +1 -1
  29. package/dist/components/filter-bar-context.js.map +1 -1
  30. package/dist/components/filter-bar-field-utils.cjs +18 -4
  31. package/dist/components/filter-bar-field-utils.cjs.map +1 -1
  32. package/dist/components/filter-bar-field-utils.d.ts +3 -2
  33. package/dist/components/filter-bar-field-utils.d.ts.map +1 -1
  34. package/dist/components/filter-bar-field-utils.js +19 -5
  35. package/dist/components/filter-bar-field-utils.js.map +1 -1
  36. package/dist/components/filter-bar-menu.cjs +189 -0
  37. package/dist/components/filter-bar-menu.cjs.map +1 -0
  38. package/dist/components/filter-bar-menu.d.ts +25 -0
  39. package/dist/components/filter-bar-menu.d.ts.map +1 -0
  40. package/dist/components/filter-bar-menu.js +189 -0
  41. package/dist/components/filter-bar-menu.js.map +1 -0
  42. package/dist/components/filter-bar-multi.cjs +1 -1
  43. package/dist/components/filter-bar-multi.cjs.map +1 -1
  44. package/dist/components/filter-bar-multi.js +2 -2
  45. package/dist/components/filter-bar-multi.js.map +1 -1
  46. package/dist/components/filter-bar-popup.cjs +37 -0
  47. package/dist/components/filter-bar-popup.cjs.map +1 -0
  48. package/dist/components/filter-bar-popup.d.ts +32 -0
  49. package/dist/components/filter-bar-popup.d.ts.map +1 -0
  50. package/dist/components/filter-bar-popup.js +37 -0
  51. package/dist/components/filter-bar-popup.js.map +1 -0
  52. package/dist/components/filter-bar-tree.cjs +1 -1
  53. package/dist/components/filter-bar-tree.cjs.map +1 -1
  54. package/dist/components/filter-bar-tree.js +2 -2
  55. package/dist/components/filter-bar-tree.js.map +1 -1
  56. package/dist/components/json-schema-form-table-array.cjs +5 -3
  57. package/dist/components/json-schema-form-table-array.cjs.map +1 -1
  58. package/dist/components/json-schema-form-table-array.d.ts.map +1 -1
  59. package/dist/components/json-schema-form-table-array.js +5 -3
  60. package/dist/components/json-schema-form-table-array.js.map +1 -1
  61. package/dist/components.cjs +1 -1
  62. package/dist/components.js +1 -1
  63. package/dist/connections/ConnectionPicker.cjs +6 -2
  64. package/dist/connections/ConnectionPicker.cjs.map +1 -1
  65. package/dist/connections/ConnectionPicker.d.ts.map +1 -1
  66. package/dist/connections/ConnectionPicker.js +6 -2
  67. package/dist/connections/ConnectionPicker.js.map +1 -1
  68. package/dist/connections/CreateConnectionDialog.cjs +8 -21
  69. package/dist/connections/CreateConnectionDialog.cjs.map +1 -1
  70. package/dist/connections/CreateConnectionDialog.d.ts +2 -1
  71. package/dist/connections/CreateConnectionDialog.d.ts.map +1 -1
  72. package/dist/connections/CreateConnectionDialog.js +8 -21
  73. package/dist/connections/CreateConnectionDialog.js.map +1 -1
  74. package/dist/data/ExpandableMarkdown.cjs +59 -0
  75. package/dist/data/ExpandableMarkdown.cjs.map +1 -0
  76. package/dist/data/ExpandableMarkdown.d.ts +17 -0
  77. package/dist/data/ExpandableMarkdown.d.ts.map +1 -0
  78. package/dist/data/ExpandableMarkdown.js +59 -0
  79. package/dist/data/ExpandableMarkdown.js.map +1 -0
  80. package/dist/data/MultiGaugeBar.cjs +49 -21
  81. package/dist/data/MultiGaugeBar.cjs.map +1 -1
  82. package/dist/data/MultiGaugeBar.d.ts +5 -2
  83. package/dist/data/MultiGaugeBar.d.ts.map +1 -1
  84. package/dist/data/MultiGaugeBar.js +49 -21
  85. package/dist/data/MultiGaugeBar.js.map +1 -1
  86. package/dist/data/flow-node/BoxNode.cjs +45 -0
  87. package/dist/data/flow-node/BoxNode.cjs.map +1 -0
  88. package/dist/data/flow-node/BoxNode.d.ts +28 -0
  89. package/dist/data/flow-node/BoxNode.d.ts.map +1 -0
  90. package/dist/data/flow-node/BoxNode.js +45 -0
  91. package/dist/data/flow-node/BoxNode.js.map +1 -0
  92. package/dist/data/flow-node/FlowMetrics.cjs +208 -0
  93. package/dist/data/flow-node/FlowMetrics.cjs.map +1 -0
  94. package/dist/data/flow-node/FlowMetrics.d.ts +60 -0
  95. package/dist/data/flow-node/FlowMetrics.d.ts.map +1 -0
  96. package/dist/data/flow-node/FlowMetrics.js +206 -0
  97. package/dist/data/flow-node/FlowMetrics.js.map +1 -0
  98. package/dist/data/flow-node/WorkloadNode.cjs +63 -0
  99. package/dist/data/flow-node/WorkloadNode.cjs.map +1 -0
  100. package/dist/data/flow-node/WorkloadNode.d.ts +42 -0
  101. package/dist/data/flow-node/WorkloadNode.d.ts.map +1 -0
  102. package/dist/data/flow-node/WorkloadNode.js +63 -0
  103. package/dist/data/flow-node/WorkloadNode.js.map +1 -0
  104. package/dist/data/flow-node/index.d.ts +5 -0
  105. package/dist/data/flow-node/index.d.ts.map +1 -0
  106. package/dist/data/flow-node/latency.cjs +37 -0
  107. package/dist/data/flow-node/latency.cjs.map +1 -0
  108. package/dist/data/flow-node/latency.d.ts +13 -0
  109. package/dist/data/flow-node/latency.d.ts.map +1 -0
  110. package/dist/data/flow-node/latency.js +35 -0
  111. package/dist/data/flow-node/latency.js.map +1 -0
  112. package/dist/data/traces/index.d.ts +1 -0
  113. package/dist/data/traces/index.d.ts.map +1 -1
  114. package/dist/data/traces/otel/OtelTraceDetail.cjs +4 -7
  115. package/dist/data/traces/otel/OtelTraceDetail.cjs.map +1 -1
  116. package/dist/data/traces/otel/OtelTraceDetail.js +4 -7
  117. package/dist/data/traces/otel/OtelTraceDetail.js.map +1 -1
  118. package/dist/data/traces/otel/OtelTraceSearch.cjs +90 -56
  119. package/dist/data/traces/otel/OtelTraceSearch.cjs.map +1 -1
  120. package/dist/data/traces/otel/OtelTraceSearch.d.ts.map +1 -1
  121. package/dist/data/traces/otel/OtelTraceSearch.js +91 -57
  122. package/dist/data/traces/otel/OtelTraceSearch.js.map +1 -1
  123. package/dist/data/traces/otel/QueryBar.cjs +83 -10
  124. package/dist/data/traces/otel/QueryBar.cjs.map +1 -1
  125. package/dist/data/traces/otel/QueryBar.d.ts.map +1 -1
  126. package/dist/data/traces/otel/QueryBar.js +83 -10
  127. package/dist/data/traces/otel/QueryBar.js.map +1 -1
  128. package/dist/data/traces/otel/TraceResults.cjs +81 -13
  129. package/dist/data/traces/otel/TraceResults.cjs.map +1 -1
  130. package/dist/data/traces/otel/TraceResults.d.ts +11 -3
  131. package/dist/data/traces/otel/TraceResults.d.ts.map +1 -1
  132. package/dist/data/traces/otel/TraceResults.js +81 -13
  133. package/dist/data/traces/otel/TraceResults.js.map +1 -1
  134. package/dist/data/traces/otel/api.cjs.map +1 -1
  135. package/dist/data/traces/otel/api.d.ts +14 -0
  136. package/dist/data/traces/otel/api.d.ts.map +1 -1
  137. package/dist/data/traces/otel/api.js.map +1 -1
  138. package/dist/data/traces/otel/query.cjs +2 -2
  139. package/dist/data/traces/otel/query.cjs.map +1 -1
  140. package/dist/data/traces/otel/query.d.ts +1 -1
  141. package/dist/data/traces/otel/query.d.ts.map +1 -1
  142. package/dist/data/traces/otel/query.js +2 -2
  143. package/dist/data/traces/otel/query.js.map +1 -1
  144. package/dist/data/version-info.cjs +3 -3
  145. package/dist/data/version-info.cjs.map +1 -1
  146. package/dist/data/version-info.js +3 -3
  147. package/dist/data/version-info.js.map +1 -1
  148. package/dist/data/workload-panel/MemoryStack.cjs +38 -1
  149. package/dist/data/workload-panel/MemoryStack.cjs.map +1 -1
  150. package/dist/data/workload-panel/MemoryStack.d.ts.map +1 -1
  151. package/dist/data/workload-panel/MemoryStack.js +38 -1
  152. package/dist/data/workload-panel/MemoryStack.js.map +1 -1
  153. package/dist/data.cjs +18 -1
  154. package/dist/data.d.ts +2 -0
  155. package/dist/data.d.ts.map +1 -1
  156. package/dist/data.js +8 -2
  157. package/dist/file-findings/AnnotatedCode.cjs +18 -2
  158. package/dist/file-findings/AnnotatedCode.cjs.map +1 -1
  159. package/dist/file-findings/AnnotatedCode.d.ts +2 -0
  160. package/dist/file-findings/AnnotatedCode.d.ts.map +1 -1
  161. package/dist/file-findings/AnnotatedCode.js +18 -2
  162. package/dist/file-findings/AnnotatedCode.js.map +1 -1
  163. package/dist/file-findings/FileFindingsView.cjs.map +1 -1
  164. package/dist/file-findings/FileFindingsView.d.ts +2 -0
  165. package/dist/file-findings/FileFindingsView.d.ts.map +1 -1
  166. package/dist/file-findings/FileFindingsView.js.map +1 -1
  167. package/dist/file-findings/file-review/FileReview.cjs +2 -1
  168. package/dist/file-findings/file-review/FileReview.cjs.map +1 -1
  169. package/dist/file-findings/file-review/FileReview.d.ts +3 -1
  170. package/dist/file-findings/file-review/FileReview.d.ts.map +1 -1
  171. package/dist/file-findings/file-review/FileReview.js +2 -1
  172. package/dist/file-findings/file-review/FileReview.js.map +1 -1
  173. package/dist/index.cjs +18 -1
  174. package/dist/index.js +8 -2
  175. package/dist/profiles/editor/profileEditor.cjs +29 -30
  176. package/dist/profiles/editor/profileEditor.cjs.map +1 -1
  177. package/dist/profiles/editor/profileEditor.d.ts.map +1 -1
  178. package/dist/profiles/editor/profileEditor.js +29 -30
  179. package/dist/profiles/editor/profileEditor.js.map +1 -1
  180. package/dist/profiles/editor/profileEditorPreview.cjs +44 -43
  181. package/dist/profiles/editor/profileEditorPreview.cjs.map +1 -1
  182. package/dist/profiles/editor/profileEditorPreview.d.ts +10 -5
  183. package/dist/profiles/editor/profileEditorPreview.d.ts.map +1 -1
  184. package/dist/profiles/editor/profileEditorPreview.js +44 -43
  185. package/dist/profiles/editor/profileEditorPreview.js.map +1 -1
  186. package/dist/profiles/editor/profileMappingPreview.cjs +153 -48
  187. package/dist/profiles/editor/profileMappingPreview.cjs.map +1 -1
  188. package/dist/profiles/editor/profileMappingPreview.d.ts +16 -2
  189. package/dist/profiles/editor/profileMappingPreview.d.ts.map +1 -1
  190. package/dist/profiles/editor/profileMappingPreview.js +155 -50
  191. package/dist/profiles/editor/profileMappingPreview.js.map +1 -1
  192. package/dist/profiles/editor/sampleError.cjs +29 -0
  193. package/dist/profiles/editor/sampleError.cjs.map +1 -0
  194. package/dist/profiles/editor/sampleError.d.ts +16 -0
  195. package/dist/profiles/editor/sampleError.d.ts.map +1 -0
  196. package/dist/profiles/editor/sampleError.js +27 -0
  197. package/dist/profiles/editor/sampleError.js.map +1 -0
  198. package/dist/profiles/query/profileSampleResult.cjs.map +1 -1
  199. package/dist/profiles/query/profileSampleResult.d.ts +2 -0
  200. package/dist/profiles/query/profileSampleResult.d.ts.map +1 -1
  201. package/dist/profiles/query/profileSampleResult.js.map +1 -1
  202. package/dist/profiles/wizard/profileWizardQueryStep.cjs +1 -0
  203. package/dist/profiles/wizard/profileWizardQueryStep.cjs.map +1 -1
  204. package/dist/profiles/wizard/profileWizardQueryStep.d.ts +2 -0
  205. package/dist/profiles/wizard/profileWizardQueryStep.d.ts.map +1 -1
  206. package/dist/profiles/wizard/profileWizardQueryStep.js +1 -0
  207. package/dist/profiles/wizard/profileWizardQueryStep.js.map +1 -1
  208. package/dist/react-grab/core/index.js +1 -1
  209. package/dist/react-grab/{core-BERtFDWh.js → core-BK5CU6Lb.js} +2 -2
  210. package/dist/react-grab/index.js +1 -1
  211. package/dist/react-grab/{renderer-KT3FY3K2.js → renderer-DcHrsQ8k.js} +1 -1
  212. package/dist/rpc/apiClient.cjs +12 -15
  213. package/dist/rpc/apiClient.cjs.map +1 -1
  214. package/dist/rpc/apiClient.js +12 -15
  215. package/dist/rpc/apiClient.js.map +1 -1
  216. package/dist/runtime/barrels.json +6481 -6441
  217. package/dist/runtime/importmap.json +2198 -2190
  218. package/dist/styles.css +1 -1
  219. package/package.json +1 -1
@@ -8,30 +8,16 @@ let react = require("react");
8
8
  let react_jsx_runtime = require("react/jsx-runtime");
9
9
  // src/profiles/editor/profileEditorPreview.tsx
10
10
  var NO_FILTERS = {};
11
- /**
12
- * The draft's results as the saved profile's page will show them, so the effect
13
- * of including a field, relabelling it, typing it or hiding it is visible
14
- * without leaving the editor.
15
- *
16
- * The rows are the sample's source rows, not a client-side projection of them:
17
- * the profile service maps them through the draft's columns and renders the same
18
- * clicky document it serves the saved profile's results page, which this shows
19
- * with the same Clicky component — a key_values column is tag pills, a datetime
20
- * is a timestamp, a duration is a duration. Rows only exist after a sample runs —
21
- * there is no placeholder data, because a fabricated preview is worse than none.
22
- *
23
- * The filter bar offers the filters the draft's columns declare. Filtering is
24
- * the backend's, so applying one samples again with it; the rows are never
25
- * filtered in the browser.
26
- */
27
- function ProfileEditorPreview({ columns, rows, profile, stale = false, onNormalized }) {
11
+ function ProfileEditorPreview({ columns, rows, sampleId, profile, stale = false, ...callbacks }) {
12
+ const { onNormalized, ...tableCallbacks } = callbacks;
28
13
  if (stale) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
29
14
  role: "status",
30
15
  children: "Source or query settings changed. Run a new sample to refresh the mapping preview."
31
16
  });
32
17
  if (profile.render === "traces") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_profileMappingPreview.ProfileMappingPreview, {
33
18
  profile,
34
- rows,
19
+ sampleId,
20
+ ...tableCallbacks,
35
21
  ...onNormalized ? { onNormalized } : {}
36
22
  });
37
23
  const included = columns.some((column) => !column.hidden);
@@ -41,16 +27,18 @@ function ProfileEditorPreview({ columns, rows, profile, stale = false, onNormali
41
27
  });
42
28
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FilterableTablePreview, {
43
29
  profile,
44
- rows
30
+ sampleId,
31
+ ...tableCallbacks
45
32
  });
46
33
  }
47
- function FilterableTablePreview({ profile, rows }) {
34
+ function FilterableTablePreview({ profile, sampleId, onSampleExpired, ...callbacks }) {
48
35
  const [selection, setSelection] = (0, react.useState)(NO_FILTERS);
49
36
  const filtered = useFilteredSample({
50
37
  profile,
51
38
  selection
52
39
  });
53
- (0, react.useEffect)(() => setSelection(NO_FILTERS), [rows]);
40
+ (0, react.useEffect)(() => setSelection(NO_FILTERS), [sampleId]);
41
+ const expired = filtered.sampleId ? filtered.refresh : onSampleExpired;
54
42
  const lookupValues = (0, react.useCallback)((request) => require_profileSampleFilterLookup.lookupProfileSampleFilterValues({
55
43
  draft: profile,
56
44
  params: {},
@@ -65,27 +53,38 @@ function FilterableTablePreview({ profile, rows }) {
65
53
  children: [filtered.error ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
66
54
  role: "alert",
67
55
  className: "shrink-0 px-3 py-1 text-xs text-destructive",
68
- children: ["Cannot apply the filter to the sample: ", filtered.error]
56
+ children: [
57
+ "Cannot apply the filter to the sample: ",
58
+ filtered.error,
59
+ ". The rows below are from before this filter."
60
+ ]
69
61
  }) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_profileMappingPreview.ProfileMappingPreview, {
70
62
  profile,
71
- rows: filtered.error ? [] : filtered.rows ?? rows,
63
+ sampleId: filtered.sampleId ?? sampleId,
64
+ stale: Boolean(filtered.error),
72
65
  filters: {
73
66
  selection,
74
67
  onChange: setSelection,
75
68
  lookupValues
76
- }
69
+ },
70
+ ...callbacks,
71
+ ...expired ? { onSampleExpired: expired } : {}
77
72
  })]
78
73
  });
79
74
  }
80
75
  /**
81
- * The sample's source rows for a draft with `selection` applied by the backend,
82
- * or null rows while nothing is selected (the unfiltered sample stands).
76
+ * The retained sample for a draft with `selection` applied by the backend, or
77
+ * a null id while nothing is selected (the unfiltered sample stands). A failed
78
+ * filter keeps the sample it had, so the preview can still offer the filter bar
79
+ * that changes it.
83
80
  */
84
81
  function useFilteredSample({ profile, selection }) {
85
82
  const [state, setState] = (0, react.useState)({
86
- rows: null,
83
+ sampleId: null,
87
84
  error: ""
88
85
  });
86
+ const [attempt, setAttempt] = (0, react.useState)(0);
87
+ const refresh = (0, react.useCallback)(() => setAttempt((count) => count + 1), []);
89
88
  const active = Object.keys(selection).length > 0;
90
89
  const selectionKey = JSON.stringify(selection);
91
90
  const draft = (0, react.useRef)(profile);
@@ -93,17 +92,18 @@ function useFilteredSample({ profile, selection }) {
93
92
  (0, react.useEffect)(() => {
94
93
  if (!active) {
95
94
  setState({
96
- rows: null,
95
+ sampleId: null,
97
96
  error: ""
98
97
  });
99
98
  return;
100
99
  }
100
+ const failed = (error) => setState((previous) => ({
101
+ ...previous,
102
+ error
103
+ }));
101
104
  const sampled = require_jsonPathSample.sampleRequestProfile(draft.current);
102
105
  if (!sampled) {
103
- setState({
104
- rows: [],
105
- error: "the draft has no provider to sample"
106
- });
106
+ failed("the draft has no provider to sample");
107
107
  return;
108
108
  }
109
109
  let current = true;
@@ -126,25 +126,26 @@ function useFilteredSample({ profile, selection }) {
126
126
  })
127
127
  }).then((response) => {
128
128
  if (!current) return;
129
- if (!response.mappingInputRows) return setState({
130
- rows: [],
131
- error: "the sample response is missing mappingInputRows"
132
- });
129
+ if (!response.sampleId) return failed("the sample response is missing sampleId");
133
130
  setState({
134
- rows: response.mappingInputRows,
131
+ sampleId: response.sampleId,
135
132
  error: ""
136
133
  });
137
134
  }, (error) => {
138
- if (current) setState({
139
- rows: [],
140
- error: error instanceof Error ? error.message : String(error)
141
- });
135
+ if (current) failed(error instanceof Error ? error.message : String(error));
142
136
  });
143
137
  return () => {
144
138
  current = false;
145
139
  };
146
- }, [active, selectionKey]);
147
- return state;
140
+ }, [
141
+ active,
142
+ selectionKey,
143
+ attempt
144
+ ]);
145
+ return {
146
+ ...state,
147
+ refresh
148
+ };
148
149
  }
149
150
  exports.ProfileEditorPreview = ProfileEditorPreview;
150
151
 
@@ -1 +1 @@
1
- {"version":3,"file":"profileEditorPreview.cjs","names":["ProfileMappingPreview","useState","useCallback","lookupProfileSampleFilterValues","useRef","sampleRequestProfile","profileApiPath","debugCaptureHeaders"],"sources":["../../../src/profiles/editor/profileEditorPreview.tsx"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from \"react\";\nimport type { DataTableFilterSelection } from \"../../data/data-table-filter-values\";\nimport type { DataTableFilterLookup } from \"../../data/data-table-server-filters\";\nimport { debugCaptureHeaders } from \"../../data/debugConsoleSignal\";\nimport { fetchJSON } from \"../connections/connectionBrowserModel\";\nimport { profileApiPath } from \"../profileApi\";\nimport { lookupProfileSampleFilterValues } from \"../query/profileSampleFilterLookup\";\nimport { sampleRequestProfile } from \"../query/jsonPathSample\";\nimport type { ProfileColumn } from \"../wizard/profileWizardModel\";\nimport type { ProfileWizardDraft } from \"../wizard/profileWizardModel\";\nimport { ProfileMappingPreview } from \"./profileMappingPreview\";\n\nconst NO_FILTERS: DataTableFilterSelection = {};\n\n/**\n * The draft's results as the saved profile's page will show them, so the effect\n * of including a field, relabelling it, typing it or hiding it is visible\n * without leaving the editor.\n *\n * The rows are the sample's source rows, not a client-side projection of them:\n * the profile service maps them through the draft's columns and renders the same\n * clicky document it serves the saved profile's results page, which this shows\n * with the same Clicky component — a key_values column is tag pills, a datetime\n * is a timestamp, a duration is a duration. Rows only exist after a sample runs —\n * there is no placeholder data, because a fabricated preview is worse than none.\n *\n * The filter bar offers the filters the draft's columns declare. Filtering is\n * the backend's, so applying one samples again with it; the rows are never\n * filtered in the browser.\n */\nexport function ProfileEditorPreview({\n columns,\n rows,\n profile,\n stale = false,\n onNormalized,\n}: {\n columns: ProfileColumn[];\n /** The sample's source rows, ahead of the draft's column mapping. */\n rows: Record<string, unknown>[];\n /** The draft being edited: its columns, aliases and filters are what the rows are mapped through. */\n profile: ProfileWizardDraft;\n stale?: boolean;\n /** Receives the span-normalised rows and columns of a traces profile. */\n onNormalized?: (rows: Record<string, unknown>[], columns: ProfileColumn[]) => void;\n}) {\n if (stale)\n return (\n <p role=\"status\">\n Source or query settings changed. Run a new sample to refresh the\n mapping preview.\n </p>\n );\n if (profile.render === \"traces\")\n return <ProfileMappingPreview profile={profile} rows={rows} {...(onNormalized ? {onNormalized} : {})} />;\n\n const included = columns.some((column) => !column.hidden);\n if (rows.length === 0 || !included) {\n return (\n <p className=\"grid h-full place-items-center px-6 text-center text-xs text-muted-foreground\">\n {included ? \"Run a sample in Query to preview rows.\" : \"No columns included yet.\"}\n </p>\n );\n }\n return <FilterableTablePreview profile={profile} rows={rows} />;\n}\n\nfunction FilterableTablePreview({\n profile,\n rows,\n}: {\n profile: ProfileWizardDraft;\n rows: Record<string, unknown>[];\n}) {\n const [selection, setSelection] = useState(NO_FILTERS);\n const filtered = useFilteredSample({ profile, selection });\n // A new sample starts from no filters: the filtered rows belong to the old one.\n useEffect(() => setSelection(NO_FILTERS), [rows]);\n\n const lookupValues = useCallback<DataTableFilterLookup>(\n (request) =>\n lookupProfileSampleFilterValues({\n draft: profile,\n params: {},\n filterColumns: profile.columns ?? [],\n request: { ...request, filters: selection },\n }),\n [profile, selection],\n );\n\n return (\n <div className=\"flex h-full min-h-0 flex-col\">\n {filtered.error ? (\n <p role=\"alert\" className=\"shrink-0 px-3 py-1 text-xs text-destructive\">\n Cannot apply the filter to the sample: {filtered.error}\n </p>\n ) : null}\n <ProfileMappingPreview\n profile={profile}\n rows={filtered.error ? [] : (filtered.rows ?? rows)}\n filters={{ selection, onChange: setSelection, lookupValues }}\n />\n </div>\n );\n}\n\n/**\n * The sample's source rows for a draft with `selection` applied by the backend,\n * or null rows while nothing is selected (the unfiltered sample stands).\n */\nfunction useFilteredSample({\n profile,\n selection,\n}: {\n profile: ProfileWizardDraft;\n selection: DataTableFilterSelection;\n}): { rows: Record<string, unknown>[] | null; error: string } {\n const [state, setState] = useState<{ rows: Record<string, unknown>[] | null; error: string }>({\n rows: null,\n error: \"\",\n });\n const active = Object.keys(selection).length > 0;\n const selectionKey = JSON.stringify(selection);\n // The draft's columns are edited without sampling again: only a changed\n // selection queries the backend, with the draft as it stands then.\n const draft = useRef(profile);\n draft.current = profile;\n\n useEffect(() => {\n if (!active) {\n setState({ rows: null, error: \"\" });\n return;\n }\n const sampled = sampleRequestProfile(draft.current);\n if (!sampled) {\n setState({ rows: [], error: \"the draft has no provider to sample\" });\n return;\n }\n let current = true;\n setState((previous) => ({ ...previous, error: \"\" }));\n fetchJSON<{ mappingInputRows?: Record<string, unknown>[] }>(profileApiPath(\"profile/sample\"), {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\", ...debugCaptureHeaders() },\n body: JSON.stringify({\n profile: sampled,\n params: {},\n previewProcessors: true,\n // The sample request leaves the draft's columns out, so the columns that\n // bind each filter key to a field travel beside the selection.\n filterColumns: draft.current.columns ?? [],\n filters: JSON.parse(selectionKey) as DataTableFilterSelection,\n }),\n }).then(\n (response) => {\n if (!current) return;\n if (!response.mappingInputRows)\n return setState({ rows: [], error: \"the sample response is missing mappingInputRows\" });\n setState({ rows: response.mappingInputRows, error: \"\" });\n },\n (error: unknown) => {\n if (current) setState({ rows: [], error: error instanceof Error ? error.message : String(error) });\n },\n );\n return () => {\n current = false;\n };\n }, [active, selectionKey]);\n\n return state;\n}\n"],"mappings":";;;;;;;;;AAYA,IAAM,a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CAAC;IAAG,OAAO;GAAkD,CAAC;GACxF,SAAS;IAAE,MAAM,SAAS;IAAkB,OAAO;GAAG,CAAC;EACzD,IACC,UAAmB;GAClB,IAAI,SAAS,SAAS;IAAE,MAAM,CAAC;IAAG,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;GAAE,CAAC;EACnG,CACF;EACA,aAAa;GACX,UAAU;EACZ;CACF,GAAG,CAAC,QAAQ,YAAY,CAAC;CAEzB,OAAO;AACT"}
1
+ {"version":3,"file":"profileEditorPreview.cjs","names":["ProfileMappingPreview","useState","useCallback","lookupProfileSampleFilterValues","useRef","sampleRequestProfile","profileApiPath","debugCaptureHeaders"],"sources":["../../../src/profiles/editor/profileEditorPreview.tsx"],"sourcesContent":["import { useCallback, useEffect, useRef, useState, type ComponentProps } from \"react\";\nimport type { DataTableFilterSelection } from \"../../data/data-table-filter-values\";\nimport type { DataTableFilterLookup } from \"../../data/data-table-server-filters\";\nimport { debugCaptureHeaders } from \"../../data/debugConsoleSignal\";\nimport { fetchJSON } from \"../connections/connectionBrowserModel\";\nimport { profileApiPath } from \"../profileApi\";\nimport { lookupProfileSampleFilterValues } from \"../query/profileSampleFilterLookup\";\nimport { sampleRequestProfile } from \"../query/jsonPathSample\";\nimport type { ProfileColumn } from \"../wizard/profileWizardModel\";\nimport type { ProfileWizardDraft } from \"../wizard/profileWizardModel\";\nimport { ProfileMappingPreview } from \"./profileMappingPreview\";\n\nconst NO_FILTERS: DataTableFilterSelection = {};\n\n/**\n * The draft's results as the saved profile's page will show them, so the effect\n * of including a field, relabelling it, typing it or hiding it is visible\n * without leaving the editor.\n *\n * The rows are the sample's source rows, not a client-side projection of them:\n * the profile service keeps the sample it took, maps it by id through the\n * draft's columns, so the rows never travel back, and renders the same\n * clicky document it serves the saved profile's results page, which this shows\n * with the same Clicky component — a key_values column is tag pills, a datetime\n * is a timestamp, a duration is a duration. Rows only exist after a sample runs —\n * there is no placeholder data, because a fabricated preview is worse than none.\n *\n * The filter bar offers the filters the draft's columns declare. Filtering is\n * the backend's, so applying one samples again with it; the rows are never\n * filtered in the browser.\n */\ntype PreviewCallbacks = Pick<\n ComponentProps<typeof ProfileMappingPreview>,\n \"onNormalized\" | \"onSampleExpired\" | \"onSelectColumn\" | \"onStatusChange\"\n>;\n\nexport function ProfileEditorPreview({\n columns,\n rows,\n sampleId,\n profile,\n stale = false,\n ...callbacks\n}: {\n columns: ProfileColumn[];\n /** The sample's source rows, ahead of the draft's column mapping. */\n rows: Record<string, unknown>[];\n /** The id the service retained those rows under: what the preview maps. */\n sampleId: string | undefined;\n /** The draft being edited: its columns, aliases and filters are what the rows are mapped through. */\n profile: ProfileWizardDraft;\n stale?: boolean;\n} & PreviewCallbacks) {\n const { onNormalized, ...tableCallbacks } = callbacks;\n if (stale)\n return (\n <p role=\"status\">\n Source or query settings changed. Run a new sample to refresh the\n mapping preview.\n </p>\n );\n if (profile.render === \"traces\")\n return (\n <ProfileMappingPreview\n profile={profile}\n sampleId={sampleId}\n {...tableCallbacks}\n {...(onNormalized ? { onNormalized } : {})}\n />\n );\n\n const included = columns.some((column) => !column.hidden);\n if (rows.length === 0 || !included) {\n return (\n <p className=\"grid h-full place-items-center px-6 text-center text-xs text-muted-foreground\">\n {included ? \"Run a sample in Query to preview rows.\" : \"No columns included yet.\"}\n </p>\n );\n }\n return <FilterableTablePreview profile={profile} sampleId={sampleId} {...tableCallbacks} />;\n}\n\nfunction FilterableTablePreview({\n profile,\n sampleId,\n onSampleExpired,\n ...callbacks\n}: {\n profile: ProfileWizardDraft;\n sampleId: string | undefined;\n} & Omit<PreviewCallbacks, \"onNormalized\">) {\n const [selection, setSelection] = useState(NO_FILTERS);\n const filtered = useFilteredSample({ profile, selection });\n // A new sample starts from no filters: the filtered sample belongs to the old one.\n useEffect(() => setSelection(NO_FILTERS), [sampleId]);\n // An expired filtered sample is the filter's to take again; the unfiltered\n // one is the editor's.\n const expired = filtered.sampleId ? filtered.refresh : onSampleExpired;\n\n const lookupValues = useCallback<DataTableFilterLookup>(\n (request) =>\n lookupProfileSampleFilterValues({\n draft: profile,\n params: {},\n filterColumns: profile.columns ?? [],\n request: { ...request, filters: selection },\n }),\n [profile, selection],\n );\n\n return (\n <div className=\"flex h-full min-h-0 flex-col\">\n {filtered.error ? (\n <p role=\"alert\" className=\"shrink-0 px-3 py-1 text-xs text-destructive\">\n Cannot apply the filter to the sample: {filtered.error}. The rows below\n are from before this filter.\n </p>\n ) : null}\n <ProfileMappingPreview\n profile={profile}\n sampleId={filtered.sampleId ?? sampleId}\n stale={Boolean(filtered.error)}\n filters={{ selection, onChange: setSelection, lookupValues }}\n {...callbacks}\n {...(expired ? { onSampleExpired: expired } : {})}\n />\n </div>\n );\n}\n\ntype FilteredSample = { sampleId: string | null; error: string };\n\n/**\n * The retained sample for a draft with `selection` applied by the backend, or\n * a null id while nothing is selected (the unfiltered sample stands). A failed\n * filter keeps the sample it had, so the preview can still offer the filter bar\n * that changes it.\n */\nfunction useFilteredSample({\n profile,\n selection,\n}: {\n profile: ProfileWizardDraft;\n selection: DataTableFilterSelection;\n}): FilteredSample & { refresh: () => void } {\n const [state, setState] = useState<FilteredSample>({ sampleId: null, error: \"\" });\n const [attempt, setAttempt] = useState(0);\n const refresh = useCallback(() => setAttempt((count) => count + 1), []);\n const active = Object.keys(selection).length > 0;\n const selectionKey = JSON.stringify(selection);\n // The draft's columns are edited without sampling again: only a changed\n // selection queries the backend, with the draft as it stands then.\n const draft = useRef(profile);\n draft.current = profile;\n\n useEffect(() => {\n if (!active) {\n setState({ sampleId: null, error: \"\" });\n return;\n }\n const failed = (error: string) => setState((previous) => ({ ...previous, error }));\n const sampled = sampleRequestProfile(draft.current);\n if (!sampled) {\n failed(\"the draft has no provider to sample\");\n return;\n }\n let current = true;\n setState((previous) => ({ ...previous, error: \"\" }));\n fetchJSON<{ sampleId?: string }>(profileApiPath(\"profile/sample\"), {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\", ...debugCaptureHeaders() },\n body: JSON.stringify({\n profile: sampled,\n params: {},\n previewProcessors: true,\n // The sample request leaves the draft's columns out, so the columns that\n // bind each filter key to a field travel beside the selection.\n filterColumns: draft.current.columns ?? [],\n filters: JSON.parse(selectionKey) as DataTableFilterSelection,\n }),\n }).then(\n (response) => {\n if (!current) return;\n if (!response.sampleId) return failed(\"the sample response is missing sampleId\");\n setState({ sampleId: response.sampleId, error: \"\" });\n },\n (error: unknown) => {\n if (current) failed(error instanceof Error ? error.message : String(error));\n },\n );\n return () => {\n current = false;\n };\n }, [active, selectionKey, attempt]);\n\n return { ...state, refresh };\n}\n"],"mappings":";;;;;;;;;AAYA,IAAM,aAAuC,CAAC;AAwB9C,SAAgB,qBAAqB,EACnC,SACA,MACA,UACA,SACA,QAAQ,OACR,GAAG,aAUiB;CACpB,MAAM,EAAE,cAAc,GAAG,mBAAmB;CAC5C,IAAI,OACF,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,KAAD;EAAG,MAAK;EAAS,UAAA;CAGd,CAAA;CAEP,IAAI,QAAQ,WAAW,UACrB,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACA,8BAAAA,uBAAD;EACW;EACC;EACV,GAAI;EACJ,GAAK,eAAe,EAAE,aAAa,IAAI,CAAC;CACzC,CAAA;CAGL,MAAM,WAAW,QAAQ,MAAM,WAAW,CAAC,OAAO,MAAM;CACxD,IAAI,KAAK,WAAW,KAAK,CAAC,UACxB,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,KAAD;EAAG,WAAU;EACV,UAAA,WAAW,2CAA2C;CACtD,CAAA;CAGP,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAAC,wBAAD;EAAiC;EAAmB;EAAU,GAAI;CAAiB,CAAA;AAC5F;AAEA,SAAS,uBAAuB,EAC9B,SACA,UACA,iBACA,GAAG,aAIuC;CAC1C,MAAM,CAAC,WAAW,iBAAA,GAAgBC,MAAAA,SAAAA,CAAS,UAAU;CACrD,MAAM,WAAW,kBAAkB;EAAE;EAA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,OAAAA,CAAO,OAAO;CAC5B,MAAM,UAAU;CAEhB,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,IAAI,CAAC,QAAQ;GACX,SAAS;IAAE,UAAU;IAAM,OAAO;GAAG,CAAC;GACtC;EACF;EACA,MAAM,UAAU,UAAkB,UAAU,cAAc;GAAE,GAAG;GAAU;EAAM,EAAE;EACjF,MAAM,UAAUC,uBAAAA,qBAAqB,MAAM,OAAO;EAClD,IAAI,CAAC,SAAS;GACZ,OAAO,qCAAqC;GAC5C;EACF;EACA,IAAI,UAAU;EACd,UAAU,cAAc;GAAE,GAAG;GAAU,OAAO;EAAG,EAAE;EACnD,+BAAA,UAAiCC,mBAAAA,eAAe,gBAAgB,GAAG;GACjE,QAAQ;GACR,SAAS;IAAE,gBAAgB;IAAoB,GAAGC,2BAAAA,oBAAoB;GAAE;GACxE,MAAM,KAAK,UAAU;IACnB,SAAS;IACT,QAAQ,CAAC;IACT,mBAAmB;IAGnB,eAAe,MAAM,QAAQ,WAAW,CAAC;IACzC,SAAS,KAAK,MAAM,YAAY;GAClC,CAAC;EACH,CAAC,CAAC,CAAC,MACA,aAAa;GACZ,IAAI,CAAC,SAAS;GACd,IAAI,CAAC,SAAS,UAAU,OAAO,OAAO,yCAAyC;GAC/E,SAAS;IAAE,UAAU,SAAS;IAAU,OAAO;GAAG,CAAC;EACrD,IACC,UAAmB;GAClB,IAAI,SAAS,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;EAC5E,CACF;EACA,aAAa;GACX,UAAU;EACZ;CACF,GAAG;EAAC;EAAQ;EAAc;CAAO,CAAC;CAElC,OAAO;EAAE,GAAG;EAAO;CAAQ;AAC7B"}
@@ -1,11 +1,14 @@
1
+ import { ComponentProps } from 'react';
1
2
  import { ProfileColumn, ProfileWizardDraft } from '../wizard/profileWizardModel.js';
3
+ import { ProfileMappingPreview } from './profileMappingPreview.js';
2
4
  /**
3
5
  * The draft's results as the saved profile's page will show them, so the effect
4
6
  * of including a field, relabelling it, typing it or hiding it is visible
5
7
  * without leaving the editor.
6
8
  *
7
9
  * The rows are the sample's source rows, not a client-side projection of them:
8
- * the profile service maps them through the draft's columns and renders the same
10
+ * the profile service keeps the sample it took, maps it by id through the
11
+ * draft's columns, so the rows never travel back, and renders the same
9
12
  * clicky document it serves the saved profile's results page, which this shows
10
13
  * with the same Clicky component — a key_values column is tag pills, a datetime
11
14
  * is a timestamp, a duration is a duration. Rows only exist after a sample runs —
@@ -15,14 +18,16 @@ import { ProfileColumn, ProfileWizardDraft } from '../wizard/profileWizardModel.
15
18
  * the backend's, so applying one samples again with it; the rows are never
16
19
  * filtered in the browser.
17
20
  */
18
- export declare function ProfileEditorPreview({ columns, rows, profile, stale, onNormalized, }: {
21
+ type PreviewCallbacks = Pick<ComponentProps<typeof ProfileMappingPreview>, "onNormalized" | "onSampleExpired" | "onSelectColumn" | "onStatusChange">;
22
+ export declare function ProfileEditorPreview({ columns, rows, sampleId, profile, stale, ...callbacks }: {
19
23
  columns: ProfileColumn[];
20
24
  /** The sample's source rows, ahead of the draft's column mapping. */
21
25
  rows: Record<string, unknown>[];
26
+ /** The id the service retained those rows under: what the preview maps. */
27
+ sampleId: string | undefined;
22
28
  /** The draft being edited: its columns, aliases and filters are what the rows are mapped through. */
23
29
  profile: ProfileWizardDraft;
24
30
  stale?: boolean;
25
- /** Receives the span-normalised rows and columns of a traces profile. */
26
- onNormalized?: (rows: Record<string, unknown>[], columns: ProfileColumn[]) => void;
27
- }): import("react").JSX.Element;
31
+ } & PreviewCallbacks): import("react").JSX.Element;
32
+ export {};
28
33
  //# sourceMappingURL=profileEditorPreview.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"profileEditorPreview.d.ts","sourceRoot":"","sources":["../../../src/profiles/editor/profileEditorPreview.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAKvE;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,OAAO,EACP,IAAI,EACJ,OAAO,EACP,KAAa,EACb,YAAY,GACb,EAAE;IACD,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,qEAAqE;IACrE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;IAChC,qGAAqG;IACrG,OAAO,EAAE,kBAAkB,CAAC;IAC5B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,yEAAyE;IACzE,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAAE,OAAO,EAAE,aAAa,EAAE,KAAK,IAAI,CAAC;CACpF,+BAoBA"}
1
+ {"version":3,"file":"profileEditorPreview.d.ts","sourceRoot":"","sources":["../../../src/profiles/editor/profileEditorPreview.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA4C,KAAK,cAAc,EAAE,MAAM,OAAO,CAAC;AAQtF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAIhE;;;;;;;;;;;;;;;;GAgBG;AACH,KAAK,gBAAgB,GAAG,IAAI,CAC1B,cAAc,CAAC,OAAO,qBAAqB,CAAC,EAC5C,cAAc,GAAG,iBAAiB,GAAG,gBAAgB,GAAG,gBAAgB,CACzE,CAAC;AAEF,wBAAgB,oBAAoB,CAAC,EACnC,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,KAAa,EACb,GAAG,SAAS,EACb,EAAE;IACD,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,qEAAqE;IACrE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;IAChC,2EAA2E;IAC3E,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,qGAAqG;IACrG,OAAO,EAAE,kBAAkB,CAAC;IAC5B,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,GAAG,gBAAgB,+BA4BnB"}
@@ -8,30 +8,16 @@ import { useCallback, useEffect, useRef, useState } from "react";
8
8
  import { jsx, jsxs } from "react/jsx-runtime";
9
9
  // src/profiles/editor/profileEditorPreview.tsx
10
10
  var NO_FILTERS = {};
11
- /**
12
- * The draft's results as the saved profile's page will show them, so the effect
13
- * of including a field, relabelling it, typing it or hiding it is visible
14
- * without leaving the editor.
15
- *
16
- * The rows are the sample's source rows, not a client-side projection of them:
17
- * the profile service maps them through the draft's columns and renders the same
18
- * clicky document it serves the saved profile's results page, which this shows
19
- * with the same Clicky component — a key_values column is tag pills, a datetime
20
- * is a timestamp, a duration is a duration. Rows only exist after a sample runs —
21
- * there is no placeholder data, because a fabricated preview is worse than none.
22
- *
23
- * The filter bar offers the filters the draft's columns declare. Filtering is
24
- * the backend's, so applying one samples again with it; the rows are never
25
- * filtered in the browser.
26
- */
27
- function ProfileEditorPreview({ columns, rows, profile, stale = false, onNormalized }) {
11
+ function ProfileEditorPreview({ columns, rows, sampleId, profile, stale = false, ...callbacks }) {
12
+ const { onNormalized, ...tableCallbacks } = callbacks;
28
13
  if (stale) return /* @__PURE__ */ jsx("p", {
29
14
  role: "status",
30
15
  children: "Source or query settings changed. Run a new sample to refresh the mapping preview."
31
16
  });
32
17
  if (profile.render === "traces") return /* @__PURE__ */ jsx(ProfileMappingPreview, {
33
18
  profile,
34
- rows,
19
+ sampleId,
20
+ ...tableCallbacks,
35
21
  ...onNormalized ? { onNormalized } : {}
36
22
  });
37
23
  const included = columns.some((column) => !column.hidden);
@@ -41,16 +27,18 @@ function ProfileEditorPreview({ columns, rows, profile, stale = false, onNormali
41
27
  });
42
28
  return /* @__PURE__ */ jsx(FilterableTablePreview, {
43
29
  profile,
44
- rows
30
+ sampleId,
31
+ ...tableCallbacks
45
32
  });
46
33
  }
47
- function FilterableTablePreview({ profile, rows }) {
34
+ function FilterableTablePreview({ profile, sampleId, onSampleExpired, ...callbacks }) {
48
35
  const [selection, setSelection] = useState(NO_FILTERS);
49
36
  const filtered = useFilteredSample({
50
37
  profile,
51
38
  selection
52
39
  });
53
- useEffect(() => setSelection(NO_FILTERS), [rows]);
40
+ useEffect(() => setSelection(NO_FILTERS), [sampleId]);
41
+ const expired = filtered.sampleId ? filtered.refresh : onSampleExpired;
54
42
  const lookupValues = useCallback((request) => lookupProfileSampleFilterValues({
55
43
  draft: profile,
56
44
  params: {},
@@ -65,27 +53,38 @@ function FilterableTablePreview({ profile, rows }) {
65
53
  children: [filtered.error ? /* @__PURE__ */ jsxs("p", {
66
54
  role: "alert",
67
55
  className: "shrink-0 px-3 py-1 text-xs text-destructive",
68
- children: ["Cannot apply the filter to the sample: ", filtered.error]
56
+ children: [
57
+ "Cannot apply the filter to the sample: ",
58
+ filtered.error,
59
+ ". The rows below are from before this filter."
60
+ ]
69
61
  }) : null, /* @__PURE__ */ jsx(ProfileMappingPreview, {
70
62
  profile,
71
- rows: filtered.error ? [] : filtered.rows ?? rows,
63
+ sampleId: filtered.sampleId ?? sampleId,
64
+ stale: Boolean(filtered.error),
72
65
  filters: {
73
66
  selection,
74
67
  onChange: setSelection,
75
68
  lookupValues
76
- }
69
+ },
70
+ ...callbacks,
71
+ ...expired ? { onSampleExpired: expired } : {}
77
72
  })]
78
73
  });
79
74
  }
80
75
  /**
81
- * The sample's source rows for a draft with `selection` applied by the backend,
82
- * or null rows while nothing is selected (the unfiltered sample stands).
76
+ * The retained sample for a draft with `selection` applied by the backend, or
77
+ * a null id while nothing is selected (the unfiltered sample stands). A failed
78
+ * filter keeps the sample it had, so the preview can still offer the filter bar
79
+ * that changes it.
83
80
  */
84
81
  function useFilteredSample({ profile, selection }) {
85
82
  const [state, setState] = useState({
86
- rows: null,
83
+ sampleId: null,
87
84
  error: ""
88
85
  });
86
+ const [attempt, setAttempt] = useState(0);
87
+ const refresh = useCallback(() => setAttempt((count) => count + 1), []);
89
88
  const active = Object.keys(selection).length > 0;
90
89
  const selectionKey = JSON.stringify(selection);
91
90
  const draft = useRef(profile);
@@ -93,17 +92,18 @@ function useFilteredSample({ profile, selection }) {
93
92
  useEffect(() => {
94
93
  if (!active) {
95
94
  setState({
96
- rows: null,
95
+ sampleId: null,
97
96
  error: ""
98
97
  });
99
98
  return;
100
99
  }
100
+ const failed = (error) => setState((previous) => ({
101
+ ...previous,
102
+ error
103
+ }));
101
104
  const sampled = sampleRequestProfile(draft.current);
102
105
  if (!sampled) {
103
- setState({
104
- rows: [],
105
- error: "the draft has no provider to sample"
106
- });
106
+ failed("the draft has no provider to sample");
107
107
  return;
108
108
  }
109
109
  let current = true;
@@ -126,25 +126,26 @@ function useFilteredSample({ profile, selection }) {
126
126
  })
127
127
  }).then((response) => {
128
128
  if (!current) return;
129
- if (!response.mappingInputRows) return setState({
130
- rows: [],
131
- error: "the sample response is missing mappingInputRows"
132
- });
129
+ if (!response.sampleId) return failed("the sample response is missing sampleId");
133
130
  setState({
134
- rows: response.mappingInputRows,
131
+ sampleId: response.sampleId,
135
132
  error: ""
136
133
  });
137
134
  }, (error) => {
138
- if (current) setState({
139
- rows: [],
140
- error: error instanceof Error ? error.message : String(error)
141
- });
135
+ if (current) failed(error instanceof Error ? error.message : String(error));
142
136
  });
143
137
  return () => {
144
138
  current = false;
145
139
  };
146
- }, [active, selectionKey]);
147
- return state;
140
+ }, [
141
+ active,
142
+ selectionKey,
143
+ attempt
144
+ ]);
145
+ return {
146
+ ...state,
147
+ refresh
148
+ };
148
149
  }
149
150
  export { ProfileEditorPreview };
150
151
 
@@ -1 +1 @@
1
- {"version":3,"file":"profileEditorPreview.js","names":[],"sources":["../../../src/profiles/editor/profileEditorPreview.tsx"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from \"react\";\nimport type { DataTableFilterSelection } from \"../../data/data-table-filter-values\";\nimport type { DataTableFilterLookup } from \"../../data/data-table-server-filters\";\nimport { debugCaptureHeaders } from \"../../data/debugConsoleSignal\";\nimport { fetchJSON } from \"../connections/connectionBrowserModel\";\nimport { profileApiPath } from \"../profileApi\";\nimport { lookupProfileSampleFilterValues } from \"../query/profileSampleFilterLookup\";\nimport { sampleRequestProfile } from \"../query/jsonPathSample\";\nimport type { ProfileColumn } from \"../wizard/profileWizardModel\";\nimport type { ProfileWizardDraft } from \"../wizard/profileWizardModel\";\nimport { ProfileMappingPreview } from \"./profileMappingPreview\";\n\nconst NO_FILTERS: DataTableFilterSelection = {};\n\n/**\n * The draft's results as the saved profile's page will show them, so the effect\n * of including a field, relabelling it, typing it or hiding it is visible\n * without leaving the editor.\n *\n * The rows are the sample's source rows, not a client-side projection of them:\n * the profile service maps them through the draft's columns and renders the same\n * clicky document it serves the saved profile's results page, which this shows\n * with the same Clicky component — a key_values column is tag pills, a datetime\n * is a timestamp, a duration is a duration. Rows only exist after a sample runs —\n * there is no placeholder data, because a fabricated preview is worse than none.\n *\n * The filter bar offers the filters the draft's columns declare. Filtering is\n * the backend's, so applying one samples again with it; the rows are never\n * filtered in the browser.\n */\nexport function ProfileEditorPreview({\n columns,\n rows,\n profile,\n stale = false,\n onNormalized,\n}: {\n columns: ProfileColumn[];\n /** The sample's source rows, ahead of the draft's column mapping. */\n rows: Record<string, unknown>[];\n /** The draft being edited: its columns, aliases and filters are what the rows are mapped through. */\n profile: ProfileWizardDraft;\n stale?: boolean;\n /** Receives the span-normalised rows and columns of a traces profile. */\n onNormalized?: (rows: Record<string, unknown>[], columns: ProfileColumn[]) => void;\n}) {\n if (stale)\n return (\n <p role=\"status\">\n Source or query settings changed. Run a new sample to refresh the\n mapping preview.\n </p>\n );\n if (profile.render === \"traces\")\n return <ProfileMappingPreview profile={profile} rows={rows} {...(onNormalized ? {onNormalized} : {})} />;\n\n const included = columns.some((column) => !column.hidden);\n if (rows.length === 0 || !included) {\n return (\n <p className=\"grid h-full place-items-center px-6 text-center text-xs text-muted-foreground\">\n {included ? \"Run a sample in Query to preview rows.\" : \"No columns included yet.\"}\n </p>\n );\n }\n return <FilterableTablePreview profile={profile} rows={rows} />;\n}\n\nfunction FilterableTablePreview({\n profile,\n rows,\n}: {\n profile: ProfileWizardDraft;\n rows: Record<string, unknown>[];\n}) {\n const [selection, setSelection] = useState(NO_FILTERS);\n const filtered = useFilteredSample({ profile, selection });\n // A new sample starts from no filters: the filtered rows belong to the old one.\n useEffect(() => setSelection(NO_FILTERS), [rows]);\n\n const lookupValues = useCallback<DataTableFilterLookup>(\n (request) =>\n lookupProfileSampleFilterValues({\n draft: profile,\n params: {},\n filterColumns: profile.columns ?? [],\n request: { ...request, filters: selection },\n }),\n [profile, selection],\n );\n\n return (\n <div className=\"flex h-full min-h-0 flex-col\">\n {filtered.error ? (\n <p role=\"alert\" className=\"shrink-0 px-3 py-1 text-xs text-destructive\">\n Cannot apply the filter to the sample: {filtered.error}\n </p>\n ) : null}\n <ProfileMappingPreview\n profile={profile}\n rows={filtered.error ? [] : (filtered.rows ?? rows)}\n filters={{ selection, onChange: setSelection, lookupValues }}\n />\n </div>\n );\n}\n\n/**\n * The sample's source rows for a draft with `selection` applied by the backend,\n * or null rows while nothing is selected (the unfiltered sample stands).\n */\nfunction useFilteredSample({\n profile,\n selection,\n}: {\n profile: ProfileWizardDraft;\n selection: DataTableFilterSelection;\n}): { rows: Record<string, unknown>[] | null; error: string } {\n const [state, setState] = useState<{ rows: Record<string, unknown>[] | null; error: string }>({\n rows: null,\n error: \"\",\n });\n const active = Object.keys(selection).length > 0;\n const selectionKey = JSON.stringify(selection);\n // The draft's columns are edited without sampling again: only a changed\n // selection queries the backend, with the draft as it stands then.\n const draft = useRef(profile);\n draft.current = profile;\n\n useEffect(() => {\n if (!active) {\n setState({ rows: null, error: \"\" });\n return;\n }\n const sampled = sampleRequestProfile(draft.current);\n if (!sampled) {\n setState({ rows: [], error: \"the draft has no provider to sample\" });\n return;\n }\n let current = true;\n setState((previous) => ({ ...previous, error: \"\" }));\n fetchJSON<{ mappingInputRows?: Record<string, unknown>[] }>(profileApiPath(\"profile/sample\"), {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\", ...debugCaptureHeaders() },\n body: JSON.stringify({\n profile: sampled,\n params: {},\n previewProcessors: true,\n // The sample request leaves the draft's columns out, so the columns that\n // bind each filter key to a field travel beside the selection.\n filterColumns: draft.current.columns ?? [],\n filters: JSON.parse(selectionKey) as DataTableFilterSelection,\n }),\n }).then(\n (response) => {\n if (!current) return;\n if (!response.mappingInputRows)\n return setState({ rows: [], error: \"the sample response is missing mappingInputRows\" });\n setState({ rows: response.mappingInputRows, error: \"\" });\n },\n (error: unknown) => {\n if (current) setState({ rows: [], error: error instanceof Error ? error.message : String(error) });\n },\n );\n return () => {\n current = false;\n };\n }, [active, selectionKey]);\n\n return state;\n}\n"],"mappings":";;;;;;;;;AAYA,IAAM,aAAuC,CAAC;;;;;;;;;;;;;;;;;AAkB9C,SAAgB,qBAAqB,EACnC,SACA,MACA,SACA,QAAQ,OACR,gBAUC;CACD,IAAI,OACF,OACE,oBAAC,KAAD;EAAG,MAAK;EAAS,UAAA;CAGd,CAAA;CAEP,IAAI,QAAQ,WAAW,UACrB,OAAO,oBAAC,uBAAD;EAAgC;EAAe;EAAM,GAAK,eAAe,EAAC,aAAY,IAAI,CAAC;CAAK,CAAA;CAEzG,MAAM,WAAW,QAAQ,MAAM,WAAW,CAAC,OAAO,MAAM;CACxD,IAAI,KAAK,WAAW,KAAK,CAAC,UACxB,OACE,oBAAC,KAAD;EAAG,WAAU;EACV,UAAA,WAAW,2CAA2C;CACtD,CAAA;CAGP,OAAO,oBAAC,wBAAD;EAAiC;EAAe;CAAO,CAAA;AAChE;AAEA,SAAS,uBAAuB,EAC9B,SACA,QAIC;CACD,MAAM,CAAC,WAAW,gBAAgB,SAAS,UAAU;CACrD,MAAM,WAAW,kBAAkB;EAAE;EAAS;CAAU,CAAC;CAEzD,gBAAgB,aAAa,UAA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B;IAGnB,eAAe,MAAM,QAAQ,WAAW,CAAC;IACzC,SAAS,KAAK,MAAM,YAAY;GAClC,CAAC;EACH,CAAC,CAAC,CAAC,MACA,aAAa;GACZ,IAAI,CAAC,SAAS;GACd,IAAI,CAAC,SAAS,kBACZ,OAAO,SAAS;IAAE,MAAM,CAAC;IAAG,OAAO;GAAkD,CAAC;GACxF,SAAS;IAAE,MAAM,SAAS;IAAkB,OAAO;GAAG,CAAC;EACzD,IACC,UAAmB;GAClB,IAAI,SAAS,SAAS;IAAE,MAAM,CAAC;IAAG,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;GAAE,CAAC;EACnG,CACF;EACA,aAAa;GACX,UAAU;EACZ;CACF,GAAG,CAAC,QAAQ,YAAY,CAAC;CAEzB,OAAO;AACT"}
1
+ {"version":3,"file":"profileEditorPreview.js","names":[],"sources":["../../../src/profiles/editor/profileEditorPreview.tsx"],"sourcesContent":["import { useCallback, useEffect, useRef, useState, type ComponentProps } from \"react\";\nimport type { DataTableFilterSelection } from \"../../data/data-table-filter-values\";\nimport type { DataTableFilterLookup } from \"../../data/data-table-server-filters\";\nimport { debugCaptureHeaders } from \"../../data/debugConsoleSignal\";\nimport { fetchJSON } from \"../connections/connectionBrowserModel\";\nimport { profileApiPath } from \"../profileApi\";\nimport { lookupProfileSampleFilterValues } from \"../query/profileSampleFilterLookup\";\nimport { sampleRequestProfile } from \"../query/jsonPathSample\";\nimport type { ProfileColumn } from \"../wizard/profileWizardModel\";\nimport type { ProfileWizardDraft } from \"../wizard/profileWizardModel\";\nimport { ProfileMappingPreview } from \"./profileMappingPreview\";\n\nconst NO_FILTERS: DataTableFilterSelection = {};\n\n/**\n * The draft's results as the saved profile's page will show them, so the effect\n * of including a field, relabelling it, typing it or hiding it is visible\n * without leaving the editor.\n *\n * The rows are the sample's source rows, not a client-side projection of them:\n * the profile service keeps the sample it took, maps it by id through the\n * draft's columns, so the rows never travel back, and renders the same\n * clicky document it serves the saved profile's results page, which this shows\n * with the same Clicky component — a key_values column is tag pills, a datetime\n * is a timestamp, a duration is a duration. Rows only exist after a sample runs —\n * there is no placeholder data, because a fabricated preview is worse than none.\n *\n * The filter bar offers the filters the draft's columns declare. Filtering is\n * the backend's, so applying one samples again with it; the rows are never\n * filtered in the browser.\n */\ntype PreviewCallbacks = Pick<\n ComponentProps<typeof ProfileMappingPreview>,\n \"onNormalized\" | \"onSampleExpired\" | \"onSelectColumn\" | \"onStatusChange\"\n>;\n\nexport function ProfileEditorPreview({\n columns,\n rows,\n sampleId,\n profile,\n stale = false,\n ...callbacks\n}: {\n columns: ProfileColumn[];\n /** The sample's source rows, ahead of the draft's column mapping. */\n rows: Record<string, unknown>[];\n /** The id the service retained those rows under: what the preview maps. */\n sampleId: string | undefined;\n /** The draft being edited: its columns, aliases and filters are what the rows are mapped through. */\n profile: ProfileWizardDraft;\n stale?: boolean;\n} & PreviewCallbacks) {\n const { onNormalized, ...tableCallbacks } = callbacks;\n if (stale)\n return (\n <p role=\"status\">\n Source or query settings changed. Run a new sample to refresh the\n mapping preview.\n </p>\n );\n if (profile.render === \"traces\")\n return (\n <ProfileMappingPreview\n profile={profile}\n sampleId={sampleId}\n {...tableCallbacks}\n {...(onNormalized ? { onNormalized } : {})}\n />\n );\n\n const included = columns.some((column) => !column.hidden);\n if (rows.length === 0 || !included) {\n return (\n <p className=\"grid h-full place-items-center px-6 text-center text-xs text-muted-foreground\">\n {included ? \"Run a sample in Query to preview rows.\" : \"No columns included yet.\"}\n </p>\n );\n }\n return <FilterableTablePreview profile={profile} sampleId={sampleId} {...tableCallbacks} />;\n}\n\nfunction FilterableTablePreview({\n profile,\n sampleId,\n onSampleExpired,\n ...callbacks\n}: {\n profile: ProfileWizardDraft;\n sampleId: string | undefined;\n} & Omit<PreviewCallbacks, \"onNormalized\">) {\n const [selection, setSelection] = useState(NO_FILTERS);\n const filtered = useFilteredSample({ profile, selection });\n // A new sample starts from no filters: the filtered sample belongs to the old one.\n useEffect(() => setSelection(NO_FILTERS), [sampleId]);\n // An expired filtered sample is the filter's to take again; the unfiltered\n // one is the editor's.\n const expired = filtered.sampleId ? filtered.refresh : onSampleExpired;\n\n const lookupValues = useCallback<DataTableFilterLookup>(\n (request) =>\n lookupProfileSampleFilterValues({\n draft: profile,\n params: {},\n filterColumns: profile.columns ?? [],\n request: { ...request, filters: selection },\n }),\n [profile, selection],\n );\n\n return (\n <div className=\"flex h-full min-h-0 flex-col\">\n {filtered.error ? (\n <p role=\"alert\" className=\"shrink-0 px-3 py-1 text-xs text-destructive\">\n Cannot apply the filter to the sample: {filtered.error}. The rows below\n are from before this filter.\n </p>\n ) : null}\n <ProfileMappingPreview\n profile={profile}\n sampleId={filtered.sampleId ?? sampleId}\n stale={Boolean(filtered.error)}\n filters={{ selection, onChange: setSelection, lookupValues }}\n {...callbacks}\n {...(expired ? { onSampleExpired: expired } : {})}\n />\n </div>\n );\n}\n\ntype FilteredSample = { sampleId: string | null; error: string };\n\n/**\n * The retained sample for a draft with `selection` applied by the backend, or\n * a null id while nothing is selected (the unfiltered sample stands). A failed\n * filter keeps the sample it had, so the preview can still offer the filter bar\n * that changes it.\n */\nfunction useFilteredSample({\n profile,\n selection,\n}: {\n profile: ProfileWizardDraft;\n selection: DataTableFilterSelection;\n}): FilteredSample & { refresh: () => void } {\n const [state, setState] = useState<FilteredSample>({ sampleId: null, error: \"\" });\n const [attempt, setAttempt] = useState(0);\n const refresh = useCallback(() => setAttempt((count) => count + 1), []);\n const active = Object.keys(selection).length > 0;\n const selectionKey = JSON.stringify(selection);\n // The draft's columns are edited without sampling again: only a changed\n // selection queries the backend, with the draft as it stands then.\n const draft = useRef(profile);\n draft.current = profile;\n\n useEffect(() => {\n if (!active) {\n setState({ sampleId: null, error: \"\" });\n return;\n }\n const failed = (error: string) => setState((previous) => ({ ...previous, error }));\n const sampled = sampleRequestProfile(draft.current);\n if (!sampled) {\n failed(\"the draft has no provider to sample\");\n return;\n }\n let current = true;\n setState((previous) => ({ ...previous, error: \"\" }));\n fetchJSON<{ sampleId?: string }>(profileApiPath(\"profile/sample\"), {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\", ...debugCaptureHeaders() },\n body: JSON.stringify({\n profile: sampled,\n params: {},\n previewProcessors: true,\n // The sample request leaves the draft's columns out, so the columns that\n // bind each filter key to a field travel beside the selection.\n filterColumns: draft.current.columns ?? [],\n filters: JSON.parse(selectionKey) as DataTableFilterSelection,\n }),\n }).then(\n (response) => {\n if (!current) return;\n if (!response.sampleId) return failed(\"the sample response is missing sampleId\");\n setState({ sampleId: response.sampleId, error: \"\" });\n },\n (error: unknown) => {\n if (current) failed(error instanceof Error ? error.message : String(error));\n },\n );\n return () => {\n current = false;\n };\n }, [active, selectionKey, attempt]);\n\n return { ...state, refresh };\n}\n"],"mappings":";;;;;;;;;AAYA,IAAM,aAAuC,CAAC;AAwB9C,SAAgB,qBAAqB,EACnC,SACA,MACA,UACA,SACA,QAAQ,OACR,GAAG,aAUiB;CACpB,MAAM,EAAE,cAAc,GAAG,mBAAmB;CAC5C,IAAI,OACF,OACE,oBAAC,KAAD;EAAG,MAAK;EAAS,UAAA;CAGd,CAAA;CAEP,IAAI,QAAQ,WAAW,UACrB,OACE,oBAAC,uBAAD;EACW;EACC;EACV,GAAI;EACJ,GAAK,eAAe,EAAE,aAAa,IAAI,CAAC;CACzC,CAAA;CAGL,MAAM,WAAW,QAAQ,MAAM,WAAW,CAAC,OAAO,MAAM;CACxD,IAAI,KAAK,WAAW,KAAK,CAAC,UACxB,OACE,oBAAC,KAAD;EAAG,WAAU;EACV,UAAA,WAAW,2CAA2C;CACtD,CAAA;CAGP,OAAO,oBAAC,wBAAD;EAAiC;EAAmB;EAAU,GAAI;CAAiB,CAAA;AAC5F;AAEA,SAAS,uBAAuB,EAC9B,SACA,UACA,iBACA,GAAG,aAIuC;CAC1C,MAAM,CAAC,WAAW,gBAAgB,SAAS,UAAU;CACrD,MAAM,WAAW,kBAAkB;EAAE;EAAS;CAAU,CAAC;CAE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