@dudousxd/nestjs-catalog-react 0.17.0 → 0.19.0-preview.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/CatalogManager.d.ts +23 -1
- package/dist/CatalogManager.js +76 -13
- package/dist/ConnectionPanel.d.ts +11 -7
- package/dist/ConnectionPanel.js +78 -149
- package/dist/LoadedBySection.d.ts +39 -0
- package/dist/LoadedBySection.js +143 -0
- package/dist/PipelineConsole.d.ts +23 -126
- package/dist/PipelineConsole.js +39 -551
- package/dist/WorkflowCanvas.d.ts +16 -0
- package/dist/WorkflowCanvas.js +1064 -64
- package/dist/connection-form.d.ts +241 -0
- package/dist/connection-form.js +235 -0
- package/dist/context.d.ts +236 -38
- package/dist/context.js +46 -11
- package/dist/index.d.ts +10 -3
- package/dist/index.js +63 -14
- package/dist/routes.d.ts +84 -13
- package/dist/routes.js +7 -4
- package/dist/schema-discovery.d.ts +232 -0
- package/dist/schema-discovery.js +225 -0
- package/dist/source-connection.d.ts +82 -0
- package/dist/source-connection.js +176 -0
- package/dist/source-fields.d.ts +16 -14
- package/dist/source-fields.js +28 -18
- package/dist/ui/code-editor.d.ts +44 -2
- package/dist/ui/code-editor.js +10 -2
- package/dist/ui/combobox.d.ts +97 -0
- package/dist/ui/combobox.js +80 -0
- package/dist/ui/dialog.d.ts +13 -1
- package/dist/ui/dialog.js +13 -2
- package/dist/workflow/edges.d.ts +110 -0
- package/dist/workflow/edges.js +112 -0
- package/dist/workflow/graph.d.ts +39 -1
- package/dist/workflow/graph.js +212 -52
- package/dist/workflow/index.d.ts +8 -0
- package/dist/workflow/index.js +12 -0
- package/dist/workflow/lifecycle.d.ts +135 -0
- package/dist/workflow/lifecycle.js +216 -0
- package/dist/workflow/model.d.ts +17 -3
- package/dist/workflow/model.js +7 -2
- package/dist/workflow/nodes.d.ts +4 -1
- package/dist/workflow/nodes.js +198 -10
- 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 +1102 -0
- package/dist/workflow/validate.d.ts +20 -1
- package/dist/workflow/validate.js +52 -3
- package/dist/workflow/wiring.d.ts +84 -0
- package/dist/workflow/wiring.js +254 -0
- package/package.json +9 -9
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { CatalogConnection } from '@dudousxd/nestjs-catalog/client';
|
|
2
|
+
import { type ConnectableKind } from './connection-form';
|
|
3
|
+
/**
|
|
4
|
+
* Making the address a source reads through, without leaving the canvas.
|
|
5
|
+
*
|
|
6
|
+
* THE HALF THAT WAS MISSING
|
|
7
|
+
* -------------------------
|
|
8
|
+
* The sink node can already create the thing it needs: the schema-discovery
|
|
9
|
+
* panel turns confirmed columns into an object type, on a draft, without going
|
|
10
|
+
* anywhere. The source node could only ever *choose* an address. With no
|
|
11
|
+
* connection of the right kind, the picker above this said so and stopped —
|
|
12
|
+
* leave the graph, open the Connections tab, make one, come back, find the node
|
|
13
|
+
* again. Everything in between is where a train of thought goes to die.
|
|
14
|
+
*
|
|
15
|
+
* WHY THIS IS NOT AN ORDINARY "QUICK ADD"
|
|
16
|
+
* ---------------------------------------
|
|
17
|
+
* A connection is the credential and the address boundary. Every protection the
|
|
18
|
+
* Connections screen has, it has for a reason somebody learned, and an inline
|
|
19
|
+
* form that dropped any of them would be the place a password gets pasted into
|
|
20
|
+
* what looks like an ordinary field. So, in full:
|
|
21
|
+
*
|
|
22
|
+
* - **The fields are the Connections screen's fields**, from
|
|
23
|
+
* `connection-form.tsx`, per kind and derived from `CONNECTOR_KINDS`. Not a
|
|
24
|
+
* reduced set: a "quick" form that omitted the credential variable would
|
|
25
|
+
* teach people to put the credential in the URL.
|
|
26
|
+
* - **Test before save.** `POST pipeline/connections/check` reaches an address
|
|
27
|
+
* that has not been stored, which exists precisely because the field most
|
|
28
|
+
* likely to be wrong is the one nobody can verify by reading it — and because
|
|
29
|
+
* a connection saved to discover a typo is a row somebody has to remember to
|
|
30
|
+
* delete. A failed check comes back with the password, the query string and
|
|
31
|
+
* the fragment removed and the host and the user kept, which is what makes it
|
|
32
|
+
* worth showing at all.
|
|
33
|
+
* - **The refusal is surfaced, never worked around.** A deployment with
|
|
34
|
+
* `allowInlineCredentials` off refuses a URL carrying a password, and its
|
|
35
|
+
* message names the field to use instead. It is printed here verbatim. This
|
|
36
|
+
* form has no way of its own around it and must not grow one: the flag is a
|
|
37
|
+
* property of the deployment — of which database these rows land in — and a
|
|
38
|
+
* console that quietly re-routed the credential somewhere else would be
|
|
39
|
+
* answering a question nobody asked it.
|
|
40
|
+
* - **The placeholder is never sent as a secret.** See
|
|
41
|
+
* {@link redactedCredentialIn}. This form creates, so there is no stored row
|
|
42
|
+
* behind what it posts and nothing on the server to restore the real
|
|
43
|
+
* credential from — a pasted `REDACTED` would simply become the password.
|
|
44
|
+
*
|
|
45
|
+
* WHAT IT DOES TO THE DRAFT, DECIDED RATHER THAN DEFAULTED
|
|
46
|
+
* --------------------------------------------------------
|
|
47
|
+
* The new connection is selected onto the node immediately. Creating one from a
|
|
48
|
+
* node and then not attaching it is the same trip to another screen, only
|
|
49
|
+
* shorter: the picker directly above would list the connection somebody had just
|
|
50
|
+
* made from this node, still saying the node reads through none of them.
|
|
51
|
+
*
|
|
52
|
+
* That selection is a real edit to the graph, so it marks the draft dirty, and
|
|
53
|
+
* it does so through the inspector's own `push` rather than through any path of
|
|
54
|
+
* its own. Nothing here is special-cased: typing a URL into the very same node
|
|
55
|
+
* dirties it identically. It matters because `dirty` is what disables schema
|
|
56
|
+
* discovery lower down the same panel, and the complaint on record about that
|
|
57
|
+
* message is that it names saving without offering it. So the confirmation below
|
|
58
|
+
* says what happened *and* what it costs, in one breath, rather than leaving
|
|
59
|
+
* somebody to infer it from a control that has gone quiet. What it must not do
|
|
60
|
+
* is pretend the graph is unchanged — a selection that did not dirty the draft
|
|
61
|
+
* is a selection lost on the next reload.
|
|
62
|
+
*/
|
|
63
|
+
export declare function SourceConnectionCreator({ kind, canEdit, hasOptions, onCreated, }: {
|
|
64
|
+
/**
|
|
65
|
+
* The source node's own kind, which is what decides the fields.
|
|
66
|
+
*
|
|
67
|
+
* Not asked again on this form. A second kind dropdown could disagree with the
|
|
68
|
+
* node it is standing in, and the connection it produced would then be
|
|
69
|
+
* invisible in the picker above — filtered out for being the wrong kind by a
|
|
70
|
+
* screen that had just offered to make it.
|
|
71
|
+
*
|
|
72
|
+
* {@link ConnectableKind} rather than `ConnectorKind`, and that narrowing is
|
|
73
|
+
* `usesConnection`'s: a file path and pasted records belong to the load, so
|
|
74
|
+
* there is no shared address to make.
|
|
75
|
+
*/
|
|
76
|
+
kind: ConnectableKind;
|
|
77
|
+
canEdit: boolean;
|
|
78
|
+
/** Whether the picker above has anything in it. Changes the wording only. */
|
|
79
|
+
hasOptions: boolean;
|
|
80
|
+
/** Attach it to the node. The caller decides what that does to the draft. */
|
|
81
|
+
onCreated: (connection: CatalogConnection) => void;
|
|
82
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
3
|
+
import { Loader2, Plug, Plus } from 'lucide-react';
|
|
4
|
+
import { useState } from 'react';
|
|
5
|
+
import { cn } from './cn';
|
|
6
|
+
import { ConnectionCheckResult, ConnectionKindFields, connectableSpec, connectionConfigFor, connectionDraftFrom, connectionIsIncomplete, redactedCredentialIn, } from './connection-form';
|
|
7
|
+
import { catalogQueryKeys, useCatalogClient } from './context';
|
|
8
|
+
import { Button } from './ui/button';
|
|
9
|
+
import { TextField } from './ui/field';
|
|
10
|
+
import { WORKFLOW_NAME } from './workflow/name';
|
|
11
|
+
const MUTED = 'text-zinc-400 dark:text-zinc-500';
|
|
12
|
+
const RULE = 'border-zinc-200 dark:border-zinc-800';
|
|
13
|
+
const REFUSAL = 'text-[11px] leading-relaxed text-red-600 dark:text-red-400';
|
|
14
|
+
/**
|
|
15
|
+
* Making the address a source reads through, without leaving the canvas.
|
|
16
|
+
*
|
|
17
|
+
* THE HALF THAT WAS MISSING
|
|
18
|
+
* -------------------------
|
|
19
|
+
* The sink node can already create the thing it needs: the schema-discovery
|
|
20
|
+
* panel turns confirmed columns into an object type, on a draft, without going
|
|
21
|
+
* anywhere. The source node could only ever *choose* an address. With no
|
|
22
|
+
* connection of the right kind, the picker above this said so and stopped —
|
|
23
|
+
* leave the graph, open the Connections tab, make one, come back, find the node
|
|
24
|
+
* again. Everything in between is where a train of thought goes to die.
|
|
25
|
+
*
|
|
26
|
+
* WHY THIS IS NOT AN ORDINARY "QUICK ADD"
|
|
27
|
+
* ---------------------------------------
|
|
28
|
+
* A connection is the credential and the address boundary. Every protection the
|
|
29
|
+
* Connections screen has, it has for a reason somebody learned, and an inline
|
|
30
|
+
* form that dropped any of them would be the place a password gets pasted into
|
|
31
|
+
* what looks like an ordinary field. So, in full:
|
|
32
|
+
*
|
|
33
|
+
* - **The fields are the Connections screen's fields**, from
|
|
34
|
+
* `connection-form.tsx`, per kind and derived from `CONNECTOR_KINDS`. Not a
|
|
35
|
+
* reduced set: a "quick" form that omitted the credential variable would
|
|
36
|
+
* teach people to put the credential in the URL.
|
|
37
|
+
* - **Test before save.** `POST pipeline/connections/check` reaches an address
|
|
38
|
+
* that has not been stored, which exists precisely because the field most
|
|
39
|
+
* likely to be wrong is the one nobody can verify by reading it — and because
|
|
40
|
+
* a connection saved to discover a typo is a row somebody has to remember to
|
|
41
|
+
* delete. A failed check comes back with the password, the query string and
|
|
42
|
+
* the fragment removed and the host and the user kept, which is what makes it
|
|
43
|
+
* worth showing at all.
|
|
44
|
+
* - **The refusal is surfaced, never worked around.** A deployment with
|
|
45
|
+
* `allowInlineCredentials` off refuses a URL carrying a password, and its
|
|
46
|
+
* message names the field to use instead. It is printed here verbatim. This
|
|
47
|
+
* form has no way of its own around it and must not grow one: the flag is a
|
|
48
|
+
* property of the deployment — of which database these rows land in — and a
|
|
49
|
+
* console that quietly re-routed the credential somewhere else would be
|
|
50
|
+
* answering a question nobody asked it.
|
|
51
|
+
* - **The placeholder is never sent as a secret.** See
|
|
52
|
+
* {@link redactedCredentialIn}. This form creates, so there is no stored row
|
|
53
|
+
* behind what it posts and nothing on the server to restore the real
|
|
54
|
+
* credential from — a pasted `REDACTED` would simply become the password.
|
|
55
|
+
*
|
|
56
|
+
* WHAT IT DOES TO THE DRAFT, DECIDED RATHER THAN DEFAULTED
|
|
57
|
+
* --------------------------------------------------------
|
|
58
|
+
* The new connection is selected onto the node immediately. Creating one from a
|
|
59
|
+
* node and then not attaching it is the same trip to another screen, only
|
|
60
|
+
* shorter: the picker directly above would list the connection somebody had just
|
|
61
|
+
* made from this node, still saying the node reads through none of them.
|
|
62
|
+
*
|
|
63
|
+
* That selection is a real edit to the graph, so it marks the draft dirty, and
|
|
64
|
+
* it does so through the inspector's own `push` rather than through any path of
|
|
65
|
+
* its own. Nothing here is special-cased: typing a URL into the very same node
|
|
66
|
+
* dirties it identically. It matters because `dirty` is what disables schema
|
|
67
|
+
* discovery lower down the same panel, and the complaint on record about that
|
|
68
|
+
* message is that it names saving without offering it. So the confirmation below
|
|
69
|
+
* says what happened *and* what it costs, in one breath, rather than leaving
|
|
70
|
+
* somebody to infer it from a control that has gone quiet. What it must not do
|
|
71
|
+
* is pretend the graph is unchanged — a selection that did not dirty the draft
|
|
72
|
+
* is a selection lost on the next reload.
|
|
73
|
+
*/
|
|
74
|
+
export function SourceConnectionCreator({ kind, canEdit, hasOptions, onCreated, }) {
|
|
75
|
+
const [open, setOpen] = useState(false);
|
|
76
|
+
/**
|
|
77
|
+
* The last one made here, kept after the form closes.
|
|
78
|
+
*
|
|
79
|
+
* The note it carries is the only place the cost of the selection is stated,
|
|
80
|
+
* and the form it was made on is gone by then.
|
|
81
|
+
*/
|
|
82
|
+
const [created, setCreated] = useState(null);
|
|
83
|
+
if (!canEdit)
|
|
84
|
+
return null;
|
|
85
|
+
if (open) {
|
|
86
|
+
return (_jsx(InlineConnectionForm, { kind: kind, onCancel: () => setOpen(false), onSaved: (connection) => {
|
|
87
|
+
setCreated(connection);
|
|
88
|
+
setOpen(false);
|
|
89
|
+
onCreated(connection);
|
|
90
|
+
} }));
|
|
91
|
+
}
|
|
92
|
+
return (_jsxs("div", { className: "space-y-2", children: [_jsxs(Button, { variant: "outline", size: "sm", onClick: () => setOpen(true), children: [_jsx(Plus, { size: 12 }), hasOptions ? 'New connection' : `Make the first ${kind} connection`] }), created && (_jsxs("p", { className: cn('text-[11px] leading-relaxed', MUTED), children: [_jsxs("span", { className: "font-medium text-emerald-700 dark:text-emerald-400", children: ["\"", created.name, "\" was created"] }), ' ', "and this node reads through it. That is a change to the graph like any other, so this", ' ', WORKFLOW_NAME.singular, " now has unsaved edits \u2014 save it before asking the source what columns it has, since discovery reads the stored node."] }))] }));
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* The form itself: a name, the kind's address fields, a test and a save.
|
|
96
|
+
*
|
|
97
|
+
* Its own component so the disclosure above stays a disclosure. It also gives
|
|
98
|
+
* the draft the right lifetime — cancelling unmounts this, so a half-typed
|
|
99
|
+
* password does not sit in memory behind a collapsed button waiting to be
|
|
100
|
+
* reopened and saved by somebody who has forgotten what is in it.
|
|
101
|
+
*/
|
|
102
|
+
function InlineConnectionForm({ kind, onCancel, onSaved, }) {
|
|
103
|
+
const client = useCatalogClient();
|
|
104
|
+
const queryClient = useQueryClient();
|
|
105
|
+
const [draft, setDraft] = useState(() => connectionDraftFrom());
|
|
106
|
+
/**
|
|
107
|
+
* A refusal this form made itself, before anything was sent.
|
|
108
|
+
*
|
|
109
|
+
* Separate state from `save.error` because it is not a failed request —
|
|
110
|
+
* nothing was posted. Folding the two together would give a sentence about
|
|
111
|
+
* what somebody pasted the wording of a server that might be worth retrying.
|
|
112
|
+
*/
|
|
113
|
+
const [refusal, setRefusal] = useState(null);
|
|
114
|
+
const config = connectionConfigFor(kind, draft);
|
|
115
|
+
const input = () => ({
|
|
116
|
+
// No `id`, and that absence is load-bearing: the server restores a stored
|
|
117
|
+
// credential where a caller posted back the redaction of one, and it can
|
|
118
|
+
// only do that for a connection it can look up. A create has none, so what
|
|
119
|
+
// is typed here is exactly what is reached and exactly what is stored.
|
|
120
|
+
name: draft.name.trim(),
|
|
121
|
+
description: draft.description.trim() || undefined,
|
|
122
|
+
kind,
|
|
123
|
+
config,
|
|
124
|
+
secretEnvVar: draft.secretEnvVar.trim() || undefined,
|
|
125
|
+
});
|
|
126
|
+
const check = useMutation({
|
|
127
|
+
mutationFn: () => client.checkUnsavedConnection(input()),
|
|
128
|
+
});
|
|
129
|
+
const save = useMutation({
|
|
130
|
+
mutationFn: () => client.saveConnection(input()),
|
|
131
|
+
onSuccess: (connection) => {
|
|
132
|
+
// Written into the cache as well as invalidated, for the same reason the
|
|
133
|
+
// canvas does it after creating a transform: the picker above resolves its
|
|
134
|
+
// options out of this list, and selecting an id that is not in it yet
|
|
135
|
+
// shows "Configure the address here" for one render — telling somebody the
|
|
136
|
+
// node uses no connection immediately after they made one.
|
|
137
|
+
queryClient.setQueryData(catalogQueryKeys.connections, (current) => [
|
|
138
|
+
...(current ?? []),
|
|
139
|
+
connection,
|
|
140
|
+
]);
|
|
141
|
+
queryClient.invalidateQueries({ queryKey: catalogQueryKeys.connections });
|
|
142
|
+
onSaved(connection);
|
|
143
|
+
},
|
|
144
|
+
});
|
|
145
|
+
const update = (patch) => {
|
|
146
|
+
setDraft({ ...draft, ...patch });
|
|
147
|
+
// Whatever was refused or reached was about the address as it was. Leaving
|
|
148
|
+
// either beside an edited field is how a green tick comes to be read as
|
|
149
|
+
// covering a URL nobody has tested.
|
|
150
|
+
setRefusal(null);
|
|
151
|
+
check.reset();
|
|
152
|
+
};
|
|
153
|
+
const attempt = () => {
|
|
154
|
+
const placeholder = redactedCredentialIn(config);
|
|
155
|
+
if (placeholder) {
|
|
156
|
+
setRefusal(`The ${placeholder} you pasted has "REDACTED" where its password goes. That is what this catalog shows in place of a stored password, not the password itself — saving it would store the word. Paste the address with the real credential, or name the environment variable that holds it.`);
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
setRefusal(null);
|
|
160
|
+
save.mutate();
|
|
161
|
+
};
|
|
162
|
+
return (
|
|
163
|
+
// A fieldset with a legend, and it earns both rather than decorating them.
|
|
164
|
+
// This form stands inside the source inspector, which already has a "Name"
|
|
165
|
+
// field of its own and — while the node carries its own address — a "URL" as
|
|
166
|
+
// well. The labels here are deliberately the Connections screen's labels,
|
|
167
|
+
// because there is one answer to what an HTTP connection needs; what stops
|
|
168
|
+
// the two "URL"s from reading as the same question is that this one sits
|
|
169
|
+
// inside something named, for a screen reader as much as for a reader.
|
|
170
|
+
_jsxs("fieldset", { className: cn('space-y-3 rounded-md border p-3', RULE), children: [_jsxs("legend", { className: cn('px-1 font-mono text-[10px] uppercase tracking-[0.14em]', MUTED), children: ["New ", kind, " connection"] }), _jsxs("p", { className: cn('text-[11px] leading-relaxed', MUTED), children: ["A ", kind, " connection, made here and used by this node. It is an object of its own once it is saved \u2014 other sources can read through it, and moving the address later moves all of them at once, which is the point of naming it."] }), _jsxs("div", { className: "grid gap-3 sm:grid-cols-2", children: [_jsx(TextField, { label: "Name", value: draft.name, onChange: (name) => update({ name }), placeholder: "Fleet warehouse", hint: "What the picker above will call it." }), _jsx(TextField, { label: "Description", value: draft.description, onChange: (description) => update({ description }), placeholder: "What lives behind it (optional)" })] }), _jsx(ConnectionKindFields, { kind: kind, draft: draft, update: update }), _jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsxs(Button, { variant: "outline", size: "sm", onClick: () => check.mutate(),
|
|
171
|
+
// The ADDRESS has to be there; the name does not. Testing is about
|
|
172
|
+
// whether the host answers, and refusing to reach it until a box that
|
|
173
|
+
// has nothing to do with reaching it is filled in is how a check that
|
|
174
|
+
// costs nothing goes unpressed.
|
|
175
|
+
disabled: check.isPending || connectableSpec(kind).isIncomplete(draft), children: [check.isPending ? _jsx(Loader2, { size: 12, className: "animate-spin" }) : _jsx(Plug, { size: 12 }), check.isPending ? 'Reaching…' : 'Test connection'] }), _jsx(Button, { size: "sm", onClick: attempt, disabled: save.isPending || connectionIsIncomplete(kind, draft), children: save.isPending ? 'Saving…' : 'Save and use it' }), _jsx(Button, { variant: "ghost", size: "sm", onClick: onCancel, children: "Cancel" })] }), _jsx("p", { className: cn('text-[11px] leading-relaxed', MUTED), children: "Testing reaches the address and stores nothing. Writing a row proves nothing about whether the host behind it answers, and finding that out afterwards means a load failing on a schedule hours later." }), check.data && _jsx(ConnectionCheckResult, { result: check.data }), check.error && !check.data && (_jsx("p", { className: REFUSAL, children: check.error instanceof Error ? check.error.message : 'The check itself failed.' })), refusal && _jsx("p", { className: REFUSAL, children: refusal }), save.error && !refusal && (_jsx("p", { className: REFUSAL, children: save.error instanceof Error ? save.error.message : 'It could not be saved.' }))] }));
|
|
176
|
+
}
|
package/dist/source-fields.d.ts
CHANGED
|
@@ -1,10 +1,23 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ConnectorKind } from '@dudousxd/nestjs-catalog/client';
|
|
2
|
+
import { type ConnectableKind } from './connection-form';
|
|
2
3
|
/** A select hands back a string. Narrow it rather than promise it is a kind. */
|
|
3
4
|
export declare function toConnectorKind(value: string): ConnectorKind;
|
|
4
5
|
/** The sources that can be asked what changed. The rest always read it all. */
|
|
5
6
|
export declare function readsIncrementally(kind: ConnectorKind): boolean;
|
|
6
|
-
/**
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Which kinds can borrow an address from a named connection.
|
|
9
|
+
*
|
|
10
|
+
* Asked of `connection-form.tsx` rather than answered here with a list of
|
|
11
|
+
* three, because that module now has to answer the same question to decide
|
|
12
|
+
* whether it can offer to CREATE one — and two lists is how a picker comes to be
|
|
13
|
+
* offered for a kind whose form has no fields, or withheld for one that does.
|
|
14
|
+
*
|
|
15
|
+
* A type predicate, and that is what it is for: the source inspector renders the
|
|
16
|
+
* picker behind this call, and the creator beside it takes a {@link
|
|
17
|
+
* ConnectableKind}. Narrowing here is what makes those two the same decision
|
|
18
|
+
* rather than two that happen to agree today.
|
|
19
|
+
*/
|
|
20
|
+
export declare function usesConnection(kind: ConnectorKind): kind is ConnectableKind;
|
|
8
21
|
export declare const KIND_OPTIONS: {
|
|
9
22
|
value: string;
|
|
10
23
|
label: string;
|
|
@@ -68,17 +81,6 @@ export interface SourceConfigOptions {
|
|
|
68
81
|
* stale url on a SQL source, which reads as configuration somebody meant.
|
|
69
82
|
*/
|
|
70
83
|
export declare function sourceConfigFrom(kind: ConnectorKind, draft: SourceDraft, { viaConnection, incremental }: SourceConfigOptions): Record<string, unknown>;
|
|
71
|
-
/**
|
|
72
|
-
* Whether there is enough here to read anything at all.
|
|
73
|
-
*
|
|
74
|
-
* Only the fields without which there is nothing to attempt — a bucket cannot be
|
|
75
|
-
* defaulted the way a prefix can. Everything else is the server's to judge.
|
|
76
|
-
*/
|
|
77
|
-
export declare function sourceIsIncomplete(kind: ConnectorKind, draft: SourceDraft, viaConnection: boolean): boolean;
|
|
78
|
-
export declare function connectionOptions(kind: ConnectorKind, connections: CatalogConnection[]): {
|
|
79
|
-
value: string;
|
|
80
|
-
label: string;
|
|
81
|
-
}[];
|
|
82
84
|
/**
|
|
83
85
|
* The address fields for one kind.
|
|
84
86
|
*
|
package/dist/source-fields.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { CONNECTOR_KINDS } from '@dudousxd/nestjs-catalog/client';
|
|
3
3
|
import { cn } from './cn';
|
|
4
|
+
import { CONNECTION_KINDS } from './connection-form';
|
|
4
5
|
import { FieldGroup, TextAreaField, TextField } from './ui/field';
|
|
5
6
|
import { SelectField } from './ui/select';
|
|
6
7
|
import { Switch } from './ui/switch';
|
|
@@ -29,9 +30,21 @@ export function toConnectorKind(value) {
|
|
|
29
30
|
export function readsIncrementally(kind) {
|
|
30
31
|
return kind === 'sql' || kind === 's3';
|
|
31
32
|
}
|
|
32
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* Which kinds can borrow an address from a named connection.
|
|
35
|
+
*
|
|
36
|
+
* Asked of `connection-form.tsx` rather than answered here with a list of
|
|
37
|
+
* three, because that module now has to answer the same question to decide
|
|
38
|
+
* whether it can offer to CREATE one — and two lists is how a picker comes to be
|
|
39
|
+
* offered for a kind whose form has no fields, or withheld for one that does.
|
|
40
|
+
*
|
|
41
|
+
* A type predicate, and that is what it is for: the source inspector renders the
|
|
42
|
+
* picker behind this call, and the creator beside it takes a {@link
|
|
43
|
+
* ConnectableKind}. Narrowing here is what makes those two the same decision
|
|
44
|
+
* rather than two that happen to agree today.
|
|
45
|
+
*/
|
|
33
46
|
export function usesConnection(kind) {
|
|
34
|
-
return kind
|
|
47
|
+
return CONNECTION_KINDS[kind].connectable;
|
|
35
48
|
}
|
|
36
49
|
export const KIND_OPTIONS = [
|
|
37
50
|
{ value: 'http', label: 'HTTP — a JSON endpoint' },
|
|
@@ -162,24 +175,21 @@ export function sourceConfigFrom(kind, draft, { viaConnection, incremental }) {
|
|
|
162
175
|
return s3Config(draft, viaConnection);
|
|
163
176
|
return inlineConfig(draft);
|
|
164
177
|
}
|
|
165
|
-
|
|
166
|
-
*
|
|
178
|
+
/*
|
|
179
|
+
* `sourceIsIncomplete` and `connectionOptions` used to be here, and both went
|
|
180
|
+
* with the connector form that was their only caller.
|
|
181
|
+
*
|
|
182
|
+
* `sourceIsIncomplete` decided whether that form's Save button was pressable.
|
|
183
|
+
* A source node has no such gate and should not grow one: an unconfigured node
|
|
184
|
+
* is the normal state of a node somebody just added, `workflow/validate.ts`
|
|
185
|
+
* separates INCOMPLETE from WRONG for exactly that reason, and a second opinion
|
|
186
|
+
* held in this module would fire while the first is deliberately quiet.
|
|
167
187
|
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
188
|
+
* `connectionOptions` was the same filter as `connectionOptionsFor` in
|
|
189
|
+
* `ConnectionPanel.tsx` without the address hint. Two spellings of "connections
|
|
190
|
+
* of this kind" is how a rule ends up enforced on one screen; the one that is
|
|
191
|
+
* left is the one that can say which address it is offering.
|
|
170
192
|
*/
|
|
171
|
-
export function sourceIsIncomplete(kind, draft, viaConnection) {
|
|
172
|
-
if (kind === 's3' && !viaConnection)
|
|
173
|
-
return draft.bucket.trim().length === 0;
|
|
174
|
-
if (kind === 'http' && !viaConnection)
|
|
175
|
-
return draft.url.trim().length === 0;
|
|
176
|
-
return false;
|
|
177
|
-
}
|
|
178
|
-
export function connectionOptions(kind, connections) {
|
|
179
|
-
return connections
|
|
180
|
-
.filter((connection) => connection.kind === kind)
|
|
181
|
-
.map((connection) => ({ value: connection.id, label: connection.name }));
|
|
182
|
-
}
|
|
183
193
|
/**
|
|
184
194
|
* The address fields for one kind.
|
|
185
195
|
*
|
package/dist/ui/code-editor.d.ts
CHANGED
|
@@ -28,11 +28,51 @@ import { type CodeThemeType } from './code-theme';
|
|
|
28
28
|
* lines and a trailing newline; overlaid, their glyphs coincided to the pixel.
|
|
29
29
|
* Aligning them harder would have fixed nothing.
|
|
30
30
|
*
|
|
31
|
-
* So the fix is {@link
|
|
31
|
+
* So the fix is {@link codeOptions}'s `overflow: 'scroll'` — real horizontal
|
|
32
32
|
* scrolling, one visual row per line — plus the line numbers a gutter-less box
|
|
33
33
|
* could never draw. Scrolling code well needs a document model, and that is what
|
|
34
34
|
* the dependency buys.
|
|
35
35
|
*
|
|
36
|
+
* THE HALF THAT FIX DID NOT COVER
|
|
37
|
+
* -------------------------------
|
|
38
|
+
* `overflow: 'scroll'` is an option about WRAPPING, and it buys exactly one
|
|
39
|
+
* axis. Inside the shadow root the dependency puts `overflow-x: scroll` on its
|
|
40
|
+
* `[data-code]` element and pairs it with `overflow-y: clip`, then lets that
|
|
41
|
+
* element size to the whole document — a sixty-line body makes it 1230px tall
|
|
42
|
+
* inside a 224px box. Nothing in `@pierre/diffs` scrolls vertically: `File` is
|
|
43
|
+
* the non-virtualised renderer and owns no vertical viewport, the only escape
|
|
44
|
+
* hatch it exposes is the `--diffs-overflow-override` custom property, and that
|
|
45
|
+
* substitutes into the X component alone. (Its `CodeView` is the virtualised
|
|
46
|
+
* scroller, but it is a multi-item viewer rather than a taller `File`.)
|
|
47
|
+
*
|
|
48
|
+
* So the vertical overflow lands on the FIRST ancestor with an opinion, and
|
|
49
|
+
* that was this component's own wrapper, wearing `overflow-hidden`. Measured in
|
|
50
|
+
* Chrome on a 61-line body in an `h-56` box: wrapper `clientHeight` 223,
|
|
51
|
+
* `scrollHeight` 1236, and walking every element from the last line up to
|
|
52
|
+
* `<html>` found not one with a user-scrollable Y axis. A real wheel event
|
|
53
|
+
* dispatched over the box through CDP moved `window.scrollY` from 0 to 270 and
|
|
54
|
+
* left the editor on line 1 — the page scrolled, the code did not, which is the
|
|
55
|
+
* report. `overflow: hidden` is defined as clipping WITHOUT offering a
|
|
56
|
+
* scrolling mechanism, so no wheel, trackpad, scrollbar or `PageDown` could
|
|
57
|
+
* reach line 61; only the browser's own caret-into-view scrolling could, which
|
|
58
|
+
* is why typing to the bottom appeared to work and dragging never did.
|
|
59
|
+
*
|
|
60
|
+
* The wrapper is ours and in the light DOM, so the repair is here rather than
|
|
61
|
+
* past a boundary host CSS cannot cross: `overflow-y-auto` makes it the
|
|
62
|
+
* vertical viewport the dependency declines to be, and `overflow-x-hidden`
|
|
63
|
+
* keeps it from becoming a SECOND horizontal scroller competing with the one
|
|
64
|
+
* `overflow: 'scroll'` created — `overflow-y: auto` beside an `overflow-x:
|
|
65
|
+
* visible` would compute that axis to `auto` too. Verified in Chrome after the
|
|
66
|
+
* change: a wheel down moves the box and leaves the page still, a horizontal
|
|
67
|
+
* wheel still scrolls the long first line, and lines stay unwrapped.
|
|
68
|
+
*
|
|
69
|
+
* One consequence worth knowing rather than discovering: the horizontal
|
|
70
|
+
* scrollbar belongs to `[data-code]`, which is document-height, so it is drawn
|
|
71
|
+
* at the bottom of the DOCUMENT and not at the bottom of the visible box. A
|
|
72
|
+
* horizontal wheel or trackpad swipe works from anywhere in the box; the
|
|
73
|
+
* scrollbar itself is only in view once you are scrolled to the end. Moving it
|
|
74
|
+
* would mean styling inside the shadow root, which nothing out here can do.
|
|
75
|
+
*
|
|
36
76
|
* WHAT CONTENTEDITABLE COSTS
|
|
37
77
|
* --------------------------
|
|
38
78
|
* `@pierre/diffs` edits through `contentEditable`, which the old docblock
|
|
@@ -125,7 +165,9 @@ export interface CodeEditorProps {
|
|
|
125
165
|
* The options every code surface in this package shares.
|
|
126
166
|
*
|
|
127
167
|
* `overflow: 'scroll'` is the fix this file's header describes and must not
|
|
128
|
-
* become `'wrap'` without re-reading it.
|
|
168
|
+
* become `'wrap'` without re-reading it. It is an option about WRAPPING, so what
|
|
169
|
+
* it settles is the horizontal axis and the meaning of `End`; the vertical one
|
|
170
|
+
* is the wrapper's job and is not decided here. Line numbers are the other half and are
|
|
129
171
|
* conspicuously ABSENT from this object: they are on unless `disableLineNumbers`
|
|
130
172
|
* turns them off, so the way to keep them is to not write it. `code-editor.spec`
|
|
131
173
|
* asserts both, because "an option nobody added" is not something a reader can
|
package/dist/ui/code-editor.js
CHANGED
|
@@ -8,7 +8,9 @@ import { useCodeThemeType } from './code-theme';
|
|
|
8
8
|
* The options every code surface in this package shares.
|
|
9
9
|
*
|
|
10
10
|
* `overflow: 'scroll'` is the fix this file's header describes and must not
|
|
11
|
-
* become `'wrap'` without re-reading it.
|
|
11
|
+
* become `'wrap'` without re-reading it. It is an option about WRAPPING, so what
|
|
12
|
+
* it settles is the horizontal axis and the meaning of `End`; the vertical one
|
|
13
|
+
* is the wrapper's job and is not decided here. Line numbers are the other half and are
|
|
12
14
|
* conspicuously ABSENT from this object: they are on unless `disableLineNumbers`
|
|
13
15
|
* turns them off, so the way to keep them is to not write it. `code-editor.spec`
|
|
14
16
|
* asserts both, because "an option nobody added" is not something a reader can
|
|
@@ -108,7 +110,13 @@ export function CodeEditor({ value, onChange, language, label, onKeyDown, handle
|
|
|
108
110
|
return (
|
|
109
111
|
// Capture, not bubble, and on the wrapper rather than on the editable
|
|
110
112
|
// element, which is not ours to attach to. See `onKeyDown`.
|
|
111
|
-
|
|
113
|
+
//
|
|
114
|
+
// `overflow-y-auto` is the vertical viewport — see this file's header for
|
|
115
|
+
// why it has to live out here — and `overflow-x-hidden` is not decoration:
|
|
116
|
+
// the horizontal scroller is `[data-code]` inside the shadow root, and
|
|
117
|
+
// leaving this axis `visible` beside a scrolling one would compute it to
|
|
118
|
+
// `auto` and stack a second, empty scrollbar on top of it.
|
|
119
|
+
_jsx("div", { ref: wrapperRef, tabIndex: -1, className: cn('relative overflow-x-hidden overflow-y-auto outline-none', className), onKeyDownCapture: onWrapperKeyDown, children: _jsx(EditProvider, { createEditor: (options) => new Editor(options), children: _jsx(File, { edit: !readOnly, file: { name: label, contents: value, lang: language, cacheKey: label }, options: codeOptions(themeType), editorOptions: {
|
|
112
120
|
onAttach: (instance) => {
|
|
113
121
|
editorRef.current = instance;
|
|
114
122
|
},
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A searchable select that is also a text box, vendored in the shadcn style on
|
|
4
|
+
* Base UI's `Autocomplete`.
|
|
5
|
+
*
|
|
6
|
+
* ## Why not {@link Select}
|
|
7
|
+
*
|
|
8
|
+
* `Select` is a closed set: it renders a button, and every choice is one of the
|
|
9
|
+
* rows. That is right for a mode or a kind, where the options are three and
|
|
10
|
+
* written in this repository. It is wrong for a list a *deployment* supplies —
|
|
11
|
+
* a fleet announcing three hundred workflows renders three hundred rows in a
|
|
12
|
+
* popup with no way to narrow them, and a field whose only gesture is "scroll
|
|
13
|
+
* until you see it" is a field people give up on.
|
|
14
|
+
*
|
|
15
|
+
* ## Why `Autocomplete` and not `Combobox`
|
|
16
|
+
*
|
|
17
|
+
* Base UI ships both, and the difference is exactly the one that matters here.
|
|
18
|
+
* `Combobox` has a *selected value* — its input is a query over a closed list
|
|
19
|
+
* and what you end up with is one of the items. `Autocomplete` has no selected
|
|
20
|
+
* value at all: the input's text **is** the value, and the list is a set of
|
|
21
|
+
* suggestions over it. So a name nobody announced can still be typed, which is
|
|
22
|
+
* the property the call node cannot lose — a deployment whose workers are too
|
|
23
|
+
* old announces little or nothing, and a picker that became the only path would
|
|
24
|
+
* make that node unusable there.
|
|
25
|
+
*
|
|
26
|
+
* That is the whole reason this component exists rather than a `searchable`
|
|
27
|
+
* flag on `Select`: the two differ in what they can *express*, not in how they
|
|
28
|
+
* look.
|
|
29
|
+
*
|
|
30
|
+
* ## Picking is not typing, and the caller is told which happened
|
|
31
|
+
*
|
|
32
|
+
* {@link ComboboxProps.onValueChange} fires for keystrokes; {@link
|
|
33
|
+
* ComboboxProps.onSelect} fires for a committed row. Base UI also fills the
|
|
34
|
+
* input on an item press, which arrives as a value change with the reason
|
|
35
|
+
* `item-press`, and that one is dropped on the floor here — otherwise a caller
|
|
36
|
+
* that writes two fields from one row (`name` **and** `version`) would have the
|
|
37
|
+
* second immediately overwritten by the keystroke-shaped event for the first.
|
|
38
|
+
*/
|
|
39
|
+
export interface ComboOption {
|
|
40
|
+
/** What {@link ComboboxProps.onSelect} hands back, and the row's identity. */
|
|
41
|
+
value: string;
|
|
42
|
+
/** Shown, and the first thing the query matches against. */
|
|
43
|
+
label: string;
|
|
44
|
+
/** A second line under the label — where a row says what it *is*. */
|
|
45
|
+
hint?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Extra text the query also matches, shown nowhere.
|
|
48
|
+
*
|
|
49
|
+
* A workflow is looked for by its group or by what it does at least as often
|
|
50
|
+
* as by the exact name somebody has half-remembered, and a search that only
|
|
51
|
+
* matched the label would answer "no results" to a perfectly good query.
|
|
52
|
+
*/
|
|
53
|
+
keywords?: string;
|
|
54
|
+
/**
|
|
55
|
+
* Offered, greyed, and refused.
|
|
56
|
+
*
|
|
57
|
+
* Never a reason to omit the row: a picker that silently drops what it cannot
|
|
58
|
+
* accept is one you cannot tell apart from a picker that never heard of it.
|
|
59
|
+
* A disabled row owes a reason, which is what {@link hint} is for.
|
|
60
|
+
*/
|
|
61
|
+
disabled?: boolean;
|
|
62
|
+
}
|
|
63
|
+
export interface ComboboxProps {
|
|
64
|
+
/** The text in the box, which IS the value. Controlled. */
|
|
65
|
+
value: string;
|
|
66
|
+
/** A keystroke, a paste, a clear — anything the person typed. */
|
|
67
|
+
onValueChange: (value: string) => void;
|
|
68
|
+
/**
|
|
69
|
+
* A row was committed, by pointer or by <kbd>Enter</kbd>.
|
|
70
|
+
*
|
|
71
|
+
* Separate from {@link onValueChange} because a row can mean more than the
|
|
72
|
+
* text it puts in the box: the call node writes a version from it as well as
|
|
73
|
+
* a name, and it must write both in one update.
|
|
74
|
+
*/
|
|
75
|
+
onSelect?: (option: ComboOption) => void;
|
|
76
|
+
options: ComboOption[];
|
|
77
|
+
/** Shown when the query matches nothing. Not optional in spirit: an empty popup is a dead end. */
|
|
78
|
+
emptyMessage?: ReactNode;
|
|
79
|
+
placeholder?: string;
|
|
80
|
+
disabled?: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* The accessible name, for a bare combobox with no `<label>` around it.
|
|
83
|
+
* {@link ComboboxField} wraps one in a real label instead, and leaves this off.
|
|
84
|
+
*/
|
|
85
|
+
ariaLabel?: string;
|
|
86
|
+
className?: string;
|
|
87
|
+
}
|
|
88
|
+
export declare function Combobox({ value, onValueChange, onSelect, options, emptyMessage, placeholder, disabled, ariaLabel, className, }: ComboboxProps): import("react/jsx-runtime").JSX.Element;
|
|
89
|
+
/**
|
|
90
|
+
* A {@link Combobox} with a label above it, matching `TextField` — and a real
|
|
91
|
+
* `<label>`, because unlike `Select` this renders an `<input>` and a label
|
|
92
|
+
* therefore names it natively.
|
|
93
|
+
*/
|
|
94
|
+
export declare function ComboboxField({ label, hint, ...props }: Omit<ComboboxProps, 'ariaLabel'> & {
|
|
95
|
+
label: string;
|
|
96
|
+
hint?: ReactNode;
|
|
97
|
+
}): import("react/jsx-runtime").JSX.Element;
|