create-fluxstack 1.7.5 → 1.8.3
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/.dockerignore +82 -0
- package/.env.example +19 -0
- package/Dockerfile +70 -0
- package/README.md +6 -3
- package/app/client/SIMPLIFICATION.md +140 -0
- package/app/client/frontend-only.ts +1 -1
- package/app/client/src/App.tsx +148 -283
- package/app/client/src/index.css +5 -20
- package/app/client/src/lib/eden-api.ts +53 -220
- package/app/client/src/main.tsx +2 -3
- package/app/server/app.ts +20 -5
- package/app/server/backend-only.ts +15 -12
- package/app/server/controllers/users.controller.ts +57 -31
- package/app/server/index.ts +86 -96
- package/app/server/live/register-components.ts +18 -7
- package/app/server/routes/env-test.ts +110 -0
- package/app/server/routes/index.ts +1 -8
- package/app/server/routes/users.routes.ts +192 -91
- package/config/app.config.ts +2 -54
- package/config/client.config.ts +95 -0
- package/config/fluxstack.config.ts +2 -2
- package/config/index.ts +57 -22
- package/config/monitoring.config.ts +114 -0
- package/config/plugins.config.ts +80 -0
- package/config/runtime.config.ts +0 -17
- package/config/server.config.ts +50 -30
- package/core/build/bundler.ts +17 -16
- package/core/build/flux-plugins-generator.ts +34 -23
- package/core/build/index.ts +32 -31
- package/core/build/live-components-generator.ts +44 -30
- package/core/build/optimizer.ts +37 -17
- package/core/cli/command-registry.ts +4 -14
- package/core/cli/commands/plugin-deps.ts +8 -8
- package/core/cli/generators/component.ts +3 -3
- package/core/cli/generators/controller.ts +4 -4
- package/core/cli/generators/index.ts +8 -8
- package/core/cli/generators/interactive.ts +4 -4
- package/core/cli/generators/plugin.ts +3 -3
- package/core/cli/generators/prompts.ts +1 -1
- package/core/cli/generators/route.ts +27 -11
- package/core/cli/generators/service.ts +5 -5
- package/core/cli/generators/template-engine.ts +1 -1
- package/core/cli/generators/types.ts +1 -1
- package/core/cli/index.ts +158 -189
- package/core/cli/plugin-discovery.ts +3 -3
- package/core/client/hooks/index.ts +2 -2
- package/core/client/hooks/state-validator.ts +1 -1
- package/core/client/hooks/useAuth.ts +1 -1
- package/core/client/hooks/useChunkedUpload.ts +1 -1
- package/core/client/hooks/useHybridLiveComponent.ts +1 -1
- package/core/client/hooks/useWebSocket.ts +1 -1
- package/core/config/env.ts +5 -1
- package/core/config/runtime-config.ts +12 -10
- package/core/config/schema.ts +33 -2
- package/core/framework/server.ts +30 -14
- package/core/framework/types.ts +2 -2
- package/core/index.ts +31 -23
- package/core/live/ComponentRegistry.ts +1 -1
- package/core/plugins/built-in/live-components/commands/create-live-component.ts +1 -1
- package/core/plugins/built-in/live-components/index.ts +1 -1
- package/core/plugins/built-in/monitoring/index.ts +65 -161
- package/core/plugins/built-in/static/index.ts +75 -277
- package/core/plugins/built-in/swagger/index.ts +301 -231
- package/core/plugins/built-in/vite/index.ts +342 -377
- package/core/plugins/config.ts +2 -2
- package/core/plugins/dependency-manager.ts +2 -2
- package/core/plugins/discovery.ts +1 -1
- package/core/plugins/executor.ts +2 -2
- package/core/plugins/manager.ts +19 -4
- package/core/plugins/module-resolver.ts +1 -1
- package/core/plugins/registry.ts +25 -21
- package/core/plugins/types.ts +147 -5
- package/core/server/backend-entry.ts +51 -0
- package/core/server/framework.ts +2 -2
- package/core/server/live/ComponentRegistry.ts +9 -26
- package/core/server/live/FileUploadManager.ts +1 -1
- package/core/server/live/auto-generated-components.ts +26 -0
- package/core/server/live/websocket-plugin.ts +211 -19
- package/core/server/middleware/errorHandling.ts +1 -1
- package/core/server/middleware/index.ts +4 -4
- package/core/server/plugins/database.ts +1 -2
- package/core/server/plugins/static-files-plugin.ts +259 -231
- package/core/server/plugins/swagger.ts +1 -1
- package/core/server/services/BaseService.ts +1 -1
- package/core/server/services/ServiceContainer.ts +1 -1
- package/core/server/services/index.ts +4 -4
- package/core/server/standalone.ts +16 -1
- package/core/testing/index.ts +1 -1
- package/core/testing/setup.ts +1 -1
- package/core/types/plugin.ts +6 -0
- package/core/utils/build-logger.ts +324 -0
- package/core/utils/config-schema.ts +2 -6
- package/core/utils/helpers.ts +14 -9
- package/core/utils/logger/startup-banner.ts +7 -33
- package/core/utils/regenerate-files.ts +69 -0
- package/core/utils/version.ts +6 -6
- package/create-fluxstack.ts +68 -25
- package/fluxstack.config.ts +138 -252
- package/package.json +3 -18
- package/plugins/crypto-auth/index.ts +52 -47
- package/plugins/crypto-auth/server/AuthMiddleware.ts +1 -1
- package/plugins/crypto-auth/server/middlewares/helpers.ts +16 -1
- package/vitest.config.ts +17 -26
- package/app/client/src/App.css +0 -883
- package/app/client/src/components/ErrorBoundary.tsx +0 -107
- package/app/client/src/components/ErrorDisplay.css +0 -365
- package/app/client/src/components/ErrorDisplay.tsx +0 -258
- package/app/client/src/components/FluxStackConfig.tsx +0 -1321
- package/app/client/src/components/HybridLiveCounter.tsx +0 -140
- package/app/client/src/components/LiveClock.tsx +0 -286
- package/app/client/src/components/MainLayout.tsx +0 -388
- package/app/client/src/components/SidebarNavigation.tsx +0 -391
- package/app/client/src/components/StateDemo.tsx +0 -178
- package/app/client/src/components/SystemMonitor.tsx +0 -1044
- package/app/client/src/components/UserProfile.tsx +0 -809
- package/app/client/src/hooks/useAuth.ts +0 -39
- package/app/client/src/hooks/useNotifications.ts +0 -56
- package/app/client/src/lib/errors.ts +0 -340
- package/app/client/src/lib/hooks/useErrorHandler.ts +0 -258
- package/app/client/src/lib/index.ts +0 -45
- package/app/client/src/pages/ApiDocs.tsx +0 -182
- package/app/client/src/pages/CryptoAuthPage.tsx +0 -394
- package/app/client/src/pages/Demo.tsx +0 -174
- package/app/client/src/pages/HybridLive.tsx +0 -263
- package/app/client/src/pages/Overview.tsx +0 -155
- package/app/client/src/store/README.md +0 -43
- package/app/client/src/store/index.ts +0 -16
- package/app/client/src/store/slices/uiSlice.ts +0 -151
- package/app/client/src/store/slices/userSlice.ts +0 -161
- package/app/client/src/test/README.md +0 -257
- package/app/client/src/test/setup.ts +0 -70
- package/app/client/src/test/types.ts +0 -12
- package/app/server/live/CounterComponent.ts +0 -191
- package/app/server/live/FluxStackConfig.ts +0 -534
- package/app/server/live/SidebarNavigation.ts +0 -157
- package/app/server/live/SystemMonitor.ts +0 -595
- package/app/server/live/SystemMonitorIntegration.ts +0 -151
- package/app/server/live/UserProfileComponent.ts +0 -141
- package/app/server/middleware/auth.ts +0 -136
- package/app/server/middleware/errorHandling.ts +0 -252
- package/app/server/middleware/index.ts +0 -10
- package/app/server/middleware/rateLimit.ts +0 -193
- package/app/server/middleware/requestLogging.ts +0 -215
- package/app/server/middleware/validation.ts +0 -270
- package/app/server/routes/config.ts +0 -145
- package/app/server/routes/crypto-auth-demo.routes.ts +0 -167
- package/app/server/routes/example-with-crypto-auth.routes.ts +0 -235
- package/app/server/routes/exemplo-posts.routes.ts +0 -161
- package/app/server/routes/upload.ts +0 -92
- package/app/server/services/NotificationService.ts +0 -302
- package/app/server/services/UserService.ts +0 -222
- package/app/server/services/index.ts +0 -46
- package/app/server/types/index.ts +0 -1
- package/config/build.config.ts +0 -24
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import React, { Component, type ErrorInfo, type ReactNode } from 'react'
|
|
2
|
-
import { logClientError } from '../lib/errors'
|
|
3
|
-
|
|
4
|
-
interface Props {
|
|
5
|
-
children: ReactNode
|
|
6
|
-
fallback?: ReactNode
|
|
7
|
-
onError?: (error: Error, errorInfo: ErrorInfo) => void
|
|
8
|
-
showErrorDetails?: boolean
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
interface State {
|
|
12
|
-
hasError: boolean
|
|
13
|
-
error?: Error
|
|
14
|
-
errorInfo?: ErrorInfo
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export class ErrorBoundary extends Component<Props, State> {
|
|
18
|
-
constructor(props: Props) {
|
|
19
|
-
super(props)
|
|
20
|
-
this.state = { hasError: false }
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
static getDerivedStateFromError(error: Error): State {
|
|
24
|
-
return {
|
|
25
|
-
hasError: true,
|
|
26
|
-
error
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
componentDidCatch(error: Error, errorInfo: ErrorInfo) {
|
|
31
|
-
// Log the error
|
|
32
|
-
logClientError(error, { componentStack: errorInfo.componentStack || '' })
|
|
33
|
-
|
|
34
|
-
// Call custom error handler if provided
|
|
35
|
-
this.props.onError?.(error, errorInfo)
|
|
36
|
-
|
|
37
|
-
this.setState({
|
|
38
|
-
error,
|
|
39
|
-
errorInfo
|
|
40
|
-
})
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
handleRetry = () => {
|
|
44
|
-
this.setState({ hasError: false, error: undefined, errorInfo: undefined })
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
render() {
|
|
48
|
-
if (this.state.hasError) {
|
|
49
|
-
// Custom fallback UI
|
|
50
|
-
if (this.props.fallback) {
|
|
51
|
-
return this.props.fallback
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Default error UI
|
|
55
|
-
return (
|
|
56
|
-
<div className="error-boundary">
|
|
57
|
-
<div className="error-boundary-content">
|
|
58
|
-
<h2>Something went wrong</h2>
|
|
59
|
-
<p>We're sorry, but something unexpected happened.</p>
|
|
60
|
-
|
|
61
|
-
{this.props.showErrorDetails && this.state.error && (
|
|
62
|
-
<details className="error-details">
|
|
63
|
-
<summary>Error Details</summary>
|
|
64
|
-
<pre>{this.state.error.message}</pre>
|
|
65
|
-
{this.state.errorInfo && (
|
|
66
|
-
<pre>{this.state.errorInfo.componentStack}</pre>
|
|
67
|
-
)}
|
|
68
|
-
</details>
|
|
69
|
-
)}
|
|
70
|
-
|
|
71
|
-
<div className="error-actions">
|
|
72
|
-
<button onClick={this.handleRetry} className="retry-button">
|
|
73
|
-
Try Again
|
|
74
|
-
</button>
|
|
75
|
-
<button onClick={() => window.location.reload()} className="reload-button">
|
|
76
|
-
Reload Page
|
|
77
|
-
</button>
|
|
78
|
-
</div>
|
|
79
|
-
</div>
|
|
80
|
-
</div>
|
|
81
|
-
)
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return this.props.children
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// Hook version of ErrorBoundary for functional components
|
|
89
|
-
export function useErrorBoundary() {
|
|
90
|
-
const [error, setError] = React.useState<Error | null>(null)
|
|
91
|
-
|
|
92
|
-
const resetError = React.useCallback(() => {
|
|
93
|
-
setError(null)
|
|
94
|
-
}, [])
|
|
95
|
-
|
|
96
|
-
const captureError = React.useCallback((error: Error) => {
|
|
97
|
-
setError(error)
|
|
98
|
-
}, [])
|
|
99
|
-
|
|
100
|
-
React.useEffect(() => {
|
|
101
|
-
if (error) {
|
|
102
|
-
throw error
|
|
103
|
-
}
|
|
104
|
-
}, [error])
|
|
105
|
-
|
|
106
|
-
return { captureError, resetError }
|
|
107
|
-
}
|
|
@@ -1,365 +0,0 @@
|
|
|
1
|
-
/* Error Display Components Styles */
|
|
2
|
-
|
|
3
|
-
.error-display {
|
|
4
|
-
border-radius: 8px;
|
|
5
|
-
padding: 16px;
|
|
6
|
-
margin: 8px 0;
|
|
7
|
-
border: 1px solid;
|
|
8
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.error-display--inline {
|
|
12
|
-
background-color: #fef2f2;
|
|
13
|
-
border-color: #fecaca;
|
|
14
|
-
color: #991b1b;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.error-display--toast {
|
|
18
|
-
background-color: #ffffff;
|
|
19
|
-
border-color: #e5e7eb;
|
|
20
|
-
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
|
|
21
|
-
position: fixed;
|
|
22
|
-
top: 20px;
|
|
23
|
-
right: 20px;
|
|
24
|
-
z-index: 1000;
|
|
25
|
-
max-width: 400px;
|
|
26
|
-
animation: slideIn 0.3s ease-out;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.error-display--modal {
|
|
30
|
-
background-color: #ffffff;
|
|
31
|
-
border-color: #e5e7eb;
|
|
32
|
-
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
|
|
33
|
-
position: fixed;
|
|
34
|
-
top: 50%;
|
|
35
|
-
left: 50%;
|
|
36
|
-
transform: translate(-50%, -50%);
|
|
37
|
-
z-index: 1001;
|
|
38
|
-
max-width: 500px;
|
|
39
|
-
width: 90%;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.error-display--warning {
|
|
43
|
-
background-color: #fffbeb;
|
|
44
|
-
border-color: #fed7aa;
|
|
45
|
-
color: #92400e;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
.error-display--severe {
|
|
49
|
-
background-color: #fef2f2;
|
|
50
|
-
border-color: #fca5a5;
|
|
51
|
-
color: #dc2626;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
.error-display__content {
|
|
55
|
-
display: flex;
|
|
56
|
-
align-items: flex-start;
|
|
57
|
-
gap: 12px;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
.error-display__icon {
|
|
61
|
-
font-size: 20px;
|
|
62
|
-
flex-shrink: 0;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
.error-display__message {
|
|
66
|
-
flex: 1;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
.error-display__text {
|
|
70
|
-
margin: 0 0 8px 0;
|
|
71
|
-
font-weight: 500;
|
|
72
|
-
line-height: 1.4;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
.error-display__correlation {
|
|
76
|
-
margin: 0;
|
|
77
|
-
font-size: 12px;
|
|
78
|
-
opacity: 0.7;
|
|
79
|
-
font-family: monospace;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
.error-display__actions {
|
|
83
|
-
display: flex;
|
|
84
|
-
gap: 8px;
|
|
85
|
-
flex-shrink: 0;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
.error-display__button {
|
|
89
|
-
padding: 6px 12px;
|
|
90
|
-
border: 1px solid;
|
|
91
|
-
border-radius: 4px;
|
|
92
|
-
background: transparent;
|
|
93
|
-
cursor: pointer;
|
|
94
|
-
font-size: 14px;
|
|
95
|
-
font-weight: 500;
|
|
96
|
-
transition: all 0.2s;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
.error-display__button--retry {
|
|
100
|
-
border-color: #3b82f6;
|
|
101
|
-
color: #3b82f6;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
.error-display__button--retry:hover {
|
|
105
|
-
background-color: #3b82f6;
|
|
106
|
-
color: white;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
.error-display__button--dismiss {
|
|
110
|
-
border-color: #6b7280;
|
|
111
|
-
color: #6b7280;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
.error-display__button--dismiss:hover {
|
|
115
|
-
background-color: #6b7280;
|
|
116
|
-
color: white;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/* Error Boundary Styles */
|
|
120
|
-
.error-boundary {
|
|
121
|
-
display: flex;
|
|
122
|
-
align-items: center;
|
|
123
|
-
justify-content: center;
|
|
124
|
-
min-height: 200px;
|
|
125
|
-
padding: 20px;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
.error-boundary-content {
|
|
129
|
-
text-align: center;
|
|
130
|
-
max-width: 500px;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
.error-boundary-content h2 {
|
|
134
|
-
color: #dc2626;
|
|
135
|
-
margin-bottom: 16px;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
.error-boundary-content p {
|
|
139
|
-
color: #6b7280;
|
|
140
|
-
margin-bottom: 20px;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
.error-details {
|
|
144
|
-
text-align: left;
|
|
145
|
-
margin: 16px 0;
|
|
146
|
-
padding: 12px;
|
|
147
|
-
background-color: #f9fafb;
|
|
148
|
-
border-radius: 4px;
|
|
149
|
-
border: 1px solid #e5e7eb;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
.error-details summary {
|
|
153
|
-
cursor: pointer;
|
|
154
|
-
font-weight: 500;
|
|
155
|
-
margin-bottom: 8px;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
.error-details pre {
|
|
159
|
-
font-size: 12px;
|
|
160
|
-
color: #374151;
|
|
161
|
-
white-space: pre-wrap;
|
|
162
|
-
word-break: break-word;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
.error-actions {
|
|
166
|
-
display: flex;
|
|
167
|
-
gap: 12px;
|
|
168
|
-
justify-content: center;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
.retry-button, .reload-button {
|
|
172
|
-
padding: 8px 16px;
|
|
173
|
-
border: 1px solid #3b82f6;
|
|
174
|
-
border-radius: 4px;
|
|
175
|
-
background: #3b82f6;
|
|
176
|
-
color: white;
|
|
177
|
-
cursor: pointer;
|
|
178
|
-
font-weight: 500;
|
|
179
|
-
transition: background-color 0.2s;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
.retry-button:hover, .reload-button:hover {
|
|
183
|
-
background-color: #2563eb;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
.reload-button {
|
|
187
|
-
background: transparent;
|
|
188
|
-
color: #3b82f6;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
.reload-button:hover {
|
|
192
|
-
background-color: #3b82f6;
|
|
193
|
-
color: white;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
/* Toast Container */
|
|
197
|
-
.error-toast-container {
|
|
198
|
-
position: fixed;
|
|
199
|
-
top: 20px;
|
|
200
|
-
right: 20px;
|
|
201
|
-
z-index: 1000;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
/* Inline Error */
|
|
205
|
-
.inline-error {
|
|
206
|
-
display: flex;
|
|
207
|
-
align-items: center;
|
|
208
|
-
gap: 8px;
|
|
209
|
-
padding: 8px 12px;
|
|
210
|
-
background-color: #fef2f2;
|
|
211
|
-
border: 1px solid #fecaca;
|
|
212
|
-
border-radius: 4px;
|
|
213
|
-
color: #dc2626;
|
|
214
|
-
font-size: 14px;
|
|
215
|
-
margin-top: 4px;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
.inline-error__icon {
|
|
219
|
-
font-size: 16px;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
.inline-error__message {
|
|
223
|
-
flex: 1;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
/* Loading Spinner */
|
|
227
|
-
.loading-spinner {
|
|
228
|
-
display: flex;
|
|
229
|
-
flex-direction: column;
|
|
230
|
-
align-items: center;
|
|
231
|
-
justify-content: center;
|
|
232
|
-
padding: 40px;
|
|
233
|
-
gap: 16px;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
.spinner {
|
|
237
|
-
width: 32px;
|
|
238
|
-
height: 32px;
|
|
239
|
-
border: 3px solid #e5e7eb;
|
|
240
|
-
border-top: 3px solid #3b82f6;
|
|
241
|
-
border-radius: 50%;
|
|
242
|
-
animation: spin 1s linear infinite;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
.loading-spinner p {
|
|
246
|
-
color: #6b7280;
|
|
247
|
-
margin: 0;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
/* Error Summary */
|
|
251
|
-
.error-summary {
|
|
252
|
-
background-color: #fef2f2;
|
|
253
|
-
border: 1px solid #fecaca;
|
|
254
|
-
border-radius: 8px;
|
|
255
|
-
padding: 16px;
|
|
256
|
-
margin: 16px 0;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
.error-summary__header {
|
|
260
|
-
display: flex;
|
|
261
|
-
justify-content: space-between;
|
|
262
|
-
align-items: center;
|
|
263
|
-
margin-bottom: 16px;
|
|
264
|
-
padding-bottom: 12px;
|
|
265
|
-
border-bottom: 1px solid #fecaca;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
.error-summary__header h3 {
|
|
269
|
-
margin: 0;
|
|
270
|
-
color: #dc2626;
|
|
271
|
-
font-size: 16px;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
.error-summary__actions {
|
|
275
|
-
display: flex;
|
|
276
|
-
gap: 8px;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
.error-summary__button {
|
|
280
|
-
padding: 4px 8px;
|
|
281
|
-
border: 1px solid #dc2626;
|
|
282
|
-
border-radius: 4px;
|
|
283
|
-
background: transparent;
|
|
284
|
-
color: #dc2626;
|
|
285
|
-
cursor: pointer;
|
|
286
|
-
font-size: 12px;
|
|
287
|
-
font-weight: 500;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
.error-summary__button:hover {
|
|
291
|
-
background-color: #dc2626;
|
|
292
|
-
color: white;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
.error-summary__list {
|
|
296
|
-
display: flex;
|
|
297
|
-
flex-direction: column;
|
|
298
|
-
gap: 8px;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
.error-summary__item {
|
|
302
|
-
padding: 8px;
|
|
303
|
-
background-color: rgba(255, 255, 255, 0.5);
|
|
304
|
-
border-radius: 4px;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
.error-summary__more {
|
|
308
|
-
padding: 8px;
|
|
309
|
-
text-align: center;
|
|
310
|
-
color: #6b7280;
|
|
311
|
-
font-style: italic;
|
|
312
|
-
font-size: 14px;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
/* Animations */
|
|
316
|
-
@keyframes slideIn {
|
|
317
|
-
from {
|
|
318
|
-
transform: translateX(100%);
|
|
319
|
-
opacity: 0;
|
|
320
|
-
}
|
|
321
|
-
to {
|
|
322
|
-
transform: translateX(0);
|
|
323
|
-
opacity: 1;
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
@keyframes spin {
|
|
328
|
-
0% { transform: rotate(0deg); }
|
|
329
|
-
100% { transform: rotate(360deg); }
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
/* Responsive Design */
|
|
333
|
-
@media (max-width: 640px) {
|
|
334
|
-
.error-display--toast {
|
|
335
|
-
top: 10px;
|
|
336
|
-
right: 10px;
|
|
337
|
-
left: 10px;
|
|
338
|
-
max-width: none;
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
.error-display--modal {
|
|
342
|
-
top: 20px;
|
|
343
|
-
left: 10px;
|
|
344
|
-
right: 10px;
|
|
345
|
-
transform: none;
|
|
346
|
-
width: auto;
|
|
347
|
-
max-width: none;
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
.error-display__content {
|
|
351
|
-
flex-direction: column;
|
|
352
|
-
gap: 8px;
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
.error-display__actions {
|
|
356
|
-
justify-content: center;
|
|
357
|
-
width: 100%;
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
.error-summary__header {
|
|
361
|
-
flex-direction: column;
|
|
362
|
-
gap: 12px;
|
|
363
|
-
align-items: stretch;
|
|
364
|
-
}
|
|
365
|
-
}
|
|
@@ -1,258 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { ClientAPIError } from '../lib/errors'
|
|
3
|
-
import { getErrorMessage, isRetryableError } from '../lib/eden-api'
|
|
4
|
-
|
|
5
|
-
interface ErrorDisplayProps {
|
|
6
|
-
error: Error | null
|
|
7
|
-
onRetry?: () => void
|
|
8
|
-
onDismiss?: () => void
|
|
9
|
-
showRetryButton?: boolean
|
|
10
|
-
showDismissButton?: boolean
|
|
11
|
-
className?: string
|
|
12
|
-
variant?: 'inline' | 'toast' | 'modal'
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function ErrorDisplay({
|
|
16
|
-
error,
|
|
17
|
-
onRetry,
|
|
18
|
-
onDismiss,
|
|
19
|
-
showRetryButton = true,
|
|
20
|
-
showDismissButton = true,
|
|
21
|
-
className = '',
|
|
22
|
-
variant = 'inline'
|
|
23
|
-
}: ErrorDisplayProps) {
|
|
24
|
-
if (!error) return null
|
|
25
|
-
|
|
26
|
-
const errorMessage = getErrorMessage(error)
|
|
27
|
-
const canRetry = isRetryableError(error)
|
|
28
|
-
const isClientError = error instanceof ClientAPIError
|
|
29
|
-
|
|
30
|
-
const baseClasses = {
|
|
31
|
-
inline: 'error-display error-display--inline',
|
|
32
|
-
toast: 'error-display error-display--toast',
|
|
33
|
-
modal: 'error-display error-display--modal'
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const severityClass = isClientError && error.statusCode >= 500
|
|
37
|
-
? 'error-display--severe'
|
|
38
|
-
: 'error-display--warning'
|
|
39
|
-
|
|
40
|
-
return (
|
|
41
|
-
<div className={`${baseClasses[variant]} ${severityClass} ${className}`}>
|
|
42
|
-
<div className="error-display__content">
|
|
43
|
-
<div className="error-display__icon">
|
|
44
|
-
{isClientError && error.statusCode >= 500 ? '⚠️' : '❌'}
|
|
45
|
-
</div>
|
|
46
|
-
|
|
47
|
-
<div className="error-display__message">
|
|
48
|
-
<p className="error-display__text">{errorMessage}</p>
|
|
49
|
-
|
|
50
|
-
{isClientError && error.correlationId && (
|
|
51
|
-
<p className="error-display__correlation">
|
|
52
|
-
Reference ID: {error.correlationId}
|
|
53
|
-
</p>
|
|
54
|
-
)}
|
|
55
|
-
</div>
|
|
56
|
-
|
|
57
|
-
<div className="error-display__actions">
|
|
58
|
-
{showRetryButton && canRetry && onRetry && (
|
|
59
|
-
<button
|
|
60
|
-
onClick={onRetry}
|
|
61
|
-
className="error-display__button error-display__button--retry"
|
|
62
|
-
>
|
|
63
|
-
Try Again
|
|
64
|
-
</button>
|
|
65
|
-
)}
|
|
66
|
-
|
|
67
|
-
{showDismissButton && onDismiss && (
|
|
68
|
-
<button
|
|
69
|
-
onClick={onDismiss}
|
|
70
|
-
className="error-display__button error-display__button--dismiss"
|
|
71
|
-
>
|
|
72
|
-
Dismiss
|
|
73
|
-
</button>
|
|
74
|
-
)}
|
|
75
|
-
</div>
|
|
76
|
-
</div>
|
|
77
|
-
</div>
|
|
78
|
-
)
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// Toast notification component for errors
|
|
82
|
-
interface ErrorToastProps {
|
|
83
|
-
error: Error | null
|
|
84
|
-
onRetry?: () => void
|
|
85
|
-
onDismiss?: () => void
|
|
86
|
-
autoHide?: boolean
|
|
87
|
-
hideDelay?: number
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export function ErrorToast({
|
|
91
|
-
error,
|
|
92
|
-
onRetry,
|
|
93
|
-
onDismiss,
|
|
94
|
-
autoHide = true,
|
|
95
|
-
hideDelay = 5000
|
|
96
|
-
}: ErrorToastProps) {
|
|
97
|
-
const [isVisible, setIsVisible] = React.useState(!!error)
|
|
98
|
-
|
|
99
|
-
React.useEffect(() => {
|
|
100
|
-
if (error) {
|
|
101
|
-
setIsVisible(true)
|
|
102
|
-
|
|
103
|
-
if (autoHide && !isRetryableError(error)) {
|
|
104
|
-
const timer = setTimeout(() => {
|
|
105
|
-
setIsVisible(false)
|
|
106
|
-
onDismiss?.()
|
|
107
|
-
}, hideDelay)
|
|
108
|
-
|
|
109
|
-
return () => clearTimeout(timer)
|
|
110
|
-
}
|
|
111
|
-
} else {
|
|
112
|
-
setIsVisible(false)
|
|
113
|
-
}
|
|
114
|
-
}, [error, autoHide, hideDelay, onDismiss])
|
|
115
|
-
|
|
116
|
-
if (!isVisible || !error) return null
|
|
117
|
-
|
|
118
|
-
return (
|
|
119
|
-
<div className="error-toast-container">
|
|
120
|
-
<ErrorDisplay
|
|
121
|
-
error={error}
|
|
122
|
-
onRetry={onRetry}
|
|
123
|
-
onDismiss={() => {
|
|
124
|
-
setIsVisible(false)
|
|
125
|
-
onDismiss?.()
|
|
126
|
-
}}
|
|
127
|
-
variant="toast"
|
|
128
|
-
showDismissButton={true}
|
|
129
|
-
/>
|
|
130
|
-
</div>
|
|
131
|
-
)
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
// Inline error component for forms
|
|
135
|
-
interface InlineErrorProps {
|
|
136
|
-
error: Error | null
|
|
137
|
-
field?: string
|
|
138
|
-
className?: string
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
export function InlineError({ error, field, className = '' }: InlineErrorProps) {
|
|
142
|
-
if (!error) return null
|
|
143
|
-
|
|
144
|
-
// Check if error is related to specific field
|
|
145
|
-
const isFieldError = error instanceof ClientAPIError &&
|
|
146
|
-
error.details?.field === field
|
|
147
|
-
|
|
148
|
-
if (field && !isFieldError) return null
|
|
149
|
-
|
|
150
|
-
const errorMessage = getErrorMessage(error)
|
|
151
|
-
|
|
152
|
-
return (
|
|
153
|
-
<div className={`inline-error ${className}`}>
|
|
154
|
-
<span className="inline-error__icon">⚠️</span>
|
|
155
|
-
<span className="inline-error__message">{errorMessage}</span>
|
|
156
|
-
</div>
|
|
157
|
-
)
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
// Loading state with error fallback
|
|
161
|
-
interface LoadingWithErrorProps {
|
|
162
|
-
loading: boolean
|
|
163
|
-
error: Error | null
|
|
164
|
-
onRetry?: () => void
|
|
165
|
-
children: React.ReactNode
|
|
166
|
-
loadingComponent?: React.ReactNode
|
|
167
|
-
errorComponent?: React.ReactNode
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
export function LoadingWithError({
|
|
171
|
-
loading,
|
|
172
|
-
error,
|
|
173
|
-
onRetry,
|
|
174
|
-
children,
|
|
175
|
-
loadingComponent,
|
|
176
|
-
errorComponent
|
|
177
|
-
}: LoadingWithErrorProps) {
|
|
178
|
-
if (loading) {
|
|
179
|
-
return loadingComponent || (
|
|
180
|
-
<div className="loading-spinner">
|
|
181
|
-
<div className="spinner"></div>
|
|
182
|
-
<p>Loading...</p>
|
|
183
|
-
</div>
|
|
184
|
-
)
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
if (error) {
|
|
188
|
-
return errorComponent || (
|
|
189
|
-
<ErrorDisplay
|
|
190
|
-
error={error}
|
|
191
|
-
onRetry={onRetry}
|
|
192
|
-
variant="inline"
|
|
193
|
-
/>
|
|
194
|
-
)
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
return <>{children}</>
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
// Error summary component for multiple errors
|
|
201
|
-
interface ErrorSummaryProps {
|
|
202
|
-
errors: Error[]
|
|
203
|
-
onRetryAll?: () => void
|
|
204
|
-
onDismissAll?: () => void
|
|
205
|
-
maxVisible?: number
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
export function ErrorSummary({
|
|
209
|
-
errors,
|
|
210
|
-
onRetryAll,
|
|
211
|
-
onDismissAll,
|
|
212
|
-
maxVisible = 3
|
|
213
|
-
}: ErrorSummaryProps) {
|
|
214
|
-
if (errors.length === 0) return null
|
|
215
|
-
|
|
216
|
-
const visibleErrors = errors.slice(0, maxVisible)
|
|
217
|
-
const hiddenCount = errors.length - maxVisible
|
|
218
|
-
|
|
219
|
-
return (
|
|
220
|
-
<div className="error-summary">
|
|
221
|
-
<div className="error-summary__header">
|
|
222
|
-
<h3>Multiple Errors Occurred ({errors.length})</h3>
|
|
223
|
-
|
|
224
|
-
<div className="error-summary__actions">
|
|
225
|
-
{onRetryAll && (
|
|
226
|
-
<button onClick={onRetryAll} className="error-summary__button">
|
|
227
|
-
Retry All
|
|
228
|
-
</button>
|
|
229
|
-
)}
|
|
230
|
-
{onDismissAll && (
|
|
231
|
-
<button onClick={onDismissAll} className="error-summary__button">
|
|
232
|
-
Dismiss All
|
|
233
|
-
</button>
|
|
234
|
-
)}
|
|
235
|
-
</div>
|
|
236
|
-
</div>
|
|
237
|
-
|
|
238
|
-
<div className="error-summary__list">
|
|
239
|
-
{visibleErrors.map((error, index) => (
|
|
240
|
-
<div key={index} className="error-summary__item">
|
|
241
|
-
<ErrorDisplay
|
|
242
|
-
error={error}
|
|
243
|
-
variant="inline"
|
|
244
|
-
showRetryButton={false}
|
|
245
|
-
showDismissButton={false}
|
|
246
|
-
/>
|
|
247
|
-
</div>
|
|
248
|
-
))}
|
|
249
|
-
|
|
250
|
-
{hiddenCount > 0 && (
|
|
251
|
-
<div className="error-summary__more">
|
|
252
|
-
+{hiddenCount} more errors
|
|
253
|
-
</div>
|
|
254
|
-
)}
|
|
255
|
-
</div>
|
|
256
|
-
</div>
|
|
257
|
-
)
|
|
258
|
-
}
|