import { r as EventSubscriber } from "./event-subscriber-base-DpZclJM4.cjs"; import { t as MockEventSubscriber } from "./mock-event-subscriber-CfAyAiQn.cjs"; import * as http from "node:http"; //#region src/testing/subscriber-test-harness.d.ts interface TestResult { name: string; passed: boolean; duration: number; error?: Error; details?: string; } interface TestSuiteResult { passed: boolean; total: number; passed_count: number; failed_count: number; duration: number; results: TestResult[]; failures: TestResult[]; } /** * Test harness for validating custom subscribers. * * Runs a comprehensive suite of tests to ensure your subscriber: * 1. Implements all required methods * 2. Handles concurrent requests * 3. Deals with errors gracefully * 4. Shuts down cleanly */ declare class SubscriberTestHarness { private subscriber; constructor(subscriber: EventSubscriber); /** * Run all tests and return a comprehensive report. */ runAll(): Promise; /** * Test basic event tracking. */ testBasicTracking(): Promise; /** * Test funnel step tracking. */ testFunnelTracking(): Promise; /** * Test outcome tracking. */ testOutcomeTracking(): Promise; /** * Test value tracking. */ testValueTracking(): Promise; /** * Test concurrent requests (sends 50 events simultaneously). */ testConcurrency(): Promise; /** * Test error handling (passes invalid data). */ testErrorHandling(): Promise; /** * Test graceful shutdown. */ testShutdown(): Promise; /** * Pretty-print test results to console. */ static printResults(results: TestSuiteResult): void; } //#endregion //#region src/testing/mock-webhook-server.d.ts interface RecordedRequest { method: string; path: string; headers: http.IncomingHttpHeaders; body: any; timestamp: number; } interface MockServerOptions { /** Port to listen on (0 = random port) */ port?: number; /** Response status code (default: 200) */ responseStatus?: number; /** Response delay in ms (default: 0) */ responseDelay?: number; /** Response body (default: 'OK') */ responseBody?: string; /** Log requests to console (default: false) */ logRequests?: boolean; } /** * In-memory HTTP server for testing webhook subscribers. * * Records all incoming requests so you can assert on them in tests. */ declare class MockWebhookServer { private server?; private requests; private options; constructor(options?: MockServerOptions); /** * Start the mock server and return its URL. * * @returns Promise resolving to the server URL (e.g., "http://localhost:3000") */ start(): Promise; /** * Stop the mock server. */ stop(): Promise; /** * Get all recorded requests. */ getRequests(): RecordedRequest[]; /** * Get requests matching a filter. */ getRequestsWhere(filter: Partial): RecordedRequest[]; /** * Get the last recorded request. */ getLastRequest(): RecordedRequest | undefined; /** * Get the first recorded request. */ getFirstRequest(): RecordedRequest | undefined; /** * Clear all recorded requests. */ reset(): void; /** * Get the number of recorded requests. */ getRequestCount(): number; /** * Wait for a specific number of requests. * * Useful when testing async subscribers. * * @example * ```typescript * await subscriber.trackEvent('event1', {}); * await subscriber.trackEvent('event2', {}); * await server.waitForRequests(2, 1000); // Wait max 1 second * ``` */ waitForRequests(count: number, timeoutMs?: number): Promise; /** * Parse request body based on Content-Type. */ private parseBody; } //#endregion export { MockEventSubscriber, type MockServerOptions, MockWebhookServer, type RecordedRequest, SubscriberTestHarness, type TestResult, type TestSuiteResult };