@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.umd.js CHANGED
@@ -4522,6 +4522,7 @@
4522
4522
  */
4523
4523
  const JOB_ENDPOINTS = {
4524
4524
  GET_ALL: `${ORCHESTRATOR_BASE}/odata/Jobs`,
4525
+ GET_BY_KEY: (identifier) => `${ORCHESTRATOR_BASE}/odata/Jobs/UiPath.Server.Configuration.OData.GetByKey(identifier=${identifier})`,
4525
4526
  };
4526
4527
  /**
4527
4528
  * Orchestrator Asset Service Endpoints
@@ -9176,7 +9177,7 @@
9176
9177
  // Connection string placeholder that will be replaced during build
9177
9178
  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";
9178
9179
  // SDK Version placeholder
9179
- const SDK_VERSION = "1.2.2";
9180
+ const SDK_VERSION = "1.3.0";
9180
9181
  const VERSION = "Version";
9181
9182
  const SERVICE = "Service";
9182
9183
  const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
@@ -11680,11 +11681,7 @@
11680
11681
  expansionLevel: options.expansionLevel
11681
11682
  });
11682
11683
  const response = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.GET_RECORD_BY_ID(entityId, recordId), { params });
11683
- // Convert PascalCase response to camelCase
11684
- const camelResponse = pascalToCamelCaseKeys(response.data);
11685
- // Apply EntityMap transformations
11686
- const transformedResponse = transformData(camelResponse, EntityMap);
11687
- return transformedResponse;
11684
+ return response.data;
11688
11685
  }
11689
11686
  /**
11690
11687
  * Inserts a single record into an entity by entity ID
@@ -11717,9 +11714,7 @@
11717
11714
  params,
11718
11715
  ...options
11719
11716
  });
11720
- // Convert PascalCase response to camelCase
11721
- const camelResponse = pascalToCamelCaseKeys(response.data);
11722
- return camelResponse;
11717
+ return response.data;
11723
11718
  }
11724
11719
  /**
11725
11720
  * Inserts data into an entity by entity ID using batch insert
@@ -11760,9 +11755,7 @@
11760
11755
  params,
11761
11756
  ...options
11762
11757
  });
11763
- // Convert PascalCase response to camelCase
11764
- const camelResponse = pascalToCamelCaseKeys(response.data);
11765
- return camelResponse;
11758
+ return response.data;
11766
11759
  }
11767
11760
  /**
11768
11761
  * Updates a single record in an entity by entity ID
@@ -11796,9 +11789,7 @@
11796
11789
  params,
11797
11790
  ...options
11798
11791
  });
11799
- // Convert PascalCase response to camelCase
11800
- const camelResponse = pascalToCamelCaseKeys(response.data);
11801
- return camelResponse;
11792
+ return response.data;
11802
11793
  }
11803
11794
  /**
11804
11795
  * Updates data in an entity by entity ID
@@ -11840,9 +11831,7 @@
11840
11831
  params,
11841
11832
  ...options
11842
11833
  });
11843
- // Convert PascalCase response to camelCase
11844
- const camelResponse = pascalToCamelCaseKeys(response.data);
11845
- return camelResponse;
11834
+ return response.data;
11846
11835
  }
11847
11836
  /**
11848
11837
  * Deletes data from an entity by entity ID
@@ -11872,9 +11861,7 @@
11872
11861
  params,
11873
11862
  ...options
11874
11863
  });
11875
- // Convert PascalCase response to camelCase
11876
- const camelResponse = pascalToCamelCaseKeys(response.data);
11877
- return camelResponse;
11864
+ return response.data;
11878
11865
  }
11879
11866
  /**
11880
11867
  * Gets all entities in the system
@@ -11926,7 +11913,7 @@
11926
11913
  *
11927
11914
  * // Get the recordId from getAllRecords()
11928
11915
  * const records = await entities.getAllRecords(entityId);
11929
- * const recordId = records[0].id;
11916
+ * const recordId = records[0].Id;
11930
11917
  *
11931
11918
  * // Download attachment for a specific record and field
11932
11919
  * const blob = await entities.downloadAttachment(entityId, recordId, 'Documents');
@@ -11960,7 +11947,7 @@
11960
11947
  *
11961
11948
  * // Get the recordId from getAllRecords()
11962
11949
  * const records = await entities.getAllRecords(entityId);
11963
- * const recordId = records[0].id;
11950
+ * const recordId = records[0].Id;
11964
11951
  *
11965
11952
  * // Upload a file attachment
11966
11953
  * const response = await entities.uploadAttachment(entityId, recordId, 'Documents', file);
@@ -11976,9 +11963,7 @@
11976
11963
  }
11977
11964
  const params = createParams({ expansionLevel: options?.expansionLevel });
11978
11965
  const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPLOAD_ATTACHMENT(entityId, recordId, fieldName), formData, { params });
11979
- // Convert PascalCase response to camelCase
11980
- const camelResponse = pascalToCamelCaseKeys(response.data);
11981
- return camelResponse;
11966
+ return response.data;
11982
11967
  }
11983
11968
  /**
11984
11969
  * Removes an attachment from a File-type field of an entity record
@@ -12000,7 +11985,7 @@
12000
11985
  *
12001
11986
  * // Get the recordId from getAllRecords()
12002
11987
  * const records = await entities.getAllRecords(entityId);
12003
- * const recordId = records[0].id;
11988
+ * const recordId = records[0].Id;
12004
11989
  *
12005
11990
  * // Delete attachment for a specific record and field
12006
11991
  * await entities.deleteAttachment(entityId, recordId, 'Documents');
@@ -14719,6 +14704,36 @@
14719
14704
  BucketOptions["AccessDataThroughOrchestrator"] = "AccessDataThroughOrchestrator";
14720
14705
  })(exports.BucketOptions || (exports.BucketOptions = {}));
14721
14706
 
14707
+ /**
14708
+ * Creates methods for a job response object.
14709
+ *
14710
+ * @param jobData - The raw job data from API
14711
+ * @param service - The job service instance
14712
+ * @returns Object containing job methods
14713
+ */
14714
+ function createJobMethods(jobData, service) {
14715
+ return {
14716
+ async getOutput() {
14717
+ if (!jobData.key)
14718
+ throw new Error('Job key is undefined');
14719
+ if (!jobData.folderId)
14720
+ throw new Error('Job folderId is undefined');
14721
+ return service.getOutput(jobData.key, jobData.folderId);
14722
+ },
14723
+ };
14724
+ }
14725
+ /**
14726
+ * Creates a job response with bound methods.
14727
+ *
14728
+ * @param jobData - The raw job data from API
14729
+ * @param service - The job service instance
14730
+ * @returns A job object with added methods
14731
+ */
14732
+ function createJobWithMethods(jobData, service) {
14733
+ const methods = createJobMethods(jobData, service);
14734
+ return Object.assign({}, jobData, methods);
14735
+ }
14736
+
14722
14737
  /**
14723
14738
  * Maps fields for Job entities to ensure consistent naming
14724
14739
  * Semantic renames only — case conversion handled by pascalToCamelCaseKeys()
@@ -14734,27 +14749,81 @@
14734
14749
  release: 'process',
14735
14750
  };
14736
14751
 
14752
+ /**
14753
+ * Maps fields for Attachment entities to ensure consistent naming
14754
+ */
14755
+ const AttachmentsMap = {
14756
+ creationTime: 'createdTime',
14757
+ lastModificationTime: 'lastModifiedTime'
14758
+ };
14759
+
14760
+ class AttachmentService extends BaseService {
14761
+ /**
14762
+ * Gets an attachment by ID
14763
+ * @param id - The UUID of the attachment to retrieve
14764
+ * @param options - Optional query parameters (expand, select)
14765
+ * @returns Promise resolving to the attachment
14766
+ *
14767
+ * @example
14768
+ * ```typescript
14769
+ * import { Attachments } from '@uipath/uipath-typescript/attachments';
14770
+ *
14771
+ * const attachments = new Attachments(sdk);
14772
+ * const attachment = await attachments.getById('12345678-1234-1234-1234-123456789abc');
14773
+ * ```
14774
+ */
14775
+ async getById(id, options = {}) {
14776
+ if (!id) {
14777
+ throw new ValidationError({ message: 'id is required for getById' });
14778
+ }
14779
+ // Prefix all keys in options with $ for OData
14780
+ const keysToPrefix = Object.keys(options);
14781
+ const apiOptions = addPrefixToKeys(options, ODATA_PREFIX, keysToPrefix);
14782
+ const response = await this.get(ORCHESTRATOR_ATTACHMENT_ENDPOINTS.GET_BY_ID(id), {
14783
+ params: apiOptions,
14784
+ });
14785
+ // Transform response from PascalCase to camelCase, then apply field maps
14786
+ const camelCased = pascalToCamelCaseKeys(response.data);
14787
+ camelCased.blobFileAccess = transformData(camelCased.blobFileAccess, BucketMap);
14788
+ return transformData(camelCased, AttachmentsMap);
14789
+ }
14790
+ }
14791
+ __decorate([
14792
+ track('Attachments.GetById')
14793
+ ], AttachmentService.prototype, "getById", null);
14794
+
14737
14795
  /**
14738
14796
  * Service for interacting with UiPath Orchestrator Jobs API
14739
14797
  */
14740
14798
  class JobService extends FolderScopedService {
14741
14799
  /**
14742
- * Gets all jobs across folders with optional filtering
14800
+ * Creates an instance of the Jobs service.
14743
14801
  *
14744
- * @param options - Query options including optional folderId and pagination options
14745
- * @returns Promise resolving to array of jobs or paginated response
14802
+ * @param instance - UiPath SDK instance providing authentication and configuration
14803
+ */
14804
+ constructor(instance) {
14805
+ super(instance);
14806
+ this.attachmentService = new AttachmentService(instance);
14807
+ }
14808
+ /**
14809
+ * Gets all jobs across folders with optional filtering and pagination.
14746
14810
  *
14747
- * @example
14748
- * ```typescript
14749
- * import { Jobs } from '@uipath/uipath-typescript/jobs';
14811
+ * Returns jobs with full details including state, timing, and input/output arguments.
14812
+ * Pass `folderId` to scope the query to a specific folder.
14750
14813
  *
14751
- * const jobs = new Jobs(sdk);
14814
+ * !!! info "Input and output fields are not included in `getAll` responses"
14815
+ * 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`.
14752
14816
  *
14817
+ * @param options - Query options including optional folderId, filtering, and pagination options
14818
+ * @returns Promise resolving to either an array of jobs {@link NonPaginatedResponse}<{@link JobGetResponse}> or a {@link PaginatedResponse}<{@link JobGetResponse}> when pagination options are used.
14819
+ * {@link JobGetResponse}
14820
+ * @example
14821
+ * ```typescript
14753
14822
  * // Get all jobs
14754
14823
  * const allJobs = await jobs.getAll();
14755
14824
  *
14756
14825
  * // Get all jobs in a specific folder
14757
- * const folderJobs = await jobs.getAll({ folderId: 123 });
14826
+ * const folderJobs = await jobs.getAll({ folderId: <folderId> });
14758
14827
  *
14759
14828
  * // With filtering
14760
14829
  * const runningJobs = await jobs.getAll({
@@ -14768,10 +14837,19 @@
14768
14837
  * if (page1.hasNextPage) {
14769
14838
  * const page2 = await jobs.getAll({ cursor: page1.nextCursor });
14770
14839
  * }
14840
+ *
14841
+ * // Jump to specific page
14842
+ * const page5 = await jobs.getAll({
14843
+ * jumpToPage: 5,
14844
+ * pageSize: 10
14845
+ * });
14771
14846
  * ```
14772
14847
  */
14773
14848
  async getAll(options) {
14774
- const transformJobResponse = (job) => transformData(pascalToCamelCaseKeys(job), JobMap);
14849
+ const transformJobResponse = (job) => {
14850
+ const rawJob = transformData(pascalToCamelCaseKeys(job), JobMap);
14851
+ return createJobWithMethods(rawJob, this);
14852
+ };
14775
14853
  return PaginationHelpers.getAll({
14776
14854
  serviceAccess: this.createPaginationServiceAccess(),
14777
14855
  getEndpoint: () => JOB_ENDPOINTS.GET_ALL,
@@ -14789,10 +14867,111 @@
14789
14867
  },
14790
14868
  }, options);
14791
14869
  }
14870
+ /**
14871
+ * Gets the output of a completed job.
14872
+ *
14873
+ * Retrieves the job's output arguments, handling both inline output (stored directly on the job
14874
+ * as a JSON string in `outputArguments`) and file-based output (stored as a blob attachment for
14875
+ * large outputs). Returns the parsed JSON output or `null` if the job has no output.
14876
+ *
14877
+ * @param jobKey - The unique key (GUID) of the job to retrieve output from
14878
+ * @param folderId - The folder ID where the job resides
14879
+ * @returns Promise resolving to the parsed output as `Record<string, unknown>`, or `null` if no output exists
14880
+ *
14881
+ * @example
14882
+ * ```typescript
14883
+ * // Get output from a completed job
14884
+ * const output = await jobs.getOutput(<jobKey>, <folderId>);
14885
+ *
14886
+ * if (output) {
14887
+ * console.log('Job output:', output);
14888
+ * }
14889
+ * ```
14890
+ *
14891
+ * @example
14892
+ * ```typescript
14893
+ * // Get output using bound method (jobKey and folderId are taken from the job object)
14894
+ * const allJobs = await jobs.getAll();
14895
+ * const completedJob = allJobs.items.find(j => j.state === JobState.Successful);
14896
+ *
14897
+ * if (completedJob) {
14898
+ * const output = await completedJob.getOutput();
14899
+ * }
14900
+ * ```
14901
+ */
14902
+ async getOutput(jobKey, folderId) {
14903
+ if (!jobKey) {
14904
+ throw new ValidationError({ message: 'jobKey is required for getOutput' });
14905
+ }
14906
+ const job = await this.fetchJobByKey(jobKey, folderId);
14907
+ if (job.OutputArguments) {
14908
+ try {
14909
+ return JSON.parse(job.OutputArguments);
14910
+ }
14911
+ catch {
14912
+ throw new ServerError({ message: 'Failed to parse job output arguments as JSON' });
14913
+ }
14914
+ }
14915
+ if (job.OutputFile) {
14916
+ return this.downloadOutputFile(job.OutputFile);
14917
+ }
14918
+ return null;
14919
+ }
14920
+ /**
14921
+ * Fetches a job by its Key (GUID) using the GetByKey endpoint.
14922
+ * Only selects fields needed for output extraction.
14923
+ */
14924
+ async fetchJobByKey(jobKey, folderId) {
14925
+ const headers = createHeaders({ [FOLDER_ID]: folderId });
14926
+ const response = await this.get(JOB_ENDPOINTS.GET_BY_KEY(jobKey), {
14927
+ params: {
14928
+ $select: 'OutputArguments,OutputFile',
14929
+ },
14930
+ headers,
14931
+ });
14932
+ return response.data;
14933
+ }
14934
+ /**
14935
+ * Downloads the output file content via the Attachments API.
14936
+ * 1. Fetches blob access info from the attachment using AttachmentService
14937
+ * 2. Downloads content from the presigned blob URI
14938
+ * 3. Parses and returns the JSON content
14939
+ */
14940
+ async downloadOutputFile(outputFileKey) {
14941
+ const attachment = await this.attachmentService.getById(outputFileKey);
14942
+ const blobAccess = attachment.blobFileAccess;
14943
+ if (!blobAccess?.uri) {
14944
+ return null;
14945
+ }
14946
+ const blobHeaders = { ...blobAccess.headers };
14947
+ // Add auth header if the blob URI requires authenticated access
14948
+ if (blobAccess.requiresAuth) {
14949
+ const token = await this.getValidAuthToken();
14950
+ blobHeaders['Authorization'] = `Bearer ${token}`;
14951
+ }
14952
+ const blobResponse = await fetch(blobAccess.uri, {
14953
+ method: 'GET',
14954
+ headers: blobHeaders,
14955
+ });
14956
+ if (!blobResponse.ok) {
14957
+ const errorInfo = await errorResponseParser.parse(blobResponse);
14958
+ throw ErrorFactory.createFromHttpStatus(blobResponse.status, errorInfo);
14959
+ }
14960
+ const content = await blobResponse.text();
14961
+ try {
14962
+ return JSON.parse(content);
14963
+ }
14964
+ catch {
14965
+ throw new ServerError({ message: 'Failed to parse job output file as JSON' });
14966
+ }
14967
+ }
14792
14968
  }
14793
14969
  __decorate([
14794
14970
  track('Jobs.GetAll')
14795
14971
  ], JobService.prototype, "getAll", null);
14972
+ __decorate([
14973
+ track('Jobs.GetOutput')
14974
+ ], JobService.prototype, "getOutput", null);
14796
14975
 
14797
14976
  /**
14798
14977
  * Enum for job sub-state
@@ -14819,6 +14998,22 @@
14819
14998
  ServerlessJobType["PythonAgent"] = "PythonAgent";
14820
14999
  })(exports.ServerlessJobType || (exports.ServerlessJobType = {}));
14821
15000
 
15001
+ /**
15002
+ * Common enum for job state used across services
15003
+ */
15004
+ exports.JobState = void 0;
15005
+ (function (JobState) {
15006
+ JobState["Pending"] = "Pending";
15007
+ JobState["Running"] = "Running";
15008
+ JobState["Stopping"] = "Stopping";
15009
+ JobState["Terminating"] = "Terminating";
15010
+ JobState["Faulted"] = "Faulted";
15011
+ JobState["Successful"] = "Successful";
15012
+ JobState["Stopped"] = "Stopped";
15013
+ JobState["Suspended"] = "Suspended";
15014
+ JobState["Resumed"] = "Resumed";
15015
+ })(exports.JobState || (exports.JobState = {}));
15016
+
14822
15017
  /**
14823
15018
  * Maps fields for Process entities to ensure consistent naming
14824
15019
  */
@@ -15275,49 +15470,6 @@
15275
15470
  track('Queues.GetById')
15276
15471
  ], QueueService.prototype, "getById", null);
15277
15472
 
15278
- /**
15279
- * Maps fields for Attachment entities to ensure consistent naming
15280
- */
15281
- const AttachmentsMap = {
15282
- creationTime: 'createdTime',
15283
- lastModificationTime: 'lastModifiedTime'
15284
- };
15285
-
15286
- class AttachmentService extends BaseService {
15287
- /**
15288
- * Gets an attachment by ID
15289
- * @param id - The UUID of the attachment to retrieve
15290
- * @param options - Optional query parameters (expand, select)
15291
- * @returns Promise resolving to the attachment
15292
- *
15293
- * @example
15294
- * ```typescript
15295
- * import { Attachments } from '@uipath/uipath-typescript/attachments';
15296
- *
15297
- * const attachments = new Attachments(sdk);
15298
- * const attachment = await attachments.getById('12345678-1234-1234-1234-123456789abc');
15299
- * ```
15300
- */
15301
- async getById(id, options = {}) {
15302
- if (!id) {
15303
- throw new ValidationError({ message: 'id is required for getById' });
15304
- }
15305
- // Prefix all keys in options with $ for OData
15306
- const keysToPrefix = Object.keys(options);
15307
- const apiOptions = addPrefixToKeys(options, ODATA_PREFIX, keysToPrefix);
15308
- const response = await this.get(ORCHESTRATOR_ATTACHMENT_ENDPOINTS.GET_BY_ID(id), {
15309
- params: apiOptions,
15310
- });
15311
- // Transform response from PascalCase to camelCase, then apply field maps
15312
- const camelCased = pascalToCamelCaseKeys(response.data);
15313
- camelCased.blobFileAccess = transformData(camelCased.blobFileAccess, BucketMap);
15314
- return transformData(camelCased, AttachmentsMap);
15315
- }
15316
- }
15317
- __decorate([
15318
- track('Attachments.GetById')
15319
- ], AttachmentService.prototype, "getById", null);
15320
-
15321
15473
  /**
15322
15474
  * UiPath SDK - Legacy class providing all services through property getters.
15323
15475
  *
@@ -15433,22 +15585,6 @@
15433
15585
  }
15434
15586
  }
15435
15587
 
15436
- /**
15437
- * Common enum for job state used across services
15438
- */
15439
- exports.JobState = void 0;
15440
- (function (JobState) {
15441
- JobState["Pending"] = "Pending";
15442
- JobState["Running"] = "Running";
15443
- JobState["Stopping"] = "Stopping";
15444
- JobState["Terminating"] = "Terminating";
15445
- JobState["Faulted"] = "Faulted";
15446
- JobState["Successful"] = "Successful";
15447
- JobState["Stopped"] = "Stopped";
15448
- JobState["Suspended"] = "Suspended";
15449
- JobState["Resumed"] = "Resumed";
15450
- })(exports.JobState || (exports.JobState = {}));
15451
-
15452
15588
  /**
15453
15589
  * Common Constants for Conversational Agent
15454
15590
  */
@@ -15821,6 +15957,7 @@
15821
15957
  exports.createCaseInstanceWithMethods = createCaseInstanceWithMethods;
15822
15958
  exports.createConversationWithMethods = createConversationWithMethods;
15823
15959
  exports.createEntityWithMethods = createEntityWithMethods;
15960
+ exports.createJobWithMethods = createJobWithMethods;
15824
15961
  exports.createProcessInstanceWithMethods = createProcessInstanceWithMethods;
15825
15962
  exports.createProcessWithMethods = createProcessWithMethods;
15826
15963
  exports.createTaskWithMethods = createTaskWithMethods;