create-fluxstack 1.0.12 → 1.0.14
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/.env.example +29 -29
- package/app/client/README.md +69 -69
- package/app/client/index.html +14 -13
- package/app/client/src/App.tsx +157 -524
- package/app/client/src/components/ErrorBoundary.tsx +107 -0
- package/app/client/src/components/ErrorDisplay.css +365 -0
- package/app/client/src/components/ErrorDisplay.tsx +258 -0
- package/app/client/src/components/FluxStackConfig.tsx +1321 -0
- package/app/client/src/components/HybridLiveCounter.tsx +140 -0
- package/app/client/src/components/LiveClock.tsx +286 -0
- package/app/client/src/components/MainLayout.tsx +390 -0
- package/app/client/src/components/SidebarNavigation.tsx +391 -0
- package/app/client/src/components/StateDemo.tsx +178 -0
- package/app/client/src/components/SystemMonitor.tsx +1038 -0
- package/app/client/src/components/Teste.tsx +104 -0
- package/app/client/src/components/UserProfile.tsx +809 -0
- package/app/client/src/hooks/useAuth.ts +39 -0
- package/app/client/src/hooks/useNotifications.ts +56 -0
- package/app/client/src/lib/eden-api.ts +189 -53
- package/app/client/src/lib/errors.ts +340 -0
- package/app/client/src/lib/hooks/useErrorHandler.ts +258 -0
- package/app/client/src/lib/index.ts +45 -0
- package/app/client/src/main.tsx +3 -2
- package/app/client/src/pages/ApiDocs.tsx +182 -0
- package/app/client/src/pages/Demo.tsx +174 -0
- package/app/client/src/pages/HybridLive.tsx +263 -0
- package/app/client/src/pages/Overview.tsx +155 -0
- package/app/client/src/store/README.md +43 -0
- package/app/client/src/store/index.ts +16 -0
- package/app/client/src/store/slices/uiSlice.ts +151 -0
- package/app/client/src/store/slices/userSlice.ts +161 -0
- package/app/client/src/test/README.md +257 -0
- package/app/client/src/test/setup.ts +70 -0
- package/app/client/src/test/types.ts +12 -0
- package/app/client/src/vite-env.d.ts +1 -1
- package/app/client/tsconfig.app.json +44 -43
- package/app/client/tsconfig.json +7 -7
- package/app/client/tsconfig.node.json +25 -25
- package/app/client/zustand-setup.md +65 -0
- package/app/server/controllers/users.controller.ts +68 -68
- package/app/server/index.ts +9 -1
- package/app/server/live/CounterComponent.ts +191 -0
- package/app/server/live/FluxStackConfig.ts +529 -0
- package/app/server/live/LiveClockComponent.ts +214 -0
- package/app/server/live/SidebarNavigation.ts +156 -0
- package/app/server/live/SystemMonitor.ts +594 -0
- package/app/server/live/SystemMonitorIntegration.ts +151 -0
- package/app/server/live/TesteComponent.ts +87 -0
- package/app/server/live/UserProfileComponent.ts +135 -0
- package/app/server/live/register-components.ts +28 -0
- package/app/server/middleware/auth.ts +136 -0
- package/app/server/middleware/errorHandling.ts +250 -0
- package/app/server/middleware/index.ts +10 -0
- package/app/server/middleware/rateLimit.ts +193 -0
- package/app/server/middleware/requestLogging.ts +215 -0
- package/app/server/middleware/validation.ts +270 -0
- package/app/server/routes/index.ts +14 -2
- package/app/server/routes/upload.ts +92 -0
- package/app/server/routes/users.routes.ts +2 -9
- package/app/server/services/NotificationService.ts +302 -0
- package/app/server/services/UserService.ts +222 -0
- package/app/server/services/index.ts +46 -0
- package/core/cli/commands/plugin-deps.ts +263 -0
- package/core/cli/generators/README.md +339 -0
- package/core/cli/generators/component.ts +770 -0
- package/core/cli/generators/controller.ts +299 -0
- package/core/cli/generators/index.ts +144 -0
- package/core/cli/generators/interactive.ts +228 -0
- package/core/cli/generators/prompts.ts +83 -0
- package/core/cli/generators/route.ts +513 -0
- package/core/cli/generators/service.ts +465 -0
- package/core/cli/generators/template-engine.ts +154 -0
- package/core/cli/generators/types.ts +71 -0
- package/core/cli/generators/utils.ts +192 -0
- package/core/cli/index.ts +69 -0
- package/core/cli/plugin-discovery.ts +16 -85
- package/core/client/fluxstack.ts +17 -0
- package/core/client/hooks/index.ts +7 -0
- package/core/client/hooks/state-validator.ts +130 -0
- package/core/client/hooks/useAuth.ts +49 -0
- package/core/client/hooks/useChunkedUpload.ts +258 -0
- package/core/client/hooks/useHybridLiveComponent.ts +967 -0
- package/core/client/hooks/useWebSocket.ts +373 -0
- package/core/client/index.ts +47 -0
- package/core/client/state/createStore.ts +193 -0
- package/core/client/state/index.ts +15 -0
- package/core/config/env-dynamic.ts +1 -1
- package/core/config/env.ts +2 -1
- package/core/config/loader.ts +8 -32
- package/core/config/runtime-config.ts +3 -3
- package/core/config/schema.ts +84 -49
- package/core/framework/server.ts +30 -0
- package/core/index.ts +25 -0
- package/core/live/ComponentRegistry.ts +399 -0
- package/core/live/types.ts +164 -0
- package/core/plugins/built-in/live-components/commands/create-live-component.ts +1201 -0
- package/core/plugins/built-in/live-components/index.ts +27 -0
- package/core/plugins/built-in/logger/index.ts +1 -1
- package/core/plugins/built-in/monitoring/index.ts +1 -1
- package/core/plugins/built-in/static/index.ts +1 -1
- package/core/plugins/built-in/swagger/index.ts +1 -1
- package/core/plugins/built-in/vite/index.ts +1 -1
- package/core/plugins/dependency-manager.ts +384 -0
- package/core/plugins/index.ts +5 -1
- package/core/plugins/manager.ts +7 -3
- package/core/plugins/registry.ts +88 -10
- package/core/plugins/types.ts +11 -11
- package/core/server/framework.ts +43 -0
- package/core/server/index.ts +11 -1
- package/core/server/live/ComponentRegistry.ts +1017 -0
- package/core/server/live/FileUploadManager.ts +272 -0
- package/core/server/live/LiveComponentPerformanceMonitor.ts +930 -0
- package/core/server/live/SingleConnectionManager.ts +0 -0
- package/core/server/live/StateSignature.ts +644 -0
- package/core/server/live/WebSocketConnectionManager.ts +688 -0
- package/core/server/live/websocket-plugin.ts +435 -0
- package/core/server/middleware/errorHandling.ts +141 -0
- package/core/server/middleware/index.ts +16 -0
- package/core/server/plugins/static-files-plugin.ts +232 -0
- package/core/server/services/BaseService.ts +95 -0
- package/core/server/services/ServiceContainer.ts +144 -0
- package/core/server/services/index.ts +9 -0
- package/core/templates/create-project.ts +46 -2
- package/core/testing/index.ts +10 -0
- package/core/testing/setup.ts +74 -0
- package/core/types/build.ts +38 -14
- package/core/types/types.ts +319 -0
- package/core/utils/env-runtime.ts +7 -0
- package/core/utils/errors/handlers.ts +264 -39
- package/core/utils/errors/index.ts +528 -18
- package/core/utils/errors/middleware.ts +114 -0
- package/core/utils/logger/formatters.ts +222 -0
- package/core/utils/logger/index.ts +167 -48
- package/core/utils/logger/middleware.ts +253 -0
- package/core/utils/logger/performance.ts +384 -0
- package/core/utils/logger/transports.ts +365 -0
- package/create-fluxstack.ts +296 -296
- package/fluxstack.config.ts +17 -1
- package/package-template.json +66 -66
- package/package.json +31 -6
- package/public/README.md +16 -0
- package/vite.config.ts +29 -14
- package/.claude/settings.local.json +0 -74
- package/.github/workflows/ci-build-tests.yml +0 -480
- package/.github/workflows/dependency-management.yml +0 -324
- package/.github/workflows/release-validation.yml +0 -355
- package/.kiro/specs/fluxstack-architecture-optimization/design.md +0 -700
- package/.kiro/specs/fluxstack-architecture-optimization/requirements.md +0 -127
- package/.kiro/specs/fluxstack-architecture-optimization/tasks.md +0 -330
- package/CLAUDE.md +0 -200
- package/Dockerfile +0 -58
- package/Dockerfile.backend +0 -52
- package/Dockerfile.frontend +0 -54
- package/README-Docker.md +0 -85
- package/ai-context/00-QUICK-START.md +0 -86
- package/ai-context/README.md +0 -88
- package/ai-context/development/eden-treaty-guide.md +0 -362
- package/ai-context/development/patterns.md +0 -382
- package/ai-context/development/plugins-guide.md +0 -572
- package/ai-context/examples/crud-complete.md +0 -626
- package/ai-context/project/architecture.md +0 -399
- package/ai-context/project/overview.md +0 -213
- package/ai-context/recent-changes/eden-treaty-refactor.md +0 -281
- package/ai-context/recent-changes/type-inference-fix.md +0 -223
- package/ai-context/reference/environment-vars.md +0 -384
- package/ai-context/reference/troubleshooting.md +0 -407
- package/app/client/src/components/TestPage.tsx +0 -453
- package/bun.lock +0 -1063
- package/bunfig.toml +0 -16
- package/core/__tests__/integration.test.ts +0 -227
- package/core/build/index.ts +0 -186
- package/core/config/__tests__/config-loader.test.ts +0 -591
- package/core/config/__tests__/config-merger.test.ts +0 -657
- package/core/config/__tests__/env-converter.test.ts +0 -372
- package/core/config/__tests__/env-processor.test.ts +0 -431
- package/core/config/__tests__/env.test.ts +0 -452
- package/core/config/__tests__/integration.test.ts +0 -418
- package/core/config/__tests__/loader.test.ts +0 -331
- package/core/config/__tests__/schema.test.ts +0 -129
- package/core/config/__tests__/validator.test.ts +0 -318
- package/core/framework/__tests__/server.test.ts +0 -233
- package/core/plugins/__tests__/built-in.test.ts.disabled +0 -366
- package/core/plugins/__tests__/manager.test.ts +0 -398
- package/core/plugins/__tests__/monitoring.test.ts +0 -401
- package/core/plugins/__tests__/registry.test.ts +0 -335
- package/core/utils/__tests__/errors.test.ts +0 -139
- package/core/utils/__tests__/helpers.test.ts +0 -297
- package/core/utils/__tests__/logger.test.ts +0 -141
- package/create-test-app.ts +0 -156
- package/docker-compose.microservices.yml +0 -75
- package/docker-compose.simple.yml +0 -57
- package/docker-compose.yml +0 -71
- package/eslint.config.js +0 -23
- package/flux-cli.ts +0 -214
- package/nginx-lb.conf +0 -37
- package/publish.sh +0 -63
- package/run-clean.ts +0 -26
- package/run-env-tests.ts +0 -313
- package/tailwind.config.js +0 -34
- package/tests/__mocks__/api.ts +0 -56
- package/tests/fixtures/users.ts +0 -69
- package/tests/integration/api/users.routes.test.ts +0 -221
- package/tests/setup.ts +0 -29
- package/tests/unit/app/client/App-simple.test.tsx +0 -56
- package/tests/unit/app/client/App.test.tsx.skip +0 -237
- package/tests/unit/app/client/eden-api.test.ts +0 -186
- package/tests/unit/app/client/simple.test.tsx +0 -23
- package/tests/unit/app/controllers/users.controller.test.ts +0 -150
- package/tests/unit/core/create-project.test.ts.skip +0 -95
- package/tests/unit/core/framework.test.ts +0 -144
- package/tests/unit/core/plugins/logger.test.ts.skip +0 -268
- package/tests/unit/core/plugins/vite.test.ts.disabled +0 -188
- package/tests/utils/test-helpers.ts +0 -61
- package/vitest.config.ts +0 -50
- package/workspace.json +0 -6
|
@@ -0,0 +1,107 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,365 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,258 @@
|
|
|
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
|
+
}
|