import type { Pool } from 'pg'; import type { LookupFunction } from '../../../lib/ssrf/guardedLookup.js'; import type { StoredFile } from '../adapters/HttpImageFetcher.js'; import type { ImportConfig, ImportDeps } from '../services/deps.js'; import type { JobAdmin } from '../services/ports/jobAdmin.js'; import type { Logger } from '../services/ports/logger.js'; import type { EntityServices } from '../services/ports/services.js'; /** * What the worker needs from the rest of EverShop, as plain functions: the pool, * the real services, the storefront routes and languages, the file storage and * the settings. `corePorts.ts` makes them from core; a test passes its own, so * the wiring below is tested on a real database without booting the store. */ export interface CorePorts { pool: Pool; services: EntityServices; /** The storefront routes without the admin and API ones, as paths. */ routePaths(): readonly string[]; enabledLanguages(): Promise; /** Writes an image to the store's file storage (`uploadFile`). */ storeImage(file: StoredFile): Promise<{ url: string; }>; /** The addresses of the store's own file storage (IMG-06). */ ownStorage(): readonly string[]; allowedImageTypes(): readonly string[]; maxImageBytesForType(contentType: string): number; sanitizeFileName(name: string): string; logger: Logger; limits: Pick; /** When the import slows down for the event queue (§ 8.5). */ backlog: Pick; imageTimeoutMs: number; /** How many images are fetched at the same time (`imageConcurrency`). */ imageConcurrency: number; /** A test switch: private addresses are refused unless it is on (§ 4.5, point 9). */ allowPrivateNetworks(): boolean; retentionMs: number; /** A test passes a fake DNS. */ dnsLookup?: LookupFunction; } export interface Composed { deps: ImportDeps; admin: JobAdmin; /** Ends what the deps hold open (the image downloader). */ close(): Promise; } /** * The composition root of the worker (§ 4.5, point 7): builds the one * `ImportDeps` that the runner takes, from the real adapters. It is the only * place where the ports meet their implementations. */ export declare function composeWorker(core: CorePorts): Composed;