@w6w/ui 0.0.0-stage → 0.1.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.
Files changed (143) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/LICENSE +21 -0
  3. package/README.md +260 -2
  4. package/dist/ActionTestForm.d.ts +76 -0
  5. package/dist/AddConnectionModal.d.ts +24 -0
  6. package/dist/AppPicker.d.ts +83 -0
  7. package/dist/CodeBlock-CZu4TFSi.cjs +15 -0
  8. package/dist/CodeBlock-CZu4TFSi.cjs.map +1 -0
  9. package/dist/CodeBlock-Dot3Pd7P.js +2889 -0
  10. package/dist/CodeBlock-Dot3Pd7P.js.map +1 -0
  11. package/dist/CodeBlock.d.ts +65 -0
  12. package/dist/CodeEditor.d.ts +42 -0
  13. package/dist/ConfirmModal-DJPYXE9t.cjs +11 -0
  14. package/dist/ConfirmModal-DJPYXE9t.cjs.map +1 -0
  15. package/dist/ConfirmModal-sY1tzkBO.js +6335 -0
  16. package/dist/ConfirmModal-sY1tzkBO.js.map +1 -0
  17. package/dist/Copyable-1niV9gUa.js +771 -0
  18. package/dist/Copyable-1niV9gUa.js.map +1 -0
  19. package/dist/Copyable-CYZU1o4X.cjs +2 -0
  20. package/dist/Copyable-CYZU1o4X.cjs.map +1 -0
  21. package/dist/JsonEditor.d.ts +60 -0
  22. package/dist/NodeConfigForm.d.ts +70 -0
  23. package/dist/ParamsForm.d.ts +56 -0
  24. package/dist/PropertyEntryForm.d.ts +56 -0
  25. package/dist/RetryPolicyFields.d.ts +18 -0
  26. package/dist/StepBuilderModal.d.ts +375 -0
  27. package/dist/TriggerFillForm.d.ts +52 -0
  28. package/dist/WaitEditor.d.ts +6 -0
  29. package/dist/WorkflowFlowEditor.d.ts +119 -0
  30. package/dist/YamlEditor.d.ts +46 -0
  31. package/dist/app-categories.d.ts +38 -0
  32. package/dist/app-pages.d.ts +111 -0
  33. package/dist/code.cjs +2 -0
  34. package/dist/code.cjs.map +1 -0
  35. package/dist/code.d.ts +29 -0
  36. package/dist/code.mjs +7 -0
  37. package/dist/code.mjs.map +1 -0
  38. package/dist/components/ApiCallsPanel.d.ts +41 -0
  39. package/dist/components/AppIcon.d.ts +25 -0
  40. package/dist/components/AuthFieldsForm.d.ts +22 -0
  41. package/dist/components/Combobox.d.ts +24 -0
  42. package/dist/components/ConfirmModal.d.ts +33 -0
  43. package/dist/components/Copyable.d.ts +51 -0
  44. package/dist/components/CopyableText.d.ts +40 -0
  45. package/dist/components/DeleteButton.d.ts +16 -0
  46. package/dist/components/EditButton.d.ts +10 -0
  47. package/dist/components/ExecutionDetail.d.ts +70 -0
  48. package/dist/components/ExecutionFilters.d.ts +59 -0
  49. package/dist/components/ExecutionList.d.ts +60 -0
  50. package/dist/components/ExecutionLogPanel.d.ts +98 -0
  51. package/dist/components/ExecutionStats.d.ts +47 -0
  52. package/dist/components/ExpressionEditorModal.d.ts +42 -0
  53. package/dist/components/ExpressionInput.d.ts +36 -0
  54. package/dist/components/ExpressionOptions.d.ts +185 -0
  55. package/dist/components/HealthStatusPill.d.ts +25 -0
  56. package/dist/components/HistoryTimeline.d.ts +56 -0
  57. package/dist/components/Icon.d.ts +34 -0
  58. package/dist/components/IconButton.d.ts +60 -0
  59. package/dist/components/InfoTip.d.ts +15 -0
  60. package/dist/components/InternalIcon.d.ts +19 -0
  61. package/dist/components/ListItem.d.ts +25 -0
  62. package/dist/components/Modal.d.ts +29 -0
  63. package/dist/components/RepoSyncIndicator.d.ts +29 -0
  64. package/dist/components/ResolvedParams.d.ts +31 -0
  65. package/dist/components/ServerResources.d.ts +47 -0
  66. package/dist/components/StepStatusPill.d.ts +51 -0
  67. package/dist/components/UptimeStrip.d.ts +56 -0
  68. package/dist/components/execution-format.d.ts +24 -0
  69. package/dist/components/expression-dom.d.ts +154 -0
  70. package/dist/components/expression-template.d.ts +86 -0
  71. package/dist/components/history-scale.d.ts +33 -0
  72. package/dist/components/icons.d.ts +41 -0
  73. package/dist/components/resolved-clip.d.ts +42 -0
  74. package/dist/components/server-resources-format.d.ts +68 -0
  75. package/dist/components/server-resources.fixture.d.ts +9 -0
  76. package/dist/components/use-copy.d.ts +14 -0
  77. package/dist/createW6WApi.d.ts +31 -0
  78. package/dist/flow-connect.d.ts +138 -0
  79. package/dist/flow-fanout.d.ts +15 -0
  80. package/dist/flow-types.d.ts +356 -0
  81. package/dist/flow-utils.d.ts +284 -0
  82. package/dist/flow.cjs +3 -0
  83. package/dist/flow.cjs.map +1 -0
  84. package/dist/flow.d.ts +22 -0
  85. package/dist/flow.mjs +1977 -0
  86. package/dist/flow.mjs.map +1 -0
  87. package/dist/index.cjs +2 -0
  88. package/dist/index.cjs.map +1 -0
  89. package/dist/index.d.ts +94 -0
  90. package/dist/index.mjs +1811 -0
  91. package/dist/index.mjs.map +1 -0
  92. package/dist/oauth-popup.d.ts +17 -0
  93. package/dist/output-shape.d.ts +58 -0
  94. package/dist/provider.d.ts +420 -0
  95. package/dist/resolve-params.d.ts +112 -0
  96. package/dist/resolved-json.d.ts +21 -0
  97. package/dist/run-visuals.d.ts +90 -0
  98. package/dist/step-preview-state.d.ts +143 -0
  99. package/dist/theme.d.ts +32 -0
  100. package/dist/trigger-fields.d.ts +56 -0
  101. package/dist/types.d.ts +413 -0
  102. package/dist/ui.css +1 -0
  103. package/dist/use-app-action-defs.d.ts +7 -0
  104. package/dist/use-enter-submit.d.ts +23 -0
  105. package/dist/use-seed-sources.d.ts +16 -0
  106. package/package.json +111 -3
  107. package/src/code.css +542 -0
  108. package/src/styles/_buttons.scss +38 -0
  109. package/src/styles/_chips.scss +210 -0
  110. package/src/styles/_code.scss +139 -0
  111. package/src/styles/_copyable.scss +147 -0
  112. package/src/styles/_data-vars.scss +38 -0
  113. package/src/styles/_execution-history.scss +282 -0
  114. package/src/styles/_execution-log.scss +178 -0
  115. package/src/styles/_expression-field.scss +65 -0
  116. package/src/styles/_expression-inline.scss +63 -0
  117. package/src/styles/_expression-modal.scss +292 -0
  118. package/src/styles/_fields.scss +161 -0
  119. package/src/styles/_flow.scss +217 -0
  120. package/src/styles/_fx.scss +158 -0
  121. package/src/styles/_health.scss +46 -0
  122. package/src/styles/_history-timeline.scss +156 -0
  123. package/src/styles/_icon-button.scss +22 -0
  124. package/src/styles/_icon.scss +15 -0
  125. package/src/styles/_icons.scss +31 -0
  126. package/src/styles/_incoming-state.scss +46 -0
  127. package/src/styles/_info-tip.scss +9 -0
  128. package/src/styles/_layout.scss +6 -0
  129. package/src/styles/_lists.scss +64 -0
  130. package/src/styles/_modal.scss +125 -0
  131. package/src/styles/_multiselect.scss +69 -0
  132. package/src/styles/_repo-sync-indicator.scss +99 -0
  133. package/src/styles/_scale.scss +70 -0
  134. package/src/styles/_sections.scss +36 -0
  135. package/src/styles/_server-resources.scss +163 -0
  136. package/src/styles/_step-builder.scss +376 -0
  137. package/src/styles/_step-config.scss +195 -0
  138. package/src/styles/_tabs.scss +54 -0
  139. package/src/styles/_tester.scss +111 -0
  140. package/src/styles/_tokens.scss +141 -0
  141. package/src/styles/_uptime.scss +61 -0
  142. package/src/styles.css +4208 -0
  143. package/src/styles.scss +61 -0
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Pure derivation of a live run's canvas visuals (T1.1.1) — step node styling
3
+ * and main-graph edge taken/skipped/untouched state. Plain functions of (run
4
+ * state, step/edge identity) → visual state, with **no React import**, so
5
+ * `node --test` exercises them directly (A7) the same way `flow-connect.ts`'s
6
+ * connection rules do.
7
+ *
8
+ * `RunStatus`/`StepStatus`/`RunState`/`StepExecution` below are thin LOCAL
9
+ * copies of the shapes `@w6w/workflow-types` declares
10
+ * (`packages/w6w-workflow/packages/types/mod.ts`) — the same house idiom
11
+ * `components/HealthStatusPill.tsx`'s `HealthPillState` uses, and the same
12
+ * design note `flow-types.ts`'s own header already states for
13
+ * `FlowWorkflow`/`FlowStep`: `packages/ui/package.json` has no dependency on
14
+ * `@w6w/workflow-types` and must not gain one, so this module stays a
15
+ * pure-presentation leaf with no transport/spec coupling. A caller who
16
+ * already has the real `RunState`/`StepExecution` is structurally compatible
17
+ * for free.
18
+ */
19
+ /** Mirrors `RunStatus` in `@w6w/workflow-types`. */
20
+ export type RunStatus = "queued" | "running" | "succeeded" | "failed" | "canceled";
21
+ /** Mirrors `StepStatus` in `@w6w/workflow-types`. */
22
+ export type StepStatus = "pending" | "running" | "succeeded" | "failed" | "skipped";
23
+ /** The slice of `StepExecution` this module reads. */
24
+ export interface StepExecution {
25
+ status: StepStatus;
26
+ }
27
+ /** The slice of `RunState` this module reads — steps keyed by step id, same
28
+ * as the engine's own `RunState.steps`. */
29
+ export interface RunState {
30
+ status: RunStatus;
31
+ steps: Record<string, StepExecution>;
32
+ }
33
+ /**
34
+ * A step node's rendered state — exactly the five {@link StepStatus} values
35
+ * plus `"no-run"` (A2): `runState` omitted ⇒ `"no-run"` (this canvas isn't
36
+ * showing any run). A step present in `runState.steps` renders its own
37
+ * recorded status; a step the run hasn't reached yet has no entry there at
38
+ * all (only steps that were actually started/skipped get a `StepExecution` —
39
+ * see the engine's `recordSkipped`), so absence reads as `"pending"`.
40
+ */
41
+ export type StepVisualState = "no-run" | StepStatus;
42
+ /**
43
+ * The rendered state for step `stepId` under `runState` — the StepStatus
44
+ * half of A3's RunStatus × StepStatus mapping. Pure function of the run's own
45
+ * step records; no additional data needed (`GET /runs/:id` already returns
46
+ * everything this reads).
47
+ */
48
+ export declare function stepVisualState(runState: RunState | undefined, stepId: string): StepVisualState;
49
+ /** One node's non-persisted, run-aware look. Colour is never the only signal
50
+ * (the house rule `HealthStatusPill`'s own doc comment states) — every
51
+ * non-default state also differs from the default (`"no-run"`) in
52
+ * `borderStyle`, `borderWidth`, or `opacity`. */
53
+ export interface StepNodeVisual {
54
+ borderColor: string;
55
+ borderStyle: "solid" | "dashed";
56
+ borderWidth: number;
57
+ opacity: number;
58
+ }
59
+ /**
60
+ * The node visual for a step's {@link StepVisualState}, `runStatus`
61
+ * (the owning run's OWN status) additionally distinguishing the `"pending"`
62
+ * case — A3: a `canceled`/`failed` run's not-yet-reached steps render
63
+ * dimmer/muted (they never will run) than a `queued`/`running` run's
64
+ * not-yet-reached steps (they still might), even though both share the same
65
+ * `StepVisualState`. Every token used is one of the five named in
66
+ * `context.notes` (`--w6w-accent`/`--w6w-success`/`--w6w-danger`/
67
+ * `--w6w-muted`/`--w6w-border`) — never a literal hex, never a different
68
+ * token family.
69
+ */
70
+ export declare function stepNodeVisual(state: StepVisualState, runStatus?: RunStatus): StepNodeVisual;
71
+ /** Whether a main-graph edge was taken, skipped, or left untouched by the
72
+ * run (`undefined` — the source step hasn't been decided yet, or there is
73
+ * no run). */
74
+ export type EdgeRunState = "taken" | "skipped";
75
+ /**
76
+ * Whether the edge `from --(when)--> …` was taken or skipped in `runState` —
77
+ * computable from the run's step records alone (no engine data beyond what
78
+ * `GET /runs/:id` already returns):
79
+ * - `from` **succeeded**: its `"success"`/omitted-`when` edges are taken,
80
+ * its `"error"` edges are skipped.
81
+ * - `from` **failed**: a declared `"error"` edge is taken, every other
82
+ * outgoing edge (the `"success"` lane) is skipped.
83
+ * - `from` was itself **skipped** (reached only through a skipped edge —
84
+ * the engine's own `recordSkipped`/`markOutgoingEdgesSkipped`): every
85
+ * outgoing edge is skipped too, regardless of lane — a step that never
86
+ * ran cannot have taken an exit.
87
+ * - `from` is **running**, or has no record at all (not yet reached): the
88
+ * edge's fate isn't decided yet ⇒ `undefined`.
89
+ */
90
+ export declare function edgeRunState(runState: RunState | undefined, from: string, when: "success" | "error" | undefined): EdgeRunState | undefined;
@@ -0,0 +1,143 @@
1
+ import { Edge } from '@xyflow/react';
2
+ import { ExpressionStepSource } from './components/ExpressionOptions.tsx';
3
+ import { StepNode } from './flow-utils.ts';
4
+ import { ActionShapeDef } from './output-shape.ts';
5
+ import { StepMeta, StepStartState, StepTest } from './provider.tsx';
6
+ /**
7
+ * What the editor knows about upstream steps' output SHAPES beyond the static
8
+ * `internalNodeDef(...).output` — both optional, so a caller without them gets
9
+ * exactly the old projection.
10
+ */
11
+ export interface StepShapeContext {
12
+ /**
13
+ * An app step's action definition (its declared `output` / `sample`).
14
+ * `undefined` while that app's actions haven't loaded — the step then makes
15
+ * no "run a test" claim it might have to retract a moment later.
16
+ */
17
+ actionDef?: (app: string, action: string) => ActionShapeDef | undefined;
18
+ /** Each step's latest saved test-run output, by step id. */
19
+ testOutputs?: Record<string, unknown>;
20
+ }
21
+ /** A graph ancestor carrying a saved step-test, offered as a one-click seed. */
22
+ export interface SeedSource {
23
+ stepId: string;
24
+ label: string;
25
+ test: StepTest;
26
+ }
27
+ /**
28
+ * `pendingConnect`'s shape (`WorkflowFlowEditor.tsx`'s state): the handle a
29
+ * connection drag was released from, when it ended on empty canvas and opened
30
+ * the step builder to create + auto-wire a new node. `position` is part of
31
+ * that state too (where to place the new node) but unused by the direction
32
+ * rule below, so it is deliberately omitted here — `pendingConnect`'s real
33
+ * type carries it, and a wider object satisfies this narrower one structurally.
34
+ */
35
+ interface PendingConnect {
36
+ nodeId: string;
37
+ handleType: "source" | "target";
38
+ }
39
+ /**
40
+ * The workflow state a given step can reference: the outputs of every step
41
+ * that runs before it (its graph ancestors) plus whether a trigger precedes
42
+ * it.
43
+ *
44
+ * A trigger ancestor is **both**. It is pushed into `steps` like any other
45
+ * ancestor — `core/rfcs/node-types.md` ("Triggers as nodes"): *"Executing a
46
+ * trigger node yields the run's start payload … which downstream nodes read as
47
+ * `steps.<triggerId>.output`"* — **and** it sets `hasTrigger`, which offers the
48
+ * separate `trigger.event` root. The two are different values, not two spellings
49
+ * of one: `trigger.event` is the dispatcher-delivered event payload (seeded from
50
+ * `seed.event`), while a manual trigger's filled fields land under
51
+ * `steps.<id>.output`. Offering only the former is why a trigger's declared
52
+ * fields were unreachable from the picker.
53
+ *
54
+ * A **manual trigger** that declares output fields (`with.fields`) carries
55
+ * them as `outputs`, so a consumer can offer `steps.<id>.output.<key>` per
56
+ * field. Only a manual trigger: `fields` is an ordinary param name, and on any
57
+ * other node — including a webhook/scheduler entry node, whose payload is
58
+ * `trigger.event` instead (see the ⚠️ note below) — it holds that action's
59
+ * INPUT; an `@w6w/http:request` with `with.fields = [{key:"x"}]` would
60
+ * otherwise be advertised as declaring an output `x` it never produces. The
61
+ * manual trigger's `fields` is the one case where the param IS the output
62
+ * contract (`core/rfcs/node-types.md:194-196`; `trigger.md:119` covers only
63
+ * what drives editor autocomplete).
64
+ *
65
+ * ⚠️ These declared fields resolve differently on each run path. On the
66
+ * **single-step Test / ▶ Run** path (below), this editor sends a start state
67
+ * seeded from the upstream saved fixtures (see {@link startStateFromSeeds})
68
+ * which `POST /apps/:id/actions/:key/invoke` projects onto
69
+ * `steps.<id>.output`. On a **full run**, a manual trigger's declared fields
70
+ * resolve too: `POST /workflows/:id/run` accepts an `input` body field, and
71
+ * `run-workflow.ts` seeds the `@w6w/trigger` node's own output with it
72
+ * (verified by `server/e2e/trigger_run_payload_e2e_test.ts`). A
73
+ * webhook/scheduler entry node's declared fields do **not** resolve on a full
74
+ * run — its payload there is `trigger.event`, not `steps.<id>.output`, by
75
+ * design (`core/rfcs/trigger.md:378`) — which is exactly why the projection
76
+ * above is narrowed to a manual trigger only.
77
+ *
78
+ * With no specific step (shouldn't happen for a field edit) every node is offered.
79
+ */
80
+ export declare function upstreamStateSources(editingId: string | null, nodes: StepNode[], edges: Edge[], shapes?: StepShapeContext): {
81
+ steps: ExpressionStepSource[];
82
+ hasTrigger: boolean;
83
+ };
84
+ /**
85
+ * The new add-step wizard's graph ancestors, derived from `pendingConnect` —
86
+ * the handle a connection drag was released from before the builder opened
87
+ * (`null` for a floating add with no drag at all).
88
+ *
89
+ * **Direction matters.** `addBuiltStep`'s edge-wiring ternary
90
+ * (`WorkflowFlowEditor.tsx`) only makes the new step DOWNSTREAM of
91
+ * `pendingConnect.nodeId` when the drag came off a **source** handle
92
+ * (`[pendingConnect.nodeId, id]`); off a **target** handle the new step becomes
93
+ * the edge's SOURCE instead (`[id, pendingConnect.nodeId]`), so
94
+ * `pendingConnect.nodeId` ends up downstream of the new step, not upstream —
95
+ * offering it as a seed would be backwards. A `handleType: "source"` drag
96
+ * carries the dragged node itself (it IS upstream of the step about to be
97
+ * created) plus that node's own ancestors, via the same projection
98
+ * {@link upstreamStateSources} uses.
99
+ */
100
+ export declare function stepBuilderUpstreamSteps(pendingConnect: PendingConnect | null, nodes: StepNode[], edges: Edge[], shapes?: StepShapeContext): ExpressionStepSource[];
101
+ /**
102
+ * Gather each graph ancestor's latest saved step-test so the incoming-state
103
+ * control can offer it as a seed. **One implementation**, called by every
104
+ * surface that mounts {@link SeedSource}s — the step editor's Test tab, the
105
+ * canvas ▶ Run collect form, and `StepBuilderModal`'s add-step Test tab — so
106
+ * the `gate_1 · succeeded` chip behaves identically everywhere.
107
+ *
108
+ * `listStepTests` is injected (rather than reached for via `useW6WApi()`
109
+ * directly) so this stays a plain async function `node --test` can call with a
110
+ * stub — the React-facing wrapper is `use-seed-sources.ts`'s `useSeedSources`.
111
+ * It returns oldest-first per step, so the last entry is the most recent
112
+ * fixture. A step with no saved fixture (an empty list, or a lookup that
113
+ * throws) contributes nothing — best-effort, per step, never breaking the rest.
114
+ */
115
+ export declare function fetchSeedSources(listStepTests: (stepId: string) => Promise<StepTest[]>, upstreamSteps: ExpressionStepSource[]): Promise<SeedSource[]>;
116
+ /**
117
+ * The start state a single-step Test / ▶ Run is sent with: **the last-known
118
+ * saved output of each upstream step**, keyed by step id, in the shape the
119
+ * invoke route accepts (`{ steps: { <id>: { output } } }` — the server's
120
+ * `StartStateInput`, `packages/api/ambient-scope.ts`). It is what makes a
121
+ * `with` block written as `{{ steps.<id>.output.<field> }}` resolve to the
122
+ * value that step last produced instead of concatenating as `""`.
123
+ *
124
+ * Read from the same `step_tests` fixtures the seed chips offer — no upstream
125
+ * step is re-run to produce it, and nothing here is computed live.
126
+ *
127
+ * A step whose fixture never captured an output contributes **no entry** rather
128
+ * than an empty one, and a set with no outputs at all returns `undefined` so
129
+ * the invoke body carries no `state` key at all (byte-identical to a request
130
+ * from before this existed). Each id gets its OWN `{ output }` object: sharing
131
+ * one would make every reference resolve the last step's data.
132
+ *
133
+ * ⚠️ Single-step scope only. A full run (`POST /workflows/:id/run`) builds its
134
+ * own scope and is not affected by this.
135
+ */
136
+ export declare function startStateFromSeeds(seeds: SeedSource[]): StepStartState | undefined;
137
+ /**
138
+ * Sample values for a step's `steps.<id>.meta.*` refs, from a saved fixture's
139
+ * `lastRunMeta`. Reads the four named fields only; absent meta yields nothing
140
+ * (a version or connection is never derived from anywhere else).
141
+ */
142
+ export declare function stepMetaSampleValues(stepId: string, meta: StepMeta | null | undefined): Record<string, unknown>;
143
+ export {};
@@ -0,0 +1,32 @@
1
+ import { ThemeMode } from './types.ts';
2
+ /**
3
+ * Set by `<W6WUIProvider theme={...}>` (`provider.tsx`) — the HOST's
4
+ * explicit theme choice for an EMBEDDED `@w6w/ui`, threaded through context
5
+ * so every JS-side theme-aware component resolves the SAME value the
6
+ * provider's own `data-theme` DOM wrapper sets for the CSS side (below),
7
+ * without each component separately re-deriving it from `<html>`.
8
+ * `undefined` when no `<W6WUIProvider>` is in the tree, or one that didn't
9
+ * pass `theme` — every consumer then falls through to the pre-existing
10
+ * `data-theme`-on-`<html>` / OS-preference chain unchanged. See
11
+ * `docs/theming.md`.
12
+ */
13
+ export declare const ProvidedThemeCtx: import('react').Context<ThemeMode | undefined>;
14
+ /**
15
+ * Resolve the effective light/dark mode. Priority: explicit prop >
16
+ * `<W6WUIProvider theme>` > `data-theme` on <html> > `prefers-color-scheme`.
17
+ * The `data-theme` step matches the CSS defaults in `styles.css`, so
18
+ * components and stylesheet agree even without a provider `theme` — see
19
+ * `docs/theming.md` for why relying on that alone is a trap for an embedded
20
+ * host, though.
21
+ */
22
+ export declare function detectTheme(explicit: ThemeMode | undefined, provided?: ThemeMode): ThemeMode;
23
+ /**
24
+ * Reactive `detectTheme`: reads `<W6WUIProvider theme>` from context, and —
25
+ * when that's unset — subscribes to `data-theme` mutations on <html> and OS
26
+ * `prefers-color-scheme` changes, so a runtime theme toggle (e.g. studio's
27
+ * ThemeToggle, or a host re-rendering `<W6WUIProvider theme>` with a new
28
+ * value) is reflected without a remount. Shared by every ui component that
29
+ * needs the mode in JS (AppIcon, CodeEditor, JsonEditor, WorkflowFlowEditor)
30
+ * so they never drift from each other or from the CSS.
31
+ */
32
+ export declare function useEffectiveTheme(explicit?: ThemeMode): ThemeMode;
@@ -0,0 +1,56 @@
1
+ import { ActionParam } from './types.ts';
2
+ /**
3
+ * One field configured on a manual (`@w6w/trigger`) or webhook (`@w6w/webhook`)
4
+ * trigger — the `fields` param stores an array of these *definitions*
5
+ * (`{ key, type, default, required }`), not values. The Test tab derives a
6
+ * fillable form from them (see `TriggerFillForm`).
7
+ */
8
+ export interface TriggerFieldDef {
9
+ key?: string;
10
+ /** Declared value type — maps to an existing `ParamsForm` widget. */
11
+ type?: string;
12
+ /** Author-declared default (stored as text on the trigger config). */
13
+ default?: unknown;
14
+ required?: boolean;
15
+ }
16
+ /** Read a trigger's `fields` param value as an array of field definitions. */
17
+ export declare function asFieldDefs(fields: unknown): TriggerFieldDef[];
18
+ /**
19
+ * Map a field def's declared type onto one of the `ParamsForm` scalar
20
+ * widgets. `object`/`array` (a `WorkflowVariable`'s type union,
21
+ * `w6w-workflow/packages/types/mod.ts:40-45` — this seam is also reused for
22
+ * T1.1.5's run-page form) render as the `json` widget, same as an explicit
23
+ * `json` declaration: there is no dedicated object/array widget, and `json`
24
+ * is the one that round-trips a structured value without flattening it to
25
+ * text. Verified inert for the trigger `fields` editor itself: its type
26
+ * `<select>` offers exactly `string|number|boolean|json`
27
+ * (`flow-types.ts:343-353`), so no editor-authored trigger field can reach
28
+ * these two arms — only a call site that hands in `WorkflowVariable.type`
29
+ * can.
30
+ */
31
+ export declare function fieldWidget(type: string | undefined): ActionParam["type"];
32
+ /**
33
+ * Coerce a field's author-declared default into a value of the field's
34
+ * declared type, so the derived form seeds a sensible starting value and the
35
+ * required gate sees it as filled. Returns `undefined` for an empty/invalid
36
+ * default (the operator then supplies the value).
37
+ *
38
+ * A trigger field's default is stored as **text** and needs parsing; a
39
+ * `WorkflowVariable`'s default is stored as a **real JSON value already**
40
+ * (T1.1.5) — coercing it through `String(...)` would flatten `{a:1}` to the
41
+ * literal text `"[object Object]"` and `[1,2]` to `"1,2"`, and re-parsing
42
+ * `String({a:1})` as JSON fails outright (`coerceDefault("json", {a:1})` used
43
+ * to return `undefined`, silently dropping the default). So an already-object
44
+ * or already-array `raw` is returned unchanged, before any type-specific
45
+ * branch runs — this holds regardless of `type`, because the value needs no
46
+ * coercion either way.
47
+ */
48
+ export declare function coerceDefault(type: string | undefined, raw: unknown): unknown;
49
+ /**
50
+ * Project a trigger's `fields` definitions into a `ParamsForm`-compatible param
51
+ * list — one input per declared field, keyed by the field's `key`, rendered with
52
+ * the existing per-type widget. Unnamed fields are skipped.
53
+ */
54
+ export declare function fieldsToParams(defs: TriggerFieldDef[]): ActionParam[];
55
+ /** Seed the fill-form values from each declared field's (coerced) default. */
56
+ export declare function seedValues(defs: TriggerFieldDef[]): Record<string, unknown>;