ebay-mcp-remote-edition 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.
Files changed (129) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +755 -0
  3. package/build/api/account-management/account.js +301 -0
  4. package/build/api/analytics-and-report/analytics.js +102 -0
  5. package/build/api/client-trading.js +96 -0
  6. package/build/api/client.js +173 -0
  7. package/build/api/communication/feedback.js +119 -0
  8. package/build/api/communication/message.js +131 -0
  9. package/build/api/communication/negotiation.js +97 -0
  10. package/build/api/communication/notification.js +373 -0
  11. package/build/api/developer/developer.js +81 -0
  12. package/build/api/index.js +109 -0
  13. package/build/api/listing-management/inventory.js +640 -0
  14. package/build/api/listing-metadata/metadata.js +485 -0
  15. package/build/api/listing-metadata/taxonomy.js +58 -0
  16. package/build/api/marketing-and-promotions/marketing.js +768 -0
  17. package/build/api/marketing-and-promotions/recommendation.js +32 -0
  18. package/build/api/order-management/dispute.js +69 -0
  19. package/build/api/order-management/fulfillment.js +89 -0
  20. package/build/api/other/compliance.js +47 -0
  21. package/build/api/other/edelivery.js +219 -0
  22. package/build/api/other/identity.js +24 -0
  23. package/build/api/other/translation.js +22 -0
  24. package/build/api/other/vero.js +48 -0
  25. package/build/api/trading/trading.js +78 -0
  26. package/build/auth/kv-store.js +40 -0
  27. package/build/auth/multi-user-store.js +120 -0
  28. package/build/auth/oauth-metadata.js +59 -0
  29. package/build/auth/oauth-middleware.js +99 -0
  30. package/build/auth/oauth-types.js +4 -0
  31. package/build/auth/oauth.js +235 -0
  32. package/build/auth/scope-utils.js +304 -0
  33. package/build/auth/token-store.js +46 -0
  34. package/build/auth/token-verifier.js +172 -0
  35. package/build/config/environment.js +297 -0
  36. package/build/index.d.ts +1 -0
  37. package/build/index.js +129 -0
  38. package/build/schemas/account-management/account.js +375 -0
  39. package/build/schemas/analytics/analytics.js +191 -0
  40. package/build/schemas/communication/messages.js +345 -0
  41. package/build/schemas/fulfillment/orders.js +338 -0
  42. package/build/schemas/index.js +68 -0
  43. package/build/schemas/inventory-management/inventory.js +471 -0
  44. package/build/schemas/marketing/marketing.js +1103 -0
  45. package/build/schemas/metadata/metadata.js +618 -0
  46. package/build/schemas/other/other-apis.js +390 -0
  47. package/build/schemas/taxonomy/taxonomy.js +575 -0
  48. package/build/scripts/auto-setup.js +364 -0
  49. package/build/scripts/dev-sync.js +512 -0
  50. package/build/scripts/diagnostics.js +301 -0
  51. package/build/scripts/download-specs.js +116 -0
  52. package/build/scripts/interactive-setup.js +757 -0
  53. package/build/scripts/setup.js +1515 -0
  54. package/build/scripts/update-api-status-doc.js +44 -0
  55. package/build/server-http.d.ts +1 -0
  56. package/build/server-http.js +581 -0
  57. package/build/tools/definitions/account-with-schemas.js +170 -0
  58. package/build/tools/definitions/account.js +428 -0
  59. package/build/tools/definitions/analytics.js +66 -0
  60. package/build/tools/definitions/communication.js +394 -0
  61. package/build/tools/definitions/developer.js +195 -0
  62. package/build/tools/definitions/fulfillment.js +326 -0
  63. package/build/tools/definitions/index.js +41 -0
  64. package/build/tools/definitions/inventory.js +464 -0
  65. package/build/tools/definitions/marketing.js +1486 -0
  66. package/build/tools/definitions/metadata.js +188 -0
  67. package/build/tools/definitions/other.js +309 -0
  68. package/build/tools/definitions/taxonomy.js +64 -0
  69. package/build/tools/definitions/token-management.js +148 -0
  70. package/build/tools/definitions/trading.js +71 -0
  71. package/build/tools/index.js +1200 -0
  72. package/build/tools/schemas.js +667 -0
  73. package/build/tools/tool-definitions.js +3534 -0
  74. package/build/types/application-settings/developerAnalyticsV1BetaOas3.js +5 -0
  75. package/build/types/application-settings/developerClientRegistrationV1Oas3.js +5 -0
  76. package/build/types/application-settings/developerKeyManagementV1Oas3.js +5 -0
  77. package/build/types/ebay-enums.js +1330 -0
  78. package/build/types/ebay.js +123 -0
  79. package/build/types/index.js +10 -0
  80. package/build/types/sell-apps/account-management/sellAccountV1Oas3.js +5 -0
  81. package/build/types/sell-apps/analytics-and-report/sellAnalyticsV1Oas3.js +5 -0
  82. package/build/types/sell-apps/communication/commerceFeedbackV1BetaOas3.js +5 -0
  83. package/build/types/sell-apps/communication/commerceMessageV1Oas3.js +5 -0
  84. package/build/types/sell-apps/communication/commerceNotificationV1Oas3.js +5 -0
  85. package/build/types/sell-apps/communication/sellNegotiationV1Oas3.js +5 -0
  86. package/build/types/sell-apps/listing-management/sellInventoryV1Oas3.js +5 -0
  87. package/build/types/sell-apps/listing-metadata/sellMetadataV1Oas3.js +5 -0
  88. package/build/types/sell-apps/markeitng-and-promotions/sellMarketingV1Oas3.js +5 -0
  89. package/build/types/sell-apps/markeitng-and-promotions/sellRecommendationV1Oas3.js +5 -0
  90. package/build/types/sell-apps/order-management/sellFulfillmentV1Oas3.js +5 -0
  91. package/build/types/sell-apps/other-apis/commerceIdentityV1Oas3.js +5 -0
  92. package/build/types/sell-apps/other-apis/commerceTranslationV1BetaOas3.js +5 -0
  93. package/build/types/sell-apps/other-apis/commerceVeroV1Oas3.js +5 -0
  94. package/build/types/sell-apps/other-apis/sellComplianceV1Oas3.js +5 -0
  95. package/build/types/sell-apps/other-apis/sellEdeliveryInternationalShippingOas3.js +5 -0
  96. package/build/types/sell-apps/other-apis/sellMarketingV1Oas3.js +5 -0
  97. package/build/types/sell-apps/other-apis/sellRecommendationV1Oas3.js +5 -0
  98. package/build/utils/account-management/account.js +831 -0
  99. package/build/utils/api-status-feed.js +83 -0
  100. package/build/utils/communication/feedback.js +216 -0
  101. package/build/utils/communication/message.js +242 -0
  102. package/build/utils/communication/negotiation.js +150 -0
  103. package/build/utils/communication/notification.js +369 -0
  104. package/build/utils/date-converter.js +160 -0
  105. package/build/utils/llm-client-detector.js +758 -0
  106. package/build/utils/logger.js +198 -0
  107. package/build/utils/oauth-helper.js +315 -0
  108. package/build/utils/order-management/dispute.js +369 -0
  109. package/build/utils/order-management/fulfillment.js +205 -0
  110. package/build/utils/other/compliance.js +76 -0
  111. package/build/utils/other/edelivery.js +241 -0
  112. package/build/utils/other/identity.js +13 -0
  113. package/build/utils/other/translation.js +41 -0
  114. package/build/utils/other/vero.js +90 -0
  115. package/build/utils/scope-helper.js +207 -0
  116. package/build/utils/security-checker.js +248 -0
  117. package/build/utils/setup-validator.js +305 -0
  118. package/build/utils/token-utils.js +40 -0
  119. package/build/utils/version.js +56 -0
  120. package/docs/auth/production_scopes.json +111 -0
  121. package/docs/auth/sandbox_scopes.json +142 -0
  122. package/package.json +122 -0
  123. package/public/icons/1024x1024.png +0 -0
  124. package/public/icons/128x128.png +0 -0
  125. package/public/icons/16x16.png +0 -0
  126. package/public/icons/256x256.png +0 -0
  127. package/public/icons/32x32.png +0 -0
  128. package/public/icons/48x48.png +0 -0
  129. package/public/icons/512x512.png +0 -0
@@ -0,0 +1,301 @@
1
+ /**
2
+ * Diagnostics Script - Troubleshooting and system health checks
3
+ *
4
+ * Usage:
5
+ * npm run diagnose
6
+ * npx ebay-mcp-remote-edition --diagnose
7
+ */
8
+ import chalk from 'chalk';
9
+ import { existsSync, readFileSync, writeFileSync } from 'fs';
10
+ import { join, dirname } from 'path';
11
+ import { fileURLToPath } from 'url';
12
+ import { runSecurityChecks, displaySecurityResults } from '../utils/security-checker.js';
13
+ import { validateSetup, displayRecommendations } from '../utils/setup-validator.js';
14
+ import { detectLLMClients } from '../utils/llm-client-detector.js';
15
+ import { displayScopeVerification, parseScopeString } from '../utils/scope-helper.js';
16
+ import { EbaySellerApi } from '../api/index.js';
17
+ const __filename = fileURLToPath(import.meta.url);
18
+ const __dirname = dirname(__filename);
19
+ const PROJECT_ROOT = join(__dirname, '../..');
20
+ /**
21
+ * Parse .env file
22
+ */
23
+ function parseEnvFile(filePath) {
24
+ const env = {};
25
+ if (!existsSync(filePath)) {
26
+ return env;
27
+ }
28
+ const content = readFileSync(filePath, 'utf-8');
29
+ const lines = content.split('\n');
30
+ for (const line of lines) {
31
+ const trimmed = line.trim();
32
+ if (!trimmed || trimmed.startsWith('#')) {
33
+ continue;
34
+ }
35
+ const match = /^([^=]+)=(.*)$/.exec(trimmed);
36
+ if (match) {
37
+ const key = match[1].trim();
38
+ let value = match[2].trim();
39
+ if ((value.startsWith('"') && value.endsWith('"')) ||
40
+ (value.startsWith("'") && value.endsWith("'"))) {
41
+ value = value.slice(1, -1);
42
+ }
43
+ env[key] = value;
44
+ }
45
+ }
46
+ return env;
47
+ }
48
+ /**
49
+ * Check API connectivity
50
+ */
51
+ async function checkApiConnectivity() {
52
+ try {
53
+ const controller = new AbortController();
54
+ const timeout = setTimeout(() => controller.abort(), 5000);
55
+ const response = await fetch('https://api.ebay.com/health', {
56
+ signal: controller.signal,
57
+ });
58
+ clearTimeout(timeout);
59
+ return { canReachEbay: response.ok || response.status === 404 };
60
+ }
61
+ catch (error) {
62
+ return {
63
+ canReachEbay: false,
64
+ error: error instanceof Error ? error.message : 'Unknown error',
65
+ };
66
+ }
67
+ }
68
+ /**
69
+ * Test eBay API authentication
70
+ */
71
+ async function testEbayAuthentication(config) {
72
+ try {
73
+ const api = new EbaySellerApi(config);
74
+ await api.initialize();
75
+ // Try to get user info
76
+ const userInfo = await api.identity.getUser();
77
+ return { success: true, userInfo };
78
+ }
79
+ catch (error) {
80
+ return {
81
+ success: false,
82
+ error: error instanceof Error ? error.message : 'Unknown error',
83
+ };
84
+ }
85
+ }
86
+ /**
87
+ * Display diagnostic header
88
+ */
89
+ function displayHeader() {
90
+ console.clear();
91
+ console.log(chalk.bold.cyan(`
92
+ ╔══════════════════════════════════════════════════════════════╗
93
+ ║ ║
94
+ ║ eBay MCP Server Diagnostics ║
95
+ ║ ║
96
+ ╚══════════════════════════════════════════════════════════════╝
97
+ `));
98
+ console.log(chalk.gray(`Run date: ${new Date().toISOString()}\n`));
99
+ }
100
+ /**
101
+ * Display system information
102
+ */
103
+ function displaySystemInfo() {
104
+ console.log(chalk.bold.cyan('💻 System Information\n'));
105
+ console.log(` ${chalk.gray('Node.js:')} ${process.version}`);
106
+ console.log(` ${chalk.gray('Platform:')} ${process.platform}`);
107
+ console.log(` ${chalk.gray('Architecture:')} ${process.arch}`);
108
+ console.log(` ${chalk.gray('CWD:')} ${process.cwd()}`);
109
+ console.log('');
110
+ }
111
+ /**
112
+ * Display configuration status
113
+ */
114
+ function displayConfigurationStatus(envVars) {
115
+ console.log(chalk.bold.cyan('⚙️ Configuration Status\n'));
116
+ const checks = [
117
+ { key: 'EBAY_CLIENT_ID', label: 'Client ID', redact: true },
118
+ { key: 'EBAY_CLIENT_SECRET', label: 'Client Secret', redact: true },
119
+ { key: 'EBAY_REDIRECT_URI', label: 'Redirect URI', redact: false },
120
+ { key: 'EBAY_ENVIRONMENT', label: 'Environment', redact: false },
121
+ { key: 'EBAY_MARKETPLACE_ID', label: 'Marketplace ID', redact: false },
122
+ { key: 'EBAY_CONTENT_LANGUAGE', label: 'Content Language', redact: false },
123
+ { key: 'EBAY_USER_REFRESH_TOKEN', label: 'User Refresh Token', redact: true },
124
+ { key: 'EBAY_USER_ACCESS_TOKEN', label: 'User Access Token', redact: true },
125
+ { key: 'EBAY_APP_ACCESS_TOKEN', label: 'App Access Token', redact: true },
126
+ ];
127
+ for (const check of checks) {
128
+ const value = envVars[check.key];
129
+ let status;
130
+ let displayValue;
131
+ if (value && value.trim() && !value.includes('_here')) {
132
+ status = chalk.green('✓ Set');
133
+ displayValue = check.redact ? `${value.substring(0, 10)}...` : value;
134
+ }
135
+ else {
136
+ status = chalk.red('✗ Not set');
137
+ displayValue = chalk.gray('(not configured)');
138
+ }
139
+ console.log(` ${status} ${chalk.bold(check.label)}: ${displayValue}`);
140
+ }
141
+ console.log('');
142
+ }
143
+ /**
144
+ * Display LLM client status
145
+ */
146
+ function displayLLMClientStatus() {
147
+ console.log(chalk.bold.cyan('🤖 LLM Client Detection\n'));
148
+ const clients = detectLLMClients();
149
+ for (const client of clients) {
150
+ const detected = client.detected ? chalk.green('✓ Detected') : chalk.gray('✗ Not found');
151
+ const configured = client.configExists
152
+ ? chalk.green('[Configured]')
153
+ : chalk.gray('[Not configured]');
154
+ console.log(` ${detected} ${chalk.bold(client.displayName)} ${configured}`);
155
+ if (client.detected) {
156
+ console.log(chalk.gray(` Config: ${client.configPath}`));
157
+ }
158
+ }
159
+ console.log('');
160
+ }
161
+ /**
162
+ * Test API authentication and display results
163
+ */
164
+ async function displayAuthenticationTest(config) {
165
+ console.log(chalk.bold.cyan('🔐 API Authentication Test\n'));
166
+ const result = await testEbayAuthentication(config);
167
+ if (result.success) {
168
+ console.log(chalk.green(' ✓ Successfully authenticated with eBay API\n'));
169
+ if (result.userInfo) {
170
+ console.log(chalk.bold.white(' User Information:'));
171
+ console.log(chalk.gray(JSON.stringify(result.userInfo, null, 2)));
172
+ console.log('');
173
+ }
174
+ }
175
+ else {
176
+ console.log(chalk.red(' ✗ Authentication failed\n'));
177
+ console.log(chalk.yellow(` Error: ${result.error}\n`));
178
+ }
179
+ }
180
+ /**
181
+ * Generate diagnostic report
182
+ */
183
+ async function generateDiagnosticReport(exportPath) {
184
+ const envPath = join(PROJECT_ROOT, '.env');
185
+ const envVars = parseEnvFile(envPath);
186
+ // Run security checks
187
+ const securityResults = await runSecurityChecks(PROJECT_ROOT);
188
+ // Run configuration validation
189
+ const validationSummary = await validateSetup(PROJECT_ROOT);
190
+ // Detect LLM clients
191
+ const llmClients = detectLLMClients();
192
+ // Check API connectivity
193
+ const apiConnection = await checkApiConnectivity();
194
+ const report = {
195
+ timestamp: new Date().toISOString(),
196
+ environment: {
197
+ nodeVersion: process.version,
198
+ platform: process.platform,
199
+ arch: process.arch,
200
+ },
201
+ security: securityResults,
202
+ configuration: validationSummary,
203
+ llmClients,
204
+ apiConnection,
205
+ };
206
+ // If we have credentials, test authentication
207
+ if (envVars.EBAY_CLIENT_ID && envVars.EBAY_CLIENT_SECRET) {
208
+ const config = {
209
+ clientId: envVars.EBAY_CLIENT_ID,
210
+ clientSecret: envVars.EBAY_CLIENT_SECRET,
211
+ redirectUri: envVars.EBAY_REDIRECT_URI,
212
+ environment: (envVars.EBAY_ENVIRONMENT || 'sandbox'),
213
+ };
214
+ const authResult = await testEbayAuthentication(config);
215
+ report.tokenInfo = {
216
+ hasUserToken: !!envVars.EBAY_USER_REFRESH_TOKEN,
217
+ hasAppToken: !!envVars.EBAY_APP_ACCESS_TOKEN,
218
+ };
219
+ if (authResult.success) {
220
+ report.tokenInfo.scopes = envVars.EBAY_USER_REFRESH_TOKEN
221
+ ? parseScopeString(envVars.EBAY_USER_REFRESH_TOKEN)
222
+ : [];
223
+ }
224
+ }
225
+ // Export report if path provided
226
+ if (exportPath) {
227
+ writeFileSync(exportPath, JSON.stringify(report, null, 2), 'utf-8');
228
+ console.log(chalk.green(`\n✓ Diagnostic report exported to: ${exportPath}\n`));
229
+ }
230
+ return report;
231
+ }
232
+ /**
233
+ * Main diagnostics function
234
+ */
235
+ async function runDiagnostics(exportReport = false) {
236
+ displayHeader();
237
+ displaySystemInfo();
238
+ // Security checks
239
+ const securityResults = await runSecurityChecks(PROJECT_ROOT);
240
+ displaySecurityResults(securityResults);
241
+ // Configuration status
242
+ const envPath = join(PROJECT_ROOT, '.env');
243
+ const envVars = parseEnvFile(envPath);
244
+ displayConfigurationStatus(envVars);
245
+ // LLM client detection
246
+ displayLLMClientStatus();
247
+ // API connectivity
248
+ console.log(chalk.bold.cyan('🌐 API Connectivity\n'));
249
+ const apiConnection = await checkApiConnectivity();
250
+ if (apiConnection.canReachEbay) {
251
+ console.log(chalk.green(' ✓ Can reach eBay API servers\n'));
252
+ }
253
+ else {
254
+ console.log(chalk.red(' ✗ Cannot reach eBay API servers'));
255
+ console.log(chalk.yellow(` Error: ${apiConnection.error}\n`));
256
+ }
257
+ // Configuration validation
258
+ console.log(chalk.bold.cyan('📋 Configuration Validation\n'));
259
+ const validationSummary = await validateSetup(PROJECT_ROOT);
260
+ displayRecommendations(validationSummary);
261
+ // If we have credentials, test authentication
262
+ if (envVars.EBAY_CLIENT_ID && envVars.EBAY_CLIENT_SECRET) {
263
+ const config = {
264
+ clientId: envVars.EBAY_CLIENT_ID,
265
+ clientSecret: envVars.EBAY_CLIENT_SECRET,
266
+ redirectUri: envVars.EBAY_REDIRECT_URI,
267
+ environment: (envVars.EBAY_ENVIRONMENT || 'sandbox'),
268
+ };
269
+ await displayAuthenticationTest(config);
270
+ // Scope verification if user has refresh token
271
+ if (envVars.EBAY_USER_REFRESH_TOKEN) {
272
+ try {
273
+ const api = new EbaySellerApi(config);
274
+ await api.initialize();
275
+ const authClient = api.getAuthClient();
276
+ const tokenInfo = authClient.getTokenInfo();
277
+ if (tokenInfo.scopeInfo) {
278
+ displayScopeVerification(tokenInfo.scopeInfo.tokenScopes, config.environment);
279
+ }
280
+ }
281
+ catch {
282
+ console.log(chalk.yellow('⚠️ Could not verify token scopes\n'));
283
+ }
284
+ }
285
+ }
286
+ // Export report if requested
287
+ if (exportReport) {
288
+ const reportPath = join(PROJECT_ROOT, `ebay-mcp-diagnostic-${Date.now()}.json`);
289
+ await generateDiagnosticReport(reportPath);
290
+ }
291
+ console.log(chalk.bold.green('✅ Diagnostics complete!\n'));
292
+ console.log(chalk.gray('For more help, visit:'));
293
+ console.log(chalk.blue.underline(' https://github.com/mrnajiboy/ebay-mcp-remote-edition#troubleshooting\n'));
294
+ }
295
+ // CLI handler
296
+ const args = process.argv.slice(2);
297
+ const exportReport = args.includes('--export') || args.includes('-e');
298
+ runDiagnostics(exportReport).catch((error) => {
299
+ console.error(chalk.red('\n❌ Diagnostics failed:'), error);
300
+ process.exit(1);
301
+ });
@@ -0,0 +1,116 @@
1
+ import axios from 'axios';
2
+ import * as fs from 'fs';
3
+ import * as path from 'path';
4
+ import { fileURLToPath } from 'url';
5
+ import { dirname } from 'path';
6
+ const __filename = fileURLToPath(import.meta.url);
7
+ const __dirname = dirname(__filename);
8
+ const DOCS_DIR = path.resolve(__dirname, '../../docs');
9
+ const README_PATH = path.resolve(__dirname, '../../docs/sell-apps/README.md');
10
+ const getUrlsFromReadme = (content) => {
11
+ // Regex to find URLs that end with .json, specifically for OpenAPI specs
12
+ // This assumes the README will directly link to the JSON spec files, but is less strict to allow for variations.
13
+ const urlRegex = /(https:\/\/[^\s)]+\.json)/g;
14
+ const urls = Array.from(content.matchAll(urlRegex)).map((match) => match[1]);
15
+ console.log('Found URLs:', urls);
16
+ return urls;
17
+ };
18
+ const _getSpecUrlsFromHtml = (html) => {
19
+ const linkRegex = /<a[^>]*?class="[^"]*\bspec-parent\b[^"]*"[^>]*?href="([^"]+)"/g;
20
+ const matches = [...html.matchAll(linkRegex)];
21
+ const urls = matches.map((match) => match[1]);
22
+ // Filter out duplicates
23
+ return [...new Set(urls)];
24
+ };
25
+ const getFolderName = (specUrl) => {
26
+ const fileName = path.basename(specUrl);
27
+ // mapping from file name to folder name
28
+ // This mapping is based on the README.md structure and common API groupings
29
+ const folderMap = {
30
+ // Application Settings
31
+ 'developer_analytics_v1_beta_oas3.json': 'application-settings',
32
+ 'developer_key_management_v1_oas3.json': 'application-settings',
33
+ 'developer_client_registration_v1_oas3.json': 'application-settings',
34
+ // Selling Apps - Listing Management
35
+ 'sell_inventory_v1_oas3.json': 'sell-apps/listing-management',
36
+ 'sell_feed_v1_oas3.json': 'sell-apps/listing-management',
37
+ 'commerce_media_v1_beta_oas3.json': 'sell-apps/listing-management',
38
+ 'sell_stores_v1_oas3.json': 'sell-apps/listing-management',
39
+ // Selling Apps - Listing Metadata & Taxonomy
40
+ 'sell_metadata_v1_oas3.json': 'sell-apps/listing-metadata',
41
+ 'commerce_taxonomy_v1_oas3.json': 'sell-apps/listing-metadata',
42
+ 'commerce_charity_v1_oas3.json': 'sell-apps/listing-metadata',
43
+ // Selling Apps - Account Management
44
+ 'sell_account_v1_oas3.json': 'sell-apps/account-management',
45
+ 'sell_account_v2_oas3.json': 'sell-apps/account-management',
46
+ 'sell_finances_v1_oas3.json': 'sell-apps/account-management',
47
+ // Selling Apps - Communication & Negotiation
48
+ 'commerce_message_v1_oas3.json': 'sell-apps/communication',
49
+ 'commerce_notification_v1_oas3.json': 'sell-apps/communication',
50
+ 'sell_negotiation_v1_oas3.json': 'sell-apps/communication',
51
+ 'commerce_feedback_v1_beta_oas3.json': 'sell-apps/communication',
52
+ // Selling Apps - Order Management
53
+ 'sell_fulfillment_v1_oas3.json': 'sell-apps/order-management',
54
+ 'sell_logistics_v1_oas3.json': 'sell-apps/order-management',
55
+ // Selling Apps - Marketing & Promotions
56
+ 'sell_marketing_v1_oas3.json': 'sell-apps/marketing-and-promotions',
57
+ 'sell_recommendation_v1_oas3.json': 'sell-apps/marketing-and-promotions',
58
+ 'sell_analytics_v1_oas3.json': 'sell-apps/analytics-and-report',
59
+ // Selling Apps - Other Selling APIs
60
+ 'commerce_translation_v1_beta_oas3.json': 'sell-apps/other-apis',
61
+ 'sell_compliance_v1_oas3.json': 'sell-apps/other-apis',
62
+ 'commerce_identity_v1_oas3.json': 'sell-apps/other-apis',
63
+ 'sell_edelivery_international_shipping_oas3.json': 'sell-apps/other-apis',
64
+ 'commerce_vero_v1_oas3.json': 'sell-apps/other-apis',
65
+ // Buying Apps - Inventory Discovery & Refresh
66
+ 'buy_browse_v1_oas3.json': 'buy-apps/inventory-discovery',
67
+ 'buy_feed_v1_beta_oas3.json': 'buy-apps/inventory-discovery',
68
+ 'buy_feed_v1_oas3.json': 'buy-apps/inventory-discovery',
69
+ // commerce_notification_v1_oas3.json is already mapped under sell-apps,
70
+ // but it's also relevant here. We'll prioritize the first mapping or create a symlink if needed.
71
+ // Buying Apps - Marketing & Discounts
72
+ 'buy_deal_v1_oas3.json': 'buy-apps/marketing-and-discounts',
73
+ 'buy_marketing_v1_beta_oas3.json': 'buy-apps/marketing-and-discounts',
74
+ // Buying Apps - Marketplace Metadata
75
+ // commerce_taxonomy_v1_oas3.json is already mapped under sell-apps
76
+ 'commerce_catalog_v1_beta_oas3.json': 'buy-apps/marketplace-metadata',
77
+ // commerce_charity_v1_oas3.json is already mapped under sell-apps
78
+ // Buying Apps - Checkout & Bidding
79
+ 'buy_order_v2_oas3.json': 'buy-apps/checkout-and-bidding',
80
+ 'buy_offer_v1_beta_oas3.json': 'buy-apps/checkout-and-bidding',
81
+ // Buying Apps - Other Buying APIs
82
+ // commerce_translation_v1_beta_oas3.json is already mapped under sell-apps
83
+ // commerce_identity_v1_oas3.json is already mapped under sell-apps
84
+ };
85
+ // Default to 'other-apis' if not found in map, or use the mapped folder
86
+ return folderMap[fileName] || 'other-apis';
87
+ };
88
+ const downloadFile = async (url, folderPath, fileName) => {
89
+ try {
90
+ const response = await axios.get(url, { responseType: 'arraybuffer' });
91
+ const filePath = path.join(folderPath, fileName);
92
+ fs.mkdirSync(folderPath, { recursive: true });
93
+ fs.writeFileSync(filePath, response.data);
94
+ console.log(`Downloaded ${fileName} to ${folderPath}`);
95
+ }
96
+ catch (error) {
97
+ console.error(`Failed to download ${url}:`, error);
98
+ }
99
+ };
100
+ const main = async () => {
101
+ try {
102
+ const readmeContent = fs.readFileSync(README_PATH, 'utf-8');
103
+ const urls = getUrlsFromReadme(readmeContent);
104
+ for (const url of urls) {
105
+ console.log(`Processing URL: ${url}`);
106
+ const fileName = path.basename(url);
107
+ const folderName = getFolderName(url);
108
+ const folderPath = path.join(DOCS_DIR, folderName);
109
+ await downloadFile(url, folderPath, fileName);
110
+ }
111
+ }
112
+ catch (error) {
113
+ console.error('Failed to read README.md:', error);
114
+ }
115
+ };
116
+ void main();