Update server.js
Browse files
server.js
CHANGED
|
@@ -243,16 +243,19 @@ function transformToN8nFormat(agentResult, keyword) {
|
|
| 243 |
emergingTrends: r.emergingTrends || []
|
| 244 |
};
|
| 245 |
|
|
|
|
| 246 |
return {
|
| 247 |
dashboard_view: dashboard_view,
|
| 248 |
// Include report_view for PDF generation if needed
|
| 249 |
report_view: report_view,
|
| 250 |
meta: {
|
| 251 |
-
job_id:
|
| 252 |
keyword: keyword,
|
| 253 |
timestamp: new Date().toISOString(),
|
| 254 |
status: "completed"
|
| 255 |
-
}
|
|
|
|
|
|
|
| 256 |
};
|
| 257 |
}
|
| 258 |
|
|
@@ -260,63 +263,131 @@ function transformToN8nFormat(agentResult, keyword) {
|
|
| 260 |
function createFallbackResponse(keyword) {
|
| 261 |
const marketTitle = `Global ${keyword} Market Analysis`;
|
| 262 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 263 |
return {
|
| 264 |
-
dashboard_view:
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
},
|
| 272 |
-
forecast: [
|
| 273 |
-
{ year: "2023", value: 8.5 },
|
| 274 |
-
{ year: "2025", value: 10.2 },
|
| 275 |
-
{ year: "2033", value: 18.7 }
|
| 276 |
-
],
|
| 277 |
-
marketSegments: [
|
| 278 |
-
{
|
| 279 |
-
segment: "Primary Segment",
|
| 280 |
-
segment_marketShare_2023: "35%",
|
| 281 |
-
segment_marketShare_2025: "38%",
|
| 282 |
-
segment_marketShare_2033: "42%",
|
| 283 |
-
segment_cagr: "12%",
|
| 284 |
-
subSegments: [
|
| 285 |
-
{
|
| 286 |
-
name: "Core Products",
|
| 287 |
-
marketShare_2023: "15%",
|
| 288 |
-
marketShare_2025: "18%",
|
| 289 |
-
marketShare_2033: "22%",
|
| 290 |
-
cagr: "14%"
|
| 291 |
-
}
|
| 292 |
-
]
|
| 293 |
-
}
|
| 294 |
-
],
|
| 295 |
-
drivers: [
|
| 296 |
-
{ driver: "Technological Advancement", impact: 85 },
|
| 297 |
-
{ driver: "Market Demand", impact: 90 },
|
| 298 |
-
{ driver: "Regulatory Support", impact: 75 }
|
| 299 |
-
],
|
| 300 |
-
insights: {
|
| 301 |
-
largestSegment2025: "Primary Segment",
|
| 302 |
-
fastestGrowingSegment: "Digital Solutions",
|
| 303 |
-
keyOpportunities: ["Market expansion", "Technology innovation"],
|
| 304 |
-
majorChallenges: ["Regulatory compliance", "Market competition"]
|
| 305 |
-
},
|
| 306 |
-
competitive: [
|
| 307 |
-
{ company: "Johnson & Johnson", share: 15 },
|
| 308 |
-
{ company: "Medtronic", share: 12 },
|
| 309 |
-
{ company: "Siemens Healthineers", share: 9 },
|
| 310 |
-
{ company: "Boston Scientific", share: 8 },
|
| 311 |
-
{ company: "Abbott Laboratories", share: 7 }
|
| 312 |
-
]
|
| 313 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 314 |
meta: {
|
| 315 |
-
job_id:
|
| 316 |
keyword: keyword,
|
| 317 |
timestamp: new Date().toISOString(),
|
| 318 |
status: "completed"
|
| 319 |
-
}
|
|
|
|
|
|
|
| 320 |
};
|
| 321 |
}
|
| 322 |
|
|
|
|
| 243 |
emergingTrends: r.emergingTrends || []
|
| 244 |
};
|
| 245 |
|
| 246 |
+
const main_job_id = `job_${Date.now()}`;
|
| 247 |
return {
|
| 248 |
dashboard_view: dashboard_view,
|
| 249 |
// Include report_view for PDF generation if needed
|
| 250 |
report_view: report_view,
|
| 251 |
meta: {
|
| 252 |
+
job_id: main_job_id,
|
| 253 |
keyword: keyword,
|
| 254 |
timestamp: new Date().toISOString(),
|
| 255 |
status: "completed"
|
| 256 |
+
},
|
| 257 |
+
// Also include job_id at root for n8n compatibility
|
| 258 |
+
job_id: main_job_id
|
| 259 |
};
|
| 260 |
}
|
| 261 |
|
|
|
|
| 263 |
function createFallbackResponse(keyword) {
|
| 264 |
const marketTitle = `Global ${keyword} Market Analysis`;
|
| 265 |
|
| 266 |
+
const dashboard_view = {
|
| 267 |
+
marketTitle: marketTitle,
|
| 268 |
+
marketSummary: {
|
| 269 |
+
past2023: 8.5,
|
| 270 |
+
current2025: 10.2,
|
| 271 |
+
forecast2033: 18.7,
|
| 272 |
+
cagr: 12.5
|
| 273 |
+
},
|
| 274 |
+
forecast: [
|
| 275 |
+
{ year: "2023", value: 8.5 },
|
| 276 |
+
{ year: "2025", value: 10.2 },
|
| 277 |
+
{ year: "2033", value: 18.7 }
|
| 278 |
+
],
|
| 279 |
+
marketSegments: [
|
| 280 |
+
{
|
| 281 |
+
segment: "Primary Segment",
|
| 282 |
+
segment_marketShare_2023: "35%",
|
| 283 |
+
segment_marketShare_2025: "38%",
|
| 284 |
+
segment_marketShare_2033: "42%",
|
| 285 |
+
segment_cagr: "12%",
|
| 286 |
+
subSegments: [
|
| 287 |
+
{
|
| 288 |
+
name: "Core Products",
|
| 289 |
+
marketShare_2023: "15%",
|
| 290 |
+
marketShare_2025: "18%",
|
| 291 |
+
marketShare_2033: "22%",
|
| 292 |
+
cagr: "14%"
|
| 293 |
+
}
|
| 294 |
+
]
|
| 295 |
+
}
|
| 296 |
+
],
|
| 297 |
+
drivers: [
|
| 298 |
+
{ driver: "Technological Advancement", impact: 85 },
|
| 299 |
+
{ driver: "Market Demand", impact: 90 },
|
| 300 |
+
{ driver: "Regulatory Support", impact: 75 }
|
| 301 |
+
],
|
| 302 |
+
insights: {
|
| 303 |
+
largestSegment2025: "Primary Segment",
|
| 304 |
+
fastestGrowingSegment: "Digital Solutions",
|
| 305 |
+
keyOpportunities: ["Market expansion", "Technology innovation"],
|
| 306 |
+
majorChallenges: ["Regulatory compliance", "Market competition"]
|
| 307 |
+
},
|
| 308 |
+
competitive: [
|
| 309 |
+
{ company: "Johnson & Johnson", share: 15 },
|
| 310 |
+
{ company: "Medtronic", share: 12 },
|
| 311 |
+
{ company: "Siemens Healthineers", share: 9 },
|
| 312 |
+
{ company: "Boston Scientific", share: 8 },
|
| 313 |
+
{ company: "Abbott Laboratories", share: 7 }
|
| 314 |
+
]
|
| 315 |
+
};
|
| 316 |
+
|
| 317 |
+
const report_view = {
|
| 318 |
+
marketTitle: marketTitle,
|
| 319 |
+
marketOverview: {
|
| 320 |
+
pastYear_2023: 8.5,
|
| 321 |
+
currentYear_2025: 10.2,
|
| 322 |
+
forecastYear_2033: 18.7,
|
| 323 |
+
global_cagr_Forecast: 12.5,
|
| 324 |
+
executiveOverview: `Comprehensive analysis of the ${keyword} market showing strong growth potential.`
|
| 325 |
+
},
|
| 326 |
+
marketSegments: [
|
| 327 |
+
{
|
| 328 |
+
segmentName: "Primary Segment",
|
| 329 |
+
segment_marketShare_2023: "35%",
|
| 330 |
+
segment_marketShare_2025: "38%",
|
| 331 |
+
segment_marketShare_2033: "42%",
|
| 332 |
+
segmentName_cagr_Forecast: "12%",
|
| 333 |
+
subSegments: [
|
| 334 |
+
{
|
| 335 |
+
name: "Core Products",
|
| 336 |
+
marketShare_2023: "15%",
|
| 337 |
+
marketShare_2025: "18%",
|
| 338 |
+
marketShare_2033: "22%",
|
| 339 |
+
cagr: "14%"
|
| 340 |
+
}
|
| 341 |
+
]
|
| 342 |
+
}
|
| 343 |
+
],
|
| 344 |
+
marketDynamics: {
|
| 345 |
+
marketDrivers: ["Technological Advancement", "Market Demand", "Regulatory Support"],
|
| 346 |
+
strategicRecommendations: ["Expand market presence", "Invest in R&D", "Strengthen partnerships"]
|
| 347 |
+
},
|
| 348 |
+
competitiveLandscape: [
|
| 349 |
+
{ company: "Johnson & Johnson", player_marketShare_2025: 15 },
|
| 350 |
+
{ company: "Medtronic", player_marketShare_2025: 12 },
|
| 351 |
+
{ company: "Siemens Healthineers", player_marketShare_2025: 9 },
|
| 352 |
+
{ company: "Boston Scientific", player_marketShare_2025: 8 },
|
| 353 |
+
{ company: "Abbott Laboratories", player_marketShare_2025: 7 }
|
| 354 |
+
],
|
| 355 |
+
insights: {
|
| 356 |
+
keyFindings: ["Market shows strong growth", "Technology is key driver", "Competition is increasing"]
|
| 357 |
+
},
|
| 358 |
+
regulatoryEnvironment: "Favorable regulatory environment supporting innovation.",
|
| 359 |
+
geographicAnalysis: "North America leads the market, followed by Europe and Asia-Pacific.",
|
| 360 |
+
futureOutlook: "Positive growth trajectory expected through 2033.",
|
| 361 |
+
emergingTrends: ["Digital transformation", "Personalized medicine", "AI integration"]
|
| 362 |
+
};
|
| 363 |
+
|
| 364 |
+
const fallback_job_id = `job_${Date.now()}`;
|
| 365 |
return {
|
| 366 |
+
dashboard_view: dashboard_view,
|
| 367 |
+
report_view: report_view,
|
| 368 |
+
meta: {
|
| 369 |
+
job_id: fallback_job_id,
|
| 370 |
+
keyword: keyword,
|
| 371 |
+
timestamp: new Date().toISOString(),
|
| 372 |
+
status: "completed"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 373 |
},
|
| 374 |
+
// Also include job_id at root for n8n compatibility
|
| 375 |
+
job_id: fallback_job_id
|
| 376 |
+
};
|
| 377 |
+
|
| 378 |
+
const job_id = `job_${Date.now()}`;
|
| 379 |
+
const transform_job_id = `job_${Date.now()}`;
|
| 380 |
+
return {
|
| 381 |
+
dashboard_view: dashboard_view,
|
| 382 |
+
report_view: report_view,
|
| 383 |
meta: {
|
| 384 |
+
job_id: transform_job_id,
|
| 385 |
keyword: keyword,
|
| 386 |
timestamp: new Date().toISOString(),
|
| 387 |
status: "completed"
|
| 388 |
+
},
|
| 389 |
+
// Also include job_id at root for n8n compatibility
|
| 390 |
+
job_id: transform_job_id
|
| 391 |
};
|
| 392 |
}
|
| 393 |
|