/** * Record of a mock adapter method call. */ export type CallRecord = { /** Name of the method that was called */ method: string; /** Arguments passed to the method */ args: unknown[]; /** Timestamp when the call was made */ timestamp: number; }; /** * Configuration for mock adapters. * * @template T The type of the default response */ export type MockAdapterConfig = { /** Map of input keys to expected responses */ responses?: Map; /** Map of input keys to errors that should be thrown */ errors?: Map; /** Default response when no specific mapping exists */ defaultResponse?: T; }; /** * Mock adapter wrapper with call recording and configuration. * * @template T The type of the adapter being mocked */ export type MockAdapter = { /** The mock adapter instance */ adapter: T; /** List of recorded method calls */ calls: CallRecord[]; /** Resets the call recording history */ resetCalls(): void; /** Sets a response for a specific key */ setResponse(key: string, response: unknown): void; /** Sets an error for a specific key (returns failure ServiceResult) */ setError(key: string, error: Error): void; /** * Sets an exception to throw for a specific key. * Unlike setError (which returns a failure ServiceResult), setThrow causes * the mock to throw an exception, allowing tests to verify service-level * exception handling. */ setThrow(key: string, error: Error): void; /** Clears a previously configured exception for a specific key */ clearThrow(key: string): void; }; /** * Configuration for mock connection facade. */ export type MockConnectionConfig = { /** API version to return */ version?: string; /** Access token for authentication (required for connection validation) */ accessToken?: string; /** Instance URL for the Salesforce org (required for connection validation) */ instanceUrl?: string; /** Default query result */ defaultQueryResult?: unknown; /** Default describe result */ defaultDescribeResult?: unknown; /** Default identity result */ defaultIdentity?: { user_id: string; organization_id: string; username: string; }; };