@kb-labs/studio-app 0.7.0 → 2.8.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 (175) hide show
  1. package/dist/index.html +1 -0
  2. package/dist/main.1d68e922.js +522 -0
  3. package/dist/main.1d68e922.js.map +1 -0
  4. package/dist/main.80b70197.css +2 -0
  5. package/dist/main.80b70197.css.map +1 -0
  6. package/dist/mf-manifest.json +241 -0
  7. package/dist/mf-stats.json +271 -0
  8. package/package.json +56 -39
  9. package/server.js +68 -0
  10. package/.env.example +0 -10
  11. package/UI-KIT-COMPONENTS.md +0 -783
  12. package/UI-KIT-PLAN.md +0 -326
  13. package/eslint-rules/no-direct-antd-import.js +0 -151
  14. package/eslint.config.ts +0 -27
  15. package/index.html +0 -17
  16. package/postcss.config.js +0 -7
  17. package/public/favicon.ico +0 -0
  18. package/rspack.config.mjs +0 -118
  19. package/src/App.tsx +0 -46
  20. package/src/components/devtools/devtools-log-feed.module.css +0 -165
  21. package/src/components/devtools/devtools-log-feed.tsx +0 -300
  22. package/src/components/devtools/devtools-panel.module.css +0 -121
  23. package/src/components/devtools/devtools-panel.tsx +0 -115
  24. package/src/components/empty-state.tsx +0 -28
  25. package/src/components/error-boundary.tsx +0 -210
  26. package/src/components/health-banner.module.css +0 -103
  27. package/src/components/health-banner.tsx +0 -134
  28. package/src/components/health-indicator.tsx +0 -12
  29. package/src/components/page-header.tsx +0 -49
  30. package/src/components/page-transition.tsx +0 -24
  31. package/src/components/role-switcher.tsx +0 -148
  32. package/src/components/run-badge.tsx +0 -13
  33. package/src/components/ui/icons.tsx +0 -509
  34. package/src/components/ui/index.ts +0 -25
  35. package/src/components/ui/kb-config-provider.tsx +0 -130
  36. package/src/components/ui/kb-header.module.css +0 -51
  37. package/src/components/ui/kb-header.tsx +0 -112
  38. package/src/components/ui/kb-notification-bell.module.css +0 -103
  39. package/src/components/ui/kb-notification-bell.tsx +0 -199
  40. package/src/components/ui/kb-page-layout.tsx +0 -66
  41. package/src/components/ui/kb-quick-search.module.css +0 -86
  42. package/src/components/ui/kb-quick-search.tsx +0 -196
  43. package/src/components/ui/kb-sidebar.module.css +0 -47
  44. package/src/components/ui/kb-sidebar.tsx +0 -196
  45. package/src/components/ui/kb-stat-card.module.css +0 -21
  46. package/src/components/ui/kb-stat-card.tsx +0 -22
  47. package/src/components/ui/kb-stat-grid.tsx +0 -22
  48. package/src/components/ui/kb-status-bar.module.css +0 -49
  49. package/src/components/ui/kb-status-bar.tsx +0 -145
  50. package/src/components/ui/kb-system-health-indicator.tsx +0 -229
  51. package/src/components/ui/kb-theme-toggle.tsx +0 -42
  52. package/src/components/ui/theme-adapter.ts +0 -812
  53. package/src/components/ui/theme-transition-overlay.tsx +0 -70
  54. package/src/components/ui/utils.ts +0 -6
  55. package/src/components/widget-error-boundary.tsx +0 -172
  56. package/src/config/env.ts +0 -5
  57. package/src/config/feature-flags.ts +0 -482
  58. package/src/config/studio.config.schema.ts +0 -88
  59. package/src/config/studio.config.ts +0 -84
  60. package/src/env.d.ts +0 -23
  61. package/src/hooks/use-command-palette.ts +0 -6
  62. package/src/hooks/use-devtools-store.ts +0 -25
  63. package/src/hooks/use-feature-flags.ts +0 -101
  64. package/src/index.css +0 -10
  65. package/src/layouts/dashboard-grid.tsx +0 -122
  66. package/src/layouts/index.ts +0 -12
  67. package/src/layouts/two-pane.tsx +0 -134
  68. package/src/main.tsx +0 -15
  69. package/src/modules/analytics/components/analytics-daily-stats-chart.tsx +0 -257
  70. package/src/modules/analytics/components/analytics-date-range-picker.tsx +0 -121
  71. package/src/modules/analytics/pages/analytics-cache-page.tsx +0 -285
  72. package/src/modules/analytics/pages/analytics-embeddings-page.tsx +0 -274
  73. package/src/modules/analytics/pages/analytics-events-page.tsx +0 -425
  74. package/src/modules/analytics/pages/analytics-llm-page.tsx +0 -434
  75. package/src/modules/analytics/pages/analytics-overview-page.tsx +0 -336
  76. package/src/modules/analytics/pages/analytics-page.tsx +0 -20
  77. package/src/modules/analytics/pages/analytics-storage-page.tsx +0 -344
  78. package/src/modules/analytics/pages/analytics-vectorstore-page.tsx +0 -279
  79. package/src/modules/analytics/routes/index.tsx +0 -133
  80. package/src/modules/analytics/utils/formatters.test.ts +0 -148
  81. package/src/modules/analytics/utils/formatters.ts +0 -100
  82. package/src/modules/auth/pages/login-page.module.css +0 -113
  83. package/src/modules/auth/pages/login-page.tsx +0 -80
  84. package/src/modules/auth/routes/index.tsx +0 -24
  85. package/src/modules/dashboard/components/ActivityTimelineWidget.tsx +0 -199
  86. package/src/modules/dashboard/components/AiInsightsWidget.tsx +0 -358
  87. package/src/modules/dashboard/components/AnimatedMetricCard.css +0 -88
  88. package/src/modules/dashboard/components/AnimatedMetricCard.tsx +0 -125
  89. package/src/modules/dashboard/components/HeroMetricCard.css +0 -114
  90. package/src/modules/dashboard/components/HeroMetricCard.tsx +0 -152
  91. package/src/modules/dashboard/components/HeroMetricsWidget.tsx +0 -146
  92. package/src/modules/dashboard/components/SystemResourcesWidget.tsx +0 -197
  93. package/src/modules/dashboard/components/dashboard-empty.tsx +0 -22
  94. package/src/modules/dashboard/components/dashboard-kpis-widget.tsx +0 -59
  95. package/src/modules/dashboard/components/dashboard-kpis.tsx +0 -13
  96. package/src/modules/dashboard/components/dashboard-latency-percentiles-widget.tsx +0 -85
  97. package/src/modules/dashboard/components/dashboard-metrics-widget.tsx +0 -78
  98. package/src/modules/dashboard/components/dashboard-plugins-widget.tsx +0 -67
  99. package/src/modules/dashboard/components/dashboard-requests-widget.tsx +0 -62
  100. package/src/modules/dashboard/layouts/dashboard-layout.tsx +0 -16
  101. package/src/modules/dashboard/pages/ai-insights-page.tsx +0 -563
  102. package/src/modules/dashboard/pages/dashboard-animations.css +0 -317
  103. package/src/modules/dashboard/pages/dashboard-page.tsx +0 -13
  104. package/src/modules/dashboard/routes/index.tsx +0 -70
  105. package/src/modules/observability/pages/devkit-page.tsx +0 -263
  106. package/src/modules/observability/pages/incident-detail-page.tsx +0 -571
  107. package/src/modules/observability/pages/incidents-page.tsx +0 -370
  108. package/src/modules/observability/pages/log-detail-page.tsx +0 -508
  109. package/src/modules/observability/pages/logs-page.tsx +0 -1129
  110. package/src/modules/observability/pages/prometheus-metrics-page.tsx +0 -486
  111. package/src/modules/observability/pages/state-broker-page.tsx +0 -229
  112. package/src/modules/observability/pages/system-events-page.tsx +0 -255
  113. package/src/modules/observability/routes/index.tsx +0 -133
  114. package/src/modules/plugins/components/marketplace-card.tsx +0 -153
  115. package/src/modules/plugins/components/plugin-ai-assistant-modal.tsx +0 -374
  116. package/src/modules/plugins/components/plugin-card.tsx +0 -136
  117. package/src/modules/plugins/components/plugin-detail/capabilities-summary.tsx +0 -101
  118. package/src/modules/plugins/components/plugin-detail/cli-commands-table.tsx +0 -101
  119. package/src/modules/plugins/components/plugin-detail/index.ts +0 -7
  120. package/src/modules/plugins/components/plugin-detail/jobs-table.tsx +0 -64
  121. package/src/modules/plugins/components/plugin-detail/permissions/env-permissions.tsx +0 -30
  122. package/src/modules/plugins/components/plugin-detail/permissions/filesystem-permissions.tsx +0 -68
  123. package/src/modules/plugins/components/plugin-detail/permissions/index.ts +0 -6
  124. package/src/modules/plugins/components/plugin-detail/permissions/network-permissions.tsx +0 -43
  125. package/src/modules/plugins/components/plugin-detail/permissions/platform-services.tsx +0 -242
  126. package/src/modules/plugins/components/plugin-detail/permissions/resource-quotas.tsx +0 -96
  127. package/src/modules/plugins/components/plugin-detail/permissions/shell-permissions.tsx +0 -55
  128. package/src/modules/plugins/components/plugin-detail/permissions-view.tsx +0 -47
  129. package/src/modules/plugins/components/plugin-detail/plugin-header.tsx +0 -169
  130. package/src/modules/plugins/components/plugin-detail/rest-routes-table.tsx +0 -159
  131. package/src/modules/plugins/components/plugin-detail/workflows-table.tsx +0 -40
  132. package/src/modules/plugins/components/plugin-grid.tsx +0 -20
  133. package/src/modules/plugins/components/plugin-table.tsx +0 -178
  134. package/src/modules/plugins/pages/marketplace-page.tsx +0 -200
  135. package/src/modules/plugins/pages/plugin-detail-page.tsx +0 -1145
  136. package/src/modules/plugins/routes/index.tsx +0 -48
  137. package/src/modules/plugins/utils/index.ts +0 -1
  138. package/src/modules/plugins/utils/schema-helpers.ts +0 -21
  139. package/src/modules/settings/components/api-routes-viewer.tsx +0 -415
  140. package/src/modules/settings/components/appearance-settings.tsx +0 -200
  141. package/src/modules/settings/components/configuration-settings.tsx +0 -321
  142. package/src/modules/settings/components/data-privacy-settings.tsx +0 -111
  143. package/src/modules/settings/components/experimental-settings.tsx +0 -243
  144. package/src/modules/settings/components/navigation-settings.tsx +0 -198
  145. package/src/modules/settings/components/notifications-settings.tsx +0 -40
  146. package/src/modules/settings/pages/settings-page.tsx +0 -298
  147. package/src/modules/settings/routes/index.tsx +0 -47
  148. package/src/pages/README-assistant.md +0 -91
  149. package/src/pages/login-page.tsx +0 -177
  150. package/src/pages/not-found-page.tsx +0 -85
  151. package/src/providers/auth-provider.tsx +0 -40
  152. package/src/providers/command-palette-provider.tsx +0 -193
  153. package/src/providers/data-sources-provider.tsx +0 -27
  154. package/src/providers/devtools-provider.tsx +0 -72
  155. package/src/providers/navigation-items-provider.tsx +0 -38
  156. package/src/providers/registry-v2-provider.tsx +0 -93
  157. package/src/providers/settings-provider.tsx +0 -158
  158. package/src/router.tsx +0 -302
  159. package/src/routes/helpers.tsx +0 -25
  160. package/src/routes/plugin-page-v2.tsx +0 -52
  161. package/src/routes/types.ts +0 -18
  162. package/src/styles/antd-overrides.css +0 -211
  163. package/src/styles/base.css +0 -190
  164. package/src/styles/settings.css +0 -75
  165. package/src/styles/variables.css +0 -94
  166. package/src/utils/analytics.ts +0 -183
  167. package/src/utils/apply-navigation-categories.ts +0 -83
  168. package/src/utils/commands.ts +0 -252
  169. package/src/utils/export.ts +0 -174
  170. package/src/utils/format-date.ts +0 -166
  171. package/src/utils/logger.ts +0 -110
  172. package/tailwind.config.ts +0 -13
  173. package/tsconfig.json +0 -13
  174. package/vitest-setup.ts +0 -1
  175. /package/{public → dist}/favicon.svg +0 -0
@@ -1,336 +0,0 @@
1
- import { UIRow, UICol, UIStatistic, UIAlert, UISpace, useUITheme } from '@kb-labs/studio-ui-kit';
2
- import {
3
- ThunderboltOutlined,
4
- DatabaseOutlined,
5
- CloudOutlined,
6
- RocketOutlined,
7
- RobotOutlined,
8
- FileTextOutlined,
9
- SaveOutlined,
10
- ArrowRightOutlined,
11
- DollarOutlined,
12
- } from '@ant-design/icons';
13
- import { UIText, UITitle, UICard, UIPage, UIPageHeader } from '@kb-labs/studio-ui-kit';
14
- import {
15
- useAnalyticsStats,
16
- useAdaptersLLMUsage,
17
- useAdaptersEmbeddingsUsage,
18
- useAdaptersVectorStoreUsage,
19
- useAdaptersCacheUsage,
20
- useAdaptersStorageUsage,
21
- } from '@kb-labs/studio-data-client';
22
- import { useDataSources } from '../../../providers/data-sources-provider';
23
- import { useNavigate } from 'react-router-dom';
24
-
25
-
26
- /**
27
- * Analytics Overview Page
28
- *
29
- * High-level dashboard showing metrics across all platform adapters:
30
- * - Total events tracked
31
- * - Adapter health status
32
- * - Quick links to detailed views (LLM, Cache, Events, etc.)
33
- */
34
- export function AnalyticsOverviewPage() {
35
- const { token } = useUITheme();
36
- const sources = useDataSources();
37
- const navigate = useNavigate();
38
-
39
- const {
40
- data: statsData,
41
- isLoading: statsLoading,
42
- error: statsError,
43
- isError: isStatsError,
44
- } = useAnalyticsStats(sources.analytics);
45
-
46
- // Fetch all adapter stats
47
- const { data: llmStats } = useAdaptersLLMUsage(sources.adapters);
48
- const { data: embeddingsStats } = useAdaptersEmbeddingsUsage(sources.adapters);
49
- const { data: vectorstoreStats } = useAdaptersVectorStoreUsage(sources.adapters);
50
- const { data: cacheStats } = useAdaptersCacheUsage(sources.adapters);
51
- const { data: storageStats } = useAdaptersStorageUsage(sources.adapters);
52
-
53
- // Check if analytics is not configured
54
- const analyticsNotConfigured =
55
- isStatsError &&
56
- statsError instanceof Error &&
57
- statsError.message.includes('not support');
58
-
59
- if (analyticsNotConfigured) {
60
- return (
61
- <UIPage>
62
- <UIPageHeader
63
- title="Analytics"
64
- description="Platform-wide analytics and adapter metrics"
65
- />
66
- <UIAlert
67
- message="Analytics Not Configured"
68
- description="Analytics adapter is not configured. Configure an analytics adapter in kb.config.json to track events and metrics."
69
- variant="info"
70
- showIcon
71
- style={{ marginTop: 16 }}
72
- />
73
- </UIPage>
74
- );
75
- }
76
-
77
- if (isStatsError) {
78
- return (
79
- <UIPage>
80
- <UIPageHeader title="Analytics" description="Platform-wide analytics" />
81
- <UIAlert
82
- message="Failed to Load Analytics"
83
- description={statsError?.message || 'Unknown error occurred'}
84
- variant="error"
85
- showIcon
86
- style={{ marginTop: 16 }}
87
- />
88
- </UIPage>
89
- );
90
- }
91
-
92
- return (
93
- <UIPage width="full">
94
- <UIPageHeader
95
- title="Analytics Overview"
96
- description="High-level metrics across all platform adapters"
97
- />
98
-
99
- <div style={{ marginTop: 24 }}>
100
- {/* Overview Stats */}
101
- <UIRow gutter={[16, 16]}>
102
- <UICol xs={24} sm={12} lg={6}>
103
- <UICard>
104
- <UIStatistic
105
- title="Total Events"
106
- value={statsData?.totalEvents ?? 0}
107
- loading={statsLoading}
108
- prefix={<ThunderboltOutlined />}
109
- valueStyle={{ color: 'var(--info)' }}
110
- />
111
- </UICard>
112
- </UICol>
113
- <UICol xs={24} sm={12} lg={6}>
114
- <UICard>
115
- <UIStatistic
116
- title="Event Types"
117
- value={statsData ? Object.keys(statsData.byType).length : 0}
118
- loading={statsLoading}
119
- prefix={<DatabaseOutlined />}
120
- valueStyle={{ color: 'var(--success)' }}
121
- />
122
- </UICard>
123
- </UICol>
124
- <UICol xs={24} sm={12} lg={6}>
125
- <UICard>
126
- <UIStatistic
127
- title="Sources"
128
- value={statsData ? Object.keys(statsData.bySource).length : 0}
129
- loading={statsLoading}
130
- prefix={<CloudOutlined />}
131
- valueStyle={{ color: 'var(--link)' }}
132
- />
133
- </UICard>
134
- </UICol>
135
- <UICol xs={24} sm={12} lg={6}>
136
- <UICard>
137
- <UIStatistic
138
- title="Actors"
139
- value={statsData ? Object.keys(statsData.byActor).length : 0}
140
- loading={statsLoading}
141
- prefix={<RocketOutlined />}
142
- valueStyle={{ color: 'var(--warning)' }}
143
- />
144
- </UICard>
145
- </UICol>
146
- </UIRow>
147
-
148
- {/* Platform Adapters */}
149
- <div style={{ marginTop: 32 }}>
150
- <UITitle level={4}>Platform Adapters</UITitle>
151
- <UIRow gutter={[16, 16]} style={{ marginTop: 16 }}>
152
- {/* LLM Adapter */}
153
- <UICol xs={24} md={12} lg={8}>
154
- <UICard
155
- hoverable
156
- onClick={() => navigate('/analytics/llm')}
157
- style={{ cursor: 'pointer' }}
158
- >
159
- <UISpace direction="vertical" style={{ width: '100%' }} size="large">
160
- <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
161
- <UISpace>
162
- <RobotOutlined style={{ fontSize: 24, color: 'var(--info)' }} />
163
- <UIText weight="semibold" style={{ fontSize: 16 }}>LLM Usage</UIText>
164
- </UISpace>
165
- <ArrowRightOutlined style={{ color: token.colorTextTertiary }} />
166
- </div>
167
- <UIRow gutter={16}>
168
- <UICol span={12}>
169
- <UIStatistic
170
- title="Requests"
171
- value={llmStats?.totalRequests ?? 0}
172
- valueStyle={{ fontSize: 20 }}
173
- />
174
- </UICol>
175
- <UICol span={12}>
176
- <UIStatistic
177
- title="Cost"
178
- value={llmStats?.totalCost ?? 0}
179
- prefix={<DollarOutlined />}
180
- precision={2}
181
- valueStyle={{ fontSize: 20 }}
182
- />
183
- </UICol>
184
- </UIRow>
185
- </UISpace>
186
- </UICard>
187
- </UICol>
188
-
189
- {/* Embeddings Adapter */}
190
- <UICol xs={24} md={12} lg={8}>
191
- <UICard
192
- hoverable
193
- onClick={() => navigate('/analytics/embeddings')}
194
- style={{ cursor: 'pointer' }}
195
- >
196
- <UISpace direction="vertical" style={{ width: '100%' }} size="large">
197
- <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
198
- <UISpace>
199
- <FileTextOutlined style={{ fontSize: 24, color: 'var(--success)' }} />
200
- <UIText weight="semibold" style={{ fontSize: 16 }}>Embeddings</UIText>
201
- </UISpace>
202
- <ArrowRightOutlined style={{ color: token.colorTextTertiary }} />
203
- </div>
204
- <UIRow gutter={16}>
205
- <UICol span={12}>
206
- <UIStatistic
207
- title="Requests"
208
- value={embeddingsStats?.totalRequests ?? 0}
209
- valueStyle={{ fontSize: 20 }}
210
- />
211
- </UICol>
212
- <UICol span={12}>
213
- <UIStatistic
214
- title="Text Chars"
215
- value={embeddingsStats?.totalTextLength ?? 0}
216
- valueStyle={{ fontSize: 20 }}
217
- />
218
- </UICol>
219
- </UIRow>
220
- </UISpace>
221
- </UICard>
222
- </UICol>
223
-
224
- {/* VectorStore Adapter */}
225
- <UICol xs={24} md={12} lg={8}>
226
- <UICard
227
- hoverable
228
- onClick={() => navigate('/analytics/vectorstore')}
229
- style={{ cursor: 'pointer' }}
230
- >
231
- <UISpace direction="vertical" style={{ width: '100%' }} size="large">
232
- <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
233
- <UISpace>
234
- <DatabaseOutlined style={{ fontSize: 24, color: 'var(--link)' }} />
235
- <UIText weight="semibold" style={{ fontSize: 16 }}>VectorStore</UIText>
236
- </UISpace>
237
- <ArrowRightOutlined style={{ color: token.colorTextTertiary }} />
238
- </div>
239
- <UIRow gutter={16}>
240
- <UICol span={12}>
241
- <UIStatistic
242
- title="Searches"
243
- value={vectorstoreStats?.searchQueries ?? 0}
244
- valueStyle={{ fontSize: 20 }}
245
- />
246
- </UICol>
247
- <UICol span={12}>
248
- <UIStatistic
249
- title="Avg Score"
250
- value={vectorstoreStats?.avgSearchScore ?? 0}
251
- precision={2}
252
- valueStyle={{ fontSize: 20 }}
253
- />
254
- </UICol>
255
- </UIRow>
256
- </UISpace>
257
- </UICard>
258
- </UICol>
259
-
260
- {/* Cache Adapter */}
261
- <UICol xs={24} md={12} lg={8}>
262
- <UICard
263
- hoverable
264
- onClick={() => navigate('/analytics/cache')}
265
- style={{ cursor: 'pointer' }}
266
- >
267
- <UISpace direction="vertical" style={{ width: '100%' }} size="large">
268
- <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
269
- <UISpace>
270
- <ThunderboltOutlined style={{ fontSize: 24, color: 'var(--warning)' }} />
271
- <UIText weight="semibold" style={{ fontSize: 16 }}>Cache</UIText>
272
- </UISpace>
273
- <ArrowRightOutlined style={{ color: token.colorTextTertiary }} />
274
- </div>
275
- <UIRow gutter={16}>
276
- <UICol span={12}>
277
- <UIStatistic
278
- title="Hit Rate"
279
- value={cacheStats?.hitRate ?? 0}
280
- suffix="%"
281
- precision={1}
282
- valueStyle={{ fontSize: 20, color: cacheStats && cacheStats.hitRate >= 80 ? 'var(--success)' : 'var(--info)' }}
283
- />
284
- </UICol>
285
- <UICol span={12}>
286
- <UIStatistic
287
- title="Total Gets"
288
- value={cacheStats?.totalGets ?? 0}
289
- valueStyle={{ fontSize: 20 }}
290
- />
291
- </UICol>
292
- </UIRow>
293
- </UISpace>
294
- </UICard>
295
- </UICol>
296
-
297
- {/* Storage Adapter */}
298
- <UICol xs={24} md={12} lg={8}>
299
- <UICard
300
- hoverable
301
- onClick={() => navigate('/analytics/storage')}
302
- style={{ cursor: 'pointer' }}
303
- >
304
- <UISpace direction="vertical" style={{ width: '100%' }} size="large">
305
- <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
306
- <UISpace>
307
- <SaveOutlined style={{ fontSize: 24, color: 'var(--error)' }} />
308
- <UIText weight="semibold" style={{ fontSize: 16 }}>Storage</UIText>
309
- </UISpace>
310
- <ArrowRightOutlined style={{ color: token.colorTextTertiary }} />
311
- </div>
312
- <UIRow gutter={16}>
313
- <UICol span={12}>
314
- <UIStatistic
315
- title="Reads"
316
- value={storageStats?.readOperations ?? 0}
317
- valueStyle={{ fontSize: 20 }}
318
- />
319
- </UICol>
320
- <UICol span={12}>
321
- <UIStatistic
322
- title="Writes"
323
- value={storageStats?.writeOperations ?? 0}
324
- valueStyle={{ fontSize: 20 }}
325
- />
326
- </UICol>
327
- </UIRow>
328
- </UISpace>
329
- </UICard>
330
- </UICol>
331
- </UIRow>
332
- </div>
333
- </div>
334
- </UIPage>
335
- );
336
- }
@@ -1,20 +0,0 @@
1
- import { EmptyState } from '@/components/empty-state';
2
- import { BarChart3 } from 'lucide-react';
3
- import { UIPage, UIPageHeader } from '@kb-labs/studio-ui-kit';
4
-
5
- export function AnalyticsPage() {
6
- return (
7
- <UIPage width="full">
8
- <UIPageHeader
9
- title="Analytics"
10
- description="Event metrics and performance charts"
11
- />
12
- <EmptyState
13
- icon={<BarChart3 size={32} />}
14
- title="Coming Soon"
15
- description="Event metrics and performance charts will appear here."
16
- />
17
- </UIPage>
18
- );
19
- }
20
-
@@ -1,344 +0,0 @@
1
- import { useState } from 'react';
2
- import { UIRow, UICol, UIStatistic, UIAlert } from '@kb-labs/studio-ui-kit';
3
- import {
4
- FileOutlined,
5
- UploadOutlined,
6
- DownloadOutlined,
7
- DeleteOutlined,
8
- ClockCircleOutlined,
9
- DatabaseOutlined,
10
- } from '@ant-design/icons';
11
- import { UIText, UIStatisticsChart, UICard, UIPage, UIPageHeader } from '@kb-labs/studio-ui-kit';
12
- import { useAdaptersStorageUsage, useAdaptersStorageDailyStats } from '@kb-labs/studio-data-client';
13
- import { useDataSources } from '../../../providers/data-sources-provider';
14
- import { AnalyticsDateRangePicker, type DateRangeValue } from '../components/analytics-date-range-picker';
15
- import dayjs from 'dayjs';
16
-
17
-
18
- /**
19
- * Analytics Storage Usage Page
20
- *
21
- * Displays storage usage statistics:
22
- * - Read/write/delete operations
23
- * - Bandwidth usage tracking
24
- * - Performance metrics
25
- */
26
- export function AnalyticsStoragePage() {
27
- const sources = useDataSources();
28
-
29
- // Date range state (default: last 30 days)
30
- const [dateRange, setDateRange] = useState<DateRangeValue>([
31
- dayjs().subtract(30, 'days'),
32
- dayjs(),
33
- ]);
34
-
35
- const {
36
- data: stats,
37
- isLoading,
38
- error,
39
- isError,
40
- } = useAdaptersStorageUsage(sources.adapters, {
41
- from: dateRange[0].toISOString(),
42
- to: dateRange[1].toISOString(),
43
- });
44
-
45
- const {
46
- data: dailyStats,
47
- isLoading: dailyStatsLoading,
48
- } = useAdaptersStorageDailyStats(sources.adapters, {
49
- from: dateRange[0].toISOString(),
50
- to: dateRange[1].toISOString(),
51
- });
52
-
53
- // Check if analytics is not implemented
54
- const analyticsNotImplemented =
55
- isError &&
56
- error instanceof Error &&
57
- (error.message.includes('not support') || error.message.includes('not implement'));
58
-
59
- if (analyticsNotImplemented) {
60
- return (
61
- <UIPage>
62
- <UIPageHeader
63
- title="Storage Usage"
64
- description="Track storage operations and bandwidth usage"
65
- />
66
- <UIAlert
67
- message="Analytics Not Available"
68
- description="Analytics adapter does not support reading events. Configure an analytics adapter in kb.config.json that implements getEvents()."
69
- variant="info"
70
- showIcon
71
- style={{ marginTop: 16 }}
72
- />
73
- </UIPage>
74
- );
75
- }
76
-
77
- if (isError) {
78
- return (
79
- <UIPage>
80
- <UIPageHeader title="Storage Usage" description="Storage usage analytics" />
81
- <UIAlert
82
- message="Failed to Load Storage Usage"
83
- description={error?.message || 'Unknown error occurred'}
84
- variant="error"
85
- showIcon
86
- style={{ marginTop: 16 }}
87
- />
88
- </UIPage>
89
- );
90
- }
91
-
92
- // Format helpers
93
- const _formatNumber = (num: number) => num.toLocaleString();
94
- const formatSize = (bytes: number) => {
95
- if (bytes < 1024) {return `${bytes} B`;}
96
- if (bytes < 1024 * 1024) {return `${(bytes / 1024).toFixed(2)} KB`;}
97
- if (bytes < 1024 * 1024 * 1024) {return `${(bytes / (1024 * 1024)).toFixed(2)} MB`;}
98
- return `${(bytes / (1024 * 1024 * 1024)).toFixed(2)} GB`;
99
- };
100
- const _formatDuration = (ms: number) => (ms < 1000 ? `${ms.toFixed(1)}ms` : `${(ms / 1000).toFixed(2)}s`);
101
-
102
- const totalOperations = stats
103
- ? stats.readOperations + stats.writeOperations + stats.deleteOperations
104
- : 0;
105
-
106
- const readPercentage = stats && totalOperations > 0
107
- ? ((stats.readOperations / totalOperations) * 100).toFixed(1)
108
- : 0;
109
-
110
- const writePercentage = stats && totalOperations > 0
111
- ? ((stats.writeOperations / totalOperations) * 100).toFixed(1)
112
- : 0;
113
-
114
- return (
115
- <UIPage width="full">
116
- <UIPageHeader
117
- title="Storage Usage Analytics"
118
- description="Track storage operations, bandwidth usage, and file I/O performance"
119
- actions={
120
- <AnalyticsDateRangePicker
121
- value={dateRange}
122
- onChange={setDateRange}
123
- />
124
- }
125
- />
126
-
127
- <div style={{ marginTop: 24 }}>
128
- {/* Operations Overview */}
129
- <UIRow gutter={[16, 16]}>
130
- <UICol xs={24} sm={12} lg={6}>
131
- <UICard>
132
- <UIStatistic
133
- title="Read Operations"
134
- value={stats?.readOperations ?? 0}
135
- prefix={<DownloadOutlined />}
136
- loading={isLoading}
137
- valueStyle={{ color: 'var(--info)' }}
138
- />
139
- </UICard>
140
- </UICol>
141
- <UICol xs={24} sm={12} lg={6}>
142
- <UICard>
143
- <UIStatistic
144
- title="Write Operations"
145
- value={stats?.writeOperations ?? 0}
146
- prefix={<UploadOutlined />}
147
- loading={isLoading}
148
- valueStyle={{ color: 'var(--success)' }}
149
- />
150
- </UICard>
151
- </UICol>
152
- <UICol xs={24} sm={12} lg={6}>
153
- <UICard>
154
- <UIStatistic
155
- title="Delete Operations"
156
- value={stats?.deleteOperations ?? 0}
157
- prefix={<DeleteOutlined />}
158
- loading={isLoading}
159
- valueStyle={{ color: 'var(--error)' }}
160
- />
161
- </UICard>
162
- </UICol>
163
- <UICol xs={24} sm={12} lg={6}>
164
- <UICard>
165
- <UIStatistic
166
- title="Total Operations"
167
- value={totalOperations}
168
- prefix={<FileOutlined />}
169
- loading={isLoading}
170
- valueStyle={{ color: 'var(--link)' }}
171
- />
172
- </UICard>
173
- </UICol>
174
- </UIRow>
175
-
176
- {/* Bandwidth Usage */}
177
- <UIRow gutter={[16, 16]} style={{ marginTop: 16 }}>
178
- <UICol xs={24} lg={12}>
179
- <UICard title="Bandwidth Usage">
180
- <UIRow gutter={[16, 16]}>
181
- <UICol span={12}>
182
- <UIStatistic
183
- title="Total Read"
184
- value={formatSize(stats?.totalBytesRead ?? 0)}
185
- prefix={<DownloadOutlined />}
186
- loading={isLoading}
187
- valueStyle={{ color: 'var(--info)' }}
188
- />
189
- </UICol>
190
- <UICol span={12}>
191
- <UIStatistic
192
- title="Total Written"
193
- value={formatSize(stats?.totalBytesWritten ?? 0)}
194
- prefix={<UploadOutlined />}
195
- loading={isLoading}
196
- valueStyle={{ color: 'var(--success)' }}
197
- />
198
- </UICol>
199
- </UIRow>
200
- <div style={{ marginTop: 16 }}>
201
- <UIStatistic
202
- title="Total Bandwidth"
203
- value={formatSize((stats?.totalBytesRead ?? 0) + (stats?.totalBytesWritten ?? 0))}
204
- prefix={<DatabaseOutlined />}
205
- loading={isLoading}
206
- valueStyle={{ color: 'var(--link)' }}
207
- />
208
- </div>
209
- </UICard>
210
- </UICol>
211
- <UICol xs={24} lg={12}>
212
- <UICard title="Performance Metrics">
213
- <UIRow gutter={[16, 16]}>
214
- <UICol span={12}>
215
- <UIStatistic
216
- title="Avg Read Duration"
217
- value={stats?.avgReadDuration ?? 0}
218
- prefix={<ClockCircleOutlined />}
219
- suffix="ms"
220
- precision={1}
221
- loading={isLoading}
222
- />
223
- </UICol>
224
- <UICol span={12}>
225
- <UIStatistic
226
- title="Avg Write Duration"
227
- value={stats?.avgWriteDuration ?? 0}
228
- prefix={<ClockCircleOutlined />}
229
- suffix="ms"
230
- precision={1}
231
- loading={isLoading}
232
- />
233
- </UICol>
234
- </UIRow>
235
- </UICard>
236
- </UICol>
237
- </UIRow>
238
-
239
- {/* Operation Statistics */}
240
- {stats && totalOperations > 0 && (
241
- <UICard title="Operation Statistics" style={{ marginTop: 16 }}>
242
- <UIRow gutter={[16, 16]}>
243
- <UICol xs={24} sm={8}>
244
- <UIStatistic
245
- title="Read Ratio"
246
- value={Number(readPercentage)}
247
- suffix="%"
248
- precision={1}
249
- loading={isLoading}
250
- valueStyle={{ color: 'var(--info)' }}
251
- />
252
- <UIText color="secondary" style={{ fontSize: 12 }}>
253
- {readPercentage}% of total operations
254
- </UIText>
255
- </UICol>
256
- <UICol xs={24} sm={8}>
257
- <UIStatistic
258
- title="Write Ratio"
259
- value={Number(writePercentage)}
260
- suffix="%"
261
- precision={1}
262
- loading={isLoading}
263
- valueStyle={{ color: 'var(--success)' }}
264
- />
265
- <UIText color="secondary" style={{ fontSize: 12 }}>
266
- {writePercentage}% of total operations
267
- </UIText>
268
- </UICol>
269
- <UICol xs={24} sm={8}>
270
- <UIStatistic
271
- title="Avg Read Size"
272
- value={formatSize(stats.totalBytesRead / Math.max(stats.readOperations, 1))}
273
- loading={isLoading}
274
- />
275
- <UIText color="secondary" style={{ fontSize: 12 }}>
276
- Per read operation
277
- </UIText>
278
- </UICol>
279
- </UIRow>
280
- <UIRow gutter={[16, 16]} style={{ marginTop: 16 }}>
281
- <UICol xs={24} sm={8}>
282
- <UIStatistic
283
- title="Avg Write Size"
284
- value={formatSize(stats.totalBytesWritten / Math.max(stats.writeOperations, 1))}
285
- loading={isLoading}
286
- />
287
- <UIText color="secondary" style={{ fontSize: 12 }}>
288
- Per write operation
289
- </UIText>
290
- </UICol>
291
- <UICol xs={24} sm={8}>
292
- <UIStatistic
293
- title="Read Throughput"
294
- value={
295
- stats.avgReadDuration > 0
296
- ? formatSize((stats.totalBytesRead / Math.max(stats.readOperations, 1)) / (stats.avgReadDuration / 1000))
297
- : '0 B'
298
- }
299
- suffix="/s"
300
- loading={isLoading}
301
- valueStyle={{ color: 'var(--info)' }}
302
- />
303
- </UICol>
304
- <UICol xs={24} sm={8}>
305
- <UIStatistic
306
- title="Write Throughput"
307
- value={
308
- stats.avgWriteDuration > 0
309
- ? formatSize((stats.totalBytesWritten / Math.max(stats.writeOperations, 1)) / (stats.avgWriteDuration / 1000))
310
- : '0 B'
311
- }
312
- suffix="/s"
313
- loading={isLoading}
314
- valueStyle={{ color: 'var(--success)' }}
315
- />
316
- </UICol>
317
- </UIRow>
318
- </UICard>
319
- )}
320
-
321
- {/* Daily Usage Chart */}
322
- <UIStatisticsChart
323
- data={dailyStats}
324
- loading={dailyStatsLoading}
325
- title="Daily Storage Activity"
326
- metrics={[
327
- {
328
- key: 'totalBytesRead',
329
- label: 'Bytes Read (MB)',
330
- transform: (v) => Math.floor(v / (1024 * 1024)),
331
- format: (v) => `${v} MB`,
332
- },
333
- {
334
- key: 'totalBytesWritten',
335
- label: 'Bytes Written (MB)',
336
- transform: (v) => Math.floor(v / (1024 * 1024)),
337
- format: (v) => `${v} MB`,
338
- },
339
- ]}
340
- />
341
- </div>
342
- </UIPage>
343
- );
344
- }