@uipath/uipath-typescript 1.1.2 → 1.2.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/assets/index.cjs +12 -6
- package/dist/assets/index.mjs +12 -6
- package/dist/buckets/index.cjs +12 -6
- package/dist/buckets/index.mjs +12 -6
- package/dist/cases/index.cjs +12 -6
- package/dist/cases/index.mjs +12 -6
- package/dist/conversational-agent/index.cjs +12 -6
- package/dist/conversational-agent/index.mjs +12 -6
- package/dist/core/index.cjs +269 -84
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.mjs +269 -84
- package/dist/entities/index.cjs +121 -23
- package/dist/entities/index.d.ts +188 -26
- package/dist/entities/index.mjs +121 -23
- package/dist/index.cjs +389 -106
- package/dist/index.d.ts +188 -26
- package/dist/index.mjs +389 -106
- package/dist/index.umd.js +389 -106
- package/dist/maestro-processes/index.cjs +12 -6
- package/dist/maestro-processes/index.mjs +12 -6
- package/dist/processes/index.cjs +12 -6
- package/dist/processes/index.mjs +12 -6
- package/dist/queues/index.cjs +12 -6
- package/dist/queues/index.mjs +12 -6
- package/dist/tasks/index.cjs +12 -6
- package/dist/tasks/index.mjs +12 -6
- package/package.json +2 -2
package/dist/entities/index.mjs
CHANGED
|
@@ -544,11 +544,8 @@ class ApiClient {
|
|
|
544
544
|
return this.tokenManager.getValidToken();
|
|
545
545
|
}
|
|
546
546
|
async getDefaultHeaders() {
|
|
547
|
-
// Get headers from execution context first
|
|
548
|
-
const contextHeaders = this.executionContext.getHeaders();
|
|
549
547
|
const token = await this.getValidToken();
|
|
550
548
|
return {
|
|
551
|
-
...contextHeaders,
|
|
552
549
|
'Authorization': `Bearer ${token}`,
|
|
553
550
|
'Content-Type': CONTENT_TYPES.JSON,
|
|
554
551
|
...this.defaultHeaders,
|
|
@@ -560,8 +557,13 @@ class ApiClient {
|
|
|
560
557
|
const normalizedPath = path.startsWith('/') ? path.substring(1) : path;
|
|
561
558
|
// Construct URL with org and tenant names
|
|
562
559
|
const url = new URL(`${this.config.orgName}/${this.config.tenantName}/${normalizedPath}`, this.config.baseUrl).toString();
|
|
560
|
+
const isFormData = options.body instanceof FormData;
|
|
561
|
+
const defaultHeaders = await this.getDefaultHeaders();
|
|
562
|
+
if (isFormData) {
|
|
563
|
+
delete defaultHeaders['Content-Type'];
|
|
564
|
+
}
|
|
563
565
|
const headers = {
|
|
564
|
-
...
|
|
566
|
+
...defaultHeaders,
|
|
565
567
|
...options.headers
|
|
566
568
|
};
|
|
567
569
|
// Convert params to URLSearchParams
|
|
@@ -572,11 +574,15 @@ class ApiClient {
|
|
|
572
574
|
});
|
|
573
575
|
}
|
|
574
576
|
const fullUrl = searchParams.toString() ? `${url}?${searchParams.toString()}` : url;
|
|
577
|
+
let body = undefined;
|
|
578
|
+
if (options.body) {
|
|
579
|
+
body = isFormData ? options.body : JSON.stringify(options.body);
|
|
580
|
+
}
|
|
575
581
|
try {
|
|
576
582
|
const response = await fetch(fullUrl, {
|
|
577
583
|
method,
|
|
578
584
|
headers,
|
|
579
|
-
body
|
|
585
|
+
body,
|
|
580
586
|
signal: options.signal
|
|
581
587
|
});
|
|
582
588
|
if (!response.ok) {
|
|
@@ -1664,13 +1670,19 @@ function createEntityMethods(entityData, service) {
|
|
|
1664
1670
|
return service.getRecordById(entityData.id, recordId, options);
|
|
1665
1671
|
},
|
|
1666
1672
|
async downloadAttachment(recordId, fieldName) {
|
|
1667
|
-
if (!entityData.
|
|
1668
|
-
throw new Error('Entity
|
|
1669
|
-
return service.downloadAttachment(
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1673
|
+
if (!entityData.id)
|
|
1674
|
+
throw new Error('Entity ID is undefined');
|
|
1675
|
+
return service.downloadAttachment(entityData.id, recordId, fieldName);
|
|
1676
|
+
},
|
|
1677
|
+
async uploadAttachment(recordId, fieldName, file, options) {
|
|
1678
|
+
if (!entityData.id)
|
|
1679
|
+
throw new Error('Entity ID is undefined');
|
|
1680
|
+
return service.uploadAttachment(entityData.id, recordId, fieldName, file, options);
|
|
1681
|
+
},
|
|
1682
|
+
async deleteAttachment(recordId, fieldName) {
|
|
1683
|
+
if (!entityData.id)
|
|
1684
|
+
throw new Error('Entity ID is undefined');
|
|
1685
|
+
return service.deleteAttachment(entityData.id, recordId, fieldName);
|
|
1674
1686
|
},
|
|
1675
1687
|
async insert(data, options) {
|
|
1676
1688
|
return this.insertRecord(data, options);
|
|
@@ -1722,7 +1734,9 @@ const DATA_FABRIC_ENDPOINTS = {
|
|
|
1722
1734
|
BATCH_INSERT_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/insert-batch`,
|
|
1723
1735
|
UPDATE_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/update-batch`,
|
|
1724
1736
|
DELETE_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/delete-batch`,
|
|
1725
|
-
DOWNLOAD_ATTACHMENT: (
|
|
1737
|
+
DOWNLOAD_ATTACHMENT: (entityId, recordId, fieldName) => `${DATAFABRIC_BASE}/api/Attachment/entity/${entityId}/${recordId}/${fieldName}`,
|
|
1738
|
+
UPLOAD_ATTACHMENT: (entityId, recordId, fieldName) => `${DATAFABRIC_BASE}/api/Attachment/entity/${entityId}/${recordId}/${fieldName}`,
|
|
1739
|
+
DELETE_ATTACHMENT: (entityId, recordId, fieldName) => `${DATAFABRIC_BASE}/api/Attachment/entity/${entityId}/${recordId}/${fieldName}`,
|
|
1726
1740
|
},
|
|
1727
1741
|
CHOICESETS: {
|
|
1728
1742
|
GET_ALL: `${DATAFABRIC_BASE}/api/Entity/choiceset`,
|
|
@@ -1879,7 +1893,7 @@ const EntityFieldTypeMap = {
|
|
|
1879
1893
|
// Connection string placeholder that will be replaced during build
|
|
1880
1894
|
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";
|
|
1881
1895
|
// SDK Version placeholder
|
|
1882
|
-
const SDK_VERSION = "1.
|
|
1896
|
+
const SDK_VERSION = "1.2.0";
|
|
1883
1897
|
const VERSION = "Version";
|
|
1884
1898
|
const SERVICE = "Service";
|
|
1885
1899
|
const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
|
|
@@ -2455,7 +2469,9 @@ class EntityService extends BaseService {
|
|
|
2455
2469
|
/**
|
|
2456
2470
|
* Downloads an attachment from an entity record field
|
|
2457
2471
|
*
|
|
2458
|
-
* @param
|
|
2472
|
+
* @param entityId - UUID of the entity
|
|
2473
|
+
* @param recordId - UUID of the record containing the attachment
|
|
2474
|
+
* @param fieldName - Name of the File-type field containing the attachment
|
|
2459
2475
|
* @returns Promise resolving to Blob containing the file content
|
|
2460
2476
|
*
|
|
2461
2477
|
* @example
|
|
@@ -2464,20 +2480,96 @@ class EntityService extends BaseService {
|
|
|
2464
2480
|
*
|
|
2465
2481
|
* const entities = new Entities(sdk);
|
|
2466
2482
|
*
|
|
2483
|
+
* // Get the entityId from getAll()
|
|
2484
|
+
* const allEntities = await entities.getAll();
|
|
2485
|
+
* const entityId = allEntities[0].id;
|
|
2486
|
+
*
|
|
2487
|
+
* // Get the recordId from getAllRecords()
|
|
2488
|
+
* const records = await entities.getAllRecords(entityId);
|
|
2489
|
+
* const recordId = records[0].id;
|
|
2490
|
+
*
|
|
2467
2491
|
* // Download attachment for a specific record and field
|
|
2468
|
-
* const blob = await entities.downloadAttachment(
|
|
2469
|
-
*
|
|
2470
|
-
* recordId: '<record-uuid>',
|
|
2471
|
-
* fieldName: 'Documents'
|
|
2472
|
-
* });
|
|
2492
|
+
* const blob = await entities.downloadAttachment(entityId, recordId, 'Documents');
|
|
2493
|
+
* ```
|
|
2473
2494
|
*/
|
|
2474
|
-
async downloadAttachment(
|
|
2475
|
-
const
|
|
2476
|
-
const response = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.DOWNLOAD_ATTACHMENT(entityName, recordId, fieldName), {
|
|
2495
|
+
async downloadAttachment(entityId, recordId, fieldName) {
|
|
2496
|
+
const response = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.DOWNLOAD_ATTACHMENT(entityId, recordId, fieldName), {
|
|
2477
2497
|
responseType: RESPONSE_TYPES.BLOB
|
|
2478
2498
|
});
|
|
2479
2499
|
return response.data;
|
|
2480
2500
|
}
|
|
2501
|
+
/**
|
|
2502
|
+
* Uploads an attachment to a File-type field of an entity record
|
|
2503
|
+
*
|
|
2504
|
+
* @param entityId - UUID of the entity
|
|
2505
|
+
* @param recordId - UUID of the record to upload the attachment to
|
|
2506
|
+
* @param fieldName - Name of the File-type field
|
|
2507
|
+
* @param file - File to upload (Blob, File, or Uint8Array)
|
|
2508
|
+
* @param options - Optional {@link EntityUploadAttachmentOptions} (e.g. expansionLevel)
|
|
2509
|
+
* @returns Promise resolving to {@link EntityUploadAttachmentResponse}
|
|
2510
|
+
*
|
|
2511
|
+
* @example
|
|
2512
|
+
* ```typescript
|
|
2513
|
+
* import { Entities } from '@uipath/uipath-typescript/entities';
|
|
2514
|
+
*
|
|
2515
|
+
* const entities = new Entities(sdk);
|
|
2516
|
+
*
|
|
2517
|
+
* // Get the entityId from getAll()
|
|
2518
|
+
* const allEntities = await entities.getAll();
|
|
2519
|
+
* const entityId = allEntities[0].id;
|
|
2520
|
+
*
|
|
2521
|
+
* // Get the recordId from getAllRecords()
|
|
2522
|
+
* const records = await entities.getAllRecords(entityId);
|
|
2523
|
+
* const recordId = records[0].id;
|
|
2524
|
+
*
|
|
2525
|
+
* // Upload a file attachment
|
|
2526
|
+
* const response = await entities.uploadAttachment(entityId, recordId, 'Documents', file);
|
|
2527
|
+
* ```
|
|
2528
|
+
*/
|
|
2529
|
+
async uploadAttachment(entityId, recordId, fieldName, file, options) {
|
|
2530
|
+
const formData = new FormData();
|
|
2531
|
+
if (file instanceof Uint8Array) {
|
|
2532
|
+
formData.append('file', new Blob([file.buffer]));
|
|
2533
|
+
}
|
|
2534
|
+
else {
|
|
2535
|
+
formData.append('file', file);
|
|
2536
|
+
}
|
|
2537
|
+
const params = createParams({ expansionLevel: options?.expansionLevel });
|
|
2538
|
+
const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPLOAD_ATTACHMENT(entityId, recordId, fieldName), formData, { params });
|
|
2539
|
+
// Convert PascalCase response to camelCase
|
|
2540
|
+
const camelResponse = pascalToCamelCaseKeys(response.data);
|
|
2541
|
+
return camelResponse;
|
|
2542
|
+
}
|
|
2543
|
+
/**
|
|
2544
|
+
* Removes an attachment from a File-type field of an entity record
|
|
2545
|
+
*
|
|
2546
|
+
* @param entityId - UUID of the entity
|
|
2547
|
+
* @param recordId - UUID of the record containing the attachment
|
|
2548
|
+
* @param fieldName - Name of the File-type field containing the attachment
|
|
2549
|
+
* @returns Promise resolving to {@link EntityDeleteAttachmentResponse}
|
|
2550
|
+
*
|
|
2551
|
+
* @example
|
|
2552
|
+
* ```typescript
|
|
2553
|
+
* import { Entities } from '@uipath/uipath-typescript/entities';
|
|
2554
|
+
*
|
|
2555
|
+
* const entities = new Entities(sdk);
|
|
2556
|
+
*
|
|
2557
|
+
* // Get the entityId from getAll()
|
|
2558
|
+
* const allEntities = await entities.getAll();
|
|
2559
|
+
* const entityId = allEntities[0].id;
|
|
2560
|
+
*
|
|
2561
|
+
* // Get the recordId from getAllRecords()
|
|
2562
|
+
* const records = await entities.getAllRecords(entityId);
|
|
2563
|
+
* const recordId = records[0].id;
|
|
2564
|
+
*
|
|
2565
|
+
* // Delete attachment for a specific record and field
|
|
2566
|
+
* await entities.deleteAttachment(entityId, recordId, 'Documents');
|
|
2567
|
+
* ```
|
|
2568
|
+
*/
|
|
2569
|
+
async deleteAttachment(entityId, recordId, fieldName) {
|
|
2570
|
+
const response = await this.delete(DATA_FABRIC_ENDPOINTS.ENTITY.DELETE_ATTACHMENT(entityId, recordId, fieldName));
|
|
2571
|
+
return response.data;
|
|
2572
|
+
}
|
|
2481
2573
|
/**
|
|
2482
2574
|
* @hidden
|
|
2483
2575
|
* @deprecated Use {@link getAllRecords} instead.
|
|
@@ -2611,6 +2703,12 @@ __decorate([
|
|
|
2611
2703
|
__decorate([
|
|
2612
2704
|
track('Entities.DownloadAttachment')
|
|
2613
2705
|
], EntityService.prototype, "downloadAttachment", null);
|
|
2706
|
+
__decorate([
|
|
2707
|
+
track('Entities.UploadAttachment')
|
|
2708
|
+
], EntityService.prototype, "uploadAttachment", null);
|
|
2709
|
+
__decorate([
|
|
2710
|
+
track('Entities.DeleteAttachment')
|
|
2711
|
+
], EntityService.prototype, "deleteAttachment", null);
|
|
2614
2712
|
|
|
2615
2713
|
class ChoiceSetService extends BaseService {
|
|
2616
2714
|
/**
|