@uipath/uipath-typescript 1.3.0 → 1.3.1

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.
Files changed (41) hide show
  1. package/dist/assets/index.cjs +5 -8
  2. package/dist/assets/index.d.ts +3 -1
  3. package/dist/assets/index.mjs +5 -8
  4. package/dist/attachments/index.cjs +5 -8
  5. package/dist/attachments/index.d.ts +3 -1
  6. package/dist/attachments/index.mjs +5 -8
  7. package/dist/buckets/index.cjs +5 -8
  8. package/dist/buckets/index.d.ts +3 -1
  9. package/dist/buckets/index.mjs +5 -8
  10. package/dist/cases/index.cjs +5 -8
  11. package/dist/cases/index.d.ts +3 -1
  12. package/dist/cases/index.mjs +5 -8
  13. package/dist/conversational-agent/index.cjs +38 -16
  14. package/dist/conversational-agent/index.d.ts +26 -4
  15. package/dist/conversational-agent/index.mjs +38 -16
  16. package/dist/core/index.cjs +2 -2
  17. package/dist/core/index.d.ts +2 -2
  18. package/dist/core/index.mjs +2 -2
  19. package/dist/entities/index.cjs +680 -284
  20. package/dist/entities/index.d.ts +559 -45
  21. package/dist/entities/index.mjs +681 -285
  22. package/dist/index.cjs +515 -86
  23. package/dist/index.d.ts +604 -52
  24. package/dist/index.mjs +516 -87
  25. package/dist/index.umd.js +515 -86
  26. package/dist/jobs/index.cjs +57 -27
  27. package/dist/jobs/index.d.ts +70 -11
  28. package/dist/jobs/index.mjs +57 -27
  29. package/dist/maestro-processes/index.cjs +5 -8
  30. package/dist/maestro-processes/index.d.ts +3 -1
  31. package/dist/maestro-processes/index.mjs +5 -8
  32. package/dist/processes/index.cjs +5 -8
  33. package/dist/processes/index.d.ts +3 -1
  34. package/dist/processes/index.mjs +5 -8
  35. package/dist/queues/index.cjs +5 -8
  36. package/dist/queues/index.d.ts +3 -1
  37. package/dist/queues/index.mjs +5 -8
  38. package/dist/tasks/index.cjs +5 -8
  39. package/dist/tasks/index.d.ts +3 -1
  40. package/dist/tasks/index.mjs +5 -8
  41. package/package.json +1 -1
package/dist/index.umd.js CHANGED
@@ -4575,6 +4575,12 @@
4575
4575
  /**
4576
4576
  * Data Fabric Service Endpoints
4577
4577
  */
4578
+ /**
4579
+ * Default folder key used for tenant-level Data Fabric entities.
4580
+ * Tenant-level entities are not scoped to a folder; this is the
4581
+ * conventional placeholder value the API expects.
4582
+ */
4583
+ const DATA_FABRIC_TENANT_FOLDER_ID = '00000000-0000-0000-0000-000000000000';
4578
4584
  /**
4579
4585
  * Data Fabric Entity Service Endpoints
4580
4586
  */
@@ -4589,6 +4595,11 @@
4589
4595
  UPDATE_RECORD_BY_ID: (entityId, recordId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/update/${recordId}`,
4590
4596
  UPDATE_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/update-batch`,
4591
4597
  DELETE_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/delete-batch`,
4598
+ UPSERT: `${DATAFABRIC_BASE}/api/Entity`,
4599
+ DELETE: (entityId) => `${DATAFABRIC_BASE}/api/Entity/${entityId}`,
4600
+ UPDATE_METADATA: (entityId) => `${DATAFABRIC_BASE}/api/Entity/${entityId}/metadata`,
4601
+ QUERY_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/query`,
4602
+ BULK_UPLOAD_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/bulk-upload`,
4592
4603
  DOWNLOAD_ATTACHMENT: (entityId, recordId, fieldName) => `${DATAFABRIC_BASE}/api/Attachment/entity/${entityId}/${recordId}/${fieldName}`,
4593
4604
  UPLOAD_ATTACHMENT: (entityId, recordId, fieldName) => `${DATAFABRIC_BASE}/api/Attachment/entity/${entityId}/${recordId}/${fieldName}`,
4594
4605
  DELETE_ATTACHMENT: (entityId, recordId, fieldName) => `${DATAFABRIC_BASE}/api/Attachment/entity/${entityId}/${recordId}/${fieldName}`,
@@ -9177,7 +9188,7 @@
9177
9188
  // Connection string placeholder that will be replaced during build
9178
9189
  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";
9179
9190
  // SDK Version placeholder
9180
- const SDK_VERSION = "1.3.0";
9191
+ const SDK_VERSION = "1.3.1";
9181
9192
  const VERSION = "Version";
9182
9193
  const SERVICE = "Service";
9183
9194
  const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
@@ -9566,7 +9577,7 @@
9566
9577
  *
9567
9578
  * Supports two usage patterns:
9568
9579
  * 1. Full config in constructor — for server-side or explicit configuration
9569
- * 2. No config / partial config — loads from meta tags injected by @uipath/coded-apps plugin
9580
+ * 2. No config / partial config — loads from meta tags injected by @uipath/coded-apps-dev plugin
9570
9581
  *
9571
9582
  * @example
9572
9583
  * ```typescript
@@ -10032,15 +10043,11 @@
10032
10043
 
10033
10044
  class ApiClient {
10034
10045
  constructor(config, executionContext, tokenManager, clientConfig = {}) {
10035
- this.defaultHeaders = {};
10036
10046
  this.config = config;
10037
10047
  this.executionContext = executionContext;
10038
10048
  this.clientConfig = clientConfig;
10039
10049
  this.tokenManager = tokenManager;
10040
10050
  }
10041
- setDefaultHeaders(headers) {
10042
- this.defaultHeaders = { ...this.defaultHeaders, ...headers };
10043
- }
10044
10051
  /**
10045
10052
  * Gets a valid authentication token, refreshing if necessary.
10046
10053
  * Used internally for API requests and exposed for services that need manual auth headers.
@@ -10056,7 +10063,6 @@
10056
10063
  return {
10057
10064
  'Authorization': `Bearer ${token}`,
10058
10065
  'Content-Type': CONTENT_TYPES.JSON,
10059
- ...this.defaultHeaders,
10060
10066
  ...this.clientConfig.headers
10061
10067
  };
10062
10068
  }
@@ -11112,6 +11118,8 @@
11112
11118
  *
11113
11119
  * @param instance - UiPath SDK instance providing authentication and configuration.
11114
11120
  * Services receive this via dependency injection in the modular pattern.
11121
+ * @param headers - Optional default headers to include in every request (e.g. `x-uipath-external-user-id` for
11122
+ * CAS external-app auth)
11115
11123
  *
11116
11124
  * @example
11117
11125
  * ```typescript
@@ -11131,11 +11139,11 @@
11131
11139
  * const entities = new Entities(sdk);
11132
11140
  * ```
11133
11141
  */
11134
- constructor(instance) {
11142
+ constructor(instance, headers) {
11135
11143
  // Private field - not visible via Object.keys() or any reflection
11136
11144
  _BaseService_apiClient.set(this, void 0);
11137
11145
  const { config, context, tokenManager } = SDKInternalsRegistry.get(instance);
11138
- __classPrivateFieldSet(this, _BaseService_apiClient, new ApiClient(config, context, tokenManager), "f");
11146
+ __classPrivateFieldSet(this, _BaseService_apiClient, new ApiClient(config, context, tokenManager, headers ? { headers } : {}), "f");
11139
11147
  }
11140
11148
  /**
11141
11149
  * Gets a valid authentication token, refreshing if necessary.
@@ -11394,27 +11402,41 @@
11394
11402
  throw new Error('Entity ID is undefined');
11395
11403
  return service.deleteAttachment(entityData.id, recordId, fieldName);
11396
11404
  },
11405
+ async queryRecords(options) {
11406
+ if (!entityData.id)
11407
+ throw new Error('Entity ID is undefined');
11408
+ return service.queryRecordsById(entityData.id, options);
11409
+ },
11410
+ async importRecords(file) {
11411
+ if (!entityData.id)
11412
+ throw new Error('Entity ID is undefined');
11413
+ return service.importRecordsById(entityData.id, file);
11414
+ },
11397
11415
  async insert(data, options) {
11398
11416
  return this.insertRecord(data, options);
11399
11417
  },
11400
11418
  async batchInsert(data, options) {
11401
11419
  return this.insertRecords(data, options);
11402
11420
  },
11403
- async update(data, options) {
11404
- return this.updateRecords(data, options);
11405
- },
11406
- async delete(recordIds, options) {
11407
- return this.deleteRecords(recordIds, options);
11408
- },
11409
11421
  async getRecords(options) {
11410
11422
  return this.getAllRecords(options);
11411
- }
11423
+ },
11424
+ async delete() {
11425
+ if (!entityData.id)
11426
+ throw new Error('Entity ID is undefined');
11427
+ return service.deleteById(entityData.id);
11428
+ },
11429
+ async update(options) {
11430
+ if (!entityData.id)
11431
+ throw new Error('Entity ID is undefined');
11432
+ return service.updateById(entityData.id, options);
11433
+ },
11412
11434
  };
11413
11435
  }
11414
11436
  /**
11415
- * Creates an actionable entity metadata by combining entity with operational methods
11437
+ * Creates an actionable entity by combining entity metadata with data and management methods
11416
11438
  *
11417
- * @param entityData - Entity metadata
11439
+ * @param entityMetadata - Entity metadata
11418
11440
  * @param service - The entity service instance
11419
11441
  * @returns Entity metadata with added methods
11420
11442
  */
@@ -11424,42 +11446,7 @@
11424
11446
  }
11425
11447
 
11426
11448
  /**
11427
- * Creates query parameters object from key-value pairs, filtering out undefined values
11428
- * @param paramsObj - Object containing parameter key-value pairs
11429
- * @returns Parameters object with undefined values filtered out
11430
- *
11431
- * @example
11432
- * ```typescript
11433
- * // Entity service parameters
11434
- * const params = createParams({
11435
- * start: 0,
11436
- * limit: 10,
11437
- * expansionLevel: 1
11438
- * });
11439
- *
11440
- * // With optional/undefined values (automatically filtered)
11441
- * const params = createParams({
11442
- * start: options.start, // Could be undefined
11443
- * limit: options.limit, // Could be undefined
11444
- * expansionLevel: options.expansionLevel // Could be undefined
11445
- * });
11446
- *
11447
- * // Empty params
11448
- * const params = createParams();
11449
- * ```
11450
- */
11451
- function createParams(paramsObj = {}) {
11452
- const params = {};
11453
- for (const [key, value] of Object.entries(paramsObj)) {
11454
- if (value !== undefined && value !== null) {
11455
- params[key] = value;
11456
- }
11457
- }
11458
- return params;
11459
- }
11460
-
11461
- /**
11462
- * Entity field type names
11449
+ * Entity field data type names (SQL-level types returned by the API)
11463
11450
  */
11464
11451
  exports.EntityFieldDataType = void 0;
11465
11452
  (function (EntityFieldDataType) {
@@ -11475,7 +11462,41 @@
11475
11462
  EntityFieldDataType["BOOLEAN"] = "BOOLEAN";
11476
11463
  EntityFieldDataType["BIG_INTEGER"] = "BIG_INTEGER";
11477
11464
  EntityFieldDataType["MULTILINE_TEXT"] = "MULTILINE_TEXT";
11465
+ EntityFieldDataType["FILE"] = "FILE";
11466
+ EntityFieldDataType["CHOICE_SET_SINGLE"] = "CHOICE_SET_SINGLE";
11467
+ EntityFieldDataType["CHOICE_SET_MULTIPLE"] = "CHOICE_SET_MULTIPLE";
11468
+ EntityFieldDataType["AUTO_NUMBER"] = "AUTO_NUMBER";
11469
+ EntityFieldDataType["RELATIONSHIP"] = "RELATIONSHIP";
11478
11470
  })(exports.EntityFieldDataType || (exports.EntityFieldDataType = {}));
11471
+ /**
11472
+ * Logical operator for combining query filter groups
11473
+ */
11474
+ exports.LogicalOperator = void 0;
11475
+ (function (LogicalOperator) {
11476
+ /** Combine conditions with AND — all conditions must match */
11477
+ LogicalOperator[LogicalOperator["And"] = 0] = "And";
11478
+ /** Combine conditions with OR — any condition must match */
11479
+ LogicalOperator[LogicalOperator["Or"] = 1] = "Or";
11480
+ })(exports.LogicalOperator || (exports.LogicalOperator = {}));
11481
+ /**
11482
+ * Comparison operators for entity query filters.
11483
+ * Not all operators are valid for all field types.
11484
+ */
11485
+ exports.QueryFilterOperator = void 0;
11486
+ (function (QueryFilterOperator) {
11487
+ QueryFilterOperator["Equals"] = "=";
11488
+ QueryFilterOperator["NotEquals"] = "!=";
11489
+ QueryFilterOperator["GreaterThan"] = ">";
11490
+ QueryFilterOperator["LessThan"] = "<";
11491
+ QueryFilterOperator["GreaterThanOrEqual"] = ">=";
11492
+ QueryFilterOperator["LessThanOrEqual"] = "<=";
11493
+ QueryFilterOperator["Contains"] = "contains";
11494
+ QueryFilterOperator["NotContains"] = "not contains";
11495
+ QueryFilterOperator["StartsWith"] = "startswith";
11496
+ QueryFilterOperator["EndsWith"] = "endswith";
11497
+ QueryFilterOperator["In"] = "in";
11498
+ QueryFilterOperator["NotIn"] = "not in";
11499
+ })(exports.QueryFilterOperator || (exports.QueryFilterOperator = {}));
11479
11500
  /**
11480
11501
  * Entity type enum
11481
11502
  */
@@ -11521,6 +11542,41 @@
11521
11542
  JoinType["LeftJoin"] = "LeftJoin";
11522
11543
  })(exports.JoinType || (exports.JoinType = {}));
11523
11544
 
11545
+ /**
11546
+ * Creates query parameters object from key-value pairs, filtering out undefined values
11547
+ * @param paramsObj - Object containing parameter key-value pairs
11548
+ * @returns Parameters object with undefined values filtered out
11549
+ *
11550
+ * @example
11551
+ * ```typescript
11552
+ * // Entity service parameters
11553
+ * const params = createParams({
11554
+ * start: 0,
11555
+ * limit: 10,
11556
+ * expansionLevel: 1
11557
+ * });
11558
+ *
11559
+ * // With optional/undefined values (automatically filtered)
11560
+ * const params = createParams({
11561
+ * start: options.start, // Could be undefined
11562
+ * limit: options.limit, // Could be undefined
11563
+ * expansionLevel: options.expansionLevel // Could be undefined
11564
+ * });
11565
+ *
11566
+ * // Empty params
11567
+ * const params = createParams();
11568
+ * ```
11569
+ */
11570
+ function createParams(paramsObj = {}) {
11571
+ const params = {};
11572
+ for (const [key, value] of Object.entries(paramsObj)) {
11573
+ if (value !== undefined && value !== null) {
11574
+ params[key] = value;
11575
+ }
11576
+ }
11577
+ return params;
11578
+ }
11579
+
11524
11580
  /**
11525
11581
  * Entity field data types (SQL types from API)
11526
11582
  */
@@ -11539,6 +11595,7 @@
11539
11595
  SqlFieldType["DECIMAL"] = "DECIMAL";
11540
11596
  SqlFieldType["MULTILINE"] = "MULTILINE";
11541
11597
  })(SqlFieldType || (SqlFieldType = {}));
11598
+
11542
11599
  /**
11543
11600
  * Maps fields for Entities
11544
11601
  */
@@ -11548,6 +11605,40 @@
11548
11605
  sqlType: 'fieldDataType',
11549
11606
  fieldDefinition: 'fieldMetaData'
11550
11607
  };
11608
+ /**
11609
+ * Maps EntityFieldDataType values to the API field payload components for create/update operations
11610
+ */
11611
+ const EntitySchemaFieldTypeMap = {
11612
+ [exports.EntityFieldDataType.UUID]: { sqlTypeName: SqlFieldType.UNIQUEIDENTIFIER, fieldDisplayType: exports.FieldDisplayType.Basic },
11613
+ [exports.EntityFieldDataType.STRING]: { sqlTypeName: SqlFieldType.NVARCHAR, fieldDisplayType: exports.FieldDisplayType.Basic },
11614
+ [exports.EntityFieldDataType.INTEGER]: { sqlTypeName: SqlFieldType.INT, fieldDisplayType: exports.FieldDisplayType.Basic },
11615
+ [exports.EntityFieldDataType.DATETIME]: { sqlTypeName: SqlFieldType.DATETIME2, fieldDisplayType: exports.FieldDisplayType.Basic },
11616
+ [exports.EntityFieldDataType.DATETIME_WITH_TZ]: { sqlTypeName: SqlFieldType.DATETIMEOFFSET, fieldDisplayType: exports.FieldDisplayType.Basic },
11617
+ [exports.EntityFieldDataType.DECIMAL]: { sqlTypeName: SqlFieldType.DECIMAL, fieldDisplayType: exports.FieldDisplayType.Basic },
11618
+ [exports.EntityFieldDataType.FLOAT]: { sqlTypeName: SqlFieldType.FLOAT, fieldDisplayType: exports.FieldDisplayType.Basic },
11619
+ [exports.EntityFieldDataType.DOUBLE]: { sqlTypeName: SqlFieldType.REAL, fieldDisplayType: exports.FieldDisplayType.Basic },
11620
+ [exports.EntityFieldDataType.DATE]: { sqlTypeName: SqlFieldType.DATE, fieldDisplayType: exports.FieldDisplayType.Basic },
11621
+ [exports.EntityFieldDataType.BOOLEAN]: { sqlTypeName: SqlFieldType.BIT, fieldDisplayType: exports.FieldDisplayType.Basic },
11622
+ [exports.EntityFieldDataType.BIG_INTEGER]: { sqlTypeName: SqlFieldType.BIGINT, fieldDisplayType: exports.FieldDisplayType.Basic },
11623
+ [exports.EntityFieldDataType.MULTILINE_TEXT]: { sqlTypeName: SqlFieldType.MULTILINE, fieldDisplayType: exports.FieldDisplayType.Basic },
11624
+ [exports.EntityFieldDataType.FILE]: { sqlTypeName: SqlFieldType.UNIQUEIDENTIFIER, fieldDisplayType: exports.FieldDisplayType.File },
11625
+ [exports.EntityFieldDataType.CHOICE_SET_SINGLE]: { sqlTypeName: SqlFieldType.INT, fieldDisplayType: exports.FieldDisplayType.ChoiceSetSingle },
11626
+ [exports.EntityFieldDataType.CHOICE_SET_MULTIPLE]: { sqlTypeName: SqlFieldType.NVARCHAR, fieldDisplayType: exports.FieldDisplayType.ChoiceSetMultiple },
11627
+ [exports.EntityFieldDataType.AUTO_NUMBER]: { sqlTypeName: SqlFieldType.DECIMAL, fieldDisplayType: exports.FieldDisplayType.AutoNumber },
11628
+ [exports.EntityFieldDataType.RELATIONSHIP]: { sqlTypeName: SqlFieldType.UNIQUEIDENTIFIER, fieldDisplayType: exports.FieldDisplayType.Relationship },
11629
+ };
11630
+ /**
11631
+ * Maps FieldDisplayType values to EntityFieldDataType for types that share SQL types
11632
+ * with other field types (File, ChoiceSetSingle, ChoiceSetMultiple, AutoNumber).
11633
+ * Used during read-side transformation to produce the correct EntityFieldDataType.
11634
+ */
11635
+ const FieldDisplayTypeToDataType = {
11636
+ [exports.FieldDisplayType.File]: exports.EntityFieldDataType.FILE,
11637
+ [exports.FieldDisplayType.ChoiceSetSingle]: exports.EntityFieldDataType.CHOICE_SET_SINGLE,
11638
+ [exports.FieldDisplayType.ChoiceSetMultiple]: exports.EntityFieldDataType.CHOICE_SET_MULTIPLE,
11639
+ [exports.FieldDisplayType.AutoNumber]: exports.EntityFieldDataType.AUTO_NUMBER,
11640
+ [exports.FieldDisplayType.Relationship]: exports.EntityFieldDataType.RELATIONSHIP,
11641
+ };
11551
11642
  /**
11552
11643
  * Maps SQL field types to friendly display names
11553
11644
  */
@@ -11563,7 +11654,7 @@
11563
11654
  [SqlFieldType.DATE]: exports.EntityFieldDataType.DATE,
11564
11655
  [SqlFieldType.BIT]: exports.EntityFieldDataType.BOOLEAN,
11565
11656
  [SqlFieldType.DECIMAL]: exports.EntityFieldDataType.DECIMAL,
11566
- [SqlFieldType.MULTILINE]: exports.EntityFieldDataType.MULTILINE_TEXT
11657
+ [SqlFieldType.MULTILINE]: exports.EntityFieldDataType.MULTILINE_TEXT,
11567
11658
  };
11568
11659
 
11569
11660
  /**
@@ -11893,6 +11984,99 @@
11893
11984
  });
11894
11985
  return entities;
11895
11986
  }
11987
+ /**
11988
+ * Queries entity records with filters, sorting, and pagination
11989
+ *
11990
+ * @param id - UUID of the entity
11991
+ * @param options - Query options including filterGroup, selectedFields, sortOptions, and pagination
11992
+ * @returns Promise resolving to {@link NonPaginatedResponse} without pagination options,
11993
+ * or {@link PaginatedResponse} when `pageSize`, `cursor`, or `jumpToPage` are provided
11994
+ *
11995
+ * @example
11996
+ * ```typescript
11997
+ * import { Entities, LogicalOperator, QueryFilterOperator } from '@uipath/uipath-typescript/entities';
11998
+ *
11999
+ * const entities = new Entities(sdk);
12000
+ *
12001
+ * // Non-paginated query with a filter
12002
+ * const result = await entities.queryRecordsById("<entityId>", {
12003
+ * filterGroup: {
12004
+ * logicalOperator: LogicalOperator.And,
12005
+ * queryFilters: [
12006
+ * { fieldName: "status", operator: QueryFilterOperator.Equals, value: "active" }
12007
+ * ]
12008
+ * },
12009
+ * sortOptions: [{ fieldName: "created_at", isDescending: true }],
12010
+ * });
12011
+ * console.log(`Found ${result.totalCount} records`);
12012
+ *
12013
+ * // With pagination
12014
+ * const page1 = await entities.queryRecordsById("<entityId>", {
12015
+ * filterGroup: { queryFilters: [{ fieldName: "status", operator: QueryFilterOperator.Equals, value: "active" }] },
12016
+ * pageSize: 25,
12017
+ * });
12018
+ * if (page1.hasNextPage) {
12019
+ * const page2 = await entities.queryRecordsById("<entityId>", { cursor: page1.nextCursor });
12020
+ * }
12021
+ * ```
12022
+ */
12023
+ async queryRecordsById(id, options) {
12024
+ return PaginationHelpers.getAll({
12025
+ serviceAccess: this.createPaginationServiceAccess(),
12026
+ getEndpoint: () => DATA_FABRIC_ENDPOINTS.ENTITY.QUERY_BY_ID(id),
12027
+ method: HTTP_METHODS.POST,
12028
+ pagination: {
12029
+ paginationType: PaginationType.OFFSET,
12030
+ itemsField: ENTITY_PAGINATION.ITEMS_FIELD,
12031
+ totalCountField: ENTITY_PAGINATION.TOTAL_COUNT_FIELD,
12032
+ paginationParams: {
12033
+ pageSizeParam: ENTITY_OFFSET_PARAMS.PAGE_SIZE_PARAM,
12034
+ offsetParam: ENTITY_OFFSET_PARAMS.OFFSET_PARAM,
12035
+ countParam: ENTITY_OFFSET_PARAMS.COUNT_PARAM
12036
+ }
12037
+ },
12038
+ excludeFromPrefix: ['expansionLevel', 'filterGroup', 'selectedFields', 'sortOptions']
12039
+ }, options);
12040
+ }
12041
+ /**
12042
+ * Imports records from a CSV file into an entity
12043
+ *
12044
+ * @param id - UUID of the entity
12045
+ * @param file - CSV file to import (Blob, File, or Uint8Array)
12046
+ * @returns Promise resolving to import result with record counts
12047
+ *
12048
+ * @example
12049
+ * ```typescript
12050
+ * import { Entities } from '@uipath/uipath-typescript/entities';
12051
+ *
12052
+ * const entities = new Entities(sdk);
12053
+ *
12054
+ * // Browser: upload from file input
12055
+ * const fileInput = document.getElementById('csv-input') as HTMLInputElement;
12056
+ * const result = await entities.importRecordsById("<entityId>", fileInput.files[0]);
12057
+ *
12058
+ * // Node.js: read from disk
12059
+ * const fileBuffer = fs.readFileSync('records.csv');
12060
+ * const result = await entities.importRecordsById("<entityId>", new Blob([fileBuffer], { type: 'text/csv' }));
12061
+ *
12062
+ * console.log(`Inserted ${result.insertedRecords} of ${result.totalRecords} records`);
12063
+ * if (result.errorFileLink) {
12064
+ * console.log(`Error file link: ${result.errorFileLink}`);
12065
+ * }
12066
+ * ```
12067
+ * @internal
12068
+ */
12069
+ async importRecordsById(id, file) {
12070
+ const formData = new FormData();
12071
+ if (file instanceof Uint8Array) {
12072
+ formData.append('file', new Blob([file.buffer]));
12073
+ }
12074
+ else {
12075
+ formData.append('file', file);
12076
+ }
12077
+ const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.BULK_UPLOAD_BY_ID(id), formData);
12078
+ return response.data;
12079
+ }
11896
12080
  /**
11897
12081
  * Downloads an attachment from an entity record field
11898
12082
  *
@@ -12017,18 +12201,169 @@
12017
12201
  return this.insertRecordsById(id, data, options);
12018
12202
  }
12019
12203
  /**
12020
- * @hidden
12021
- * @deprecated Use {@link updateRecordsById} instead.
12204
+ * Creates a new Data Fabric entity with the given schema
12205
+ *
12206
+ * @param name - Entity name — must start with a letter and contain
12207
+ * only letters, numbers, and underscores (e.g., `"productCatalog"`).
12208
+ * @param fields - Array of field definitions
12209
+ * @param options - Optional entity-level settings ({@link EntityCreateOptions})
12210
+ * @returns Promise resolving to the ID of the created entity
12211
+ *
12212
+ * @example
12213
+ * ```typescript
12214
+ * const entityId = await entities.create("product_catalog", [
12215
+ * { fieldName: "product_name", type: EntityFieldDataType.STRING, isRequired: true, isUnique: true },
12216
+ * { fieldName: "price", type: EntityFieldDataType.INTEGER, defaultValue: "0" },
12217
+ * ], { displayName: "Product Catalog", description: "Our product catalog", isRbacEnabled: true });
12218
+ * ```
12219
+ * @internal
12022
12220
  */
12023
- async updateById(id, data, options = {}) {
12024
- return this.updateRecordsById(id, data, options);
12221
+ async create(name, fields, options) {
12222
+ this.validateName(name, 'entity');
12223
+ for (const field of fields) {
12224
+ this.validateName(field.fieldName, 'field');
12225
+ }
12226
+ const opts = options ?? {};
12227
+ const payload = {
12228
+ ...(opts.description !== undefined && { description: opts.description }),
12229
+ displayName: opts.displayName ?? name,
12230
+ entityDefinition: {
12231
+ name,
12232
+ fields: fields.map(f => this.buildSchemaFieldPayload(f)),
12233
+ folderId: opts.folderKey ?? DATA_FABRIC_TENANT_FOLDER_ID,
12234
+ isRbacEnabled: opts.isRbacEnabled ?? false,
12235
+ isInsightsEnabled: opts.isAnalyticsEnabled ?? false,
12236
+ externalFields: opts.externalFields ?? [],
12237
+ },
12238
+ };
12239
+ const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPSERT, payload);
12240
+ return response.data;
12025
12241
  }
12026
12242
  /**
12027
- * @hidden
12028
- * @deprecated Use {@link deleteRecordsById} instead.
12243
+ * Deletes a Data Fabric entity and all its records
12244
+ *
12245
+ * @param id - UUID of the entity to delete
12246
+ * @returns Promise resolving when the entity is deleted
12247
+ *
12248
+ * @example
12249
+ * ```typescript
12250
+ * await entities.deleteById("<entityId>");
12251
+ * ```
12252
+ * @internal
12253
+ */
12254
+ async deleteById(id) {
12255
+ await this.delete(DATA_FABRIC_ENDPOINTS.ENTITY.DELETE(id));
12256
+ }
12257
+ /**
12258
+ * Updates an existing Data Fabric entity — schema and/or metadata.
12259
+ *
12260
+ * Provide any combination of schema fields (`addFields`, `removeFields`, `updateFields`) and
12261
+ * metadata fields (`displayName`, `description`, `isRbacEnabled`). Each group is applied
12262
+ * only when the corresponding fields are present.
12263
+ *
12264
+ * **Warning:** Schema changes (`addFields`, `removeFields`, `updateFields`) use a
12265
+ * read-modify-write pattern — concurrent calls on the same entity may silently
12266
+ * overwrite each other's changes.
12267
+ *
12268
+ * @param id - UUID of the entity to update
12269
+ * @param options - Changes to apply ({@link EntityUpdateByIdOptions})
12270
+ * @returns Promise resolving when the update is complete
12271
+ *
12272
+ * @example
12273
+ * ```typescript
12274
+ * // Schema-only
12275
+ * await entities.updateById("<entityId>", {
12276
+ * addFields: [{ fieldName: "notes", type: EntityFieldDataType.MULTILINE_TEXT }],
12277
+ * removeFields: [{ fieldName: "old_field" }],
12278
+ * });
12279
+ *
12280
+ * // Metadata-only
12281
+ * await entities.updateById("<entityId>", {
12282
+ * displayName: "My Updated Entity",
12283
+ * description: "Updated description",
12284
+ * });
12285
+ *
12286
+ * // Combined
12287
+ * await entities.updateById("<entityId>", {
12288
+ * updateFields: [{ id: "<fieldId>", displayName: "Unit Price", isRequired: true }],
12289
+ * displayName: "Price Catalog",
12290
+ * });
12291
+ * ```
12292
+ * @internal
12293
+ */
12294
+ async updateById(id, options) {
12295
+ const opts = options ?? {};
12296
+ const hasSchemaChanges = !!(opts.addFields?.length || opts.removeFields?.length || opts.updateFields?.length);
12297
+ const hasMetadataChanges = opts.displayName !== undefined || opts.description !== undefined || opts.isRbacEnabled !== undefined;
12298
+ if (hasSchemaChanges) {
12299
+ await this.applySchemaUpdate(id, opts);
12300
+ }
12301
+ if (hasMetadataChanges) {
12302
+ await this.patch(DATA_FABRIC_ENDPOINTS.ENTITY.UPDATE_METADATA(id), {
12303
+ ...(opts.displayName !== undefined && { displayName: opts.displayName }),
12304
+ ...(opts.description !== undefined && { description: opts.description }),
12305
+ ...(opts.isRbacEnabled !== undefined && { isRbacEnabled: opts.isRbacEnabled }),
12306
+ });
12307
+ }
12308
+ }
12309
+ /**
12310
+ * Fetches the current entity schema, applies the field delta, then posts the full updated schema.
12311
+ *
12312
+ * @param entityId - UUID of the entity to update
12313
+ * @param options - Field changes to apply
12314
+ * @private
12029
12315
  */
12030
- async deleteById(id, recordIds, options = {}) {
12031
- return this.deleteRecordsById(id, recordIds, options);
12316
+ async applySchemaUpdate(entityId, options) {
12317
+ const entityResponse = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.GET_BY_ID(entityId));
12318
+ const raw = entityResponse.data;
12319
+ // Carry forward existing non-system fields from GET response (skip system/primary-key fields)
12320
+ let fields = (raw.fields ?? [])
12321
+ .filter(f => !f.isSystemField && !f.isPrimaryKey);
12322
+ // Filter out removed fields
12323
+ if (options.removeFields?.length) {
12324
+ const removeSet = new Set(options.removeFields.map(r => r.fieldName));
12325
+ fields = fields.filter(f => !removeSet.has(f.name));
12326
+ }
12327
+ // Apply per-field metadata updates (matched by field ID)
12328
+ if (options.updateFields?.length) {
12329
+ const updateMap = new Map(options.updateFields.map(u => [u.id, u]));
12330
+ fields = fields.map(f => {
12331
+ const update = updateMap.get(f.id ?? '');
12332
+ if (!update)
12333
+ return f;
12334
+ return {
12335
+ ...f,
12336
+ ...(update.displayName !== undefined && { displayName: update.displayName }),
12337
+ ...(update.description !== undefined && { description: update.description }),
12338
+ ...(update.isRequired !== undefined && { isRequired: update.isRequired }),
12339
+ ...(update.isUnique !== undefined && { isUnique: update.isUnique }),
12340
+ ...(update.isRbacEnabled !== undefined && { isRbacEnabled: update.isRbacEnabled }),
12341
+ ...(update.isEncrypted !== undefined && { isEncrypted: update.isEncrypted }),
12342
+ ...(update.defaultValue !== undefined && { defaultValue: update.defaultValue }),
12343
+ };
12344
+ });
12345
+ }
12346
+ // Build and append new fields
12347
+ const newFields = [];
12348
+ if (options.addFields?.length) {
12349
+ for (const field of options.addFields) {
12350
+ this.validateName(field.fieldName, 'field');
12351
+ }
12352
+ newFields.push(...options.addFields.map(f => this.buildSchemaFieldPayload(f)));
12353
+ }
12354
+ await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPSERT, {
12355
+ displayName: raw.displayName,
12356
+ description: raw.description,
12357
+ entityDefinition: {
12358
+ id: entityId,
12359
+ name: raw.name,
12360
+ fields: [...fields, ...newFields],
12361
+ folderId: raw.folderId ?? DATA_FABRIC_TENANT_FOLDER_ID,
12362
+ isRbacEnabled: raw.isRbacEnabled ?? false,
12363
+ isInsightsEnabled: raw.isInsightsEnabled ?? false,
12364
+ externalFields: raw.externalFields ?? [],
12365
+ },
12366
+ });
12032
12367
  }
12033
12368
  /**
12034
12369
  * Orchestrates all field mapping transformations
@@ -12052,11 +12387,20 @@
12052
12387
  metadata.fields = metadata.fields.map(field => {
12053
12388
  // Rename sqlType to fieldDataType
12054
12389
  let transformedField = transformData(field, EntityMap);
12055
- // Map SQL field type to friendly name
12390
+ // Map field type: prefer fieldDisplayType for types that share SQL types (File, ChoiceSet, AutoNumber)
12056
12391
  if (transformedField.fieldDataType?.name) {
12057
- const sqlTypeName = transformedField.fieldDataType.name;
12058
- if (EntityFieldTypeMap[sqlTypeName]) {
12059
- transformedField.fieldDataType.name = EntityFieldTypeMap[sqlTypeName];
12392
+ const displayTypeMapped = transformedField.fieldDisplayType
12393
+ ? FieldDisplayTypeToDataType[transformedField.fieldDisplayType]
12394
+ : undefined;
12395
+ if (displayTypeMapped) {
12396
+ transformedField.fieldDataType.name = displayTypeMapped;
12397
+ }
12398
+ else {
12399
+ const rawSqlTypeName = field.sqlType?.name;
12400
+ const mapped = rawSqlTypeName ? EntityFieldTypeMap[rawSqlTypeName] : undefined;
12401
+ if (mapped) {
12402
+ transformedField.fieldDataType.name = mapped;
12403
+ }
12060
12404
  }
12061
12405
  }
12062
12406
  this.transformNestedReferences(transformedField);
@@ -12100,7 +12444,44 @@
12100
12444
  return externalSource;
12101
12445
  });
12102
12446
  }
12447
+ /** Converts a user-facing EntityCreateFieldOptions to the raw API field payload */
12448
+ buildSchemaFieldPayload(field) {
12449
+ this.validateName(field.fieldName, 'field');
12450
+ const mapping = EntitySchemaFieldTypeMap[field.type ?? exports.EntityFieldDataType.STRING];
12451
+ return {
12452
+ name: field.fieldName,
12453
+ displayName: field.displayName ?? field.fieldName,
12454
+ sqlType: { name: mapping.sqlTypeName },
12455
+ fieldDisplayType: mapping.fieldDisplayType,
12456
+ description: field.description ?? '',
12457
+ isRequired: field.isRequired ?? false,
12458
+ isUnique: field.isUnique ?? false,
12459
+ isRbacEnabled: field.isRbacEnabled ?? false,
12460
+ isEncrypted: field.isEncrypted ?? false,
12461
+ ...(field.defaultValue !== undefined && { defaultValue: field.defaultValue }),
12462
+ ...(field.choiceSetId !== undefined && { choiceSetId: field.choiceSetId }),
12463
+ ...(field.referenceEntityName !== undefined && { referenceEntityName: field.referenceEntityName }),
12464
+ ...(field.referenceFieldName !== undefined && { referenceFieldName: field.referenceFieldName }),
12465
+ };
12466
+ }
12467
+ validateName(name, context) {
12468
+ if (name.length < 3 || name.length > 100 || !/^[a-zA-Z]\w*$/.test(name)) {
12469
+ const suggestion = name.replace(/\W/g, '').replace(/^[0-9_]+/, '');
12470
+ const defaultName = `My${context.charAt(0).toUpperCase() + context.slice(1)}`;
12471
+ throw new ValidationError({
12472
+ message: `Invalid ${context} name '${name}'. Must start with a letter, contain only letters, numbers, and underscores, 3–100 characters (e.g., "${suggestion || defaultName}").`
12473
+ });
12474
+ }
12475
+ if (context === 'field' && EntityService.RESERVED_FIELD_NAMES.has(name)) {
12476
+ throw new ValidationError({
12477
+ message: `Field name '${name}' is reserved. Reserved names: ${[...EntityService.RESERVED_FIELD_NAMES].join(', ')}.`
12478
+ });
12479
+ }
12480
+ }
12103
12481
  }
12482
+ EntityService.RESERVED_FIELD_NAMES = new Set([
12483
+ 'Id', 'CreatedBy', 'CreateTime', 'UpdatedBy', 'UpdateTime'
12484
+ ]);
12104
12485
  __decorate([
12105
12486
  track('Entities.GetById')
12106
12487
  ], EntityService.prototype, "getById", null);
@@ -12128,6 +12509,12 @@
12128
12509
  __decorate([
12129
12510
  track('Entities.GetAll')
12130
12511
  ], EntityService.prototype, "getAll", null);
12512
+ __decorate([
12513
+ track('Entities.QueryRecordsById')
12514
+ ], EntityService.prototype, "queryRecordsById", null);
12515
+ __decorate([
12516
+ track('Entities.ImportRecordsById')
12517
+ ], EntityService.prototype, "importRecordsById", null);
12131
12518
  __decorate([
12132
12519
  track('Entities.DownloadAttachment')
12133
12520
  ], EntityService.prototype, "downloadAttachment", null);
@@ -12137,6 +12524,15 @@
12137
12524
  __decorate([
12138
12525
  track('Entities.DeleteAttachment')
12139
12526
  ], EntityService.prototype, "deleteAttachment", null);
12527
+ __decorate([
12528
+ track('Entities.Create')
12529
+ ], EntityService.prototype, "create", null);
12530
+ __decorate([
12531
+ track('Entities.DeleteById')
12532
+ ], EntityService.prototype, "deleteById", null);
12533
+ __decorate([
12534
+ track('Entities.UpdateById')
12535
+ ], EntityService.prototype, "updateById", null);
12140
12536
 
12141
12537
  class ChoiceSetService extends BaseService {
12142
12538
  /**
@@ -14867,6 +15263,50 @@
14867
15263
  },
14868
15264
  }, options);
14869
15265
  }
15266
+ /**
15267
+ * Gets a job by its unique key (GUID).
15268
+ *
15269
+ * Returns the full job details including state, timing, input/output arguments, and error information.
15270
+ * Use `expand` to include related entities like `robot`, or `machine`.
15271
+ *
15272
+ * @param id - The unique key (GUID) of the job to retrieve
15273
+ * @param folderId - The folder ID where the job resides
15274
+ * @param options - Optional query options for expanding or selecting fields
15275
+ * @returns Promise resolving to a {@link JobGetResponse} with full job details and bound methods
15276
+ *
15277
+ * @example
15278
+ * ```typescript
15279
+ * // Get a job by key
15280
+ * const job = await jobs.getById(<id>, <folderId>);
15281
+ * console.log(job.state, job.processName);
15282
+ * ```
15283
+ *
15284
+ * @example
15285
+ * ```typescript
15286
+ * // With expanded related entities
15287
+ * const job = await jobs.getById(<id>, <folderId>, {
15288
+ * expand: 'robot,machine'
15289
+ * });
15290
+ * console.log(job.robot?.name, job.machine?.name);
15291
+ * ```
15292
+ */
15293
+ async getById(id, folderId, options) {
15294
+ if (!id) {
15295
+ throw new ValidationError({ message: 'id is required for getById' });
15296
+ }
15297
+ if (!folderId) {
15298
+ throw new ValidationError({ message: 'folderId is required for getById' });
15299
+ }
15300
+ const headers = createHeaders({ [FOLDER_ID]: folderId });
15301
+ const keysToPrefix = Object.keys(options ?? {});
15302
+ const apiOptions = options ? addPrefixToKeys(options, ODATA_PREFIX, keysToPrefix) : {};
15303
+ const response = await this.get(JOB_ENDPOINTS.GET_BY_KEY(id), {
15304
+ params: apiOptions,
15305
+ headers,
15306
+ });
15307
+ const rawJob = transformData(pascalToCamelCaseKeys(response.data), JobMap);
15308
+ return createJobWithMethods(rawJob, this);
15309
+ }
14870
15310
  /**
14871
15311
  * Gets the output of a completed job.
14872
15312
  *
@@ -14903,34 +15343,20 @@
14903
15343
  if (!jobKey) {
14904
15344
  throw new ValidationError({ message: 'jobKey is required for getOutput' });
14905
15345
  }
14906
- const job = await this.fetchJobByKey(jobKey, folderId);
14907
- if (job.OutputArguments) {
15346
+ const job = await this.getById(jobKey, folderId, { select: 'outputArguments,outputFile' });
15347
+ if (job.outputArguments) {
14908
15348
  try {
14909
- return JSON.parse(job.OutputArguments);
15349
+ return JSON.parse(job.outputArguments);
14910
15350
  }
14911
15351
  catch {
14912
15352
  throw new ServerError({ message: 'Failed to parse job output arguments as JSON' });
14913
15353
  }
14914
15354
  }
14915
- if (job.OutputFile) {
14916
- return this.downloadOutputFile(job.OutputFile);
15355
+ if (job.outputFile) {
15356
+ return this.downloadOutputFile(job.outputFile);
14917
15357
  }
14918
15358
  return null;
14919
15359
  }
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
15360
  /**
14935
15361
  * Downloads the output file content via the Attachments API.
14936
15362
  * 1. Fetches blob access info from the attachment using AttachmentService
@@ -14969,6 +15395,9 @@
14969
15395
  __decorate([
14970
15396
  track('Jobs.GetAll')
14971
15397
  ], JobService.prototype, "getAll", null);
15398
+ __decorate([
15399
+ track('Jobs.GetById')
15400
+ ], JobService.prototype, "getById", null);
14972
15401
  __decorate([
14973
15402
  track('Jobs.GetOutput')
14974
15403
  ], JobService.prototype, "getOutput", null);