@dudousxd/nestjs-catalog-react 0.17.0 → 0.18.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.
@@ -1,85 +1,50 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
3
- import { Cable, CircleCheck, CircleX, Code2, KeyRound, Loader2, Play, Plug, Plus, RefreshCw, ScanSearch, Trash2, TriangleAlert, } from 'lucide-react';
4
- import { useMemo, useState } from 'react';
5
- import { ConnectionPanel, connectionOptionsFor } from './ConnectionPanel';
3
+ import { Code2, Plug, Plus, Trash2 } from 'lucide-react';
4
+ import { useState } from 'react';
5
+ import { ConnectionPanel } from './ConnectionPanel';
6
6
  import { TransformEditor } from './TransformEditor';
7
7
  import { cn } from './cn';
8
8
  import { catalogQueryKeys, useCatalogClient } from './context';
9
- import { RevisionHistorySheet } from './diff/RevisionDiff';
10
- // One description of what a source needs, shared with the workflow canvas's
11
- // source inspector. See the header of that module for why it is not two.
12
- import { INLINE_CONNECTION, KIND_OPTIONS, ReadModeFields, SourceFields, parseRecords, readsIncrementally, sourceConfigFrom, sourceDraftFrom, sourceIsIncomplete, toConnectorKind, usesConnection, } from './source-fields';
9
+ import { Button } from './ui/button';
13
10
  import { ConfirmDialog } from './ui/dialog';
14
- import { TextField } from './ui/field';
15
- import { SelectField } from './ui/select';
16
- import { Switch } from './ui/switch';
17
11
  import { Tabs, TabsList, TabsPanel, TabsTab } from './ui/tabs';
18
12
  import { Tooltip, TooltipProvider } from './ui/tooltip';
13
+ import { WORKFLOW_NAME } from './workflow/name';
19
14
  const MUTED = 'text-zinc-400 dark:text-zinc-500';
20
15
  const RULE = 'border-zinc-200 dark:border-zinc-800';
21
16
  const PANEL = 'bg-white dark:bg-zinc-900';
22
17
  /**
23
- * The discovery response, checked rather than assumed.
24
- *
25
- * The client returns `unknown` because this package must not import
26
- * `@dudousxd/nestjs-catalog-pipeline` — it would drag database drivers behind
27
- * optional imports into a browser bundle — so the shape above is a mirror of a
28
- * contract held somewhere else. A mirror can fall behind: a console talking to
29
- * an older server gets a body with no `columns`, and rendering it would throw
30
- * somewhere deep in the table with a message about `undefined.map`.
31
- *
32
- * Checked at the seam, once, so the failure names itself. Only the fields this
33
- * screen would crash without — validating every column here would be
34
- * re-implementing the server's own shape in a place that cannot be kept honest.
35
- */
36
- function narrowDiscovery(answer) {
37
- if (!answer || typeof answer !== 'object' || !Array.isArray(Reflect.get(answer, 'columns'))) {
38
- throw new Error('The server answered the discovery request with something this console does not recognise. ' +
39
- 'It is most likely running a version of @dudousxd/nestjs-catalog-pipeline older than this ' +
40
- 'console expects.');
41
- }
42
- return Object.assign(Object.create(null), answer);
43
- }
44
- /**
45
- * Where data comes from, and the code that shapes it.
46
- *
47
- * Three tabs on one screen because they are only ever understood together: a
48
- * connection without its connectors is an address nobody uses, a connector
49
- * without its transform is a URL, and a transform without the connector it
50
- * feeds is code nobody can place.
18
+ * The two things a pipeline borrows, and neither of them is a pipeline.
19
+ *
20
+ * WHAT THIS SCREEN STOPPED BEING
21
+ * ------------------------------
22
+ * It was `#connectors`, and its middle tab was where somebody authored a load:
23
+ * a name, a source kind, an address, a credential, a transform, a target type, a
24
+ * schedule. Every one of those is a field on a node of a graph now, and the
25
+ * routes behind that tab are gone — a connector is not authored any more, it is
26
+ * what a published {@link WORKFLOW_NAME.singular} runs as. Keeping the tab would
27
+ * have meant a form whose Save button 404s, which is worse than no form.
28
+ *
29
+ * WHAT IS LEFT, AND WHY IT IS NOT ON THE CANVAS
30
+ * ---------------------------------------------
31
+ * A connection is the credential and address boundary: a real object somebody
32
+ * manages, shared by several pipelines, with a "can this host actually be
33
+ * reached" question of its own that has nothing to do with any graph. Moving it
34
+ * onto a canvas would make managing an address something you can only do while
35
+ * drawing something.
36
+ *
37
+ * A transform is the other shared object — code, referenced by node id from any
38
+ * number of graphs. The canvas creates one and edits its code inline, because
39
+ * that is where you want it while wiring; this is where the whole set is listed,
40
+ * and where deleting one is a decision made deliberately rather than mid-drag.
41
+ *
42
+ * Authoring a pipeline is one screen and it is not this one. See
43
+ * `WorkflowCanvas`.
51
44
  */
52
- export function PipelineConsole({ title = 'Connectors', eyebrow = 'Ingestion', intro = 'A source, code that reshapes it, and a snapshot at the end. Running one goes through exactly the same append-and-commit a publisher uses, so there is one way rows arrive rather than two.', canEdit = true, schemaDiscovery, }) {
45
+ export function PipelineConsole({ title = 'Connections & transforms', eyebrow = 'Ingestion', intro = `The two things a ${WORKFLOW_NAME.singular} borrows: the addresses it reads through and the code it runs. Both are shared, so both outlive any one of them — which is why they are managed here rather than on the canvas where they are used.`, canEdit = true, }) {
53
46
  const client = useCatalogClient();
54
- const [tab, setTab] = useState('connectors');
55
- /**
56
- * The bridge, from the client, unless the host supplied its own.
57
- *
58
- * Until this existed the panel took `schemaDiscovery` as a prop and nothing
59
- * supplied one, so the feature was reachable only by a host that had read the
60
- * source and written the two calls itself. The prop stays — a host embedding
61
- * this screen may route discovery through its own gateway — but it is an
62
- * override now rather than the only way in.
63
- */
64
- const bridge = useMemo(() => ({
65
- discover: async (connectorId) => narrowDiscovery(await client.discoverConnectorSchema(connectorId)),
66
- // `async` on purpose: `publishType` THROWS rather than rejecting when the
67
- // transport cannot PUT, and a bridge whose method throws synchronously
68
- // would escape the panel's error handling and take the screen with it.
69
- createType: async (draft) => client.publishType(draft.name, {
70
- // Only what a person confirmed on screen. Everything else about a type
71
- // — its label, its description, its units — is curation, and inventing
72
- // any of it here would put words nobody chose into a catalog whose
73
- // whole claim is that its names were chosen.
74
- properties: draft.properties.map((property) => ({
75
- name: property.name,
76
- columnName: property.columnName,
77
- type: property.type,
78
- nullable: property.nullable,
79
- })),
80
- }),
81
- }), [client]);
82
- const discovery = schemaDiscovery ?? bridge;
47
+ const [tab, setTab] = useState('connections');
83
48
  const { data: capabilities } = useQuery({
84
49
  queryKey: catalogQueryKeys.capabilities,
85
50
  queryFn: () => client.pipelineCapabilities(),
@@ -88,486 +53,9 @@ export function PipelineConsole({ title = 'Connectors', eyebrow = 'Ingestion', i
88
53
  // request that can only ever return the same answer.
89
54
  staleTime: Number.POSITIVE_INFINITY,
90
55
  });
91
- return (_jsx(TooltipProvider, { children: _jsx("div", { className: "h-full overflow-y-auto", children: _jsxs("div", { className: "mx-auto max-w-5xl px-8 py-8", 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: "mt-1 max-w-2xl text-sm text-zinc-500 dark:text-zinc-400", children: intro }), _jsxs(Tabs, { value: tab, onValueChange: setTab, className: "mt-6", children: [_jsxs(TabsList, { children: [_jsxs(TabsTab, { value: "connections", children: [_jsx(Plug, { size: 13 }), "Connections"] }), _jsxs(TabsTab, { value: "connectors", children: [_jsx(Cable, { size: 13 }), "Connectors"] }), _jsxs(TabsTab, { value: "transforms", children: [_jsx(Code2, { size: 13 }), "Transforms"] }), _jsx(Tooltip, { content: capabilities?.pythonPackages?.length
56
+ return (_jsx(TooltipProvider, { children: _jsx("div", { className: "h-full overflow-y-auto", children: _jsxs("div", { className: "mx-auto max-w-5xl px-8 py-8", 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: "mt-1 max-w-2xl text-sm text-zinc-500 dark:text-zinc-400", children: intro }), _jsxs(Tabs, { value: tab, onValueChange: setTab, className: "mt-6", children: [_jsxs(TabsList, { children: [_jsxs(TabsTab, { value: "connections", children: [_jsx(Plug, { size: 13 }), "Connections"] }), _jsxs(TabsTab, { value: "transforms", children: [_jsx(Code2, { size: 13 }), "Transforms"] }), _jsx(Tooltip, { content: capabilities?.pythonPackages?.length
92
57
  ? `Python transforms may import ${capabilities.pythonPackages.join(', ')} — provisioned by the image, not by this service.`
93
- : 'Which languages this deployment can actually execute.', children: _jsx("span", { className: cn('ml-auto cursor-help self-center font-mono text-[10px]', MUTED), children: capabilities ? `runs ${capabilities.languages.join(' · ')}` : 'checking…' }) })] }), _jsx(TabsPanel, { value: "connections", children: _jsx(ConnectionPanel, { canEdit: canEdit }) }), _jsx(TabsPanel, { value: "connectors", children: _jsx(ConnectorList, { canEdit: canEdit, schemaDiscovery: discovery }) }), _jsx(TabsPanel, { value: "transforms", children: _jsx(TransformList, { canEdit: canEdit, languages: capabilities?.languages ?? ['javascript'], pythonPackages: capabilities?.pythonPackages ?? [] }) })] })] }) }) }));
94
- }
95
- function ConnectorList({ canEdit, schemaDiscovery, }) {
96
- const client = useCatalogClient();
97
- const queryClient = useQueryClient();
98
- const [editing, setEditing] = useState(null);
99
- const connectors = useQuery({
100
- queryKey: catalogQueryKeys.connectors,
101
- queryFn: () => client.listConnectors(),
102
- });
103
- const { data: transforms = [] } = useQuery({
104
- queryKey: catalogQueryKeys.transforms,
105
- queryFn: () => client.listTransforms(),
106
- staleTime: 30_000,
107
- });
108
- const { data: connections = [] } = useQuery({
109
- queryKey: catalogQueryKeys.connections,
110
- queryFn: () => client.listConnections(),
111
- staleTime: 30_000,
112
- });
113
- /**
114
- * A run rewrites three things at once, so all three are invalidated together.
115
- *
116
- * The connector's own last-run fields, its run list, and the catalog snapshot
117
- * the load wrote into. Invalidating them one at a time is how a list ends up
118
- * showing a run that finished beside a connector that still says it never has.
119
- */
120
- const invalidateRun = () => {
121
- queryClient.invalidateQueries({ queryKey: catalogQueryKeys.connectors });
122
- queryClient.invalidateQueries({ queryKey: catalogQueryKeys.runs() });
123
- queryClient.invalidateQueries({ queryKey: catalogQueryKeys.snapshot });
124
- };
125
- const run = useMutation({
126
- mutationFn: (id) => client.runConnector(id),
127
- onSuccess: invalidateRun,
128
- });
129
- if (editing) {
130
- return (_jsx(ConnectorForm, { connector: editing === 'new' ? undefined : editing, transforms: transforms, connections: connections, schemaDiscovery: schemaDiscovery, onClose: () => setEditing(null), onSaved: () => {
131
- setEditing(null);
132
- queryClient.invalidateQueries({ queryKey: catalogQueryKeys.connectors });
133
- } }));
134
- }
135
- 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 connector"] })), connectors.isPending && (_jsx("p", { className: cn('rounded-lg border border-dashed px-4 py-12 text-center text-sm', RULE, MUTED), children: "Reading connectors\u2026" })), connectors.isError && (_jsxs("div", { className: "rounded-lg border border-red-200 bg-red-50 px-4 py-6 text-center dark:border-red-900 dark:bg-red-950/40", children: [_jsx("p", { className: "text-sm text-red-700 dark:text-red-300", children: connectors.error instanceof Error
136
- ? connectors.error.message
137
- : 'Could not read the connectors.' }), _jsx("button", { type: "button", onClick: () => connectors.refetch(), className: "mt-2 rounded-md border border-red-300 px-3 py-1 text-xs text-red-700 dark:border-red-800 dark:text-red-300", children: "Try again" })] })), connectors.data?.length === 0 && (_jsx("p", { className: cn('rounded-lg border border-dashed px-4 py-12 text-center text-sm', RULE, MUTED), children: "No connectors yet." })), connectors.data?.map((connector) => (_jsx(ConnectorCard, { connector: connector, canEdit: canEdit, transform: transforms.find((t) => t.id === connector.transformId), connection: connections.find((c) => c.id === connector.connectionId), running: run.isPending && run.variables === connector.id, onRun: () => run.mutate(connector.id), onEdit: () => setEditing(connector), onDeleted: invalidateRun }, connector.id)))] }));
138
- }
139
- /**
140
- * One line saying where a connector actually reads from.
141
- *
142
- * Per kind, because reading `config.url` for everything left an s3 connector
143
- * with a blank subtitle — the card said a connector existed and nothing about
144
- * where it pointed, which is the one thing the list is for.
145
- */
146
- /** Read a string out of a stored config without believing it is one. */
147
- function configText(config, key) {
148
- const value = config[key];
149
- return typeof value === 'string' ? value : '';
150
- }
151
- /** A prefix under a shared bucket, or a bucket of this connector's own. */
152
- function describeS3Source(config, via) {
153
- if (via)
154
- return `${via}${configText(config, 'prefix') || '(whole bucket)'}`;
155
- const bucket = configText(config, 'bucket');
156
- if (!bucket)
157
- return 'no bucket configured';
158
- return `s3://${bucket}/${configText(config, 'prefix')}`;
159
- }
160
- /** The query, shortened to fit a line, plus the watermark when it reads incrementally. */
161
- function describeSqlSource(config, via) {
162
- const watermark = configText(config, 'watermarkColumn');
163
- const query = configText(config, 'query').replace(/\s+/g, ' ').trim();
164
- const shown = query.length > 70 ? `${query.slice(0, 70)}…` : query;
165
- return `${via}${watermark ? `${shown} · since ${watermark}` : shown}`;
166
- }
167
- /** A path under a shared base URL, or a full URL of this connector's own. */
168
- function describeHttpSource(config, via) {
169
- const path = configText(config, 'path');
170
- if (via)
171
- return `${via}${path || '/'}`;
172
- return `${configText(config, 'url')}${path ? ` · ${path}` : ''}`;
173
- }
174
- function describeSource(connector, connection) {
175
- const config = connector.config ?? {};
176
- // The connection's name first, because when one is in use it is the answer to
177
- // "where does this read from" and the connector's own config is only the part
178
- // specific to this load.
179
- const via = connection ? `${connection.name} · ` : '';
180
- if (connector.kind === 's3')
181
- return describeS3Source(config, via);
182
- if (connector.kind === 'sql')
183
- return describeSqlSource(config, via);
184
- if (connector.kind === 'file') {
185
- return configText(config, 'path') || configText(config, 'url') || 'no path configured';
186
- }
187
- if (connector.kind === 'inline') {
188
- const records = config.records;
189
- return `${Array.isArray(records) ? records.length : 0} pasted records`;
190
- }
191
- return describeHttpSource(config, via);
192
- }
193
- function ConnectorCard({ connector, transform, connection, canEdit, running, onRun, onEdit, onDeleted, }) {
194
- const client = useCatalogClient();
195
- const [confirming, setConfirming] = useState(false);
196
- const remove = useMutation({
197
- mutationFn: () => client.deleteConnector(connector.id),
198
- onSuccess: () => {
199
- setConfirming(false);
200
- onDeleted();
201
- },
202
- });
203
- 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("span", { className: "text-sm font-medium", children: connector.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: connector.kind }), _jsxs("span", { className: cn('font-mono text-[10px]', MUTED), children: ["\u2192 ", connector.targetType] }), connection && (_jsx(Tooltip, { content: `Reads through the ${connection.name} connection, which supplies the address and the credential. Moving that connection moves this connector with it.`, children: _jsxs("span", { className: cn('flex cursor-help items-center gap-1 font-mono text-[10px]', MUTED), children: [_jsx(Plug, { size: 10 }), connection.name] }) })), connector.mode === 'incremental' && (_jsx(Tooltip, { content: "Reads only what changed since the last run, and carries the rest forward.", children: _jsxs("span", { className: cn('flex cursor-help items-center gap-1 font-mono text-[10px]', MUTED), children: [_jsx(RefreshCw, { size: 10 }), "incremental"] }) })), !connector.enabled && (_jsx("span", { className: "rounded-sm bg-zinc-100 px-1.5 py-0.5 font-mono text-[10px] uppercase text-zinc-500 dark:bg-zinc-800", children: "disabled" }))] }), _jsx("div", { className: cn('mt-1 font-mono text-[11px]', MUTED), children: describeSource(connector, connection) }), connector.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 }), connector.secretEnvVar] }) }))] }), _jsxs("div", { className: "flex shrink-0 items-center gap-1", children: [_jsxs("button", { type: "button", onClick: onRun, disabled: running || !connector.enabled, 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: [running ? _jsx(Loader2, { size: 12, className: "animate-spin" }) : _jsx(Play, { size: 12 }), running ? 'Running…' : 'Run now'] }), canEdit && (_jsx(Tooltip, { content: `Delete ${connector.name}`, children: _jsx("button", { type: "button", onClick: () => setConfirming(true), "aria-label": `Delete ${connector.name}`, className: cn('rounded-sm p-1.5 hover:text-red-600', MUTED), children: _jsx(Trash2, { size: 12 }) }) }))] })] }), transform && (_jsxs("button", { type: "button", onClick: onEdit, className: cn('mt-3 flex items-center gap-1.5 text-[11px]', MUTED, 'hover:text-sky-600'), children: [_jsx(Code2, { size: 11 }), transform.name, _jsxs("span", { className: "font-mono", children: [transform.language, " \u00B7 v", transform.version] })] })), _jsx(RecentRuns, { connectorId: connector.id, transform: transform }), _jsx(ConfirmDialog, { open: confirming, onOpenChange: setConfirming, title: `Delete ${connector.name}?`, description: "The snapshots it already wrote stay where they are \u2014 this removes the connector, its schedule and its incremental watermark. Recreating it later starts reading from the beginning again.", confirmLabel: remove.isPending ? 'Deleting…' : 'Delete', pending: remove.isPending, onConfirm: () => remove.mutate(), error: remove.error
204
- ? remove.error instanceof Error
205
- ? remove.error.message
206
- : 'Could not delete it.'
207
- : undefined })] }));
208
- }
209
- /**
210
- * What this connector has done lately, and the way from a load to the code that
211
- * produced it.
212
- *
213
- * Its own component rather than a block inside the card, because it owns state
214
- * the card has no other use for — which version is being compared — and because
215
- * the runs it reads are the card's only query that is not about the connector
216
- * itself. Lifting it out is also what keeps `ConnectorCard` under the cognitive
217
- * complexity the linter enforces, which is the linter noticing something real:
218
- * a card that renders a source, a schedule, a credential, a transform, a run
219
- * list AND a comparison panel is doing six things.
220
- */
221
- function RecentRuns({ connectorId, transform, }) {
222
- const client = useCatalogClient();
223
- /**
224
- * Which run's code is being compared, as the version number it recorded.
225
- *
226
- * This is where the question actually occurs to somebody: they are looking at
227
- * a load that came out different from the last one, and the row in front of
228
- * them already says `code v3`. Making that number the way in means nobody has
229
- * to carry it to another screen and pick it out of a dropdown — which is the
230
- * step where you pick the wrong one and conclude the code was fine.
231
- */
232
- const [comparing, setComparing] = useState(null);
233
- const { data: runs = [] } = useQuery({
234
- queryKey: catalogQueryKeys.runs(connectorId),
235
- queryFn: () => client.listRuns(connectorId),
236
- });
237
- if (runs.length === 0)
238
- return null;
239
- return (_jsxs(_Fragment, { children: [_jsxs("div", { className: cn('mt-3 border-t pt-3', RULE), children: [_jsx("div", { className: cn('mb-1.5 font-mono text-[10px] uppercase tracking-[0.14em]', MUTED), children: "Recent runs" }), _jsx("div", { className: "space-y-1", children: runs.slice(0, 4).map((entry) => (_jsx(Tooltip, { content: entry.error ? (_jsx("span", { className: "font-mono text-[11px]", children: entry.error })) : (_jsx("span", { className: "font-mono text-[11px]", children: entry.logs.slice(-3).join('\n') || 'No logs.' })), children: _jsxs("div", { className: "flex cursor-help items-center gap-2 text-[11px]", children: [_jsxs("span", { className: "sr-only", children: [entry.status, ": "] }), _jsx(RunStatusIcon, { status: entry.status }), _jsx("span", { className: "font-mono", children: entry.snapshotId }), _jsxs("span", { className: MUTED, children: [entry.fetched, " fetched \u00B7 ", entry.written, " written"] }), _jsx(RanCodeVersion, { version: entry.transformVersion, comparable: transform !== undefined, onCompare: setComparing }), _jsx("span", { className: cn('ml-auto font-mono text-[10px]', MUTED), children: new Date(entry.startedAt).toLocaleTimeString() })] }) }, entry.id))) })] }), transform && (_jsx(RevisionHistorySheet, { open: comparing !== null, onOpenChange: (open) => {
240
- if (!open)
241
- setComparing(null);
242
- }, subject: { kind: 'transform', id: transform.id, name: transform.name }, current: { version: transform.version, body: transform.code }, ranVersion: comparing ?? undefined }))] }));
243
- }
244
- function RunStatusIcon({ status }) {
245
- if (status === 'succeeded')
246
- return _jsx(CircleCheck, { size: 11, "aria-hidden": true, className: "text-emerald-600" });
247
- if (status === 'failed')
248
- return _jsx(CircleX, { size: 11, "aria-hidden": true, className: "text-red-600" });
249
- return _jsx(Loader2, { size: 11, "aria-hidden": true, className: "animate-spin text-sky-600" });
250
- }
251
- /**
252
- * `code v3` on a run, as a way into the comparison rather than as a fact.
253
- *
254
- * Where somebody is standing when the question occurs to them. The number was
255
- * already on this row and already meant "this load ran that code"; what it did
256
- * not have was anywhere to go, because until revisions existed the code it named
257
- * had been overwritten. Making it the control means nobody carries a version
258
- * number to another screen and picks it out of a dropdown — which is the step
259
- * where you pick the wrong one and conclude the code was fine.
260
- *
261
- * Still only text when there is nothing on the other side: a connector with no
262
- * transform never records a version, and a version whose transform has since
263
- * been deleted has no current code to compare against. A control that opens an
264
- * empty panel is a control that teaches people to stop pressing it.
265
- *
266
- * Its own component rather than three ternaries inside the run row, because the
267
- * row is inside a `Tooltip` inside a `map` inside a card that is already at the
268
- * complexity budget — and because "what does the version on a run do" is a
269
- * question with one answer, which should be in one place.
270
- */
271
- function RanCodeVersion({ version, comparable, onCompare, }) {
272
- if (version === undefined)
273
- return null;
274
- if (!comparable)
275
- return _jsxs("span", { className: cn('font-mono', MUTED), children: ["code v", version] });
276
- return (
277
- // Inside the tooltip's trigger rather than beside it, because this row IS
278
- // the trigger: pulling the button out would put a gap in the hover target
279
- // exactly where the pointer is heading. A click inside it bubbles normally.
280
- _jsxs("button", { type: "button", onClick: () => onCompare(version), "aria-label": `Compare the code that ran (v${version}) with the current code`, className: cn('rounded-sm px-1 font-mono underline decoration-dotted underline-offset-2', MUTED, 'hover:text-sky-600'), children: ["code v", version] }));
281
- }
282
- /**
283
- * The connection picker, above the address fields it replaces.
284
- *
285
- * Offered rather than required: a one-off source does not deserve a second
286
- * object to manage, and forcing one would make the quickest thing this screen
287
- * can do — paste a URL, load it once — the slowest.
288
- */
289
- function ConnectionPicker({ value, options, viaConnection, onChange, }) {
290
- return (_jsx(SelectField, { label: "Read through", ariaLabel: "Connection", value: value, onValueChange: onChange, options: [
291
- {
292
- value: INLINE_CONNECTION,
293
- label: 'Configure the address here',
294
- hint: 'This connector alone',
295
- },
296
- ...options,
297
- ], hint: connectionPickerHint(options.length, viaConnection) }));
298
- }
299
- /** Why the picker looks the way it does — nothing to choose, or something chosen. */
300
- function connectionPickerHint(optionCount, viaConnection) {
301
- if (optionCount === 0) {
302
- return 'No connections of this kind yet. One is worth making when a second connector needs the same address.';
303
- }
304
- if (viaConnection) {
305
- return 'The connection supplies the address and the credential. What stays below is only what is specific to this load.';
306
- }
307
- return undefined;
308
- }
309
- /** Save and cancel, plus whatever the server said when saving failed. */
310
- function ConnectorFormActions({ editing, pending, incomplete, error, onClose, }) {
311
- return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("button", { type: "submit", disabled: pending || 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: pending ? 'Saving…' : editing ? 'Save changes' : 'Save connector' }), _jsx("button", { type: "button", onClick: onClose, className: cn('rounded-md px-3 py-1.5 text-xs', MUTED), children: "Cancel" })] }), error ? (_jsx("p", { className: "text-[11px] text-red-600", children: error instanceof Error ? error.message : 'Could not save.' })) : null] }));
312
- }
313
- /**
314
- * Every type the catalog can hold, in the order a person scans for one.
315
- *
316
- * `unknown` is last and named plainly, because choosing it is a decision: the
317
- * store gives it a TEXT column and stringifies whatever arrives. It is the right
318
- * answer for a column nobody can classify and the wrong answer for one nobody
319
- * looked at, which is exactly why discovery never picks it on anyone's behalf.
320
- */
321
- const SCALAR_TYPES = [
322
- 'string',
323
- 'number',
324
- 'boolean',
325
- 'date',
326
- 'uuid',
327
- 'json',
328
- 'unknown',
329
- ];
330
- /**
331
- * Where the checkboxes start, and why the untyped ones start off.
332
- *
333
- * A column discovery could type is proposed; a column it could not is present,
334
- * visible, and **excluded** until somebody says what it is. Pre-selecting it
335
- * with a plausible default is the failure that matters — a wrong type becomes a
336
- * wrong column in a lake nobody re-checks, and everything downstream reads it
337
- * as fact rather than as the guess it was.
338
- *
339
- * Keyed by position rather than by name on purpose: `SELECT a.id, b.id` gives
340
- * two columns called `id`, and a map would silently merge their choices.
341
- */
342
- export function initialChoices(columns) {
343
- return columns.map((column) => ({ include: column.type !== null, type: column.type ?? '' }));
344
- }
345
- /**
346
- * The type this would create, and everything standing in the way of creating it.
347
- *
348
- * Pure, and separate from the panel, because these are the rules that decide
349
- * whether a schema somebody approved is one the publish route will accept — and
350
- * rules that live inside a component are rules only a rendered DOM can check.
351
- *
352
- * `columnName` is sent as well as `name`, and they are the same string. The
353
- * publish service maps `columnName` to `sourceColumn` and `name` to the property
354
- * itself, and the store reads records by property name; sending them equal is
355
- * what makes a load match. See the server's `DiscoveredColumn.name`.
356
- */
357
- export function proposalFrom(discovery, choices) {
358
- const chosen = discovery.columns
359
- .map((column, index) => ({ column, choice: choices[index] ?? { include: false, type: '' } }))
360
- .filter((entry) => entry.choice.include);
361
- const problems = [];
362
- const untyped = chosen.filter((entry) => entry.choice.type === '');
363
- if (untyped.length > 0) {
364
- problems.push(`Choose a type for ${untyped.map((entry) => `"${entry.column.name}"`).join(', ')}, or leave ${untyped.length === 1 ? 'it' : 'them'} out.`);
365
- }
366
- const counts = new Map();
367
- for (const entry of chosen) {
368
- counts.set(entry.column.name, (counts.get(entry.column.name) ?? 0) + 1);
369
- }
370
- const duplicated = [...counts].filter(([, count]) => count > 1).map(([name]) => `"${name}"`);
371
- if (duplicated.length > 0) {
372
- problems.push(`${duplicated.join(', ')} appears more than once. A record is an object, so only one of them can survive — leave the others out.`);
373
- }
374
- const properties = [];
375
- for (const entry of chosen) {
376
- if (entry.choice.type === '')
377
- continue;
378
- properties.push({
379
- name: entry.column.name,
380
- columnName: entry.column.name,
381
- type: entry.choice.type,
382
- // Not stated is published nullable. A column marked NOT NULL that the
383
- // source sometimes leaves empty is a load that fails at 3am; a nullable
384
- // column that never holds a null costs nothing at all.
385
- nullable: entry.column.nullable ?? true,
386
- });
387
- }
388
- if (properties.length === 0) {
389
- problems.push('Nothing is selected, and a type with no properties is refused.');
390
- }
391
- return { draft: { name: discovery.targetType, properties }, problems };
392
- }
393
- /**
394
- * What the source looks like, offered to the person who has to name it.
395
- *
396
- * Only for a SAVED connector: discovery runs the connector's own configured
397
- * read, and there is nothing to read from a form that has not been stored yet.
398
- *
399
- * The screen's job is to make the difference between what was *reported* and
400
- * what was *inferred* impossible to miss, because that difference is the whole
401
- * value of the report. A driver describing a `NUMERIC` column is the database
402
- * speaking; forty records that all happened to hold a string is a sample, and
403
- * the forty-first is where somebody finds out.
404
- */
405
- function SchemaDiscoveryPanel({ connectorId, bridge, }) {
406
- // Counted rather than timestamped so a second discovery always remounts the
407
- // table below, dropping the choices somebody made against a column list that
408
- // no longer exists.
409
- const [discovered, setDiscovered] = useState();
410
- const discover = useMutation({
411
- mutationFn: () => bridge.discover(connectorId),
412
- onSuccess: (value) => setDiscovered((previous) => ({ run: (previous?.run ?? 0) + 1, value })),
413
- });
414
- return (_jsxs("div", { className: cn('rounded-md border border-dashed p-3', RULE), children: [_jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsxs("button", { type: "button", onClick: () => discover.mutate(), disabled: discover.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: [discover.isPending ? (_jsx(Loader2, { size: 12, className: "animate-spin" })) : (_jsx(ScanSearch, { size: 12 })), discover.isPending ? 'Reading the source…' : 'Discover schema'] }), _jsx("span", { className: cn('text-[11px]', MUTED), children: "Reads the source and reports its columns. Creates nothing on its own." })] }), discover.error ? (_jsx("p", { className: "mt-2 text-[11px] text-red-600", children: discover.error instanceof Error ? discover.error.message : 'Could not read the source.' })) : null, discovered && (_jsx(DiscoveredSchema, { discovery: discovered.value, createType: bridge.createType }, discovered.run))] }));
415
- }
416
- function DiscoveredSchema({ discovery, createType, }) {
417
- const [choices, setChoices] = useState(() => initialChoices(discovery.columns));
418
- const { draft, problems } = proposalFrom(discovery, choices);
419
- const setChoice = (index, next) => setChoices((current) => current.map((choice, position) => (position === index ? { ...choice, ...next } : choice)));
420
- return (_jsxs("div", { className: "mt-3 space-y-3", children: [_jsx("p", { className: cn('text-[11px]', MUTED), children: discovery.caveat }), _jsx(DriftReport, { drift: discovery.drift, targetType: discovery.targetType }), discovery.columns.length === 0 ? (_jsx("p", { className: cn('text-[11px]', MUTED), children: "No columns came back." })) : (_jsxs("table", { className: "w-full text-left text-[11px]", children: [_jsx("thead", { className: cn('font-mono uppercase tracking-[0.14em]', MUTED), children: _jsxs("tr", { children: [_jsx("th", { className: "w-6 pb-1 font-normal", children: _jsx("span", { className: "sr-only", children: "Include" }) }), _jsx("th", { className: "pb-1 font-normal", children: "Column" }), _jsx("th", { className: "pb-1 font-normal", children: "Type" }), _jsx("th", { className: "pb-1 font-normal", children: "Null" }), _jsx("th", { className: "pb-1 font-normal", children: "Source" })] }) }), _jsx("tbody", { children: discovery.columns.map((column, index) => (_jsx(ColumnRow
421
- // The source may legally return two columns of one name, so the
422
- // position has to be part of the key: on its own the name would
423
- // collide, and React would reuse one row's choice for the other.
424
- , { column: column, choice: choices[index] ?? { include: false, type: '' }, onChange: (next) => setChoice(index, next) }, `${column.name}-${index}`))) })] })), problems.map((problem) => (_jsxs("p", { className: "flex items-start gap-1.5 text-[11px] text-amber-600", children: [_jsx(TriangleAlert, { size: 11, className: "mt-0.5 shrink-0", "aria-hidden": true }), problem] }, problem))), _jsx(Confirmation, { discovery: discovery, draft: draft, problems: problems, createType: createType })] }));
425
- }
426
- /**
427
- * The act that creates the type — the only thing on this screen that writes.
428
- *
429
- * Its own component because it has three states and they are not variations on
430
- * a button: nothing has been created yet, something has, or this console has no
431
- * way to create anything and has to hand over the request instead.
432
- */
433
- function Confirmation({ discovery, draft, problems, createType, }) {
434
- const [created, setCreated] = useState(false);
435
- const create = useMutation({
436
- mutationFn: () => {
437
- if (!createType)
438
- return Promise.reject(new Error('This console cannot create types.'));
439
- return createType(draft);
440
- },
441
- onSuccess: () => setCreated(true),
442
- });
443
- if (!createType)
444
- return _jsx(UnwiredConfirmation, { draft: draft });
445
- if (created) {
446
- return (_jsxs("p", { className: "flex items-center gap-1.5 text-[11px] text-emerald-600", children: [_jsx(CircleCheck, { size: 11, "aria-hidden": true }), discovery.targetType, " now exists with ", draft.properties.length, " properties. Running this connector will load into it."] }));
447
- }
448
- return (_jsxs("div", { className: "space-y-1", children: [_jsx("button", { type: "button", onClick: () => create.mutate(), disabled: problems.length > 0 || create.isPending, 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: create.isPending
449
- ? 'Creating…'
450
- : discovery.typeExists
451
- ? `Update ${discovery.targetType}`
452
- : `Create ${discovery.targetType}` }), _jsx("p", { className: cn('text-[11px]', MUTED), children: discovery.typeExists
453
- ? 'Adds and retypes properties. Display names, descriptions and classifications somebody wrote are kept.'
454
- : 'This is the act that creates the type. Nothing has been created up to here.' }), create.error ? (_jsx("p", { className: "text-[11px] text-red-600", children: create.error instanceof Error ? create.error.message : 'Could not create it.' })) : null] }));
455
- }
456
- /** One column, with the two decisions a person can make about it. */
457
- function ColumnRow({ column, choice, onChange, }) {
458
- return (_jsxs(_Fragment, { children: [_jsxs("tr", { className: cn('border-t', RULE), children: [_jsx("td", { className: "py-1 align-top", children: _jsx("input", { type: "checkbox", checked: choice.include, "aria-label": `Include ${column.name}`, onChange: (event) => onChange({ include: event.target.checked }) }) }), _jsx("td", { className: "py-1 align-top font-mono", children: column.name }), _jsxs("td", { className: "py-1 align-top", children: [_jsxs("select", { value: choice.type, "aria-label": `Type for ${column.name}`, onChange: (event) => {
459
- const next = SCALAR_TYPES.find((scalar) => scalar === event.target.value);
460
- onChange({ type: next ?? '' });
461
- }, className: cn('rounded-sm border bg-transparent px-1 py-0.5 font-mono text-[11px]', RULE, choice.type === '' && 'text-amber-600'), children: [_jsx("option", { value: "", children: "not typed" }), SCALAR_TYPES.map((scalar) => (_jsx("option", { value: scalar, children: scalar }, scalar)))] }), column.confidence === 'inferred' && (_jsx("span", { className: cn('ml-1.5 font-mono text-[10px]', MUTED), children: "inferred" }))] }), _jsx("td", { className: cn('py-1 align-top font-mono', MUTED), children: column.nullable === null ? 'not stated' : column.nullable ? 'nullable' : 'not null' }), _jsx("td", { className: cn('py-1 align-top font-mono', MUTED), children: column.sourceType })] }), column.note && (_jsxs("tr", { children: [_jsx("td", {}), _jsx("td", { colSpan: 4, className: "pb-1.5 text-[11px] text-amber-600", children: column.note })] }))] }));
462
- }
463
- /**
464
- * What the source says now against what the type says now.
465
- *
466
- * The part worth having. A first discovery happens once per source; drift
467
- * happens for as long as the connector exists, and every one of these is silent
468
- * today — an added column is dropped by the store, a removed one loads as null,
469
- * and a retyped one is coerced into whatever the catalog still believes.
470
- */
471
- function DriftReport({ drift, targetType }) {
472
- if (!drift) {
473
- return (_jsxs("p", { className: cn('text-[11px]', MUTED), children: [targetType, " does not exist yet, so there is nothing to compare against."] }));
474
- }
475
- const quiet = drift.added.length === 0 && drift.removed.length === 0 && drift.retyped.length === 0;
476
- if (quiet) {
477
- return (_jsxs("p", { className: "flex items-center gap-1.5 text-[11px] text-emerald-600", children: [_jsx(CircleCheck, { size: 11, "aria-hidden": true }), "The source still matches ", targetType, "."] }));
478
- }
479
- return (_jsxs("div", { className: "space-y-1 rounded-md border border-amber-300 bg-amber-50 p-2 dark:border-amber-900 dark:bg-amber-950/30", children: [_jsxs("p", { className: "font-mono text-[10px] uppercase tracking-[0.14em] text-amber-700 dark:text-amber-400", children: ["Drift since ", targetType, " was written down"] }), drift.added.length > 0 && (_jsxs("p", { className: "text-[11px] text-amber-700 dark:text-amber-300", children: ["New in the source, and dropped by every load until the type has them:", ' ', _jsx("span", { className: "font-mono", children: drift.added.join(', ') })] })), drift.removed.length > 0 && (_jsxs("p", { className: "text-[11px] text-amber-700 dark:text-amber-300", children: ["On the type, absent from the source, so they load as null:", ' ', _jsx("span", { className: "font-mono", children: drift.removed.join(', ') })] })), drift.retyped.map((change) => (_jsxs("p", { className: "text-[11px] text-amber-700 dark:text-amber-300", children: [_jsx("span", { className: "font-mono", children: change.property }), " is ", change.now, " in the source and", ' ', change.was, " here \u2014 every load coerces it, and a value that will not convert becomes null."] }, change.property)))] }));
480
- }
481
- /**
482
- * The confirmation, for a console whose host did not wire one.
483
- *
484
- * The request is printed rather than the button being greyed out with a
485
- * shrug. Creating a type is a `PUT` a person can make with a terminal, and a
486
- * host that deliberately kept type creation out of its console — because the
487
- * publish route is owned by an application principal, or because schema changes
488
- * go through review — has a reader here who still needs the body somebody
489
- * approved on this screen.
490
- */
491
- function UnwiredConfirmation({ draft }) {
492
- return (_jsxs("div", { className: "space-y-1", children: [_jsx("p", { className: cn('text-[11px]', MUTED), children: "This console cannot create types \u2014 nothing is wired to the publish route. What was confirmed above is this request:" }), _jsx("pre", { className: cn('overflow-x-auto rounded-md border p-2 font-mono text-[10px]', RULE, 'bg-zinc-50 dark:bg-zinc-950'), children: `PUT /publish/${draft.name}/schema\n${JSON.stringify(draft, null, 2)}` })] }));
493
- }
494
- function ConnectorForm({ connector, transforms, connections, schemaDiscovery, onClose, onSaved, }) {
495
- const client = useCatalogClient();
496
- const [kind, setKind] = useState(toConnectorKind(connector?.kind ?? 'http'));
497
- const [connectionId, setConnectionId] = useState(connector?.connectionId ?? INLINE_CONNECTION);
498
- const [mode, setMode] = useState(connector?.mode === 'incremental' ? 'incremental' : 'full');
499
- const [enabled, setEnabled] = useState(connector?.enabled ?? true);
500
- // The address fields live in their own state because they are shared with the
501
- // workflow source inspector — see `source-fields.tsx`. What is left in `draft`
502
- // is what only a connector has.
503
- const [source, setSource] = useState(() => sourceDraftFrom(connector?.config));
504
- const [draft, setDraft] = useState({
505
- name: connector?.name ?? '',
506
- targetType: connector?.targetType ?? '',
507
- secretEnvVar: connector?.secretEnvVar ?? '',
508
- transformId: connector?.transformId ?? '',
509
- });
510
- const incremental = readsIncrementally(kind) && mode === 'incremental';
511
- const connectionOptions = connectionOptionsFor(kind, connections);
512
- // A connection chosen for one kind is meaningless for another, so switching
513
- // the kind drops it rather than sending an id the server would reject.
514
- const chosenConnection = connectionOptions.some((option) => option.value === connectionId)
515
- ? connectionId
516
- : INLINE_CONNECTION;
517
- const viaConnection = chosenConnection !== INLINE_CONNECTION;
518
- const records = parseRecords(source.records);
519
- const save = useMutation({
520
- mutationFn: () => {
521
- if (kind === 'inline' && !records.ok) {
522
- // Refused here rather than sent, so the message names the JSON rather
523
- // than arriving as a server error about an empty load.
524
- return Promise.reject(new Error(records.message));
525
- }
526
- const next = sourceConfigFrom(kind, source, { viaConnection, incremental });
527
- const input = {
528
- id: connector?.id,
529
- name: draft.name.trim(),
530
- kind,
531
- targetType: draft.targetType.trim(),
532
- config: next,
533
- // Omitted, never sent empty: an empty string is a connection id the
534
- // server would look up and fail to find, where absent means "this
535
- // connector carries its own address".
536
- ...(viaConnection ? { connectionId: chosenConnection } : {}),
537
- // A kind that cannot be asked what changed is saved as `full`, so the
538
- // stored mode never claims something the fetcher does not do.
539
- mode: incremental ? 'incremental' : 'full',
540
- // The connection owns the credential when one is in use. Sending the
541
- // connector's own as well would mean two answers to "which variable
542
- // holds the password", and the runner can only use one.
543
- ...(viaConnection || !draft.secretEnvVar.trim()
544
- ? {}
545
- : { secretEnvVar: draft.secretEnvVar.trim() }),
546
- ...(draft.transformId ? { transformId: draft.transformId } : {}),
547
- enabled,
548
- };
549
- return client.saveConnector(input);
550
- },
551
- onSuccess: onSaved,
552
- });
553
- const incomplete = draft.name.trim().length === 0 ||
554
- draft.targetType.trim().length === 0 ||
555
- sourceIsIncomplete(kind, source, viaConnection);
556
- return (_jsxs("form", { className: cn('mt-6 space-y-4 rounded-lg border p-4', RULE, PANEL), onSubmit: (event) => {
557
- event.preventDefault();
558
- save.mutate();
559
- }, 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: "Nightly fleet load" }), _jsx(TextField, { label: "Target object type", value: draft.targetType, onChange: (targetType) => setDraft({ ...draft, targetType }), placeholder: "e.g. Mvr" }), _jsx(SelectField, { label: "Source kind", ariaLabel: "Source kind", value: kind, onValueChange: (value) => setKind(toConnectorKind(value)), options: KIND_OPTIONS })] }), usesConnection(kind) && (_jsx(ConnectionPicker, { value: chosenConnection, options: connectionOptions, viaConnection: viaConnection, onChange: setConnectionId })), schemaDiscovery && connector?.id && (_jsx(SchemaDiscoveryPanel, { connectorId: connector.id, bridge: schemaDiscovery })), _jsx(SourceFields, { kind: kind, draft: source, onChange: setSource, viaConnection: viaConnection }), _jsx(ReadModeFields, { kind: kind, mode: mode, onModeChange: setMode, draft: source, onChange: setSource }), _jsx("div", { className: "grid gap-3 sm:grid-cols-2", children: _jsx(SelectField, { label: "Transform", ariaLabel: "Transform", value: draft.transformId, onValueChange: (transformId) => setDraft({ ...draft, transformId }), options: [
560
- {
561
- value: '',
562
- label: 'No transform',
563
- hint: 'Store records as they arrive',
564
- },
565
- ...transforms.map((transform) => ({
566
- value: transform.id,
567
- label: transform.name,
568
- hint: `${transform.language} · v${transform.version}`,
569
- })),
570
- ] }) }), _jsx(Switch, { checked: enabled, onCheckedChange: setEnabled, label: "Enabled", hint: "A disabled connector keeps its configuration and its watermark, and refuses to run." }), _jsx(ConnectorFormActions, { editing: connector !== undefined, pending: save.isPending, incomplete: incomplete, error: save.error, onClose: onClose })] }));
58
+ : 'Which languages this deployment can actually execute.', children: _jsx("span", { className: cn('ml-auto cursor-help self-center font-mono text-[10px]', MUTED), children: capabilities ? `runs ${capabilities.languages.join(' · ')}` : 'checking…' }) })] }), _jsx(TabsPanel, { value: "connections", children: _jsx(ConnectionPanel, { canEdit: canEdit }) }), _jsx(TabsPanel, { value: "transforms", children: _jsx(TransformList, { canEdit: canEdit, languages: capabilities?.languages ?? ['javascript'], pythonPackages: capabilities?.pythonPackages ?? [] }) })] })] }) }) }));
571
59
  }
572
60
  function TransformList({ canEdit, languages, pythonPackages, }) {
573
61
  const client = useCatalogClient();
@@ -591,12 +79,12 @@ function TransformList({ canEdit, languages, pythonPackages, }) {
591
79
  queryClient.invalidateQueries({ queryKey: catalogQueryKeys.transforms });
592
80
  } }));
593
81
  }
594
- 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 transform"] })), transforms.isPending && (_jsx("p", { className: cn('rounded-lg border border-dashed px-4 py-12 text-center text-sm', RULE, MUTED), children: "Reading transforms\u2026" })), transforms.isError && (_jsxs("div", { className: "rounded-lg border border-red-200 bg-red-50 px-4 py-6 text-center dark:border-red-900 dark:bg-red-950/40", children: [_jsx("p", { className: "text-sm text-red-700 dark:text-red-300", children: transforms.error instanceof Error
82
+ return (_jsxs("div", { className: "mt-6 space-y-3", children: [canEdit && (_jsxs(Button, { variant: "outline", size: "sm", onClick: () => setEditing('new'), children: [_jsx(Plus, { size: 12 }), "New transform"] })), transforms.isPending && (_jsx("p", { className: cn('rounded-lg border border-dashed px-4 py-12 text-center text-sm', RULE, MUTED), children: "Reading transforms\u2026" })), transforms.isError && (_jsxs("div", { className: "rounded-lg border border-red-200 bg-red-50 px-4 py-6 text-center dark:border-red-900 dark:bg-red-950/40", children: [_jsx("p", { className: "text-sm text-red-700 dark:text-red-300", children: transforms.error instanceof Error
595
83
  ? transforms.error.message
596
- : 'Could not read the transforms.' }), _jsx("button", { type: "button", onClick: () => transforms.refetch(), className: "mt-2 rounded-md border border-red-300 px-3 py-1 text-xs text-red-700 dark:border-red-800 dark:text-red-300", children: "Try again" })] })), transforms.data?.length === 0 && (_jsx("p", { className: cn('rounded-lg border border-dashed px-4 py-12 text-center text-sm', RULE, MUTED), children: "No transforms yet. Without one, a connector stores records exactly as they arrive." })), transforms.data?.map((transform) => (_jsxs("div", { className: cn('flex items-start gap-3 rounded-lg border p-4', RULE, PANEL), children: [_jsx(Code2, { size: 14, className: cn('mt-0.5 shrink-0', MUTED) }), _jsxs("button", { type: "button", onClick: () => setEditing(transform), className: "min-w-0 flex-1 text-left", children: [_jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsx("span", { className: "text-sm font-medium", children: transform.name }), _jsx("span", { className: "rounded-sm bg-zinc-100 px-1.5 py-0.5 font-mono text-[10px] dark:bg-zinc-800", children: transform.language }), _jsx(Tooltip, { content: "Bumped only when the code changed, so it stays useful for tracing a surprising load back to what ran.", children: _jsxs("span", { className: cn('cursor-help font-mono text-[10px]', MUTED), children: ["v", transform.version] }) })] }), transform.description && (_jsx("p", { className: cn('mt-0.5 text-[11px]', MUTED), children: transform.description }))] }), canEdit && (_jsx(Tooltip, { content: `Delete ${transform.name}`, children: _jsx("button", { type: "button", onClick: () => setConfirming(transform), "aria-label": `Delete ${transform.name}`, className: cn('rounded-sm p-1 hover:text-red-600', MUTED), children: _jsx(Trash2, { size: 12 }) }) }))] }, transform.id))), _jsx(ConfirmDialog, { open: confirming !== null, onOpenChange: (open) => {
84
+ : 'Could not read the transforms.' }), _jsx(Button, { variant: "outline", size: "sm", className: "mt-2 border-red-300 text-red-700 dark:border-red-800 dark:text-red-300", onClick: () => transforms.refetch(), children: "Try again" })] })), transforms.data?.length === 0 && (_jsxs("p", { className: cn('rounded-lg border border-dashed px-4 py-12 text-center text-sm', RULE, MUTED), children: ["No transforms yet. Without one, a ", WORKFLOW_NAME.singular, " stores records exactly as they arrive \u2014 and a transform node on the canvas can write its first one for you."] })), transforms.data?.map((transform) => (_jsxs("div", { className: cn('flex items-start gap-3 rounded-lg border p-4', RULE, PANEL), children: [_jsx(Code2, { size: 14, className: cn('mt-0.5 shrink-0', MUTED) }), _jsxs("button", { type: "button", onClick: () => setEditing(transform), className: "min-w-0 flex-1 text-left", children: [_jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsx("span", { className: "text-sm font-medium", children: transform.name }), _jsx("span", { className: "rounded-sm bg-zinc-100 px-1.5 py-0.5 font-mono text-[10px] dark:bg-zinc-800", children: transform.language }), _jsx(Tooltip, { content: "Bumped only when the code changed, so it stays useful for tracing a surprising load back to what ran.", children: _jsxs("span", { className: cn('cursor-help font-mono text-[10px]', MUTED), children: ["v", transform.version] }) })] }), transform.description && (_jsx("p", { className: cn('mt-0.5 text-[11px]', MUTED), children: transform.description }))] }), canEdit && (_jsx(Tooltip, { content: `Delete ${transform.name}`, children: _jsx(Button, { variant: "ghost", size: "icon", onClick: () => setConfirming(transform), "aria-label": `Delete ${transform.name}`, className: "hover:text-red-600", children: _jsx(Trash2, { size: 12 }) }) }))] }, transform.id))), _jsx(ConfirmDialog, { open: confirming !== null, onOpenChange: (open) => {
597
85
  if (!open)
598
86
  setConfirming(null);
599
- }, title: confirming ? `Delete ${confirming.name}?` : '', description: "Any connector pointing at it will store records exactly as they arrive from now on, which is rarely what its target type expects. Every past version goes with it, so a surprising load can no longer be traced to the code that ran.", confirmLabel: remove.isPending ? 'Deleting…' : 'Delete', pending: remove.isPending, onConfirm: () => {
87
+ }, title: confirming ? `Delete ${confirming.name}?` : '', description: `Any ${WORKFLOW_NAME.singular} with a transform node pointing at it stops validating — the node names code that no longer exists, and the graph cannot be published until somebody chooses another. Every past version goes with it, so a surprising load can no longer be traced to the code that ran.`, confirmLabel: remove.isPending ? 'Deleting…' : 'Delete', pending: remove.isPending, onConfirm: () => {
600
88
  if (confirming)
601
89
  remove.mutate(confirming.id);
602
90
  }, error: remove.error