@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,123 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
3
+ import { ArrowUpRight, Eye, EyeOff, RotateCcw, Search } from 'lucide-react';
4
+ import { useMemo, useState } from 'react';
5
+ import { CoverageLedger } from './CoverageLedger';
6
+ import { EditableField } from './EditableField';
7
+ import { cn } from './cn';
8
+ import { catalogQueryKeys, useCatalogClient } from './context';
9
+ import { Tooltip, TooltipProvider } from './ui/tooltip';
10
+ /**
11
+ * Browse and label the model.
12
+ *
13
+ * The screen reads as a nomenclature plate: what the machine calls a thing in
14
+ * mono, what a person calls it in prose. Wherever both exist, both are shown —
15
+ * the gap between them is the work.
16
+ */
17
+ const TYPE_TONE = {
18
+ string: 'text-sky-700 dark:text-sky-300',
19
+ number: 'text-violet-700 dark:text-violet-300',
20
+ date: 'text-amber-700 dark:text-amber-300',
21
+ boolean: 'text-emerald-700 dark:text-emerald-300',
22
+ json: 'text-zinc-600 dark:text-zinc-300',
23
+ uuid: 'text-rose-700 dark:text-rose-300',
24
+ unknown: 'text-zinc-400',
25
+ };
26
+ const MUTED = 'text-zinc-400 dark:text-zinc-500';
27
+ const SECONDARY = 'text-zinc-500 dark:text-zinc-400';
28
+ const PANEL = 'bg-white dark:bg-zinc-900';
29
+ const RULE = 'border-zinc-200 dark:border-zinc-800';
30
+ const HAIRLINE = 'border-zinc-100 dark:border-zinc-900';
31
+ function ScalarBadge({ type }) {
32
+ return (_jsx("span", { className: cn('rounded-sm bg-zinc-100 px-1.5 py-0.5 font-mono text-[10px] uppercase tracking-wider dark:bg-zinc-800', TYPE_TONE[type]), children: type }));
33
+ }
34
+ export function CatalogManager({ explorerHref, title = 'Catalog', eyebrow = 'Semantic layer', intro = 'Every object type the system already holds, derived from the ORM. Names, descriptions and units are yours to change — none of it touches the database.', }) {
35
+ const client = useCatalogClient();
36
+ const queryClient = useQueryClient();
37
+ const { data, isLoading, isError } = useQuery({
38
+ queryKey: catalogQueryKeys.snapshot,
39
+ queryFn: () => client.snapshot(),
40
+ staleTime: 30_000,
41
+ });
42
+ const [selectedName, setSelectedName] = useState(null);
43
+ const [filter, setFilter] = useState('');
44
+ const [onlyUnnamed, setOnlyUnnamed] = useState(false);
45
+ /** Presentation edits should feel like typing, not like saving. */
46
+ function applyToSnapshot(updated) {
47
+ if (!updated || typeof updated !== 'object' || !('name' in updated))
48
+ return;
49
+ const next = updated;
50
+ queryClient.setQueryData(catalogQueryKeys.snapshot, (prev) => prev
51
+ ? {
52
+ ...prev,
53
+ types: prev.types.map((t) => (t.name === next.name ? next : t)),
54
+ stats: {
55
+ ...prev.stats,
56
+ enrichedTypes: prev.types.filter((t) => t.name === next.name ? next.enriched : t.enriched).length,
57
+ },
58
+ }
59
+ : prev);
60
+ }
61
+ const typeMutation = useMutation({
62
+ mutationFn: ({ name, patch }) => client.patchType(name, patch),
63
+ onSuccess: applyToSnapshot,
64
+ });
65
+ const propertyMutation = useMutation({
66
+ mutationFn: ({ name, property, patch, }) => client.patchProperty(name, property, patch),
67
+ onSuccess: applyToSnapshot,
68
+ });
69
+ const resetMutation = useMutation({
70
+ mutationFn: () => client.reset(),
71
+ onSuccess: (snapshot) => queryClient.setQueryData(catalogQueryKeys.snapshot, snapshot),
72
+ });
73
+ const types = useMemo(() => data?.types ?? [], [data]);
74
+ const selected = useMemo(() => types.find((t) => t.name === selectedName) ?? types[0], [types, selectedName]);
75
+ const grouped = useMemo(() => {
76
+ const term = filter.trim().toLowerCase();
77
+ const matching = types.filter((t) => {
78
+ if (onlyUnnamed && t.enriched)
79
+ return false;
80
+ if (!term)
81
+ return true;
82
+ return (t.displayName.toLowerCase().includes(term) ||
83
+ t.name.toLowerCase().includes(term) ||
84
+ t.tableName.toLowerCase().includes(term));
85
+ });
86
+ const byGroup = new Map();
87
+ for (const type of matching) {
88
+ const list = byGroup.get(type.group) ?? [];
89
+ list.push(type);
90
+ byGroup.set(type.group, list);
91
+ }
92
+ return [...byGroup.entries()].sort(([a], [b]) => a.localeCompare(b));
93
+ }, [types, filter, onlyUnnamed]);
94
+ if (isLoading) {
95
+ return (_jsx("div", { className: "flex h-full items-center justify-center", children: _jsx("p", { className: cn('font-mono text-sm', MUTED), children: "Reading the catalog\u2026" }) }));
96
+ }
97
+ if (isError || !data) {
98
+ return (_jsx("div", { className: "flex h-full items-center justify-center px-6", children: _jsxs("div", { className: "max-w-md text-center", children: [_jsx("h2", { className: "text-lg font-medium", children: "The catalog did not load" }), _jsx("p", { className: cn('mt-1 text-sm', SECONDARY), children: "The server builds it from ORM metadata at boot. Check that the API is reachable and that your account may read it." })] }) }));
99
+ }
100
+ return (_jsx(TooltipProvider, { children: _jsxs("div", { className: "flex h-full flex-col bg-zinc-50 dark:bg-zinc-950", children: [_jsxs("header", { className: cn('shrink-0 border-b px-8 py-6', RULE, PANEL), children: [_jsxs("div", { className: "flex flex-wrap items-start justify-between gap-6", children: [_jsxs("div", { children: [_jsx("p", { className: cn('font-mono text-[11px] uppercase tracking-[0.18em]', MUTED), children: eyebrow }), _jsx("h1", { className: "mt-1 text-2xl font-semibold tracking-tight", children: title }), _jsx("p", { className: cn('mt-1 max-w-xl text-sm', SECONDARY), children: intro })] }), _jsxs("div", { className: "flex items-center gap-6", children: [_jsx(Stat, { label: "Types", value: data.stats.types }), _jsx(Stat, { label: "Properties", value: data.stats.properties }), _jsx(Stat, { label: "Links", value: data.stats.relations }), _jsxs("button", { type: "button", onClick: () => resetMutation.mutate(), disabled: resetMutation.isPending, className: cn('flex items-center gap-1.5 rounded-md border px-3 py-1.5 text-xs', RULE, SECONDARY, 'transition-colors hover:bg-zinc-50 disabled:opacity-50 dark:hover:bg-zinc-800'), children: [_jsx(RotateCcw, { size: 13 }), "Reset edits"] })] })] }), _jsx("div", { className: "mt-6", children: _jsx(CoverageLedger, { types: types, selected: selected?.name, onSelect: setSelectedName }) })] }), _jsxs("div", { className: "flex min-h-0 flex-1", children: [_jsxs("aside", { className: cn('flex w-72 shrink-0 flex-col border-r', RULE, PANEL), children: [_jsxs("div", { className: cn('shrink-0 space-y-2 border-b p-3', HAIRLINE), children: [_jsxs("div", { className: "relative", children: [_jsx(Search, { size: 14, className: cn('pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2', MUTED) }), _jsx("input", { type: "text", value: filter, onChange: (e) => setFilter(e.target.value), placeholder: "Find a type or table", "aria-label": "Filter object types", className: cn('w-full rounded-md border bg-zinc-50 py-1.5 pl-8 pr-2 text-sm outline-none dark:bg-zinc-950', RULE, 'placeholder:text-zinc-400 focus:border-violet-500 focus:ring-2 focus:ring-violet-500/15') })] }), _jsxs("label", { className: cn('flex cursor-pointer items-center gap-2 px-0.5 text-xs', SECONDARY), children: [_jsx("input", { type: "checkbox", checked: onlyUnnamed, onChange: (e) => setOnlyUnnamed(e.target.checked), className: "accent-amber-500" }), "Only types nobody has named"] })] }), _jsxs("nav", { className: "min-h-0 flex-1 overflow-y-auto p-2", children: [grouped.length === 0 && (_jsxs("p", { className: cn('px-2 py-6 text-center text-xs', MUTED), children: ["Nothing matches \u201C", filter, "\u201D."] })), grouped.map(([group, groupTypes]) => (_jsxs("div", { className: "mb-3", children: [_jsxs("div", { className: "flex items-baseline justify-between px-2 py-1", children: [_jsx("span", { className: cn('font-mono text-[10px] uppercase tracking-[0.14em]', MUTED), children: group }), _jsx("span", { className: cn('font-mono text-[10px]', MUTED), children: groupTypes.length })] }), groupTypes.map((type) => (_jsxs("button", { type: "button", onClick: () => setSelectedName(type.name), className: cn('group flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors', selected?.name === type.name
101
+ ? 'bg-violet-100 dark:bg-violet-950'
102
+ : 'hover:bg-zinc-50 dark:hover:bg-zinc-800'), children: [_jsx("span", { "aria-hidden": true, className: cn('h-1.5 w-1.5 shrink-0 rounded-full', type.enriched ? 'bg-emerald-500' : 'bg-amber-400/60') }), _jsxs("span", { className: "min-w-0 flex-1", children: [_jsxs("span", { className: "block truncate text-sm", children: [type.icon ? `${type.icon} ` : '', type.displayName] }), _jsx("span", { className: cn('block truncate font-mono text-[10px]', MUTED), children: type.tableName })] })] }, type.name)))] }, group)))] })] }), _jsx("main", { className: "min-w-0 flex-1 overflow-y-auto", children: selected && (_jsx(TypeDetail, { type: selected, explorerHref: explorerHref, onPatchType: (patch) => typeMutation.mutate({ name: selected.name, patch }), onPatchProperty: (property, patch) => propertyMutation.mutate({ name: selected.name, property, patch }), onNavigate: setSelectedName }, selected.name)) })] })] }) }));
103
+ }
104
+ function Stat({ label, value }) {
105
+ return (_jsxs("div", { className: "text-right", children: [_jsx("div", { className: "font-mono text-xl leading-none tabular-nums", children: value }), _jsx("div", { className: cn('mt-1 font-mono text-[10px] uppercase tracking-[0.14em]', MUTED), children: label })] }));
106
+ }
107
+ function TypeDetail({ type, explorerHref, onPatchType, onPatchProperty, onNavigate, }) {
108
+ const visible = type.properties.filter((p) => !p.hidden).length;
109
+ return (_jsxs("div", { className: "mx-auto max-w-5xl px-8 py-8", children: [_jsxs("div", { className: "flex flex-wrap items-start justify-between gap-4", children: [_jsxs("div", { className: "min-w-0", children: [_jsxs("div", { className: "flex items-baseline gap-2", children: [_jsx("span", { className: "text-2xl leading-none", children: type.icon ?? '◈' }), _jsx(EditableField, { label: "display name", value: type.displayName, onSave: (displayName) => onPatchType({ displayName }), className: "text-2xl font-semibold tracking-tight", inputClassName: "text-2xl font-semibold tracking-tight" })] }), _jsxs("div", { className: cn('mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-1 pl-1 font-mono text-[11px]', MUTED), children: [_jsx("span", { children: type.name }), _jsx("span", { "aria-hidden": true, children: "\u00B7" }), _jsx("span", { children: type.tableName }), _jsx("span", { "aria-hidden": true, children: "\u00B7" }), _jsxs("span", { children: ["pk ", type.primaryKey.join(', ') || 'none'] }), _jsx("span", { "aria-hidden": true, children: "\u00B7" }), _jsxs("span", { children: [visible, " of ", type.properties.length, " shown"] })] })] }), explorerHref && (_jsxs("a", { href: explorerHref(type.name), className: cn('flex items-center gap-1.5 rounded-md bg-zinc-950 px-3 py-2 text-xs text-zinc-50', 'transition-colors hover:bg-zinc-800 dark:bg-zinc-100 dark:text-zinc-950 dark:hover:bg-zinc-300'), children: ["Open ", type.pluralDisplayName, _jsx(ArrowUpRight, { size: 13 })] }))] }), _jsx("div", { className: "mt-5 border-l-2 border-violet-200 pl-4 dark:border-violet-900", children: _jsx(EditableField, { label: "description", multiline: true, value: type.description ?? '', placeholder: "No one has written down what this type means yet.", onSave: (description) => onPatchType({ description }), className: cn('text-sm leading-relaxed', SECONDARY), inputClassName: "text-sm leading-relaxed" }) }), _jsxs("div", { className: "mt-4 flex flex-wrap items-center gap-2", children: [_jsx(FieldChip, { label: "Group", value: type.group, onSave: (group) => onPatchType({ group }) }), _jsx(FieldChip, { label: "Plural", value: type.pluralDisplayName, onSave: (pluralDisplayName) => onPatchType({ pluralDisplayName }) }), _jsx(FieldChip, { label: "Icon", value: type.icon ?? '', onSave: (icon) => onPatchType({ icon }) })] }), _jsxs("section", { className: "mt-10", children: [_jsx(SectionHeading, { title: "Properties", note: "The column and its SQL type are read from the ORM. The label, description and unit are yours." }), _jsx("div", { className: cn('overflow-hidden rounded-lg border', RULE, PANEL), children: _jsxs("table", { className: "w-full text-sm", children: [_jsx("thead", { children: _jsxs("tr", { className: cn('border-b bg-zinc-50 text-left dark:bg-zinc-950', RULE), children: [_jsx(Th, { className: "w-[30%]", children: "Label" }), _jsx(Th, { className: "w-[22%]", children: "Column" }), _jsx(Th, { className: "w-[10%]", children: "Type" }), _jsx(Th, { className: "w-[12%]", children: "Unit" }), _jsx(Th, { className: "w-[20%]", children: "Meaning" }), _jsx(Th, { className: "w-[6%] text-right", children: "Shown" })] }) }), _jsx("tbody", { children: type.properties.map((property) => (_jsxs("tr", { className: cn('border-b last:border-0', HAIRLINE, property.hidden && 'opacity-45'), children: [_jsxs("td", { className: "px-3 py-2 align-top", children: [_jsx(EditableField, { label: `label for ${property.name}`, value: property.displayName, onSave: (displayName) => onPatchProperty(property.name, { displayName }), inputClassName: "text-sm" }), _jsxs("div", { className: cn('px-1.5 font-mono text-[10px]', MUTED), children: [property.name, property.primary && (_jsx(Tooltip, { content: "Primary key. Always fetched, even when hidden, so a row keeps a stable identity.", children: _jsx("span", { className: "ml-1.5 cursor-help text-violet-600 dark:text-violet-400", children: "pk" }) })), !property.nullable && !property.primary && (_jsx(Tooltip, { content: "NOT NULL in the database. Read from the ORM, not something this screen can change.", children: _jsx("span", { className: "ml-1.5 cursor-help text-amber-600", children: "required" }) }))] })] }), _jsx("td", { className: cn('px-3 py-2 align-top font-mono text-[11px]', SECONDARY), children: property.columnName }), _jsx("td", { className: "px-3 py-2 align-top", children: _jsx(ScalarBadge, { type: property.type }) }), _jsx("td", { className: "px-3 py-2 align-top", children: _jsx(EditableField, { label: `unit for ${property.name}`, value: property.unit ?? '', placeholder: "\u2014", onSave: (unit) => onPatchProperty(property.name, { unit }), inputClassName: "text-xs", className: "text-xs" }) }), _jsx("td", { className: "px-3 py-2 align-top", children: _jsx(EditableField, { label: `description for ${property.name}`, multiline: true, value: property.description ?? '', placeholder: "\u2014", onSave: (description) => onPatchProperty(property.name, { description }), className: cn('text-xs leading-snug', SECONDARY), inputClassName: "text-xs leading-snug" }) }), _jsx("td", { className: "px-3 py-2 text-right align-top", children: _jsx(Tooltip, { content: property.hidden
110
+ ? `Hidden from tables and search. ${property.displayName} is still stored — showing it again needs no migration.`
111
+ : `Shown in tables and search. Hiding it only changes what is displayed; the column is untouched.`, children: _jsx("button", { type: "button", "aria-label": `${property.hidden ? 'Show' : 'Hide'} ${property.displayName}`, onClick: () => onPatchProperty(property.name, {
112
+ hidden: !property.hidden,
113
+ }), className: cn('rounded-sm p-1 hover:bg-zinc-100 dark:hover:bg-zinc-800', MUTED), children: property.hidden ? _jsx(EyeOff, { size: 14 }) : _jsx(Eye, { size: 14 }) }) }) })] }, property.name))) })] }) })] }), _jsxs("section", { className: "mt-10 pb-16", children: [_jsx(SectionHeading, { title: "Links", note: "Read from the foreign keys." }), type.relations.length === 0 ? (_jsxs("p", { className: cn('rounded-lg border border-dashed px-4 py-6 text-center text-sm', RULE, MUTED), children: ["Nothing links to or from ", type.displayName, " yet."] })) : (_jsx("div", { className: "flex flex-wrap gap-2", children: type.relations.map((relation) => (_jsxs("button", { type: "button", onClick: () => onNavigate(relation.targetType), className: cn('group flex items-center gap-2 rounded-md border px-3 py-2 text-left transition-colors', RULE, PANEL, 'hover:border-violet-500 hover:bg-violet-100 dark:hover:bg-violet-950'), children: [_jsx("span", { className: cn('font-mono text-[10px] uppercase tracking-wider', MUTED), children: relation.kind }), _jsx("span", { className: "text-sm", children: relation.displayName }), _jsxs("span", { className: cn('font-mono text-[10px]', MUTED), children: ["\u2192 ", relation.targetType] })] }, relation.name))) }))] })] }));
114
+ }
115
+ function SectionHeading({ title, note }) {
116
+ return (_jsxs("div", { className: "mb-3", children: [_jsx("h2", { className: cn('font-mono text-[11px] uppercase tracking-[0.16em]', MUTED), children: title }), _jsx("p", { className: cn('mt-1 text-xs', MUTED), children: note })] }));
117
+ }
118
+ function Th({ children, className, }) {
119
+ return (_jsx("th", { className: cn('px-3 py-2 font-mono text-[10px] font-normal uppercase tracking-[0.12em]', MUTED, className), children: children }));
120
+ }
121
+ function FieldChip({ label, value, onSave, }) {
122
+ return (_jsxs("div", { className: cn('flex items-center gap-1.5 rounded-md border px-2 py-1', RULE, PANEL), children: [_jsx("span", { className: cn('font-mono text-[10px] uppercase tracking-wider', MUTED), children: label }), _jsx(EditableField, { label: label, value: value, placeholder: "\u2014", onSave: onSave, className: "text-xs", inputClassName: "text-xs" })] }));
123
+ }
@@ -0,0 +1,41 @@
1
+ import type { CatalogConnection, ConnectorKind } from '@dudousxd/nestjs-catalog/client';
2
+ /**
3
+ * One line saying what a connection actually points at.
4
+ *
5
+ * Per kind rather than reading `config.url` for everything, because an S3
6
+ * connection has no url and would render a blank subtitle — a card saying a
7
+ * connection exists and nothing about where it goes, which is the one thing the
8
+ * list is for.
9
+ */
10
+ export declare function describeConnection(connection: CatalogConnection): string;
11
+ export interface ConnectionPanelProps {
12
+ /**
13
+ * Hidden when the caller knows the viewer cannot write. The endpoints refuse
14
+ * anyway; this only stops a console offering a button that always 403s.
15
+ */
16
+ canEdit?: boolean;
17
+ }
18
+ /**
19
+ * Named, reusable sources — and a button that finds out whether they answer.
20
+ *
21
+ * The reason this screen is worth having at all is the test. Before it, the
22
+ * only way to learn that a host was wrong, a credential missing or a bucket
23
+ * spelled differently was to run a load and read the failure — which happens on
24
+ * a schedule, hours after somebody typed it, and is attributed to a connector
25
+ * rather than to the address it borrowed.
26
+ */
27
+ export declare function ConnectionPanel({ canEdit }: ConnectionPanelProps): import("react/jsx-runtime").JSX.Element;
28
+ /**
29
+ * The options a connector form offers for "read through".
30
+ *
31
+ * Exported because the connector form lives in another file and this list has
32
+ * one rule that must not be duplicated: only connections of the same kind. A
33
+ * connector reading S3 through a database connection is not a configuration
34
+ * anybody meant, and it would fail at run time with an error about a missing
35
+ * bucket rather than about the mistake.
36
+ */
37
+ export declare function connectionOptionsFor(kind: ConnectorKind, connections: CatalogConnection[]): {
38
+ value: string;
39
+ label: string;
40
+ hint: string;
41
+ }[];
@@ -0,0 +1,228 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
3
+ import { CircleCheck, CircleX, KeyRound, Loader2, Pencil, Plug, Plus, Trash2, Waypoints, } from 'lucide-react';
4
+ import { useState } from 'react';
5
+ import { cn } from './cn';
6
+ import { catalogQueryKeys, useCatalogClient } from './context';
7
+ import { ConfirmDialog } from './ui/dialog';
8
+ import { FieldGroup, TextField } from './ui/field';
9
+ import { SelectField } from './ui/select';
10
+ import { Switch } from './ui/switch';
11
+ import { Tooltip } from './ui/tooltip';
12
+ const MUTED = 'text-zinc-400 dark:text-zinc-500';
13
+ const RULE = 'border-zinc-200 dark:border-zinc-800';
14
+ const PANEL = 'bg-white dark:bg-zinc-900';
15
+ /**
16
+ * The kinds worth naming once and reusing.
17
+ *
18
+ * Deliberately three of the five a connector can be, and the two that are
19
+ * missing are missing for the same reason the checker refuses to probe them: a
20
+ * file's path and a set of pasted records belong to the load, not to a shared
21
+ * address. A connection there would be a name with no address behind it, and a
22
+ * "Test connection" that always passes is worse than no button — it teaches
23
+ * people that a green tick means nothing.
24
+ */
25
+ const CONNECTABLE_KINDS = ['http', 'sql', 's3'];
26
+ /** A select hands back a string. Narrow it rather than promise it is a kind. */
27
+ function toConnectableKind(value) {
28
+ return CONNECTABLE_KINDS.find((kind) => kind === value) ?? 'http';
29
+ }
30
+ const KIND_OPTIONS = [
31
+ { value: 'http', label: 'HTTP — a JSON endpoint' },
32
+ { value: 'sql', label: 'SQL — a database' },
33
+ { value: 's3', label: 'S3 — a bucket, or anything S3-compatible' },
34
+ ];
35
+ /** Read a string out of a stored config without believing it is one. */
36
+ function text(config, key) {
37
+ const value = config[key];
38
+ return typeof value === 'string' ? value : '';
39
+ }
40
+ /**
41
+ * One line saying what a connection actually points at.
42
+ *
43
+ * Per kind rather than reading `config.url` for everything, because an S3
44
+ * connection has no url and would render a blank subtitle — a card saying a
45
+ * connection exists and nothing about where it goes, which is the one thing the
46
+ * list is for.
47
+ */
48
+ export function describeConnection(connection) {
49
+ const config = connection.config ?? {};
50
+ if (connection.kind === 's3') {
51
+ const bucket = text(config, 'bucket') || '(no bucket)';
52
+ const endpoint = text(config, 'endpoint');
53
+ const region = text(config, 'region');
54
+ return `s3://${bucket}${endpoint ? ` · ${endpoint}` : ''}${region ? ` · ${region}` : ''}`;
55
+ }
56
+ if (connection.kind === 'sql') {
57
+ const url = text(config, 'url');
58
+ // The credential path is the normal one for a database, and it has no URL
59
+ // to show — saying which variable holds it is the honest substitute.
60
+ if (url)
61
+ return url;
62
+ return connection.secretEnvVar ? `URL from $${connection.secretEnvVar}` : 'no URL configured';
63
+ }
64
+ return text(config, 'url') || 'no URL configured';
65
+ }
66
+ /**
67
+ * Named, reusable sources — and a button that finds out whether they answer.
68
+ *
69
+ * The reason this screen is worth having at all is the test. Before it, the
70
+ * only way to learn that a host was wrong, a credential missing or a bucket
71
+ * spelled differently was to run a load and read the failure — which happens on
72
+ * a schedule, hours after somebody typed it, and is attributed to a connector
73
+ * rather than to the address it borrowed.
74
+ */
75
+ export function ConnectionPanel({ canEdit = true }) {
76
+ const client = useCatalogClient();
77
+ const queryClient = useQueryClient();
78
+ const [editing, setEditing] = useState(null);
79
+ const { data: connections = [], isPending, isError, } = useQuery({
80
+ queryKey: catalogQueryKeys.connections,
81
+ queryFn: () => client.listConnections(),
82
+ });
83
+ // One request for every card's "used by", rather than one per card. The
84
+ // connectors list is loaded by the sibling tab anyway, so this is usually a
85
+ // cache hit, and a per-card fetch would put N requests behind a screen whose
86
+ // whole job is to be quick to glance at.
87
+ const { data: connectors = [] } = useQuery({
88
+ queryKey: catalogQueryKeys.connectors,
89
+ queryFn: () => client.listConnectors(),
90
+ });
91
+ const invalidate = () => {
92
+ queryClient.invalidateQueries({ queryKey: catalogQueryKeys.connections });
93
+ queryClient.invalidateQueries({ queryKey: catalogQueryKeys.connectors });
94
+ };
95
+ if (editing) {
96
+ return (_jsx(ConnectionForm, { connection: editing === 'new' ? undefined : editing, onClose: () => setEditing(null), onSaved: () => {
97
+ setEditing(null);
98
+ invalidate();
99
+ } }));
100
+ }
101
+ return (_jsxs("div", { className: "mt-6 space-y-3", children: [canEdit && (_jsxs("button", { type: "button", onClick: () => setEditing('new'), className: cn('flex items-center gap-1.5 rounded-md border px-3 py-1.5 text-xs', RULE, 'hover:bg-zinc-50 dark:hover:bg-zinc-800'), children: [_jsx(Plus, { size: 12 }), "New connection"] })), isPending && (_jsx("p", { className: cn('rounded-lg border border-dashed px-4 py-12 text-center text-sm', RULE, MUTED), children: "Reading connections\u2026" })), isError && (_jsx("p", { className: "rounded-lg border border-red-200 bg-red-50 px-4 py-8 text-center text-sm text-red-700 dark:border-red-900 dark:bg-red-950/40 dark:text-red-300", children: "Could not read the connections. This is not the same as having none \u2014 nothing here is safe to act on until it loads." })), !isPending && !isError && connections.length === 0 && (_jsx("p", { className: cn('rounded-lg border border-dashed px-4 py-12 text-center text-sm', RULE, MUTED), children: "No connections yet. A connector can still carry its own address \u2014 a connection is worth making when more than one of them shares it." })), connections.map((connection) => (_jsx(ConnectionCard, { connection: connection, users: connectors.filter((c) => c.connectionId === connection.id), canEdit: canEdit, onEdit: () => setEditing(connection), onChanged: invalidate }, connection.id)))] }));
102
+ }
103
+ function ConnectionCard({ connection, users, canEdit, onEdit, onChanged, }) {
104
+ const client = useCatalogClient();
105
+ const [confirming, setConfirming] = useState(false);
106
+ /** Filled only when the server refuses a delete, with its own answer. */
107
+ const [blockedBy, setBlockedBy] = useState(null);
108
+ const check = useMutation({
109
+ mutationFn: () => client.checkConnection(connection.id),
110
+ // The server records the outcome as well as returning it, so the stored
111
+ // lastChecked fields on the card are stale the moment this resolves.
112
+ onSuccess: onChanged,
113
+ });
114
+ const remove = useMutation({
115
+ mutationFn: async () => {
116
+ const result = await client.deleteConnection(connection.id);
117
+ if (!result.deleted) {
118
+ // The store refuses while connectors still read through it. Asking who
119
+ // they are is the difference between "it would not delete" and a
120
+ // sentence somebody can act on — and it is the server's answer, not the
121
+ // list this page happened to load a minute ago.
122
+ setBlockedBy(await client.connectionConnectors(connection.id));
123
+ throw new Error('Still in use.');
124
+ }
125
+ return result;
126
+ },
127
+ onSuccess: () => {
128
+ setConfirming(false);
129
+ onChanged();
130
+ },
131
+ });
132
+ const result = check.data;
133
+ return (_jsxs("div", { className: cn('rounded-lg border p-4', RULE, PANEL), children: [_jsxs("div", { className: "flex flex-wrap items-start justify-between gap-3", children: [_jsxs("div", { className: "min-w-0", children: [_jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsx(Plug, { size: 13, className: MUTED }), _jsx("span", { className: "text-sm font-medium", children: connection.name }), _jsx("span", { className: "rounded-sm bg-zinc-100 px-1.5 py-0.5 font-mono text-[10px] uppercase dark:bg-zinc-800", children: connection.kind }), users.length > 0 && (_jsx(Tooltip, { content: `Read through by ${users.map((c) => c.name).join(', ')}. Moving this address moves all of them at once, which is the point.`, children: _jsxs("span", { className: cn('flex cursor-help items-center gap-1 font-mono text-[10px]', MUTED), children: [_jsx(Waypoints, { size: 10 }), users.length] }) }))] }), _jsx("div", { className: cn('mt-1 font-mono text-[11px]', MUTED), children: describeConnection(connection) }), connection.description && (_jsx("p", { className: cn('mt-1 text-[11px]', MUTED), children: connection.description })), connection.secretEnvVar && (_jsx(Tooltip, { content: "The catalog stores the NAME of this variable, never its value. A leaked catalog database gives away the shape of the integration, not the keys to it.", children: _jsxs("div", { className: cn('mt-1 flex w-fit cursor-help items-center gap-1 font-mono text-[10px]', MUTED), children: [_jsx(KeyRound, { size: 10 }), connection.secretEnvVar] }) }))] }), _jsxs("div", { className: "flex shrink-0 items-center gap-1", children: [_jsxs("button", { type: "button", onClick: () => check.mutate(), disabled: check.isPending, className: cn('flex items-center gap-1.5 rounded-md border px-3 py-1.5 text-xs disabled:opacity-40', RULE, 'hover:bg-zinc-50 dark:hover:bg-zinc-800'), children: [check.isPending ? _jsx(Loader2, { size: 12, className: "animate-spin" }) : _jsx(Plug, { size: 12 }), check.isPending ? 'Reaching…' : 'Test connection'] }), canEdit && (_jsxs(_Fragment, { children: [_jsx(Tooltip, { content: `Edit ${connection.name}`, children: _jsx("button", { type: "button", onClick: onEdit, "aria-label": `Edit ${connection.name}`, className: cn('rounded-sm p-1.5 hover:text-violet-600', MUTED), children: _jsx(Pencil, { size: 12 }) }) }), _jsx(Tooltip, { content: users.length > 0
134
+ ? `${users.length} connector${users.length === 1 ? '' : 's'} read through this. Deleting it is refused while that is true.`
135
+ : `Delete ${connection.name}`, children: _jsx("button", { type: "button", onClick: () => {
136
+ setBlockedBy(null);
137
+ remove.reset();
138
+ setConfirming(true);
139
+ }, "aria-label": `Delete ${connection.name}`, className: cn('rounded-sm p-1.5 hover:text-red-600', MUTED), children: _jsx(Trash2, { size: 12 }) }) })] }))] })] }), !result && connection.lastCheckedAt && (_jsxs("div", { className: cn('mt-3 flex items-center gap-2 border-t pt-3 text-[11px]', RULE), children: [connection.lastCheckOk ? (_jsx(CircleCheck, { size: 12, "aria-hidden": true, className: "text-emerald-600" })) : (_jsx(CircleX, { size: 12, "aria-hidden": true, className: "text-red-600" })), _jsx("span", { className: "sr-only", children: connection.lastCheckOk ? 'Reachable: ' : 'Unreachable: ' }), _jsx("span", { className: MUTED, children: connection.lastCheckOk
140
+ ? 'Reached'
141
+ : (connection.lastCheckError ?? 'Could not reach it') }), _jsx("span", { className: cn('ml-auto font-mono text-[10px]', MUTED), children: new Date(connection.lastCheckedAt).toLocaleString() })] })), result && (_jsx("div", { className: cn('mt-3 rounded-md border px-3 py-2 text-[11px]', result.ok
142
+ ? 'border-emerald-200 bg-emerald-50 text-emerald-800 dark:border-emerald-900 dark:bg-emerald-950/40 dark:text-emerald-300'
143
+ : 'border-red-200 bg-red-50 text-red-700 dark:border-red-900 dark:bg-red-950/40 dark:text-red-300'), children: _jsxs("div", { className: "flex items-start gap-2", children: [result.ok ? (_jsx(CircleCheck, { size: 13, "aria-hidden": true, className: "mt-px shrink-0" })) : (_jsx(CircleX, { size: 13, "aria-hidden": true, className: "mt-px shrink-0" })), _jsxs("div", { className: "min-w-0", children: [_jsx("div", { className: "font-medium", children: result.ok ? 'Reached it.' : 'Could not reach it.' }), _jsx("div", { className: "mt-0.5 font-mono leading-relaxed", children: result.detail }), result.error && (_jsx("div", { className: "mt-1 font-mono leading-relaxed opacity-80", children: result.error })), _jsxs("div", { className: "mt-1 font-mono text-[10px] opacity-70", children: [result.elapsedMs, " ms"] })] })] }) })), check.error && !result && (_jsx("p", { className: "mt-3 text-[11px] text-red-600", children: check.error instanceof Error ? check.error.message : 'The check itself failed.' })), _jsx(ConfirmDialog, { open: confirming, onOpenChange: (open) => {
144
+ setConfirming(open);
145
+ if (!open)
146
+ setBlockedBy(null);
147
+ }, title: `Delete ${connection.name}?`, description: users.length > 0 ? (_jsxs(_Fragment, { children: [users.length, " connector", users.length === 1 ? '' : 's', " read through this connection \u2014", ' ', users.map((c) => c.name).join(', '), ". Deleting it would leave", ' ', users.length === 1 ? 'it' : 'them', " without an address, and that is discovered on the next scheduled run rather than now. The server refuses while this is true."] })) : ('Nothing reads through it. The connectors that used to are unaffected; only this address and the name of its credential variable go.'), confirmLabel: remove.isPending ? 'Deleting…' : 'Delete', pending: remove.isPending, onConfirm: () => remove.mutate(), error: blockedBy && blockedBy.length > 0 ? (_jsxs(_Fragment, { children: ["Refused: still read through by ", blockedBy.map((c) => c.name).join(', '), ". Point", ' ', blockedBy.length === 1 ? 'it' : 'them', " elsewhere first."] })) : remove.error && !blockedBy ? (remove.error instanceof Error ? (remove.error.message) : ('Could not delete it.')) : undefined })] }));
148
+ }
149
+ /**
150
+ * Create or edit one.
151
+ *
152
+ * The form carries the address and the credential variable and nothing about
153
+ * any particular load — no query, no prefix, no path. That split is the whole
154
+ * point of the concept: five connectors reading one database used to hold five
155
+ * copies of its URL, and moving the database meant editing five rows nobody
156
+ * could find.
157
+ */
158
+ function ConnectionForm({ connection, onClose, onSaved, }) {
159
+ const client = useCatalogClient();
160
+ const config = connection?.config ?? {};
161
+ const [kind, setKind] = useState(toConnectableKind(connection?.kind ?? 'http'));
162
+ const [draft, setDraft] = useState({
163
+ name: connection?.name ?? '',
164
+ description: connection?.description ?? '',
165
+ url: text(config, 'url'),
166
+ bucket: text(config, 'bucket'),
167
+ endpoint: text(config, 'endpoint'),
168
+ region: text(config, 'region'),
169
+ forcePathStyle: config.forcePathStyle === true,
170
+ secretEnvVar: connection?.secretEnvVar ?? '',
171
+ });
172
+ const save = useMutation({
173
+ mutationFn: () => {
174
+ // Only the fields this kind reads. Carrying the rest would leave a stale
175
+ // bucket on an HTTP connection, which reads as configuration somebody
176
+ // meant rather than a leftover from a dropdown they changed.
177
+ const next = kind === 's3'
178
+ ? {
179
+ bucket: draft.bucket,
180
+ ...(draft.endpoint ? { endpoint: draft.endpoint } : {}),
181
+ ...(draft.region ? { region: draft.region } : {}),
182
+ ...(draft.forcePathStyle ? { forcePathStyle: true } : {}),
183
+ }
184
+ : draft.url
185
+ ? { url: draft.url }
186
+ : {};
187
+ const input = {
188
+ id: connection?.id,
189
+ name: draft.name.trim(),
190
+ description: draft.description.trim() || undefined,
191
+ kind,
192
+ config: next,
193
+ secretEnvVar: draft.secretEnvVar.trim() || undefined,
194
+ };
195
+ return client.saveConnection(input);
196
+ },
197
+ onSuccess: onSaved,
198
+ });
199
+ const incomplete = draft.name.trim().length === 0 ||
200
+ (kind === 's3' && draft.bucket.trim().length === 0) ||
201
+ (kind === 'http' && draft.url.trim().length === 0) ||
202
+ // A SQL connection needs one of the two, and neither is more correct: the
203
+ // variable is the right answer in a deployment, the inline URL is the one
204
+ // that gets somebody running locally in a minute.
205
+ (kind === 'sql' && draft.url.trim().length === 0 && draft.secretEnvVar.trim().length === 0);
206
+ return (_jsxs("form", { className: cn('mt-6 space-y-4 rounded-lg border p-4', RULE, PANEL), onSubmit: (event) => {
207
+ event.preventDefault();
208
+ save.mutate();
209
+ }, children: [_jsxs("div", { className: "grid gap-3 sm:grid-cols-3", children: [_jsx(TextField, { label: "Name", value: draft.name, onChange: (name) => setDraft({ ...draft, name }), placeholder: "Fleet warehouse" }), _jsx(TextField, { label: "Description", value: draft.description, onChange: (description) => setDraft({ ...draft, description }), placeholder: "What lives behind it (optional)" }), _jsx(SelectField, { label: "Kind", ariaLabel: "Connection kind", value: kind, onValueChange: (value) => setKind(toConnectableKind(value)), options: KIND_OPTIONS })] }), kind === 'http' && (_jsx(TextField, { label: "URL", value: draft.url, onChange: (url) => setDraft({ ...draft, url }), placeholder: "https://api.example.mil/v1", hint: "The base the connectors reading through this will hang their paths off." })), kind === 'sql' && (_jsx(FieldGroup, { title: "Address", hint: "Name the variable holding the connection URL \u2014 that is the whole credential for most databases, so the catalog stores its name and never its value. The inline URL is here for local work.", children: _jsxs("div", { className: "grid gap-3 sm:grid-cols-2", children: [_jsx(TextField, { label: "URL (optional)", value: draft.url, onChange: (url) => setDraft({ ...draft, url }), placeholder: "mysql://user:pass@host/db" }), _jsx(TextField, { label: "Env var holding the URL", value: draft.secretEnvVar, onChange: (secretEnvVar) => setDraft({ ...draft, secretEnvVar }), placeholder: "FLEET_DATABASE_URL" })] }) })), kind === 's3' && (_jsxs(FieldGroup, { title: "Bucket", children: [_jsxs("div", { className: "grid gap-3 sm:grid-cols-2", children: [_jsx(TextField, { label: "Bucket", value: draft.bucket, onChange: (bucket) => setDraft({ ...draft, bucket }), placeholder: "fleet-drops" }), _jsx(TextField, { label: "Region", value: draft.region, onChange: (region) => setDraft({ ...draft, region }), placeholder: "Blank uses the environment's" }), _jsx(TextField, { label: "Endpoint", value: draft.endpoint, onChange: (endpoint) => setDraft({ ...draft, endpoint }), placeholder: "MinIO, e.g. http://localhost:9000" }), _jsx(TextField, { label: "Env var holding accessKeyId:secretAccessKey", value: draft.secretEnvVar, onChange: (secretEnvVar) => setDraft({ ...draft, secretEnvVar }), placeholder: "Optional", hint: "Leave blank anywhere the pod has its own role \u2014 those credentials rotate, and a static pair named here would not." })] }), _jsx(Switch, { checked: draft.forcePathStyle, onCheckedChange: (forcePathStyle) => setDraft({ ...draft, forcePathStyle }), label: "Path-style addressing", hint: "MinIO needs it; AWS does not." })] })), kind === 'http' && (_jsx(TextField, { label: "Credential env var", value: draft.secretEnvVar, onChange: (secretEnvVar) => setDraft({ ...draft, secretEnvVar }), placeholder: "Optional \u2014 sent as a bearer token" })), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx("button", { type: "submit", disabled: save.isPending || incomplete, className: "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: save.isPending ? 'Saving…' : connection ? 'Save changes' : 'Save connection' }), _jsx("button", { type: "button", onClick: onClose, className: cn('rounded-md px-3 py-1.5 text-xs', MUTED), children: "Cancel" }), _jsx("span", { className: cn('text-[11px]', MUTED), children: "Saving does not reach it. Test the connection from its card." })] }), save.error && (_jsx("p", { className: "text-[11px] text-red-600", children: save.error instanceof Error ? save.error.message : 'Could not save.' }))] }));
210
+ }
211
+ /**
212
+ * The options a connector form offers for "read through".
213
+ *
214
+ * Exported because the connector form lives in another file and this list has
215
+ * one rule that must not be duplicated: only connections of the same kind. A
216
+ * connector reading S3 through a database connection is not a configuration
217
+ * anybody meant, and it would fail at run time with an error about a missing
218
+ * bucket rather than about the mistake.
219
+ */
220
+ export function connectionOptionsFor(kind, connections) {
221
+ return connections
222
+ .filter((connection) => connection.kind === kind)
223
+ .map((connection) => ({
224
+ value: connection.id,
225
+ label: connection.name,
226
+ hint: describeConnection(connection),
227
+ }));
228
+ }
@@ -0,0 +1,16 @@
1
+ import type { CatalogObjectTypeDef } from '@dudousxd/nestjs-catalog/client';
2
+ interface CoverageLedgerProps {
3
+ types: CatalogObjectTypeDef[];
4
+ selected?: string;
5
+ onSelect: (name: string) => void;
6
+ }
7
+ /**
8
+ * One tick per object type: filled when a human has named it, hollow when its
9
+ * name is still a guess made by a regex.
10
+ *
11
+ * A count would say "13 of 58". The ledger shows *which* 58, that the named
12
+ * ones cluster in the groups people actually work in, and that the long hollow
13
+ * tail is the work remaining.
14
+ */
15
+ export declare function CoverageLedger({ types, selected, onSelect }: CoverageLedgerProps): import("react/jsx-runtime").JSX.Element;
16
+ export {};
@@ -0,0 +1,16 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cn } from './cn';
3
+ /**
4
+ * One tick per object type: filled when a human has named it, hollow when its
5
+ * name is still a guess made by a regex.
6
+ *
7
+ * A count would say "13 of 58". The ledger shows *which* 58, that the named
8
+ * ones cluster in the groups people actually work in, and that the long hollow
9
+ * tail is the work remaining.
10
+ */
11
+ export function CoverageLedger({ types, selected, onSelect }) {
12
+ const named = types.filter((t) => t.enriched).length;
13
+ return (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx("div", { className: "flex flex-wrap items-end gap-[3px]", children: types.map((type, index) => (_jsx("button", { type: "button", onClick: () => onSelect(type.name), title: `${type.displayName} — ${type.enriched ? 'named' : 'not yet named'}`, "aria-label": `${type.displayName}, ${type.enriched ? 'named' : 'not yet named'}`, style: { animationDelay: `${Math.min(index * 12, 600)}ms` }, className: cn('h-7 w-[7px] rounded-[1px] transition-all duration-150', 'hover:h-9 focus-visible:h-9 focus-visible:outline-2', 'focus-visible:outline-offset-2 focus-visible:outline-violet-500', type.enriched
14
+ ? 'bg-emerald-500/85 hover:bg-emerald-500'
15
+ : 'bg-amber-400/55 hover:bg-amber-400/90', selected === type.name && 'h-10 bg-violet-600 hover:bg-violet-600') }, type.name))) }), _jsxs("p", { className: "font-mono text-[11px] tracking-tight text-zinc-400 dark:text-zinc-500", children: [_jsx("span", { className: "text-zinc-950 dark:text-zinc-50", children: named }), " of ", types.length, " object types carry a name a person chose. The rest still answer to whatever the class was called."] })] }));
16
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Saved queries, laid out on a page.
3
+ *
4
+ * Each card runs its own saved query and honours the TTL that query was saved
5
+ * with — so a dashboard of cached cards costs one round trip and no database
6
+ * work, and a dashboard of uncached ones is honest about being expensive. The
7
+ * alternative, a dashboard-wide refresh policy, would override a decision the
8
+ * query's author already made with more information than the dashboard has.
9
+ */
10
+ export declare function DashboardBoard(): import("react/jsx-runtime").JSX.Element;