import type { ISoqlQueryAdapter } from '../adapters/soql/soql-query-adapter.js'; import type { IRestApiAdapter } from '../adapters/rest/rest-api-adapter.js'; import type { DeploymentStatus as DeploymentStatusValue, ConfigurationActionStatus } from '../models/status-types.js'; import type { UserReadinessService } from './UserReadinessService.js'; /** * Permission sets that the configure command can assign (writable actions). * The Pro Administrative User permission set is a prerequisite verified via * UserReadinessService but NOT assigned by the CLI — admin intervention required. */ export declare const CONFIGURABLE_PERMISSION_SETS: readonly string[]; /** * User configuration profile information from Cuneiform CMT. */ export type UserConfig = { /** User ID being checked */ userId: string; /** Active configuration profile developer name */ profileDeveloperName?: string; /** Active configuration profile label */ profileLabel?: string; /** Whether API-only profiling is enabled */ apiOnlyProfilingEnabled: boolean; }; /** * Result of a CMT deployment trigger. */ export type DeploymentResult = { /** Whether the deployment was successfully triggered */ triggered: boolean; /** The deployment job ID (for status tracking) */ jobId?: string; /** Message describing the result */ message: string; }; /** * Status of a CMT deployment job. */ export type DeploymentStatus = { /** The deployment job ID */ jobId: string; /** Current status (Pending, InProgress, Succeeded, Failed, Canceled) */ status: DeploymentStatusValue; /** Whether the deployment is complete */ isComplete: boolean; /** Error message if failed */ errorMessage?: string; }; /** * Represents the current configuration state for a user. */ export type ConfigurationState = { /** User ID that was checked */ userId: string; /** User's login username */ username: string; /** Whether all required permission sets are assigned */ hasRequiredPermissionSets: boolean; /** Names of missing permission sets (empty if all assigned) */ missingPermissionSets: string[]; /** Whether API-only profiling is enabled */ apiOnlyProfilingEnabled: boolean; /** Active profile developer name (if configured) */ profileDeveloperName?: string; }; /** * A single configuration action with its result. */ export type ConfigurationAction = { /** Type of action (e.g., 'assignPermissionSet', 'enableApiOnlyProfiling') */ type: 'assignPermissionSet' | 'enableApiOnlyProfiling' | 'unassignPermissionSet' | 'disableApiOnlyProfiling'; /** Target identifier (permission set name or profile name) */ target: string; /** Human-readable label for the target (e.g., 'Cuneiform for CRM Global Profiling Support') */ targetLabel?: string; /** Action status */ status: ConfigurationActionStatus; /** Reason for skipping or failure message */ message?: string; /** Additional details (e.g., PermissionSetAssignment ID, deployment job ID) */ details?: Record; }; /** * Result of the configure orchestration method. */ export type UserConfigurationResult = { /** User information */ user: { id: string; username: string; }; /** Whether this was a dry-run (no changes applied) */ dryRun: boolean; /** Configuration state before changes */ previousState: ConfigurationState; /** Actions taken or planned */ actions: ConfigurationAction[]; /** Configuration state after changes (null for dry-run) */ currentState: ConfigurationState | null; /** Summary statistics */ summary: { /** Number of changes required */ changesRequired: number; /** Number of changes successfully applied */ changesApplied: number; /** Number of changes that failed */ changesFailed: number; /** * Whether the user has all required configuration (permission sets assigned + API-only enabled). * For configure(): true when all permissions are in place after changes. * For unconfigure(): reflects the post-unconfigure state (typically false after successful unconfigure). */ isReady: boolean; }; }; /** * Raw Active Configuration CMT query record with relationship. */ export type ActiveConfigurationRecord = { Id: string; DeveloperName: string; pnova__Active_Configuration_Profile__r?: { Id: string; DeveloperName: string; Label: string; pnova__Enable_API_Only_Profiling__c: boolean; }; }; /** * Raw DeployRequest query record for status tracking. */ export type DeployRequestRecord = { Id: string; Status: string; ErrorMessage?: string; }; /** * Raw PermissionSet query record. */ export type PermissionSetRecord = { Id: string; Name: string; NamespacePrefix: string | null; }; /** * Configuration for UserConfigurationService. */ export type IUserConfigurationServiceConfig = { /** SOQL query adapter for CMT queries */ soqlAdapter: ISoqlQueryAdapter; /** REST API adapter for CMT deployments and record inserts */ restApiAdapter: IRestApiAdapter; /** User readiness service for checking user state (required for configure()) */ userReadinessService?: UserReadinessService; /** Optional logger for debug output */ logger?: Console; }; /** * Shared service dependencies passed to configure/unconfigure mode classes. * * These are the subset of UserConfigurationService methods that modes need * to perform their work. Using an interface decouples modes from the * full service class. */ export type IConfigurationServiceDeps = { /** SOQL adapter for queries */ soqlAdapter: ISoqlQueryAdapter; /** REST API adapter for record operations */ restApiAdapter: IRestApiAdapter; /** User readiness service (always available within modes) */ userReadinessService: UserReadinessService; /** Optional logger */ logger?: Console; /** Get the ID of a permission set by name and namespace */ getPermissionSetId: (name: string, namespace: string) => Promise>; /** Enable API-only profiling for a profile */ enableApiOnlyProfiling: (profileDeveloperName: string) => Promise>; /** Disable API-only profiling for a profile */ disableApiOnlyProfiling: (profileDeveloperName: string) => Promise>; /** Wait for a deployment to complete */ waitForDeploymentCompletion: (jobId: string) => Promise>; };