UNPKG

@fluentity/core

Version:

Fluentity is a fluent, model-oriented, typed HTTP client for TypeScript and framework agnostic.

55 lines (54 loc) 1.9 kB
import { AdapterOptions, AdapterResponse, QueryBuilder } from '../Fluentity'; /** * Default adapter implementation that provides a no-op behavior. * Used as a fallback when no specific adapter is configured. * Returns undefined data for all requests, making it useful for testing or mock scenarios. * * @class * @implements {AdapterInterface} * @example * ```typescript * // Use as default adapter * Fluentity.initialize({ * adapter: new DefaultAdapter() * }); * * // Use for testing * const mockAdapter = new DefaultAdapter(); * const response = await mockAdapter.call(queryBuilder); * console.log(response.data); // undefined * ``` */ export declare class DefaultAdapter<A extends AdapterOptions = AdapterOptions> { /** * Default options for the adapter. * Empty object since this adapter doesn't require configuration. */ options: A; /** * Makes a mock API request that always returns undefined data. * This method is useful for testing or when you need a no-op adapter. * * @param _queryBuilder - The query builder (unused in this implementation) * @returns Promise resolving to a response with undefined data * @example * ```typescript * const adapter = new DefaultAdapter(); * const response = await adapter.call(new QueryBuilder()); * console.log(response.data); // undefined * ``` */ call(_queryBuilder: QueryBuilder): Promise<AdapterResponse>; /** * Configures the adapter with new options. * No-op implementation since this adapter doesn't use configuration. * * @param _options - Configuration options (unused in this implementation) * @example * ```typescript * const adapter = new DefaultAdapter(); * adapter.configure({ baseURL: 'https://example.com' }); // No effect * ``` */ configure(_options: Partial<A>): void; }