import { IUiPath } from '../core/index'; /** * 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; }); /** * 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; } /** * Common enum for job state used across services */ declare enum JobState { Pending = "Pending", Running = "Running", Stopping = "Stopping", Terminating = "Terminating", Faulted = "Faulted", Successful = "Successful", Stopped = "Stopped", Suspended = "Suspended", Resumed = "Resumed", Cancelled = "Cancelled", /** Server-side fallback for an unrecognized or missing job state. */ Unknown = "Unknown" } interface BaseOptions { expand?: string; select?: string; } /** * Common request options interface used across services for querying data */ interface RequestOptions extends BaseOptions { filter?: string; orderby?: string; } /** * Options that scope a name-based lookup (e.g. `getByName`) to a folder. * Provide one of `folderId`, `folderKey`, or `folderPath`. When more than * one is supplied, all are forwarded; the server applies precedence * `folderPath` > `folderKey` > `folderId`. */ interface FolderScopedOptions extends BaseOptions { /** Numeric folder ID. */ folderId?: number; /** Folder key (GUID-formatted string). */ folderKey?: string; /** Slash-delimited folder path, e.g. `'Shared/Finance'`. */ folderPath?: string; } /** * Type for field mapping configuration * Maps source field names to target field names */ type FieldMapping = { [sourceField: string]: string; }; /** * Base service for services that need folder-specific functionality. * * Extends BaseService with additional methods for working with folder-scoped resources * in UiPath Orchestrator. Services that work with folders (Assets, Queues) extend this class. * * @remarks * This class provides helper methods for making folder-scoped API calls, handling folder IDs * in request headers, and managing cross-folder queries. */ declare class FolderScopedService extends BaseService { /** * Gets resources in a folder with optional query parameters * * @param endpoint - API endpoint to call * @param folderId - required folder ID * @param options - Query options * @param transformFn - Optional function to transform the response data * @returns Promise resolving to an array of resources */ protected _getByFolder(endpoint: string, folderId: number, options?: Record, transformFn?: (item: T) => R): Promise; /** * Look up a single resource by name on a folder-scoped OData collection. * * Shared by `getByName` implementations across services (Assets, Processes, etc). * Handles: * - Name validation via `validateName` * - Folder header resolution via `resolveFolderHeaders` (folderId → ID/key * header by type, folderPath → encoded path header, falls back to * init-time `config.folderKey` from the `uipath:folder-key` meta tag) * - OData `$filter=Name eq '…'` with single-quote escaping + `$top=1` * - Empty-result → `NotFoundError` with folder context in the message * * The transform step is caller-provided because each resource has its own * PascalCase → camelCase field mapping. * * @param resourceType - Resource label used in validation + error messages (e.g. 'Asset', 'Process') * @param endpoint - Folder-scoped OData collection endpoint * @param name - Resource name to search for * @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`) + OData query options (`expand`, `select`) * @param transform - Maps a raw OData item to the typed response (e.g. PascalCase → camelCase via field map) * @param responseFieldMap - Optional response field map (API → SDK), reversed internally by * `transformOptions` to rewrite SDK field names back to API names in user-supplied * `expand` / `select` (symmetric counterpart to `transform`) * @throws ValidationError when inputs are malformed; NotFoundError when no match */ protected getByNameLookup(resourceType: string, endpoint: string, name: string, options: FolderScopedOptions, transform: (raw: TRaw) => T, responseFieldMap?: FieldMapping): Promise; } /** * Enum for package types */ declare enum PackageType { Undefined = "Undefined", Process = "Process", ProcessOrchestration = "ProcessOrchestration", WebApp = "WebApp", Agent = "Agent", TestAutomationProcess = "TestAutomationProcess", Api = "Api", MCPServer = "MCPServer", BusinessRules = "BusinessRules", CaseManagement = "CaseManagement", Flow = "Flow", Function = "Function" } /** * Enum for job priority */ declare enum JobPriority { Low = "Low", Normal = "Normal", High = "High" } /** * Enum for remote control access */ declare enum RemoteControlAccess { None = "None", ReadOnly = "ReadOnly", Full = "Full" } /** * Enum for job source type */ declare enum JobSourceType { Manual = "Manual", Schedule = "Schedule", Agent = "Agent", Queue = "Queue", StudioWeb = "StudioWeb", IntegrationTrigger = "IntegrationTrigger", StudioDesktop = "StudioDesktop", AutomationOpsPipelines = "AutomationOpsPipelines", Apps = "Apps", SAP = "SAP", HttpTrigger = "HttpTrigger", HttpTriggerCallback = "HttpTriggerCallback", RobotAPI = "RobotAPI", CommandLine = "CommandLine", RobotNetAPI = "RobotNetAPI", Autopilot = "Autopilot", TestManager = "TestManager", AgentService = "AgentService", ProcessOrchestration = "ProcessOrchestration", PluginEcosystem = "PluginEcosystem", PerformanceTesting = "PerformanceTesting", AgentHub = "AgentHub", ApiWorkflow = "ApiWorkflow", CaseManagement = "CaseManagement" } /** * Enum for stop strategy */ declare enum StopStrategy { SoftStop = "SoftStop", Kill = "Kill" } /** * Enum for runtime type */ declare enum RuntimeType { NonProduction = "NonProduction", Attended = "Attended", Unattended = "Unattended", Development = "Development", Studio = "Studio", RpaDeveloper = "RpaDeveloper", StudioX = "StudioX", CitizenDeveloper = "CitizenDeveloper", Headless = "Headless", StudioPro = "StudioPro", RpaDeveloperPro = "RpaDeveloperPro", TestAutomation = "TestAutomation", AutomationCloud = "AutomationCloud", Serverless = "Serverless", AutomationKit = "AutomationKit", ServerlessTestAutomation = "ServerlessTestAutomation", AutomationCloudTestAutomation = "AutomationCloudTestAutomation", AttendedStudioWeb = "AttendedStudioWeb", Hosting = "Hosting", AssistantWeb = "AssistantWeb", ProcessOrchestration = "ProcessOrchestration", AgentService = "AgentService", AppTest = "AppTest", PerformanceTest = "PerformanceTest", BusinessRule = "BusinessRule", CaseManagement = "CaseManagement", Flow = "Flow" } /** * Interface for common folder properties */ interface FolderProperties { folderId: number; folderName: string | null; } /** * Interface for robot metadata */ interface RobotMetadata { id: number; name?: string; username?: string; } /** * Interface for machine */ interface Machine { id: number; name?: string; } /** * Interface for job error */ interface JobError { code?: string; title?: string; detail?: string; category?: string; status?: number; timestamp?: string; } /** * Enum for job type */ declare enum JobType { Unattended = "Unattended", Attended = "Attended", ServerlessGeneric = "ServerlessGeneric" } /** * Enum for job sub-state */ declare enum JobSubState { WithFaults = "WITH_FAULTS", Manually = "MANUALLY" } /** * Enum for serverless job type */ declare enum ServerlessJobType { RobotJob = "RobotJob", WebApp = "WebApp", LoadTest = "LoadTest", StudioWebDesigner = "StudioWebDesigner", PublishStudioProject = "PublishStudioProject", JsApi = "JsApi", PythonCodedAgent = "PythonCodedAgent", MCPServer = "MCPServer", PythonCodedSystemAgent = "PythonCodedSystemAgent", PythonAgent = "PythonAgent" } /** * Interface for process metadata associated with a job. * Represents a lightweight summary of the process (release) linked to a job. * Available when using 'expand: "release"' in the query. */ interface ProcessMetadata { /** The unique key of the release */ key?: string; /** The process key identifying the package */ processKey?: string; /** The version of the process package */ processVersion?: string; /** Whether this is the latest version of the process */ isLatestVersion?: boolean; /** The display name of the process */ name?: string; /** The numeric ID of the release */ id?: number; } /** * Raw job response from the API before method attachment */ interface RawJobGetResponse extends FolderProperties { /** The unique numeric identifier of the job */ id: number; /** The unique job identifier (GUID) */ key: string; /** The current execution state of the job */ state: JobState; /** The date and time when the job was created */ createdTime: string; /** The date and time when the job execution started, or null if the job hasn't started yet */ startTime: string | null; /** The date and time when the job execution ended, or null if the job hasn't ended yet */ endTime: string | null; /** The date and time when the job was last modified */ lastModifiedTime: string | null; /** The date and time when the job was resumed after suspension */ resumeTime: string | null; /** The name of the process (release) associated with the job */ processName: string | null; /** Path to the entry point workflow (XAML) that will be executed by the robot */ entryPointPath: string | null; /** The name of the machine where the robot ran the job */ hostMachineName: string | null; /** Input parameters as a JSON string passed to job execution */ inputArguments: string | null; /** Output parameters as a JSON string resulted from job execution */ outputArguments: string | null; /** Attachment key for file-based output when output is too large for inline arguments */ outputFile: string | null; /** Environment variables as a JSON string passed to the job execution */ environmentVariables: string | null; /** Additional information about the current job */ info: string | null; /** The source name of the job, describing how the job was triggered */ source: string | null; /** Reference identifier for the job, used for external correlation */ reference: string | null; /** The execution priority of the job */ jobPriority: JobPriority | null; /** Value for more granular control over execution priority (1-100) */ specificPriorityValue: number | null; /** The type of the job - Attended if started via the robot, Unattended otherwise */ type: JobType; /** The package type of the process associated with the job */ packageType: PackageType; /** The runtime type of the robot which can pick up the job */ runtimeType: RuntimeType | null; /** The source type indicating how the job was triggered */ sourceType: JobSourceType; /** The type of the serverless job, or null for non-serverless jobs */ serverlessJobType: ServerlessJobType | null; /** The stop strategy for the job */ stopStrategy: StopStrategy | null; /** The remote control access level for the job */ remoteControlAccess: RemoteControlAccess; /** The folder key (GUID) of the folder this job is part of */ folderKey: string | null; /** The unique identifier grouping multiple jobs, usually generated when started by a schedule */ batchExecutionKey: string; /** The parent job key (GUID), set when the job was started by another job */ parentJobKey: string | null; /** The ID of the schedule that started the job, or null if started by the user */ startingScheduleId: number | null; /** The starting trigger ID, can be ApiTriggerId or HttpTriggerId */ startingTriggerId: string | null; /** The process version ID */ processVersionId: number | null; /** Expected maximum running time in seconds before the job is flagged */ maxExpectedRunningTimeSeconds: number | null; /** Whether the job requires user interaction */ requiresUserInteraction: boolean; /** If set, the job will resume on the same robot-machine pair on which it initially ran */ resumeOnSameContext: boolean; /** Distinguishes between multiple job suspend/resume cycles */ resumeVersion: number | null; /** The sub-state in which the job is, providing more granular status information */ subState: JobSubState | null; /** The target runtime for the job */ targetRuntime: string | null; /** The trace ID for distributed tracing */ traceId: string | null; /** The parent span ID for distributed tracing */ parentSpanId: string | null; /** The error code associated with a failed job */ errorCode: string | null; /** The machine associated with the job (available when using expand=machine) */ machine?: Machine; /** The robot associated with the job (available when using expand=robot) */ robot?: RobotMetadata; /** The process metadata associated with the job */ process?: ProcessMetadata | null; /** Error details for the job, or null if the job has no errors */ jobError: JobError | null; } /** * Options for resuming a suspended job */ interface JobResumeOptions { /** Input arguments to pass to the resumed job */ inputArguments?: Record; } /** * Options for getting all jobs */ type JobGetAllOptions = RequestOptions & PaginationOptions & { /** * Optional folder ID to filter jobs by folder */ folderId?: number; }; /** * Options for getting a job by ID */ interface JobGetByIdOptions extends BaseOptions { } /** * Options for stopping jobs */ interface JobStopOptions { /** * The stop strategy to use. * - `SoftStop` — requests graceful cancellation; the job completes its current activity before stopping * - `Kill` — requests immediate termination of the job * @default StopStrategy.SoftStop */ strategy?: StopStrategy; } /** Combined response type for job data with bound methods. */ type JobGetResponse = RawJobGetResponse & JobMethods; /** * Service for managing UiPath Orchestrator Jobs. * * Jobs represent the execution of a process (automation) on a UiPath Robot. Each job tracks the lifecycle of a single process run, including its state, timing, input/output arguments, and associated resources. [UiPath Jobs Guide](https://docs.uipath.com/orchestrator/automation-cloud/latest/user-guide/about-jobs) * * ### Usage * * Prerequisites: Initialize the SDK first - see [Getting Started](/uipath-typescript/getting-started/#import-initialize) * * ```typescript * import { Jobs } from '@uipath/uipath-typescript/jobs'; * * const jobs = new Jobs(sdk); * const allJobs = await jobs.getAll(); * ``` */ interface JobServiceModel { /** * Gets all jobs across folders with optional filtering and pagination. * * Returns jobs with full details including state, timing, and input/output arguments. * Pass `folderId` to scope the query to a specific folder. * * !!! info "Input and output fields are not included in `getAll` responses" * The `inputArguments`, `inputFile`, `outputArguments`, and `outputFile` fields will always be `null` in the `getAll` response. To retrieve a job's output, use the {@link getOutput} method with the job's `key` and `folderId`. * * @param options - Query options including optional folderId, filtering, and pagination options * @returns Promise resolving to either an array of jobs {@link NonPaginatedResponse}<{@link JobGetResponse}> or a {@link PaginatedResponse}<{@link JobGetResponse}> when pagination options are used. * {@link JobGetResponse} * @example * ```typescript * // Get all jobs * const allJobs = await jobs.getAll(); * * // Get all jobs in a specific folder * const folderJobs = await jobs.getAll({ folderId: }); * * // With filtering * const recentInvoiceJobs = await jobs.getAll({ * filter: "processName eq 'InvoiceBot'", * orderby: 'createdTime desc', * }); * * // First page with pagination * const page1 = await jobs.getAll({ pageSize: 10 }); * * // Navigate using cursor * if (page1.hasNextPage) { * const page2 = await jobs.getAll({ cursor: page1.nextCursor }); * } * * // Jump to specific page * const page5 = await jobs.getAll({ * jumpToPage: 5, * pageSize: 10 * }); * ``` */ getAll(options?: T): Promise ? PaginatedResponse : NonPaginatedResponse>; /** * Gets a job by its unique key (GUID). * * Returns the full job details including state, timing, input/output arguments, and error information. * Use `expand` to include related entities like `robot`, or `machine`. * * @param id - The unique key (GUID) of the job to retrieve * @param folderId - The folder ID where the job resides * @param options - Optional query options for expanding or selecting fields * @returns Promise resolving to a {@link JobGetResponse} with full job details and bound methods * * @example * ```typescript * // Get a job by key * const job = await jobs.getById(, ); * console.log(job.state, job.processName); * ``` * * @example * ```typescript * // With expanded related entities * const job = await jobs.getById(, , { * expand: 'robot,machine' * }); * console.log(job.robot?.name, job.machine?.name); * ``` */ getById(id: string, folderId: number, options?: JobGetByIdOptions): Promise; /** * Gets the output of a completed job. * * Retrieves the job's output arguments, handling both inline output (stored directly on the job * as a JSON string in `outputArguments`) and file-based output (stored as a blob attachment for * large outputs). Returns the parsed JSON output or `null` if the job has no output. * * @param jobKey - The unique key (GUID) of the job to retrieve output from * @param folderId - The folder ID where the job resides * @returns Promise resolving to the parsed output as `Record`, or `null` if no output exists * * @example * ```typescript * // Get output from a completed job * const output = await jobs.getOutput(, ); * * if (output) { * console.log('Job output:', output); * } * ``` * * @example * ```typescript * // Get output using bound method (jobKey and folderId are taken from the job object) * const allJobs = await jobs.getAll(); * const completedJob = allJobs.items.find(j => j.state === JobState.Successful); * * if (completedJob) { * const output = await completedJob.getOutput(); * } * ``` */ getOutput(jobKey: string, folderId: number): Promise | null>; /** * Stops one or more jobs by their UUID keys. * * Sends a stop request for the specified jobs to the Orchestrator. Throws if any keys cannot be resolved. * * @param jobKeys - Array of job UUID keys to stop (e.g., from {@link JobGetResponse}.key) * @param folderId - The folder ID where the jobs reside (required) * @param options - Optional {@link JobStopOptions} including stop strategy * @returns Promise that resolves when the jobs are stopped successfully, or rejects on failure * * @example * ```typescript * // Stop a single job with default soft stop * await jobs.stop([], ); * ``` * * @example * ```typescript * import { StopStrategy } from '@uipath/uipath-typescript/jobs'; * * // Force-kill multiple jobs * await jobs.stop( * [, ], * , * { strategy: StopStrategy.Kill } * ); * ``` */ stop(jobKeys: string[], folderId: number, options?: JobStopOptions): Promise; /** * Resumes a suspended job. * * Sends a resume request to a job that is currently in the `Suspended` state. * The job transitions to `Resumed` and then to `Running` as it continues execution. Optionally pass * input arguments to provide data for the resumed workflow. * * @param jobKey - The unique key (GUID) of the suspended job to resume * @param folderId - The folder ID where the job resides * @param options - Optional parameters including input arguments * @returns Promise that resolves when the job is resumed successfully, or rejects on failure * * @example * ```typescript * // Resume a suspended job * await jobs.resume(, ); * ``` * * @example * ```typescript * // Resume with input arguments * await jobs.resume(, , { * inputArguments: { approved: true } * }); * ``` */ resume(jobKey: string, folderId: number, options?: JobResumeOptions): Promise; /** * Restarts a job in a final state (Successful, Faulted, or Stopped). * * Creates a **new** job execution from a previously successful, faulted, or stopped job. * The new job has its own unique `key`, starts in `Pending` state, and uses * the same process and input arguments as the original job. * * To monitor the new job's progress, poll with {@link getById} * using the returned job's key until the state reaches a final value. * * @param jobKey - The unique key (GUID) of the job to restart * @param folderId - The folder ID where the job resides * @returns Promise resolving to the new {@link JobGetResponse} with full job details * * @example * ```typescript * // Restart a faulted job * const newJob = await jobs.restart(, ); * console.log(newJob.state); // 'Pending' * console.log(newJob.key); // new job key (different from original) * ``` */ restart(jobKey: string, folderId: number): Promise; } /** * Methods available on job response objects. * These are bound to the job data and delegate to the service. */ interface JobMethods { /** * Gets the output of this job. * * Retrieves the job's output arguments, handling both inline output (stored directly on the job * as a JSON string in `outputArguments`) and file-based output (stored as a blob attachment for * large outputs). Returns the parsed JSON output or `null` if the job has no output. * * @returns Promise resolving to the parsed output as `Record`, or `null` if no output exists * * @example * ```typescript * const allJobs = await jobs.getAll(); * const completedJob = allJobs.items.find(j => j.state === JobState.Successful); * * if (completedJob) { * const output = await completedJob.getOutput(); * } * ``` */ getOutput(): Promise | null>; /** * Stops this job. * * Sends a stop request for this job to the Orchestrator. * * @param options - Optional {@link JobStopOptions} including stop strategy (defaults to SoftStop) * @returns Promise that resolves when the jobs are stopped successfully, or rejects on failure * * @example * ```typescript * const allJobs = await jobs.getAll({ folderId: }); * const runningJob = allJobs.items.find(j => j.state === JobState.Running); * * if (runningJob) { * await runningJob.stop(); * } * ``` */ stop(options?: JobStopOptions): Promise; /** * Resumes this suspended job. * * @param options - Optional parameters including input arguments * @returns Promise that resolves when the job is resumed successfully, or rejects on failure */ resume(options?: JobResumeOptions): Promise; /** * Restarts this job, creating a new execution with a new key. * * @returns Promise resolving to the new {@link JobGetResponse} with full job details */ restart(): Promise; } /** * Creates a job response with bound methods. * * @param jobData - The raw job data from API * @param service - The job service instance * @returns A job object with added methods */ declare function createJobWithMethods(jobData: RawJobGetResponse, service: JobServiceModel): JobGetResponse; /** * Service for interacting with UiPath Orchestrator Jobs API */ declare class JobService extends FolderScopedService implements JobServiceModel { private attachmentService; /** * Creates an instance of the Jobs service. * * @param instance - UiPath SDK instance providing authentication and configuration */ constructor(instance: IUiPath); getAll(options?: T): Promise ? PaginatedResponse : NonPaginatedResponse>; getById(id: string, folderId: number, options?: JobGetByIdOptions): Promise; getOutput(jobKey: string, folderId: number): Promise | null>; stop(jobKeys: string[], folderId: number, options?: JobStopOptions): Promise; resume(jobKey: string, folderId: number, options?: JobResumeOptions): Promise; restart(jobKey: string, folderId: number): Promise; /** * Downloads the output file content via the Attachments API. * 1. Fetches blob access info from the attachment using AttachmentService * 2. Downloads content from the presigned blob URI * 3. Parses and returns the JSON content */ private downloadOutputFile; /** * Resolves job UUID keys to integer IDs via the getAll method. * Chunks keys into batches to avoid URL length limits. */ private resolveJobKeys; /** * Calls the StopJobs OData action with resolved integer IDs. */ private stopJobsByIds; } export { JobService, JobState, JobSubState, JobService as Jobs, ServerlessJobType, StopStrategy, createJobWithMethods }; export type { JobGetAllOptions, JobGetByIdOptions, JobGetResponse, JobMethods, JobResumeOptions, JobServiceModel, JobStopOptions, ProcessMetadata, RawJobGetResponse };