@uipath/uipath-typescript 1.3.9 → 1.3.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -4512,6 +4512,8 @@ const BUCKET_ENDPOINTS = {
4512
4512
  GET_FILE_META_DATA: (id) => `${ORCHESTRATOR_BASE}/api/Buckets/${id}/ListFiles`,
4513
4513
  GET_READ_URI: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})/UiPath.Server.Configuration.OData.GetReadUri`,
4514
4514
  GET_WRITE_URI: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})/UiPath.Server.Configuration.OData.GetWriteUri`,
4515
+ DELETE_FILE: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})/UiPath.Server.Configuration.OData.DeleteFile`,
4516
+ GET_FILES: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})/UiPath.Server.Configuration.OData.GetFiles`,
4515
4517
  };
4516
4518
  /**
4517
4519
  * Orchestrator Process Service Endpoints
@@ -4637,6 +4639,12 @@ const DATA_FABRIC_ENDPOINTS = {
4637
4639
  CHOICESETS: {
4638
4640
  GET_ALL: `${DATAFABRIC_BASE}/api/Entity/choiceset`,
4639
4641
  GET_BY_ID: (choiceSetId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${choiceSetId}/query_expansion`,
4642
+ CREATE: `${DATAFABRIC_BASE}/api/Entity/choiceset`,
4643
+ UPDATE: (choiceSetId) => `${DATAFABRIC_BASE}/api/Entity/${choiceSetId}/metadata`,
4644
+ DELETE: (choiceSetId) => `${DATAFABRIC_BASE}/api/Entity/${choiceSetId}/delete`,
4645
+ INSERT_BY_NAME: (choiceSetName) => `${DATAFABRIC_BASE}/api/EntityService/${choiceSetName}/choiceset/insert`,
4646
+ UPDATE_BY_NAME: (choiceSetName, valueId) => `${DATAFABRIC_BASE}/api/EntityService/${choiceSetName}/choiceset/${valueId}/update`,
4647
+ DELETE_BY_ID: (choiceSetId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${choiceSetId}/choiceset/delete`,
4640
4648
  },
4641
4649
  };
4642
4650
 
@@ -5482,7 +5490,7 @@ function normalizeBaseUrl(url) {
5482
5490
  * SDK's public API.
5483
5491
  */
5484
5492
  /** SDK version placeholder — patched by the SDK publish workflow. */
5485
- const SDK_VERSION = '1.3.9';
5493
+ const SDK_VERSION = '1.3.10';
5486
5494
  const CLOUD_ROLE_NAME = 'uipath-ts-sdk';
5487
5495
  const SDK_SERVICE_NAME = 'UiPath.TypeScript.Sdk';
5488
5496
  const SDK_LOGGER_NAME = 'uipath-ts-sdk-telemetry';
@@ -6208,14 +6216,25 @@ class ApiClient {
6208
6216
  if (!text) {
6209
6217
  return undefined;
6210
6218
  }
6211
- return JSON.parse(text);
6219
+ try {
6220
+ return JSON.parse(text);
6221
+ }
6222
+ catch (error) {
6223
+ if (error instanceof SyntaxError) {
6224
+ throw new ServerError({
6225
+ message: `Server returned non-JSON response (${response.status} ${response.url}): ${error.message}`,
6226
+ statusCode: response.status,
6227
+ });
6228
+ }
6229
+ throw error;
6230
+ }
6212
6231
  }
6213
6232
  catch (error) {
6214
6233
  // If it's already one of our errors, re-throw it
6215
6234
  if (error.type && error.type.includes('Error')) {
6216
6235
  throw error;
6217
6236
  }
6218
- // Otherwise, it's likely a network error
6237
+ // Otherwise, it's a genuine network/fetch failure
6219
6238
  throw ErrorFactory.createNetworkError(error);
6220
6239
  }
6221
6240
  }
@@ -7111,9 +7130,9 @@ class PaginationHelpers {
7111
7130
  * @returns Promise resolving to a paginated result
7112
7131
  */
7113
7132
  static async getAllPaginated(params) {
7114
- const { serviceAccess, getEndpoint, folderId, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
7133
+ const { serviceAccess, getEndpoint, folderId, headers: providedHeaders, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
7115
7134
  const endpoint = getEndpoint(folderId);
7116
- const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
7135
+ const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
7117
7136
  const paginatedResponse = await serviceAccess.requestWithPagination(method, endpoint, paginationParams, {
7118
7137
  headers,
7119
7138
  params: additionalParams,
@@ -7141,13 +7160,13 @@ class PaginationHelpers {
7141
7160
  * @returns Promise resolving to an object with data and totalCount
7142
7161
  */
7143
7162
  static async getAllNonPaginated(params) {
7144
- const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
7163
+ const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, headers: providedHeaders, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
7145
7164
  // Set default field names
7146
7165
  const itemsField = options.itemsField || DEFAULT_ITEMS_FIELD;
7147
7166
  const totalCountField = options.totalCountField || DEFAULT_TOTAL_COUNT_FIELD;
7148
7167
  // Determine endpoint and headers based on folderId
7149
7168
  const endpoint = folderId ? getByFolderEndpoint : getAllEndpoint;
7150
- const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
7169
+ const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
7151
7170
  // Make the API call based on method
7152
7171
  let response;
7153
7172
  if (method === HTTP_METHODS.POST) {
@@ -7206,6 +7225,7 @@ class PaginationHelpers {
7206
7225
  serviceAccess: config.serviceAccess,
7207
7226
  getEndpoint: config.getEndpoint,
7208
7227
  folderId,
7228
+ headers: config.headers,
7209
7229
  paginationParams: cursor ? { cursor, pageSize } : jumpToPage ? { jumpToPage, pageSize } : { pageSize },
7210
7230
  additionalParams: prefixedOptions,
7211
7231
  transformFn: config.transformFn,
@@ -7223,6 +7243,7 @@ class PaginationHelpers {
7223
7243
  getAllEndpoint: config.getEndpoint(),
7224
7244
  getByFolderEndpoint: byFolderEndpoint,
7225
7245
  folderId,
7246
+ headers: config.headers,
7226
7247
  additionalParams: prefixedOptions,
7227
7248
  transformFn: config.transformFn,
7228
7249
  method: config.method,
@@ -9010,7 +9031,7 @@ class ChoiceSetService extends BaseService {
9010
9031
  *
9011
9032
  * @example
9012
9033
  * ```typescript
9013
- * import { ChoiceSets } from '@uipath/uipath-typescript/choicesets';
9034
+ * import { ChoiceSets } from '@uipath/uipath-typescript/entities';
9014
9035
  *
9015
9036
  * const choiceSets = new ChoiceSets(sdk);
9016
9037
  *
@@ -9059,6 +9080,188 @@ class ChoiceSetService extends BaseService {
9059
9080
  }
9060
9081
  }, options);
9061
9082
  }
9083
+ /**
9084
+ * Creates a new Data Fabric choice set
9085
+ *
9086
+ * @param name - Choice set name. Must start with a
9087
+ * letter, may contain only letters, numbers, and underscores, length
9088
+ * 3–100 characters (e.g., `"expenseTypes"`).
9089
+ * @param options - Optional choice-set-level settings ({@link ChoiceSetCreateOptions})
9090
+ * @returns Promise resolving to the UUID of the created choice set
9091
+ *
9092
+ * @example
9093
+ * ```typescript
9094
+ * import { ChoiceSets } from '@uipath/uipath-typescript/entities';
9095
+ *
9096
+ * const choicesets = new ChoiceSets(sdk);
9097
+ *
9098
+ * // Minimal create
9099
+ * const expenseTypesId = await choicesets.create("expense_types");
9100
+ *
9101
+ * // With display name and description
9102
+ * const priorityLevelsId = await choicesets.create("priority_levels", {
9103
+ * displayName: "Priority Levels",
9104
+ * description: "Ticket priority categories",
9105
+ * });
9106
+ * ```
9107
+ * @internal
9108
+ */
9109
+ async create(name, options) {
9110
+ const opts = options ?? {};
9111
+ const payload = {
9112
+ ...(opts.description !== undefined && { description: opts.description }),
9113
+ ...(opts.displayName !== undefined && { displayName: opts.displayName }),
9114
+ entityDefinition: {
9115
+ name,
9116
+ fields: [],
9117
+ folderId: opts.folderKey ?? DATA_FABRIC_TENANT_FOLDER_ID,
9118
+ },
9119
+ };
9120
+ const response = await this.post(DATA_FABRIC_ENDPOINTS.CHOICESETS.CREATE, payload);
9121
+ return response.data;
9122
+ }
9123
+ /**
9124
+ * Updates an existing choice set's metadata (display name and/or description).
9125
+ *
9126
+ * **At least one of `displayName` or `description` must be provided** —
9127
+ * the call throws `ValidationError` if both are omitted.
9128
+ *
9129
+ * @param choiceSetId - UUID of the choice set to update
9130
+ * @param options - Metadata fields to change ({@link ChoiceSetUpdateOptions})
9131
+ * @returns Promise resolving when the update is complete
9132
+ *
9133
+ * @example
9134
+ * ```typescript
9135
+ * // First, get the choice set ID using getAll()
9136
+ * const allChoiceSets = await choicesets.getAll();
9137
+ * const expenseTypes = allChoiceSets.find(cs => cs.name === 'expense_types');
9138
+ *
9139
+ * await choicesets.updateById(expenseTypes.id, {
9140
+ * displayName: "Expense Categories",
9141
+ * description: "Updated description",
9142
+ * });
9143
+ * ```
9144
+ * @internal
9145
+ */
9146
+ async updateById(choiceSetId, options) {
9147
+ if (options.displayName === undefined && options.description === undefined) {
9148
+ throw new ValidationError({
9149
+ message: 'updateById requires at least one of displayName or description.',
9150
+ });
9151
+ }
9152
+ await this.patch(DATA_FABRIC_ENDPOINTS.CHOICESETS.UPDATE(choiceSetId), {
9153
+ ...(options.displayName !== undefined && { displayName: options.displayName }),
9154
+ ...(options.description !== undefined && { description: options.description }),
9155
+ });
9156
+ }
9157
+ /**
9158
+ * Deletes a Data Fabric choice set and all its values.
9159
+ *
9160
+ * @param choiceSetId - UUID of the choice set to delete
9161
+ * @returns Promise resolving when the choice set is deleted
9162
+ *
9163
+ * @example
9164
+ * ```typescript
9165
+ * // First, get the choice set ID using getAll()
9166
+ * const allChoiceSets = await choicesets.getAll();
9167
+ * const expenseTypes = allChoiceSets.find(cs => cs.name === 'expense_types');
9168
+ *
9169
+ * await choicesets.deleteById(expenseTypes.id);
9170
+ * ```
9171
+ * @internal
9172
+ */
9173
+ async deleteById(choiceSetId) {
9174
+ await this.post(DATA_FABRIC_ENDPOINTS.CHOICESETS.DELETE(choiceSetId), {});
9175
+ }
9176
+ /**
9177
+ * Inserts a single value into a choice set.
9178
+ *
9179
+ * @param choiceSetId - UUID of the parent choice set
9180
+ * @param name - Identifier name of the new value (e.g., `"TRAVEL"`)
9181
+ * @param options - Optional fields ({@link ChoiceSetValueInsertOptions})
9182
+ * @returns Promise resolving to the inserted value ({@link ChoiceSetValueInsertResponse})
9183
+ *
9184
+ * @example
9185
+ * ```typescript
9186
+ * // First, get the choice set ID using getAll()
9187
+ * const allChoiceSets = await choicesets.getAll();
9188
+ * const expenseTypes = allChoiceSets.find(cs => cs.name === 'expense_types');
9189
+ *
9190
+ * const inserted = await choicesets.insertValueById(expenseTypes.id, 'TRAVEL', {
9191
+ * displayName: 'Travel',
9192
+ * });
9193
+ * console.log(inserted.id);
9194
+ * ```
9195
+ * @internal
9196
+ */
9197
+ async insertValueById(choiceSetId, name, options) {
9198
+ const choiceSetName = await this.resolveChoiceSetName(choiceSetId);
9199
+ const payload = {
9200
+ Name: name,
9201
+ ...(options?.displayName !== undefined && { DisplayName: options.displayName }),
9202
+ };
9203
+ const response = await this.post(DATA_FABRIC_ENDPOINTS.CHOICESETS.INSERT_BY_NAME(choiceSetName), payload);
9204
+ const camelCased = pascalToCamelCaseKeys(response.data);
9205
+ return transformData(camelCased, EntityMap);
9206
+ }
9207
+ /**
9208
+ * Updates an existing choice-set value's display name.
9209
+ *
9210
+ * Only `displayName` is mutable; the value's `name` (identifier) is fixed at
9211
+ * insert time and cannot be changed.
9212
+ *
9213
+ * @param choiceSetId - UUID of the parent choice set
9214
+ * @param valueId - UUID of the value to update
9215
+ * @param displayName - New human-readable display name for the value
9216
+ * @returns Promise resolving to the updated value ({@link ChoiceSetValueUpdateResponse})
9217
+ *
9218
+ * @example
9219
+ * ```typescript
9220
+ * // Get the choice set ID from getAll() and the value ID from getById()
9221
+ * const allChoiceSets = await choicesets.getAll();
9222
+ * const expenseTypes = allChoiceSets.find(cs => cs.name === 'expense_types');
9223
+ * const values = await choicesets.getById(expenseTypes.id);
9224
+ * const travel = values.items.find(v => v.name === 'TRAVEL');
9225
+ *
9226
+ * await choicesets.updateValueById(expenseTypes.id, travel.id, 'Business Travel');
9227
+ * ```
9228
+ * @internal
9229
+ */
9230
+ async updateValueById(choiceSetId, valueId, displayName) {
9231
+ const choiceSetName = await this.resolveChoiceSetName(choiceSetId);
9232
+ const payload = { DisplayName: displayName };
9233
+ const response = await this.post(DATA_FABRIC_ENDPOINTS.CHOICESETS.UPDATE_BY_NAME(choiceSetName, valueId), payload);
9234
+ const camelCased = pascalToCamelCaseKeys(response.data);
9235
+ return transformData(camelCased, EntityMap);
9236
+ }
9237
+ /**
9238
+ * Deletes one or more values from a choice set.
9239
+ *
9240
+ * @param choiceSetId - UUID of the parent choice set
9241
+ * @param valueIds - Array of value UUIDs to delete
9242
+ * @returns Promise resolving when the values are deleted
9243
+ *
9244
+ * @example
9245
+ * ```typescript
9246
+ * // Get the value IDs from getById()
9247
+ * const values = await choicesets.getById('<choiceSetId>');
9248
+ * const idsToDelete = values.items.slice(0, 2).map(v => v.id);
9249
+ *
9250
+ * await choicesets.deleteValuesById('<choiceSetId>', idsToDelete);
9251
+ * ```
9252
+ * @internal
9253
+ */
9254
+ async deleteValuesById(choiceSetId, valueIds) {
9255
+ await this.post(DATA_FABRIC_ENDPOINTS.CHOICESETS.DELETE_BY_ID(choiceSetId), valueIds);
9256
+ }
9257
+ async resolveChoiceSetName(choiceSetId) {
9258
+ const all = await this.getAll();
9259
+ const match = all.find(cs => cs.id === choiceSetId);
9260
+ if (!match) {
9261
+ throw new NotFoundError({ message: `Choice set with id '${choiceSetId}' not found.` });
9262
+ }
9263
+ return match.name;
9264
+ }
9062
9265
  }
9063
9266
  __decorate([
9064
9267
  track('Choicesets.GetAll')
@@ -9066,6 +9269,24 @@ __decorate([
9066
9269
  __decorate([
9067
9270
  track('Choicesets.GetById')
9068
9271
  ], ChoiceSetService.prototype, "getById", null);
9272
+ __decorate([
9273
+ track('Choicesets.Create')
9274
+ ], ChoiceSetService.prototype, "create", null);
9275
+ __decorate([
9276
+ track('Choicesets.UpdateById')
9277
+ ], ChoiceSetService.prototype, "updateById", null);
9278
+ __decorate([
9279
+ track('Choicesets.DeleteById')
9280
+ ], ChoiceSetService.prototype, "deleteById", null);
9281
+ __decorate([
9282
+ track('Choicesets.InsertValueById')
9283
+ ], ChoiceSetService.prototype, "insertValueById", null);
9284
+ __decorate([
9285
+ track('Choicesets.UpdateValueById')
9286
+ ], ChoiceSetService.prototype, "updateValueById", null);
9287
+ __decorate([
9288
+ track('Choicesets.DeleteValuesById')
9289
+ ], ChoiceSetService.prototype, "deleteValuesById", null);
9069
9290
 
9070
9291
  /**
9071
9292
  * Maestro Process Models
@@ -12319,6 +12540,120 @@ class BucketService extends FolderScopedService {
12319
12540
  }
12320
12541
  return transformedData;
12321
12542
  }
12543
+ /**
12544
+ * Lists all files in a bucket.
12545
+ *
12546
+ * Returns a flat, recursive listing of all files in the bucket. Supports regex filtering
12547
+ * and filter / orderby / select / expand. {@link BucketFile} entries include
12548
+ * `isDirectory` so callers can distinguish folders from files.
12549
+ *
12550
+ * The method returns either:
12551
+ * - A NonPaginatedResponse with items array (when no pagination parameters are provided)
12552
+ * - A PaginatedResponse with navigation cursors (when any pagination parameter is provided)
12553
+ *
12554
+ * @param bucketId - The ID of the bucket
12555
+ * @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`) and optional parameters for regex filtering, query options, and pagination
12556
+ * @returns Promise resolving to either an array of files NonPaginatedResponse<BucketFile> or a PaginatedResponse<BucketFile> when pagination options are used.
12557
+ *
12558
+ * @example
12559
+ * ```typescript
12560
+ * import { Buckets } from '@uipath/uipath-typescript/buckets';
12561
+ *
12562
+ * const buckets = new Buckets(sdk);
12563
+ *
12564
+ * // List all files in the bucket
12565
+ * const files = await buckets.getFiles(<bucketId>, { folderId: <folderId> });
12566
+ *
12567
+ * // Filter by regex pattern
12568
+ * const pdfs = await buckets.getFiles(<bucketId>, {
12569
+ * folderId: <folderId>,
12570
+ * fileNameRegex: '.*\\.pdf$'
12571
+ * });
12572
+ *
12573
+ * // First page with pagination
12574
+ * const page1 = await buckets.getFiles(<bucketId>, { folderId: <folderId>, pageSize: 10 });
12575
+ *
12576
+ * // Navigate using cursor
12577
+ * if (page1.hasNextPage) {
12578
+ * const page2 = await buckets.getFiles(<bucketId>, { folderId: <folderId>, cursor: page1.nextCursor });
12579
+ * }
12580
+ *
12581
+ * // Jump to specific page
12582
+ * const page5 = await buckets.getFiles(<bucketId>, {
12583
+ * folderId: <folderId>,
12584
+ * jumpToPage: 5,
12585
+ * pageSize: 10
12586
+ * });
12587
+ * ```
12588
+ */
12589
+ async getFiles(bucketId, options) {
12590
+ if (!bucketId) {
12591
+ throw new ValidationError({ message: 'bucketId is required for getFiles' });
12592
+ }
12593
+ const { folderId, folderKey, folderPath, ...restOptions } = options ?? {};
12594
+ const headers = resolveFolderHeaders({
12595
+ folderId,
12596
+ folderKey,
12597
+ folderPath,
12598
+ resourceType: 'Buckets.getFiles',
12599
+ fallbackFolderKey: this.config.folderKey,
12600
+ });
12601
+ const transformBucketFile = (file) => transformData(pascalToCamelCaseKeys(file), BucketMap);
12602
+ return PaginationHelpers.getAll({
12603
+ serviceAccess: this.createPaginationServiceAccess(),
12604
+ getEndpoint: () => BUCKET_ENDPOINTS.GET_FILES(bucketId),
12605
+ transformFn: transformBucketFile,
12606
+ pagination: {
12607
+ paginationType: PaginationType.OFFSET,
12608
+ itemsField: ODATA_PAGINATION.ITEMS_FIELD,
12609
+ totalCountField: ODATA_PAGINATION.TOTAL_COUNT_FIELD,
12610
+ paginationParams: {
12611
+ pageSizeParam: ODATA_OFFSET_PARAMS.PAGE_SIZE_PARAM,
12612
+ offsetParam: ODATA_OFFSET_PARAMS.OFFSET_PARAM,
12613
+ countParam: ODATA_OFFSET_PARAMS.COUNT_PARAM,
12614
+ },
12615
+ },
12616
+ excludeFromPrefix: ['directory', 'recursive', 'fileNameRegex'],
12617
+ headers,
12618
+ }, { ...restOptions, directory: '/', recursive: true });
12619
+ }
12620
+ /**
12621
+ * Deletes a file from a bucket
12622
+ *
12623
+ * @param bucketId - The ID of the bucket
12624
+ * @param path - The full path to the file to delete
12625
+ * @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`)
12626
+ * @returns Promise resolving when the file is deleted
12627
+ *
12628
+ * @example
12629
+ * ```typescript
12630
+ * import { Buckets } from '@uipath/uipath-typescript/buckets';
12631
+ *
12632
+ * const buckets = new Buckets(sdk);
12633
+ *
12634
+ * // Delete a file from a bucket
12635
+ * await buckets.deleteFile(<bucketId>, '/folder/file.pdf', { folderId: <folderId> });
12636
+ * ```
12637
+ */
12638
+ async deleteFile(bucketId, path, options) {
12639
+ if (!bucketId) {
12640
+ throw new ValidationError({ message: 'bucketId is required for deleteFile' });
12641
+ }
12642
+ if (!path) {
12643
+ throw new ValidationError({ message: 'path is required for deleteFile' });
12644
+ }
12645
+ const headers = resolveFolderHeaders({
12646
+ folderId: options?.folderId,
12647
+ folderKey: options?.folderKey,
12648
+ folderPath: options?.folderPath,
12649
+ resourceType: 'Buckets.deleteFile',
12650
+ fallbackFolderKey: this.config.folderKey,
12651
+ });
12652
+ await this.delete(BUCKET_ENDPOINTS.DELETE_FILE(bucketId), {
12653
+ params: { path },
12654
+ headers,
12655
+ });
12656
+ }
12322
12657
  /**
12323
12658
  * Gets a direct upload URL for a file in the bucket
12324
12659
  *
@@ -12352,6 +12687,12 @@ __decorate([
12352
12687
  __decorate([
12353
12688
  track('Buckets.GetReadUri')
12354
12689
  ], BucketService.prototype, "getReadUri", null);
12690
+ __decorate([
12691
+ track('Buckets.GetFiles')
12692
+ ], BucketService.prototype, "getFiles", null);
12693
+ __decorate([
12694
+ track('Buckets.DeleteFile')
12695
+ ], BucketService.prototype, "deleteFile", null);
12355
12696
 
12356
12697
  var BucketOptions;
12357
12698
  (function (BucketOptions) {
@@ -13149,33 +13490,32 @@ class ProcessService extends FolderScopedService {
13149
13490
  }
13150
13491
  }, options);
13151
13492
  }
13152
- /**
13153
- * Starts a process execution (job)
13154
- *
13155
- * @param request - Process start request body
13156
- * @param folderId - Required folder ID
13157
- * @param options - Optional query parameters
13158
- * @returns Promise resolving to the created jobs
13159
- *
13160
- * @example
13161
- * ```typescript
13162
- * import { Processes } from '@uipath/uipath-typescript/processes';
13163
- *
13164
- * const processes = new Processes(sdk);
13165
- *
13166
- * // Start a process by process key
13167
- * const jobs = await processes.start({
13168
- * processKey: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
13169
- * }, 123); // folderId is required
13170
- *
13171
- * // Start a process by name with specific robots
13172
- * const jobs = await processes.start({
13173
- * processName: "MyProcess"
13174
- * }, 123); // folderId is required
13175
- * ```
13176
- */
13177
- async start(request, folderId, options = {}) {
13178
- const headers = createHeaders({ [FOLDER_ID]: folderId });
13493
+ async start(request, optionsOrFolderId, legacyOptions) {
13494
+ // Normalize the two overload forms into a single internal shape.
13495
+ let folderId;
13496
+ let folderKey;
13497
+ let folderPath;
13498
+ let queryOptions;
13499
+ if (typeof optionsOrFolderId === 'number') {
13500
+ // Deprecated positional form: start(request, folderId, options?)
13501
+ folderId = optionsOrFolderId;
13502
+ queryOptions = legacyOptions ?? {};
13503
+ }
13504
+ else {
13505
+ // Preferred form: start(request, options?)
13506
+ const { folderId: fid, folderKey: fkey, folderPath: fpath, ...rest } = optionsOrFolderId ?? {};
13507
+ folderId = fid;
13508
+ folderKey = fkey;
13509
+ folderPath = fpath;
13510
+ queryOptions = rest;
13511
+ }
13512
+ const headers = resolveFolderHeaders({
13513
+ folderId,
13514
+ folderKey,
13515
+ folderPath,
13516
+ resourceType: 'processes.start',
13517
+ fallbackFolderKey: this.config.folderKey,
13518
+ });
13179
13519
  // Transform SDK field names to API field names (e.g., processKey → releaseKey)
13180
13520
  const apiRequest = transformRequest(request, ProcessMap);
13181
13521
  // Create the request object according to API spec
@@ -13183,8 +13523,8 @@ class ProcessService extends FolderScopedService {
13183
13523
  startInfo: apiRequest
13184
13524
  };
13185
13525
  // Prefix all query parameter keys with '$' for OData
13186
- const keysToPrefix = Object.keys(options);
13187
- const apiOptions = addPrefixToKeys(options, ODATA_PREFIX, keysToPrefix);
13526
+ const keysToPrefix = Object.keys(queryOptions);
13527
+ const apiOptions = addPrefixToKeys(queryOptions, ODATA_PREFIX, keysToPrefix);
13188
13528
  const response = await this.post(PROCESS_ENDPOINTS.START_PROCESS, requestBody, {
13189
13529
  params: apiOptions,
13190
13530
  headers