@uipath/uipath-typescript 1.3.2 → 1.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/index.cjs +21 -8
- package/dist/assets/index.mjs +21 -8
- package/dist/attachments/index.cjs +21 -8
- package/dist/attachments/index.mjs +21 -8
- package/dist/buckets/index.cjs +21 -8
- package/dist/buckets/index.mjs +21 -8
- package/dist/cases/index.cjs +41 -13
- package/dist/cases/index.d.ts +15 -0
- package/dist/cases/index.mjs +41 -13
- package/dist/conversational-agent/index.cjs +39 -8
- package/dist/conversational-agent/index.d.ts +55 -2
- package/dist/conversational-agent/index.mjs +39 -8
- package/dist/core/index.cjs +16 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.mjs +16 -1
- package/dist/entities/index.cjs +55 -8
- package/dist/entities/index.d.ts +54 -0
- package/dist/entities/index.mjs +55 -8
- package/dist/feedback/index.cjs +1911 -0
- package/dist/feedback/index.d.ts +475 -0
- package/dist/feedback/index.mjs +1909 -0
- package/dist/index.cjs +451 -189
- package/dist/index.d.ts +388 -13
- package/dist/index.mjs +452 -190
- package/dist/index.umd.js +451 -189
- package/dist/jobs/index.cjs +384 -8
- package/dist/jobs/index.d.ts +220 -2
- package/dist/jobs/index.mjs +385 -9
- package/dist/maestro-processes/index.cjs +21 -8
- package/dist/maestro-processes/index.mjs +21 -8
- package/dist/processes/index.cjs +21 -8
- package/dist/processes/index.mjs +21 -8
- package/dist/queues/index.cjs +21 -8
- package/dist/queues/index.mjs +21 -8
- package/dist/tasks/index.cjs +41 -13
- package/dist/tasks/index.d.ts +25 -10
- package/dist/tasks/index.mjs +42 -14
- package/package.json +13 -2
package/dist/jobs/index.cjs
CHANGED
|
@@ -506,6 +506,8 @@ class ErrorFactory {
|
|
|
506
506
|
}
|
|
507
507
|
|
|
508
508
|
const FOLDER_ID = 'X-UIPATH-OrganizationUnitId';
|
|
509
|
+
const TRACEPARENT = 'traceparent';
|
|
510
|
+
const UIPATH_TRACEPARENT_ID = 'x-uipath-traceparent-id';
|
|
509
511
|
/**
|
|
510
512
|
* Content type constants for HTTP requests/responses
|
|
511
513
|
*/
|
|
@@ -559,8 +561,13 @@ class ApiClient {
|
|
|
559
561
|
if (isFormData) {
|
|
560
562
|
delete defaultHeaders['Content-Type'];
|
|
561
563
|
}
|
|
564
|
+
const traceId = crypto.randomUUID().replace(/-/g, '');
|
|
565
|
+
const spanId = crypto.randomUUID().replace(/-/g, '').slice(0, 16);
|
|
566
|
+
const traceparentValue = `00-${traceId}-${spanId}-01`;
|
|
562
567
|
const headers = {
|
|
563
568
|
...defaultHeaders,
|
|
569
|
+
[TRACEPARENT]: traceparentValue,
|
|
570
|
+
[UIPATH_TRACEPARENT_ID]: traceparentValue,
|
|
564
571
|
...options.headers
|
|
565
572
|
};
|
|
566
573
|
// Convert params to URLSearchParams
|
|
@@ -600,7 +607,11 @@ class ApiClient {
|
|
|
600
607
|
const text = await response.text();
|
|
601
608
|
return text;
|
|
602
609
|
}
|
|
603
|
-
|
|
610
|
+
const text = await response.text();
|
|
611
|
+
if (!text) {
|
|
612
|
+
return undefined;
|
|
613
|
+
}
|
|
614
|
+
return JSON.parse(text);
|
|
604
615
|
}
|
|
605
616
|
catch (error) {
|
|
606
617
|
// If it's already one of our errors, re-throw it
|
|
@@ -1232,8 +1243,9 @@ class PaginationHelpers {
|
|
|
1232
1243
|
});
|
|
1233
1244
|
}
|
|
1234
1245
|
// Extract and transform items from response
|
|
1235
|
-
|
|
1236
|
-
const
|
|
1246
|
+
// Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
|
|
1247
|
+
const rawItems = Array.isArray(response.data) ? response.data : response.data?.[itemsField];
|
|
1248
|
+
const totalCount = Array.isArray(response.data) ? undefined : response.data?.[totalCountField];
|
|
1237
1249
|
// Parse items - automatically handle JSON string responses
|
|
1238
1250
|
const parsedItems = typeof rawItems === 'string' ? JSON.parse(rawItems) : (rawItems || []);
|
|
1239
1251
|
const items = transformFn ? parsedItems.map(transformFn) : parsedItems;
|
|
@@ -1484,7 +1496,7 @@ class BaseService {
|
|
|
1484
1496
|
const params = this.validateAndPreparePaginationParams(paginationType, paginationOptions);
|
|
1485
1497
|
// Prepare request parameters based on pagination type
|
|
1486
1498
|
const requestParams = this.preparePaginationRequestParams(paginationType, params, options.pagination);
|
|
1487
|
-
// For POST requests, merge pagination params into body; for GET, use query params
|
|
1499
|
+
// For POST requests, merge pagination params into body and set params to undefined; for GET, use query params
|
|
1488
1500
|
if (method.toUpperCase() === 'POST') {
|
|
1489
1501
|
const existingBody = (options.body && typeof options.body === 'object') ? options.body : {};
|
|
1490
1502
|
options.body = {
|
|
@@ -1492,6 +1504,7 @@ class BaseService {
|
|
|
1492
1504
|
...options.params,
|
|
1493
1505
|
...requestParams
|
|
1494
1506
|
};
|
|
1507
|
+
options.params = undefined;
|
|
1495
1508
|
}
|
|
1496
1509
|
else {
|
|
1497
1510
|
// Merge pagination parameters with existing parameters
|
|
@@ -1532,7 +1545,6 @@ class BaseService {
|
|
|
1532
1545
|
if (params.pageNumber && params.pageNumber > 1) {
|
|
1533
1546
|
requestParams[offsetParam] = (params.pageNumber - 1) * limitedPageSize;
|
|
1534
1547
|
}
|
|
1535
|
-
// Include total count for ODATA APIs
|
|
1536
1548
|
{
|
|
1537
1549
|
requestParams[countParam] = true;
|
|
1538
1550
|
}
|
|
@@ -1560,8 +1572,9 @@ class BaseService {
|
|
|
1560
1572
|
const totalCountField = fields.totalCountField || 'totalRecordCount';
|
|
1561
1573
|
const continuationTokenField = fields.continuationTokenField || 'continuationToken';
|
|
1562
1574
|
// Extract items and metadata
|
|
1563
|
-
|
|
1564
|
-
const
|
|
1575
|
+
// Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
|
|
1576
|
+
const items = Array.isArray(response.data) ? response.data : (response.data[itemsField] || []);
|
|
1577
|
+
const totalCount = Array.isArray(response.data) ? undefined : response.data[totalCountField];
|
|
1565
1578
|
const continuationToken = response.data[continuationTokenField];
|
|
1566
1579
|
// Determine if there are more pages
|
|
1567
1580
|
const hasMore = this.determineHasMorePages(paginationType, {
|
|
@@ -1657,6 +1670,27 @@ function createJobMethods(jobData, service) {
|
|
|
1657
1670
|
throw new Error('Job folderId is undefined');
|
|
1658
1671
|
return service.getOutput(jobData.key, jobData.folderId);
|
|
1659
1672
|
},
|
|
1673
|
+
async stop(options) {
|
|
1674
|
+
if (!jobData.key)
|
|
1675
|
+
throw new Error('Job key is undefined');
|
|
1676
|
+
if (!jobData.folderId)
|
|
1677
|
+
throw new Error('Job folderId is undefined');
|
|
1678
|
+
return service.stop([jobData.key], jobData.folderId, options);
|
|
1679
|
+
},
|
|
1680
|
+
async resume(options) {
|
|
1681
|
+
if (!jobData.key)
|
|
1682
|
+
throw new Error('Job key is undefined');
|
|
1683
|
+
if (!jobData.folderId)
|
|
1684
|
+
throw new Error('Job folderId is undefined');
|
|
1685
|
+
return service.resume(jobData.key, jobData.folderId, options);
|
|
1686
|
+
},
|
|
1687
|
+
async restart() {
|
|
1688
|
+
if (!jobData.key)
|
|
1689
|
+
throw new Error('Job key is undefined');
|
|
1690
|
+
if (!jobData.folderId)
|
|
1691
|
+
throw new Error('Job folderId is undefined');
|
|
1692
|
+
return service.restart(jobData.key, jobData.folderId);
|
|
1693
|
+
},
|
|
1660
1694
|
};
|
|
1661
1695
|
}
|
|
1662
1696
|
/**
|
|
@@ -1685,6 +1719,9 @@ const ORCHESTRATOR_BASE = 'orchestrator_';
|
|
|
1685
1719
|
const JOB_ENDPOINTS = {
|
|
1686
1720
|
GET_ALL: `${ORCHESTRATOR_BASE}/odata/Jobs`,
|
|
1687
1721
|
GET_BY_KEY: (identifier) => `${ORCHESTRATOR_BASE}/odata/Jobs/UiPath.Server.Configuration.OData.GetByKey(identifier=${identifier})`,
|
|
1722
|
+
STOP: `${ORCHESTRATOR_BASE}/odata/Jobs/UiPath.Server.Configuration.OData.StopJobs`,
|
|
1723
|
+
RESUME: `${ORCHESTRATOR_BASE}/odata/Jobs/UiPath.Server.Configuration.OData.ResumeJob`,
|
|
1724
|
+
RESTART: `${ORCHESTRATOR_BASE}/odata/Jobs/UiPath.Server.Configuration.OData.RestartJob`,
|
|
1688
1725
|
};
|
|
1689
1726
|
/**
|
|
1690
1727
|
* Orchestrator Attachment Service Endpoints
|
|
@@ -1693,6 +1730,8 @@ const ORCHESTRATOR_ATTACHMENT_ENDPOINTS = {
|
|
|
1693
1730
|
GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/Attachments(${id})`,
|
|
1694
1731
|
};
|
|
1695
1732
|
|
|
1733
|
+
/** Maximum number of job keys to resolve in a single OData filter query */
|
|
1734
|
+
const JOB_KEY_RESOLUTION_CHUNK_SIZE = 50;
|
|
1696
1735
|
/**
|
|
1697
1736
|
* Maps fields for Job entities to ensure consistent naming
|
|
1698
1737
|
* Semantic renames only — case conversion handled by pascalToCamelCaseKeys()
|
|
@@ -1714,7 +1753,7 @@ const JobMap = {
|
|
|
1714
1753
|
// Connection string placeholder that will be replaced during build
|
|
1715
1754
|
const CONNECTION_STRING = "InstrumentationKey=a6efa11d-1feb-4508-9738-e13e12dcae5e;IngestionEndpoint=https://westeurope-5.in.applicationinsights.azure.com/;LiveEndpoint=https://westeurope.livediagnostics.monitor.azure.com/;ApplicationId=7c58eb1c-9581-4ba6-839e-11725848a037";
|
|
1716
1755
|
// SDK Version placeholder
|
|
1717
|
-
const SDK_VERSION = "1.3.
|
|
1756
|
+
const SDK_VERSION = "1.3.4";
|
|
1718
1757
|
const VERSION = "Version";
|
|
1719
1758
|
const SERVICE = "Service";
|
|
1720
1759
|
const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
|
|
@@ -2034,6 +2073,182 @@ __decorate([
|
|
|
2034
2073
|
track('Attachments.GetById')
|
|
2035
2074
|
], AttachmentService.prototype, "getById", null);
|
|
2036
2075
|
|
|
2076
|
+
/**
|
|
2077
|
+
* Enum for package types
|
|
2078
|
+
*/
|
|
2079
|
+
var PackageType;
|
|
2080
|
+
(function (PackageType) {
|
|
2081
|
+
PackageType["Undefined"] = "Undefined";
|
|
2082
|
+
PackageType["Process"] = "Process";
|
|
2083
|
+
PackageType["ProcessOrchestration"] = "ProcessOrchestration";
|
|
2084
|
+
PackageType["WebApp"] = "WebApp";
|
|
2085
|
+
PackageType["Agent"] = "Agent";
|
|
2086
|
+
PackageType["TestAutomationProcess"] = "TestAutomationProcess";
|
|
2087
|
+
PackageType["Api"] = "Api";
|
|
2088
|
+
PackageType["MCPServer"] = "MCPServer";
|
|
2089
|
+
PackageType["BusinessRules"] = "BusinessRules";
|
|
2090
|
+
PackageType["CaseManagement"] = "CaseManagement";
|
|
2091
|
+
PackageType["Flow"] = "Flow";
|
|
2092
|
+
PackageType["Function"] = "Function";
|
|
2093
|
+
})(PackageType || (PackageType = {}));
|
|
2094
|
+
/**
|
|
2095
|
+
* Enum for job priority
|
|
2096
|
+
*/
|
|
2097
|
+
var JobPriority;
|
|
2098
|
+
(function (JobPriority) {
|
|
2099
|
+
JobPriority["Low"] = "Low";
|
|
2100
|
+
JobPriority["Normal"] = "Normal";
|
|
2101
|
+
JobPriority["High"] = "High";
|
|
2102
|
+
})(JobPriority || (JobPriority = {}));
|
|
2103
|
+
/**
|
|
2104
|
+
* Enum for target framework
|
|
2105
|
+
*/
|
|
2106
|
+
var TargetFramework;
|
|
2107
|
+
(function (TargetFramework) {
|
|
2108
|
+
TargetFramework["Legacy"] = "Legacy";
|
|
2109
|
+
TargetFramework["Windows"] = "Windows";
|
|
2110
|
+
TargetFramework["Portable"] = "Portable";
|
|
2111
|
+
})(TargetFramework || (TargetFramework = {}));
|
|
2112
|
+
/**
|
|
2113
|
+
* Enum for robot size
|
|
2114
|
+
*/
|
|
2115
|
+
var RobotSize;
|
|
2116
|
+
(function (RobotSize) {
|
|
2117
|
+
RobotSize["Small"] = "Small";
|
|
2118
|
+
RobotSize["Standard"] = "Standard";
|
|
2119
|
+
RobotSize["Medium"] = "Medium";
|
|
2120
|
+
RobotSize["Large"] = "Large";
|
|
2121
|
+
})(RobotSize || (RobotSize = {}));
|
|
2122
|
+
/**
|
|
2123
|
+
* Enum for remote control access
|
|
2124
|
+
*/
|
|
2125
|
+
var RemoteControlAccess;
|
|
2126
|
+
(function (RemoteControlAccess) {
|
|
2127
|
+
RemoteControlAccess["None"] = "None";
|
|
2128
|
+
RemoteControlAccess["ReadOnly"] = "ReadOnly";
|
|
2129
|
+
RemoteControlAccess["Full"] = "Full";
|
|
2130
|
+
})(RemoteControlAccess || (RemoteControlAccess = {}));
|
|
2131
|
+
/**
|
|
2132
|
+
* Enum for process start strategy
|
|
2133
|
+
*/
|
|
2134
|
+
var StartStrategy;
|
|
2135
|
+
(function (StartStrategy) {
|
|
2136
|
+
StartStrategy["All"] = "All";
|
|
2137
|
+
StartStrategy["Specific"] = "Specific";
|
|
2138
|
+
StartStrategy["RobotCount"] = "RobotCount";
|
|
2139
|
+
StartStrategy["JobsCount"] = "JobsCount";
|
|
2140
|
+
StartStrategy["ModernJobsCount"] = "ModernJobsCount";
|
|
2141
|
+
})(StartStrategy || (StartStrategy = {}));
|
|
2142
|
+
/**
|
|
2143
|
+
* Enum for package source type
|
|
2144
|
+
*/
|
|
2145
|
+
var PackageSourceType;
|
|
2146
|
+
(function (PackageSourceType) {
|
|
2147
|
+
PackageSourceType["Manual"] = "Manual";
|
|
2148
|
+
PackageSourceType["Schedule"] = "Schedule";
|
|
2149
|
+
PackageSourceType["Queue"] = "Queue";
|
|
2150
|
+
PackageSourceType["StudioWeb"] = "StudioWeb";
|
|
2151
|
+
PackageSourceType["IntegrationTrigger"] = "IntegrationTrigger";
|
|
2152
|
+
PackageSourceType["StudioDesktop"] = "StudioDesktop";
|
|
2153
|
+
PackageSourceType["AutomationOpsPipelines"] = "AutomationOpsPipelines";
|
|
2154
|
+
PackageSourceType["Apps"] = "Apps";
|
|
2155
|
+
PackageSourceType["SAP"] = "SAP";
|
|
2156
|
+
PackageSourceType["HttpTrigger"] = "HttpTrigger";
|
|
2157
|
+
PackageSourceType["HttpTriggerWithCallback"] = "HttpTriggerWithCallback";
|
|
2158
|
+
PackageSourceType["RobotAPI"] = "RobotAPI";
|
|
2159
|
+
PackageSourceType["Assistant"] = "Assistant";
|
|
2160
|
+
PackageSourceType["CommandLine"] = "CommandLine";
|
|
2161
|
+
PackageSourceType["RobotNetAPI"] = "RobotNetAPI";
|
|
2162
|
+
PackageSourceType["Autopilot"] = "Autopilot";
|
|
2163
|
+
PackageSourceType["TestManager"] = "TestManager";
|
|
2164
|
+
PackageSourceType["AgentService"] = "AgentService";
|
|
2165
|
+
PackageSourceType["ProcessOrchestration"] = "ProcessOrchestration";
|
|
2166
|
+
PackageSourceType["PluginEcosystem"] = "PluginEcosystem";
|
|
2167
|
+
PackageSourceType["PerformanceTesting"] = "PerformanceTesting";
|
|
2168
|
+
PackageSourceType["AgentHub"] = "AgentHub";
|
|
2169
|
+
PackageSourceType["ApiWorkflow"] = "ApiWorkflow";
|
|
2170
|
+
})(PackageSourceType || (PackageSourceType = {}));
|
|
2171
|
+
/**
|
|
2172
|
+
* Enum for job source type
|
|
2173
|
+
*/
|
|
2174
|
+
var JobSourceType;
|
|
2175
|
+
(function (JobSourceType) {
|
|
2176
|
+
JobSourceType["Manual"] = "Manual";
|
|
2177
|
+
JobSourceType["Schedule"] = "Schedule";
|
|
2178
|
+
JobSourceType["Agent"] = "Agent";
|
|
2179
|
+
JobSourceType["Queue"] = "Queue";
|
|
2180
|
+
JobSourceType["StudioWeb"] = "StudioWeb";
|
|
2181
|
+
JobSourceType["IntegrationTrigger"] = "IntegrationTrigger";
|
|
2182
|
+
JobSourceType["StudioDesktop"] = "StudioDesktop";
|
|
2183
|
+
JobSourceType["AutomationOpsPipelines"] = "AutomationOpsPipelines";
|
|
2184
|
+
JobSourceType["Apps"] = "Apps";
|
|
2185
|
+
JobSourceType["SAP"] = "SAP";
|
|
2186
|
+
JobSourceType["HttpTrigger"] = "HttpTrigger";
|
|
2187
|
+
JobSourceType["HttpTriggerCallback"] = "HttpTriggerCallback";
|
|
2188
|
+
JobSourceType["RobotAPI"] = "RobotAPI";
|
|
2189
|
+
JobSourceType["CommandLine"] = "CommandLine";
|
|
2190
|
+
JobSourceType["RobotNetAPI"] = "RobotNetAPI";
|
|
2191
|
+
JobSourceType["Autopilot"] = "Autopilot";
|
|
2192
|
+
JobSourceType["TestManager"] = "TestManager";
|
|
2193
|
+
JobSourceType["AgentService"] = "AgentService";
|
|
2194
|
+
JobSourceType["ProcessOrchestration"] = "ProcessOrchestration";
|
|
2195
|
+
JobSourceType["PluginEcosystem"] = "PluginEcosystem";
|
|
2196
|
+
JobSourceType["PerformanceTesting"] = "PerformanceTesting";
|
|
2197
|
+
JobSourceType["AgentHub"] = "AgentHub";
|
|
2198
|
+
JobSourceType["ApiWorkflow"] = "ApiWorkflow";
|
|
2199
|
+
JobSourceType["CaseManagement"] = "CaseManagement";
|
|
2200
|
+
})(JobSourceType || (JobSourceType = {}));
|
|
2201
|
+
/**
|
|
2202
|
+
* Enum for stop strategy
|
|
2203
|
+
*/
|
|
2204
|
+
exports.StopStrategy = void 0;
|
|
2205
|
+
(function (StopStrategy) {
|
|
2206
|
+
StopStrategy["SoftStop"] = "SoftStop";
|
|
2207
|
+
StopStrategy["Kill"] = "Kill";
|
|
2208
|
+
})(exports.StopStrategy || (exports.StopStrategy = {}));
|
|
2209
|
+
/**
|
|
2210
|
+
* Enum for runtime type
|
|
2211
|
+
*/
|
|
2212
|
+
var RuntimeType;
|
|
2213
|
+
(function (RuntimeType) {
|
|
2214
|
+
RuntimeType["NonProduction"] = "NonProduction";
|
|
2215
|
+
RuntimeType["Attended"] = "Attended";
|
|
2216
|
+
RuntimeType["Unattended"] = "Unattended";
|
|
2217
|
+
RuntimeType["Development"] = "Development";
|
|
2218
|
+
RuntimeType["Studio"] = "Studio";
|
|
2219
|
+
RuntimeType["RpaDeveloper"] = "RpaDeveloper";
|
|
2220
|
+
RuntimeType["StudioX"] = "StudioX";
|
|
2221
|
+
RuntimeType["CitizenDeveloper"] = "CitizenDeveloper";
|
|
2222
|
+
RuntimeType["Headless"] = "Headless";
|
|
2223
|
+
RuntimeType["StudioPro"] = "StudioPro";
|
|
2224
|
+
RuntimeType["RpaDeveloperPro"] = "RpaDeveloperPro";
|
|
2225
|
+
RuntimeType["TestAutomation"] = "TestAutomation";
|
|
2226
|
+
RuntimeType["AutomationCloud"] = "AutomationCloud";
|
|
2227
|
+
RuntimeType["Serverless"] = "Serverless";
|
|
2228
|
+
RuntimeType["AutomationKit"] = "AutomationKit";
|
|
2229
|
+
RuntimeType["ServerlessTestAutomation"] = "ServerlessTestAutomation";
|
|
2230
|
+
RuntimeType["AutomationCloudTestAutomation"] = "AutomationCloudTestAutomation";
|
|
2231
|
+
RuntimeType["AttendedStudioWeb"] = "AttendedStudioWeb";
|
|
2232
|
+
RuntimeType["Hosting"] = "Hosting";
|
|
2233
|
+
RuntimeType["AssistantWeb"] = "AssistantWeb";
|
|
2234
|
+
RuntimeType["ProcessOrchestration"] = "ProcessOrchestration";
|
|
2235
|
+
RuntimeType["AgentService"] = "AgentService";
|
|
2236
|
+
RuntimeType["AppTest"] = "AppTest";
|
|
2237
|
+
RuntimeType["PerformanceTest"] = "PerformanceTest";
|
|
2238
|
+
RuntimeType["BusinessRule"] = "BusinessRule";
|
|
2239
|
+
RuntimeType["CaseManagement"] = "CaseManagement";
|
|
2240
|
+
RuntimeType["Flow"] = "Flow";
|
|
2241
|
+
})(RuntimeType || (RuntimeType = {}));
|
|
2242
|
+
/**
|
|
2243
|
+
* Enum for job type
|
|
2244
|
+
*/
|
|
2245
|
+
var JobType;
|
|
2246
|
+
(function (JobType) {
|
|
2247
|
+
JobType["Unattended"] = "Unattended";
|
|
2248
|
+
JobType["Attended"] = "Attended";
|
|
2249
|
+
JobType["ServerlessGeneric"] = "ServerlessGeneric";
|
|
2250
|
+
})(JobType || (JobType = {}));
|
|
2251
|
+
|
|
2037
2252
|
/**
|
|
2038
2253
|
* Service for interacting with UiPath Orchestrator Jobs API
|
|
2039
2254
|
*/
|
|
@@ -2203,6 +2418,121 @@ class JobService extends FolderScopedService {
|
|
|
2203
2418
|
}
|
|
2204
2419
|
return null;
|
|
2205
2420
|
}
|
|
2421
|
+
/**
|
|
2422
|
+
* Stops one or more jobs by their UUID keys.
|
|
2423
|
+
*
|
|
2424
|
+
* Sends a stop request for the specified jobs to the Orchestrator. Throws if any keys cannot be resolved.
|
|
2425
|
+
*
|
|
2426
|
+
* @param jobKeys - Array of job UUID keys to stop (e.g., from {@link JobGetResponse}.key)
|
|
2427
|
+
* @param folderId - The folder ID where the jobs reside (required)
|
|
2428
|
+
* @param options - Optional {@link JobStopOptions} including stop strategy
|
|
2429
|
+
* @returns Promise that resolves when the jobs are stopped successfully, or rejects on failure
|
|
2430
|
+
*
|
|
2431
|
+
* @example
|
|
2432
|
+
* ```typescript
|
|
2433
|
+
* // Stop a single job with default soft stop
|
|
2434
|
+
* await jobs.stop([<jobKey>], <folderId>);
|
|
2435
|
+
* ```
|
|
2436
|
+
*
|
|
2437
|
+
* @example
|
|
2438
|
+
* ```typescript
|
|
2439
|
+
* import { StopStrategy } from '@uipath/uipath-typescript/jobs';
|
|
2440
|
+
*
|
|
2441
|
+
* // Force-kill multiple jobs
|
|
2442
|
+
* await jobs.stop(
|
|
2443
|
+
* [<jobKey1>, <jobKey2>],
|
|
2444
|
+
* <folderId>,
|
|
2445
|
+
* { strategy: StopStrategy.Kill }
|
|
2446
|
+
* );
|
|
2447
|
+
* ```
|
|
2448
|
+
*/
|
|
2449
|
+
async stop(jobKeys, folderId, options) {
|
|
2450
|
+
if (jobKeys.length === 0) {
|
|
2451
|
+
return;
|
|
2452
|
+
}
|
|
2453
|
+
if (!folderId) {
|
|
2454
|
+
throw new ValidationError({ message: 'folderId is required for stop' });
|
|
2455
|
+
}
|
|
2456
|
+
const headers = createHeaders({ [FOLDER_ID]: folderId });
|
|
2457
|
+
const strategy = options?.strategy ?? exports.StopStrategy.SoftStop;
|
|
2458
|
+
const jobIds = await this.resolveJobKeys(jobKeys, folderId);
|
|
2459
|
+
await this.stopJobsByIds(jobIds, strategy, headers);
|
|
2460
|
+
}
|
|
2461
|
+
/**
|
|
2462
|
+
* Resumes a suspended job.
|
|
2463
|
+
*
|
|
2464
|
+
* Sends a resume request to a job that is currently in the `Suspended` state.
|
|
2465
|
+
* The job transitions to `Resumed` and then to `Running` as it continues execution. Optionally pass
|
|
2466
|
+
* input arguments to provide data for the resumed workflow.
|
|
2467
|
+
*
|
|
2468
|
+
* @param jobKey - The unique key (GUID) of the suspended job to resume
|
|
2469
|
+
* @param folderId - The folder ID where the job resides
|
|
2470
|
+
* @param options - Optional parameters including input arguments
|
|
2471
|
+
* @returns Promise that resolves when the job is resumed successfully, or rejects on failure
|
|
2472
|
+
*
|
|
2473
|
+
* @example
|
|
2474
|
+
* ```typescript
|
|
2475
|
+
* // Resume a suspended job
|
|
2476
|
+
* await jobs.resume(<jobKey>, <folderId>);
|
|
2477
|
+
* ```
|
|
2478
|
+
*
|
|
2479
|
+
* @example
|
|
2480
|
+
* ```typescript
|
|
2481
|
+
* // Resume with input arguments
|
|
2482
|
+
* await jobs.resume(<jobKey>, <folderId>, {
|
|
2483
|
+
* inputArguments: { approved: true }
|
|
2484
|
+
* });
|
|
2485
|
+
* ```
|
|
2486
|
+
*/
|
|
2487
|
+
async resume(jobKey, folderId, options) {
|
|
2488
|
+
if (!jobKey) {
|
|
2489
|
+
throw new ValidationError({ message: 'jobKey is required for resume' });
|
|
2490
|
+
}
|
|
2491
|
+
if (!folderId) {
|
|
2492
|
+
throw new ValidationError({ message: 'folderId is required for resume' });
|
|
2493
|
+
}
|
|
2494
|
+
const headers = createHeaders({ [FOLDER_ID]: folderId });
|
|
2495
|
+
const body = { jobKey };
|
|
2496
|
+
if (options?.inputArguments) {
|
|
2497
|
+
body.inputArguments = JSON.stringify(options.inputArguments);
|
|
2498
|
+
}
|
|
2499
|
+
await this.post(JOB_ENDPOINTS.RESUME, body, { headers });
|
|
2500
|
+
}
|
|
2501
|
+
/**
|
|
2502
|
+
* Restarts a job in a final state (Successful, Faulted, or Stopped).
|
|
2503
|
+
*
|
|
2504
|
+
* Creates a **new** job execution from a previously successful, faulted, or stopped job.
|
|
2505
|
+
* The new job has its own unique `key`, starts in `Pending` state, and uses
|
|
2506
|
+
* the same process and input arguments as the original job.
|
|
2507
|
+
*
|
|
2508
|
+
* To monitor the new job's progress, poll with {@link getById}
|
|
2509
|
+
* using the returned job's key until the state reaches a final value.
|
|
2510
|
+
*
|
|
2511
|
+
* @param jobKey - The unique key (GUID) of the job to restart
|
|
2512
|
+
* @param folderId - The folder ID where the job resides
|
|
2513
|
+
* @returns Promise resolving to the new {@link JobGetResponse} with full job details
|
|
2514
|
+
*
|
|
2515
|
+
* @example
|
|
2516
|
+
* ```typescript
|
|
2517
|
+
* // Restart a faulted job
|
|
2518
|
+
* const newJob = await jobs.restart(<jobKey>, <folderId>);
|
|
2519
|
+
* console.log(newJob.state); // 'Pending'
|
|
2520
|
+
* console.log(newJob.key); // new job key (different from original)
|
|
2521
|
+
* ```
|
|
2522
|
+
*/
|
|
2523
|
+
async restart(jobKey, folderId) {
|
|
2524
|
+
if (!jobKey) {
|
|
2525
|
+
throw new ValidationError({ message: 'jobKey is required for restart' });
|
|
2526
|
+
}
|
|
2527
|
+
if (!folderId) {
|
|
2528
|
+
throw new ValidationError({ message: 'folderId is required for restart' });
|
|
2529
|
+
}
|
|
2530
|
+
const [jobId] = await this.resolveJobKeys([jobKey], folderId);
|
|
2531
|
+
const headers = createHeaders({ [FOLDER_ID]: folderId });
|
|
2532
|
+
const response = await this.post(JOB_ENDPOINTS.RESTART, { jobId }, { headers });
|
|
2533
|
+
const rawJob = transformData(pascalToCamelCaseKeys(response.data), JobMap);
|
|
2534
|
+
return createJobWithMethods(rawJob, this);
|
|
2535
|
+
}
|
|
2206
2536
|
/**
|
|
2207
2537
|
* Downloads the output file content via the Attachments API.
|
|
2208
2538
|
* 1. Fetches blob access info from the attachment using AttachmentService
|
|
@@ -2237,6 +2567,43 @@ class JobService extends FolderScopedService {
|
|
|
2237
2567
|
throw new ServerError({ message: 'Failed to parse job output file as JSON' });
|
|
2238
2568
|
}
|
|
2239
2569
|
}
|
|
2570
|
+
/**
|
|
2571
|
+
* Resolves job UUID keys to integer IDs via the getAll method.
|
|
2572
|
+
* Chunks keys into batches to avoid URL length limits.
|
|
2573
|
+
*/
|
|
2574
|
+
async resolveJobKeys(jobKeys, folderId) {
|
|
2575
|
+
const uniqueKeys = [...new Set(jobKeys)];
|
|
2576
|
+
const keyToIdMap = new Map();
|
|
2577
|
+
const chunks = [];
|
|
2578
|
+
for (let i = 0; i < uniqueKeys.length; i += JOB_KEY_RESOLUTION_CHUNK_SIZE) {
|
|
2579
|
+
chunks.push(uniqueKeys.slice(i, i + JOB_KEY_RESOLUTION_CHUNK_SIZE));
|
|
2580
|
+
}
|
|
2581
|
+
const results = await Promise.all(chunks.map((chunk) => {
|
|
2582
|
+
const filterValues = chunk.map((key) => `'${key}'`).join(',');
|
|
2583
|
+
return this.getAll({
|
|
2584
|
+
folderId,
|
|
2585
|
+
filter: `key in (${filterValues})`,
|
|
2586
|
+
select: 'id,key',
|
|
2587
|
+
pageSize: chunk.length,
|
|
2588
|
+
});
|
|
2589
|
+
}));
|
|
2590
|
+
for (const response of results) {
|
|
2591
|
+
for (const job of response.items) {
|
|
2592
|
+
keyToIdMap.set(job.key, job.id);
|
|
2593
|
+
}
|
|
2594
|
+
}
|
|
2595
|
+
const missingKeys = uniqueKeys.filter((key) => !keyToIdMap.has(key));
|
|
2596
|
+
if (missingKeys.length > 0) {
|
|
2597
|
+
throw new ValidationError({ message: `Jobs not found for keys: ${missingKeys.join(', ')}` });
|
|
2598
|
+
}
|
|
2599
|
+
return uniqueKeys.map((key) => keyToIdMap.get(key));
|
|
2600
|
+
}
|
|
2601
|
+
/**
|
|
2602
|
+
* Calls the StopJobs OData action with resolved integer IDs.
|
|
2603
|
+
*/
|
|
2604
|
+
async stopJobsByIds(jobIds, strategy, headers) {
|
|
2605
|
+
await this.post(JOB_ENDPOINTS.STOP, { jobIds, strategy }, { headers });
|
|
2606
|
+
}
|
|
2240
2607
|
}
|
|
2241
2608
|
__decorate([
|
|
2242
2609
|
track('Jobs.GetAll')
|
|
@@ -2247,6 +2614,15 @@ __decorate([
|
|
|
2247
2614
|
__decorate([
|
|
2248
2615
|
track('Jobs.GetOutput')
|
|
2249
2616
|
], JobService.prototype, "getOutput", null);
|
|
2617
|
+
__decorate([
|
|
2618
|
+
track('Jobs.Stop')
|
|
2619
|
+
], JobService.prototype, "stop", null);
|
|
2620
|
+
__decorate([
|
|
2621
|
+
track('Jobs.Resume')
|
|
2622
|
+
], JobService.prototype, "resume", null);
|
|
2623
|
+
__decorate([
|
|
2624
|
+
track('Jobs.Restart')
|
|
2625
|
+
], JobService.prototype, "restart", null);
|
|
2250
2626
|
|
|
2251
2627
|
/**
|
|
2252
2628
|
* Enum for job sub-state
|