@contractspec/example.integration-hub 3.7.7 → 3.8.2

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 (45) hide show
  1. package/README.md +4 -1
  2. package/dist/docs/index.js +2 -1
  3. package/dist/docs/integration-hub.docblock.js +2 -1
  4. package/dist/index.d.ts +1 -0
  5. package/dist/index.js +669 -177
  6. package/dist/integration-hub.feature.js +202 -0
  7. package/dist/node/docs/index.js +2 -1
  8. package/dist/node/docs/integration-hub.docblock.js +2 -1
  9. package/dist/node/index.js +669 -177
  10. package/dist/node/integration-hub.feature.js +202 -0
  11. package/dist/node/ui/IntegrationDashboard.js +646 -172
  12. package/dist/node/ui/IntegrationDashboard.visualizations.js +250 -0
  13. package/dist/node/ui/index.js +661 -177
  14. package/dist/node/ui/renderers/index.js +216 -5
  15. package/dist/node/ui/renderers/integration.markdown.js +216 -5
  16. package/dist/node/ui/tables/ConnectionsTable.js +211 -0
  17. package/dist/node/ui/tables/IntegrationTables.js +361 -0
  18. package/dist/node/ui/tables/SyncConfigsTable.js +230 -0
  19. package/dist/node/ui/tables/integration-table.shared.js +84 -0
  20. package/dist/node/visualizations/catalog.js +137 -0
  21. package/dist/node/visualizations/index.js +211 -0
  22. package/dist/node/visualizations/selectors.js +204 -0
  23. package/dist/ui/IntegrationDashboard.js +646 -172
  24. package/dist/ui/IntegrationDashboard.visualizations.d.ts +6 -0
  25. package/dist/ui/IntegrationDashboard.visualizations.js +251 -0
  26. package/dist/ui/index.js +661 -177
  27. package/dist/ui/renderers/index.js +216 -5
  28. package/dist/ui/renderers/integration.markdown.js +216 -5
  29. package/dist/ui/tables/ConnectionsTable.d.ts +4 -0
  30. package/dist/ui/tables/ConnectionsTable.js +212 -0
  31. package/dist/ui/tables/IntegrationTables.d.ts +2 -0
  32. package/dist/ui/tables/IntegrationTables.js +362 -0
  33. package/dist/ui/tables/IntegrationTables.smoke.test.d.ts +1 -0
  34. package/dist/ui/tables/SyncConfigsTable.d.ts +4 -0
  35. package/dist/ui/tables/SyncConfigsTable.js +231 -0
  36. package/dist/ui/tables/integration-table.shared.d.ts +18 -0
  37. package/dist/ui/tables/integration-table.shared.js +85 -0
  38. package/dist/visualizations/catalog.d.ts +11 -0
  39. package/dist/visualizations/catalog.js +138 -0
  40. package/dist/visualizations/index.d.ts +2 -0
  41. package/dist/visualizations/index.js +212 -0
  42. package/dist/visualizations/selectors.d.ts +10 -0
  43. package/dist/visualizations/selectors.js +205 -0
  44. package/dist/visualizations/selectors.test.d.ts +1 -0
  45. package/package.json +108 -10
package/dist/ui/index.js CHANGED
@@ -54,9 +54,257 @@ function useIntegrationData(projectId = "local-project") {
54
54
  // src/ui/hooks/index.ts
55
55
  "use client";
56
56
 
57
+ // src/visualizations/catalog.ts
58
+ import {
59
+ defineVisualization,
60
+ VisualizationRegistry
61
+ } from "@contractspec/lib.contracts-spec/visualizations";
62
+ var INTEGRATION_LIST_REF = {
63
+ key: "integration.list",
64
+ version: "1.0.0"
65
+ };
66
+ var CONNECTION_LIST_REF = {
67
+ key: "integration.connection.list",
68
+ version: "1.0.0"
69
+ };
70
+ var SYNC_CONFIG_REF = {
71
+ key: "integration.syncConfig.list",
72
+ version: "1.0.0"
73
+ };
74
+ var META = {
75
+ version: "1.0.0",
76
+ domain: "integration",
77
+ stability: "experimental",
78
+ owners: ["@example.integration-hub"],
79
+ tags: ["integration", "visualization", "sync"]
80
+ };
81
+ var IntegrationTypeVisualization = defineVisualization({
82
+ meta: {
83
+ ...META,
84
+ key: "integration-hub.visualization.integration-types",
85
+ title: "Integration Types",
86
+ description: "Distribution of configured integration categories.",
87
+ goal: "Show where integration coverage is concentrated.",
88
+ context: "Integration overview."
89
+ },
90
+ source: { primary: INTEGRATION_LIST_REF, resultPath: "data" },
91
+ visualization: {
92
+ kind: "pie",
93
+ nameDimension: "type",
94
+ valueMeasure: "count",
95
+ dimensions: [
96
+ { key: "type", label: "Type", dataPath: "type", type: "category" }
97
+ ],
98
+ measures: [
99
+ { key: "count", label: "Count", dataPath: "count", format: "number" }
100
+ ],
101
+ table: { caption: "Integration counts by type." }
102
+ }
103
+ });
104
+ var ConnectionStatusVisualization = defineVisualization({
105
+ meta: {
106
+ ...META,
107
+ key: "integration-hub.visualization.connection-status",
108
+ title: "Connection Status",
109
+ description: "Status distribution across configured connections.",
110
+ goal: "Highlight connection health and instability.",
111
+ context: "Connection monitoring."
112
+ },
113
+ source: { primary: CONNECTION_LIST_REF, resultPath: "data" },
114
+ visualization: {
115
+ kind: "cartesian",
116
+ variant: "bar",
117
+ xDimension: "status",
118
+ yMeasures: ["count"],
119
+ dimensions: [
120
+ { key: "status", label: "Status", dataPath: "status", type: "category" }
121
+ ],
122
+ measures: [
123
+ {
124
+ key: "count",
125
+ label: "Connections",
126
+ dataPath: "count",
127
+ format: "number",
128
+ color: "#1d4ed8"
129
+ }
130
+ ],
131
+ table: { caption: "Connection counts by status." }
132
+ }
133
+ });
134
+ var HealthySyncMetricVisualization = defineVisualization({
135
+ meta: {
136
+ ...META,
137
+ key: "integration-hub.visualization.sync-healthy",
138
+ title: "Healthy Syncs",
139
+ description: "Sync configurations currently healthy or recently successful.",
140
+ goal: "Summarize healthy synchronization capacity.",
141
+ context: "Sync-state comparison."
142
+ },
143
+ source: { primary: SYNC_CONFIG_REF, resultPath: "data" },
144
+ visualization: {
145
+ kind: "metric",
146
+ measure: "value",
147
+ measures: [
148
+ { key: "value", label: "Syncs", dataPath: "value", format: "number" }
149
+ ],
150
+ table: { caption: "Healthy sync count." }
151
+ }
152
+ });
153
+ var AttentionSyncMetricVisualization = defineVisualization({
154
+ meta: {
155
+ ...META,
156
+ key: "integration-hub.visualization.sync-attention",
157
+ title: "Attention Needed",
158
+ description: "Sync configurations paused, failing, or otherwise needing review.",
159
+ goal: "Summarize syncs needing action.",
160
+ context: "Sync-state comparison."
161
+ },
162
+ source: { primary: SYNC_CONFIG_REF, resultPath: "data" },
163
+ visualization: {
164
+ kind: "metric",
165
+ measure: "value",
166
+ measures: [
167
+ { key: "value", label: "Syncs", dataPath: "value", format: "number" }
168
+ ],
169
+ table: { caption: "Syncs requiring attention." }
170
+ }
171
+ });
172
+ var IntegrationVisualizationSpecs = [
173
+ IntegrationTypeVisualization,
174
+ ConnectionStatusVisualization,
175
+ HealthySyncMetricVisualization,
176
+ AttentionSyncMetricVisualization
177
+ ];
178
+ var IntegrationVisualizationRegistry = new VisualizationRegistry([
179
+ ...IntegrationVisualizationSpecs
180
+ ]);
181
+ var IntegrationVisualizationRefs = IntegrationVisualizationSpecs.map((spec) => ({
182
+ key: spec.meta.key,
183
+ version: spec.meta.version
184
+ }));
185
+
186
+ // src/visualizations/selectors.ts
187
+ function isHealthySync(status) {
188
+ return status === "ACTIVE" || status === "SUCCESS";
189
+ }
190
+ function createIntegrationVisualizationSections(integrations, connections, syncConfigs) {
191
+ const integrationTypes = new Map;
192
+ const connectionStatuses = new Map;
193
+ let healthySyncs = 0;
194
+ let attentionSyncs = 0;
195
+ for (const integration of integrations) {
196
+ integrationTypes.set(integration.type, (integrationTypes.get(integration.type) ?? 0) + 1);
197
+ }
198
+ for (const connection of connections) {
199
+ connectionStatuses.set(connection.status, (connectionStatuses.get(connection.status) ?? 0) + 1);
200
+ }
201
+ for (const syncConfig of syncConfigs) {
202
+ if (isHealthySync(syncConfig.status)) {
203
+ healthySyncs += 1;
204
+ } else {
205
+ attentionSyncs += 1;
206
+ }
207
+ }
208
+ const primaryItems = [
209
+ {
210
+ key: "integration-types",
211
+ spec: IntegrationTypeVisualization,
212
+ data: {
213
+ data: Array.from(integrationTypes.entries()).map(([type, count]) => ({
214
+ type,
215
+ count
216
+ }))
217
+ },
218
+ title: "Integration Types",
219
+ description: "Configured integrations grouped by category.",
220
+ height: 260
221
+ },
222
+ {
223
+ key: "connection-status",
224
+ spec: ConnectionStatusVisualization,
225
+ data: {
226
+ data: Array.from(connectionStatuses.entries()).map(([status, count]) => ({
227
+ status,
228
+ count
229
+ }))
230
+ },
231
+ title: "Connection Status",
232
+ description: "Operational health across current connections."
233
+ }
234
+ ];
235
+ const comparisonItems = [
236
+ {
237
+ key: "healthy-syncs",
238
+ spec: HealthySyncMetricVisualization,
239
+ data: { data: [{ value: healthySyncs }] },
240
+ title: "Healthy Syncs",
241
+ description: "Active or recently successful sync configurations.",
242
+ height: 200
243
+ },
244
+ {
245
+ key: "attention-syncs",
246
+ spec: AttentionSyncMetricVisualization,
247
+ data: { data: [{ value: attentionSyncs }] },
248
+ title: "Attention Needed",
249
+ description: "Paused, failed, or degraded sync configurations.",
250
+ height: 200
251
+ }
252
+ ];
253
+ return {
254
+ primaryItems,
255
+ comparisonItems
256
+ };
257
+ }
258
+ // src/ui/IntegrationDashboard.visualizations.tsx
259
+ import {
260
+ ComparisonView,
261
+ VisualizationCard,
262
+ VisualizationGrid
263
+ } from "@contractspec/lib.design-system";
264
+ import { jsxDEV } from "react/jsx-dev-runtime";
265
+ "use client";
266
+ function IntegrationVisualizationOverview({
267
+ integrations,
268
+ connections,
269
+ syncConfigs
270
+ }) {
271
+ const { primaryItems, comparisonItems } = createIntegrationVisualizationSections(integrations, connections, syncConfigs);
272
+ return /* @__PURE__ */ jsxDEV("section", {
273
+ className: "space-y-4",
274
+ children: [
275
+ /* @__PURE__ */ jsxDEV("div", {
276
+ children: [
277
+ /* @__PURE__ */ jsxDEV("h3", {
278
+ className: "font-semibold text-lg",
279
+ children: "Integration Visualizations"
280
+ }, undefined, false, undefined, this),
281
+ /* @__PURE__ */ jsxDEV("p", {
282
+ className: "text-muted-foreground text-sm",
283
+ children: "Contract-backed charts for integration coverage and sync health."
284
+ }, undefined, false, undefined, this)
285
+ ]
286
+ }, undefined, true, undefined, this),
287
+ /* @__PURE__ */ jsxDEV(VisualizationGrid, {
288
+ children: primaryItems.map((item) => /* @__PURE__ */ jsxDEV(VisualizationCard, {
289
+ data: item.data,
290
+ description: item.description,
291
+ height: item.height,
292
+ spec: item.spec,
293
+ title: item.title
294
+ }, item.key, false, undefined, this))
295
+ }, undefined, false, undefined, this),
296
+ /* @__PURE__ */ jsxDEV(ComparisonView, {
297
+ description: "Comparison surface for healthy versus attention-needed syncs.",
298
+ items: comparisonItems,
299
+ title: "Sync-State Comparison"
300
+ }, undefined, false, undefined, this)
301
+ ]
302
+ }, undefined, true, undefined, this);
303
+ }
304
+
57
305
  // src/ui/IntegrationHubChat.tsx
58
306
  import { ChatWithSidebar } from "@contractspec/module.ai-chat";
59
- import { jsxDEV } from "react/jsx-dev-runtime";
307
+ import { jsxDEV as jsxDEV2 } from "react/jsx-dev-runtime";
60
308
  "use client";
61
309
  var DEFAULT_SUGGESTIONS = [
62
310
  "List my integrations",
@@ -72,9 +320,9 @@ function IntegrationHubChat({
72
320
  systemPrompt = DEFAULT_SYSTEM_PROMPT,
73
321
  className
74
322
  }) {
75
- return /* @__PURE__ */ jsxDEV("div", {
323
+ return /* @__PURE__ */ jsxDEV2("div", {
76
324
  className: className ?? "flex h-[500px] flex-col",
77
- children: /* @__PURE__ */ jsxDEV(ChatWithSidebar, {
325
+ children: /* @__PURE__ */ jsxDEV2(ChatWithSidebar, {
78
326
  className: "flex-1",
79
327
  systemPrompt,
80
328
  proxyUrl,
@@ -86,16 +334,373 @@ function IntegrationHubChat({
86
334
  }, undefined, false, undefined, this);
87
335
  }
88
336
 
337
+ // src/ui/tables/integration-table.shared.tsx
338
+ import { Button } from "@contractspec/lib.design-system";
339
+ import { Badge } from "@contractspec/lib.ui-kit-web/ui/badge";
340
+ import { HStack } from "@contractspec/lib.ui-kit-web/ui/stack";
341
+ import { jsxDEV as jsxDEV3 } from "react/jsx-dev-runtime";
342
+ "use client";
343
+ var STATUS_VARIANTS = {
344
+ ACTIVE: "default",
345
+ CONNECTED: "default",
346
+ SUCCESS: "default",
347
+ PENDING: "secondary",
348
+ PAUSED: "secondary",
349
+ ERROR: "destructive",
350
+ DISCONNECTED: "outline"
351
+ };
352
+ function formatDateTime(value) {
353
+ return value ? value.toLocaleString() : "Never";
354
+ }
355
+ function formatJson(value) {
356
+ return value ? JSON.stringify(value, null, 2) : "No configuration";
357
+ }
358
+ function StatusBadge({ status }) {
359
+ return /* @__PURE__ */ jsxDEV3(Badge, {
360
+ variant: STATUS_VARIANTS[status] ?? "outline",
361
+ children: status
362
+ }, undefined, false, undefined, this);
363
+ }
364
+ function IntegrationTableToolbar({
365
+ controller,
366
+ label,
367
+ toggleColumnId,
368
+ toggleVisibleLabel,
369
+ toggleHiddenLabel,
370
+ pinColumnId,
371
+ pinLabel,
372
+ resizeColumnId,
373
+ resizeLabel
374
+ }) {
375
+ const firstRow = controller.rows[0];
376
+ const toggleColumn = controller.columns.find((column) => column.id === toggleColumnId);
377
+ const pinColumn = controller.columns.find((column) => column.id === pinColumnId);
378
+ const resizeColumn = controller.columns.find((column) => column.id === resizeColumnId);
379
+ const pinTarget = pinColumn?.pinState === "left" ? false : "left";
380
+ return /* @__PURE__ */ jsxDEV3(HStack, {
381
+ gap: "sm",
382
+ className: "flex-wrap",
383
+ children: [
384
+ /* @__PURE__ */ jsxDEV3(Badge, {
385
+ variant: "outline",
386
+ children: label
387
+ }, undefined, false, undefined, this),
388
+ /* @__PURE__ */ jsxDEV3(Button, {
389
+ variant: "outline",
390
+ size: "sm",
391
+ onPress: () => firstRow?.toggleExpanded?.(!firstRow?.isExpanded),
392
+ children: "Expand First Row"
393
+ }, undefined, false, undefined, this),
394
+ /* @__PURE__ */ jsxDEV3(Button, {
395
+ variant: "outline",
396
+ size: "sm",
397
+ onPress: () => toggleColumn?.toggleVisibility?.(!toggleColumn?.visible),
398
+ children: toggleColumn?.visible ? toggleVisibleLabel : toggleHiddenLabel
399
+ }, undefined, false, undefined, this),
400
+ /* @__PURE__ */ jsxDEV3(Button, {
401
+ variant: "outline",
402
+ size: "sm",
403
+ onPress: () => pinColumn?.pin?.(pinTarget),
404
+ children: pinColumn?.pinState === "left" ? `Unpin ${pinLabel}` : `Pin ${pinLabel}`
405
+ }, undefined, false, undefined, this),
406
+ /* @__PURE__ */ jsxDEV3(Button, {
407
+ variant: "outline",
408
+ size: "sm",
409
+ onPress: () => resizeColumn?.resizeBy?.(40),
410
+ children: resizeLabel
411
+ }, undefined, false, undefined, this)
412
+ ]
413
+ }, undefined, true, undefined, this);
414
+ }
415
+
416
+ // src/ui/tables/ConnectionsTable.tsx
417
+ import { DataTable } from "@contractspec/lib.design-system";
418
+ import { useContractTable } from "@contractspec/lib.presentation-runtime-react";
419
+ import { VStack } from "@contractspec/lib.ui-kit-web/ui/stack";
420
+ import { Text } from "@contractspec/lib.ui-kit-web/ui/text";
421
+ import { jsxDEV as jsxDEV4 } from "react/jsx-dev-runtime";
422
+ "use client";
423
+ function ConnectionsTable({
424
+ connections
425
+ }) {
426
+ const controller = useContractTable({
427
+ data: connections,
428
+ columns: [
429
+ {
430
+ id: "connection",
431
+ header: "Connection",
432
+ label: "Connection",
433
+ accessor: (connection) => connection.name,
434
+ cell: ({ item }) => /* @__PURE__ */ jsxDEV4(VStack, {
435
+ gap: "xs",
436
+ children: [
437
+ /* @__PURE__ */ jsxDEV4(Text, {
438
+ className: "font-medium text-sm",
439
+ children: item.name
440
+ }, undefined, false, undefined, this),
441
+ /* @__PURE__ */ jsxDEV4(Text, {
442
+ className: "text-muted-foreground text-xs",
443
+ children: [
444
+ "Created ",
445
+ item.createdAt.toLocaleDateString()
446
+ ]
447
+ }, undefined, true, undefined, this)
448
+ ]
449
+ }, undefined, true, undefined, this),
450
+ size: 240,
451
+ minSize: 180,
452
+ canSort: true,
453
+ canPin: true,
454
+ canResize: true
455
+ },
456
+ {
457
+ id: "status",
458
+ header: "Status",
459
+ label: "Status",
460
+ accessorKey: "status",
461
+ cell: ({ value }) => /* @__PURE__ */ jsxDEV4(StatusBadge, {
462
+ status: String(value)
463
+ }, undefined, false, undefined, this),
464
+ size: 150,
465
+ canSort: true,
466
+ canPin: true,
467
+ canResize: true
468
+ },
469
+ {
470
+ id: "lastSyncAt",
471
+ header: "Last Sync",
472
+ label: "Last Sync",
473
+ accessor: (connection) => connection.lastSyncAt?.getTime() ?? 0,
474
+ cell: ({ item }) => formatDateTime(item.lastSyncAt),
475
+ size: 200,
476
+ canSort: true,
477
+ canHide: true,
478
+ canResize: true
479
+ },
480
+ {
481
+ id: "errorMessage",
482
+ header: "Errors",
483
+ label: "Errors",
484
+ accessor: (connection) => connection.errorMessage ?? "",
485
+ cell: ({ value }) => String(value || "No errors"),
486
+ size: 240,
487
+ canHide: true,
488
+ canResize: true
489
+ }
490
+ ],
491
+ initialState: {
492
+ pagination: { pageIndex: 0, pageSize: 3 },
493
+ columnVisibility: { errorMessage: false },
494
+ columnPinning: { left: ["connection"], right: [] }
495
+ },
496
+ renderExpandedContent: (connection) => /* @__PURE__ */ jsxDEV4(VStack, {
497
+ gap: "sm",
498
+ className: "py-2",
499
+ children: [
500
+ /* @__PURE__ */ jsxDEV4(Text, {
501
+ className: "font-medium text-sm",
502
+ children: "Credentials"
503
+ }, undefined, false, undefined, this),
504
+ /* @__PURE__ */ jsxDEV4("pre", {
505
+ className: "overflow-auto rounded-md bg-muted/40 p-3 text-xs",
506
+ children: formatJson(connection.credentials)
507
+ }, undefined, false, undefined, this),
508
+ /* @__PURE__ */ jsxDEV4(Text, {
509
+ className: "font-medium text-sm",
510
+ children: "Config"
511
+ }, undefined, false, undefined, this),
512
+ /* @__PURE__ */ jsxDEV4("pre", {
513
+ className: "overflow-auto rounded-md bg-muted/40 p-3 text-xs",
514
+ children: formatJson(connection.config)
515
+ }, undefined, false, undefined, this),
516
+ /* @__PURE__ */ jsxDEV4(Text, {
517
+ className: "text-muted-foreground text-sm",
518
+ children: connection.errorMessage ?? "No sync errors recorded."
519
+ }, undefined, false, undefined, this)
520
+ ]
521
+ }, undefined, true, undefined, this),
522
+ getCanExpand: () => true
523
+ });
524
+ return /* @__PURE__ */ jsxDEV4(DataTable, {
525
+ controller,
526
+ title: "Connections",
527
+ description: "Client-mode ContractSpec table with visibility, pinning, resizing, and expanded diagnostics.",
528
+ toolbar: /* @__PURE__ */ jsxDEV4(IntegrationTableToolbar, {
529
+ controller,
530
+ label: `${connections.length} total connections`,
531
+ toggleColumnId: "errorMessage",
532
+ toggleVisibleLabel: "Hide Error Column",
533
+ toggleHiddenLabel: "Show Error Column",
534
+ pinColumnId: "status",
535
+ pinLabel: "Status",
536
+ resizeColumnId: "connection",
537
+ resizeLabel: "Widen Connection"
538
+ }, undefined, false, undefined, this),
539
+ emptyState: /* @__PURE__ */ jsxDEV4("div", {
540
+ className: "rounded-md border border-dashed p-8 text-center text-muted-foreground text-sm",
541
+ children: "No connections found"
542
+ }, undefined, false, undefined, this)
543
+ }, undefined, false, undefined, this);
544
+ }
545
+
546
+ // src/ui/tables/SyncConfigsTable.tsx
547
+ import { DataTable as DataTable2 } from "@contractspec/lib.design-system";
548
+ import { useContractTable as useContractTable2 } from "@contractspec/lib.presentation-runtime-react";
549
+ import { VStack as VStack2 } from "@contractspec/lib.ui-kit-web/ui/stack";
550
+ import { Text as Text2 } from "@contractspec/lib.ui-kit-web/ui/text";
551
+ import { jsxDEV as jsxDEV5 } from "react/jsx-dev-runtime";
552
+ "use client";
553
+ function SyncConfigsTable({
554
+ syncConfigs
555
+ }) {
556
+ const controller = useContractTable2({
557
+ data: syncConfigs,
558
+ columns: [
559
+ {
560
+ id: "sync",
561
+ header: "Sync Config",
562
+ label: "Sync Config",
563
+ accessor: (sync) => sync.name,
564
+ cell: ({ item }) => /* @__PURE__ */ jsxDEV5(VStack2, {
565
+ gap: "xs",
566
+ children: [
567
+ /* @__PURE__ */ jsxDEV5(Text2, {
568
+ className: "font-medium text-sm",
569
+ children: item.name
570
+ }, undefined, false, undefined, this),
571
+ /* @__PURE__ */ jsxDEV5(Text2, {
572
+ className: "text-muted-foreground text-xs",
573
+ children: [
574
+ item.sourceEntity,
575
+ " \u2192 ",
576
+ item.targetEntity
577
+ ]
578
+ }, undefined, true, undefined, this)
579
+ ]
580
+ }, undefined, true, undefined, this),
581
+ size: 260,
582
+ minSize: 200,
583
+ canSort: true,
584
+ canPin: true,
585
+ canResize: true
586
+ },
587
+ {
588
+ id: "frequency",
589
+ header: "Frequency",
590
+ label: "Frequency",
591
+ accessorKey: "frequency",
592
+ size: 160,
593
+ canSort: true,
594
+ canHide: true,
595
+ canResize: true
596
+ },
597
+ {
598
+ id: "status",
599
+ header: "Status",
600
+ label: "Status",
601
+ accessorKey: "status",
602
+ cell: ({ value }) => /* @__PURE__ */ jsxDEV5(StatusBadge, {
603
+ status: String(value)
604
+ }, undefined, false, undefined, this),
605
+ size: 150,
606
+ canSort: true,
607
+ canPin: true,
608
+ canResize: true
609
+ },
610
+ {
611
+ id: "recordsSynced",
612
+ header: "Records",
613
+ label: "Records",
614
+ accessorKey: "recordsSynced",
615
+ align: "right",
616
+ size: 140,
617
+ canSort: true,
618
+ canResize: true
619
+ },
620
+ {
621
+ id: "lastRunAt",
622
+ header: "Last Run",
623
+ label: "Last Run",
624
+ accessor: (sync) => sync.lastRunAt?.getTime() ?? 0,
625
+ cell: ({ item }) => formatDateTime(item.lastRunAt),
626
+ size: 200,
627
+ canSort: true,
628
+ canHide: true,
629
+ canResize: true
630
+ }
631
+ ],
632
+ initialState: {
633
+ pagination: { pageIndex: 0, pageSize: 3 },
634
+ columnVisibility: { lastRunAt: false },
635
+ columnPinning: { left: ["sync"], right: [] }
636
+ },
637
+ renderExpandedContent: (sync) => /* @__PURE__ */ jsxDEV5(VStack2, {
638
+ gap: "sm",
639
+ className: "py-2",
640
+ children: [
641
+ /* @__PURE__ */ jsxDEV5(Text2, {
642
+ className: "text-muted-foreground text-sm",
643
+ children: [
644
+ "Connection ",
645
+ sync.connectionId
646
+ ]
647
+ }, undefined, true, undefined, this),
648
+ /* @__PURE__ */ jsxDEV5(Text2, {
649
+ className: "text-muted-foreground text-sm",
650
+ children: [
651
+ "Last run: ",
652
+ formatDateTime(sync.lastRunAt)
653
+ ]
654
+ }, undefined, true, undefined, this),
655
+ /* @__PURE__ */ jsxDEV5(Text2, {
656
+ className: "text-muted-foreground text-sm",
657
+ children: [
658
+ "Last status: ",
659
+ sync.lastRunStatus ?? "No runs recorded"
660
+ ]
661
+ }, undefined, true, undefined, this),
662
+ /* @__PURE__ */ jsxDEV5(Text2, {
663
+ className: "text-muted-foreground text-sm",
664
+ children: [
665
+ "Updated ",
666
+ sync.updatedAt.toLocaleString()
667
+ ]
668
+ }, undefined, true, undefined, this)
669
+ ]
670
+ }, undefined, true, undefined, this),
671
+ getCanExpand: () => true
672
+ });
673
+ return /* @__PURE__ */ jsxDEV5(DataTable2, {
674
+ controller,
675
+ title: "Sync Configs",
676
+ description: "Shared table primitives applied to sync monitoring without changing the surrounding dashboard layout.",
677
+ toolbar: /* @__PURE__ */ jsxDEV5(IntegrationTableToolbar, {
678
+ controller,
679
+ label: `${syncConfigs.length} syncs`,
680
+ toggleColumnId: "lastRunAt",
681
+ toggleVisibleLabel: "Hide Last Run",
682
+ toggleHiddenLabel: "Show Last Run",
683
+ pinColumnId: "status",
684
+ pinLabel: "Status",
685
+ resizeColumnId: "sync",
686
+ resizeLabel: "Widen Sync"
687
+ }, undefined, false, undefined, this),
688
+ emptyState: /* @__PURE__ */ jsxDEV5("div", {
689
+ className: "rounded-md border border-dashed p-8 text-center text-muted-foreground text-sm",
690
+ children: "No sync configurations found"
691
+ }, undefined, false, undefined, this)
692
+ }, undefined, false, undefined, this);
693
+ }
89
694
  // src/ui/IntegrationDashboard.tsx
90
695
  import {
91
- Button,
696
+ Button as Button2,
92
697
  ErrorState,
93
698
  LoaderBlock,
94
699
  StatCard,
95
700
  StatCardGroup
96
701
  } from "@contractspec/lib.design-system";
97
702
  import { useState as useState2 } from "react";
98
- import { jsxDEV as jsxDEV2 } from "react/jsx-dev-runtime";
703
+ import { jsxDEV as jsxDEV6 } from "react/jsx-dev-runtime";
99
704
  "use client";
100
705
  var STATUS_COLORS = {
101
706
  ACTIVE: "bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400",
@@ -132,32 +737,32 @@ function IntegrationDashboard() {
132
737
  { id: "chat", label: "Chat", icon: "\uD83D\uDCAC" }
133
738
  ];
134
739
  if (loading) {
135
- return /* @__PURE__ */ jsxDEV2(LoaderBlock, {
740
+ return /* @__PURE__ */ jsxDEV6(LoaderBlock, {
136
741
  label: "Loading Integrations..."
137
742
  }, undefined, false, undefined, this);
138
743
  }
139
744
  if (error) {
140
- return /* @__PURE__ */ jsxDEV2(ErrorState, {
745
+ return /* @__PURE__ */ jsxDEV6(ErrorState, {
141
746
  title: "Failed to load Integrations",
142
747
  description: error.message,
143
748
  onRetry: refetch,
144
749
  retryLabel: "Retry"
145
750
  }, undefined, false, undefined, this);
146
751
  }
147
- return /* @__PURE__ */ jsxDEV2("div", {
752
+ return /* @__PURE__ */ jsxDEV6("div", {
148
753
  className: "space-y-6",
149
754
  children: [
150
- /* @__PURE__ */ jsxDEV2("div", {
755
+ /* @__PURE__ */ jsxDEV6("div", {
151
756
  className: "flex items-center justify-between",
152
757
  children: [
153
- /* @__PURE__ */ jsxDEV2("h2", {
758
+ /* @__PURE__ */ jsxDEV6("h2", {
154
759
  className: "font-bold text-2xl",
155
760
  children: "Integration Hub"
156
761
  }, undefined, false, undefined, this),
157
- /* @__PURE__ */ jsxDEV2(Button, {
762
+ /* @__PURE__ */ jsxDEV6(Button2, {
158
763
  onClick: () => alert("Add integration modal"),
159
764
  children: [
160
- /* @__PURE__ */ jsxDEV2("span", {
765
+ /* @__PURE__ */ jsxDEV6("span", {
161
766
  className: "mr-2",
162
767
  children: "+"
163
768
  }, undefined, false, undefined, this),
@@ -166,66 +771,71 @@ function IntegrationDashboard() {
166
771
  }, undefined, true, undefined, this)
167
772
  ]
168
773
  }, undefined, true, undefined, this),
169
- /* @__PURE__ */ jsxDEV2(StatCardGroup, {
774
+ /* @__PURE__ */ jsxDEV6(StatCardGroup, {
170
775
  children: [
171
- /* @__PURE__ */ jsxDEV2(StatCard, {
776
+ /* @__PURE__ */ jsxDEV6(StatCard, {
172
777
  label: "Integrations",
173
778
  value: stats.totalIntegrations,
174
779
  hint: `${stats.activeIntegrations} active`
175
780
  }, undefined, false, undefined, this),
176
- /* @__PURE__ */ jsxDEV2(StatCard, {
781
+ /* @__PURE__ */ jsxDEV6(StatCard, {
177
782
  label: "Connections",
178
783
  value: stats.totalConnections,
179
784
  hint: `${stats.connectedCount} connected`
180
785
  }, undefined, false, undefined, this),
181
- /* @__PURE__ */ jsxDEV2(StatCard, {
786
+ /* @__PURE__ */ jsxDEV6(StatCard, {
182
787
  label: "Syncs",
183
788
  value: stats.totalSyncs,
184
789
  hint: `${stats.activeSyncs} active`
185
790
  }, undefined, false, undefined, this)
186
791
  ]
187
792
  }, undefined, true, undefined, this),
188
- /* @__PURE__ */ jsxDEV2("nav", {
793
+ /* @__PURE__ */ jsxDEV6(IntegrationVisualizationOverview, {
794
+ connections,
795
+ integrations,
796
+ syncConfigs
797
+ }, undefined, false, undefined, this),
798
+ /* @__PURE__ */ jsxDEV6("nav", {
189
799
  className: "flex gap-1 rounded-lg bg-muted p-1",
190
800
  role: "tablist",
191
- children: tabs.map((tab) => /* @__PURE__ */ jsxDEV2(Button, {
801
+ children: tabs.map((tab) => /* @__PURE__ */ jsxDEV6(Button2, {
192
802
  type: "button",
193
803
  role: "tab",
194
804
  "aria-selected": activeTab === tab.id,
195
805
  onClick: () => setActiveTab(tab.id),
196
806
  className: `flex flex-1 items-center justify-center gap-2 rounded-md px-4 py-2 font-medium text-sm transition-colors ${activeTab === tab.id ? "bg-background text-foreground shadow-sm" : "text-muted-foreground hover:text-foreground"}`,
197
807
  children: [
198
- /* @__PURE__ */ jsxDEV2("span", {
808
+ /* @__PURE__ */ jsxDEV6("span", {
199
809
  children: tab.icon
200
810
  }, undefined, false, undefined, this),
201
811
  tab.label
202
812
  ]
203
813
  }, tab.id, true, undefined, this))
204
814
  }, undefined, false, undefined, this),
205
- /* @__PURE__ */ jsxDEV2("div", {
815
+ /* @__PURE__ */ jsxDEV6("div", {
206
816
  className: "min-h-[400px]",
207
817
  role: "tabpanel",
208
818
  children: [
209
- activeTab === "integrations" && /* @__PURE__ */ jsxDEV2("div", {
819
+ activeTab === "integrations" && /* @__PURE__ */ jsxDEV6("div", {
210
820
  className: "grid gap-4 sm:grid-cols-2 lg:grid-cols-3",
211
821
  children: [
212
- integrations.map((integration) => /* @__PURE__ */ jsxDEV2("div", {
822
+ integrations.map((integration) => /* @__PURE__ */ jsxDEV6("div", {
213
823
  className: "cursor-pointer rounded-lg border border-border bg-card p-4 transition-colors hover:bg-muted/50",
214
824
  children: [
215
- /* @__PURE__ */ jsxDEV2("div", {
825
+ /* @__PURE__ */ jsxDEV6("div", {
216
826
  className: "mb-3 flex items-center gap-3",
217
827
  children: [
218
- /* @__PURE__ */ jsxDEV2("span", {
828
+ /* @__PURE__ */ jsxDEV6("span", {
219
829
  className: "text-2xl",
220
830
  children: TYPE_ICONS[integration.type] ?? "\u2699\uFE0F"
221
831
  }, undefined, false, undefined, this),
222
- /* @__PURE__ */ jsxDEV2("div", {
832
+ /* @__PURE__ */ jsxDEV6("div", {
223
833
  children: [
224
- /* @__PURE__ */ jsxDEV2("h3", {
834
+ /* @__PURE__ */ jsxDEV6("h3", {
225
835
  className: "font-medium",
226
836
  children: integration.name
227
837
  }, undefined, false, undefined, this),
228
- /* @__PURE__ */ jsxDEV2("p", {
838
+ /* @__PURE__ */ jsxDEV6("p", {
229
839
  className: "text-muted-foreground text-sm",
230
840
  children: integration.type
231
841
  }, undefined, false, undefined, this)
@@ -233,14 +843,14 @@ function IntegrationDashboard() {
233
843
  }, undefined, true, undefined, this)
234
844
  ]
235
845
  }, undefined, true, undefined, this),
236
- /* @__PURE__ */ jsxDEV2("div", {
846
+ /* @__PURE__ */ jsxDEV6("div", {
237
847
  className: "flex items-center justify-between",
238
848
  children: [
239
- /* @__PURE__ */ jsxDEV2("span", {
849
+ /* @__PURE__ */ jsxDEV6("span", {
240
850
  className: `inline-flex rounded-full px-2 py-0.5 font-medium text-xs ${STATUS_COLORS[integration.status] ?? ""}`,
241
851
  children: integration.status
242
852
  }, undefined, false, undefined, this),
243
- /* @__PURE__ */ jsxDEV2("span", {
853
+ /* @__PURE__ */ jsxDEV6("span", {
244
854
  className: "text-muted-foreground text-xs",
245
855
  children: integration.createdAt.toLocaleDateString()
246
856
  }, undefined, false, undefined, this)
@@ -248,75 +858,16 @@ function IntegrationDashboard() {
248
858
  }, undefined, true, undefined, this)
249
859
  ]
250
860
  }, integration.id, true, undefined, this)),
251
- integrations.length === 0 && /* @__PURE__ */ jsxDEV2("div", {
861
+ integrations.length === 0 && /* @__PURE__ */ jsxDEV6("div", {
252
862
  className: "col-span-full flex h-64 items-center justify-center text-muted-foreground",
253
863
  children: "No integrations configured"
254
864
  }, undefined, false, undefined, this)
255
865
  ]
256
866
  }, undefined, true, undefined, this),
257
- activeTab === "connections" && /* @__PURE__ */ jsxDEV2("div", {
258
- className: "rounded-lg border border-border",
259
- children: /* @__PURE__ */ jsxDEV2("table", {
260
- className: "w-full",
261
- children: [
262
- /* @__PURE__ */ jsxDEV2("thead", {
263
- className: "border-border border-b bg-muted/30",
264
- children: /* @__PURE__ */ jsxDEV2("tr", {
265
- children: [
266
- /* @__PURE__ */ jsxDEV2("th", {
267
- className: "px-4 py-3 text-left font-medium text-sm",
268
- children: "Connection"
269
- }, undefined, false, undefined, this),
270
- /* @__PURE__ */ jsxDEV2("th", {
271
- className: "px-4 py-3 text-left font-medium text-sm",
272
- children: "Status"
273
- }, undefined, false, undefined, this),
274
- /* @__PURE__ */ jsxDEV2("th", {
275
- className: "px-4 py-3 text-left font-medium text-sm",
276
- children: "Last Sync"
277
- }, undefined, false, undefined, this)
278
- ]
279
- }, undefined, true, undefined, this)
280
- }, undefined, false, undefined, this),
281
- /* @__PURE__ */ jsxDEV2("tbody", {
282
- className: "divide-y divide-border",
283
- children: [
284
- connections.map((conn) => /* @__PURE__ */ jsxDEV2("tr", {
285
- className: "hover:bg-muted/50",
286
- children: [
287
- /* @__PURE__ */ jsxDEV2("td", {
288
- className: "px-4 py-3",
289
- children: /* @__PURE__ */ jsxDEV2("div", {
290
- className: "font-medium",
291
- children: conn.name
292
- }, undefined, false, undefined, this)
293
- }, undefined, false, undefined, this),
294
- /* @__PURE__ */ jsxDEV2("td", {
295
- className: "px-4 py-3",
296
- children: /* @__PURE__ */ jsxDEV2("span", {
297
- className: `inline-flex rounded-full px-2 py-0.5 font-medium text-xs ${STATUS_COLORS[conn.status] ?? ""}`,
298
- children: conn.status
299
- }, undefined, false, undefined, this)
300
- }, undefined, false, undefined, this),
301
- /* @__PURE__ */ jsxDEV2("td", {
302
- className: "px-4 py-3 text-muted-foreground text-sm",
303
- children: conn.lastSyncAt?.toLocaleString() ?? "Never"
304
- }, undefined, false, undefined, this)
305
- ]
306
- }, conn.id, true, undefined, this)),
307
- connections.length === 0 && /* @__PURE__ */ jsxDEV2("tr", {
308
- children: /* @__PURE__ */ jsxDEV2("td", {
309
- colSpan: 3,
310
- className: "px-4 py-8 text-center text-muted-foreground",
311
- children: "No connections found"
312
- }, undefined, false, undefined, this)
313
- }, undefined, false, undefined, this)
314
- ]
315
- }, undefined, true, undefined, this)
316
- ]
317
- }, undefined, true, undefined, this)
867
+ activeTab === "connections" && /* @__PURE__ */ jsxDEV6(ConnectionsTable, {
868
+ connections
318
869
  }, undefined, false, undefined, this),
319
- activeTab === "chat" && /* @__PURE__ */ jsxDEV2(IntegrationHubChat, {
870
+ activeTab === "chat" && /* @__PURE__ */ jsxDEV6(IntegrationHubChat, {
320
871
  proxyUrl: "/api/chat",
321
872
  thinkingLevel: "thinking",
322
873
  suggestions: [
@@ -326,85 +877,8 @@ function IntegrationDashboard() {
326
877
  ],
327
878
  className: "min-h-[400px]"
328
879
  }, undefined, false, undefined, this),
329
- activeTab === "syncs" && /* @__PURE__ */ jsxDEV2("div", {
330
- className: "rounded-lg border border-border",
331
- children: /* @__PURE__ */ jsxDEV2("table", {
332
- className: "w-full",
333
- children: [
334
- /* @__PURE__ */ jsxDEV2("thead", {
335
- className: "border-border border-b bg-muted/30",
336
- children: /* @__PURE__ */ jsxDEV2("tr", {
337
- children: [
338
- /* @__PURE__ */ jsxDEV2("th", {
339
- className: "px-4 py-3 text-left font-medium text-sm",
340
- children: "Sync Config"
341
- }, undefined, false, undefined, this),
342
- /* @__PURE__ */ jsxDEV2("th", {
343
- className: "px-4 py-3 text-left font-medium text-sm",
344
- children: "Frequency"
345
- }, undefined, false, undefined, this),
346
- /* @__PURE__ */ jsxDEV2("th", {
347
- className: "px-4 py-3 text-left font-medium text-sm",
348
- children: "Status"
349
- }, undefined, false, undefined, this),
350
- /* @__PURE__ */ jsxDEV2("th", {
351
- className: "px-4 py-3 text-left font-medium text-sm",
352
- children: "Records"
353
- }, undefined, false, undefined, this)
354
- ]
355
- }, undefined, true, undefined, this)
356
- }, undefined, false, undefined, this),
357
- /* @__PURE__ */ jsxDEV2("tbody", {
358
- className: "divide-y divide-border",
359
- children: [
360
- syncConfigs.map((sync) => /* @__PURE__ */ jsxDEV2("tr", {
361
- className: "hover:bg-muted/50",
362
- children: [
363
- /* @__PURE__ */ jsxDEV2("td", {
364
- className: "px-4 py-3",
365
- children: [
366
- /* @__PURE__ */ jsxDEV2("div", {
367
- className: "font-medium",
368
- children: sync.name
369
- }, undefined, false, undefined, this),
370
- /* @__PURE__ */ jsxDEV2("div", {
371
- className: "text-muted-foreground text-sm",
372
- children: [
373
- sync.sourceEntity,
374
- " \u2192 ",
375
- sync.targetEntity
376
- ]
377
- }, undefined, true, undefined, this)
378
- ]
379
- }, undefined, true, undefined, this),
380
- /* @__PURE__ */ jsxDEV2("td", {
381
- className: "px-4 py-3 text-sm",
382
- children: sync.frequency
383
- }, undefined, false, undefined, this),
384
- /* @__PURE__ */ jsxDEV2("td", {
385
- className: "px-4 py-3",
386
- children: /* @__PURE__ */ jsxDEV2("span", {
387
- className: `inline-flex rounded-full px-2 py-0.5 font-medium text-xs ${STATUS_COLORS[sync.status] ?? ""}`,
388
- children: sync.status
389
- }, undefined, false, undefined, this)
390
- }, undefined, false, undefined, this),
391
- /* @__PURE__ */ jsxDEV2("td", {
392
- className: "px-4 py-3 text-muted-foreground text-sm",
393
- children: sync.recordsSynced.toLocaleString()
394
- }, undefined, false, undefined, this)
395
- ]
396
- }, sync.id, true, undefined, this)),
397
- syncConfigs.length === 0 && /* @__PURE__ */ jsxDEV2("tr", {
398
- children: /* @__PURE__ */ jsxDEV2("td", {
399
- colSpan: 4,
400
- className: "px-4 py-8 text-center text-muted-foreground",
401
- children: "No sync configurations found"
402
- }, undefined, false, undefined, this)
403
- }, undefined, false, undefined, this)
404
- ]
405
- }, undefined, true, undefined, this)
406
- ]
407
- }, undefined, true, undefined, this)
880
+ activeTab === "syncs" && /* @__PURE__ */ jsxDEV6(SyncConfigsTable, {
881
+ syncConfigs
408
882
  }, undefined, false, undefined, this)
409
883
  ]
410
884
  }, undefined, true, undefined, this)
@@ -549,6 +1023,7 @@ var integrationDashboardMarkdownRenderer = {
549
1023
  const integrations = mockIntegrations;
550
1024
  const connections = mockConnections;
551
1025
  const syncs = mockSyncConfigs;
1026
+ const visualizations = createIntegrationVisualizationSections(integrations, connections, syncs);
552
1027
  const activeIntegrations = integrations.filter((i) => i.status === "ACTIVE");
553
1028
  const connectedConnections = connections.filter((c) => c.status === "CONNECTED");
554
1029
  const errorConnections = connections.filter((c) => c.status === "ERROR");
@@ -568,12 +1043,21 @@ var integrationDashboardMarkdownRenderer = {
568
1043
  `| Error Connections | ${errorConnections.length} |`,
569
1044
  `| Sync Configs | ${syncs.length} |`,
570
1045
  `| Records Synced (24h) | ${totalRecordsSynced.toLocaleString()} |`,
571
- "",
572
- "## Integrations",
573
- "",
574
- "| Name | Type | Connections | Status |",
575
- "|------|------|-------------|--------|"
1046
+ ""
576
1047
  ];
1048
+ lines.push("## Visualization Overview");
1049
+ lines.push("");
1050
+ for (const item of [
1051
+ ...visualizations.primaryItems,
1052
+ ...visualizations.comparisonItems
1053
+ ]) {
1054
+ lines.push(`- **${item.title}** via \`${item.spec.meta.key}\``);
1055
+ }
1056
+ lines.push("");
1057
+ lines.push("## Integrations");
1058
+ lines.push("");
1059
+ lines.push("| Name | Type | Connections | Status |");
1060
+ lines.push("|------|------|-------------|--------|");
577
1061
  for (const integration of integrations) {
578
1062
  const statusIcon = integration.status === "ACTIVE" ? "\uD83D\uDFE2" : "\u26AB";
579
1063
  lines.push(`| ${integration.name} | ${integration.type} | ${integration.connectionCount} | ${statusIcon} ${integration.status} |`);