File tree Expand file tree Collapse file tree 5 files changed +23
-15
lines changed
Expand file tree Collapse file tree 5 files changed +23
-15
lines changed Original file line number Diff line number Diff line change 44 * Types for URL metadata scraping.
55 */
66
7+ /**
8+ * Minimal response interface that both standard Response and Bun's Response satisfy.
9+ * Avoids Bun's BunResponseOverride type conflicts.
10+ */
11+ interface FetchResponse {
12+ readonly ok : boolean
13+ readonly status : number
14+ readonly headers : { get ( name : string ) : string | null }
15+ text ( ) : Promise < string >
16+ json ( ) : Promise < unknown >
17+ arrayBuffer ( ) : Promise < ArrayBuffer >
18+ }
19+
720/**
821 * Fetch function type for dependency injection.
22+ * Uses explicit interface to avoid Bun type conflicts.
923 */
10- export type FetchFn = typeof fetch
24+ export type FetchFn = ( url : string , init ?: RequestInit ) => Promise < FetchResponse >
1125
1226/**
1327 * Configuration for the scraper.
Original file line number Diff line number Diff line change 77
88import { generateCacheKey } from '../caching/key'
99import type { ResponseCache } from '../caching/types'
10- import { type HttpResponse , httpFetch } from '../http'
10+ import { httpFetch } from '../http'
11+ import type { FetchFn } from '../scraper/types'
1112import type { OpenLibraryResult } from './types'
1213import { DEFAULT_TIMEOUT , DEFAULT_USER_AGENT } from './types'
1314
1415const SEARCH_API = 'https://openlibrary.org/search.json'
1516
16- /**
17- * Fetch function type - returns HttpResponse which standard Response satisfies.
18- */
19- type FetchFn = ( url : string , init ?: RequestInit ) => Promise < HttpResponse >
20-
2117/**
2218 * Configuration for Open Library search.
2319 */
Original file line number Diff line number Diff line change 66 */
77
88import type { ResponseCache } from '../caching/types'
9+ import type { FetchFn } from '../scraper/types'
910
1011/**
1112 * Entity type categories for resolution.
@@ -182,7 +183,7 @@ export interface ResolverConfig {
182183 /** Request timeout in milliseconds (default: 30000) */
183184 timeout ?: number | undefined
184185 /** Custom fetch function (for testing) */
185- customFetch ?: ( ( url : string , init ?: RequestInit ) => Promise < Response > ) | undefined
186+ customFetch ?: FetchFn | undefined
186187}
187188
188189/**
Original file line number Diff line number Diff line change 77
88import { generateCacheKey } from '../caching/key'
99import type { ResponseCache } from '../caching/types'
10- import { type HttpResponse , httpFetch } from '../http'
10+ import { httpFetch } from '../http'
11+ import type { FetchFn } from '../scraper/types'
1112import type { EntityType , ExternalIdType , WikidataResult } from './types'
1213import {
1314 DEFAULT_TIMEOUT ,
@@ -19,11 +20,6 @@ import {
1920
2021const SPARQL_ENDPOINT = 'https://query.wikidata.org/sparql'
2122
22- /**
23- * Fetch function type - returns HttpResponse which standard Response satisfies.
24- */
25- type FetchFn = ( url : string , init ?: RequestInit ) => Promise < HttpResponse >
26-
2723/**
2824 * Configuration for Wikidata search.
2925 */
Original file line number Diff line number Diff line change 44 * Types for looking up places and getting coordinates.
55 */
66
7+ import type { FetchFn } from '../scraper/types'
78import type { ClassifiedActivity } from './classifier'
89
910export type PlaceLookupSource = 'google_maps_url' | 'places_api' | 'geocoding_api'
@@ -50,7 +51,7 @@ export interface PlaceLookupConfig {
5051 readonly regionBias ?: string | undefined
5152 readonly defaultCountry ?: string | undefined
5253 /** Custom fetch function for testing */
53- readonly fetch ?: typeof fetch | undefined
54+ readonly fetch ?: FetchFn | undefined
5455}
5556
5657export interface PlaceLookupResult {
You can’t perform that action at this time.
0 commit comments