@mweinbach/apple-docs-mcp 1.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/LICENSE +21 -0
- package/README.md +560 -0
- package/dist/constants/browser-headers.d.ts +48 -0
- package/dist/constants/browser-headers.d.ts.map +1 -0
- package/dist/constants/browser-headers.js +166 -0
- package/dist/constants/browser-headers.js.map +1 -0
- package/dist/index.d.ts +83 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +215 -0
- package/dist/index.js.map +1 -0
- package/dist/schemas/analyze-api.schema.d.ts +42 -0
- package/dist/schemas/analyze-api.schema.d.ts.map +1 -0
- package/dist/schemas/analyze-api.schema.js +23 -0
- package/dist/schemas/analyze-api.schema.js.map +1 -0
- package/dist/schemas/apple-docs.schema.d.ts +18 -0
- package/dist/schemas/apple-docs.schema.d.ts.map +1 -0
- package/dist/schemas/apple-docs.schema.js +10 -0
- package/dist/schemas/apple-docs.schema.js.map +1 -0
- package/dist/schemas/doc-content.schema.d.ts +24 -0
- package/dist/schemas/doc-content.schema.d.ts.map +1 -0
- package/dist/schemas/doc-content.schema.js +10 -0
- package/dist/schemas/doc-content.schema.js.map +1 -0
- package/dist/schemas/documentation-updates.schema.d.ts +27 -0
- package/dist/schemas/documentation-updates.schema.d.ts.map +1 -0
- package/dist/schemas/documentation-updates.schema.js +12 -0
- package/dist/schemas/documentation-updates.schema.js.map +1 -0
- package/dist/schemas/framework-symbols.schema.d.ts +24 -0
- package/dist/schemas/framework-symbols.schema.d.ts.map +1 -0
- package/dist/schemas/framework-symbols.schema.js +11 -0
- package/dist/schemas/framework-symbols.schema.js.map +1 -0
- package/dist/schemas/index.d.ts +15 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +15 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/schemas/platform-compatibility.schema.d.ts +18 -0
- package/dist/schemas/platform-compatibility.schema.d.ts.map +1 -0
- package/dist/schemas/platform-compatibility.schema.js +8 -0
- package/dist/schemas/platform-compatibility.schema.js.map +1 -0
- package/dist/schemas/references.schema.d.ts +18 -0
- package/dist/schemas/references.schema.d.ts.map +1 -0
- package/dist/schemas/references.schema.js +9 -0
- package/dist/schemas/references.schema.js.map +1 -0
- package/dist/schemas/related-apis.schema.d.ts +21 -0
- package/dist/schemas/related-apis.schema.d.ts.map +1 -0
- package/dist/schemas/related-apis.schema.js +9 -0
- package/dist/schemas/related-apis.schema.js.map +1 -0
- package/dist/schemas/sample-code.schema.d.ts +21 -0
- package/dist/schemas/sample-code.schema.d.ts.map +1 -0
- package/dist/schemas/sample-code.schema.js +10 -0
- package/dist/schemas/sample-code.schema.js.map +1 -0
- package/dist/schemas/search.schema.d.ts +15 -0
- package/dist/schemas/search.schema.d.ts.map +1 -0
- package/dist/schemas/search.schema.js +8 -0
- package/dist/schemas/search.schema.js.map +1 -0
- package/dist/schemas/similar-apis.schema.d.ts +21 -0
- package/dist/schemas/similar-apis.schema.d.ts.map +1 -0
- package/dist/schemas/similar-apis.schema.js +9 -0
- package/dist/schemas/similar-apis.schema.js.map +1 -0
- package/dist/schemas/technologies.schema.d.ts +21 -0
- package/dist/schemas/technologies.schema.d.ts.map +1 -0
- package/dist/schemas/technologies.schema.js +10 -0
- package/dist/schemas/technologies.schema.js.map +1 -0
- package/dist/schemas/technology-overviews.schema.d.ts +24 -0
- package/dist/schemas/technology-overviews.schema.d.ts.map +1 -0
- package/dist/schemas/technology-overviews.schema.js +11 -0
- package/dist/schemas/technology-overviews.schema.js.map +1 -0
- package/dist/schemas/wwdc.schemas.d.ts +208 -0
- package/dist/schemas/wwdc.schemas.d.ts.map +1 -0
- package/dist/schemas/wwdc.schemas.js +97 -0
- package/dist/schemas/wwdc.schemas.js.map +1 -0
- package/dist/tools/definitions.d.ts +10 -0
- package/dist/tools/definitions.d.ts.map +1 -0
- package/dist/tools/definitions.js +690 -0
- package/dist/tools/definitions.js.map +1 -0
- package/dist/tools/doc-fetcher.d.ts +19 -0
- package/dist/tools/doc-fetcher.d.ts.map +1 -0
- package/dist/tools/doc-fetcher.js +487 -0
- package/dist/tools/doc-fetcher.js.map +1 -0
- package/dist/tools/doc-formatter.d.ts +69 -0
- package/dist/tools/doc-formatter.d.ts.map +1 -0
- package/dist/tools/doc-formatter.js +208 -0
- package/dist/tools/doc-formatter.js.map +1 -0
- package/dist/tools/find-similar-apis.d.ts +5 -0
- package/dist/tools/find-similar-apis.d.ts.map +1 -0
- package/dist/tools/find-similar-apis.js +275 -0
- package/dist/tools/find-similar-apis.js.map +1 -0
- package/dist/tools/get-documentation-updates.d.ts +5 -0
- package/dist/tools/get-documentation-updates.d.ts.map +1 -0
- package/dist/tools/get-documentation-updates.js +244 -0
- package/dist/tools/get-documentation-updates.js.map +1 -0
- package/dist/tools/get-platform-compatibility.d.ts +5 -0
- package/dist/tools/get-platform-compatibility.d.ts.map +1 -0
- package/dist/tools/get-platform-compatibility.js +205 -0
- package/dist/tools/get-platform-compatibility.js.map +1 -0
- package/dist/tools/get-related-apis.d.ts +5 -0
- package/dist/tools/get-related-apis.d.ts.map +1 -0
- package/dist/tools/get-related-apis.js +155 -0
- package/dist/tools/get-related-apis.js.map +1 -0
- package/dist/tools/get-sample-code.d.ts +5 -0
- package/dist/tools/get-sample-code.d.ts.map +1 -0
- package/dist/tools/get-sample-code.js +375 -0
- package/dist/tools/get-sample-code.js.map +1 -0
- package/dist/tools/get-technology-overviews.d.ts +5 -0
- package/dist/tools/get-technology-overviews.d.ts.map +1 -0
- package/dist/tools/get-technology-overviews.js +306 -0
- package/dist/tools/get-technology-overviews.js.map +1 -0
- package/dist/tools/handlers.d.ts +29 -0
- package/dist/tools/handlers.d.ts.map +1 -0
- package/dist/tools/handlers.js +350 -0
- package/dist/tools/handlers.js.map +1 -0
- package/dist/tools/list-technologies.d.ts +5 -0
- package/dist/tools/list-technologies.d.ts.map +1 -0
- package/dist/tools/list-technologies.js +165 -0
- package/dist/tools/list-technologies.js.map +1 -0
- package/dist/tools/resolve-references-batch.d.ts +5 -0
- package/dist/tools/resolve-references-batch.d.ts.map +1 -0
- package/dist/tools/resolve-references-batch.js +199 -0
- package/dist/tools/resolve-references-batch.js.map +1 -0
- package/dist/tools/search-framework-symbols.d.ts +7 -0
- package/dist/tools/search-framework-symbols.d.ts.map +1 -0
- package/dist/tools/search-framework-symbols.js +235 -0
- package/dist/tools/search-framework-symbols.js.map +1 -0
- package/dist/tools/search-parser.d.ts +15 -0
- package/dist/tools/search-parser.d.ts.map +1 -0
- package/dist/tools/search-parser.js +188 -0
- package/dist/tools/search-parser.js.map +1 -0
- package/dist/tools/search-result-parser.d.ts +52 -0
- package/dist/tools/search-result-parser.d.ts.map +1 -0
- package/dist/tools/search-result-parser.js +137 -0
- package/dist/tools/search-result-parser.js.map +1 -0
- package/dist/tools/tools-guide.d.ts +124 -0
- package/dist/tools/tools-guide.d.ts.map +1 -0
- package/dist/tools/tools-guide.js +389 -0
- package/dist/tools/tools-guide.js.map +1 -0
- package/dist/tools/wwdc/content-extractor.d.ts +9 -0
- package/dist/tools/wwdc/content-extractor.d.ts.map +1 -0
- package/dist/tools/wwdc/content-extractor.js +520 -0
- package/dist/tools/wwdc/content-extractor.js.map +1 -0
- package/dist/tools/wwdc/topics-extractor.d.ts +32 -0
- package/dist/tools/wwdc/topics-extractor.d.ts.map +1 -0
- package/dist/tools/wwdc/topics-extractor.js +146 -0
- package/dist/tools/wwdc/topics-extractor.js.map +1 -0
- package/dist/tools/wwdc/video-list-extractor.d.ts +13 -0
- package/dist/tools/wwdc/video-list-extractor.d.ts.map +1 -0
- package/dist/tools/wwdc/video-list-extractor.js +238 -0
- package/dist/tools/wwdc/video-list-extractor.js.map +1 -0
- package/dist/tools/wwdc/wwdc-handlers.d.ts +32 -0
- package/dist/tools/wwdc/wwdc-handlers.d.ts.map +1 -0
- package/dist/tools/wwdc/wwdc-handlers.js +791 -0
- package/dist/tools/wwdc/wwdc-handlers.js.map +1 -0
- package/dist/types/apple-docs.d.ts +112 -0
- package/dist/types/apple-docs.d.ts.map +1 -0
- package/dist/types/apple-docs.js +5 -0
- package/dist/types/apple-docs.js.map +1 -0
- package/dist/types/cache.d.ts +28 -0
- package/dist/types/cache.d.ts.map +1 -0
- package/dist/types/cache.js +5 -0
- package/dist/types/cache.js.map +1 -0
- package/dist/types/content-sections.d.ts +37 -0
- package/dist/types/content-sections.d.ts.map +1 -0
- package/dist/types/content-sections.js +5 -0
- package/dist/types/content-sections.js.map +1 -0
- package/dist/types/error.d.ts +39 -0
- package/dist/types/error.d.ts.map +1 -0
- package/dist/types/error.js +21 -0
- package/dist/types/error.js.map +1 -0
- package/dist/types/headers.d.ts +95 -0
- package/dist/types/headers.d.ts.map +1 -0
- package/dist/types/headers.js +5 -0
- package/dist/types/headers.js.map +1 -0
- package/dist/types/http.d.ts +31 -0
- package/dist/types/http.d.ts.map +1 -0
- package/dist/types/http.js +5 -0
- package/dist/types/http.js.map +1 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +12 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/search.d.ts +62 -0
- package/dist/types/search.d.ts.map +1 -0
- package/dist/types/search.js +5 -0
- package/dist/types/search.js.map +1 -0
- package/dist/types/sections.d.ts +64 -0
- package/dist/types/sections.d.ts.map +1 -0
- package/dist/types/sections.js +5 -0
- package/dist/types/sections.js.map +1 -0
- package/dist/types/tools/platform.d.ts +33 -0
- package/dist/types/tools/platform.d.ts.map +1 -0
- package/dist/types/tools/platform.js +5 -0
- package/dist/types/tools/platform.js.map +1 -0
- package/dist/types/tools/sample-code.d.ts +23 -0
- package/dist/types/tools/sample-code.d.ts.map +1 -0
- package/dist/types/tools/sample-code.js +5 -0
- package/dist/types/tools/sample-code.js.map +1 -0
- package/dist/types/tools/technology.d.ts +18 -0
- package/dist/types/tools/technology.d.ts.map +1 -0
- package/dist/types/tools/technology.js +5 -0
- package/dist/types/tools/technology.js.map +1 -0
- package/dist/types/tools/updates.d.ts +23 -0
- package/dist/types/tools/updates.d.ts.map +1 -0
- package/dist/types/tools/updates.js +5 -0
- package/dist/types/tools/updates.js.map +1 -0
- package/dist/types/wwdc.d.ts +200 -0
- package/dist/types/wwdc.d.ts.map +1 -0
- package/dist/types/wwdc.js +5 -0
- package/dist/types/wwdc.js.map +1 -0
- package/dist/utils/cache-warmer.d.ts +22 -0
- package/dist/utils/cache-warmer.d.ts.map +1 -0
- package/dist/utils/cache-warmer.js +115 -0
- package/dist/utils/cache-warmer.js.map +1 -0
- package/dist/utils/cache.d.ts +109 -0
- package/dist/utils/cache.d.ts.map +1 -0
- package/dist/utils/cache.js +302 -0
- package/dist/utils/cache.js.map +1 -0
- package/dist/utils/constants.d.ts +178 -0
- package/dist/utils/constants.d.ts.map +1 -0
- package/dist/utils/constants.js +266 -0
- package/dist/utils/constants.js.map +1 -0
- package/dist/utils/error-handler.d.ts +80 -0
- package/dist/utils/error-handler.d.ts.map +1 -0
- package/dist/utils/error-handler.js +437 -0
- package/dist/utils/error-handler.js.map +1 -0
- package/dist/utils/framework-mapper.d.ts +84 -0
- package/dist/utils/framework-mapper.d.ts.map +1 -0
- package/dist/utils/framework-mapper.js +534 -0
- package/dist/utils/framework-mapper.js.map +1 -0
- package/dist/utils/http-client.d.ts +130 -0
- package/dist/utils/http-client.d.ts.map +1 -0
- package/dist/utils/http-client.js +464 -0
- package/dist/utils/http-client.js.map +1 -0
- package/dist/utils/http-headers-generator.d.ts +151 -0
- package/dist/utils/http-headers-generator.d.ts.map +1 -0
- package/dist/utils/http-headers-generator.js +407 -0
- package/dist/utils/http-headers-generator.js.map +1 -0
- package/dist/utils/logger.d.ts +44 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +73 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/preloader.d.ts +20 -0
- package/dist/utils/preloader.d.ts.map +1 -0
- package/dist/utils/preloader.js +82 -0
- package/dist/utils/preloader.js.map +1 -0
- package/dist/utils/rate-limiter.d.ts +28 -0
- package/dist/utils/rate-limiter.d.ts.map +1 -0
- package/dist/utils/rate-limiter.js +48 -0
- package/dist/utils/rate-limiter.js.map +1 -0
- package/dist/utils/topic-mapper.d.ts +18 -0
- package/dist/utils/topic-mapper.d.ts.map +1 -0
- package/dist/utils/topic-mapper.js +182 -0
- package/dist/utils/topic-mapper.js.map +1 -0
- package/dist/utils/url-converter.d.ts +22 -0
- package/dist/utils/url-converter.d.ts.map +1 -0
- package/dist/utils/url-converter.js +70 -0
- package/dist/utils/url-converter.js.map +1 -0
- package/dist/utils/user-agent-pool.d.ts +241 -0
- package/dist/utils/user-agent-pool.d.ts.map +1 -0
- package/dist/utils/user-agent-pool.js +557 -0
- package/dist/utils/user-agent-pool.js.map +1 -0
- package/dist/utils/wwdc-data-source-path.d.ts +9 -0
- package/dist/utils/wwdc-data-source-path.d.ts.map +1 -0
- package/dist/utils/wwdc-data-source-path.js +22 -0
- package/dist/utils/wwdc-data-source-path.js.map +1 -0
- package/dist/utils/wwdc-data-source.d.ts +36 -0
- package/dist/utils/wwdc-data-source.d.ts.map +1 -0
- package/dist/utils/wwdc-data-source.js +133 -0
- package/dist/utils/wwdc-data-source.js.map +1 -0
- package/package.json +83 -0
|
@@ -0,0 +1,437 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified error handling utilities
|
|
3
|
+
*/
|
|
4
|
+
import { ERROR_MESSAGES } from './constants.js';
|
|
5
|
+
import { ErrorType } from '../types/error.js';
|
|
6
|
+
import { logger } from './logger.js';
|
|
7
|
+
export { ErrorType };
|
|
8
|
+
/**
|
|
9
|
+
* Create a standardized error response
|
|
10
|
+
*/
|
|
11
|
+
export function createErrorResponse(error) {
|
|
12
|
+
let message = `Error: ${error.message}`;
|
|
13
|
+
if (error.suggestions && error.suggestions.length > 0) {
|
|
14
|
+
message += '\n\nSuggestions:\n' + error.suggestions.map(s => `• ${s}`).join('\n');
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
content: [
|
|
18
|
+
{
|
|
19
|
+
type: 'text',
|
|
20
|
+
text: message,
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
isError: true,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Handle fetch errors with specific error types
|
|
28
|
+
*/
|
|
29
|
+
export function handleFetchError(error, url) {
|
|
30
|
+
if (error instanceof TypeError) {
|
|
31
|
+
return {
|
|
32
|
+
type: ErrorType.NETWORK_ERROR,
|
|
33
|
+
message: ERROR_MESSAGES.NETWORK_ERROR,
|
|
34
|
+
originalError: error,
|
|
35
|
+
suggestions: [
|
|
36
|
+
'Check your internet connection',
|
|
37
|
+
'Verify the URL is accessible',
|
|
38
|
+
'Try again in a few moments',
|
|
39
|
+
],
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
if (error instanceof Error) {
|
|
43
|
+
if (error.message.includes('timeout')) {
|
|
44
|
+
return {
|
|
45
|
+
type: ErrorType.TIMEOUT,
|
|
46
|
+
message: ERROR_MESSAGES.TIMEOUT,
|
|
47
|
+
originalError: error,
|
|
48
|
+
suggestions: [
|
|
49
|
+
'Try again with a simpler query',
|
|
50
|
+
'Check your network connection',
|
|
51
|
+
],
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
if (error.message.includes('404')) {
|
|
55
|
+
return {
|
|
56
|
+
type: ErrorType.NOT_FOUND,
|
|
57
|
+
message: ERROR_MESSAGES.NOT_FOUND,
|
|
58
|
+
originalError: error,
|
|
59
|
+
suggestions: [
|
|
60
|
+
'Search for the topic in Apple Developer Documentation',
|
|
61
|
+
'Check if this is an outdated link',
|
|
62
|
+
`Visit the original URL directly: ${url}`,
|
|
63
|
+
],
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
type: ErrorType.UNKNOWN,
|
|
68
|
+
message: error.message,
|
|
69
|
+
originalError: error,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
type: ErrorType.UNKNOWN,
|
|
74
|
+
message: String(error),
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Handle JSON parsing errors
|
|
79
|
+
*/
|
|
80
|
+
export function handleParseError(error) {
|
|
81
|
+
return {
|
|
82
|
+
type: ErrorType.PARSE_ERROR,
|
|
83
|
+
message: ERROR_MESSAGES.PARSE_FAILED,
|
|
84
|
+
originalError: error instanceof Error ? error : undefined,
|
|
85
|
+
suggestions: [
|
|
86
|
+
'The API response format may have changed',
|
|
87
|
+
'Try again later',
|
|
88
|
+
'Report this issue if it persists',
|
|
89
|
+
],
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Validate input parameters
|
|
94
|
+
*/
|
|
95
|
+
export function validateInput(value, fieldName, minLength = 1) {
|
|
96
|
+
if (!value || value.trim().length < minLength) {
|
|
97
|
+
return {
|
|
98
|
+
type: ErrorType.INVALID_INPUT,
|
|
99
|
+
message: `${fieldName} is required and must be at least ${minLength} character(s)`,
|
|
100
|
+
suggestions: [
|
|
101
|
+
`Provide a valid ${fieldName.toLowerCase()}`,
|
|
102
|
+
'Check the parameter format',
|
|
103
|
+
],
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Log error for debugging (only in development)
|
|
110
|
+
*/
|
|
111
|
+
export function logError(error, context) {
|
|
112
|
+
if (process.env.NODE_ENV === 'development') {
|
|
113
|
+
logger.error(`[${context ?? 'ERROR'}] ${error.message}`, error.originalError);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Handle generic errors and convert them to AppError
|
|
118
|
+
*/
|
|
119
|
+
export function handleGenericError(error, context, fallbackMessage) {
|
|
120
|
+
logger.error(`Error in ${context}:`, error);
|
|
121
|
+
if (error instanceof Error) {
|
|
122
|
+
// Check for specific error types
|
|
123
|
+
if (error.message.includes('timeout') || error.message.includes('ETIMEDOUT')) {
|
|
124
|
+
return {
|
|
125
|
+
type: ErrorType.TIMEOUT,
|
|
126
|
+
message: ERROR_MESSAGES.TIMEOUT,
|
|
127
|
+
originalError: error,
|
|
128
|
+
suggestions: [
|
|
129
|
+
'Try again with a simpler query',
|
|
130
|
+
'Check your network connection',
|
|
131
|
+
'Verify the service is available',
|
|
132
|
+
],
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
if (error.message.includes('429') || error.message.includes('rate limit')) {
|
|
136
|
+
return {
|
|
137
|
+
type: ErrorType.RATE_LIMITED,
|
|
138
|
+
message: 'Request rate limit exceeded',
|
|
139
|
+
originalError: error,
|
|
140
|
+
suggestions: [
|
|
141
|
+
'Wait a moment before trying again',
|
|
142
|
+
'Consider reducing the frequency of requests',
|
|
143
|
+
],
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
if (error.message.includes('500') || error.message.includes('502') || error.message.includes('503')) {
|
|
147
|
+
return {
|
|
148
|
+
type: ErrorType.SERVICE_UNAVAILABLE,
|
|
149
|
+
message: 'Apple Developer Documentation service is temporarily unavailable',
|
|
150
|
+
originalError: error,
|
|
151
|
+
suggestions: [
|
|
152
|
+
'Try again in a few minutes',
|
|
153
|
+
'Check Apple Developer status page',
|
|
154
|
+
'Verify your internet connection',
|
|
155
|
+
],
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
if (error.message.includes('JSON') || error.message.includes('parse')) {
|
|
159
|
+
return handleParseError(error);
|
|
160
|
+
}
|
|
161
|
+
return {
|
|
162
|
+
type: ErrorType.API_ERROR,
|
|
163
|
+
message: error.message,
|
|
164
|
+
originalError: error,
|
|
165
|
+
suggestions: [
|
|
166
|
+
'Check the request parameters',
|
|
167
|
+
'Try again later',
|
|
168
|
+
'Verify the API endpoint is correct',
|
|
169
|
+
],
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
return {
|
|
173
|
+
type: ErrorType.UNKNOWN,
|
|
174
|
+
message: fallbackMessage || `An error occurred in ${context}`,
|
|
175
|
+
suggestions: [
|
|
176
|
+
'Try again later',
|
|
177
|
+
'Check your input parameters',
|
|
178
|
+
'Contact support if the issue persists',
|
|
179
|
+
],
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Create a standardized error response with consistent formatting
|
|
184
|
+
*/
|
|
185
|
+
export function createStandardErrorResponse(error, operation) {
|
|
186
|
+
const appError = handleGenericError(error, operation);
|
|
187
|
+
return createErrorResponse(appError);
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Wrap async functions with error handling
|
|
191
|
+
*/
|
|
192
|
+
export async function withErrorHandling(operation, context, fallbackMessage) {
|
|
193
|
+
try {
|
|
194
|
+
return await operation();
|
|
195
|
+
}
|
|
196
|
+
catch (error) {
|
|
197
|
+
const appError = handleGenericError(error, context, fallbackMessage);
|
|
198
|
+
logError(appError, context);
|
|
199
|
+
throw appError;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Validate multiple input parameters
|
|
204
|
+
*/
|
|
205
|
+
export function validateInputs(validations) {
|
|
206
|
+
for (const validation of validations) {
|
|
207
|
+
const error = validateInput(validation.value, validation.fieldName, validation.minLength);
|
|
208
|
+
if (error) {
|
|
209
|
+
return error;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
return null;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Handle cache-related errors
|
|
216
|
+
*/
|
|
217
|
+
export function handleCacheError(error, operation) {
|
|
218
|
+
return {
|
|
219
|
+
type: ErrorType.CACHE_ERROR,
|
|
220
|
+
message: `Cache operation failed: ${operation}`,
|
|
221
|
+
originalError: error instanceof Error ? error : undefined,
|
|
222
|
+
suggestions: [
|
|
223
|
+
'The operation will continue without cache',
|
|
224
|
+
'Try clearing the cache if issues persist',
|
|
225
|
+
],
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Tool-specific recovery actions - ready-to-use tool calls for error recovery
|
|
230
|
+
*/
|
|
231
|
+
export const TOOL_RECOVERY_ACTIONS = {
|
|
232
|
+
search_apple_docs: {
|
|
233
|
+
[ErrorType.NOT_FOUND]: {
|
|
234
|
+
tool: 'list_technologies',
|
|
235
|
+
args: { limit: 20, compact: true },
|
|
236
|
+
reason: 'Discover available frameworks to search within',
|
|
237
|
+
},
|
|
238
|
+
[ErrorType.INVALID_INPUT]: {
|
|
239
|
+
tool: 'get_tool_guide',
|
|
240
|
+
args: { task: 'search for Apple documentation' },
|
|
241
|
+
reason: 'Get guidance on search best practices',
|
|
242
|
+
},
|
|
243
|
+
},
|
|
244
|
+
search_framework_symbols: {
|
|
245
|
+
[ErrorType.NOT_FOUND]: {
|
|
246
|
+
tool: 'list_technologies',
|
|
247
|
+
args: { limit: 25, compact: true },
|
|
248
|
+
reason: 'Find available framework identifiers',
|
|
249
|
+
},
|
|
250
|
+
[ErrorType.INVALID_INPUT]: {
|
|
251
|
+
tool: 'list_technologies',
|
|
252
|
+
args: { limit: 25, compact: true },
|
|
253
|
+
reason: 'Get correct framework identifiers',
|
|
254
|
+
},
|
|
255
|
+
},
|
|
256
|
+
get_apple_doc_content: {
|
|
257
|
+
[ErrorType.NOT_FOUND]: {
|
|
258
|
+
tool: 'search_apple_docs',
|
|
259
|
+
args: { type: 'documentation', compact: true },
|
|
260
|
+
reason: 'Search for valid documentation URLs',
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
get_related_apis: {
|
|
264
|
+
[ErrorType.NOT_FOUND]: {
|
|
265
|
+
tool: 'search_apple_docs',
|
|
266
|
+
args: { type: 'documentation', compact: true },
|
|
267
|
+
reason: 'Find valid API documentation first',
|
|
268
|
+
},
|
|
269
|
+
},
|
|
270
|
+
find_similar_apis: {
|
|
271
|
+
[ErrorType.NOT_FOUND]: {
|
|
272
|
+
tool: 'analyze_api',
|
|
273
|
+
args: { analysis: 'related', compact: true },
|
|
274
|
+
reason: 'Try analyzing related APIs instead',
|
|
275
|
+
},
|
|
276
|
+
},
|
|
277
|
+
list_wwdc_videos: {
|
|
278
|
+
[ErrorType.NOT_FOUND]: {
|
|
279
|
+
tool: 'wwdc',
|
|
280
|
+
args: { action: 'years' },
|
|
281
|
+
reason: 'List available WWDC years',
|
|
282
|
+
},
|
|
283
|
+
},
|
|
284
|
+
get_wwdc_video: {
|
|
285
|
+
[ErrorType.NOT_FOUND]: {
|
|
286
|
+
tool: 'wwdc',
|
|
287
|
+
args: { action: 'list', compact: true },
|
|
288
|
+
reason: 'Browse available WWDC videos',
|
|
289
|
+
},
|
|
290
|
+
},
|
|
291
|
+
};
|
|
292
|
+
/**
|
|
293
|
+
* Tool-specific error suggestions
|
|
294
|
+
*/
|
|
295
|
+
export const TOOL_ERROR_SUGGESTIONS = {
|
|
296
|
+
search_apple_docs: {
|
|
297
|
+
[ErrorType.NOT_FOUND]: [
|
|
298
|
+
'Try broader search terms (e.g., "UIView" instead of "UIViewAnimationOptions")',
|
|
299
|
+
'Use framework names like "SwiftUI" or "UIKit"',
|
|
300
|
+
'Check spelling and avoid special characters',
|
|
301
|
+
'For WWDC videos, use search_wwdc_content instead',
|
|
302
|
+
],
|
|
303
|
+
[ErrorType.INVALID_INPUT]: [
|
|
304
|
+
'Provide specific API or framework names',
|
|
305
|
+
'Avoid generic terms like "how to" or "tutorial"',
|
|
306
|
+
'Use technical terms like class names or method names',
|
|
307
|
+
],
|
|
308
|
+
},
|
|
309
|
+
get_apple_doc_content: {
|
|
310
|
+
[ErrorType.NOT_FOUND]: [
|
|
311
|
+
'Verify the URL starts with https://developer.apple.com/documentation/',
|
|
312
|
+
'Use search_apple_docs first to find valid URLs',
|
|
313
|
+
'Check if the API might have been renamed or moved',
|
|
314
|
+
],
|
|
315
|
+
[ErrorType.INVALID_INPUT]: [
|
|
316
|
+
'URL must be a complete Apple Developer Documentation URL',
|
|
317
|
+
'Example: https://developer.apple.com/documentation/uikit/uiview',
|
|
318
|
+
],
|
|
319
|
+
},
|
|
320
|
+
search_framework_symbols: {
|
|
321
|
+
[ErrorType.NOT_FOUND]: [
|
|
322
|
+
'Use list_technologies to find exact framework identifiers',
|
|
323
|
+
'Framework names should be lowercase (e.g., "uikit" not "UIKit")',
|
|
324
|
+
'Some frameworks might be part of larger frameworks',
|
|
325
|
+
],
|
|
326
|
+
[ErrorType.INVALID_INPUT]: [
|
|
327
|
+
'Framework identifier must be in lowercase',
|
|
328
|
+
'Common identifiers: "uikit", "swiftui", "foundation", "combine"',
|
|
329
|
+
'Use list_technologies to discover available frameworks',
|
|
330
|
+
],
|
|
331
|
+
},
|
|
332
|
+
list_wwdc_videos: {
|
|
333
|
+
[ErrorType.NOT_FOUND]: [
|
|
334
|
+
'Available years are 2020-2025',
|
|
335
|
+
'Use "all" to see videos from all years',
|
|
336
|
+
'Topic searches are case-insensitive partial matches',
|
|
337
|
+
],
|
|
338
|
+
[ErrorType.INVALID_INPUT]: [
|
|
339
|
+
'Year should be a 4-digit string like "2025"',
|
|
340
|
+
'Topic can be any keyword like "SwiftUI" or "Performance"',
|
|
341
|
+
],
|
|
342
|
+
},
|
|
343
|
+
search_wwdc_content: {
|
|
344
|
+
[ErrorType.NOT_FOUND]: [
|
|
345
|
+
'Try different search terms or broaden your query',
|
|
346
|
+
'Search is case-insensitive',
|
|
347
|
+
'Use technical terms that would appear in transcripts',
|
|
348
|
+
],
|
|
349
|
+
[ErrorType.INVALID_INPUT]: [
|
|
350
|
+
'Query is required and cannot be empty',
|
|
351
|
+
'searchIn must be "transcript", "code", or "both"',
|
|
352
|
+
],
|
|
353
|
+
},
|
|
354
|
+
get_platform_compatibility: {
|
|
355
|
+
[ErrorType.API_ERROR]: [
|
|
356
|
+
'Platform data might not be available for all APIs',
|
|
357
|
+
'Try using the single API mode instead of framework mode',
|
|
358
|
+
'Some newer APIs might not have compatibility data yet',
|
|
359
|
+
],
|
|
360
|
+
},
|
|
361
|
+
find_similar_apis: {
|
|
362
|
+
[ErrorType.NOT_FOUND]: [
|
|
363
|
+
'Not all APIs have similar alternatives documented',
|
|
364
|
+
'Try using a broader search depth ("deep" instead of "shallow")',
|
|
365
|
+
'Consider using get_related_apis for inheritance relationships',
|
|
366
|
+
],
|
|
367
|
+
},
|
|
368
|
+
};
|
|
369
|
+
/**
|
|
370
|
+
* Get tool-specific error suggestions
|
|
371
|
+
*/
|
|
372
|
+
export function getToolErrorSuggestions(toolName, errorType) {
|
|
373
|
+
const toolSuggestions = TOOL_ERROR_SUGGESTIONS[toolName]?.[errorType];
|
|
374
|
+
if (toolSuggestions) {
|
|
375
|
+
return toolSuggestions;
|
|
376
|
+
}
|
|
377
|
+
// Default suggestions based on error type
|
|
378
|
+
switch (errorType) {
|
|
379
|
+
case ErrorType.NOT_FOUND:
|
|
380
|
+
return [
|
|
381
|
+
'Verify the input parameters are correct',
|
|
382
|
+
'Try using a search tool first to find valid values',
|
|
383
|
+
'Check if the resource exists on developer.apple.com',
|
|
384
|
+
];
|
|
385
|
+
case ErrorType.INVALID_INPUT:
|
|
386
|
+
return [
|
|
387
|
+
'Check the parameter format and requirements',
|
|
388
|
+
'Refer to the tool description for examples',
|
|
389
|
+
'Ensure all required parameters are provided',
|
|
390
|
+
];
|
|
391
|
+
case ErrorType.TIMEOUT:
|
|
392
|
+
return [
|
|
393
|
+
'Try with fewer results or simpler queries',
|
|
394
|
+
'The service might be temporarily slow',
|
|
395
|
+
'Consider breaking the request into smaller parts',
|
|
396
|
+
];
|
|
397
|
+
default:
|
|
398
|
+
return [];
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Get recovery action for a tool error
|
|
403
|
+
*/
|
|
404
|
+
export function getRecoveryAction(toolName, errorType) {
|
|
405
|
+
return TOOL_RECOVERY_ACTIONS[toolName]?.[errorType] ?? null;
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Create error response with tool-specific suggestions and recovery actions
|
|
409
|
+
*/
|
|
410
|
+
export function createToolErrorResponse(error, toolName) {
|
|
411
|
+
const toolSuggestions = getToolErrorSuggestions(toolName, error.type);
|
|
412
|
+
const recoveryAction = getRecoveryAction(toolName, error.type);
|
|
413
|
+
if (toolSuggestions.length > 0) {
|
|
414
|
+
error.suggestions = [...(error.suggestions ?? []), ...toolSuggestions];
|
|
415
|
+
}
|
|
416
|
+
let message = `Error: ${error.message}`;
|
|
417
|
+
if (error.suggestions && error.suggestions.length > 0) {
|
|
418
|
+
message += '\n\nSuggestions:\n' + error.suggestions.map(s => `- ${s}`).join('\n');
|
|
419
|
+
}
|
|
420
|
+
// Add recovery action if available
|
|
421
|
+
if (recoveryAction) {
|
|
422
|
+
message += '\n\n**Recovery Action:**\n';
|
|
423
|
+
message += `Tool: \`${recoveryAction.tool}\`\n`;
|
|
424
|
+
message += `Args: \`${JSON.stringify(recoveryAction.args)}\`\n`;
|
|
425
|
+
message += `Reason: ${recoveryAction.reason}`;
|
|
426
|
+
}
|
|
427
|
+
return {
|
|
428
|
+
content: [
|
|
429
|
+
{
|
|
430
|
+
type: 'text',
|
|
431
|
+
text: message,
|
|
432
|
+
},
|
|
433
|
+
],
|
|
434
|
+
isError: true,
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
//# sourceMappingURL=error-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-handler.js","sourceRoot":"","sources":["../../src/utils/error-handler.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAIrC,OAAO,EAAE,SAAS,EAAE,CAAC;AAErB;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAe;IACjD,IAAI,OAAO,GAAG,UAAU,KAAK,CAAC,OAAO,EAAE,CAAC;IAExC,IAAI,KAAK,CAAC,WAAW,IAAI,KAAK,CAAC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G,CAAC,EAAE,CAAC;QACtD,OAAO,IAAI,oBAAoB,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACpF,CAAC;IAED,mCAAmC;IACnC,IAAI,cAAc,EAAE,CAAC;QACnB,OAAO,IAAI,4BAA4B,CAAC;QACxC,OAAO,IAAI,WAAW,cAAc,CAAC,IAAI,MAAM,CAAC;QAChD,OAAO,IAAI,WAAW,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC;QAChE,OAAO,IAAI,WAAW,cAAc,CAAC,MAAM,EAAE,CAAC;IAChD,CAAC;IAED,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAe;gBACrB,IAAI,EAAE,OAAO;aACd;SACF;QACD,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified framework name mapping system for Apple Docs MCP
|
|
3
|
+
*
|
|
4
|
+
* This module provides consistent framework name normalization across all tools.
|
|
5
|
+
* It handles common variations, typos, and alternative names for Apple frameworks.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Comprehensive framework name mappings
|
|
9
|
+
* Maps lowercase/alternative names to canonical Apple framework names
|
|
10
|
+
*/
|
|
11
|
+
export declare const FRAMEWORK_MAPPINGS: Record<string, string>;
|
|
12
|
+
/**
|
|
13
|
+
* Alternative framework names and common aliases
|
|
14
|
+
*/
|
|
15
|
+
export declare const FRAMEWORK_ALIASES: Record<string, string[]>;
|
|
16
|
+
/**
|
|
17
|
+
* Framework categories for organization
|
|
18
|
+
*/
|
|
19
|
+
export declare const FRAMEWORK_CATEGORIES: {
|
|
20
|
+
readonly UI: readonly ["SwiftUI", "UIKit", "AppKit", "WidgetKit", "WatchKit"];
|
|
21
|
+
readonly Graphics: readonly ["Core Graphics", "Core Image", "Core Animation", "Metal"];
|
|
22
|
+
readonly Games: readonly ["ARKit", "RealityKit", "SceneKit", "SpriteKit", "GameKit"];
|
|
23
|
+
readonly Media: readonly ["AVFoundation", "Core Audio", "PhotoKit", "MusicKit"];
|
|
24
|
+
readonly Data: readonly ["Core Data", "CloudKit", "UserDefaults", "Keychain Services"];
|
|
25
|
+
readonly ML: readonly ["Core ML", "Create ML", "Natural Language", "Vision", "Speech"];
|
|
26
|
+
readonly Services: readonly ["HealthKit", "HomeKit", "MapKit", "StoreKit", "AlarmKit"];
|
|
27
|
+
readonly System: readonly ["Core Bluetooth", "Core Motion", "Core Location"];
|
|
28
|
+
readonly Foundation: readonly ["Foundation", "Combine", "Swift"];
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Normalize a framework name to its canonical Apple form
|
|
32
|
+
*
|
|
33
|
+
* @param framework - The framework name to normalize (case-insensitive)
|
|
34
|
+
* @returns The canonical framework name, or the original if no mapping exists
|
|
35
|
+
*/
|
|
36
|
+
export declare function normalizeFrameworkName(framework: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* Get all possible aliases for a framework
|
|
39
|
+
*
|
|
40
|
+
* @param framework - The canonical framework name
|
|
41
|
+
* @returns Array of all known aliases for the framework
|
|
42
|
+
*/
|
|
43
|
+
export declare function getFrameworkAliases(framework: string): string[];
|
|
44
|
+
/**
|
|
45
|
+
* Check if a framework name is valid (has a known mapping)
|
|
46
|
+
*
|
|
47
|
+
* @param framework - The framework name to check
|
|
48
|
+
* @returns True if the framework is recognized
|
|
49
|
+
*/
|
|
50
|
+
export declare function isValidFramework(framework: string): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Get frameworks by category
|
|
53
|
+
*
|
|
54
|
+
* @param category - The category name
|
|
55
|
+
* @returns Array of framework names in the category
|
|
56
|
+
*/
|
|
57
|
+
export declare function getFrameworksByCategory(category: keyof typeof FRAMEWORK_CATEGORIES): string[];
|
|
58
|
+
/**
|
|
59
|
+
* Find the category of a framework
|
|
60
|
+
*
|
|
61
|
+
* @param framework - The framework name
|
|
62
|
+
* @returns The category name or null if not found
|
|
63
|
+
*/
|
|
64
|
+
export declare function getFrameworkCategory(framework: string): keyof typeof FRAMEWORK_CATEGORIES | null;
|
|
65
|
+
/**
|
|
66
|
+
* Search for frameworks by partial name or description
|
|
67
|
+
*
|
|
68
|
+
* @param query - The search query
|
|
69
|
+
* @returns Array of matching framework names
|
|
70
|
+
*/
|
|
71
|
+
export declare function searchFrameworks(query: string): string[];
|
|
72
|
+
/**
|
|
73
|
+
* Get comprehensive framework information
|
|
74
|
+
*
|
|
75
|
+
* @param framework - The framework name
|
|
76
|
+
* @returns Object with framework details
|
|
77
|
+
*/
|
|
78
|
+
export declare function getFrameworkInfo(framework: string): {
|
|
79
|
+
canonical: string;
|
|
80
|
+
aliases: string[];
|
|
81
|
+
category: string | null;
|
|
82
|
+
isValid: boolean;
|
|
83
|
+
};
|
|
84
|
+
//# sourceMappingURL=framework-mapper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"framework-mapper.d.ts","sourceRoot":"","sources":["../../src/utils/framework-mapper.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAsX5C,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAwB7C,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;CAUvB,CAAC;AAEX;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CA2BhE;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,CAG/D;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAU3D;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,OAAO,oBAAoB,GAAG,MAAM,EAAE,CAE7F;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,OAAO,oBAAoB,GAAG,IAAI,CAUhG;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAuBxD;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG;IACnD,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,OAAO,EAAE,OAAO,CAAC;CAClB,CAYA"}
|