@contractspec/example.integration-hub 3.8.8 → 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 +14 -14
|
@@ -1,484 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} from "@contractspec/lib.contracts-spec/visualizations";
|
|
6
|
-
var INTEGRATION_LIST_REF = {
|
|
7
|
-
key: "integration.list",
|
|
8
|
-
version: "1.0.0"
|
|
9
|
-
};
|
|
10
|
-
var CONNECTION_LIST_REF = {
|
|
11
|
-
key: "integration.connection.list",
|
|
12
|
-
version: "1.0.0"
|
|
13
|
-
};
|
|
14
|
-
var SYNC_CONFIG_REF = {
|
|
15
|
-
key: "integration.syncConfig.list",
|
|
16
|
-
version: "1.0.0"
|
|
17
|
-
};
|
|
18
|
-
var META = {
|
|
19
|
-
version: "1.0.0",
|
|
20
|
-
domain: "integration",
|
|
21
|
-
stability: "experimental",
|
|
22
|
-
owners: ["@example.integration-hub"],
|
|
23
|
-
tags: ["integration", "visualization", "sync"]
|
|
24
|
-
};
|
|
25
|
-
var IntegrationTypeVisualization = defineVisualization({
|
|
26
|
-
meta: {
|
|
27
|
-
...META,
|
|
28
|
-
key: "integration-hub.visualization.integration-types",
|
|
29
|
-
title: "Integration Types",
|
|
30
|
-
description: "Distribution of configured integration categories.",
|
|
31
|
-
goal: "Show where integration coverage is concentrated.",
|
|
32
|
-
context: "Integration overview."
|
|
33
|
-
},
|
|
34
|
-
source: { primary: INTEGRATION_LIST_REF, resultPath: "data" },
|
|
35
|
-
visualization: {
|
|
36
|
-
kind: "pie",
|
|
37
|
-
nameDimension: "type",
|
|
38
|
-
valueMeasure: "count",
|
|
39
|
-
dimensions: [
|
|
40
|
-
{ key: "type", label: "Type", dataPath: "type", type: "category" }
|
|
41
|
-
],
|
|
42
|
-
measures: [
|
|
43
|
-
{ key: "count", label: "Count", dataPath: "count", format: "number" }
|
|
44
|
-
],
|
|
45
|
-
table: { caption: "Integration counts by type." }
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
var ConnectionStatusVisualization = defineVisualization({
|
|
49
|
-
meta: {
|
|
50
|
-
...META,
|
|
51
|
-
key: "integration-hub.visualization.connection-status",
|
|
52
|
-
title: "Connection Status",
|
|
53
|
-
description: "Status distribution across configured connections.",
|
|
54
|
-
goal: "Highlight connection health and instability.",
|
|
55
|
-
context: "Connection monitoring."
|
|
56
|
-
},
|
|
57
|
-
source: { primary: CONNECTION_LIST_REF, resultPath: "data" },
|
|
58
|
-
visualization: {
|
|
59
|
-
kind: "cartesian",
|
|
60
|
-
variant: "bar",
|
|
61
|
-
xDimension: "status",
|
|
62
|
-
yMeasures: ["count"],
|
|
63
|
-
dimensions: [
|
|
64
|
-
{ key: "status", label: "Status", dataPath: "status", type: "category" }
|
|
65
|
-
],
|
|
66
|
-
measures: [
|
|
67
|
-
{
|
|
68
|
-
key: "count",
|
|
69
|
-
label: "Connections",
|
|
70
|
-
dataPath: "count",
|
|
71
|
-
format: "number",
|
|
72
|
-
color: "#1d4ed8"
|
|
73
|
-
}
|
|
74
|
-
],
|
|
75
|
-
table: { caption: "Connection counts by status." }
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
var HealthySyncMetricVisualization = defineVisualization({
|
|
79
|
-
meta: {
|
|
80
|
-
...META,
|
|
81
|
-
key: "integration-hub.visualization.sync-healthy",
|
|
82
|
-
title: "Healthy Syncs",
|
|
83
|
-
description: "Sync configurations currently healthy or recently successful.",
|
|
84
|
-
goal: "Summarize healthy synchronization capacity.",
|
|
85
|
-
context: "Sync-state comparison."
|
|
86
|
-
},
|
|
87
|
-
source: { primary: SYNC_CONFIG_REF, resultPath: "data" },
|
|
88
|
-
visualization: {
|
|
89
|
-
kind: "metric",
|
|
90
|
-
measure: "value",
|
|
91
|
-
measures: [
|
|
92
|
-
{ key: "value", label: "Syncs", dataPath: "value", format: "number" }
|
|
93
|
-
],
|
|
94
|
-
table: { caption: "Healthy sync count." }
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
var AttentionSyncMetricVisualization = defineVisualization({
|
|
98
|
-
meta: {
|
|
99
|
-
...META,
|
|
100
|
-
key: "integration-hub.visualization.sync-attention",
|
|
101
|
-
title: "Attention Needed",
|
|
102
|
-
description: "Sync configurations paused, failing, or otherwise needing review.",
|
|
103
|
-
goal: "Summarize syncs needing action.",
|
|
104
|
-
context: "Sync-state comparison."
|
|
105
|
-
},
|
|
106
|
-
source: { primary: SYNC_CONFIG_REF, resultPath: "data" },
|
|
107
|
-
visualization: {
|
|
108
|
-
kind: "metric",
|
|
109
|
-
measure: "value",
|
|
110
|
-
measures: [
|
|
111
|
-
{ key: "value", label: "Syncs", dataPath: "value", format: "number" }
|
|
112
|
-
],
|
|
113
|
-
table: { caption: "Syncs requiring attention." }
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
var IntegrationVisualizationSpecs = [
|
|
117
|
-
IntegrationTypeVisualization,
|
|
118
|
-
ConnectionStatusVisualization,
|
|
119
|
-
HealthySyncMetricVisualization,
|
|
120
|
-
AttentionSyncMetricVisualization
|
|
121
|
-
];
|
|
122
|
-
var IntegrationVisualizationRegistry = new VisualizationRegistry([
|
|
123
|
-
...IntegrationVisualizationSpecs
|
|
124
|
-
]);
|
|
125
|
-
var IntegrationVisualizationRefs = IntegrationVisualizationSpecs.map((spec) => ({
|
|
126
|
-
key: spec.meta.key,
|
|
127
|
-
version: spec.meta.version
|
|
128
|
-
}));
|
|
129
|
-
|
|
130
|
-
// src/visualizations/selectors.ts
|
|
131
|
-
function isHealthySync(status) {
|
|
132
|
-
return status === "ACTIVE" || status === "SUCCESS";
|
|
133
|
-
}
|
|
134
|
-
function createIntegrationVisualizationSections(integrations, connections, syncConfigs) {
|
|
135
|
-
const integrationTypes = new Map;
|
|
136
|
-
const connectionStatuses = new Map;
|
|
137
|
-
let healthySyncs = 0;
|
|
138
|
-
let attentionSyncs = 0;
|
|
139
|
-
for (const integration of integrations) {
|
|
140
|
-
integrationTypes.set(integration.type, (integrationTypes.get(integration.type) ?? 0) + 1);
|
|
141
|
-
}
|
|
142
|
-
for (const connection of connections) {
|
|
143
|
-
connectionStatuses.set(connection.status, (connectionStatuses.get(connection.status) ?? 0) + 1);
|
|
144
|
-
}
|
|
145
|
-
for (const syncConfig of syncConfigs) {
|
|
146
|
-
if (isHealthySync(syncConfig.status)) {
|
|
147
|
-
healthySyncs += 1;
|
|
148
|
-
} else {
|
|
149
|
-
attentionSyncs += 1;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
const primaryItems = [
|
|
153
|
-
{
|
|
154
|
-
key: "integration-types",
|
|
155
|
-
spec: IntegrationTypeVisualization,
|
|
156
|
-
data: {
|
|
157
|
-
data: Array.from(integrationTypes.entries()).map(([type, count]) => ({
|
|
158
|
-
type,
|
|
159
|
-
count
|
|
160
|
-
}))
|
|
161
|
-
},
|
|
162
|
-
title: "Integration Types",
|
|
163
|
-
description: "Configured integrations grouped by category.",
|
|
164
|
-
height: 260
|
|
165
|
-
},
|
|
166
|
-
{
|
|
167
|
-
key: "connection-status",
|
|
168
|
-
spec: ConnectionStatusVisualization,
|
|
169
|
-
data: {
|
|
170
|
-
data: Array.from(connectionStatuses.entries()).map(([status, count]) => ({
|
|
171
|
-
status,
|
|
172
|
-
count
|
|
173
|
-
}))
|
|
174
|
-
},
|
|
175
|
-
title: "Connection Status",
|
|
176
|
-
description: "Operational health across current connections."
|
|
177
|
-
}
|
|
178
|
-
];
|
|
179
|
-
const comparisonItems = [
|
|
180
|
-
{
|
|
181
|
-
key: "healthy-syncs",
|
|
182
|
-
spec: HealthySyncMetricVisualization,
|
|
183
|
-
data: { data: [{ value: healthySyncs }] },
|
|
184
|
-
title: "Healthy Syncs",
|
|
185
|
-
description: "Active or recently successful sync configurations.",
|
|
186
|
-
height: 200
|
|
187
|
-
},
|
|
188
|
-
{
|
|
189
|
-
key: "attention-syncs",
|
|
190
|
-
spec: AttentionSyncMetricVisualization,
|
|
191
|
-
data: { data: [{ value: attentionSyncs }] },
|
|
192
|
-
title: "Attention Needed",
|
|
193
|
-
description: "Paused, failed, or degraded sync configurations.",
|
|
194
|
-
height: 200
|
|
195
|
-
}
|
|
196
|
-
];
|
|
197
|
-
return {
|
|
198
|
-
primaryItems,
|
|
199
|
-
comparisonItems
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
// src/ui/renderers/integration.markdown.ts
|
|
203
|
-
var mockIntegrations = [
|
|
204
|
-
{
|
|
205
|
-
id: "int-1",
|
|
206
|
-
name: "Salesforce",
|
|
207
|
-
type: "CRM",
|
|
208
|
-
status: "ACTIVE",
|
|
209
|
-
connectionCount: 3
|
|
210
|
-
},
|
|
211
|
-
{
|
|
212
|
-
id: "int-2",
|
|
213
|
-
name: "HubSpot",
|
|
214
|
-
type: "MARKETING",
|
|
215
|
-
status: "ACTIVE",
|
|
216
|
-
connectionCount: 2
|
|
217
|
-
},
|
|
218
|
-
{
|
|
219
|
-
id: "int-3",
|
|
220
|
-
name: "Stripe",
|
|
221
|
-
type: "PAYMENT",
|
|
222
|
-
status: "ACTIVE",
|
|
223
|
-
connectionCount: 1
|
|
224
|
-
},
|
|
225
|
-
{
|
|
226
|
-
id: "int-4",
|
|
227
|
-
name: "Slack",
|
|
228
|
-
type: "COMMUNICATION",
|
|
229
|
-
status: "INACTIVE",
|
|
230
|
-
connectionCount: 0
|
|
231
|
-
},
|
|
232
|
-
{
|
|
233
|
-
id: "int-5",
|
|
234
|
-
name: "Google Sheets",
|
|
235
|
-
type: "DATA",
|
|
236
|
-
status: "ACTIVE",
|
|
237
|
-
connectionCount: 5
|
|
238
|
-
},
|
|
239
|
-
{
|
|
240
|
-
id: "int-6",
|
|
241
|
-
name: "PostHog",
|
|
242
|
-
type: "ANALYTICS",
|
|
243
|
-
status: "ACTIVE",
|
|
244
|
-
connectionCount: 1
|
|
245
|
-
}
|
|
246
|
-
];
|
|
247
|
-
var mockConnections = [
|
|
248
|
-
{
|
|
249
|
-
id: "conn-1",
|
|
250
|
-
integrationId: "int-1",
|
|
251
|
-
name: "Production Salesforce",
|
|
252
|
-
status: "CONNECTED",
|
|
253
|
-
lastSyncAt: "2024-01-16T10:00:00Z"
|
|
254
|
-
},
|
|
255
|
-
{
|
|
256
|
-
id: "conn-2",
|
|
257
|
-
integrationId: "int-1",
|
|
258
|
-
name: "Sandbox Salesforce",
|
|
259
|
-
status: "CONNECTED",
|
|
260
|
-
lastSyncAt: "2024-01-15T14:00:00Z"
|
|
261
|
-
},
|
|
262
|
-
{
|
|
263
|
-
id: "conn-3",
|
|
264
|
-
integrationId: "int-2",
|
|
265
|
-
name: "Marketing HubSpot",
|
|
266
|
-
status: "CONNECTED",
|
|
267
|
-
lastSyncAt: "2024-01-16T08:00:00Z"
|
|
268
|
-
},
|
|
269
|
-
{
|
|
270
|
-
id: "conn-4",
|
|
271
|
-
integrationId: "int-3",
|
|
272
|
-
name: "Stripe Live",
|
|
273
|
-
status: "CONNECTED",
|
|
274
|
-
lastSyncAt: "2024-01-16T12:00:00Z"
|
|
275
|
-
},
|
|
276
|
-
{
|
|
277
|
-
id: "conn-5",
|
|
278
|
-
integrationId: "int-5",
|
|
279
|
-
name: "Analytics Sheet",
|
|
280
|
-
status: "ERROR",
|
|
281
|
-
lastSyncAt: "2024-01-14T09:00:00Z",
|
|
282
|
-
error: "Authentication expired"
|
|
283
|
-
},
|
|
284
|
-
{
|
|
285
|
-
id: "conn-6",
|
|
286
|
-
integrationId: "int-6",
|
|
287
|
-
name: "PostHog Workspace",
|
|
288
|
-
status: "CONNECTED",
|
|
289
|
-
lastSyncAt: "2024-01-16T11:45:00Z"
|
|
290
|
-
}
|
|
291
|
-
];
|
|
292
|
-
var mockSyncConfigs = [
|
|
293
|
-
{
|
|
294
|
-
id: "sync-1",
|
|
295
|
-
connectionId: "conn-1",
|
|
296
|
-
name: "Contacts Sync",
|
|
297
|
-
frequency: "HOURLY",
|
|
298
|
-
lastRunAt: "2024-01-16T10:00:00Z",
|
|
299
|
-
status: "SUCCESS",
|
|
300
|
-
recordsSynced: 1250
|
|
301
|
-
},
|
|
302
|
-
{
|
|
303
|
-
id: "sync-2",
|
|
304
|
-
connectionId: "conn-1",
|
|
305
|
-
name: "Opportunities Sync",
|
|
306
|
-
frequency: "DAILY",
|
|
307
|
-
lastRunAt: "2024-01-16T00:00:00Z",
|
|
308
|
-
status: "SUCCESS",
|
|
309
|
-
recordsSynced: 340
|
|
310
|
-
},
|
|
311
|
-
{
|
|
312
|
-
id: "sync-3",
|
|
313
|
-
connectionId: "conn-3",
|
|
314
|
-
name: "Orders Sync",
|
|
315
|
-
frequency: "REALTIME",
|
|
316
|
-
lastRunAt: "2024-01-16T12:30:00Z",
|
|
317
|
-
status: "SUCCESS",
|
|
318
|
-
recordsSynced: 89
|
|
319
|
-
},
|
|
320
|
-
{
|
|
321
|
-
id: "sync-4",
|
|
322
|
-
connectionId: "conn-5",
|
|
323
|
-
name: "Metrics Export",
|
|
324
|
-
frequency: "DAILY",
|
|
325
|
-
lastRunAt: "2024-01-14T09:00:00Z",
|
|
326
|
-
status: "FAILED",
|
|
327
|
-
recordsSynced: 0
|
|
328
|
-
}
|
|
329
|
-
];
|
|
330
|
-
var integrationDashboardMarkdownRenderer = {
|
|
331
|
-
target: "markdown",
|
|
332
|
-
render: async (desc) => {
|
|
333
|
-
if (desc.source.type !== "component" || desc.source.componentKey !== "IntegrationDashboard") {
|
|
334
|
-
throw new Error("integrationDashboardMarkdownRenderer: not IntegrationDashboard");
|
|
335
|
-
}
|
|
336
|
-
const integrations = mockIntegrations;
|
|
337
|
-
const connections = mockConnections;
|
|
338
|
-
const syncs = mockSyncConfigs;
|
|
339
|
-
const visualizations = createIntegrationVisualizationSections(integrations, connections, syncs);
|
|
340
|
-
const activeIntegrations = integrations.filter((i) => i.status === "ACTIVE");
|
|
341
|
-
const connectedConnections = connections.filter((c) => c.status === "CONNECTED");
|
|
342
|
-
const errorConnections = connections.filter((c) => c.status === "ERROR");
|
|
343
|
-
const successfulSyncs = syncs.filter((s) => s.status === "SUCCESS");
|
|
344
|
-
const totalRecordsSynced = successfulSyncs.reduce((sum, s) => sum + s.recordsSynced, 0);
|
|
345
|
-
const lines = [
|
|
346
|
-
"# Integration Hub",
|
|
347
|
-
"",
|
|
348
|
-
"> Connect and sync data with external services",
|
|
349
|
-
"",
|
|
350
|
-
"## Overview",
|
|
351
|
-
"",
|
|
352
|
-
"| Metric | Value |",
|
|
353
|
-
"|--------|-------|",
|
|
354
|
-
`| Active Integrations | ${activeIntegrations.length} |`,
|
|
355
|
-
`| Connected Services | ${connectedConnections.length} |`,
|
|
356
|
-
`| Error Connections | ${errorConnections.length} |`,
|
|
357
|
-
`| Sync Configs | ${syncs.length} |`,
|
|
358
|
-
`| Records Synced (24h) | ${totalRecordsSynced.toLocaleString()} |`,
|
|
359
|
-
""
|
|
360
|
-
];
|
|
361
|
-
lines.push("## Visualization Overview");
|
|
362
|
-
lines.push("");
|
|
363
|
-
for (const item of [
|
|
364
|
-
...visualizations.primaryItems,
|
|
365
|
-
...visualizations.comparisonItems
|
|
366
|
-
]) {
|
|
367
|
-
lines.push(`- **${item.title}** via \`${item.spec.meta.key}\``);
|
|
368
|
-
}
|
|
369
|
-
lines.push("");
|
|
370
|
-
lines.push("## Integrations");
|
|
371
|
-
lines.push("");
|
|
372
|
-
lines.push("| Name | Type | Connections | Status |");
|
|
373
|
-
lines.push("|------|------|-------------|--------|");
|
|
374
|
-
for (const integration of integrations) {
|
|
375
|
-
const statusIcon = integration.status === "ACTIVE" ? "\uD83D\uDFE2" : "⚫";
|
|
376
|
-
lines.push(`| ${integration.name} | ${integration.type} | ${integration.connectionCount} | ${statusIcon} ${integration.status} |`);
|
|
377
|
-
}
|
|
378
|
-
lines.push("");
|
|
379
|
-
lines.push("## Recent Sync Activity");
|
|
380
|
-
lines.push("");
|
|
381
|
-
lines.push("| Sync | Frequency | Last Run | Records | Status |");
|
|
382
|
-
lines.push("|------|-----------|----------|---------|--------|");
|
|
383
|
-
for (const sync of syncs) {
|
|
384
|
-
const lastRun = new Date(sync.lastRunAt).toLocaleString();
|
|
385
|
-
const statusIcon = sync.status === "SUCCESS" ? "✅" : "❌";
|
|
386
|
-
lines.push(`| ${sync.name} | ${sync.frequency} | ${lastRun} | ${sync.recordsSynced} | ${statusIcon} ${sync.status} |`);
|
|
387
|
-
}
|
|
388
|
-
if (errorConnections.length > 0) {
|
|
389
|
-
lines.push("");
|
|
390
|
-
lines.push("## ⚠️ Connections with Errors");
|
|
391
|
-
lines.push("");
|
|
392
|
-
for (const conn of errorConnections) {
|
|
393
|
-
const integration = integrations.find((i) => i.id === conn.integrationId);
|
|
394
|
-
lines.push(`- **${conn.name}** (${integration?.name ?? "Unknown"}): ${conn.error ?? "Unknown error"}`);
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
return {
|
|
398
|
-
mimeType: "text/markdown",
|
|
399
|
-
body: lines.join(`
|
|
400
|
-
`)
|
|
401
|
-
};
|
|
402
|
-
}
|
|
403
|
-
};
|
|
404
|
-
var connectionListMarkdownRenderer = {
|
|
405
|
-
target: "markdown",
|
|
406
|
-
render: async (desc) => {
|
|
407
|
-
if (desc.source.type !== "component" || desc.source.componentKey !== "ConnectionList") {
|
|
408
|
-
throw new Error("connectionListMarkdownRenderer: not ConnectionList");
|
|
409
|
-
}
|
|
410
|
-
const connections = mockConnections;
|
|
411
|
-
const integrations = mockIntegrations;
|
|
412
|
-
const lines = [
|
|
413
|
-
"# Connections",
|
|
414
|
-
"",
|
|
415
|
-
"> Manage connections to external services",
|
|
416
|
-
""
|
|
417
|
-
];
|
|
418
|
-
for (const integration of integrations) {
|
|
419
|
-
const intConnections = connections.filter((c) => c.integrationId === integration.id);
|
|
420
|
-
if (intConnections.length === 0)
|
|
421
|
-
continue;
|
|
422
|
-
lines.push(`## ${integration.name}`);
|
|
423
|
-
lines.push("");
|
|
424
|
-
lines.push("| Connection | Status | Last Sync |");
|
|
425
|
-
lines.push("|------------|--------|-----------|");
|
|
426
|
-
for (const conn of intConnections) {
|
|
427
|
-
const lastSync = new Date(conn.lastSyncAt).toLocaleString();
|
|
428
|
-
const statusIcon = conn.status === "CONNECTED" ? "\uD83D\uDFE2" : conn.status === "ERROR" ? "\uD83D\uDD34" : "⚫";
|
|
429
|
-
lines.push(`| ${conn.name} | ${statusIcon} ${conn.status} | ${lastSync} |`);
|
|
430
|
-
}
|
|
431
|
-
lines.push("");
|
|
432
|
-
}
|
|
433
|
-
return {
|
|
434
|
-
mimeType: "text/markdown",
|
|
435
|
-
body: lines.join(`
|
|
436
|
-
`)
|
|
437
|
-
};
|
|
438
|
-
}
|
|
439
|
-
};
|
|
440
|
-
var syncConfigMarkdownRenderer = {
|
|
441
|
-
target: "markdown",
|
|
442
|
-
render: async (desc) => {
|
|
443
|
-
if (desc.source.type !== "component" || desc.source.componentKey !== "SyncConfigEditor") {
|
|
444
|
-
throw new Error("syncConfigMarkdownRenderer: not SyncConfigEditor");
|
|
445
|
-
}
|
|
446
|
-
const syncs = mockSyncConfigs;
|
|
447
|
-
const connections = mockConnections;
|
|
448
|
-
const lines = [
|
|
449
|
-
"# Sync Configurations",
|
|
450
|
-
"",
|
|
451
|
-
"> Configure automated data synchronization",
|
|
452
|
-
""
|
|
453
|
-
];
|
|
454
|
-
for (const sync of syncs) {
|
|
455
|
-
const connection = connections.find((c) => c.id === sync.connectionId);
|
|
456
|
-
const statusIcon = sync.status === "SUCCESS" ? "✅" : "❌";
|
|
457
|
-
lines.push(`## ${sync.name}`);
|
|
458
|
-
lines.push("");
|
|
459
|
-
lines.push(`**Connection:** ${connection?.name ?? "Unknown"}`);
|
|
460
|
-
lines.push(`**Frequency:** ${sync.frequency}`);
|
|
461
|
-
lines.push(`**Status:** ${statusIcon} ${sync.status}`);
|
|
462
|
-
lines.push(`**Last Run:** ${new Date(sync.lastRunAt).toLocaleString()}`);
|
|
463
|
-
lines.push(`**Records Synced:** ${sync.recordsSynced.toLocaleString()}`);
|
|
464
|
-
lines.push("");
|
|
465
|
-
}
|
|
466
|
-
lines.push("## Frequency Options");
|
|
467
|
-
lines.push("");
|
|
468
|
-
lines.push("- **REALTIME**: Sync on every change");
|
|
469
|
-
lines.push("- **HOURLY**: Sync every hour");
|
|
470
|
-
lines.push("- **DAILY**: Sync once per day");
|
|
471
|
-
lines.push("- **WEEKLY**: Sync once per week");
|
|
472
|
-
lines.push("- **MANUAL**: Sync only when triggered");
|
|
473
|
-
return {
|
|
474
|
-
mimeType: "text/markdown",
|
|
475
|
-
body: lines.join(`
|
|
476
|
-
`)
|
|
477
|
-
};
|
|
478
|
-
}
|
|
479
|
-
};
|
|
480
|
-
export {
|
|
481
|
-
syncConfigMarkdownRenderer,
|
|
482
|
-
integrationDashboardMarkdownRenderer,
|
|
483
|
-
connectionListMarkdownRenderer
|
|
484
|
-
};
|
|
1
|
+
import{defineVisualization as W,VisualizationRegistry as h}from"@contractspec/lib.contracts-spec/visualizations";var F={key:"integration.list",version:"1.0.0"},A={key:"integration.connection.list",version:"1.0.0"},k={key:"integration.syncConfig.list",version:"1.0.0"},X={version:"1.0.0",domain:"integration",stability:"experimental",owners:["@example.integration-hub"],tags:["integration","visualization","sync"]},L=W({meta:{...X,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:F,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."}}}),H=W({meta:{...X,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:A,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."}}}),Y=W({meta:{...X,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:k,resultPath:"data"},visualization:{kind:"metric",measure:"value",measures:[{key:"value",label:"Syncs",dataPath:"value",format:"number"}],table:{caption:"Healthy sync count."}}}),v=W({meta:{...X,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:k,resultPath:"data"},visualization:{kind:"metric",measure:"value",measures:[{key:"value",label:"Syncs",dataPath:"value",format:"number"}],table:{caption:"Syncs requiring attention."}}}),R=[L,H,Y,v],d=new h([...R]),V=R.map((j)=>({key:j.meta.key,version:j.meta.version}));function m(j){return j==="ACTIVE"||j==="SUCCESS"}function f(j,J,K){let w=new Map,D=new Map,P=0,q=0;for(let B of j)w.set(B.type,(w.get(B.type)??0)+1);for(let B of J)D.set(B.status,(D.get(B.status)??0)+1);for(let B of K)if(m(B.status))P+=1;else q+=1;return{primaryItems:[{key:"integration-types",spec:L,data:{data:Array.from(w.entries()).map(([B,b])=>({type:B,count:b}))},title:"Integration Types",description:"Configured integrations grouped by category.",height:260},{key:"connection-status",spec:H,data:{data:Array.from(D.entries()).map(([B,b])=>({status:B,count:b}))},title:"Connection Status",description:"Operational health across current connections."}],comparisonItems:[{key:"healthy-syncs",spec:Y,data:{data:[{value:P}]},title:"Healthy Syncs",description:"Active or recently successful sync configurations.",height:200},{key:"attention-syncs",spec:v,data:{data:[{value:q}]},title:"Attention Needed",description:"Paused, failed, or degraded sync configurations.",height:200}]}}var M=[{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}],G=[{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"}],O=[{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}],_={target:"markdown",render:async(j)=>{if(j.source.type!=="component"||j.source.componentKey!=="IntegrationDashboard")throw Error("integrationDashboardMarkdownRenderer: not IntegrationDashboard");let J=M,K=G,w=O,D=f(J,K,w),P=J.filter((x)=>x.status==="ACTIVE"),q=K.filter((x)=>x.status==="CONNECTED"),Q=K.filter((x)=>x.status==="ERROR"),B=w.filter((x)=>x.status==="SUCCESS").reduce((x,U)=>x+U.recordsSynced,0),b=["# Integration Hub","","> Connect and sync data with external services","","## Overview","","| Metric | Value |","|--------|-------|",`| Active Integrations | ${P.length} |`,`| Connected Services | ${q.length} |`,`| Error Connections | ${Q.length} |`,`| Sync Configs | ${w.length} |`,`| Records Synced (24h) | ${B.toLocaleString()} |`,""];b.push("## Visualization Overview"),b.push("");for(let x of[...D.primaryItems,...D.comparisonItems])b.push(`- **${x.title}** via \`${x.spec.meta.key}\``);b.push(""),b.push("## Integrations"),b.push(""),b.push("| Name | Type | Connections | Status |"),b.push("|------|------|-------------|--------|");for(let x of J){let U=x.status==="ACTIVE"?"\uD83D\uDFE2":"⚫";b.push(`| ${x.name} | ${x.type} | ${x.connectionCount} | ${U} ${x.status} |`)}b.push(""),b.push("## Recent Sync Activity"),b.push(""),b.push("| Sync | Frequency | Last Run | Records | Status |"),b.push("|------|-----------|----------|---------|--------|");for(let x of w){let U=new Date(x.lastRunAt).toLocaleString(),$=x.status==="SUCCESS"?"✅":"❌";b.push(`| ${x.name} | ${x.frequency} | ${U} | ${x.recordsSynced} | ${$} ${x.status} |`)}if(Q.length>0){b.push(""),b.push("## ⚠️ Connections with Errors"),b.push("");for(let x of Q){let U=J.find(($)=>$.id===x.integrationId);b.push(`- **${x.name}** (${U?.name??"Unknown"}): ${x.error??"Unknown error"}`)}}return{mimeType:"text/markdown",body:b.join(`
|
|
2
|
+
`)}}},p={target:"markdown",render:async(j)=>{if(j.source.type!=="component"||j.source.componentKey!=="ConnectionList")throw Error("connectionListMarkdownRenderer: not ConnectionList");let J=G,K=M,w=["# Connections","","> Manage connections to external services",""];for(let D of K){let P=J.filter((q)=>q.integrationId===D.id);if(P.length===0)continue;w.push(`## ${D.name}`),w.push(""),w.push("| Connection | Status | Last Sync |"),w.push("|------------|--------|-----------|");for(let q of P){let Q=new Date(q.lastSyncAt).toLocaleString(),Z=q.status==="CONNECTED"?"\uD83D\uDFE2":q.status==="ERROR"?"\uD83D\uDD34":"⚫";w.push(`| ${q.name} | ${Z} ${q.status} | ${Q} |`)}w.push("")}return{mimeType:"text/markdown",body:w.join(`
|
|
3
|
+
`)}}},N={target:"markdown",render:async(j)=>{if(j.source.type!=="component"||j.source.componentKey!=="SyncConfigEditor")throw Error("syncConfigMarkdownRenderer: not SyncConfigEditor");let J=O,K=G,w=["# Sync Configurations","","> Configure automated data synchronization",""];for(let D of J){let P=K.find((Q)=>Q.id===D.connectionId),q=D.status==="SUCCESS"?"✅":"❌";w.push(`## ${D.name}`),w.push(""),w.push(`**Connection:** ${P?.name??"Unknown"}`),w.push(`**Frequency:** ${D.frequency}`),w.push(`**Status:** ${q} ${D.status}`),w.push(`**Last Run:** ${new Date(D.lastRunAt).toLocaleString()}`),w.push(`**Records Synced:** ${D.recordsSynced.toLocaleString()}`),w.push("")}return w.push("## Frequency Options"),w.push(""),w.push("- **REALTIME**: Sync on every change"),w.push("- **HOURLY**: Sync every hour"),w.push("- **DAILY**: Sync once per day"),w.push("- **WEEKLY**: Sync once per week"),w.push("- **MANUAL**: Sync only when triggered"),{mimeType:"text/markdown",body:w.join(`
|
|
4
|
+
`)}}};export{N as syncConfigMarkdownRenderer,_ as integrationDashboardMarkdownRenderer,p as connectionListMarkdownRenderer};
|