@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.umd.js CHANGED
@@ -4516,6 +4516,8 @@
4516
4516
  GET_FILE_META_DATA: (id) => `${ORCHESTRATOR_BASE}/api/Buckets/${id}/ListFiles`,
4517
4517
  GET_READ_URI: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})/UiPath.Server.Configuration.OData.GetReadUri`,
4518
4518
  GET_WRITE_URI: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})/UiPath.Server.Configuration.OData.GetWriteUri`,
4519
+ DELETE_FILE: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})/UiPath.Server.Configuration.OData.DeleteFile`,
4520
+ GET_FILES: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})/UiPath.Server.Configuration.OData.GetFiles`,
4519
4521
  };
4520
4522
  /**
4521
4523
  * Orchestrator Process Service Endpoints
@@ -4641,6 +4643,12 @@
4641
4643
  CHOICESETS: {
4642
4644
  GET_ALL: `${DATAFABRIC_BASE}/api/Entity/choiceset`,
4643
4645
  GET_BY_ID: (choiceSetId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${choiceSetId}/query_expansion`,
4646
+ CREATE: `${DATAFABRIC_BASE}/api/Entity/choiceset`,
4647
+ UPDATE: (choiceSetId) => `${DATAFABRIC_BASE}/api/Entity/${choiceSetId}/metadata`,
4648
+ DELETE: (choiceSetId) => `${DATAFABRIC_BASE}/api/Entity/${choiceSetId}/delete`,
4649
+ INSERT_BY_NAME: (choiceSetName) => `${DATAFABRIC_BASE}/api/EntityService/${choiceSetName}/choiceset/insert`,
4650
+ UPDATE_BY_NAME: (choiceSetName, valueId) => `${DATAFABRIC_BASE}/api/EntityService/${choiceSetName}/choiceset/${valueId}/update`,
4651
+ DELETE_BY_ID: (choiceSetId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${choiceSetId}/choiceset/delete`,
4644
4652
  },
4645
4653
  };
4646
4654
 
@@ -9565,7 +9573,7 @@
9565
9573
  * SDK's public API.
9566
9574
  */
9567
9575
  /** SDK version placeholder — patched by the SDK publish workflow. */
9568
- const SDK_VERSION = '1.3.9';
9576
+ const SDK_VERSION = '1.3.10';
9569
9577
  const CLOUD_ROLE_NAME = 'uipath-ts-sdk';
9570
9578
  const SDK_SERVICE_NAME = 'UiPath.TypeScript.Sdk';
9571
9579
  const SDK_LOGGER_NAME = 'uipath-ts-sdk-telemetry';
@@ -10291,14 +10299,25 @@
10291
10299
  if (!text) {
10292
10300
  return undefined;
10293
10301
  }
10294
- return JSON.parse(text);
10302
+ try {
10303
+ return JSON.parse(text);
10304
+ }
10305
+ catch (error) {
10306
+ if (error instanceof SyntaxError) {
10307
+ throw new ServerError({
10308
+ message: `Server returned non-JSON response (${response.status} ${response.url}): ${error.message}`,
10309
+ statusCode: response.status,
10310
+ });
10311
+ }
10312
+ throw error;
10313
+ }
10295
10314
  }
10296
10315
  catch (error) {
10297
10316
  // If it's already one of our errors, re-throw it
10298
10317
  if (error.type && error.type.includes('Error')) {
10299
10318
  throw error;
10300
10319
  }
10301
- // Otherwise, it's likely a network error
10320
+ // Otherwise, it's a genuine network/fetch failure
10302
10321
  throw ErrorFactory.createNetworkError(error);
10303
10322
  }
10304
10323
  }
@@ -11194,9 +11213,9 @@
11194
11213
  * @returns Promise resolving to a paginated result
11195
11214
  */
11196
11215
  static async getAllPaginated(params) {
11197
- const { serviceAccess, getEndpoint, folderId, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
11216
+ const { serviceAccess, getEndpoint, folderId, headers: providedHeaders, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
11198
11217
  const endpoint = getEndpoint(folderId);
11199
- const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
11218
+ const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
11200
11219
  const paginatedResponse = await serviceAccess.requestWithPagination(method, endpoint, paginationParams, {
11201
11220
  headers,
11202
11221
  params: additionalParams,
@@ -11224,13 +11243,13 @@
11224
11243
  * @returns Promise resolving to an object with data and totalCount
11225
11244
  */
11226
11245
  static async getAllNonPaginated(params) {
11227
- const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
11246
+ const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, headers: providedHeaders, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
11228
11247
  // Set default field names
11229
11248
  const itemsField = options.itemsField || DEFAULT_ITEMS_FIELD;
11230
11249
  const totalCountField = options.totalCountField || DEFAULT_TOTAL_COUNT_FIELD;
11231
11250
  // Determine endpoint and headers based on folderId
11232
11251
  const endpoint = folderId ? getByFolderEndpoint : getAllEndpoint;
11233
- const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
11252
+ const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
11234
11253
  // Make the API call based on method
11235
11254
  let response;
11236
11255
  if (method === HTTP_METHODS.POST) {
@@ -11289,6 +11308,7 @@
11289
11308
  serviceAccess: config.serviceAccess,
11290
11309
  getEndpoint: config.getEndpoint,
11291
11310
  folderId,
11311
+ headers: config.headers,
11292
11312
  paginationParams: cursor ? { cursor, pageSize } : jumpToPage ? { jumpToPage, pageSize } : { pageSize },
11293
11313
  additionalParams: prefixedOptions,
11294
11314
  transformFn: config.transformFn,
@@ -11306,6 +11326,7 @@
11306
11326
  getAllEndpoint: config.getEndpoint(),
11307
11327
  getByFolderEndpoint: byFolderEndpoint,
11308
11328
  folderId,
11329
+ headers: config.headers,
11309
11330
  additionalParams: prefixedOptions,
11310
11331
  transformFn: config.transformFn,
11311
11332
  method: config.method,
@@ -13093,7 +13114,7 @@
13093
13114
  *
13094
13115
  * @example
13095
13116
  * ```typescript
13096
- * import { ChoiceSets } from '@uipath/uipath-typescript/choicesets';
13117
+ * import { ChoiceSets } from '@uipath/uipath-typescript/entities';
13097
13118
  *
13098
13119
  * const choiceSets = new ChoiceSets(sdk);
13099
13120
  *
@@ -13142,6 +13163,188 @@
13142
13163
  }
13143
13164
  }, options);
13144
13165
  }
13166
+ /**
13167
+ * Creates a new Data Fabric choice set
13168
+ *
13169
+ * @param name - Choice set name. Must start with a
13170
+ * letter, may contain only letters, numbers, and underscores, length
13171
+ * 3–100 characters (e.g., `"expenseTypes"`).
13172
+ * @param options - Optional choice-set-level settings ({@link ChoiceSetCreateOptions})
13173
+ * @returns Promise resolving to the UUID of the created choice set
13174
+ *
13175
+ * @example
13176
+ * ```typescript
13177
+ * import { ChoiceSets } from '@uipath/uipath-typescript/entities';
13178
+ *
13179
+ * const choicesets = new ChoiceSets(sdk);
13180
+ *
13181
+ * // Minimal create
13182
+ * const expenseTypesId = await choicesets.create("expense_types");
13183
+ *
13184
+ * // With display name and description
13185
+ * const priorityLevelsId = await choicesets.create("priority_levels", {
13186
+ * displayName: "Priority Levels",
13187
+ * description: "Ticket priority categories",
13188
+ * });
13189
+ * ```
13190
+ * @internal
13191
+ */
13192
+ async create(name, options) {
13193
+ const opts = options ?? {};
13194
+ const payload = {
13195
+ ...(opts.description !== undefined && { description: opts.description }),
13196
+ ...(opts.displayName !== undefined && { displayName: opts.displayName }),
13197
+ entityDefinition: {
13198
+ name,
13199
+ fields: [],
13200
+ folderId: opts.folderKey ?? DATA_FABRIC_TENANT_FOLDER_ID,
13201
+ },
13202
+ };
13203
+ const response = await this.post(DATA_FABRIC_ENDPOINTS.CHOICESETS.CREATE, payload);
13204
+ return response.data;
13205
+ }
13206
+ /**
13207
+ * Updates an existing choice set's metadata (display name and/or description).
13208
+ *
13209
+ * **At least one of `displayName` or `description` must be provided** —
13210
+ * the call throws `ValidationError` if both are omitted.
13211
+ *
13212
+ * @param choiceSetId - UUID of the choice set to update
13213
+ * @param options - Metadata fields to change ({@link ChoiceSetUpdateOptions})
13214
+ * @returns Promise resolving when the update is complete
13215
+ *
13216
+ * @example
13217
+ * ```typescript
13218
+ * // First, get the choice set ID using getAll()
13219
+ * const allChoiceSets = await choicesets.getAll();
13220
+ * const expenseTypes = allChoiceSets.find(cs => cs.name === 'expense_types');
13221
+ *
13222
+ * await choicesets.updateById(expenseTypes.id, {
13223
+ * displayName: "Expense Categories",
13224
+ * description: "Updated description",
13225
+ * });
13226
+ * ```
13227
+ * @internal
13228
+ */
13229
+ async updateById(choiceSetId, options) {
13230
+ if (options.displayName === undefined && options.description === undefined) {
13231
+ throw new ValidationError({
13232
+ message: 'updateById requires at least one of displayName or description.',
13233
+ });
13234
+ }
13235
+ await this.patch(DATA_FABRIC_ENDPOINTS.CHOICESETS.UPDATE(choiceSetId), {
13236
+ ...(options.displayName !== undefined && { displayName: options.displayName }),
13237
+ ...(options.description !== undefined && { description: options.description }),
13238
+ });
13239
+ }
13240
+ /**
13241
+ * Deletes a Data Fabric choice set and all its values.
13242
+ *
13243
+ * @param choiceSetId - UUID of the choice set to delete
13244
+ * @returns Promise resolving when the choice set is deleted
13245
+ *
13246
+ * @example
13247
+ * ```typescript
13248
+ * // First, get the choice set ID using getAll()
13249
+ * const allChoiceSets = await choicesets.getAll();
13250
+ * const expenseTypes = allChoiceSets.find(cs => cs.name === 'expense_types');
13251
+ *
13252
+ * await choicesets.deleteById(expenseTypes.id);
13253
+ * ```
13254
+ * @internal
13255
+ */
13256
+ async deleteById(choiceSetId) {
13257
+ await this.post(DATA_FABRIC_ENDPOINTS.CHOICESETS.DELETE(choiceSetId), {});
13258
+ }
13259
+ /**
13260
+ * Inserts a single value into a choice set.
13261
+ *
13262
+ * @param choiceSetId - UUID of the parent choice set
13263
+ * @param name - Identifier name of the new value (e.g., `"TRAVEL"`)
13264
+ * @param options - Optional fields ({@link ChoiceSetValueInsertOptions})
13265
+ * @returns Promise resolving to the inserted value ({@link ChoiceSetValueInsertResponse})
13266
+ *
13267
+ * @example
13268
+ * ```typescript
13269
+ * // First, get the choice set ID using getAll()
13270
+ * const allChoiceSets = await choicesets.getAll();
13271
+ * const expenseTypes = allChoiceSets.find(cs => cs.name === 'expense_types');
13272
+ *
13273
+ * const inserted = await choicesets.insertValueById(expenseTypes.id, 'TRAVEL', {
13274
+ * displayName: 'Travel',
13275
+ * });
13276
+ * console.log(inserted.id);
13277
+ * ```
13278
+ * @internal
13279
+ */
13280
+ async insertValueById(choiceSetId, name, options) {
13281
+ const choiceSetName = await this.resolveChoiceSetName(choiceSetId);
13282
+ const payload = {
13283
+ Name: name,
13284
+ ...(options?.displayName !== undefined && { DisplayName: options.displayName }),
13285
+ };
13286
+ const response = await this.post(DATA_FABRIC_ENDPOINTS.CHOICESETS.INSERT_BY_NAME(choiceSetName), payload);
13287
+ const camelCased = pascalToCamelCaseKeys(response.data);
13288
+ return transformData(camelCased, EntityMap);
13289
+ }
13290
+ /**
13291
+ * Updates an existing choice-set value's display name.
13292
+ *
13293
+ * Only `displayName` is mutable; the value's `name` (identifier) is fixed at
13294
+ * insert time and cannot be changed.
13295
+ *
13296
+ * @param choiceSetId - UUID of the parent choice set
13297
+ * @param valueId - UUID of the value to update
13298
+ * @param displayName - New human-readable display name for the value
13299
+ * @returns Promise resolving to the updated value ({@link ChoiceSetValueUpdateResponse})
13300
+ *
13301
+ * @example
13302
+ * ```typescript
13303
+ * // Get the choice set ID from getAll() and the value ID from getById()
13304
+ * const allChoiceSets = await choicesets.getAll();
13305
+ * const expenseTypes = allChoiceSets.find(cs => cs.name === 'expense_types');
13306
+ * const values = await choicesets.getById(expenseTypes.id);
13307
+ * const travel = values.items.find(v => v.name === 'TRAVEL');
13308
+ *
13309
+ * await choicesets.updateValueById(expenseTypes.id, travel.id, 'Business Travel');
13310
+ * ```
13311
+ * @internal
13312
+ */
13313
+ async updateValueById(choiceSetId, valueId, displayName) {
13314
+ const choiceSetName = await this.resolveChoiceSetName(choiceSetId);
13315
+ const payload = { DisplayName: displayName };
13316
+ const response = await this.post(DATA_FABRIC_ENDPOINTS.CHOICESETS.UPDATE_BY_NAME(choiceSetName, valueId), payload);
13317
+ const camelCased = pascalToCamelCaseKeys(response.data);
13318
+ return transformData(camelCased, EntityMap);
13319
+ }
13320
+ /**
13321
+ * Deletes one or more values from a choice set.
13322
+ *
13323
+ * @param choiceSetId - UUID of the parent choice set
13324
+ * @param valueIds - Array of value UUIDs to delete
13325
+ * @returns Promise resolving when the values are deleted
13326
+ *
13327
+ * @example
13328
+ * ```typescript
13329
+ * // Get the value IDs from getById()
13330
+ * const values = await choicesets.getById('<choiceSetId>');
13331
+ * const idsToDelete = values.items.slice(0, 2).map(v => v.id);
13332
+ *
13333
+ * await choicesets.deleteValuesById('<choiceSetId>', idsToDelete);
13334
+ * ```
13335
+ * @internal
13336
+ */
13337
+ async deleteValuesById(choiceSetId, valueIds) {
13338
+ await this.post(DATA_FABRIC_ENDPOINTS.CHOICESETS.DELETE_BY_ID(choiceSetId), valueIds);
13339
+ }
13340
+ async resolveChoiceSetName(choiceSetId) {
13341
+ const all = await this.getAll();
13342
+ const match = all.find(cs => cs.id === choiceSetId);
13343
+ if (!match) {
13344
+ throw new NotFoundError({ message: `Choice set with id '${choiceSetId}' not found.` });
13345
+ }
13346
+ return match.name;
13347
+ }
13145
13348
  }
13146
13349
  __decorate([
13147
13350
  track('Choicesets.GetAll')
@@ -13149,6 +13352,24 @@
13149
13352
  __decorate([
13150
13353
  track('Choicesets.GetById')
13151
13354
  ], ChoiceSetService.prototype, "getById", null);
13355
+ __decorate([
13356
+ track('Choicesets.Create')
13357
+ ], ChoiceSetService.prototype, "create", null);
13358
+ __decorate([
13359
+ track('Choicesets.UpdateById')
13360
+ ], ChoiceSetService.prototype, "updateById", null);
13361
+ __decorate([
13362
+ track('Choicesets.DeleteById')
13363
+ ], ChoiceSetService.prototype, "deleteById", null);
13364
+ __decorate([
13365
+ track('Choicesets.InsertValueById')
13366
+ ], ChoiceSetService.prototype, "insertValueById", null);
13367
+ __decorate([
13368
+ track('Choicesets.UpdateValueById')
13369
+ ], ChoiceSetService.prototype, "updateValueById", null);
13370
+ __decorate([
13371
+ track('Choicesets.DeleteValuesById')
13372
+ ], ChoiceSetService.prototype, "deleteValuesById", null);
13152
13373
 
13153
13374
  /**
13154
13375
  * Maestro Process Models
@@ -16402,6 +16623,120 @@
16402
16623
  }
16403
16624
  return transformedData;
16404
16625
  }
16626
+ /**
16627
+ * Lists all files in a bucket.
16628
+ *
16629
+ * Returns a flat, recursive listing of all files in the bucket. Supports regex filtering
16630
+ * and filter / orderby / select / expand. {@link BucketFile} entries include
16631
+ * `isDirectory` so callers can distinguish folders from files.
16632
+ *
16633
+ * The method returns either:
16634
+ * - A NonPaginatedResponse with items array (when no pagination parameters are provided)
16635
+ * - A PaginatedResponse with navigation cursors (when any pagination parameter is provided)
16636
+ *
16637
+ * @param bucketId - The ID of the bucket
16638
+ * @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`) and optional parameters for regex filtering, query options, and pagination
16639
+ * @returns Promise resolving to either an array of files NonPaginatedResponse<BucketFile> or a PaginatedResponse<BucketFile> when pagination options are used.
16640
+ *
16641
+ * @example
16642
+ * ```typescript
16643
+ * import { Buckets } from '@uipath/uipath-typescript/buckets';
16644
+ *
16645
+ * const buckets = new Buckets(sdk);
16646
+ *
16647
+ * // List all files in the bucket
16648
+ * const files = await buckets.getFiles(<bucketId>, { folderId: <folderId> });
16649
+ *
16650
+ * // Filter by regex pattern
16651
+ * const pdfs = await buckets.getFiles(<bucketId>, {
16652
+ * folderId: <folderId>,
16653
+ * fileNameRegex: '.*\\.pdf$'
16654
+ * });
16655
+ *
16656
+ * // First page with pagination
16657
+ * const page1 = await buckets.getFiles(<bucketId>, { folderId: <folderId>, pageSize: 10 });
16658
+ *
16659
+ * // Navigate using cursor
16660
+ * if (page1.hasNextPage) {
16661
+ * const page2 = await buckets.getFiles(<bucketId>, { folderId: <folderId>, cursor: page1.nextCursor });
16662
+ * }
16663
+ *
16664
+ * // Jump to specific page
16665
+ * const page5 = await buckets.getFiles(<bucketId>, {
16666
+ * folderId: <folderId>,
16667
+ * jumpToPage: 5,
16668
+ * pageSize: 10
16669
+ * });
16670
+ * ```
16671
+ */
16672
+ async getFiles(bucketId, options) {
16673
+ if (!bucketId) {
16674
+ throw new ValidationError({ message: 'bucketId is required for getFiles' });
16675
+ }
16676
+ const { folderId, folderKey, folderPath, ...restOptions } = options ?? {};
16677
+ const headers = resolveFolderHeaders({
16678
+ folderId,
16679
+ folderKey,
16680
+ folderPath,
16681
+ resourceType: 'Buckets.getFiles',
16682
+ fallbackFolderKey: this.config.folderKey,
16683
+ });
16684
+ const transformBucketFile = (file) => transformData(pascalToCamelCaseKeys(file), BucketMap);
16685
+ return PaginationHelpers.getAll({
16686
+ serviceAccess: this.createPaginationServiceAccess(),
16687
+ getEndpoint: () => BUCKET_ENDPOINTS.GET_FILES(bucketId),
16688
+ transformFn: transformBucketFile,
16689
+ pagination: {
16690
+ paginationType: PaginationType.OFFSET,
16691
+ itemsField: ODATA_PAGINATION.ITEMS_FIELD,
16692
+ totalCountField: ODATA_PAGINATION.TOTAL_COUNT_FIELD,
16693
+ paginationParams: {
16694
+ pageSizeParam: ODATA_OFFSET_PARAMS.PAGE_SIZE_PARAM,
16695
+ offsetParam: ODATA_OFFSET_PARAMS.OFFSET_PARAM,
16696
+ countParam: ODATA_OFFSET_PARAMS.COUNT_PARAM,
16697
+ },
16698
+ },
16699
+ excludeFromPrefix: ['directory', 'recursive', 'fileNameRegex'],
16700
+ headers,
16701
+ }, { ...restOptions, directory: '/', recursive: true });
16702
+ }
16703
+ /**
16704
+ * Deletes a file from a bucket
16705
+ *
16706
+ * @param bucketId - The ID of the bucket
16707
+ * @param path - The full path to the file to delete
16708
+ * @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`)
16709
+ * @returns Promise resolving when the file is deleted
16710
+ *
16711
+ * @example
16712
+ * ```typescript
16713
+ * import { Buckets } from '@uipath/uipath-typescript/buckets';
16714
+ *
16715
+ * const buckets = new Buckets(sdk);
16716
+ *
16717
+ * // Delete a file from a bucket
16718
+ * await buckets.deleteFile(<bucketId>, '/folder/file.pdf', { folderId: <folderId> });
16719
+ * ```
16720
+ */
16721
+ async deleteFile(bucketId, path, options) {
16722
+ if (!bucketId) {
16723
+ throw new ValidationError({ message: 'bucketId is required for deleteFile' });
16724
+ }
16725
+ if (!path) {
16726
+ throw new ValidationError({ message: 'path is required for deleteFile' });
16727
+ }
16728
+ const headers = resolveFolderHeaders({
16729
+ folderId: options?.folderId,
16730
+ folderKey: options?.folderKey,
16731
+ folderPath: options?.folderPath,
16732
+ resourceType: 'Buckets.deleteFile',
16733
+ fallbackFolderKey: this.config.folderKey,
16734
+ });
16735
+ await this.delete(BUCKET_ENDPOINTS.DELETE_FILE(bucketId), {
16736
+ params: { path },
16737
+ headers,
16738
+ });
16739
+ }
16405
16740
  /**
16406
16741
  * Gets a direct upload URL for a file in the bucket
16407
16742
  *
@@ -16435,6 +16770,12 @@
16435
16770
  __decorate([
16436
16771
  track('Buckets.GetReadUri')
16437
16772
  ], BucketService.prototype, "getReadUri", null);
16773
+ __decorate([
16774
+ track('Buckets.GetFiles')
16775
+ ], BucketService.prototype, "getFiles", null);
16776
+ __decorate([
16777
+ track('Buckets.DeleteFile')
16778
+ ], BucketService.prototype, "deleteFile", null);
16438
16779
 
16439
16780
  exports.BucketOptions = void 0;
16440
16781
  (function (BucketOptions) {
@@ -17232,33 +17573,32 @@
17232
17573
  }
17233
17574
  }, options);
17234
17575
  }
17235
- /**
17236
- * Starts a process execution (job)
17237
- *
17238
- * @param request - Process start request body
17239
- * @param folderId - Required folder ID
17240
- * @param options - Optional query parameters
17241
- * @returns Promise resolving to the created jobs
17242
- *
17243
- * @example
17244
- * ```typescript
17245
- * import { Processes } from '@uipath/uipath-typescript/processes';
17246
- *
17247
- * const processes = new Processes(sdk);
17248
- *
17249
- * // Start a process by process key
17250
- * const jobs = await processes.start({
17251
- * processKey: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
17252
- * }, 123); // folderId is required
17253
- *
17254
- * // Start a process by name with specific robots
17255
- * const jobs = await processes.start({
17256
- * processName: "MyProcess"
17257
- * }, 123); // folderId is required
17258
- * ```
17259
- */
17260
- async start(request, folderId, options = {}) {
17261
- const headers = createHeaders({ [FOLDER_ID]: folderId });
17576
+ async start(request, optionsOrFolderId, legacyOptions) {
17577
+ // Normalize the two overload forms into a single internal shape.
17578
+ let folderId;
17579
+ let folderKey;
17580
+ let folderPath;
17581
+ let queryOptions;
17582
+ if (typeof optionsOrFolderId === 'number') {
17583
+ // Deprecated positional form: start(request, folderId, options?)
17584
+ folderId = optionsOrFolderId;
17585
+ queryOptions = legacyOptions ?? {};
17586
+ }
17587
+ else {
17588
+ // Preferred form: start(request, options?)
17589
+ const { folderId: fid, folderKey: fkey, folderPath: fpath, ...rest } = optionsOrFolderId ?? {};
17590
+ folderId = fid;
17591
+ folderKey = fkey;
17592
+ folderPath = fpath;
17593
+ queryOptions = rest;
17594
+ }
17595
+ const headers = resolveFolderHeaders({
17596
+ folderId,
17597
+ folderKey,
17598
+ folderPath,
17599
+ resourceType: 'processes.start',
17600
+ fallbackFolderKey: this.config.folderKey,
17601
+ });
17262
17602
  // Transform SDK field names to API field names (e.g., processKey → releaseKey)
17263
17603
  const apiRequest = transformRequest(request, ProcessMap);
17264
17604
  // Create the request object according to API spec
@@ -17266,8 +17606,8 @@
17266
17606
  startInfo: apiRequest
17267
17607
  };
17268
17608
  // Prefix all query parameter keys with '$' for OData
17269
- const keysToPrefix = Object.keys(options);
17270
- const apiOptions = addPrefixToKeys(options, ODATA_PREFIX, keysToPrefix);
17609
+ const keysToPrefix = Object.keys(queryOptions);
17610
+ const apiOptions = addPrefixToKeys(queryOptions, ODATA_PREFIX, keysToPrefix);
17271
17611
  const response = await this.post(PROCESS_ENDPOINTS.START_PROCESS, requestBody, {
17272
17612
  params: apiOptions,
17273
17613
  headers
@@ -613,14 +613,25 @@ class ApiClient {
613
613
  if (!text) {
614
614
  return undefined;
615
615
  }
616
- return JSON.parse(text);
616
+ try {
617
+ return JSON.parse(text);
618
+ }
619
+ catch (error) {
620
+ if (error instanceof SyntaxError) {
621
+ throw new ServerError({
622
+ message: `Server returned non-JSON response (${response.status} ${response.url}): ${error.message}`,
623
+ statusCode: response.status,
624
+ });
625
+ }
626
+ throw error;
627
+ }
617
628
  }
618
629
  catch (error) {
619
630
  // If it's already one of our errors, re-throw it
620
631
  if (error.type && error.type.includes('Error')) {
621
632
  throw error;
622
633
  }
623
- // Otherwise, it's likely a network error
634
+ // Otherwise, it's a genuine network/fetch failure
624
635
  throw ErrorFactory.createNetworkError(error);
625
636
  }
626
637
  }
@@ -1221,9 +1232,9 @@ class PaginationHelpers {
1221
1232
  * @returns Promise resolving to a paginated result
1222
1233
  */
1223
1234
  static async getAllPaginated(params) {
1224
- const { serviceAccess, getEndpoint, folderId, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1235
+ const { serviceAccess, getEndpoint, folderId, headers: providedHeaders, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1225
1236
  const endpoint = getEndpoint(folderId);
1226
- const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
1237
+ const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
1227
1238
  const paginatedResponse = await serviceAccess.requestWithPagination(method, endpoint, paginationParams, {
1228
1239
  headers,
1229
1240
  params: additionalParams,
@@ -1251,13 +1262,13 @@ class PaginationHelpers {
1251
1262
  * @returns Promise resolving to an object with data and totalCount
1252
1263
  */
1253
1264
  static async getAllNonPaginated(params) {
1254
- const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1265
+ const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, headers: providedHeaders, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1255
1266
  // Set default field names
1256
1267
  const itemsField = options.itemsField || DEFAULT_ITEMS_FIELD;
1257
1268
  const totalCountField = options.totalCountField || DEFAULT_TOTAL_COUNT_FIELD;
1258
1269
  // Determine endpoint and headers based on folderId
1259
1270
  const endpoint = folderId ? getByFolderEndpoint : getAllEndpoint;
1260
- const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
1271
+ const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
1261
1272
  // Make the API call based on method
1262
1273
  let response;
1263
1274
  if (method === HTTP_METHODS.POST) {
@@ -1316,6 +1327,7 @@ class PaginationHelpers {
1316
1327
  serviceAccess: config.serviceAccess,
1317
1328
  getEndpoint: config.getEndpoint,
1318
1329
  folderId,
1330
+ headers: config.headers,
1319
1331
  paginationParams: cursor ? { cursor, pageSize } : jumpToPage ? { jumpToPage, pageSize } : { pageSize },
1320
1332
  additionalParams: prefixedOptions,
1321
1333
  transformFn: config.transformFn,
@@ -1333,6 +1345,7 @@ class PaginationHelpers {
1333
1345
  getAllEndpoint: config.getEndpoint(),
1334
1346
  getByFolderEndpoint: byFolderEndpoint,
1335
1347
  folderId,
1348
+ headers: config.headers,
1336
1349
  additionalParams: prefixedOptions,
1337
1350
  transformFn: config.transformFn,
1338
1351
  method: config.method,
@@ -611,14 +611,25 @@ class ApiClient {
611
611
  if (!text) {
612
612
  return undefined;
613
613
  }
614
- return JSON.parse(text);
614
+ try {
615
+ return JSON.parse(text);
616
+ }
617
+ catch (error) {
618
+ if (error instanceof SyntaxError) {
619
+ throw new ServerError({
620
+ message: `Server returned non-JSON response (${response.status} ${response.url}): ${error.message}`,
621
+ statusCode: response.status,
622
+ });
623
+ }
624
+ throw error;
625
+ }
615
626
  }
616
627
  catch (error) {
617
628
  // If it's already one of our errors, re-throw it
618
629
  if (error.type && error.type.includes('Error')) {
619
630
  throw error;
620
631
  }
621
- // Otherwise, it's likely a network error
632
+ // Otherwise, it's a genuine network/fetch failure
622
633
  throw ErrorFactory.createNetworkError(error);
623
634
  }
624
635
  }
@@ -1219,9 +1230,9 @@ class PaginationHelpers {
1219
1230
  * @returns Promise resolving to a paginated result
1220
1231
  */
1221
1232
  static async getAllPaginated(params) {
1222
- const { serviceAccess, getEndpoint, folderId, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1233
+ const { serviceAccess, getEndpoint, folderId, headers: providedHeaders, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1223
1234
  const endpoint = getEndpoint(folderId);
1224
- const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
1235
+ const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
1225
1236
  const paginatedResponse = await serviceAccess.requestWithPagination(method, endpoint, paginationParams, {
1226
1237
  headers,
1227
1238
  params: additionalParams,
@@ -1249,13 +1260,13 @@ class PaginationHelpers {
1249
1260
  * @returns Promise resolving to an object with data and totalCount
1250
1261
  */
1251
1262
  static async getAllNonPaginated(params) {
1252
- const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1263
+ const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, headers: providedHeaders, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1253
1264
  // Set default field names
1254
1265
  const itemsField = options.itemsField || DEFAULT_ITEMS_FIELD;
1255
1266
  const totalCountField = options.totalCountField || DEFAULT_TOTAL_COUNT_FIELD;
1256
1267
  // Determine endpoint and headers based on folderId
1257
1268
  const endpoint = folderId ? getByFolderEndpoint : getAllEndpoint;
1258
- const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
1269
+ const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
1259
1270
  // Make the API call based on method
1260
1271
  let response;
1261
1272
  if (method === HTTP_METHODS.POST) {
@@ -1314,6 +1325,7 @@ class PaginationHelpers {
1314
1325
  serviceAccess: config.serviceAccess,
1315
1326
  getEndpoint: config.getEndpoint,
1316
1327
  folderId,
1328
+ headers: config.headers,
1317
1329
  paginationParams: cursor ? { cursor, pageSize } : jumpToPage ? { jumpToPage, pageSize } : { pageSize },
1318
1330
  additionalParams: prefixedOptions,
1319
1331
  transformFn: config.transformFn,
@@ -1331,6 +1343,7 @@ class PaginationHelpers {
1331
1343
  getAllEndpoint: config.getEndpoint(),
1332
1344
  getByFolderEndpoint: byFolderEndpoint,
1333
1345
  folderId,
1346
+ headers: config.headers,
1334
1347
  additionalParams: prefixedOptions,
1335
1348
  transformFn: config.transformFn,
1336
1349
  method: config.method,