@uipath/uipath-typescript 1.3.0 → 1.3.2

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