@uipath/uipath-typescript 1.2.2 → 1.3.0

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.cjs CHANGED
@@ -4520,6 +4520,7 @@ const QUEUE_ENDPOINTS = {
4520
4520
  */
4521
4521
  const JOB_ENDPOINTS = {
4522
4522
  GET_ALL: `${ORCHESTRATOR_BASE}/odata/Jobs`,
4523
+ GET_BY_KEY: (identifier) => `${ORCHESTRATOR_BASE}/odata/Jobs/UiPath.Server.Configuration.OData.GetByKey(identifier=${identifier})`,
4523
4524
  };
4524
4525
  /**
4525
4526
  * Orchestrator Asset Service Endpoints
@@ -5419,7 +5420,7 @@ function normalizeBaseUrl(url) {
5419
5420
  // Connection string placeholder that will be replaced during build
5420
5421
  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";
5421
5422
  // SDK Version placeholder
5422
- const SDK_VERSION = "1.2.2";
5423
+ const SDK_VERSION = "1.3.0";
5423
5424
  const VERSION = "Version";
5424
5425
  const SERVICE = "Service";
5425
5426
  const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
@@ -7923,11 +7924,7 @@ class EntityService extends BaseService {
7923
7924
  expansionLevel: options.expansionLevel
7924
7925
  });
7925
7926
  const response = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.GET_RECORD_BY_ID(entityId, recordId), { params });
7926
- // Convert PascalCase response to camelCase
7927
- const camelResponse = pascalToCamelCaseKeys(response.data);
7928
- // Apply EntityMap transformations
7929
- const transformedResponse = transformData(camelResponse, EntityMap);
7930
- return transformedResponse;
7927
+ return response.data;
7931
7928
  }
7932
7929
  /**
7933
7930
  * Inserts a single record into an entity by entity ID
@@ -7960,9 +7957,7 @@ class EntityService extends BaseService {
7960
7957
  params,
7961
7958
  ...options
7962
7959
  });
7963
- // Convert PascalCase response to camelCase
7964
- const camelResponse = pascalToCamelCaseKeys(response.data);
7965
- return camelResponse;
7960
+ return response.data;
7966
7961
  }
7967
7962
  /**
7968
7963
  * Inserts data into an entity by entity ID using batch insert
@@ -8003,9 +7998,7 @@ class EntityService extends BaseService {
8003
7998
  params,
8004
7999
  ...options
8005
8000
  });
8006
- // Convert PascalCase response to camelCase
8007
- const camelResponse = pascalToCamelCaseKeys(response.data);
8008
- return camelResponse;
8001
+ return response.data;
8009
8002
  }
8010
8003
  /**
8011
8004
  * Updates a single record in an entity by entity ID
@@ -8039,9 +8032,7 @@ class EntityService extends BaseService {
8039
8032
  params,
8040
8033
  ...options
8041
8034
  });
8042
- // Convert PascalCase response to camelCase
8043
- const camelResponse = pascalToCamelCaseKeys(response.data);
8044
- return camelResponse;
8035
+ return response.data;
8045
8036
  }
8046
8037
  /**
8047
8038
  * Updates data in an entity by entity ID
@@ -8083,9 +8074,7 @@ class EntityService extends BaseService {
8083
8074
  params,
8084
8075
  ...options
8085
8076
  });
8086
- // Convert PascalCase response to camelCase
8087
- const camelResponse = pascalToCamelCaseKeys(response.data);
8088
- return camelResponse;
8077
+ return response.data;
8089
8078
  }
8090
8079
  /**
8091
8080
  * Deletes data from an entity by entity ID
@@ -8115,9 +8104,7 @@ class EntityService extends BaseService {
8115
8104
  params,
8116
8105
  ...options
8117
8106
  });
8118
- // Convert PascalCase response to camelCase
8119
- const camelResponse = pascalToCamelCaseKeys(response.data);
8120
- return camelResponse;
8107
+ return response.data;
8121
8108
  }
8122
8109
  /**
8123
8110
  * Gets all entities in the system
@@ -8169,7 +8156,7 @@ class EntityService extends BaseService {
8169
8156
  *
8170
8157
  * // Get the recordId from getAllRecords()
8171
8158
  * const records = await entities.getAllRecords(entityId);
8172
- * const recordId = records[0].id;
8159
+ * const recordId = records[0].Id;
8173
8160
  *
8174
8161
  * // Download attachment for a specific record and field
8175
8162
  * const blob = await entities.downloadAttachment(entityId, recordId, 'Documents');
@@ -8203,7 +8190,7 @@ class EntityService extends BaseService {
8203
8190
  *
8204
8191
  * // Get the recordId from getAllRecords()
8205
8192
  * const records = await entities.getAllRecords(entityId);
8206
- * const recordId = records[0].id;
8193
+ * const recordId = records[0].Id;
8207
8194
  *
8208
8195
  * // Upload a file attachment
8209
8196
  * const response = await entities.uploadAttachment(entityId, recordId, 'Documents', file);
@@ -8219,9 +8206,7 @@ class EntityService extends BaseService {
8219
8206
  }
8220
8207
  const params = createParams({ expansionLevel: options?.expansionLevel });
8221
8208
  const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPLOAD_ATTACHMENT(entityId, recordId, fieldName), formData, { params });
8222
- // Convert PascalCase response to camelCase
8223
- const camelResponse = pascalToCamelCaseKeys(response.data);
8224
- return camelResponse;
8209
+ return response.data;
8225
8210
  }
8226
8211
  /**
8227
8212
  * Removes an attachment from a File-type field of an entity record
@@ -8243,7 +8228,7 @@ class EntityService extends BaseService {
8243
8228
  *
8244
8229
  * // Get the recordId from getAllRecords()
8245
8230
  * const records = await entities.getAllRecords(entityId);
8246
- * const recordId = records[0].id;
8231
+ * const recordId = records[0].Id;
8247
8232
  *
8248
8233
  * // Delete attachment for a specific record and field
8249
8234
  * await entities.deleteAttachment(entityId, recordId, 'Documents');
@@ -10962,6 +10947,36 @@ exports.BucketOptions = void 0;
10962
10947
  BucketOptions["AccessDataThroughOrchestrator"] = "AccessDataThroughOrchestrator";
10963
10948
  })(exports.BucketOptions || (exports.BucketOptions = {}));
10964
10949
 
10950
+ /**
10951
+ * Creates methods for a job response object.
10952
+ *
10953
+ * @param jobData - The raw job data from API
10954
+ * @param service - The job service instance
10955
+ * @returns Object containing job methods
10956
+ */
10957
+ function createJobMethods(jobData, service) {
10958
+ return {
10959
+ async getOutput() {
10960
+ if (!jobData.key)
10961
+ throw new Error('Job key is undefined');
10962
+ if (!jobData.folderId)
10963
+ throw new Error('Job folderId is undefined');
10964
+ return service.getOutput(jobData.key, jobData.folderId);
10965
+ },
10966
+ };
10967
+ }
10968
+ /**
10969
+ * Creates a job response with bound methods.
10970
+ *
10971
+ * @param jobData - The raw job data from API
10972
+ * @param service - The job service instance
10973
+ * @returns A job object with added methods
10974
+ */
10975
+ function createJobWithMethods(jobData, service) {
10976
+ const methods = createJobMethods(jobData, service);
10977
+ return Object.assign({}, jobData, methods);
10978
+ }
10979
+
10965
10980
  /**
10966
10981
  * Maps fields for Job entities to ensure consistent naming
10967
10982
  * Semantic renames only — case conversion handled by pascalToCamelCaseKeys()
@@ -10977,27 +10992,81 @@ const JobMap = {
10977
10992
  release: 'process',
10978
10993
  };
10979
10994
 
10995
+ /**
10996
+ * Maps fields for Attachment entities to ensure consistent naming
10997
+ */
10998
+ const AttachmentsMap = {
10999
+ creationTime: 'createdTime',
11000
+ lastModificationTime: 'lastModifiedTime'
11001
+ };
11002
+
11003
+ class AttachmentService extends BaseService {
11004
+ /**
11005
+ * Gets an attachment by ID
11006
+ * @param id - The UUID of the attachment to retrieve
11007
+ * @param options - Optional query parameters (expand, select)
11008
+ * @returns Promise resolving to the attachment
11009
+ *
11010
+ * @example
11011
+ * ```typescript
11012
+ * import { Attachments } from '@uipath/uipath-typescript/attachments';
11013
+ *
11014
+ * const attachments = new Attachments(sdk);
11015
+ * const attachment = await attachments.getById('12345678-1234-1234-1234-123456789abc');
11016
+ * ```
11017
+ */
11018
+ async getById(id, options = {}) {
11019
+ if (!id) {
11020
+ throw new ValidationError({ message: 'id is required for getById' });
11021
+ }
11022
+ // Prefix all keys in options with $ for OData
11023
+ const keysToPrefix = Object.keys(options);
11024
+ const apiOptions = addPrefixToKeys(options, ODATA_PREFIX, keysToPrefix);
11025
+ const response = await this.get(ORCHESTRATOR_ATTACHMENT_ENDPOINTS.GET_BY_ID(id), {
11026
+ params: apiOptions,
11027
+ });
11028
+ // Transform response from PascalCase to camelCase, then apply field maps
11029
+ const camelCased = pascalToCamelCaseKeys(response.data);
11030
+ camelCased.blobFileAccess = transformData(camelCased.blobFileAccess, BucketMap);
11031
+ return transformData(camelCased, AttachmentsMap);
11032
+ }
11033
+ }
11034
+ __decorate([
11035
+ track('Attachments.GetById')
11036
+ ], AttachmentService.prototype, "getById", null);
11037
+
10980
11038
  /**
10981
11039
  * Service for interacting with UiPath Orchestrator Jobs API
10982
11040
  */
10983
11041
  class JobService extends FolderScopedService {
10984
11042
  /**
10985
- * Gets all jobs across folders with optional filtering
11043
+ * Creates an instance of the Jobs service.
10986
11044
  *
10987
- * @param options - Query options including optional folderId and pagination options
10988
- * @returns Promise resolving to array of jobs or paginated response
11045
+ * @param instance - UiPath SDK instance providing authentication and configuration
11046
+ */
11047
+ constructor(instance) {
11048
+ super(instance);
11049
+ this.attachmentService = new AttachmentService(instance);
11050
+ }
11051
+ /**
11052
+ * Gets all jobs across folders with optional filtering and pagination.
10989
11053
  *
10990
- * @example
10991
- * ```typescript
10992
- * import { Jobs } from '@uipath/uipath-typescript/jobs';
11054
+ * Returns jobs with full details including state, timing, and input/output arguments.
11055
+ * Pass `folderId` to scope the query to a specific folder.
10993
11056
  *
10994
- * const jobs = new Jobs(sdk);
11057
+ * !!! info "Input and output fields are not included in `getAll` responses"
11058
+ * The `inputArguments`, `inputFile`, `outputArguments`, and `outputFile` fields will always be `null` in the `getAll` response. To retrieve a job's output, use the {@link getOutput} method with the job's `key` and `folderId`.
10995
11059
  *
11060
+ * @param options - Query options including optional folderId, filtering, and pagination options
11061
+ * @returns Promise resolving to either an array of jobs {@link NonPaginatedResponse}<{@link JobGetResponse}> or a {@link PaginatedResponse}<{@link JobGetResponse}> when pagination options are used.
11062
+ * {@link JobGetResponse}
11063
+ * @example
11064
+ * ```typescript
10996
11065
  * // Get all jobs
10997
11066
  * const allJobs = await jobs.getAll();
10998
11067
  *
10999
11068
  * // Get all jobs in a specific folder
11000
- * const folderJobs = await jobs.getAll({ folderId: 123 });
11069
+ * const folderJobs = await jobs.getAll({ folderId: <folderId> });
11001
11070
  *
11002
11071
  * // With filtering
11003
11072
  * const runningJobs = await jobs.getAll({
@@ -11011,10 +11080,19 @@ class JobService extends FolderScopedService {
11011
11080
  * if (page1.hasNextPage) {
11012
11081
  * const page2 = await jobs.getAll({ cursor: page1.nextCursor });
11013
11082
  * }
11083
+ *
11084
+ * // Jump to specific page
11085
+ * const page5 = await jobs.getAll({
11086
+ * jumpToPage: 5,
11087
+ * pageSize: 10
11088
+ * });
11014
11089
  * ```
11015
11090
  */
11016
11091
  async getAll(options) {
11017
- const transformJobResponse = (job) => transformData(pascalToCamelCaseKeys(job), JobMap);
11092
+ const transformJobResponse = (job) => {
11093
+ const rawJob = transformData(pascalToCamelCaseKeys(job), JobMap);
11094
+ return createJobWithMethods(rawJob, this);
11095
+ };
11018
11096
  return PaginationHelpers.getAll({
11019
11097
  serviceAccess: this.createPaginationServiceAccess(),
11020
11098
  getEndpoint: () => JOB_ENDPOINTS.GET_ALL,
@@ -11032,10 +11110,111 @@ class JobService extends FolderScopedService {
11032
11110
  },
11033
11111
  }, options);
11034
11112
  }
11113
+ /**
11114
+ * Gets the output of a completed job.
11115
+ *
11116
+ * Retrieves the job's output arguments, handling both inline output (stored directly on the job
11117
+ * as a JSON string in `outputArguments`) and file-based output (stored as a blob attachment for
11118
+ * large outputs). Returns the parsed JSON output or `null` if the job has no output.
11119
+ *
11120
+ * @param jobKey - The unique key (GUID) of the job to retrieve output from
11121
+ * @param folderId - The folder ID where the job resides
11122
+ * @returns Promise resolving to the parsed output as `Record<string, unknown>`, or `null` if no output exists
11123
+ *
11124
+ * @example
11125
+ * ```typescript
11126
+ * // Get output from a completed job
11127
+ * const output = await jobs.getOutput(<jobKey>, <folderId>);
11128
+ *
11129
+ * if (output) {
11130
+ * console.log('Job output:', output);
11131
+ * }
11132
+ * ```
11133
+ *
11134
+ * @example
11135
+ * ```typescript
11136
+ * // Get output using bound method (jobKey and folderId are taken from the job object)
11137
+ * const allJobs = await jobs.getAll();
11138
+ * const completedJob = allJobs.items.find(j => j.state === JobState.Successful);
11139
+ *
11140
+ * if (completedJob) {
11141
+ * const output = await completedJob.getOutput();
11142
+ * }
11143
+ * ```
11144
+ */
11145
+ async getOutput(jobKey, folderId) {
11146
+ if (!jobKey) {
11147
+ throw new ValidationError({ message: 'jobKey is required for getOutput' });
11148
+ }
11149
+ const job = await this.fetchJobByKey(jobKey, folderId);
11150
+ if (job.OutputArguments) {
11151
+ try {
11152
+ return JSON.parse(job.OutputArguments);
11153
+ }
11154
+ catch {
11155
+ throw new ServerError({ message: 'Failed to parse job output arguments as JSON' });
11156
+ }
11157
+ }
11158
+ if (job.OutputFile) {
11159
+ return this.downloadOutputFile(job.OutputFile);
11160
+ }
11161
+ return null;
11162
+ }
11163
+ /**
11164
+ * Fetches a job by its Key (GUID) using the GetByKey endpoint.
11165
+ * Only selects fields needed for output extraction.
11166
+ */
11167
+ async fetchJobByKey(jobKey, folderId) {
11168
+ const headers = createHeaders({ [FOLDER_ID]: folderId });
11169
+ const response = await this.get(JOB_ENDPOINTS.GET_BY_KEY(jobKey), {
11170
+ params: {
11171
+ $select: 'OutputArguments,OutputFile',
11172
+ },
11173
+ headers,
11174
+ });
11175
+ return response.data;
11176
+ }
11177
+ /**
11178
+ * Downloads the output file content via the Attachments API.
11179
+ * 1. Fetches blob access info from the attachment using AttachmentService
11180
+ * 2. Downloads content from the presigned blob URI
11181
+ * 3. Parses and returns the JSON content
11182
+ */
11183
+ async downloadOutputFile(outputFileKey) {
11184
+ const attachment = await this.attachmentService.getById(outputFileKey);
11185
+ const blobAccess = attachment.blobFileAccess;
11186
+ if (!blobAccess?.uri) {
11187
+ return null;
11188
+ }
11189
+ const blobHeaders = { ...blobAccess.headers };
11190
+ // Add auth header if the blob URI requires authenticated access
11191
+ if (blobAccess.requiresAuth) {
11192
+ const token = await this.getValidAuthToken();
11193
+ blobHeaders['Authorization'] = `Bearer ${token}`;
11194
+ }
11195
+ const blobResponse = await fetch(blobAccess.uri, {
11196
+ method: 'GET',
11197
+ headers: blobHeaders,
11198
+ });
11199
+ if (!blobResponse.ok) {
11200
+ const errorInfo = await errorResponseParser.parse(blobResponse);
11201
+ throw ErrorFactory.createFromHttpStatus(blobResponse.status, errorInfo);
11202
+ }
11203
+ const content = await blobResponse.text();
11204
+ try {
11205
+ return JSON.parse(content);
11206
+ }
11207
+ catch {
11208
+ throw new ServerError({ message: 'Failed to parse job output file as JSON' });
11209
+ }
11210
+ }
11035
11211
  }
11036
11212
  __decorate([
11037
11213
  track('Jobs.GetAll')
11038
11214
  ], JobService.prototype, "getAll", null);
11215
+ __decorate([
11216
+ track('Jobs.GetOutput')
11217
+ ], JobService.prototype, "getOutput", null);
11039
11218
 
11040
11219
  /**
11041
11220
  * Enum for job sub-state
@@ -11062,6 +11241,22 @@ exports.ServerlessJobType = void 0;
11062
11241
  ServerlessJobType["PythonAgent"] = "PythonAgent";
11063
11242
  })(exports.ServerlessJobType || (exports.ServerlessJobType = {}));
11064
11243
 
11244
+ /**
11245
+ * Common enum for job state used across services
11246
+ */
11247
+ exports.JobState = void 0;
11248
+ (function (JobState) {
11249
+ JobState["Pending"] = "Pending";
11250
+ JobState["Running"] = "Running";
11251
+ JobState["Stopping"] = "Stopping";
11252
+ JobState["Terminating"] = "Terminating";
11253
+ JobState["Faulted"] = "Faulted";
11254
+ JobState["Successful"] = "Successful";
11255
+ JobState["Stopped"] = "Stopped";
11256
+ JobState["Suspended"] = "Suspended";
11257
+ JobState["Resumed"] = "Resumed";
11258
+ })(exports.JobState || (exports.JobState = {}));
11259
+
11065
11260
  /**
11066
11261
  * Maps fields for Process entities to ensure consistent naming
11067
11262
  */
@@ -11518,49 +11713,6 @@ __decorate([
11518
11713
  track('Queues.GetById')
11519
11714
  ], QueueService.prototype, "getById", null);
11520
11715
 
11521
- /**
11522
- * Maps fields for Attachment entities to ensure consistent naming
11523
- */
11524
- const AttachmentsMap = {
11525
- creationTime: 'createdTime',
11526
- lastModificationTime: 'lastModifiedTime'
11527
- };
11528
-
11529
- class AttachmentService extends BaseService {
11530
- /**
11531
- * Gets an attachment by ID
11532
- * @param id - The UUID of the attachment to retrieve
11533
- * @param options - Optional query parameters (expand, select)
11534
- * @returns Promise resolving to the attachment
11535
- *
11536
- * @example
11537
- * ```typescript
11538
- * import { Attachments } from '@uipath/uipath-typescript/attachments';
11539
- *
11540
- * const attachments = new Attachments(sdk);
11541
- * const attachment = await attachments.getById('12345678-1234-1234-1234-123456789abc');
11542
- * ```
11543
- */
11544
- async getById(id, options = {}) {
11545
- if (!id) {
11546
- throw new ValidationError({ message: 'id is required for getById' });
11547
- }
11548
- // Prefix all keys in options with $ for OData
11549
- const keysToPrefix = Object.keys(options);
11550
- const apiOptions = addPrefixToKeys(options, ODATA_PREFIX, keysToPrefix);
11551
- const response = await this.get(ORCHESTRATOR_ATTACHMENT_ENDPOINTS.GET_BY_ID(id), {
11552
- params: apiOptions,
11553
- });
11554
- // Transform response from PascalCase to camelCase, then apply field maps
11555
- const camelCased = pascalToCamelCaseKeys(response.data);
11556
- camelCased.blobFileAccess = transformData(camelCased.blobFileAccess, BucketMap);
11557
- return transformData(camelCased, AttachmentsMap);
11558
- }
11559
- }
11560
- __decorate([
11561
- track('Attachments.GetById')
11562
- ], AttachmentService.prototype, "getById", null);
11563
-
11564
11716
  /**
11565
11717
  * UiPath SDK - Legacy class providing all services through property getters.
11566
11718
  *
@@ -11676,22 +11828,6 @@ class UiPath extends UiPath$1 {
11676
11828
  }
11677
11829
  }
11678
11830
 
11679
- /**
11680
- * Common enum for job state used across services
11681
- */
11682
- exports.JobState = void 0;
11683
- (function (JobState) {
11684
- JobState["Pending"] = "Pending";
11685
- JobState["Running"] = "Running";
11686
- JobState["Stopping"] = "Stopping";
11687
- JobState["Terminating"] = "Terminating";
11688
- JobState["Faulted"] = "Faulted";
11689
- JobState["Successful"] = "Successful";
11690
- JobState["Stopped"] = "Stopped";
11691
- JobState["Suspended"] = "Suspended";
11692
- JobState["Resumed"] = "Resumed";
11693
- })(exports.JobState || (exports.JobState = {}));
11694
-
11695
11831
  /**
11696
11832
  * Common Constants for Conversational Agent
11697
11833
  */
@@ -12064,6 +12200,7 @@ exports.createAgentWithMethods = createAgentWithMethods;
12064
12200
  exports.createCaseInstanceWithMethods = createCaseInstanceWithMethods;
12065
12201
  exports.createConversationWithMethods = createConversationWithMethods;
12066
12202
  exports.createEntityWithMethods = createEntityWithMethods;
12203
+ exports.createJobWithMethods = createJobWithMethods;
12067
12204
  exports.createProcessInstanceWithMethods = createProcessInstanceWithMethods;
12068
12205
  exports.createProcessWithMethods = createProcessWithMethods;
12069
12206
  exports.createTaskWithMethods = createTaskWithMethods;