import { ServiceNowInstance } from "../ServiceNowInstance.js"; import { Logger } from "../../util/Logger.js"; import { ServiceNowRequest } from "../../comm/http/ServiceNowRequest.js"; import { ApplicationDetailModel } from "./ApplicationDetailModel.js"; import { BatchInstallation } from "./BatchInstallation.js"; import { BatchDefinition } from "./BatchDefinition.js"; import { StoreAppSearchOptions, StoreAppInstallOptions, StoreAppUpdateOptions, StoreAppOperationResult, StoreAppFinalResult } from "./StoreApplicationModels.js"; import { OperationProgressCallback } from "../OperationProgress.js"; export declare enum APP_TAB_CONTEXT { AVAILABLE_FOR_YOU = "available_for_you", INSTALLED = "installed", UPDATES = "updates" } export declare class ApplicationManager { BATCH_API_URL: string; APP_DETAILS_API_URL: string; APP_SEARCH_API_URL: string; APP_INSTALL_API_URL: string; APP_SEARCH_POST_API_URL: string; APP_UPDATE_API_URL: string; DEFAULT_INSTALL_TIMEOUT: number; DEFAULT_POLL_INTERVAL: number; BATCH_INSTALL_TIMEOUT: number; _logger: Logger; _req: ServiceNowRequest; constructor(instance: ServiceNowInstance); private _instance; installBatch(batchDefinitionPath: string): Promise; private getInstallableApplicationPackages; getApplicationDetails(appID: string): Promise; private waitForBatchInstallCompletion; private executeBatchInstallRequest; private getBatchProgress; /** * Validates a batch definition file against currently installed applications * @param batchDefinitionPath Path to the batch definition JSON file * @returns Promise Validation results for all applications in the batch */ validateBatchDefinition(batchDefinitionPath: string): Promise; /** * Validates a BatchInstallation object against currently installed applications * @param batchInstall BatchInstallation object to validate * @returns Promise Validation results for all applications in the batch */ validateBatchInstallation(batchInstall: BatchInstallation): Promise; /** * Validates a single application from a batch definition * @param pkg BatchDefinition to validate * @returns Promise Validation result for the application */ validateApplication(pkg: BatchDefinition): Promise; /** * Checks which applications from a batch definition are currently installed * @param batchDefinitionPath Path to the batch definition JSON file * @returns Promise Array of validation results */ checkInstalledApplications(batchDefinitionPath: string): Promise; /** * Gets applications that need installation or upgrade from a batch definition * @param batchDefinitionPath Path to the batch definition JSON file * @returns Promise Array of applications needing action */ getApplicationsNeedingAction(batchDefinitionPath: string): Promise; /** * Search/list store applications by tab context with optional search key and pagination. * Uses POST /api/sn_appclient/appmanager/apps * @param options Search options including tabContext, searchKey, limit, offset, requestBody * @returns Array of ApplicationDetailModel matching the search criteria */ searchApplications(options: StoreAppSearchOptions): Promise; /** * Initiate installation of a store application. * Uses GET /api/sn_appclient/appmanager/app/install * @param options Install options including appId and version * @returns StoreAppOperationResult with tracker info for monitoring progress */ installStoreApplication(options: StoreAppInstallOptions): Promise; /** * Install a store application and wait for completion by polling the tracker. * @param options Install options including appId and version * @param pollIntervalMs Polling interval in ms (default: 5000) * @param timeoutMs Timeout in ms (default: 30 min) * @returns StoreAppFinalResult with success status and details */ installStoreApplicationAndWait(options: StoreAppInstallOptions, pollIntervalMs?: number, timeoutMs?: number, onProgress?: OperationProgressCallback): Promise; /** * Initiate update of a store application. * Uses GET /api/sn_appclient/appmanager/app/update * @param options Update options including appId and version * @returns StoreAppOperationResult with tracker info for monitoring progress */ updateStoreApplication(options: StoreAppUpdateOptions): Promise; /** * Update a store application and wait for completion by polling the tracker. * @param options Update options including appId and version * @param pollIntervalMs Polling interval in ms (default: 5000) * @param timeoutMs Timeout in ms (default: 30 min) * @returns StoreAppFinalResult with success status and details */ updateStoreApplicationAndWait(options: StoreAppUpdateOptions, pollIntervalMs?: number, timeoutMs?: number, onProgress?: OperationProgressCallback): Promise; /** * Poll installation progress via ProgressWorker until complete, timed out, or failed. * Uses GET /api/sn_cicd/progress/{progressId} * @param progressId Progress ID from an install/update operation * @param pollIntervalMs Polling interval in ms * @param timeoutMs Timeout in ms * @returns StoreAppFinalResult with success status */ private waitForInstallationCompletion; /** * Compares two version strings * @param version1 First version string (e.g., "1.2.3") * @param version2 Second version string (e.g., "1.2.4") * @returns -1 if version1 < version2, 0 if equal, 1 if version1 > version2 */ private compareVersions; } export declare class BatchInstallResultResponse { result: BatchInstallResult; } export interface BatchInstallResultLinks { progress?: { id: string; url: string; }; } export declare class BatchInstallResult { links: BatchInstallResultLinks; } /** * Represents the validation result for a single application in a batch definition */ export interface ApplicationValidationResult { /** Application sys_id from batch definition */ id: string; /** Application name */ name?: string; /** Requested version from batch definition */ requested_version: string; /** Currently installed version (if any) */ installed_version?: string; /** Whether the application is currently installed */ isInstalled: boolean; /** Whether the installed version matches the requested version */ isVersionMatch: boolean; /** Whether an update is available */ isUpdateAvailable: boolean; /** Whether the application needs to be installed or upgraded */ needsAction: boolean; /** Validation status: 'valid', 'mismatch', 'not_installed', 'update_needed', 'error' */ validationStatus: 'valid' | 'mismatch' | 'not_installed' | 'update_needed' | 'error'; /** Any error message if validation failed */ error?: string; /** Full application details if available */ appDetails?: ApplicationDetailModel; } /** * Represents the validation result for an entire batch definition */ export interface BatchValidationResult { /** Array of validation results for each application */ applications: ApplicationValidationResult[]; /** Total number of applications in batch */ totalApplications: number; /** Number of applications already installed with correct version */ alreadyValid: number; /** Number of applications that need installation */ needsInstallation: number; /** Number of applications that need upgrade */ needsUpgrade: number; /** Number of applications with errors during validation */ errors: number; /** Overall validation passed (all apps either valid or can be installed/upgraded) */ isValid: boolean; }