@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
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { BatchLogRecordProcessor, LoggerProvider } from '@opentelemetry/sdk-logs';
|
|
3
|
-
import * as mimeTypes from 'mime-types';
|
|
4
3
|
import axios from 'axios';
|
|
5
4
|
|
|
6
5
|
z.object({
|
|
@@ -560,7 +559,7 @@ class ErrorFactory {
|
|
|
560
559
|
* Creates appropriate error instance based on HTTP status code
|
|
561
560
|
*/
|
|
562
561
|
static createFromHttpStatus(statusCode, errorInfo) {
|
|
563
|
-
const { message, requestId
|
|
562
|
+
const { message, requestId } = errorInfo;
|
|
564
563
|
// Map status codes to error types
|
|
565
564
|
switch (statusCode) {
|
|
566
565
|
case HttpStatus.BAD_REQUEST:
|
|
@@ -978,6 +977,8 @@ function createHeaders(headersObj) {
|
|
|
978
977
|
* Prefix used for OData query parameters
|
|
979
978
|
*/
|
|
980
979
|
const ODATA_PREFIX = '$';
|
|
980
|
+
const UNKNOWN$1 = 'Unknown';
|
|
981
|
+
const NO_INSTANCE = 'no-instance';
|
|
981
982
|
/**
|
|
982
983
|
* OData pagination constants
|
|
983
984
|
*/
|
|
@@ -1470,12 +1471,12 @@ class PaginationHelpers {
|
|
|
1470
1471
|
throw new Error('jumpToPage is not supported for token-based pagination. Use cursor-based navigation instead.');
|
|
1471
1472
|
}
|
|
1472
1473
|
// Get processed parameters
|
|
1473
|
-
return PaginationHelpers.getRequestParameters(options);
|
|
1474
|
+
return PaginationHelpers.getRequestParameters(options, paginationType);
|
|
1474
1475
|
}
|
|
1475
1476
|
/**
|
|
1476
1477
|
* Convert a unified pagination options to service-specific parameters
|
|
1477
1478
|
*/
|
|
1478
|
-
static getRequestParameters(options) {
|
|
1479
|
+
static getRequestParameters(options, paginationType) {
|
|
1479
1480
|
// Handle jumpToPage
|
|
1480
1481
|
if (options.jumpToPage !== undefined) {
|
|
1481
1482
|
const jumpToPageOptions = {
|
|
@@ -1488,7 +1489,8 @@ class PaginationHelpers {
|
|
|
1488
1489
|
if (!options.cursor) {
|
|
1489
1490
|
const firstPageOptions = {
|
|
1490
1491
|
pageSize: options.pageSize,
|
|
1491
|
-
pageNumber
|
|
1492
|
+
// Only set pageNumber for OFFSET pagination
|
|
1493
|
+
pageNumber: paginationType === PaginationType.OFFSET ? 1 : undefined
|
|
1492
1494
|
};
|
|
1493
1495
|
return filterUndefined(firstPageOptions);
|
|
1494
1496
|
}
|
|
@@ -1779,7 +1781,7 @@ class BaseService {
|
|
|
1779
1781
|
pageInfo: {
|
|
1780
1782
|
hasMore,
|
|
1781
1783
|
totalCount,
|
|
1782
|
-
currentPage: params.pageNumber
|
|
1784
|
+
currentPage: params.pageNumber,
|
|
1783
1785
|
pageSize: params.pageSize,
|
|
1784
1786
|
continuationToken
|
|
1785
1787
|
},
|
|
@@ -2086,6 +2088,11 @@ const MAESTRO_ENDPOINTS = {
|
|
|
2086
2088
|
PAUSE: (instanceId) => `pims_/api/v1/instances/${instanceId}/pause`,
|
|
2087
2089
|
RESUME: (instanceId) => `pims_/api/v1/instances/${instanceId}/resume`,
|
|
2088
2090
|
},
|
|
2091
|
+
INCIDENTS: {
|
|
2092
|
+
GET_ALL: 'pims_/api/v1/incidents/summary',
|
|
2093
|
+
GET_BY_PROCESS: (processKey) => `pims_/api/v1/incidents/process/${processKey}`,
|
|
2094
|
+
GET_BY_INSTANCE: (instanceId) => `pims_/api/v1/instances/${instanceId}/incidents`,
|
|
2095
|
+
},
|
|
2089
2096
|
CASES: {
|
|
2090
2097
|
GET_CASE_JSON: (instanceId) => `pims_/api/v1/cases/${instanceId}/case-json`,
|
|
2091
2098
|
GET_ELEMENT_EXECUTIONS: (instanceId) => `pims_/api/v1alpha1/element-executions/case-instances/${instanceId}`,
|
|
@@ -2712,7 +2719,7 @@ const EntityFieldTypeMap = {
|
|
|
2712
2719
|
// Connection string placeholder that will be replaced during build
|
|
2713
2720
|
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";
|
|
2714
2721
|
// SDK Version placeholder
|
|
2715
|
-
const SDK_VERSION = "1.0.0-beta.
|
|
2722
|
+
const SDK_VERSION = "1.0.0-beta.15";
|
|
2716
2723
|
const VERSION = "Version";
|
|
2717
2724
|
const SERVICE = "Service";
|
|
2718
2725
|
const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
|
|
@@ -3297,46 +3304,161 @@ __decorate([
|
|
|
3297
3304
|
], EntityService.prototype, "getAll", null);
|
|
3298
3305
|
|
|
3299
3306
|
/**
|
|
3300
|
-
*
|
|
3307
|
+
* Maestro Process Models
|
|
3308
|
+
* Model classes for Maestro processes
|
|
3301
3309
|
*/
|
|
3302
|
-
|
|
3310
|
+
/**
|
|
3311
|
+
* Creates methods for a process object
|
|
3312
|
+
*
|
|
3313
|
+
* @param processData - The process data (response from API)
|
|
3314
|
+
* @param service - The process service instance
|
|
3315
|
+
* @returns Object containing process methods
|
|
3316
|
+
*/
|
|
3317
|
+
function createProcessMethods(processData, service) {
|
|
3318
|
+
return {
|
|
3319
|
+
async getIncidents() {
|
|
3320
|
+
if (!processData.processKey)
|
|
3321
|
+
throw new Error('Process key is undefined');
|
|
3322
|
+
if (!processData.folderKey)
|
|
3323
|
+
throw new Error('Folder key is undefined');
|
|
3324
|
+
return service.getIncidents(processData.processKey, processData.folderKey);
|
|
3325
|
+
}
|
|
3326
|
+
};
|
|
3327
|
+
}
|
|
3328
|
+
/**
|
|
3329
|
+
* Creates an actionable process by combining API process data with operational methods.
|
|
3330
|
+
*
|
|
3331
|
+
* @param processData - The process data from API
|
|
3332
|
+
* @param service - The process service instance
|
|
3333
|
+
* @returns A process object with added methods
|
|
3334
|
+
*/
|
|
3335
|
+
function createProcessWithMethods(processData, service) {
|
|
3336
|
+
const methods = createProcessMethods(processData, service);
|
|
3337
|
+
return Object.assign({}, processData, methods);
|
|
3338
|
+
}
|
|
3339
|
+
|
|
3340
|
+
/**
|
|
3341
|
+
* Maps fields for Incident entities
|
|
3342
|
+
*/
|
|
3343
|
+
const ProcessIncidentMap = {
|
|
3344
|
+
errorTimeUtc: 'errorTime'
|
|
3345
|
+
};
|
|
3346
|
+
/**
|
|
3347
|
+
* Maps fields for Incident Summary entities
|
|
3348
|
+
*/
|
|
3349
|
+
const ProcessIncidentSummaryMap = {
|
|
3350
|
+
firstTimeUtc: 'firstOccuranceTime'
|
|
3351
|
+
};
|
|
3352
|
+
|
|
3353
|
+
/**
|
|
3354
|
+
* Helpers for fetching BPMN XML and extracting element details used to annotate responses
|
|
3355
|
+
*/
|
|
3356
|
+
class BpmnHelpers {
|
|
3303
3357
|
/**
|
|
3304
|
-
*
|
|
3358
|
+
* Parse BPMN XML and extract element id → {name,type} used for incidents
|
|
3305
3359
|
*/
|
|
3306
|
-
|
|
3307
|
-
|
|
3360
|
+
static parseBpmnElementsForIncidents(bpmnXml) {
|
|
3361
|
+
const elementInfo = {};
|
|
3362
|
+
try {
|
|
3363
|
+
// Find <bpmn:...> start tags and capture the element type.
|
|
3364
|
+
// Then read 'id' and 'name' attributes from each tag.
|
|
3365
|
+
const bpmnOpenTagRegex = /<bpmn:([A-Za-z][\w.-]*)\b[^>]*>/g;
|
|
3366
|
+
for (const tagMatch of bpmnXml.matchAll(bpmnOpenTagRegex)) {
|
|
3367
|
+
const [fullTag, elementType] = tagMatch;
|
|
3368
|
+
// Extract attributes from the current tag text.
|
|
3369
|
+
const idMatch = /\bid\s*=\s*"([^"]*)"/.exec(fullTag);
|
|
3370
|
+
if (!idMatch) {
|
|
3371
|
+
continue;
|
|
3372
|
+
}
|
|
3373
|
+
const elementId = idMatch[1];
|
|
3374
|
+
const nameMatch = /\bname\s*=\s*"([^"]*)"/.exec(fullTag);
|
|
3375
|
+
const name = nameMatch ? nameMatch[1] : '';
|
|
3376
|
+
// Convert BPMN element type to human-readable format
|
|
3377
|
+
const activityType = this.formatActivityTypeForIncidents(elementType);
|
|
3378
|
+
const activityName = name || elementId;
|
|
3379
|
+
elementInfo[elementId] = {
|
|
3380
|
+
type: activityType,
|
|
3381
|
+
name: activityName
|
|
3382
|
+
};
|
|
3383
|
+
}
|
|
3384
|
+
}
|
|
3385
|
+
catch (error) {
|
|
3386
|
+
console.warn('Failed to parse BPMN XML for incidents:', error);
|
|
3387
|
+
}
|
|
3388
|
+
return elementInfo;
|
|
3308
3389
|
}
|
|
3309
3390
|
/**
|
|
3310
|
-
*
|
|
3311
|
-
* @returns Promise resolving to array of MaestroProcess objects
|
|
3312
|
-
*
|
|
3313
|
-
* @example
|
|
3314
|
-
* ```typescript
|
|
3315
|
-
* // Get all processes
|
|
3316
|
-
* const processes = await sdk.maestro.processes.getAll();
|
|
3317
|
-
*
|
|
3318
|
-
* // Access process information
|
|
3319
|
-
* for (const process of processes) {
|
|
3320
|
-
* console.log(`Process: ${process.processKey}`);
|
|
3321
|
-
* console.log(`Running instances: ${process.runningCount}`);
|
|
3322
|
-
* console.log(`Faulted instances: ${process.faultedCount}`);
|
|
3323
|
-
* }
|
|
3324
|
-
*
|
|
3325
|
-
* ```
|
|
3391
|
+
* Format BPMN element type to human-readable activity type for incidents
|
|
3326
3392
|
*/
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
//
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3393
|
+
static formatActivityTypeForIncidents(elementType) {
|
|
3394
|
+
// Convert camelCase BPMN element types to human-readable format
|
|
3395
|
+
// e.g., "serviceTask" -> "Service Task", "exclusiveGateway" -> "Exclusive Gateway"
|
|
3396
|
+
return elementType
|
|
3397
|
+
.replace(/([A-Z])/g, ' $1') // Add space before uppercase letters
|
|
3398
|
+
.replace(/^./, str => str.toUpperCase()) // Capitalize first letter
|
|
3399
|
+
.trim(); // Remove any leading/trailing spaces
|
|
3400
|
+
}
|
|
3401
|
+
/**
|
|
3402
|
+
* Fetch BPMN via getBpmn and add element name/type to each incident
|
|
3403
|
+
*/
|
|
3404
|
+
static async enrichIncidentsWithBpmnData(incidents, folderKey, service) {
|
|
3405
|
+
// Check if all incidents have the same instanceId
|
|
3406
|
+
const uniqueInstanceIds = [...new Set(incidents.map(i => i.instanceId))];
|
|
3407
|
+
if (uniqueInstanceIds.length === 1) {
|
|
3408
|
+
// Single instance optimization (in case of process instance incidents)
|
|
3409
|
+
const elementInfo = await this.getBpmnElementInfo(uniqueInstanceIds[0], folderKey, service);
|
|
3410
|
+
return incidents.map((incident) => this.transformIncidentWithBpmn(incident, elementInfo));
|
|
3411
|
+
}
|
|
3412
|
+
else {
|
|
3413
|
+
// Multiple instances optimization (in case of process incidents)
|
|
3414
|
+
return this.enrichMultipleInstanceIncidents(incidents, folderKey, service);
|
|
3415
|
+
}
|
|
3416
|
+
}
|
|
3417
|
+
/**
|
|
3418
|
+
* When incidents span multiple instances, fetch BPMN per instance and annotate
|
|
3419
|
+
*/
|
|
3420
|
+
static async enrichMultipleInstanceIncidents(incidents, folderKey, service) {
|
|
3421
|
+
const groups = incidents.reduce((acc, incident) => {
|
|
3422
|
+
const id = incident.instanceId || NO_INSTANCE;
|
|
3423
|
+
(acc[id] = acc[id] || []).push(incident);
|
|
3424
|
+
return acc;
|
|
3425
|
+
}, {});
|
|
3426
|
+
const results = await Promise.all(Object.entries(groups).map(async (entry) => {
|
|
3427
|
+
const [instanceId, groupIncidents] = entry;
|
|
3428
|
+
const elementInfo = await this.getBpmnElementInfo(instanceId, folderKey, service);
|
|
3429
|
+
return groupIncidents.map((incident) => this.transformIncidentWithBpmn(incident, elementInfo));
|
|
3334
3430
|
}));
|
|
3431
|
+
return results.flat();
|
|
3432
|
+
}
|
|
3433
|
+
/**
|
|
3434
|
+
* Retrieve BPMN XML for an instance and derive element id → {name,type}
|
|
3435
|
+
*/
|
|
3436
|
+
static async getBpmnElementInfo(instanceId, folderKey, service) {
|
|
3437
|
+
if (!instanceId || instanceId === NO_INSTANCE) {
|
|
3438
|
+
return {};
|
|
3439
|
+
}
|
|
3440
|
+
try {
|
|
3441
|
+
const bpmnXml = await service.getBpmn(instanceId, folderKey);
|
|
3442
|
+
return this.parseBpmnElementsForIncidents(bpmnXml);
|
|
3443
|
+
}
|
|
3444
|
+
catch (error) {
|
|
3445
|
+
console.warn(`Failed to get BPMN for instance ${instanceId}:`, error);
|
|
3446
|
+
return {};
|
|
3447
|
+
}
|
|
3448
|
+
}
|
|
3449
|
+
/**
|
|
3450
|
+
* Transform a raw incident by attaching element name/type from BPMN
|
|
3451
|
+
*/
|
|
3452
|
+
static transformIncidentWithBpmn(incident, elementInfo) {
|
|
3453
|
+
const element = elementInfo[incident.elementId];
|
|
3454
|
+
const transformed = transformData(incident, ProcessIncidentMap);
|
|
3455
|
+
return {
|
|
3456
|
+
...transformed,
|
|
3457
|
+
incidentElementActivityType: element?.type || UNKNOWN$1,
|
|
3458
|
+
incidentElementActivityName: element?.name || UNKNOWN$1
|
|
3459
|
+
};
|
|
3335
3460
|
}
|
|
3336
3461
|
}
|
|
3337
|
-
__decorate([
|
|
3338
|
-
track('MaestroProcesses.GetAll')
|
|
3339
|
-
], MaestroProcessesService.prototype, "getAll", null);
|
|
3340
3462
|
|
|
3341
3463
|
/**
|
|
3342
3464
|
* Creates methods for a process instance
|
|
@@ -3350,17 +3472,49 @@ function createProcessInstanceMethods(instanceData, service) {
|
|
|
3350
3472
|
async cancel(options) {
|
|
3351
3473
|
if (!instanceData.instanceId)
|
|
3352
3474
|
throw new Error('Process instance ID is undefined');
|
|
3475
|
+
if (!instanceData.folderKey)
|
|
3476
|
+
throw new Error('Process instance folder key is undefined');
|
|
3353
3477
|
return service.cancel(instanceData.instanceId, instanceData.folderKey, options);
|
|
3354
3478
|
},
|
|
3355
3479
|
async pause(options) {
|
|
3356
3480
|
if (!instanceData.instanceId)
|
|
3357
3481
|
throw new Error('Process instance ID is undefined');
|
|
3482
|
+
if (!instanceData.folderKey)
|
|
3483
|
+
throw new Error('Process instance folder key is undefined');
|
|
3358
3484
|
return service.pause(instanceData.instanceId, instanceData.folderKey, options);
|
|
3359
3485
|
},
|
|
3360
3486
|
async resume(options) {
|
|
3361
3487
|
if (!instanceData.instanceId)
|
|
3362
3488
|
throw new Error('Process instance ID is undefined');
|
|
3489
|
+
if (!instanceData.folderKey)
|
|
3490
|
+
throw new Error('Process instance folder key is undefined');
|
|
3363
3491
|
return service.resume(instanceData.instanceId, instanceData.folderKey, options);
|
|
3492
|
+
},
|
|
3493
|
+
async getIncidents() {
|
|
3494
|
+
if (!instanceData.instanceId)
|
|
3495
|
+
throw new Error('Process instance ID is undefined');
|
|
3496
|
+
if (!instanceData.folderKey)
|
|
3497
|
+
throw new Error('Process instance folder key is undefined');
|
|
3498
|
+
return service.getIncidents(instanceData.instanceId, instanceData.folderKey);
|
|
3499
|
+
},
|
|
3500
|
+
async getExecutionHistory() {
|
|
3501
|
+
if (!instanceData.instanceId)
|
|
3502
|
+
throw new Error('Process instance ID is undefined');
|
|
3503
|
+
return service.getExecutionHistory(instanceData.instanceId);
|
|
3504
|
+
},
|
|
3505
|
+
async getBpmn() {
|
|
3506
|
+
if (!instanceData.instanceId)
|
|
3507
|
+
throw new Error('Process instance ID is undefined');
|
|
3508
|
+
if (!instanceData.folderKey)
|
|
3509
|
+
throw new Error('Process instance folder key is undefined');
|
|
3510
|
+
return service.getBpmn(instanceData.instanceId, instanceData.folderKey);
|
|
3511
|
+
},
|
|
3512
|
+
async getVariables(options) {
|
|
3513
|
+
if (!instanceData.instanceId)
|
|
3514
|
+
throw new Error('Process instance ID is undefined');
|
|
3515
|
+
if (!instanceData.folderKey)
|
|
3516
|
+
throw new Error('Process instance folder key is undefined');
|
|
3517
|
+
return service.getVariables(instanceData.instanceId, instanceData.folderKey, options);
|
|
3364
3518
|
}
|
|
3365
3519
|
};
|
|
3366
3520
|
}
|
|
@@ -3376,6 +3530,42 @@ function createProcessInstanceWithMethods(instanceData, service) {
|
|
|
3376
3530
|
return Object.assign({}, instanceData, methods);
|
|
3377
3531
|
}
|
|
3378
3532
|
|
|
3533
|
+
/**
|
|
3534
|
+
* Process Incident Status
|
|
3535
|
+
*/
|
|
3536
|
+
var ProcessIncidentStatus;
|
|
3537
|
+
(function (ProcessIncidentStatus) {
|
|
3538
|
+
ProcessIncidentStatus["Open"] = "Open";
|
|
3539
|
+
ProcessIncidentStatus["Closed"] = "Closed";
|
|
3540
|
+
})(ProcessIncidentStatus || (ProcessIncidentStatus = {}));
|
|
3541
|
+
/**
|
|
3542
|
+
* Process Incident Type
|
|
3543
|
+
*/
|
|
3544
|
+
var ProcessIncidentType;
|
|
3545
|
+
(function (ProcessIncidentType) {
|
|
3546
|
+
ProcessIncidentType["System"] = "System";
|
|
3547
|
+
ProcessIncidentType["User"] = "User";
|
|
3548
|
+
ProcessIncidentType["Deployment"] = "Deployment";
|
|
3549
|
+
})(ProcessIncidentType || (ProcessIncidentType = {}));
|
|
3550
|
+
/**
|
|
3551
|
+
* Process Incident Severity
|
|
3552
|
+
*/
|
|
3553
|
+
var ProcessIncidentSeverity;
|
|
3554
|
+
(function (ProcessIncidentSeverity) {
|
|
3555
|
+
ProcessIncidentSeverity["Error"] = "Error";
|
|
3556
|
+
ProcessIncidentSeverity["Warning"] = "Warning";
|
|
3557
|
+
})(ProcessIncidentSeverity || (ProcessIncidentSeverity = {}));
|
|
3558
|
+
/**
|
|
3559
|
+
* Process Incident Debug Mode
|
|
3560
|
+
*/
|
|
3561
|
+
var DebugMode;
|
|
3562
|
+
(function (DebugMode) {
|
|
3563
|
+
DebugMode["None"] = "None";
|
|
3564
|
+
DebugMode["Default"] = "Default";
|
|
3565
|
+
DebugMode["StepByStep"] = "StepByStep";
|
|
3566
|
+
DebugMode["SingleStep"] = "SingleStep";
|
|
3567
|
+
})(DebugMode || (DebugMode = {}));
|
|
3568
|
+
|
|
3379
3569
|
/**
|
|
3380
3570
|
* Case Instance Types
|
|
3381
3571
|
* Types and interfaces for Maestro case instance management
|
|
@@ -3438,17 +3628,42 @@ function createCaseInstanceMethods(instanceData, service) {
|
|
|
3438
3628
|
async close(options) {
|
|
3439
3629
|
if (!instanceData.instanceId)
|
|
3440
3630
|
throw new Error('Case instance ID is undefined');
|
|
3631
|
+
if (!instanceData.folderKey)
|
|
3632
|
+
throw new Error('Case instance folder key is undefined');
|
|
3441
3633
|
return service.close(instanceData.instanceId, instanceData.folderKey, options);
|
|
3442
3634
|
},
|
|
3443
3635
|
async pause(options) {
|
|
3444
3636
|
if (!instanceData.instanceId)
|
|
3445
3637
|
throw new Error('Case instance ID is undefined');
|
|
3638
|
+
if (!instanceData.folderKey)
|
|
3639
|
+
throw new Error('Case instance folder key is undefined');
|
|
3446
3640
|
return service.pause(instanceData.instanceId, instanceData.folderKey, options);
|
|
3447
3641
|
},
|
|
3448
3642
|
async resume(options) {
|
|
3449
3643
|
if (!instanceData.instanceId)
|
|
3450
3644
|
throw new Error('Case instance ID is undefined');
|
|
3645
|
+
if (!instanceData.folderKey)
|
|
3646
|
+
throw new Error('Case instance folder key is undefined');
|
|
3451
3647
|
return service.resume(instanceData.instanceId, instanceData.folderKey, options);
|
|
3648
|
+
},
|
|
3649
|
+
async getExecutionHistory() {
|
|
3650
|
+
if (!instanceData.instanceId)
|
|
3651
|
+
throw new Error('Case instance ID is undefined');
|
|
3652
|
+
if (!instanceData.folderKey)
|
|
3653
|
+
throw new Error('Case instance folder key is undefined');
|
|
3654
|
+
return service.getExecutionHistory(instanceData.instanceId, instanceData.folderKey);
|
|
3655
|
+
},
|
|
3656
|
+
async getStages() {
|
|
3657
|
+
if (!instanceData.instanceId)
|
|
3658
|
+
throw new Error('Case instance ID is undefined');
|
|
3659
|
+
if (!instanceData.folderKey)
|
|
3660
|
+
throw new Error('Case instance folder key is undefined');
|
|
3661
|
+
return service.getStages(instanceData.instanceId, instanceData.folderKey);
|
|
3662
|
+
},
|
|
3663
|
+
async getActionTasks(options) {
|
|
3664
|
+
if (!instanceData.instanceId)
|
|
3665
|
+
throw new Error('Case instance ID is undefined');
|
|
3666
|
+
return service.getActionTasks(instanceData.instanceId, options);
|
|
3452
3667
|
}
|
|
3453
3668
|
};
|
|
3454
3669
|
}
|
|
@@ -3746,6 +3961,19 @@ class ProcessInstancesService extends BaseService {
|
|
|
3746
3961
|
};
|
|
3747
3962
|
return variablesResponse;
|
|
3748
3963
|
}
|
|
3964
|
+
/**
|
|
3965
|
+
* Get incidents for a process instance
|
|
3966
|
+
* @param instanceId The ID of the instance to get incidents for
|
|
3967
|
+
* @param folderKey The folder key for authorization
|
|
3968
|
+
* @returns Promise<ProcessIncidentGetResponse[]>
|
|
3969
|
+
*/
|
|
3970
|
+
async getIncidents(instanceId, folderKey) {
|
|
3971
|
+
const rawResponse = await this.get(MAESTRO_ENDPOINTS.INCIDENTS.GET_BY_INSTANCE(instanceId), {
|
|
3972
|
+
headers: createHeaders({ [FOLDER_KEY]: folderKey })
|
|
3973
|
+
});
|
|
3974
|
+
// Filter out excluded fields and transform response, then enrich with BPMN data
|
|
3975
|
+
return BpmnHelpers.enrichIncidentsWithBpmnData(rawResponse.data || [], folderKey, this);
|
|
3976
|
+
}
|
|
3749
3977
|
}
|
|
3750
3978
|
__decorate([
|
|
3751
3979
|
track('ProcessInstances.GetAll')
|
|
@@ -3771,6 +3999,101 @@ __decorate([
|
|
|
3771
3999
|
__decorate([
|
|
3772
4000
|
track('ProcessInstances.GetVariables')
|
|
3773
4001
|
], ProcessInstancesService.prototype, "getVariables", null);
|
|
4002
|
+
__decorate([
|
|
4003
|
+
track('ProcessInstances.GetIncidents')
|
|
4004
|
+
], ProcessInstancesService.prototype, "getIncidents", null);
|
|
4005
|
+
|
|
4006
|
+
/**
|
|
4007
|
+
* Service for interacting with Maestro Processes
|
|
4008
|
+
*/
|
|
4009
|
+
class MaestroProcessesService extends BaseService {
|
|
4010
|
+
/**
|
|
4011
|
+
* @hideconstructor
|
|
4012
|
+
*/
|
|
4013
|
+
constructor(config, executionContext, tokenManager) {
|
|
4014
|
+
super(config, executionContext, tokenManager);
|
|
4015
|
+
this.processInstancesService = new ProcessInstancesService(config, executionContext, tokenManager);
|
|
4016
|
+
}
|
|
4017
|
+
/**
|
|
4018
|
+
* Get all processes with their instance statistics
|
|
4019
|
+
* @returns Promise resolving to array of MaestroProcess objects
|
|
4020
|
+
*
|
|
4021
|
+
* @example
|
|
4022
|
+
* ```typescript
|
|
4023
|
+
* // Get all processes
|
|
4024
|
+
* const processes = await sdk.maestro.processes.getAll();
|
|
4025
|
+
*
|
|
4026
|
+
* // Access process information
|
|
4027
|
+
* for (const process of processes) {
|
|
4028
|
+
* console.log(`Process: ${process.processKey}`);
|
|
4029
|
+
* console.log(`Running instances: ${process.runningCount}`);
|
|
4030
|
+
* console.log(`Faulted instances: ${process.faultedCount}`);
|
|
4031
|
+
* }
|
|
4032
|
+
*
|
|
4033
|
+
* ```
|
|
4034
|
+
*/
|
|
4035
|
+
async getAll() {
|
|
4036
|
+
const response = await this.get(MAESTRO_ENDPOINTS.PROCESSES.GET_ALL);
|
|
4037
|
+
// Extract processes array from response data and add name field
|
|
4038
|
+
const processes = response.data?.processes || [];
|
|
4039
|
+
const processesWithName = processes.map(process => ({
|
|
4040
|
+
...process,
|
|
4041
|
+
name: process.packageId
|
|
4042
|
+
}));
|
|
4043
|
+
// Add methods to each process
|
|
4044
|
+
return processesWithName.map(process => createProcessWithMethods(process, this));
|
|
4045
|
+
}
|
|
4046
|
+
/**
|
|
4047
|
+
* Get incidents for a specific process
|
|
4048
|
+
*/
|
|
4049
|
+
async getIncidents(processKey, folderKey) {
|
|
4050
|
+
const rawResponse = await this.get(MAESTRO_ENDPOINTS.INCIDENTS.GET_BY_PROCESS(processKey), {
|
|
4051
|
+
headers: createHeaders({ [FOLDER_KEY]: folderKey })
|
|
4052
|
+
});
|
|
4053
|
+
// Fetch BPMN XML and add element name/type to each incident
|
|
4054
|
+
return BpmnHelpers.enrichIncidentsWithBpmnData(rawResponse.data || [], folderKey, this.processInstancesService);
|
|
4055
|
+
}
|
|
4056
|
+
}
|
|
4057
|
+
__decorate([
|
|
4058
|
+
track('MaestroProcesses.GetAll')
|
|
4059
|
+
], MaestroProcessesService.prototype, "getAll", null);
|
|
4060
|
+
__decorate([
|
|
4061
|
+
track('MaestroProcesses.GetIncidents')
|
|
4062
|
+
], MaestroProcessesService.prototype, "getIncidents", null);
|
|
4063
|
+
|
|
4064
|
+
/**
|
|
4065
|
+
* Service class for Maestro Process Incidents
|
|
4066
|
+
*/
|
|
4067
|
+
class ProcessIncidentsService extends BaseService {
|
|
4068
|
+
/**
|
|
4069
|
+
* Get all process incidents across all folders
|
|
4070
|
+
*
|
|
4071
|
+
* @returns Promise resolving to array of process incident
|
|
4072
|
+
* {@link ProcessIncidentGetAllResponse}
|
|
4073
|
+
* @example
|
|
4074
|
+
* ```typescript
|
|
4075
|
+
* // Get all process incidents across all folders
|
|
4076
|
+
* const incidents = await sdk.maestro.processes.incidents.getAll();
|
|
4077
|
+
*
|
|
4078
|
+
* // Access process incident information
|
|
4079
|
+
* for (const incident of incidents) {
|
|
4080
|
+
* console.log(`Process: ${incident.processKey}`);
|
|
4081
|
+
* console.log(`Error: ${incident.errorMessage}`);
|
|
4082
|
+
* console.log(`Count: ${incident.count}`);
|
|
4083
|
+
* console.log(`First occurrence: ${incident.firstOccuranceTime}`);
|
|
4084
|
+
* }
|
|
4085
|
+
* ```
|
|
4086
|
+
*/
|
|
4087
|
+
async getAll() {
|
|
4088
|
+
const rawResponse = await this.get(MAESTRO_ENDPOINTS.INCIDENTS.GET_ALL);
|
|
4089
|
+
// Transform field names
|
|
4090
|
+
const data = rawResponse.data || [];
|
|
4091
|
+
return data.map(incident => transformData(incident, ProcessIncidentSummaryMap));
|
|
4092
|
+
}
|
|
4093
|
+
}
|
|
4094
|
+
__decorate([
|
|
4095
|
+
track('ProcessIncidents.getAll')
|
|
4096
|
+
], ProcessIncidentsService.prototype, "getAll", null);
|
|
3774
4097
|
|
|
3775
4098
|
/**
|
|
3776
4099
|
* Internal types for Maestro Cases
|
|
@@ -3966,35 +4289,32 @@ function createTaskMethods(taskData, service) {
|
|
|
3966
4289
|
async assign(options) {
|
|
3967
4290
|
if (!taskData.id)
|
|
3968
4291
|
throw new Error('Task ID is undefined');
|
|
3969
|
-
const assignmentOptions =
|
|
3970
|
-
taskId: taskData.id,
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
};
|
|
3974
|
-
return service.assign(assignmentOptions, taskData.organizationUnitId);
|
|
4292
|
+
const assignmentOptions = 'userId' in options && options.userId !== undefined
|
|
4293
|
+
? { taskId: taskData.id, userId: options.userId }
|
|
4294
|
+
: { taskId: taskData.id, userNameOrEmail: options.userNameOrEmail };
|
|
4295
|
+
return service.assign(assignmentOptions);
|
|
3975
4296
|
},
|
|
3976
4297
|
async reassign(options) {
|
|
3977
4298
|
if (!taskData.id)
|
|
3978
4299
|
throw new Error('Task ID is undefined');
|
|
3979
|
-
const assignmentOptions =
|
|
3980
|
-
taskId: taskData.id,
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
};
|
|
3984
|
-
return service.reassign(assignmentOptions, taskData.organizationUnitId);
|
|
4300
|
+
const assignmentOptions = 'userId' in options && options.userId !== undefined
|
|
4301
|
+
? { taskId: taskData.id, userId: options.userId }
|
|
4302
|
+
: { taskId: taskData.id, userNameOrEmail: options.userNameOrEmail };
|
|
4303
|
+
return service.reassign(assignmentOptions);
|
|
3985
4304
|
},
|
|
3986
4305
|
async unassign() {
|
|
3987
4306
|
if (!taskData.id)
|
|
3988
4307
|
throw new Error('Task ID is undefined');
|
|
3989
|
-
return service.unassign(taskData.id
|
|
4308
|
+
return service.unassign(taskData.id);
|
|
3990
4309
|
},
|
|
3991
4310
|
async complete(options) {
|
|
3992
4311
|
if (!taskData.id)
|
|
3993
4312
|
throw new Error('Task ID is undefined');
|
|
3994
|
-
const folderId = taskData.
|
|
4313
|
+
const folderId = taskData.folderId;
|
|
3995
4314
|
if (!folderId)
|
|
3996
4315
|
throw new Error('Folder ID is required');
|
|
3997
|
-
return service.complete(
|
|
4316
|
+
return service.complete({
|
|
4317
|
+
type: options.type,
|
|
3998
4318
|
taskId: taskData.id,
|
|
3999
4319
|
data: options.data,
|
|
4000
4320
|
action: options.action
|
|
@@ -4031,6 +4351,10 @@ const TaskMap = {
|
|
|
4031
4351
|
creationTime: 'createdTime',
|
|
4032
4352
|
organizationUnitId: 'folderId'
|
|
4033
4353
|
};
|
|
4354
|
+
/**
|
|
4355
|
+
* Default expand parameters
|
|
4356
|
+
*/
|
|
4357
|
+
const DEFAULT_TASK_EXPAND = 'AssignedToUser,CreatorUser,LastModifierUser';
|
|
4034
4358
|
|
|
4035
4359
|
/**
|
|
4036
4360
|
* Service for interacting with UiPath Tasks API
|
|
@@ -4049,7 +4373,8 @@ class TaskService extends BaseService {
|
|
|
4049
4373
|
* @private
|
|
4050
4374
|
*/
|
|
4051
4375
|
this.processTaskParameters = (options, folderId) => {
|
|
4052
|
-
|
|
4376
|
+
// Add default expand parameters
|
|
4377
|
+
const processedOptions = this.addDefaultExpand(options);
|
|
4053
4378
|
if (folderId) {
|
|
4054
4379
|
// Create or add to existing filter for folder-specific queries
|
|
4055
4380
|
if (processedOptions.filter) {
|
|
@@ -4208,10 +4533,11 @@ class TaskService extends BaseService {
|
|
|
4208
4533
|
}
|
|
4209
4534
|
/**
|
|
4210
4535
|
* Gets a task by ID
|
|
4536
|
+
* IMPORTANT: For form tasks, folderId must be provided.
|
|
4211
4537
|
*
|
|
4212
4538
|
* @param id - The ID of the task to retrieve
|
|
4213
4539
|
* @param options - Optional query parameters
|
|
4214
|
-
* @param folderId - Optional folder ID
|
|
4540
|
+
* @param folderId - Optional folder ID (REQUIRED for form tasks)
|
|
4215
4541
|
* @returns Promise resolving to the task (form tasks will return form-specific data)
|
|
4216
4542
|
*
|
|
4217
4543
|
* @example
|
|
@@ -4224,9 +4550,11 @@ class TaskService extends BaseService {
|
|
|
4224
4550
|
*/
|
|
4225
4551
|
async getById(id, options = {}, folderId) {
|
|
4226
4552
|
const headers = createHeaders({ [FOLDER_ID]: folderId });
|
|
4553
|
+
// Add default expand parameters
|
|
4554
|
+
const modifiedOptions = this.addDefaultExpand(options);
|
|
4227
4555
|
// prefix all keys in options
|
|
4228
|
-
const keysToPrefix = Object.keys(
|
|
4229
|
-
const apiOptions = addPrefixToKeys(
|
|
4556
|
+
const keysToPrefix = Object.keys(modifiedOptions);
|
|
4557
|
+
const apiOptions = addPrefixToKeys(modifiedOptions, ODATA_PREFIX, keysToPrefix);
|
|
4230
4558
|
const response = await this.get(TASK_ENDPOINTS.GET_BY_ID(id), {
|
|
4231
4559
|
params: apiOptions,
|
|
4232
4560
|
headers
|
|
@@ -4236,7 +4564,7 @@ class TaskService extends BaseService {
|
|
|
4236
4564
|
// Check if this is a form task and get form-specific data if it is
|
|
4237
4565
|
if (transformedTask.type === TaskType.Form) {
|
|
4238
4566
|
const formOptions = { expandOnFormLayout: true };
|
|
4239
|
-
return this.getFormTaskById(id, folderId || transformedTask.
|
|
4567
|
+
return this.getFormTaskById(id, folderId || transformedTask.folderId, formOptions);
|
|
4240
4568
|
}
|
|
4241
4569
|
return createTaskWithMethods(applyDataTransforms(transformedTask, { field: 'status', valueMap: TaskStatusMap }), this);
|
|
4242
4570
|
}
|
|
@@ -4244,7 +4572,6 @@ class TaskService extends BaseService {
|
|
|
4244
4572
|
* Assigns tasks to users
|
|
4245
4573
|
*
|
|
4246
4574
|
* @param taskAssignments - Single task assignment or array of task assignments
|
|
4247
|
-
* @param folderId - Optional folder ID
|
|
4248
4575
|
* @returns Promise resolving to array of task assignment results
|
|
4249
4576
|
*
|
|
4250
4577
|
* @example
|
|
@@ -4274,8 +4601,7 @@ class TaskService extends BaseService {
|
|
|
4274
4601
|
* ]);
|
|
4275
4602
|
* ```
|
|
4276
4603
|
*/
|
|
4277
|
-
async assign(taskAssignments
|
|
4278
|
-
const headers = createHeaders({ [FOLDER_ID]: folderId });
|
|
4604
|
+
async assign(taskAssignments) {
|
|
4279
4605
|
// Normalize input to array
|
|
4280
4606
|
const assignmentArray = Array.isArray(taskAssignments) ? taskAssignments : [taskAssignments];
|
|
4281
4607
|
const options = {
|
|
@@ -4283,7 +4609,7 @@ class TaskService extends BaseService {
|
|
|
4283
4609
|
};
|
|
4284
4610
|
// Convert options to PascalCase for API
|
|
4285
4611
|
const pascalOptions = camelToPascalCaseKeys(options);
|
|
4286
|
-
const response = await this.post(TASK_ENDPOINTS.ASSIGN_TASKS, pascalOptions
|
|
4612
|
+
const response = await this.post(TASK_ENDPOINTS.ASSIGN_TASKS, pascalOptions);
|
|
4287
4613
|
// Transform response from PascalCase to camelCase
|
|
4288
4614
|
const transformedResponse = pascalToCamelCaseKeys(response.data);
|
|
4289
4615
|
// Process OData array response - empty array = success, non-empty = error
|
|
@@ -4293,7 +4619,6 @@ class TaskService extends BaseService {
|
|
|
4293
4619
|
* Reassigns tasks to new users
|
|
4294
4620
|
*
|
|
4295
4621
|
* @param taskAssignments - Single task assignment or array of task assignments
|
|
4296
|
-
* @param folderId - Optional folder ID
|
|
4297
4622
|
* @returns Promise resolving to array of task assignment results
|
|
4298
4623
|
*
|
|
4299
4624
|
* @example
|
|
@@ -4323,8 +4648,7 @@ class TaskService extends BaseService {
|
|
|
4323
4648
|
* ]);
|
|
4324
4649
|
* ```
|
|
4325
4650
|
*/
|
|
4326
|
-
async reassign(taskAssignments
|
|
4327
|
-
const headers = createHeaders({ [FOLDER_ID]: folderId });
|
|
4651
|
+
async reassign(taskAssignments) {
|
|
4328
4652
|
// Normalize input to array
|
|
4329
4653
|
const assignmentArray = Array.isArray(taskAssignments) ? taskAssignments : [taskAssignments];
|
|
4330
4654
|
const options = {
|
|
@@ -4332,7 +4656,7 @@ class TaskService extends BaseService {
|
|
|
4332
4656
|
};
|
|
4333
4657
|
// Convert options to PascalCase for API
|
|
4334
4658
|
const pascalOptions = camelToPascalCaseKeys(options);
|
|
4335
|
-
const response = await this.post(TASK_ENDPOINTS.REASSIGN_TASKS, pascalOptions
|
|
4659
|
+
const response = await this.post(TASK_ENDPOINTS.REASSIGN_TASKS, pascalOptions);
|
|
4336
4660
|
// Transform response from PascalCase to camelCase
|
|
4337
4661
|
const transformedResponse = pascalToCamelCaseKeys(response.data);
|
|
4338
4662
|
// Process OData array response - empty array = success, non-empty = error
|
|
@@ -4342,7 +4666,6 @@ class TaskService extends BaseService {
|
|
|
4342
4666
|
* Unassigns tasks (removes current assignees)
|
|
4343
4667
|
*
|
|
4344
4668
|
* @param taskIds - Single task ID or array of task IDs to unassign
|
|
4345
|
-
* @param folderId - Optional folder ID
|
|
4346
4669
|
* @returns Promise resolving to array of task assignment results
|
|
4347
4670
|
*
|
|
4348
4671
|
* @example
|
|
@@ -4354,14 +4677,13 @@ class TaskService extends BaseService {
|
|
|
4354
4677
|
* const result = await sdk.tasks.unassign([123, 456, 789]);
|
|
4355
4678
|
* ```
|
|
4356
4679
|
*/
|
|
4357
|
-
async unassign(taskIds
|
|
4358
|
-
const headers = createHeaders({ [FOLDER_ID]: folderId });
|
|
4680
|
+
async unassign(taskIds) {
|
|
4359
4681
|
// Normalize input to array
|
|
4360
4682
|
const taskIdArray = Array.isArray(taskIds) ? taskIds : [taskIds];
|
|
4361
4683
|
const options = {
|
|
4362
4684
|
taskIds: taskIdArray
|
|
4363
4685
|
};
|
|
4364
|
-
const response = await this.post(TASK_ENDPOINTS.UNASSIGN_TASKS, options
|
|
4686
|
+
const response = await this.post(TASK_ENDPOINTS.UNASSIGN_TASKS, options);
|
|
4365
4687
|
// Transform response from PascalCase to camelCase
|
|
4366
4688
|
const transformedResponse = pascalToCamelCaseKeys(response.data);
|
|
4367
4689
|
// Process OData array response - empty array = success, non-empty = error
|
|
@@ -4371,30 +4693,31 @@ class TaskService extends BaseService {
|
|
|
4371
4693
|
/**
|
|
4372
4694
|
* Completes a task with the specified type and data
|
|
4373
4695
|
*
|
|
4374
|
-
* @param
|
|
4375
|
-
* @param options - The completion options
|
|
4696
|
+
* @param options - The completion options including task type, taskId, data, and action
|
|
4376
4697
|
* @param folderId - Required folder ID
|
|
4377
|
-
* @returns Promise resolving to
|
|
4698
|
+
* @returns Promise resolving to completion result
|
|
4378
4699
|
*
|
|
4379
4700
|
* @example
|
|
4380
4701
|
* ```typescript
|
|
4381
4702
|
* // Complete an app task
|
|
4382
|
-
* await sdk.tasks.complete(
|
|
4703
|
+
* await sdk.tasks.complete({
|
|
4704
|
+
* type: TaskType.App,
|
|
4383
4705
|
* taskId: 456,
|
|
4384
4706
|
* data: {},
|
|
4385
4707
|
* action: "submit"
|
|
4386
4708
|
* }, 123); // folderId is required
|
|
4387
4709
|
*
|
|
4388
4710
|
* // Complete an external task
|
|
4389
|
-
* await sdk.tasks.complete(
|
|
4711
|
+
* await sdk.tasks.complete({
|
|
4712
|
+
* type: TaskType.External,
|
|
4390
4713
|
* taskId: 789
|
|
4391
4714
|
* }, 123); // folderId is required
|
|
4392
4715
|
* ```
|
|
4393
4716
|
*/
|
|
4394
|
-
async complete(
|
|
4717
|
+
async complete(options, folderId) {
|
|
4395
4718
|
const headers = createHeaders({ [FOLDER_ID]: folderId });
|
|
4396
4719
|
let endpoint;
|
|
4397
|
-
switch (
|
|
4720
|
+
switch (options.type) {
|
|
4398
4721
|
case TaskType.Form:
|
|
4399
4722
|
endpoint = TASK_ENDPOINTS.COMPLETE_FORM_TASK;
|
|
4400
4723
|
break;
|
|
@@ -4433,6 +4756,19 @@ class TaskService extends BaseService {
|
|
|
4433
4756
|
const transformedFormTask = transformData(response.data, TaskMap);
|
|
4434
4757
|
return createTaskWithMethods(applyDataTransforms(transformedFormTask, { field: 'status', valueMap: TaskStatusMap }), this);
|
|
4435
4758
|
}
|
|
4759
|
+
/**
|
|
4760
|
+
* Adds default expand parameters to options
|
|
4761
|
+
* @param options - The options object to add default expand to
|
|
4762
|
+
* @returns Options with default expand parameters added
|
|
4763
|
+
* @private
|
|
4764
|
+
*/
|
|
4765
|
+
addDefaultExpand(options) {
|
|
4766
|
+
const processedOptions = { ...options };
|
|
4767
|
+
processedOptions.expand = processedOptions.expand
|
|
4768
|
+
? `${DEFAULT_TASK_EXPAND},${processedOptions.expand}`
|
|
4769
|
+
: DEFAULT_TASK_EXPAND;
|
|
4770
|
+
return processedOptions;
|
|
4771
|
+
}
|
|
4436
4772
|
}
|
|
4437
4773
|
__decorate([
|
|
4438
4774
|
track('Tasks.Create')
|
|
@@ -5025,17 +5361,6 @@ const BucketMap = {
|
|
|
5025
5361
|
verb: 'httpMethod'
|
|
5026
5362
|
};
|
|
5027
5363
|
|
|
5028
|
-
// Import file-type dynamically to avoid issues in browser environment
|
|
5029
|
-
// This variable will hold the fileTypeFromBuffer function when in Node.js environment
|
|
5030
|
-
let fileTypeFromBuffer;
|
|
5031
|
-
// Only import in Node.js environment
|
|
5032
|
-
if (!isBrowser) {
|
|
5033
|
-
import('file-type').then(module => {
|
|
5034
|
-
fileTypeFromBuffer = module.fileTypeFromBuffer;
|
|
5035
|
-
}).catch(err => {
|
|
5036
|
-
console.debug('Could not load file-type module:', err);
|
|
5037
|
-
});
|
|
5038
|
-
}
|
|
5039
5364
|
class BucketService extends FolderScopedService {
|
|
5040
5365
|
/**
|
|
5041
5366
|
* @hideconstructor
|
|
@@ -5208,19 +5533,18 @@ class BucketService extends FolderScopedService {
|
|
|
5208
5533
|
* content: file
|
|
5209
5534
|
* });
|
|
5210
5535
|
*
|
|
5211
|
-
* // In Node env with
|
|
5536
|
+
* // In Node env with Buffer
|
|
5212
5537
|
* const buffer = Buffer.from('file content');
|
|
5213
5538
|
* const result = await sdk.buckets.uploadFile({
|
|
5214
5539
|
* bucketId: 123,
|
|
5215
5540
|
* folderId: 456,
|
|
5216
5541
|
* path: '/folder/example.txt',
|
|
5217
|
-
* content: buffer
|
|
5218
|
-
* contentType: 'text/plain'
|
|
5542
|
+
* content: buffer
|
|
5219
5543
|
* });
|
|
5220
5544
|
* ```
|
|
5221
5545
|
*/
|
|
5222
5546
|
async uploadFile(options) {
|
|
5223
|
-
const { bucketId, folderId, path, content
|
|
5547
|
+
const { bucketId, folderId, path, content } = options;
|
|
5224
5548
|
if (!bucketId) {
|
|
5225
5549
|
throw new ValidationError({ message: 'bucketId is required for uploadFile' });
|
|
5226
5550
|
}
|
|
@@ -5234,19 +5558,13 @@ class BucketService extends FolderScopedService {
|
|
|
5234
5558
|
throw new ValidationError({ message: 'content is required for uploadFile' });
|
|
5235
5559
|
}
|
|
5236
5560
|
try {
|
|
5237
|
-
// Get write URI for upload with detected content type if not provided
|
|
5238
|
-
let detectedContentType = contentType;
|
|
5239
|
-
if (!detectedContentType) {
|
|
5240
|
-
detectedContentType = await this._determineContentType(content, path);
|
|
5241
|
-
}
|
|
5242
5561
|
const uriResponse = await this._getWriteUri({
|
|
5243
5562
|
bucketId,
|
|
5244
5563
|
folderId,
|
|
5245
5564
|
path,
|
|
5246
|
-
contentType: detectedContentType
|
|
5247
5565
|
});
|
|
5248
5566
|
// Upload file to the provided URI
|
|
5249
|
-
const response = await this._uploadToUri(uriResponse, content
|
|
5567
|
+
const response = await this._uploadToUri(uriResponse, content);
|
|
5250
5568
|
return {
|
|
5251
5569
|
success: response.status >= 200 && response.status < 300,
|
|
5252
5570
|
statusCode: response.status
|
|
@@ -5257,61 +5575,42 @@ class BucketService extends FolderScopedService {
|
|
|
5257
5575
|
}
|
|
5258
5576
|
}
|
|
5259
5577
|
/**
|
|
5260
|
-
*
|
|
5261
|
-
* Uses a hybrid approach:
|
|
5262
|
-
* 1. Checks Blob/File type if available (browser)
|
|
5263
|
-
* 2. Uses content-based detection with file-type (primarily Node.js)
|
|
5264
|
-
* 3. Falls back to extension-based detection with mime-types
|
|
5265
|
-
* 4. Finally defaults to application/octet-stream
|
|
5578
|
+
* Gets a direct download URL for a file in the bucket
|
|
5266
5579
|
*
|
|
5267
|
-
* @param
|
|
5268
|
-
* @
|
|
5269
|
-
*
|
|
5580
|
+
* @param options - Contains bucketId, folderId, file path and optional expiry time
|
|
5581
|
+
* @returns Promise resolving to blob file access information
|
|
5582
|
+
*
|
|
5583
|
+
* @example
|
|
5584
|
+
* ```typescript
|
|
5585
|
+
* // Get download URL for a file
|
|
5586
|
+
* const fileAccess = await sdk.buckets.getReadUri({
|
|
5587
|
+
* bucketId: 123,
|
|
5588
|
+
* folderId: 456,
|
|
5589
|
+
* path: '/folder/file.pdf'
|
|
5590
|
+
* });
|
|
5591
|
+
* ```
|
|
5270
5592
|
*/
|
|
5271
|
-
async
|
|
5272
|
-
|
|
5273
|
-
|
|
5274
|
-
|
|
5275
|
-
|
|
5276
|
-
|
|
5277
|
-
|
|
5278
|
-
try {
|
|
5279
|
-
const fileTypeResult = await fileTypeFromBuffer(content);
|
|
5280
|
-
if (fileTypeResult?.mime) {
|
|
5281
|
-
return fileTypeResult.mime;
|
|
5282
|
-
}
|
|
5283
|
-
}
|
|
5284
|
-
catch (error) {
|
|
5285
|
-
// Silently continue to next detection method if this fails
|
|
5286
|
-
console.debug('Content-based type detection failed:', error);
|
|
5287
|
-
}
|
|
5288
|
-
}
|
|
5289
|
-
// 3. Try to infer from file extension using mime-types library
|
|
5290
|
-
const mimeType = mimeTypes.lookup(path);
|
|
5291
|
-
if (mimeType) {
|
|
5292
|
-
return mimeType;
|
|
5293
|
-
}
|
|
5294
|
-
// 4. Final fallback
|
|
5295
|
-
return CONTENT_TYPES.OCTET_STREAM;
|
|
5593
|
+
async getReadUri(options) {
|
|
5594
|
+
const { bucketId, folderId, path, expiryInMinutes, ...restOptions } = options;
|
|
5595
|
+
const queryOptions = {
|
|
5596
|
+
expiryInMinutes,
|
|
5597
|
+
...addPrefixToKeys(restOptions, ODATA_PREFIX, Object.keys(restOptions))
|
|
5598
|
+
};
|
|
5599
|
+
return this._getUri(BUCKET_ENDPOINTS.GET_READ_URI(bucketId), bucketId, folderId, path, queryOptions);
|
|
5296
5600
|
}
|
|
5297
5601
|
/**
|
|
5298
5602
|
* Uploads content to the provided URI
|
|
5299
5603
|
* @param uriResponse - Response from getWriteUri containing URL and headers
|
|
5300
5604
|
* @param content - The content to upload
|
|
5301
|
-
* @param contentType - The content type of the file
|
|
5302
5605
|
* @returns The response from the upload request with status info
|
|
5303
5606
|
*/
|
|
5304
|
-
async _uploadToUri(uriResponse, content
|
|
5607
|
+
async _uploadToUri(uriResponse, content) {
|
|
5305
5608
|
const { uri, headers = {}, requiresAuth } = uriResponse;
|
|
5306
5609
|
if (!uri) {
|
|
5307
5610
|
throw new ValidationError({ message: 'Upload URI not available', statusCode: HttpStatus.BAD_REQUEST });
|
|
5308
5611
|
}
|
|
5309
5612
|
// Create headers for the request
|
|
5310
5613
|
let requestHeaders = { ...headers };
|
|
5311
|
-
// Ensure content-type is set if provided
|
|
5312
|
-
if (contentType && !requestHeaders['content-type']) {
|
|
5313
|
-
requestHeaders['content-type'] = contentType;
|
|
5314
|
-
}
|
|
5315
5614
|
// Add auth header if required
|
|
5316
5615
|
if (requiresAuth) {
|
|
5317
5616
|
try {
|
|
@@ -5383,41 +5682,16 @@ class BucketService extends FolderScopedService {
|
|
|
5383
5682
|
}
|
|
5384
5683
|
return transformedData;
|
|
5385
5684
|
}
|
|
5386
|
-
/**
|
|
5387
|
-
* Gets a direct download URL for a file in the bucket
|
|
5388
|
-
*
|
|
5389
|
-
* @param options - Contains bucketId, folderId, file path and optional expiry time
|
|
5390
|
-
* @returns Promise resolving to blob file access information
|
|
5391
|
-
*
|
|
5392
|
-
* @example
|
|
5393
|
-
* ```typescript
|
|
5394
|
-
* // Get download URL for a file
|
|
5395
|
-
* const fileAccess = await sdk.buckets.getReadUri({
|
|
5396
|
-
* bucketId: 123,
|
|
5397
|
-
* folderId: 456,
|
|
5398
|
-
* path: '/folder/file.pdf'
|
|
5399
|
-
* });
|
|
5400
|
-
* ```
|
|
5401
|
-
*/
|
|
5402
|
-
async getReadUri(options) {
|
|
5403
|
-
const { bucketId, folderId, path, expiryInMinutes, ...restOptions } = options;
|
|
5404
|
-
const queryOptions = {
|
|
5405
|
-
expiryInMinutes,
|
|
5406
|
-
...addPrefixToKeys(restOptions, ODATA_PREFIX, Object.keys(restOptions))
|
|
5407
|
-
};
|
|
5408
|
-
return this._getUri(BUCKET_ENDPOINTS.GET_READ_URI(bucketId), bucketId, folderId, path, queryOptions);
|
|
5409
|
-
}
|
|
5410
5685
|
/**
|
|
5411
5686
|
* Gets a direct upload URL for a file in the bucket
|
|
5412
5687
|
*
|
|
5413
|
-
* @param options - Contains bucketId, folderId, file path, optional expiry time
|
|
5688
|
+
* @param options - Contains bucketId, folderId, file path, optional expiry time
|
|
5414
5689
|
* @returns Promise resolving to blob file access information
|
|
5415
5690
|
*/
|
|
5416
5691
|
async _getWriteUri(options) {
|
|
5417
|
-
const { bucketId, folderId, path, expiryInMinutes,
|
|
5692
|
+
const { bucketId, folderId, path, expiryInMinutes, ...restOptions } = options;
|
|
5418
5693
|
const queryOptions = {
|
|
5419
5694
|
expiryInMinutes,
|
|
5420
|
-
contentType,
|
|
5421
5695
|
...addPrefixToKeys(restOptions, ODATA_PREFIX, Object.keys(restOptions))
|
|
5422
5696
|
};
|
|
5423
5697
|
return this._getUri(BUCKET_ENDPOINTS.GET_WRITE_URI(bucketId), bucketId, folderId, path, queryOptions);
|
|
@@ -5865,7 +6139,11 @@ class UiPath {
|
|
|
5865
6139
|
/**
|
|
5866
6140
|
* Access to Process Instances service
|
|
5867
6141
|
*/
|
|
5868
|
-
instances: this.getService(ProcessInstancesService)
|
|
6142
|
+
instances: this.getService(ProcessInstancesService),
|
|
6143
|
+
/**
|
|
6144
|
+
* Access to Process Incidents service
|
|
6145
|
+
*/
|
|
6146
|
+
incidents: this.getService(ProcessIncidentsService)
|
|
5869
6147
|
}),
|
|
5870
6148
|
/**
|
|
5871
6149
|
* Access to Maestro Cases service
|
|
@@ -6074,4 +6352,4 @@ var JobType;
|
|
|
6074
6352
|
JobType["ServerlessGeneric"] = "ServerlessGeneric";
|
|
6075
6353
|
})(JobType || (JobType = {}));
|
|
6076
6354
|
|
|
6077
|
-
export { APP_NAME, AssetValueScope, AssetValueType, AuthenticationError, AuthorizationError, BucketOptions, CLOUD_CLIENT_ID, CLOUD_ORGANIZATION_NAME, CLOUD_REDIRECT_URI, CLOUD_ROLE_NAME, CLOUD_TENANT_NAME, CLOUD_URL, CONNECTION_STRING, DEFAULT_ITEMS_FIELD, DEFAULT_PAGE_SIZE, DEFAULT_TOTAL_COUNT_FIELD, DataDirectionType, EntityFieldDataType, EntityType, ErrorType, EscalationActionType, EscalationRecipientScope, EscalationTriggerType, FieldDisplayType, HttpStatus, JobPriority, JobState, JobType, JoinType, MAX_PAGE_SIZE, NetworkError, NotFoundError, PackageSourceType, PackageType, RateLimitError, ReferenceType, RemoteControlAccess, RobotSize, SDK_LOGGER_NAME, SDK_RUN_EVENT, SDK_SERVICE_NAME, SDK_VERSION, SERVICE, SLADurationUnit, ServerError, StageTaskType, StartStrategy, StopStrategy, TargetFramework, TaskActivityType, TaskPriority, TaskSlaCriteria, TaskSlaStatus, TaskSourceName, TaskStatus, TaskType, UNKNOWN, UiPath, UiPathError, VERSION, ValidationError, createCaseInstanceWithMethods, createEntityWithMethods, createProcessInstanceWithMethods, createTaskWithMethods, getErrorDetails, getLimitedPageSize, isAuthenticationError, isAuthorizationError, isNetworkError, isNotFoundError, isRateLimitError, isServerError, isUiPathError, isValidationError, telemetryClient, track, trackEvent };
|
|
6355
|
+
export { APP_NAME, AssetValueScope, AssetValueType, AuthenticationError, AuthorizationError, BucketOptions, CLOUD_CLIENT_ID, CLOUD_ORGANIZATION_NAME, CLOUD_REDIRECT_URI, CLOUD_ROLE_NAME, CLOUD_TENANT_NAME, CLOUD_URL, CONNECTION_STRING, DEFAULT_ITEMS_FIELD, DEFAULT_PAGE_SIZE, DEFAULT_TOTAL_COUNT_FIELD, DataDirectionType, DebugMode, EntityFieldDataType, EntityType, ErrorType, EscalationActionType, EscalationRecipientScope, EscalationTriggerType, FieldDisplayType, HttpStatus, JobPriority, JobState, JobType, JoinType, MAX_PAGE_SIZE, NetworkError, NotFoundError, PackageSourceType, PackageType, ProcessIncidentSeverity, ProcessIncidentStatus, ProcessIncidentType, RateLimitError, ReferenceType, RemoteControlAccess, RobotSize, SDK_LOGGER_NAME, SDK_RUN_EVENT, SDK_SERVICE_NAME, SDK_VERSION, SERVICE, SLADurationUnit, ServerError, StageTaskType, StartStrategy, StopStrategy, TargetFramework, TaskActivityType, TaskPriority, TaskSlaCriteria, TaskSlaStatus, TaskSourceName, TaskStatus, TaskType, UNKNOWN, UiPath, UiPathError, VERSION, ValidationError, createCaseInstanceWithMethods, createEntityWithMethods, createProcessInstanceWithMethods, createProcessWithMethods, createTaskWithMethods, getErrorDetails, getLimitedPageSize, isAuthenticationError, isAuthorizationError, isNetworkError, isNotFoundError, isRateLimitError, isServerError, isUiPathError, isValidationError, telemetryClient, track, trackEvent };
|