import { b as SourceSpec, d as IngestPort, f as LastRun, h as RunPort, n as CollectedRecord, o as CollectorMapping, p as Logger, q as FinalizeOptions, u as EventPort, x as UpsertedSource } from "./types-B500HM6G.js";
//#region src/testing/in-memory-ingest.d.ts
/** A source's own mapping as the in-memory port keeps it: the definition only. */
type RecordedMapping = Pick<CollectorMapping, 'engine' | 'expression'>;
/** Where a mapping is written, as the in-memory port keeps it: one per record type, target and endpoint. */
interface RecordedDestination {
  recordType: string;
  target: string;
  endpoint: string;
  enabled: boolean;
}
/** A run the in-memory port recorded. */
interface RecordedRun {
  id: string;
  sourceId: string;
  types: string[];
  records: (CollectedRecord & {
    observedAt: string;
  })[];
  status: 'open' | 'completed' | 'aborted';
  finalizeOptions?: FinalizeOptions;
  /** Record count at each flush, to see where the listing paused. */
  flushes: number[];
  /** When it was opened (ISO 8601), as the API dates a run. */
  createdAt: string;
}
/** An event the in-memory port recorded. */
interface RecordedEvent {
  sourceId: string;
  op: 'upsert' | 'delete';
  record: CollectedRecord & {
    observedAt: string;
  };
}
interface InMemoryIngestOptions {
  /**
   * The record types its sources apply, as an organization's destinations
   * would bind them. Default: every type asked about. The types of the
   * mappings a source upserted apply always.
   */
  applied?: string[];
  /** Told what the port does, at `info` (a local run's log). Default: silent. */
  log?: Logger;
}
/**
 * An `IngestPort` that records everything and never networks: what a test or
 * a local run feeds. Sources, mappings, destinations, runs and events are
 * kept in public fields to assert on.
 * @example
 * const ingest = new InMemoryIngest();
 * await runSnapshot(collector, ingest, { source: { slug: 'test' }, log: console });
 * ingest.runs[0].records; // what the snapshot sent
 */
declare class InMemoryIngest implements IngestPort {
  #private;
  /** By slug, each with the id this port assigned it (a UUIDv7, standing in for the API's). */
  readonly sources: Map<string, SourceSpec & UpsertedSource>;
  /** By source id, then record type: each mapping's definition. */
  readonly mappings: Map<string, Record<string, RecordedMapping>>;
  /** By source id, then record type, target and endpoint: where each mapping is written. */
  readonly destinations: Map<string, Record<string, RecordedDestination>>;
  readonly runs: RecordedRun[];
  readonly emitted: RecordedEvent[];
  constructor(options?: InMemoryIngestOptions);
  upsertSource(source: SourceSpec): Promise<UpsertedSource>;
  /**
   * Like the API's upserts: a mapping's definition is kept per record type; a
   * destination per record type, target and endpoint, so another endpoint is
   * another destination beside the first (a record type may go to several).
   */
  upsertMappings(sourceId: string, mappings: Record<string, CollectorMapping>): Promise<string[]>;
  appliedTypes(sourceId: string, types: string[]): Promise<string[]>;
  /** The source's newest run among `runs`, of any status: the latest opened (the last on a tie). */
  lastRun(sourceId: string): Promise<LastRun | null>;
  openRun(sourceId: string, types: string[]): Promise<RunPort>;
  events(sourceId: string): EventPort;
}
//#endregion
export { InMemoryIngest, type InMemoryIngestOptions, type RecordedDestination, type RecordedEvent, type RecordedMapping, type RecordedRun };
//# sourceMappingURL=testing.d.ts.map