@contractspec/example.integration-hub 1.57.0 → 1.58.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (190) hide show
  1. package/dist/browser/connection/connection.enum.js +12 -0
  2. package/dist/browser/connection/connection.operation.js +101 -0
  3. package/dist/browser/connection/connection.presentation.js +99 -0
  4. package/dist/browser/connection/connection.schema.js +48 -0
  5. package/dist/browser/connection/index.js +104 -0
  6. package/dist/browser/docs/index.js +104 -0
  7. package/dist/browser/docs/integration-hub.docblock.js +104 -0
  8. package/dist/browser/events.js +211 -0
  9. package/dist/browser/example.js +42 -0
  10. package/dist/browser/handlers/index.js +246 -0
  11. package/dist/browser/handlers/integration.handlers.js +246 -0
  12. package/dist/browser/index.js +1595 -0
  13. package/dist/browser/integration/index.js +92 -0
  14. package/dist/browser/integration/integration.enum.js +12 -0
  15. package/dist/browser/integration/integration.operations.js +89 -0
  16. package/dist/browser/integration/integration.presentation.js +117 -0
  17. package/dist/browser/integration/integration.schema.js +42 -0
  18. package/dist/browser/integration-hub.capability.js +40 -0
  19. package/dist/browser/integration-hub.feature.js +114 -0
  20. package/dist/browser/seeders/index.js +60 -0
  21. package/dist/browser/sync/index.js +332 -0
  22. package/dist/browser/sync/sync.enum.js +26 -0
  23. package/dist/browser/sync/sync.operations.js +321 -0
  24. package/dist/browser/sync/sync.presentation.js +298 -0
  25. package/dist/browser/sync/sync.schema.js +154 -0
  26. package/dist/browser/sync-engine/index.js +186 -0
  27. package/dist/browser/tests/operations.test-spec.js +85 -0
  28. package/dist/browser/ui/IntegrationDashboard.js +369 -0
  29. package/dist/browser/ui/hooks/index.js +57 -0
  30. package/dist/browser/ui/hooks/useIntegrationData.js +54 -0
  31. package/dist/browser/ui/index.js +644 -0
  32. package/dist/browser/ui/renderers/index.js +273 -0
  33. package/dist/browser/ui/renderers/integration.markdown.js +273 -0
  34. package/dist/connection/connection.enum.d.ts +1 -6
  35. package/dist/connection/connection.enum.d.ts.map +1 -1
  36. package/dist/connection/connection.enum.js +11 -15
  37. package/dist/connection/connection.operation.d.ts +78 -84
  38. package/dist/connection/connection.operation.d.ts.map +1 -1
  39. package/dist/connection/connection.operation.js +99 -60
  40. package/dist/connection/connection.presentation.d.ts +2 -7
  41. package/dist/connection/connection.presentation.d.ts.map +1 -1
  42. package/dist/connection/connection.presentation.js +96 -56
  43. package/dist/connection/connection.schema.d.ts +54 -59
  44. package/dist/connection/connection.schema.d.ts.map +1 -1
  45. package/dist/connection/connection.schema.js +46 -73
  46. package/dist/connection/index.d.ts +7 -4
  47. package/dist/connection/index.d.ts.map +1 -0
  48. package/dist/connection/index.js +104 -4
  49. package/dist/docs/index.d.ts +2 -1
  50. package/dist/docs/index.d.ts.map +1 -0
  51. package/dist/docs/index.js +105 -1
  52. package/dist/docs/integration-hub.docblock.d.ts +2 -1
  53. package/dist/docs/integration-hub.docblock.d.ts.map +1 -0
  54. package/dist/docs/integration-hub.docblock.js +45 -56
  55. package/dist/events.d.ts +137 -143
  56. package/dist/events.d.ts.map +1 -1
  57. package/dist/events.js +210 -287
  58. package/dist/example.d.ts +2 -6
  59. package/dist/example.d.ts.map +1 -1
  60. package/dist/example.js +41 -55
  61. package/dist/handlers/index.d.ts +2 -2
  62. package/dist/handlers/index.d.ts.map +1 -0
  63. package/dist/handlers/index.js +247 -3
  64. package/dist/handlers/integration.handlers.d.ts +114 -113
  65. package/dist/handlers/integration.handlers.d.ts.map +1 -1
  66. package/dist/handlers/integration.handlers.js +232 -267
  67. package/dist/index.d.ts +12 -19
  68. package/dist/index.d.ts.map +1 -0
  69. package/dist/index.js +1596 -20
  70. package/dist/integration/index.d.ts +7 -4
  71. package/dist/integration/index.d.ts.map +1 -0
  72. package/dist/integration/index.js +92 -4
  73. package/dist/integration/integration.enum.d.ts +1 -6
  74. package/dist/integration/integration.enum.d.ts.map +1 -1
  75. package/dist/integration/integration.enum.js +11 -15
  76. package/dist/integration/integration.operations.d.ts +74 -80
  77. package/dist/integration/integration.operations.d.ts.map +1 -1
  78. package/dist/integration/integration.operations.js +87 -54
  79. package/dist/integration/integration.presentation.d.ts +3 -8
  80. package/dist/integration/integration.presentation.d.ts.map +1 -1
  81. package/dist/integration/integration.presentation.js +114 -73
  82. package/dist/integration/integration.schema.d.ts +54 -59
  83. package/dist/integration/integration.schema.d.ts.map +1 -1
  84. package/dist/integration/integration.schema.js +40 -73
  85. package/dist/integration-hub.capability.d.ts +3 -8
  86. package/dist/integration-hub.capability.d.ts.map +1 -1
  87. package/dist/integration-hub.capability.js +41 -38
  88. package/dist/integration-hub.feature.d.ts +1 -6
  89. package/dist/integration-hub.feature.d.ts.map +1 -1
  90. package/dist/integration-hub.feature.js +113 -242
  91. package/dist/node/connection/connection.enum.js +12 -0
  92. package/dist/node/connection/connection.operation.js +101 -0
  93. package/dist/node/connection/connection.presentation.js +99 -0
  94. package/dist/node/connection/connection.schema.js +48 -0
  95. package/dist/node/connection/index.js +104 -0
  96. package/dist/node/docs/index.js +104 -0
  97. package/dist/node/docs/integration-hub.docblock.js +104 -0
  98. package/dist/node/events.js +211 -0
  99. package/dist/node/example.js +42 -0
  100. package/dist/node/handlers/index.js +246 -0
  101. package/dist/node/handlers/integration.handlers.js +246 -0
  102. package/dist/node/index.js +1595 -0
  103. package/dist/node/integration/index.js +92 -0
  104. package/dist/node/integration/integration.enum.js +12 -0
  105. package/dist/node/integration/integration.operations.js +89 -0
  106. package/dist/node/integration/integration.presentation.js +117 -0
  107. package/dist/node/integration/integration.schema.js +42 -0
  108. package/dist/node/integration-hub.capability.js +40 -0
  109. package/dist/node/integration-hub.feature.js +114 -0
  110. package/dist/node/seeders/index.js +60 -0
  111. package/dist/node/sync/index.js +332 -0
  112. package/dist/node/sync/sync.enum.js +26 -0
  113. package/dist/node/sync/sync.operations.js +321 -0
  114. package/dist/node/sync/sync.presentation.js +298 -0
  115. package/dist/node/sync/sync.schema.js +154 -0
  116. package/dist/node/sync-engine/index.js +186 -0
  117. package/dist/node/tests/operations.test-spec.js +85 -0
  118. package/dist/node/ui/IntegrationDashboard.js +369 -0
  119. package/dist/node/ui/hooks/index.js +57 -0
  120. package/dist/node/ui/hooks/useIntegrationData.js +54 -0
  121. package/dist/node/ui/index.js +644 -0
  122. package/dist/node/ui/renderers/index.js +273 -0
  123. package/dist/node/ui/renderers/integration.markdown.js +273 -0
  124. package/dist/seeders/index.d.ts +4 -8
  125. package/dist/seeders/index.d.ts.map +1 -1
  126. package/dist/seeders/index.js +54 -52
  127. package/dist/sync/index.d.ts +7 -4
  128. package/dist/sync/index.d.ts.map +1 -0
  129. package/dist/sync/index.js +332 -4
  130. package/dist/sync/sync.enum.d.ts +3 -8
  131. package/dist/sync/sync.enum.d.ts.map +1 -1
  132. package/dist/sync/sync.enum.js +23 -31
  133. package/dist/sync/sync.operations.d.ts +413 -419
  134. package/dist/sync/sync.operations.d.ts.map +1 -1
  135. package/dist/sync/sync.operations.js +316 -197
  136. package/dist/sync/sync.presentation.d.ts +6 -11
  137. package/dist/sync/sync.presentation.d.ts.map +1 -1
  138. package/dist/sync/sync.presentation.js +291 -160
  139. package/dist/sync/sync.schema.d.ts +317 -322
  140. package/dist/sync/sync.schema.d.ts.map +1 -1
  141. package/dist/sync/sync.schema.js +146 -295
  142. package/dist/sync-engine/index.d.ts +88 -91
  143. package/dist/sync-engine/index.d.ts.map +1 -1
  144. package/dist/sync-engine/index.js +181 -142
  145. package/dist/tests/operations.test-spec.d.ts +3 -8
  146. package/dist/tests/operations.test-spec.d.ts.map +1 -1
  147. package/dist/tests/operations.test-spec.js +82 -90
  148. package/dist/ui/IntegrationDashboard.d.ts +1 -6
  149. package/dist/ui/IntegrationDashboard.d.ts.map +1 -1
  150. package/dist/ui/IntegrationDashboard.js +365 -261
  151. package/dist/ui/hooks/index.d.ts +2 -2
  152. package/dist/ui/hooks/index.d.ts.map +1 -0
  153. package/dist/ui/hooks/index.js +57 -4
  154. package/dist/ui/hooks/useIntegrationData.d.ts +16 -20
  155. package/dist/ui/hooks/useIntegrationData.d.ts.map +1 -1
  156. package/dist/ui/hooks/useIntegrationData.js +51 -55
  157. package/dist/ui/index.d.ts +7 -6
  158. package/dist/ui/index.d.ts.map +1 -0
  159. package/dist/ui/index.js +644 -5
  160. package/dist/ui/renderers/index.d.ts +2 -2
  161. package/dist/ui/renderers/index.d.ts.map +1 -0
  162. package/dist/ui/renderers/index.js +274 -3
  163. package/dist/ui/renderers/integration.markdown.d.ts +13 -14
  164. package/dist/ui/renderers/integration.markdown.d.ts.map +1 -1
  165. package/dist/ui/renderers/integration.markdown.js +268 -264
  166. package/package.json +360 -71
  167. package/dist/connection/connection.enum.js.map +0 -1
  168. package/dist/connection/connection.operation.js.map +0 -1
  169. package/dist/connection/connection.presentation.js.map +0 -1
  170. package/dist/connection/connection.schema.js.map +0 -1
  171. package/dist/docs/integration-hub.docblock.js.map +0 -1
  172. package/dist/events.js.map +0 -1
  173. package/dist/example.js.map +0 -1
  174. package/dist/handlers/integration.handlers.js.map +0 -1
  175. package/dist/integration/integration.enum.js.map +0 -1
  176. package/dist/integration/integration.operations.js.map +0 -1
  177. package/dist/integration/integration.presentation.js.map +0 -1
  178. package/dist/integration/integration.schema.js.map +0 -1
  179. package/dist/integration-hub.capability.js.map +0 -1
  180. package/dist/integration-hub.feature.js.map +0 -1
  181. package/dist/seeders/index.js.map +0 -1
  182. package/dist/sync/sync.enum.js.map +0 -1
  183. package/dist/sync/sync.operations.js.map +0 -1
  184. package/dist/sync/sync.presentation.js.map +0 -1
  185. package/dist/sync/sync.schema.js.map +0 -1
  186. package/dist/sync-engine/index.js.map +0 -1
  187. package/dist/tests/operations.test-spec.js.map +0 -1
  188. package/dist/ui/IntegrationDashboard.js.map +0 -1
  189. package/dist/ui/hooks/useIntegrationData.js.map +0 -1
  190. package/dist/ui/renderers/integration.markdown.js.map +0 -1
package/dist/ui/index.js CHANGED
@@ -1,6 +1,645 @@
1
- import { connectionListMarkdownRenderer, integrationDashboardMarkdownRenderer, syncConfigMarkdownRenderer } from "./renderers/integration.markdown.js";
2
- import { useIntegrationData } from "./hooks/useIntegrationData.js";
3
- import { IntegrationDashboard } from "./IntegrationDashboard.js";
4
- import "./hooks/index.js";
1
+ // @bun
2
+ // src/ui/renderers/integration.markdown.ts
3
+ var mockIntegrations = [
4
+ {
5
+ id: "int-1",
6
+ name: "Salesforce",
7
+ type: "CRM",
8
+ status: "ACTIVE",
9
+ connectionCount: 3
10
+ },
11
+ {
12
+ id: "int-2",
13
+ name: "HubSpot",
14
+ type: "MARKETING",
15
+ status: "ACTIVE",
16
+ connectionCount: 2
17
+ },
18
+ {
19
+ id: "int-3",
20
+ name: "Stripe",
21
+ type: "PAYMENT",
22
+ status: "ACTIVE",
23
+ connectionCount: 1
24
+ },
25
+ {
26
+ id: "int-4",
27
+ name: "Slack",
28
+ type: "COMMUNICATION",
29
+ status: "INACTIVE",
30
+ connectionCount: 0
31
+ },
32
+ {
33
+ id: "int-5",
34
+ name: "Google Sheets",
35
+ type: "DATA",
36
+ status: "ACTIVE",
37
+ connectionCount: 5
38
+ },
39
+ {
40
+ id: "int-6",
41
+ name: "PostHog",
42
+ type: "ANALYTICS",
43
+ status: "ACTIVE",
44
+ connectionCount: 1
45
+ }
46
+ ];
47
+ var mockConnections = [
48
+ {
49
+ id: "conn-1",
50
+ integrationId: "int-1",
51
+ name: "Production Salesforce",
52
+ status: "CONNECTED",
53
+ lastSyncAt: "2024-01-16T10:00:00Z"
54
+ },
55
+ {
56
+ id: "conn-2",
57
+ integrationId: "int-1",
58
+ name: "Sandbox Salesforce",
59
+ status: "CONNECTED",
60
+ lastSyncAt: "2024-01-15T14:00:00Z"
61
+ },
62
+ {
63
+ id: "conn-3",
64
+ integrationId: "int-2",
65
+ name: "Marketing HubSpot",
66
+ status: "CONNECTED",
67
+ lastSyncAt: "2024-01-16T08:00:00Z"
68
+ },
69
+ {
70
+ id: "conn-4",
71
+ integrationId: "int-3",
72
+ name: "Stripe Live",
73
+ status: "CONNECTED",
74
+ lastSyncAt: "2024-01-16T12:00:00Z"
75
+ },
76
+ {
77
+ id: "conn-5",
78
+ integrationId: "int-5",
79
+ name: "Analytics Sheet",
80
+ status: "ERROR",
81
+ lastSyncAt: "2024-01-14T09:00:00Z",
82
+ error: "Authentication expired"
83
+ },
84
+ {
85
+ id: "conn-6",
86
+ integrationId: "int-6",
87
+ name: "PostHog Workspace",
88
+ status: "CONNECTED",
89
+ lastSyncAt: "2024-01-16T11:45:00Z"
90
+ }
91
+ ];
92
+ var mockSyncConfigs = [
93
+ {
94
+ id: "sync-1",
95
+ connectionId: "conn-1",
96
+ name: "Contacts Sync",
97
+ frequency: "HOURLY",
98
+ lastRunAt: "2024-01-16T10:00:00Z",
99
+ status: "SUCCESS",
100
+ recordsSynced: 1250
101
+ },
102
+ {
103
+ id: "sync-2",
104
+ connectionId: "conn-1",
105
+ name: "Opportunities Sync",
106
+ frequency: "DAILY",
107
+ lastRunAt: "2024-01-16T00:00:00Z",
108
+ status: "SUCCESS",
109
+ recordsSynced: 340
110
+ },
111
+ {
112
+ id: "sync-3",
113
+ connectionId: "conn-3",
114
+ name: "Orders Sync",
115
+ frequency: "REALTIME",
116
+ lastRunAt: "2024-01-16T12:30:00Z",
117
+ status: "SUCCESS",
118
+ recordsSynced: 89
119
+ },
120
+ {
121
+ id: "sync-4",
122
+ connectionId: "conn-5",
123
+ name: "Metrics Export",
124
+ frequency: "DAILY",
125
+ lastRunAt: "2024-01-14T09:00:00Z",
126
+ status: "FAILED",
127
+ recordsSynced: 0
128
+ }
129
+ ];
130
+ var integrationDashboardMarkdownRenderer = {
131
+ target: "markdown",
132
+ render: async (desc) => {
133
+ if (desc.source.type !== "component" || desc.source.componentKey !== "IntegrationDashboard") {
134
+ throw new Error("integrationDashboardMarkdownRenderer: not IntegrationDashboard");
135
+ }
136
+ const integrations = mockIntegrations;
137
+ const connections = mockConnections;
138
+ const syncs = mockSyncConfigs;
139
+ const activeIntegrations = integrations.filter((i) => i.status === "ACTIVE");
140
+ const connectedConnections = connections.filter((c) => c.status === "CONNECTED");
141
+ const errorConnections = connections.filter((c) => c.status === "ERROR");
142
+ const successfulSyncs = syncs.filter((s) => s.status === "SUCCESS");
143
+ const totalRecordsSynced = successfulSyncs.reduce((sum, s) => sum + s.recordsSynced, 0);
144
+ const lines = [
145
+ "# Integration Hub",
146
+ "",
147
+ "> Connect and sync data with external services",
148
+ "",
149
+ "## Overview",
150
+ "",
151
+ "| Metric | Value |",
152
+ "|--------|-------|",
153
+ `| Active Integrations | ${activeIntegrations.length} |`,
154
+ `| Connected Services | ${connectedConnections.length} |`,
155
+ `| Error Connections | ${errorConnections.length} |`,
156
+ `| Sync Configs | ${syncs.length} |`,
157
+ `| Records Synced (24h) | ${totalRecordsSynced.toLocaleString()} |`,
158
+ "",
159
+ "## Integrations",
160
+ "",
161
+ "| Name | Type | Connections | Status |",
162
+ "|------|------|-------------|--------|"
163
+ ];
164
+ for (const integration of integrations) {
165
+ const statusIcon = integration.status === "ACTIVE" ? "\uD83D\uDFE2" : "\u26AB";
166
+ lines.push(`| ${integration.name} | ${integration.type} | ${integration.connectionCount} | ${statusIcon} ${integration.status} |`);
167
+ }
168
+ lines.push("");
169
+ lines.push("## Recent Sync Activity");
170
+ lines.push("");
171
+ lines.push("| Sync | Frequency | Last Run | Records | Status |");
172
+ lines.push("|------|-----------|----------|---------|--------|");
173
+ for (const sync of syncs) {
174
+ const lastRun = new Date(sync.lastRunAt).toLocaleString();
175
+ const statusIcon = sync.status === "SUCCESS" ? "\u2705" : "\u274C";
176
+ lines.push(`| ${sync.name} | ${sync.frequency} | ${lastRun} | ${sync.recordsSynced} | ${statusIcon} ${sync.status} |`);
177
+ }
178
+ if (errorConnections.length > 0) {
179
+ lines.push("");
180
+ lines.push("## \u26A0\uFE0F Connections with Errors");
181
+ lines.push("");
182
+ for (const conn of errorConnections) {
183
+ const integration = integrations.find((i) => i.id === conn.integrationId);
184
+ lines.push(`- **${conn.name}** (${integration?.name ?? "Unknown"}): ${conn.error ?? "Unknown error"}`);
185
+ }
186
+ }
187
+ return {
188
+ mimeType: "text/markdown",
189
+ body: lines.join(`
190
+ `)
191
+ };
192
+ }
193
+ };
194
+ var connectionListMarkdownRenderer = {
195
+ target: "markdown",
196
+ render: async (desc) => {
197
+ if (desc.source.type !== "component" || desc.source.componentKey !== "ConnectionList") {
198
+ throw new Error("connectionListMarkdownRenderer: not ConnectionList");
199
+ }
200
+ const connections = mockConnections;
201
+ const integrations = mockIntegrations;
202
+ const lines = [
203
+ "# Connections",
204
+ "",
205
+ "> Manage connections to external services",
206
+ ""
207
+ ];
208
+ for (const integration of integrations) {
209
+ const intConnections = connections.filter((c) => c.integrationId === integration.id);
210
+ if (intConnections.length === 0)
211
+ continue;
212
+ lines.push(`## ${integration.name}`);
213
+ lines.push("");
214
+ lines.push("| Connection | Status | Last Sync |");
215
+ lines.push("|------------|--------|-----------|");
216
+ for (const conn of intConnections) {
217
+ const lastSync = new Date(conn.lastSyncAt).toLocaleString();
218
+ const statusIcon = conn.status === "CONNECTED" ? "\uD83D\uDFE2" : conn.status === "ERROR" ? "\uD83D\uDD34" : "\u26AB";
219
+ lines.push(`| ${conn.name} | ${statusIcon} ${conn.status} | ${lastSync} |`);
220
+ }
221
+ lines.push("");
222
+ }
223
+ return {
224
+ mimeType: "text/markdown",
225
+ body: lines.join(`
226
+ `)
227
+ };
228
+ }
229
+ };
230
+ var syncConfigMarkdownRenderer = {
231
+ target: "markdown",
232
+ render: async (desc) => {
233
+ if (desc.source.type !== "component" || desc.source.componentKey !== "SyncConfigEditor") {
234
+ throw new Error("syncConfigMarkdownRenderer: not SyncConfigEditor");
235
+ }
236
+ const syncs = mockSyncConfigs;
237
+ const connections = mockConnections;
238
+ const lines = [
239
+ "# Sync Configurations",
240
+ "",
241
+ "> Configure automated data synchronization",
242
+ ""
243
+ ];
244
+ for (const sync of syncs) {
245
+ const connection = connections.find((c) => c.id === sync.connectionId);
246
+ const statusIcon = sync.status === "SUCCESS" ? "\u2705" : "\u274C";
247
+ lines.push(`## ${sync.name}`);
248
+ lines.push("");
249
+ lines.push(`**Connection:** ${connection?.name ?? "Unknown"}`);
250
+ lines.push(`**Frequency:** ${sync.frequency}`);
251
+ lines.push(`**Status:** ${statusIcon} ${sync.status}`);
252
+ lines.push(`**Last Run:** ${new Date(sync.lastRunAt).toLocaleString()}`);
253
+ lines.push(`**Records Synced:** ${sync.recordsSynced.toLocaleString()}`);
254
+ lines.push("");
255
+ }
256
+ lines.push("## Frequency Options");
257
+ lines.push("");
258
+ lines.push("- **REALTIME**: Sync on every change");
259
+ lines.push("- **HOURLY**: Sync every hour");
260
+ lines.push("- **DAILY**: Sync once per day");
261
+ lines.push("- **WEEKLY**: Sync once per week");
262
+ lines.push("- **MANUAL**: Sync only when triggered");
263
+ return {
264
+ mimeType: "text/markdown",
265
+ body: lines.join(`
266
+ `)
267
+ };
268
+ }
269
+ };
270
+ // src/ui/hooks/useIntegrationData.ts
271
+ import { useCallback, useEffect, useState } from "react";
272
+ import { useTemplateRuntime } from "@contractspec/lib.example-shared-ui";
273
+ "use client";
274
+ function useIntegrationData(projectId = "local-project") {
275
+ const { handlers } = useTemplateRuntime();
276
+ const integration = handlers.integration;
277
+ const [integrations, setIntegrations] = useState([]);
278
+ const [connections, setConnections] = useState([]);
279
+ const [syncConfigs, setSyncConfigs] = useState([]);
280
+ const [loading, setLoading] = useState(true);
281
+ const [error, setError] = useState(null);
282
+ const fetchData = useCallback(async () => {
283
+ try {
284
+ setLoading(true);
285
+ setError(null);
286
+ const [integResult, connResult, syncResult] = await Promise.all([
287
+ integration.listIntegrations({ projectId, limit: 100 }),
288
+ integration.listConnections({ limit: 100 }),
289
+ integration.listSyncConfigs({ limit: 100 })
290
+ ]);
291
+ setIntegrations(integResult.integrations);
292
+ setConnections(connResult.connections);
293
+ setSyncConfigs(syncResult.configs);
294
+ } catch (err) {
295
+ setError(err instanceof Error ? err : new Error("Failed to load integrations"));
296
+ } finally {
297
+ setLoading(false);
298
+ }
299
+ }, [integration, projectId]);
300
+ useEffect(() => {
301
+ fetchData();
302
+ }, [fetchData]);
303
+ const stats = {
304
+ totalIntegrations: integrations.length,
305
+ activeIntegrations: integrations.filter((i) => i.status === "ACTIVE").length,
306
+ totalConnections: connections.length,
307
+ connectedCount: connections.filter((c) => c.status === "CONNECTED").length,
308
+ totalSyncs: syncConfigs.length,
309
+ activeSyncs: syncConfigs.filter((s) => s.status === "ACTIVE").length
310
+ };
311
+ return {
312
+ integrations,
313
+ connections,
314
+ syncConfigs,
315
+ loading,
316
+ error,
317
+ stats,
318
+ refetch: fetchData
319
+ };
320
+ }
5
321
 
6
- export { IntegrationDashboard, connectionListMarkdownRenderer, integrationDashboardMarkdownRenderer, syncConfigMarkdownRenderer, useIntegrationData };
322
+ // src/ui/IntegrationDashboard.tsx
323
+ import { useState as useState2 } from "react";
324
+ import {
325
+ Button,
326
+ ErrorState,
327
+ LoaderBlock,
328
+ StatCard,
329
+ StatCardGroup
330
+ } from "@contractspec/lib.design-system";
331
+ import { jsxDEV } from "react/jsx-dev-runtime";
332
+ "use client";
333
+ var STATUS_COLORS = {
334
+ ACTIVE: "bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400",
335
+ INACTIVE: "bg-gray-100 text-gray-700 dark:bg-gray-900/30 dark:text-gray-400",
336
+ CONNECTED: "bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400",
337
+ DISCONNECTED: "bg-gray-100 text-gray-700 dark:bg-gray-900/30 dark:text-gray-400",
338
+ PENDING: "bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400",
339
+ ERROR: "bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400",
340
+ PAUSED: "bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400"
341
+ };
342
+ var TYPE_ICONS = {
343
+ CRM: "\uD83D\uDCCA",
344
+ MARKETING: "\uD83D\uDCE3",
345
+ PAYMENT: "\uD83D\uDCB3",
346
+ COMMUNICATION: "\uD83D\uDCAC",
347
+ DATA: "\uD83D\uDDC4\uFE0F",
348
+ CUSTOM: "\u2699\uFE0F"
349
+ };
350
+ function IntegrationDashboard() {
351
+ const [activeTab, setActiveTab] = useState2("integrations");
352
+ const {
353
+ integrations,
354
+ connections,
355
+ syncConfigs,
356
+ loading,
357
+ error,
358
+ stats,
359
+ refetch
360
+ } = useIntegrationData();
361
+ const tabs = [
362
+ { id: "integrations", label: "Integrations", icon: "\uD83D\uDD0C" },
363
+ { id: "connections", label: "Connections", icon: "\uD83D\uDD17" },
364
+ { id: "syncs", label: "Sync Configs", icon: "\uD83D\uDD04" }
365
+ ];
366
+ if (loading) {
367
+ return /* @__PURE__ */ jsxDEV(LoaderBlock, {
368
+ label: "Loading Integrations..."
369
+ }, undefined, false, undefined, this);
370
+ }
371
+ if (error) {
372
+ return /* @__PURE__ */ jsxDEV(ErrorState, {
373
+ title: "Failed to load Integrations",
374
+ description: error.message,
375
+ onRetry: refetch,
376
+ retryLabel: "Retry"
377
+ }, undefined, false, undefined, this);
378
+ }
379
+ return /* @__PURE__ */ jsxDEV("div", {
380
+ className: "space-y-6",
381
+ children: [
382
+ /* @__PURE__ */ jsxDEV("div", {
383
+ className: "flex items-center justify-between",
384
+ children: [
385
+ /* @__PURE__ */ jsxDEV("h2", {
386
+ className: "text-2xl font-bold",
387
+ children: "Integration Hub"
388
+ }, undefined, false, undefined, this),
389
+ /* @__PURE__ */ jsxDEV(Button, {
390
+ onClick: () => alert("Add integration modal"),
391
+ children: [
392
+ /* @__PURE__ */ jsxDEV("span", {
393
+ className: "mr-2",
394
+ children: "+"
395
+ }, undefined, false, undefined, this),
396
+ " Add Integration"
397
+ ]
398
+ }, undefined, true, undefined, this)
399
+ ]
400
+ }, undefined, true, undefined, this),
401
+ /* @__PURE__ */ jsxDEV(StatCardGroup, {
402
+ children: [
403
+ /* @__PURE__ */ jsxDEV(StatCard, {
404
+ label: "Integrations",
405
+ value: stats.totalIntegrations,
406
+ hint: `${stats.activeIntegrations} active`
407
+ }, undefined, false, undefined, this),
408
+ /* @__PURE__ */ jsxDEV(StatCard, {
409
+ label: "Connections",
410
+ value: stats.totalConnections,
411
+ hint: `${stats.connectedCount} connected`
412
+ }, undefined, false, undefined, this),
413
+ /* @__PURE__ */ jsxDEV(StatCard, {
414
+ label: "Syncs",
415
+ value: stats.totalSyncs,
416
+ hint: `${stats.activeSyncs} active`
417
+ }, undefined, false, undefined, this)
418
+ ]
419
+ }, undefined, true, undefined, this),
420
+ /* @__PURE__ */ jsxDEV("nav", {
421
+ className: "bg-muted flex gap-1 rounded-lg p-1",
422
+ role: "tablist",
423
+ children: tabs.map((tab) => /* @__PURE__ */ jsxDEV(Button, {
424
+ type: "button",
425
+ role: "tab",
426
+ "aria-selected": activeTab === tab.id,
427
+ onClick: () => setActiveTab(tab.id),
428
+ className: `flex flex-1 items-center justify-center gap-2 rounded-md px-4 py-2 text-sm font-medium transition-colors ${activeTab === tab.id ? "bg-background text-foreground shadow-sm" : "text-muted-foreground hover:text-foreground"}`,
429
+ children: [
430
+ /* @__PURE__ */ jsxDEV("span", {
431
+ children: tab.icon
432
+ }, undefined, false, undefined, this),
433
+ tab.label
434
+ ]
435
+ }, tab.id, true, undefined, this))
436
+ }, undefined, false, undefined, this),
437
+ /* @__PURE__ */ jsxDEV("div", {
438
+ className: "min-h-[400px]",
439
+ role: "tabpanel",
440
+ children: [
441
+ activeTab === "integrations" && /* @__PURE__ */ jsxDEV("div", {
442
+ className: "grid gap-4 sm:grid-cols-2 lg:grid-cols-3",
443
+ children: [
444
+ integrations.map((integration) => /* @__PURE__ */ jsxDEV("div", {
445
+ className: "border-border bg-card hover:bg-muted/50 cursor-pointer rounded-lg border p-4 transition-colors",
446
+ children: [
447
+ /* @__PURE__ */ jsxDEV("div", {
448
+ className: "mb-3 flex items-center gap-3",
449
+ children: [
450
+ /* @__PURE__ */ jsxDEV("span", {
451
+ className: "text-2xl",
452
+ children: TYPE_ICONS[integration.type] ?? "\u2699\uFE0F"
453
+ }, undefined, false, undefined, this),
454
+ /* @__PURE__ */ jsxDEV("div", {
455
+ children: [
456
+ /* @__PURE__ */ jsxDEV("h3", {
457
+ className: "font-medium",
458
+ children: integration.name
459
+ }, undefined, false, undefined, this),
460
+ /* @__PURE__ */ jsxDEV("p", {
461
+ className: "text-muted-foreground text-sm",
462
+ children: integration.type
463
+ }, undefined, false, undefined, this)
464
+ ]
465
+ }, undefined, true, undefined, this)
466
+ ]
467
+ }, undefined, true, undefined, this),
468
+ /* @__PURE__ */ jsxDEV("div", {
469
+ className: "flex items-center justify-between",
470
+ children: [
471
+ /* @__PURE__ */ jsxDEV("span", {
472
+ className: `inline-flex rounded-full px-2 py-0.5 text-xs font-medium ${STATUS_COLORS[integration.status] ?? ""}`,
473
+ children: integration.status
474
+ }, undefined, false, undefined, this),
475
+ /* @__PURE__ */ jsxDEV("span", {
476
+ className: "text-muted-foreground text-xs",
477
+ children: integration.createdAt.toLocaleDateString()
478
+ }, undefined, false, undefined, this)
479
+ ]
480
+ }, undefined, true, undefined, this)
481
+ ]
482
+ }, integration.id, true, undefined, this)),
483
+ integrations.length === 0 && /* @__PURE__ */ jsxDEV("div", {
484
+ className: "text-muted-foreground col-span-full flex h-64 items-center justify-center",
485
+ children: "No integrations configured"
486
+ }, undefined, false, undefined, this)
487
+ ]
488
+ }, undefined, true, undefined, this),
489
+ activeTab === "connections" && /* @__PURE__ */ jsxDEV("div", {
490
+ className: "border-border rounded-lg border",
491
+ children: /* @__PURE__ */ jsxDEV("table", {
492
+ className: "w-full",
493
+ children: [
494
+ /* @__PURE__ */ jsxDEV("thead", {
495
+ className: "border-border bg-muted/30 border-b",
496
+ children: /* @__PURE__ */ jsxDEV("tr", {
497
+ children: [
498
+ /* @__PURE__ */ jsxDEV("th", {
499
+ className: "px-4 py-3 text-left text-sm font-medium",
500
+ children: "Connection"
501
+ }, undefined, false, undefined, this),
502
+ /* @__PURE__ */ jsxDEV("th", {
503
+ className: "px-4 py-3 text-left text-sm font-medium",
504
+ children: "Status"
505
+ }, undefined, false, undefined, this),
506
+ /* @__PURE__ */ jsxDEV("th", {
507
+ className: "px-4 py-3 text-left text-sm font-medium",
508
+ children: "Last Sync"
509
+ }, undefined, false, undefined, this)
510
+ ]
511
+ }, undefined, true, undefined, this)
512
+ }, undefined, false, undefined, this),
513
+ /* @__PURE__ */ jsxDEV("tbody", {
514
+ className: "divide-border divide-y",
515
+ children: [
516
+ connections.map((conn) => /* @__PURE__ */ jsxDEV("tr", {
517
+ className: "hover:bg-muted/50",
518
+ children: [
519
+ /* @__PURE__ */ jsxDEV("td", {
520
+ className: "px-4 py-3",
521
+ children: /* @__PURE__ */ jsxDEV("div", {
522
+ className: "font-medium",
523
+ children: conn.name
524
+ }, undefined, false, undefined, this)
525
+ }, undefined, false, undefined, this),
526
+ /* @__PURE__ */ jsxDEV("td", {
527
+ className: "px-4 py-3",
528
+ children: /* @__PURE__ */ jsxDEV("span", {
529
+ className: `inline-flex rounded-full px-2 py-0.5 text-xs font-medium ${STATUS_COLORS[conn.status] ?? ""}`,
530
+ children: conn.status
531
+ }, undefined, false, undefined, this)
532
+ }, undefined, false, undefined, this),
533
+ /* @__PURE__ */ jsxDEV("td", {
534
+ className: "text-muted-foreground px-4 py-3 text-sm",
535
+ children: conn.lastSyncAt?.toLocaleString() ?? "Never"
536
+ }, undefined, false, undefined, this)
537
+ ]
538
+ }, conn.id, true, undefined, this)),
539
+ connections.length === 0 && /* @__PURE__ */ jsxDEV("tr", {
540
+ children: /* @__PURE__ */ jsxDEV("td", {
541
+ colSpan: 3,
542
+ className: "text-muted-foreground px-4 py-8 text-center",
543
+ children: "No connections found"
544
+ }, undefined, false, undefined, this)
545
+ }, undefined, false, undefined, this)
546
+ ]
547
+ }, undefined, true, undefined, this)
548
+ ]
549
+ }, undefined, true, undefined, this)
550
+ }, undefined, false, undefined, this),
551
+ activeTab === "syncs" && /* @__PURE__ */ jsxDEV("div", {
552
+ className: "border-border rounded-lg border",
553
+ children: /* @__PURE__ */ jsxDEV("table", {
554
+ className: "w-full",
555
+ children: [
556
+ /* @__PURE__ */ jsxDEV("thead", {
557
+ className: "border-border bg-muted/30 border-b",
558
+ children: /* @__PURE__ */ jsxDEV("tr", {
559
+ children: [
560
+ /* @__PURE__ */ jsxDEV("th", {
561
+ className: "px-4 py-3 text-left text-sm font-medium",
562
+ children: "Sync Config"
563
+ }, undefined, false, undefined, this),
564
+ /* @__PURE__ */ jsxDEV("th", {
565
+ className: "px-4 py-3 text-left text-sm font-medium",
566
+ children: "Frequency"
567
+ }, undefined, false, undefined, this),
568
+ /* @__PURE__ */ jsxDEV("th", {
569
+ className: "px-4 py-3 text-left text-sm font-medium",
570
+ children: "Status"
571
+ }, undefined, false, undefined, this),
572
+ /* @__PURE__ */ jsxDEV("th", {
573
+ className: "px-4 py-3 text-left text-sm font-medium",
574
+ children: "Records"
575
+ }, undefined, false, undefined, this)
576
+ ]
577
+ }, undefined, true, undefined, this)
578
+ }, undefined, false, undefined, this),
579
+ /* @__PURE__ */ jsxDEV("tbody", {
580
+ className: "divide-border divide-y",
581
+ children: [
582
+ syncConfigs.map((sync) => /* @__PURE__ */ jsxDEV("tr", {
583
+ className: "hover:bg-muted/50",
584
+ children: [
585
+ /* @__PURE__ */ jsxDEV("td", {
586
+ className: "px-4 py-3",
587
+ children: [
588
+ /* @__PURE__ */ jsxDEV("div", {
589
+ className: "font-medium",
590
+ children: sync.name
591
+ }, undefined, false, undefined, this),
592
+ /* @__PURE__ */ jsxDEV("div", {
593
+ className: "text-muted-foreground text-sm",
594
+ children: [
595
+ sync.sourceEntity,
596
+ " \u2192 ",
597
+ sync.targetEntity
598
+ ]
599
+ }, undefined, true, undefined, this)
600
+ ]
601
+ }, undefined, true, undefined, this),
602
+ /* @__PURE__ */ jsxDEV("td", {
603
+ className: "px-4 py-3 text-sm",
604
+ children: sync.frequency
605
+ }, undefined, false, undefined, this),
606
+ /* @__PURE__ */ jsxDEV("td", {
607
+ className: "px-4 py-3",
608
+ children: /* @__PURE__ */ jsxDEV("span", {
609
+ className: `inline-flex rounded-full px-2 py-0.5 text-xs font-medium ${STATUS_COLORS[sync.status] ?? ""}`,
610
+ children: sync.status
611
+ }, undefined, false, undefined, this)
612
+ }, undefined, false, undefined, this),
613
+ /* @__PURE__ */ jsxDEV("td", {
614
+ className: "text-muted-foreground px-4 py-3 text-sm",
615
+ children: sync.recordsSynced.toLocaleString()
616
+ }, undefined, false, undefined, this)
617
+ ]
618
+ }, sync.id, true, undefined, this)),
619
+ syncConfigs.length === 0 && /* @__PURE__ */ jsxDEV("tr", {
620
+ children: /* @__PURE__ */ jsxDEV("td", {
621
+ colSpan: 4,
622
+ className: "text-muted-foreground px-4 py-8 text-center",
623
+ children: "No sync configurations found"
624
+ }, undefined, false, undefined, this)
625
+ }, undefined, false, undefined, this)
626
+ ]
627
+ }, undefined, true, undefined, this)
628
+ ]
629
+ }, undefined, true, undefined, this)
630
+ }, undefined, false, undefined, this)
631
+ ]
632
+ }, undefined, true, undefined, this)
633
+ ]
634
+ }, undefined, true, undefined, this);
635
+ }
636
+
637
+ // src/ui/hooks/index.ts
638
+ "use client";
639
+ export {
640
+ useIntegrationData,
641
+ syncConfigMarkdownRenderer,
642
+ integrationDashboardMarkdownRenderer,
643
+ connectionListMarkdownRenderer,
644
+ IntegrationDashboard
645
+ };
@@ -1,2 +1,2 @@
1
- import { connectionListMarkdownRenderer, integrationDashboardMarkdownRenderer, syncConfigMarkdownRenderer } from "./integration.markdown.js";
2
- export { connectionListMarkdownRenderer, integrationDashboardMarkdownRenderer, syncConfigMarkdownRenderer };
1
+ export { integrationDashboardMarkdownRenderer, connectionListMarkdownRenderer, syncConfigMarkdownRenderer, } from './integration.markdown';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ui/renderers/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,oCAAoC,EACpC,8BAA8B,EAC9B,0BAA0B,GAC3B,MAAM,wBAAwB,CAAC"}