import type { ServiceResult } from '../models/service-result.js'; import type { ObjectFilteringService, FilterOptions, SObjectInfo } from './ObjectFilteringService.js'; import type { TabDetectionService, TabInfo } from './TabDetectionService.js'; import type { ContactPointService, ContactPointAnalysis } from './ContactPointService.js'; /** * Default pagination limit for object list results. */ export declare const DEFAULT_PAGINATION_LIMIT = 50; /** * Maximum pagination limit for object list results. */ export declare const MAX_PAGINATION_LIMIT = 200; /** * Sort direction for object list results. */ export type SortDirection = 'asc' | 'desc'; /** * Fields that can be used for sorting. */ export type SortField = 'name' | 'label' | 'recordCount'; /** * Sort configuration for object list results. */ export type SortOptions = { /** Field to sort by */ field: SortField; /** Sort direction */ direction: SortDirection; }; /** * Pagination options for object list queries. */ export type PaginationOptions = { /** Number of items per page (default: 50, max: 200) */ limit?: number; /** Zero-based offset for pagination */ offset?: number; }; /** * Options for enriching object list results with additional metadata. */ export type EnrichmentOptions = { /** Include tab information (requires TabDetectionService) */ includeTabs?: boolean; /** Include contact point analysis (requires ContactPointService) */ withContactPoints?: boolean; }; /** * Combined options for listing objects. */ export type ObjectListOptions = FilterOptions & PaginationOptions & EnrichmentOptions & { /** Sort configuration */ sort?: SortOptions; }; /** * Enriched object information with optional metadata. */ export type EnrichedObjectInfo = SObjectInfo & { /** Tab information if includeTabs is true */ tabInfo?: TabInfo | null; /** Contact point analysis if withContactPoints is true */ contactPointAnalysis?: ContactPointAnalysis | null; /** Whether enrichment failed for this object */ enrichmentFailed?: boolean; }; /** * Result of object list operation. */ export type ObjectListResult = { /** Array of enriched object info */ objects: EnrichedObjectInfo[]; /** Total count before pagination */ totalCount: number; /** Number of items returned */ returnedCount: number; /** Current offset */ offset: number; /** Current limit */ limit: number; /** Whether there are more results after this page */ hasMore: boolean; }; /** * Configuration for ObjectListService. */ export type IObjectListServiceConfig = { /** Object filtering service for core filtering operations */ objectFilteringService: ObjectFilteringService; /** Optional tab detection service for tab enrichment */ tabDetectionService?: TabDetectionService; /** Optional contact point service for contact point enrichment */ contactPointService?: ContactPointService; /** Optional logger for debug output */ logger?: Console; }; /** * Service for listing Salesforce objects with filtering, pagination, and enrichment. * * Composes ObjectFilteringService for core filtering and optionally enriches * results with tab detection and contact point analysis. Handles pagination * and sorting of results. * * @design * This service follows the Composition over Reimplementation pattern. Instead of * reimplementing filter logic, it delegates to ObjectFilteringService and focuses * on pagination, sorting, and enrichment orchestration. * * @example * ```typescript * const service = new ObjectListService({ * objectFilteringService, * tabDetectionService, * contactPointService, * logger: console, * }); * * // List custom objects with tabs * const result = await service.listObjects({ * type: 'custom', * limit: 25, * offset: 0, * includeTabs: true, * sort: { field: 'name', direction: 'asc' }, * }); * * if (result.success) { * console.log(`Found ${result.data.totalCount} objects, showing ${result.data.returnedCount}`); * for (const obj of result.data.objects) { * console.log(`${obj.name}: hasTab=${obj.tabInfo !== null}`); * } * } * ``` */ export declare class ObjectListService { private readonly objectFilteringService; private readonly tabDetectionService?; private readonly contactPointService?; private readonly logger?; constructor(config: IObjectListServiceConfig); /** * Validates pagination options. * * @param options - Pagination options to validate * @returns Error message if invalid, undefined if valid */ private static validatePagination; /** * Validates sort options. * * @param sort - Sort options to validate * @returns Error message if invalid, undefined if valid */ private static validateSort; /** * Creates an empty ObjectListResult for error cases. */ private static createEmptyResult; /** * Sorts objects by the specified field and direction. */ private static sortObjects; /** * Lists Salesforce objects with filtering, pagination, sorting, and enrichment. * * Execution order: * 1. Validate inputs * 2. Filter objects (via ObjectFilteringService) * 3. Sort results (if sort specified) * 4. Paginate (slice) * 5. Enrich (parallel with catch-per-promise) * * @param options - Combined filter, pagination, sort, and enrichment options * @returns ServiceResult containing ObjectListResult */ listObjects(options?: ObjectListOptions): Promise>; /** * Gets the count of objects matching the filter criteria. * * More efficient than listObjects when only the count is needed, * as it skips pagination and enrichment. * * @param options - Filter options (pagination and enrichment ignored) * @returns ServiceResult containing the count */ getObjectCount(options?: FilterOptions): Promise>; /** * Enriches a list of objects with tab and contact point information. * * Uses parallel execution with per-promise catch to ensure one failure * doesn't prevent other enrichments from completing. * * @design enrichmentFailed is set only when a service is injected AND fails. * If a service is not injected, that enrichment is skipped without setting * enrichmentFailed (allowing graceful degradation). * * @param objects - Objects to enrich * @param options - Enrichment options * @returns Array of enriched objects */ private enrichObjects; }