import type { IConnectionFacade, QueryResult } from '../connection-facade.js'; import type { ServiceResult } from '../../models/service-result.js'; import type { ToolingApiAdapterConfig, CustomField, ValidationRule, TabDefinition } from './types.js'; /** * Interface for Tooling API operations. * * Provides methods for querying Salesforce metadata via the Tooling API. */ export type IToolingApiAdapter = { /** * Executes a Tooling API SOQL query. * * @template T The type of records being queried * @param soql - The SOQL query string * @returns ServiceResult containing query results (first page only) */ query(soql: string): Promise>>; /** * Executes a Tooling API SOQL query and fetches all pages. * * @template T The type of records being queried * @param soql - The SOQL query string * @returns ServiceResult containing all records */ queryAll(soql: string): Promise>>; /** * Queries custom fields for a specific object. * * @param objectName - The API name of the object * @returns ServiceResult containing custom field metadata */ queryCustomFields(objectName: string): Promise>; /** * Queries validation rules for a specific object. * * @param objectName - The API name of the object * @returns ServiceResult containing validation rule metadata */ queryValidationRules(objectName: string): Promise>; /** * Queries all tab definitions. * * @returns ServiceResult containing tab definitions */ queryTabs(): Promise>; /** * Queries a tab definition for a specific object. * * More efficient than queryTabs() when checking a single object, * as it uses a WHERE clause to filter server-side. * * @param objectName - The API name of the object to check * @returns ServiceResult containing the TabDefinition or null if no tab exists */ queryTabByObject(objectName: string): Promise>; }; /** * Adapter for Tooling API operations against Salesforce. * * Provides methods for querying metadata such as custom fields, * validation rules, and tab definitions. * * @example * ```typescript * const adapter = new ToolingApiAdapter(connectionFacade); * * // Query custom fields * const fields = await adapter.queryCustomFields('Account'); * * // Query validation rules * const rules = await adapter.queryValidationRules('Contact'); * * // Query all tabs * const tabs = await adapter.queryTabs(); * * // Query tab for specific object (more efficient for single lookups) * const accountTab = await adapter.queryTabByObject('Account'); * * // Custom Tooling API query * const result = await adapter.query('SELECT Id, Name FROM ApexClass LIMIT 10'); * ``` */ export declare class ToolingApiAdapter implements IToolingApiAdapter { private readonly connection; private readonly logger?; private readonly lifecycle; private readonly retryConfig?; /** * Creates a new ToolingApiAdapter. * * @param connection - The connection facade to use for API calls * @param config - Optional configuration */ constructor(connection: IConnectionFacade, config?: ToolingApiAdapterConfig); /** * Executes a Tooling API SOQL query (first page only). * * @template T The type of records being queried * @param soql - The SOQL query string * @returns ServiceResult containing query results */ query(soql: string): Promise>>; /** * Executes a Tooling API SOQL query and fetches all pages. * * Use this method when you need all records from a query that may * return more than 2000 records. * * @template T The type of records being queried * @param soql - The SOQL query string * @returns ServiceResult containing all records */ queryAll(soql: string): Promise>>; /** * Queries custom fields for a specific object. * * @param objectName - The API name of the object * @returns ServiceResult containing custom field metadata */ queryCustomFields(objectName: string): Promise>; /** * Queries validation rules for a specific object. * * @param objectName - The API name of the object * @returns ServiceResult containing validation rule metadata */ queryValidationRules(objectName: string): Promise>; /** * Queries all tab definitions. * * @returns ServiceResult containing tab definitions */ queryTabs(): Promise>; /** * Queries a tab definition for a specific object. * * More efficient than queryTabs() for single-object lookups because it filters * server-side with a WHERE clause rather than fetching all tabs. * * @param objectName - The API name of the object to check * @returns ServiceResult containing the TabDefinition or null if no tab exists */ queryTabByObject(objectName: string): Promise>; /** * Handles errors and maps them to appropriate error codes. * * Accepts SfError, jsforce errors, or unknown error types. Extracts Salesforce * error codes when available and maps them to adapter-specific error codes. * * @param error - The caught error (SfError, jsforce error, or unknown) * @param startTime - The operation start time for duration calculation * @param emptyResult - The empty result to return on failure * @param context - Optional context for logging (e.g., "custom fields for Account") * @returns ServiceResult with success=false and mapped error code */ private handleError; }