import type { ServiceResult } from '../models/service-result.js'; import type { IToolingApiAdapter } from '../adapters/tooling/tooling-api-adapter.js'; /** * Information about a Salesforce tab associated with an object. */ export type TabInfo = { /** Salesforce ID of the tab */ id: string; /** Name of the tab */ name: string; /** API name of the associated SObject */ sobjectName: string; /** Whether this is a custom tab */ isCustom: boolean; /** Display label for the tab */ label: string; }; /** * Configuration for TabDetectionService. */ export type ITabDetectionServiceConfig = { /** Tooling API adapter for querying tab definitions */ toolingAdapter: IToolingApiAdapter; /** Optional logger for debug output */ logger?: Console; }; /** * Service for detecting which Salesforce objects have tabs. * * Uses the Tooling API to query TabDefinition records and provides * methods for checking tab existence, retrieving tab information, * and filtering object lists by tab availability. * * @design * **API Choice**: Uses Tooling API (TabDefinition) rather than REST API * because tab metadata is not exposed through standard REST endpoints. * TabDefinition provides accurate tab-to-object mappings including custom tabs. * * @design * **Query Strategy**: Single-object lookups use `queryTabByObject()` for * efficiency (targeted query). Bulk operations use `getAllTabs()` and * filter in memory to minimize API calls. * * @example * ```typescript * const service = new TabDetectionService({ * toolingAdapter: myToolingAdapter, * logger: console, * }); * * // Check if an object has a tab * const result = await service.hasTab('Account'); * if (result.success && result.data) { * console.log('Account has a tab'); * } * * // Filter a list of objects to only those with tabs * const filtered = await service.filterObjectsWithTabs(['Account', 'Contact', 'Custom__c']); * ``` */ export declare class TabDetectionService { private readonly toolingAdapter; private readonly logger?; /** * Creates a new TabDetectionService. * * @param config - Service configuration with tooling adapter and optional logger */ constructor(config: ITabDetectionServiceConfig); /** * Retrieves all tab definitions from the org, mapped to TabInfo objects. * * Only includes tabs that have a non-null, non-empty SobjectName (object tabs). * * @returns ServiceResult containing an array of TabInfo objects */ getAllTabs(): Promise>; /** * Checks whether a specific object has a tab defined. * * Uses targeted query (queryTabByObject) for efficiency — only fetches * the specific object's tab rather than all tabs in the org. * * @param objectName - The API name of the object to check * @returns ServiceResult containing true if the object has a tab, false otherwise */ hasTab(objectName: string): Promise>; /** * Retrieves tab information for a specific object. * * Uses targeted query (queryTabByObject) for efficiency — only fetches * the specific object's tab rather than all tabs in the org. * * @param objectName - The API name of the object to look up * @returns ServiceResult containing the TabInfo if found, or null if no tab exists */ getTab(objectName: string): Promise>; /** * Filters a list of object names to only those that have tabs. * * @param objectNames - Array of object API names to check * @returns ServiceResult containing the subset of object names that have tabs */ filterObjectsWithTabs(objectNames: string[]): Promise>; }