@uipath/uipath-typescript 1.1.1 → 1.1.3
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 +13 -12
- package/dist/assets/index.mjs +13 -12
- package/dist/buckets/index.cjs +13 -12
- package/dist/buckets/index.mjs +13 -12
- package/dist/cases/index.cjs +13 -12
- package/dist/cases/index.mjs +13 -12
- package/dist/conversational-agent/index.cjs +13 -12
- package/dist/conversational-agent/index.mjs +13 -12
- package/dist/core/index.cjs +309 -69
- package/dist/core/index.d.ts +17 -9
- package/dist/core/index.mjs +309 -69
- package/dist/entities/index.cjs +64 -12
- package/dist/entities/index.d.ts +94 -1
- package/dist/entities/index.mjs +64 -12
- package/dist/index.cjs +449 -80
- package/dist/index.d.ts +192 -11
- package/dist/index.mjs +447 -81
- package/dist/index.umd.js +449 -80
- package/dist/maestro-processes/index.cjs +13 -12
- package/dist/maestro-processes/index.mjs +13 -12
- package/dist/processes/index.cjs +13 -12
- package/dist/processes/index.mjs +13 -12
- package/dist/queues/index.cjs +13 -12
- package/dist/queues/index.mjs +13 -12
- package/dist/tasks/index.cjs +13 -12
- package/dist/tasks/index.mjs +13 -12
- package/package.json +1 -1
package/dist/entities/index.d.ts
CHANGED
|
@@ -400,6 +400,31 @@ interface EntityDownloadAttachmentOptions {
|
|
|
400
400
|
/** Field name containing the attachment */
|
|
401
401
|
fieldName: string;
|
|
402
402
|
}
|
|
403
|
+
/**
|
|
404
|
+
* Options for uploading an attachment to an entity record
|
|
405
|
+
*/
|
|
406
|
+
interface EntityUploadAttachmentOptions {
|
|
407
|
+
/** Entity name */
|
|
408
|
+
entityName: string;
|
|
409
|
+
/** Record ID (UUID) */
|
|
410
|
+
recordId: string;
|
|
411
|
+
/** Field name of the File-type field */
|
|
412
|
+
fieldName: string;
|
|
413
|
+
/**
|
|
414
|
+
* File to upload. Accepts the native types supported by FormData:
|
|
415
|
+
* - `Blob` / `File`: standard browser and Node.js ≥ 18 types accepted directly by FormData.
|
|
416
|
+
* `File` is a subclass of `Blob` and is typically obtained from a browser file input.
|
|
417
|
+
* - `Uint8Array`: raw binary buffer (e.g. from `fs.readFileSync` or a Node.js Buffer).
|
|
418
|
+
* Converted to a `Blob` internally before appending to FormData.
|
|
419
|
+
*/
|
|
420
|
+
file: Blob | File | Uint8Array;
|
|
421
|
+
/** Optional expansion level (default: 0) */
|
|
422
|
+
expansionLevel?: number;
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* Response from uploading an attachment to an entity record
|
|
426
|
+
*/
|
|
427
|
+
type EntityUploadAttachmentResponse = Record<string, unknown>;
|
|
403
428
|
/**
|
|
404
429
|
* Represents a failure record in an entity operation
|
|
405
430
|
*/
|
|
@@ -920,6 +945,42 @@ interface EntityServiceModel {
|
|
|
920
945
|
* ```
|
|
921
946
|
*/
|
|
922
947
|
downloadAttachment(options: EntityDownloadAttachmentOptions): Promise<Blob>;
|
|
948
|
+
/**
|
|
949
|
+
* Uploads an attachment to a File-type field of an entity record.
|
|
950
|
+
*
|
|
951
|
+
* Uses multipart/form-data to upload the file content to the specified field.
|
|
952
|
+
*
|
|
953
|
+
* @param options - Options containing entityName, recordId, fieldName, file, and optional expansionLevel
|
|
954
|
+
* @returns Promise resolving to the upload response
|
|
955
|
+
* {@link EntityUploadAttachmentResponse}
|
|
956
|
+
* @example
|
|
957
|
+
* ```typescript
|
|
958
|
+
* import { Entities } from '@uipath/uipath-typescript/entities';
|
|
959
|
+
*
|
|
960
|
+
* const entities = new Entities(sdk);
|
|
961
|
+
*
|
|
962
|
+
* // Browser: Upload a file from an input element
|
|
963
|
+
* const fileInput = document.getElementById('file-input') as HTMLInputElement;
|
|
964
|
+
* const file = fileInput.files[0];
|
|
965
|
+
* const response = await entities.uploadAttachment({
|
|
966
|
+
* entityName: 'Invoice',
|
|
967
|
+
* recordId: '<recordId>',
|
|
968
|
+
* fieldName: 'Documents',
|
|
969
|
+
* file: file
|
|
970
|
+
* });
|
|
971
|
+
*
|
|
972
|
+
* // Node.js: Upload a file from disk
|
|
973
|
+
* const fileBuffer = fs.readFileSync('document.pdf');
|
|
974
|
+
* const blob = new Blob([fileBuffer], { type: 'application/pdf' });
|
|
975
|
+
* const response = await entities.uploadAttachment({
|
|
976
|
+
* entityName: 'Invoice',
|
|
977
|
+
* recordId: '<recordId>',
|
|
978
|
+
* fieldName: 'Documents',
|
|
979
|
+
* file: blob
|
|
980
|
+
* });
|
|
981
|
+
* ```
|
|
982
|
+
*/
|
|
983
|
+
uploadAttachment(options: EntityUploadAttachmentOptions): Promise<EntityUploadAttachmentResponse>;
|
|
923
984
|
}
|
|
924
985
|
/**
|
|
925
986
|
* Entity methods interface - defines operations that can be performed on an entity
|
|
@@ -987,6 +1048,16 @@ interface EntityMethods {
|
|
|
987
1048
|
* @returns Promise resolving to Blob containing the file content
|
|
988
1049
|
*/
|
|
989
1050
|
downloadAttachment(recordId: string, fieldName: string): Promise<Blob>;
|
|
1051
|
+
/**
|
|
1052
|
+
* Uploads an attachment to a File-type field of an entity record
|
|
1053
|
+
*
|
|
1054
|
+
* @param recordId - UUID of the record to upload the attachment to
|
|
1055
|
+
* @param fieldName - Name of the File-type field
|
|
1056
|
+
* @param file - File to upload (Blob, File, or Uint8Array)
|
|
1057
|
+
* @param expansionLevel - Optional expansion level (default: 0)
|
|
1058
|
+
* @returns Promise resolving to the upload response
|
|
1059
|
+
*/
|
|
1060
|
+
uploadAttachment(recordId: string, fieldName: string, file: Blob | File | Uint8Array, expansionLevel?: number): Promise<EntityUploadAttachmentResponse>;
|
|
990
1061
|
/**
|
|
991
1062
|
* @deprecated Use {@link insertRecord} instead.
|
|
992
1063
|
* @hidden
|
|
@@ -1259,6 +1330,28 @@ declare class EntityService extends BaseService implements EntityServiceModel {
|
|
|
1259
1330
|
* });
|
|
1260
1331
|
*/
|
|
1261
1332
|
downloadAttachment(options: EntityDownloadAttachmentOptions): Promise<Blob>;
|
|
1333
|
+
/**
|
|
1334
|
+
* Uploads an attachment to a File-type field of an entity record
|
|
1335
|
+
*
|
|
1336
|
+
* @param options - Options containing entityName, recordId, fieldName, file, and optional expansionLevel
|
|
1337
|
+
* @returns Promise resolving to the upload response
|
|
1338
|
+
*
|
|
1339
|
+
* @example
|
|
1340
|
+
* ```typescript
|
|
1341
|
+
* import { Entities } from '@uipath/uipath-typescript/entities';
|
|
1342
|
+
*
|
|
1343
|
+
* const entities = new Entities(sdk);
|
|
1344
|
+
*
|
|
1345
|
+
* // Upload a file attachment
|
|
1346
|
+
* const response = await entities.uploadAttachment({
|
|
1347
|
+
* entityName: 'Invoice',
|
|
1348
|
+
* recordId: '<record-uuid>',
|
|
1349
|
+
* fieldName: 'Documents',
|
|
1350
|
+
* file: file
|
|
1351
|
+
* });
|
|
1352
|
+
* ```
|
|
1353
|
+
*/
|
|
1354
|
+
uploadAttachment(options: EntityUploadAttachmentOptions): Promise<EntityUploadAttachmentResponse>;
|
|
1262
1355
|
/**
|
|
1263
1356
|
* @hidden
|
|
1264
1357
|
* @deprecated Use {@link getAllRecords} instead.
|
|
@@ -1510,4 +1603,4 @@ declare class ChoiceSetService extends BaseService implements ChoiceSetServiceMo
|
|
|
1510
1603
|
}
|
|
1511
1604
|
|
|
1512
1605
|
export { ChoiceSetService, ChoiceSetService as ChoiceSets, DataDirectionType, EntityService as Entities, EntityFieldDataType, EntityService, EntityType, FieldDisplayType, JoinType, ReferenceType, createEntityWithMethods };
|
|
1513
|
-
export type { ChoiceSetGetAllResponse, ChoiceSetGetByIdOptions, ChoiceSetGetResponse, ChoiceSetServiceModel, EntityBatchInsertOptions, EntityBatchInsertResponse, EntityDeleteOptions, EntityDeleteRecordsOptions, EntityDeleteResponse, EntityDownloadAttachmentOptions, EntityGetAllRecordsOptions, EntityGetRecordByIdOptions, EntityGetRecordsByIdOptions, EntityGetResponse, EntityInsertOptions, EntityInsertRecordOptions, EntityInsertRecordsOptions, EntityInsertResponse, EntityMethods, EntityOperationOptions, EntityOperationResponse, EntityRecord, EntityServiceModel, EntityUpdateOptions, EntityUpdateRecordsOptions, EntityUpdateResponse, ExternalConnection, ExternalField, ExternalFieldMapping, ExternalObject, ExternalSourceFields, FailureRecord, Field, FieldDataType, FieldMetaData, RawEntityGetResponse, SourceJoinCriteria };
|
|
1606
|
+
export type { ChoiceSetGetAllResponse, ChoiceSetGetByIdOptions, ChoiceSetGetResponse, ChoiceSetServiceModel, EntityBatchInsertOptions, EntityBatchInsertResponse, EntityDeleteOptions, EntityDeleteRecordsOptions, EntityDeleteResponse, EntityDownloadAttachmentOptions, EntityGetAllRecordsOptions, EntityGetRecordByIdOptions, EntityGetRecordsByIdOptions, EntityGetResponse, EntityInsertOptions, EntityInsertRecordOptions, EntityInsertRecordsOptions, EntityInsertResponse, EntityMethods, EntityOperationOptions, EntityOperationResponse, EntityRecord, EntityServiceModel, EntityUpdateOptions, EntityUpdateRecordsOptions, EntityUpdateResponse, EntityUploadAttachmentOptions, EntityUploadAttachmentResponse, ExternalConnection, ExternalField, ExternalFieldMapping, ExternalObject, ExternalSourceFields, FailureRecord, Field, FieldDataType, FieldMetaData, RawEntityGetResponse, SourceJoinCriteria };
|
package/dist/entities/index.mjs
CHANGED
|
@@ -546,15 +546,6 @@ class ApiClient {
|
|
|
546
546
|
async getDefaultHeaders() {
|
|
547
547
|
// Get headers from execution context first
|
|
548
548
|
const contextHeaders = this.executionContext.getHeaders();
|
|
549
|
-
// If Authorization header is already set in context, use that
|
|
550
|
-
if (contextHeaders['Authorization']) {
|
|
551
|
-
return {
|
|
552
|
-
...contextHeaders,
|
|
553
|
-
'Content-Type': CONTENT_TYPES.JSON,
|
|
554
|
-
...this.defaultHeaders,
|
|
555
|
-
...this.clientConfig.headers
|
|
556
|
-
};
|
|
557
|
-
}
|
|
558
549
|
const token = await this.getValidToken();
|
|
559
550
|
return {
|
|
560
551
|
...contextHeaders,
|
|
@@ -569,8 +560,13 @@ class ApiClient {
|
|
|
569
560
|
const normalizedPath = path.startsWith('/') ? path.substring(1) : path;
|
|
570
561
|
// Construct URL with org and tenant names
|
|
571
562
|
const url = new URL(`${this.config.orgName}/${this.config.tenantName}/${normalizedPath}`, this.config.baseUrl).toString();
|
|
563
|
+
const isFormData = options.body instanceof FormData;
|
|
564
|
+
const defaultHeaders = await this.getDefaultHeaders();
|
|
565
|
+
if (isFormData) {
|
|
566
|
+
delete defaultHeaders['Content-Type'];
|
|
567
|
+
}
|
|
572
568
|
const headers = {
|
|
573
|
-
...
|
|
569
|
+
...defaultHeaders,
|
|
574
570
|
...options.headers
|
|
575
571
|
};
|
|
576
572
|
// Convert params to URLSearchParams
|
|
@@ -581,11 +577,15 @@ class ApiClient {
|
|
|
581
577
|
});
|
|
582
578
|
}
|
|
583
579
|
const fullUrl = searchParams.toString() ? `${url}?${searchParams.toString()}` : url;
|
|
580
|
+
let body = undefined;
|
|
581
|
+
if (options.body) {
|
|
582
|
+
body = isFormData ? options.body : JSON.stringify(options.body);
|
|
583
|
+
}
|
|
584
584
|
try {
|
|
585
585
|
const response = await fetch(fullUrl, {
|
|
586
586
|
method,
|
|
587
587
|
headers,
|
|
588
|
-
body
|
|
588
|
+
body,
|
|
589
589
|
signal: options.signal
|
|
590
590
|
});
|
|
591
591
|
if (!response.ok) {
|
|
@@ -681,6 +681,7 @@ function filterUndefined(obj) {
|
|
|
681
681
|
* Checks if code is running in a browser environment
|
|
682
682
|
*/
|
|
683
683
|
const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
684
|
+
isBrowser && window.self != window.top && window.location.href.includes('source=ActionCenter');
|
|
684
685
|
|
|
685
686
|
/**
|
|
686
687
|
* Base64 encoding/decoding
|
|
@@ -1680,6 +1681,17 @@ function createEntityMethods(entityData, service) {
|
|
|
1680
1681
|
fieldName
|
|
1681
1682
|
});
|
|
1682
1683
|
},
|
|
1684
|
+
async uploadAttachment(recordId, fieldName, file, expansionLevel) {
|
|
1685
|
+
if (!entityData.name)
|
|
1686
|
+
throw new Error('Entity name is undefined');
|
|
1687
|
+
return service.uploadAttachment({
|
|
1688
|
+
entityName: entityData.name,
|
|
1689
|
+
recordId,
|
|
1690
|
+
fieldName,
|
|
1691
|
+
file,
|
|
1692
|
+
expansionLevel
|
|
1693
|
+
});
|
|
1694
|
+
},
|
|
1683
1695
|
async insert(data, options) {
|
|
1684
1696
|
return this.insertRecord(data, options);
|
|
1685
1697
|
},
|
|
@@ -1731,6 +1743,7 @@ const DATA_FABRIC_ENDPOINTS = {
|
|
|
1731
1743
|
UPDATE_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/update-batch`,
|
|
1732
1744
|
DELETE_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/delete-batch`,
|
|
1733
1745
|
DOWNLOAD_ATTACHMENT: (entityName, recordId, fieldName) => `${DATAFABRIC_BASE}/api/Attachment/${entityName}/${recordId}/${fieldName}`,
|
|
1746
|
+
UPLOAD_ATTACHMENT: (entityName, recordId, fieldName) => `${DATAFABRIC_BASE}/api/Attachment/${entityName}/${recordId}/${fieldName}`,
|
|
1734
1747
|
},
|
|
1735
1748
|
CHOICESETS: {
|
|
1736
1749
|
GET_ALL: `${DATAFABRIC_BASE}/api/Entity/choiceset`,
|
|
@@ -1887,7 +1900,7 @@ const EntityFieldTypeMap = {
|
|
|
1887
1900
|
// Connection string placeholder that will be replaced during build
|
|
1888
1901
|
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";
|
|
1889
1902
|
// SDK Version placeholder
|
|
1890
|
-
const SDK_VERSION = "1.1.
|
|
1903
|
+
const SDK_VERSION = "1.1.3";
|
|
1891
1904
|
const VERSION = "Version";
|
|
1892
1905
|
const SERVICE = "Service";
|
|
1893
1906
|
const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
|
|
@@ -2486,6 +2499,42 @@ class EntityService extends BaseService {
|
|
|
2486
2499
|
});
|
|
2487
2500
|
return response.data;
|
|
2488
2501
|
}
|
|
2502
|
+
/**
|
|
2503
|
+
* Uploads an attachment to a File-type field of an entity record
|
|
2504
|
+
*
|
|
2505
|
+
* @param options - Options containing entityName, recordId, fieldName, file, and optional expansionLevel
|
|
2506
|
+
* @returns Promise resolving to the upload response
|
|
2507
|
+
*
|
|
2508
|
+
* @example
|
|
2509
|
+
* ```typescript
|
|
2510
|
+
* import { Entities } from '@uipath/uipath-typescript/entities';
|
|
2511
|
+
*
|
|
2512
|
+
* const entities = new Entities(sdk);
|
|
2513
|
+
*
|
|
2514
|
+
* // Upload a file attachment
|
|
2515
|
+
* const response = await entities.uploadAttachment({
|
|
2516
|
+
* entityName: 'Invoice',
|
|
2517
|
+
* recordId: '<record-uuid>',
|
|
2518
|
+
* fieldName: 'Documents',
|
|
2519
|
+
* file: file
|
|
2520
|
+
* });
|
|
2521
|
+
* ```
|
|
2522
|
+
*/
|
|
2523
|
+
async uploadAttachment(options) {
|
|
2524
|
+
const { entityName, recordId, fieldName, file, expansionLevel } = options;
|
|
2525
|
+
const formData = new FormData();
|
|
2526
|
+
if (file instanceof Uint8Array) {
|
|
2527
|
+
formData.append('file', new Blob([file.buffer]));
|
|
2528
|
+
}
|
|
2529
|
+
else {
|
|
2530
|
+
formData.append('file', file);
|
|
2531
|
+
}
|
|
2532
|
+
const params = createParams({ expansionLevel });
|
|
2533
|
+
const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPLOAD_ATTACHMENT(entityName, recordId, fieldName), formData, { params });
|
|
2534
|
+
// Convert PascalCase response to camelCase
|
|
2535
|
+
const camelResponse = pascalToCamelCaseKeys(response.data);
|
|
2536
|
+
return camelResponse;
|
|
2537
|
+
}
|
|
2489
2538
|
/**
|
|
2490
2539
|
* @hidden
|
|
2491
2540
|
* @deprecated Use {@link getAllRecords} instead.
|
|
@@ -2619,6 +2668,9 @@ __decorate([
|
|
|
2619
2668
|
__decorate([
|
|
2620
2669
|
track('Entities.DownloadAttachment')
|
|
2621
2670
|
], EntityService.prototype, "downloadAttachment", null);
|
|
2671
|
+
__decorate([
|
|
2672
|
+
track('Entities.UploadAttachment')
|
|
2673
|
+
], EntityService.prototype, "uploadAttachment", null);
|
|
2622
2674
|
|
|
2623
2675
|
class ChoiceSetService extends BaseService {
|
|
2624
2676
|
/**
|