@ekanos/harness 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.
Files changed (158) hide show
  1. package/README.md +6 -4
  2. package/dist/internal/components/approvals-tray.d.ts +44 -6
  3. package/dist/internal/components/approvals-tray.js +252 -30
  4. package/dist/internal/components/ask-assistant-bridge.js +7 -1
  5. package/dist/internal/components/connect-controls.js +4 -2
  6. package/dist/internal/components/connect-dialog.d.ts +8 -1
  7. package/dist/internal/components/connect-dialog.js +23 -10
  8. package/dist/internal/components/connect-panel.d.ts +3 -2
  9. package/dist/internal/components/connect-panel.js +680 -340
  10. package/dist/internal/components/connect-steps.d.ts +72 -0
  11. package/dist/internal/components/connect-steps.js +341 -0
  12. package/dist/internal/components/console-not-found.d.ts +14 -0
  13. package/dist/internal/components/console-not-found.js +57 -0
  14. package/dist/internal/components/dashboard-grid.d.ts +10 -5
  15. package/dist/internal/components/dashboard-grid.js +8 -9
  16. package/dist/internal/components/dev-toolbar.d.ts +27 -5
  17. package/dist/internal/components/dev-toolbar.js +214 -176
  18. package/dist/internal/components/ekanos-logo.d.ts +18 -0
  19. package/dist/internal/components/ekanos-logo.js +74 -0
  20. package/dist/internal/components/events-panel.d.ts +13 -4
  21. package/dist/internal/components/events-panel.js +478 -81
  22. package/dist/internal/components/harness-widget-provider.d.ts +6 -8
  23. package/dist/internal/components/harness-widget-provider.js +5 -19
  24. package/dist/internal/components/health-panel.d.ts +8 -1
  25. package/dist/internal/components/health-panel.js +328 -31
  26. package/dist/internal/components/integration-badge.js +4 -2
  27. package/dist/internal/components/integration-tab-skeletons.d.ts +8 -0
  28. package/dist/internal/components/integration-tab-skeletons.js +76 -0
  29. package/dist/internal/components/not-found-state.d.ts +39 -0
  30. package/dist/internal/components/not-found-state.js +127 -0
  31. package/dist/internal/components/operation-runner-panel.d.ts +1 -1
  32. package/dist/internal/components/operation-runner-panel.js +624 -189
  33. package/dist/internal/components/operation-scope.d.ts +13 -0
  34. package/dist/internal/components/operation-scope.js +79 -0
  35. package/dist/internal/components/page-skeletons.d.ts +11 -0
  36. package/dist/internal/components/page-skeletons.js +61 -0
  37. package/dist/internal/components/provenance-banner.d.ts +13 -4
  38. package/dist/internal/components/provenance-banner.js +35 -10
  39. package/dist/internal/components/run-log-copy.d.ts +17 -0
  40. package/dist/internal/components/run-log-copy.js +67 -0
  41. package/dist/internal/components/run-log-detail.d.ts +22 -0
  42. package/dist/internal/components/run-log-detail.js +295 -0
  43. package/dist/internal/components/run-log-empty.d.ts +13 -0
  44. package/dist/internal/components/run-log-empty.js +46 -0
  45. package/dist/internal/components/run-log.d.ts +23 -3
  46. package/dist/internal/components/run-log.js +384 -130
  47. package/dist/internal/components/runtime-strip.d.ts +5 -1
  48. package/dist/internal/components/runtime-strip.js +82 -5
  49. package/dist/internal/components/schema-form.d.ts +2 -1
  50. package/dist/internal/components/schema-form.js +212 -79
  51. package/dist/internal/components/scrollable-nav.js +14 -2
  52. package/dist/internal/components/segmented-control.d.ts +19 -0
  53. package/dist/internal/components/segmented-control.js +46 -0
  54. package/dist/internal/components/shell-header.d.ts +25 -0
  55. package/dist/internal/components/shell-header.js +126 -0
  56. package/dist/internal/components/surface-nav.d.ts +12 -4
  57. package/dist/internal/components/surface-nav.js +79 -80
  58. package/dist/internal/components/widget-surface.d.ts +5 -1
  59. package/dist/internal/components/widget-surface.js +86 -14
  60. package/dist/internal/components/workflow-runner.d.ts +23 -10
  61. package/dist/internal/components/workflow-runner.js +451 -69
  62. package/dist/internal/lib/connect-model.d.ts +134 -0
  63. package/dist/internal/lib/connect-model.js +282 -0
  64. package/dist/internal/lib/connection-facts.js +2 -1
  65. package/dist/internal/lib/console-client.js +5 -2
  66. package/dist/internal/lib/console-hooks.d.ts +4 -1
  67. package/dist/internal/lib/console-hooks.js +3 -2
  68. package/dist/internal/lib/console-types.d.ts +6 -0
  69. package/dist/internal/lib/docs-links.d.ts +27 -0
  70. package/dist/internal/lib/docs-links.js +55 -1
  71. package/dist/internal/lib/event-delivery.d.ts +33 -0
  72. package/dist/internal/lib/event-delivery.js +66 -0
  73. package/dist/internal/lib/font-files/OFL-BricolageGrotesque.txt +93 -0
  74. package/dist/internal/lib/font-files/OFL-Figtree.txt +93 -0
  75. package/dist/internal/lib/font-files/bricolage-grotesque-latin-variable.woff2 +0 -0
  76. package/dist/internal/lib/font-files/figtree-latin-variable.woff2 +0 -0
  77. package/dist/internal/lib/fonts.js +13 -12
  78. package/dist/internal/lib/health-model.d.ts +58 -0
  79. package/dist/internal/lib/health-model.js +140 -0
  80. package/dist/internal/lib/integration-console-href.d.ts +5 -0
  81. package/dist/internal/lib/integration-console-href.js +7 -1
  82. package/dist/internal/lib/oauth-setup-guide.d.ts +28 -0
  83. package/dist/internal/lib/oauth-setup-guide.js +35 -1
  84. package/dist/internal/lib/operation-catalog.d.ts +70 -0
  85. package/dist/internal/lib/operation-catalog.js +261 -0
  86. package/dist/internal/lib/overview-model.d.ts +34 -0
  87. package/dist/internal/lib/overview-model.js +91 -0
  88. package/dist/internal/lib/registry-entry.d.ts +8 -0
  89. package/dist/internal/lib/registry-entry.js +11 -0
  90. package/dist/internal/lib/repo-name.d.ts +9 -0
  91. package/dist/internal/lib/repo-name.js +21 -0
  92. package/dist/internal/lib/run-log-view.d.ts +66 -1
  93. package/dist/internal/lib/run-log-view.js +183 -4
  94. package/dist/internal/lib/runner-view.d.ts +15 -0
  95. package/dist/internal/lib/runner-view.js +18 -0
  96. package/dist/internal/lib/schema-form-model.d.ts +17 -0
  97. package/dist/internal/lib/schema-form-model.js +50 -0
  98. package/dist/internal/lib/setup-checklist.d.ts +34 -0
  99. package/dist/internal/lib/setup-checklist.js +79 -0
  100. package/dist/internal/lib/toolbar-context.d.ts +0 -1
  101. package/dist/internal/lib/toolbar-context.js +0 -2
  102. package/dist/internal/lib/toolbar-visibility.d.ts +9 -2
  103. package/dist/internal/lib/toolbar-visibility.js +5 -0
  104. package/dist/internal/lib/use-operation-effects.d.ts +7 -0
  105. package/dist/internal/lib/use-operation-effects.js +28 -0
  106. package/dist/internal/lib/use-run-log-query.d.ts +9 -0
  107. package/dist/internal/lib/use-run-log-query.js +35 -0
  108. package/dist/internal/lib/widget-grid-gaps.d.ts +18 -0
  109. package/dist/internal/lib/widget-grid-gaps.js +41 -0
  110. package/dist/internal/lib/workflow-summary.d.ts +54 -0
  111. package/dist/internal/lib/workflow-summary.js +147 -0
  112. package/dist/internal/routes/console-home-page.js +2 -1
  113. package/dist/internal/routes/experience-connect-page.js +46 -17
  114. package/dist/internal/routes/experience-layout-page.d.ts +6 -6
  115. package/dist/internal/routes/experience-layout-page.js +3 -119
  116. package/dist/internal/routes/experience-page-host.js +61 -5
  117. package/dist/internal/routes/experience-pages-page.d.ts +5 -0
  118. package/dist/internal/routes/experience-pages-page.js +118 -0
  119. package/dist/internal/routes/experience-review-queue-page.d.ts +4 -1
  120. package/dist/internal/routes/experience-review-queue-page.js +108 -12
  121. package/dist/internal/routes/experience-runs-page.js +57 -4
  122. package/dist/internal/routes/experience-summary-page.d.ts +19 -0
  123. package/dist/internal/routes/experience-summary-page.js +212 -52
  124. package/dist/internal/routes/experience-widget-page.js +58 -7
  125. package/dist/internal/routes/experience-widgets-page.d.ts +2 -3
  126. package/dist/internal/routes/experience-widgets-page.js +29 -4
  127. package/dist/internal/routes/experience-workflow-page.js +81 -9
  128. package/dist/internal/routes/experience-workflows-page.js +85 -21
  129. package/dist/internal/routes/integration-layout.js +28 -3
  130. package/dist/internal/routes/integrations-connect-page.js +16 -6
  131. package/dist/internal/routes/integrations-events-page.js +22 -1
  132. package/dist/internal/routes/integrations-health-page.js +16 -1
  133. package/dist/internal/routes/integrations-layout.js +28 -4
  134. package/dist/internal/routes/integrations-list-page.d.ts +0 -1
  135. package/dist/internal/routes/integrations-list-page.js +11 -9
  136. package/dist/internal/routes/integrations-operation-page.js +53 -17
  137. package/dist/internal/routes/integrations-operations-page.js +539 -49
  138. package/dist/internal/routes/integrations-overview-page.js +332 -69
  139. package/dist/internal/routes/integrations-runs-page.js +53 -3
  140. package/dist/internal/routes/integrations-scope.d.ts +15 -2
  141. package/dist/internal/routes/integrations-scope.js +66 -18
  142. package/dist/internal/routes/preview-index-page.js +2 -2
  143. package/dist/internal/routes/repo-home-page.d.ts +2 -2
  144. package/dist/internal/routes/repo-home-page.js +429 -236
  145. package/dist/internal/routes/repo-layout.d.ts +12 -0
  146. package/dist/internal/routes/repo-layout.js +50 -38
  147. package/dist/internal/routes/repo-package-layouts.js +22 -8
  148. package/dist/internal/routes/single-widget-page.d.ts +1 -1
  149. package/dist/internal/routes/single-widget-page.js +28 -5
  150. package/dist/internal/routes/tile-page.d.ts +1 -1
  151. package/dist/internal/routes/tile-page.js +1 -2
  152. package/dist/internal/routes/widgets-page.d.ts +1 -1
  153. package/dist/internal/routes/widgets-page.js +5 -3
  154. package/dist/registry.d.ts +4 -5
  155. package/dist/registry.js +0 -1
  156. package/dist/routes.d.ts +8 -1
  157. package/dist/routes.js +4 -0
  158. package/package.json +14 -14
@@ -1,60 +1,550 @@
1
1
  "use client";
2
- import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import {
4
+ Suspense,
5
+ useEffect,
6
+ useMemo,
7
+ useRef,
8
+ useState
9
+ } from "react";
10
+ import { flushSync } from "react-dom";
3
11
  import Link from "next/link";
12
+ import { usePathname, useSearchParams } from "next/navigation";
4
13
  import { Badge } from "@ekanos/ui/badge";
5
- import { StatusBadge } from "@ekanos/ui/status-badge";
14
+ import { Button } from "@ekanos/ui/button";
15
+ import { Card, CardButton } from "@ekanos/ui/card";
6
16
  import {
7
- Table,
8
- TableBody,
9
- TableCell,
10
- TableHead,
11
- TableHeader,
12
- TableRow
13
- } from "@ekanos/ui/table";
17
+ EmptyState,
18
+ EmptyStateButton,
19
+ EmptyStateHeading,
20
+ EmptyStateText
21
+ } from "@ekanos/ui/empty-state";
22
+ import { Icon } from "@ekanos/ui/icon";
23
+ import { SearchField } from "@ekanos/ui/search-field";
24
+ import { StatusBadge } from "@ekanos/ui/status-badge";
25
+ import { cn } from "@ekanos/ui/utils";
14
26
  import { operationKey } from "../components/operation-runner-panel.js";
15
- import { IntegrationScope } from "./integrations-scope.js";
16
- function IntegrationOperationsPage() {
17
- return /* @__PURE__ */ jsx(IntegrationScope, { title: "Operations", children: ({ integration, contract }) => /* @__PURE__ */ jsx("div", { className: "overflow-x-auto", "data-test": "operations-table", children: /* @__PURE__ */ jsxs(Table, { children: [
18
- /* @__PURE__ */ jsx(TableHeader, { children: /* @__PURE__ */ jsxs(TableRow, { children: [
19
- /* @__PURE__ */ jsx(TableHead, { children: "Operation" }),
20
- /* @__PURE__ */ jsx(TableHead, { children: "Sensitivity" }),
21
- /* @__PURE__ */ jsx(TableHead, { children: "Since" }),
22
- /* @__PURE__ */ jsx(TableHead, { children: "Used by" })
23
- ] }) }),
24
- /* @__PURE__ */ jsx(TableBody, { children: contract.operations.map((operation) => {
25
- const key = operationKey(operation);
26
- const usedBy = contract.usedBy[key] ?? [];
27
- const allowed = integration.operations.includes(key);
28
- return /* @__PURE__ */ jsxs(TableRow, { "data-test": "operation-row", children: [
29
- /* @__PURE__ */ jsxs(TableCell, { className: "min-w-56 whitespace-normal", children: [
30
- /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
31
- /* @__PURE__ */ jsx(
32
- Link,
27
+ import {
28
+ OperationListSkeleton,
29
+ OperationScope
30
+ } from "../components/operation-scope.js";
31
+ import { SegmentedControl } from "../components/segmented-control.js";
32
+ import {
33
+ EMPTY_FILTERS,
34
+ choicesAfterFilter,
35
+ commonSince,
36
+ effectSplit,
37
+ filterGroups,
38
+ groupOperations,
39
+ groupRuns,
40
+ groupsOpenByDefault,
41
+ isFiltered,
42
+ isGroupOpen,
43
+ listKeyTarget,
44
+ readFilters,
45
+ writeFilters
46
+ } from "../lib/operation-catalog.js";
47
+ import { runTargetHref } from "../lib/run-log-view.js";
48
+ function consoleBase(pathname) {
49
+ const at = pathname.lastIndexOf("/operations");
50
+ return at === -1 ? pathname : pathname.slice(0, at);
51
+ }
52
+ function isTypingTarget(target) {
53
+ if (!(target instanceof HTMLElement)) return false;
54
+ return target.isContentEditable || ["INPUT", "TEXTAREA", "SELECT"].includes(target.tagName);
55
+ }
56
+ const SEARCH_ID = "operations-search";
57
+ const NAV = "data-nav";
58
+ const SENSITIVE = /* @__PURE__ */ new Set([
59
+ "pii",
60
+ "financial"
61
+ ]);
62
+ const SENSITIVITY_LABEL = {
63
+ public: "Public",
64
+ internal: "Internal",
65
+ pii: "PII",
66
+ financial: "Financial"
67
+ };
68
+ function splitWords(operations) {
69
+ const { reads, writes } = effectSplit(operations);
70
+ return [
71
+ reads > 0 ? `${reads} read` : null,
72
+ writes > 0 ? `${writes} write` : null
73
+ ].filter(Boolean).join(" \xB7 ");
74
+ }
75
+ function groupPanelId(key) {
76
+ return `operations-group-${key.replace(/[^a-z0-9_-]/gi, "-")}`;
77
+ }
78
+ function OperationRow({
79
+ operation,
80
+ href,
81
+ allowed,
82
+ usedBy,
83
+ since
84
+ }) {
85
+ const write = operation.effect === "write";
86
+ const opaque = operation.opaque.input || operation.opaque.output;
87
+ return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(
88
+ Link,
89
+ {
90
+ href,
91
+ "data-test": "operation-row",
92
+ "data-operation": operationKey(operation),
93
+ "data-nav": "",
94
+ className: "hover:bg-muted focus-visible:bg-muted focus-visible:ring-ring group flex items-start gap-3 px-3 py-2.5 outline-none focus-visible:ring-2 focus-visible:ring-inset sm:items-center",
95
+ children: [
96
+ /* @__PURE__ */ jsx(
97
+ StatusBadge,
98
+ {
99
+ tone: write ? "warning" : "info",
100
+ "data-test": "operation-effect",
101
+ className: "mt-0.5 w-16 shrink-0 justify-start sm:mt-0",
102
+ children: write ? "Write" : "Read"
103
+ }
104
+ ),
105
+ /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-0.5 sm:flex-row sm:items-baseline sm:gap-3", children: [
106
+ /* @__PURE__ */ jsx("code", { className: "text-foreground shrink-0 font-mono text-sm font-medium break-all group-hover:underline sm:break-normal", children: operation.name }),
107
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground min-w-0 truncate text-sm", children: operation.description })
108
+ ] }),
109
+ /* @__PURE__ */ jsxs("div", { className: "hidden shrink-0 items-center gap-1.5 md:flex", children: [
110
+ SENSITIVE.has(operation.sensitivity) ? /* @__PURE__ */ jsx(Badge, { variant: "outline", title: "Data sensitivity", children: SENSITIVITY_LABEL[operation.sensitivity] }) : null,
111
+ opaque ? /* @__PURE__ */ jsx(
112
+ Badge,
113
+ {
114
+ variant: "outline",
115
+ title: "The contract does not describe this shape",
116
+ children: "Opaque"
117
+ }
118
+ ) : null,
119
+ usedBy > 0 ? /* @__PURE__ */ jsxs(Badge, { variant: "secondary", children: [
120
+ "Used by ",
121
+ usedBy
122
+ ] }) : null,
123
+ since ? /* @__PURE__ */ jsxs(Badge, { variant: "outline", children: [
124
+ "Since ",
125
+ since
126
+ ] }) : null,
127
+ allowed ? null : /* @__PURE__ */ jsx(Badge, { variant: "secondary", children: "Not in this experience" })
128
+ ] }),
129
+ /* @__PURE__ */ jsx(
130
+ Icon,
131
+ {
132
+ name: "caret-right",
133
+ "aria-hidden": true,
134
+ className: "text-muted-foreground mt-1 size-4 shrink-0 sm:mt-0"
135
+ }
136
+ )
137
+ ]
138
+ }
139
+ ) });
140
+ }
141
+ function ClosedGroup({
142
+ group,
143
+ onToggle
144
+ }) {
145
+ return /* @__PURE__ */ jsx("section", { "data-test": "operation-group", "data-group": group.key, children: /* @__PURE__ */ jsx("h3", { children: /* @__PURE__ */ jsxs(
146
+ CardButton,
147
+ {
148
+ layout: "bleed",
149
+ type: "button",
150
+ "aria-expanded": false,
151
+ "data-test": "operation-group-toggle",
152
+ "data-nav": "",
153
+ onClick: () => onToggle(group.key),
154
+ className: "w-full flex-row items-center gap-2.5 px-3 py-2.5 max-sm:gap-2",
155
+ children: [
156
+ /* @__PURE__ */ jsx(
157
+ Icon,
158
+ {
159
+ name: "caret-right",
160
+ "aria-hidden": true,
161
+ className: "text-muted-foreground size-4 shrink-0 max-sm:hidden"
162
+ }
163
+ ),
164
+ /* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-1 flex-col", children: [
165
+ /* @__PURE__ */ jsx("span", { className: "truncate text-sm font-medium", children: group.label }),
166
+ /* @__PURE__ */ jsx(
167
+ "span",
168
+ {
169
+ className: "text-muted-foreground truncate text-xs tabular-nums",
170
+ "data-test": "operation-group-split",
171
+ children: splitWords(group.operations)
172
+ }
173
+ )
174
+ ] }),
175
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground text-sm tabular-nums", children: group.operations.length })
176
+ ]
177
+ }
178
+ ) }) });
179
+ }
180
+ function OpenGroup({
181
+ group,
182
+ onToggle,
183
+ rowFor
184
+ }) {
185
+ const panelId = groupPanelId(group.key);
186
+ return /* @__PURE__ */ jsxs(
187
+ Card,
188
+ {
189
+ layout: "bleed",
190
+ render: /* @__PURE__ */ jsx("section", {}),
191
+ "data-test": "operation-group",
192
+ "data-group": group.key,
193
+ children: [
194
+ /* @__PURE__ */ jsx("h3", { className: "border-b", children: /* @__PURE__ */ jsxs(
195
+ Button,
196
+ {
197
+ type: "button",
198
+ variant: "ghost",
199
+ size: "lg",
200
+ "aria-expanded": true,
201
+ "aria-controls": panelId,
202
+ "data-test": "operation-group-toggle",
203
+ "data-nav": "",
204
+ onClick: () => onToggle(group.key),
205
+ className: "w-full justify-start gap-2 rounded-none px-3 focus-visible:ring-inset",
206
+ children: [
207
+ /* @__PURE__ */ jsx(
208
+ Icon,
209
+ {
210
+ name: "caret-right",
211
+ "aria-hidden": true,
212
+ className: "text-muted-foreground size-4 shrink-0 rotate-90"
213
+ }
214
+ ),
215
+ /* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: group.label }),
216
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground text-sm tabular-nums", children: group.operations.length }),
217
+ /* @__PURE__ */ jsx(
218
+ "span",
219
+ {
220
+ className: "text-muted-foreground ml-auto hidden text-xs font-normal tabular-nums sm:inline",
221
+ "data-test": "operation-group-split",
222
+ children: splitWords(group.operations)
223
+ }
224
+ )
225
+ ]
226
+ }
227
+ ) }),
228
+ /* @__PURE__ */ jsx("ul", { id: panelId, className: "divide-y", children: group.operations.map(rowFor) })
229
+ ]
230
+ }
231
+ );
232
+ }
233
+ function groupToggle(root, key) {
234
+ const group = [
235
+ ...root?.querySelectorAll("[data-group]") ?? []
236
+ ].find((element) => element.dataset.group === key);
237
+ return group?.querySelector('[data-test="operation-group-toggle"]') ?? null;
238
+ }
239
+ const CHOICES_KEY = "ekanos-harness:operation-groups:";
240
+ function loadChoices(integration) {
241
+ try {
242
+ const raw = window.sessionStorage.getItem(CHOICES_KEY + integration);
243
+ const parsed = raw ? JSON.parse(raw) : [];
244
+ if (!Array.isArray(parsed)) return /* @__PURE__ */ new Map();
245
+ return new Map(
246
+ parsed.filter(
247
+ (entry) => Array.isArray(entry) && typeof entry[0] === "string" && typeof entry[1] === "boolean"
248
+ )
249
+ );
250
+ } catch (error) {
251
+ console.warn("[harness] could not read the open operation groups:", error);
252
+ return /* @__PURE__ */ new Map();
253
+ }
254
+ }
255
+ function saveChoices(integration, choices) {
256
+ try {
257
+ window.sessionStorage.setItem(
258
+ CHOICES_KEY + integration,
259
+ JSON.stringify([...choices])
260
+ );
261
+ } catch (error) {
262
+ console.warn("[harness] could not keep the open operation groups:", error);
263
+ }
264
+ }
265
+ function OperationCatalog({
266
+ integration,
267
+ contract
268
+ }) {
269
+ const pathname = usePathname();
270
+ const searchParams = useSearchParams();
271
+ const listRef = useRef(null);
272
+ const [state, setState] = useState(() => ({
273
+ filters: readFilters(searchParams),
274
+ choices: loadChoices(integration.integration)
275
+ }));
276
+ const setChoices = (choices) => {
277
+ saveChoices(integration.integration, choices);
278
+ setState((current) => ({ ...current, choices }));
279
+ };
280
+ useEffect(() => {
281
+ const onKey = (event) => {
282
+ if (event.key !== "/" || event.metaKey || event.ctrlKey) return;
283
+ if (isTypingTarget(event.target)) return;
284
+ event.preventDefault();
285
+ document.getElementById(SEARCH_ID)?.focus();
286
+ };
287
+ document.addEventListener("keydown", onKey);
288
+ return () => document.removeEventListener("keydown", onKey);
289
+ }, []);
290
+ const operations = contract.operations;
291
+ const groups = useMemo(() => groupOperations(operations), [operations]);
292
+ const shared = useMemo(() => commonSince(operations), [operations]);
293
+ const visible = filterGroups(groups, state.filters);
294
+ const shown = visible.reduce(
295
+ (sum, group) => sum + group.operations.length,
296
+ 0
297
+ );
298
+ const filtered = isFiltered(state.filters);
299
+ const byDefault = groupsOpenByDefault(operations.length, state.filters);
300
+ const open = (key) => isGroupOpen(key, state.choices, byDefault);
301
+ const runs = groupRuns(visible, open);
302
+ const kinds = [...new Set(operations.map((operation) => operation.kind))];
303
+ const reads = operations.filter((operation) => operation.effect === "read");
304
+ const base = consoleBase(pathname);
305
+ const allOpen = visible.length > 0 && visible.every((group) => open(group.key));
306
+ const setFilters = (next) => {
307
+ const filters = { ...state.filters, ...next };
308
+ const choices = choicesAfterFilter(state.choices);
309
+ saveChoices(integration.integration, choices);
310
+ setState({ filters, choices });
311
+ window.history.replaceState(
312
+ null,
313
+ "",
314
+ `${pathname}${writeFilters(window.location.search, filters)}`
315
+ );
316
+ };
317
+ const toggleGroup = (key) => {
318
+ const choices = new Map(state.choices);
319
+ choices.set(key, !open(key));
320
+ flushSync(() => setChoices(choices));
321
+ groupToggle(listRef.current, key)?.focus({ preventScroll: true });
322
+ };
323
+ const onListKey = (event) => {
324
+ if (event.altKey || event.metaKey || event.ctrlKey) return;
325
+ const items = [
326
+ ...listRef.current?.querySelectorAll(`[${NAV}]`) ?? []
327
+ ];
328
+ const target = event.target;
329
+ if (target.id === SEARCH_ID) {
330
+ if (event.key !== "ArrowDown") return;
331
+ event.preventDefault();
332
+ items[0]?.focus();
333
+ return;
334
+ }
335
+ const current = items.indexOf(target);
336
+ if (current === -1) return;
337
+ const toggle = target.dataset.test === "operation-group-toggle";
338
+ const expanded = target.getAttribute("aria-expanded") === "true";
339
+ const groupKey = target.closest("[data-group]")?.getAttribute("data-group");
340
+ if (event.key === "ArrowRight" && toggle && !expanded && groupKey) {
341
+ event.preventDefault();
342
+ toggleGroup(groupKey);
343
+ return;
344
+ }
345
+ if (event.key === "ArrowLeft" && groupKey) {
346
+ event.preventDefault();
347
+ if (toggle && expanded) toggleGroup(groupKey);
348
+ else if (!toggle) {
349
+ groupToggle(listRef.current, groupKey)?.focus();
350
+ }
351
+ return;
352
+ }
353
+ const next = listKeyTarget(event.key, current, items.length);
354
+ if (next === null) return;
355
+ event.preventDefault();
356
+ items[next]?.focus();
357
+ items[next]?.scrollIntoView?.({ block: "nearest" });
358
+ };
359
+ const rowFor = (operation) => {
360
+ const key = operationKey(operation);
361
+ return /* @__PURE__ */ jsx(
362
+ OperationRow,
363
+ {
364
+ operation,
365
+ href: runTargetHref(base, key) ?? `${base}/operations/${key}`,
366
+ allowed: integration.operations.includes(key),
367
+ usedBy: (contract.usedBy[key] ?? []).length,
368
+ since: operation.since && operation.since !== shared ? operation.since : void 0
369
+ },
370
+ operation.id
371
+ );
372
+ };
373
+ return /* @__PURE__ */ jsxs(
374
+ "div",
375
+ {
376
+ ref: listRef,
377
+ className: "flex flex-col gap-4",
378
+ "data-test": "operations-catalog",
379
+ onKeyDown: onListKey,
380
+ children: [
381
+ /* @__PURE__ */ jsxs(
382
+ "div",
383
+ {
384
+ className: "bg-background sticky top-0 z-30 flex flex-col gap-2 border-b py-3 lg:flex-row lg:items-center lg:gap-3",
385
+ "data-test": "operations-toolbar",
386
+ children: [
387
+ /* @__PURE__ */ jsx(
388
+ SearchField,
389
+ {
390
+ id: SEARCH_ID,
391
+ value: state.filters.query,
392
+ onValueChange: (query) => setFilters({ query }),
393
+ "aria-label": "Search operations",
394
+ placeholder: "Search by name or description",
395
+ className: "lg:max-w-md lg:flex-1",
396
+ "data-test": "operations-search"
397
+ }
398
+ ),
399
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-x-3 gap-y-2 lg:flex-1", children: [
400
+ /* @__PURE__ */ jsx(
401
+ SegmentedControl,
402
+ {
403
+ label: "Effect",
404
+ testPrefix: "operations-effect",
405
+ value: state.filters.effect,
406
+ onChange: (effect) => setFilters({ effect }),
407
+ options: [
408
+ { value: "all", label: "All" },
409
+ {
410
+ value: "read",
411
+ label: /* @__PURE__ */ jsxs(Fragment, { children: [
412
+ "Read",
413
+ " ",
414
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground tabular-nums", children: reads.length })
415
+ ] })
416
+ },
417
+ {
418
+ value: "write",
419
+ label: /* @__PURE__ */ jsxs(Fragment, { children: [
420
+ "Write",
421
+ " ",
422
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground tabular-nums", children: operations.length - reads.length })
423
+ ] })
424
+ }
425
+ ]
426
+ }
427
+ ),
428
+ kinds.length > 1 ? /* @__PURE__ */ jsx(
429
+ SegmentedControl,
430
+ {
431
+ label: "Kind",
432
+ testPrefix: "operations-kind",
433
+ value: state.filters.kind,
434
+ onChange: (kind) => setFilters({ kind }),
435
+ options: [
436
+ { value: "all", label: "All kinds" },
437
+ ...kinds.map((kind) => ({
438
+ value: kind,
439
+ label: kind === "tool" ? "Tools" : "Actions"
440
+ }))
441
+ ]
442
+ }
443
+ ) : null,
444
+ /* @__PURE__ */ jsxs("div", { className: "ml-auto flex items-center gap-2", children: [
445
+ /* @__PURE__ */ jsx(
446
+ "p",
447
+ {
448
+ className: cn(
449
+ "text-muted-foreground text-sm tabular-nums",
450
+ filtered || "max-sm:sr-only"
451
+ ),
452
+ "aria-live": "polite",
453
+ "data-test": "operations-count",
454
+ children: filtered ? `${shown} of ${operations.length}` : `${operations.length} operations`
455
+ }
456
+ ),
457
+ visible.length > 1 ? /* @__PURE__ */ jsx(
458
+ Button,
459
+ {
460
+ type: "button",
461
+ variant: "ghost",
462
+ size: "sm",
463
+ "data-test": "operations-toggle-all",
464
+ onClick: () => setChoices(
465
+ new Map([
466
+ ...state.choices,
467
+ ...visible.map((group) => [group.key, !allOpen])
468
+ ])
469
+ ),
470
+ children: allOpen ? "Collapse all" : "Expand all"
471
+ }
472
+ ) : null
473
+ ] })
474
+ ] })
475
+ ]
476
+ }
477
+ ),
478
+ visible.length === 0 ? /* @__PURE__ */ jsxs(EmptyState, { "data-test": "operations-empty", children: [
479
+ /* @__PURE__ */ jsx(EmptyStateHeading, { children: "No operations match" }),
480
+ /* @__PURE__ */ jsx(EmptyStateText, { children: state.filters.query.trim() ? `Nothing in ${integration.integration} matches \u201C${state.filters.query.trim()}\u201D with these filters.` : "No operation has that effect and kind." }),
481
+ /* @__PURE__ */ jsx(
482
+ EmptyStateButton,
483
+ {
484
+ variant: "outline",
485
+ "data-test": "operations-clear-filters",
486
+ onClick: () => setFilters(EMPTY_FILTERS),
487
+ children: "Clear filters"
488
+ }
489
+ )
490
+ ] }) : /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", "data-test": "operations-table", children: [
491
+ byDefault || filtered ? null : /* @__PURE__ */ jsxs(
492
+ "p",
493
+ {
494
+ className: "text-muted-foreground text-sm",
495
+ "data-test": "operations-collapsed-hint",
496
+ children: [
497
+ visible.length,
498
+ " groups. Open a group, or search to see matching operations.",
499
+ /* @__PURE__ */ jsxs("span", { className: "max-sm:hidden", children: [
500
+ " ",
501
+ "Arrow keys move between groups and rows."
502
+ ] })
503
+ ]
504
+ }
505
+ ),
506
+ runs.map(
507
+ (run) => run.open ? /* @__PURE__ */ jsx(
508
+ OpenGroup,
33
509
  {
34
- href: `/integrations/${integration.integration}/operations/${operation.kind}/${operation.name}`,
35
- className: "break-all hover:underline",
36
- children: /* @__PURE__ */ jsx("code", { className: "text-sm font-medium", children: key })
37
- }
38
- ),
39
- /* @__PURE__ */ jsx(
40
- StatusBadge,
510
+ group: run.group,
511
+ onToggle: toggleGroup,
512
+ rowFor
513
+ },
514
+ run.group.key
515
+ ) : /* @__PURE__ */ jsx(
516
+ "div",
41
517
  {
42
- tone: operation.effect === "write" ? "warning" : "info",
43
- "data-test": "operation-effect",
44
- children: operation.effect === "write" ? "Write" : "Read"
45
- }
518
+ className: "grid grid-cols-2 gap-2 lg:grid-cols-3",
519
+ children: run.groups.map((group) => /* @__PURE__ */ jsx(
520
+ ClosedGroup,
521
+ {
522
+ group,
523
+ onToggle: toggleGroup
524
+ },
525
+ group.key
526
+ ))
527
+ },
528
+ `closed-${run.groups[0]?.key ?? ""}`
46
529
  )
47
- ] }),
48
- /* @__PURE__ */ jsx("span", { className: "text-muted-foreground block text-xs break-words whitespace-normal", children: operation.description }),
49
- operation.opaque.input || operation.opaque.output ? /* @__PURE__ */ jsx(Badge, { variant: "outline", className: "mt-1", children: "opaque" }) : null,
50
- allowed ? null : /* @__PURE__ */ jsx(Badge, { variant: "secondary", className: "mt-1 ml-1", children: "not in this experience's uses" })
51
- ] }),
52
- /* @__PURE__ */ jsx(TableCell, { className: "text-xs", children: operation.sensitivity }),
53
- /* @__PURE__ */ jsx(TableCell, { className: "text-xs", children: operation.since ?? "n/a" }),
54
- /* @__PURE__ */ jsx(TableCell, { className: "text-xs", children: usedBy.length === 0 ? "n/a" : usedBy.map((use) => use.title).join(", ") })
55
- ] }, operation.id);
56
- }) })
57
- ] }) }) });
530
+ )
531
+ ] })
532
+ ]
533
+ }
534
+ );
535
+ }
536
+ function IntegrationOperationsPage() {
537
+ return /* @__PURE__ */ jsx(OperationScope, { skeleton: /* @__PURE__ */ jsx(OperationListSkeleton, {}), children: ({ integration, contract }) => /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-6", "data-test": "page-Operations", children: [
538
+ /* @__PURE__ */ jsxs("header", { className: "flex flex-col gap-1", children: [
539
+ /* @__PURE__ */ jsx("h2", { className: "font-heading text-xl font-normal", children: "Operations" }),
540
+ /* @__PURE__ */ jsxs("p", { className: "text-muted-foreground text-sm", children: [
541
+ "Every tool and action in the ",
542
+ integration.integration,
543
+ " contract. Open one to run it against fixtures or your live connection."
544
+ ] })
545
+ ] }),
546
+ /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(OperationListSkeleton, {}), children: /* @__PURE__ */ jsx(OperationCatalog, { integration, contract }) })
547
+ ] }) });
58
548
  }
59
549
  export {
60
550
  IntegrationOperationsPage