import { IUiPath } from '../core/index'; /** * Insights Types * Shared types for Maestro insights analytics endpoints */ /** * Optional filters for Insights "top" endpoint queries. * All fields are optional — pass any combination to narrow results. */ interface TopQueryOptions { /** Filter by package identifier */ packageId?: string; /** Filter by process key */ processKey?: string; /** Filter by package version */ version?: string; } /** * Common fields returned by all Insights "top" endpoints */ interface GetTopBaseResponse { /** The package identifier */ packageId: string; /** The unique process key */ processKey: string; } /** * Response for the top run count Insights endpoint */ interface GetTopRunCountResponse extends GetTopBaseResponse { /** Number of times the process was run in the given time range */ runCount: number; } /** * Response for the top failure count Insights endpoint */ interface GetTopFaultedCountResponse extends GetTopBaseResponse { /** Number of faulted instances in the given time range */ faultedCount: number; } /** * SDK response for top elements with failure. * Shared by both MaestroProcesses and Cases — no service-specific enrichment. */ interface ElementGetTopFailedCountResponse { /** BPMN element name (falls back to element ID if name is empty) */ elementName: string; /** BPMN element type (e.g. ServiceTask, ReceiveTask, IntermediateCatchEvent) */ elementType: string; /** The unique process key this element belongs to */ processKey: string; /** Number of failed executions of this element in the given time range */ failedCount: number; } /** * Time bucketing granularity for insights time-series queries. * * Controls how data points are grouped on the time axis. */ declare enum TimeInterval { /** Group data points by hour */ Hour = "HOUR", /** Group data points by day */ Day = "DAY", /** Group data points by week */ Week = "WEEK" } /** * Options for insights time-series queries. */ interface TimelineOptions { /** * How to group data points on the time axis. * @default TimeInterval.Day */ groupBy?: TimeInterval; /** Filter by package identifier */ packageId?: string; /** Filter by package version */ version?: string; /** Filter by one or more process keys. Pass `['']` for a single process. */ processKeys?: string[]; } /** * Final instance statuses returned by the instance status timeline endpoint. * * Only includes statuses where the instance has finished execution — Completed, Faulted, or Cancelled. * Active statuses like Running or Paused are not included. */ declare enum InstanceFinalStatus { /** Instance completed successfully */ Completed = "Completed", /** Instance encountered an error */ Faulted = "Faulted", /** Instance was cancelled */ Cancelled = "Cancelled" } /** * Instance count for a process with a given status * within a specific time bucket. */ interface InstanceStatusTimelineResponse { /** Start of the time bucket in local timezone (e.g. `"5/8/2026 12:00:00 AM"`) */ startTime: string; /** Instance status */ status: InstanceFinalStatus; /** Number of instances with this status in the time bucket */ count: number; } /** * Incident count within a specific time bucket. */ interface IncidentTimelineResponse { /** Start of the time bucket in local timezone (ISO 8601, e.g. `"2026-05-04T00:00:00"`) */ startTime: string; /** End of the time bucket in local timezone (ISO 8601, e.g. `"2026-05-11T00:00:00"`) */ endTime: string; /** Number of incidents that occurred within this time bucket */ count: number; } /** * Response for the top duration Insights endpoint */ interface GetTopDurationResponse extends GetTopBaseResponse { /** Total execution duration in milliseconds */ duration: number; } /** * Duration percentile stats shared by Insights aggregate endpoints (per-element and per-process/case). * * For instance-level stats, durations are computed over terminal instances only * (Completed, Cancelled, Deleted) and default to `0` when no terminal instances exist. */ interface DurationStats { /** Minimum duration in milliseconds */ minDurationMs: number; /** Maximum duration in milliseconds */ maxDurationMs: number; /** Average duration in milliseconds */ avgDurationMs: number; /** 50th percentile (median) duration in milliseconds */ p50DurationMs: number; /** 95th percentile duration in milliseconds */ p95DurationMs: number; /** 99th percentile duration in milliseconds */ p99DurationMs: number; } /** * Instance count and duration stats aggregated by status for a process or case within a time range. * * Duration fields are computed over terminal instances only (Completed, Cancelled, Deleted) * and default to `0` when no terminal instances exist in the time range. */ interface InstanceStats extends DurationStats { /** Total number of instances across all statuses */ totalCount: number; /** Number of currently running instances */ runningCount: number; /** Number of instances in transitioning state */ transitioningCount: number; /** Number of paused instances */ pausedCount: number; /** Number of faulted instances */ faultedCount: number; /** Number of completed instances */ completedCount: number; /** Number of cancelled instances */ cancelledCount: number; /** Number of deleted instances */ deletedCount: number; } /** * Required request parameters for process-scoped insights stats endpoints * (`getElementStats`, `getInstanceStats`). * * Identifies a single process+package+version and the time range to aggregate over. */ interface MaestroProcessStatsRequest { /** Process key to filter by */ processKey: string; /** Package identifier */ packageId: string; /** Package version to filter by */ packageVersion: string; /** Start of the time range to query */ startTime: Date; /** End of the time range to query */ endTime: Date; } /** * Per-element execution counts and duration percentiles for a BPMN element within a process or case. */ interface ElementStats extends DurationStats { /** BPMN element identifier */ elementId: string; /** Number of successful executions */ successCount: number; /** Number of failed executions */ failCount: number; /** Number of terminated executions */ terminatedCount: number; /** Number of paused executions */ pausedCount: number; /** Number of in-progress executions */ inProgressCount: number; } /** * Maestro Process Types * Types and interfaces for Maestro process management */ /** * Optional filters for {@link MaestroProcessesServiceModel.getAll}. * All fields are optional — pass any combination to narrow the returned processes. */ interface MaestroProcessGetAllOptions { /** Filter by process key */ processKey?: string; /** Filter by package identifier */ packageId?: string; /** Only include processes with instances started at or after this time */ startTime?: Date; /** Only include processes with instances started at or before this time */ endTime?: Date; } /** * Process information with instance statistics */ interface RawMaestroProcessGetAllResponse { /** Unique key identifying the process */ processKey: string; /** Package identifier */ packageId: string; /** Process name */ name: string; /** Folder key where process is located */ folderKey: string; /** Folder name */ folderName: string; /** Available package versions */ packageVersions: string[]; /** Total number of versions */ versionCount: number; /** Process instance count - pending */ pendingCount: number; /** Process instance count - running */ runningCount: number; /** Process instance count - completed */ completedCount: number; /** Process instance count - paused */ pausedCount: number; /** Process instance count - cancelled */ cancelledCount: number; /** Process instance count - faulted */ faultedCount: number; /** Process instance count - retrying */ retryingCount: number; /** Process instance count - resuming */ resumingCount: number; /** Process instance count - pausing */ pausingCount: number; /** Process instance count - canceling */ cancelingCount: number; } /** * Response for a single entry in top processes by run count */ interface ProcessGetTopRunCountResponse extends GetTopRunCountResponse { /** Human-readable process name */ name: string; } /** * Response for a single entry in top processes by failure count */ interface ProcessGetTopFaultedCountResponse extends GetTopFaultedCountResponse { /** Human-readable process name */ name: string; } /** * Response for a single entry in top processes by duration */ interface ProcessGetTopDurationResponse extends GetTopDurationResponse { /** Human-readable process name */ name: string; } /** * Process Incident Status */ declare enum ProcessIncidentStatus { Open = "Open", Closed = "Closed" } /** * Process Incident Type */ declare enum ProcessIncidentType { System = "System", User = "User", Deployment = "Deployment" } /** * Process Incident Severity */ declare enum ProcessIncidentSeverity { Error = "Error", Warning = "Warning" } /** * Process Incident Debug Mode */ declare enum DebugMode { None = "None", Default = "Default", StepByStep = "StepByStep", SingleStep = "SingleStep" } /** * Process Incident Get Response */ interface ProcessIncidentGetResponse { instanceId: string; elementId: string; folderKey: string; processKey: string; incidentId: string; incidentStatus: ProcessIncidentStatus; incidentType: ProcessIncidentType | null; errorCode: string; errorMessage: string; errorTime: string; errorDetails: string; debugMode: DebugMode; incidentSeverity: ProcessIncidentSeverity | null; incidentElementActivityType: string; incidentElementActivityName: string; } /** * Process Incident Summary Get Response */ interface ProcessIncidentGetAllResponse { count: number; errorMessage: string; errorCode: string; firstOccuranceTime: string; processKey: string; } /** * Maestro Process Models * Model classes for Maestro processes */ /** * Service for managing UiPath Maestro Processes * * UiPath Maestro is a cloud-native orchestration layer that coordinates bots, AI agents, and humans for seamless, intelligent automation of complex workflows. [UiPath Maestro Guide](https://docs.uipath.com/maestro/automation-cloud/latest/user-guide/introduction-to-maestro) * * ### Usage * * Prerequisites: Initialize the SDK first - see [Getting Started](/uipath-typescript/getting-started/#import-initialize) * * ```typescript * import { MaestroProcesses } from '@uipath/uipath-typescript/maestro-processes'; * * const maestroProcesses = new MaestroProcesses(sdk); * const allProcesses = await maestroProcesses.getAll(); * ``` */ interface MaestroProcessesServiceModel { /** * Get all processes with their instance statistics. * * Returns every Maestro process with aggregated instance counts by status. Pass `options` * to narrow the results by process key, package, or the time range their instances started in. * * @param options - Optional filters (processKey, packageId, startTime, endTime) * @returns Promise resolving to array of MaestroProcess objects with methods * {@link MaestroProcessGetAllResponse} * @example * ```typescript * // Get all processes * const allProcesses = await maestroProcesses.getAll(); * * // Access process information and incidents * for (const process of allProcesses) { * console.log(`Process: ${process.processKey}`); * console.log(`Running instances: ${process.runningCount}`); * console.log(`Faulted instances: ${process.faultedCount}`); * * // Get incidents for this process * const incidents = await process.getIncidents(); * console.log(`Incidents: ${incidents.length}`); * } * ``` * * @example * ```typescript * // Filter by package and the time range instances started in * const filtered = await maestroProcesses.getAll({ * packageId: '', * startTime: new Date(Date.now() - 7 * 24 * 60 * 60 * 1000), * endTime: new Date(), * }); * ``` */ getAll(options?: MaestroProcessGetAllOptions): Promise; /** * Get incidents for a specific process * * @param processKey The key of the process to get incidents for * @param folderKey The folder key for authorization * @returns Promise resolving to array of incidents for the process * {@link ProcessIncidentGetResponse} * @example * ```typescript * // Get incidents for a specific process * const incidents = await maestroProcesses.getIncidents('', ''); * * // Access incident details * for (const incident of incidents) { * console.log(`Element: ${incident.incidentElementActivityName} (${incident.incidentElementActivityType})`); * console.log(`Status: ${incident.incidentStatus}`); * console.log(`Error: ${incident.errorMessage}`); * } * ``` */ getIncidents(processKey: string, folderKey: string): Promise; /** * Get the top 5 processes ranked by run count within a time range. * * Returns an array of up to 5 processes sorted by how many times they were executed, * useful for identifying the most active processes in a given period. * * @param startTime - Start of the time range to query * @param endTime - End of the time range to query * @param options - Optional filters (packageId, processKey, version) * @returns Promise resolving to an array of {@link ProcessGetTopRunCountResponse} * @example * ```typescript * import { MaestroProcesses } from '@uipath/uipath-typescript/maestro-processes'; * * const maestroProcesses = new MaestroProcesses(sdk); * * // Get top processes by run count for the last 7 days * const topProcesses = await maestroProcesses.getTopRunCount( * new Date(Date.now() - 7 * 24 * 60 * 60 * 1000), * new Date() * ); * * for (const process of topProcesses) { * console.log(`${process.packageId}: ${process.runCount} runs`); * } * ``` * * @example * ```typescript * // Get top processes by run count for a specific package * const filtered = await maestroProcesses.getTopRunCount( * new Date(Date.now() - 7 * 24 * 60 * 60 * 1000), * new Date(), * { packageId: '' } * ); * ``` */ getTopRunCount(startTime: Date, endTime: Date, options?: TopQueryOptions): Promise; /** * Get the top 10 processes ranked by failure count within a time range. * * Returns an array of up to 10 processes sorted by how many instances faulted, * useful for identifying the most error-prone processes in a given period. * * @param startTime - Start of the time range to query * @param endTime - End of the time range to query * @param options - Optional filters (packageId, processKey, version) * @returns Promise resolving to an array of {@link ProcessGetTopFaultedCountResponse} * @example * ```typescript * import { MaestroProcesses } from '@uipath/uipath-typescript/maestro-processes'; * * const maestroProcesses = new MaestroProcesses(sdk); * * // Get top processes by faulted count for the last 7 days * const topFailing = await maestroProcesses.getTopFaultedCount( * new Date(Date.now() - 7 * 24 * 60 * 60 * 1000), * new Date() * ); * * for (const process of topFailing) { * console.log(`${process.packageId}: ${process.faultedCount} failures`); * } * ``` * * @example * ```typescript * // Get top processes by faulted count for a specific package * const filtered = await maestroProcesses.getTopFaultedCount( * new Date(Date.now() - 7 * 24 * 60 * 60 * 1000), * new Date(), * { packageId: '' } * ); * ``` */ getTopFaultedCount(startTime: Date, endTime: Date, options?: TopQueryOptions): Promise; /** * Get the top 10 BPMN elements ranked by failure count within a time range. * * Returns an array of up to 10 elements sorted by how many times they failed, * useful for identifying the most error-prone activities in processes. * * @param startTime - Start of the time range to query * @param endTime - End of the time range to query * @param options - Optional filters (packageId, processKey, version) * @returns Promise resolving to an array of {@link ElementGetTopFailedCountResponse} * @example * ```typescript * import { MaestroProcesses } from '@uipath/uipath-typescript/maestro-processes'; * * const maestroProcesses = new MaestroProcesses(sdk); * * // Get top failing elements for the last 7 days * const topFailing = await maestroProcesses.getTopElementFailedCount( * new Date(Date.now() - 7 * 24 * 60 * 60 * 1000), * new Date() * ); * * for (const element of topFailing) { * console.log(`${element.elementName} (${element.elementType}): ${element.failedCount} failures`); * } * ``` * * @example * ```typescript * // Get top failing elements for a specific process * const filtered = await maestroProcesses.getTopElementFailedCount( * new Date(Date.now() - 7 * 24 * 60 * 60 * 1000), * new Date(), * { processKey: '' } * ); * ``` */ getTopElementFailedCount(startTime: Date, endTime: Date, options?: TopQueryOptions): Promise; /** * Get all instances status counts aggregated by date for maestro processes. * * Returns time-grouped counts of instances grouped by status (Completed, Faulted, Cancelled), * useful for rendering time-series charts. Use `groupBy` to control the time bucket size * (hour, day, or week) — defaults to day if not provided. * * @param startTime - Start of the time range to query * @param endTime - End of the time range to query * @param options - Optional settings for filtering and time bucket granularity * @returns Promise resolving to an array of {@link InstanceStatusTimelineResponse} * * @example * ```typescript * // Get daily instance status for the last 7 days * const now = new Date(); * const sevenDaysAgo = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000); * const statuses = await maestroProcesses.getInstanceStatusTimeline(sevenDaysAgo, now); * * for (const entry of statuses) { * console.log(`${entry.startTime} — ${entry.status}: ${entry.count}`); * } * ``` * * @example * ```typescript * import { TimeInterval } from '@uipath/uipath-typescript/maestro-processes'; * * // Get hourly breakdown * const statuses = await maestroProcesses.getInstanceStatusTimeline(startTime, endTime, { * groupBy: TimeInterval.Hour, * }); * ``` * * @example * ```typescript * // Filter to a specific process * const filtered = await maestroProcesses.getInstanceStatusTimeline(startTime, endTime, { * processKeys: [''], * }); * ``` * * @example * ```typescript * // Get all-time data (from Unix epoch to now) * const allTime = await maestroProcesses.getInstanceStatusTimeline(new Date(0), new Date()); * ``` */ getInstanceStatusTimeline(startTime: Date, endTime: Date, options?: TimelineOptions): Promise; /** * Get incident counts aggregated by time bucket for maestro processes. * * Returns time-grouped counts of incidents that occurred within each bucket, * useful for rendering incident time-series charts. Use `groupBy` to control * the time bucket size (hour, day, or week) — defaults to day if not provided. * * @param startTime - Start of the time range to query * @param endTime - End of the time range to query * @param options - Optional settings for filtering and time bucket granularity * @returns Promise resolving to an array of {@link IncidentTimelineResponse} * * @example * ```typescript * // Get daily incident counts for the last 7 days * const now = new Date(); * const sevenDaysAgo = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000); * const incidents = await maestroProcesses.getIncidentsTimeline(sevenDaysAgo, now); * * for (const incident of incidents) { * console.log(`${incident.startTime} → ${incident.endTime}: ${incident.count} incidents`); * } * ``` * * @example * ```typescript * import { TimeInterval } from '@uipath/uipath-typescript/maestro-processes'; * * // Get weekly breakdown * const incidents = await maestroProcesses.getIncidentsTimeline(startTime, endTime, { * groupBy: TimeInterval.Week, * }); * ``` * * @example * ```typescript * // Filter to a specific process * const filtered = await maestroProcesses.getIncidentsTimeline(startTime, endTime, { * processKeys: [''], * }); * ``` */ getIncidentsTimeline(startTime: Date, endTime: Date, options?: TimelineOptions): Promise; /** * Get the top 5 processes ranked by total duration within a time range. * * Returns an array of up to 5 processes sorted by their total execution time, * useful for identifying the longest-running processes in a given period. * * @param startTime - Start of the time range to query * @param endTime - End of the time range to query * @param options - Optional filters (packageId, processKey, version) * @returns Promise resolving to an array of {@link ProcessGetTopDurationResponse} * @example * ```typescript * import { MaestroProcesses } from '@uipath/uipath-typescript/maestro-processes'; * * const maestroProcesses = new MaestroProcesses(sdk); * * // Get top processes by duration for the last 7 days * const topProcesses = await maestroProcesses.getTopExecutionDuration( * new Date(Date.now() - 7 * 24 * 60 * 60 * 1000), * new Date() * ); * * for (const process of topProcesses) { * console.log(`${process.packageId}: ${process.duration}ms total`); * } * ``` * * @example * ```typescript * // Get top processes by duration for a specific package * const filtered = await maestroProcesses.getTopExecutionDuration( * new Date(Date.now() - 7 * 24 * 60 * 60 * 1000), * new Date(), * { packageId: '' } * ); * ``` */ getTopExecutionDuration(startTime: Date, endTime: Date, options?: TopQueryOptions): Promise; /** * Get element stats for process instances * * Returns per-element execution counts (success, fail, terminated, paused, in-progress) and * duration percentile metrics (min, max, avg, p50, p95, p99) for BPMN elements within a process. * * @param request - Process scope + time range to aggregate over * @returns Promise resolving to an array of {@link ElementStats} * @example * ```typescript * // First, list processes to find the processKey, packageId, and available versions * const processes = await maestroProcesses.getAll(); * const process = processes[0]; * * // Get element metrics for that process * const elements = await maestroProcesses.getElementStats({ * processKey: process.processKey, * packageId: process.packageId, * packageVersion: process.packageVersions[0], * startTime: new Date('2026-04-01'), * endTime: new Date(), * }); * * // Analyze element performance * for (const element of elements) { * console.log(`Element: ${element.elementId}`); * console.log(` Success: ${element.successCount}, Failed: ${element.failCount}`); * console.log(` Avg duration: ${element.avgDurationMs}ms, P95: ${element.p95DurationMs}ms`); * } * * // Using bound method on a process — auto-fills processKey and packageId * const boundElements = await process.getElementStats( * new Date('2026-04-01'), * new Date(), * process.packageVersions[0] * ); * ``` */ getElementStats(request: MaestroProcessStatsRequest): Promise; /** * Get instance stats for a process. * * Returns total instance counts broken down by status (running, completed, faulted, etc.) * and the average execution duration for all instances of a process within a time range. * * @param request - Process scope + time range to aggregate over * @returns Promise resolving to {@link InstanceStats} * @example * ```typescript * // First, list processes to find the processKey, packageId, and available versions * const processes = await maestroProcesses.getAll(); * const process = processes[0]; * * // Get instance status breakdown for that process * const counts = await maestroProcesses.getInstanceStats({ * processKey: process.processKey, * packageId: process.packageId, * packageVersion: process.packageVersions[0], * startTime: new Date('2026-04-01'), * endTime: new Date(), * }); * * console.log(`Total: ${counts.totalCount}`); * console.log(`Running: ${counts.runningCount}, Completed: ${counts.completedCount}`); * console.log(`Faulted: ${counts.faultedCount}, Avg duration: ${counts.avgDurationMs}ms`); * * // Using bound method on a process — auto-fills processKey and packageId * const boundCounts = await process.getInstanceStats( * new Date('2026-04-01'), * new Date(), * process.packageVersions[0] * ); * ``` */ getInstanceStats(request: MaestroProcessStatsRequest): Promise; } interface ProcessMethods { /** * Gets incidents for this process * * @returns Promise resolving to array of process incidents */ getIncidents(): Promise; /** * Get element stats for this process * * @param startTime - Start of the time range to query * @param endTime - End of the time range to query * @param packageVersion - Package version to filter by * @returns Promise resolving to an array of {@link ElementStats} */ getElementStats(startTime: Date, endTime: Date, packageVersion: string): Promise; /** * Get instance stats for this process * * @param startTime - Start of the time range to query * @param endTime - End of the time range to query * @param packageVersion - Package version to filter by * @returns Promise resolving to {@link InstanceStats} */ getInstanceStats(startTime: Date, endTime: Date, packageVersion: string): Promise; /** * Get instance status counts aggregated by date for this process. * * @param startTime - Start of the time range to query * @param endTime - End of the time range to query * @param options - Optional settings for filtering and time bucket granularity (processKey is auto-captured from this process) * @returns Promise resolving to an array of {@link InstanceStatusTimelineResponse} */ getInstanceStatusTimeline(startTime: Date, endTime: Date, options?: Omit): Promise; /** * Get incident counts aggregated by time bucket for this process. * * @param startTime - Start of the time range to query * @param endTime - End of the time range to query * @param options - Optional settings for filtering and time bucket granularity (processKey is auto-captured from this process) * @returns Promise resolving to an array of {@link IncidentTimelineResponse} */ getIncidentsTimeline(startTime: Date, endTime: Date, options?: Omit): Promise; } type MaestroProcessGetAllResponse = RawMaestroProcessGetAllResponse & ProcessMethods; /** * Creates an actionable process by combining API process data with operational methods. * * @param processData - The process data from API * @param service - The process service instance * @returns A process object with added methods */ declare function createProcessWithMethods(processData: MaestroProcessGetAllResponse, service: MaestroProcessesServiceModel): MaestroProcessGetAllResponse; /** * Simplified universal pagination cursor * Used to fetch next/previous pages */ interface PaginationCursor { /** Opaque string containing all information needed to fetch next page */ value: string; } /** * Discriminated union for pagination methods - ensures cursor and jumpToPage are mutually exclusive */ type PaginationMethodUnion = { cursor?: PaginationCursor; jumpToPage?: never; } | { cursor?: never; jumpToPage?: number; } | { cursor?: never; jumpToPage?: never; }; /** * Pagination options. Users cannot specify both cursor and jumpToPage. */ type PaginationOptions = { /** Size of the page to fetch (items per page) */ pageSize?: number; } & PaginationMethodUnion; /** * Paginated response containing items and navigation information */ interface PaginatedResponse { /** The items in the current page */ items: T[]; /** Total count of items across all pages (if available) */ totalCount?: number; /** Whether more pages are available */ hasNextPage: boolean; /** Cursor to fetch the next page (if available) */ nextCursor?: PaginationCursor; /** Cursor to fetch the previous page (if available) */ previousCursor?: PaginationCursor; /** Current page number (1-based, if available) */ currentPage?: number; /** Total number of pages (if available) */ totalPages?: number; /** Whether this pagination type supports jumping to arbitrary pages */ supportsPageJump: boolean; } /** * Response for non-paginated calls that includes both data and total count */ interface NonPaginatedResponse { items: T[]; totalCount?: number; } /** * Helper type for defining paginated method overloads * Creates a union type of all ways pagination can be triggered */ type HasPaginationOptions = (T & { pageSize: number; }) | (T & { cursor: PaginationCursor; }) | (T & { jumpToPage: number; }); /** * Process Instance Types * Types and interfaces for Maestro process instance management */ /** * Response for getting a single process instance */ interface RawProcessInstanceGetResponse { instanceId: string; packageKey: string; packageId: string; packageVersion: string; latestRunId: string; latestRunStatus: string; processKey: string; folderKey: string; userId: number; instanceDisplayName: string; startedByUser: string; source: string; creatorUserKey: string; startedTime: string; completedTime: string | null; instanceRuns: ProcessInstanceRun[]; } /** * Query options for getting process instances */ interface ProcessInstanceGetAllOptions { packageId?: string; packageVersion?: string; processKey?: string; errorCode?: string; } /** * Query options for getting process instances with pagination support */ type ProcessInstanceGetAllWithPaginationOptions = ProcessInstanceGetAllOptions & PaginationOptions; /** * Request for process instance operations (cancel, pause, resume) */ interface ProcessInstanceOperationOptions { comment?: string; } /** * Response from PIMS operations (cancel, pause, resume) */ interface ProcessInstanceOperationResponse { instanceId: string; status: string; } /** * Response for process instance execution history */ interface ProcessInstanceExecutionHistoryResponse { id: string; traceId: string; parentId: string | null; name: string; startedTime: string; endTime: string | null; attributes: string | null; updatedTime: string; expiredTime: string | null; } /** * Process Instance run */ interface ProcessInstanceRun { runId: string; status: string; startedTime: string; completedTime: string; } type BpmnXmlString = string; /** * Process Instance element metadata */ interface ElementMetaData { elementId: string; elementRunId: string; isMarker: boolean; inputs: Record; inputDefinitions: Record; outputs: Record; } /** * Process Instance global variable metadata */ interface GlobalVariableMetaData { id: string; name: string; /** * Common values: "integer", "string", "boolean" * May also contain custom types or "any" when type cannot be determined */ type: string; elementId: string; /** Name of the BPMN node/element */ source: string; value: any; } /** * Response for getting global variables for process instance */ interface ProcessInstanceGetVariablesResponse { elements: ElementMetaData[]; globalVariables: GlobalVariableMetaData[]; instanceId: string; parentElementId: string | null; } /** * Options for getting global variables */ interface ProcessInstanceGetVariablesOptions { parentElementId?: string; } /** * Standardized result interface for all operation methods (pause, cancel, complete, update, upload, etc.) * Success responses include data from the request context or API response */ interface OperationResponse { /** * Whether the operation was successful */ success: boolean; /** * Response data (can contain error details in case of failure) */ data: TData; } /** * Service for managing UiPath Maestro Process instances * * Maestro process instances are the running instances of Maestro processes. [UiPath Maestro Process Instances Guide](https://docs.uipath.com/maestro/automation-cloud/latest/user-guide/all-instances-view) * * ### Usage * * Prerequisites: Initialize the SDK first - see [Getting Started](/uipath-typescript/getting-started/#import-initialize) * * ```typescript * import { ProcessInstances } from '@uipath/uipath-typescript/maestro-processes'; * * const processInstances = new ProcessInstances(sdk); * const allInstances = await processInstances.getAll(); * ``` */ interface ProcessInstancesServiceModel { /** * Get all process instances with optional filtering and pagination * * The method returns either: * - A NonPaginatedResponse with items array (when no pagination parameters are provided) * - A PaginatedResponse with navigation cursors (when any pagination parameter is provided) * * @param options Query parameters for filtering instances and pagination * @returns Promise resolving to either an array of process instances NonPaginatedResponse or a PaginatedResponse when pagination options are used. * {@link ProcessInstanceGetResponse} * @example * ```typescript * // Get all instances (non-paginated) * const instances = await processInstances.getAll(); * * // Cancel faulted instances using methods directly on instances * for (const instance of instances.items) { * if (instance.latestRunStatus === 'Faulted') { * await instance.cancel({ comment: 'Cancelling faulted instance' }); * } * } * * // With filtering * const filteredInstances = await processInstances.getAll({ * processKey: 'MyProcess' * }); * * // First page with pagination * const page1 = await processInstances.getAll({ pageSize: 10 }); * * // Navigate using cursor * if (page1.hasNextPage) { * const page2 = await processInstances.getAll({ cursor: page1.nextCursor }); * } * ``` */ getAll(options?: T): Promise ? PaginatedResponse : NonPaginatedResponse>; /** * Get a process instance by ID with operation methods (cancel, pause, resume, retry) * @param id The ID of the instance to retrieve * @param folderKey The folder key for authorization * @returns Promise resolving to a process instance * {@link ProcessInstanceGetResponse} * @example * ```typescript * // Get a specific process instance * const instance = await processInstances.getById( * , * * ); * * // Access instance properties * console.log(`Status: ${instance.latestRunStatus}`); * ``` */ getById(id: string, folderKey: string): Promise; /** * Get execution history (spans) for a process instance * @param instanceId The ID of the instance to get history for * @param folderKey The folder key for authorization * @returns Promise resolving to execution history * {@link ProcessInstanceExecutionHistoryResponse} * @example * ```typescript * // Get execution history for a process instance * const history = await processInstances.getExecutionHistory( * , * * ); * * // Analyze execution timeline * history.forEach(span => { * console.log(`Activity: ${span.name}`); * console.log(`Start: ${span.startedTime}`); * console.log(`End: ${span.endTime}`); * }); * ``` */ getExecutionHistory(instanceId: string, folderKey: string): Promise; /** * Get BPMN XML file for a process instance * @param instanceId The ID of the instance to get BPMN for * @param folderKey The folder key for authorization * @returns Promise resolving to BPMN XML file * {@link BpmnXmlString} * @example * ```typescript * // Get BPMN XML for a process instance * const bpmnXml = await processInstances.getBpmn( * , * * ); * * // Render BPMN diagram in frontend using bpmn-js * import BpmnViewer from 'bpmn-js/lib/Viewer'; * * const viewer = new BpmnViewer({ * container: '#bpmn-diagram' * }); * * await viewer.importXML(bpmnXml); * * // Zoom to fit the diagram * viewer.get('canvas').zoom('fit-viewport'); * ``` */ getBpmn(instanceId: string, folderKey: string): Promise; /** * Cancel a process instance * @param instanceId The ID of the instance to cancel * @param folderKey The folder key for authorization * @param options Optional cancellation options with comment * @returns Promise resolving to operation result with instance data * @example * ```typescript * // Cancel a process instance * const result = await processInstances.cancel( * , * * ); * * // Or using instance method * const instance = await processInstances.getById( * , * * ); * const result = await instance.cancel(); * * console.log(`Cancelled: ${result.success}`); * * // Cancel with a comment * const resultWithComment = await instance.cancel({ * comment: 'Cancelling due to invalid input data' * }); * * if (resultWithComment.success) { * console.log(`Instance ${resultWithComment.data.instanceId} status: ${resultWithComment.data.status}`); * } * ``` */ cancel(instanceId: string, folderKey: string, options?: ProcessInstanceOperationOptions): Promise>; /** * Pause a process instance * @param instanceId The ID of the instance to pause * @param folderKey The folder key for authorization * @param options Optional pause options with comment * @returns Promise resolving to operation result with instance data */ pause(instanceId: string, folderKey: string, options?: ProcessInstanceOperationOptions): Promise>; /** * Resume a process instance * @param instanceId The ID of the instance to resume * @param folderKey The folder key for authorization * @param options Optional resume options with comment * @returns Promise resolving to operation result with instance data */ resume(instanceId: string, folderKey: string, options?: ProcessInstanceOperationOptions): Promise>; /** * Retry a faulted process instance * * Re-runs the failed elements of the instance (and the elements that follow) within the * same instance, spawning new jobs. Use to recover from transient/flaky failures. * @param instanceId The ID of the instance to retry * @param folderKey The folder key for authorization * @param options Optional retry options with comment * @returns Promise resolving to operation result with instance data * @example * ```typescript * // Retry a faulted process instance * const result = await processInstances.retry( * , * * ); * * // Or using instance method * const instance = await processInstances.getById( * , * * ); * if (instance.latestRunStatus === 'Faulted') { * const result = await instance.retry({ comment: 'Retrying flaky failure' }); * console.log(`Retried: ${result.success}`); * } * ``` */ retry(instanceId: string, folderKey: string, options?: ProcessInstanceOperationOptions): Promise>; /** * Get global variables for a process instance * * @param instanceId The ID of the instance to get variables for * @param folderKey The folder key for authorization * @param options Optional options including parentElementId to filter by parent element * @returns Promise resolving to variables response with elements and globals * {@link ProcessInstanceGetVariablesResponse} * @example * ```typescript * // Get all variables for a process instance * const variables = await processInstances.getVariables( * , * * ); * * // Access global variables * console.log('Global variables:', variables.globalVariables); * * // Iterate through global variables with metadata * variables.globalVariables?.forEach(variable => { * console.log(`Variable: ${variable.name} (${variable.id})`); * console.log(` Type: ${variable.type}`); * console.log(` Element: ${variable.elementId}`); * console.log(` Value: ${variable.value}`); * }); * * // Get variables for a specific parent element * const elementVariables = await processInstances.getVariables( * , * , * { parentElementId: } * ); * ``` */ getVariables(instanceId: string, folderKey: string, options?: ProcessInstanceGetVariablesOptions): Promise; /** * Get incidents for a process instance * * @param instanceId The ID of the instance to get incidents for * @param folderKey The folder key for authorization * @returns Promise resolving to array of incidents for the processinstance * {@link ProcessIncidentGetResponse} * @example * ```typescript * // Get incidents for a specific instance * const incidents = await processInstances.getIncidents('', ''); * * // Access process incident details * for (const incident of incidents) { * console.log(`Element: ${incident.incidentElementActivityName} (${incident.incidentElementActivityType})`); * console.log(`Severity: ${incident.incidentSeverity}`); * console.log(`Error: ${incident.errorMessage}`); * } * ``` */ getIncidents(instanceId: string, folderKey: string): Promise; } interface ProcessInstanceMethods { /** * Cancels this process instance * * @param options - Optional cancellation options with comment * @returns Promise resolving to operation result */ cancel(options?: ProcessInstanceOperationOptions): Promise>; /** * Pauses this process instance * * @param options - Optional pause options with comment * @returns Promise resolving to operation result */ pause(options?: ProcessInstanceOperationOptions): Promise>; /** * Resumes this process instance * * @param options - Optional resume options with comment * @returns Promise resolving to operation result */ resume(options?: ProcessInstanceOperationOptions): Promise>; /** * Retries this faulted process instance * * @param options - Optional retry options with comment * @returns Promise resolving to operation result */ retry(options?: ProcessInstanceOperationOptions): Promise>; /** * Gets incidents for this process instance * * @returns Promise resolving to array of incidents for this instance */ getIncidents(): Promise; /** * Gets execution history (spans) for this process instance * * @returns Promise resolving to execution history */ getExecutionHistory(): Promise; /** * Gets BPMN XML file for this process instance * * @returns Promise resolving to BPMN XML file */ getBpmn(): Promise; /** * Gets global variables for this process instance * * @param options - Optional options including parentElementId to filter by parent element * @returns Promise resolving to variables response with elements and globals */ getVariables(options?: ProcessInstanceGetVariablesOptions): Promise; } type ProcessInstanceGetResponse = RawProcessInstanceGetResponse & ProcessInstanceMethods; /** * Creates an actionable process instance by combining API process instance data with operational methods. * * @param instanceData - The process instance data from API * @param service - The process instance service instance * @returns A process instance object with added methods */ declare function createProcessInstanceWithMethods(instanceData: RawProcessInstanceGetResponse, service: ProcessInstancesServiceModel): ProcessInstanceGetResponse; /** * Service for managing UiPath Maestro Process incidents * * Maestro Process incidents helps you identify, investigate, and resolve errors that occur during process execution. [UiPath Maestro Process Incidents Guide](https://docs.uipath.com/maestro/automation-cloud/latest/user-guide/all-incidents-view) */ interface ProcessIncidentsServiceModel { /** * Get all process incidents across all folders * * @returns Promise resolving to array of process incident * {@link ProcessIncidentGetAllResponse} * @example * ```typescript * import { ProcessIncidents } from '@uipath/uipath-typescript/maestro-processes'; * * const processIncidents = new ProcessIncidents(sdk); * * // Get all process incidents across all folders * const incidents = await processIncidents.getAll(); * * // Access process incident information * for (const incident of incidents) { * console.log(`Process: ${incident.processKey}`); * console.log(`Error: ${incident.errorMessage}`); * console.log(`Count: ${incident.count}`); * console.log(`First occurrence: ${incident.firstOccuranceTime}`); * } * ``` */ getAll(): Promise; } /** * Pagination types supported by the SDK */ declare enum PaginationType { OFFSET = "offset", TOKEN = "token" } /** * Interface for service access methods needed by pagination helpers */ interface PaginationServiceAccess { get(path: string, options?: any): Promise<{ data: T; }>; post(path: string, body?: any, options?: any): Promise<{ data: T; }>; requestWithPagination(method: string, path: string, paginationOptions: PaginationOptions, options: RequestWithPaginationOptions): Promise>; } /** * Field names for extracting data from paginated responses. */ interface PaginationFieldNames { itemsField?: string; totalCountField?: string; continuationTokenField?: string; } /** * Options for the requestWithPagination method in BaseService. */ interface RequestWithPaginationOptions extends RequestSpec { pagination: PaginationFieldNames & { paginationType: PaginationType; paginationParams?: { pageSizeParam?: string; offsetParam?: string; tokenParam?: string; countParam?: string; convertToSkip?: boolean; zeroBased?: boolean; }; }; } /** * HTTP methods supported by the API client */ type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS'; /** * Supported response types for API requests */ type ResponseType = 'json' | 'text' | 'blob' | 'arraybuffer' | 'stream'; /** * Query parameters type with support for arrays and nested objects */ type QueryParams = Record | null | undefined>; /** * Standard HTTP headers type */ type Headers = Record; /** * Options for request retries */ interface RetryOptions { /** Maximum number of retry attempts */ maxRetries?: number; /** Base delay between retries in milliseconds */ retryDelay?: number; /** Whether to use exponential backoff */ useExponentialBackoff?: boolean; /** Status codes that should trigger a retry */ retryableStatusCodes?: number[]; } /** * Options for request timeouts */ interface TimeoutOptions { /** Request timeout in milliseconds */ timeout?: number; /** Whether to abort the request on timeout */ abortOnTimeout?: boolean; } /** * Options for request body transformation */ interface BodyOptions { /** Whether to stringify the body */ stringify?: boolean; /** Content type override */ contentType?: string; } /** * Pagination metadata for API requests */ interface PaginationMetadata { /** Type of pagination used by the API endpoint */ paginationType: PaginationType; /** Response field containing items array (defaults to 'value') */ itemsField?: string; /** Response field containing total count (defaults to '@odata.count') */ totalCountField?: string; /** Response field containing continuation token (defaults to 'continuationToken') */ continuationTokenField?: string; } /** * Base interface for all API requests */ interface RequestSpec { /** HTTP method for the request */ method?: HttpMethod; /** URL endpoint for the request */ url?: string; /** Query parameters to be appended to the URL */ params?: QueryParams; /** HTTP headers to include with the request */ headers?: Headers; /** Raw body content (takes precedence over data) */ body?: unknown; /** Expected response type */ responseType?: ResponseType; /** Request timeout options */ timeoutOptions?: TimeoutOptions; /** Retry behavior options */ retryOptions?: RetryOptions; /** Body transformation options */ bodyOptions?: BodyOptions; /** AbortSignal for cancelling the request */ signal?: AbortSignal; /** Pagination metadata for the request */ pagination?: PaginationMetadata; } interface ApiResponse { data: T; } /** * Base class for all UiPath SDK services. * * Provides common functionality for authentication, configuration, and API communication. * All service classes extend this base to inherit dependency injection and HTTP client access. * * This class implements the dependency injection pattern where services receive a configured * UiPath instance. The ApiClient is created internally and handles all HTTP operations * including authentication token management. * * @remarks * Service classes should extend this base and call `super(uiPath)` in their constructor. * Protected HTTP methods (get, post, put, patch, delete) are available to all subclasses. * */ declare class BaseService { #private; /** * SDK configuration (read-only). Available to subclasses so they can * fall back to init-time defaults like `folderKey`. */ protected readonly config: { folderKey?: string; }; /** * Creates a base service instance with dependency injection. * * Extracts configuration, execution context, and token manager from the UiPath instance * to initialize an authenticated API client. The ApiClient handles all HTTP operations * and token management internally. * * @param instance - UiPath SDK instance providing authentication and configuration. * Services receive this via dependency injection in the modular pattern. * @param headers - Optional default headers to include in every request (e.g. `x-uipath-external-user-id` for * CAS external-app auth) * * @example * ```typescript * // Services automatically call this via super() * export class EntityService extends BaseService { * constructor(instance: IUiPath) { * super(instance); // Initializes the internal ApiClient * } * } * * // Usage in modular pattern * import { UiPath } from '@uipath/uipath-typescript/core'; * import { Entities } from '@uipath/uipath-typescript/entities'; * * const sdk = new UiPath(config); * await sdk.initialize(); * const entities = new Entities(sdk); * ``` */ constructor(instance: IUiPath, headers?: Record); /** * Gets a valid authentication token, refreshing if necessary. * Use this when you need to manually add Authorization headers (e.g., direct uploads). * * @returns Promise resolving to a valid access token string * @throws AuthenticationError if no token is available or refresh fails */ protected getValidAuthToken(): Promise; /** * Creates a service accessor for pagination helpers * This allows pagination helpers to access protected methods without making them public */ protected createPaginationServiceAccess(): PaginationServiceAccess; protected request(method: string, path: string, options?: RequestSpec): Promise>; protected requestWithSpec(spec: RequestSpec): Promise>; protected get(path: string, options?: RequestSpec): Promise>; protected post(path: string, data?: unknown, options?: RequestSpec): Promise>; protected put(path: string, data?: unknown, options?: RequestSpec): Promise>; protected patch(path: string, data?: unknown, options?: RequestSpec): Promise>; protected delete(path: string, options?: RequestSpec): Promise>; /** * Execute a request with cursor-based pagination */ protected requestWithPagination(method: string, path: string, paginationOptions: PaginationOptions, options: RequestWithPaginationOptions): Promise>; /** * Validates and prepares pagination parameters from options */ private validateAndPreparePaginationParams; /** * Prepares request parameters for pagination based on pagination type */ private preparePaginationRequestParams; /** * Creates a paginated response from API response */ private createPaginatedResponseFromResponse; /** * Determines if there are more pages based on pagination type and metadata */ private determineHasMorePages; } /** * Service for interacting with Maestro Processes */ declare class MaestroProcessesService extends BaseService implements MaestroProcessesServiceModel { private processInstancesService; /** * Creates an instance of the Maestro Processes service. * * @param instance - UiPath SDK instance providing authentication and configuration */ constructor(instance: IUiPath); getAll(options?: MaestroProcessGetAllOptions): Promise; getIncidents(processKey: string, folderKey: string): Promise; getTopRunCount(startTime: Date, endTime: Date, options?: TopQueryOptions): Promise; getTopElementFailedCount(startTime: Date, endTime: Date, options?: TopQueryOptions): Promise; getInstanceStatusTimeline(startTime: Date, endTime: Date, options?: TimelineOptions): Promise; getIncidentsTimeline(startTime: Date, endTime: Date, options?: TimelineOptions): Promise; getTopFaultedCount(startTime: Date, endTime: Date, options?: TopQueryOptions): Promise; getTopExecutionDuration(startTime: Date, endTime: Date, options?: TopQueryOptions): Promise; getElementStats(request: MaestroProcessStatsRequest): Promise; getInstanceStats(request: MaestroProcessStatsRequest): Promise; } declare class ProcessInstancesService extends BaseService implements ProcessInstancesServiceModel { getAll(options?: T): Promise ? PaginatedResponse : NonPaginatedResponse>; getById(id: string, folderKey: string): Promise; getExecutionHistory(instanceId: string, folderKey: string): Promise; private mapSpanToHistory; getBpmn(instanceId: string, folderKey: string): Promise; cancel(instanceId: string, folderKey: string, options?: ProcessInstanceOperationOptions): Promise>; pause(instanceId: string, folderKey: string, options?: ProcessInstanceOperationOptions): Promise>; resume(instanceId: string, folderKey: string, options?: ProcessInstanceOperationOptions): Promise>; retry(instanceId: string, folderKey: string, options?: ProcessInstanceOperationOptions): Promise>; /** * Parses BPMN XML to extract variable metadata from uipath:inputOutput elements * @private * @param bpmnXml The BPMN XML string * @returns Map of variable ID to metadata */ private parseBpmnVariables; /** * Extracts element names from BPMN XML and maps them to their element IDs * @private * @param bpmnXml The BPMN XML string * @returns Map of elementId to element name */ private getVariableSource; /** * Enriches global variables with metadata from BPMN * @private * @param globals The raw globals object from API response * @param variableMetadata The parsed BPMN variable metadata * @returns Array of global variables */ private transformGlobalVariables; getVariables(instanceId: string, folderKey: string, options?: ProcessInstanceGetVariablesOptions): Promise; getIncidents(instanceId: string, folderKey: string): Promise; } /** * Service class for Maestro Process Incidents */ declare class ProcessIncidentsService extends BaseService implements ProcessIncidentsServiceModel { getAll(): Promise; } export { DebugMode, InstanceFinalStatus, MaestroProcessesService as MaestroProcesses, MaestroProcessesService, ProcessIncidentSeverity, ProcessIncidentStatus, ProcessIncidentType, ProcessIncidentsService as ProcessIncidents, ProcessIncidentsService, ProcessInstancesService as ProcessInstances, ProcessInstancesService, TimeInterval, createProcessInstanceWithMethods, createProcessWithMethods }; export type { BpmnXmlString, DurationStats, ElementGetTopFailedCountResponse, ElementMetaData, ElementStats, GetTopBaseResponse, GetTopDurationResponse, GetTopFaultedCountResponse, GetTopRunCountResponse, GlobalVariableMetaData, IncidentTimelineResponse, InstanceStats, InstanceStatusTimelineResponse, MaestroProcessGetAllOptions, MaestroProcessGetAllResponse, MaestroProcessStatsRequest, MaestroProcessesServiceModel, ProcessGetTopDurationResponse, ProcessGetTopFaultedCountResponse, ProcessGetTopRunCountResponse, ProcessIncidentGetAllResponse, ProcessIncidentGetResponse, ProcessIncidentsServiceModel, ProcessInstanceExecutionHistoryResponse, ProcessInstanceGetAllOptions, ProcessInstanceGetAllWithPaginationOptions, ProcessInstanceGetResponse, ProcessInstanceGetVariablesOptions, ProcessInstanceGetVariablesResponse, ProcessInstanceMethods, ProcessInstanceOperationOptions, ProcessInstanceOperationResponse, ProcessInstanceRun, ProcessInstancesServiceModel, ProcessMethods, RawMaestroProcessGetAllResponse, RawProcessInstanceGetResponse, TimelineOptions, TopQueryOptions };