@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.
@@ -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, details } = errorInfo;
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: 1
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 || 1,
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}`,
@@ -2359,12 +2366,17 @@ class AuthService extends BaseService {
2359
2366
  }
2360
2367
  else {
2361
2368
  // In Node.js environment
2362
- const crypto = require('crypto');
2363
- return crypto.randomBytes(32)
2364
- .toString('base64')
2365
- .replace(/\+/g, '-')
2366
- .replace(/\//g, '_')
2367
- .replace(/=/g, '');
2369
+ try {
2370
+ const crypto = require('crypto');
2371
+ return crypto.randomBytes(32)
2372
+ .toString('base64')
2373
+ .replace(/\+/g, '-')
2374
+ .replace(/\//g, '_')
2375
+ .replace(/=/g, '');
2376
+ }
2377
+ catch (e) {
2378
+ throw new Error("crypto not available in browser");
2379
+ }
2368
2380
  }
2369
2381
  }
2370
2382
  /**
@@ -2379,13 +2391,18 @@ class AuthService extends BaseService {
2379
2391
  }
2380
2392
  else {
2381
2393
  // In Node.js environment
2382
- const crypto = require('crypto');
2383
- return crypto.createHash('sha256')
2384
- .update(codeVerifier)
2385
- .digest('base64')
2386
- .replace(/\+/g, '-')
2387
- .replace(/\//g, '_')
2388
- .replace(/=/g, '');
2394
+ try {
2395
+ const crypto = require('crypto');
2396
+ return crypto.createHash('sha256')
2397
+ .update(codeVerifier)
2398
+ .digest('base64')
2399
+ .replace(/\+/g, '-')
2400
+ .replace(/\//g, '_')
2401
+ .replace(/=/g, '');
2402
+ }
2403
+ catch (e) {
2404
+ throw new Error("crypto not available in browser");
2405
+ }
2389
2406
  }
2390
2407
  }
2391
2408
  /**
@@ -2712,7 +2729,7 @@ const EntityFieldTypeMap = {
2712
2729
  // Connection string placeholder that will be replaced during build
2713
2730
  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
2731
  // SDK Version placeholder
2715
- const SDK_VERSION = "1.0.0-beta.14";
2732
+ const SDK_VERSION = "1.0.0-beta.16";
2716
2733
  const VERSION = "Version";
2717
2734
  const SERVICE = "Service";
2718
2735
  const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
@@ -3025,76 +3042,6 @@ class EntityService extends BaseService {
3025
3042
  // Return the entity metadata with methods attached
3026
3043
  return createEntityWithMethods(metadata, this);
3027
3044
  }
3028
- /**
3029
- * Orchestrates all field mapping transformations
3030
- *
3031
- * @param metadata - Entity metadata to transform
3032
- * @private
3033
- */
3034
- applyFieldMappings(metadata) {
3035
- this.mapFieldTypes(metadata);
3036
- this.mapExternalFields(metadata);
3037
- }
3038
- /**
3039
- * Maps SQL field types to friendly EntityFieldTypes
3040
- *
3041
- * @param metadata - Entity metadata with fields
3042
- * @private
3043
- */
3044
- mapFieldTypes(metadata) {
3045
- if (!metadata.fields?.length)
3046
- return;
3047
- metadata.fields = metadata.fields.map(field => {
3048
- // Rename sqlType to fieldDataType
3049
- let transformedField = transformData(field, EntityMap);
3050
- // Map SQL field type to friendly name
3051
- if (transformedField.fieldDataType?.name) {
3052
- const sqlTypeName = transformedField.fieldDataType.name;
3053
- if (EntityFieldTypeMap[sqlTypeName]) {
3054
- transformedField.fieldDataType.name = EntityFieldTypeMap[sqlTypeName];
3055
- }
3056
- }
3057
- this.transformNestedReferences(transformedField);
3058
- return transformedField;
3059
- });
3060
- }
3061
- /**
3062
- * Transforms nested reference objects in field metadata
3063
- */
3064
- transformNestedReferences(field) {
3065
- if (field.referenceEntity) {
3066
- field.referenceEntity = transformData(field.referenceEntity, EntityMap);
3067
- }
3068
- if (field.referenceChoiceSet) {
3069
- field.referenceChoiceSet = transformData(field.referenceChoiceSet, EntityMap);
3070
- }
3071
- if (field.referenceField?.definition) {
3072
- field.referenceField.definition = transformData(field.referenceField.definition, EntityMap);
3073
- }
3074
- }
3075
- /**
3076
- * Maps external field names to consistent naming
3077
- *
3078
- * @param metadata - Entity metadata with externalFields
3079
- * @private
3080
- */
3081
- mapExternalFields(metadata) {
3082
- if (!metadata.externalFields?.length)
3083
- return;
3084
- metadata.externalFields = metadata.externalFields.map(externalSource => {
3085
- if (externalSource.fields?.length) {
3086
- externalSource.fields = externalSource.fields.map(field => {
3087
- const transformedField = transformData(field, EntityMap);
3088
- if (transformedField.fieldMetaData) {
3089
- transformedField.fieldMetaData = transformData(transformedField.fieldMetaData, EntityMap);
3090
- this.transformNestedReferences(transformedField.fieldMetaData);
3091
- }
3092
- return transformedField;
3093
- });
3094
- }
3095
- return externalSource;
3096
- });
3097
- }
3098
3045
  /**
3099
3046
  * Gets entity records by entity ID
3100
3047
  *
@@ -3129,7 +3076,6 @@ class EntityService extends BaseService {
3129
3076
  return PaginationHelpers.getAll({
3130
3077
  serviceAccess: this.createPaginationServiceAccess(),
3131
3078
  getEndpoint: () => DATA_FABRIC_ENDPOINTS.ENTITY.GET_ENTITY_RECORDS(entityId),
3132
- transformFn: (item) => pascalToCamelCaseKeys(item),
3133
3079
  pagination: {
3134
3080
  paginationType: PaginationType.OFFSET,
3135
3081
  itemsField: ENTITY_PAGINATION.ITEMS_FIELD,
@@ -3276,6 +3222,76 @@ class EntityService extends BaseService {
3276
3222
  });
3277
3223
  return entities;
3278
3224
  }
3225
+ /**
3226
+ * Orchestrates all field mapping transformations
3227
+ *
3228
+ * @param metadata - Entity metadata to transform
3229
+ * @private
3230
+ */
3231
+ applyFieldMappings(metadata) {
3232
+ this.mapFieldTypes(metadata);
3233
+ this.mapExternalFields(metadata);
3234
+ }
3235
+ /**
3236
+ * Maps SQL field types to friendly EntityFieldTypes
3237
+ *
3238
+ * @param metadata - Entity metadata with fields
3239
+ * @private
3240
+ */
3241
+ mapFieldTypes(metadata) {
3242
+ if (!metadata.fields?.length)
3243
+ return;
3244
+ metadata.fields = metadata.fields.map(field => {
3245
+ // Rename sqlType to fieldDataType
3246
+ let transformedField = transformData(field, EntityMap);
3247
+ // Map SQL field type to friendly name
3248
+ if (transformedField.fieldDataType?.name) {
3249
+ const sqlTypeName = transformedField.fieldDataType.name;
3250
+ if (EntityFieldTypeMap[sqlTypeName]) {
3251
+ transformedField.fieldDataType.name = EntityFieldTypeMap[sqlTypeName];
3252
+ }
3253
+ }
3254
+ this.transformNestedReferences(transformedField);
3255
+ return transformedField;
3256
+ });
3257
+ }
3258
+ /**
3259
+ * Transforms nested reference objects in field metadata
3260
+ */
3261
+ transformNestedReferences(field) {
3262
+ if (field.referenceEntity) {
3263
+ field.referenceEntity = transformData(field.referenceEntity, EntityMap);
3264
+ }
3265
+ if (field.referenceChoiceSet) {
3266
+ field.referenceChoiceSet = transformData(field.referenceChoiceSet, EntityMap);
3267
+ }
3268
+ if (field.referenceField?.definition) {
3269
+ field.referenceField.definition = transformData(field.referenceField.definition, EntityMap);
3270
+ }
3271
+ }
3272
+ /**
3273
+ * Maps external field names to consistent naming
3274
+ *
3275
+ * @param metadata - Entity metadata with externalFields
3276
+ * @private
3277
+ */
3278
+ mapExternalFields(metadata) {
3279
+ if (!metadata.externalFields?.length)
3280
+ return;
3281
+ metadata.externalFields = metadata.externalFields.map(externalSource => {
3282
+ if (externalSource.fields?.length) {
3283
+ externalSource.fields = externalSource.fields.map(field => {
3284
+ const transformedField = transformData(field, EntityMap);
3285
+ if (transformedField.fieldMetaData) {
3286
+ transformedField.fieldMetaData = transformData(transformedField.fieldMetaData, EntityMap);
3287
+ this.transformNestedReferences(transformedField.fieldMetaData);
3288
+ }
3289
+ return transformedField;
3290
+ });
3291
+ }
3292
+ return externalSource;
3293
+ });
3294
+ }
3279
3295
  }
3280
3296
  __decorate([
3281
3297
  track('Entities.GetById')
@@ -3297,46 +3313,161 @@ __decorate([
3297
3313
  ], EntityService.prototype, "getAll", null);
3298
3314
 
3299
3315
  /**
3300
- * Service for interacting with Maestro Processes
3316
+ * Maestro Process Models
3317
+ * Model classes for Maestro processes
3301
3318
  */
3302
- class MaestroProcessesService extends BaseService {
3319
+ /**
3320
+ * Creates methods for a process object
3321
+ *
3322
+ * @param processData - The process data (response from API)
3323
+ * @param service - The process service instance
3324
+ * @returns Object containing process methods
3325
+ */
3326
+ function createProcessMethods(processData, service) {
3327
+ return {
3328
+ async getIncidents() {
3329
+ if (!processData.processKey)
3330
+ throw new Error('Process key is undefined');
3331
+ if (!processData.folderKey)
3332
+ throw new Error('Folder key is undefined');
3333
+ return service.getIncidents(processData.processKey, processData.folderKey);
3334
+ }
3335
+ };
3336
+ }
3337
+ /**
3338
+ * Creates an actionable process by combining API process data with operational methods.
3339
+ *
3340
+ * @param processData - The process data from API
3341
+ * @param service - The process service instance
3342
+ * @returns A process object with added methods
3343
+ */
3344
+ function createProcessWithMethods(processData, service) {
3345
+ const methods = createProcessMethods(processData, service);
3346
+ return Object.assign({}, processData, methods);
3347
+ }
3348
+
3349
+ /**
3350
+ * Maps fields for Incident entities
3351
+ */
3352
+ const ProcessIncidentMap = {
3353
+ errorTimeUtc: 'errorTime'
3354
+ };
3355
+ /**
3356
+ * Maps fields for Incident Summary entities
3357
+ */
3358
+ const ProcessIncidentSummaryMap = {
3359
+ firstTimeUtc: 'firstOccuranceTime'
3360
+ };
3361
+
3362
+ /**
3363
+ * Helpers for fetching BPMN XML and extracting element details used to annotate responses
3364
+ */
3365
+ class BpmnHelpers {
3303
3366
  /**
3304
- * @hideconstructor
3367
+ * Parse BPMN XML and extract element id → {name,type} used for incidents
3305
3368
  */
3306
- constructor(config, executionContext, tokenManager) {
3307
- super(config, executionContext, tokenManager);
3369
+ static parseBpmnElementsForIncidents(bpmnXml) {
3370
+ const elementInfo = {};
3371
+ try {
3372
+ // Find <bpmn:...> start tags and capture the element type.
3373
+ // Then read 'id' and 'name' attributes from each tag.
3374
+ const bpmnOpenTagRegex = /<bpmn:([A-Za-z][\w.-]*)\b[^>]*>/g;
3375
+ for (const tagMatch of bpmnXml.matchAll(bpmnOpenTagRegex)) {
3376
+ const [fullTag, elementType] = tagMatch;
3377
+ // Extract attributes from the current tag text.
3378
+ const idMatch = /\bid\s*=\s*"([^"]*)"/.exec(fullTag);
3379
+ if (!idMatch) {
3380
+ continue;
3381
+ }
3382
+ const elementId = idMatch[1];
3383
+ const nameMatch = /\bname\s*=\s*"([^"]*)"/.exec(fullTag);
3384
+ const name = nameMatch ? nameMatch[1] : '';
3385
+ // Convert BPMN element type to human-readable format
3386
+ const activityType = this.formatActivityTypeForIncidents(elementType);
3387
+ const activityName = name || elementId;
3388
+ elementInfo[elementId] = {
3389
+ type: activityType,
3390
+ name: activityName
3391
+ };
3392
+ }
3393
+ }
3394
+ catch (error) {
3395
+ console.warn('Failed to parse BPMN XML for incidents:', error);
3396
+ }
3397
+ return elementInfo;
3308
3398
  }
3309
3399
  /**
3310
- * Get all processes with their instance statistics
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
- * ```
3400
+ * Format BPMN element type to human-readable activity type for incidents
3326
3401
  */
3327
- async getAll() {
3328
- const response = await this.get(MAESTRO_ENDPOINTS.PROCESSES.GET_ALL);
3329
- // Extract processes array from response data and add name field
3330
- const processes = response.data?.processes || [];
3331
- return processes.map(process => ({
3332
- ...process,
3333
- name: process.packageId
3402
+ static formatActivityTypeForIncidents(elementType) {
3403
+ // Convert camelCase BPMN element types to human-readable format
3404
+ // e.g., "serviceTask" -> "Service Task", "exclusiveGateway" -> "Exclusive Gateway"
3405
+ return elementType
3406
+ .replace(/([A-Z])/g, ' $1') // Add space before uppercase letters
3407
+ .replace(/^./, str => str.toUpperCase()) // Capitalize first letter
3408
+ .trim(); // Remove any leading/trailing spaces
3409
+ }
3410
+ /**
3411
+ * Fetch BPMN via getBpmn and add element name/type to each incident
3412
+ */
3413
+ static async enrichIncidentsWithBpmnData(incidents, folderKey, service) {
3414
+ // Check if all incidents have the same instanceId
3415
+ const uniqueInstanceIds = [...new Set(incidents.map(i => i.instanceId))];
3416
+ if (uniqueInstanceIds.length === 1) {
3417
+ // Single instance optimization (in case of process instance incidents)
3418
+ const elementInfo = await this.getBpmnElementInfo(uniqueInstanceIds[0], folderKey, service);
3419
+ return incidents.map((incident) => this.transformIncidentWithBpmn(incident, elementInfo));
3420
+ }
3421
+ else {
3422
+ // Multiple instances optimization (in case of process incidents)
3423
+ return this.enrichMultipleInstanceIncidents(incidents, folderKey, service);
3424
+ }
3425
+ }
3426
+ /**
3427
+ * When incidents span multiple instances, fetch BPMN per instance and annotate
3428
+ */
3429
+ static async enrichMultipleInstanceIncidents(incidents, folderKey, service) {
3430
+ const groups = incidents.reduce((acc, incident) => {
3431
+ const id = incident.instanceId || NO_INSTANCE;
3432
+ (acc[id] = acc[id] || []).push(incident);
3433
+ return acc;
3434
+ }, {});
3435
+ const results = await Promise.all(Object.entries(groups).map(async (entry) => {
3436
+ const [instanceId, groupIncidents] = entry;
3437
+ const elementInfo = await this.getBpmnElementInfo(instanceId, folderKey, service);
3438
+ return groupIncidents.map((incident) => this.transformIncidentWithBpmn(incident, elementInfo));
3334
3439
  }));
3440
+ return results.flat();
3441
+ }
3442
+ /**
3443
+ * Retrieve BPMN XML for an instance and derive element id → {name,type}
3444
+ */
3445
+ static async getBpmnElementInfo(instanceId, folderKey, service) {
3446
+ if (!instanceId || instanceId === NO_INSTANCE) {
3447
+ return {};
3448
+ }
3449
+ try {
3450
+ const bpmnXml = await service.getBpmn(instanceId, folderKey);
3451
+ return this.parseBpmnElementsForIncidents(bpmnXml);
3452
+ }
3453
+ catch (error) {
3454
+ console.warn(`Failed to get BPMN for instance ${instanceId}:`, error);
3455
+ return {};
3456
+ }
3457
+ }
3458
+ /**
3459
+ * Transform a raw incident by attaching element name/type from BPMN
3460
+ */
3461
+ static transformIncidentWithBpmn(incident, elementInfo) {
3462
+ const element = elementInfo[incident.elementId];
3463
+ const transformed = transformData(incident, ProcessIncidentMap);
3464
+ return {
3465
+ ...transformed,
3466
+ incidentElementActivityType: element?.type || UNKNOWN$1,
3467
+ incidentElementActivityName: element?.name || UNKNOWN$1
3468
+ };
3335
3469
  }
3336
3470
  }
3337
- __decorate([
3338
- track('MaestroProcesses.GetAll')
3339
- ], MaestroProcessesService.prototype, "getAll", null);
3340
3471
 
3341
3472
  /**
3342
3473
  * Creates methods for a process instance
@@ -3350,17 +3481,49 @@ function createProcessInstanceMethods(instanceData, service) {
3350
3481
  async cancel(options) {
3351
3482
  if (!instanceData.instanceId)
3352
3483
  throw new Error('Process instance ID is undefined');
3484
+ if (!instanceData.folderKey)
3485
+ throw new Error('Process instance folder key is undefined');
3353
3486
  return service.cancel(instanceData.instanceId, instanceData.folderKey, options);
3354
3487
  },
3355
3488
  async pause(options) {
3356
3489
  if (!instanceData.instanceId)
3357
3490
  throw new Error('Process instance ID is undefined');
3491
+ if (!instanceData.folderKey)
3492
+ throw new Error('Process instance folder key is undefined');
3358
3493
  return service.pause(instanceData.instanceId, instanceData.folderKey, options);
3359
3494
  },
3360
3495
  async resume(options) {
3361
3496
  if (!instanceData.instanceId)
3362
3497
  throw new Error('Process instance ID is undefined');
3498
+ if (!instanceData.folderKey)
3499
+ throw new Error('Process instance folder key is undefined');
3363
3500
  return service.resume(instanceData.instanceId, instanceData.folderKey, options);
3501
+ },
3502
+ async getIncidents() {
3503
+ if (!instanceData.instanceId)
3504
+ throw new Error('Process instance ID is undefined');
3505
+ if (!instanceData.folderKey)
3506
+ throw new Error('Process instance folder key is undefined');
3507
+ return service.getIncidents(instanceData.instanceId, instanceData.folderKey);
3508
+ },
3509
+ async getExecutionHistory() {
3510
+ if (!instanceData.instanceId)
3511
+ throw new Error('Process instance ID is undefined');
3512
+ return service.getExecutionHistory(instanceData.instanceId);
3513
+ },
3514
+ async getBpmn() {
3515
+ if (!instanceData.instanceId)
3516
+ throw new Error('Process instance ID is undefined');
3517
+ if (!instanceData.folderKey)
3518
+ throw new Error('Process instance folder key is undefined');
3519
+ return service.getBpmn(instanceData.instanceId, instanceData.folderKey);
3520
+ },
3521
+ async getVariables(options) {
3522
+ if (!instanceData.instanceId)
3523
+ throw new Error('Process instance ID is undefined');
3524
+ if (!instanceData.folderKey)
3525
+ throw new Error('Process instance folder key is undefined');
3526
+ return service.getVariables(instanceData.instanceId, instanceData.folderKey, options);
3364
3527
  }
3365
3528
  };
3366
3529
  }
@@ -3376,6 +3539,42 @@ function createProcessInstanceWithMethods(instanceData, service) {
3376
3539
  return Object.assign({}, instanceData, methods);
3377
3540
  }
3378
3541
 
3542
+ /**
3543
+ * Process Incident Status
3544
+ */
3545
+ var ProcessIncidentStatus;
3546
+ (function (ProcessIncidentStatus) {
3547
+ ProcessIncidentStatus["Open"] = "Open";
3548
+ ProcessIncidentStatus["Closed"] = "Closed";
3549
+ })(ProcessIncidentStatus || (ProcessIncidentStatus = {}));
3550
+ /**
3551
+ * Process Incident Type
3552
+ */
3553
+ var ProcessIncidentType;
3554
+ (function (ProcessIncidentType) {
3555
+ ProcessIncidentType["System"] = "System";
3556
+ ProcessIncidentType["User"] = "User";
3557
+ ProcessIncidentType["Deployment"] = "Deployment";
3558
+ })(ProcessIncidentType || (ProcessIncidentType = {}));
3559
+ /**
3560
+ * Process Incident Severity
3561
+ */
3562
+ var ProcessIncidentSeverity;
3563
+ (function (ProcessIncidentSeverity) {
3564
+ ProcessIncidentSeverity["Error"] = "Error";
3565
+ ProcessIncidentSeverity["Warning"] = "Warning";
3566
+ })(ProcessIncidentSeverity || (ProcessIncidentSeverity = {}));
3567
+ /**
3568
+ * Process Incident Debug Mode
3569
+ */
3570
+ var DebugMode;
3571
+ (function (DebugMode) {
3572
+ DebugMode["None"] = "None";
3573
+ DebugMode["Default"] = "Default";
3574
+ DebugMode["StepByStep"] = "StepByStep";
3575
+ DebugMode["SingleStep"] = "SingleStep";
3576
+ })(DebugMode || (DebugMode = {}));
3577
+
3379
3578
  /**
3380
3579
  * Case Instance Types
3381
3580
  * Types and interfaces for Maestro case instance management
@@ -3438,17 +3637,42 @@ function createCaseInstanceMethods(instanceData, service) {
3438
3637
  async close(options) {
3439
3638
  if (!instanceData.instanceId)
3440
3639
  throw new Error('Case instance ID is undefined');
3640
+ if (!instanceData.folderKey)
3641
+ throw new Error('Case instance folder key is undefined');
3441
3642
  return service.close(instanceData.instanceId, instanceData.folderKey, options);
3442
3643
  },
3443
3644
  async pause(options) {
3444
3645
  if (!instanceData.instanceId)
3445
3646
  throw new Error('Case instance ID is undefined');
3647
+ if (!instanceData.folderKey)
3648
+ throw new Error('Case instance folder key is undefined');
3446
3649
  return service.pause(instanceData.instanceId, instanceData.folderKey, options);
3447
3650
  },
3448
3651
  async resume(options) {
3449
3652
  if (!instanceData.instanceId)
3450
3653
  throw new Error('Case instance ID is undefined');
3654
+ if (!instanceData.folderKey)
3655
+ throw new Error('Case instance folder key is undefined');
3451
3656
  return service.resume(instanceData.instanceId, instanceData.folderKey, options);
3657
+ },
3658
+ async getExecutionHistory() {
3659
+ if (!instanceData.instanceId)
3660
+ throw new Error('Case instance ID is undefined');
3661
+ if (!instanceData.folderKey)
3662
+ throw new Error('Case instance folder key is undefined');
3663
+ return service.getExecutionHistory(instanceData.instanceId, instanceData.folderKey);
3664
+ },
3665
+ async getStages() {
3666
+ if (!instanceData.instanceId)
3667
+ throw new Error('Case instance ID is undefined');
3668
+ if (!instanceData.folderKey)
3669
+ throw new Error('Case instance folder key is undefined');
3670
+ return service.getStages(instanceData.instanceId, instanceData.folderKey);
3671
+ },
3672
+ async getActionTasks(options) {
3673
+ if (!instanceData.instanceId)
3674
+ throw new Error('Case instance ID is undefined');
3675
+ return service.getActionTasks(instanceData.instanceId, options);
3452
3676
  }
3453
3677
  };
3454
3678
  }
@@ -3746,6 +3970,19 @@ class ProcessInstancesService extends BaseService {
3746
3970
  };
3747
3971
  return variablesResponse;
3748
3972
  }
3973
+ /**
3974
+ * Get incidents for a process instance
3975
+ * @param instanceId The ID of the instance to get incidents for
3976
+ * @param folderKey The folder key for authorization
3977
+ * @returns Promise<ProcessIncidentGetResponse[]>
3978
+ */
3979
+ async getIncidents(instanceId, folderKey) {
3980
+ const rawResponse = await this.get(MAESTRO_ENDPOINTS.INCIDENTS.GET_BY_INSTANCE(instanceId), {
3981
+ headers: createHeaders({ [FOLDER_KEY]: folderKey })
3982
+ });
3983
+ // Filter out excluded fields and transform response, then enrich with BPMN data
3984
+ return BpmnHelpers.enrichIncidentsWithBpmnData(rawResponse.data || [], folderKey, this);
3985
+ }
3749
3986
  }
3750
3987
  __decorate([
3751
3988
  track('ProcessInstances.GetAll')
@@ -3771,6 +4008,101 @@ __decorate([
3771
4008
  __decorate([
3772
4009
  track('ProcessInstances.GetVariables')
3773
4010
  ], ProcessInstancesService.prototype, "getVariables", null);
4011
+ __decorate([
4012
+ track('ProcessInstances.GetIncidents')
4013
+ ], ProcessInstancesService.prototype, "getIncidents", null);
4014
+
4015
+ /**
4016
+ * Service for interacting with Maestro Processes
4017
+ */
4018
+ class MaestroProcessesService extends BaseService {
4019
+ /**
4020
+ * @hideconstructor
4021
+ */
4022
+ constructor(config, executionContext, tokenManager) {
4023
+ super(config, executionContext, tokenManager);
4024
+ this.processInstancesService = new ProcessInstancesService(config, executionContext, tokenManager);
4025
+ }
4026
+ /**
4027
+ * Get all processes with their instance statistics
4028
+ * @returns Promise resolving to array of MaestroProcess objects
4029
+ *
4030
+ * @example
4031
+ * ```typescript
4032
+ * // Get all processes
4033
+ * const processes = await sdk.maestro.processes.getAll();
4034
+ *
4035
+ * // Access process information
4036
+ * for (const process of processes) {
4037
+ * console.log(`Process: ${process.processKey}`);
4038
+ * console.log(`Running instances: ${process.runningCount}`);
4039
+ * console.log(`Faulted instances: ${process.faultedCount}`);
4040
+ * }
4041
+ *
4042
+ * ```
4043
+ */
4044
+ async getAll() {
4045
+ const response = await this.get(MAESTRO_ENDPOINTS.PROCESSES.GET_ALL);
4046
+ // Extract processes array from response data and add name field
4047
+ const processes = response.data?.processes || [];
4048
+ const processesWithName = processes.map(process => ({
4049
+ ...process,
4050
+ name: process.packageId
4051
+ }));
4052
+ // Add methods to each process
4053
+ return processesWithName.map(process => createProcessWithMethods(process, this));
4054
+ }
4055
+ /**
4056
+ * Get incidents for a specific process
4057
+ */
4058
+ async getIncidents(processKey, folderKey) {
4059
+ const rawResponse = await this.get(MAESTRO_ENDPOINTS.INCIDENTS.GET_BY_PROCESS(processKey), {
4060
+ headers: createHeaders({ [FOLDER_KEY]: folderKey })
4061
+ });
4062
+ // Fetch BPMN XML and add element name/type to each incident
4063
+ return BpmnHelpers.enrichIncidentsWithBpmnData(rawResponse.data || [], folderKey, this.processInstancesService);
4064
+ }
4065
+ }
4066
+ __decorate([
4067
+ track('MaestroProcesses.GetAll')
4068
+ ], MaestroProcessesService.prototype, "getAll", null);
4069
+ __decorate([
4070
+ track('MaestroProcesses.GetIncidents')
4071
+ ], MaestroProcessesService.prototype, "getIncidents", null);
4072
+
4073
+ /**
4074
+ * Service class for Maestro Process Incidents
4075
+ */
4076
+ class ProcessIncidentsService extends BaseService {
4077
+ /**
4078
+ * Get all process incidents across all folders
4079
+ *
4080
+ * @returns Promise resolving to array of process incident
4081
+ * {@link ProcessIncidentGetAllResponse}
4082
+ * @example
4083
+ * ```typescript
4084
+ * // Get all process incidents across all folders
4085
+ * const incidents = await sdk.maestro.processes.incidents.getAll();
4086
+ *
4087
+ * // Access process incident information
4088
+ * for (const incident of incidents) {
4089
+ * console.log(`Process: ${incident.processKey}`);
4090
+ * console.log(`Error: ${incident.errorMessage}`);
4091
+ * console.log(`Count: ${incident.count}`);
4092
+ * console.log(`First occurrence: ${incident.firstOccuranceTime}`);
4093
+ * }
4094
+ * ```
4095
+ */
4096
+ async getAll() {
4097
+ const rawResponse = await this.get(MAESTRO_ENDPOINTS.INCIDENTS.GET_ALL);
4098
+ // Transform field names
4099
+ const data = rawResponse.data || [];
4100
+ return data.map(incident => transformData(incident, ProcessIncidentSummaryMap));
4101
+ }
4102
+ }
4103
+ __decorate([
4104
+ track('ProcessIncidents.getAll')
4105
+ ], ProcessIncidentsService.prototype, "getAll", null);
3774
4106
 
3775
4107
  /**
3776
4108
  * Internal types for Maestro Cases
@@ -3966,35 +4298,32 @@ function createTaskMethods(taskData, service) {
3966
4298
  async assign(options) {
3967
4299
  if (!taskData.id)
3968
4300
  throw new Error('Task ID is undefined');
3969
- const assignmentOptions = {
3970
- taskId: taskData.id,
3971
- userId: options.userId || 0, // Will be handled by userNameOrEmail if userId is not provided, 0 is considered as invalid user id
3972
- userNameOrEmail: options.userNameOrEmail
3973
- };
3974
- return service.assign(assignmentOptions, taskData.organizationUnitId);
4301
+ const assignmentOptions = 'userId' in options && options.userId !== undefined
4302
+ ? { taskId: taskData.id, userId: options.userId }
4303
+ : { taskId: taskData.id, userNameOrEmail: options.userNameOrEmail };
4304
+ return service.assign(assignmentOptions);
3975
4305
  },
3976
4306
  async reassign(options) {
3977
4307
  if (!taskData.id)
3978
4308
  throw new Error('Task ID is undefined');
3979
- const assignmentOptions = {
3980
- taskId: taskData.id,
3981
- userId: options.userId || 0, // Will be handled by userNameOrEmail if userId is not provided, 0 is considered as invalid user id
3982
- userNameOrEmail: options.userNameOrEmail
3983
- };
3984
- return service.reassign(assignmentOptions, taskData.organizationUnitId);
4309
+ const assignmentOptions = 'userId' in options && options.userId !== undefined
4310
+ ? { taskId: taskData.id, userId: options.userId }
4311
+ : { taskId: taskData.id, userNameOrEmail: options.userNameOrEmail };
4312
+ return service.reassign(assignmentOptions);
3985
4313
  },
3986
4314
  async unassign() {
3987
4315
  if (!taskData.id)
3988
4316
  throw new Error('Task ID is undefined');
3989
- return service.unassign(taskData.id, taskData.organizationUnitId);
4317
+ return service.unassign(taskData.id);
3990
4318
  },
3991
4319
  async complete(options) {
3992
4320
  if (!taskData.id)
3993
4321
  throw new Error('Task ID is undefined');
3994
- const folderId = taskData.organizationUnitId;
4322
+ const folderId = taskData.folderId;
3995
4323
  if (!folderId)
3996
4324
  throw new Error('Folder ID is required');
3997
- return service.complete(options.type, {
4325
+ return service.complete({
4326
+ type: options.type,
3998
4327
  taskId: taskData.id,
3999
4328
  data: options.data,
4000
4329
  action: options.action
@@ -4031,6 +4360,10 @@ const TaskMap = {
4031
4360
  creationTime: 'createdTime',
4032
4361
  organizationUnitId: 'folderId'
4033
4362
  };
4363
+ /**
4364
+ * Default expand parameters
4365
+ */
4366
+ const DEFAULT_TASK_EXPAND = 'AssignedToUser,CreatorUser,LastModifierUser';
4034
4367
 
4035
4368
  /**
4036
4369
  * Service for interacting with UiPath Tasks API
@@ -4049,7 +4382,8 @@ class TaskService extends BaseService {
4049
4382
  * @private
4050
4383
  */
4051
4384
  this.processTaskParameters = (options, folderId) => {
4052
- const processedOptions = { ...options };
4385
+ // Add default expand parameters
4386
+ const processedOptions = this.addDefaultExpand(options);
4053
4387
  if (folderId) {
4054
4388
  // Create or add to existing filter for folder-specific queries
4055
4389
  if (processedOptions.filter) {
@@ -4208,10 +4542,11 @@ class TaskService extends BaseService {
4208
4542
  }
4209
4543
  /**
4210
4544
  * Gets a task by ID
4545
+ * IMPORTANT: For form tasks, folderId must be provided.
4211
4546
  *
4212
4547
  * @param id - The ID of the task to retrieve
4213
4548
  * @param options - Optional query parameters
4214
- * @param folderId - Optional folder ID
4549
+ * @param folderId - Optional folder ID (REQUIRED for form tasks)
4215
4550
  * @returns Promise resolving to the task (form tasks will return form-specific data)
4216
4551
  *
4217
4552
  * @example
@@ -4224,9 +4559,11 @@ class TaskService extends BaseService {
4224
4559
  */
4225
4560
  async getById(id, options = {}, folderId) {
4226
4561
  const headers = createHeaders({ [FOLDER_ID]: folderId });
4562
+ // Add default expand parameters
4563
+ const modifiedOptions = this.addDefaultExpand(options);
4227
4564
  // prefix all keys in options
4228
- const keysToPrefix = Object.keys(options);
4229
- const apiOptions = addPrefixToKeys(options, ODATA_PREFIX, keysToPrefix);
4565
+ const keysToPrefix = Object.keys(modifiedOptions);
4566
+ const apiOptions = addPrefixToKeys(modifiedOptions, ODATA_PREFIX, keysToPrefix);
4230
4567
  const response = await this.get(TASK_ENDPOINTS.GET_BY_ID(id), {
4231
4568
  params: apiOptions,
4232
4569
  headers
@@ -4236,7 +4573,7 @@ class TaskService extends BaseService {
4236
4573
  // Check if this is a form task and get form-specific data if it is
4237
4574
  if (transformedTask.type === TaskType.Form) {
4238
4575
  const formOptions = { expandOnFormLayout: true };
4239
- return this.getFormTaskById(id, folderId || transformedTask.organizationUnitId, formOptions);
4576
+ return this.getFormTaskById(id, folderId || transformedTask.folderId, formOptions);
4240
4577
  }
4241
4578
  return createTaskWithMethods(applyDataTransforms(transformedTask, { field: 'status', valueMap: TaskStatusMap }), this);
4242
4579
  }
@@ -4244,7 +4581,6 @@ class TaskService extends BaseService {
4244
4581
  * Assigns tasks to users
4245
4582
  *
4246
4583
  * @param taskAssignments - Single task assignment or array of task assignments
4247
- * @param folderId - Optional folder ID
4248
4584
  * @returns Promise resolving to array of task assignment results
4249
4585
  *
4250
4586
  * @example
@@ -4274,8 +4610,7 @@ class TaskService extends BaseService {
4274
4610
  * ]);
4275
4611
  * ```
4276
4612
  */
4277
- async assign(taskAssignments, folderId) {
4278
- const headers = createHeaders({ [FOLDER_ID]: folderId });
4613
+ async assign(taskAssignments) {
4279
4614
  // Normalize input to array
4280
4615
  const assignmentArray = Array.isArray(taskAssignments) ? taskAssignments : [taskAssignments];
4281
4616
  const options = {
@@ -4283,7 +4618,7 @@ class TaskService extends BaseService {
4283
4618
  };
4284
4619
  // Convert options to PascalCase for API
4285
4620
  const pascalOptions = camelToPascalCaseKeys(options);
4286
- const response = await this.post(TASK_ENDPOINTS.ASSIGN_TASKS, pascalOptions, { headers });
4621
+ const response = await this.post(TASK_ENDPOINTS.ASSIGN_TASKS, pascalOptions);
4287
4622
  // Transform response from PascalCase to camelCase
4288
4623
  const transformedResponse = pascalToCamelCaseKeys(response.data);
4289
4624
  // Process OData array response - empty array = success, non-empty = error
@@ -4293,7 +4628,6 @@ class TaskService extends BaseService {
4293
4628
  * Reassigns tasks to new users
4294
4629
  *
4295
4630
  * @param taskAssignments - Single task assignment or array of task assignments
4296
- * @param folderId - Optional folder ID
4297
4631
  * @returns Promise resolving to array of task assignment results
4298
4632
  *
4299
4633
  * @example
@@ -4323,8 +4657,7 @@ class TaskService extends BaseService {
4323
4657
  * ]);
4324
4658
  * ```
4325
4659
  */
4326
- async reassign(taskAssignments, folderId) {
4327
- const headers = createHeaders({ [FOLDER_ID]: folderId });
4660
+ async reassign(taskAssignments) {
4328
4661
  // Normalize input to array
4329
4662
  const assignmentArray = Array.isArray(taskAssignments) ? taskAssignments : [taskAssignments];
4330
4663
  const options = {
@@ -4332,7 +4665,7 @@ class TaskService extends BaseService {
4332
4665
  };
4333
4666
  // Convert options to PascalCase for API
4334
4667
  const pascalOptions = camelToPascalCaseKeys(options);
4335
- const response = await this.post(TASK_ENDPOINTS.REASSIGN_TASKS, pascalOptions, { headers });
4668
+ const response = await this.post(TASK_ENDPOINTS.REASSIGN_TASKS, pascalOptions);
4336
4669
  // Transform response from PascalCase to camelCase
4337
4670
  const transformedResponse = pascalToCamelCaseKeys(response.data);
4338
4671
  // Process OData array response - empty array = success, non-empty = error
@@ -4342,7 +4675,6 @@ class TaskService extends BaseService {
4342
4675
  * Unassigns tasks (removes current assignees)
4343
4676
  *
4344
4677
  * @param taskIds - Single task ID or array of task IDs to unassign
4345
- * @param folderId - Optional folder ID
4346
4678
  * @returns Promise resolving to array of task assignment results
4347
4679
  *
4348
4680
  * @example
@@ -4354,14 +4686,13 @@ class TaskService extends BaseService {
4354
4686
  * const result = await sdk.tasks.unassign([123, 456, 789]);
4355
4687
  * ```
4356
4688
  */
4357
- async unassign(taskIds, folderId) {
4358
- const headers = createHeaders({ [FOLDER_ID]: folderId });
4689
+ async unassign(taskIds) {
4359
4690
  // Normalize input to array
4360
4691
  const taskIdArray = Array.isArray(taskIds) ? taskIds : [taskIds];
4361
4692
  const options = {
4362
4693
  taskIds: taskIdArray
4363
4694
  };
4364
- const response = await this.post(TASK_ENDPOINTS.UNASSIGN_TASKS, options, { headers });
4695
+ const response = await this.post(TASK_ENDPOINTS.UNASSIGN_TASKS, options);
4365
4696
  // Transform response from PascalCase to camelCase
4366
4697
  const transformedResponse = pascalToCamelCaseKeys(response.data);
4367
4698
  // Process OData array response - empty array = success, non-empty = error
@@ -4371,30 +4702,31 @@ class TaskService extends BaseService {
4371
4702
  /**
4372
4703
  * Completes a task with the specified type and data
4373
4704
  *
4374
- * @param completionType - The type of task (Form, App, or Generic)
4375
- * @param options - The completion options
4705
+ * @param options - The completion options including task type, taskId, data, and action
4376
4706
  * @param folderId - Required folder ID
4377
- * @returns Promise resolving to void
4707
+ * @returns Promise resolving to completion result
4378
4708
  *
4379
4709
  * @example
4380
4710
  * ```typescript
4381
4711
  * // Complete an app task
4382
- * await sdk.tasks.complete(TaskType.App, {
4712
+ * await sdk.tasks.complete({
4713
+ * type: TaskType.App,
4383
4714
  * taskId: 456,
4384
4715
  * data: {},
4385
4716
  * action: "submit"
4386
4717
  * }, 123); // folderId is required
4387
4718
  *
4388
4719
  * // Complete an external task
4389
- * await sdk.tasks.complete(TaskType.ExternalTask, {
4720
+ * await sdk.tasks.complete({
4721
+ * type: TaskType.External,
4390
4722
  * taskId: 789
4391
4723
  * }, 123); // folderId is required
4392
4724
  * ```
4393
4725
  */
4394
- async complete(completionType, options, folderId) {
4726
+ async complete(options, folderId) {
4395
4727
  const headers = createHeaders({ [FOLDER_ID]: folderId });
4396
4728
  let endpoint;
4397
- switch (completionType) {
4729
+ switch (options.type) {
4398
4730
  case TaskType.Form:
4399
4731
  endpoint = TASK_ENDPOINTS.COMPLETE_FORM_TASK;
4400
4732
  break;
@@ -4433,6 +4765,19 @@ class TaskService extends BaseService {
4433
4765
  const transformedFormTask = transformData(response.data, TaskMap);
4434
4766
  return createTaskWithMethods(applyDataTransforms(transformedFormTask, { field: 'status', valueMap: TaskStatusMap }), this);
4435
4767
  }
4768
+ /**
4769
+ * Adds default expand parameters to options
4770
+ * @param options - The options object to add default expand to
4771
+ * @returns Options with default expand parameters added
4772
+ * @private
4773
+ */
4774
+ addDefaultExpand(options) {
4775
+ const processedOptions = { ...options };
4776
+ processedOptions.expand = processedOptions.expand
4777
+ ? `${DEFAULT_TASK_EXPAND},${processedOptions.expand}`
4778
+ : DEFAULT_TASK_EXPAND;
4779
+ return processedOptions;
4780
+ }
4436
4781
  }
4437
4782
  __decorate([
4438
4783
  track('Tasks.Create')
@@ -5025,17 +5370,6 @@ const BucketMap = {
5025
5370
  verb: 'httpMethod'
5026
5371
  };
5027
5372
 
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
5373
  class BucketService extends FolderScopedService {
5040
5374
  /**
5041
5375
  * @hideconstructor
@@ -5208,19 +5542,18 @@ class BucketService extends FolderScopedService {
5208
5542
  * content: file
5209
5543
  * });
5210
5544
  *
5211
- * // In Node env with explicit content type
5545
+ * // In Node env with Buffer
5212
5546
  * const buffer = Buffer.from('file content');
5213
5547
  * const result = await sdk.buckets.uploadFile({
5214
5548
  * bucketId: 123,
5215
5549
  * folderId: 456,
5216
5550
  * path: '/folder/example.txt',
5217
- * content: buffer,
5218
- * contentType: 'text/plain'
5551
+ * content: buffer
5219
5552
  * });
5220
5553
  * ```
5221
5554
  */
5222
5555
  async uploadFile(options) {
5223
- const { bucketId, folderId, path, content, contentType } = options;
5556
+ const { bucketId, folderId, path, content } = options;
5224
5557
  if (!bucketId) {
5225
5558
  throw new ValidationError({ message: 'bucketId is required for uploadFile' });
5226
5559
  }
@@ -5234,19 +5567,13 @@ class BucketService extends FolderScopedService {
5234
5567
  throw new ValidationError({ message: 'content is required for uploadFile' });
5235
5568
  }
5236
5569
  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
5570
  const uriResponse = await this._getWriteUri({
5243
5571
  bucketId,
5244
5572
  folderId,
5245
5573
  path,
5246
- contentType: detectedContentType
5247
5574
  });
5248
5575
  // Upload file to the provided URI
5249
- const response = await this._uploadToUri(uriResponse, content, detectedContentType);
5576
+ const response = await this._uploadToUri(uriResponse, content);
5250
5577
  return {
5251
5578
  success: response.status >= 200 && response.status < 300,
5252
5579
  statusCode: response.status
@@ -5257,61 +5584,42 @@ class BucketService extends FolderScopedService {
5257
5584
  }
5258
5585
  }
5259
5586
  /**
5260
- * Determines the content type of the file based on the content and path
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
5587
+ * Gets a direct download URL for a file in the bucket
5266
5588
  *
5267
- * @param content - The file content
5268
- * @param path - The file path
5269
- * @returns The determined content type or default
5589
+ * @param options - Contains bucketId, folderId, file path and optional expiry time
5590
+ * @returns Promise resolving to blob file access information
5591
+ *
5592
+ * @example
5593
+ * ```typescript
5594
+ * // Get download URL for a file
5595
+ * const fileAccess = await sdk.buckets.getReadUri({
5596
+ * bucketId: 123,
5597
+ * folderId: 456,
5598
+ * path: '/folder/file.pdf'
5599
+ * });
5600
+ * ```
5270
5601
  */
5271
- async _determineContentType(content, path) {
5272
- // 1. If content is a File or Blob with type, use that (works in browser)
5273
- if ('type' in content && content.type) {
5274
- return content.type;
5275
- }
5276
- // 2. Try content-based detection (primarily for Node.js)
5277
- if (content instanceof Buffer && fileTypeFromBuffer) {
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;
5602
+ async getReadUri(options) {
5603
+ const { bucketId, folderId, path, expiryInMinutes, ...restOptions } = options;
5604
+ const queryOptions = {
5605
+ expiryInMinutes,
5606
+ ...addPrefixToKeys(restOptions, ODATA_PREFIX, Object.keys(restOptions))
5607
+ };
5608
+ return this._getUri(BUCKET_ENDPOINTS.GET_READ_URI(bucketId), bucketId, folderId, path, queryOptions);
5296
5609
  }
5297
5610
  /**
5298
5611
  * Uploads content to the provided URI
5299
5612
  * @param uriResponse - Response from getWriteUri containing URL and headers
5300
5613
  * @param content - The content to upload
5301
- * @param contentType - The content type of the file
5302
5614
  * @returns The response from the upload request with status info
5303
5615
  */
5304
- async _uploadToUri(uriResponse, content, contentType) {
5616
+ async _uploadToUri(uriResponse, content) {
5305
5617
  const { uri, headers = {}, requiresAuth } = uriResponse;
5306
5618
  if (!uri) {
5307
5619
  throw new ValidationError({ message: 'Upload URI not available', statusCode: HttpStatus.BAD_REQUEST });
5308
5620
  }
5309
5621
  // Create headers for the request
5310
5622
  let requestHeaders = { ...headers };
5311
- // Ensure content-type is set if provided
5312
- if (contentType && !requestHeaders['content-type']) {
5313
- requestHeaders['content-type'] = contentType;
5314
- }
5315
5623
  // Add auth header if required
5316
5624
  if (requiresAuth) {
5317
5625
  try {
@@ -5383,41 +5691,16 @@ class BucketService extends FolderScopedService {
5383
5691
  }
5384
5692
  return transformedData;
5385
5693
  }
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
5694
  /**
5411
5695
  * Gets a direct upload URL for a file in the bucket
5412
5696
  *
5413
- * @param options - Contains bucketId, folderId, file path, optional expiry time and content type
5697
+ * @param options - Contains bucketId, folderId, file path, optional expiry time
5414
5698
  * @returns Promise resolving to blob file access information
5415
5699
  */
5416
5700
  async _getWriteUri(options) {
5417
- const { bucketId, folderId, path, expiryInMinutes, contentType, ...restOptions } = options;
5701
+ const { bucketId, folderId, path, expiryInMinutes, ...restOptions } = options;
5418
5702
  const queryOptions = {
5419
5703
  expiryInMinutes,
5420
- contentType,
5421
5704
  ...addPrefixToKeys(restOptions, ODATA_PREFIX, Object.keys(restOptions))
5422
5705
  };
5423
5706
  return this._getUri(BUCKET_ENDPOINTS.GET_WRITE_URI(bucketId), bucketId, folderId, path, queryOptions);
@@ -5560,11 +5843,9 @@ class ProcessService extends BaseService {
5560
5843
  delete apiRequest[clientKey];
5561
5844
  }
5562
5845
  });
5563
- // Convert to PascalCase for API
5564
- const pascalOptions = camelToPascalCaseKeys(apiRequest);
5565
5846
  // Create the request object according to API spec
5566
5847
  const requestBody = {
5567
- startInfo: pascalOptions
5848
+ startInfo: apiRequest
5568
5849
  };
5569
5850
  // Prefix all query parameter keys with '$' for OData
5570
5851
  const keysToPrefix = Object.keys(options);
@@ -5865,7 +6146,11 @@ class UiPath {
5865
6146
  /**
5866
6147
  * Access to Process Instances service
5867
6148
  */
5868
- instances: this.getService(ProcessInstancesService)
6149
+ instances: this.getService(ProcessInstancesService),
6150
+ /**
6151
+ * Access to Process Incidents service
6152
+ */
6153
+ incidents: this.getService(ProcessIncidentsService)
5869
6154
  }),
5870
6155
  /**
5871
6156
  * Access to Maestro Cases service
@@ -6074,4 +6359,4 @@ var JobType;
6074
6359
  JobType["ServerlessGeneric"] = "ServerlessGeneric";
6075
6360
  })(JobType || (JobType = {}));
6076
6361
 
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 };
6362
+ 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 };