@contractspec/example.integration-hub 3.8.9 → 3.8.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/connection/connection.enum.js +1 -29
- package/dist/connection/connection.operation.js +1 -124
- package/dist/connection/connection.presentation.js +1 -125
- package/dist/connection/connection.schema.js +1 -71
- package/dist/connection/index.js +1 -127
- package/dist/docs/index.js +5 -49
- package/dist/docs/integration-hub.docblock.js +5 -49
- package/dist/events.js +1 -211
- package/dist/example.js +1 -42
- package/dist/handlers/index.js +5 -292
- package/dist/handlers/integration.handlers.js +5 -292
- package/dist/index.js +8 -2355
- package/dist/integration/index.js +1 -92
- package/dist/integration/integration.enum.js +1 -12
- package/dist/integration/integration.operations.js +1 -89
- package/dist/integration/integration.presentation.js +1 -120
- package/dist/integration/integration.schema.js +1 -42
- package/dist/integration-hub.capability.js +1 -43
- package/dist/integration-hub.feature.js +1 -330
- package/dist/mcp-example.js +1 -154
- package/dist/node/connection/connection.enum.js +1 -29
- package/dist/node/connection/connection.operation.js +1 -124
- package/dist/node/connection/connection.presentation.js +1 -125
- package/dist/node/connection/connection.schema.js +1 -71
- package/dist/node/connection/index.js +1 -127
- package/dist/node/docs/index.js +5 -49
- package/dist/node/docs/integration-hub.docblock.js +5 -49
- package/dist/node/events.js +1 -211
- package/dist/node/example.js +1 -42
- package/dist/node/handlers/index.js +5 -292
- package/dist/node/handlers/integration.handlers.js +5 -292
- package/dist/node/index.js +8 -2355
- package/dist/node/integration/index.js +1 -92
- package/dist/node/integration/integration.enum.js +1 -12
- package/dist/node/integration/integration.operations.js +1 -89
- package/dist/node/integration/integration.presentation.js +1 -120
- package/dist/node/integration/integration.schema.js +1 -42
- package/dist/node/integration-hub.capability.js +1 -43
- package/dist/node/integration-hub.feature.js +1 -330
- package/dist/node/mcp-example.js +1 -154
- package/dist/node/run-mcp.js +1 -159
- package/dist/node/seeders/index.js +6 -60
- package/dist/node/sync/index.js +1 -332
- package/dist/node/sync/sync.enum.js +1 -26
- package/dist/node/sync/sync.operations.js +1 -321
- package/dist/node/sync/sync.presentation.js +1 -301
- package/dist/node/sync/sync.schema.js +1 -154
- package/dist/node/sync-engine/index.js +1 -186
- package/dist/node/tests/operations.test-spec.js +1 -85
- package/dist/node/ui/IntegrationDashboard.js +1 -886
- package/dist/node/ui/IntegrationDashboard.visualizations.js +1 -250
- package/dist/node/ui/IntegrationHubChat.js +1 -34
- package/dist/node/ui/hooks/index.js +1 -57
- package/dist/node/ui/hooks/useIntegrationData.js +1 -54
- package/dist/node/ui/index.js +4 -1173
- package/dist/node/ui/renderers/index.js +4 -484
- package/dist/node/ui/renderers/integration.markdown.js +4 -484
- package/dist/node/ui/tables/ConnectionsTable.js +1 -211
- package/dist/node/ui/tables/IntegrationTables.js +1 -361
- package/dist/node/ui/tables/SyncConfigsTable.js +1 -230
- package/dist/node/ui/tables/integration-table.shared.js +1 -84
- package/dist/node/visualizations/catalog.js +1 -137
- package/dist/node/visualizations/index.js +1 -211
- package/dist/node/visualizations/selectors.js +1 -204
- package/dist/run-mcp.js +1 -159
- package/dist/seeders/index.js +6 -60
- package/dist/sync/index.js +1 -332
- package/dist/sync/sync.enum.js +1 -26
- package/dist/sync/sync.operations.js +1 -321
- package/dist/sync/sync.presentation.js +1 -301
- package/dist/sync/sync.schema.js +1 -154
- package/dist/sync-engine/index.js +1 -186
- package/dist/tests/operations.test-spec.js +1 -85
- package/dist/ui/IntegrationDashboard.js +1 -886
- package/dist/ui/IntegrationDashboard.visualizations.js +1 -250
- package/dist/ui/IntegrationHubChat.js +1 -34
- package/dist/ui/hooks/index.js +1 -57
- package/dist/ui/hooks/useIntegrationData.js +1 -54
- package/dist/ui/index.js +4 -1173
- package/dist/ui/renderers/index.js +4 -484
- package/dist/ui/renderers/integration.markdown.js +4 -484
- package/dist/ui/tables/ConnectionsTable.js +1 -211
- package/dist/ui/tables/IntegrationTables.js +1 -361
- package/dist/ui/tables/SyncConfigsTable.js +1 -230
- package/dist/ui/tables/integration-table.shared.js +1 -84
- package/dist/visualizations/catalog.js +1 -137
- package/dist/visualizations/index.js +1 -211
- package/dist/visualizations/selectors.js +1 -204
- package/package.json +11 -11
package/dist/ui/index.js
CHANGED
|
@@ -1,1174 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
// src/ui/hooks/useIntegrationData.ts
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
function useIntegrationData(projectId = "local-project") {
|
|
7
|
-
const { handlers } = useTemplateRuntime();
|
|
8
|
-
const integration = handlers.integration;
|
|
9
|
-
const [integrations, setIntegrations] = useState([]);
|
|
10
|
-
const [connections, setConnections] = useState([]);
|
|
11
|
-
const [syncConfigs, setSyncConfigs] = useState([]);
|
|
12
|
-
const [loading, setLoading] = useState(true);
|
|
13
|
-
const [error, setError] = useState(null);
|
|
14
|
-
const fetchData = useCallback(async () => {
|
|
15
|
-
try {
|
|
16
|
-
setLoading(true);
|
|
17
|
-
setError(null);
|
|
18
|
-
const [integResult, connResult, syncResult] = await Promise.all([
|
|
19
|
-
integration.listIntegrations({ projectId, limit: 100 }),
|
|
20
|
-
integration.listConnections({ limit: 100 }),
|
|
21
|
-
integration.listSyncConfigs({ limit: 100 })
|
|
22
|
-
]);
|
|
23
|
-
setIntegrations(integResult.integrations);
|
|
24
|
-
setConnections(connResult.connections);
|
|
25
|
-
setSyncConfigs(syncResult.configs);
|
|
26
|
-
} catch (err) {
|
|
27
|
-
setError(err instanceof Error ? err : new Error("Failed to load integrations"));
|
|
28
|
-
} finally {
|
|
29
|
-
setLoading(false);
|
|
30
|
-
}
|
|
31
|
-
}, [integration, projectId]);
|
|
32
|
-
useEffect(() => {
|
|
33
|
-
fetchData();
|
|
34
|
-
}, [fetchData]);
|
|
35
|
-
const stats = {
|
|
36
|
-
totalIntegrations: integrations.length,
|
|
37
|
-
activeIntegrations: integrations.filter((i) => i.status === "ACTIVE").length,
|
|
38
|
-
totalConnections: connections.length,
|
|
39
|
-
connectedCount: connections.filter((c) => c.status === "CONNECTED").length,
|
|
40
|
-
totalSyncs: syncConfigs.length,
|
|
41
|
-
activeSyncs: syncConfigs.filter((s) => s.status === "ACTIVE").length
|
|
42
|
-
};
|
|
43
|
-
return {
|
|
44
|
-
integrations,
|
|
45
|
-
connections,
|
|
46
|
-
syncConfigs,
|
|
47
|
-
loading,
|
|
48
|
-
error,
|
|
49
|
-
stats,
|
|
50
|
-
refetch: fetchData
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// src/ui/hooks/index.ts
|
|
55
|
-
"use client";
|
|
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
|
-
|
|
305
|
-
// src/ui/IntegrationHubChat.tsx
|
|
306
|
-
import { ChatWithSidebar } from "@contractspec/module.ai-chat";
|
|
307
|
-
import { jsxDEV as jsxDEV2 } from "react/jsx-dev-runtime";
|
|
308
|
-
"use client";
|
|
309
|
-
var DEFAULT_SUGGESTIONS = [
|
|
310
|
-
"List my integrations",
|
|
311
|
-
"Show sync status",
|
|
312
|
-
"Add a connection"
|
|
313
|
-
];
|
|
314
|
-
var DEFAULT_SYSTEM_PROMPT = `You are an Integration Hub assistant. Help users manage integrations, connections, and sync configurations. When asked about integrations, connections, or syncs, provide clear, actionable guidance.`;
|
|
315
|
-
function IntegrationHubChat({
|
|
316
|
-
proxyUrl = "/api/chat",
|
|
317
|
-
mcpServers,
|
|
318
|
-
thinkingLevel = "thinking",
|
|
319
|
-
suggestions = DEFAULT_SUGGESTIONS,
|
|
320
|
-
systemPrompt = DEFAULT_SYSTEM_PROMPT,
|
|
321
|
-
className
|
|
322
|
-
}) {
|
|
323
|
-
return /* @__PURE__ */ jsxDEV2("div", {
|
|
324
|
-
className: className ?? "flex h-[500px] flex-col",
|
|
325
|
-
children: /* @__PURE__ */ jsxDEV2(ChatWithSidebar, {
|
|
326
|
-
className: "flex-1",
|
|
327
|
-
systemPrompt,
|
|
328
|
-
proxyUrl,
|
|
329
|
-
mcpServers,
|
|
330
|
-
thinkingLevel,
|
|
331
|
-
suggestions,
|
|
332
|
-
showSuggestionsWhenEmpty: true
|
|
333
|
-
}, undefined, false, undefined, this)
|
|
334
|
-
}, undefined, false, undefined, this);
|
|
335
|
-
}
|
|
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
|
-
}
|
|
694
|
-
// src/ui/IntegrationDashboard.tsx
|
|
695
|
-
import {
|
|
696
|
-
Button as Button2,
|
|
697
|
-
ErrorState,
|
|
698
|
-
LoaderBlock,
|
|
699
|
-
StatCard,
|
|
700
|
-
StatCardGroup
|
|
701
|
-
} from "@contractspec/lib.design-system";
|
|
702
|
-
import { useState as useState2 } from "react";
|
|
703
|
-
import { jsxDEV as jsxDEV6 } from "react/jsx-dev-runtime";
|
|
704
|
-
"use client";
|
|
705
|
-
var STATUS_COLORS = {
|
|
706
|
-
ACTIVE: "bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400",
|
|
707
|
-
INACTIVE: "bg-gray-100 text-gray-700 dark:bg-gray-900/30 dark:text-gray-400",
|
|
708
|
-
CONNECTED: "bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400",
|
|
709
|
-
DISCONNECTED: "bg-gray-100 text-gray-700 dark:bg-gray-900/30 dark:text-gray-400",
|
|
710
|
-
PENDING: "bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400",
|
|
711
|
-
ERROR: "bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400",
|
|
712
|
-
PAUSED: "bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400"
|
|
713
|
-
};
|
|
714
|
-
var TYPE_ICONS = {
|
|
715
|
-
CRM: "\uD83D\uDCCA",
|
|
716
|
-
MARKETING: "\uD83D\uDCE3",
|
|
717
|
-
PAYMENT: "\uD83D\uDCB3",
|
|
718
|
-
COMMUNICATION: "\uD83D\uDCAC",
|
|
719
|
-
DATA: "\uD83D\uDDC4\uFE0F",
|
|
720
|
-
CUSTOM: "\u2699\uFE0F"
|
|
721
|
-
};
|
|
722
|
-
function IntegrationDashboard() {
|
|
723
|
-
const [activeTab, setActiveTab] = useState2("integrations");
|
|
724
|
-
const {
|
|
725
|
-
integrations,
|
|
726
|
-
connections,
|
|
727
|
-
syncConfigs,
|
|
728
|
-
loading,
|
|
729
|
-
error,
|
|
730
|
-
stats,
|
|
731
|
-
refetch
|
|
732
|
-
} = useIntegrationData();
|
|
733
|
-
const tabs = [
|
|
734
|
-
{ id: "integrations", label: "Integrations", icon: "\uD83D\uDD0C" },
|
|
735
|
-
{ id: "connections", label: "Connections", icon: "\uD83D\uDD17" },
|
|
736
|
-
{ id: "syncs", label: "Sync Configs", icon: "\uD83D\uDD04" },
|
|
737
|
-
{ id: "chat", label: "Chat", icon: "\uD83D\uDCAC" }
|
|
738
|
-
];
|
|
739
|
-
if (loading) {
|
|
740
|
-
return /* @__PURE__ */ jsxDEV6(LoaderBlock, {
|
|
741
|
-
label: "Loading Integrations..."
|
|
742
|
-
}, undefined, false, undefined, this);
|
|
743
|
-
}
|
|
744
|
-
if (error) {
|
|
745
|
-
return /* @__PURE__ */ jsxDEV6(ErrorState, {
|
|
746
|
-
title: "Failed to load Integrations",
|
|
747
|
-
description: error.message,
|
|
748
|
-
onRetry: refetch,
|
|
749
|
-
retryLabel: "Retry"
|
|
750
|
-
}, undefined, false, undefined, this);
|
|
751
|
-
}
|
|
752
|
-
return /* @__PURE__ */ jsxDEV6("div", {
|
|
753
|
-
className: "space-y-6",
|
|
754
|
-
children: [
|
|
755
|
-
/* @__PURE__ */ jsxDEV6("div", {
|
|
756
|
-
className: "flex items-center justify-between",
|
|
757
|
-
children: [
|
|
758
|
-
/* @__PURE__ */ jsxDEV6("h2", {
|
|
759
|
-
className: "font-bold text-2xl",
|
|
760
|
-
children: "Integration Hub"
|
|
761
|
-
}, undefined, false, undefined, this),
|
|
762
|
-
/* @__PURE__ */ jsxDEV6(Button2, {
|
|
763
|
-
onClick: () => alert("Add integration modal"),
|
|
764
|
-
children: [
|
|
765
|
-
/* @__PURE__ */ jsxDEV6("span", {
|
|
766
|
-
className: "mr-2",
|
|
767
|
-
children: "+"
|
|
768
|
-
}, undefined, false, undefined, this),
|
|
769
|
-
" Add Integration"
|
|
770
|
-
]
|
|
771
|
-
}, undefined, true, undefined, this)
|
|
772
|
-
]
|
|
773
|
-
}, undefined, true, undefined, this),
|
|
774
|
-
/* @__PURE__ */ jsxDEV6(StatCardGroup, {
|
|
775
|
-
children: [
|
|
776
|
-
/* @__PURE__ */ jsxDEV6(StatCard, {
|
|
777
|
-
label: "Integrations",
|
|
778
|
-
value: stats.totalIntegrations,
|
|
779
|
-
hint: `${stats.activeIntegrations} active`
|
|
780
|
-
}, undefined, false, undefined, this),
|
|
781
|
-
/* @__PURE__ */ jsxDEV6(StatCard, {
|
|
782
|
-
label: "Connections",
|
|
783
|
-
value: stats.totalConnections,
|
|
784
|
-
hint: `${stats.connectedCount} connected`
|
|
785
|
-
}, undefined, false, undefined, this),
|
|
786
|
-
/* @__PURE__ */ jsxDEV6(StatCard, {
|
|
787
|
-
label: "Syncs",
|
|
788
|
-
value: stats.totalSyncs,
|
|
789
|
-
hint: `${stats.activeSyncs} active`
|
|
790
|
-
}, undefined, false, undefined, this)
|
|
791
|
-
]
|
|
792
|
-
}, undefined, true, undefined, this),
|
|
793
|
-
/* @__PURE__ */ jsxDEV6(IntegrationVisualizationOverview, {
|
|
794
|
-
connections,
|
|
795
|
-
integrations,
|
|
796
|
-
syncConfigs
|
|
797
|
-
}, undefined, false, undefined, this),
|
|
798
|
-
/* @__PURE__ */ jsxDEV6("nav", {
|
|
799
|
-
className: "flex gap-1 rounded-lg bg-muted p-1",
|
|
800
|
-
role: "tablist",
|
|
801
|
-
children: tabs.map((tab) => /* @__PURE__ */ jsxDEV6(Button2, {
|
|
802
|
-
type: "button",
|
|
803
|
-
role: "tab",
|
|
804
|
-
"aria-selected": activeTab === tab.id,
|
|
805
|
-
onClick: () => setActiveTab(tab.id),
|
|
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"}`,
|
|
807
|
-
children: [
|
|
808
|
-
/* @__PURE__ */ jsxDEV6("span", {
|
|
809
|
-
children: tab.icon
|
|
810
|
-
}, undefined, false, undefined, this),
|
|
811
|
-
tab.label
|
|
812
|
-
]
|
|
813
|
-
}, tab.id, true, undefined, this))
|
|
814
|
-
}, undefined, false, undefined, this),
|
|
815
|
-
/* @__PURE__ */ jsxDEV6("div", {
|
|
816
|
-
className: "min-h-[400px]",
|
|
817
|
-
role: "tabpanel",
|
|
818
|
-
children: [
|
|
819
|
-
activeTab === "integrations" && /* @__PURE__ */ jsxDEV6("div", {
|
|
820
|
-
className: "grid gap-4 sm:grid-cols-2 lg:grid-cols-3",
|
|
821
|
-
children: [
|
|
822
|
-
integrations.map((integration) => /* @__PURE__ */ jsxDEV6("div", {
|
|
823
|
-
className: "cursor-pointer rounded-lg border border-border bg-card p-4 transition-colors hover:bg-muted/50",
|
|
824
|
-
children: [
|
|
825
|
-
/* @__PURE__ */ jsxDEV6("div", {
|
|
826
|
-
className: "mb-3 flex items-center gap-3",
|
|
827
|
-
children: [
|
|
828
|
-
/* @__PURE__ */ jsxDEV6("span", {
|
|
829
|
-
className: "text-2xl",
|
|
830
|
-
children: TYPE_ICONS[integration.type] ?? "\u2699\uFE0F"
|
|
831
|
-
}, undefined, false, undefined, this),
|
|
832
|
-
/* @__PURE__ */ jsxDEV6("div", {
|
|
833
|
-
children: [
|
|
834
|
-
/* @__PURE__ */ jsxDEV6("h3", {
|
|
835
|
-
className: "font-medium",
|
|
836
|
-
children: integration.name
|
|
837
|
-
}, undefined, false, undefined, this),
|
|
838
|
-
/* @__PURE__ */ jsxDEV6("p", {
|
|
839
|
-
className: "text-muted-foreground text-sm",
|
|
840
|
-
children: integration.type
|
|
841
|
-
}, undefined, false, undefined, this)
|
|
842
|
-
]
|
|
843
|
-
}, undefined, true, undefined, this)
|
|
844
|
-
]
|
|
845
|
-
}, undefined, true, undefined, this),
|
|
846
|
-
/* @__PURE__ */ jsxDEV6("div", {
|
|
847
|
-
className: "flex items-center justify-between",
|
|
848
|
-
children: [
|
|
849
|
-
/* @__PURE__ */ jsxDEV6("span", {
|
|
850
|
-
className: `inline-flex rounded-full px-2 py-0.5 font-medium text-xs ${STATUS_COLORS[integration.status] ?? ""}`,
|
|
851
|
-
children: integration.status
|
|
852
|
-
}, undefined, false, undefined, this),
|
|
853
|
-
/* @__PURE__ */ jsxDEV6("span", {
|
|
854
|
-
className: "text-muted-foreground text-xs",
|
|
855
|
-
children: integration.createdAt.toLocaleDateString()
|
|
856
|
-
}, undefined, false, undefined, this)
|
|
857
|
-
]
|
|
858
|
-
}, undefined, true, undefined, this)
|
|
859
|
-
]
|
|
860
|
-
}, integration.id, true, undefined, this)),
|
|
861
|
-
integrations.length === 0 && /* @__PURE__ */ jsxDEV6("div", {
|
|
862
|
-
className: "col-span-full flex h-64 items-center justify-center text-muted-foreground",
|
|
863
|
-
children: "No integrations configured"
|
|
864
|
-
}, undefined, false, undefined, this)
|
|
865
|
-
]
|
|
866
|
-
}, undefined, true, undefined, this),
|
|
867
|
-
activeTab === "connections" && /* @__PURE__ */ jsxDEV6(ConnectionsTable, {
|
|
868
|
-
connections
|
|
869
|
-
}, undefined, false, undefined, this),
|
|
870
|
-
activeTab === "chat" && /* @__PURE__ */ jsxDEV6(IntegrationHubChat, {
|
|
871
|
-
proxyUrl: "/api/chat",
|
|
872
|
-
thinkingLevel: "thinking",
|
|
873
|
-
suggestions: [
|
|
874
|
-
"List my integrations",
|
|
875
|
-
"Show sync status",
|
|
876
|
-
"Add a connection"
|
|
877
|
-
],
|
|
878
|
-
className: "min-h-[400px]"
|
|
879
|
-
}, undefined, false, undefined, this),
|
|
880
|
-
activeTab === "syncs" && /* @__PURE__ */ jsxDEV6(SyncConfigsTable, {
|
|
881
|
-
syncConfigs
|
|
882
|
-
}, undefined, false, undefined, this)
|
|
883
|
-
]
|
|
884
|
-
}, undefined, true, undefined, this)
|
|
885
|
-
]
|
|
886
|
-
}, undefined, true, undefined, this);
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
// src/ui/renderers/integration.markdown.ts
|
|
890
|
-
var mockIntegrations = [
|
|
891
|
-
{
|
|
892
|
-
id: "int-1",
|
|
893
|
-
name: "Salesforce",
|
|
894
|
-
type: "CRM",
|
|
895
|
-
status: "ACTIVE",
|
|
896
|
-
connectionCount: 3
|
|
897
|
-
},
|
|
898
|
-
{
|
|
899
|
-
id: "int-2",
|
|
900
|
-
name: "HubSpot",
|
|
901
|
-
type: "MARKETING",
|
|
902
|
-
status: "ACTIVE",
|
|
903
|
-
connectionCount: 2
|
|
904
|
-
},
|
|
905
|
-
{
|
|
906
|
-
id: "int-3",
|
|
907
|
-
name: "Stripe",
|
|
908
|
-
type: "PAYMENT",
|
|
909
|
-
status: "ACTIVE",
|
|
910
|
-
connectionCount: 1
|
|
911
|
-
},
|
|
912
|
-
{
|
|
913
|
-
id: "int-4",
|
|
914
|
-
name: "Slack",
|
|
915
|
-
type: "COMMUNICATION",
|
|
916
|
-
status: "INACTIVE",
|
|
917
|
-
connectionCount: 0
|
|
918
|
-
},
|
|
919
|
-
{
|
|
920
|
-
id: "int-5",
|
|
921
|
-
name: "Google Sheets",
|
|
922
|
-
type: "DATA",
|
|
923
|
-
status: "ACTIVE",
|
|
924
|
-
connectionCount: 5
|
|
925
|
-
},
|
|
926
|
-
{
|
|
927
|
-
id: "int-6",
|
|
928
|
-
name: "PostHog",
|
|
929
|
-
type: "ANALYTICS",
|
|
930
|
-
status: "ACTIVE",
|
|
931
|
-
connectionCount: 1
|
|
932
|
-
}
|
|
933
|
-
];
|
|
934
|
-
var mockConnections = [
|
|
935
|
-
{
|
|
936
|
-
id: "conn-1",
|
|
937
|
-
integrationId: "int-1",
|
|
938
|
-
name: "Production Salesforce",
|
|
939
|
-
status: "CONNECTED",
|
|
940
|
-
lastSyncAt: "2024-01-16T10:00:00Z"
|
|
941
|
-
},
|
|
942
|
-
{
|
|
943
|
-
id: "conn-2",
|
|
944
|
-
integrationId: "int-1",
|
|
945
|
-
name: "Sandbox Salesforce",
|
|
946
|
-
status: "CONNECTED",
|
|
947
|
-
lastSyncAt: "2024-01-15T14:00:00Z"
|
|
948
|
-
},
|
|
949
|
-
{
|
|
950
|
-
id: "conn-3",
|
|
951
|
-
integrationId: "int-2",
|
|
952
|
-
name: "Marketing HubSpot",
|
|
953
|
-
status: "CONNECTED",
|
|
954
|
-
lastSyncAt: "2024-01-16T08:00:00Z"
|
|
955
|
-
},
|
|
956
|
-
{
|
|
957
|
-
id: "conn-4",
|
|
958
|
-
integrationId: "int-3",
|
|
959
|
-
name: "Stripe Live",
|
|
960
|
-
status: "CONNECTED",
|
|
961
|
-
lastSyncAt: "2024-01-16T12:00:00Z"
|
|
962
|
-
},
|
|
963
|
-
{
|
|
964
|
-
id: "conn-5",
|
|
965
|
-
integrationId: "int-5",
|
|
966
|
-
name: "Analytics Sheet",
|
|
967
|
-
status: "ERROR",
|
|
968
|
-
lastSyncAt: "2024-01-14T09:00:00Z",
|
|
969
|
-
error: "Authentication expired"
|
|
970
|
-
},
|
|
971
|
-
{
|
|
972
|
-
id: "conn-6",
|
|
973
|
-
integrationId: "int-6",
|
|
974
|
-
name: "PostHog Workspace",
|
|
975
|
-
status: "CONNECTED",
|
|
976
|
-
lastSyncAt: "2024-01-16T11:45:00Z"
|
|
977
|
-
}
|
|
978
|
-
];
|
|
979
|
-
var mockSyncConfigs = [
|
|
980
|
-
{
|
|
981
|
-
id: "sync-1",
|
|
982
|
-
connectionId: "conn-1",
|
|
983
|
-
name: "Contacts Sync",
|
|
984
|
-
frequency: "HOURLY",
|
|
985
|
-
lastRunAt: "2024-01-16T10:00:00Z",
|
|
986
|
-
status: "SUCCESS",
|
|
987
|
-
recordsSynced: 1250
|
|
988
|
-
},
|
|
989
|
-
{
|
|
990
|
-
id: "sync-2",
|
|
991
|
-
connectionId: "conn-1",
|
|
992
|
-
name: "Opportunities Sync",
|
|
993
|
-
frequency: "DAILY",
|
|
994
|
-
lastRunAt: "2024-01-16T00:00:00Z",
|
|
995
|
-
status: "SUCCESS",
|
|
996
|
-
recordsSynced: 340
|
|
997
|
-
},
|
|
998
|
-
{
|
|
999
|
-
id: "sync-3",
|
|
1000
|
-
connectionId: "conn-3",
|
|
1001
|
-
name: "Orders Sync",
|
|
1002
|
-
frequency: "REALTIME",
|
|
1003
|
-
lastRunAt: "2024-01-16T12:30:00Z",
|
|
1004
|
-
status: "SUCCESS",
|
|
1005
|
-
recordsSynced: 89
|
|
1006
|
-
},
|
|
1007
|
-
{
|
|
1008
|
-
id: "sync-4",
|
|
1009
|
-
connectionId: "conn-5",
|
|
1010
|
-
name: "Metrics Export",
|
|
1011
|
-
frequency: "DAILY",
|
|
1012
|
-
lastRunAt: "2024-01-14T09:00:00Z",
|
|
1013
|
-
status: "FAILED",
|
|
1014
|
-
recordsSynced: 0
|
|
1015
|
-
}
|
|
1016
|
-
];
|
|
1017
|
-
var integrationDashboardMarkdownRenderer = {
|
|
1018
|
-
target: "markdown",
|
|
1019
|
-
render: async (desc) => {
|
|
1020
|
-
if (desc.source.type !== "component" || desc.source.componentKey !== "IntegrationDashboard") {
|
|
1021
|
-
throw new Error("integrationDashboardMarkdownRenderer: not IntegrationDashboard");
|
|
1022
|
-
}
|
|
1023
|
-
const integrations = mockIntegrations;
|
|
1024
|
-
const connections = mockConnections;
|
|
1025
|
-
const syncs = mockSyncConfigs;
|
|
1026
|
-
const visualizations = createIntegrationVisualizationSections(integrations, connections, syncs);
|
|
1027
|
-
const activeIntegrations = integrations.filter((i) => i.status === "ACTIVE");
|
|
1028
|
-
const connectedConnections = connections.filter((c) => c.status === "CONNECTED");
|
|
1029
|
-
const errorConnections = connections.filter((c) => c.status === "ERROR");
|
|
1030
|
-
const successfulSyncs = syncs.filter((s) => s.status === "SUCCESS");
|
|
1031
|
-
const totalRecordsSynced = successfulSyncs.reduce((sum, s) => sum + s.recordsSynced, 0);
|
|
1032
|
-
const lines = [
|
|
1033
|
-
"# Integration Hub",
|
|
1034
|
-
"",
|
|
1035
|
-
"> Connect and sync data with external services",
|
|
1036
|
-
"",
|
|
1037
|
-
"## Overview",
|
|
1038
|
-
"",
|
|
1039
|
-
"| Metric | Value |",
|
|
1040
|
-
"|--------|-------|",
|
|
1041
|
-
`| Active Integrations | ${activeIntegrations.length} |`,
|
|
1042
|
-
`| Connected Services | ${connectedConnections.length} |`,
|
|
1043
|
-
`| Error Connections | ${errorConnections.length} |`,
|
|
1044
|
-
`| Sync Configs | ${syncs.length} |`,
|
|
1045
|
-
`| Records Synced (24h) | ${totalRecordsSynced.toLocaleString()} |`,
|
|
1046
|
-
""
|
|
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("|------|------|-------------|--------|");
|
|
1061
|
-
for (const integration of integrations) {
|
|
1062
|
-
const statusIcon = integration.status === "ACTIVE" ? "\uD83D\uDFE2" : "\u26AB";
|
|
1063
|
-
lines.push(`| ${integration.name} | ${integration.type} | ${integration.connectionCount} | ${statusIcon} ${integration.status} |`);
|
|
1064
|
-
}
|
|
1065
|
-
lines.push("");
|
|
1066
|
-
lines.push("## Recent Sync Activity");
|
|
1067
|
-
lines.push("");
|
|
1068
|
-
lines.push("| Sync | Frequency | Last Run | Records | Status |");
|
|
1069
|
-
lines.push("|------|-----------|----------|---------|--------|");
|
|
1070
|
-
for (const sync of syncs) {
|
|
1071
|
-
const lastRun = new Date(sync.lastRunAt).toLocaleString();
|
|
1072
|
-
const statusIcon = sync.status === "SUCCESS" ? "\u2705" : "\u274C";
|
|
1073
|
-
lines.push(`| ${sync.name} | ${sync.frequency} | ${lastRun} | ${sync.recordsSynced} | ${statusIcon} ${sync.status} |`);
|
|
1074
|
-
}
|
|
1075
|
-
if (errorConnections.length > 0) {
|
|
1076
|
-
lines.push("");
|
|
1077
|
-
lines.push("## \u26A0\uFE0F Connections with Errors");
|
|
1078
|
-
lines.push("");
|
|
1079
|
-
for (const conn of errorConnections) {
|
|
1080
|
-
const integration = integrations.find((i) => i.id === conn.integrationId);
|
|
1081
|
-
lines.push(`- **${conn.name}** (${integration?.name ?? "Unknown"}): ${conn.error ?? "Unknown error"}`);
|
|
1082
|
-
}
|
|
1083
|
-
}
|
|
1084
|
-
return {
|
|
1085
|
-
mimeType: "text/markdown",
|
|
1086
|
-
body: lines.join(`
|
|
1087
|
-
`)
|
|
1088
|
-
};
|
|
1089
|
-
}
|
|
1090
|
-
};
|
|
1091
|
-
var connectionListMarkdownRenderer = {
|
|
1092
|
-
target: "markdown",
|
|
1093
|
-
render: async (desc) => {
|
|
1094
|
-
if (desc.source.type !== "component" || desc.source.componentKey !== "ConnectionList") {
|
|
1095
|
-
throw new Error("connectionListMarkdownRenderer: not ConnectionList");
|
|
1096
|
-
}
|
|
1097
|
-
const connections = mockConnections;
|
|
1098
|
-
const integrations = mockIntegrations;
|
|
1099
|
-
const lines = [
|
|
1100
|
-
"# Connections",
|
|
1101
|
-
"",
|
|
1102
|
-
"> Manage connections to external services",
|
|
1103
|
-
""
|
|
1104
|
-
];
|
|
1105
|
-
for (const integration of integrations) {
|
|
1106
|
-
const intConnections = connections.filter((c) => c.integrationId === integration.id);
|
|
1107
|
-
if (intConnections.length === 0)
|
|
1108
|
-
continue;
|
|
1109
|
-
lines.push(`## ${integration.name}`);
|
|
1110
|
-
lines.push("");
|
|
1111
|
-
lines.push("| Connection | Status | Last Sync |");
|
|
1112
|
-
lines.push("|------------|--------|-----------|");
|
|
1113
|
-
for (const conn of intConnections) {
|
|
1114
|
-
const lastSync = new Date(conn.lastSyncAt).toLocaleString();
|
|
1115
|
-
const statusIcon = conn.status === "CONNECTED" ? "\uD83D\uDFE2" : conn.status === "ERROR" ? "\uD83D\uDD34" : "\u26AB";
|
|
1116
|
-
lines.push(`| ${conn.name} | ${statusIcon} ${conn.status} | ${lastSync} |`);
|
|
1117
|
-
}
|
|
1118
|
-
lines.push("");
|
|
1119
|
-
}
|
|
1120
|
-
return {
|
|
1121
|
-
mimeType: "text/markdown",
|
|
1122
|
-
body: lines.join(`
|
|
1123
|
-
`)
|
|
1124
|
-
};
|
|
1125
|
-
}
|
|
1126
|
-
};
|
|
1127
|
-
var syncConfigMarkdownRenderer = {
|
|
1128
|
-
target: "markdown",
|
|
1129
|
-
render: async (desc) => {
|
|
1130
|
-
if (desc.source.type !== "component" || desc.source.componentKey !== "SyncConfigEditor") {
|
|
1131
|
-
throw new Error("syncConfigMarkdownRenderer: not SyncConfigEditor");
|
|
1132
|
-
}
|
|
1133
|
-
const syncs = mockSyncConfigs;
|
|
1134
|
-
const connections = mockConnections;
|
|
1135
|
-
const lines = [
|
|
1136
|
-
"# Sync Configurations",
|
|
1137
|
-
"",
|
|
1138
|
-
"> Configure automated data synchronization",
|
|
1139
|
-
""
|
|
1140
|
-
];
|
|
1141
|
-
for (const sync of syncs) {
|
|
1142
|
-
const connection = connections.find((c) => c.id === sync.connectionId);
|
|
1143
|
-
const statusIcon = sync.status === "SUCCESS" ? "\u2705" : "\u274C";
|
|
1144
|
-
lines.push(`## ${sync.name}`);
|
|
1145
|
-
lines.push("");
|
|
1146
|
-
lines.push(`**Connection:** ${connection?.name ?? "Unknown"}`);
|
|
1147
|
-
lines.push(`**Frequency:** ${sync.frequency}`);
|
|
1148
|
-
lines.push(`**Status:** ${statusIcon} ${sync.status}`);
|
|
1149
|
-
lines.push(`**Last Run:** ${new Date(sync.lastRunAt).toLocaleString()}`);
|
|
1150
|
-
lines.push(`**Records Synced:** ${sync.recordsSynced.toLocaleString()}`);
|
|
1151
|
-
lines.push("");
|
|
1152
|
-
}
|
|
1153
|
-
lines.push("## Frequency Options");
|
|
1154
|
-
lines.push("");
|
|
1155
|
-
lines.push("- **REALTIME**: Sync on every change");
|
|
1156
|
-
lines.push("- **HOURLY**: Sync every hour");
|
|
1157
|
-
lines.push("- **DAILY**: Sync once per day");
|
|
1158
|
-
lines.push("- **WEEKLY**: Sync once per week");
|
|
1159
|
-
lines.push("- **MANUAL**: Sync only when triggered");
|
|
1160
|
-
return {
|
|
1161
|
-
mimeType: "text/markdown",
|
|
1162
|
-
body: lines.join(`
|
|
1163
|
-
`)
|
|
1164
|
-
};
|
|
1165
|
-
}
|
|
1166
|
-
};
|
|
1167
|
-
export {
|
|
1168
|
-
useIntegrationData,
|
|
1169
|
-
syncConfigMarkdownRenderer,
|
|
1170
|
-
integrationDashboardMarkdownRenderer,
|
|
1171
|
-
connectionListMarkdownRenderer,
|
|
1172
|
-
IntegrationHubChat,
|
|
1173
|
-
IntegrationDashboard
|
|
1174
|
-
};
|
|
2
|
+
import{useTemplateRuntime as Zq}from"@contractspec/lib.example-shared-ui";import{useCallback as $q,useEffect as Wq,useState as N}from"react";function d(K="local-project"){let{handlers:W}=Zq(),q=W.integration,[Q,$]=N([]),[J,H]=N([]),[w,D]=N([]),[Y,X]=N(!0),[Z,U]=N(null),F=$q(async()=>{try{X(!0),U(null);let[M,Qq,Xq]=await Promise.all([q.listIntegrations({projectId:K,limit:100}),q.listConnections({limit:100}),q.listSyncConfigs({limit:100})]);$(M.integrations),H(Qq.connections),D(Xq.configs)}catch(M){U(M instanceof Error?M:Error("Failed to load integrations"))}finally{X(!1)}},[q,K]);Wq(()=>{F()},[F]);let O={totalIntegrations:Q.length,activeIntegrations:Q.filter((M)=>M.status==="ACTIVE").length,totalConnections:J.length,connectedCount:J.filter((M)=>M.status==="CONNECTED").length,totalSyncs:w.length,activeSyncs:w.filter((M)=>M.status==="ACTIVE").length};return{integrations:Q,connections:J,syncConfigs:w,loading:Y,error:Z,stats:O,refetch:F}}import{defineVisualization as z,VisualizationRegistry as Jq}from"@contractspec/lib.contracts-spec/visualizations";var Hq={key:"integration.list",version:"1.0.0"},wq={key:"integration.connection.list",version:"1.0.0"},l={key:"integration.syncConfig.list",version:"1.0.0"},V={version:"1.0.0",domain:"integration",stability:"experimental",owners:["@example.integration-hub"],tags:["integration","visualization","sync"]},b=z({meta:{...V,key:"integration-hub.visualization.integration-types",title:"Integration Types",description:"Distribution of configured integration categories.",goal:"Show where integration coverage is concentrated.",context:"Integration overview."},source:{primary:Hq,resultPath:"data"},visualization:{kind:"pie",nameDimension:"type",valueMeasure:"count",dimensions:[{key:"type",label:"Type",dataPath:"type",type:"category"}],measures:[{key:"count",label:"Count",dataPath:"count",format:"number"}],table:{caption:"Integration counts by type."}}}),T=z({meta:{...V,key:"integration-hub.visualization.connection-status",title:"Connection Status",description:"Status distribution across configured connections.",goal:"Highlight connection health and instability.",context:"Connection monitoring."},source:{primary:wq,resultPath:"data"},visualization:{kind:"cartesian",variant:"bar",xDimension:"status",yMeasures:["count"],dimensions:[{key:"status",label:"Status",dataPath:"status",type:"category"}],measures:[{key:"count",label:"Connections",dataPath:"count",format:"number",color:"#1d4ed8"}],table:{caption:"Connection counts by status."}}}),C=z({meta:{...V,key:"integration-hub.visualization.sync-healthy",title:"Healthy Syncs",description:"Sync configurations currently healthy or recently successful.",goal:"Summarize healthy synchronization capacity.",context:"Sync-state comparison."},source:{primary:l,resultPath:"data"},visualization:{kind:"metric",measure:"value",measures:[{key:"value",label:"Syncs",dataPath:"value",format:"number"}],table:{caption:"Healthy sync count."}}}),S=z({meta:{...V,key:"integration-hub.visualization.sync-attention",title:"Attention Needed",description:"Sync configurations paused, failing, or otherwise needing review.",goal:"Summarize syncs needing action.",context:"Sync-state comparison."},source:{primary:l,resultPath:"data"},visualization:{kind:"metric",measure:"value",measures:[{key:"value",label:"Syncs",dataPath:"value",format:"number"}],table:{caption:"Syncs requiring attention."}}}),a=[b,T,C,S],jq=new Jq([...a]),xq=a.map((K)=>({key:K.meta.key,version:K.meta.version}));function Yq(K){return K==="ACTIVE"||K==="SUCCESS"}function f(K,W,q){let Q=new Map,$=new Map,J=0,H=0;for(let Y of K)Q.set(Y.type,(Q.get(Y.type)??0)+1);for(let Y of W)$.set(Y.status,($.get(Y.status)??0)+1);for(let Y of q)if(Yq(Y.status))J+=1;else H+=1;return{primaryItems:[{key:"integration-types",spec:b,data:{data:Array.from(Q.entries()).map(([Y,X])=>({type:Y,count:X}))},title:"Integration Types",description:"Configured integrations grouped by category.",height:260},{key:"connection-status",spec:T,data:{data:Array.from($.entries()).map(([Y,X])=>({status:Y,count:X}))},title:"Connection Status",description:"Operational health across current connections."}],comparisonItems:[{key:"healthy-syncs",spec:C,data:{data:[{value:J}]},title:"Healthy Syncs",description:"Active or recently successful sync configurations.",height:200},{key:"attention-syncs",spec:S,data:{data:[{value:H}]},title:"Attention Needed",description:"Paused, failed, or degraded sync configurations.",height:200}]}}import{ComparisonView as Pq,VisualizationCard as Uq,VisualizationGrid as Gq}from"@contractspec/lib.design-system";import{jsx as k,jsxs as c}from"react/jsx-runtime";function o({integrations:K,connections:W,syncConfigs:q}){let{primaryItems:Q,comparisonItems:$}=f(K,W,q);return c("section",{className:"space-y-4",children:[c("div",{children:[k("h3",{className:"font-semibold text-lg",children:"Integration Visualizations"}),k("p",{className:"text-muted-foreground text-sm",children:"Contract-backed charts for integration coverage and sync health."})]}),k(Gq,{children:Q.map((J)=>k(Uq,{data:J.data,description:J.description,height:J.height,spec:J.spec,title:J.title},J.key))}),k(Pq,{description:"Comparison surface for healthy versus attention-needed syncs.",items:$,title:"Sync-State Comparison"})]})}import{ChatWithSidebar as Mq}from"@contractspec/module.ai-chat";import{jsx as i}from"react/jsx-runtime";var Bq=["List my integrations","Show sync status","Add a connection"],Dq="You are an Integration Hub assistant. Help users manage integrations, connections, and sync configurations. When asked about integrations, connections, or syncs, provide clear, actionable guidance.";function y({proxyUrl:K="/api/chat",mcpServers:W,thinkingLevel:q="thinking",suggestions:Q=Bq,systemPrompt:$=Dq,className:J}){return i("div",{className:J??"flex h-[500px] flex-col",children:i(Mq,{className:"flex-1",systemPrompt:$,proxyUrl:K,mcpServers:W,thinkingLevel:q,suggestions:Q,showSuggestionsWhenEmpty:!0})})}import{Button as v}from"@contractspec/lib.design-system";import{Badge as e}from"@contractspec/lib.ui-kit-web/ui/badge";import{HStack as Fq}from"@contractspec/lib.ui-kit-web/ui/stack";import{jsx as A,jsxs as Rq}from"react/jsx-runtime";var Oq={ACTIVE:"default",CONNECTED:"default",SUCCESS:"default",PENDING:"secondary",PAUSED:"secondary",ERROR:"destructive",DISCONNECTED:"outline"};function L(K){return K?K.toLocaleString():"Never"}function m(K){return K?JSON.stringify(K,null,2):"No configuration"}function I({status:K}){return A(e,{variant:Oq[K]??"outline",children:K})}function p({controller:K,label:W,toggleColumnId:q,toggleVisibleLabel:Q,toggleHiddenLabel:$,pinColumnId:J,pinLabel:H,resizeColumnId:w,resizeLabel:D}){let Y=K.rows[0],X=K.columns.find((O)=>O.id===q),Z=K.columns.find((O)=>O.id===J),U=K.columns.find((O)=>O.id===w),F=Z?.pinState==="left"?!1:"left";return Rq(Fq,{gap:"sm",className:"flex-wrap",children:[A(e,{variant:"outline",children:W}),A(v,{variant:"outline",size:"sm",onPress:()=>Y?.toggleExpanded?.(!Y?.isExpanded),children:"Expand First Row"}),A(v,{variant:"outline",size:"sm",onPress:()=>X?.toggleVisibility?.(!X?.visible),children:X?.visible?Q:$}),A(v,{variant:"outline",size:"sm",onPress:()=>Z?.pin?.(F),children:Z?.pinState==="left"?`Unpin ${H}`:`Pin ${H}`}),A(v,{variant:"outline",size:"sm",onPress:()=>U?.resizeBy?.(40),children:D})]})}import{DataTable as Aq}from"@contractspec/lib.design-system";import{useContractTable as _q}from"@contractspec/lib.presentation-runtime-react";import{VStack as s}from"@contractspec/lib.ui-kit-web/ui/stack";import{Text as h}from"@contractspec/lib.ui-kit-web/ui/text";import{jsx as B,jsxs as j}from"react/jsx-runtime";function x({connections:K}){let W=_q({data:K,columns:[{id:"connection",header:"Connection",label:"Connection",accessor:(q)=>q.name,cell:({item:q})=>j(s,{gap:"xs",children:[B(h,{className:"font-medium text-sm",children:q.name}),j(h,{className:"text-muted-foreground text-xs",children:["Created ",q.createdAt.toLocaleDateString()]})]}),size:240,minSize:180,canSort:!0,canPin:!0,canResize:!0},{id:"status",header:"Status",label:"Status",accessorKey:"status",cell:({value:q})=>B(I,{status:String(q)}),size:150,canSort:!0,canPin:!0,canResize:!0},{id:"lastSyncAt",header:"Last Sync",label:"Last Sync",accessor:(q)=>q.lastSyncAt?.getTime()??0,cell:({item:q})=>L(q.lastSyncAt),size:200,canSort:!0,canHide:!0,canResize:!0},{id:"errorMessage",header:"Errors",label:"Errors",accessor:(q)=>q.errorMessage??"",cell:({value:q})=>String(q||"No errors"),size:240,canHide:!0,canResize:!0}],initialState:{pagination:{pageIndex:0,pageSize:3},columnVisibility:{errorMessage:!1},columnPinning:{left:["connection"],right:[]}},renderExpandedContent:(q)=>j(s,{gap:"sm",className:"py-2",children:[B(h,{className:"font-medium text-sm",children:"Credentials"}),B("pre",{className:"overflow-auto rounded-md bg-muted/40 p-3 text-xs",children:m(q.credentials)}),B(h,{className:"font-medium text-sm",children:"Config"}),B("pre",{className:"overflow-auto rounded-md bg-muted/40 p-3 text-xs",children:m(q.config)}),B(h,{className:"text-muted-foreground text-sm",children:q.errorMessage??"No sync errors recorded."})]}),getCanExpand:()=>!0});return B(Aq,{controller:W,title:"Connections",description:"Client-mode ContractSpec table with visibility, pinning, resizing, and expanded diagnostics.",toolbar:B(p,{controller:W,label:`${K.length} total connections`,toggleColumnId:"errorMessage",toggleVisibleLabel:"Hide Error Column",toggleHiddenLabel:"Show Error Column",pinColumnId:"status",pinLabel:"Status",resizeColumnId:"connection",resizeLabel:"Widen Connection"}),emptyState:B("div",{className:"rounded-md border border-dashed p-8 text-center text-muted-foreground text-sm",children:"No connections found"})})}import{DataTable as Nq}from"@contractspec/lib.design-system";import{useContractTable as kq}from"@contractspec/lib.presentation-runtime-react";import{VStack as t}from"@contractspec/lib.ui-kit-web/ui/stack";import{Text as _}from"@contractspec/lib.ui-kit-web/ui/text";import{jsx as E,jsxs as R}from"react/jsx-runtime";function g({syncConfigs:K}){let W=kq({data:K,columns:[{id:"sync",header:"Sync Config",label:"Sync Config",accessor:(q)=>q.name,cell:({item:q})=>R(t,{gap:"xs",children:[E(_,{className:"font-medium text-sm",children:q.name}),R(_,{className:"text-muted-foreground text-xs",children:[q.sourceEntity," \u2192 ",q.targetEntity]})]}),size:260,minSize:200,canSort:!0,canPin:!0,canResize:!0},{id:"frequency",header:"Frequency",label:"Frequency",accessorKey:"frequency",size:160,canSort:!0,canHide:!0,canResize:!0},{id:"status",header:"Status",label:"Status",accessorKey:"status",cell:({value:q})=>E(I,{status:String(q)}),size:150,canSort:!0,canPin:!0,canResize:!0},{id:"recordsSynced",header:"Records",label:"Records",accessorKey:"recordsSynced",align:"right",size:140,canSort:!0,canResize:!0},{id:"lastRunAt",header:"Last Run",label:"Last Run",accessor:(q)=>q.lastRunAt?.getTime()??0,cell:({item:q})=>L(q.lastRunAt),size:200,canSort:!0,canHide:!0,canResize:!0}],initialState:{pagination:{pageIndex:0,pageSize:3},columnVisibility:{lastRunAt:!1},columnPinning:{left:["sync"],right:[]}},renderExpandedContent:(q)=>R(t,{gap:"sm",className:"py-2",children:[R(_,{className:"text-muted-foreground text-sm",children:["Connection ",q.connectionId]}),R(_,{className:"text-muted-foreground text-sm",children:["Last run: ",L(q.lastRunAt)]}),R(_,{className:"text-muted-foreground text-sm",children:["Last status: ",q.lastRunStatus??"No runs recorded"]}),R(_,{className:"text-muted-foreground text-sm",children:["Updated ",q.updatedAt.toLocaleString()]})]}),getCanExpand:()=>!0});return E(Nq,{controller:W,title:"Sync Configs",description:"Shared table primitives applied to sync monitoring without changing the surrounding dashboard layout.",toolbar:E(p,{controller:W,label:`${K.length} syncs`,toggleColumnId:"lastRunAt",toggleVisibleLabel:"Hide Last Run",toggleHiddenLabel:"Show Last Run",pinColumnId:"status",pinLabel:"Status",resizeColumnId:"sync",resizeLabel:"Widen Sync"}),emptyState:E("div",{className:"rounded-md border border-dashed p-8 text-center text-muted-foreground text-sm",children:"No sync configurations found"})})}import{Button as n,ErrorState as Lq,LoaderBlock as hq,StatCard as u,StatCardGroup as Eq}from"@contractspec/lib.design-system";import{useState as zq}from"react";import{jsx as P,jsxs as G}from"react/jsx-runtime";var Vq={ACTIVE:"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400",INACTIVE:"bg-gray-100 text-gray-700 dark:bg-gray-900/30 dark:text-gray-400",CONNECTED:"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400",DISCONNECTED:"bg-gray-100 text-gray-700 dark:bg-gray-900/30 dark:text-gray-400",PENDING:"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400",ERROR:"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400",PAUSED:"bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400"},fq={CRM:"\uD83D\uDCCA",MARKETING:"\uD83D\uDCE3",PAYMENT:"\uD83D\uDCB3",COMMUNICATION:"\uD83D\uDCAC",DATA:"\uD83D\uDDC4\uFE0F",CUSTOM:"\u2699\uFE0F"};function vq(){let[K,W]=zq("integrations"),{integrations:q,connections:Q,syncConfigs:$,loading:J,error:H,stats:w,refetch:D}=d(),Y=[{id:"integrations",label:"Integrations",icon:"\uD83D\uDD0C"},{id:"connections",label:"Connections",icon:"\uD83D\uDD17"},{id:"syncs",label:"Sync Configs",icon:"\uD83D\uDD04"},{id:"chat",label:"Chat",icon:"\uD83D\uDCAC"}];if(J)return P(hq,{label:"Loading Integrations..."});if(H)return P(Lq,{title:"Failed to load Integrations",description:H.message,onRetry:D,retryLabel:"Retry"});return G("div",{className:"space-y-6",children:[G("div",{className:"flex items-center justify-between",children:[P("h2",{className:"font-bold text-2xl",children:"Integration Hub"}),G(n,{onClick:()=>alert("Add integration modal"),children:[P("span",{className:"mr-2",children:"+"})," Add Integration"]})]}),G(Eq,{children:[P(u,{label:"Integrations",value:w.totalIntegrations,hint:`${w.activeIntegrations} active`}),P(u,{label:"Connections",value:w.totalConnections,hint:`${w.connectedCount} connected`}),P(u,{label:"Syncs",value:w.totalSyncs,hint:`${w.activeSyncs} active`})]}),P(o,{connections:Q,integrations:q,syncConfigs:$}),P("nav",{className:"flex gap-1 rounded-lg bg-muted p-1",role:"tablist",children:Y.map((X)=>G(n,{type:"button",role:"tab","aria-selected":K===X.id,onClick:()=>W(X.id),className:`flex flex-1 items-center justify-center gap-2 rounded-md px-4 py-2 font-medium text-sm transition-colors ${K===X.id?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[P("span",{children:X.icon}),X.label]},X.id))}),G("div",{className:"min-h-[400px]",role:"tabpanel",children:[K==="integrations"&&G("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:[q.map((X)=>G("div",{className:"cursor-pointer rounded-lg border border-border bg-card p-4 transition-colors hover:bg-muted/50",children:[G("div",{className:"mb-3 flex items-center gap-3",children:[P("span",{className:"text-2xl",children:fq[X.type]??"\u2699\uFE0F"}),G("div",{children:[P("h3",{className:"font-medium",children:X.name}),P("p",{className:"text-muted-foreground text-sm",children:X.type})]})]}),G("div",{className:"flex items-center justify-between",children:[P("span",{className:`inline-flex rounded-full px-2 py-0.5 font-medium text-xs ${Vq[X.status]??""}`,children:X.status}),P("span",{className:"text-muted-foreground text-xs",children:X.createdAt.toLocaleDateString()})]})]},X.id)),q.length===0&&P("div",{className:"col-span-full flex h-64 items-center justify-center text-muted-foreground",children:"No integrations configured"})]}),K==="connections"&&P(x,{connections:Q}),K==="chat"&&P(y,{proxyUrl:"/api/chat",thinkingLevel:"thinking",suggestions:["List my integrations","Show sync status","Add a connection"],className:"min-h-[400px]"}),K==="syncs"&&P(g,{syncConfigs:$})]})]})}var qq=[{id:"int-1",name:"Salesforce",type:"CRM",status:"ACTIVE",connectionCount:3},{id:"int-2",name:"HubSpot",type:"MARKETING",status:"ACTIVE",connectionCount:2},{id:"int-3",name:"Stripe",type:"PAYMENT",status:"ACTIVE",connectionCount:1},{id:"int-4",name:"Slack",type:"COMMUNICATION",status:"INACTIVE",connectionCount:0},{id:"int-5",name:"Google Sheets",type:"DATA",status:"ACTIVE",connectionCount:5},{id:"int-6",name:"PostHog",type:"ANALYTICS",status:"ACTIVE",connectionCount:1}],r=[{id:"conn-1",integrationId:"int-1",name:"Production Salesforce",status:"CONNECTED",lastSyncAt:"2024-01-16T10:00:00Z"},{id:"conn-2",integrationId:"int-1",name:"Sandbox Salesforce",status:"CONNECTED",lastSyncAt:"2024-01-15T14:00:00Z"},{id:"conn-3",integrationId:"int-2",name:"Marketing HubSpot",status:"CONNECTED",lastSyncAt:"2024-01-16T08:00:00Z"},{id:"conn-4",integrationId:"int-3",name:"Stripe Live",status:"CONNECTED",lastSyncAt:"2024-01-16T12:00:00Z"},{id:"conn-5",integrationId:"int-5",name:"Analytics Sheet",status:"ERROR",lastSyncAt:"2024-01-14T09:00:00Z",error:"Authentication expired"},{id:"conn-6",integrationId:"int-6",name:"PostHog Workspace",status:"CONNECTED",lastSyncAt:"2024-01-16T11:45:00Z"}],Kq=[{id:"sync-1",connectionId:"conn-1",name:"Contacts Sync",frequency:"HOURLY",lastRunAt:"2024-01-16T10:00:00Z",status:"SUCCESS",recordsSynced:1250},{id:"sync-2",connectionId:"conn-1",name:"Opportunities Sync",frequency:"DAILY",lastRunAt:"2024-01-16T00:00:00Z",status:"SUCCESS",recordsSynced:340},{id:"sync-3",connectionId:"conn-3",name:"Orders Sync",frequency:"REALTIME",lastRunAt:"2024-01-16T12:30:00Z",status:"SUCCESS",recordsSynced:89},{id:"sync-4",connectionId:"conn-5",name:"Metrics Export",frequency:"DAILY",lastRunAt:"2024-01-14T09:00:00Z",status:"FAILED",recordsSynced:0}],Iq={target:"markdown",render:async(K)=>{if(K.source.type!=="component"||K.source.componentKey!=="IntegrationDashboard")throw Error("integrationDashboardMarkdownRenderer: not IntegrationDashboard");let W=qq,q=r,Q=Kq,$=f(W,q,Q),J=W.filter((Z)=>Z.status==="ACTIVE"),H=q.filter((Z)=>Z.status==="CONNECTED"),w=q.filter((Z)=>Z.status==="ERROR"),Y=Q.filter((Z)=>Z.status==="SUCCESS").reduce((Z,U)=>Z+U.recordsSynced,0),X=["# Integration Hub","","> Connect and sync data with external services","","## Overview","","| Metric | Value |","|--------|-------|",`| Active Integrations | ${J.length} |`,`| Connected Services | ${H.length} |`,`| Error Connections | ${w.length} |`,`| Sync Configs | ${Q.length} |`,`| Records Synced (24h) | ${Y.toLocaleString()} |`,""];X.push("## Visualization Overview"),X.push("");for(let Z of[...$.primaryItems,...$.comparisonItems])X.push(`- **${Z.title}** via \`${Z.spec.meta.key}\``);X.push(""),X.push("## Integrations"),X.push(""),X.push("| Name | Type | Connections | Status |"),X.push("|------|------|-------------|--------|");for(let Z of W){let U=Z.status==="ACTIVE"?"\uD83D\uDFE2":"\u26AB";X.push(`| ${Z.name} | ${Z.type} | ${Z.connectionCount} | ${U} ${Z.status} |`)}X.push(""),X.push("## Recent Sync Activity"),X.push(""),X.push("| Sync | Frequency | Last Run | Records | Status |"),X.push("|------|-----------|----------|---------|--------|");for(let Z of Q){let U=new Date(Z.lastRunAt).toLocaleString(),F=Z.status==="SUCCESS"?"\u2705":"\u274C";X.push(`| ${Z.name} | ${Z.frequency} | ${U} | ${Z.recordsSynced} | ${F} ${Z.status} |`)}if(w.length>0){X.push(""),X.push("## \u26A0\uFE0F Connections with Errors"),X.push("");for(let Z of w){let U=W.find((F)=>F.id===Z.integrationId);X.push(`- **${Z.name}** (${U?.name??"Unknown"}): ${Z.error??"Unknown error"}`)}}return{mimeType:"text/markdown",body:X.join(`
|
|
3
|
+
`)}}},pq={target:"markdown",render:async(K)=>{if(K.source.type!=="component"||K.source.componentKey!=="ConnectionList")throw Error("connectionListMarkdownRenderer: not ConnectionList");let W=r,q=qq,Q=["# Connections","","> Manage connections to external services",""];for(let $ of q){let J=W.filter((H)=>H.integrationId===$.id);if(J.length===0)continue;Q.push(`## ${$.name}`),Q.push(""),Q.push("| Connection | Status | Last Sync |"),Q.push("|------------|--------|-----------|");for(let H of J){let w=new Date(H.lastSyncAt).toLocaleString(),D=H.status==="CONNECTED"?"\uD83D\uDFE2":H.status==="ERROR"?"\uD83D\uDD34":"\u26AB";Q.push(`| ${H.name} | ${D} ${H.status} | ${w} |`)}Q.push("")}return{mimeType:"text/markdown",body:Q.join(`
|
|
4
|
+
`)}}},dq={target:"markdown",render:async(K)=>{if(K.source.type!=="component"||K.source.componentKey!=="SyncConfigEditor")throw Error("syncConfigMarkdownRenderer: not SyncConfigEditor");let W=Kq,q=r,Q=["# Sync Configurations","","> Configure automated data synchronization",""];for(let $ of W){let J=q.find((w)=>w.id===$.connectionId),H=$.status==="SUCCESS"?"\u2705":"\u274C";Q.push(`## ${$.name}`),Q.push(""),Q.push(`**Connection:** ${J?.name??"Unknown"}`),Q.push(`**Frequency:** ${$.frequency}`),Q.push(`**Status:** ${H} ${$.status}`),Q.push(`**Last Run:** ${new Date($.lastRunAt).toLocaleString()}`),Q.push(`**Records Synced:** ${$.recordsSynced.toLocaleString()}`),Q.push("")}return Q.push("## Frequency Options"),Q.push(""),Q.push("- **REALTIME**: Sync on every change"),Q.push("- **HOURLY**: Sync every hour"),Q.push("- **DAILY**: Sync once per day"),Q.push("- **WEEKLY**: Sync once per week"),Q.push("- **MANUAL**: Sync only when triggered"),{mimeType:"text/markdown",body:Q.join(`
|
|
5
|
+
`)}}};export{d as useIntegrationData,dq as syncConfigMarkdownRenderer,Iq as integrationDashboardMarkdownRenderer,pq as connectionListMarkdownRenderer,y as IntegrationHubChat,vq as IntegrationDashboard};
|