@dudousxd/nestjs-catalog-react 0.16.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.
- package/README.md +39 -13
- package/dist/ConnectionPanel.d.ts +11 -7
- package/dist/ConnectionPanel.js +65 -28
- package/dist/ObjectExplorer.js +424 -48
- package/dist/PipelineConsole.d.ts +23 -126
- package/dist/PipelineConsole.js +39 -551
- package/dist/QueryConsole.js +25 -17
- package/dist/SavedQueryPanel.js +1 -1
- package/dist/TransformEditor.js +12 -3
- package/dist/WorkflowCanvas.js +401 -29
- package/dist/bundler/index.d.ts +20 -0
- package/dist/bundler/index.js +20 -0
- package/dist/bundler/shiki-subset.d.ts +83 -0
- package/dist/bundler/shiki-subset.js +196 -0
- package/dist/context.d.ts +181 -38
- package/dist/context.js +44 -11
- package/dist/diff/RevisionDiff.d.ts +67 -4
- package/dist/diff/RevisionDiff.js +126 -91
- package/dist/index.d.ts +8 -5
- package/dist/index.js +56 -20
- package/dist/routes.d.ts +54 -13
- package/dist/routes.js +5 -4
- package/dist/schema-discovery.d.ts +216 -0
- package/dist/schema-discovery.js +225 -0
- package/dist/source-fields.d.ts +1 -12
- package/dist/source-fields.js +13 -16
- package/dist/ui/code-editor.d.ts +196 -8
- package/dist/ui/code-editor.js +184 -72
- package/dist/ui/code-languages.d.ts +80 -0
- package/dist/ui/code-languages.js +76 -0
- package/dist/ui/code-theme.d.ts +25 -0
- package/dist/ui/code-theme.js +26 -0
- package/dist/ui/dialog.d.ts +13 -1
- package/dist/ui/dialog.js +13 -2
- package/dist/workflow/graph.js +31 -9
- package/dist/workflow/index.d.ts +2 -0
- package/dist/workflow/index.js +7 -0
- package/dist/workflow/lifecycle.d.ts +164 -0
- package/dist/workflow/lifecycle.js +249 -0
- package/dist/workflow/model.d.ts +1 -1
- package/dist/workflow/nodes.js +10 -1
- package/dist/workflow/runs.d.ts +38 -0
- package/dist/workflow/runs.js +101 -0
- package/dist/workflow/shape.d.ts +169 -0
- package/dist/workflow/shape.js +249 -0
- package/dist/workflow/templates.d.ts +623 -0
- package/dist/workflow/templates.js +1092 -0
- package/dist/workflow/validate.d.ts +20 -1
- package/dist/workflow/validate.js +41 -3
- package/package.json +21 -17
- package/dist/diff/line-diff.d.ts +0 -124
- package/dist/diff/line-diff.js +0 -318
package/dist/QueryConsole.js
CHANGED
|
@@ -150,19 +150,23 @@ export function QueryConsole({ onGenerate, maxRows = 500, savedQueryId, onSavedQ
|
|
|
150
150
|
}
|
|
151
151
|
return [...byType.entries()].sort(([a], [b]) => a.localeCompare(b));
|
|
152
152
|
}, [relations]);
|
|
153
|
+
/**
|
|
154
|
+
* Put a relation or column name where the caret is.
|
|
155
|
+
*
|
|
156
|
+
* One call now, where it used to be a `selectionStart` splice, a `setSql` and
|
|
157
|
+
* a `requestAnimationFrame` to put the caret back — the editor owns its
|
|
158
|
+
* document, so the insert goes THROUGH it and lands on its undo stack.
|
|
159
|
+
* Ctrl+Z takes an inserted table name back out again, which the splice
|
|
160
|
+
* version could not do: React rewrote the whole value and the browser's undo
|
|
161
|
+
* stack lost its boundary. The `setSql` still happens, via `onChange`.
|
|
162
|
+
*/
|
|
153
163
|
function insert(text) {
|
|
154
164
|
const editor = editorRef.current;
|
|
155
165
|
if (!editor) {
|
|
156
166
|
setSql((current) => `${current}${text}`);
|
|
157
167
|
return;
|
|
158
168
|
}
|
|
159
|
-
|
|
160
|
-
const end = editor.selectionEnd;
|
|
161
|
-
setSql((current) => current.slice(0, start) + text + current.slice(end));
|
|
162
|
-
requestAnimationFrame(() => {
|
|
163
|
-
editor.focus();
|
|
164
|
-
editor.selectionStart = editor.selectionEnd = start + text.length;
|
|
165
|
-
});
|
|
169
|
+
editor.insertAtCursor(text);
|
|
166
170
|
}
|
|
167
171
|
function onEditorKeyDown(event) {
|
|
168
172
|
// Cmd/Ctrl+Enter runs, the way every SQL console does.
|
|
@@ -171,10 +175,14 @@ export function QueryConsole({ onGenerate, maxRows = 500, savedQueryId, onSavedQ
|
|
|
171
175
|
run.mutate();
|
|
172
176
|
}
|
|
173
177
|
// A textarea that eats Tab is a textarea nobody can leave by keyboard, so
|
|
174
|
-
// Tab
|
|
178
|
+
// Tab is the editor's own now — it indents rather than moving focus, which
|
|
179
|
+
// is why `CodeEditor` puts an Escape hatch in front of it. And ⌘↵ has to be
|
|
180
|
+
// claimed here rather than merely observed: the editor's default keymap
|
|
181
|
+
// binds it to "insert a blank line", so a handler that did not
|
|
182
|
+
// `preventDefault` would run the query AND leave a blank line behind.
|
|
175
183
|
}
|
|
176
184
|
const error = run.error instanceof Error ? run.error.message : null;
|
|
177
|
-
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, openId: openedId, onLoad: open })] }), _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'] }))] }), missingId && _jsx(MissingSavedQuery, { id: missingId }), 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,
|
|
185
|
+
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, openId: openedId, onLoad: open })] }), _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'] }))] }), missingId && _jsx(MissingSavedQuery, { id: missingId }), 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, editorRef: 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." }))] })] })] }) }));
|
|
178
186
|
}
|
|
179
187
|
/**
|
|
180
188
|
* What a link naming a query that is not here gets to say.
|
|
@@ -198,18 +206,18 @@ function RelationRow({ relation, onInsert, }) {
|
|
|
198
206
|
return (_jsxs("div", { children: [_jsxs("div", { className: "flex items-center", children: [_jsx(Tooltip, { content: relation.description, side: "right", children: _jsxs("button", { type: "button", onClick: () => onInsert(relation.name), className: cn('flex min-w-0 flex-1 items-center gap-1.5 rounded-md px-2 py-1 text-left', 'hover:bg-zinc-50 dark:hover:bg-zinc-800'), children: [_jsx(Icon, { size: 12, className: relation.kind === 'current' ? 'text-emerald-600' : 'text-amber-600' }), _jsx("span", { className: "truncate font-mono text-[11px]", children: relation.name })] }) }), _jsx("button", { type: "button", onClick: () => setOpen((o) => !o), "aria-label": `${open ? 'Hide' : 'Show'} columns of ${relation.name}`, className: cn('rounded-sm px-1 py-1 text-[10px]', MUTED), children: _jsx(Layers, { size: 11 }) })] }), open && (_jsx("div", { className: "ml-4 border-l border-zinc-100 pl-2 dark:border-zinc-800", children: relation.columns.map((column) => (_jsxs("button", { type: "button", onClick: () => onInsert(column.name), className: "flex w-full items-baseline justify-between gap-2 rounded-sm px-1 py-0.5 text-left hover:bg-zinc-50 dark:hover:bg-zinc-800", children: [_jsx("span", { className: "truncate font-mono text-[10px]", children: column.name }), _jsx("span", { className: cn('font-mono text-[9px] uppercase', MUTED), children: column.type })] }, column.name))) }))] }));
|
|
199
207
|
}
|
|
200
208
|
/**
|
|
201
|
-
*
|
|
209
|
+
* The SQL box.
|
|
202
210
|
*
|
|
203
|
-
*
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
*
|
|
211
|
+
* One `CodeEditor`, which is the same component the transform editor and the
|
|
212
|
+
* workflow canvas's code sheet render — there is deliberately no second
|
|
213
|
+
* implementation for "the primary input". What differs between the callers is
|
|
214
|
+
* the box it sits in, and that is a class name.
|
|
207
215
|
*/
|
|
208
|
-
function SqlEditor({ value, onChange, onKeyDown,
|
|
209
|
-
return (_jsx(CodeEditor, { value: value, onChange: onChange, onKeyDown: onKeyDown,
|
|
216
|
+
function SqlEditor({ value, onChange, onKeyDown, editorRef, }) {
|
|
217
|
+
return (_jsx(CodeEditor, { value: value, onChange: onChange, onKeyDown: onKeyDown, handleRef: editorRef, language: "sql", label: "SQL query",
|
|
210
218
|
// Roomier than the transform pane: this is the screen's primary input,
|
|
211
219
|
// not a side panel.
|
|
212
|
-
className: cn('h-56 shrink-0 border-b', RULE, PANEL)
|
|
220
|
+
className: cn('h-56 shrink-0 border-b', RULE, PANEL) }));
|
|
213
221
|
}
|
|
214
222
|
function ResultTable({ result }) {
|
|
215
223
|
// Built from the answer, because the answer decides them: a free SQL query
|
package/dist/SavedQueryPanel.js
CHANGED
|
@@ -127,5 +127,5 @@ export function SavedQueryPanel({ currentSql, openId, onLoad, }) {
|
|
|
127
127
|
: 'hover:bg-zinc-50 dark:hover:bg-zinc-800'), children: [query.name, query.cacheTtlSeconds > 0 && (_jsxs("span", { className: cn('ml-1 font-mono text-[9px]', MUTED), children: [query.cacheTtlSeconds, "s"] }))] }) }), query.shared && _jsx(ShareBadge, { shared: true, className: "mr-1" }), _jsx(ShareControl, { layout: "row", kind: "query", shared: query.shared, pending: share.isPending, name: query.name, onChange: (shared) => share.mutate({ id: query.id, shared }), className: cn('opacity-0 group-hover:opacity-100 focus-visible:opacity-100', MUTED) }), _jsx(Tooltip, { content: "Every SQL this query has been, and what changed between two of them", children: _jsx("button", { type: "button", onClick: () => setHistory(query), className: cn('rounded-sm p-1 opacity-0 group-hover:opacity-100 focus-visible:opacity-100', MUTED), "aria-label": `History of ${query.name}`, children: _jsx(History, { size: 11 }) }) }), _jsx(Tooltip, { content: "Download as CSV", children: _jsx("a", { href: client.exportUrl(query.id), className: cn('rounded-sm p-1 opacity-0 group-hover:opacity-100', MUTED), "aria-label": `Export ${query.name}`, children: _jsx(Download, { size: 11 }) }) }), _jsx("button", { type: "button", onClick: () => remove.mutate(query.id), className: cn('rounded-sm p-1 opacity-0 group-hover:opacity-100 hover:text-red-600', MUTED), "aria-label": `Delete ${query.name}`, children: _jsx(Trash2, { size: 11 }) })] }, query.id)))] }, folder))), share.error !== null && (_jsx("p", { className: "px-2 py-1 text-[11px] text-red-600", children: share.error instanceof Error ? share.error.message : 'Could not change sharing.' }))] }), history && (_jsx(RevisionHistorySheet, { open: true, onOpenChange: (open) => {
|
|
128
128
|
if (!open)
|
|
129
129
|
setHistory(null);
|
|
130
|
-
}, subject: { kind: 'saved-query', id: history.id, name: history.name } }))] }));
|
|
130
|
+
}, subject: { kind: 'saved-query', id: history.id, name: history.name }, ...(history.id === openId ? { buffer: { body: currentSql } } : {}) }))] }));
|
|
131
131
|
}
|
package/dist/TransformEditor.js
CHANGED
|
@@ -2,11 +2,12 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
2
2
|
import { isTransformLanguage } from '@dudousxd/nestjs-catalog/client';
|
|
3
3
|
import { useMutation } from '@tanstack/react-query';
|
|
4
4
|
import { ArrowLeft, Play } from 'lucide-react';
|
|
5
|
-
import {
|
|
5
|
+
import { useState } from 'react';
|
|
6
6
|
import { cn } from './cn';
|
|
7
7
|
import { useCatalogClient } from './context';
|
|
8
8
|
import { RevisionHistoryButton, RevisionHistorySheet } from './diff/RevisionDiff';
|
|
9
9
|
import { CodeEditor } from './ui/code-editor';
|
|
10
|
+
import { TRANSFORM_HIGHLIGHTED_AS } from './ui/code-languages';
|
|
10
11
|
import { TextField } from './ui/field';
|
|
11
12
|
import { SelectField } from './ui/select';
|
|
12
13
|
const MUTED = 'text-zinc-400 dark:text-zinc-500';
|
|
@@ -91,7 +92,6 @@ export function TransformEditor({ transform, languages, pythonPackages = [], onC
|
|
|
91
92
|
const [code, setCode] = useState(transform?.code ?? STARTERS[transform?.language ?? 'javascript']);
|
|
92
93
|
const [sample, setSample] = useState(SAMPLE);
|
|
93
94
|
const [historyOpen, setHistoryOpen] = useState(false);
|
|
94
|
-
const editorRef = useRef(null);
|
|
95
95
|
const tryIt = useMutation({
|
|
96
96
|
mutationFn: () => {
|
|
97
97
|
let records;
|
|
@@ -118,6 +118,10 @@ export function TransformEditor({ transform, languages, pythonPackages = [], onC
|
|
|
118
118
|
}),
|
|
119
119
|
onSuccess: onSaved,
|
|
120
120
|
});
|
|
121
|
+
// `preventDefault` is what claims the key. The editor's default keymap binds
|
|
122
|
+
// ⌘↵ to "insert a blank line", and `CodeEditor` only withholds a keystroke
|
|
123
|
+
// from it when the host has said it wants it — so without this, trying the
|
|
124
|
+
// transform would also leave a blank line in the code being tried.
|
|
121
125
|
function onKeyDown(event) {
|
|
122
126
|
if ((event.metaKey || event.ctrlKey) && event.key === 'Enter') {
|
|
123
127
|
event.preventDefault();
|
|
@@ -140,7 +144,12 @@ export function TransformEditor({ transform, languages, pythonPackages = [], onC
|
|
|
140
144
|
label: option,
|
|
141
145
|
})) })] }), _jsxs("div", { className: "grid gap-3 lg:grid-cols-2", children: [_jsxs("div", { className: cn('overflow-hidden rounded-lg border', RULE, PANEL), children: [_jsxs("div", { className: cn('flex items-center justify-between border-b px-3 py-1.5', RULE), children: [_jsx("span", { className: cn('font-mono text-[10px] uppercase tracking-[0.14em]', MUTED), children: "Code" }), _jsx("span", { className: cn('font-mono text-[10px]', MUTED), children: language === 'python' && pythonPackages.length > 0
|
|
142
146
|
? `imports: ${pythonPackages.join(', ')}`
|
|
143
|
-
: '⌘↵ to try' })] }), _jsx(CodeEditor, { value: code, onChange: setCode, onKeyDown: onKeyDown,
|
|
147
|
+
: '⌘↵ to try' })] }), _jsx(CodeEditor, { value: code, onChange: setCode, onKeyDown: onKeyDown,
|
|
148
|
+
// A table rather than the `language === 'python' ? 'python' : 'tsx'`
|
|
149
|
+
// that used to be here. The ternary answered a fourth transform
|
|
150
|
+
// language with `tsx` — silently, and wrongly — where the table
|
|
151
|
+
// cannot be indexed by one at all until somebody adds the row.
|
|
152
|
+
language: TRANSFORM_HIGHLIGHTED_AS[language], label: "Transform code", className: "h-72" })] }), _jsxs("div", { className: "space-y-3", children: [_jsxs("div", { className: cn('overflow-hidden rounded-lg border', RULE, PANEL), children: [_jsx("div", { className: cn('border-b px-3 py-1.5', RULE), children: _jsx("span", { className: cn('font-mono text-[10px] uppercase tracking-[0.14em]', MUTED), children: "Sample records" }) }), _jsx(CodeEditor, { value: sample, onChange: setSample, language: "json", label: "Sample records", className: "h-32" })] }), _jsxs("button", { type: "button", onClick: () => tryIt.mutate(), disabled: tryIt.isPending, className: "flex items-center gap-1.5 rounded-md bg-zinc-950 px-3 py-1.5 text-xs text-zinc-50 disabled:opacity-40 dark:bg-zinc-100 dark:text-zinc-950", children: [_jsx(Play, { size: 12 }), tryIt.isPending ? 'Running…' : 'Try it'] }), _jsxs("div", { className: cn('overflow-hidden rounded-lg border', RULE, PANEL), children: [_jsx("div", { className: cn('border-b px-3 py-1.5', RULE), children: _jsx("span", { className: cn('font-mono text-[10px] uppercase tracking-[0.14em]', MUTED), children: "Output" }) }), _jsx(TryOutput, { result: tryIt.data, error: tryIt.error })] })] })] }), _jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsx(SaveBar, { transform: transform, nameIsEmpty: name.trim().length === 0, pending: save.isPending, error: save.error, onSave: () => save.mutate() }), transform && (_jsx(RevisionHistoryButton, { className: "ml-auto", onClick: () => setHistoryOpen(true) }))] }), transform && (_jsx(RevisionHistorySheet, { open: historyOpen, onOpenChange: setHistoryOpen, subject: { kind: 'transform', id: transform.id, name: transform.name },
|
|
144
153
|
// The SAVED code, not what is in the editor above. A history is what
|
|
145
154
|
// this catalog has recorded; comparing against an unsaved buffer would
|
|
146
155
|
// put a version number on text that exists only in one browser tab,
|