@dudousxd/nestjs-catalog-react 0.27.0 → 0.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { isTransformLanguage, transformShape } from '@dudousxd/nestjs-catalog/client';
2
+ import { isTransformLanguage, isTransformMode, recordModeRefusal, transformMode, transformShape, } from '@dudousxd/nestjs-catalog/client';
3
3
  import { useMutation } from '@tanstack/react-query';
4
4
  import { ArrowLeft, Play } from 'lucide-react';
5
5
  import { useState } from 'react';
@@ -72,6 +72,63 @@ return [{
72
72
  "critical": int(r["risk"]) >= 80,
73
73
  } for r in records]`,
74
74
  };
75
+ /**
76
+ * Starter code for the per-record mode.
77
+ *
78
+ * A second table rather than a branch inside the first, so that adding a
79
+ * language without a per-record starter is a type error in the same way adding
80
+ * one without a batch starter already is.
81
+ *
82
+ * Python is absent from this table and cannot be here: its harness writes
83
+ * `def transform(records, context):` and there is no second `def` yet, which is
84
+ * why `recordModeRefusal` refuses the combination outright. The type says so —
85
+ * the key set is the two languages the mode can actually run in — rather than
86
+ * carrying a starter for a mode the server will reject.
87
+ */
88
+ const RECORD_STARTERS = {
89
+ typescript: `import type { CatalogRecordTransformFunction } from '@dudousxd/nestjs-catalog/client';
90
+
91
+ // One record in, one row out. This runs once per record over a stream, so
92
+ // nothing anywhere holds the whole read — see the mode selector above.
93
+ type Source = { tag: string; risk: string; kind: string };
94
+
95
+ const transform: CatalogRecordTransformFunction<Source> = ({ record, context }) => ({
96
+ assetId: record.tag,
97
+ riskScore: Number(record.risk),
98
+ vehicleTypeName: record.kind.toUpperCase(),
99
+ critical: Number(record.risk) >= 80,
100
+ });
101
+
102
+ export default transform;`,
103
+ javascript: `// One record in, one row out — this runs once per record over a stream.
104
+ // Return an array to turn one record into several, or null to drop it.
105
+ export default function transform({ record, context }) {
106
+ return {
107
+ assetId: record.tag,
108
+ riskScore: Number(record.risk),
109
+ vehicleTypeName: String(record.kind).toUpperCase(),
110
+ critical: Number(record.risk) >= 80,
111
+ };
112
+ }`,
113
+ };
114
+ /**
115
+ * What an empty editor opens with, for this language in this mode.
116
+ *
117
+ * One function so the two tables are consulted in one place. A per-record
118
+ * Python transform has no starter because it has no harness; it falls back to
119
+ * the batch one, and `recordModeRefusal` is what tells the author why the
120
+ * combination cannot be saved — a starter that pretended otherwise would be the
121
+ * editor teaching a shape the server refuses.
122
+ */
123
+ function starterFor(language, mode) {
124
+ if (mode === 'record' && language !== 'python')
125
+ return RECORD_STARTERS[language];
126
+ return STARTERS[language];
127
+ }
128
+ /** Every starter, so "has this been edited" can be asked without listing them. */
129
+ function isUntouchedStarter(code) {
130
+ return Object.values(STARTERS).includes(code) || Object.values(RECORD_STARTERS).includes(code);
131
+ }
75
132
  const SAMPLE = `[
76
133
  { "tag": "AF93E00073", "risk": "88", "kind": "truck" },
77
134
  { "tag": "AF00D00169", "risk": "12", "kind": "sedan" }
@@ -113,13 +170,18 @@ function TryOutput({ result, error }) {
113
170
  * Not shown for Python, which has one shape and no rule: its harness writes the
114
171
  * `def` itself, so there is nothing here for an author to have got wrong.
115
172
  */
116
- function ShapeBadge({ language, code }) {
173
+ function ShapeBadge({ language, code, mode, }) {
117
174
  if (language === 'python')
118
175
  return null;
119
176
  const shape = transformShape(code);
120
177
  const isModule = shape === 'module';
178
+ // The argument named in the tooltip follows the selected mode, because that is
179
+ // what the harness will actually pass. A badge that said `{ records, context }`
180
+ // beside a per-record selector would be reassuring somebody about a call that
181
+ // is not going to happen.
182
+ const argument = mode === 'record' ? '{ record, context }' : '{ records, context }';
121
183
  return (_jsx(Tooltip, { content: isModule
122
- ? 'A top-level `export`, so this is imported as a module and its default export (or an export named `transform`) is called with one object: { records, context }. Fields can be added to that object later without changing this signature.'
184
+ ? `A top-level \`export\`, so this is imported as a module and its default export (or an export named \`transform\`) is called with one object: ${argument}. Fields can be added to that object later without changing this signature.`
123
185
  : 'No top-level `export`, so this runs as the body of a function that already has `records` and `context` in scope. Supported and unchanged — `export default function transform({ records, context })` is the shape that can gain fields later.', children: _jsx("span", { className: cn('cursor-default rounded border px-1.5 py-0.5 font-mono text-[10px] uppercase tracking-[0.14em]', RULE, MUTED), children: isModule ? 'function' : 'bare body' }) }));
124
186
  }
125
187
  /**
@@ -130,15 +192,16 @@ function ShapeBadge({ language, code }) {
130
192
  * the code it was pinned to — and it should be visible before the click, not
131
193
  * explained after it.
132
194
  */
133
- function SaveBar({ transform, nameIsEmpty, pending, error, onSave, }) {
134
- return (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("button", { type: "button", onClick: onSave, disabled: pending || nameIsEmpty, className: cn('rounded-md border px-3 py-1.5 text-xs disabled:opacity-40', RULE, 'hover:bg-zinc-50 dark:hover:bg-zinc-800'), children: pending ? 'Saving…' : transform ? 'Save changes' : 'Save transform' }), transform && (_jsxs("span", { className: cn('font-mono text-[10px]', MUTED), children: ["saving new code makes this v", transform.version + 1] })), error ? (_jsx("span", { className: "text-[11px] text-red-600", children: error instanceof Error ? error.message : 'Could not save.' })) : null] }));
195
+ function SaveBar({ transform, nameIsEmpty, refused, pending, error, onSave, }) {
196
+ return (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("button", { type: "button", onClick: onSave, disabled: pending || nameIsEmpty || refused, className: cn('rounded-md border px-3 py-1.5 text-xs disabled:opacity-40', RULE, 'hover:bg-zinc-50 dark:hover:bg-zinc-800'), children: pending ? 'Saving…' : transform ? 'Save changes' : 'Save transform' }), transform && (_jsxs("span", { className: cn('font-mono text-[10px]', MUTED), children: ["saving new code makes this v", transform.version + 1] })), error ? (_jsx("span", { className: "text-[11px] text-red-600", children: error instanceof Error ? error.message : 'Could not save.' })) : null] }));
135
197
  }
136
198
  export function TransformEditor({ transform, languages, pythonPackages = [], onClose, onSaved, }) {
137
199
  const client = useCatalogClient();
138
200
  const [name, setName] = useState(transform?.name ?? '');
139
201
  const [description, setDescription] = useState(transform?.description ?? '');
140
202
  const [language, setLanguage] = useState(transform?.language ?? languages[0] ?? 'javascript');
141
- const [code, setCode] = useState(transform?.code ?? STARTERS[transform?.language ?? 'javascript']);
203
+ const [mode, setMode] = useState(transform ? transformMode(transform) : 'batch');
204
+ const [code, setCode] = useState(transform?.code ?? starterFor(transform?.language ?? 'javascript', 'batch'));
142
205
  const [sample, setSample] = useState(SAMPLE);
143
206
  const [historyOpen, setHistoryOpen] = useState(false);
144
207
  const tryIt = useMutation({
@@ -154,7 +217,11 @@ export function TransformEditor({ transform, languages, pythonPackages = [], onC
154
217
  // person reading it would go looking at their transform.
155
218
  throw new Error('The sample is not valid JSON.');
156
219
  }
157
- return client.tryTransform({ language, code, records });
220
+ // The mode goes with it, so the pane runs the code under the contract the
221
+ // author has selected rather than under whichever one the server would
222
+ // default to. A per-record transform tried as a batch is handed the whole
223
+ // array as its `record` and shows empty rows for correct code.
224
+ return client.tryTransform({ language, code, records, mode });
158
225
  },
159
226
  });
160
227
  const save = useMutation({
@@ -163,10 +230,14 @@ export function TransformEditor({ transform, languages, pythonPackages = [], onC
163
230
  name: name.trim(),
164
231
  language,
165
232
  code,
233
+ mode,
166
234
  description: description.trim() || undefined,
167
235
  }),
168
236
  onSuccess: onSaved,
169
237
  });
238
+ // The same question the controller asks, from the same function, so the
239
+ // editor and the server cannot disagree about which combinations are legal.
240
+ const refusal = recordModeRefusal({ language, code, mode });
170
241
  // `preventDefault` is what claims the key. The editor's default keymap binds
171
242
  // ⌘↵ to "insert a blank line", and `CodeEditor` only withholds a keystroke
172
243
  // from it when the host has said it wants it — so without this, trying the
@@ -185,20 +256,30 @@ export function TransformEditor({ transform, languages, pythonPackages = [], onC
185
256
  setLanguage(value);
186
257
  // Only replace untouched starter code — silently discarding
187
258
  // somebody's work because they changed a dropdown would be rude.
188
- if (Object.values(STARTERS).includes(code)) {
189
- setCode(STARTERS[value]);
190
- }
259
+ if (isUntouchedStarter(code))
260
+ setCode(starterFor(value, mode));
191
261
  }, options: languages.map((option) => ({
192
262
  value: option,
193
263
  label: option,
194
- })) })] }), _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: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("span", { className: cn('font-mono text-[10px] uppercase tracking-[0.14em]', MUTED), children: "Code" }), _jsx(ShapeBadge, { language: language, code: code })] }), _jsx("span", { className: cn('font-mono text-[10px]', MUTED), children: language === 'python' && pythonPackages.length > 0
264
+ })) })] }), _jsxs("div", { className: "grid gap-3 sm:grid-cols-3", children: [_jsx(SelectField, { label: "Called", ariaLabel: "Called", value: mode, onValueChange: (value) => {
265
+ if (!isTransformMode(value))
266
+ return;
267
+ setMode(value);
268
+ if (isUntouchedStarter(code))
269
+ setCode(starterFor(language, value));
270
+ }, options: [
271
+ { value: 'batch', label: 'once with the whole batch' },
272
+ { value: 'record', label: 'once per record (streams)' },
273
+ ] }), _jsx("p", { className: cn('sm:col-span-2 self-center text-xs leading-relaxed', MUTED), children: mode === 'record'
274
+ ? 'Each record is mapped on its own and the rows are written as they are produced, so nothing holds the whole read. Return one object, an array of them, or null to drop the record. Aggregating, deduplicating and sorting need the whole batch and cannot be written this way.'
275
+ : 'The code is called once with every record, which is what aggregating, deduplicating, sorting and joining need. The whole read is held in memory while it runs.' })] }), refusal ? (_jsx("p", { className: "rounded-lg border border-amber-300 bg-amber-50 px-3 py-2 text-xs leading-relaxed text-amber-900 dark:border-amber-900/60 dark:bg-amber-950/40 dark:text-amber-200", children: refusal })) : null, _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: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("span", { className: cn('font-mono text-[10px] uppercase tracking-[0.14em]', MUTED), children: "Code" }), _jsx(ShapeBadge, { language: language, code: code, mode: mode })] }), _jsx("span", { className: cn('font-mono text-[10px]', MUTED), children: language === 'python' && pythonPackages.length > 0
195
276
  ? `imports: ${pythonPackages.join(', ')}`
196
277
  : '⌘↵ to try' })] }), _jsx(CodeEditor, { value: code, onChange: setCode, onKeyDown: onKeyDown,
197
278
  // A table rather than the `language === 'python' ? 'python' : 'tsx'`
198
279
  // that used to be here. The ternary answered a fourth transform
199
280
  // language with `tsx` — silently, and wrongly — where the table
200
281
  // cannot be indexed by one at all until somebody adds the row.
201
- 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 },
282
+ 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, { refused: refusal !== undefined, 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 },
202
283
  // The SAVED code, not what is in the editor above. A history is what
203
284
  // this catalog has recorded; comparing against an unsaved buffer would
204
285
  // put a version number on text that exists only in one browser tab,
@@ -2133,6 +2133,9 @@ function Canvas({ title = WORKFLOW_NAME.titlePlural, eyebrow = 'Ingestion', intr
2133
2133
  useUndoShortcut({ enabled: canEdit, onUndo: undo, onSay: setAnnouncement });
2134
2134
  useUnsavedGuard(draft.dirty);
2135
2135
  const durability = describeDurability(capabilities?.durable);
2136
+ // Threaded to the source inspector rather than read there, so the one query
2137
+ // for `capabilities` serves both the canvas banner and the disk picker.
2138
+ const storage = capabilities?.storage;
2136
2139
  // Asked about EVERY problem, not about `live`. This is the guarantee: a graph
2137
2140
  // that would silently do nothing is coloured as unsaveable from the moment it
2138
2141
  // becomes one, whether or not the node responsible is still being worked on.
@@ -2333,7 +2336,7 @@ function Canvas({ title = WORKFLOW_NAME.titlePlural, eyebrow = 'Ingestion', intr
2333
2336
  }, onDisconnect: disconnect, onOpenMenu: openMenuFor, wiring: wiring, wiringRefusal: wiringRefusal, nodeMenu: _jsx(NodeActionsToolbar, { node: menu.anchor, canEdit: canEdit, open: menu.open, sections: toolbarSections, deleteHint: deleteHint(menu.anchor, draft, stored), onOpenChange: menu.onOpenChange, onHoverChange: menu.onHoverChange, onDelete: () => {
2334
2337
  dropNodes(idsOf(menu.anchor));
2335
2338
  menu.reset();
2336
- } }), fitPadding: fitPadding }), _jsx(CanvasContextMenu, { opening: contextMenu, sections: contextSections, label: contextLabel, onClose: forgetMenu }), workflows.isSuccess && workflows.data.length === 0 && _jsx(NothingDrawnYet, {}), _jsx("output", { "aria-live": "polite", className: "sr-only", children: announcement }), _jsx(NodeInspector, { node: inspectingNode, draft: draft, transforms: transforms, connections: connections, typeOptions: typeOptions, canEdit: canEdit, modelHref: modelHref, problems: problemsOf(problemsFor, inspectingNode), pending: problemsOf(pendingFor, inspectingNode), discovery: discovery, discoverable: { ...discoveryTarget(draft), onSave: saveNow, saving: save.isPending }, onDiscovered: rememberShape, onClose: () => setInspecting(null), onChange: (next) => {
2339
+ } }), fitPadding: fitPadding }), _jsx(CanvasContextMenu, { opening: contextMenu, sections: contextSections, label: contextLabel, onClose: forgetMenu }), workflows.isSuccess && workflows.data.length === 0 && _jsx(NothingDrawnYet, {}), _jsx("output", { "aria-live": "polite", className: "sr-only", children: announcement }), _jsx(NodeInspector, { node: inspectingNode, draft: draft, transforms: transforms, connections: connections, storage: storage, typeOptions: typeOptions, canEdit: canEdit, modelHref: modelHref, problems: problemsOf(problemsFor, inspectingNode), pending: problemsOf(pendingFor, inspectingNode), discovery: discovery, discoverable: { ...discoveryTarget(draft), onSave: saveNow, saving: save.isPending }, onDiscovered: rememberShape, onClose: () => setInspecting(null), onChange: (next) => {
2337
2340
  // Editing any field is the clearest statement there is that somebody
2338
2341
  // is working on this node rather than looking at one they just made.
2339
2342
  markStarted(next.id);
@@ -3754,7 +3757,7 @@ function parseConfigText(text) {
3754
3757
  * a kind added without a branch here shows up as a node with a name and nothing
3755
3758
  * to configure, which is visible on the screen rather than silent.
3756
3759
  */
3757
- function KindInspector({ node, graph, transforms, connections, typeOptions, canEdit, modelHref, discovery, discoverable, onDiscovered, onChange, onEditCode, onCreateTransform, creatingTransform, createTransformError, }) {
3760
+ function KindInspector({ node, graph, transforms, connections, storage, typeOptions, canEdit, modelHref, discovery, discoverable, onDiscovered, onChange, onEditCode, onCreateTransform, creatingTransform, createTransformError, }) {
3758
3761
  if (node.kind === 'transform') {
3759
3762
  return (_jsx(TransformInspector, { node: node, transforms: transforms, canEdit: canEdit, creating: creatingTransform, createError: createTransformError, onChange: onChange, onEditCode: onEditCode, onCreate: onCreateTransform }));
3760
3763
  }
@@ -3763,7 +3766,7 @@ function KindInspector({ node, graph, transforms, connections, typeOptions, canE
3763
3766
  // Keyed so the text fields reset when a different source is opened.
3764
3767
  // Without it the draft state would survive the swap and one node's URL
3765
3768
  // would appear inside another.
3766
- , { node: node, connections: connections, canEdit: canEdit, discovery: discovery, discoverable: discoverable, onDiscovered: onDiscovered, onChange: onChange }, node.id));
3769
+ , { node: node, connections: connections, storage: storage, canEdit: canEdit, discovery: discovery, discoverable: discoverable, onDiscovered: onDiscovered, onChange: onChange }, node.id));
3767
3770
  }
3768
3771
  if (node.kind === 'call') {
3769
3772
  // Keyed for the same reason the source inspector is: the parameter box
@@ -3797,7 +3800,7 @@ function KindInspector({ node, graph, transforms, connections, typeOptions, canE
3797
3800
  // with a name and nothing to configure". It no longer can.
3798
3801
  return unreachableNodeKind(node, 'KindInspector');
3799
3802
  }
3800
- function NodeInspector({ node, draft, transforms, connections, typeOptions, canEdit, modelHref, problems, pending, discovery, discoverable, onDiscovered, onClose, onChange, onConnect, onConnectToNew, onDisconnect, onBranch, onDelete, onEditCode, onCreateTransform, creatingTransform, createTransformError, }) {
3803
+ function NodeInspector({ node, draft, transforms, connections, storage, typeOptions, canEdit, modelHref, problems, pending, discovery, discoverable, onDiscovered, onClose, onChange, onConnect, onConnectToNew, onDisconnect, onBranch, onDelete, onEditCode, onCreateTransform, creatingTransform, createTransformError, }) {
3801
3804
  const [pendingTarget, setPendingTarget] = useState('');
3802
3805
  const label = (id) => {
3803
3806
  const found = draft.nodes.find((n) => n.id === id);
@@ -3838,7 +3841,7 @@ function NodeInspector({ node, draft, transforms, connections, typeOptions, canE
3838
3841
  return (_jsx(Sheet, { open: node !== null, onOpenChange: (open) => {
3839
3842
  if (!open)
3840
3843
  onClose();
3841
- }, title: node ? nodeName(node) : '', description: node ? `${node.kind} node` : undefined, children: node && (_jsxs("div", { className: "space-y-4", children: [problems.length > 0 && (_jsx("ul", { className: "space-y-1.5 rounded-md border border-red-200 bg-red-50 p-2 dark:border-red-900 dark:bg-red-950/40", children: problems.map((problem) => (_jsx("li", { className: "text-[11px] leading-relaxed text-red-700 dark:text-red-300", children: problem.message }, problem.code))) })), pending.length > 0 && (_jsxs("div", { className: cn('rounded-md border p-2', RULE), children: [_jsx("p", { className: cn('font-mono text-[10px] uppercase tracking-[0.14em]', MUTED), children: "Still to do" }), _jsx("ul", { className: "mt-1 space-y-0.5", children: pending.map((problem) => (_jsx("li", { className: "text-[11px] leading-relaxed", children: todoFor(problem) }, problem.code))) })] })), _jsx(TextField, { label: "Name", value: node.name, onChange: (name) => onChange({ ...node, name }), placeholder: node.kind, disabled: !canEdit, hint: "What it is called on the canvas and in the wiring list. Renaming it does not change what the graph does, so it does not bump the version." }), _jsx(KindInspector, { node: node, graph: draft, transforms: transforms, connections: connections, typeOptions: typeOptions, canEdit: canEdit, modelHref: modelHref, discovery: discovery, discoverable: discoverable, onDiscovered: onDiscovered, onChange: onChange, onEditCode: onEditCode, onCreateTransform: onCreateTransform, creatingTransform: creatingTransform, createTransformError: createTransformError }), _jsx(WiringList, { title: "Fed by", edges: incoming, otherEnd: (edge) => label(edge.from), describeRemoval: (name) => `Stop ${name} feeding this node`, canEdit: canEdit, onDisconnect: onDisconnect, children: incoming.length > 1 && (_jsx("p", { className: cn('mt-1 text-[11px] leading-relaxed', MUTED), children: "Inputs arrive in this order, and the order is part of what the graph produces \u2014 a transform joining two feeds sees them exactly like this." })) }), _jsxs(WiringList, { title: "Feeds", edges: outgoing, otherEnd: (edge) => label(edge.to), describeRemoval: (name) => `Stop this node feeding ${name}`, canEdit: canEdit, onDisconnect: onDisconnect,
3844
+ }, title: node ? nodeName(node) : '', description: node ? `${node.kind} node` : undefined, children: node && (_jsxs("div", { className: "space-y-4", children: [problems.length > 0 && (_jsx("ul", { className: "space-y-1.5 rounded-md border border-red-200 bg-red-50 p-2 dark:border-red-900 dark:bg-red-950/40", children: problems.map((problem) => (_jsx("li", { className: "text-[11px] leading-relaxed text-red-700 dark:text-red-300", children: problem.message }, problem.code))) })), pending.length > 0 && (_jsxs("div", { className: cn('rounded-md border p-2', RULE), children: [_jsx("p", { className: cn('font-mono text-[10px] uppercase tracking-[0.14em]', MUTED), children: "Still to do" }), _jsx("ul", { className: "mt-1 space-y-0.5", children: pending.map((problem) => (_jsx("li", { className: "text-[11px] leading-relaxed", children: todoFor(problem) }, problem.code))) })] })), _jsx(TextField, { label: "Name", value: node.name, onChange: (name) => onChange({ ...node, name }), placeholder: node.kind, disabled: !canEdit, hint: "What it is called on the canvas and in the wiring list. Renaming it does not change what the graph does, so it does not bump the version." }), _jsx(KindInspector, { node: node, graph: draft, transforms: transforms, connections: connections, storage: storage, typeOptions: typeOptions, canEdit: canEdit, modelHref: modelHref, discovery: discovery, discoverable: discoverable, onDiscovered: onDiscovered, onChange: onChange, onEditCode: onEditCode, onCreateTransform: onCreateTransform, creatingTransform: creatingTransform, createTransformError: createTransformError }), _jsx(WiringList, { title: "Fed by", edges: incoming, otherEnd: (edge) => label(edge.from), describeRemoval: (name) => `Stop ${name} feeding this node`, canEdit: canEdit, onDisconnect: onDisconnect, children: incoming.length > 1 && (_jsx("p", { className: cn('mt-1 text-[11px] leading-relaxed', MUTED), children: "Inputs arrive in this order, and the order is part of what the graph produces \u2014 a transform joining two feeds sees them exactly like this." })) }), _jsxs(WiringList, { title: "Feeds", edges: outgoing, otherEnd: (edge) => label(edge.to), describeRemoval: (name) => `Stop this node feeding ${name}`, canEdit: canEdit, onDisconnect: onDisconnect,
3842
3845
  // Only a gate's wires have a side to be on. `validateWorkflow`
3843
3846
  // refuses a label on any other wire, so offering the control there
3844
3847
  // would be offering a change the server will not take.
@@ -3869,7 +3872,7 @@ function NodeInspector({ node, draft, transforms, connections, typeOptions, canE
3869
3872
  * rather than read back out of the node. Re-deriving them from the stored config
3870
3873
  * would make a half-typed number disappear the moment it stopped parsing.
3871
3874
  */
3872
- function SourceInspector({ node, connections, canEdit, discovery, discoverable, onDiscovered, onChange, }) {
3875
+ function SourceInspector({ node, connections, storage, canEdit, discovery, discoverable, onDiscovered, onChange, }) {
3873
3876
  const [source, setSource] = useState(() => sourceDraftFrom(node.config));
3874
3877
  const kind = toConnectorKind(node.sourceKind ?? 'http');
3875
3878
  const options = connectionOptionsFor(kind, connections);
@@ -3919,5 +3922,5 @@ function SourceInspector({ node, connections, canEdit, discovery, discoverable,
3919
3922
  ? 'No connections of this kind yet. One is worth making when a second source needs the same address.'
3920
3923
  : viaConnection
3921
3924
  ? 'The connection supplies the address and the credential. What stays below is only what is specific to this load.'
3922
- : undefined }), _jsx(SourceConnectionCreator, { kind: kind, canEdit: canEdit, hasOptions: options.length > 0, onCreated: (connection) => push(source, { connectionId: connection.id }) })] })), _jsx(SourceFields, { kind: kind, draft: source, onChange: update, viaConnection: viaConnection, disabled: !canEdit }), _jsx(ReadModeFields, { kind: kind, mode: mode, onModeChange: (next) => push(source, { mode: next }), draft: source, onChange: update, disabled: !canEdit }), incremental && (_jsx("p", { className: cn('text-[11px] leading-relaxed', MUTED), children: "A watermark is kept per node, so two sources in the same graph reading incrementally do not overwrite each other's position." })), _jsx(SchemaDiscoveryPanel, { workflowId: discoverable.workflowId ?? '', nodeId: node.id, bridge: discovery, onDiscovered: onDiscovered, onSave: discoverable.onSave, saving: discoverable.saving, ...(discoverable.workflowId === undefined ? { disabledReason: discoverable.because } : {}) })] }));
3925
+ : undefined }), _jsx(SourceConnectionCreator, { kind: kind, canEdit: canEdit, hasOptions: options.length > 0, onCreated: (connection) => push(source, { connectionId: connection.id }) })] })), _jsx(SourceFields, { kind: kind, draft: source, onChange: update, viaConnection: viaConnection, disabled: !canEdit, storage: storage }), _jsx(ReadModeFields, { kind: kind, mode: mode, onModeChange: (next) => push(source, { mode: next }), draft: source, onChange: update, disabled: !canEdit }), incremental && (_jsx("p", { className: cn('text-[11px] leading-relaxed', MUTED), children: "A watermark is kept per node, so two sources in the same graph reading incrementally do not overwrite each other's position." })), _jsx(SchemaDiscoveryPanel, { workflowId: discoverable.workflowId ?? '', nodeId: node.id, bridge: discovery, onDiscovered: onDiscovered, onSave: discoverable.onSave, saving: discoverable.saving, ...(discoverable.workflowId === undefined ? { disabledReason: discoverable.because } : {}) })] }));
3923
3926
  }
package/dist/context.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import type { CallableWorkflowRef, CatalogAuditEvent, CatalogConnection, CatalogConnector, CatalogObjectPage, CatalogQueryRelation, CatalogQueryResult, CatalogReusableNode, CatalogRevision, CatalogSearchResult, CatalogSnapshot, CatalogTrace, CatalogTraceList, CatalogTransform, ConnectionCheck, ConnectorRun, Dashboard, DashboardCard, DeleteReconciliation, LoadExpectation, LoadExpectationInput, ObjectQueryParams, PropertyPatch, ResolvedLoadExpectation, ReusableNodeBody, RowCountBound, SaveQueryInput, SavedQuery, SnapshotRef, StoredLoadExpectation, TraceQuery, TransformLanguage, TransformResult, TypePatch } from '@dudousxd/nestjs-catalog/client';
1
+ import type { CallableWorkflowRef, CatalogAuditEvent, CatalogConnection, CatalogConnector, CatalogObjectPage, CatalogQueryRelation, CatalogQueryResult, CatalogReusableNode, CatalogRevision, CatalogSearchResult, CatalogSnapshot, CatalogTrace, CatalogTraceList, CatalogTransform, ConnectionCheck, ConnectorRun, Dashboard, DashboardCard, DeleteReconciliation, LoadExpectation, LoadExpectationInput, ObjectQueryParams, PropertyPatch, ResolvedLoadExpectation, ReusableNodeBody, RowCountBound, SaveQueryInput, SavedQuery, SnapshotRef, StoredLoadExpectation, TraceQuery, TransformLanguage, TransformMode, TransformResult, TypePatch } from '@dudousxd/nestjs-catalog/client';
2
2
  import { type ReactNode } from 'react';
3
3
  import type { EmbeddedChartPayload, EmbeddedDashboardPayload } from './embed/payload';
4
4
  import { type PeopleQuery } from './routes';
5
- import type { CatalogWorkflow, CatalogWorkflowRelease, WorkflowDurability, WorkflowInput, WorkflowRun } from './workflow/model';
5
+ import type { CatalogWorkflow, CatalogWorkflowRelease, StorageAvailability, WorkflowDurability, WorkflowInput, WorkflowRun } from './workflow/model';
6
6
  /**
7
7
  * How these screens talk to the server.
8
8
  *
@@ -76,6 +76,17 @@ export interface PipelineCapabilities {
76
76
  * engine — is the exact promise this project keeps having to remove.
77
77
  */
78
78
  durable?: WorkflowDurability;
79
+ /**
80
+ * Whether a connector here may name a media disk instead of carrying its own
81
+ * bucket and credential.
82
+ *
83
+ * Optional for the same reason `durable` is, and absent is the same third
84
+ * answer: a server older than this field has not been asked. The console must
85
+ * not render "no disks" over it — the two look identical to somebody who has
86
+ * never seen the field, and the first invites them to go and configure a disk
87
+ * that will never appear.
88
+ */
89
+ storage?: StorageAvailability;
79
90
  }
80
91
  /**
81
92
  * What a call node could be pointed at, and whether the question was answerable.
@@ -153,6 +164,16 @@ export interface TransformInput {
153
164
  description?: string;
154
165
  language: TransformLanguage;
155
166
  code: string;
167
+ /**
168
+ * Whether the code is called once with the batch or once per record.
169
+ *
170
+ * Optional, and **absent means "leave whatever is stored alone"** rather than
171
+ * "make it a batch". A caller written before this field existed sends no mode,
172
+ * and the store reads that as no instruction — so an older client saving a
173
+ * rename cannot silently undo somebody's deliberate choice. See
174
+ * `TRANSFORM_MODES`.
175
+ */
176
+ mode?: TransformMode;
156
177
  }
157
178
  /**
158
179
  * One pipeline that would break if a connection were deleted.
@@ -718,6 +739,15 @@ export interface CatalogClient {
718
739
  language: TransformLanguage;
719
740
  code: string;
720
741
  records: unknown[];
742
+ /**
743
+ * Which contract to run the sample under.
744
+ *
745
+ * Sent by the editor, because a pane that tried a per-record transform as a
746
+ * batch would hand it the whole array as its `record` and show empty rows
747
+ * for correct code — through the one screen whose value is that it predicts
748
+ * what the load will do.
749
+ */
750
+ mode?: TransformMode;
721
751
  }): Promise<TransformResult>;
722
752
  /**
723
753
  * Authored graphs: sources wired through transforms into sinks.
package/dist/index.d.ts CHANGED
@@ -24,7 +24,7 @@ export { type ColumnChoice, type ConnectorSchemaDiscovery, type DiscoveredColumn
24
24
  export { TransformEditor, type TransformEditorProps } from './TransformEditor';
25
25
  export { DiffBody, RevisionHistory, type RevisionHistoryProps, RevisionHistoryButton, RevisionHistorySheet, type RevisionHistorySheetProps, type RevisionSubject, type RevisionSubjectKind, } from './diff/RevisionDiff';
26
26
  export { AccessConsole, type AccessConsoleProps } from './AccessConsole';
27
- export { type CallableWorkflowRef, type CatalogWorkflow, describeDurability, type DurabilityCopy, isWorkflowNodeKind, newLocalId, nodeName, producedTypes, WORKFLOW_NODE_ID_PATTERN, WORKFLOW_NODE_KINDS, type WorkflowCallNode, type WorkflowDurability, type WorkflowEdge, type WorkflowGraph, type WorkflowInput, type WorkflowNode, type WorkflowNodeKind, type WorkflowRun, type WorkflowRunNode, type WorkflowSinkNode, type WorkflowSourceNode, type WorkflowTransformNode, } from './workflow/model';
27
+ export { type CallableWorkflowRef, type CatalogWorkflow, describeDurability, describeStorage, type DurabilityCopy, isWorkflowNodeKind, newLocalId, nodeName, producedTypes, type StorageAvailability, type StorageCopy, WORKFLOW_NODE_ID_PATTERN, WORKFLOW_NODE_KINDS, type WorkflowCallNode, type WorkflowDurability, type WorkflowEdge, type WorkflowGraph, type WorkflowInput, type WorkflowNode, type WorkflowNodeKind, type WorkflowRun, type WorkflowRunNode, type WorkflowSinkNode, type WorkflowSourceNode, type WorkflowTransformNode, } from './workflow/model';
28
28
  export { WORKFLOW_NAME } from './workflow/name';
29
29
  export { checkShapes, type ShapeKnowledge, type SourceColumn, type SourceShape, type TargetProperty, type TargetShape, } from './workflow/shape';
30
30
  export { canConnect, type ConnectionVerdict, edgeId, hasBlockingProblem, problemsByNode, type ValidateOptions, validateWorkflow, type WorkflowDraft, type WorkflowProblem, type WorkflowProblemCode, type WorkflowProblemLevel, wouldCycle, } from './workflow/validate';
package/dist/index.js CHANGED
@@ -114,7 +114,7 @@ export { AccessConsole } from './AccessConsole';
114
114
  // Most of what follows is re-exported from `@dudousxd/nestjs-catalog/client`
115
115
  // rather than declared here — a node, an edge and a graph have one definition,
116
116
  // and it belongs to the package that executes them. See `workflow/model.ts`.
117
- export { describeDurability, isWorkflowNodeKind, newLocalId, nodeName, producedTypes, WORKFLOW_NODE_ID_PATTERN, WORKFLOW_NODE_KINDS, } from './workflow/model';
117
+ export { describeDurability, describeStorage, isWorkflowNodeKind, newLocalId, nodeName, producedTypes, WORKFLOW_NODE_ID_PATTERN, WORKFLOW_NODE_KINDS, } from './workflow/model';
118
118
  export { WORKFLOW_NAME } from './workflow/name';
119
119
  // Whether what a source reads fits the type its sink writes.
120
120
  //
@@ -1,5 +1,6 @@
1
1
  import type { ConnectorKind } from '@dudousxd/nestjs-catalog/client';
2
2
  import { type ConnectableKind } from './connection-form';
3
+ import { type StorageAvailability } from './workflow/model';
3
4
  /** A select hands back a string. Narrow it rather than promise it is a kind. */
4
5
  export declare function toConnectorKind(value: string): ConnectorKind;
5
6
  /** The sources that can be asked what changed. The rest always read it all. */
@@ -62,6 +63,8 @@ export interface SourceDraft {
62
63
  format: string;
63
64
  records: string;
64
65
  bucket: string;
66
+ /** A named media disk, which stands in for the bucket AND the credential. */
67
+ disk: string;
65
68
  prefix: string;
66
69
  suffix: string;
67
70
  endpoint: string;
@@ -100,19 +103,19 @@ export interface SourceConfigOptions {
100
103
  * stale url on a SQL source, which reads as configuration somebody meant.
101
104
  */
102
105
  export declare function sourceConfigFrom(kind: ConnectorKind, draft: SourceDraft, { viaConnection, incremental }: SourceConfigOptions): Record<string, unknown>;
103
- /**
104
- * The address fields for one kind.
105
- *
106
- * Rendered by both the connector form and the workflow source inspector, which
107
- * is the entire point of this module: the two screens configure the same thing
108
- * and there is exactly one description of what that thing needs.
109
- */
110
- export declare function SourceFields({ kind, draft, onChange, viaConnection, disabled, }: {
106
+ export declare function SourceFields({ kind, draft, onChange, viaConnection, disabled, storage, }: {
111
107
  kind: ConnectorKind;
112
108
  draft: SourceDraft;
113
109
  onChange: (draft: SourceDraft) => void;
114
110
  viaConnection: boolean;
115
111
  disabled?: boolean;
112
+ /**
113
+ * What this deployment says about naming a media disk.
114
+ *
115
+ * Optional, and absent is a third answer rather than "no" — see
116
+ * {@link describeStorage}, which is what renders it.
117
+ */
118
+ storage?: StorageAvailability;
116
119
  }): import("react/jsx-runtime").JSX.Element;
117
120
  /** Full or incremental, with the per-kind explanation of what that means. */
118
121
  export declare function ReadModeFields({ kind, mode, onModeChange, draft, onChange, disabled, }: {
@@ -5,6 +5,7 @@ import { CONNECTION_KINDS } from './connection-form';
5
5
  import { FieldGroup, TextAreaField, TextField } from './ui/field';
6
6
  import { SelectField } from './ui/select';
7
7
  import { Switch } from './ui/switch';
8
+ import { describeStorage } from './workflow/model';
8
9
  /**
9
10
  * Describing where records are read from, in one place.
10
11
  *
@@ -108,6 +109,7 @@ export function sourceDraftFrom(config) {
108
109
  format: text('format'),
109
110
  records: Array.isArray(records) && records.length > 0 ? JSON.stringify(records, null, 2) : '',
110
111
  bucket: text('bucket'),
112
+ disk: text('disk'),
111
113
  prefix: text('prefix'),
112
114
  suffix: text('suffix'),
113
115
  endpoint: text('endpoint'),
@@ -163,17 +165,30 @@ function fileConfig(draft) {
163
165
  ...(draft.format ? { format: draft.format } : {}),
164
166
  };
165
167
  }
168
+ /**
169
+ * Where the objects are, which is one of three answers and never two.
170
+ *
171
+ * A connection supplies it, or a disk does, or the fields below do. They are
172
+ * mutually exclusive on purpose: writing a bucket beside a disk would store two
173
+ * answers to one question and leave whoever reads it back to guess which won.
174
+ */
175
+ function s3Address(draft, viaConnection) {
176
+ if (viaConnection)
177
+ return {};
178
+ // A disk carries the bucket, the endpoint, the region AND the credential.
179
+ if (draft.disk)
180
+ return { disk: draft.disk };
181
+ return {
182
+ bucket: draft.bucket,
183
+ ...(draft.endpoint ? { endpoint: draft.endpoint } : {}),
184
+ ...(draft.region ? { region: draft.region } : {}),
185
+ ...(draft.forcePathStyle ? { forcePathStyle: true } : {}),
186
+ };
187
+ }
166
188
  /** Bucket and addressing, which a connection can supply, then the per-load narrowing. */
167
189
  function s3Config(draft, viaConnection) {
168
190
  return {
169
- ...(viaConnection
170
- ? {}
171
- : {
172
- bucket: draft.bucket,
173
- ...(draft.endpoint ? { endpoint: draft.endpoint } : {}),
174
- ...(draft.region ? { region: draft.region } : {}),
175
- ...(draft.forcePathStyle ? { forcePathStyle: true } : {}),
176
- }),
191
+ ...s3Address(draft, viaConnection),
177
192
  ...(draft.prefix ? { prefix: draft.prefix } : {}),
178
193
  ...(draft.suffix ? { suffix: draft.suffix } : {}),
179
194
  ...(draft.format ? { format: draft.format } : {}),
@@ -230,7 +245,15 @@ export function sourceConfigFrom(kind, draft, { viaConnection, incremental }) {
230
245
  * is the entire point of this module: the two screens configure the same thing
231
246
  * and there is exactly one description of what that thing needs.
232
247
  */
233
- export function SourceFields({ kind, draft, onChange, viaConnection, disabled, }) {
248
+ /**
249
+ * The blank option's value, which cannot be the empty string.
250
+ *
251
+ * A select whose option value is `''` is indistinguishable from an unset select
252
+ * to the underlying primitive, so the "no disk" choice carries a sentinel and is
253
+ * mapped back to `''` on the way into the draft.
254
+ */
255
+ const NO_DISK = '__no_disk__';
256
+ export function SourceFields({ kind, draft, onChange, viaConnection, disabled, storage, }) {
234
257
  const set = (patch) => onChange({ ...draft, ...patch });
235
258
  if (kind === 'http') {
236
259
  return (_jsxs("div", { className: "grid gap-3 sm:grid-cols-2", children: [!viaConnection && (_jsx(TextField, { label: "URL", value: draft.url, onChange: (url) => set({ url }), placeholder: "https://\u2026", disabled: disabled })), _jsx(TextField, { label: "Path to the array", value: draft.path, onChange: (path) => set({ path }), placeholder: "e.g. data", disabled: disabled })] }));
@@ -242,7 +265,16 @@ export function SourceFields({ kind, draft, onChange, viaConnection, disabled, }
242
265
  return (_jsxs("div", { className: "grid gap-3 sm:grid-cols-2", children: [_jsx(TextField, { label: "File path or URL", value: draft.path, onChange: (path) => set({ path }), placeholder: "/data/drop.csv or https://\u2026", disabled: disabled }), _jsx(SelectField, { label: "Format", ariaLabel: "Format", value: draft.format, onValueChange: (format) => set({ format }), options: FORMAT_OPTIONS, disabled: disabled })] }));
243
266
  }
244
267
  if (kind === 's3') {
245
- return (_jsxs("div", { className: "space-y-3", children: [!viaConnection && (_jsxs("div", { className: "grid gap-3 sm:grid-cols-2", children: [_jsx(TextField, { label: "Bucket", value: draft.bucket, onChange: (bucket) => set({ bucket }), placeholder: "fleet-drops", disabled: disabled }), _jsx(TextField, { label: "Region", value: draft.region, onChange: (region) => set({ region }), placeholder: "Blank uses the environment's", disabled: disabled }), _jsx(TextField, { label: "Endpoint", value: draft.endpoint, onChange: (endpoint) => set({ endpoint }), placeholder: "MinIO, e.g. http://localhost:9000", disabled: disabled })] })), _jsxs("div", { className: "grid gap-3 sm:grid-cols-3", children: [_jsx(TextField, { label: "Prefix", value: draft.prefix, onChange: (prefix) => set({ prefix }), placeholder: "drops/mvr/", disabled: disabled }), _jsx(TextField, { label: "Only keys ending in", value: draft.suffix, onChange: (suffix) => set({ suffix }), placeholder: ".csv", disabled: disabled }), _jsx(TextField, { label: "Max objects per run", value: draft.maxObjectsPerRun, onChange: (maxObjectsPerRun) => set({ maxObjectsPerRun }), inputMode: "numeric", disabled: disabled })] }), _jsx(SelectField, { label: "Format", ariaLabel: "Format", value: draft.format, onValueChange: (format) => set({ format }), options: KEY_FORMAT_OPTIONS, disabled: disabled }), !viaConnection && (_jsx(Switch, { checked: draft.forcePathStyle, onCheckedChange: (forcePathStyle) => set({ forcePathStyle }), label: "Path-style addressing", hint: "MinIO needs it; AWS does not." }))] }));
268
+ const disks = describeStorage(storage);
269
+ const named = draft.disk.trim().length > 0;
270
+ return (_jsxs("div", { className: "space-y-3", children: [!viaConnection && (_jsx("div", { className: "space-y-2", children: storage?.available && storage.disks.length > 0 ? (_jsx(SelectField, { label: "Read through a disk", ariaLabel: "Media disk", value: draft.disk || NO_DISK, onValueChange: (value) => set({ disk: value === NO_DISK ? '' : value }), options: [
271
+ {
272
+ value: NO_DISK,
273
+ label: 'Configure the bucket here',
274
+ hint: 'This source alone',
275
+ },
276
+ ...storage.disks.map((name) => ({ value: name, label: name })),
277
+ ], disabled: disabled, hint: disks.detail })) : (_jsx("p", { className: "text-xs text-zinc-500 dark:text-zinc-400", "data-testid": "source-storage-detail", children: disks.detail })) })), !viaConnection && !named && (_jsxs("div", { className: "grid gap-3 sm:grid-cols-2", children: [_jsx(TextField, { label: "Bucket", value: draft.bucket, onChange: (bucket) => set({ bucket }), placeholder: "fleet-drops", disabled: disabled }), _jsx(TextField, { label: "Region", value: draft.region, onChange: (region) => set({ region }), placeholder: "Blank uses the environment's", disabled: disabled }), _jsx(TextField, { label: "Endpoint", value: draft.endpoint, onChange: (endpoint) => set({ endpoint }), placeholder: "MinIO, e.g. http://localhost:9000", disabled: disabled })] })), _jsxs("div", { className: "grid gap-3 sm:grid-cols-3", children: [_jsx(TextField, { label: "Prefix", value: draft.prefix, onChange: (prefix) => set({ prefix }), placeholder: "drops/mvr/", disabled: disabled }), _jsx(TextField, { label: "Only keys ending in", value: draft.suffix, onChange: (suffix) => set({ suffix }), placeholder: ".csv", disabled: disabled }), _jsx(TextField, { label: "Max objects per run", value: draft.maxObjectsPerRun, onChange: (maxObjectsPerRun) => set({ maxObjectsPerRun }), inputMode: "numeric", disabled: disabled })] }), _jsx(SelectField, { label: "Format", ariaLabel: "Format", value: draft.format, onValueChange: (format) => set({ format }), options: KEY_FORMAT_OPTIONS, disabled: disabled }), !viaConnection && (_jsx(Switch, { checked: draft.forcePathStyle, onCheckedChange: (forcePathStyle) => set({ forcePathStyle }), label: "Path-style addressing", hint: "MinIO needs it; AWS does not." }))] }));
246
278
  }
247
279
  const parsed = parseRecords(draft.records);
248
280
  return (_jsx(TextAreaField, { label: "Records", value: draft.records, onChange: (records) => set({ records }), placeholder: '[{ "tag": "AF93E00073" }]', mono: true, rows: 5, disabled: disabled, hint: parsed.ok ? undefined : (_jsx("span", { className: "text-red-600 dark:text-red-400", children: parsed.message })) }));
@@ -68,6 +68,36 @@ export interface DurabilityCopy {
68
68
  detail: string;
69
69
  }
70
70
  export declare function describeDurability(durability: WorkflowDurability | undefined): DurabilityCopy;
71
+ /**
72
+ * Whether a connector here may name a media disk.
73
+ *
74
+ * The same three-state shape {@link WorkflowDurability} has, for the same
75
+ * reason: the field being absent means a server that predates it, which is not
76
+ * the same as a server that says no.
77
+ */
78
+ export interface StorageAvailability {
79
+ available: boolean;
80
+ disks: string[];
81
+ detail: string;
82
+ }
83
+ /** The three answers, as prose the screen can render without branching twice. */
84
+ export interface StorageCopy {
85
+ state: 'disks' | 'none' | 'unknown';
86
+ label: string;
87
+ detail: string;
88
+ }
89
+ /**
90
+ * What to tell somebody authoring an object-store source.
91
+ *
92
+ * The `none` case is the one that matters, and it is written to say what is
93
+ * LOST rather than what is missing. "Media is not available" would be true and
94
+ * useless: nobody would notice the absence of a feature they have never used.
95
+ * What they will do instead is mint a second copy of a credential the host has
96
+ * already got, under a name of the catalog's own, and add that name to the
97
+ * secret allow-list — and the second copy is the one that outlives its
98
+ * rotation. Saying so is the whole point of rendering this at all.
99
+ */
100
+ export declare function describeStorage(storage: StorageAvailability | undefined): StorageCopy;
71
101
  /**
72
102
  * The outcome of running a graph, node by node.
73
103
  *
@@ -64,6 +64,45 @@ export function describeDurability(durability) {
64
64
  detail: 'No durable engine is available here, so the whole graph runs inline in one process. A failure at node seven re-runs the graph from node one, and nothing between nodes is checkpointed.',
65
65
  };
66
66
  }
67
+ /**
68
+ * What to tell somebody authoring an object-store source.
69
+ *
70
+ * The `none` case is the one that matters, and it is written to say what is
71
+ * LOST rather than what is missing. "Media is not available" would be true and
72
+ * useless: nobody would notice the absence of a feature they have never used.
73
+ * What they will do instead is mint a second copy of a credential the host has
74
+ * already got, under a name of the catalog's own, and add that name to the
75
+ * secret allow-list — and the second copy is the one that outlives its
76
+ * rotation. Saying so is the whole point of rendering this at all.
77
+ */
78
+ export function describeStorage(storage) {
79
+ if (!storage) {
80
+ return {
81
+ state: 'unknown',
82
+ label: 'disks: not reported',
83
+ detail: 'This deployment did not say whether media disks are wired up, so this screen cannot offer them. Give the connector a bucket and a credential of its own. Treating silence as "there are no disks" would send somebody looking for a picker that is not missing, only unreported.',
84
+ };
85
+ }
86
+ if (storage.available && storage.disks.length > 0) {
87
+ return {
88
+ state: 'disks',
89
+ label: `disks: ${storage.disks.length}`,
90
+ detail: `This connector can name a disk instead of carrying its own bucket, endpoint and credential: ${storage.disks.join(', ')}. The disk already holds all four, configured once by the host and rotated in one place.`,
91
+ };
92
+ }
93
+ if (storage.available) {
94
+ return {
95
+ state: 'none',
96
+ label: 'disks: none configured',
97
+ detail: 'Media is mounted here but has no disks configured, so there is nothing to name yet. Give the connector a bucket and a credential of its own, or configure a disk on the host and it becomes selectable here.',
98
+ };
99
+ }
100
+ return {
101
+ state: 'none',
102
+ label: 'disks: off',
103
+ detail: 'No media storage manager resolved here, so this connector cannot name a disk. It still reads an object store — but it has to carry its own bucket, endpoint and region, and its own environment variable holding "accessKeyId:secretAccessKey", which is a second copy of a credential this deployment would otherwise have configured once on a disk.',
104
+ };
105
+ }
67
106
  /**
68
107
  * A stable id for a node the person just drew.
69
108
  *
@@ -22,6 +22,12 @@ export const SOURCE_KINDS = {
22
22
  label: 'an object store',
23
23
  required: ['bucket'],
24
24
  optional: [
25
+ // A named media disk, which stands in for `bucket`, `region`, `endpoint`
26
+ // AND the credential — the host configured all four once, and a connector
27
+ // that names a disk inherits them instead of restating them. Optional
28
+ // rather than an alternative `required` set because a deployment with no
29
+ // media has no disks to name, and `bucket` is still the answer there.
30
+ 'disk',
25
31
  'prefix',
26
32
  'suffix',
27
33
  'format',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dudousxd/nestjs-catalog-react",
3
- "version": "0.27.0",
3
+ "version": "0.29.0",
4
4
  "description": "Ready-made React screens for @dudousxd/nestjs-catalog — a model manager and a generic object explorer you can drop into your own app shell.",
5
5
  "license": "MIT",
6
6
  "author": "Davide Carvalho",
@@ -110,7 +110,7 @@
110
110
  "tailwind-merge": "3.4.1",
111
111
  "tiptap-markdown": "0.9.0",
112
112
  "typescript": "5.9.3",
113
- "@dudousxd/nestjs-catalog": "0.23.0"
113
+ "@dudousxd/nestjs-catalog": "0.25.0"
114
114
  },
115
115
  "dependencies": {
116
116
  "clsx": "2.1.1",