@dudousxd/nestjs-catalog-react 0.1.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 (239) hide show
  1. package/LICENSE-bklit +21 -0
  2. package/README.md +282 -0
  3. package/dist/AccessConsole.d.ts +40 -0
  4. package/dist/AccessConsole.js +160 -0
  5. package/dist/CatalogManager.d.ts +12 -0
  6. package/dist/CatalogManager.js +123 -0
  7. package/dist/ConnectionPanel.d.ts +41 -0
  8. package/dist/ConnectionPanel.js +228 -0
  9. package/dist/CoverageLedger.d.ts +16 -0
  10. package/dist/CoverageLedger.js +16 -0
  11. package/dist/DashboardBoard.d.ts +10 -0
  12. package/dist/DashboardBoard.js +206 -0
  13. package/dist/EditableField.d.ts +18 -0
  14. package/dist/EditableField.js +61 -0
  15. package/dist/FlowView.d.ts +13 -0
  16. package/dist/FlowView.js +93 -0
  17. package/dist/GovernanceTimeline.d.ts +16 -0
  18. package/dist/GovernanceTimeline.js +93 -0
  19. package/dist/ObjectExplorer.d.ts +9 -0
  20. package/dist/ObjectExplorer.js +153 -0
  21. package/dist/PipelineConsole.d.ts +20 -0
  22. package/dist/PipelineConsole.js +272 -0
  23. package/dist/QueryConsole.d.ts +11 -0
  24. package/dist/QueryConsole.js +144 -0
  25. package/dist/SavedQueryPanel.d.ts +16 -0
  26. package/dist/SavedQueryPanel.js +78 -0
  27. package/dist/TraceExplorer.d.ts +54 -0
  28. package/dist/TraceExplorer.js +342 -0
  29. package/dist/TransformEditor.d.ts +23 -0
  30. package/dist/TransformEditor.js +129 -0
  31. package/dist/WorkflowCanvas.d.ts +24 -0
  32. package/dist/WorkflowCanvas.js +701 -0
  33. package/dist/charts/bklit/animation.d.ts +19 -0
  34. package/dist/charts/bklit/animation.js +28 -0
  35. package/dist/charts/bklit/area-chart-loading.d.ts +33 -0
  36. package/dist/charts/bklit/area-chart-loading.js +30 -0
  37. package/dist/charts/bklit/area-chart.d.ts +47 -0
  38. package/dist/charts/bklit/area-chart.js +65 -0
  39. package/dist/charts/bklit/area-gradient-defs.d.ts +28 -0
  40. package/dist/charts/bklit/area-gradient-defs.js +23 -0
  41. package/dist/charts/bklit/area.d.ts +75 -0
  42. package/dist/charts/bklit/area.js +112 -0
  43. package/dist/charts/bklit/bar-chart-loading.d.ts +16 -0
  44. package/dist/charts/bklit/bar-chart-loading.js +22 -0
  45. package/dist/charts/bklit/bar-chart.d.ts +54 -0
  46. package/dist/charts/bklit/bar-chart.js +440 -0
  47. package/dist/charts/bklit/bar-depth-geometry.d.ts +41 -0
  48. package/dist/charts/bklit/bar-depth-geometry.js +46 -0
  49. package/dist/charts/bklit/bar-squares-layout.d.ts +36 -0
  50. package/dist/charts/bklit/bar-squares-layout.js +46 -0
  51. package/dist/charts/bklit/bar-squares.d.ts +48 -0
  52. package/dist/charts/bklit/bar-squares.js +206 -0
  53. package/dist/charts/bklit/bar-x-axis.d.ts +13 -0
  54. package/dist/charts/bklit/bar-x-axis.js +81 -0
  55. package/dist/charts/bklit/bar-y-axis.d.ts +11 -0
  56. package/dist/charts/bklit/bar-y-axis.js +72 -0
  57. package/dist/charts/bklit/bar.d.ts +40 -0
  58. package/dist/charts/bklit/bar.js +207 -0
  59. package/dist/charts/bklit/chart-child-passthrough.d.ts +25 -0
  60. package/dist/charts/bklit/chart-child-passthrough.js +82 -0
  61. package/dist/charts/bklit/chart-config-context.d.ts +34 -0
  62. package/dist/charts/bklit/chart-config-context.js +55 -0
  63. package/dist/charts/bklit/chart-context.d.ts +207 -0
  64. package/dist/charts/bklit/chart-context.js +200 -0
  65. package/dist/charts/bklit/chart-defs.d.ts +21 -0
  66. package/dist/charts/bklit/chart-defs.js +57 -0
  67. package/dist/charts/bklit/chart-formatters.d.ts +16 -0
  68. package/dist/charts/bklit/chart-formatters.js +26 -0
  69. package/dist/charts/bklit/chart-legend-hover.d.ts +21 -0
  70. package/dist/charts/bklit/chart-legend-hover.js +26 -0
  71. package/dist/charts/bklit/chart-loading-label.d.ts +9 -0
  72. package/dist/charts/bklit/chart-loading-label.js +29 -0
  73. package/dist/charts/bklit/chart-phase.d.ts +39 -0
  74. package/dist/charts/bklit/chart-phase.js +20 -0
  75. package/dist/charts/bklit/chart-reveal-clip.d.ts +32 -0
  76. package/dist/charts/bklit/chart-reveal-clip.js +23 -0
  77. package/dist/charts/bklit/dash-tail-stroke.d.ts +17 -0
  78. package/dist/charts/bklit/dash-tail-stroke.js +21 -0
  79. package/dist/charts/bklit/decimate-time-series.d.ts +18 -0
  80. package/dist/charts/bklit/decimate-time-series.js +120 -0
  81. package/dist/charts/bklit/fade-edges.d.ts +42 -0
  82. package/dist/charts/bklit/fade-edges.js +34 -0
  83. package/dist/charts/bklit/filter-data-by-x-domain.d.ts +13 -0
  84. package/dist/charts/bklit/filter-data-by-x-domain.js +50 -0
  85. package/dist/charts/bklit/generate-chart-skeleton-data.d.ts +24 -0
  86. package/dist/charts/bklit/generate-chart-skeleton-data.js +33 -0
  87. package/dist/charts/bklit/grid.d.ts +57 -0
  88. package/dist/charts/bklit/grid.js +88 -0
  89. package/dist/charts/bklit/highlight-segment-bounds.d.ts +26 -0
  90. package/dist/charts/bklit/highlight-segment-bounds.js +35 -0
  91. package/dist/charts/bklit/highlight-segment.d.ts +30 -0
  92. package/dist/charts/bklit/highlight-segment.js +22 -0
  93. package/dist/charts/bklit/indicator-fade.d.ts +23 -0
  94. package/dist/charts/bklit/indicator-fade.js +41 -0
  95. package/dist/charts/bklit/line-chart-loading.d.ts +33 -0
  96. package/dist/charts/bklit/line-chart-loading.js +30 -0
  97. package/dist/charts/bklit/line-chart.d.ts +45 -0
  98. package/dist/charts/bklit/line-chart.js +99 -0
  99. package/dist/charts/bklit/line-loading-pulse.d.ts +19 -0
  100. package/dist/charts/bklit/line-loading-pulse.js +132 -0
  101. package/dist/charts/bklit/line-loading-timing.d.ts +18 -0
  102. package/dist/charts/bklit/line-loading-timing.js +18 -0
  103. package/dist/charts/bklit/line-series-terminal-marker.d.ts +15 -0
  104. package/dist/charts/bklit/line-series-terminal-marker.js +54 -0
  105. package/dist/charts/bklit/line.d.ts +63 -0
  106. package/dist/charts/bklit/line.js +104 -0
  107. package/dist/charts/bklit/loading-sweep.d.ts +65 -0
  108. package/dist/charts/bklit/loading-sweep.js +182 -0
  109. package/dist/charts/bklit/motion-utils.d.ts +17 -0
  110. package/dist/charts/bklit/motion-utils.js +27 -0
  111. package/dist/charts/bklit/path-stroke-utils.d.ts +28 -0
  112. package/dist/charts/bklit/path-stroke-utils.js +64 -0
  113. package/dist/charts/bklit/pattern-area.d.ts +20 -0
  114. package/dist/charts/bklit/pattern-area.js +27 -0
  115. package/dist/charts/bklit/pattern-preset.d.ts +34 -0
  116. package/dist/charts/bklit/pattern-preset.js +82 -0
  117. package/dist/charts/bklit/projection-config.d.ts +19 -0
  118. package/dist/charts/bklit/projection-config.js +88 -0
  119. package/dist/charts/bklit/projection-line-end-marker.d.ts +14 -0
  120. package/dist/charts/bklit/projection-line-end-marker.js +35 -0
  121. package/dist/charts/bklit/projection-line.d.ts +39 -0
  122. package/dist/charts/bklit/projection-line.js +87 -0
  123. package/dist/charts/bklit/projection-utils.d.ts +54 -0
  124. package/dist/charts/bklit/projection-utils.js +252 -0
  125. package/dist/charts/bklit/reference-area-config.d.ts +18 -0
  126. package/dist/charts/bklit/reference-area-config.js +47 -0
  127. package/dist/charts/bklit/reference-area-registration-context.d.ts +7 -0
  128. package/dist/charts/bklit/reference-area-registration-context.js +15 -0
  129. package/dist/charts/bklit/series-bar-layout.d.ts +26 -0
  130. package/dist/charts/bklit/series-bar-layout.js +39 -0
  131. package/dist/charts/bklit/series-dash-tail-overlay.d.ts +16 -0
  132. package/dist/charts/bklit/series-dash-tail-overlay.js +47 -0
  133. package/dist/charts/bklit/series-highlight-layer.d.ts +31 -0
  134. package/dist/charts/bklit/series-highlight-layer.js +20 -0
  135. package/dist/charts/bklit/series-hover-dim.d.ts +28 -0
  136. package/dist/charts/bklit/series-hover-dim.js +34 -0
  137. package/dist/charts/bklit/series-markers.d.ts +13 -0
  138. package/dist/charts/bklit/series-markers.js +106 -0
  139. package/dist/charts/bklit/series-path-utils.d.ts +18 -0
  140. package/dist/charts/bklit/series-path-utils.js +68 -0
  141. package/dist/charts/bklit/series-point-marker.d.ts +47 -0
  142. package/dist/charts/bklit/series-point-marker.js +47 -0
  143. package/dist/charts/bklit/static-chart-preview-context.d.ts +15 -0
  144. package/dist/charts/bklit/static-chart-preview-context.js +20 -0
  145. package/dist/charts/bklit/time-series-chart-shell.d.ts +46 -0
  146. package/dist/charts/bklit/time-series-chart-shell.js +398 -0
  147. package/dist/charts/bklit/tooltip/chart-tooltip.d.ts +75 -0
  148. package/dist/charts/bklit/tooltip/chart-tooltip.js +158 -0
  149. package/dist/charts/bklit/tooltip/date-ticker.d.ts +10 -0
  150. package/dist/charts/bklit/tooltip/date-ticker.js +85 -0
  151. package/dist/charts/bklit/tooltip/index.d.ts +15 -0
  152. package/dist/charts/bklit/tooltip/index.js +15 -0
  153. package/dist/charts/bklit/tooltip/tooltip-box.d.ts +56 -0
  154. package/dist/charts/bklit/tooltip/tooltip-box.js +122 -0
  155. package/dist/charts/bklit/tooltip/tooltip-content.d.ts +26 -0
  156. package/dist/charts/bklit/tooltip/tooltip-content.js +8 -0
  157. package/dist/charts/bklit/tooltip/tooltip-dot.d.ts +27 -0
  158. package/dist/charts/bklit/tooltip/tooltip-dot.js +62 -0
  159. package/dist/charts/bklit/tooltip/tooltip-indicator.d.ts +44 -0
  160. package/dist/charts/bklit/tooltip/tooltip-indicator.js +73 -0
  161. package/dist/charts/bklit/use-animated-series-path.d.ts +18 -0
  162. package/dist/charts/bklit/use-animated-series-path.js +101 -0
  163. package/dist/charts/bklit/use-animated-y-domains.d.ts +13 -0
  164. package/dist/charts/bklit/use-animated-y-domains.js +158 -0
  165. package/dist/charts/bklit/use-chart-interaction.d.ts +40 -0
  166. package/dist/charts/bklit/use-chart-interaction.js +252 -0
  167. package/dist/charts/bklit/use-chart-phase-orchestrator.d.ts +22 -0
  168. package/dist/charts/bklit/use-chart-phase-orchestrator.js +147 -0
  169. package/dist/charts/bklit/use-enter-complete.d.ts +16 -0
  170. package/dist/charts/bklit/use-enter-complete.js +22 -0
  171. package/dist/charts/bklit/use-grid-shimmer.d.ts +15 -0
  172. package/dist/charts/bklit/use-grid-shimmer.js +71 -0
  173. package/dist/charts/bklit/use-highlight-segment.d.ts +22 -0
  174. package/dist/charts/bklit/use-highlight-segment.js +42 -0
  175. package/dist/charts/bklit/use-mount-progress.d.ts +12 -0
  176. package/dist/charts/bklit/use-mount-progress.js +30 -0
  177. package/dist/charts/bklit/use-scheduled-tooltip.d.ts +8 -0
  178. package/dist/charts/bklit/use-scheduled-tooltip.js +84 -0
  179. package/dist/charts/bklit/visx-pattern.d.ts +27 -0
  180. package/dist/charts/bklit/visx-pattern.js +28 -0
  181. package/dist/charts/bklit/x-axis.d.ts +26 -0
  182. package/dist/charts/bklit/x-axis.js +423 -0
  183. package/dist/charts/bklit/y-axis-scales.d.ts +34 -0
  184. package/dist/charts/bklit/y-axis-scales.js +80 -0
  185. package/dist/charts/bklit/y-axis-ticks.d.ts +20 -0
  186. package/dist/charts/bklit/y-axis-ticks.js +32 -0
  187. package/dist/charts/bklit/y-domain-utils.d.ts +26 -0
  188. package/dist/charts/bklit/y-domain-utils.js +96 -0
  189. package/dist/charts/bklit.d.ts +2 -0
  190. package/dist/charts/bklit.js +90 -0
  191. package/dist/charts/components/shimmering-text.d.ts +31 -0
  192. package/dist/charts/components/shimmering-text.js +39 -0
  193. package/dist/charts/css.d.ts +35 -0
  194. package/dist/charts/css.js +64 -0
  195. package/dist/charts/recharts.d.ts +28 -0
  196. package/dist/charts/recharts.js +48 -0
  197. package/dist/charts/registry.d.ts +34 -0
  198. package/dist/charts/registry.js +60 -0
  199. package/dist/charts/skeleton.d.ts +55 -0
  200. package/dist/charts/skeleton.js +66 -0
  201. package/dist/cn.d.ts +10 -0
  202. package/dist/cn.js +13 -0
  203. package/dist/context.d.ts +346 -0
  204. package/dist/context.js +95 -0
  205. package/dist/index.d.ts +30 -0
  206. package/dist/index.js +65 -0
  207. package/dist/routes.d.ts +70 -0
  208. package/dist/routes.js +73 -0
  209. package/dist/source-fields.d.ts +111 -0
  210. package/dist/source-fields.js +204 -0
  211. package/dist/ui/chart.d.ts +54 -0
  212. package/dist/ui/chart.js +122 -0
  213. package/dist/ui/dialog.d.ts +27 -0
  214. package/dist/ui/dialog.js +24 -0
  215. package/dist/ui/field.d.ts +29 -0
  216. package/dist/ui/field.js +31 -0
  217. package/dist/ui/select.d.ts +42 -0
  218. package/dist/ui/select.js +30 -0
  219. package/dist/ui/sheet.d.ts +38 -0
  220. package/dist/ui/sheet.js +37 -0
  221. package/dist/ui/switch.d.ts +17 -0
  222. package/dist/ui/switch.js +14 -0
  223. package/dist/ui/tabs.d.ts +30 -0
  224. package/dist/ui/tabs.js +36 -0
  225. package/dist/ui/tooltip.d.ts +37 -0
  226. package/dist/ui/tooltip.js +43 -0
  227. package/dist/workflow/graph.d.ts +112 -0
  228. package/dist/workflow/graph.js +297 -0
  229. package/dist/workflow/index.d.ts +16 -0
  230. package/dist/workflow/index.js +16 -0
  231. package/dist/workflow/model.d.ts +151 -0
  232. package/dist/workflow/model.js +97 -0
  233. package/dist/workflow/name.d.ts +28 -0
  234. package/dist/workflow/name.js +28 -0
  235. package/dist/workflow/nodes.d.ts +40 -0
  236. package/dist/workflow/nodes.js +86 -0
  237. package/dist/workflow/validate.d.ts +104 -0
  238. package/dist/workflow/validate.js +199 -0
  239. package/package.json +148 -0
@@ -0,0 +1,342 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useQuery } from '@tanstack/react-query';
3
+ import { ChevronDown, ChevronRight, CircleCheck, CircleDot, Columns3, Flag, GitCommitVertical, LoaderCircle, OctagonX, Pencil, Play, RefreshCw, ScrollText, Trash2, TriangleAlert, Upload, } from 'lucide-react';
4
+ import { useMemo, useState } from 'react';
5
+ import { cn } from './cn';
6
+ import { useCatalogClient } from './context';
7
+ import { Tooltip, TooltipProvider } from './ui/tooltip';
8
+ const MUTED = 'text-zinc-400 dark:text-zinc-500';
9
+ const RULE = 'border-zinc-200 dark:border-zinc-800';
10
+ const PANEL = 'bg-white dark:bg-zinc-900';
11
+ /**
12
+ * Resolves the trace source from whatever client the host provided.
13
+ *
14
+ * Discovered at run time instead of being declared on `CatalogClient`, because
15
+ * this screen must not be the reason a host that has not updated its provider
16
+ * stops compiling — and because the shipped React view and a hand-written one
17
+ * should be reaching the same endpoint through the same seam. The moment
18
+ * `CatalogProvider` exposes `listTraces`, this lights up with no change here.
19
+ *
20
+ * The result is validated rather than trusted: it arrived through a method
21
+ * nobody type-checked, and a screen that renders a malformed trace as an empty
22
+ * one would hide exactly the load somebody came here to find.
23
+ */
24
+ export function useTraceSource(explicit) {
25
+ const client = useCatalogClient();
26
+ return useMemo(() => {
27
+ if (explicit)
28
+ return explicit;
29
+ const candidate = Reflect.get(client, 'listTraces');
30
+ if (typeof candidate !== 'function')
31
+ return undefined;
32
+ return {
33
+ listTraces: (query) => Promise.resolve(candidate.call(client, query)).then(toTraceList),
34
+ };
35
+ }, [client, explicit]);
36
+ }
37
+ function toTraceList(value) {
38
+ if (typeof value !== 'object' || value === null) {
39
+ throw new Error('The trace endpoint answered with something that is not a trace list.');
40
+ }
41
+ const rawTraces = Reflect.get(value, 'traces');
42
+ if (!Array.isArray(rawTraces)) {
43
+ throw new Error('The trace endpoint answered without a list of traces.');
44
+ }
45
+ const rawUnlinked = Reflect.get(value, 'unlinked');
46
+ const traces = rawTraces.filter(isTrace);
47
+ return {
48
+ traces,
49
+ // The server's own count when it sent one. Falling back to the page length
50
+ // is a deliberate under-claim: "showing 25 of 25" is wrong but harmless,
51
+ // where a fabricated larger total would put a page nobody can reach behind
52
+ // a control that promises one.
53
+ total: numberOr(Reflect.get(value, 'total'), traces.length),
54
+ limit: numberOr(Reflect.get(value, 'limit'), traces.length),
55
+ offset: numberOr(Reflect.get(value, 'offset'), 0),
56
+ unlinked: Array.isArray(rawUnlinked) ? rawUnlinked.filter(isAuditEvent) : [],
57
+ unlinkedTotal: numberOr(Reflect.get(value, 'unlinkedTotal'), 0),
58
+ clockResolutionMs: numberOr(Reflect.get(value, 'clockResolutionMs'), 1),
59
+ };
60
+ }
61
+ function isAuditEvent(value) {
62
+ return (typeof value === 'object' &&
63
+ value !== null &&
64
+ typeof Reflect.get(value, 'id') === 'string' &&
65
+ typeof Reflect.get(value, 'event') === 'string');
66
+ }
67
+ function isTrace(value) {
68
+ return (typeof value === 'object' &&
69
+ value !== null &&
70
+ typeof Reflect.get(value, 'id') === 'string' &&
71
+ Array.isArray(Reflect.get(value, 'spans')));
72
+ }
73
+ function numberOr(value, fallback) {
74
+ return typeof value === 'number' && Number.isFinite(value) ? value : fallback;
75
+ }
76
+ /** What each event looks like, and what it means in one line. */
77
+ export const CATALOG_EVENT_META = {
78
+ 'connector.run.started': {
79
+ icon: Play,
80
+ tone: 'text-sky-600',
81
+ bar: 'bg-sky-500/70',
82
+ label: 'Run started',
83
+ meaning: 'A connector began pulling. Everything after this is that run.',
84
+ },
85
+ 'transform.changed': {
86
+ icon: ScrollText,
87
+ tone: 'text-violet-600',
88
+ bar: 'bg-violet-500/70',
89
+ label: 'Transform changed',
90
+ meaning: 'Code that shapes stored data was edited. The first question about a surprising load.',
91
+ },
92
+ 'schema.changed': {
93
+ icon: Columns3,
94
+ tone: 'text-amber-600',
95
+ bar: 'bg-amber-500/70',
96
+ label: 'Schema changed',
97
+ meaning: 'Columns were added. Nothing is ever dropped automatically.',
98
+ },
99
+ 'snapshot.written': {
100
+ icon: Upload,
101
+ tone: 'text-sky-600',
102
+ bar: 'bg-sky-500/70',
103
+ label: 'Batch written',
104
+ meaning: 'Rows landed but were not yet visible to anyone.',
105
+ },
106
+ 'snapshot.committed': {
107
+ icon: GitCommitVertical,
108
+ tone: 'text-emerald-600',
109
+ bar: 'bg-emerald-500/70',
110
+ label: 'Snapshot committed',
111
+ meaning: 'A load became the one readers get.',
112
+ },
113
+ 'snapshot.dropped': {
114
+ icon: Trash2,
115
+ tone: 'text-red-600',
116
+ bar: 'bg-red-500/70',
117
+ label: 'Snapshot dropped',
118
+ meaning: 'A load was deleted. Never the one being served.',
119
+ },
120
+ 'connector.run.finished': {
121
+ icon: Flag,
122
+ tone: 'text-zinc-500',
123
+ bar: 'bg-zinc-400/70',
124
+ label: 'Run finished',
125
+ meaning: 'The run reported back, one way or the other.',
126
+ },
127
+ 'type.curated': {
128
+ icon: Pencil,
129
+ tone: 'text-violet-600',
130
+ bar: 'bg-violet-500/70',
131
+ label: 'Curated',
132
+ meaning: 'A label, description or unit changed. No migration.',
133
+ },
134
+ };
135
+ export function eventMeta(event) {
136
+ return (CATALOG_EVENT_META[event] ?? {
137
+ icon: CircleDot,
138
+ tone: MUTED,
139
+ bar: 'bg-zinc-400/70',
140
+ label: event,
141
+ meaning: '',
142
+ });
143
+ }
144
+ /**
145
+ * How each ending is drawn.
146
+ *
147
+ * `running` and `incomplete` are deliberately as loud as `failed` and share
148
+ * none of `succeeded`'s vocabulary. A load that is still going and a load that
149
+ * stopped halfway have both moved nothing a reader can see, and the expensive
150
+ * mistake on this screen is not mistaking one for the other — it is either of
151
+ * them being read as a night that went fine.
152
+ */
153
+ const OUTCOMES = {
154
+ succeeded: {
155
+ icon: CircleCheck,
156
+ label: 'Succeeded',
157
+ chip: 'text-emerald-700 border-emerald-300 bg-emerald-50 dark:text-emerald-300 dark:border-emerald-900 dark:bg-emerald-950/40',
158
+ edge: 'border-l-emerald-500',
159
+ meaning: 'It reached an event that said it worked.',
160
+ settled: true,
161
+ },
162
+ failed: {
163
+ icon: OctagonX,
164
+ label: 'Failed',
165
+ chip: 'text-red-700 border-red-300 bg-red-50 dark:text-red-300 dark:border-red-900 dark:bg-red-950/40',
166
+ edge: 'border-l-red-500',
167
+ meaning: 'It reached an event that said it did not work.',
168
+ settled: true,
169
+ },
170
+ running: {
171
+ icon: LoaderCircle,
172
+ label: 'Running',
173
+ chip: 'text-sky-700 border-sky-300 bg-sky-50 dark:text-sky-300 dark:border-sky-900 dark:bg-sky-950/40',
174
+ edge: 'border-l-sky-500',
175
+ meaning: 'Something started and has not reported back. Nothing here is a result yet.',
176
+ settled: false,
177
+ },
178
+ incomplete: {
179
+ icon: TriangleAlert,
180
+ label: 'Never finished',
181
+ chip: 'text-amber-700 border-amber-300 bg-amber-50 dark:text-amber-300 dark:border-amber-900 dark:bg-amber-950/40',
182
+ edge: 'border-l-amber-500',
183
+ meaning: 'It stopped without ever saying how it went. Rows may have been written, but nothing was committed, so no reader can see them.',
184
+ settled: false,
185
+ },
186
+ };
187
+ const OUTCOME_FILTERS = [
188
+ { id: '', label: 'Everything' },
189
+ { id: 'failed', label: 'Failed' },
190
+ { id: 'running', label: 'Running' },
191
+ { id: 'incomplete', label: 'Never finished' },
192
+ { id: 'succeeded', label: 'Succeeded' },
193
+ ];
194
+ /**
195
+ * The trail as stories rather than as a list.
196
+ *
197
+ * Grouped by the correlation id that was always in the data — the snapshot id,
198
+ * which a connector run, its batches, its commit and its finish all carry, and
199
+ * which is the durable run id when durable scheduled the load. Nothing is
200
+ * inferred from timing: an event with no correlation id is shown as what it is,
201
+ * at the bottom, rather than adopted by whichever load happened to be running.
202
+ */
203
+ export function TraceExplorer({ source } = {}) {
204
+ const traces = useTraceSource(source);
205
+ const [outcome, setOutcome] = useState('');
206
+ const [open, setOpen] = useState(null);
207
+ const { data, isLoading, isFetching, error, refetch } = useQuery({
208
+ queryKey: ['catalog', 'traces', outcome],
209
+ queryFn: () => traces
210
+ ? traces.listTraces({ outcome: outcome || undefined, limit: 50 })
211
+ : Promise.reject(new Error('No trace source')),
212
+ enabled: traces !== undefined,
213
+ // Short, because a running trace is the case this screen exists for and a
214
+ // stale one reads as a load that stopped.
215
+ refetchInterval: 10_000,
216
+ });
217
+ if (!traces)
218
+ return _jsx(TraceSourceMissing, {});
219
+ // Its own provider even though the governance screen already has one: this
220
+ // component is exported on its own, and a Radix tooltip outside a provider
221
+ // throws. Nested providers are a no-op, so the shared case costs nothing.
222
+ return (_jsx(TooltipProvider, { children: _jsxs("div", { className: "space-y-4", children: [_jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [OUTCOME_FILTERS.map((filter) => (_jsx("button", { type: "button", onClick: () => setOutcome(filter.id), className: cn('rounded-md border px-2.5 py-1 text-xs transition-colors', filter.id === outcome
223
+ ? 'border-zinc-400 bg-zinc-100 text-zinc-950 dark:border-zinc-600 dark:bg-zinc-800 dark:text-zinc-50'
224
+ : cn(RULE, 'hover:bg-zinc-50 dark:hover:bg-zinc-800/60', MUTED)), children: filter.label }, filter.id || 'all'))), _jsx(Tooltip, { content: "Re-read the trail now", children: _jsx("button", { type: "button", onClick: () => void refetch(), "aria-label": "Refresh traces", className: cn('ml-auto rounded-md border p-1.5 transition-colors', RULE, 'hover:bg-zinc-50 dark:hover:bg-zinc-800/60'), children: _jsx(RefreshCw, { size: 13, className: cn(isFetching && 'animate-spin') }) }) })] }), isLoading && (_jsx("p", { className: cn('py-10 text-center font-mono text-sm', MUTED), children: "Reassembling the trail\u2026" })), error && (_jsx("p", { className: cn('rounded-lg border border-red-300 bg-red-50 px-4 py-3 text-sm text-red-700', 'dark:border-red-900 dark:bg-red-950/40 dark:text-red-300'), children: error instanceof Error ? error.message : String(error) })), data && data.traces.length === 0 && (_jsx("p", { className: cn('rounded-lg border border-dashed px-4 py-12 text-center text-sm', RULE, MUTED), children: "No trace matches. Every trace is one snapshot id \u2014 publish something, or run a connector, and its whole story appears here." })), _jsx("div", { className: "space-y-2", children: (data?.traces ?? []).map((trace) => (_jsx(TraceCard, { trace: trace, expanded: open === trace.id, onToggle: () => setOpen(open === trace.id ? null : trace.id) }, trace.id))) }), data && data.total > data.traces.length && (_jsxs("p", { className: cn('text-center font-mono text-[10px]', MUTED), children: ["Showing ", data.traces.length, " of ", data.total, " traces."] })), data && data.unlinked.length > 0 && _jsx(Unlinked, { list: data.unlinked })] }) }));
225
+ }
226
+ function TraceCard({ trace, expanded, onToggle, }) {
227
+ const outcome = OUTCOMES[trace.outcome];
228
+ const OutcomeIcon = outcome.icon;
229
+ return (_jsxs("div", { className: cn('rounded-lg border border-l-2 p-3', RULE, PANEL, outcome.edge), children: [_jsxs("div", { className: "flex flex-wrap items-center gap-x-2 gap-y-1", children: [_jsx(Tooltip, { content: outcome.meaning, children: _jsxs("span", { className: cn('flex cursor-help items-center gap-1.5 rounded-md border px-1.5 py-0.5 text-[11px]', outcome.chip), children: [_jsx(OutcomeIcon, { size: 11, className: cn(trace.outcome === 'running' && 'animate-spin') }), outcome.label] }) }), _jsx("span", { className: "font-mono text-[11px]", children: trace.id }), trace.typeName && (_jsx("span", { className: cn('font-mono text-[10px]', MUTED), children: trace.typeName })), trace.connectorName && (_jsxs("span", { className: "text-[11px] text-zinc-600 dark:text-zinc-300", children: ["via ", trace.connectorName] })), _jsx("span", { className: cn('ml-auto font-mono text-[10px]', MUTED), children: new Date(trace.startedAt).toLocaleString() })] }), _jsxs("div", { className: cn('mt-1 flex flex-wrap gap-x-3 font-mono text-[10px]', MUTED), children: [_jsx(Tooltip, { content: outcome.settled
230
+ ? 'Start of the first event to the end of the last.'
231
+ : 'Time since it started. It has not reported an end, so this keeps growing.', children: _jsx("span", { className: "cursor-help", children: outcome.settled
232
+ ? formatDuration(trace.durationMs ?? 0)
233
+ : `${formatSince(trace.startedAt)} so far` }) }), _jsxs("span", { children: [trace.eventCount, " events"] }), trace.rowsCommitted !== undefined && _jsxs("span", { children: [trace.rowsCommitted, " rows served"] }), trace.principalId && _jsx("span", { children: trace.principalId }), trace.failureCount > 0 && trace.outcome !== 'failed' && (_jsx(Tooltip, { content: "An earlier attempt on this same snapshot id failed. A retry reuses the id, so both attempts are in this one story.", children: _jsxs("span", { className: "cursor-help text-amber-600", children: [trace.failureCount, " earlier failure", trace.failureCount === 1 ? '' : 's'] }) })), !outcome.settled && _jsxs("span", { children: ["last event ", formatSince(trace.lastEventAt), " ago"] })] }), _jsx(Waterfall, { trace: trace }), trace.error && (_jsx("p", { className: cn('mt-2 rounded-md border border-red-300 bg-red-50 px-2.5 py-1.5 font-mono text-[11px] leading-snug text-red-700', 'dark:border-red-900 dark:bg-red-950/40 dark:text-red-300'), children: trace.error })), _jsxs("button", { type: "button", onClick: onToggle, className: cn('mt-2 flex items-center gap-1 text-[11px] transition-colors', MUTED, 'hover:text-zinc-950 dark:hover:text-zinc-50'), children: [expanded ? _jsx(ChevronDown, { size: 12 }) : _jsx(ChevronRight, { size: 12 }), expanded ? 'Hide steps' : `${trace.spans.length} steps`] }), expanded && (_jsx("div", { className: "mt-2 space-y-1 border-t border-zinc-100 pt-2 dark:border-zinc-800", children: trace.spans.map((span) => (_jsx(Step, { span: span, coarse: trace.coarse }, span.id))) }))] }));
234
+ }
235
+ /**
236
+ * The waterfall.
237
+ *
238
+ * Bars are placed by offset and sized by the gap to the next event, because
239
+ * events are instants and the interesting quantity is the work between them —
240
+ * the stretch from `connector.run.started` to the first batch is the fetch and
241
+ * the transform, and on a slow load it is most of the picture.
242
+ *
243
+ * When the recorder's clock cannot separate the events, the bars are replaced
244
+ * by evenly spaced markers on a dashed track. Drawing them to scale anyway
245
+ * would produce a chart of rounding error that looks exactly like a chart of
246
+ * measurements.
247
+ */
248
+ function Waterfall({ trace }) {
249
+ const settled = OUTCOMES[trace.outcome].settled;
250
+ if (trace.coarse) {
251
+ return (_jsx(Tooltip, { content: "The whole trace landed inside one tick of the audit clock, so there is no internal timing to draw. The order is still right \u2014 it comes from the events' place in a load's life, not from their timestamps.", children: _jsxs("div", { className: "mt-2 flex cursor-help items-center gap-0.5 rounded-md border border-dashed border-zinc-300 px-1.5 py-1 dark:border-zinc-700", children: [trace.spans.map((span) => (_jsx("span", { className: cn('h-1.5 flex-1 rounded-full', span.failed ? 'bg-red-500/80' : eventMeta(span.event).bar) }, span.id))), !settled && _jsx("span", { className: "h-1.5 flex-1 animate-pulse rounded-full bg-sky-400/50" })] }) }));
252
+ }
253
+ // The full width of the track. For an unsettled trace it runs to now, so the
254
+ // open end grows on screen instead of the last event looking like an ending.
255
+ const start = new Date(trace.startedAt).getTime();
256
+ const end = settled
257
+ ? start + (trace.durationMs ?? 0)
258
+ : Math.max(Date.now(), new Date(trace.lastEventAt).getTime());
259
+ const total = Math.max(end - start, 1);
260
+ const lastAt = new Date(trace.lastEventAt).getTime();
261
+ return (_jsxs("div", { className: "relative mt-2 h-6 rounded-md bg-zinc-100 dark:bg-zinc-800/60", children: [trace.spans.map((span) => {
262
+ const meta = eventMeta(span.event);
263
+ return (_jsx(Tooltip, { content: _jsxs("span", { className: "font-mono text-[11px]", children: [meta.label, _jsx("br", {}), "+", formatDuration(span.offsetMs), " \u00B7 ", formatDuration(span.durationMs), " to the next", _jsx("br", {}), new Date(span.occurredAt).toLocaleTimeString()] }), children: _jsx("span", { className: cn('absolute top-1.5 h-3 cursor-help rounded-sm', span.failed ? 'bg-red-500/80' : meta.bar), style: {
264
+ left: `${(span.offsetMs / total) * 100}%`,
265
+ // A floor of a few pixels so an instantaneous step is still
266
+ // visible and hoverable; without it the fast steps vanish and
267
+ // the trace looks like it had fewer of them than it did.
268
+ width: `max(3px, ${(span.durationMs / total) * 100}%)`,
269
+ } }) }, span.id));
270
+ }), !settled && (_jsx(Tooltip, { content: "Still open. This end of the trace has not been written yet.", children: _jsx("span", { className: "absolute top-1.5 h-3 animate-pulse cursor-help rounded-sm bg-sky-400/50", style: {
271
+ left: `${((lastAt - start) / total) * 100}%`,
272
+ right: 0,
273
+ } }) }))] }));
274
+ }
275
+ function Step({ span, coarse }) {
276
+ const meta = eventMeta(span.event);
277
+ const Icon = meta.icon;
278
+ return (_jsxs("div", { className: "flex items-start gap-2", children: [_jsx(Tooltip, { content: meta.meaning, side: "right", children: _jsx("span", { className: cn('mt-0.5 shrink-0 cursor-help', span.failed ? 'text-red-600' : meta.tone), children: _jsx(Icon, { size: 12 }) }) }), _jsxs("div", { className: "min-w-0 flex-1", children: [_jsxs("div", { className: "flex flex-wrap items-baseline gap-x-2", children: [_jsx("span", { className: "text-[12px]", children: meta.label }), _jsx("span", { className: cn('font-mono text-[10px]', MUTED), children: summarise(span) })] }), span.error && (_jsx("div", { className: "font-mono text-[10px] leading-snug text-red-600 dark:text-red-400", children: span.error }))] }), _jsx("div", { className: cn('shrink-0 text-right font-mono text-[10px]', MUTED), children: coarse ? (new Date(span.occurredAt).toLocaleTimeString()) : (_jsxs(_Fragment, { children: ["+", formatDuration(span.offsetMs), span.durationMs > 0 && (_jsx("span", { className: "ml-1.5", children: formatDuration(span.durationMs) }))] })) })] }));
279
+ }
280
+ /** One line of the payload, chosen per event rather than dumped as JSON. */
281
+ function summarise(span) {
282
+ const detail = span.detail ?? {};
283
+ switch (span.event) {
284
+ case 'snapshot.committed':
285
+ return `${detail.rowCount ?? '?'} rows now served`;
286
+ case 'snapshot.written':
287
+ return `${detail.rows ?? '?'} rows in this batch`;
288
+ case 'connector.run.started':
289
+ return typeof detail.connectorName === 'string' ? detail.connectorName : '';
290
+ case 'connector.run.finished':
291
+ return `${detail.fetched ?? '?'} fetched, ${detail.written ?? '?'} written`;
292
+ case 'schema.changed': {
293
+ const added = Array.isArray(detail.addedColumns) ? detail.addedColumns : [];
294
+ return detail.created
295
+ ? `table created with ${added.length} columns`
296
+ : `added ${added.join(', ')}`;
297
+ }
298
+ case 'transform.changed':
299
+ return `${detail.name ?? ''} v${detail.version ?? '?'}`;
300
+ default:
301
+ return '';
302
+ }
303
+ }
304
+ /**
305
+ * Events with no correlation id, shown as exactly that.
306
+ *
307
+ * The alternative — attaching them to whichever load was running at the time —
308
+ * is tempting and wrong. A transform edit and a connector run share a second in
309
+ * this very catalog, and the guess would look right; it would still be a guess
310
+ * rendered as lineage, and the next person would read it as a cause.
311
+ */
312
+ function Unlinked({ list }) {
313
+ return (_jsxs("div", { className: cn('rounded-lg border border-dashed p-3', RULE), children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("span", { className: "text-[12px]", children: "Not part of any trace" }), _jsxs("span", { className: cn('font-mono text-[10px]', MUTED), children: [list.length, " events"] })] }), _jsx("p", { className: cn('mt-1 max-w-2xl text-[11px] leading-snug', MUTED), children: "These carry no correlation id, so there is nothing to group them by. Curation edits and transform changes are standalone acts \u2014 attaching one to the load that happened to be running would invent a cause." }), _jsx("div", { className: "mt-2 space-y-1", children: list.map((entry) => {
314
+ const meta = eventMeta(entry.event);
315
+ const Icon = meta.icon;
316
+ return (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Tooltip, { content: meta.meaning, side: "right", children: _jsx("span", { className: cn('shrink-0 cursor-help', meta.tone), children: _jsx(Icon, { size: 12 }) }) }), _jsx("span", { className: "text-[12px]", children: meta.label }), entry.typeName && (_jsx("span", { className: cn('font-mono text-[10px]', MUTED), children: entry.typeName })), _jsx("span", { className: cn('ml-auto font-mono text-[10px]', MUTED), children: new Date(entry.occurredAt).toLocaleString() })] }, entry.id));
317
+ }) })] }));
318
+ }
319
+ /**
320
+ * Shown when the host's client has no way to reach the trace endpoint.
321
+ *
322
+ * Says what is missing and what to add, rather than rendering an empty list. An
323
+ * empty list here would read as "nothing ever ran", which on a governance
324
+ * screen is the worst available lie.
325
+ */
326
+ function TraceSourceMissing() {
327
+ return (_jsxs("div", { className: cn('rounded-lg border border-dashed px-4 py-10 text-center text-sm', RULE, MUTED), children: [_jsx("p", { children: "This console\u2019s catalog client cannot reach the trace endpoint yet." }), _jsxs("p", { className: "mt-2 font-mono text-[11px]", children: ["Add ", _jsx("span", { className: "text-zinc-600 dark:text-zinc-300", children: "listTraces" }), " to the client, wired to", ' ', _jsx("span", { className: "text-zinc-600 dark:text-zinc-300", children: "GET /catalog/events/traces" }), "."] })] }));
328
+ }
329
+ function formatDuration(ms) {
330
+ if (ms < 1)
331
+ return '0ms';
332
+ if (ms < 1_000)
333
+ return `${Math.round(ms)}ms`;
334
+ if (ms < 60_000)
335
+ return `${(ms / 1_000).toFixed(1)}s`;
336
+ if (ms < 3_600_000)
337
+ return `${Math.round(ms / 60_000)}m`;
338
+ return `${(ms / 3_600_000).toFixed(1)}h`;
339
+ }
340
+ function formatSince(iso) {
341
+ return formatDuration(Math.max(Date.now() - new Date(iso).getTime(), 0));
342
+ }
@@ -0,0 +1,23 @@
1
+ import type { CatalogTransform, TransformLanguage } from '@dudousxd/nestjs-catalog/client';
2
+ export interface TransformEditorProps {
3
+ transform?: CatalogTransform;
4
+ /**
5
+ * The languages this deployment can actually run, from
6
+ * `pipelineCapabilities()`. Offering one the image cannot execute turns a
7
+ * deployment difference into a traceback the author cannot act on.
8
+ */
9
+ languages: TransformLanguage[];
10
+ pythonPackages?: string[];
11
+ onClose: () => void;
12
+ onSaved: () => void;
13
+ }
14
+ /**
15
+ * Write the code, and run it against a couple of records before it ever touches
16
+ * a load.
17
+ *
18
+ * The try pane is the point of this screen. A transform is the one place where
19
+ * somebody's typo silently reshapes stored data, and the difference between a
20
+ * transform you can iterate on and one you can only test in production is
21
+ * whether you can see its output beside its input.
22
+ */
23
+ export declare function TransformEditor({ transform, languages, pythonPackages, onClose, onSaved, }: TransformEditorProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,129 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { isTransformLanguage } from '@dudousxd/nestjs-catalog/client';
3
+ import { useMutation } from '@tanstack/react-query';
4
+ import { ArrowLeft, Play } from 'lucide-react';
5
+ import { Highlight, themes } from 'prism-react-renderer';
6
+ import { useRef, useState } from 'react';
7
+ import { cn } from './cn';
8
+ import { useCatalogClient } from './context';
9
+ import { TextField } from './ui/field';
10
+ import { SelectField } from './ui/select';
11
+ const MUTED = 'text-zinc-400 dark:text-zinc-500';
12
+ const RULE = 'border-zinc-200 dark:border-zinc-800';
13
+ const PANEL = 'bg-white dark:bg-zinc-900';
14
+ /**
15
+ * Starter code per language.
16
+ *
17
+ * Keyed by the language union rather than by `string`, so adding a language to
18
+ * the library without a starter here is a type error rather than an editor that
19
+ * silently opens empty.
20
+ */
21
+ const STARTERS = {
22
+ typescript: `// \`records\` is the batch the connector fetched.
23
+ // Types are stripped, never checked — the try pane is what catches a mistake.
24
+ type Source = { tag: string; risk: string; kind: string };
25
+
26
+ return (records as Source[]).map((r) => ({
27
+ assetId: r.tag,
28
+ riskScore: Number(r.risk),
29
+ vehicleTypeName: r.kind.toUpperCase(),
30
+ critical: Number(r.risk) >= 80,
31
+ }));`,
32
+ javascript: `// \`records\` is the batch the connector fetched.
33
+ // Return the rows to store — the keys must be property names of the target type.
34
+ return records.map((r) => ({
35
+ assetId: r.tag,
36
+ riskScore: Number(r.risk),
37
+ vehicleTypeName: String(r.kind).toUpperCase(),
38
+ critical: Number(r.risk) >= 80,
39
+ }));`,
40
+ python: `# \`records\` is the batch the connector fetched.
41
+ # Return the rows to store — the keys must be property names of the target type.
42
+ log("mapping", len(records), "records")
43
+ return [{
44
+ "assetId": r["tag"],
45
+ "riskScore": int(r["risk"]),
46
+ "vehicleTypeName": r["kind"].upper(),
47
+ "critical": int(r["risk"]) >= 80,
48
+ } for r in records]`,
49
+ };
50
+ const SAMPLE = `[
51
+ { "tag": "AF93E00073", "risk": "88", "kind": "truck" },
52
+ { "tag": "AF00D00169", "risk": "12", "kind": "sedan" }
53
+ ]`;
54
+ /**
55
+ * Write the code, and run it against a couple of records before it ever touches
56
+ * a load.
57
+ *
58
+ * The try pane is the point of this screen. A transform is the one place where
59
+ * somebody's typo silently reshapes stored data, and the difference between a
60
+ * transform you can iterate on and one you can only test in production is
61
+ * whether you can see its output beside its input.
62
+ */
63
+ export function TransformEditor({ transform, languages, pythonPackages = [], onClose, onSaved, }) {
64
+ const client = useCatalogClient();
65
+ const [name, setName] = useState(transform?.name ?? '');
66
+ const [description, setDescription] = useState(transform?.description ?? '');
67
+ const [language, setLanguage] = useState(transform?.language ?? languages[0] ?? 'javascript');
68
+ const [code, setCode] = useState(transform?.code ?? STARTERS[transform?.language ?? 'javascript']);
69
+ const [sample, setSample] = useState(SAMPLE);
70
+ const editorRef = useRef(null);
71
+ const tryIt = useMutation({
72
+ mutationFn: () => {
73
+ let records;
74
+ try {
75
+ const parsed = JSON.parse(sample);
76
+ records = Array.isArray(parsed) ? parsed : [parsed];
77
+ }
78
+ catch {
79
+ // Thrown rather than sent, because the server would answer with a
80
+ // parser error about a body it never should have received, and the
81
+ // person reading it would go looking at their transform.
82
+ throw new Error('The sample is not valid JSON.');
83
+ }
84
+ return client.tryTransform({ language, code, records });
85
+ },
86
+ });
87
+ const save = useMutation({
88
+ mutationFn: () => client.saveTransform({
89
+ id: transform?.id,
90
+ name: name.trim(),
91
+ language,
92
+ code,
93
+ description: description.trim() || undefined,
94
+ }),
95
+ onSuccess: onSaved,
96
+ });
97
+ function onKeyDown(event) {
98
+ if ((event.metaKey || event.ctrlKey) && event.key === 'Enter') {
99
+ event.preventDefault();
100
+ tryIt.mutate();
101
+ }
102
+ }
103
+ return (_jsxs("div", { className: "mt-6 space-y-3", children: [_jsxs("button", { type: "button", onClick: onClose, className: cn('flex items-center gap-1.5 font-mono text-[11px] uppercase tracking-[0.14em]', MUTED, 'hover:text-zinc-950 dark:hover:text-zinc-50'), children: [_jsx(ArrowLeft, { size: 12 }), "Transforms"] }), _jsxs("div", { className: "grid gap-3 sm:grid-cols-3", children: [_jsx(TextField, { label: "Name", value: name, onChange: setName, placeholder: "Fleet rows" }), _jsx(TextField, { label: "Description", value: description, onChange: setDescription, placeholder: "What it does (optional)" }), _jsx(SelectField, { label: "Language", ariaLabel: "Language", value: language, onValueChange: (value) => {
104
+ // Narrowed against the library's own list rather than trusted from
105
+ // the select, which hands back a bare string.
106
+ if (!isTransformLanguage(value))
107
+ return;
108
+ setLanguage(value);
109
+ // Only replace untouched starter code — silently discarding
110
+ // somebody's work because they changed a dropdown would be rude.
111
+ if (Object.values(STARTERS).includes(code)) {
112
+ setCode(STARTERS[value]);
113
+ }
114
+ }, options: languages.map((option) => ({
115
+ value: option,
116
+ label: option,
117
+ })) })] }), _jsxs("div", { className: "grid gap-3 lg:grid-cols-2", children: [_jsxs("div", { className: cn('overflow-hidden rounded-lg border', RULE, PANEL), children: [_jsxs("div", { className: cn('flex items-center justify-between border-b px-3 py-1.5', RULE), children: [_jsx("span", { className: cn('font-mono text-[10px] uppercase tracking-[0.14em]', MUTED), children: "Code" }), _jsx("span", { className: cn('font-mono text-[10px]', MUTED), children: language === 'python' && pythonPackages.length > 0
118
+ ? `imports: ${pythonPackages.join(', ')}`
119
+ : '⌘↵ to try' })] }), _jsx(CodePane, { value: code, onChange: setCode, onKeyDown: onKeyDown, language: language === 'python' ? 'python' : 'tsx', textareaRef: editorRef })] }), _jsxs("div", { className: "space-y-3", children: [_jsxs("div", { className: cn('overflow-hidden rounded-lg border', RULE, PANEL), children: [_jsx("div", { className: cn('border-b px-3 py-1.5', RULE), children: _jsx("span", { className: cn('font-mono text-[10px] uppercase tracking-[0.14em]', MUTED), children: "Sample records" }) }), _jsx("textarea", { value: sample, onChange: (event) => setSample(event.target.value), "aria-label": "Sample records", spellCheck: false, className: "h-32 w-full resize-none bg-transparent p-3 font-mono text-[12px] outline-none" })] }), _jsxs("button", { type: "button", onClick: () => tryIt.mutate(), disabled: tryIt.isPending, className: "flex items-center gap-1.5 rounded-md bg-zinc-950 px-3 py-1.5 text-xs text-zinc-50 disabled:opacity-40 dark:bg-zinc-100 dark:text-zinc-950", children: [_jsx(Play, { size: 12 }), tryIt.isPending ? 'Running…' : 'Try it'] }), _jsxs("div", { className: cn('overflow-hidden rounded-lg border', RULE, PANEL), children: [_jsx("div", { className: cn('border-b px-3 py-1.5', RULE), children: _jsx("span", { className: cn('font-mono text-[10px] uppercase tracking-[0.14em]', MUTED), children: "Output" }) }), _jsxs("div", { className: "max-h-64 overflow-auto p-3", children: [tryIt.error && (_jsx("p", { className: "font-mono text-[11px] leading-relaxed text-red-600", children: tryIt.error instanceof Error ? tryIt.error.message : 'It failed.' })), tryIt.data && (_jsxs(_Fragment, { children: [tryIt.data.logs.length > 0 && (_jsx("pre", { className: cn('mb-2 whitespace-pre-wrap font-mono text-[10px]', MUTED), children: tryIt.data.logs.join('\n') })), tryIt.data.rows.length === 0 ? (_jsx("p", { className: "text-[11px] text-amber-600", children: "It ran and returned no rows. A connector using this would commit an empty snapshot." })) : (_jsx("pre", { className: "whitespace-pre-wrap font-mono text-[11px]", children: JSON.stringify(tryIt.data.rows, null, 2) })), _jsxs("p", { className: cn('mt-2 font-mono text-[10px]', MUTED), children: [tryIt.data.rows.length, " rows \u00B7 ", tryIt.data.elapsedMs, "ms"] })] })), !tryIt.data && !tryIt.error && (_jsx("p", { className: cn('py-4 text-center text-[11px]', MUTED), children: "Run it to see what it produces." }))] })] })] })] }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx("button", { type: "button", onClick: () => save.mutate(), disabled: save.isPending || name.trim().length === 0, className: cn('rounded-md border px-3 py-1.5 text-xs disabled:opacity-40', RULE, 'hover:bg-zinc-50 dark:hover:bg-zinc-800'), children: save.isPending ? 'Saving…' : transform ? 'Save changes' : 'Save transform' }), transform && (_jsxs("span", { className: cn('font-mono text-[10px]', MUTED), children: ["saving new code makes this v", transform.version + 1] })), save.error && (_jsx("span", { className: "text-[11px] text-red-600", children: save.error instanceof Error ? save.error.message : 'Could not save.' }))] })] }));
120
+ }
121
+ /** A textarea under a highlighted `<pre>`, the same shape the query editor uses. */
122
+ function CodePane({ value, onChange, onKeyDown, language, textareaRef, }) {
123
+ const shared = 'm-0 p-3 font-mono text-[12px] leading-[1.5] whitespace-pre-wrap break-words';
124
+ return (_jsxs("div", { className: "relative h-72 overflow-auto", children: [_jsx(Highlight, { code: value, language: language, theme: themes.github, children: ({ tokens, getLineProps, getTokenProps }) => (_jsx("pre", { className: cn(shared, 'pointer-events-none min-h-full'), "aria-hidden": true, children: tokens.map((line, i) => (
125
+ // biome-ignore lint/suspicious/noArrayIndexKey: lines have no id
126
+ _jsx("div", { ...getLineProps({ line }), children: line.map((token, key) => (
127
+ // biome-ignore lint/suspicious/noArrayIndexKey: tokens have no id
128
+ _jsx("span", { ...getTokenProps({ token }) }, key))) }, i))) })) }), _jsx("textarea", { ref: textareaRef, value: value, onChange: (event) => onChange(event.target.value), onKeyDown: onKeyDown, spellCheck: false, "aria-label": "Transform code", className: cn(shared, 'absolute inset-0 h-full w-full resize-none bg-transparent', 'text-transparent caret-zinc-900 outline-none dark:caret-zinc-100') })] }));
129
+ }
@@ -0,0 +1,24 @@
1
+ import '@xyflow/react/dist/style.css';
2
+ export interface WorkflowCanvasProps {
3
+ /** Heading copy, so the host can call this whatever its users call it. */
4
+ title?: string;
5
+ eyebrow?: string;
6
+ intro?: string;
7
+ /**
8
+ * Set false where the viewer is known to be read-only. The endpoints refuse
9
+ * regardless; this only stops the canvas offering controls that always 403.
10
+ */
11
+ canEdit?: boolean;
12
+ }
13
+ /**
14
+ * Transforms wired to each other, ending at one or more sinks.
15
+ *
16
+ * Deliberately **not** called Flow. `FlowView` in this package is a *derived*
17
+ * picture — it reconstructs who feeds what from the audit trail, and argues in
18
+ * its own comment that inferring the graph from what publishers actually did is
19
+ * more truthful than a diagram somebody maintains. This screen is the opposite
20
+ * claim: a graph a person authors and the server then executes. Sharing a name
21
+ * would leave two screens making opposite promises about where the truth is.
22
+ * See `workflow/name.ts`.
23
+ */
24
+ export declare function WorkflowCanvas(props: WorkflowCanvasProps): import("react/jsx-runtime").JSX.Element;