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.
- package/README.md +11 -9
- package/README.zh.md +11 -9
- package/dist/capabilities/body-snippet-search/handler.d.ts +9 -0
- package/dist/capabilities/body-snippet-search/handler.d.ts.map +1 -0
- package/dist/capabilities/body-snippet-search/handler.js +17 -0
- package/dist/capabilities/body-snippet-search/handler.js.map +1 -0
- package/dist/capabilities/body-snippet-search/index.d.ts +7 -0
- package/dist/capabilities/body-snippet-search/index.d.ts.map +1 -0
- package/dist/capabilities/body-snippet-search/index.js +6 -0
- package/dist/capabilities/body-snippet-search/index.js.map +1 -0
- package/dist/capabilities/body-snippet-search/schemas.d.ts +36 -0
- package/dist/capabilities/body-snippet-search/schemas.d.ts.map +1 -0
- package/dist/capabilities/body-snippet-search/schemas.js +16 -0
- package/dist/capabilities/body-snippet-search/schemas.js.map +1 -0
- package/dist/capabilities/body-snippet-search/service.d.ts +4 -0
- package/dist/capabilities/body-snippet-search/service.d.ts.map +1 -0
- package/dist/capabilities/body-snippet-search/service.js +4 -0
- package/dist/capabilities/body-snippet-search/service.js.map +1 -0
- package/dist/capabilities/body-snippet-search/tools.d.ts +187 -0
- package/dist/capabilities/body-snippet-search/tools.d.ts.map +1 -0
- package/dist/capabilities/body-snippet-search/tools.js +49 -0
- package/dist/capabilities/body-snippet-search/tools.js.map +1 -0
- package/dist/capabilities/body-snippet-search/types.d.ts +14 -0
- package/dist/capabilities/body-snippet-search/types.d.ts.map +1 -0
- package/dist/capabilities/body-snippet-search/types.js +2 -0
- package/dist/capabilities/body-snippet-search/types.js.map +1 -0
- package/dist/capabilities/citation-expansion/CitationService.d.ts +47 -0
- package/dist/capabilities/citation-expansion/CitationService.d.ts.map +1 -0
- package/dist/capabilities/citation-expansion/CitationService.js +243 -0
- package/dist/capabilities/citation-expansion/CitationService.js.map +1 -0
- package/dist/capabilities/citation-expansion/handler.d.ts +36 -0
- package/dist/capabilities/citation-expansion/handler.d.ts.map +1 -0
- package/dist/capabilities/citation-expansion/handler.js +44 -0
- package/dist/capabilities/citation-expansion/handler.js.map +1 -0
- package/dist/capabilities/citation-expansion/index.d.ts +6 -0
- package/dist/capabilities/citation-expansion/index.d.ts.map +1 -0
- package/dist/capabilities/citation-expansion/index.js +5 -0
- package/dist/capabilities/citation-expansion/index.js.map +1 -0
- package/dist/capabilities/citation-expansion/schemas.d.ts +28 -0
- package/dist/capabilities/citation-expansion/schemas.d.ts.map +1 -0
- package/dist/capabilities/citation-expansion/schemas.js +13 -0
- package/dist/capabilities/citation-expansion/schemas.js.map +1 -0
- package/dist/capabilities/citation-expansion/tools.d.ts +82 -0
- package/dist/capabilities/citation-expansion/tools.d.ts.map +1 -0
- package/dist/capabilities/citation-expansion/tools.js +48 -0
- package/dist/capabilities/citation-expansion/tools.js.map +1 -0
- package/dist/capabilities/citation-expansion/types.d.ts +22 -0
- package/dist/capabilities/citation-expansion/types.d.ts.map +1 -0
- package/dist/capabilities/citation-expansion/types.js +2 -0
- package/dist/capabilities/citation-expansion/types.js.map +1 -0
- package/dist/capabilities/journal-metrics/JournalMetricsService.d.ts +3 -0
- package/dist/capabilities/journal-metrics/JournalMetricsService.d.ts.map +1 -0
- package/dist/capabilities/journal-metrics/JournalMetricsService.js +142 -0
- package/dist/capabilities/journal-metrics/JournalMetricsService.js.map +1 -0
- package/dist/capabilities/journal-metrics/handler.d.ts +12 -0
- package/dist/capabilities/journal-metrics/handler.d.ts.map +1 -0
- package/dist/capabilities/journal-metrics/handler.js +38 -0
- package/dist/capabilities/journal-metrics/handler.js.map +1 -0
- package/dist/capabilities/journal-metrics/index.d.ts +6 -0
- package/dist/capabilities/journal-metrics/index.d.ts.map +1 -0
- package/dist/capabilities/journal-metrics/index.js +5 -0
- package/dist/capabilities/journal-metrics/index.js.map +1 -0
- package/dist/capabilities/journal-metrics/schemas.d.ts +28 -0
- package/dist/capabilities/journal-metrics/schemas.d.ts.map +1 -0
- package/dist/capabilities/journal-metrics/schemas.js +13 -0
- package/dist/capabilities/journal-metrics/schemas.js.map +1 -0
- package/dist/capabilities/journal-metrics/tools.d.ts +67 -0
- package/dist/capabilities/journal-metrics/tools.d.ts.map +1 -0
- package/dist/capabilities/journal-metrics/tools.js +27 -0
- package/dist/capabilities/journal-metrics/tools.js.map +1 -0
- package/dist/capabilities/journal-metrics/types.d.ts +36 -0
- package/dist/capabilities/journal-metrics/types.d.ts.map +1 -0
- package/dist/capabilities/journal-metrics/types.js +2 -0
- package/dist/capabilities/journal-metrics/types.js.map +1 -0
- package/dist/capabilities/metadata-search/MultiSourceSearchService.d.ts +9 -0
- package/dist/capabilities/metadata-search/MultiSourceSearchService.d.ts.map +1 -0
- package/dist/capabilities/metadata-search/MultiSourceSearchService.js +78 -0
- package/dist/capabilities/metadata-search/MultiSourceSearchService.js.map +1 -0
- package/dist/capabilities/metadata-search/handler.d.ts +23 -0
- package/dist/capabilities/metadata-search/handler.d.ts.map +1 -0
- package/dist/capabilities/metadata-search/handler.js +163 -0
- package/dist/capabilities/metadata-search/handler.js.map +1 -0
- package/dist/capabilities/metadata-search/index.d.ts +6 -0
- package/dist/capabilities/metadata-search/index.d.ts.map +1 -0
- package/dist/capabilities/metadata-search/index.js +5 -0
- package/dist/capabilities/metadata-search/index.js.map +1 -0
- package/dist/capabilities/metadata-search/schemas.d.ts +83 -0
- package/dist/capabilities/metadata-search/schemas.d.ts.map +1 -0
- package/dist/capabilities/metadata-search/schemas.js +81 -0
- package/dist/capabilities/metadata-search/schemas.js.map +1 -0
- package/dist/capabilities/metadata-search/tools.d.ts +178 -0
- package/dist/capabilities/metadata-search/tools.d.ts.map +1 -0
- package/dist/capabilities/metadata-search/tools.js +75 -0
- package/dist/capabilities/metadata-search/tools.js.map +1 -0
- package/dist/capabilities/metadata-search/types.d.ts +13 -0
- package/dist/capabilities/metadata-search/types.d.ts.map +1 -0
- package/dist/capabilities/metadata-search/types.js +2 -0
- package/dist/capabilities/metadata-search/types.js.map +1 -0
- package/dist/capabilities/pdf-discovery/DownloadTier.d.ts +22 -0
- package/dist/capabilities/pdf-discovery/DownloadTier.d.ts.map +1 -0
- package/dist/capabilities/pdf-discovery/DownloadTier.js +2 -0
- package/dist/capabilities/pdf-discovery/DownloadTier.js.map +1 -0
- package/dist/capabilities/pdf-discovery/OpenAccessFallbackService.d.ts +10 -0
- package/dist/capabilities/pdf-discovery/OpenAccessFallbackService.d.ts.map +1 -0
- package/dist/capabilities/pdf-discovery/OpenAccessFallbackService.js +53 -0
- package/dist/capabilities/pdf-discovery/OpenAccessFallbackService.js.map +1 -0
- package/dist/capabilities/pdf-discovery/handler.d.ts +19 -0
- package/dist/capabilities/pdf-discovery/handler.d.ts.map +1 -0
- package/dist/capabilities/pdf-discovery/handler.js +56 -0
- package/dist/capabilities/pdf-discovery/handler.js.map +1 -0
- package/dist/capabilities/pdf-discovery/index.d.ts +7 -0
- package/dist/capabilities/pdf-discovery/index.d.ts.map +1 -0
- package/dist/capabilities/pdf-discovery/index.js +5 -0
- package/dist/capabilities/pdf-discovery/index.js.map +1 -0
- package/dist/capabilities/pdf-discovery/schemas.d.ts +37 -0
- package/dist/capabilities/pdf-discovery/schemas.d.ts.map +1 -0
- package/dist/capabilities/pdf-discovery/schemas.js +22 -0
- package/dist/capabilities/pdf-discovery/schemas.js.map +1 -0
- package/dist/capabilities/pdf-discovery/tiers/directPdfUrl.d.ts +3 -0
- package/dist/capabilities/pdf-discovery/tiers/directPdfUrl.d.ts.map +1 -0
- package/dist/capabilities/pdf-discovery/tiers/directPdfUrl.js +27 -0
- package/dist/capabilities/pdf-discovery/tiers/directPdfUrl.js.map +1 -0
- package/dist/capabilities/pdf-discovery/tiers/primary.d.ts +3 -0
- package/dist/capabilities/pdf-discovery/tiers/primary.d.ts.map +1 -0
- package/dist/capabilities/pdf-discovery/tiers/primary.js +21 -0
- package/dist/capabilities/pdf-discovery/tiers/primary.js.map +1 -0
- package/dist/capabilities/pdf-discovery/tiers/repositories.d.ts +3 -0
- package/dist/capabilities/pdf-discovery/tiers/repositories.d.ts.map +1 -0
- package/dist/capabilities/pdf-discovery/tiers/repositories.js +35 -0
- package/dist/capabilities/pdf-discovery/tiers/repositories.js.map +1 -0
- package/dist/capabilities/pdf-discovery/tiers/scihub.d.ts +3 -0
- package/dist/capabilities/pdf-discovery/tiers/scihub.d.ts.map +1 -0
- package/dist/capabilities/pdf-discovery/tiers/scihub.js +21 -0
- package/dist/capabilities/pdf-discovery/tiers/scihub.js.map +1 -0
- package/dist/capabilities/pdf-discovery/tiers/unpaywall.d.ts +3 -0
- package/dist/capabilities/pdf-discovery/tiers/unpaywall.d.ts.map +1 -0
- package/dist/capabilities/pdf-discovery/tiers/unpaywall.js +29 -0
- package/dist/capabilities/pdf-discovery/tiers/unpaywall.js.map +1 -0
- package/dist/capabilities/pdf-discovery/tools.d.ts +114 -0
- package/dist/capabilities/pdf-discovery/tools.d.ts.map +1 -0
- package/dist/capabilities/pdf-discovery/tools.js +42 -0
- package/dist/capabilities/pdf-discovery/tools.js.map +1 -0
- package/dist/capabilities/pdf-discovery/types.d.ts +19 -0
- package/dist/capabilities/pdf-discovery/types.d.ts.map +1 -0
- package/dist/capabilities/pdf-discovery/types.js +2 -0
- package/dist/capabilities/pdf-discovery/types.js.map +1 -0
- package/dist/cli.js +10 -6
- package/dist/cli.js.map +1 -1
- package/dist/core/capabilityProfile.d.ts +1 -17
- package/dist/core/capabilityProfile.d.ts.map +1 -1
- package/dist/core/capabilityProfile.js +1 -152
- package/dist/core/capabilityProfile.js.map +1 -1
- package/dist/core/diagnostics.d.ts +1 -42
- package/dist/core/diagnostics.d.ts.map +1 -1
- package/dist/core/diagnostics.js +1 -585
- package/dist/core/diagnostics.js.map +1 -1
- package/dist/core/handleToolCall.d.ts +1 -0
- package/dist/core/handleToolCall.d.ts.map +1 -1
- package/dist/core/handleToolCall.js +265 -476
- package/dist/core/handleToolCall.js.map +1 -1
- package/dist/core/httpPolicies.d.ts +2 -0
- package/dist/core/httpPolicies.d.ts.map +1 -0
- package/dist/core/httpPolicies.js +2 -0
- package/dist/core/httpPolicies.js.map +1 -0
- package/dist/core/liveSmoke.d.ts +1 -41
- package/dist/core/liveSmoke.d.ts.map +1 -1
- package/dist/core/liveSmoke.js +1 -225
- package/dist/core/liveSmoke.js.map +1 -1
- package/dist/core/platformFactories.d.ts +2 -0
- package/dist/core/platformFactories.d.ts.map +1 -0
- package/dist/core/platformFactories.js +2 -0
- package/dist/core/platformFactories.js.map +1 -0
- package/dist/core/platformMetadata.d.ts +1 -27
- package/dist/core/platformMetadata.d.ts.map +1 -1
- package/dist/core/platformMetadata.js +1 -257
- package/dist/core/platformMetadata.js.map +1 -1
- package/dist/core/schemas.d.ts +11 -177
- package/dist/core/schemas.d.ts.map +1 -1
- package/dist/core/schemas.js +14 -107
- package/dist/core/schemas.js.map +1 -1
- package/dist/core/searchers.d.ts +24 -24
- package/dist/core/searchers.d.ts.map +1 -1
- package/dist/core/searchers.js +14 -79
- package/dist/core/searchers.js.map +1 -1
- package/dist/core/textReports.d.ts +1 -20
- package/dist/core/textReports.d.ts.map +1 -1
- package/dist/core/textReports.js +1 -84
- package/dist/core/textReports.js.map +1 -1
- package/dist/core/tools.d.ts.map +1 -1
- package/dist/core/tools.js +15 -183
- package/dist/core/tools.js.map +1 -1
- package/dist/infrastructure/cache/RequestCache.d.ts +26 -0
- package/dist/infrastructure/cache/RequestCache.d.ts.map +1 -0
- package/dist/infrastructure/cache/RequestCache.js +66 -0
- package/dist/infrastructure/cache/RequestCache.js.map +1 -0
- package/dist/infrastructure/http/ErrorHandler.d.ts +99 -0
- package/dist/infrastructure/http/ErrorHandler.d.ts.map +1 -0
- package/dist/infrastructure/http/ErrorHandler.js +266 -0
- package/dist/infrastructure/http/ErrorHandler.js.map +1 -0
- package/dist/infrastructure/http/HttpClient.d.ts +31 -0
- package/dist/infrastructure/http/HttpClient.d.ts.map +1 -0
- package/dist/infrastructure/http/HttpClient.js +50 -0
- package/dist/infrastructure/http/HttpClient.js.map +1 -0
- package/dist/infrastructure/pdf/PDFExtractor.d.ts +34 -0
- package/dist/infrastructure/pdf/PDFExtractor.d.ts.map +1 -0
- package/dist/infrastructure/pdf/PDFExtractor.js +130 -0
- package/dist/infrastructure/pdf/PDFExtractor.js.map +1 -0
- package/dist/infrastructure/pdf/PdfDownload.d.ts +7 -0
- package/dist/infrastructure/pdf/PdfDownload.d.ts.map +1 -0
- package/dist/infrastructure/pdf/PdfDownload.js +175 -0
- package/dist/infrastructure/pdf/PdfDownload.js.map +1 -0
- package/dist/infrastructure/rate-limit/RateLimiter.d.ts +50 -0
- package/dist/infrastructure/rate-limit/RateLimiter.d.ts.map +1 -0
- package/dist/infrastructure/rate-limit/RateLimiter.js +128 -0
- package/dist/infrastructure/rate-limit/RateLimiter.js.map +1 -0
- package/dist/infrastructure/security/SecurityUtils.d.ts +80 -0
- package/dist/infrastructure/security/SecurityUtils.d.ts.map +1 -0
- package/dist/infrastructure/security/SecurityUtils.js +357 -0
- package/dist/infrastructure/security/SecurityUtils.js.map +1 -0
- package/dist/management/capability-profile/index.d.ts +18 -0
- package/dist/management/capability-profile/index.d.ts.map +1 -0
- package/dist/management/capability-profile/index.js +167 -0
- package/dist/management/capability-profile/index.js.map +1 -0
- package/dist/management/config/index.d.ts +2 -0
- package/dist/management/config/index.d.ts.map +1 -0
- package/dist/management/config/index.js +2 -0
- package/dist/management/config/index.js.map +1 -0
- package/dist/management/diagnostics/index.d.ts +43 -0
- package/dist/management/diagnostics/index.d.ts.map +1 -0
- package/dist/management/diagnostics/index.js +586 -0
- package/dist/management/diagnostics/index.js.map +1 -0
- package/dist/management/reports/index.d.ts +21 -0
- package/dist/management/reports/index.d.ts.map +1 -0
- package/dist/management/reports/index.js +85 -0
- package/dist/management/reports/index.js.map +1 -0
- package/dist/management/skills/index.d.ts +2 -0
- package/dist/management/skills/index.d.ts.map +1 -0
- package/dist/management/skills/index.js +2 -0
- package/dist/management/skills/index.js.map +1 -0
- package/dist/management/smoke/index.d.ts +42 -0
- package/dist/management/smoke/index.d.ts.map +1 -0
- package/dist/management/smoke/index.js +226 -0
- package/dist/management/smoke/index.js.map +1 -0
- package/dist/platforms/BioRxivSearcher.d.ts.map +1 -1
- package/dist/platforms/BioRxivSearcher.js +40 -21
- package/dist/platforms/BioRxivSearcher.js.map +1 -1
- package/dist/platforms/GoogleScholarSearcher.d.ts.map +1 -1
- package/dist/platforms/GoogleScholarSearcher.js +3 -2
- package/dist/platforms/GoogleScholarSearcher.js.map +1 -1
- package/dist/registry/aliases.d.ts +2 -0
- package/dist/registry/aliases.d.ts.map +1 -0
- package/dist/registry/aliases.js +2 -0
- package/dist/registry/aliases.js.map +1 -0
- package/dist/registry/httpPolicies.d.ts +3 -0
- package/dist/registry/httpPolicies.d.ts.map +1 -0
- package/dist/registry/httpPolicies.js +17 -0
- package/dist/registry/httpPolicies.js.map +1 -0
- package/dist/registry/platformFactories.d.ts +8 -0
- package/dist/registry/platformFactories.d.ts.map +1 -0
- package/dist/registry/platformFactories.js +55 -0
- package/dist/registry/platformFactories.js.map +1 -0
- package/dist/registry/platformMetadata.d.ts +39 -0
- package/dist/registry/platformMetadata.d.ts.map +1 -0
- package/dist/registry/platformMetadata.js +321 -0
- package/dist/registry/platformMetadata.js.map +1 -0
- package/dist/services/CitationService.d.ts +2 -65
- package/dist/services/CitationService.d.ts.map +1 -1
- package/dist/services/CitationService.js +1 -236
- package/dist/services/CitationService.js.map +1 -1
- package/dist/services/JournalMetricsService.d.ts +2 -37
- package/dist/services/JournalMetricsService.d.ts.map +1 -1
- package/dist/services/JournalMetricsService.js +1 -141
- package/dist/services/JournalMetricsService.js.map +1 -1
- package/dist/services/MultiSourceSearchService.d.ts +2 -18
- package/dist/services/MultiSourceSearchService.d.ts.map +1 -1
- package/dist/services/MultiSourceSearchService.js +1 -77
- package/dist/services/MultiSourceSearchService.js.map +1 -1
- package/dist/services/OpenAccessFallbackService.d.ts +3 -20
- package/dist/services/OpenAccessFallbackService.d.ts.map +1 -1
- package/dist/services/OpenAccessFallbackService.js +1 -123
- package/dist/services/OpenAccessFallbackService.js.map +1 -1
- package/dist/utils/ErrorHandler.d.ts +2 -98
- package/dist/utils/ErrorHandler.d.ts.map +1 -1
- package/dist/utils/ErrorHandler.js +2 -265
- package/dist/utils/ErrorHandler.js.map +1 -1
- package/dist/utils/HttpClient.d.ts +1 -5
- package/dist/utils/HttpClient.d.ts.map +1 -1
- package/dist/utils/HttpClient.js +1 -29
- package/dist/utils/HttpClient.js.map +1 -1
- package/dist/utils/PDFExtractor.d.ts +2 -33
- package/dist/utils/PDFExtractor.d.ts.map +1 -1
- package/dist/utils/PDFExtractor.js +2 -129
- package/dist/utils/PDFExtractor.js.map +1 -1
- package/dist/utils/PdfDownload.d.ts +1 -6
- package/dist/utils/PdfDownload.d.ts.map +1 -1
- package/dist/utils/PdfDownload.js +1 -141
- package/dist/utils/PdfDownload.js.map +1 -1
- package/dist/utils/RateLimiter.d.ts +1 -49
- package/dist/utils/RateLimiter.d.ts.map +1 -1
- package/dist/utils/RateLimiter.js +1 -120
- package/dist/utils/RateLimiter.js.map +1 -1
- package/dist/utils/RequestCache.d.ts +2 -25
- package/dist/utils/RequestCache.d.ts.map +1 -1
- package/dist/utils/RequestCache.js +2 -65
- package/dist/utils/RequestCache.js.map +1 -1
- package/dist/utils/SecurityUtils.d.ts +2 -79
- package/dist/utils/SecurityUtils.d.ts.map +1 -1
- package/dist/utils/SecurityUtils.js +2 -356
- package/dist/utils/SecurityUtils.js.map +1 -1
- package/package.json +1 -1
- package/skills/paper-search/SKILL.md +4 -2
- package/skills/paper-search/references/capability-routing.md +15 -2
- package/skills/paper-search/references/cli-contract.md +19 -0
- package/skills/paper-search/references/management-layer.md +1 -0
|
@@ -1,124 +1,2 @@
|
|
|
1
|
-
|
|
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":[],"mappings":"
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
|
1
|
+
{"version":3,"file":"ErrorHandler.js","sourceRoot":"","sources":["../../src/utils/ErrorHandler.ts"],"names":[],"mappings":"AAAA,cAAc,wCAAwC,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,wCAAwC,CAAC"}
|
|
@@ -1,6 +1,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":"
|
|
1
|
+
{"version":3,"file":"HttpClient.d.ts","sourceRoot":"","sources":["../../src/utils/HttpClient.ts"],"names":[],"mappings":"AAAA,cAAc,sCAAsC,CAAC"}
|
package/dist/utils/HttpClient.js
CHANGED
|
@@ -1,30 +1,2 @@
|
|
|
1
|
-
|
|
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,
|
|
1
|
+
{"version":3,"file":"HttpClient.js","sourceRoot":"","sources":["../../src/utils/HttpClient.ts"],"names":[],"mappings":"AAAA,cAAc,sCAAsC,CAAC"}
|
|
@@ -1,34 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
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":"
|
|
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"}
|