@manojkmfsi/monodog 1.1.38 → 1.1.39
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/CHANGELOG.md +6 -0
- package/monodog-dashboard/dist/assets/index-C08ciT3A.js +20 -0
- package/monodog-dashboard/dist/assets/index-C08ciT3A.js.map +1 -0
- package/monodog-dashboard/dist/assets/index-Dc2vaUOq.css +1 -0
- package/monodog-dashboard/{index.html → dist/index.html} +2 -1
- package/package.json +2 -2
- package/monodog-dashboard/THEME_SYSTEM.md +0 -309
- package/monodog-dashboard/__tests__/AuthCallbackPage.test.ts +0 -138
- package/monodog-dashboard/__tests__/ConfigInspector.test.ts +0 -33
- package/monodog-dashboard/__tests__/DependencyGraph.test.ts +0 -72
- package/monodog-dashboard/__tests__/HealthStatus.test.ts +0 -69
- package/monodog-dashboard/__tests__/LoginPage.test.ts +0 -79
- package/monodog-dashboard/__tests__/PackageDetail.test.ts +0 -22
- package/monodog-dashboard/__tests__/ReleaseManager.test.tsx +0 -510
- package/monodog-dashboard/__tests__/api-client.test.ts +0 -475
- package/monodog-dashboard/__tests__/components.test.ts +0 -117
- package/monodog-dashboard/__tests__/dashboard.utils.test.ts +0 -144
- package/monodog-dashboard/__tests__/dependency.utils.test.ts +0 -125
- package/monodog-dashboard/__tests__/monorepoService.unit.test.ts +0 -103
- package/monodog-dashboard/__tests__/packages.utils.test.ts +0 -37
- package/monodog-dashboard/__tests__/pages.test.ts +0 -103
- package/monodog-dashboard/package-lock.json +0 -4587
- package/monodog-dashboard/postcss.config.js +0 -6
- package/monodog-dashboard/src/components/App.tsx +0 -36
- package/monodog-dashboard/src/components/LoadingState.tsx +0 -18
- package/monodog-dashboard/src/components/PermissionGuard.tsx +0 -92
- package/monodog-dashboard/src/components/ProtectedRoute.tsx +0 -24
- package/monodog-dashboard/src/components/configuration/Configuration.tsx +0 -91
- package/monodog-dashboard/src/components/configuration/components/BrandingSettings.tsx +0 -128
- package/monodog-dashboard/src/components/configuration/components/ConfigurationHeader.tsx +0 -34
- package/monodog-dashboard/src/components/configuration/components/ConfigurationModal.tsx +0 -20
- package/monodog-dashboard/src/components/configuration/components/ConfigurationTabs.tsx +0 -30
- package/monodog-dashboard/src/components/configuration/components/FeatureToggles.tsx +0 -66
- package/monodog-dashboard/src/components/configuration/components/GeneralSettings.tsx +0 -77
- package/monodog-dashboard/src/components/configuration/components/MonorepoSettings.tsx +0 -179
- package/monodog-dashboard/src/components/configuration/components/index.ts +0 -8
- package/monodog-dashboard/src/components/configuration/types/config.types.ts +0 -52
- package/monodog-dashboard/src/components/configuration/utils/config.utils.tsx +0 -115
- package/monodog-dashboard/src/components/main-dashboard/Dashboard.tsx +0 -242
- package/monodog-dashboard/src/components/main-dashboard/Layout.tsx +0 -112
- package/monodog-dashboard/src/components/main-dashboard/components/Header.tsx +0 -47
- package/monodog-dashboard/src/components/main-dashboard/components/PackageDistribution.tsx +0 -35
- package/monodog-dashboard/src/components/main-dashboard/components/PackageSearchFilter.tsx +0 -47
- package/monodog-dashboard/src/components/main-dashboard/components/PackageTable.tsx +0 -87
- package/monodog-dashboard/src/components/main-dashboard/components/QuickActions.tsx +0 -60
- package/monodog-dashboard/src/components/main-dashboard/components/StatsCards.tsx +0 -73
- package/monodog-dashboard/src/components/main-dashboard/components/index.ts +0 -7
- package/monodog-dashboard/src/components/main-dashboard/types/dashboard.types.ts +0 -33
- package/monodog-dashboard/src/components/main-dashboard/utils/dashboard.utils.tsx +0 -70
- package/monodog-dashboard/src/components/modules/ci-integration/CIIntegration.tsx +0 -277
- package/monodog-dashboard/src/components/modules/ci-integration/components/BuildDetails.tsx +0 -228
- package/monodog-dashboard/src/components/modules/ci-integration/components/BuildList.tsx +0 -212
- package/monodog-dashboard/src/components/modules/ci-integration/components/BuildOverview.tsx +0 -158
- package/monodog-dashboard/src/components/modules/ci-integration/components/CIIntegrationHeader.tsx +0 -38
- package/monodog-dashboard/src/components/modules/ci-integration/components/ErrorState.tsx +0 -25
- package/monodog-dashboard/src/components/modules/ci-integration/components/LoadingState.tsx +0 -16
- package/monodog-dashboard/src/components/modules/ci-integration/components/PipelineStatus.tsx +0 -223
- package/monodog-dashboard/src/components/modules/ci-integration/components/index.ts +0 -8
- package/monodog-dashboard/src/components/modules/ci-integration/types/ci.types.ts +0 -97
- package/monodog-dashboard/src/components/modules/ci-integration/utils/ci.utils.tsx +0 -264
- package/monodog-dashboard/src/components/modules/config-inspector/ConfigInspector.tsx +0 -324
- package/monodog-dashboard/src/components/modules/config-inspector/components/ConfigEditor.tsx +0 -93
- package/monodog-dashboard/src/components/modules/config-inspector/components/ConfigInspectorHeader.tsx +0 -36
- package/monodog-dashboard/src/components/modules/config-inspector/components/ConfigPreview.tsx +0 -89
- package/monodog-dashboard/src/components/modules/config-inspector/components/ConfigSidebar.tsx +0 -141
- package/monodog-dashboard/src/components/modules/config-inspector/components/ConfigToolbar.tsx +0 -184
- package/monodog-dashboard/src/components/modules/config-inspector/components/ErrorState.tsx +0 -25
- package/monodog-dashboard/src/components/modules/config-inspector/components/LoadingState.tsx +0 -16
- package/monodog-dashboard/src/components/modules/config-inspector/components/ValidationPanel.tsx +0 -155
- package/monodog-dashboard/src/components/modules/config-inspector/components/index.ts +0 -9
- package/monodog-dashboard/src/components/modules/config-inspector/types/config.types.ts +0 -100
- package/monodog-dashboard/src/components/modules/config-inspector/utils/config.utils.tsx +0 -704
- package/monodog-dashboard/src/components/modules/dependency-graph/DependencyGraph.tsx +0 -224
- package/monodog-dashboard/src/components/modules/dependency-graph/components/CircularDependencies.tsx +0 -177
- package/monodog-dashboard/src/components/modules/dependency-graph/components/DependencyDetails.tsx +0 -192
- package/monodog-dashboard/src/components/modules/dependency-graph/components/DependencyGraphHeader.tsx +0 -30
- package/monodog-dashboard/src/components/modules/dependency-graph/components/DependencyList.tsx +0 -177
- package/monodog-dashboard/src/components/modules/dependency-graph/components/ErrorState.tsx +0 -25
- package/monodog-dashboard/src/components/modules/dependency-graph/components/GraphLegend.tsx +0 -89
- package/monodog-dashboard/src/components/modules/dependency-graph/components/GraphStats.tsx +0 -141
- package/monodog-dashboard/src/components/modules/dependency-graph/components/GraphToolbar.tsx +0 -107
- package/monodog-dashboard/src/components/modules/dependency-graph/components/GraphVisualization.tsx +0 -179
- package/monodog-dashboard/src/components/modules/dependency-graph/components/LoadingState.tsx +0 -16
- package/monodog-dashboard/src/components/modules/dependency-graph/components/index.ts +0 -11
- package/monodog-dashboard/src/components/modules/dependency-graph/types/dependency.types.ts +0 -105
- package/monodog-dashboard/src/components/modules/dependency-graph/utils/dependency.utils.tsx +0 -433
- package/monodog-dashboard/src/components/modules/health-status/HealthStatus.tsx +0 -739
- package/monodog-dashboard/src/components/modules/health-status/components/ErrorState.tsx +0 -25
- package/monodog-dashboard/src/components/modules/health-status/components/HealthActions.tsx +0 -122
- package/monodog-dashboard/src/components/modules/health-status/components/HealthAlerts.tsx +0 -151
- package/monodog-dashboard/src/components/modules/health-status/components/HealthMetrics.tsx +0 -132
- package/monodog-dashboard/src/components/modules/health-status/components/HealthStatusHeader.tsx +0 -30
- package/monodog-dashboard/src/components/modules/health-status/components/LoadingState.tsx +0 -16
- package/monodog-dashboard/src/components/modules/health-status/components/OverallHealthScore.tsx +0 -122
- package/monodog-dashboard/src/components/modules/health-status/components/PackageHealthList.tsx +0 -195
- package/monodog-dashboard/src/components/modules/health-status/types/health.types.ts +0 -80
- package/monodog-dashboard/src/components/modules/health-status/utils/health.utils.tsx +0 -220
- package/monodog-dashboard/src/components/modules/packages/PackageDetail.tsx +0 -255
- package/monodog-dashboard/src/components/modules/packages/PackagesOverview.tsx +0 -166
- package/monodog-dashboard/src/components/modules/packages/components/ConfigurationTab.tsx +0 -311
- package/monodog-dashboard/src/components/modules/packages/components/DependenciesTab.tsx +0 -154
- package/monodog-dashboard/src/components/modules/packages/components/ErrorState.tsx +0 -21
- package/monodog-dashboard/src/components/modules/packages/components/HealthMetricsTab.tsx +0 -275
- package/monodog-dashboard/src/components/modules/packages/components/LoadingState.tsx +0 -14
- package/monodog-dashboard/src/components/modules/packages/components/PackageDetailHeader.tsx +0 -167
- package/monodog-dashboard/src/components/modules/packages/components/PackageDetailTabs.tsx +0 -49
- package/monodog-dashboard/src/components/modules/packages/components/PackageStats.tsx +0 -70
- package/monodog-dashboard/src/components/modules/packages/components/PackagesTable.tsx +0 -163
- package/monodog-dashboard/src/components/modules/packages/components/RecentCommitsTab.tsx +0 -90
- package/monodog-dashboard/src/components/modules/packages/components/SearchAndFilter.tsx +0 -66
- package/monodog-dashboard/src/components/modules/packages/components/index.ts +0 -12
- package/monodog-dashboard/src/components/modules/packages/types/packages.types.ts +0 -101
- package/monodog-dashboard/src/components/modules/packages/utils/packages.utils.tsx +0 -178
- package/monodog-dashboard/src/components/pipeline/JobsList.tsx +0 -83
- package/monodog-dashboard/src/components/pipeline/LogViewer.tsx +0 -392
- package/monodog-dashboard/src/components/pipeline/PipelineManager.tsx +0 -562
- package/monodog-dashboard/src/components/pipeline/WorkflowRunsList.tsx +0 -272
- package/monodog-dashboard/src/components/pipeline/WorkflowTrigger.tsx +0 -182
- package/monodog-dashboard/src/components/pipeline/utils/pipeline.utils.tsx +0 -11
- package/monodog-dashboard/src/components/publish-control/PublishControl.tsx +0 -229
- package/monodog-dashboard/src/components/publish-control/components/ChangelogViewer.tsx +0 -103
- package/monodog-dashboard/src/components/publish-control/components/ErrorState.tsx +0 -23
- package/monodog-dashboard/src/components/publish-control/components/LoadingState.tsx +0 -10
- package/monodog-dashboard/src/components/publish-control/components/PackageReleaseTable.tsx +0 -140
- package/monodog-dashboard/src/components/publish-control/components/PublishHeader.tsx +0 -30
- package/monodog-dashboard/src/components/publish-control/components/QuickActionCards.tsx +0 -56
- package/monodog-dashboard/src/components/publish-control/components/ReleaseSchedule.tsx +0 -104
- package/monodog-dashboard/src/components/publish-control/components/index.ts +0 -8
- package/monodog-dashboard/src/components/publish-control/types/publish.types.ts +0 -39
- package/monodog-dashboard/src/components/publish-control/utils/publish.utils.ts +0 -59
- package/monodog-dashboard/src/components/release-manager/ReleaseManager.tsx +0 -342
- package/monodog-dashboard/src/components/release-manager/components/ChangesetPreview.tsx +0 -123
- package/monodog-dashboard/src/components/release-manager/components/ErrorState.tsx +0 -38
- package/monodog-dashboard/src/components/release-manager/components/LoadingState.tsx +0 -18
- package/monodog-dashboard/src/components/release-manager/components/PackageSelector.tsx +0 -137
- package/monodog-dashboard/src/components/release-manager/components/PublishConfirmation.tsx +0 -150
- package/monodog-dashboard/src/components/release-manager/components/ReleaseValidation.tsx +0 -138
- package/monodog-dashboard/src/components/release-manager/components/VersionBumpSelector.tsx +0 -142
- package/monodog-dashboard/src/components/release-manager/types/index.ts +0 -9
- package/monodog-dashboard/src/components/release-manager/types/release-manager.types.ts +0 -29
- package/monodog-dashboard/src/components/setup-guide/SetupGuide.tsx +0 -96
- package/monodog-dashboard/src/components/setup-guide/components/SetupHeader.tsx +0 -24
- package/monodog-dashboard/src/components/setup-guide/components/SetupModal.tsx +0 -24
- package/monodog-dashboard/src/components/setup-guide/components/SetupProgress.tsx +0 -29
- package/monodog-dashboard/src/components/setup-guide/components/StepContent.tsx +0 -272
- package/monodog-dashboard/src/components/setup-guide/components/StepNavigation.tsx +0 -62
- package/monodog-dashboard/src/components/setup-guide/components/index.ts +0 -6
- package/monodog-dashboard/src/components/setup-guide/types/setup.types.ts +0 -38
- package/monodog-dashboard/src/components/setup-guide/utils/setup.utils.ts +0 -79
- package/monodog-dashboard/src/constants/api-config.ts +0 -81
- package/monodog-dashboard/src/constants/index.ts +0 -9
- package/monodog-dashboard/src/constants/messages.ts +0 -40
- package/monodog-dashboard/src/icons/heroicons.ts +0 -65
- package/monodog-dashboard/src/icons/index.tsx +0 -1788
- package/monodog-dashboard/src/index.css +0 -175
- package/monodog-dashboard/src/main.tsx +0 -9
- package/monodog-dashboard/src/pages/AuthCallbackPage.tsx +0 -103
- package/monodog-dashboard/src/pages/CIPage.tsx +0 -6
- package/monodog-dashboard/src/pages/ConfigPage.tsx +0 -6
- package/monodog-dashboard/src/pages/DashboardPage.tsx +0 -6
- package/monodog-dashboard/src/pages/DependenciesPage.tsx +0 -6
- package/monodog-dashboard/src/pages/HealthPage.tsx +0 -6
- package/monodog-dashboard/src/pages/LoginPage.tsx +0 -77
- package/monodog-dashboard/src/pages/PackageDetailPage.tsx +0 -6
- package/monodog-dashboard/src/pages/PackagesPage.tsx +0 -6
- package/monodog-dashboard/src/pages/PipelinePage.tsx +0 -22
- package/monodog-dashboard/src/pages/PublishPage.tsx +0 -6
- package/monodog-dashboard/src/pages/ReleaseManagerPage.tsx +0 -9
- package/monodog-dashboard/src/pages/index.ts +0 -28
- package/monodog-dashboard/src/routes/AppRouter.tsx +0 -89
- package/monodog-dashboard/src/routes/AppRouterPages.tsx +0 -56
- package/monodog-dashboard/src/routes/index.ts +0 -10
- package/monodog-dashboard/src/routes/routes.config.ts +0 -94
- package/monodog-dashboard/src/services/api/api-client.ts +0 -189
- package/monodog-dashboard/src/services/api/index.ts +0 -30
- package/monodog-dashboard/src/services/api/types/api.types.ts +0 -63
- package/monodog-dashboard/src/services/auth-context.tsx +0 -344
- package/monodog-dashboard/src/services/monorepoService.ts +0 -733
- package/monodog-dashboard/src/services/permission-context.tsx +0 -193
- package/monodog-dashboard/src/theme/COMPONENT_UPDATES.md +0 -273
- package/monodog-dashboard/src/theme/INTEGRATION.md +0 -381
- package/monodog-dashboard/src/theme/README.md +0 -239
- package/monodog-dashboard/src/theme/examples.tsx +0 -386
- package/monodog-dashboard/src/theme/index.ts +0 -402
- package/monodog-dashboard/src/theme/migration-guide.md +0 -335
- package/monodog-dashboard/src/types/auth-context.types.ts +0 -51
- package/monodog-dashboard/src/types/component.types.ts +0 -96
- package/monodog-dashboard/src/types/icons.types.ts +0 -13
- package/monodog-dashboard/src/types/index.ts +0 -68
- package/monodog-dashboard/src/types/monorepo-service.types.ts +0 -53
- package/monodog-dashboard/src/types/permission-context.types.ts +0 -49
- package/monodog-dashboard/src/types/pipeline.types.ts +0 -89
- package/monodog-dashboard/src/types/routes.types.ts +0 -12
- package/monodog-dashboard/src/utils/cookies.ts +0 -47
- package/monodog-dashboard/tailwind.config.js +0 -68
- package/monodog-dashboard/tsconfig.app.json +0 -14
- package/monodog-dashboard/tsconfig.json +0 -17
- package/monodog-dashboard/tsconfig.node.json +0 -10
- package/monodog-dashboard/vite.config.ts +0 -9
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
// Route configuration for the dashboard application
|
|
2
|
-
import type { RouteConfig } from '../types/routes.types';
|
|
3
|
-
|
|
4
|
-
export const routes: RouteConfig[] = [
|
|
5
|
-
{
|
|
6
|
-
path: '/',
|
|
7
|
-
name: 'dashboard',
|
|
8
|
-
component: 'Dashboard',
|
|
9
|
-
title: 'Dashboard',
|
|
10
|
-
description: 'Main dashboard overview',
|
|
11
|
-
exact: true,
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
path: '/packages',
|
|
15
|
-
name: 'packages',
|
|
16
|
-
component: 'PackagesOverview',
|
|
17
|
-
title: 'Packages',
|
|
18
|
-
description: 'Package management and overview',
|
|
19
|
-
exact: true,
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
path: '/packages/:name',
|
|
23
|
-
name: 'package-detail',
|
|
24
|
-
component: 'PackageDetail',
|
|
25
|
-
title: 'Package Details',
|
|
26
|
-
description: 'Detailed view of a specific package',
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
path: '/dependencies',
|
|
30
|
-
name: 'dependencies',
|
|
31
|
-
component: 'DependencyGraph',
|
|
32
|
-
title: 'Dependencies',
|
|
33
|
-
description: 'Dependency graph visualization',
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
path: '/health',
|
|
37
|
-
name: 'health',
|
|
38
|
-
component: 'HealthStatus',
|
|
39
|
-
title: 'Health Status',
|
|
40
|
-
description: 'Monorepo health monitoring',
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
path: '/publish',
|
|
44
|
-
name: 'publish',
|
|
45
|
-
component: 'PublishControl',
|
|
46
|
-
title: 'Publish Control',
|
|
47
|
-
description: 'Package publishing and versioning',
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
path: '/release',
|
|
51
|
-
name: 'release',
|
|
52
|
-
component: 'ReleaseManager',
|
|
53
|
-
title: 'Release Manager',
|
|
54
|
-
description: 'Comprehensive release management with Changesets',
|
|
55
|
-
protected: true,
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
path: '/ci',
|
|
59
|
-
name: 'ci',
|
|
60
|
-
component: 'CIIntegration',
|
|
61
|
-
title: 'CI/CD',
|
|
62
|
-
description: 'Continuous integration and deployment',
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
path: '/pipeline',
|
|
66
|
-
name: 'pipeline',
|
|
67
|
-
component: 'Pipeline',
|
|
68
|
-
title: 'Release Pipeline',
|
|
69
|
-
description: 'Real-time release pipeline monitoring and management',
|
|
70
|
-
protected: true,
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
path: '/config',
|
|
74
|
-
name: 'config',
|
|
75
|
-
component: 'ConfigInspector',
|
|
76
|
-
title: 'Configuration',
|
|
77
|
-
description: 'Configuration file inspector',
|
|
78
|
-
},
|
|
79
|
-
];
|
|
80
|
-
|
|
81
|
-
// Navigation items for sidebar (subset of routes)
|
|
82
|
-
export const navigationRoutes = routes.filter(
|
|
83
|
-
route => !route.path.includes(':') && route.path !== '/'
|
|
84
|
-
);
|
|
85
|
-
|
|
86
|
-
// Get route by name
|
|
87
|
-
export const getRouteByName = (name: string): RouteConfig | undefined => {
|
|
88
|
-
return routes.find(route => route.name === name);
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
// Get route by path
|
|
92
|
-
export const getRouteByPath = (path: string): RouteConfig | undefined => {
|
|
93
|
-
return routes.find(route => route.path === path);
|
|
94
|
-
};
|
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
import axios, { AxiosInstance, AxiosError } from 'axios';
|
|
2
|
-
import type {
|
|
3
|
-
HttpMethod,
|
|
4
|
-
ApiRequestConfig,
|
|
5
|
-
ApiResponse,
|
|
6
|
-
ApiErrorResponse,
|
|
7
|
-
} from './types/api.types';
|
|
8
|
-
import { cookieUtils } from '../../utils/cookies';
|
|
9
|
-
|
|
10
|
-
import { DEFAULT_TIMEOUT, DEFAULT_API_BASE_URL } from '../../constants/api-config';
|
|
11
|
-
class ApiClient {
|
|
12
|
-
private axiosInstance: AxiosInstance;
|
|
13
|
-
|
|
14
|
-
constructor(config: Partial<{ baseUrl?: string; timeout?: number; headers?: Record<string, string> }> = {}) {
|
|
15
|
-
const baseUrl = config.baseUrl || DEFAULT_API_BASE_URL;
|
|
16
|
-
|
|
17
|
-
this.axiosInstance = axios.create({
|
|
18
|
-
baseURL: baseUrl,
|
|
19
|
-
timeout: config.timeout || DEFAULT_TIMEOUT,
|
|
20
|
-
headers: {
|
|
21
|
-
'Content-Type': 'application/json',
|
|
22
|
-
...config.headers,
|
|
23
|
-
},
|
|
24
|
-
withCredentials: true,
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
this.attachAuthHandling();
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Attach request/response handlers responsible for auth token header
|
|
32
|
-
* and clearing cookies on 401 responses.
|
|
33
|
-
*/
|
|
34
|
-
private attachAuthHandling(): void {
|
|
35
|
-
this.axiosInstance.interceptors.request.use(config => {
|
|
36
|
-
const token = cookieUtils.get('monodog_session_token');
|
|
37
|
-
if (token) {
|
|
38
|
-
// axios headers type can be AxiosHeaders or plain object, cast to any for mutation
|
|
39
|
-
(config.headers as any) = config.headers || {};
|
|
40
|
-
(config.headers as any).Authorization = `Bearer ${token}`;
|
|
41
|
-
}
|
|
42
|
-
return config;
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
this.axiosInstance.interceptors.response.use(
|
|
46
|
-
response => response,
|
|
47
|
-
error => {
|
|
48
|
-
if (error.response?.status === 401) {
|
|
49
|
-
cookieUtils.remove('monodog_session_token');
|
|
50
|
-
cookieUtils.remove('monodog_session_data');
|
|
51
|
-
}
|
|
52
|
-
return Promise.reject(error);
|
|
53
|
-
}
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
private mapAxiosError(error: AxiosError): ApiErrorResponse {
|
|
58
|
-
const status = error.response?.status || 0;
|
|
59
|
-
const statusText = error.response?.statusText || error.message;
|
|
60
|
-
const details =
|
|
61
|
-
error.response && typeof error.response.data === 'object' ? error.response.data : undefined;
|
|
62
|
-
|
|
63
|
-
let code: string;
|
|
64
|
-
switch (status) {
|
|
65
|
-
case 400:
|
|
66
|
-
code = 'VALIDATION';
|
|
67
|
-
break;
|
|
68
|
-
case 401:
|
|
69
|
-
code = 'UNAUTHORIZED';
|
|
70
|
-
break;
|
|
71
|
-
case 403:
|
|
72
|
-
code = 'FORBIDDEN';
|
|
73
|
-
break;
|
|
74
|
-
case 404:
|
|
75
|
-
code = 'NOT_FOUND';
|
|
76
|
-
break;
|
|
77
|
-
case 408:
|
|
78
|
-
code = 'TIMEOUT';
|
|
79
|
-
break;
|
|
80
|
-
case 429:
|
|
81
|
-
code = 'RATE_LIMIT';
|
|
82
|
-
break;
|
|
83
|
-
case 500:
|
|
84
|
-
case 502:
|
|
85
|
-
case 503:
|
|
86
|
-
case 504:
|
|
87
|
-
code = 'SERVER_ERROR';
|
|
88
|
-
break;
|
|
89
|
-
default:
|
|
90
|
-
code = status ? `HTTP_${status}` : 'UNKNOWN';
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
console.error(`API error [${status}] ${statusText}`, { code, details });
|
|
94
|
-
|
|
95
|
-
return {
|
|
96
|
-
success: false,
|
|
97
|
-
error: { code, message: statusText, status, details: details?.details as Record<string, unknown> | undefined },
|
|
98
|
-
meta: {
|
|
99
|
-
status,
|
|
100
|
-
statusText,
|
|
101
|
-
headers: error.response?.headers || {},
|
|
102
|
-
timestamp: Date.now(),
|
|
103
|
-
duration: 0,
|
|
104
|
-
},
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
async request<T = unknown>(
|
|
109
|
-
method: HttpMethod,
|
|
110
|
-
endpoint: string,
|
|
111
|
-
config: Partial<ApiRequestConfig> = {}
|
|
112
|
-
): Promise<ApiResponse<T>> {
|
|
113
|
-
const url = `/api${endpoint}`;
|
|
114
|
-
const start = Date.now();
|
|
115
|
-
|
|
116
|
-
try {
|
|
117
|
-
const response = await this.axiosInstance.request<T>({
|
|
118
|
-
method: method.toLowerCase() as any,
|
|
119
|
-
url,
|
|
120
|
-
data: config.body,
|
|
121
|
-
headers: config.headers,
|
|
122
|
-
timeout: config.timeout,
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
const duration = Date.now() - start;
|
|
126
|
-
|
|
127
|
-
return {
|
|
128
|
-
success: true,
|
|
129
|
-
data: response.data,
|
|
130
|
-
meta: {
|
|
131
|
-
status: response.status,
|
|
132
|
-
statusText: response.statusText,
|
|
133
|
-
headers: response.headers,
|
|
134
|
-
timestamp: Date.now(),
|
|
135
|
-
duration,
|
|
136
|
-
},
|
|
137
|
-
};
|
|
138
|
-
} catch (err) {
|
|
139
|
-
const duration = Date.now() - start;
|
|
140
|
-
|
|
141
|
-
if (axios.isAxiosError(err)) {
|
|
142
|
-
return this.mapAxiosError(err);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
const message = err instanceof Error ? err.message : 'Unknown error';
|
|
146
|
-
console.error('Unexpected error in API client', message);
|
|
147
|
-
|
|
148
|
-
return {
|
|
149
|
-
success: false,
|
|
150
|
-
error: { code: 'UNKNOWN', message, status: 0 },
|
|
151
|
-
meta: { timestamp: Date.now(), duration },
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
get<T = unknown>(endpoint: string, config?: Partial<ApiRequestConfig>): Promise<ApiResponse<T>> {
|
|
157
|
-
return this.request<T>('GET', endpoint, config || {});
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
post<T = unknown>(
|
|
161
|
-
endpoint: string,
|
|
162
|
-
body?: unknown,
|
|
163
|
-
config?: Partial<ApiRequestConfig>
|
|
164
|
-
): Promise<ApiResponse<T>> {
|
|
165
|
-
return this.request<T>('POST', endpoint, { ...config, body });
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
put<T = unknown>(
|
|
169
|
-
endpoint: string,
|
|
170
|
-
body?: unknown,
|
|
171
|
-
config?: Partial<ApiRequestConfig>
|
|
172
|
-
): Promise<ApiResponse<T>> {
|
|
173
|
-
return this.request<T>('PUT', endpoint, { ...config, body });
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
delete<T = unknown>(endpoint: string, config?: Partial<ApiRequestConfig>): Promise<ApiResponse<T>> {
|
|
177
|
-
return this.request<T>('DELETE', endpoint, config || {});
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
patch<T = unknown>(
|
|
181
|
-
endpoint: string,
|
|
182
|
-
body?: unknown,
|
|
183
|
-
config?: Partial<ApiRequestConfig>
|
|
184
|
-
): Promise<ApiResponse<T>> {
|
|
185
|
-
return this.request<T>('PATCH', endpoint, { ...config, body });
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
export default ApiClient;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* API Client Instance and Initialization
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import ApiClient from './api-client';
|
|
6
|
-
import { TIMEOUT_MS, DEFAULT_API_BASE_URL } from '../../constants/api-config';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Determine base URL from env/window or fall back to localhost
|
|
10
|
-
*/
|
|
11
|
-
function getBaseUrl(): string {
|
|
12
|
-
const envUrl = process.env.REACT_APP_API_URL || process.env.VITE_API_URL;
|
|
13
|
-
if (envUrl) return envUrl;
|
|
14
|
-
|
|
15
|
-
const windowUrl = (window as any).ENV?.API_URL;
|
|
16
|
-
if (windowUrl) return windowUrl;
|
|
17
|
-
|
|
18
|
-
return DEFAULT_API_BASE_URL;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const apiClient = new ApiClient({
|
|
22
|
-
baseUrl: getBaseUrl(),
|
|
23
|
-
timeout: TIMEOUT_MS,
|
|
24
|
-
headers: {
|
|
25
|
-
'Content-Type': 'application/json',
|
|
26
|
-
},
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
export default apiClient;
|
|
30
|
-
export { ApiClient };
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* API Types and Interfaces
|
|
3
|
-
* Minimal definitions used throughout the dashboard.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* HTTP Methods supported by the client helpers
|
|
8
|
-
*/
|
|
9
|
-
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Configuration passed to individual requests
|
|
13
|
-
*/
|
|
14
|
-
export interface ApiRequestConfig {
|
|
15
|
-
headers?: Record<string, string>;
|
|
16
|
-
body?: unknown;
|
|
17
|
-
timeout?: number;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Metadata included with every response
|
|
22
|
-
*/
|
|
23
|
-
export interface ApiResponseMeta {
|
|
24
|
-
status: number;
|
|
25
|
-
statusText: string;
|
|
26
|
-
headers: Record<string, unknown>;
|
|
27
|
-
timestamp: number;
|
|
28
|
-
duration: number;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Successful API response shape
|
|
33
|
-
*/
|
|
34
|
-
export interface ApiSuccessResponse<T = unknown> {
|
|
35
|
-
success: true;
|
|
36
|
-
data: T;
|
|
37
|
-
meta: ApiResponseMeta;
|
|
38
|
-
message?: string;
|
|
39
|
-
// error property always present but undefined for successes
|
|
40
|
-
error?: undefined;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Error API response shape exposed to callers
|
|
45
|
-
*/
|
|
46
|
-
export interface ApiErrorResponse {
|
|
47
|
-
success: false;
|
|
48
|
-
error: {
|
|
49
|
-
code: string;
|
|
50
|
-
message: string;
|
|
51
|
-
status: number;
|
|
52
|
-
details?: Record<string, unknown>;
|
|
53
|
-
};
|
|
54
|
-
meta: Partial<ApiResponseMeta>;
|
|
55
|
-
// data property always present but undefined for errors
|
|
56
|
-
data?: undefined;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Union type returned by every client helper
|
|
61
|
-
*/
|
|
62
|
-
export type ApiResponse<T = unknown> = ApiSuccessResponse<T> | ApiErrorResponse;
|
|
63
|
-
|