@dudousxd/nestjs-catalog-react 0.6.0 → 0.7.2
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.
- package/dist/ConnectionPanel.js +131 -34
- package/dist/DashboardBoard.js +30 -3
- package/dist/FlowView.js +35 -26
- package/dist/PipelineConsole.js +68 -34
- package/dist/QueryConsole.js +14 -6
- package/dist/TransformEditor.d.ts +0 -9
- package/dist/TransformEditor.js +23 -1
- package/dist/WorkflowCanvas.js +221 -128
- package/dist/charts/bklit/area.js +0 -1
- package/dist/charts/bklit/bar-chart.js +0 -1
- package/dist/charts/bklit/grid.js +0 -1
- package/dist/charts/bklit/line-loading-pulse.js +0 -1
- package/dist/charts/bklit/tooltip/chart-tooltip.js +0 -1
- package/dist/charts/bklit/tooltip/tooltip-indicator.js +0 -1
- package/dist/charts/bklit/use-chart-phase-orchestrator.js +0 -2
- package/dist/charts/bklit/use-mount-progress.js +0 -1
- package/dist/source-fields.js +61 -42
- package/dist/ui/chart.js +35 -16
- package/dist/ui/select.d.ts +10 -1
- package/dist/ui/select.js +8 -2
- package/dist/ui/switch.js +7 -1
- package/dist/ui/tabs.d.ts +11 -1
- package/dist/ui/tabs.js +2 -2
- package/dist/workflow/graph.js +51 -35
- package/package.json +2 -2
package/dist/ConnectionPanel.js
CHANGED
|
@@ -100,6 +100,73 @@ export function ConnectionPanel({ canEdit = true }) {
|
|
|
100
100
|
}
|
|
101
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
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Who this connection is: name, kind, who reads through it, what it addresses.
|
|
105
|
+
*
|
|
106
|
+
* The credential line names the variable and never its value — that is the
|
|
107
|
+
* property worth showing, so it is shown rather than described in a doc.
|
|
108
|
+
*/
|
|
109
|
+
function ConnectionIdentity({ connection, users, }) {
|
|
110
|
+
return (_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] }) }))] }));
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* What the last check found, from the stored fields.
|
|
114
|
+
*
|
|
115
|
+
* Recorded rather than probed on every page load, because a list that reaches
|
|
116
|
+
* every system it names on render turns opening a tab into a burst of outbound
|
|
117
|
+
* connections.
|
|
118
|
+
*/
|
|
119
|
+
function StoredCheckSummary({ connection }) {
|
|
120
|
+
if (!connection.lastCheckedAt)
|
|
121
|
+
return null;
|
|
122
|
+
return (_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 ? 'Reached' : (connection.lastCheckError ?? 'Could not reach it') }), _jsx("span", { className: cn('ml-auto font-mono text-[10px]', MUTED), children: new Date(connection.lastCheckedAt).toLocaleString() })] }));
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* What a check that just ran found, in the checker's own words.
|
|
126
|
+
*
|
|
127
|
+
* A server version, a bucket and whether anything is under the prefix, an HTTP
|
|
128
|
+
* status. That sentence is the whole product of the button; "OK" would prove
|
|
129
|
+
* only that something is listening on a port.
|
|
130
|
+
*/
|
|
131
|
+
function LiveCheckResult({ result }) {
|
|
132
|
+
return (_jsx("div", { className: cn('mt-3 rounded-md border px-3 py-2 text-[11px]', result.ok
|
|
133
|
+
? 'border-emerald-200 bg-emerald-50 text-emerald-800 dark:border-emerald-900 dark:bg-emerald-950/40 dark:text-emerald-300'
|
|
134
|
+
: '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"] })] })] }) }));
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Why a delete would be refused, said before it is attempted.
|
|
138
|
+
*
|
|
139
|
+
* `blockedBy` is the server's own answer to "who still reads through this",
|
|
140
|
+
* asked after it refused; it outranks `remove.error`, which is only the generic
|
|
141
|
+
* failure that came with it.
|
|
142
|
+
*/
|
|
143
|
+
function deleteRefusalMessage(blockedBy, error) {
|
|
144
|
+
if (blockedBy && blockedBy.length > 0) {
|
|
145
|
+
return (_jsxs(_Fragment, { children: ["Refused: still read through by ", blockedBy.map((c) => c.name).join(', '), ". Point", ' ', blockedBy.length === 1 ? 'it' : 'them', " elsewhere first."] }));
|
|
146
|
+
}
|
|
147
|
+
if (error && !blockedBy) {
|
|
148
|
+
return error instanceof Error ? error.message : 'Could not delete it.';
|
|
149
|
+
}
|
|
150
|
+
return undefined;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* The buttons on a card: test it, and — with write access — edit or delete it.
|
|
154
|
+
*
|
|
155
|
+
* The delete tooltip says up front that a connection with readers will be
|
|
156
|
+
* refused, so the refusal is not the first time somebody hears about it.
|
|
157
|
+
*/
|
|
158
|
+
function ConnectionCardActions({ connection, users, canEdit, testing, onTest, onEdit, onAskDelete, }) {
|
|
159
|
+
return (_jsxs("div", { className: "flex shrink-0 items-center gap-1", children: [_jsxs("button", { type: "button", onClick: onTest, disabled: testing, 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: [testing ? _jsx(Loader2, { size: 12, className: "animate-spin" }) : _jsx(Plug, { size: 12 }), testing ? '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-sky-600', MUTED), children: _jsx(Pencil, { size: 12 }) }) }), _jsx(Tooltip, { content: users.length > 0
|
|
160
|
+
? `${users.length} connector${users.length === 1 ? '' : 's'} read through this. Deleting it is refused while that is true.`
|
|
161
|
+
: `Delete ${connection.name}`, children: _jsx("button", { type: "button", onClick: onAskDelete, "aria-label": `Delete ${connection.name}`, className: cn('rounded-sm p-1.5 hover:text-red-600', MUTED), children: _jsx(Trash2, { size: 12 }) }) })] }))] }));
|
|
162
|
+
}
|
|
163
|
+
/** What deleting would actually cost, named readers and all, before it is tried. */
|
|
164
|
+
function deleteConsequence(users) {
|
|
165
|
+
if (users.length === 0) {
|
|
166
|
+
return 'Nothing reads through it. The connectors that used to are unaffected; only this address and the name of its credential variable go.';
|
|
167
|
+
}
|
|
168
|
+
return (_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."] }));
|
|
169
|
+
}
|
|
103
170
|
function ConnectionCard({ connection, users, canEdit, onEdit, onChanged, }) {
|
|
104
171
|
const client = useCatalogClient();
|
|
105
172
|
const [confirming, setConfirming] = useState(false);
|
|
@@ -130,21 +197,69 @@ function ConnectionCard({ connection, users, canEdit, onEdit, onChanged, }) {
|
|
|
130
197
|
},
|
|
131
198
|
});
|
|
132
199
|
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: [
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
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) => {
|
|
200
|
+
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: [_jsx(ConnectionIdentity, { connection: connection, users: users }), _jsx(ConnectionCardActions, { connection: connection, users: users, canEdit: canEdit, testing: check.isPending, onTest: () => check.mutate(), onEdit: onEdit, onAskDelete: () => {
|
|
201
|
+
setBlockedBy(null);
|
|
202
|
+
remove.reset();
|
|
203
|
+
setConfirming(true);
|
|
204
|
+
} })] }), !result && _jsx(StoredCheckSummary, { connection: connection }), result && _jsx(LiveCheckResult, { result: result }), 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
205
|
setConfirming(open);
|
|
145
206
|
if (!open)
|
|
146
207
|
setBlockedBy(null);
|
|
147
|
-
}, title: `Delete ${connection.name}?`, description:
|
|
208
|
+
}, title: `Delete ${connection.name}?`, description: deleteConsequence(users), confirmLabel: remove.isPending ? 'Deleting…' : 'Delete', pending: remove.isPending, onConfirm: () => remove.mutate(), error: deleteRefusalMessage(blockedBy, remove.error) })] }));
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Only the config fields the chosen kind actually reads.
|
|
212
|
+
*
|
|
213
|
+
* Carrying the rest would leave a stale bucket on an HTTP connection, which
|
|
214
|
+
* reads as configuration somebody meant rather than as a leftover from a
|
|
215
|
+
* dropdown they changed.
|
|
216
|
+
*/
|
|
217
|
+
function connectionConfigFor(kind, draft) {
|
|
218
|
+
if (kind === 's3') {
|
|
219
|
+
return {
|
|
220
|
+
bucket: draft.bucket,
|
|
221
|
+
...(draft.endpoint ? { endpoint: draft.endpoint } : {}),
|
|
222
|
+
...(draft.region ? { region: draft.region } : {}),
|
|
223
|
+
...(draft.forcePathStyle ? { forcePathStyle: true } : {}),
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
return draft.url ? { url: draft.url } : {};
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Whether there is not yet enough here to save.
|
|
230
|
+
*
|
|
231
|
+
* A SQL connection needs one of its two addresses and neither is more correct:
|
|
232
|
+
* the variable is the right answer in a deployment, the inline URL is the one
|
|
233
|
+
* that gets somebody running locally in a minute.
|
|
234
|
+
*/
|
|
235
|
+
function connectionIsIncomplete(kind, draft) {
|
|
236
|
+
if (draft.name.trim().length === 0)
|
|
237
|
+
return true;
|
|
238
|
+
if (kind === 's3')
|
|
239
|
+
return draft.bucket.trim().length === 0;
|
|
240
|
+
if (kind === 'http')
|
|
241
|
+
return draft.url.trim().length === 0;
|
|
242
|
+
return draft.url.trim().length === 0 && draft.secretEnvVar.trim().length === 0;
|
|
243
|
+
}
|
|
244
|
+
/** A base URL, and the token sent against it. */
|
|
245
|
+
function HttpFields({ draft, update }) {
|
|
246
|
+
return (_jsxs(_Fragment, { children: [_jsx(TextField, { label: "URL", value: draft.url, onChange: (url) => update({ url }), placeholder: "https://api.example.mil/v1", hint: "The base the connectors reading through this will hang their paths off." }), _jsx(TextField, { label: "Credential env var", value: draft.secretEnvVar, onChange: (secretEnvVar) => update({ secretEnvVar }), placeholder: "Optional \u2014 sent as a bearer token" })] }));
|
|
247
|
+
}
|
|
248
|
+
/** Either an inline URL or the variable holding one. */
|
|
249
|
+
function SqlFields({ draft, update }) {
|
|
250
|
+
return (_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) => update({ url }), placeholder: "mysql://user:pass@host/db" }), _jsx(TextField, { label: "Env var holding the URL", value: draft.secretEnvVar, onChange: (secretEnvVar) => update({ secretEnvVar }), placeholder: "FLEET_DATABASE_URL" })] }) }));
|
|
251
|
+
}
|
|
252
|
+
/** A bucket, plus everything needed to address a non-AWS one. */
|
|
253
|
+
function S3Fields({ draft, update }) {
|
|
254
|
+
return (_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) => update({ bucket }), placeholder: "fleet-drops" }), _jsx(TextField, { label: "Region", value: draft.region, onChange: (region) => update({ region }), placeholder: "Blank uses the environment's" }), _jsx(TextField, { label: "Endpoint", value: draft.endpoint, onChange: (endpoint) => update({ endpoint }), placeholder: "MinIO, e.g. http://localhost:9000" }), _jsx(TextField, { label: "Env var holding accessKeyId:secretAccessKey", value: draft.secretEnvVar, onChange: (secretEnvVar) => update({ 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) => update({ forcePathStyle }), label: "Path-style addressing", hint: "MinIO needs it; AWS does not." })] }));
|
|
255
|
+
}
|
|
256
|
+
/** The address fields for whichever kind is selected, and only those. */
|
|
257
|
+
function ConnectionKindFields({ kind, draft, update, }) {
|
|
258
|
+
if (kind === 'http')
|
|
259
|
+
return _jsx(HttpFields, { draft: draft, update: update });
|
|
260
|
+
if (kind === 'sql')
|
|
261
|
+
return _jsx(SqlFields, { draft: draft, update: update });
|
|
262
|
+
return _jsx(S3Fields, { draft: draft, update: update });
|
|
148
263
|
}
|
|
149
264
|
/**
|
|
150
265
|
* Create or edit one.
|
|
@@ -169,44 +284,26 @@ function ConnectionForm({ connection, onClose, onSaved, }) {
|
|
|
169
284
|
forcePathStyle: config.forcePathStyle === true,
|
|
170
285
|
secretEnvVar: connection?.secretEnvVar ?? '',
|
|
171
286
|
});
|
|
287
|
+
const update = (patch) => setDraft({ ...draft, ...patch });
|
|
172
288
|
const save = useMutation({
|
|
173
289
|
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
290
|
const input = {
|
|
188
291
|
id: connection?.id,
|
|
189
292
|
name: draft.name.trim(),
|
|
190
293
|
description: draft.description.trim() || undefined,
|
|
191
294
|
kind,
|
|
192
|
-
config:
|
|
295
|
+
config: connectionConfigFor(kind, draft),
|
|
193
296
|
secretEnvVar: draft.secretEnvVar.trim() || undefined,
|
|
194
297
|
};
|
|
195
298
|
return client.saveConnection(input);
|
|
196
299
|
},
|
|
197
300
|
onSuccess: onSaved,
|
|
198
301
|
});
|
|
199
|
-
const incomplete = draft
|
|
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);
|
|
302
|
+
const incomplete = connectionIsIncomplete(kind, draft);
|
|
206
303
|
return (_jsxs("form", { className: cn('mt-6 space-y-4 rounded-lg border p-4', RULE, PANEL), onSubmit: (event) => {
|
|
207
304
|
event.preventDefault();
|
|
208
305
|
save.mutate();
|
|
209
|
-
}, children: [_jsxs("div", { className: "grid gap-3 sm:grid-cols-3", children: [_jsx(TextField, { label: "Name", value: draft.name, onChange: (name) =>
|
|
306
|
+
}, children: [_jsxs("div", { className: "grid gap-3 sm:grid-cols-3", children: [_jsx(TextField, { label: "Name", value: draft.name, onChange: (name) => update({ name }), placeholder: "Fleet warehouse" }), _jsx(TextField, { label: "Description", value: draft.description, onChange: (description) => update({ description }), placeholder: "What lives behind it (optional)" }), _jsx(SelectField, { label: "Kind", ariaLabel: "Connection kind", value: kind, onValueChange: (value) => setKind(toConnectableKind(value)), options: KIND_OPTIONS })] }), _jsx(ConnectionKindFields, { kind: kind, draft: draft, update: update }), _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
307
|
}
|
|
211
308
|
/**
|
|
212
309
|
* The options a connector form offers for "read through".
|
package/dist/DashboardBoard.js
CHANGED
|
@@ -163,6 +163,35 @@ const SPAN = {
|
|
|
163
163
|
3: '@2xl:col-span-2 @5xl:col-span-3',
|
|
164
164
|
4: '@2xl:col-span-2 @5xl:col-span-4',
|
|
165
165
|
};
|
|
166
|
+
/**
|
|
167
|
+
* How many of the four columns this card spans.
|
|
168
|
+
*
|
|
169
|
+
* A pressed-state button group rather than a select: there are exactly four
|
|
170
|
+
* choices, the current one has to be visible at a glance while arranging a
|
|
171
|
+
* board, and a closed dropdown shows nothing.
|
|
172
|
+
*/
|
|
173
|
+
function CardWidthPicker({ width, onWidth, }) {
|
|
174
|
+
return (_jsx("span", {
|
|
175
|
+
// A group of toggle buttons, not form fields, so `role="group"` is the
|
|
176
|
+
// accurate semantic — it is what the ARIA authoring practices give a
|
|
177
|
+
// toolbar toggle group and what Base UI's own ToggleGroup renders. A
|
|
178
|
+
// `<fieldset>` here would claim these are form controls and drag its
|
|
179
|
+
// user-agent sizing into a component the host styles.
|
|
180
|
+
// biome-ignore lint/a11y/useSemanticElements: fieldset is for grouping form controls; these are toggle buttons
|
|
181
|
+
className: cn('mr-1 flex overflow-hidden rounded-md border', RULE), role: "group", "aria-label": "Card width", children: [1, 2, 3, 4].map((size) => (_jsx(Tooltip, { content: `${size} of 4 columns wide`, children: _jsx("button", { type: "button", onClick: () => onWidth(size), "aria-pressed": width === size, className: cn('px-1.5 py-0.5 font-mono text-[10px] transition-colors', width === size
|
|
182
|
+
? 'bg-zinc-950 text-zinc-50 dark:bg-zinc-100 dark:text-zinc-950'
|
|
183
|
+
: 'hover:bg-zinc-100 dark:hover:bg-zinc-800'), children: size }) }, size))) }));
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* The controls in a card's top-right: width, refresh, export, remove.
|
|
187
|
+
*
|
|
188
|
+
* Export appears only once there is a result, because the URL exports what the
|
|
189
|
+
* query returns and offering it before the first run promises a file that does
|
|
190
|
+
* not exist yet.
|
|
191
|
+
*/
|
|
192
|
+
function CardToolbar({ width, onWidth, cached, fetching, exportHref, onRefresh, onRemove, }) {
|
|
193
|
+
return (_jsxs("div", { className: "flex shrink-0 items-center gap-0.5", children: [onWidth && _jsx(CardWidthPicker, { width: width, onWidth: onWidth }), _jsx(Tooltip, { content: cached ? 'Cached — refetch anyway' : 'Run again', children: _jsx("button", { type: "button", onClick: onRefresh, className: cn('rounded-sm p-1 hover:bg-zinc-100 dark:hover:bg-zinc-800', MUTED), "aria-label": "Refresh card", children: _jsx(RefreshCw, { size: 11, className: fetching ? 'animate-spin' : undefined }) }) }), exportHref && (_jsx(Tooltip, { content: "Download as CSV", children: _jsx("a", { href: exportHref, className: cn('rounded-sm p-1 hover:bg-zinc-100 dark:hover:bg-zinc-800', MUTED), "aria-label": "Export card", children: _jsx(Download, { size: 11 }) }) })), _jsx("button", { type: "button", onClick: onRemove, className: cn('rounded-sm p-1 hover:text-red-600', MUTED), "aria-label": "Remove card", children: _jsx(Trash2, { size: 11 }) })] }));
|
|
194
|
+
}
|
|
166
195
|
function Card({ savedQueryId, width, onRemove, onWidth, dragHandle, }) {
|
|
167
196
|
const client = useCatalogClient();
|
|
168
197
|
const { data, isPending, isFetching, refetch, error } = useQuery({
|
|
@@ -183,9 +212,7 @@ function Card({ savedQueryId, width, onRemove, onWidth, dragHandle, }) {
|
|
|
183
212
|
staleTime: 60_000,
|
|
184
213
|
});
|
|
185
214
|
const pendingKind = saved.find((query) => query.id === savedQueryId)?.visualization?.kind ?? 'table';
|
|
186
|
-
return (_jsxs("div", { className: cn('h-full rounded-lg border p-3 transition-shadow', RULE, PANEL), children: [_jsxs("div", { className: "flex items-start justify-between gap-2", children: [dragHandle, _jsxs("div", { className: "min-w-0 flex-1", children: [_jsx("h3", { className: "truncate text-sm font-medium", children: data?.savedQuery.name ?? '…' }), data && (_jsxs("p", { className: cn('font-mono text-[10px]', MUTED), children: [data.result.rowCount, " rows", data.result.cached ? ' · cached' : ` · ${data.result.elapsedMs}ms`] }))] }),
|
|
187
|
-
? 'bg-zinc-950 text-zinc-50 dark:bg-zinc-100 dark:text-zinc-950'
|
|
188
|
-
: 'hover:bg-zinc-100 dark:hover:bg-zinc-800'), children: size }) }, size))) })), _jsx(Tooltip, { content: data?.result.cached ? 'Cached — refetch anyway' : 'Run again', children: _jsx("button", { type: "button", onClick: () => refetch(), className: cn('rounded-sm p-1 hover:bg-zinc-100 dark:hover:bg-zinc-800', MUTED), "aria-label": "Refresh card", children: _jsx(RefreshCw, { size: 11, className: isFetching ? 'animate-spin' : undefined }) }) }), data && (_jsx(Tooltip, { content: "Download as CSV", children: _jsx("a", { href: client.exportUrl(savedQueryId), className: cn('rounded-sm p-1 hover:bg-zinc-100 dark:hover:bg-zinc-800', MUTED), "aria-label": "Export card", children: _jsx(Download, { size: 11 }) }) })), _jsx("button", { type: "button", onClick: onRemove, className: cn('rounded-sm p-1 hover:text-red-600', MUTED), "aria-label": "Remove card", children: _jsx(Trash2, { size: 11 }) })] })] }), _jsx("div", { className: "mt-3", children: error ? (_jsx(ChartFailed, { height: 200, message: error instanceof Error ? error.message : 'The card failed to load.', onRetry: () => refetch() })) : isPending ? (_jsx(ChartSkeleton, { kind: pendingKind, height: 200 })) : data ? (_jsx(CardBody, { query: data.savedQuery, result: data.result })) : null })] }));
|
|
215
|
+
return (_jsxs("div", { className: cn('h-full rounded-lg border p-3 transition-shadow', RULE, PANEL), children: [_jsxs("div", { className: "flex items-start justify-between gap-2", children: [dragHandle, _jsxs("div", { className: "min-w-0 flex-1", children: [_jsx("h3", { className: "truncate text-sm font-medium", children: data?.savedQuery.name ?? '…' }), data && (_jsxs("p", { className: cn('font-mono text-[10px]', MUTED), children: [data.result.rowCount, " rows", data.result.cached ? ' · cached' : ` · ${data.result.elapsedMs}ms`] }))] }), _jsx(CardToolbar, { width: width, onWidth: onWidth, cached: data?.result.cached === true, fetching: isFetching, exportHref: data ? client.exportUrl(savedQueryId) : undefined, onRefresh: () => refetch(), onRemove: onRemove })] }), _jsx("div", { className: "mt-3", children: error ? (_jsx(ChartFailed, { height: 200, message: error instanceof Error ? error.message : 'The card failed to load.', onRetry: () => refetch() })) : isPending ? (_jsx(ChartSkeleton, { kind: pendingKind, height: 200 })) : data ? (_jsx(CardBody, { query: data.savedQuery, result: data.result })) : null })] }));
|
|
189
216
|
}
|
|
190
217
|
function CardBody({ query, result, }) {
|
|
191
218
|
const viz = query.visualization ?? { kind: 'table' };
|
package/dist/FlowView.js
CHANGED
|
@@ -41,6 +41,39 @@ export function FlowView() {
|
|
|
41
41
|
* most important thing on this screen, and collapsing by type would hide
|
|
42
42
|
* exactly that.
|
|
43
43
|
*/
|
|
44
|
+
/** An empty lane for one (publisher, type) pair, named from the type when it is known. */
|
|
45
|
+
function newLane(principalId, typeName, def) {
|
|
46
|
+
return {
|
|
47
|
+
principalId,
|
|
48
|
+
typeName,
|
|
49
|
+
displayName: def?.displayName ?? typeName,
|
|
50
|
+
icon: def?.icon,
|
|
51
|
+
loads: [],
|
|
52
|
+
schemaChanges: 0,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Fold one snapshot event into a lane's loads.
|
|
57
|
+
*
|
|
58
|
+
* A snapshot is written and then committed — two events for one load — so a
|
|
59
|
+
* second event updates the load already recorded rather than adding another bar
|
|
60
|
+
* beside it. Capped at 12 because a lane is a sparkline, not a log.
|
|
61
|
+
*/
|
|
62
|
+
function recordSnapshot(lane, event) {
|
|
63
|
+
if (!event.snapshotId || !event.event.startsWith('snapshot.'))
|
|
64
|
+
return;
|
|
65
|
+
const committed = event.event === 'snapshot.committed';
|
|
66
|
+
const rows = Number(event.detail?.rowCount ?? event.detail?.rows ?? 0);
|
|
67
|
+
const existing = lane.loads.find((load) => load.snapshotId === event.snapshotId);
|
|
68
|
+
if (existing) {
|
|
69
|
+
existing.committed = existing.committed || committed;
|
|
70
|
+
existing.rows = Math.max(existing.rows, rows);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (lane.loads.length < 12) {
|
|
74
|
+
lane.loads.push({ snapshotId: event.snapshotId, rows, committed, at: event.occurredAt });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
44
77
|
function buildLanes(types, events) {
|
|
45
78
|
const byType = new Map(types.map((t) => [t.name, t]));
|
|
46
79
|
const lanes = new Map();
|
|
@@ -51,34 +84,10 @@ function buildLanes(types, events) {
|
|
|
51
84
|
continue;
|
|
52
85
|
const principalId = event.principalId ?? 'curated by hand';
|
|
53
86
|
const key = `${principalId}:${event.typeName}`;
|
|
54
|
-
const lane = lanes.get(key) ??
|
|
55
|
-
{
|
|
56
|
-
principalId,
|
|
57
|
-
typeName: event.typeName,
|
|
58
|
-
displayName: byType.get(event.typeName)?.displayName ?? event.typeName,
|
|
59
|
-
icon: byType.get(event.typeName)?.icon,
|
|
60
|
-
loads: [],
|
|
61
|
-
schemaChanges: 0,
|
|
62
|
-
};
|
|
87
|
+
const lane = lanes.get(key) ?? newLane(principalId, event.typeName, byType.get(event.typeName));
|
|
63
88
|
if (event.event === 'schema.changed')
|
|
64
89
|
lane.schemaChanges += 1;
|
|
65
|
-
|
|
66
|
-
const existing = lane.loads.find((l) => l.snapshotId === event.snapshotId);
|
|
67
|
-
const committed = event.event === 'snapshot.committed';
|
|
68
|
-
const rows = Number(event.detail?.rowCount ?? event.detail?.rows ?? 0);
|
|
69
|
-
if (existing) {
|
|
70
|
-
existing.committed = existing.committed || committed;
|
|
71
|
-
existing.rows = Math.max(existing.rows, rows);
|
|
72
|
-
}
|
|
73
|
-
else if (lane.loads.length < 12) {
|
|
74
|
-
lane.loads.push({
|
|
75
|
-
snapshotId: event.snapshotId,
|
|
76
|
-
rows,
|
|
77
|
-
committed,
|
|
78
|
-
at: event.occurredAt,
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
}
|
|
90
|
+
recordSnapshot(lane, event);
|
|
82
91
|
lane.lastAt = lane.lastAt ?? event.occurredAt;
|
|
83
92
|
lanes.set(key, lane);
|
|
84
93
|
}
|
package/dist/PipelineConsole.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
3
3
|
import { Cable, CircleCheck, CircleX, Code2, KeyRound, Loader2, Play, Plug, Plus, RefreshCw, Trash2, } from 'lucide-react';
|
|
4
4
|
import { useState } from 'react';
|
|
@@ -92,38 +92,52 @@ function ConnectorList({ canEdit }) {
|
|
|
92
92
|
* with a blank subtitle — the card said a connector existed and nothing about
|
|
93
93
|
* where it pointed, which is the one thing the list is for.
|
|
94
94
|
*/
|
|
95
|
+
/** Read a string out of a stored config without believing it is one. */
|
|
96
|
+
function configText(config, key) {
|
|
97
|
+
const value = config[key];
|
|
98
|
+
return typeof value === 'string' ? value : '';
|
|
99
|
+
}
|
|
100
|
+
/** A prefix under a shared bucket, or a bucket of this connector's own. */
|
|
101
|
+
function describeS3Source(config, via) {
|
|
102
|
+
if (via)
|
|
103
|
+
return `${via}${configText(config, 'prefix') || '(whole bucket)'}`;
|
|
104
|
+
const bucket = configText(config, 'bucket');
|
|
105
|
+
if (!bucket)
|
|
106
|
+
return 'no bucket configured';
|
|
107
|
+
return `s3://${bucket}/${configText(config, 'prefix')}`;
|
|
108
|
+
}
|
|
109
|
+
/** The query, shortened to fit a line, plus the watermark when it reads incrementally. */
|
|
110
|
+
function describeSqlSource(config, via) {
|
|
111
|
+
const watermark = configText(config, 'watermarkColumn');
|
|
112
|
+
const query = configText(config, 'query').replace(/\s+/g, ' ').trim();
|
|
113
|
+
const shown = query.length > 70 ? `${query.slice(0, 70)}…` : query;
|
|
114
|
+
return `${via}${watermark ? `${shown} · since ${watermark}` : shown}`;
|
|
115
|
+
}
|
|
116
|
+
/** A path under a shared base URL, or a full URL of this connector's own. */
|
|
117
|
+
function describeHttpSource(config, via) {
|
|
118
|
+
const path = configText(config, 'path');
|
|
119
|
+
if (via)
|
|
120
|
+
return `${via}${path || '/'}`;
|
|
121
|
+
return `${configText(config, 'url')}${path ? ` · ${path}` : ''}`;
|
|
122
|
+
}
|
|
95
123
|
function describeSource(connector, connection) {
|
|
96
124
|
const config = connector.config ?? {};
|
|
97
|
-
const text = (key) => (typeof config[key] === 'string' ? config[key] : '');
|
|
98
125
|
// The connection's name first, because when one is in use it is the answer to
|
|
99
126
|
// "where does this read from" and the connector's own config is only the part
|
|
100
127
|
// specific to this load.
|
|
101
128
|
const via = connection ? `${connection.name} · ` : '';
|
|
102
|
-
if (connector.kind === 's3')
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
if (!bucket)
|
|
107
|
-
return 'no bucket configured';
|
|
108
|
-
return `s3://${bucket}/${text('prefix')}`;
|
|
109
|
-
}
|
|
110
|
-
if (connector.kind === 'sql') {
|
|
111
|
-
const watermark = text('watermarkColumn');
|
|
112
|
-
const query = text('query').replace(/\s+/g, ' ').trim();
|
|
113
|
-
const shown = query.length > 70 ? `${query.slice(0, 70)}…` : query;
|
|
114
|
-
return `${via}${watermark ? `${shown} · since ${watermark}` : shown}`;
|
|
115
|
-
}
|
|
129
|
+
if (connector.kind === 's3')
|
|
130
|
+
return describeS3Source(config, via);
|
|
131
|
+
if (connector.kind === 'sql')
|
|
132
|
+
return describeSqlSource(config, via);
|
|
116
133
|
if (connector.kind === 'file') {
|
|
117
|
-
return
|
|
134
|
+
return configText(config, 'path') || configText(config, 'url') || 'no path configured';
|
|
118
135
|
}
|
|
119
136
|
if (connector.kind === 'inline') {
|
|
120
137
|
const records = config.records;
|
|
121
138
|
return `${Array.isArray(records) ? records.length : 0} pasted records`;
|
|
122
139
|
}
|
|
123
|
-
|
|
124
|
-
if (connection)
|
|
125
|
-
return `${via}${path || '/'}`;
|
|
126
|
-
return `${text('url')}${path ? ` · ${path}` : ''}`;
|
|
140
|
+
return describeHttpSource(config, via);
|
|
127
141
|
}
|
|
128
142
|
function ConnectorCard({ connector, transform, connection, canEdit, running, onRun, onEdit, onDeleted, }) {
|
|
129
143
|
const client = useCatalogClient();
|
|
@@ -145,6 +159,37 @@ function ConnectorCard({ connector, transform, connection, canEdit, running, onR
|
|
|
145
159
|
: 'Could not delete it.'
|
|
146
160
|
: undefined })] }));
|
|
147
161
|
}
|
|
162
|
+
/**
|
|
163
|
+
* The connection picker, above the address fields it replaces.
|
|
164
|
+
*
|
|
165
|
+
* Offered rather than required: a one-off source does not deserve a second
|
|
166
|
+
* object to manage, and forcing one would make the quickest thing this screen
|
|
167
|
+
* can do — paste a URL, load it once — the slowest.
|
|
168
|
+
*/
|
|
169
|
+
function ConnectionPicker({ value, options, viaConnection, onChange, }) {
|
|
170
|
+
return (_jsx(SelectField, { label: "Read through", ariaLabel: "Connection", value: value, onValueChange: onChange, options: [
|
|
171
|
+
{
|
|
172
|
+
value: INLINE_CONNECTION,
|
|
173
|
+
label: 'Configure the address here',
|
|
174
|
+
hint: 'This connector alone',
|
|
175
|
+
},
|
|
176
|
+
...options,
|
|
177
|
+
], hint: connectionPickerHint(options.length, viaConnection) }));
|
|
178
|
+
}
|
|
179
|
+
/** Why the picker looks the way it does — nothing to choose, or something chosen. */
|
|
180
|
+
function connectionPickerHint(optionCount, viaConnection) {
|
|
181
|
+
if (optionCount === 0) {
|
|
182
|
+
return 'No connections of this kind yet. One is worth making when a second connector needs the same address.';
|
|
183
|
+
}
|
|
184
|
+
if (viaConnection) {
|
|
185
|
+
return 'The connection supplies the address and the credential. What stays below is only what is specific to this load.';
|
|
186
|
+
}
|
|
187
|
+
return undefined;
|
|
188
|
+
}
|
|
189
|
+
/** Save and cancel, plus whatever the server said when saving failed. */
|
|
190
|
+
function ConnectorFormActions({ editing, pending, incomplete, error, onClose, }) {
|
|
191
|
+
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] }));
|
|
192
|
+
}
|
|
148
193
|
function ConnectorForm({ connector, transforms, connections, onClose, onSaved, }) {
|
|
149
194
|
const client = useCatalogClient();
|
|
150
195
|
const [kind, setKind] = useState(toConnectorKind(connector?.kind ?? 'http'));
|
|
@@ -210,18 +255,7 @@ function ConnectorForm({ connector, transforms, connections, onClose, onSaved, }
|
|
|
210
255
|
return (_jsxs("form", { className: cn('mt-6 space-y-4 rounded-lg border p-4', RULE, PANEL), onSubmit: (event) => {
|
|
211
256
|
event.preventDefault();
|
|
212
257
|
save.mutate();
|
|
213
|
-
}, 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(SelectField, { label: "
|
|
214
|
-
{
|
|
215
|
-
value: INLINE_CONNECTION,
|
|
216
|
-
label: 'Configure the address here',
|
|
217
|
-
hint: 'This connector alone',
|
|
218
|
-
},
|
|
219
|
-
...connectionOptions,
|
|
220
|
-
], hint: connectionOptions.length === 0
|
|
221
|
-
? 'No connections of this kind yet. One is worth making when a second connector needs the same address.'
|
|
222
|
-
: viaConnection
|
|
223
|
-
? 'The connection supplies the address and the credential. What stays below is only what is specific to this load.'
|
|
224
|
-
: undefined })), _jsx(SourceFields, { kind: kind, draft: source, onChange: setSource, viaConnection: viaConnection }), _jsx(ReadModeFields, { kind: kind, mode: mode, onModeChange: setMode, draft: source, onChange: setSource }), _jsxs("div", { className: "grid gap-3 sm:grid-cols-2", children: [!viaConnection && (_jsx(CredentialField, { kind: kind, value: draft.secretEnvVar, onChange: (secretEnvVar) => setDraft({ ...draft, secretEnvVar }) })), _jsx(SelectField, { label: "Transform", ariaLabel: "Transform", value: draft.transformId, onValueChange: (transformId) => setDraft({ ...draft, transformId }), options: [
|
|
258
|
+
}, 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 })), _jsx(SourceFields, { kind: kind, draft: source, onChange: setSource, viaConnection: viaConnection }), _jsx(ReadModeFields, { kind: kind, mode: mode, onModeChange: setMode, draft: source, onChange: setSource }), _jsxs("div", { className: "grid gap-3 sm:grid-cols-2", children: [!viaConnection && (_jsx(CredentialField, { kind: kind, value: draft.secretEnvVar, onChange: (secretEnvVar) => setDraft({ ...draft, secretEnvVar }) })), _jsx(SelectField, { label: "Transform", ariaLabel: "Transform", value: draft.transformId, onValueChange: (transformId) => setDraft({ ...draft, transformId }), options: [
|
|
225
259
|
{
|
|
226
260
|
value: '',
|
|
227
261
|
label: 'No transform',
|
|
@@ -232,7 +266,7 @@ function ConnectorForm({ connector, transforms, connections, onClose, onSaved, }
|
|
|
232
266
|
label: transform.name,
|
|
233
267
|
hint: `${transform.language} · v${transform.version}`,
|
|
234
268
|
})),
|
|
235
|
-
] })] }), _jsx(Switch, { checked: enabled, onCheckedChange: setEnabled, label: "Enabled", hint: "A disabled connector keeps its configuration and its watermark, and refuses to run." }),
|
|
269
|
+
] })] }), _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 })] }));
|
|
236
270
|
}
|
|
237
271
|
function TransformList({ canEdit, languages, pythonPackages, }) {
|
|
238
272
|
const client = useCatalogClient();
|
package/dist/QueryConsole.js
CHANGED
|
@@ -24,6 +24,19 @@ const STARTER = `-- Two relations per object type, and the difference is the poi
|
|
|
24
24
|
-- SELECT _snapshot_id, AVG(\`Risk Score\`) FROM obj_mvr GROUP BY _snapshot_id
|
|
25
25
|
|
|
26
26
|
SELECT * FROM `;
|
|
27
|
+
/**
|
|
28
|
+
* Turn a sentence into SQL, and say what the assistant was shown.
|
|
29
|
+
*
|
|
30
|
+
* The note about relation and column names is not decoration: somebody typing a
|
|
31
|
+
* question here is entitled to know that the rows never left the database, and
|
|
32
|
+
* that what comes back is a draft to read rather than a result to trust.
|
|
33
|
+
*/
|
|
34
|
+
function AskAssistantPanel({ prompt, onPromptChange, pending, error, onSubmit, }) {
|
|
35
|
+
return (_jsxs("div", { className: cn('shrink-0 border-b bg-sky-50/60 px-4 py-3 dark:bg-sky-950/20', RULE), children: [_jsxs("form", { className: "flex gap-2", onSubmit: (e) => {
|
|
36
|
+
e.preventDefault();
|
|
37
|
+
onSubmit();
|
|
38
|
+
}, children: [_jsx("input", { value: prompt, onChange: (e) => onPromptChange(e.target.value), placeholder: "Which vehicles gained the most work orders since the last load?", "aria-label": "Describe the query", className: cn('flex-1 rounded-md border px-3 py-1.5 text-sm outline-none', RULE, PANEL, 'focus:border-sky-500 focus:ring-2 focus:ring-sky-500/15') }), _jsx("button", { type: "submit", disabled: pending || prompt.trim().length === 0, className: "rounded-md bg-sky-600 px-3 py-1.5 text-xs text-white disabled:opacity-40", children: pending ? 'Writing…' : 'Write the SQL' })] }), _jsx("p", { className: cn('mt-1.5 text-[11px]', MUTED), children: "It sees the relation and column names above, never the rows. Read the SQL before running it." }), error ? (_jsx("p", { className: "mt-1 text-[11px] text-red-600", children: error instanceof Error ? error.message : 'The assistant could not write that.' })) : null] }));
|
|
39
|
+
}
|
|
27
40
|
export function QueryConsole({ onGenerate, maxRows = 500 }) {
|
|
28
41
|
const client = useCatalogClient();
|
|
29
42
|
const [sql, setSql] = useState(STARTER);
|
|
@@ -83,12 +96,7 @@ export function QueryConsole({ onGenerate, maxRows = 500 }) {
|
|
|
83
96
|
// Tab still moves focus; indentation is Shift-agnostic two spaces on Enter.
|
|
84
97
|
}
|
|
85
98
|
const error = run.error instanceof Error ? run.error.message : null;
|
|
86
|
-
return (_jsx(TooltipProvider, { children: _jsxs("div", { className: "flex h-full min-h-0", children: [_jsxs("aside", { className: cn('flex w-64 shrink-0 flex-col border-r', RULE, PANEL), children: [_jsx("div", { className: cn('border-b px-3 py-2', RULE), children: _jsx("p", { className: cn('font-mono text-[10px] uppercase tracking-[0.14em]', MUTED), children: "Relations" }) }), _jsxs("div", { className: "min-h-0 flex-1 overflow-y-auto p-2", children: [grouped.length === 0 && (_jsx("p", { className: cn('px-2 py-6 text-center text-xs', MUTED), children: "Nothing has been published yet." })), grouped.map(([objectType, list]) => (_jsxs("div", { className: "mb-3", children: [_jsx("div", { className: cn('px-2 py-1 font-mono text-[10px] uppercase tracking-[0.14em]', MUTED), children: objectType }), list.map((relation) => (_jsx(RelationRow, { relation: relation, onInsert: insert }, relation.name)))] }, objectType)))] }), _jsx(SavedQueryPanel, { currentSql: sql, onLoad: (query) => setSql(query.sql) })] }), _jsxs("div", { className: "flex min-w-0 flex-1 flex-col", children: [_jsxs("div", { className: cn('flex shrink-0 items-center gap-2 border-b px-4 py-2', RULE, PANEL), children: [_jsxs("button", { type: "button", onClick: () => run.mutate(), disabled: run.isPending, className: "flex items-center gap-1.5 rounded-md bg-zinc-950 px-3 py-1.5 text-xs text-zinc-50 transition-colors hover:bg-zinc-800 disabled:opacity-50 dark:bg-zinc-100 dark:text-zinc-950", children: [_jsx(Play, { size: 12 }), run.isPending ? 'Running…' : 'Run'] }), _jsx("span", { className: cn('font-mono text-[10px]', MUTED), children: "\u2318\u21B5" }), onGenerate && (_jsxs("button", { type: "button", onClick: () => setAskOpen((open) => !open), className: cn('flex items-center gap-1.5 rounded-md border px-3 py-1.5 text-xs transition-colors', RULE, 'hover:bg-zinc-50 dark:hover:bg-zinc-800', askOpen && 'bg-sky-100 dark:bg-sky-950'), children: [_jsx(Sparkles, { size: 12 }), "Ask"] })), run.data && (_jsxs("span", { className: cn('ml-auto font-mono text-[11px]', MUTED), children: [run.data.rowCount, " rows \u00B7 ", run.data.cached ? 'cached' : `${run.data.elapsedMs} ms`, run.data.truncated && ' · capped'] }))] }), askOpen && onGenerate && (_jsxs("div", { className:
|
|
87
|
-
e.preventDefault();
|
|
88
|
-
generate.mutate();
|
|
89
|
-
}, children: [_jsx("input", { value: prompt, onChange: (e) => setPrompt(e.target.value), placeholder: "Which vehicles gained the most work orders since the last load?", "aria-label": "Describe the query", className: cn('flex-1 rounded-md border px-3 py-1.5 text-sm outline-none', RULE, PANEL, 'focus:border-sky-500 focus:ring-2 focus:ring-sky-500/15') }), _jsx("button", { type: "submit", disabled: generate.isPending || prompt.trim().length === 0, className: "rounded-md bg-sky-600 px-3 py-1.5 text-xs text-white disabled:opacity-40", children: generate.isPending ? 'Writing…' : 'Write the SQL' })] }), _jsx("p", { className: cn('mt-1.5 text-[11px]', MUTED), children: "It sees the relation and column names above, never the rows. Read the SQL before running it." }), generate.error && (_jsx("p", { className: "mt-1 text-[11px] text-red-600", children: generate.error instanceof Error
|
|
90
|
-
? generate.error.message
|
|
91
|
-
: 'The assistant could not write that.' }))] })), _jsx(SqlEditor, { value: sql, onChange: setSql, onKeyDown: onEditorKeyDown, textareaRef: editorRef }), _jsxs("div", { className: "min-h-0 flex-1 overflow-auto", children: [error && (_jsxs("div", { className: "m-4 flex items-start gap-2 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700 dark:border-red-900 dark:bg-red-950/40 dark:text-red-300", children: [_jsx(AlertTriangle, { size: 14, className: "mt-0.5 shrink-0" }), _jsx("span", { className: "font-mono leading-relaxed", children: error })] })), run.data && _jsx(ResultTable, { result: run.data }), !run.data && !error && (_jsx("p", { className: cn('p-8 text-center text-sm', MUTED), children: "Results appear here." }))] })] })] }) }));
|
|
99
|
+
return (_jsx(TooltipProvider, { children: _jsxs("div", { className: "flex h-full min-h-0", children: [_jsxs("aside", { className: cn('flex w-64 shrink-0 flex-col border-r', RULE, PANEL), children: [_jsx("div", { className: cn('border-b px-3 py-2', RULE), children: _jsx("p", { className: cn('font-mono text-[10px] uppercase tracking-[0.14em]', MUTED), children: "Relations" }) }), _jsxs("div", { className: "min-h-0 flex-1 overflow-y-auto p-2", children: [grouped.length === 0 && (_jsx("p", { className: cn('px-2 py-6 text-center text-xs', MUTED), children: "Nothing has been published yet." })), grouped.map(([objectType, list]) => (_jsxs("div", { className: "mb-3", children: [_jsx("div", { className: cn('px-2 py-1 font-mono text-[10px] uppercase tracking-[0.14em]', MUTED), children: objectType }), list.map((relation) => (_jsx(RelationRow, { relation: relation, onInsert: insert }, relation.name)))] }, objectType)))] }), _jsx(SavedQueryPanel, { currentSql: sql, onLoad: (query) => setSql(query.sql) })] }), _jsxs("div", { className: "flex min-w-0 flex-1 flex-col", children: [_jsxs("div", { className: cn('flex shrink-0 items-center gap-2 border-b px-4 py-2', RULE, PANEL), children: [_jsxs("button", { type: "button", onClick: () => run.mutate(), disabled: run.isPending, className: "flex items-center gap-1.5 rounded-md bg-zinc-950 px-3 py-1.5 text-xs text-zinc-50 transition-colors hover:bg-zinc-800 disabled:opacity-50 dark:bg-zinc-100 dark:text-zinc-950", children: [_jsx(Play, { size: 12 }), run.isPending ? 'Running…' : 'Run'] }), _jsx("span", { className: cn('font-mono text-[10px]', MUTED), children: "\u2318\u21B5" }), onGenerate && (_jsxs("button", { type: "button", onClick: () => setAskOpen((open) => !open), className: cn('flex items-center gap-1.5 rounded-md border px-3 py-1.5 text-xs transition-colors', RULE, 'hover:bg-zinc-50 dark:hover:bg-zinc-800', askOpen && 'bg-sky-100 dark:bg-sky-950'), children: [_jsx(Sparkles, { size: 12 }), "Ask"] })), run.data && (_jsxs("span", { className: cn('ml-auto font-mono text-[11px]', MUTED), children: [run.data.rowCount, " rows \u00B7 ", run.data.cached ? 'cached' : `${run.data.elapsedMs} ms`, run.data.truncated && ' · capped'] }))] }), askOpen && onGenerate && (_jsx(AskAssistantPanel, { prompt: prompt, onPromptChange: setPrompt, pending: generate.isPending, error: generate.error, onSubmit: () => generate.mutate() })), _jsx(SqlEditor, { value: sql, onChange: setSql, onKeyDown: onEditorKeyDown, textareaRef: editorRef }), _jsxs("div", { className: "min-h-0 flex-1 overflow-auto", children: [error && (_jsxs("div", { className: "m-4 flex items-start gap-2 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700 dark:border-red-900 dark:bg-red-950/40 dark:text-red-300", children: [_jsx(AlertTriangle, { size: 14, className: "mt-0.5 shrink-0" }), _jsx("span", { className: "font-mono leading-relaxed", children: error })] })), run.data && _jsx(ResultTable, { result: run.data }), !run.data && !error && (_jsx("p", { className: cn('p-8 text-center text-sm', MUTED), children: "Results appear here." }))] })] })] }) }));
|
|
92
100
|
}
|
|
93
101
|
function RelationRow({ relation, onInsert, }) {
|
|
94
102
|
const [open, setOpen] = useState(false);
|
|
@@ -11,13 +11,4 @@ export interface TransformEditorProps {
|
|
|
11
11
|
onClose: () => void;
|
|
12
12
|
onSaved: () => void;
|
|
13
13
|
}
|
|
14
|
-
/**
|
|
15
|
-
* Write the code, and run it against a couple of records before it ever touches
|
|
16
|
-
* a load.
|
|
17
|
-
*
|
|
18
|
-
* The try pane is the point of this screen. A transform is the one place where
|
|
19
|
-
* somebody's typo silently reshapes stored data, and the difference between a
|
|
20
|
-
* transform you can iterate on and one you can only test in production is
|
|
21
|
-
* whether you can see its output beside its input.
|
|
22
|
-
*/
|
|
23
14
|
export declare function TransformEditor({ transform, languages, pythonPackages, onClose, onSaved, }: TransformEditorProps): import("react/jsx-runtime").JSX.Element;
|