@uipath/uipath-typescript 1.0.0-beta.14 → 1.0.0-beta.16

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.
@@ -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, details } = errorInfo;
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: 1
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 || 1,
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}`,
@@ -2380,12 +2368,17 @@ class AuthService extends BaseService {
2380
2368
  }
2381
2369
  else {
2382
2370
  // In Node.js environment
2383
- const crypto = require('crypto');
2384
- return crypto.randomBytes(32)
2385
- .toString('base64')
2386
- .replace(/\+/g, '-')
2387
- .replace(/\//g, '_')
2388
- .replace(/=/g, '');
2371
+ try {
2372
+ const crypto = require('crypto');
2373
+ return crypto.randomBytes(32)
2374
+ .toString('base64')
2375
+ .replace(/\+/g, '-')
2376
+ .replace(/\//g, '_')
2377
+ .replace(/=/g, '');
2378
+ }
2379
+ catch (e) {
2380
+ throw new Error("crypto not available in browser");
2381
+ }
2389
2382
  }
2390
2383
  }
2391
2384
  /**
@@ -2400,13 +2393,18 @@ class AuthService extends BaseService {
2400
2393
  }
2401
2394
  else {
2402
2395
  // In Node.js environment
2403
- const crypto = require('crypto');
2404
- return crypto.createHash('sha256')
2405
- .update(codeVerifier)
2406
- .digest('base64')
2407
- .replace(/\+/g, '-')
2408
- .replace(/\//g, '_')
2409
- .replace(/=/g, '');
2396
+ try {
2397
+ const crypto = require('crypto');
2398
+ return crypto.createHash('sha256')
2399
+ .update(codeVerifier)
2400
+ .digest('base64')
2401
+ .replace(/\+/g, '-')
2402
+ .replace(/\//g, '_')
2403
+ .replace(/=/g, '');
2404
+ }
2405
+ catch (e) {
2406
+ throw new Error("crypto not available in browser");
2407
+ }
2410
2408
  }
2411
2409
  }
2412
2410
  /**
@@ -2733,7 +2731,7 @@ const EntityFieldTypeMap = {
2733
2731
  // Connection string placeholder that will be replaced during build
2734
2732
  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
2733
  // SDK Version placeholder
2736
- const SDK_VERSION = "1.0.0-beta.14";
2734
+ const SDK_VERSION = "1.0.0-beta.16";
2737
2735
  const VERSION = "Version";
2738
2736
  const SERVICE = "Service";
2739
2737
  const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
@@ -3046,76 +3044,6 @@ class EntityService extends BaseService {
3046
3044
  // Return the entity metadata with methods attached
3047
3045
  return createEntityWithMethods(metadata, this);
3048
3046
  }
3049
- /**
3050
- * Orchestrates all field mapping transformations
3051
- *
3052
- * @param metadata - Entity metadata to transform
3053
- * @private
3054
- */
3055
- applyFieldMappings(metadata) {
3056
- this.mapFieldTypes(metadata);
3057
- this.mapExternalFields(metadata);
3058
- }
3059
- /**
3060
- * Maps SQL field types to friendly EntityFieldTypes
3061
- *
3062
- * @param metadata - Entity metadata with fields
3063
- * @private
3064
- */
3065
- mapFieldTypes(metadata) {
3066
- if (!metadata.fields?.length)
3067
- return;
3068
- metadata.fields = metadata.fields.map(field => {
3069
- // Rename sqlType to fieldDataType
3070
- let transformedField = transformData(field, EntityMap);
3071
- // Map SQL field type to friendly name
3072
- if (transformedField.fieldDataType?.name) {
3073
- const sqlTypeName = transformedField.fieldDataType.name;
3074
- if (EntityFieldTypeMap[sqlTypeName]) {
3075
- transformedField.fieldDataType.name = EntityFieldTypeMap[sqlTypeName];
3076
- }
3077
- }
3078
- this.transformNestedReferences(transformedField);
3079
- return transformedField;
3080
- });
3081
- }
3082
- /**
3083
- * Transforms nested reference objects in field metadata
3084
- */
3085
- transformNestedReferences(field) {
3086
- if (field.referenceEntity) {
3087
- field.referenceEntity = transformData(field.referenceEntity, EntityMap);
3088
- }
3089
- if (field.referenceChoiceSet) {
3090
- field.referenceChoiceSet = transformData(field.referenceChoiceSet, EntityMap);
3091
- }
3092
- if (field.referenceField?.definition) {
3093
- field.referenceField.definition = transformData(field.referenceField.definition, EntityMap);
3094
- }
3095
- }
3096
- /**
3097
- * Maps external field names to consistent naming
3098
- *
3099
- * @param metadata - Entity metadata with externalFields
3100
- * @private
3101
- */
3102
- mapExternalFields(metadata) {
3103
- if (!metadata.externalFields?.length)
3104
- return;
3105
- metadata.externalFields = metadata.externalFields.map(externalSource => {
3106
- if (externalSource.fields?.length) {
3107
- externalSource.fields = externalSource.fields.map(field => {
3108
- const transformedField = transformData(field, EntityMap);
3109
- if (transformedField.fieldMetaData) {
3110
- transformedField.fieldMetaData = transformData(transformedField.fieldMetaData, EntityMap);
3111
- this.transformNestedReferences(transformedField.fieldMetaData);
3112
- }
3113
- return transformedField;
3114
- });
3115
- }
3116
- return externalSource;
3117
- });
3118
- }
3119
3047
  /**
3120
3048
  * Gets entity records by entity ID
3121
3049
  *
@@ -3150,7 +3078,6 @@ class EntityService extends BaseService {
3150
3078
  return PaginationHelpers.getAll({
3151
3079
  serviceAccess: this.createPaginationServiceAccess(),
3152
3080
  getEndpoint: () => DATA_FABRIC_ENDPOINTS.ENTITY.GET_ENTITY_RECORDS(entityId),
3153
- transformFn: (item) => pascalToCamelCaseKeys(item),
3154
3081
  pagination: {
3155
3082
  paginationType: PaginationType.OFFSET,
3156
3083
  itemsField: ENTITY_PAGINATION.ITEMS_FIELD,
@@ -3297,6 +3224,76 @@ class EntityService extends BaseService {
3297
3224
  });
3298
3225
  return entities;
3299
3226
  }
3227
+ /**
3228
+ * Orchestrates all field mapping transformations
3229
+ *
3230
+ * @param metadata - Entity metadata to transform
3231
+ * @private
3232
+ */
3233
+ applyFieldMappings(metadata) {
3234
+ this.mapFieldTypes(metadata);
3235
+ this.mapExternalFields(metadata);
3236
+ }
3237
+ /**
3238
+ * Maps SQL field types to friendly EntityFieldTypes
3239
+ *
3240
+ * @param metadata - Entity metadata with fields
3241
+ * @private
3242
+ */
3243
+ mapFieldTypes(metadata) {
3244
+ if (!metadata.fields?.length)
3245
+ return;
3246
+ metadata.fields = metadata.fields.map(field => {
3247
+ // Rename sqlType to fieldDataType
3248
+ let transformedField = transformData(field, EntityMap);
3249
+ // Map SQL field type to friendly name
3250
+ if (transformedField.fieldDataType?.name) {
3251
+ const sqlTypeName = transformedField.fieldDataType.name;
3252
+ if (EntityFieldTypeMap[sqlTypeName]) {
3253
+ transformedField.fieldDataType.name = EntityFieldTypeMap[sqlTypeName];
3254
+ }
3255
+ }
3256
+ this.transformNestedReferences(transformedField);
3257
+ return transformedField;
3258
+ });
3259
+ }
3260
+ /**
3261
+ * Transforms nested reference objects in field metadata
3262
+ */
3263
+ transformNestedReferences(field) {
3264
+ if (field.referenceEntity) {
3265
+ field.referenceEntity = transformData(field.referenceEntity, EntityMap);
3266
+ }
3267
+ if (field.referenceChoiceSet) {
3268
+ field.referenceChoiceSet = transformData(field.referenceChoiceSet, EntityMap);
3269
+ }
3270
+ if (field.referenceField?.definition) {
3271
+ field.referenceField.definition = transformData(field.referenceField.definition, EntityMap);
3272
+ }
3273
+ }
3274
+ /**
3275
+ * Maps external field names to consistent naming
3276
+ *
3277
+ * @param metadata - Entity metadata with externalFields
3278
+ * @private
3279
+ */
3280
+ mapExternalFields(metadata) {
3281
+ if (!metadata.externalFields?.length)
3282
+ return;
3283
+ metadata.externalFields = metadata.externalFields.map(externalSource => {
3284
+ if (externalSource.fields?.length) {
3285
+ externalSource.fields = externalSource.fields.map(field => {
3286
+ const transformedField = transformData(field, EntityMap);
3287
+ if (transformedField.fieldMetaData) {
3288
+ transformedField.fieldMetaData = transformData(transformedField.fieldMetaData, EntityMap);
3289
+ this.transformNestedReferences(transformedField.fieldMetaData);
3290
+ }
3291
+ return transformedField;
3292
+ });
3293
+ }
3294
+ return externalSource;
3295
+ });
3296
+ }
3300
3297
  }
3301
3298
  __decorate([
3302
3299
  track('Entities.GetById')
@@ -3318,46 +3315,161 @@ __decorate([
3318
3315
  ], EntityService.prototype, "getAll", null);
3319
3316
 
3320
3317
  /**
3321
- * Service for interacting with Maestro Processes
3318
+ * Maestro Process Models
3319
+ * Model classes for Maestro processes
3322
3320
  */
3323
- class MaestroProcessesService extends BaseService {
3321
+ /**
3322
+ * Creates methods for a process object
3323
+ *
3324
+ * @param processData - The process data (response from API)
3325
+ * @param service - The process service instance
3326
+ * @returns Object containing process methods
3327
+ */
3328
+ function createProcessMethods(processData, service) {
3329
+ return {
3330
+ async getIncidents() {
3331
+ if (!processData.processKey)
3332
+ throw new Error('Process key is undefined');
3333
+ if (!processData.folderKey)
3334
+ throw new Error('Folder key is undefined');
3335
+ return service.getIncidents(processData.processKey, processData.folderKey);
3336
+ }
3337
+ };
3338
+ }
3339
+ /**
3340
+ * Creates an actionable process by combining API process data with operational methods.
3341
+ *
3342
+ * @param processData - The process data from API
3343
+ * @param service - The process service instance
3344
+ * @returns A process object with added methods
3345
+ */
3346
+ function createProcessWithMethods(processData, service) {
3347
+ const methods = createProcessMethods(processData, service);
3348
+ return Object.assign({}, processData, methods);
3349
+ }
3350
+
3351
+ /**
3352
+ * Maps fields for Incident entities
3353
+ */
3354
+ const ProcessIncidentMap = {
3355
+ errorTimeUtc: 'errorTime'
3356
+ };
3357
+ /**
3358
+ * Maps fields for Incident Summary entities
3359
+ */
3360
+ const ProcessIncidentSummaryMap = {
3361
+ firstTimeUtc: 'firstOccuranceTime'
3362
+ };
3363
+
3364
+ /**
3365
+ * Helpers for fetching BPMN XML and extracting element details used to annotate responses
3366
+ */
3367
+ class BpmnHelpers {
3324
3368
  /**
3325
- * @hideconstructor
3369
+ * Parse BPMN XML and extract element id → {name,type} used for incidents
3326
3370
  */
3327
- constructor(config, executionContext, tokenManager) {
3328
- super(config, executionContext, tokenManager);
3371
+ static parseBpmnElementsForIncidents(bpmnXml) {
3372
+ const elementInfo = {};
3373
+ try {
3374
+ // Find <bpmn:...> start tags and capture the element type.
3375
+ // Then read 'id' and 'name' attributes from each tag.
3376
+ const bpmnOpenTagRegex = /<bpmn:([A-Za-z][\w.-]*)\b[^>]*>/g;
3377
+ for (const tagMatch of bpmnXml.matchAll(bpmnOpenTagRegex)) {
3378
+ const [fullTag, elementType] = tagMatch;
3379
+ // Extract attributes from the current tag text.
3380
+ const idMatch = /\bid\s*=\s*"([^"]*)"/.exec(fullTag);
3381
+ if (!idMatch) {
3382
+ continue;
3383
+ }
3384
+ const elementId = idMatch[1];
3385
+ const nameMatch = /\bname\s*=\s*"([^"]*)"/.exec(fullTag);
3386
+ const name = nameMatch ? nameMatch[1] : '';
3387
+ // Convert BPMN element type to human-readable format
3388
+ const activityType = this.formatActivityTypeForIncidents(elementType);
3389
+ const activityName = name || elementId;
3390
+ elementInfo[elementId] = {
3391
+ type: activityType,
3392
+ name: activityName
3393
+ };
3394
+ }
3395
+ }
3396
+ catch (error) {
3397
+ console.warn('Failed to parse BPMN XML for incidents:', error);
3398
+ }
3399
+ return elementInfo;
3329
3400
  }
3330
3401
  /**
3331
- * Get all processes with their instance statistics
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
- * ```
3402
+ * Format BPMN element type to human-readable activity type for incidents
3347
3403
  */
3348
- async getAll() {
3349
- const response = await this.get(MAESTRO_ENDPOINTS.PROCESSES.GET_ALL);
3350
- // Extract processes array from response data and add name field
3351
- const processes = response.data?.processes || [];
3352
- return processes.map(process => ({
3353
- ...process,
3354
- name: process.packageId
3404
+ static formatActivityTypeForIncidents(elementType) {
3405
+ // Convert camelCase BPMN element types to human-readable format
3406
+ // e.g., "serviceTask" -> "Service Task", "exclusiveGateway" -> "Exclusive Gateway"
3407
+ return elementType
3408
+ .replace(/([A-Z])/g, ' $1') // Add space before uppercase letters
3409
+ .replace(/^./, str => str.toUpperCase()) // Capitalize first letter
3410
+ .trim(); // Remove any leading/trailing spaces
3411
+ }
3412
+ /**
3413
+ * Fetch BPMN via getBpmn and add element name/type to each incident
3414
+ */
3415
+ static async enrichIncidentsWithBpmnData(incidents, folderKey, service) {
3416
+ // Check if all incidents have the same instanceId
3417
+ const uniqueInstanceIds = [...new Set(incidents.map(i => i.instanceId))];
3418
+ if (uniqueInstanceIds.length === 1) {
3419
+ // Single instance optimization (in case of process instance incidents)
3420
+ const elementInfo = await this.getBpmnElementInfo(uniqueInstanceIds[0], folderKey, service);
3421
+ return incidents.map((incident) => this.transformIncidentWithBpmn(incident, elementInfo));
3422
+ }
3423
+ else {
3424
+ // Multiple instances optimization (in case of process incidents)
3425
+ return this.enrichMultipleInstanceIncidents(incidents, folderKey, service);
3426
+ }
3427
+ }
3428
+ /**
3429
+ * When incidents span multiple instances, fetch BPMN per instance and annotate
3430
+ */
3431
+ static async enrichMultipleInstanceIncidents(incidents, folderKey, service) {
3432
+ const groups = incidents.reduce((acc, incident) => {
3433
+ const id = incident.instanceId || NO_INSTANCE;
3434
+ (acc[id] = acc[id] || []).push(incident);
3435
+ return acc;
3436
+ }, {});
3437
+ const results = await Promise.all(Object.entries(groups).map(async (entry) => {
3438
+ const [instanceId, groupIncidents] = entry;
3439
+ const elementInfo = await this.getBpmnElementInfo(instanceId, folderKey, service);
3440
+ return groupIncidents.map((incident) => this.transformIncidentWithBpmn(incident, elementInfo));
3355
3441
  }));
3442
+ return results.flat();
3443
+ }
3444
+ /**
3445
+ * Retrieve BPMN XML for an instance and derive element id → {name,type}
3446
+ */
3447
+ static async getBpmnElementInfo(instanceId, folderKey, service) {
3448
+ if (!instanceId || instanceId === NO_INSTANCE) {
3449
+ return {};
3450
+ }
3451
+ try {
3452
+ const bpmnXml = await service.getBpmn(instanceId, folderKey);
3453
+ return this.parseBpmnElementsForIncidents(bpmnXml);
3454
+ }
3455
+ catch (error) {
3456
+ console.warn(`Failed to get BPMN for instance ${instanceId}:`, error);
3457
+ return {};
3458
+ }
3459
+ }
3460
+ /**
3461
+ * Transform a raw incident by attaching element name/type from BPMN
3462
+ */
3463
+ static transformIncidentWithBpmn(incident, elementInfo) {
3464
+ const element = elementInfo[incident.elementId];
3465
+ const transformed = transformData(incident, ProcessIncidentMap);
3466
+ return {
3467
+ ...transformed,
3468
+ incidentElementActivityType: element?.type || UNKNOWN$1,
3469
+ incidentElementActivityName: element?.name || UNKNOWN$1
3470
+ };
3356
3471
  }
3357
3472
  }
3358
- __decorate([
3359
- track('MaestroProcesses.GetAll')
3360
- ], MaestroProcessesService.prototype, "getAll", null);
3361
3473
 
3362
3474
  /**
3363
3475
  * Creates methods for a process instance
@@ -3371,17 +3483,49 @@ function createProcessInstanceMethods(instanceData, service) {
3371
3483
  async cancel(options) {
3372
3484
  if (!instanceData.instanceId)
3373
3485
  throw new Error('Process instance ID is undefined');
3486
+ if (!instanceData.folderKey)
3487
+ throw new Error('Process instance folder key is undefined');
3374
3488
  return service.cancel(instanceData.instanceId, instanceData.folderKey, options);
3375
3489
  },
3376
3490
  async pause(options) {
3377
3491
  if (!instanceData.instanceId)
3378
3492
  throw new Error('Process instance ID is undefined');
3493
+ if (!instanceData.folderKey)
3494
+ throw new Error('Process instance folder key is undefined');
3379
3495
  return service.pause(instanceData.instanceId, instanceData.folderKey, options);
3380
3496
  },
3381
3497
  async resume(options) {
3382
3498
  if (!instanceData.instanceId)
3383
3499
  throw new Error('Process instance ID is undefined');
3500
+ if (!instanceData.folderKey)
3501
+ throw new Error('Process instance folder key is undefined');
3384
3502
  return service.resume(instanceData.instanceId, instanceData.folderKey, options);
3503
+ },
3504
+ async getIncidents() {
3505
+ if (!instanceData.instanceId)
3506
+ throw new Error('Process instance ID is undefined');
3507
+ if (!instanceData.folderKey)
3508
+ throw new Error('Process instance folder key is undefined');
3509
+ return service.getIncidents(instanceData.instanceId, instanceData.folderKey);
3510
+ },
3511
+ async getExecutionHistory() {
3512
+ if (!instanceData.instanceId)
3513
+ throw new Error('Process instance ID is undefined');
3514
+ return service.getExecutionHistory(instanceData.instanceId);
3515
+ },
3516
+ async getBpmn() {
3517
+ if (!instanceData.instanceId)
3518
+ throw new Error('Process instance ID is undefined');
3519
+ if (!instanceData.folderKey)
3520
+ throw new Error('Process instance folder key is undefined');
3521
+ return service.getBpmn(instanceData.instanceId, instanceData.folderKey);
3522
+ },
3523
+ async getVariables(options) {
3524
+ if (!instanceData.instanceId)
3525
+ throw new Error('Process instance ID is undefined');
3526
+ if (!instanceData.folderKey)
3527
+ throw new Error('Process instance folder key is undefined');
3528
+ return service.getVariables(instanceData.instanceId, instanceData.folderKey, options);
3385
3529
  }
3386
3530
  };
3387
3531
  }
@@ -3397,6 +3541,42 @@ function createProcessInstanceWithMethods(instanceData, service) {
3397
3541
  return Object.assign({}, instanceData, methods);
3398
3542
  }
3399
3543
 
3544
+ /**
3545
+ * Process Incident Status
3546
+ */
3547
+ exports.ProcessIncidentStatus = void 0;
3548
+ (function (ProcessIncidentStatus) {
3549
+ ProcessIncidentStatus["Open"] = "Open";
3550
+ ProcessIncidentStatus["Closed"] = "Closed";
3551
+ })(exports.ProcessIncidentStatus || (exports.ProcessIncidentStatus = {}));
3552
+ /**
3553
+ * Process Incident Type
3554
+ */
3555
+ exports.ProcessIncidentType = void 0;
3556
+ (function (ProcessIncidentType) {
3557
+ ProcessIncidentType["System"] = "System";
3558
+ ProcessIncidentType["User"] = "User";
3559
+ ProcessIncidentType["Deployment"] = "Deployment";
3560
+ })(exports.ProcessIncidentType || (exports.ProcessIncidentType = {}));
3561
+ /**
3562
+ * Process Incident Severity
3563
+ */
3564
+ exports.ProcessIncidentSeverity = void 0;
3565
+ (function (ProcessIncidentSeverity) {
3566
+ ProcessIncidentSeverity["Error"] = "Error";
3567
+ ProcessIncidentSeverity["Warning"] = "Warning";
3568
+ })(exports.ProcessIncidentSeverity || (exports.ProcessIncidentSeverity = {}));
3569
+ /**
3570
+ * Process Incident Debug Mode
3571
+ */
3572
+ exports.DebugMode = void 0;
3573
+ (function (DebugMode) {
3574
+ DebugMode["None"] = "None";
3575
+ DebugMode["Default"] = "Default";
3576
+ DebugMode["StepByStep"] = "StepByStep";
3577
+ DebugMode["SingleStep"] = "SingleStep";
3578
+ })(exports.DebugMode || (exports.DebugMode = {}));
3579
+
3400
3580
  /**
3401
3581
  * Case Instance Types
3402
3582
  * Types and interfaces for Maestro case instance management
@@ -3459,17 +3639,42 @@ function createCaseInstanceMethods(instanceData, service) {
3459
3639
  async close(options) {
3460
3640
  if (!instanceData.instanceId)
3461
3641
  throw new Error('Case instance ID is undefined');
3642
+ if (!instanceData.folderKey)
3643
+ throw new Error('Case instance folder key is undefined');
3462
3644
  return service.close(instanceData.instanceId, instanceData.folderKey, options);
3463
3645
  },
3464
3646
  async pause(options) {
3465
3647
  if (!instanceData.instanceId)
3466
3648
  throw new Error('Case instance ID is undefined');
3649
+ if (!instanceData.folderKey)
3650
+ throw new Error('Case instance folder key is undefined');
3467
3651
  return service.pause(instanceData.instanceId, instanceData.folderKey, options);
3468
3652
  },
3469
3653
  async resume(options) {
3470
3654
  if (!instanceData.instanceId)
3471
3655
  throw new Error('Case instance ID is undefined');
3656
+ if (!instanceData.folderKey)
3657
+ throw new Error('Case instance folder key is undefined');
3472
3658
  return service.resume(instanceData.instanceId, instanceData.folderKey, options);
3659
+ },
3660
+ async getExecutionHistory() {
3661
+ if (!instanceData.instanceId)
3662
+ throw new Error('Case instance ID is undefined');
3663
+ if (!instanceData.folderKey)
3664
+ throw new Error('Case instance folder key is undefined');
3665
+ return service.getExecutionHistory(instanceData.instanceId, instanceData.folderKey);
3666
+ },
3667
+ async getStages() {
3668
+ if (!instanceData.instanceId)
3669
+ throw new Error('Case instance ID is undefined');
3670
+ if (!instanceData.folderKey)
3671
+ throw new Error('Case instance folder key is undefined');
3672
+ return service.getStages(instanceData.instanceId, instanceData.folderKey);
3673
+ },
3674
+ async getActionTasks(options) {
3675
+ if (!instanceData.instanceId)
3676
+ throw new Error('Case instance ID is undefined');
3677
+ return service.getActionTasks(instanceData.instanceId, options);
3473
3678
  }
3474
3679
  };
3475
3680
  }
@@ -3767,6 +3972,19 @@ class ProcessInstancesService extends BaseService {
3767
3972
  };
3768
3973
  return variablesResponse;
3769
3974
  }
3975
+ /**
3976
+ * Get incidents for a process instance
3977
+ * @param instanceId The ID of the instance to get incidents for
3978
+ * @param folderKey The folder key for authorization
3979
+ * @returns Promise<ProcessIncidentGetResponse[]>
3980
+ */
3981
+ async getIncidents(instanceId, folderKey) {
3982
+ const rawResponse = await this.get(MAESTRO_ENDPOINTS.INCIDENTS.GET_BY_INSTANCE(instanceId), {
3983
+ headers: createHeaders({ [FOLDER_KEY]: folderKey })
3984
+ });
3985
+ // Filter out excluded fields and transform response, then enrich with BPMN data
3986
+ return BpmnHelpers.enrichIncidentsWithBpmnData(rawResponse.data || [], folderKey, this);
3987
+ }
3770
3988
  }
3771
3989
  __decorate([
3772
3990
  track('ProcessInstances.GetAll')
@@ -3792,6 +4010,101 @@ __decorate([
3792
4010
  __decorate([
3793
4011
  track('ProcessInstances.GetVariables')
3794
4012
  ], ProcessInstancesService.prototype, "getVariables", null);
4013
+ __decorate([
4014
+ track('ProcessInstances.GetIncidents')
4015
+ ], ProcessInstancesService.prototype, "getIncidents", null);
4016
+
4017
+ /**
4018
+ * Service for interacting with Maestro Processes
4019
+ */
4020
+ class MaestroProcessesService extends BaseService {
4021
+ /**
4022
+ * @hideconstructor
4023
+ */
4024
+ constructor(config, executionContext, tokenManager) {
4025
+ super(config, executionContext, tokenManager);
4026
+ this.processInstancesService = new ProcessInstancesService(config, executionContext, tokenManager);
4027
+ }
4028
+ /**
4029
+ * Get all processes with their instance statistics
4030
+ * @returns Promise resolving to array of MaestroProcess objects
4031
+ *
4032
+ * @example
4033
+ * ```typescript
4034
+ * // Get all processes
4035
+ * const processes = await sdk.maestro.processes.getAll();
4036
+ *
4037
+ * // Access process information
4038
+ * for (const process of processes) {
4039
+ * console.log(`Process: ${process.processKey}`);
4040
+ * console.log(`Running instances: ${process.runningCount}`);
4041
+ * console.log(`Faulted instances: ${process.faultedCount}`);
4042
+ * }
4043
+ *
4044
+ * ```
4045
+ */
4046
+ async getAll() {
4047
+ const response = await this.get(MAESTRO_ENDPOINTS.PROCESSES.GET_ALL);
4048
+ // Extract processes array from response data and add name field
4049
+ const processes = response.data?.processes || [];
4050
+ const processesWithName = processes.map(process => ({
4051
+ ...process,
4052
+ name: process.packageId
4053
+ }));
4054
+ // Add methods to each process
4055
+ return processesWithName.map(process => createProcessWithMethods(process, this));
4056
+ }
4057
+ /**
4058
+ * Get incidents for a specific process
4059
+ */
4060
+ async getIncidents(processKey, folderKey) {
4061
+ const rawResponse = await this.get(MAESTRO_ENDPOINTS.INCIDENTS.GET_BY_PROCESS(processKey), {
4062
+ headers: createHeaders({ [FOLDER_KEY]: folderKey })
4063
+ });
4064
+ // Fetch BPMN XML and add element name/type to each incident
4065
+ return BpmnHelpers.enrichIncidentsWithBpmnData(rawResponse.data || [], folderKey, this.processInstancesService);
4066
+ }
4067
+ }
4068
+ __decorate([
4069
+ track('MaestroProcesses.GetAll')
4070
+ ], MaestroProcessesService.prototype, "getAll", null);
4071
+ __decorate([
4072
+ track('MaestroProcesses.GetIncidents')
4073
+ ], MaestroProcessesService.prototype, "getIncidents", null);
4074
+
4075
+ /**
4076
+ * Service class for Maestro Process Incidents
4077
+ */
4078
+ class ProcessIncidentsService extends BaseService {
4079
+ /**
4080
+ * Get all process incidents across all folders
4081
+ *
4082
+ * @returns Promise resolving to array of process incident
4083
+ * {@link ProcessIncidentGetAllResponse}
4084
+ * @example
4085
+ * ```typescript
4086
+ * // Get all process incidents across all folders
4087
+ * const incidents = await sdk.maestro.processes.incidents.getAll();
4088
+ *
4089
+ * // Access process incident information
4090
+ * for (const incident of incidents) {
4091
+ * console.log(`Process: ${incident.processKey}`);
4092
+ * console.log(`Error: ${incident.errorMessage}`);
4093
+ * console.log(`Count: ${incident.count}`);
4094
+ * console.log(`First occurrence: ${incident.firstOccuranceTime}`);
4095
+ * }
4096
+ * ```
4097
+ */
4098
+ async getAll() {
4099
+ const rawResponse = await this.get(MAESTRO_ENDPOINTS.INCIDENTS.GET_ALL);
4100
+ // Transform field names
4101
+ const data = rawResponse.data || [];
4102
+ return data.map(incident => transformData(incident, ProcessIncidentSummaryMap));
4103
+ }
4104
+ }
4105
+ __decorate([
4106
+ track('ProcessIncidents.getAll')
4107
+ ], ProcessIncidentsService.prototype, "getAll", null);
3795
4108
 
3796
4109
  /**
3797
4110
  * Internal types for Maestro Cases
@@ -3987,35 +4300,32 @@ function createTaskMethods(taskData, service) {
3987
4300
  async assign(options) {
3988
4301
  if (!taskData.id)
3989
4302
  throw new Error('Task ID is undefined');
3990
- const assignmentOptions = {
3991
- taskId: taskData.id,
3992
- userId: options.userId || 0, // Will be handled by userNameOrEmail if userId is not provided, 0 is considered as invalid user id
3993
- userNameOrEmail: options.userNameOrEmail
3994
- };
3995
- return service.assign(assignmentOptions, taskData.organizationUnitId);
4303
+ const assignmentOptions = 'userId' in options && options.userId !== undefined
4304
+ ? { taskId: taskData.id, userId: options.userId }
4305
+ : { taskId: taskData.id, userNameOrEmail: options.userNameOrEmail };
4306
+ return service.assign(assignmentOptions);
3996
4307
  },
3997
4308
  async reassign(options) {
3998
4309
  if (!taskData.id)
3999
4310
  throw new Error('Task ID is undefined');
4000
- const assignmentOptions = {
4001
- taskId: taskData.id,
4002
- userId: options.userId || 0, // Will be handled by userNameOrEmail if userId is not provided, 0 is considered as invalid user id
4003
- userNameOrEmail: options.userNameOrEmail
4004
- };
4005
- return service.reassign(assignmentOptions, taskData.organizationUnitId);
4311
+ const assignmentOptions = 'userId' in options && options.userId !== undefined
4312
+ ? { taskId: taskData.id, userId: options.userId }
4313
+ : { taskId: taskData.id, userNameOrEmail: options.userNameOrEmail };
4314
+ return service.reassign(assignmentOptions);
4006
4315
  },
4007
4316
  async unassign() {
4008
4317
  if (!taskData.id)
4009
4318
  throw new Error('Task ID is undefined');
4010
- return service.unassign(taskData.id, taskData.organizationUnitId);
4319
+ return service.unassign(taskData.id);
4011
4320
  },
4012
4321
  async complete(options) {
4013
4322
  if (!taskData.id)
4014
4323
  throw new Error('Task ID is undefined');
4015
- const folderId = taskData.organizationUnitId;
4324
+ const folderId = taskData.folderId;
4016
4325
  if (!folderId)
4017
4326
  throw new Error('Folder ID is required');
4018
- return service.complete(options.type, {
4327
+ return service.complete({
4328
+ type: options.type,
4019
4329
  taskId: taskData.id,
4020
4330
  data: options.data,
4021
4331
  action: options.action
@@ -4052,6 +4362,10 @@ const TaskMap = {
4052
4362
  creationTime: 'createdTime',
4053
4363
  organizationUnitId: 'folderId'
4054
4364
  };
4365
+ /**
4366
+ * Default expand parameters
4367
+ */
4368
+ const DEFAULT_TASK_EXPAND = 'AssignedToUser,CreatorUser,LastModifierUser';
4055
4369
 
4056
4370
  /**
4057
4371
  * Service for interacting with UiPath Tasks API
@@ -4070,7 +4384,8 @@ class TaskService extends BaseService {
4070
4384
  * @private
4071
4385
  */
4072
4386
  this.processTaskParameters = (options, folderId) => {
4073
- const processedOptions = { ...options };
4387
+ // Add default expand parameters
4388
+ const processedOptions = this.addDefaultExpand(options);
4074
4389
  if (folderId) {
4075
4390
  // Create or add to existing filter for folder-specific queries
4076
4391
  if (processedOptions.filter) {
@@ -4229,10 +4544,11 @@ class TaskService extends BaseService {
4229
4544
  }
4230
4545
  /**
4231
4546
  * Gets a task by ID
4547
+ * IMPORTANT: For form tasks, folderId must be provided.
4232
4548
  *
4233
4549
  * @param id - The ID of the task to retrieve
4234
4550
  * @param options - Optional query parameters
4235
- * @param folderId - Optional folder ID
4551
+ * @param folderId - Optional folder ID (REQUIRED for form tasks)
4236
4552
  * @returns Promise resolving to the task (form tasks will return form-specific data)
4237
4553
  *
4238
4554
  * @example
@@ -4245,9 +4561,11 @@ class TaskService extends BaseService {
4245
4561
  */
4246
4562
  async getById(id, options = {}, folderId) {
4247
4563
  const headers = createHeaders({ [FOLDER_ID]: folderId });
4564
+ // Add default expand parameters
4565
+ const modifiedOptions = this.addDefaultExpand(options);
4248
4566
  // prefix all keys in options
4249
- const keysToPrefix = Object.keys(options);
4250
- const apiOptions = addPrefixToKeys(options, ODATA_PREFIX, keysToPrefix);
4567
+ const keysToPrefix = Object.keys(modifiedOptions);
4568
+ const apiOptions = addPrefixToKeys(modifiedOptions, ODATA_PREFIX, keysToPrefix);
4251
4569
  const response = await this.get(TASK_ENDPOINTS.GET_BY_ID(id), {
4252
4570
  params: apiOptions,
4253
4571
  headers
@@ -4257,7 +4575,7 @@ class TaskService extends BaseService {
4257
4575
  // Check if this is a form task and get form-specific data if it is
4258
4576
  if (transformedTask.type === exports.TaskType.Form) {
4259
4577
  const formOptions = { expandOnFormLayout: true };
4260
- return this.getFormTaskById(id, folderId || transformedTask.organizationUnitId, formOptions);
4578
+ return this.getFormTaskById(id, folderId || transformedTask.folderId, formOptions);
4261
4579
  }
4262
4580
  return createTaskWithMethods(applyDataTransforms(transformedTask, { field: 'status', valueMap: TaskStatusMap }), this);
4263
4581
  }
@@ -4265,7 +4583,6 @@ class TaskService extends BaseService {
4265
4583
  * Assigns tasks to users
4266
4584
  *
4267
4585
  * @param taskAssignments - Single task assignment or array of task assignments
4268
- * @param folderId - Optional folder ID
4269
4586
  * @returns Promise resolving to array of task assignment results
4270
4587
  *
4271
4588
  * @example
@@ -4295,8 +4612,7 @@ class TaskService extends BaseService {
4295
4612
  * ]);
4296
4613
  * ```
4297
4614
  */
4298
- async assign(taskAssignments, folderId) {
4299
- const headers = createHeaders({ [FOLDER_ID]: folderId });
4615
+ async assign(taskAssignments) {
4300
4616
  // Normalize input to array
4301
4617
  const assignmentArray = Array.isArray(taskAssignments) ? taskAssignments : [taskAssignments];
4302
4618
  const options = {
@@ -4304,7 +4620,7 @@ class TaskService extends BaseService {
4304
4620
  };
4305
4621
  // Convert options to PascalCase for API
4306
4622
  const pascalOptions = camelToPascalCaseKeys(options);
4307
- const response = await this.post(TASK_ENDPOINTS.ASSIGN_TASKS, pascalOptions, { headers });
4623
+ const response = await this.post(TASK_ENDPOINTS.ASSIGN_TASKS, pascalOptions);
4308
4624
  // Transform response from PascalCase to camelCase
4309
4625
  const transformedResponse = pascalToCamelCaseKeys(response.data);
4310
4626
  // Process OData array response - empty array = success, non-empty = error
@@ -4314,7 +4630,6 @@ class TaskService extends BaseService {
4314
4630
  * Reassigns tasks to new users
4315
4631
  *
4316
4632
  * @param taskAssignments - Single task assignment or array of task assignments
4317
- * @param folderId - Optional folder ID
4318
4633
  * @returns Promise resolving to array of task assignment results
4319
4634
  *
4320
4635
  * @example
@@ -4344,8 +4659,7 @@ class TaskService extends BaseService {
4344
4659
  * ]);
4345
4660
  * ```
4346
4661
  */
4347
- async reassign(taskAssignments, folderId) {
4348
- const headers = createHeaders({ [FOLDER_ID]: folderId });
4662
+ async reassign(taskAssignments) {
4349
4663
  // Normalize input to array
4350
4664
  const assignmentArray = Array.isArray(taskAssignments) ? taskAssignments : [taskAssignments];
4351
4665
  const options = {
@@ -4353,7 +4667,7 @@ class TaskService extends BaseService {
4353
4667
  };
4354
4668
  // Convert options to PascalCase for API
4355
4669
  const pascalOptions = camelToPascalCaseKeys(options);
4356
- const response = await this.post(TASK_ENDPOINTS.REASSIGN_TASKS, pascalOptions, { headers });
4670
+ const response = await this.post(TASK_ENDPOINTS.REASSIGN_TASKS, pascalOptions);
4357
4671
  // Transform response from PascalCase to camelCase
4358
4672
  const transformedResponse = pascalToCamelCaseKeys(response.data);
4359
4673
  // Process OData array response - empty array = success, non-empty = error
@@ -4363,7 +4677,6 @@ class TaskService extends BaseService {
4363
4677
  * Unassigns tasks (removes current assignees)
4364
4678
  *
4365
4679
  * @param taskIds - Single task ID or array of task IDs to unassign
4366
- * @param folderId - Optional folder ID
4367
4680
  * @returns Promise resolving to array of task assignment results
4368
4681
  *
4369
4682
  * @example
@@ -4375,14 +4688,13 @@ class TaskService extends BaseService {
4375
4688
  * const result = await sdk.tasks.unassign([123, 456, 789]);
4376
4689
  * ```
4377
4690
  */
4378
- async unassign(taskIds, folderId) {
4379
- const headers = createHeaders({ [FOLDER_ID]: folderId });
4691
+ async unassign(taskIds) {
4380
4692
  // Normalize input to array
4381
4693
  const taskIdArray = Array.isArray(taskIds) ? taskIds : [taskIds];
4382
4694
  const options = {
4383
4695
  taskIds: taskIdArray
4384
4696
  };
4385
- const response = await this.post(TASK_ENDPOINTS.UNASSIGN_TASKS, options, { headers });
4697
+ const response = await this.post(TASK_ENDPOINTS.UNASSIGN_TASKS, options);
4386
4698
  // Transform response from PascalCase to camelCase
4387
4699
  const transformedResponse = pascalToCamelCaseKeys(response.data);
4388
4700
  // Process OData array response - empty array = success, non-empty = error
@@ -4392,30 +4704,31 @@ class TaskService extends BaseService {
4392
4704
  /**
4393
4705
  * Completes a task with the specified type and data
4394
4706
  *
4395
- * @param completionType - The type of task (Form, App, or Generic)
4396
- * @param options - The completion options
4707
+ * @param options - The completion options including task type, taskId, data, and action
4397
4708
  * @param folderId - Required folder ID
4398
- * @returns Promise resolving to void
4709
+ * @returns Promise resolving to completion result
4399
4710
  *
4400
4711
  * @example
4401
4712
  * ```typescript
4402
4713
  * // Complete an app task
4403
- * await sdk.tasks.complete(TaskType.App, {
4714
+ * await sdk.tasks.complete({
4715
+ * type: TaskType.App,
4404
4716
  * taskId: 456,
4405
4717
  * data: {},
4406
4718
  * action: "submit"
4407
4719
  * }, 123); // folderId is required
4408
4720
  *
4409
4721
  * // Complete an external task
4410
- * await sdk.tasks.complete(TaskType.ExternalTask, {
4722
+ * await sdk.tasks.complete({
4723
+ * type: TaskType.External,
4411
4724
  * taskId: 789
4412
4725
  * }, 123); // folderId is required
4413
4726
  * ```
4414
4727
  */
4415
- async complete(completionType, options, folderId) {
4728
+ async complete(options, folderId) {
4416
4729
  const headers = createHeaders({ [FOLDER_ID]: folderId });
4417
4730
  let endpoint;
4418
- switch (completionType) {
4731
+ switch (options.type) {
4419
4732
  case exports.TaskType.Form:
4420
4733
  endpoint = TASK_ENDPOINTS.COMPLETE_FORM_TASK;
4421
4734
  break;
@@ -4454,6 +4767,19 @@ class TaskService extends BaseService {
4454
4767
  const transformedFormTask = transformData(response.data, TaskMap);
4455
4768
  return createTaskWithMethods(applyDataTransforms(transformedFormTask, { field: 'status', valueMap: TaskStatusMap }), this);
4456
4769
  }
4770
+ /**
4771
+ * Adds default expand parameters to options
4772
+ * @param options - The options object to add default expand to
4773
+ * @returns Options with default expand parameters added
4774
+ * @private
4775
+ */
4776
+ addDefaultExpand(options) {
4777
+ const processedOptions = { ...options };
4778
+ processedOptions.expand = processedOptions.expand
4779
+ ? `${DEFAULT_TASK_EXPAND},${processedOptions.expand}`
4780
+ : DEFAULT_TASK_EXPAND;
4781
+ return processedOptions;
4782
+ }
4457
4783
  }
4458
4784
  __decorate([
4459
4785
  track('Tasks.Create')
@@ -5046,17 +5372,6 @@ const BucketMap = {
5046
5372
  verb: 'httpMethod'
5047
5373
  };
5048
5374
 
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
5375
  class BucketService extends FolderScopedService {
5061
5376
  /**
5062
5377
  * @hideconstructor
@@ -5229,19 +5544,18 @@ class BucketService extends FolderScopedService {
5229
5544
  * content: file
5230
5545
  * });
5231
5546
  *
5232
- * // In Node env with explicit content type
5547
+ * // In Node env with Buffer
5233
5548
  * const buffer = Buffer.from('file content');
5234
5549
  * const result = await sdk.buckets.uploadFile({
5235
5550
  * bucketId: 123,
5236
5551
  * folderId: 456,
5237
5552
  * path: '/folder/example.txt',
5238
- * content: buffer,
5239
- * contentType: 'text/plain'
5553
+ * content: buffer
5240
5554
  * });
5241
5555
  * ```
5242
5556
  */
5243
5557
  async uploadFile(options) {
5244
- const { bucketId, folderId, path, content, contentType } = options;
5558
+ const { bucketId, folderId, path, content } = options;
5245
5559
  if (!bucketId) {
5246
5560
  throw new ValidationError({ message: 'bucketId is required for uploadFile' });
5247
5561
  }
@@ -5255,19 +5569,13 @@ class BucketService extends FolderScopedService {
5255
5569
  throw new ValidationError({ message: 'content is required for uploadFile' });
5256
5570
  }
5257
5571
  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
5572
  const uriResponse = await this._getWriteUri({
5264
5573
  bucketId,
5265
5574
  folderId,
5266
5575
  path,
5267
- contentType: detectedContentType
5268
5576
  });
5269
5577
  // Upload file to the provided URI
5270
- const response = await this._uploadToUri(uriResponse, content, detectedContentType);
5578
+ const response = await this._uploadToUri(uriResponse, content);
5271
5579
  return {
5272
5580
  success: response.status >= 200 && response.status < 300,
5273
5581
  statusCode: response.status
@@ -5278,61 +5586,42 @@ class BucketService extends FolderScopedService {
5278
5586
  }
5279
5587
  }
5280
5588
  /**
5281
- * Determines the content type of the file based on the content and path
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
5589
+ * Gets a direct download URL for a file in the bucket
5287
5590
  *
5288
- * @param content - The file content
5289
- * @param path - The file path
5290
- * @returns The determined content type or default
5591
+ * @param options - Contains bucketId, folderId, file path and optional expiry time
5592
+ * @returns Promise resolving to blob file access information
5593
+ *
5594
+ * @example
5595
+ * ```typescript
5596
+ * // Get download URL for a file
5597
+ * const fileAccess = await sdk.buckets.getReadUri({
5598
+ * bucketId: 123,
5599
+ * folderId: 456,
5600
+ * path: '/folder/file.pdf'
5601
+ * });
5602
+ * ```
5291
5603
  */
5292
- async _determineContentType(content, path) {
5293
- // 1. If content is a File or Blob with type, use that (works in browser)
5294
- if ('type' in content && content.type) {
5295
- return content.type;
5296
- }
5297
- // 2. Try content-based detection (primarily for Node.js)
5298
- if (content instanceof Buffer && fileTypeFromBuffer) {
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;
5604
+ async getReadUri(options) {
5605
+ const { bucketId, folderId, path, expiryInMinutes, ...restOptions } = options;
5606
+ const queryOptions = {
5607
+ expiryInMinutes,
5608
+ ...addPrefixToKeys(restOptions, ODATA_PREFIX, Object.keys(restOptions))
5609
+ };
5610
+ return this._getUri(BUCKET_ENDPOINTS.GET_READ_URI(bucketId), bucketId, folderId, path, queryOptions);
5317
5611
  }
5318
5612
  /**
5319
5613
  * Uploads content to the provided URI
5320
5614
  * @param uriResponse - Response from getWriteUri containing URL and headers
5321
5615
  * @param content - The content to upload
5322
- * @param contentType - The content type of the file
5323
5616
  * @returns The response from the upload request with status info
5324
5617
  */
5325
- async _uploadToUri(uriResponse, content, contentType) {
5618
+ async _uploadToUri(uriResponse, content) {
5326
5619
  const { uri, headers = {}, requiresAuth } = uriResponse;
5327
5620
  if (!uri) {
5328
5621
  throw new ValidationError({ message: 'Upload URI not available', statusCode: HttpStatus.BAD_REQUEST });
5329
5622
  }
5330
5623
  // Create headers for the request
5331
5624
  let requestHeaders = { ...headers };
5332
- // Ensure content-type is set if provided
5333
- if (contentType && !requestHeaders['content-type']) {
5334
- requestHeaders['content-type'] = contentType;
5335
- }
5336
5625
  // Add auth header if required
5337
5626
  if (requiresAuth) {
5338
5627
  try {
@@ -5404,41 +5693,16 @@ class BucketService extends FolderScopedService {
5404
5693
  }
5405
5694
  return transformedData;
5406
5695
  }
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
5696
  /**
5432
5697
  * Gets a direct upload URL for a file in the bucket
5433
5698
  *
5434
- * @param options - Contains bucketId, folderId, file path, optional expiry time and content type
5699
+ * @param options - Contains bucketId, folderId, file path, optional expiry time
5435
5700
  * @returns Promise resolving to blob file access information
5436
5701
  */
5437
5702
  async _getWriteUri(options) {
5438
- const { bucketId, folderId, path, expiryInMinutes, contentType, ...restOptions } = options;
5703
+ const { bucketId, folderId, path, expiryInMinutes, ...restOptions } = options;
5439
5704
  const queryOptions = {
5440
5705
  expiryInMinutes,
5441
- contentType,
5442
5706
  ...addPrefixToKeys(restOptions, ODATA_PREFIX, Object.keys(restOptions))
5443
5707
  };
5444
5708
  return this._getUri(BUCKET_ENDPOINTS.GET_WRITE_URI(bucketId), bucketId, folderId, path, queryOptions);
@@ -5581,11 +5845,9 @@ class ProcessService extends BaseService {
5581
5845
  delete apiRequest[clientKey];
5582
5846
  }
5583
5847
  });
5584
- // Convert to PascalCase for API
5585
- const pascalOptions = camelToPascalCaseKeys(apiRequest);
5586
5848
  // Create the request object according to API spec
5587
5849
  const requestBody = {
5588
- startInfo: pascalOptions
5850
+ startInfo: apiRequest
5589
5851
  };
5590
5852
  // Prefix all query parameter keys with '$' for OData
5591
5853
  const keysToPrefix = Object.keys(options);
@@ -5886,7 +6148,11 @@ class UiPath {
5886
6148
  /**
5887
6149
  * Access to Process Instances service
5888
6150
  */
5889
- instances: this.getService(ProcessInstancesService)
6151
+ instances: this.getService(ProcessInstancesService),
6152
+ /**
6153
+ * Access to Process Incidents service
6154
+ */
6155
+ incidents: this.getService(ProcessIncidentsService)
5890
6156
  }),
5891
6157
  /**
5892
6158
  * Access to Maestro Cases service
@@ -6128,6 +6394,7 @@ exports.ValidationError = ValidationError;
6128
6394
  exports.createCaseInstanceWithMethods = createCaseInstanceWithMethods;
6129
6395
  exports.createEntityWithMethods = createEntityWithMethods;
6130
6396
  exports.createProcessInstanceWithMethods = createProcessInstanceWithMethods;
6397
+ exports.createProcessWithMethods = createProcessWithMethods;
6131
6398
  exports.createTaskWithMethods = createTaskWithMethods;
6132
6399
  exports.getErrorDetails = getErrorDetails;
6133
6400
  exports.getLimitedPageSize = getLimitedPageSize;