import type { ServiceResult } from '../models/service-result.js'; import { OrgInfoService, type OrgLimit, type OrgType } from '../services/OrgInfoService.js'; /** * Cloud item in the org details result. */ export type CloudItem = { name: string; type: 'license' | 'package'; installed: boolean; totalLicenses?: number; usedLicenses?: number; namespace?: string; version?: string; status?: string; }; /** * Namespace detail item in the org details result. */ export type NamespaceDetailItem = { prefix: string; productName: string; objectCount: number; populatedCount: number; emptyCount: number; }; /** * Business process item in the org details result. */ export type ProcessItem = { name: string; objectName: string; isActive: boolean; description?: string; recordTypeCount: number; recordTypeNames: string[]; }; /** * A single limit item for grouped display. */ export type LimitItem = { name: string; label: string; max: number; used: number; percentUsed: number; }; /** * A group of related limits with a category label. */ export type LimitGroup = { key: string; label: string; limits: LimitItem[]; }; /** * Result returned by OrgDetailsOperation and the org details command. */ export type OrgDetailsResult = { /** Org identity information */ identity: { orgId: string; orgName: string; orgType: OrgType; edition: string; namespace: string | null; instanceUrl: string; username: string; }; /** Cuneiform for Salesforce installation status */ cuneiform: { installed: boolean; version: string | null; licenseStatus: string; }; /** Detected org features */ features: { multiCurrency: boolean; enhancedNotes: boolean; stateCountryPicklists: boolean; territoryManagement: boolean; personAccounts: boolean; digitalExperiences: boolean; einsteinAI: boolean; }; /** Detected Salesforce Clouds (includes uninstalled for JSON completeness) */ clouds: { count: number; details: CloudItem[]; }; /** Installed namespace summary */ namespaces: { count: number; details: NamespaceDetailItem[]; }; /** Business processes with record type associations */ processes: { count: number; details: ProcessItem[]; }; /** API limits (omitted if limits call failed) */ limits?: { dailyApiRequests?: { max: number; used: number; percentUsed: number; }; dataStorageMB?: { max: number; used: number; percentUsed: number; }; fileStorageMB?: { max: number; used: number; percentUsed: number; }; dailyBulkApiRequests?: { max: number; used: number; percentUsed: number; }; dailyBulkV2QueryJobs?: { max: number; used: number; percentUsed: number; }; dailyAsyncApexExecutions?: { max: number; used: number; percentUsed: number; }; dailyStreamingApiEvents?: { max: number; used: number; percentUsed: number; }; /** All limits grouped by category for `limits-all` / `limits-` display */ groups: LimitGroup[]; }; /** Non-fatal warnings collected during execution */ warnings?: string[]; /** R-11: Sections included in this result (self-describing for MCP consumers) */ sections: OrgDetailsSection[]; }; /** * Error codes for OrgDetailsOperation failures. */ export declare const OrgDetailsErrorCodes: { /** Failed to retrieve org identity — operation cannot continue */ readonly IDENTITY_FAILED: "ORG_DETAILS_IDENTITY_FAILED"; }; /** * Valid section names for selective retrieval. */ export type OrgDetailsSection = 'identity' | 'cuneiform' | 'features' | 'clouds' | 'namespaces' | 'processes' | 'limits'; /** * Configuration for OrgDetailsOperation. */ export type OrgDetailsOperationConfig = { /** Initialized OrgInfoService instance */ orgInfoService: OrgInfoService; /** Connection instance URL for the identity section */ instanceUrl: string; /** Optional list of sections to retrieve. When omitted, all sections are retrieved. */ sections?: string[]; }; /** * Orchestrates retrieval and assembly of org details. * * Calls describeGlobal() once and passes the cached result to the three * service methods that require it (features, clouds, namespaces), eliminating * redundant API calls and enforcing the 4-layer architecture boundary. * * @example * ```typescript * const operation = new OrgDetailsOperation({ orgInfoService, instanceUrl }); * const result = await operation.execute(); * if (result.success) { * console.log(result.data.identity.orgName); * } * ``` */ export declare class OrgDetailsOperation { /** * Limit group definitions mapping Salesforce limit names to display categories. * Limits not matching any group are placed in 'other'. */ private static readonly LIMIT_GROUP_DEFS; /** All valid section names in display order. */ private static readonly ALL_SECTIONS; private readonly orgInfoService; private readonly instanceUrl; private readonly sections; constructor(config: OrgDetailsOperationConfig); /** * Groups all limits by category, producing LimitGroup arrays. * Limits not matching any defined group are placed in 'other'. */ static groupLimits(allLimits: Record): LimitGroup[]; /** * Converts a Salesforce limit API name to a human-readable label. * Inserts spaces before uppercase letters and handles common suffixes. */ private static humanizeLimit; /** * Collects warnings from non-critical service failures and result warnings. */ private static collectWarnings; /** * Formats an OrgLimit for result output. */ private static formatLimit; /** * Returns an empty OrgFeatures object for error fallback. */ private static emptyFeatures; /** * Extracts data from service results, falling back to empty defaults on failure. */ private static extractServiceData; /** * Returns an empty OrgDetailsResult for error fallback. */ private static buildEmptyResult; /** * Returns stub success results for sections that are skipped. */ private static skippedResults; /** * Executes the org details retrieval. * * Calls fetchDescribeGlobal() once, then fans out to all service methods * in parallel. Identity failure is fatal; all other failures degrade * gracefully to empty data with warnings. * * @returns ServiceResult containing the assembled OrgDetailsResult */ execute(): Promise>; /** * Builds the OrgDetailsResult from resolved service data. */ private buildResult; /** * Returns the list of sections included in this result. */ private getIncludedSections; /** * Returns true if the given section should be retrieved. * When no sections filter is set, all sections are included. * For 'limits', also triggers on 'limits-all' and 'limits-' variants. */ private needsSection; }