import { type ServiceResult } from '../models/service-result.js'; import type { YearRange } from '../models/year-range.js'; import type { ISoqlQueryAdapter } from '../adapters/soql/soql-query-adapter.js'; /** * Per-object availability result for a single year. */ export type YearAvailability = { /** The year checked */ readonly year: number; /** Whether data exists in this year (records created in this calendar year) */ readonly hasData: boolean; }; /** * Per-object availability row in the grid. */ export type AvailabilityRow = { /** Salesforce object API name */ readonly objectApiName: string; /** Oldest record year (minimum CALENDAR_YEAR from GROUP BY results), or null if no records exist */ readonly oldestYear: number | null; /** Per-year data availability flags */ readonly years: readonly YearAvailability[]; }; /** * Complete availability grid result. */ export type AvailabilityGrid = { /** Column headers: the years checked (from YearRange entries) */ readonly yearColumns: readonly number[]; /** Per-object rows */ readonly rows: readonly AvailabilityRow[]; }; /** * Configuration for DataAvailabilityService. */ export type DataAvailabilityServiceConfig = { /** SOQL query adapter for executing probes */ readonly soqlAdapter: ISoqlQueryAdapter; /** Number of objects to process concurrently per batch (default: 5) */ readonly concurrencyLimit?: number; /** Optional logger */ readonly logger?: Console; }; /** * Service that builds a data availability grid for objects across a year range. * * Uses a single CALENDAR_YEAR(CreatedDate) GROUP BY query per object, which returns * all years with data in one round-trip. This replaces the previous approach of * Y+1 queries per object (one probe per year + one MIN(CreatedDate) for oldest). * * Objects are processed in batched parallel groups (default: 5 concurrent). * API call count: 1 per object (vs. N×(Y+1) in the sequential pre-fix approach). */ export declare class DataAvailabilityService { private readonly soqlAdapter; private readonly concurrencyLimit; private readonly logger?; constructor(config: DataAvailabilityServiceConfig); /** * Builds a data availability grid for the given objects and year range. * * @param objectNames - Salesforce object API names to check * @param yearRange - The year range to check (from resolveYearRange) * @returns Grid with per-object, per-year presence flags and oldest record year */ buildGrid(objectNames: string[], yearRange: YearRange): Promise>; /** * Builds a single row for one object using a single CALENDAR_YEAR GROUP BY query. * Derives both per-year presence flags and the oldest year from one round-trip. */ private buildRowForObject; /** * Issues a single CALENDAR_YEAR(CreatedDate) GROUP BY query for an object. * * Returns a year → hasData map and the oldest year (minimum year in results). * Returns empty map and null oldestYear when no records exist or query fails. * * Single query replaces Y+1 separate probes per object (CLI-1513 optimization). */ private queryYearAvailabilityByGroupBy; }