paper-search-cli 0.3.0 → 0.3.2

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 (314) hide show
  1. package/README.md +11 -9
  2. package/README.zh.md +11 -9
  3. package/dist/capabilities/body-snippet-search/handler.d.ts +9 -0
  4. package/dist/capabilities/body-snippet-search/handler.d.ts.map +1 -0
  5. package/dist/capabilities/body-snippet-search/handler.js +17 -0
  6. package/dist/capabilities/body-snippet-search/handler.js.map +1 -0
  7. package/dist/capabilities/body-snippet-search/index.d.ts +7 -0
  8. package/dist/capabilities/body-snippet-search/index.d.ts.map +1 -0
  9. package/dist/capabilities/body-snippet-search/index.js +6 -0
  10. package/dist/capabilities/body-snippet-search/index.js.map +1 -0
  11. package/dist/capabilities/body-snippet-search/schemas.d.ts +36 -0
  12. package/dist/capabilities/body-snippet-search/schemas.d.ts.map +1 -0
  13. package/dist/capabilities/body-snippet-search/schemas.js +16 -0
  14. package/dist/capabilities/body-snippet-search/schemas.js.map +1 -0
  15. package/dist/capabilities/body-snippet-search/service.d.ts +4 -0
  16. package/dist/capabilities/body-snippet-search/service.d.ts.map +1 -0
  17. package/dist/capabilities/body-snippet-search/service.js +4 -0
  18. package/dist/capabilities/body-snippet-search/service.js.map +1 -0
  19. package/dist/capabilities/body-snippet-search/tools.d.ts +187 -0
  20. package/dist/capabilities/body-snippet-search/tools.d.ts.map +1 -0
  21. package/dist/capabilities/body-snippet-search/tools.js +49 -0
  22. package/dist/capabilities/body-snippet-search/tools.js.map +1 -0
  23. package/dist/capabilities/body-snippet-search/types.d.ts +14 -0
  24. package/dist/capabilities/body-snippet-search/types.d.ts.map +1 -0
  25. package/dist/capabilities/body-snippet-search/types.js +2 -0
  26. package/dist/capabilities/body-snippet-search/types.js.map +1 -0
  27. package/dist/capabilities/citation-expansion/CitationService.d.ts +47 -0
  28. package/dist/capabilities/citation-expansion/CitationService.d.ts.map +1 -0
  29. package/dist/capabilities/citation-expansion/CitationService.js +243 -0
  30. package/dist/capabilities/citation-expansion/CitationService.js.map +1 -0
  31. package/dist/capabilities/citation-expansion/handler.d.ts +36 -0
  32. package/dist/capabilities/citation-expansion/handler.d.ts.map +1 -0
  33. package/dist/capabilities/citation-expansion/handler.js +44 -0
  34. package/dist/capabilities/citation-expansion/handler.js.map +1 -0
  35. package/dist/capabilities/citation-expansion/index.d.ts +6 -0
  36. package/dist/capabilities/citation-expansion/index.d.ts.map +1 -0
  37. package/dist/capabilities/citation-expansion/index.js +5 -0
  38. package/dist/capabilities/citation-expansion/index.js.map +1 -0
  39. package/dist/capabilities/citation-expansion/schemas.d.ts +28 -0
  40. package/dist/capabilities/citation-expansion/schemas.d.ts.map +1 -0
  41. package/dist/capabilities/citation-expansion/schemas.js +13 -0
  42. package/dist/capabilities/citation-expansion/schemas.js.map +1 -0
  43. package/dist/capabilities/citation-expansion/tools.d.ts +82 -0
  44. package/dist/capabilities/citation-expansion/tools.d.ts.map +1 -0
  45. package/dist/capabilities/citation-expansion/tools.js +48 -0
  46. package/dist/capabilities/citation-expansion/tools.js.map +1 -0
  47. package/dist/capabilities/citation-expansion/types.d.ts +22 -0
  48. package/dist/capabilities/citation-expansion/types.d.ts.map +1 -0
  49. package/dist/capabilities/citation-expansion/types.js +2 -0
  50. package/dist/capabilities/citation-expansion/types.js.map +1 -0
  51. package/dist/capabilities/journal-metrics/JournalMetricsService.d.ts +3 -0
  52. package/dist/capabilities/journal-metrics/JournalMetricsService.d.ts.map +1 -0
  53. package/dist/capabilities/journal-metrics/JournalMetricsService.js +142 -0
  54. package/dist/capabilities/journal-metrics/JournalMetricsService.js.map +1 -0
  55. package/dist/capabilities/journal-metrics/handler.d.ts +12 -0
  56. package/dist/capabilities/journal-metrics/handler.d.ts.map +1 -0
  57. package/dist/capabilities/journal-metrics/handler.js +38 -0
  58. package/dist/capabilities/journal-metrics/handler.js.map +1 -0
  59. package/dist/capabilities/journal-metrics/index.d.ts +6 -0
  60. package/dist/capabilities/journal-metrics/index.d.ts.map +1 -0
  61. package/dist/capabilities/journal-metrics/index.js +5 -0
  62. package/dist/capabilities/journal-metrics/index.js.map +1 -0
  63. package/dist/capabilities/journal-metrics/schemas.d.ts +28 -0
  64. package/dist/capabilities/journal-metrics/schemas.d.ts.map +1 -0
  65. package/dist/capabilities/journal-metrics/schemas.js +13 -0
  66. package/dist/capabilities/journal-metrics/schemas.js.map +1 -0
  67. package/dist/capabilities/journal-metrics/tools.d.ts +67 -0
  68. package/dist/capabilities/journal-metrics/tools.d.ts.map +1 -0
  69. package/dist/capabilities/journal-metrics/tools.js +27 -0
  70. package/dist/capabilities/journal-metrics/tools.js.map +1 -0
  71. package/dist/capabilities/journal-metrics/types.d.ts +36 -0
  72. package/dist/capabilities/journal-metrics/types.d.ts.map +1 -0
  73. package/dist/capabilities/journal-metrics/types.js +2 -0
  74. package/dist/capabilities/journal-metrics/types.js.map +1 -0
  75. package/dist/capabilities/metadata-search/MultiSourceSearchService.d.ts +9 -0
  76. package/dist/capabilities/metadata-search/MultiSourceSearchService.d.ts.map +1 -0
  77. package/dist/capabilities/metadata-search/MultiSourceSearchService.js +78 -0
  78. package/dist/capabilities/metadata-search/MultiSourceSearchService.js.map +1 -0
  79. package/dist/capabilities/metadata-search/handler.d.ts +23 -0
  80. package/dist/capabilities/metadata-search/handler.d.ts.map +1 -0
  81. package/dist/capabilities/metadata-search/handler.js +163 -0
  82. package/dist/capabilities/metadata-search/handler.js.map +1 -0
  83. package/dist/capabilities/metadata-search/index.d.ts +6 -0
  84. package/dist/capabilities/metadata-search/index.d.ts.map +1 -0
  85. package/dist/capabilities/metadata-search/index.js +5 -0
  86. package/dist/capabilities/metadata-search/index.js.map +1 -0
  87. package/dist/capabilities/metadata-search/schemas.d.ts +83 -0
  88. package/dist/capabilities/metadata-search/schemas.d.ts.map +1 -0
  89. package/dist/capabilities/metadata-search/schemas.js +81 -0
  90. package/dist/capabilities/metadata-search/schemas.js.map +1 -0
  91. package/dist/capabilities/metadata-search/tools.d.ts +178 -0
  92. package/dist/capabilities/metadata-search/tools.d.ts.map +1 -0
  93. package/dist/capabilities/metadata-search/tools.js +75 -0
  94. package/dist/capabilities/metadata-search/tools.js.map +1 -0
  95. package/dist/capabilities/metadata-search/types.d.ts +13 -0
  96. package/dist/capabilities/metadata-search/types.d.ts.map +1 -0
  97. package/dist/capabilities/metadata-search/types.js +2 -0
  98. package/dist/capabilities/metadata-search/types.js.map +1 -0
  99. package/dist/capabilities/pdf-discovery/DownloadTier.d.ts +22 -0
  100. package/dist/capabilities/pdf-discovery/DownloadTier.d.ts.map +1 -0
  101. package/dist/capabilities/pdf-discovery/DownloadTier.js +2 -0
  102. package/dist/capabilities/pdf-discovery/DownloadTier.js.map +1 -0
  103. package/dist/capabilities/pdf-discovery/OpenAccessFallbackService.d.ts +10 -0
  104. package/dist/capabilities/pdf-discovery/OpenAccessFallbackService.d.ts.map +1 -0
  105. package/dist/capabilities/pdf-discovery/OpenAccessFallbackService.js +53 -0
  106. package/dist/capabilities/pdf-discovery/OpenAccessFallbackService.js.map +1 -0
  107. package/dist/capabilities/pdf-discovery/handler.d.ts +19 -0
  108. package/dist/capabilities/pdf-discovery/handler.d.ts.map +1 -0
  109. package/dist/capabilities/pdf-discovery/handler.js +56 -0
  110. package/dist/capabilities/pdf-discovery/handler.js.map +1 -0
  111. package/dist/capabilities/pdf-discovery/index.d.ts +7 -0
  112. package/dist/capabilities/pdf-discovery/index.d.ts.map +1 -0
  113. package/dist/capabilities/pdf-discovery/index.js +5 -0
  114. package/dist/capabilities/pdf-discovery/index.js.map +1 -0
  115. package/dist/capabilities/pdf-discovery/schemas.d.ts +37 -0
  116. package/dist/capabilities/pdf-discovery/schemas.d.ts.map +1 -0
  117. package/dist/capabilities/pdf-discovery/schemas.js +22 -0
  118. package/dist/capabilities/pdf-discovery/schemas.js.map +1 -0
  119. package/dist/capabilities/pdf-discovery/tiers/directPdfUrl.d.ts +3 -0
  120. package/dist/capabilities/pdf-discovery/tiers/directPdfUrl.d.ts.map +1 -0
  121. package/dist/capabilities/pdf-discovery/tiers/directPdfUrl.js +27 -0
  122. package/dist/capabilities/pdf-discovery/tiers/directPdfUrl.js.map +1 -0
  123. package/dist/capabilities/pdf-discovery/tiers/primary.d.ts +3 -0
  124. package/dist/capabilities/pdf-discovery/tiers/primary.d.ts.map +1 -0
  125. package/dist/capabilities/pdf-discovery/tiers/primary.js +21 -0
  126. package/dist/capabilities/pdf-discovery/tiers/primary.js.map +1 -0
  127. package/dist/capabilities/pdf-discovery/tiers/repositories.d.ts +3 -0
  128. package/dist/capabilities/pdf-discovery/tiers/repositories.d.ts.map +1 -0
  129. package/dist/capabilities/pdf-discovery/tiers/repositories.js +35 -0
  130. package/dist/capabilities/pdf-discovery/tiers/repositories.js.map +1 -0
  131. package/dist/capabilities/pdf-discovery/tiers/scihub.d.ts +3 -0
  132. package/dist/capabilities/pdf-discovery/tiers/scihub.d.ts.map +1 -0
  133. package/dist/capabilities/pdf-discovery/tiers/scihub.js +21 -0
  134. package/dist/capabilities/pdf-discovery/tiers/scihub.js.map +1 -0
  135. package/dist/capabilities/pdf-discovery/tiers/unpaywall.d.ts +3 -0
  136. package/dist/capabilities/pdf-discovery/tiers/unpaywall.d.ts.map +1 -0
  137. package/dist/capabilities/pdf-discovery/tiers/unpaywall.js +29 -0
  138. package/dist/capabilities/pdf-discovery/tiers/unpaywall.js.map +1 -0
  139. package/dist/capabilities/pdf-discovery/tools.d.ts +114 -0
  140. package/dist/capabilities/pdf-discovery/tools.d.ts.map +1 -0
  141. package/dist/capabilities/pdf-discovery/tools.js +42 -0
  142. package/dist/capabilities/pdf-discovery/tools.js.map +1 -0
  143. package/dist/capabilities/pdf-discovery/types.d.ts +19 -0
  144. package/dist/capabilities/pdf-discovery/types.d.ts.map +1 -0
  145. package/dist/capabilities/pdf-discovery/types.js +2 -0
  146. package/dist/capabilities/pdf-discovery/types.js.map +1 -0
  147. package/dist/cli.js +10 -6
  148. package/dist/cli.js.map +1 -1
  149. package/dist/core/capabilityProfile.d.ts +1 -17
  150. package/dist/core/capabilityProfile.d.ts.map +1 -1
  151. package/dist/core/capabilityProfile.js +1 -152
  152. package/dist/core/capabilityProfile.js.map +1 -1
  153. package/dist/core/diagnostics.d.ts +1 -42
  154. package/dist/core/diagnostics.d.ts.map +1 -1
  155. package/dist/core/diagnostics.js +1 -585
  156. package/dist/core/diagnostics.js.map +1 -1
  157. package/dist/core/handleToolCall.d.ts +1 -0
  158. package/dist/core/handleToolCall.d.ts.map +1 -1
  159. package/dist/core/handleToolCall.js +265 -476
  160. package/dist/core/handleToolCall.js.map +1 -1
  161. package/dist/core/httpPolicies.d.ts +2 -0
  162. package/dist/core/httpPolicies.d.ts.map +1 -0
  163. package/dist/core/httpPolicies.js +2 -0
  164. package/dist/core/httpPolicies.js.map +1 -0
  165. package/dist/core/liveSmoke.d.ts +1 -41
  166. package/dist/core/liveSmoke.d.ts.map +1 -1
  167. package/dist/core/liveSmoke.js +1 -225
  168. package/dist/core/liveSmoke.js.map +1 -1
  169. package/dist/core/platformFactories.d.ts +2 -0
  170. package/dist/core/platformFactories.d.ts.map +1 -0
  171. package/dist/core/platformFactories.js +2 -0
  172. package/dist/core/platformFactories.js.map +1 -0
  173. package/dist/core/platformMetadata.d.ts +1 -27
  174. package/dist/core/platformMetadata.d.ts.map +1 -1
  175. package/dist/core/platformMetadata.js +1 -257
  176. package/dist/core/platformMetadata.js.map +1 -1
  177. package/dist/core/schemas.d.ts +11 -177
  178. package/dist/core/schemas.d.ts.map +1 -1
  179. package/dist/core/schemas.js +14 -107
  180. package/dist/core/schemas.js.map +1 -1
  181. package/dist/core/searchers.d.ts +24 -24
  182. package/dist/core/searchers.d.ts.map +1 -1
  183. package/dist/core/searchers.js +14 -79
  184. package/dist/core/searchers.js.map +1 -1
  185. package/dist/core/textReports.d.ts +1 -20
  186. package/dist/core/textReports.d.ts.map +1 -1
  187. package/dist/core/textReports.js +1 -84
  188. package/dist/core/textReports.js.map +1 -1
  189. package/dist/core/tools.d.ts.map +1 -1
  190. package/dist/core/tools.js +15 -183
  191. package/dist/core/tools.js.map +1 -1
  192. package/dist/infrastructure/cache/RequestCache.d.ts +26 -0
  193. package/dist/infrastructure/cache/RequestCache.d.ts.map +1 -0
  194. package/dist/infrastructure/cache/RequestCache.js +66 -0
  195. package/dist/infrastructure/cache/RequestCache.js.map +1 -0
  196. package/dist/infrastructure/http/ErrorHandler.d.ts +99 -0
  197. package/dist/infrastructure/http/ErrorHandler.d.ts.map +1 -0
  198. package/dist/infrastructure/http/ErrorHandler.js +266 -0
  199. package/dist/infrastructure/http/ErrorHandler.js.map +1 -0
  200. package/dist/infrastructure/http/HttpClient.d.ts +31 -0
  201. package/dist/infrastructure/http/HttpClient.d.ts.map +1 -0
  202. package/dist/infrastructure/http/HttpClient.js +50 -0
  203. package/dist/infrastructure/http/HttpClient.js.map +1 -0
  204. package/dist/infrastructure/pdf/PDFExtractor.d.ts +34 -0
  205. package/dist/infrastructure/pdf/PDFExtractor.d.ts.map +1 -0
  206. package/dist/infrastructure/pdf/PDFExtractor.js +130 -0
  207. package/dist/infrastructure/pdf/PDFExtractor.js.map +1 -0
  208. package/dist/infrastructure/pdf/PdfDownload.d.ts +7 -0
  209. package/dist/infrastructure/pdf/PdfDownload.d.ts.map +1 -0
  210. package/dist/infrastructure/pdf/PdfDownload.js +175 -0
  211. package/dist/infrastructure/pdf/PdfDownload.js.map +1 -0
  212. package/dist/infrastructure/rate-limit/RateLimiter.d.ts +50 -0
  213. package/dist/infrastructure/rate-limit/RateLimiter.d.ts.map +1 -0
  214. package/dist/infrastructure/rate-limit/RateLimiter.js +128 -0
  215. package/dist/infrastructure/rate-limit/RateLimiter.js.map +1 -0
  216. package/dist/infrastructure/security/SecurityUtils.d.ts +80 -0
  217. package/dist/infrastructure/security/SecurityUtils.d.ts.map +1 -0
  218. package/dist/infrastructure/security/SecurityUtils.js +357 -0
  219. package/dist/infrastructure/security/SecurityUtils.js.map +1 -0
  220. package/dist/management/capability-profile/index.d.ts +18 -0
  221. package/dist/management/capability-profile/index.d.ts.map +1 -0
  222. package/dist/management/capability-profile/index.js +167 -0
  223. package/dist/management/capability-profile/index.js.map +1 -0
  224. package/dist/management/config/index.d.ts +2 -0
  225. package/dist/management/config/index.d.ts.map +1 -0
  226. package/dist/management/config/index.js +2 -0
  227. package/dist/management/config/index.js.map +1 -0
  228. package/dist/management/diagnostics/index.d.ts +43 -0
  229. package/dist/management/diagnostics/index.d.ts.map +1 -0
  230. package/dist/management/diagnostics/index.js +586 -0
  231. package/dist/management/diagnostics/index.js.map +1 -0
  232. package/dist/management/reports/index.d.ts +21 -0
  233. package/dist/management/reports/index.d.ts.map +1 -0
  234. package/dist/management/reports/index.js +85 -0
  235. package/dist/management/reports/index.js.map +1 -0
  236. package/dist/management/skills/index.d.ts +2 -0
  237. package/dist/management/skills/index.d.ts.map +1 -0
  238. package/dist/management/skills/index.js +2 -0
  239. package/dist/management/skills/index.js.map +1 -0
  240. package/dist/management/smoke/index.d.ts +42 -0
  241. package/dist/management/smoke/index.d.ts.map +1 -0
  242. package/dist/management/smoke/index.js +226 -0
  243. package/dist/management/smoke/index.js.map +1 -0
  244. package/dist/platforms/BioRxivSearcher.d.ts.map +1 -1
  245. package/dist/platforms/BioRxivSearcher.js +40 -21
  246. package/dist/platforms/BioRxivSearcher.js.map +1 -1
  247. package/dist/platforms/GoogleScholarSearcher.d.ts.map +1 -1
  248. package/dist/platforms/GoogleScholarSearcher.js +3 -2
  249. package/dist/platforms/GoogleScholarSearcher.js.map +1 -1
  250. package/dist/registry/aliases.d.ts +2 -0
  251. package/dist/registry/aliases.d.ts.map +1 -0
  252. package/dist/registry/aliases.js +2 -0
  253. package/dist/registry/aliases.js.map +1 -0
  254. package/dist/registry/httpPolicies.d.ts +3 -0
  255. package/dist/registry/httpPolicies.d.ts.map +1 -0
  256. package/dist/registry/httpPolicies.js +17 -0
  257. package/dist/registry/httpPolicies.js.map +1 -0
  258. package/dist/registry/platformFactories.d.ts +8 -0
  259. package/dist/registry/platformFactories.d.ts.map +1 -0
  260. package/dist/registry/platformFactories.js +55 -0
  261. package/dist/registry/platformFactories.js.map +1 -0
  262. package/dist/registry/platformMetadata.d.ts +39 -0
  263. package/dist/registry/platformMetadata.d.ts.map +1 -0
  264. package/dist/registry/platformMetadata.js +321 -0
  265. package/dist/registry/platformMetadata.js.map +1 -0
  266. package/dist/services/CitationService.d.ts +2 -65
  267. package/dist/services/CitationService.d.ts.map +1 -1
  268. package/dist/services/CitationService.js +1 -236
  269. package/dist/services/CitationService.js.map +1 -1
  270. package/dist/services/JournalMetricsService.d.ts +2 -37
  271. package/dist/services/JournalMetricsService.d.ts.map +1 -1
  272. package/dist/services/JournalMetricsService.js +1 -141
  273. package/dist/services/JournalMetricsService.js.map +1 -1
  274. package/dist/services/MultiSourceSearchService.d.ts +2 -18
  275. package/dist/services/MultiSourceSearchService.d.ts.map +1 -1
  276. package/dist/services/MultiSourceSearchService.js +1 -77
  277. package/dist/services/MultiSourceSearchService.js.map +1 -1
  278. package/dist/services/OpenAccessFallbackService.d.ts +3 -20
  279. package/dist/services/OpenAccessFallbackService.d.ts.map +1 -1
  280. package/dist/services/OpenAccessFallbackService.js +1 -123
  281. package/dist/services/OpenAccessFallbackService.js.map +1 -1
  282. package/dist/utils/ErrorHandler.d.ts +2 -98
  283. package/dist/utils/ErrorHandler.d.ts.map +1 -1
  284. package/dist/utils/ErrorHandler.js +2 -265
  285. package/dist/utils/ErrorHandler.js.map +1 -1
  286. package/dist/utils/HttpClient.d.ts +1 -5
  287. package/dist/utils/HttpClient.d.ts.map +1 -1
  288. package/dist/utils/HttpClient.js +1 -29
  289. package/dist/utils/HttpClient.js.map +1 -1
  290. package/dist/utils/PDFExtractor.d.ts +2 -33
  291. package/dist/utils/PDFExtractor.d.ts.map +1 -1
  292. package/dist/utils/PDFExtractor.js +2 -129
  293. package/dist/utils/PDFExtractor.js.map +1 -1
  294. package/dist/utils/PdfDownload.d.ts +1 -6
  295. package/dist/utils/PdfDownload.d.ts.map +1 -1
  296. package/dist/utils/PdfDownload.js +1 -141
  297. package/dist/utils/PdfDownload.js.map +1 -1
  298. package/dist/utils/RateLimiter.d.ts +1 -49
  299. package/dist/utils/RateLimiter.d.ts.map +1 -1
  300. package/dist/utils/RateLimiter.js +1 -120
  301. package/dist/utils/RateLimiter.js.map +1 -1
  302. package/dist/utils/RequestCache.d.ts +2 -25
  303. package/dist/utils/RequestCache.d.ts.map +1 -1
  304. package/dist/utils/RequestCache.js +2 -65
  305. package/dist/utils/RequestCache.js.map +1 -1
  306. package/dist/utils/SecurityUtils.d.ts +2 -79
  307. package/dist/utils/SecurityUtils.d.ts.map +1 -1
  308. package/dist/utils/SecurityUtils.js +2 -356
  309. package/dist/utils/SecurityUtils.js.map +1 -1
  310. package/package.json +1 -1
  311. package/skills/paper-search/SKILL.md +4 -2
  312. package/skills/paper-search/references/capability-routing.md +15 -2
  313. package/skills/paper-search/references/cli-contract.md +19 -0
  314. package/skills/paper-search/references/management-layer.md +1 -0
@@ -1,124 +1,2 @@
1
- import { downloadPdfFromUrl, safeFilename } from '../utils/PdfDownload.js';
2
- const REPOSITORY_SOURCES = ['pmc', 'europepmc', 'core', 'openaire'];
3
- export async function downloadWithFallback(searchers, options) {
4
- const savePath = options.savePath || './downloads';
5
- const attempts = [];
6
- const source = normalizeSource(options.source);
7
- const primary = searchers[source];
8
- if (primary?.getCapabilities().download) {
9
- try {
10
- const path = await primary.downloadPdf(options.paperId, { savePath });
11
- attempts.push({ stage: 'primary', status: 'ok', message: path });
12
- return { status: 'ok', path, attempts };
13
- }
14
- catch (error) {
15
- attempts.push({ stage: 'primary', status: 'error', message: error?.message || String(error) });
16
- }
17
- }
18
- else {
19
- attempts.push({ stage: 'primary', status: 'skipped', message: `No primary downloader for ${source}` });
20
- }
21
- const directResult = await tryDirectMetadataUrl(searchers, source, options.paperId, savePath, attempts);
22
- if (directResult)
23
- return { status: 'ok', path: directResult, attempts };
24
- const repositoryResult = await tryRepositoryFallback(searchers, options, savePath, attempts);
25
- if (repositoryResult)
26
- return { status: 'ok', path: repositoryResult, attempts };
27
- const unpaywallResult = await tryUnpaywall(searchers, options.doi || '', savePath, attempts);
28
- if (unpaywallResult)
29
- return { status: 'ok', path: unpaywallResult, attempts };
30
- if (options.useSciHub !== false) {
31
- const identifier = options.doi || options.title || options.paperId;
32
- try {
33
- const path = await searchers.scihub.downloadPdf(identifier, { savePath });
34
- attempts.push({ stage: 'scihub', status: 'ok', message: path });
35
- return { status: 'ok', path, attempts };
36
- }
37
- catch (error) {
38
- attempts.push({ stage: 'scihub', status: 'error', message: error?.message || String(error) });
39
- }
40
- }
41
- else {
42
- attempts.push({ stage: 'scihub', status: 'skipped', message: 'Sci-Hub fallback disabled by useSciHub=false.' });
43
- }
44
- return { status: 'error', attempts };
45
- }
46
- async function tryDirectMetadataUrl(searchers, source, paperId, savePath, attempts) {
47
- const searcher = searchers[source];
48
- if (!searcher)
49
- return '';
50
- try {
51
- const paper = await searcher.getPaperByDoi(paperId);
52
- if (!paper?.pdfUrl) {
53
- attempts.push({ stage: 'direct_pdf_url', status: 'skipped', message: 'No pdf_url found in source metadata.' });
54
- return '';
55
- }
56
- const path = await downloadPdfFromUrl(paper.pdfUrl, savePath, `${source}_${safeFilename(paper.paperId)}`);
57
- attempts.push({ stage: 'direct_pdf_url', status: 'ok', message: path });
58
- return path;
59
- }
60
- catch (error) {
61
- attempts.push({ stage: 'direct_pdf_url', status: 'error', message: error?.message || String(error) });
62
- return '';
63
- }
64
- }
65
- async function tryRepositoryFallback(searchers, options, savePath, attempts) {
66
- const queries = [options.doi || '', options.title || ''].filter(Boolean);
67
- if (queries.length === 0) {
68
- attempts.push({ stage: 'repositories', status: 'skipped', message: 'No DOI/title provided for repository discovery.' });
69
- return '';
70
- }
71
- for (const source of REPOSITORY_SOURCES) {
72
- const searcher = searchers[source];
73
- if (!searcher)
74
- continue;
75
- for (const query of queries) {
76
- try {
77
- const papers = await searcher.search(query, { maxResults: 3 });
78
- const paper = papers.find(candidate => candidate.pdfUrl);
79
- if (!paper?.pdfUrl)
80
- continue;
81
- const path = await downloadPdfFromUrl(paper.pdfUrl, savePath, `${source}_${safeFilename(paper.paperId)}`);
82
- attempts.push({ stage: `repository:${source}`, status: 'ok', message: path });
83
- return path;
84
- }
85
- catch (error) {
86
- attempts.push({ stage: `repository:${source}`, status: 'error', message: error?.message || String(error) });
87
- }
88
- }
89
- }
90
- attempts.push({ stage: 'repositories', status: 'skipped', message: 'No repository PDF candidate succeeded.' });
91
- return '';
92
- }
93
- async function tryUnpaywall(searchers, doi, savePath, attempts) {
94
- if (!doi) {
95
- attempts.push({ stage: 'unpaywall', status: 'skipped', message: 'DOI not provided.' });
96
- return '';
97
- }
98
- try {
99
- const unpaywall = searchers.unpaywall;
100
- const pdfUrl = await unpaywall.resolveBestPdfUrl(doi);
101
- if (!pdfUrl) {
102
- attempts.push({ stage: 'unpaywall', status: 'skipped', message: 'No OA PDF URL found or email not configured.' });
103
- return '';
104
- }
105
- const path = await downloadPdfFromUrl(pdfUrl, savePath, `unpaywall_${safeFilename(doi)}`);
106
- attempts.push({ stage: 'unpaywall', status: 'ok', message: path });
107
- return path;
108
- }
109
- catch (error) {
110
- attempts.push({ stage: 'unpaywall', status: 'error', message: error?.message || String(error) });
111
- return '';
112
- }
113
- }
114
- function normalizeSource(source) {
115
- const normalized = source.trim().toLowerCase();
116
- if (normalized === 'google_scholar')
117
- return 'googlescholar';
118
- if (normalized === 'pubmed_central')
119
- return 'pmc';
120
- if (normalized === 'europe_pmc')
121
- return 'europepmc';
122
- return normalized;
123
- }
1
+ export { createDefaultDownloadTiers, downloadWithFallback, INSTITUTIONAL_ACCESS_TIER_ID, insertDownloadTierBefore } from '../capabilities/pdf-discovery/OpenAccessFallbackService.js';
124
2
  //# sourceMappingURL=OpenAccessFallbackService.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"OpenAccessFallbackService.js","sourceRoot":"","sources":["../../src/services/OpenAccessFallbackService.ts"],"names":[],"mapp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,MAAM,EAAE,QAAQ,EAAE,aAAa,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC1F,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QACnE,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,QAAQ,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACjG,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED,SAAS,eAAe,CAAC,MAAc;IACrC,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC/C,IAAI,UAAU,KAAK,gBAAgB;QAAE,OAAO,eAAe,CAAC;IAC5D,IAAI,UAAU,KAAK,gBAAgB;QAAE,OAAO,KAAK,CAAC;IAClD,IAAI,UAAU,KAAK,YAAY;QAAE,OAAO,WAAW,CAAC;IACpD,OAAO,UAAU,CAAC;AACpB,CAAC"}
1
+ {"version":3,"file":"OpenAccessFallbackService.js","sourceRoot":"","sources":["../../src/services/OpenAccessFallbackService.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,oBAAoB,EACpB,4BAA4B,EAC5B,wBAAwB,EACzB,MAAM,4DAA4D,CAAC"}
@@ -1,99 +1,3 @@
1
- /**
2
- * Unified Error Handler for API requests
3
- * Provides consistent error handling across all platforms
4
- */
5
- /**
6
- * API Error codes and their meanings
7
- */
8
- export declare const HTTP_ERROR_CODES: {
9
- readonly 400: "Bad Request - Invalid parameters or syntax";
10
- readonly 401: "Unauthorized - Invalid or missing API key";
11
- readonly 403: "Forbidden - Access denied or rate limit exceeded";
12
- readonly 404: "Not Found - Resource does not exist";
13
- readonly 405: "Method Not Allowed - HTTP method not supported";
14
- readonly 408: "Request Timeout - Server took too long to respond";
15
- readonly 429: "Too Many Requests - Rate limit exceeded";
16
- readonly 500: "Internal Server Error - Server error";
17
- readonly 502: "Bad Gateway - Server communication error";
18
- readonly 503: "Service Unavailable - Server temporarily unavailable";
19
- readonly 504: "Gateway Timeout - Server timeout";
20
- };
21
- /**
22
- * Custom API Error class with detailed information
23
- */
24
- export declare class ApiError extends Error {
25
- readonly status?: number;
26
- readonly platform: string;
27
- readonly operation: string;
28
- readonly timestamp: string;
29
- readonly retryable: boolean;
30
- readonly details?: any;
31
- constructor(options: {
32
- message: string;
33
- status?: number;
34
- platform: string;
35
- operation: string;
36
- details?: any;
37
- });
38
- private isRetryable;
39
- toJSON(): {
40
- name: string;
41
- message: string;
42
- status: number | undefined;
43
- platform: string;
44
- operation: string;
45
- timestamp: string;
46
- retryable: boolean;
47
- };
48
- }
49
- /**
50
- * Error Handler class for unified error processing
51
- */
52
- export declare class ErrorHandler {
53
- private platform;
54
- private verbose;
55
- constructor(platform: string, verbose?: boolean);
56
- /**
57
- * Handle HTTP errors from axios or similar libraries
58
- */
59
- handleHttpError(error: any, operation: string): never;
60
- /**
61
- * Handle generic errors
62
- */
63
- handleError(error: any, operation: string): never;
64
- /**
65
- * Extract error message from various error formats
66
- */
67
- private extractErrorMessage;
68
- /**
69
- * Create user-friendly error message
70
- */
71
- private createUserMessage;
72
- /**
73
- * Sanitize URL for logging
74
- */
75
- private sanitizeUrl;
76
- /**
77
- * Log error with consistent format
78
- */
79
- private logError;
80
- /**
81
- * Check if an error is retryable
82
- */
83
- static isRetryable(error: any): boolean;
84
- /**
85
- * Get suggested retry delay based on error
86
- */
87
- static getRetryDelay(error: any, attempt?: number): number;
88
- /**
89
- * Retry a function with exponential backoff and full jitter
90
- */
91
- static retryWithBackoff<T>(fn: () => Promise<T>, options?: {
92
- maxRetries?: number;
93
- initialDelayMs?: number;
94
- maxDelayMs?: number;
95
- context?: string;
96
- }): Promise<T>;
97
- }
98
- export default ErrorHandler;
1
+ export * from '../infrastructure/http/ErrorHandler.js';
2
+ export { default } from '../infrastructure/http/ErrorHandler.js';
99
3
  //# sourceMappingURL=ErrorHandler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ErrorHandler.d.ts","sourceRoot":"","sources":["../../src/utils/ErrorHandler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;CAYnB,CAAC;AAEX;;GAEG;AACH,qBAAa,QAAS,SAAQ,KAAK;IACjC,SAAgB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChC,SAAgB,QAAQ,EAAE,MAAM,CAAC;IACjC,SAAgB,SAAS,EAAE,MAAM,CAAC;IAClC,SAAgB,SAAS,EAAE,MAAM,CAAC;IAClC,SAAgB,SAAS,EAAE,OAAO,CAAC;IACnC,SAAgB,OAAO,CAAC,EAAE,GAAG,CAAC;gBAElB,OAAO,EAAE;QACnB,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,CAAC,EAAE,GAAG,CAAC;KACf;IAaD,OAAO,CAAC,WAAW;IAMnB,MAAM;;;;;;;;;CAWP;AAED;;GAEG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,OAAO,CAAU;gBAEb,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,OAAe;IAKtD;;OAEG;IACH,eAAe,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,GAAG,KAAK;IAiCrD;;OAEG;IACH,WAAW,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,GAAG,KAAK;IAqBjD;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAuB3B;;OAEG;IACH,OAAO,CAAC,iBAAiB;IA6BzB;;OAEG;IACH,OAAO,CAAC,WAAW;IAiBnB;;OAEG;IACH,OAAO,CAAC,QAAQ;IAOhB;;OAEG;IACH,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO;IASvC;;OAEG;IACH,MAAM,CAAC,aAAa,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,GAAE,MAAU,GAAG,MAAM;IAyB7D;;OAEG;WACU,gBAAgB,CAAC,CAAC,EAC7B,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,OAAO,GAAE;QACP,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,OAAO,CAAC,EAAE,MAAM,CAAC;KACb,GACL,OAAO,CAAC,CAAC,CAAC;CAgCd;AAED,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"ErrorHandler.d.ts","sourceRoot":"","sources":["../../src/utils/ErrorHandler.ts"],"names":[],"mappings":"AAAA,cAAc,wCAAwC,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,wCAAwC,CAAC"}
@@ -1,266 +1,3 @@
1
- /**
2
- * Unified Error Handler for API requests
3
- * Provides consistent error handling across all platforms
4
- */
5
- import { sanitizeRequest, maskSensitiveData } from './SecurityUtils.js';
6
- import { logError as loggerError, logDebug } from './Logger.js';
7
- /**
8
- * API Error codes and their meanings
9
- */
10
- export const HTTP_ERROR_CODES = {
11
- 400: 'Bad Request - Invalid parameters or syntax',
12
- 401: 'Unauthorized - Invalid or missing API key',
13
- 403: 'Forbidden - Access denied or rate limit exceeded',
14
- 404: 'Not Found - Resource does not exist',
15
- 405: 'Method Not Allowed - HTTP method not supported',
16
- 408: 'Request Timeout - Server took too long to respond',
17
- 429: 'Too Many Requests - Rate limit exceeded',
18
- 500: 'Internal Server Error - Server error',
19
- 502: 'Bad Gateway - Server communication error',
20
- 503: 'Service Unavailable - Server temporarily unavailable',
21
- 504: 'Gateway Timeout - Server timeout'
22
- };
23
- /**
24
- * Custom API Error class with detailed information
25
- */
26
- export class ApiError extends Error {
27
- status;
28
- platform;
29
- operation;
30
- timestamp;
31
- retryable;
32
- details;
33
- constructor(options) {
34
- super(options.message);
35
- this.name = 'ApiError';
36
- this.status = options.status;
37
- this.platform = options.platform;
38
- this.operation = options.operation;
39
- this.timestamp = new Date().toISOString();
40
- this.details = options.details;
41
- // Determine if error is retryable
42
- this.retryable = this.isRetryable(options.status);
43
- }
44
- isRetryable(status) {
45
- if (!status)
46
- return true;
47
- // Retryable: rate limits, timeouts, server errors
48
- return [408, 429, 500, 502, 503, 504].includes(status);
49
- }
50
- toJSON() {
51
- return {
52
- name: this.name,
53
- message: this.message,
54
- status: this.status,
55
- platform: this.platform,
56
- operation: this.operation,
57
- timestamp: this.timestamp,
58
- retryable: this.retryable
59
- };
60
- }
61
- }
62
- /**
63
- * Error Handler class for unified error processing
64
- */
65
- export class ErrorHandler {
66
- platform;
67
- verbose;
68
- constructor(platform, verbose = false) {
69
- this.platform = platform;
70
- this.verbose = verbose || process.env.NODE_ENV === 'development';
71
- }
72
- /**
73
- * Handle HTTP errors from axios or similar libraries
74
- */
75
- handleHttpError(error, operation) {
76
- const status = error.response?.status;
77
- const responseMessage = this.extractErrorMessage(error);
78
- const url = error.config?.url;
79
- const method = error.config?.method?.toUpperCase() || 'GET';
80
- // Sanitize sensitive data before logging
81
- const sanitizedConfig = sanitizeRequest(error.config);
82
- const sanitizedUrl = url ? this.sanitizeUrl(url) : 'unknown';
83
- // Log error details (sanitized)
84
- this.logError({
85
- status,
86
- message: responseMessage,
87
- url: sanitizedUrl,
88
- method,
89
- operation,
90
- config: this.verbose ? sanitizedConfig : undefined,
91
- responseData: this.verbose ? error.response?.data : undefined
92
- });
93
- // Create user-friendly error message
94
- const userMessage = this.createUserMessage(status, responseMessage, operation);
95
- throw new ApiError({
96
- message: userMessage,
97
- status,
98
- platform: this.platform,
99
- operation,
100
- details: this.verbose ? { url: sanitizedUrl, method } : undefined
101
- });
102
- }
103
- /**
104
- * Handle generic errors
105
- */
106
- handleError(error, operation) {
107
- if (error.response) {
108
- // HTTP error
109
- this.handleHttpError(error, operation);
110
- }
111
- const message = error.message || 'Unknown error occurred';
112
- this.logError({
113
- message,
114
- operation,
115
- stack: this.verbose ? error.stack : undefined
116
- });
117
- throw new ApiError({
118
- message: `${this.platform} ${operation} failed: ${message}`,
119
- platform: this.platform,
120
- operation
121
- });
122
- }
123
- /**
124
- * Extract error message from various error formats
125
- */
126
- extractErrorMessage(error) {
127
- // Try different error message locations
128
- const candidates = [
129
- error.response?.data?.message,
130
- error.response?.data?.error?.message,
131
- error.response?.data?.error?.error_description,
132
- error.response?.data?.error,
133
- error.response?.data?.detail,
134
- error.response?.data?.['service-error']?.status?.statusText,
135
- error.response?.data?.apiMessage,
136
- error.response?.statusText,
137
- error.message
138
- ];
139
- for (const candidate of candidates) {
140
- if (candidate && typeof candidate === 'string') {
141
- return candidate;
142
- }
143
- }
144
- return 'Unknown error';
145
- }
146
- /**
147
- * Create user-friendly error message
148
- */
149
- createUserMessage(status, message, operation) {
150
- const statusDesc = status ? HTTP_ERROR_CODES[status] : '';
151
- // Platform-specific messages
152
- if (status === 401) {
153
- if (/not authorized|insufficient|permission|entitlement|access.*requested/i.test(message)) {
154
- return `${this.platform}: API key was accepted but does not have permission for this API product, view, or resource.`;
155
- }
156
- return `${this.platform}: Invalid or missing API key. Please check your credentials.`;
157
- }
158
- if (status === 403) {
159
- return `${this.platform}: Access forbidden. This may be due to rate limiting or insufficient permissions.`;
160
- }
161
- if (status === 404) {
162
- return `${this.platform}: Resource not found. The requested item may not exist.`;
163
- }
164
- if (status === 429) {
165
- return `${this.platform}: Rate limit exceeded. Please wait before making more requests.`;
166
- }
167
- if (status && status >= 500) {
168
- return `${this.platform}: Server error (${status}). The service may be temporarily unavailable.`;
169
- }
170
- // Generic message
171
- const prefix = `${this.platform} ${operation} failed`;
172
- const statusInfo = status ? ` (${status}${statusDesc ? ': ' + statusDesc : ''})` : '';
173
- return `${prefix}${statusInfo}: ${maskSensitiveData(message)}`;
174
- }
175
- /**
176
- * Sanitize URL for logging
177
- */
178
- sanitizeUrl(url) {
179
- try {
180
- const urlObj = new URL(url);
181
- // Remove sensitive query parameters
182
- const sensitiveParams = ['api_key', 'apikey', 'key', 'token', 'secret', 'auth'];
183
- sensitiveParams.forEach(param => {
184
- if (urlObj.searchParams.has(param)) {
185
- urlObj.searchParams.set(param, '***');
186
- }
187
- });
188
- return urlObj.toString();
189
- }
190
- catch {
191
- // If URL parsing fails, mask the entire thing
192
- return '***sanitized-url***';
193
- }
194
- }
195
- /**
196
- * Log error with consistent format
197
- */
198
- logError(details) {
199
- loggerError(`[${this.platform}] Error:`, {
200
- timestamp: new Date().toISOString(),
201
- ...details
202
- });
203
- }
204
- /**
205
- * Check if an error is retryable
206
- */
207
- static isRetryable(error) {
208
- if (error instanceof ApiError) {
209
- return error.retryable;
210
- }
211
- const status = error.response?.status;
212
- if (!status)
213
- return true;
214
- return [408, 429, 500, 502, 503, 504].includes(status);
215
- }
216
- /**
217
- * Get suggested retry delay based on error
218
- */
219
- static getRetryDelay(error, attempt = 1) {
220
- const status = error.response?.status || error.status;
221
- // For rate limiting, check Retry-After header
222
- if (status === 429) {
223
- const retryAfter = error.response?.headers?.['retry-after'];
224
- if (retryAfter) {
225
- const seconds = parseInt(retryAfter, 10);
226
- if (!isNaN(seconds)) {
227
- return seconds * 1000;
228
- }
229
- }
230
- // Default: exponential backoff for rate limits
231
- return Math.min(60000, 1000 * Math.pow(2, attempt));
232
- }
233
- // For server errors, use exponential backoff
234
- if (status && status >= 500) {
235
- return Math.min(30000, 1000 * Math.pow(2, attempt));
236
- }
237
- // Default delay
238
- return 1000 * attempt;
239
- }
240
- /**
241
- * Retry a function with exponential backoff and full jitter
242
- */
243
- static async retryWithBackoff(fn, options = {}) {
244
- const { maxRetries = 3, initialDelayMs = 1000, maxDelayMs = 30000, context = 'operation' } = options;
245
- let lastError;
246
- for (let attempt = 0; attempt <= maxRetries; attempt++) {
247
- try {
248
- return await fn();
249
- }
250
- catch (error) {
251
- lastError = error;
252
- if (attempt >= maxRetries || !ErrorHandler.isRetryable(error)) {
253
- throw error;
254
- }
255
- // Exponential backoff with full jitter
256
- const baseDelay = Math.min(maxDelayMs, initialDelayMs * Math.pow(2, attempt));
257
- const jitteredDelay = Math.floor(Math.random() * baseDelay);
258
- logDebug(`[Retry] ${context} attempt ${attempt + 1}/${maxRetries} failed, retrying in ${jitteredDelay}ms`);
259
- await new Promise(resolve => setTimeout(resolve, jitteredDelay));
260
- }
261
- }
262
- throw lastError;
263
- }
264
- }
265
- export default ErrorHandler;
1
+ export * from '../infrastructure/http/ErrorHandler.js';
2
+ export { default } from '../infrastructure/http/ErrorHandler.js';
266
3
  //# sourceMappingURL=ErrorHandler.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ErrorHandler.js","sourceRoot":"","sources":["../../src/utils/ErrorHandler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAAE,QAAQ,IAAI,WAAW,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEhE;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,GAAG,EAAE,4CAA4C;IACjD,GAAG,EAAE,2CAA2C;IAChD,GAAG,EAAE,kDAAkD;IACvD,GAAG,EAAE,qCAAqC;IAC1C,GAAG,EAAE,gDAAgD;IACrD,GAAG,EAAE,mDAAmD;IACxD,GAAG,EAAE,yCAAyC;IAC9C,GAAG,EAAE,sCAAsC;IAC3C,GAAG,EAAE,0CAA0C;IAC/C,GAAG,EAAE,sDAAsD;IAC3D,GAAG,EAAE,kCAAkC;CAC/B,CAAC;AAEX;;GAEG;AACH,MAAM,OAAO,QAAS,SAAQ,KAAK;IACjB,M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,2 @@
1
- /**
2
- * Initializes global HTTP/HTTPS and SOCKS proxy agents for Axios
3
- * based on standard proxy environment variables.
4
- */
5
- export declare function setupGlobalProxy(): void;
1
+ export * from '../infrastructure/http/HttpClient.js';
6
2
  //# sourceMappingURL=HttpClient.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"HttpClient.d.ts","sourceRoot":"","sources":["../../src/utils/HttpClient.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAuBvC"}
1
+ {"version":3,"file":"HttpClient.d.ts","sourceRoot":"","sources":["../../src/utils/HttpClient.ts"],"names":[],"mappings":"AAAA,cAAc,sCAAsC,CAAC"}
@@ -1,30 +1,2 @@
1
- import axios from 'axios';
2
- import { HttpsProxyAgent } from 'https-proxy-agent';
3
- import { SocksProxyAgent } from 'socks-proxy-agent';
4
- import { logDebug } from './Logger.js';
5
- /**
6
- * Initializes global HTTP/HTTPS and SOCKS proxy agents for Axios
7
- * based on standard proxy environment variables.
8
- */
9
- export function setupGlobalProxy() {
10
- const proxy = process.env.HTTPS_PROXY ||
11
- process.env.HTTP_PROXY ||
12
- process.env.https_proxy ||
13
- process.env.http_proxy;
14
- if (!proxy) {
15
- return;
16
- }
17
- try {
18
- logDebug(`Configuring global HTTP/HTTPS proxy: ${proxy}`);
19
- const agent = proxy.startsWith('socks')
20
- ? new SocksProxyAgent(proxy)
21
- : new HttpsProxyAgent(proxy);
22
- // Inject agent as default for both http and https protocols
23
- axios.defaults.httpAgent = agent;
24
- axios.defaults.httpsAgent = agent;
25
- }
26
- catch (error) {
27
- logDebug(`Failed to initialize global proxy agent: ${error.message}`);
28
- }
29
- }
1
+ export * from '../infrastructure/http/HttpClient.js';
30
2
  //# sourceMappingURL=HttpClient.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"HttpClient.js","sourceRoot":"","sources":["../../src/utils/HttpClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC;;;GAGG;AACH,MAAM,UAAU,gBAAgB;IAC9B,MAAM,KAAK,GACT,OAAO,CAAC,GAAG,CAAC,WAAW;QACvB,OAAO,CAAC,GAAG,CAAC,UAAU;QACtB,OAAO,CAAC,GAAG,CAAC,WAAW;QACvB,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC;IAEzB,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO;IACT,CAAC;IAED,IAAI,CAAC;QACH,QAAQ,CAAC,wCAAwC,KAAK,EAAE,CAAC,CAAC;QAC1D,MAAM,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC;YACrC,CAAC,CAAC,IAAI,eAAe,CAAC,KAAK,CAAC;YAC5B,CAAC,CAAC,IAAI,eAAe,CAAC,KAAK,CAAC,CAAC;QAE/B,4DAA4D;QAC5D,KAAK,CAAC,QAAQ,CAAC,SAAS,GAAG,KAAK,CAAC;QACjC,KAAK,CAAC,QAAQ,CAAC,UAAU,GAAG,KAAK,CAAC;IACpC,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,QAAQ,CAAC,4CAA4C,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IACxE,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"HttpClient.js","sourceRoot":"","sources":["../../src/utils/HttpClient.ts"],"names":[],"mappings":"AAAA,cAAc,sCAAsC,CAAC"}
@@ -1,34 +1,3 @@
1
- export interface PDFExtractOptions {
2
- maxPages?: number;
3
- cleanText?: boolean;
4
- }
5
- export interface PDFExtractResult {
6
- text: string;
7
- numPages: number;
8
- info?: any;
9
- metadata?: any;
10
- }
11
- export declare class PDFExtractor {
12
- /**
13
- * Download PDF from URL and extract text
14
- */
15
- extractFromUrl(url: string, options?: PDFExtractOptions): Promise<PDFExtractResult>;
16
- /**
17
- * Extract text from PDF file
18
- */
19
- extractFromFile(filePath: string, options?: PDFExtractOptions): Promise<PDFExtractResult>;
20
- /**
21
- * Extract text from PDF buffer
22
- */
23
- extractFromBuffer(buffer: Buffer, options?: PDFExtractOptions): Promise<PDFExtractResult>;
24
- /**
25
- * Clean extracted text
26
- */
27
- private cleanText;
28
- /**
29
- * Download PDF and save to file
30
- */
31
- downloadPdf(url: string, savePath: string): Promise<string>;
32
- }
33
- export default PDFExtractor;
1
+ export * from '../infrastructure/pdf/PDFExtractor.js';
2
+ export { default } from '../infrastructure/pdf/PDFExtractor.js';
34
3
  //# sourceMappingURL=PDFExtractor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PDFExtractor.d.ts","sourceRoot":"","sources":["../../src/utils/PDFExtractor.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,QAAQ,CAAC,EAAE,GAAG,CAAC;CAChB;AAED,qBAAa,YAAY;IACvB;;OAEG;IACG,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAyB7F;;OAEG;IACG,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAgBnG;;OAEG;IACG,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IA8BnG;;OAEG;IACH,OAAO,CAAC,SAAS;IAcjB;;OAEG;IACG,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAkClE;AAED,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"PDFExtractor.d.ts","sourceRoot":"","sources":["../../src/utils/PDFExtractor.ts"],"names":[],"mappings":"AAAA,cAAc,uCAAuC,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,uCAAuC,CAAC"}