UNPKG

@nodesecure/tarball

Version:
56 lines 1.97 kB
import { EventEmitter } from "node:events"; import type { AstAnalyserOptions, Type } from "@nodesecure/js-x-ray"; import { type WorkerHandle, type PooledWorkerEvents } from "./PooledWorker.class.ts"; import type { ScanResultPayload } from "../types.ts"; export type WorkerFactory = (events: PooledWorkerEvents) => WorkerHandle; export interface NpmTarballWorkerPoolOptions { /** * Number of workers in the pool * @default 4 */ workerCount?: number; /** * Factory used to create each worker in the pool. * Defaults to creating a real PooledWorker backed by a worker thread. * Override in tests to inject a mock without patching modules. */ workerFactory?: WorkerFactory; } export interface WorkerTask { /** * Location of the package to scan (e.g. tarball path or directory path). */ location: string; /** * Options for the AST analyser. * `collectables` is not supported and should not be provided, * as collectable sets are managed separately via the `collectableTypes` option. */ astAnalyserOptions?: Omit<AstAnalyserOptions, "collectables">; /** * Collectable types to gather during scanning (e.g. "url", "hostname"). * Results are serialized and returned in ScanResultPayload.collectables. */ collectableTypes?: Type[]; } export interface WorkerTaskWithId extends WorkerTask { id: string; } type WorkerTaskResultOk = { id: string; result: ScanResultPayload; }; type WorkerTaskResultErr = { id: string; error: string; }; export type WorkerTaskResult = WorkerTaskResultOk | WorkerTaskResultErr; export declare class NpmTarballWorkerPool extends EventEmitter { #private; constructor(options?: NpmTarballWorkerPoolOptions); scan(task: WorkerTask): Promise<ScanResultPayload>; terminate(): Promise<void>; [Symbol.asyncDispose](): Promise<void>; } export {}; //# sourceMappingURL=NpmTarballWorkerPool.class.d.ts.map