@uipath/uipath-typescript 1.0.0-beta.14 → 1.0.0-beta.15
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/README.md +201 -132
- package/dist/{index.js → index.cjs} +446 -186
- package/dist/index.d.cts +5091 -0
- package/dist/index.d.mts +5091 -0
- package/dist/index.d.ts +517 -136
- package/dist/{index.esm.js → index.mjs} +446 -168
- package/dist/index.umd.js +17784 -0
- package/package.json +18 -22
|
@@ -2,28 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
var zod = require('zod');
|
|
4
4
|
var sdkLogs = require('@opentelemetry/sdk-logs');
|
|
5
|
-
var mimeTypes = require('mime-types');
|
|
6
5
|
var axios = require('axios');
|
|
7
6
|
|
|
8
|
-
function _interopNamespaceDefault(e) {
|
|
9
|
-
var n = Object.create(null);
|
|
10
|
-
if (e) {
|
|
11
|
-
Object.keys(e).forEach(function (k) {
|
|
12
|
-
if (k !== 'default') {
|
|
13
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
get: function () { return e[k]; }
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
n.default = e;
|
|
22
|
-
return Object.freeze(n);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
var mimeTypes__namespace = /*#__PURE__*/_interopNamespaceDefault(mimeTypes);
|
|
26
|
-
|
|
27
7
|
zod.z.object({
|
|
28
8
|
baseUrl: zod.z.string().url().default('https://cloud.uipath.com'),
|
|
29
9
|
orgName: zod.z.string().min(1),
|
|
@@ -581,7 +561,7 @@ class ErrorFactory {
|
|
|
581
561
|
* Creates appropriate error instance based on HTTP status code
|
|
582
562
|
*/
|
|
583
563
|
static createFromHttpStatus(statusCode, errorInfo) {
|
|
584
|
-
const { message, requestId
|
|
564
|
+
const { message, requestId } = errorInfo;
|
|
585
565
|
// Map status codes to error types
|
|
586
566
|
switch (statusCode) {
|
|
587
567
|
case HttpStatus.BAD_REQUEST:
|
|
@@ -999,6 +979,8 @@ function createHeaders(headersObj) {
|
|
|
999
979
|
* Prefix used for OData query parameters
|
|
1000
980
|
*/
|
|
1001
981
|
const ODATA_PREFIX = '$';
|
|
982
|
+
const UNKNOWN$1 = 'Unknown';
|
|
983
|
+
const NO_INSTANCE = 'no-instance';
|
|
1002
984
|
/**
|
|
1003
985
|
* OData pagination constants
|
|
1004
986
|
*/
|
|
@@ -1491,12 +1473,12 @@ class PaginationHelpers {
|
|
|
1491
1473
|
throw new Error('jumpToPage is not supported for token-based pagination. Use cursor-based navigation instead.');
|
|
1492
1474
|
}
|
|
1493
1475
|
// Get processed parameters
|
|
1494
|
-
return PaginationHelpers.getRequestParameters(options);
|
|
1476
|
+
return PaginationHelpers.getRequestParameters(options, paginationType);
|
|
1495
1477
|
}
|
|
1496
1478
|
/**
|
|
1497
1479
|
* Convert a unified pagination options to service-specific parameters
|
|
1498
1480
|
*/
|
|
1499
|
-
static getRequestParameters(options) {
|
|
1481
|
+
static getRequestParameters(options, paginationType) {
|
|
1500
1482
|
// Handle jumpToPage
|
|
1501
1483
|
if (options.jumpToPage !== undefined) {
|
|
1502
1484
|
const jumpToPageOptions = {
|
|
@@ -1509,7 +1491,8 @@ class PaginationHelpers {
|
|
|
1509
1491
|
if (!options.cursor) {
|
|
1510
1492
|
const firstPageOptions = {
|
|
1511
1493
|
pageSize: options.pageSize,
|
|
1512
|
-
pageNumber
|
|
1494
|
+
// Only set pageNumber for OFFSET pagination
|
|
1495
|
+
pageNumber: paginationType === PaginationType.OFFSET ? 1 : undefined
|
|
1513
1496
|
};
|
|
1514
1497
|
return filterUndefined(firstPageOptions);
|
|
1515
1498
|
}
|
|
@@ -1800,7 +1783,7 @@ class BaseService {
|
|
|
1800
1783
|
pageInfo: {
|
|
1801
1784
|
hasMore,
|
|
1802
1785
|
totalCount,
|
|
1803
|
-
currentPage: params.pageNumber
|
|
1786
|
+
currentPage: params.pageNumber,
|
|
1804
1787
|
pageSize: params.pageSize,
|
|
1805
1788
|
continuationToken
|
|
1806
1789
|
},
|
|
@@ -2107,6 +2090,11 @@ const MAESTRO_ENDPOINTS = {
|
|
|
2107
2090
|
PAUSE: (instanceId) => `pims_/api/v1/instances/${instanceId}/pause`,
|
|
2108
2091
|
RESUME: (instanceId) => `pims_/api/v1/instances/${instanceId}/resume`,
|
|
2109
2092
|
},
|
|
2093
|
+
INCIDENTS: {
|
|
2094
|
+
GET_ALL: 'pims_/api/v1/incidents/summary',
|
|
2095
|
+
GET_BY_PROCESS: (processKey) => `pims_/api/v1/incidents/process/${processKey}`,
|
|
2096
|
+
GET_BY_INSTANCE: (instanceId) => `pims_/api/v1/instances/${instanceId}/incidents`,
|
|
2097
|
+
},
|
|
2110
2098
|
CASES: {
|
|
2111
2099
|
GET_CASE_JSON: (instanceId) => `pims_/api/v1/cases/${instanceId}/case-json`,
|
|
2112
2100
|
GET_ELEMENT_EXECUTIONS: (instanceId) => `pims_/api/v1alpha1/element-executions/case-instances/${instanceId}`,
|
|
@@ -2733,7 +2721,7 @@ const EntityFieldTypeMap = {
|
|
|
2733
2721
|
// Connection string placeholder that will be replaced during build
|
|
2734
2722
|
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";
|
|
2735
2723
|
// SDK Version placeholder
|
|
2736
|
-
const SDK_VERSION = "1.0.0-beta.
|
|
2724
|
+
const SDK_VERSION = "1.0.0-beta.15";
|
|
2737
2725
|
const VERSION = "Version";
|
|
2738
2726
|
const SERVICE = "Service";
|
|
2739
2727
|
const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
|
|
@@ -3318,46 +3306,161 @@ __decorate([
|
|
|
3318
3306
|
], EntityService.prototype, "getAll", null);
|
|
3319
3307
|
|
|
3320
3308
|
/**
|
|
3321
|
-
*
|
|
3309
|
+
* Maestro Process Models
|
|
3310
|
+
* Model classes for Maestro processes
|
|
3322
3311
|
*/
|
|
3323
|
-
|
|
3312
|
+
/**
|
|
3313
|
+
* Creates methods for a process object
|
|
3314
|
+
*
|
|
3315
|
+
* @param processData - The process data (response from API)
|
|
3316
|
+
* @param service - The process service instance
|
|
3317
|
+
* @returns Object containing process methods
|
|
3318
|
+
*/
|
|
3319
|
+
function createProcessMethods(processData, service) {
|
|
3320
|
+
return {
|
|
3321
|
+
async getIncidents() {
|
|
3322
|
+
if (!processData.processKey)
|
|
3323
|
+
throw new Error('Process key is undefined');
|
|
3324
|
+
if (!processData.folderKey)
|
|
3325
|
+
throw new Error('Folder key is undefined');
|
|
3326
|
+
return service.getIncidents(processData.processKey, processData.folderKey);
|
|
3327
|
+
}
|
|
3328
|
+
};
|
|
3329
|
+
}
|
|
3330
|
+
/**
|
|
3331
|
+
* Creates an actionable process by combining API process data with operational methods.
|
|
3332
|
+
*
|
|
3333
|
+
* @param processData - The process data from API
|
|
3334
|
+
* @param service - The process service instance
|
|
3335
|
+
* @returns A process object with added methods
|
|
3336
|
+
*/
|
|
3337
|
+
function createProcessWithMethods(processData, service) {
|
|
3338
|
+
const methods = createProcessMethods(processData, service);
|
|
3339
|
+
return Object.assign({}, processData, methods);
|
|
3340
|
+
}
|
|
3341
|
+
|
|
3342
|
+
/**
|
|
3343
|
+
* Maps fields for Incident entities
|
|
3344
|
+
*/
|
|
3345
|
+
const ProcessIncidentMap = {
|
|
3346
|
+
errorTimeUtc: 'errorTime'
|
|
3347
|
+
};
|
|
3348
|
+
/**
|
|
3349
|
+
* Maps fields for Incident Summary entities
|
|
3350
|
+
*/
|
|
3351
|
+
const ProcessIncidentSummaryMap = {
|
|
3352
|
+
firstTimeUtc: 'firstOccuranceTime'
|
|
3353
|
+
};
|
|
3354
|
+
|
|
3355
|
+
/**
|
|
3356
|
+
* Helpers for fetching BPMN XML and extracting element details used to annotate responses
|
|
3357
|
+
*/
|
|
3358
|
+
class BpmnHelpers {
|
|
3324
3359
|
/**
|
|
3325
|
-
*
|
|
3360
|
+
* Parse BPMN XML and extract element id → {name,type} used for incidents
|
|
3326
3361
|
*/
|
|
3327
|
-
|
|
3328
|
-
|
|
3362
|
+
static parseBpmnElementsForIncidents(bpmnXml) {
|
|
3363
|
+
const elementInfo = {};
|
|
3364
|
+
try {
|
|
3365
|
+
// Find <bpmn:...> start tags and capture the element type.
|
|
3366
|
+
// Then read 'id' and 'name' attributes from each tag.
|
|
3367
|
+
const bpmnOpenTagRegex = /<bpmn:([A-Za-z][\w.-]*)\b[^>]*>/g;
|
|
3368
|
+
for (const tagMatch of bpmnXml.matchAll(bpmnOpenTagRegex)) {
|
|
3369
|
+
const [fullTag, elementType] = tagMatch;
|
|
3370
|
+
// Extract attributes from the current tag text.
|
|
3371
|
+
const idMatch = /\bid\s*=\s*"([^"]*)"/.exec(fullTag);
|
|
3372
|
+
if (!idMatch) {
|
|
3373
|
+
continue;
|
|
3374
|
+
}
|
|
3375
|
+
const elementId = idMatch[1];
|
|
3376
|
+
const nameMatch = /\bname\s*=\s*"([^"]*)"/.exec(fullTag);
|
|
3377
|
+
const name = nameMatch ? nameMatch[1] : '';
|
|
3378
|
+
// Convert BPMN element type to human-readable format
|
|
3379
|
+
const activityType = this.formatActivityTypeForIncidents(elementType);
|
|
3380
|
+
const activityName = name || elementId;
|
|
3381
|
+
elementInfo[elementId] = {
|
|
3382
|
+
type: activityType,
|
|
3383
|
+
name: activityName
|
|
3384
|
+
};
|
|
3385
|
+
}
|
|
3386
|
+
}
|
|
3387
|
+
catch (error) {
|
|
3388
|
+
console.warn('Failed to parse BPMN XML for incidents:', error);
|
|
3389
|
+
}
|
|
3390
|
+
return elementInfo;
|
|
3329
3391
|
}
|
|
3330
3392
|
/**
|
|
3331
|
-
*
|
|
3332
|
-
* @returns Promise resolving to array of MaestroProcess objects
|
|
3333
|
-
*
|
|
3334
|
-
* @example
|
|
3335
|
-
* ```typescript
|
|
3336
|
-
* // Get all processes
|
|
3337
|
-
* const processes = await sdk.maestro.processes.getAll();
|
|
3338
|
-
*
|
|
3339
|
-
* // Access process information
|
|
3340
|
-
* for (const process of processes) {
|
|
3341
|
-
* console.log(`Process: ${process.processKey}`);
|
|
3342
|
-
* console.log(`Running instances: ${process.runningCount}`);
|
|
3343
|
-
* console.log(`Faulted instances: ${process.faultedCount}`);
|
|
3344
|
-
* }
|
|
3345
|
-
*
|
|
3346
|
-
* ```
|
|
3393
|
+
* Format BPMN element type to human-readable activity type for incidents
|
|
3347
3394
|
*/
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
//
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3395
|
+
static formatActivityTypeForIncidents(elementType) {
|
|
3396
|
+
// Convert camelCase BPMN element types to human-readable format
|
|
3397
|
+
// e.g., "serviceTask" -> "Service Task", "exclusiveGateway" -> "Exclusive Gateway"
|
|
3398
|
+
return elementType
|
|
3399
|
+
.replace(/([A-Z])/g, ' $1') // Add space before uppercase letters
|
|
3400
|
+
.replace(/^./, str => str.toUpperCase()) // Capitalize first letter
|
|
3401
|
+
.trim(); // Remove any leading/trailing spaces
|
|
3402
|
+
}
|
|
3403
|
+
/**
|
|
3404
|
+
* Fetch BPMN via getBpmn and add element name/type to each incident
|
|
3405
|
+
*/
|
|
3406
|
+
static async enrichIncidentsWithBpmnData(incidents, folderKey, service) {
|
|
3407
|
+
// Check if all incidents have the same instanceId
|
|
3408
|
+
const uniqueInstanceIds = [...new Set(incidents.map(i => i.instanceId))];
|
|
3409
|
+
if (uniqueInstanceIds.length === 1) {
|
|
3410
|
+
// Single instance optimization (in case of process instance incidents)
|
|
3411
|
+
const elementInfo = await this.getBpmnElementInfo(uniqueInstanceIds[0], folderKey, service);
|
|
3412
|
+
return incidents.map((incident) => this.transformIncidentWithBpmn(incident, elementInfo));
|
|
3413
|
+
}
|
|
3414
|
+
else {
|
|
3415
|
+
// Multiple instances optimization (in case of process incidents)
|
|
3416
|
+
return this.enrichMultipleInstanceIncidents(incidents, folderKey, service);
|
|
3417
|
+
}
|
|
3418
|
+
}
|
|
3419
|
+
/**
|
|
3420
|
+
* When incidents span multiple instances, fetch BPMN per instance and annotate
|
|
3421
|
+
*/
|
|
3422
|
+
static async enrichMultipleInstanceIncidents(incidents, folderKey, service) {
|
|
3423
|
+
const groups = incidents.reduce((acc, incident) => {
|
|
3424
|
+
const id = incident.instanceId || NO_INSTANCE;
|
|
3425
|
+
(acc[id] = acc[id] || []).push(incident);
|
|
3426
|
+
return acc;
|
|
3427
|
+
}, {});
|
|
3428
|
+
const results = await Promise.all(Object.entries(groups).map(async (entry) => {
|
|
3429
|
+
const [instanceId, groupIncidents] = entry;
|
|
3430
|
+
const elementInfo = await this.getBpmnElementInfo(instanceId, folderKey, service);
|
|
3431
|
+
return groupIncidents.map((incident) => this.transformIncidentWithBpmn(incident, elementInfo));
|
|
3355
3432
|
}));
|
|
3433
|
+
return results.flat();
|
|
3434
|
+
}
|
|
3435
|
+
/**
|
|
3436
|
+
* Retrieve BPMN XML for an instance and derive element id → {name,type}
|
|
3437
|
+
*/
|
|
3438
|
+
static async getBpmnElementInfo(instanceId, folderKey, service) {
|
|
3439
|
+
if (!instanceId || instanceId === NO_INSTANCE) {
|
|
3440
|
+
return {};
|
|
3441
|
+
}
|
|
3442
|
+
try {
|
|
3443
|
+
const bpmnXml = await service.getBpmn(instanceId, folderKey);
|
|
3444
|
+
return this.parseBpmnElementsForIncidents(bpmnXml);
|
|
3445
|
+
}
|
|
3446
|
+
catch (error) {
|
|
3447
|
+
console.warn(`Failed to get BPMN for instance ${instanceId}:`, error);
|
|
3448
|
+
return {};
|
|
3449
|
+
}
|
|
3450
|
+
}
|
|
3451
|
+
/**
|
|
3452
|
+
* Transform a raw incident by attaching element name/type from BPMN
|
|
3453
|
+
*/
|
|
3454
|
+
static transformIncidentWithBpmn(incident, elementInfo) {
|
|
3455
|
+
const element = elementInfo[incident.elementId];
|
|
3456
|
+
const transformed = transformData(incident, ProcessIncidentMap);
|
|
3457
|
+
return {
|
|
3458
|
+
...transformed,
|
|
3459
|
+
incidentElementActivityType: element?.type || UNKNOWN$1,
|
|
3460
|
+
incidentElementActivityName: element?.name || UNKNOWN$1
|
|
3461
|
+
};
|
|
3356
3462
|
}
|
|
3357
3463
|
}
|
|
3358
|
-
__decorate([
|
|
3359
|
-
track('MaestroProcesses.GetAll')
|
|
3360
|
-
], MaestroProcessesService.prototype, "getAll", null);
|
|
3361
3464
|
|
|
3362
3465
|
/**
|
|
3363
3466
|
* Creates methods for a process instance
|
|
@@ -3371,17 +3474,49 @@ function createProcessInstanceMethods(instanceData, service) {
|
|
|
3371
3474
|
async cancel(options) {
|
|
3372
3475
|
if (!instanceData.instanceId)
|
|
3373
3476
|
throw new Error('Process instance ID is undefined');
|
|
3477
|
+
if (!instanceData.folderKey)
|
|
3478
|
+
throw new Error('Process instance folder key is undefined');
|
|
3374
3479
|
return service.cancel(instanceData.instanceId, instanceData.folderKey, options);
|
|
3375
3480
|
},
|
|
3376
3481
|
async pause(options) {
|
|
3377
3482
|
if (!instanceData.instanceId)
|
|
3378
3483
|
throw new Error('Process instance ID is undefined');
|
|
3484
|
+
if (!instanceData.folderKey)
|
|
3485
|
+
throw new Error('Process instance folder key is undefined');
|
|
3379
3486
|
return service.pause(instanceData.instanceId, instanceData.folderKey, options);
|
|
3380
3487
|
},
|
|
3381
3488
|
async resume(options) {
|
|
3382
3489
|
if (!instanceData.instanceId)
|
|
3383
3490
|
throw new Error('Process instance ID is undefined');
|
|
3491
|
+
if (!instanceData.folderKey)
|
|
3492
|
+
throw new Error('Process instance folder key is undefined');
|
|
3384
3493
|
return service.resume(instanceData.instanceId, instanceData.folderKey, options);
|
|
3494
|
+
},
|
|
3495
|
+
async getIncidents() {
|
|
3496
|
+
if (!instanceData.instanceId)
|
|
3497
|
+
throw new Error('Process instance ID is undefined');
|
|
3498
|
+
if (!instanceData.folderKey)
|
|
3499
|
+
throw new Error('Process instance folder key is undefined');
|
|
3500
|
+
return service.getIncidents(instanceData.instanceId, instanceData.folderKey);
|
|
3501
|
+
},
|
|
3502
|
+
async getExecutionHistory() {
|
|
3503
|
+
if (!instanceData.instanceId)
|
|
3504
|
+
throw new Error('Process instance ID is undefined');
|
|
3505
|
+
return service.getExecutionHistory(instanceData.instanceId);
|
|
3506
|
+
},
|
|
3507
|
+
async getBpmn() {
|
|
3508
|
+
if (!instanceData.instanceId)
|
|
3509
|
+
throw new Error('Process instance ID is undefined');
|
|
3510
|
+
if (!instanceData.folderKey)
|
|
3511
|
+
throw new Error('Process instance folder key is undefined');
|
|
3512
|
+
return service.getBpmn(instanceData.instanceId, instanceData.folderKey);
|
|
3513
|
+
},
|
|
3514
|
+
async getVariables(options) {
|
|
3515
|
+
if (!instanceData.instanceId)
|
|
3516
|
+
throw new Error('Process instance ID is undefined');
|
|
3517
|
+
if (!instanceData.folderKey)
|
|
3518
|
+
throw new Error('Process instance folder key is undefined');
|
|
3519
|
+
return service.getVariables(instanceData.instanceId, instanceData.folderKey, options);
|
|
3385
3520
|
}
|
|
3386
3521
|
};
|
|
3387
3522
|
}
|
|
@@ -3397,6 +3532,42 @@ function createProcessInstanceWithMethods(instanceData, service) {
|
|
|
3397
3532
|
return Object.assign({}, instanceData, methods);
|
|
3398
3533
|
}
|
|
3399
3534
|
|
|
3535
|
+
/**
|
|
3536
|
+
* Process Incident Status
|
|
3537
|
+
*/
|
|
3538
|
+
exports.ProcessIncidentStatus = void 0;
|
|
3539
|
+
(function (ProcessIncidentStatus) {
|
|
3540
|
+
ProcessIncidentStatus["Open"] = "Open";
|
|
3541
|
+
ProcessIncidentStatus["Closed"] = "Closed";
|
|
3542
|
+
})(exports.ProcessIncidentStatus || (exports.ProcessIncidentStatus = {}));
|
|
3543
|
+
/**
|
|
3544
|
+
* Process Incident Type
|
|
3545
|
+
*/
|
|
3546
|
+
exports.ProcessIncidentType = void 0;
|
|
3547
|
+
(function (ProcessIncidentType) {
|
|
3548
|
+
ProcessIncidentType["System"] = "System";
|
|
3549
|
+
ProcessIncidentType["User"] = "User";
|
|
3550
|
+
ProcessIncidentType["Deployment"] = "Deployment";
|
|
3551
|
+
})(exports.ProcessIncidentType || (exports.ProcessIncidentType = {}));
|
|
3552
|
+
/**
|
|
3553
|
+
* Process Incident Severity
|
|
3554
|
+
*/
|
|
3555
|
+
exports.ProcessIncidentSeverity = void 0;
|
|
3556
|
+
(function (ProcessIncidentSeverity) {
|
|
3557
|
+
ProcessIncidentSeverity["Error"] = "Error";
|
|
3558
|
+
ProcessIncidentSeverity["Warning"] = "Warning";
|
|
3559
|
+
})(exports.ProcessIncidentSeverity || (exports.ProcessIncidentSeverity = {}));
|
|
3560
|
+
/**
|
|
3561
|
+
* Process Incident Debug Mode
|
|
3562
|
+
*/
|
|
3563
|
+
exports.DebugMode = void 0;
|
|
3564
|
+
(function (DebugMode) {
|
|
3565
|
+
DebugMode["None"] = "None";
|
|
3566
|
+
DebugMode["Default"] = "Default";
|
|
3567
|
+
DebugMode["StepByStep"] = "StepByStep";
|
|
3568
|
+
DebugMode["SingleStep"] = "SingleStep";
|
|
3569
|
+
})(exports.DebugMode || (exports.DebugMode = {}));
|
|
3570
|
+
|
|
3400
3571
|
/**
|
|
3401
3572
|
* Case Instance Types
|
|
3402
3573
|
* Types and interfaces for Maestro case instance management
|
|
@@ -3459,17 +3630,42 @@ function createCaseInstanceMethods(instanceData, service) {
|
|
|
3459
3630
|
async close(options) {
|
|
3460
3631
|
if (!instanceData.instanceId)
|
|
3461
3632
|
throw new Error('Case instance ID is undefined');
|
|
3633
|
+
if (!instanceData.folderKey)
|
|
3634
|
+
throw new Error('Case instance folder key is undefined');
|
|
3462
3635
|
return service.close(instanceData.instanceId, instanceData.folderKey, options);
|
|
3463
3636
|
},
|
|
3464
3637
|
async pause(options) {
|
|
3465
3638
|
if (!instanceData.instanceId)
|
|
3466
3639
|
throw new Error('Case instance ID is undefined');
|
|
3640
|
+
if (!instanceData.folderKey)
|
|
3641
|
+
throw new Error('Case instance folder key is undefined');
|
|
3467
3642
|
return service.pause(instanceData.instanceId, instanceData.folderKey, options);
|
|
3468
3643
|
},
|
|
3469
3644
|
async resume(options) {
|
|
3470
3645
|
if (!instanceData.instanceId)
|
|
3471
3646
|
throw new Error('Case instance ID is undefined');
|
|
3647
|
+
if (!instanceData.folderKey)
|
|
3648
|
+
throw new Error('Case instance folder key is undefined');
|
|
3472
3649
|
return service.resume(instanceData.instanceId, instanceData.folderKey, options);
|
|
3650
|
+
},
|
|
3651
|
+
async getExecutionHistory() {
|
|
3652
|
+
if (!instanceData.instanceId)
|
|
3653
|
+
throw new Error('Case instance ID is undefined');
|
|
3654
|
+
if (!instanceData.folderKey)
|
|
3655
|
+
throw new Error('Case instance folder key is undefined');
|
|
3656
|
+
return service.getExecutionHistory(instanceData.instanceId, instanceData.folderKey);
|
|
3657
|
+
},
|
|
3658
|
+
async getStages() {
|
|
3659
|
+
if (!instanceData.instanceId)
|
|
3660
|
+
throw new Error('Case instance ID is undefined');
|
|
3661
|
+
if (!instanceData.folderKey)
|
|
3662
|
+
throw new Error('Case instance folder key is undefined');
|
|
3663
|
+
return service.getStages(instanceData.instanceId, instanceData.folderKey);
|
|
3664
|
+
},
|
|
3665
|
+
async getActionTasks(options) {
|
|
3666
|
+
if (!instanceData.instanceId)
|
|
3667
|
+
throw new Error('Case instance ID is undefined');
|
|
3668
|
+
return service.getActionTasks(instanceData.instanceId, options);
|
|
3473
3669
|
}
|
|
3474
3670
|
};
|
|
3475
3671
|
}
|
|
@@ -3767,6 +3963,19 @@ class ProcessInstancesService extends BaseService {
|
|
|
3767
3963
|
};
|
|
3768
3964
|
return variablesResponse;
|
|
3769
3965
|
}
|
|
3966
|
+
/**
|
|
3967
|
+
* Get incidents for a process instance
|
|
3968
|
+
* @param instanceId The ID of the instance to get incidents for
|
|
3969
|
+
* @param folderKey The folder key for authorization
|
|
3970
|
+
* @returns Promise<ProcessIncidentGetResponse[]>
|
|
3971
|
+
*/
|
|
3972
|
+
async getIncidents(instanceId, folderKey) {
|
|
3973
|
+
const rawResponse = await this.get(MAESTRO_ENDPOINTS.INCIDENTS.GET_BY_INSTANCE(instanceId), {
|
|
3974
|
+
headers: createHeaders({ [FOLDER_KEY]: folderKey })
|
|
3975
|
+
});
|
|
3976
|
+
// Filter out excluded fields and transform response, then enrich with BPMN data
|
|
3977
|
+
return BpmnHelpers.enrichIncidentsWithBpmnData(rawResponse.data || [], folderKey, this);
|
|
3978
|
+
}
|
|
3770
3979
|
}
|
|
3771
3980
|
__decorate([
|
|
3772
3981
|
track('ProcessInstances.GetAll')
|
|
@@ -3792,6 +4001,101 @@ __decorate([
|
|
|
3792
4001
|
__decorate([
|
|
3793
4002
|
track('ProcessInstances.GetVariables')
|
|
3794
4003
|
], ProcessInstancesService.prototype, "getVariables", null);
|
|
4004
|
+
__decorate([
|
|
4005
|
+
track('ProcessInstances.GetIncidents')
|
|
4006
|
+
], ProcessInstancesService.prototype, "getIncidents", null);
|
|
4007
|
+
|
|
4008
|
+
/**
|
|
4009
|
+
* Service for interacting with Maestro Processes
|
|
4010
|
+
*/
|
|
4011
|
+
class MaestroProcessesService extends BaseService {
|
|
4012
|
+
/**
|
|
4013
|
+
* @hideconstructor
|
|
4014
|
+
*/
|
|
4015
|
+
constructor(config, executionContext, tokenManager) {
|
|
4016
|
+
super(config, executionContext, tokenManager);
|
|
4017
|
+
this.processInstancesService = new ProcessInstancesService(config, executionContext, tokenManager);
|
|
4018
|
+
}
|
|
4019
|
+
/**
|
|
4020
|
+
* Get all processes with their instance statistics
|
|
4021
|
+
* @returns Promise resolving to array of MaestroProcess objects
|
|
4022
|
+
*
|
|
4023
|
+
* @example
|
|
4024
|
+
* ```typescript
|
|
4025
|
+
* // Get all processes
|
|
4026
|
+
* const processes = await sdk.maestro.processes.getAll();
|
|
4027
|
+
*
|
|
4028
|
+
* // Access process information
|
|
4029
|
+
* for (const process of processes) {
|
|
4030
|
+
* console.log(`Process: ${process.processKey}`);
|
|
4031
|
+
* console.log(`Running instances: ${process.runningCount}`);
|
|
4032
|
+
* console.log(`Faulted instances: ${process.faultedCount}`);
|
|
4033
|
+
* }
|
|
4034
|
+
*
|
|
4035
|
+
* ```
|
|
4036
|
+
*/
|
|
4037
|
+
async getAll() {
|
|
4038
|
+
const response = await this.get(MAESTRO_ENDPOINTS.PROCESSES.GET_ALL);
|
|
4039
|
+
// Extract processes array from response data and add name field
|
|
4040
|
+
const processes = response.data?.processes || [];
|
|
4041
|
+
const processesWithName = processes.map(process => ({
|
|
4042
|
+
...process,
|
|
4043
|
+
name: process.packageId
|
|
4044
|
+
}));
|
|
4045
|
+
// Add methods to each process
|
|
4046
|
+
return processesWithName.map(process => createProcessWithMethods(process, this));
|
|
4047
|
+
}
|
|
4048
|
+
/**
|
|
4049
|
+
* Get incidents for a specific process
|
|
4050
|
+
*/
|
|
4051
|
+
async getIncidents(processKey, folderKey) {
|
|
4052
|
+
const rawResponse = await this.get(MAESTRO_ENDPOINTS.INCIDENTS.GET_BY_PROCESS(processKey), {
|
|
4053
|
+
headers: createHeaders({ [FOLDER_KEY]: folderKey })
|
|
4054
|
+
});
|
|
4055
|
+
// Fetch BPMN XML and add element name/type to each incident
|
|
4056
|
+
return BpmnHelpers.enrichIncidentsWithBpmnData(rawResponse.data || [], folderKey, this.processInstancesService);
|
|
4057
|
+
}
|
|
4058
|
+
}
|
|
4059
|
+
__decorate([
|
|
4060
|
+
track('MaestroProcesses.GetAll')
|
|
4061
|
+
], MaestroProcessesService.prototype, "getAll", null);
|
|
4062
|
+
__decorate([
|
|
4063
|
+
track('MaestroProcesses.GetIncidents')
|
|
4064
|
+
], MaestroProcessesService.prototype, "getIncidents", null);
|
|
4065
|
+
|
|
4066
|
+
/**
|
|
4067
|
+
* Service class for Maestro Process Incidents
|
|
4068
|
+
*/
|
|
4069
|
+
class ProcessIncidentsService extends BaseService {
|
|
4070
|
+
/**
|
|
4071
|
+
* Get all process incidents across all folders
|
|
4072
|
+
*
|
|
4073
|
+
* @returns Promise resolving to array of process incident
|
|
4074
|
+
* {@link ProcessIncidentGetAllResponse}
|
|
4075
|
+
* @example
|
|
4076
|
+
* ```typescript
|
|
4077
|
+
* // Get all process incidents across all folders
|
|
4078
|
+
* const incidents = await sdk.maestro.processes.incidents.getAll();
|
|
4079
|
+
*
|
|
4080
|
+
* // Access process incident information
|
|
4081
|
+
* for (const incident of incidents) {
|
|
4082
|
+
* console.log(`Process: ${incident.processKey}`);
|
|
4083
|
+
* console.log(`Error: ${incident.errorMessage}`);
|
|
4084
|
+
* console.log(`Count: ${incident.count}`);
|
|
4085
|
+
* console.log(`First occurrence: ${incident.firstOccuranceTime}`);
|
|
4086
|
+
* }
|
|
4087
|
+
* ```
|
|
4088
|
+
*/
|
|
4089
|
+
async getAll() {
|
|
4090
|
+
const rawResponse = await this.get(MAESTRO_ENDPOINTS.INCIDENTS.GET_ALL);
|
|
4091
|
+
// Transform field names
|
|
4092
|
+
const data = rawResponse.data || [];
|
|
4093
|
+
return data.map(incident => transformData(incident, ProcessIncidentSummaryMap));
|
|
4094
|
+
}
|
|
4095
|
+
}
|
|
4096
|
+
__decorate([
|
|
4097
|
+
track('ProcessIncidents.getAll')
|
|
4098
|
+
], ProcessIncidentsService.prototype, "getAll", null);
|
|
3795
4099
|
|
|
3796
4100
|
/**
|
|
3797
4101
|
* Internal types for Maestro Cases
|
|
@@ -3987,35 +4291,32 @@ function createTaskMethods(taskData, service) {
|
|
|
3987
4291
|
async assign(options) {
|
|
3988
4292
|
if (!taskData.id)
|
|
3989
4293
|
throw new Error('Task ID is undefined');
|
|
3990
|
-
const assignmentOptions =
|
|
3991
|
-
taskId: taskData.id,
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
};
|
|
3995
|
-
return service.assign(assignmentOptions, taskData.organizationUnitId);
|
|
4294
|
+
const assignmentOptions = 'userId' in options && options.userId !== undefined
|
|
4295
|
+
? { taskId: taskData.id, userId: options.userId }
|
|
4296
|
+
: { taskId: taskData.id, userNameOrEmail: options.userNameOrEmail };
|
|
4297
|
+
return service.assign(assignmentOptions);
|
|
3996
4298
|
},
|
|
3997
4299
|
async reassign(options) {
|
|
3998
4300
|
if (!taskData.id)
|
|
3999
4301
|
throw new Error('Task ID is undefined');
|
|
4000
|
-
const assignmentOptions =
|
|
4001
|
-
taskId: taskData.id,
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
};
|
|
4005
|
-
return service.reassign(assignmentOptions, taskData.organizationUnitId);
|
|
4302
|
+
const assignmentOptions = 'userId' in options && options.userId !== undefined
|
|
4303
|
+
? { taskId: taskData.id, userId: options.userId }
|
|
4304
|
+
: { taskId: taskData.id, userNameOrEmail: options.userNameOrEmail };
|
|
4305
|
+
return service.reassign(assignmentOptions);
|
|
4006
4306
|
},
|
|
4007
4307
|
async unassign() {
|
|
4008
4308
|
if (!taskData.id)
|
|
4009
4309
|
throw new Error('Task ID is undefined');
|
|
4010
|
-
return service.unassign(taskData.id
|
|
4310
|
+
return service.unassign(taskData.id);
|
|
4011
4311
|
},
|
|
4012
4312
|
async complete(options) {
|
|
4013
4313
|
if (!taskData.id)
|
|
4014
4314
|
throw new Error('Task ID is undefined');
|
|
4015
|
-
const folderId = taskData.
|
|
4315
|
+
const folderId = taskData.folderId;
|
|
4016
4316
|
if (!folderId)
|
|
4017
4317
|
throw new Error('Folder ID is required');
|
|
4018
|
-
return service.complete(
|
|
4318
|
+
return service.complete({
|
|
4319
|
+
type: options.type,
|
|
4019
4320
|
taskId: taskData.id,
|
|
4020
4321
|
data: options.data,
|
|
4021
4322
|
action: options.action
|
|
@@ -4052,6 +4353,10 @@ const TaskMap = {
|
|
|
4052
4353
|
creationTime: 'createdTime',
|
|
4053
4354
|
organizationUnitId: 'folderId'
|
|
4054
4355
|
};
|
|
4356
|
+
/**
|
|
4357
|
+
* Default expand parameters
|
|
4358
|
+
*/
|
|
4359
|
+
const DEFAULT_TASK_EXPAND = 'AssignedToUser,CreatorUser,LastModifierUser';
|
|
4055
4360
|
|
|
4056
4361
|
/**
|
|
4057
4362
|
* Service for interacting with UiPath Tasks API
|
|
@@ -4070,7 +4375,8 @@ class TaskService extends BaseService {
|
|
|
4070
4375
|
* @private
|
|
4071
4376
|
*/
|
|
4072
4377
|
this.processTaskParameters = (options, folderId) => {
|
|
4073
|
-
|
|
4378
|
+
// Add default expand parameters
|
|
4379
|
+
const processedOptions = this.addDefaultExpand(options);
|
|
4074
4380
|
if (folderId) {
|
|
4075
4381
|
// Create or add to existing filter for folder-specific queries
|
|
4076
4382
|
if (processedOptions.filter) {
|
|
@@ -4229,10 +4535,11 @@ class TaskService extends BaseService {
|
|
|
4229
4535
|
}
|
|
4230
4536
|
/**
|
|
4231
4537
|
* Gets a task by ID
|
|
4538
|
+
* IMPORTANT: For form tasks, folderId must be provided.
|
|
4232
4539
|
*
|
|
4233
4540
|
* @param id - The ID of the task to retrieve
|
|
4234
4541
|
* @param options - Optional query parameters
|
|
4235
|
-
* @param folderId - Optional folder ID
|
|
4542
|
+
* @param folderId - Optional folder ID (REQUIRED for form tasks)
|
|
4236
4543
|
* @returns Promise resolving to the task (form tasks will return form-specific data)
|
|
4237
4544
|
*
|
|
4238
4545
|
* @example
|
|
@@ -4245,9 +4552,11 @@ class TaskService extends BaseService {
|
|
|
4245
4552
|
*/
|
|
4246
4553
|
async getById(id, options = {}, folderId) {
|
|
4247
4554
|
const headers = createHeaders({ [FOLDER_ID]: folderId });
|
|
4555
|
+
// Add default expand parameters
|
|
4556
|
+
const modifiedOptions = this.addDefaultExpand(options);
|
|
4248
4557
|
// prefix all keys in options
|
|
4249
|
-
const keysToPrefix = Object.keys(
|
|
4250
|
-
const apiOptions = addPrefixToKeys(
|
|
4558
|
+
const keysToPrefix = Object.keys(modifiedOptions);
|
|
4559
|
+
const apiOptions = addPrefixToKeys(modifiedOptions, ODATA_PREFIX, keysToPrefix);
|
|
4251
4560
|
const response = await this.get(TASK_ENDPOINTS.GET_BY_ID(id), {
|
|
4252
4561
|
params: apiOptions,
|
|
4253
4562
|
headers
|
|
@@ -4257,7 +4566,7 @@ class TaskService extends BaseService {
|
|
|
4257
4566
|
// Check if this is a form task and get form-specific data if it is
|
|
4258
4567
|
if (transformedTask.type === exports.TaskType.Form) {
|
|
4259
4568
|
const formOptions = { expandOnFormLayout: true };
|
|
4260
|
-
return this.getFormTaskById(id, folderId || transformedTask.
|
|
4569
|
+
return this.getFormTaskById(id, folderId || transformedTask.folderId, formOptions);
|
|
4261
4570
|
}
|
|
4262
4571
|
return createTaskWithMethods(applyDataTransforms(transformedTask, { field: 'status', valueMap: TaskStatusMap }), this);
|
|
4263
4572
|
}
|
|
@@ -4265,7 +4574,6 @@ class TaskService extends BaseService {
|
|
|
4265
4574
|
* Assigns tasks to users
|
|
4266
4575
|
*
|
|
4267
4576
|
* @param taskAssignments - Single task assignment or array of task assignments
|
|
4268
|
-
* @param folderId - Optional folder ID
|
|
4269
4577
|
* @returns Promise resolving to array of task assignment results
|
|
4270
4578
|
*
|
|
4271
4579
|
* @example
|
|
@@ -4295,8 +4603,7 @@ class TaskService extends BaseService {
|
|
|
4295
4603
|
* ]);
|
|
4296
4604
|
* ```
|
|
4297
4605
|
*/
|
|
4298
|
-
async assign(taskAssignments
|
|
4299
|
-
const headers = createHeaders({ [FOLDER_ID]: folderId });
|
|
4606
|
+
async assign(taskAssignments) {
|
|
4300
4607
|
// Normalize input to array
|
|
4301
4608
|
const assignmentArray = Array.isArray(taskAssignments) ? taskAssignments : [taskAssignments];
|
|
4302
4609
|
const options = {
|
|
@@ -4304,7 +4611,7 @@ class TaskService extends BaseService {
|
|
|
4304
4611
|
};
|
|
4305
4612
|
// Convert options to PascalCase for API
|
|
4306
4613
|
const pascalOptions = camelToPascalCaseKeys(options);
|
|
4307
|
-
const response = await this.post(TASK_ENDPOINTS.ASSIGN_TASKS, pascalOptions
|
|
4614
|
+
const response = await this.post(TASK_ENDPOINTS.ASSIGN_TASKS, pascalOptions);
|
|
4308
4615
|
// Transform response from PascalCase to camelCase
|
|
4309
4616
|
const transformedResponse = pascalToCamelCaseKeys(response.data);
|
|
4310
4617
|
// Process OData array response - empty array = success, non-empty = error
|
|
@@ -4314,7 +4621,6 @@ class TaskService extends BaseService {
|
|
|
4314
4621
|
* Reassigns tasks to new users
|
|
4315
4622
|
*
|
|
4316
4623
|
* @param taskAssignments - Single task assignment or array of task assignments
|
|
4317
|
-
* @param folderId - Optional folder ID
|
|
4318
4624
|
* @returns Promise resolving to array of task assignment results
|
|
4319
4625
|
*
|
|
4320
4626
|
* @example
|
|
@@ -4344,8 +4650,7 @@ class TaskService extends BaseService {
|
|
|
4344
4650
|
* ]);
|
|
4345
4651
|
* ```
|
|
4346
4652
|
*/
|
|
4347
|
-
async reassign(taskAssignments
|
|
4348
|
-
const headers = createHeaders({ [FOLDER_ID]: folderId });
|
|
4653
|
+
async reassign(taskAssignments) {
|
|
4349
4654
|
// Normalize input to array
|
|
4350
4655
|
const assignmentArray = Array.isArray(taskAssignments) ? taskAssignments : [taskAssignments];
|
|
4351
4656
|
const options = {
|
|
@@ -4353,7 +4658,7 @@ class TaskService extends BaseService {
|
|
|
4353
4658
|
};
|
|
4354
4659
|
// Convert options to PascalCase for API
|
|
4355
4660
|
const pascalOptions = camelToPascalCaseKeys(options);
|
|
4356
|
-
const response = await this.post(TASK_ENDPOINTS.REASSIGN_TASKS, pascalOptions
|
|
4661
|
+
const response = await this.post(TASK_ENDPOINTS.REASSIGN_TASKS, pascalOptions);
|
|
4357
4662
|
// Transform response from PascalCase to camelCase
|
|
4358
4663
|
const transformedResponse = pascalToCamelCaseKeys(response.data);
|
|
4359
4664
|
// Process OData array response - empty array = success, non-empty = error
|
|
@@ -4363,7 +4668,6 @@ class TaskService extends BaseService {
|
|
|
4363
4668
|
* Unassigns tasks (removes current assignees)
|
|
4364
4669
|
*
|
|
4365
4670
|
* @param taskIds - Single task ID or array of task IDs to unassign
|
|
4366
|
-
* @param folderId - Optional folder ID
|
|
4367
4671
|
* @returns Promise resolving to array of task assignment results
|
|
4368
4672
|
*
|
|
4369
4673
|
* @example
|
|
@@ -4375,14 +4679,13 @@ class TaskService extends BaseService {
|
|
|
4375
4679
|
* const result = await sdk.tasks.unassign([123, 456, 789]);
|
|
4376
4680
|
* ```
|
|
4377
4681
|
*/
|
|
4378
|
-
async unassign(taskIds
|
|
4379
|
-
const headers = createHeaders({ [FOLDER_ID]: folderId });
|
|
4682
|
+
async unassign(taskIds) {
|
|
4380
4683
|
// Normalize input to array
|
|
4381
4684
|
const taskIdArray = Array.isArray(taskIds) ? taskIds : [taskIds];
|
|
4382
4685
|
const options = {
|
|
4383
4686
|
taskIds: taskIdArray
|
|
4384
4687
|
};
|
|
4385
|
-
const response = await this.post(TASK_ENDPOINTS.UNASSIGN_TASKS, options
|
|
4688
|
+
const response = await this.post(TASK_ENDPOINTS.UNASSIGN_TASKS, options);
|
|
4386
4689
|
// Transform response from PascalCase to camelCase
|
|
4387
4690
|
const transformedResponse = pascalToCamelCaseKeys(response.data);
|
|
4388
4691
|
// Process OData array response - empty array = success, non-empty = error
|
|
@@ -4392,30 +4695,31 @@ class TaskService extends BaseService {
|
|
|
4392
4695
|
/**
|
|
4393
4696
|
* Completes a task with the specified type and data
|
|
4394
4697
|
*
|
|
4395
|
-
* @param
|
|
4396
|
-
* @param options - The completion options
|
|
4698
|
+
* @param options - The completion options including task type, taskId, data, and action
|
|
4397
4699
|
* @param folderId - Required folder ID
|
|
4398
|
-
* @returns Promise resolving to
|
|
4700
|
+
* @returns Promise resolving to completion result
|
|
4399
4701
|
*
|
|
4400
4702
|
* @example
|
|
4401
4703
|
* ```typescript
|
|
4402
4704
|
* // Complete an app task
|
|
4403
|
-
* await sdk.tasks.complete(
|
|
4705
|
+
* await sdk.tasks.complete({
|
|
4706
|
+
* type: TaskType.App,
|
|
4404
4707
|
* taskId: 456,
|
|
4405
4708
|
* data: {},
|
|
4406
4709
|
* action: "submit"
|
|
4407
4710
|
* }, 123); // folderId is required
|
|
4408
4711
|
*
|
|
4409
4712
|
* // Complete an external task
|
|
4410
|
-
* await sdk.tasks.complete(
|
|
4713
|
+
* await sdk.tasks.complete({
|
|
4714
|
+
* type: TaskType.External,
|
|
4411
4715
|
* taskId: 789
|
|
4412
4716
|
* }, 123); // folderId is required
|
|
4413
4717
|
* ```
|
|
4414
4718
|
*/
|
|
4415
|
-
async complete(
|
|
4719
|
+
async complete(options, folderId) {
|
|
4416
4720
|
const headers = createHeaders({ [FOLDER_ID]: folderId });
|
|
4417
4721
|
let endpoint;
|
|
4418
|
-
switch (
|
|
4722
|
+
switch (options.type) {
|
|
4419
4723
|
case exports.TaskType.Form:
|
|
4420
4724
|
endpoint = TASK_ENDPOINTS.COMPLETE_FORM_TASK;
|
|
4421
4725
|
break;
|
|
@@ -4454,6 +4758,19 @@ class TaskService extends BaseService {
|
|
|
4454
4758
|
const transformedFormTask = transformData(response.data, TaskMap);
|
|
4455
4759
|
return createTaskWithMethods(applyDataTransforms(transformedFormTask, { field: 'status', valueMap: TaskStatusMap }), this);
|
|
4456
4760
|
}
|
|
4761
|
+
/**
|
|
4762
|
+
* Adds default expand parameters to options
|
|
4763
|
+
* @param options - The options object to add default expand to
|
|
4764
|
+
* @returns Options with default expand parameters added
|
|
4765
|
+
* @private
|
|
4766
|
+
*/
|
|
4767
|
+
addDefaultExpand(options) {
|
|
4768
|
+
const processedOptions = { ...options };
|
|
4769
|
+
processedOptions.expand = processedOptions.expand
|
|
4770
|
+
? `${DEFAULT_TASK_EXPAND},${processedOptions.expand}`
|
|
4771
|
+
: DEFAULT_TASK_EXPAND;
|
|
4772
|
+
return processedOptions;
|
|
4773
|
+
}
|
|
4457
4774
|
}
|
|
4458
4775
|
__decorate([
|
|
4459
4776
|
track('Tasks.Create')
|
|
@@ -5046,17 +5363,6 @@ const BucketMap = {
|
|
|
5046
5363
|
verb: 'httpMethod'
|
|
5047
5364
|
};
|
|
5048
5365
|
|
|
5049
|
-
// Import file-type dynamically to avoid issues in browser environment
|
|
5050
|
-
// This variable will hold the fileTypeFromBuffer function when in Node.js environment
|
|
5051
|
-
let fileTypeFromBuffer;
|
|
5052
|
-
// Only import in Node.js environment
|
|
5053
|
-
if (!isBrowser) {
|
|
5054
|
-
import('file-type').then(module => {
|
|
5055
|
-
fileTypeFromBuffer = module.fileTypeFromBuffer;
|
|
5056
|
-
}).catch(err => {
|
|
5057
|
-
console.debug('Could not load file-type module:', err);
|
|
5058
|
-
});
|
|
5059
|
-
}
|
|
5060
5366
|
class BucketService extends FolderScopedService {
|
|
5061
5367
|
/**
|
|
5062
5368
|
* @hideconstructor
|
|
@@ -5229,19 +5535,18 @@ class BucketService extends FolderScopedService {
|
|
|
5229
5535
|
* content: file
|
|
5230
5536
|
* });
|
|
5231
5537
|
*
|
|
5232
|
-
* // In Node env with
|
|
5538
|
+
* // In Node env with Buffer
|
|
5233
5539
|
* const buffer = Buffer.from('file content');
|
|
5234
5540
|
* const result = await sdk.buckets.uploadFile({
|
|
5235
5541
|
* bucketId: 123,
|
|
5236
5542
|
* folderId: 456,
|
|
5237
5543
|
* path: '/folder/example.txt',
|
|
5238
|
-
* content: buffer
|
|
5239
|
-
* contentType: 'text/plain'
|
|
5544
|
+
* content: buffer
|
|
5240
5545
|
* });
|
|
5241
5546
|
* ```
|
|
5242
5547
|
*/
|
|
5243
5548
|
async uploadFile(options) {
|
|
5244
|
-
const { bucketId, folderId, path, content
|
|
5549
|
+
const { bucketId, folderId, path, content } = options;
|
|
5245
5550
|
if (!bucketId) {
|
|
5246
5551
|
throw new ValidationError({ message: 'bucketId is required for uploadFile' });
|
|
5247
5552
|
}
|
|
@@ -5255,19 +5560,13 @@ class BucketService extends FolderScopedService {
|
|
|
5255
5560
|
throw new ValidationError({ message: 'content is required for uploadFile' });
|
|
5256
5561
|
}
|
|
5257
5562
|
try {
|
|
5258
|
-
// Get write URI for upload with detected content type if not provided
|
|
5259
|
-
let detectedContentType = contentType;
|
|
5260
|
-
if (!detectedContentType) {
|
|
5261
|
-
detectedContentType = await this._determineContentType(content, path);
|
|
5262
|
-
}
|
|
5263
5563
|
const uriResponse = await this._getWriteUri({
|
|
5264
5564
|
bucketId,
|
|
5265
5565
|
folderId,
|
|
5266
5566
|
path,
|
|
5267
|
-
contentType: detectedContentType
|
|
5268
5567
|
});
|
|
5269
5568
|
// Upload file to the provided URI
|
|
5270
|
-
const response = await this._uploadToUri(uriResponse, content
|
|
5569
|
+
const response = await this._uploadToUri(uriResponse, content);
|
|
5271
5570
|
return {
|
|
5272
5571
|
success: response.status >= 200 && response.status < 300,
|
|
5273
5572
|
statusCode: response.status
|
|
@@ -5278,61 +5577,42 @@ class BucketService extends FolderScopedService {
|
|
|
5278
5577
|
}
|
|
5279
5578
|
}
|
|
5280
5579
|
/**
|
|
5281
|
-
*
|
|
5282
|
-
* Uses a hybrid approach:
|
|
5283
|
-
* 1. Checks Blob/File type if available (browser)
|
|
5284
|
-
* 2. Uses content-based detection with file-type (primarily Node.js)
|
|
5285
|
-
* 3. Falls back to extension-based detection with mime-types
|
|
5286
|
-
* 4. Finally defaults to application/octet-stream
|
|
5580
|
+
* Gets a direct download URL for a file in the bucket
|
|
5287
5581
|
*
|
|
5288
|
-
* @param
|
|
5289
|
-
* @
|
|
5290
|
-
*
|
|
5582
|
+
* @param options - Contains bucketId, folderId, file path and optional expiry time
|
|
5583
|
+
* @returns Promise resolving to blob file access information
|
|
5584
|
+
*
|
|
5585
|
+
* @example
|
|
5586
|
+
* ```typescript
|
|
5587
|
+
* // Get download URL for a file
|
|
5588
|
+
* const fileAccess = await sdk.buckets.getReadUri({
|
|
5589
|
+
* bucketId: 123,
|
|
5590
|
+
* folderId: 456,
|
|
5591
|
+
* path: '/folder/file.pdf'
|
|
5592
|
+
* });
|
|
5593
|
+
* ```
|
|
5291
5594
|
*/
|
|
5292
|
-
async
|
|
5293
|
-
|
|
5294
|
-
|
|
5295
|
-
|
|
5296
|
-
|
|
5297
|
-
|
|
5298
|
-
|
|
5299
|
-
try {
|
|
5300
|
-
const fileTypeResult = await fileTypeFromBuffer(content);
|
|
5301
|
-
if (fileTypeResult?.mime) {
|
|
5302
|
-
return fileTypeResult.mime;
|
|
5303
|
-
}
|
|
5304
|
-
}
|
|
5305
|
-
catch (error) {
|
|
5306
|
-
// Silently continue to next detection method if this fails
|
|
5307
|
-
console.debug('Content-based type detection failed:', error);
|
|
5308
|
-
}
|
|
5309
|
-
}
|
|
5310
|
-
// 3. Try to infer from file extension using mime-types library
|
|
5311
|
-
const mimeType = mimeTypes__namespace.lookup(path);
|
|
5312
|
-
if (mimeType) {
|
|
5313
|
-
return mimeType;
|
|
5314
|
-
}
|
|
5315
|
-
// 4. Final fallback
|
|
5316
|
-
return CONTENT_TYPES.OCTET_STREAM;
|
|
5595
|
+
async getReadUri(options) {
|
|
5596
|
+
const { bucketId, folderId, path, expiryInMinutes, ...restOptions } = options;
|
|
5597
|
+
const queryOptions = {
|
|
5598
|
+
expiryInMinutes,
|
|
5599
|
+
...addPrefixToKeys(restOptions, ODATA_PREFIX, Object.keys(restOptions))
|
|
5600
|
+
};
|
|
5601
|
+
return this._getUri(BUCKET_ENDPOINTS.GET_READ_URI(bucketId), bucketId, folderId, path, queryOptions);
|
|
5317
5602
|
}
|
|
5318
5603
|
/**
|
|
5319
5604
|
* Uploads content to the provided URI
|
|
5320
5605
|
* @param uriResponse - Response from getWriteUri containing URL and headers
|
|
5321
5606
|
* @param content - The content to upload
|
|
5322
|
-
* @param contentType - The content type of the file
|
|
5323
5607
|
* @returns The response from the upload request with status info
|
|
5324
5608
|
*/
|
|
5325
|
-
async _uploadToUri(uriResponse, content
|
|
5609
|
+
async _uploadToUri(uriResponse, content) {
|
|
5326
5610
|
const { uri, headers = {}, requiresAuth } = uriResponse;
|
|
5327
5611
|
if (!uri) {
|
|
5328
5612
|
throw new ValidationError({ message: 'Upload URI not available', statusCode: HttpStatus.BAD_REQUEST });
|
|
5329
5613
|
}
|
|
5330
5614
|
// Create headers for the request
|
|
5331
5615
|
let requestHeaders = { ...headers };
|
|
5332
|
-
// Ensure content-type is set if provided
|
|
5333
|
-
if (contentType && !requestHeaders['content-type']) {
|
|
5334
|
-
requestHeaders['content-type'] = contentType;
|
|
5335
|
-
}
|
|
5336
5616
|
// Add auth header if required
|
|
5337
5617
|
if (requiresAuth) {
|
|
5338
5618
|
try {
|
|
@@ -5404,41 +5684,16 @@ class BucketService extends FolderScopedService {
|
|
|
5404
5684
|
}
|
|
5405
5685
|
return transformedData;
|
|
5406
5686
|
}
|
|
5407
|
-
/**
|
|
5408
|
-
* Gets a direct download URL for a file in the bucket
|
|
5409
|
-
*
|
|
5410
|
-
* @param options - Contains bucketId, folderId, file path and optional expiry time
|
|
5411
|
-
* @returns Promise resolving to blob file access information
|
|
5412
|
-
*
|
|
5413
|
-
* @example
|
|
5414
|
-
* ```typescript
|
|
5415
|
-
* // Get download URL for a file
|
|
5416
|
-
* const fileAccess = await sdk.buckets.getReadUri({
|
|
5417
|
-
* bucketId: 123,
|
|
5418
|
-
* folderId: 456,
|
|
5419
|
-
* path: '/folder/file.pdf'
|
|
5420
|
-
* });
|
|
5421
|
-
* ```
|
|
5422
|
-
*/
|
|
5423
|
-
async getReadUri(options) {
|
|
5424
|
-
const { bucketId, folderId, path, expiryInMinutes, ...restOptions } = options;
|
|
5425
|
-
const queryOptions = {
|
|
5426
|
-
expiryInMinutes,
|
|
5427
|
-
...addPrefixToKeys(restOptions, ODATA_PREFIX, Object.keys(restOptions))
|
|
5428
|
-
};
|
|
5429
|
-
return this._getUri(BUCKET_ENDPOINTS.GET_READ_URI(bucketId), bucketId, folderId, path, queryOptions);
|
|
5430
|
-
}
|
|
5431
5687
|
/**
|
|
5432
5688
|
* Gets a direct upload URL for a file in the bucket
|
|
5433
5689
|
*
|
|
5434
|
-
* @param options - Contains bucketId, folderId, file path, optional expiry time
|
|
5690
|
+
* @param options - Contains bucketId, folderId, file path, optional expiry time
|
|
5435
5691
|
* @returns Promise resolving to blob file access information
|
|
5436
5692
|
*/
|
|
5437
5693
|
async _getWriteUri(options) {
|
|
5438
|
-
const { bucketId, folderId, path, expiryInMinutes,
|
|
5694
|
+
const { bucketId, folderId, path, expiryInMinutes, ...restOptions } = options;
|
|
5439
5695
|
const queryOptions = {
|
|
5440
5696
|
expiryInMinutes,
|
|
5441
|
-
contentType,
|
|
5442
5697
|
...addPrefixToKeys(restOptions, ODATA_PREFIX, Object.keys(restOptions))
|
|
5443
5698
|
};
|
|
5444
5699
|
return this._getUri(BUCKET_ENDPOINTS.GET_WRITE_URI(bucketId), bucketId, folderId, path, queryOptions);
|
|
@@ -5886,7 +6141,11 @@ class UiPath {
|
|
|
5886
6141
|
/**
|
|
5887
6142
|
* Access to Process Instances service
|
|
5888
6143
|
*/
|
|
5889
|
-
instances: this.getService(ProcessInstancesService)
|
|
6144
|
+
instances: this.getService(ProcessInstancesService),
|
|
6145
|
+
/**
|
|
6146
|
+
* Access to Process Incidents service
|
|
6147
|
+
*/
|
|
6148
|
+
incidents: this.getService(ProcessIncidentsService)
|
|
5890
6149
|
}),
|
|
5891
6150
|
/**
|
|
5892
6151
|
* Access to Maestro Cases service
|
|
@@ -6128,6 +6387,7 @@ exports.ValidationError = ValidationError;
|
|
|
6128
6387
|
exports.createCaseInstanceWithMethods = createCaseInstanceWithMethods;
|
|
6129
6388
|
exports.createEntityWithMethods = createEntityWithMethods;
|
|
6130
6389
|
exports.createProcessInstanceWithMethods = createProcessInstanceWithMethods;
|
|
6390
|
+
exports.createProcessWithMethods = createProcessWithMethods;
|
|
6131
6391
|
exports.createTaskWithMethods = createTaskWithMethods;
|
|
6132
6392
|
exports.getErrorDetails = getErrorDetails;
|
|
6133
6393
|
exports.getLimitedPageSize = getLimitedPageSize;
|