@andrebuzeli/git-mcp 4.0.21 → 5.0.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.
- package/README.md +59 -32
- package/dist/config.d.ts +0 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +0 -27
- package/dist/config.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +54 -3
- package/dist/index.js.map +1 -1
- package/dist/providers/gitea-provider.d.ts +5 -5
- package/dist/providers/gitea-provider.d.ts.map +1 -1
- package/dist/providers/gitea-provider.js +75 -220
- package/dist/providers/gitea-provider.js.map +1 -1
- package/dist/providers/github-provider.d.ts +0 -48
- package/dist/providers/github-provider.d.ts.map +1 -1
- package/dist/providers/github-provider.js +805 -849
- package/dist/providers/github-provider.js.map +1 -1
- package/dist/providers/provider-factory.d.ts +1 -1
- package/dist/providers/provider-factory.d.ts.map +1 -1
- package/dist/providers/provider-factory.js +4 -14
- package/dist/providers/provider-factory.js.map +1 -1
- package/dist/providers/types.d.ts +1 -1
- package/dist/providers/types.d.ts.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +91 -37
- package/dist/server.js.map +1 -1
- package/dist/tools/git-files.d.ts.map +1 -1
- package/dist/tools/git-files.js +103 -5
- package/dist/tools/git-files.js.map +1 -1
- package/dist/tools/git-sync.d.ts.map +1 -1
- package/dist/tools/git-sync.js +104 -6
- package/dist/tools/git-sync.js.map +1 -1
- package/dist/tools/git-workflow.d.ts +55 -0
- package/dist/tools/git-workflow.d.ts.map +1 -1
- package/dist/tools/git-workflow.js +660 -7
- package/dist/tools/git-workflow.js.map +1 -1
- package/dist/utils/auto-detection.js +1 -1
- package/dist/utils/auto-detection.js.map +1 -1
- package/dist/utils/configuration-error-generator.d.ts +41 -0
- package/dist/utils/configuration-error-generator.d.ts.map +1 -0
- package/dist/utils/configuration-error-generator.js +168 -0
- package/dist/utils/configuration-error-generator.js.map +1 -0
- package/dist/utils/configuration-validator.d.ts +67 -0
- package/dist/utils/configuration-validator.d.ts.map +1 -0
- package/dist/utils/configuration-validator.js +257 -0
- package/dist/utils/configuration-validator.js.map +1 -0
- package/dist/utils/multi-provider-error-handler.d.ts +75 -0
- package/dist/utils/multi-provider-error-handler.d.ts.map +1 -0
- package/dist/utils/multi-provider-error-handler.js +276 -0
- package/dist/utils/multi-provider-error-handler.js.map +1 -0
- package/dist/utils/multi-provider-operation-handler.d.ts +113 -0
- package/dist/utils/multi-provider-operation-handler.d.ts.map +1 -0
- package/dist/utils/multi-provider-operation-handler.js +303 -0
- package/dist/utils/multi-provider-operation-handler.js.map +1 -0
- package/dist/utils/operation-error-handler.d.ts +69 -0
- package/dist/utils/operation-error-handler.d.ts.map +1 -0
- package/dist/utils/operation-error-handler.js +277 -0
- package/dist/utils/operation-error-handler.js.map +1 -0
- package/dist/utils/provider-operation-handler.d.ts +80 -0
- package/dist/utils/provider-operation-handler.d.ts.map +1 -0
- package/dist/utils/provider-operation-handler.js +201 -0
- package/dist/utils/provider-operation-handler.js.map +1 -0
- package/dist/utils/response-helper.js +1 -1
- package/dist/utils/response-helper.js.map +1 -1
- package/package.json +60 -60
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OperationErrorHandler = void 0;
|
|
4
|
+
const configuration_error_generator_js_1 = require("./configuration-error-generator.js");
|
|
5
|
+
/**
|
|
6
|
+
* Operation error handler for Git MCP providers
|
|
7
|
+
* Provides comprehensive error handling with configuration guidance
|
|
8
|
+
*/
|
|
9
|
+
class OperationErrorHandler {
|
|
10
|
+
/**
|
|
11
|
+
* Handle authentication errors with configuration guidance
|
|
12
|
+
*/
|
|
13
|
+
static handleAuthenticationError(error, provider) {
|
|
14
|
+
const configError = configuration_error_generator_js_1.ConfigurationErrorGenerator.generateAuthenticationError(provider);
|
|
15
|
+
return {
|
|
16
|
+
code: 'AUTHENTICATION_FAILED',
|
|
17
|
+
message: `Authentication failed for ${provider}`,
|
|
18
|
+
provider,
|
|
19
|
+
cause: 'Invalid or expired token, or insufficient permissions',
|
|
20
|
+
solution: 'Update your token with proper permissions',
|
|
21
|
+
configuration: configError,
|
|
22
|
+
troubleshooting: [
|
|
23
|
+
'Verify your token is not expired',
|
|
24
|
+
'Check token permissions include repo, user, and admin:repo_hook',
|
|
25
|
+
'Test token manually with API call',
|
|
26
|
+
'Regenerate token if necessary'
|
|
27
|
+
]
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Handle network errors with troubleshooting steps
|
|
32
|
+
*/
|
|
33
|
+
static handleNetworkError(error, provider, endpoint) {
|
|
34
|
+
const configError = configuration_error_generator_js_1.ConfigurationErrorGenerator.generateNetworkError(provider, endpoint);
|
|
35
|
+
return {
|
|
36
|
+
code: 'NETWORK_ERROR',
|
|
37
|
+
message: `Network error connecting to ${provider}`,
|
|
38
|
+
provider,
|
|
39
|
+
cause: 'Connection failed to provider API',
|
|
40
|
+
solution: 'Check network connectivity and provider configuration',
|
|
41
|
+
configuration: configError,
|
|
42
|
+
troubleshooting: [
|
|
43
|
+
'Check internet connection',
|
|
44
|
+
'Verify provider API is accessible',
|
|
45
|
+
'Test DNS resolution for provider domain',
|
|
46
|
+
'Check firewall settings',
|
|
47
|
+
'Verify proxy settings if applicable'
|
|
48
|
+
]
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Handle permission errors with access instructions
|
|
53
|
+
*/
|
|
54
|
+
static handlePermissionError(error, provider, operation) {
|
|
55
|
+
const baseConfig = provider === 'github'
|
|
56
|
+
? configuration_error_generator_js_1.ConfigurationErrorGenerator.generateGitHubError()
|
|
57
|
+
: configuration_error_generator_js_1.ConfigurationErrorGenerator.generateGiteaError();
|
|
58
|
+
const configError = {
|
|
59
|
+
...baseConfig,
|
|
60
|
+
instructions: [
|
|
61
|
+
`Permission denied for ${operation || 'operation'} on ${provider}`,
|
|
62
|
+
'',
|
|
63
|
+
'This usually means:',
|
|
64
|
+
'• Token lacks required permissions for this operation',
|
|
65
|
+
'• Repository/resource access is restricted',
|
|
66
|
+
'• Organization policies prevent this action',
|
|
67
|
+
'',
|
|
68
|
+
'To fix permission issues:',
|
|
69
|
+
'1. Check token permissions include:',
|
|
70
|
+
' - repo (for repository operations)',
|
|
71
|
+
' - user (for user information)',
|
|
72
|
+
' - admin:repo_hook (for webhook management)',
|
|
73
|
+
' - delete_repo (for repository deletion)',
|
|
74
|
+
'2. Verify you have access to the target repository/resource',
|
|
75
|
+
'3. Check organization/team permissions if applicable',
|
|
76
|
+
'4. Contact repository owner if you need additional access'
|
|
77
|
+
]
|
|
78
|
+
};
|
|
79
|
+
return {
|
|
80
|
+
code: 'PERMISSION_DENIED',
|
|
81
|
+
message: `Permission denied for ${operation || 'operation'} on ${provider}`,
|
|
82
|
+
provider,
|
|
83
|
+
cause: 'Insufficient permissions or access restrictions',
|
|
84
|
+
solution: 'Update token permissions or request access',
|
|
85
|
+
configuration: configError,
|
|
86
|
+
troubleshooting: [
|
|
87
|
+
'Verify token has required scopes',
|
|
88
|
+
'Check repository/organization access',
|
|
89
|
+
'Confirm user permissions for the operation',
|
|
90
|
+
'Review organization security policies'
|
|
91
|
+
]
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Handle resource not found errors
|
|
96
|
+
*/
|
|
97
|
+
static handleNotFoundError(error, provider, resource) {
|
|
98
|
+
return {
|
|
99
|
+
code: 'RESOURCE_NOT_FOUND',
|
|
100
|
+
message: `${resource || 'Resource'} not found on ${provider}`,
|
|
101
|
+
provider,
|
|
102
|
+
cause: 'Requested resource does not exist or is not accessible',
|
|
103
|
+
solution: 'Verify resource name and access permissions',
|
|
104
|
+
troubleshooting: [
|
|
105
|
+
'Check spelling of repository/resource name',
|
|
106
|
+
'Verify the resource exists on the provider',
|
|
107
|
+
'Confirm you have read access to the resource',
|
|
108
|
+
'Check if resource was moved or renamed',
|
|
109
|
+
'Verify organization/user name is correct'
|
|
110
|
+
]
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Handle rate limiting errors
|
|
115
|
+
*/
|
|
116
|
+
static handleRateLimitError(error, provider) {
|
|
117
|
+
return {
|
|
118
|
+
code: 'RATE_LIMIT_EXCEEDED',
|
|
119
|
+
message: `Rate limit exceeded for ${provider}`,
|
|
120
|
+
provider,
|
|
121
|
+
cause: 'Too many API requests in a short time period',
|
|
122
|
+
solution: 'Wait before retrying or use authenticated requests',
|
|
123
|
+
troubleshooting: [
|
|
124
|
+
'Wait for rate limit reset (usually 1 hour)',
|
|
125
|
+
'Use authenticated requests for higher limits',
|
|
126
|
+
'Implement request throttling in your application',
|
|
127
|
+
'Consider using multiple tokens for higher throughput',
|
|
128
|
+
'Check provider documentation for rate limit details'
|
|
129
|
+
]
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Handle timeout errors
|
|
134
|
+
*/
|
|
135
|
+
static handleTimeoutError(error, provider) {
|
|
136
|
+
return {
|
|
137
|
+
code: 'REQUEST_TIMEOUT',
|
|
138
|
+
message: `Request timeout for ${provider}`,
|
|
139
|
+
provider,
|
|
140
|
+
cause: 'Request took too long to complete',
|
|
141
|
+
solution: 'Retry the operation or check provider status',
|
|
142
|
+
troubleshooting: [
|
|
143
|
+
'Check provider service status',
|
|
144
|
+
'Verify network connectivity is stable',
|
|
145
|
+
'Try the operation again after a short delay',
|
|
146
|
+
'Check if provider is experiencing high load',
|
|
147
|
+
'Consider breaking large operations into smaller chunks'
|
|
148
|
+
]
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Handle validation errors
|
|
153
|
+
*/
|
|
154
|
+
static handleValidationError(error, provider, field) {
|
|
155
|
+
return {
|
|
156
|
+
code: 'VALIDATION_ERROR',
|
|
157
|
+
message: `Validation error for ${provider}${field ? ` (${field})` : ''}`,
|
|
158
|
+
provider,
|
|
159
|
+
cause: 'Invalid input data or parameters',
|
|
160
|
+
solution: 'Check input parameters and format',
|
|
161
|
+
troubleshooting: [
|
|
162
|
+
'Verify all required parameters are provided',
|
|
163
|
+
'Check parameter formats match provider requirements',
|
|
164
|
+
'Validate string lengths and character restrictions',
|
|
165
|
+
'Ensure boolean and numeric values are correct type',
|
|
166
|
+
'Review provider API documentation for parameter rules'
|
|
167
|
+
]
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Handle generic API errors
|
|
172
|
+
*/
|
|
173
|
+
static handleGenericError(error, provider) {
|
|
174
|
+
return {
|
|
175
|
+
code: 'API_ERROR',
|
|
176
|
+
message: `API error from ${provider}: ${error.message}`,
|
|
177
|
+
provider,
|
|
178
|
+
cause: 'Unexpected error from provider API',
|
|
179
|
+
solution: 'Check error details and provider status',
|
|
180
|
+
troubleshooting: [
|
|
181
|
+
'Review the specific error message for clues',
|
|
182
|
+
'Check provider status page for known issues',
|
|
183
|
+
'Verify your request format matches API documentation',
|
|
184
|
+
'Try the operation again after a short delay',
|
|
185
|
+
'Contact provider support if error persists'
|
|
186
|
+
]
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Analyze error and return appropriate error handler result
|
|
191
|
+
*/
|
|
192
|
+
static analyzeAndHandleError(error, provider, operation) {
|
|
193
|
+
const errorMessage = error.message.toLowerCase();
|
|
194
|
+
// Authentication errors
|
|
195
|
+
if (errorMessage.includes('401') ||
|
|
196
|
+
errorMessage.includes('unauthorized') ||
|
|
197
|
+
errorMessage.includes('authentication') ||
|
|
198
|
+
errorMessage.includes('invalid token')) {
|
|
199
|
+
return this.handleAuthenticationError(error, provider);
|
|
200
|
+
}
|
|
201
|
+
// Permission errors
|
|
202
|
+
if (errorMessage.includes('403') ||
|
|
203
|
+
errorMessage.includes('forbidden') ||
|
|
204
|
+
errorMessage.includes('permission denied')) {
|
|
205
|
+
return this.handlePermissionError(error, provider, operation);
|
|
206
|
+
}
|
|
207
|
+
// Not found errors
|
|
208
|
+
if (errorMessage.includes('404') ||
|
|
209
|
+
errorMessage.includes('not found')) {
|
|
210
|
+
return this.handleNotFoundError(error, provider, operation);
|
|
211
|
+
}
|
|
212
|
+
// Rate limiting errors
|
|
213
|
+
if (errorMessage.includes('429') ||
|
|
214
|
+
errorMessage.includes('rate limit') ||
|
|
215
|
+
errorMessage.includes('too many requests')) {
|
|
216
|
+
return this.handleRateLimitError(error, provider);
|
|
217
|
+
}
|
|
218
|
+
// Network errors
|
|
219
|
+
if (errorMessage.includes('enotfound') ||
|
|
220
|
+
errorMessage.includes('econnrefused') ||
|
|
221
|
+
errorMessage.includes('network') ||
|
|
222
|
+
errorMessage.includes('connection')) {
|
|
223
|
+
return this.handleNetworkError(error, provider);
|
|
224
|
+
}
|
|
225
|
+
// Timeout errors
|
|
226
|
+
if (errorMessage.includes('timeout') ||
|
|
227
|
+
errorMessage.includes('etimedout')) {
|
|
228
|
+
return this.handleTimeoutError(error, provider);
|
|
229
|
+
}
|
|
230
|
+
// Validation errors
|
|
231
|
+
if (errorMessage.includes('400') ||
|
|
232
|
+
errorMessage.includes('bad request') ||
|
|
233
|
+
errorMessage.includes('validation') ||
|
|
234
|
+
errorMessage.includes('invalid')) {
|
|
235
|
+
return this.handleValidationError(error, provider);
|
|
236
|
+
}
|
|
237
|
+
// Generic error fallback
|
|
238
|
+
return this.handleGenericError(error, provider);
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Format operation error as user-friendly message
|
|
242
|
+
*/
|
|
243
|
+
static formatErrorMessage(operationError) {
|
|
244
|
+
const lines = [
|
|
245
|
+
`❌ ${operationError.code}: ${operationError.message}`,
|
|
246
|
+
'',
|
|
247
|
+
`🔍 Cause: ${operationError.cause}`,
|
|
248
|
+
`💡 Solution: ${operationError.solution}`,
|
|
249
|
+
''
|
|
250
|
+
];
|
|
251
|
+
if (operationError.troubleshooting && operationError.troubleshooting.length > 0) {
|
|
252
|
+
lines.push('🛠️ Troubleshooting Steps:');
|
|
253
|
+
lines.push(...operationError.troubleshooting.map(step => ` • ${step}`));
|
|
254
|
+
lines.push('');
|
|
255
|
+
}
|
|
256
|
+
if (operationError.configuration) {
|
|
257
|
+
lines.push('⚙️ Configuration Help:');
|
|
258
|
+
lines.push(configuration_error_generator_js_1.ConfigurationErrorGenerator.formatErrorMessage(operationError.configuration));
|
|
259
|
+
}
|
|
260
|
+
return lines.join('\n');
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Create a comprehensive error response for API operations
|
|
264
|
+
*/
|
|
265
|
+
static createErrorResponse(error, provider, operation) {
|
|
266
|
+
const operationError = this.analyzeAndHandleError(error, provider, operation);
|
|
267
|
+
const formattedMessage = this.formatErrorMessage(operationError);
|
|
268
|
+
return {
|
|
269
|
+
success: false,
|
|
270
|
+
error: operationError.message,
|
|
271
|
+
details: operationError,
|
|
272
|
+
formattedMessage
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
exports.OperationErrorHandler = OperationErrorHandler;
|
|
277
|
+
//# sourceMappingURL=operation-error-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operation-error-handler.js","sourceRoot":"","sources":["../../src/utils/operation-error-handler.ts"],"names":[],"mappings":";;;AAAA,yFAAqG;AAerG;;;GAGG;AACH,MAAa,qBAAqB;IAEhC;;OAEG;IACH,MAAM,CAAC,yBAAyB,CAAC,KAAY,EAAE,QAAgB;QAC7D,MAAM,WAAW,GAAG,8DAA2B,CAAC,2BAA2B,CAAC,QAAQ,CAAC,CAAC;QAEtF,OAAO;YACL,IAAI,EAAE,uBAAuB;YAC7B,OAAO,EAAE,6BAA6B,QAAQ,EAAE;YAChD,QAAQ;YACR,KAAK,EAAE,uDAAuD;YAC9D,QAAQ,EAAE,2CAA2C;YACrD,aAAa,EAAE,WAAW;YAC1B,eAAe,EAA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mBAAmB,CAAC,KAAY,EAAE,QAAgB,EAAE,SAAkB;QAM3E,MAAM,cAAc,GAAG,IAAI,CAAC,qBAAqB,CAAC,KAAK,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;QAC9E,MAAM,gBAAgB,GAAG,IAAI,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAAC;QAEjE,OAAO;YACL,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,cAAc,CAAC,OAAO;YAC7B,OAAO,EAAE,cAAc;YACvB,gBAAgB;SACjB,CAAC;IACJ,CAAC;CACF;AA1SD,sDA0SC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { VcsOperations } from '../providers/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Result interface for single provider operations
|
|
4
|
+
*/
|
|
5
|
+
export interface SingleProviderResult<T> {
|
|
6
|
+
success: boolean;
|
|
7
|
+
data?: T;
|
|
8
|
+
error?: string;
|
|
9
|
+
provider: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Result interface for multi-provider operations
|
|
13
|
+
*/
|
|
14
|
+
export interface MultiProviderResult<T> {
|
|
15
|
+
success: boolean;
|
|
16
|
+
message: string;
|
|
17
|
+
data: {
|
|
18
|
+
github?: SingleProviderResult<T>;
|
|
19
|
+
gitea?: SingleProviderResult<T>;
|
|
20
|
+
};
|
|
21
|
+
warnings?: string[];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Operation result that can be either single or multi-provider
|
|
25
|
+
*/
|
|
26
|
+
export type OperationResult<T> = SingleProviderResult<T> | MultiProviderResult<T>;
|
|
27
|
+
/**
|
|
28
|
+
* Provider-specific operation handler
|
|
29
|
+
* Handles execution of operations on specific providers (github, gitea, both)
|
|
30
|
+
*/
|
|
31
|
+
export declare class ProviderOperationHandler {
|
|
32
|
+
/**
|
|
33
|
+
* Execute operation on specified provider(s)
|
|
34
|
+
*/
|
|
35
|
+
static executeOperation<T>(provider: 'github' | 'gitea' | 'both', operation: (provider: VcsOperations) => Promise<T>): Promise<OperationResult<T>>;
|
|
36
|
+
/**
|
|
37
|
+
* Execute operation on a single provider
|
|
38
|
+
*/
|
|
39
|
+
private static executeSingleProvider;
|
|
40
|
+
/**
|
|
41
|
+
* Execute operation on both providers simultaneously
|
|
42
|
+
* Uses the dedicated MultiProviderOperationHandler for enhanced functionality
|
|
43
|
+
*/
|
|
44
|
+
private static executeMultiProvider;
|
|
45
|
+
/**
|
|
46
|
+
* Convert MultiProviderOperationResult to MultiProviderResult for backward compatibility
|
|
47
|
+
*/
|
|
48
|
+
private static convertMultiProviderResult;
|
|
49
|
+
/**
|
|
50
|
+
* Get available providers for operation
|
|
51
|
+
*/
|
|
52
|
+
static getAvailableProviders(): string[];
|
|
53
|
+
/**
|
|
54
|
+
* Check if provider is available
|
|
55
|
+
*/
|
|
56
|
+
static isProviderAvailable(provider: 'github' | 'gitea'): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Get provider configuration status
|
|
59
|
+
*/
|
|
60
|
+
static getProviderStatus(): {
|
|
61
|
+
github: {
|
|
62
|
+
configured: boolean;
|
|
63
|
+
error?: string;
|
|
64
|
+
};
|
|
65
|
+
gitea: {
|
|
66
|
+
configured: boolean;
|
|
67
|
+
error?: string;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Validate provider parameter and configuration before operation
|
|
72
|
+
* Enhanced with multi-provider error handling
|
|
73
|
+
*/
|
|
74
|
+
static validateProviderForOperation(provider: 'github' | 'gitea' | 'both'): {
|
|
75
|
+
valid: boolean;
|
|
76
|
+
error?: string;
|
|
77
|
+
warnings?: string[];
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=provider-operation-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-operation-handler.d.ts","sourceRoot":"","sources":["../../src/utils/provider-operation-handler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,a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E,OAAO,CAAC;YAAC,KAAK,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;QAChD,KAAK,EAAE;YAAE,UAAU,EAAE,OAAO,CAAC;YAAC,KAAK,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;KAChD;IAkBD;;;OAGG;IACH,MAAM,CAAC,4BAA4B,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG;QAC1E,KAAK,EAAE,OAAO,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;KACrB;CAuDF"}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProviderOperationHandler = void 0;
|
|
4
|
+
const index_js_1 = require("../providers/index.js");
|
|
5
|
+
const configuration_validator_js_1 = require("./configuration-validator.js");
|
|
6
|
+
const configuration_error_generator_js_1 = require("./configuration-error-generator.js");
|
|
7
|
+
const operation_error_handler_js_1 = require("./operation-error-handler.js");
|
|
8
|
+
const multi_provider_operation_handler_js_1 = require("./multi-provider-operation-handler.js");
|
|
9
|
+
const multi_provider_error_handler_js_1 = require("./multi-provider-error-handler.js");
|
|
10
|
+
/**
|
|
11
|
+
* Provider-specific operation handler
|
|
12
|
+
* Handles execution of operations on specific providers (github, gitea, both)
|
|
13
|
+
*/
|
|
14
|
+
class ProviderOperationHandler {
|
|
15
|
+
/**
|
|
16
|
+
* Execute operation on specified provider(s)
|
|
17
|
+
*/
|
|
18
|
+
static async executeOperation(provider, operation) {
|
|
19
|
+
switch (provider) {
|
|
20
|
+
case 'github':
|
|
21
|
+
return this.executeSingleProvider('github', operation);
|
|
22
|
+
case 'gitea':
|
|
23
|
+
return this.executeSingleProvider('gitea', operation);
|
|
24
|
+
case 'both':
|
|
25
|
+
return this.executeMultiProvider(operation);
|
|
26
|
+
default:
|
|
27
|
+
throw new Error(`Invalid provider: ${provider}`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Execute operation on a single provider
|
|
32
|
+
*/
|
|
33
|
+
static async executeSingleProvider(providerName, operation) {
|
|
34
|
+
try {
|
|
35
|
+
// Get provider instance
|
|
36
|
+
const providerInstance = index_js_1.globalProviderFactory.getProvider(providerName);
|
|
37
|
+
if (!providerInstance) {
|
|
38
|
+
const configError = providerName === 'github'
|
|
39
|
+
? configuration_error_generator_js_1.ConfigurationErrorGenerator.generateGitHubError()
|
|
40
|
+
: configuration_error_generator_js_1.ConfigurationErrorGenerator.generateGiteaError();
|
|
41
|
+
return {
|
|
42
|
+
success: false,
|
|
43
|
+
provider: providerName,
|
|
44
|
+
error: `${providerName} provider is not configured. ${configuration_error_generator_js_1.ConfigurationErrorGenerator.formatErrorMessage(configError)}`
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
// Execute operation
|
|
48
|
+
const result = await operation(providerInstance);
|
|
49
|
+
return {
|
|
50
|
+
success: true,
|
|
51
|
+
provider: providerName,
|
|
52
|
+
data: result
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
const errorResponse = operation_error_handler_js_1.OperationErrorHandler.createErrorResponse(error instanceof Error ? error : new Error(String(error)), providerName);
|
|
57
|
+
return {
|
|
58
|
+
success: false,
|
|
59
|
+
provider: providerName,
|
|
60
|
+
error: errorResponse.formattedMessage
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Execute operation on both providers simultaneously
|
|
66
|
+
* Uses the dedicated MultiProviderOperationHandler for enhanced functionality
|
|
67
|
+
*/
|
|
68
|
+
static async executeMultiProvider(operation) {
|
|
69
|
+
try {
|
|
70
|
+
// Use the dedicated MultiProviderOperationHandler
|
|
71
|
+
const result = await multi_provider_operation_handler_js_1.MultiProviderOperationHandler.executeOnBoth(operation);
|
|
72
|
+
// Convert MultiProviderOperationResult to MultiProviderResult for backward compatibility
|
|
73
|
+
return this.convertMultiProviderResult(result);
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
// Handle any unexpected errors
|
|
77
|
+
const config = multi_provider_operation_handler_js_1.MultiProviderOperationHandler.getProviderConfiguration();
|
|
78
|
+
const errorResponse = multi_provider_error_handler_js_1.MultiProviderErrorHandler.createMultiProviderErrorResponse(config, undefined, undefined);
|
|
79
|
+
return {
|
|
80
|
+
success: false,
|
|
81
|
+
message: errorResponse.error.message,
|
|
82
|
+
data: {
|
|
83
|
+
github: { success: false, provider: 'github', error: 'Operation failed' },
|
|
84
|
+
gitea: { success: false, provider: 'gitea', error: 'Operation failed' }
|
|
85
|
+
},
|
|
86
|
+
warnings: errorResponse.error.warnings
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Convert MultiProviderOperationResult to MultiProviderResult for backward compatibility
|
|
92
|
+
*/
|
|
93
|
+
static convertMultiProviderResult(result) {
|
|
94
|
+
const convertedData = {};
|
|
95
|
+
if (result.data.github) {
|
|
96
|
+
convertedData.github = {
|
|
97
|
+
success: result.data.github.success,
|
|
98
|
+
provider: result.data.github.provider,
|
|
99
|
+
data: result.data.github.data,
|
|
100
|
+
error: result.data.github.error
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
if (result.data.gitea) {
|
|
104
|
+
convertedData.gitea = {
|
|
105
|
+
success: result.data.gitea.success,
|
|
106
|
+
provider: result.data.gitea.provider,
|
|
107
|
+
data: result.data.gitea.data,
|
|
108
|
+
error: result.data.gitea.error
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
return {
|
|
112
|
+
success: result.success,
|
|
113
|
+
message: result.message,
|
|
114
|
+
data: convertedData,
|
|
115
|
+
warnings: result.warnings
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Get available providers for operation
|
|
120
|
+
*/
|
|
121
|
+
static getAvailableProviders() {
|
|
122
|
+
return configuration_validator_js_1.ConfigurationValidator.getConfiguredProviders();
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Check if provider is available
|
|
126
|
+
*/
|
|
127
|
+
static isProviderAvailable(provider) {
|
|
128
|
+
const validation = provider === 'github'
|
|
129
|
+
? configuration_validator_js_1.ConfigurationValidator.validateGitHubConfiguration()
|
|
130
|
+
: configuration_validator_js_1.ConfigurationValidator.validateGiteaConfiguration();
|
|
131
|
+
return validation.valid;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Get provider configuration status
|
|
135
|
+
*/
|
|
136
|
+
static getProviderStatus() {
|
|
137
|
+
const githubValidation = configuration_validator_js_1.ConfigurationValidator.validateGitHubConfiguration();
|
|
138
|
+
const giteaValidation = configuration_validator_js_1.ConfigurationValidator.validateGiteaConfiguration();
|
|
139
|
+
return {
|
|
140
|
+
github: {
|
|
141
|
+
configured: githubValidation.valid,
|
|
142
|
+
error: githubValidation.error?.message
|
|
143
|
+
},
|
|
144
|
+
gitea: {
|
|
145
|
+
configured: giteaValidation.valid,
|
|
146
|
+
error: giteaValidation.error?.message
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Validate provider parameter and configuration before operation
|
|
152
|
+
* Enhanced with multi-provider error handling
|
|
153
|
+
*/
|
|
154
|
+
static validateProviderForOperation(provider) {
|
|
155
|
+
// Validate provider parameter
|
|
156
|
+
const providerValidation = configuration_validator_js_1.ConfigurationValidator.validateProvider(provider);
|
|
157
|
+
if (!providerValidation.valid) {
|
|
158
|
+
return {
|
|
159
|
+
valid: false,
|
|
160
|
+
error: providerValidation.error?.message
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
// Handle multi-provider validation
|
|
164
|
+
if (provider === 'both') {
|
|
165
|
+
const config = multi_provider_operation_handler_js_1.MultiProviderOperationHandler.getProviderConfiguration();
|
|
166
|
+
// Check if no providers are configured
|
|
167
|
+
if (!config.hasAnyProvider) {
|
|
168
|
+
const errorResponse = multi_provider_error_handler_js_1.MultiProviderErrorHandler.handleNoProvidersConfigured();
|
|
169
|
+
return {
|
|
170
|
+
valid: false,
|
|
171
|
+
error: multi_provider_error_handler_js_1.MultiProviderErrorHandler.formatMultiProviderError(errorResponse)
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
// Generate warnings for missing providers
|
|
175
|
+
const warnings = multi_provider_error_handler_js_1.MultiProviderErrorHandler.generateMissingProviderWarnings(config);
|
|
176
|
+
// Handle single provider scenario
|
|
177
|
+
if (config.totalConfigured === 1) {
|
|
178
|
+
const configuredProvider = config.github.configured ? 'github' : 'gitea';
|
|
179
|
+
const singleProviderWarnings = multi_provider_error_handler_js_1.MultiProviderErrorHandler.handleSingleProviderScenario(configuredProvider, config);
|
|
180
|
+
warnings.push(...singleProviderWarnings.warnings);
|
|
181
|
+
}
|
|
182
|
+
return {
|
|
183
|
+
valid: true,
|
|
184
|
+
warnings: warnings.length > 0 ? warnings : undefined
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
// Validate single provider configuration
|
|
188
|
+
const configValidation = configuration_validator_js_1.ConfigurationValidator.validateProviderConfiguration(provider);
|
|
189
|
+
if (!configValidation.valid) {
|
|
190
|
+
return {
|
|
191
|
+
valid: false,
|
|
192
|
+
error: configValidation.error?.message
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
return {
|
|
196
|
+
valid: true
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
exports.ProviderOperationHandler = ProviderOperationHandler;
|
|
201
|
+
//# sourceMappingURL=provider-operation-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-operation-handler.js","sourceRoot":"","sources":["../../src/utils/provider-operation-handler.ts"],"names":[],"mappings":";;;AAAA,oDAA8D;AAE9D,6EAAsE;AACtE,yFAAiF;AACjF,6EAAqE;AACrE,+FAAoH;AAC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