@uipath/uipath-typescript 1.2.2 → 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 +697 -317
  20. package/dist/entities/index.d.ts +572 -58
  21. package/dist/entities/index.mjs +698 -318
  22. package/dist/index.cjs +727 -161
  23. package/dist/index.d.ts +697 -69
  24. package/dist/index.mjs +727 -162
  25. package/dist/index.umd.js +727 -161
  26. package/dist/jobs/index.cjs +278 -20
  27. package/dist/jobs/index.d.ts +214 -19
  28. package/dist/jobs/index.mjs +278 -21
  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.cjs CHANGED
@@ -4520,6 +4520,7 @@ const QUEUE_ENDPOINTS = {
4520
4520
  */
4521
4521
  const JOB_ENDPOINTS = {
4522
4522
  GET_ALL: `${ORCHESTRATOR_BASE}/odata/Jobs`,
4523
+ GET_BY_KEY: (identifier) => `${ORCHESTRATOR_BASE}/odata/Jobs/UiPath.Server.Configuration.OData.GetByKey(identifier=${identifier})`,
4523
4524
  };
4524
4525
  /**
4525
4526
  * Orchestrator Asset Service Endpoints
@@ -4572,6 +4573,12 @@ const MAESTRO_ENDPOINTS = {
4572
4573
  /**
4573
4574
  * Data Fabric Service Endpoints
4574
4575
  */
4576
+ /**
4577
+ * Default folder key used for tenant-level Data Fabric entities.
4578
+ * Tenant-level entities are not scoped to a folder; this is the
4579
+ * conventional placeholder value the API expects.
4580
+ */
4581
+ const DATA_FABRIC_TENANT_FOLDER_ID = '00000000-0000-0000-0000-000000000000';
4575
4582
  /**
4576
4583
  * Data Fabric Entity Service Endpoints
4577
4584
  */
@@ -4586,6 +4593,11 @@ const DATA_FABRIC_ENDPOINTS = {
4586
4593
  UPDATE_RECORD_BY_ID: (entityId, recordId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/update/${recordId}`,
4587
4594
  UPDATE_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/update-batch`,
4588
4595
  DELETE_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/delete-batch`,
4596
+ UPSERT: `${DATAFABRIC_BASE}/api/Entity`,
4597
+ DELETE: (entityId) => `${DATAFABRIC_BASE}/api/Entity/${entityId}`,
4598
+ UPDATE_METADATA: (entityId) => `${DATAFABRIC_BASE}/api/Entity/${entityId}/metadata`,
4599
+ QUERY_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/query`,
4600
+ BULK_UPLOAD_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/bulk-upload`,
4589
4601
  DOWNLOAD_ATTACHMENT: (entityId, recordId, fieldName) => `${DATAFABRIC_BASE}/api/Attachment/entity/${entityId}/${recordId}/${fieldName}`,
4590
4602
  UPLOAD_ATTACHMENT: (entityId, recordId, fieldName) => `${DATAFABRIC_BASE}/api/Attachment/entity/${entityId}/${recordId}/${fieldName}`,
4591
4603
  DELETE_ATTACHMENT: (entityId, recordId, fieldName) => `${DATAFABRIC_BASE}/api/Attachment/entity/${entityId}/${recordId}/${fieldName}`,
@@ -5419,7 +5431,7 @@ function normalizeBaseUrl(url) {
5419
5431
  // Connection string placeholder that will be replaced during build
5420
5432
  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";
5421
5433
  // SDK Version placeholder
5422
- const SDK_VERSION = "1.2.2";
5434
+ const SDK_VERSION = "1.3.1";
5423
5435
  const VERSION = "Version";
5424
5436
  const SERVICE = "Service";
5425
5437
  const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
@@ -5808,7 +5820,7 @@ var _UiPath_instances, _UiPath_config, _UiPath_authService, _UiPath_initialized,
5808
5820
  *
5809
5821
  * Supports two usage patterns:
5810
5822
  * 1. Full config in constructor — for server-side or explicit configuration
5811
- * 2. No config / partial config — loads from meta tags injected by @uipath/coded-apps plugin
5823
+ * 2. No config / partial config — loads from meta tags injected by @uipath/coded-apps-dev plugin
5812
5824
  *
5813
5825
  * @example
5814
5826
  * ```typescript
@@ -6274,15 +6286,11 @@ const RESPONSE_TYPES = {
6274
6286
 
6275
6287
  class ApiClient {
6276
6288
  constructor(config, executionContext, tokenManager, clientConfig = {}) {
6277
- this.defaultHeaders = {};
6278
6289
  this.config = config;
6279
6290
  this.executionContext = executionContext;
6280
6291
  this.clientConfig = clientConfig;
6281
6292
  this.tokenManager = tokenManager;
6282
6293
  }
6283
- setDefaultHeaders(headers) {
6284
- this.defaultHeaders = { ...this.defaultHeaders, ...headers };
6285
- }
6286
6294
  /**
6287
6295
  * Gets a valid authentication token, refreshing if necessary.
6288
6296
  * Used internally for API requests and exposed for services that need manual auth headers.
@@ -6298,7 +6306,6 @@ class ApiClient {
6298
6306
  return {
6299
6307
  'Authorization': `Bearer ${token}`,
6300
6308
  'Content-Type': CONTENT_TYPES.JSON,
6301
- ...this.defaultHeaders,
6302
6309
  ...this.clientConfig.headers
6303
6310
  };
6304
6311
  }
@@ -7354,6 +7361,8 @@ class BaseService {
7354
7361
  *
7355
7362
  * @param instance - UiPath SDK instance providing authentication and configuration.
7356
7363
  * Services receive this via dependency injection in the modular pattern.
7364
+ * @param headers - Optional default headers to include in every request (e.g. `x-uipath-external-user-id` for
7365
+ * CAS external-app auth)
7357
7366
  *
7358
7367
  * @example
7359
7368
  * ```typescript
@@ -7373,11 +7382,11 @@ class BaseService {
7373
7382
  * const entities = new Entities(sdk);
7374
7383
  * ```
7375
7384
  */
7376
- constructor(instance) {
7385
+ constructor(instance, headers) {
7377
7386
  // Private field - not visible via Object.keys() or any reflection
7378
7387
  _BaseService_apiClient.set(this, void 0);
7379
7388
  const { config, context, tokenManager } = SDKInternalsRegistry.get(instance);
7380
- __classPrivateFieldSet(this, _BaseService_apiClient, new ApiClient(config, context, tokenManager), "f");
7389
+ __classPrivateFieldSet(this, _BaseService_apiClient, new ApiClient(config, context, tokenManager, headers ? { headers } : {}), "f");
7381
7390
  }
7382
7391
  /**
7383
7392
  * Gets a valid authentication token, refreshing if necessary.
@@ -7636,27 +7645,41 @@ function createEntityMethods(entityData, service) {
7636
7645
  throw new Error('Entity ID is undefined');
7637
7646
  return service.deleteAttachment(entityData.id, recordId, fieldName);
7638
7647
  },
7648
+ async queryRecords(options) {
7649
+ if (!entityData.id)
7650
+ throw new Error('Entity ID is undefined');
7651
+ return service.queryRecordsById(entityData.id, options);
7652
+ },
7653
+ async importRecords(file) {
7654
+ if (!entityData.id)
7655
+ throw new Error('Entity ID is undefined');
7656
+ return service.importRecordsById(entityData.id, file);
7657
+ },
7639
7658
  async insert(data, options) {
7640
7659
  return this.insertRecord(data, options);
7641
7660
  },
7642
7661
  async batchInsert(data, options) {
7643
7662
  return this.insertRecords(data, options);
7644
7663
  },
7645
- async update(data, options) {
7646
- return this.updateRecords(data, options);
7647
- },
7648
- async delete(recordIds, options) {
7649
- return this.deleteRecords(recordIds, options);
7650
- },
7651
7664
  async getRecords(options) {
7652
7665
  return this.getAllRecords(options);
7653
- }
7666
+ },
7667
+ async delete() {
7668
+ if (!entityData.id)
7669
+ throw new Error('Entity ID is undefined');
7670
+ return service.deleteById(entityData.id);
7671
+ },
7672
+ async update(options) {
7673
+ if (!entityData.id)
7674
+ throw new Error('Entity ID is undefined');
7675
+ return service.updateById(entityData.id, options);
7676
+ },
7654
7677
  };
7655
7678
  }
7656
7679
  /**
7657
- * Creates an actionable entity metadata by combining entity with operational methods
7680
+ * Creates an actionable entity by combining entity metadata with data and management methods
7658
7681
  *
7659
- * @param entityData - Entity metadata
7682
+ * @param entityMetadata - Entity metadata
7660
7683
  * @param service - The entity service instance
7661
7684
  * @returns Entity metadata with added methods
7662
7685
  */
@@ -7666,42 +7689,7 @@ function createEntityWithMethods(entityData, service) {
7666
7689
  }
7667
7690
 
7668
7691
  /**
7669
- * Creates query parameters object from key-value pairs, filtering out undefined values
7670
- * @param paramsObj - Object containing parameter key-value pairs
7671
- * @returns Parameters object with undefined values filtered out
7672
- *
7673
- * @example
7674
- * ```typescript
7675
- * // Entity service parameters
7676
- * const params = createParams({
7677
- * start: 0,
7678
- * limit: 10,
7679
- * expansionLevel: 1
7680
- * });
7681
- *
7682
- * // With optional/undefined values (automatically filtered)
7683
- * const params = createParams({
7684
- * start: options.start, // Could be undefined
7685
- * limit: options.limit, // Could be undefined
7686
- * expansionLevel: options.expansionLevel // Could be undefined
7687
- * });
7688
- *
7689
- * // Empty params
7690
- * const params = createParams();
7691
- * ```
7692
- */
7693
- function createParams(paramsObj = {}) {
7694
- const params = {};
7695
- for (const [key, value] of Object.entries(paramsObj)) {
7696
- if (value !== undefined && value !== null) {
7697
- params[key] = value;
7698
- }
7699
- }
7700
- return params;
7701
- }
7702
-
7703
- /**
7704
- * Entity field type names
7692
+ * Entity field data type names (SQL-level types returned by the API)
7705
7693
  */
7706
7694
  exports.EntityFieldDataType = void 0;
7707
7695
  (function (EntityFieldDataType) {
@@ -7717,7 +7705,41 @@ exports.EntityFieldDataType = void 0;
7717
7705
  EntityFieldDataType["BOOLEAN"] = "BOOLEAN";
7718
7706
  EntityFieldDataType["BIG_INTEGER"] = "BIG_INTEGER";
7719
7707
  EntityFieldDataType["MULTILINE_TEXT"] = "MULTILINE_TEXT";
7708
+ EntityFieldDataType["FILE"] = "FILE";
7709
+ EntityFieldDataType["CHOICE_SET_SINGLE"] = "CHOICE_SET_SINGLE";
7710
+ EntityFieldDataType["CHOICE_SET_MULTIPLE"] = "CHOICE_SET_MULTIPLE";
7711
+ EntityFieldDataType["AUTO_NUMBER"] = "AUTO_NUMBER";
7712
+ EntityFieldDataType["RELATIONSHIP"] = "RELATIONSHIP";
7720
7713
  })(exports.EntityFieldDataType || (exports.EntityFieldDataType = {}));
7714
+ /**
7715
+ * Logical operator for combining query filter groups
7716
+ */
7717
+ exports.LogicalOperator = void 0;
7718
+ (function (LogicalOperator) {
7719
+ /** Combine conditions with AND — all conditions must match */
7720
+ LogicalOperator[LogicalOperator["And"] = 0] = "And";
7721
+ /** Combine conditions with OR — any condition must match */
7722
+ LogicalOperator[LogicalOperator["Or"] = 1] = "Or";
7723
+ })(exports.LogicalOperator || (exports.LogicalOperator = {}));
7724
+ /**
7725
+ * Comparison operators for entity query filters.
7726
+ * Not all operators are valid for all field types.
7727
+ */
7728
+ exports.QueryFilterOperator = void 0;
7729
+ (function (QueryFilterOperator) {
7730
+ QueryFilterOperator["Equals"] = "=";
7731
+ QueryFilterOperator["NotEquals"] = "!=";
7732
+ QueryFilterOperator["GreaterThan"] = ">";
7733
+ QueryFilterOperator["LessThan"] = "<";
7734
+ QueryFilterOperator["GreaterThanOrEqual"] = ">=";
7735
+ QueryFilterOperator["LessThanOrEqual"] = "<=";
7736
+ QueryFilterOperator["Contains"] = "contains";
7737
+ QueryFilterOperator["NotContains"] = "not contains";
7738
+ QueryFilterOperator["StartsWith"] = "startswith";
7739
+ QueryFilterOperator["EndsWith"] = "endswith";
7740
+ QueryFilterOperator["In"] = "in";
7741
+ QueryFilterOperator["NotIn"] = "not in";
7742
+ })(exports.QueryFilterOperator || (exports.QueryFilterOperator = {}));
7721
7743
  /**
7722
7744
  * Entity type enum
7723
7745
  */
@@ -7763,6 +7785,41 @@ exports.JoinType = void 0;
7763
7785
  JoinType["LeftJoin"] = "LeftJoin";
7764
7786
  })(exports.JoinType || (exports.JoinType = {}));
7765
7787
 
7788
+ /**
7789
+ * Creates query parameters object from key-value pairs, filtering out undefined values
7790
+ * @param paramsObj - Object containing parameter key-value pairs
7791
+ * @returns Parameters object with undefined values filtered out
7792
+ *
7793
+ * @example
7794
+ * ```typescript
7795
+ * // Entity service parameters
7796
+ * const params = createParams({
7797
+ * start: 0,
7798
+ * limit: 10,
7799
+ * expansionLevel: 1
7800
+ * });
7801
+ *
7802
+ * // With optional/undefined values (automatically filtered)
7803
+ * const params = createParams({
7804
+ * start: options.start, // Could be undefined
7805
+ * limit: options.limit, // Could be undefined
7806
+ * expansionLevel: options.expansionLevel // Could be undefined
7807
+ * });
7808
+ *
7809
+ * // Empty params
7810
+ * const params = createParams();
7811
+ * ```
7812
+ */
7813
+ function createParams(paramsObj = {}) {
7814
+ const params = {};
7815
+ for (const [key, value] of Object.entries(paramsObj)) {
7816
+ if (value !== undefined && value !== null) {
7817
+ params[key] = value;
7818
+ }
7819
+ }
7820
+ return params;
7821
+ }
7822
+
7766
7823
  /**
7767
7824
  * Entity field data types (SQL types from API)
7768
7825
  */
@@ -7781,6 +7838,7 @@ var SqlFieldType;
7781
7838
  SqlFieldType["DECIMAL"] = "DECIMAL";
7782
7839
  SqlFieldType["MULTILINE"] = "MULTILINE";
7783
7840
  })(SqlFieldType || (SqlFieldType = {}));
7841
+
7784
7842
  /**
7785
7843
  * Maps fields for Entities
7786
7844
  */
@@ -7790,6 +7848,40 @@ const EntityMap = {
7790
7848
  sqlType: 'fieldDataType',
7791
7849
  fieldDefinition: 'fieldMetaData'
7792
7850
  };
7851
+ /**
7852
+ * Maps EntityFieldDataType values to the API field payload components for create/update operations
7853
+ */
7854
+ const EntitySchemaFieldTypeMap = {
7855
+ [exports.EntityFieldDataType.UUID]: { sqlTypeName: SqlFieldType.UNIQUEIDENTIFIER, fieldDisplayType: exports.FieldDisplayType.Basic },
7856
+ [exports.EntityFieldDataType.STRING]: { sqlTypeName: SqlFieldType.NVARCHAR, fieldDisplayType: exports.FieldDisplayType.Basic },
7857
+ [exports.EntityFieldDataType.INTEGER]: { sqlTypeName: SqlFieldType.INT, fieldDisplayType: exports.FieldDisplayType.Basic },
7858
+ [exports.EntityFieldDataType.DATETIME]: { sqlTypeName: SqlFieldType.DATETIME2, fieldDisplayType: exports.FieldDisplayType.Basic },
7859
+ [exports.EntityFieldDataType.DATETIME_WITH_TZ]: { sqlTypeName: SqlFieldType.DATETIMEOFFSET, fieldDisplayType: exports.FieldDisplayType.Basic },
7860
+ [exports.EntityFieldDataType.DECIMAL]: { sqlTypeName: SqlFieldType.DECIMAL, fieldDisplayType: exports.FieldDisplayType.Basic },
7861
+ [exports.EntityFieldDataType.FLOAT]: { sqlTypeName: SqlFieldType.FLOAT, fieldDisplayType: exports.FieldDisplayType.Basic },
7862
+ [exports.EntityFieldDataType.DOUBLE]: { sqlTypeName: SqlFieldType.REAL, fieldDisplayType: exports.FieldDisplayType.Basic },
7863
+ [exports.EntityFieldDataType.DATE]: { sqlTypeName: SqlFieldType.DATE, fieldDisplayType: exports.FieldDisplayType.Basic },
7864
+ [exports.EntityFieldDataType.BOOLEAN]: { sqlTypeName: SqlFieldType.BIT, fieldDisplayType: exports.FieldDisplayType.Basic },
7865
+ [exports.EntityFieldDataType.BIG_INTEGER]: { sqlTypeName: SqlFieldType.BIGINT, fieldDisplayType: exports.FieldDisplayType.Basic },
7866
+ [exports.EntityFieldDataType.MULTILINE_TEXT]: { sqlTypeName: SqlFieldType.MULTILINE, fieldDisplayType: exports.FieldDisplayType.Basic },
7867
+ [exports.EntityFieldDataType.FILE]: { sqlTypeName: SqlFieldType.UNIQUEIDENTIFIER, fieldDisplayType: exports.FieldDisplayType.File },
7868
+ [exports.EntityFieldDataType.CHOICE_SET_SINGLE]: { sqlTypeName: SqlFieldType.INT, fieldDisplayType: exports.FieldDisplayType.ChoiceSetSingle },
7869
+ [exports.EntityFieldDataType.CHOICE_SET_MULTIPLE]: { sqlTypeName: SqlFieldType.NVARCHAR, fieldDisplayType: exports.FieldDisplayType.ChoiceSetMultiple },
7870
+ [exports.EntityFieldDataType.AUTO_NUMBER]: { sqlTypeName: SqlFieldType.DECIMAL, fieldDisplayType: exports.FieldDisplayType.AutoNumber },
7871
+ [exports.EntityFieldDataType.RELATIONSHIP]: { sqlTypeName: SqlFieldType.UNIQUEIDENTIFIER, fieldDisplayType: exports.FieldDisplayType.Relationship },
7872
+ };
7873
+ /**
7874
+ * Maps FieldDisplayType values to EntityFieldDataType for types that share SQL types
7875
+ * with other field types (File, ChoiceSetSingle, ChoiceSetMultiple, AutoNumber).
7876
+ * Used during read-side transformation to produce the correct EntityFieldDataType.
7877
+ */
7878
+ const FieldDisplayTypeToDataType = {
7879
+ [exports.FieldDisplayType.File]: exports.EntityFieldDataType.FILE,
7880
+ [exports.FieldDisplayType.ChoiceSetSingle]: exports.EntityFieldDataType.CHOICE_SET_SINGLE,
7881
+ [exports.FieldDisplayType.ChoiceSetMultiple]: exports.EntityFieldDataType.CHOICE_SET_MULTIPLE,
7882
+ [exports.FieldDisplayType.AutoNumber]: exports.EntityFieldDataType.AUTO_NUMBER,
7883
+ [exports.FieldDisplayType.Relationship]: exports.EntityFieldDataType.RELATIONSHIP,
7884
+ };
7793
7885
  /**
7794
7886
  * Maps SQL field types to friendly display names
7795
7887
  */
@@ -7805,7 +7897,7 @@ const EntityFieldTypeMap = {
7805
7897
  [SqlFieldType.DATE]: exports.EntityFieldDataType.DATE,
7806
7898
  [SqlFieldType.BIT]: exports.EntityFieldDataType.BOOLEAN,
7807
7899
  [SqlFieldType.DECIMAL]: exports.EntityFieldDataType.DECIMAL,
7808
- [SqlFieldType.MULTILINE]: exports.EntityFieldDataType.MULTILINE_TEXT
7900
+ [SqlFieldType.MULTILINE]: exports.EntityFieldDataType.MULTILINE_TEXT,
7809
7901
  };
7810
7902
 
7811
7903
  /**
@@ -7923,11 +8015,7 @@ class EntityService extends BaseService {
7923
8015
  expansionLevel: options.expansionLevel
7924
8016
  });
7925
8017
  const response = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.GET_RECORD_BY_ID(entityId, recordId), { params });
7926
- // Convert PascalCase response to camelCase
7927
- const camelResponse = pascalToCamelCaseKeys(response.data);
7928
- // Apply EntityMap transformations
7929
- const transformedResponse = transformData(camelResponse, EntityMap);
7930
- return transformedResponse;
8018
+ return response.data;
7931
8019
  }
7932
8020
  /**
7933
8021
  * Inserts a single record into an entity by entity ID
@@ -7960,9 +8048,7 @@ class EntityService extends BaseService {
7960
8048
  params,
7961
8049
  ...options
7962
8050
  });
7963
- // Convert PascalCase response to camelCase
7964
- const camelResponse = pascalToCamelCaseKeys(response.data);
7965
- return camelResponse;
8051
+ return response.data;
7966
8052
  }
7967
8053
  /**
7968
8054
  * Inserts data into an entity by entity ID using batch insert
@@ -8003,9 +8089,7 @@ class EntityService extends BaseService {
8003
8089
  params,
8004
8090
  ...options
8005
8091
  });
8006
- // Convert PascalCase response to camelCase
8007
- const camelResponse = pascalToCamelCaseKeys(response.data);
8008
- return camelResponse;
8092
+ return response.data;
8009
8093
  }
8010
8094
  /**
8011
8095
  * Updates a single record in an entity by entity ID
@@ -8039,9 +8123,7 @@ class EntityService extends BaseService {
8039
8123
  params,
8040
8124
  ...options
8041
8125
  });
8042
- // Convert PascalCase response to camelCase
8043
- const camelResponse = pascalToCamelCaseKeys(response.data);
8044
- return camelResponse;
8126
+ return response.data;
8045
8127
  }
8046
8128
  /**
8047
8129
  * Updates data in an entity by entity ID
@@ -8083,9 +8165,7 @@ class EntityService extends BaseService {
8083
8165
  params,
8084
8166
  ...options
8085
8167
  });
8086
- // Convert PascalCase response to camelCase
8087
- const camelResponse = pascalToCamelCaseKeys(response.data);
8088
- return camelResponse;
8168
+ return response.data;
8089
8169
  }
8090
8170
  /**
8091
8171
  * Deletes data from an entity by entity ID
@@ -8115,9 +8195,7 @@ class EntityService extends BaseService {
8115
8195
  params,
8116
8196
  ...options
8117
8197
  });
8118
- // Convert PascalCase response to camelCase
8119
- const camelResponse = pascalToCamelCaseKeys(response.data);
8120
- return camelResponse;
8198
+ return response.data;
8121
8199
  }
8122
8200
  /**
8123
8201
  * Gets all entities in the system
@@ -8149,6 +8227,99 @@ class EntityService extends BaseService {
8149
8227
  });
8150
8228
  return entities;
8151
8229
  }
8230
+ /**
8231
+ * Queries entity records with filters, sorting, and pagination
8232
+ *
8233
+ * @param id - UUID of the entity
8234
+ * @param options - Query options including filterGroup, selectedFields, sortOptions, and pagination
8235
+ * @returns Promise resolving to {@link NonPaginatedResponse} without pagination options,
8236
+ * or {@link PaginatedResponse} when `pageSize`, `cursor`, or `jumpToPage` are provided
8237
+ *
8238
+ * @example
8239
+ * ```typescript
8240
+ * import { Entities, LogicalOperator, QueryFilterOperator } from '@uipath/uipath-typescript/entities';
8241
+ *
8242
+ * const entities = new Entities(sdk);
8243
+ *
8244
+ * // Non-paginated query with a filter
8245
+ * const result = await entities.queryRecordsById("<entityId>", {
8246
+ * filterGroup: {
8247
+ * logicalOperator: LogicalOperator.And,
8248
+ * queryFilters: [
8249
+ * { fieldName: "status", operator: QueryFilterOperator.Equals, value: "active" }
8250
+ * ]
8251
+ * },
8252
+ * sortOptions: [{ fieldName: "created_at", isDescending: true }],
8253
+ * });
8254
+ * console.log(`Found ${result.totalCount} records`);
8255
+ *
8256
+ * // With pagination
8257
+ * const page1 = await entities.queryRecordsById("<entityId>", {
8258
+ * filterGroup: { queryFilters: [{ fieldName: "status", operator: QueryFilterOperator.Equals, value: "active" }] },
8259
+ * pageSize: 25,
8260
+ * });
8261
+ * if (page1.hasNextPage) {
8262
+ * const page2 = await entities.queryRecordsById("<entityId>", { cursor: page1.nextCursor });
8263
+ * }
8264
+ * ```
8265
+ */
8266
+ async queryRecordsById(id, options) {
8267
+ return PaginationHelpers.getAll({
8268
+ serviceAccess: this.createPaginationServiceAccess(),
8269
+ getEndpoint: () => DATA_FABRIC_ENDPOINTS.ENTITY.QUERY_BY_ID(id),
8270
+ method: HTTP_METHODS.POST,
8271
+ pagination: {
8272
+ paginationType: PaginationType.OFFSET,
8273
+ itemsField: ENTITY_PAGINATION.ITEMS_FIELD,
8274
+ totalCountField: ENTITY_PAGINATION.TOTAL_COUNT_FIELD,
8275
+ paginationParams: {
8276
+ pageSizeParam: ENTITY_OFFSET_PARAMS.PAGE_SIZE_PARAM,
8277
+ offsetParam: ENTITY_OFFSET_PARAMS.OFFSET_PARAM,
8278
+ countParam: ENTITY_OFFSET_PARAMS.COUNT_PARAM
8279
+ }
8280
+ },
8281
+ excludeFromPrefix: ['expansionLevel', 'filterGroup', 'selectedFields', 'sortOptions']
8282
+ }, options);
8283
+ }
8284
+ /**
8285
+ * Imports records from a CSV file into an entity
8286
+ *
8287
+ * @param id - UUID of the entity
8288
+ * @param file - CSV file to import (Blob, File, or Uint8Array)
8289
+ * @returns Promise resolving to import result with record counts
8290
+ *
8291
+ * @example
8292
+ * ```typescript
8293
+ * import { Entities } from '@uipath/uipath-typescript/entities';
8294
+ *
8295
+ * const entities = new Entities(sdk);
8296
+ *
8297
+ * // Browser: upload from file input
8298
+ * const fileInput = document.getElementById('csv-input') as HTMLInputElement;
8299
+ * const result = await entities.importRecordsById("<entityId>", fileInput.files[0]);
8300
+ *
8301
+ * // Node.js: read from disk
8302
+ * const fileBuffer = fs.readFileSync('records.csv');
8303
+ * const result = await entities.importRecordsById("<entityId>", new Blob([fileBuffer], { type: 'text/csv' }));
8304
+ *
8305
+ * console.log(`Inserted ${result.insertedRecords} of ${result.totalRecords} records`);
8306
+ * if (result.errorFileLink) {
8307
+ * console.log(`Error file link: ${result.errorFileLink}`);
8308
+ * }
8309
+ * ```
8310
+ * @internal
8311
+ */
8312
+ async importRecordsById(id, file) {
8313
+ const formData = new FormData();
8314
+ if (file instanceof Uint8Array) {
8315
+ formData.append('file', new Blob([file.buffer]));
8316
+ }
8317
+ else {
8318
+ formData.append('file', file);
8319
+ }
8320
+ const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.BULK_UPLOAD_BY_ID(id), formData);
8321
+ return response.data;
8322
+ }
8152
8323
  /**
8153
8324
  * Downloads an attachment from an entity record field
8154
8325
  *
@@ -8169,7 +8340,7 @@ class EntityService extends BaseService {
8169
8340
  *
8170
8341
  * // Get the recordId from getAllRecords()
8171
8342
  * const records = await entities.getAllRecords(entityId);
8172
- * const recordId = records[0].id;
8343
+ * const recordId = records[0].Id;
8173
8344
  *
8174
8345
  * // Download attachment for a specific record and field
8175
8346
  * const blob = await entities.downloadAttachment(entityId, recordId, 'Documents');
@@ -8203,7 +8374,7 @@ class EntityService extends BaseService {
8203
8374
  *
8204
8375
  * // Get the recordId from getAllRecords()
8205
8376
  * const records = await entities.getAllRecords(entityId);
8206
- * const recordId = records[0].id;
8377
+ * const recordId = records[0].Id;
8207
8378
  *
8208
8379
  * // Upload a file attachment
8209
8380
  * const response = await entities.uploadAttachment(entityId, recordId, 'Documents', file);
@@ -8219,9 +8390,7 @@ class EntityService extends BaseService {
8219
8390
  }
8220
8391
  const params = createParams({ expansionLevel: options?.expansionLevel });
8221
8392
  const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPLOAD_ATTACHMENT(entityId, recordId, fieldName), formData, { params });
8222
- // Convert PascalCase response to camelCase
8223
- const camelResponse = pascalToCamelCaseKeys(response.data);
8224
- return camelResponse;
8393
+ return response.data;
8225
8394
  }
8226
8395
  /**
8227
8396
  * Removes an attachment from a File-type field of an entity record
@@ -8243,7 +8412,7 @@ class EntityService extends BaseService {
8243
8412
  *
8244
8413
  * // Get the recordId from getAllRecords()
8245
8414
  * const records = await entities.getAllRecords(entityId);
8246
- * const recordId = records[0].id;
8415
+ * const recordId = records[0].Id;
8247
8416
  *
8248
8417
  * // Delete attachment for a specific record and field
8249
8418
  * await entities.deleteAttachment(entityId, recordId, 'Documents');
@@ -8275,18 +8444,169 @@ class EntityService extends BaseService {
8275
8444
  return this.insertRecordsById(id, data, options);
8276
8445
  }
8277
8446
  /**
8278
- * @hidden
8279
- * @deprecated Use {@link updateRecordsById} instead.
8447
+ * Creates a new Data Fabric entity with the given schema
8448
+ *
8449
+ * @param name - Entity name — must start with a letter and contain
8450
+ * only letters, numbers, and underscores (e.g., `"productCatalog"`).
8451
+ * @param fields - Array of field definitions
8452
+ * @param options - Optional entity-level settings ({@link EntityCreateOptions})
8453
+ * @returns Promise resolving to the ID of the created entity
8454
+ *
8455
+ * @example
8456
+ * ```typescript
8457
+ * const entityId = await entities.create("product_catalog", [
8458
+ * { fieldName: "product_name", type: EntityFieldDataType.STRING, isRequired: true, isUnique: true },
8459
+ * { fieldName: "price", type: EntityFieldDataType.INTEGER, defaultValue: "0" },
8460
+ * ], { displayName: "Product Catalog", description: "Our product catalog", isRbacEnabled: true });
8461
+ * ```
8462
+ * @internal
8280
8463
  */
8281
- async updateById(id, data, options = {}) {
8282
- return this.updateRecordsById(id, data, options);
8464
+ async create(name, fields, options) {
8465
+ this.validateName(name, 'entity');
8466
+ for (const field of fields) {
8467
+ this.validateName(field.fieldName, 'field');
8468
+ }
8469
+ const opts = options ?? {};
8470
+ const payload = {
8471
+ ...(opts.description !== undefined && { description: opts.description }),
8472
+ displayName: opts.displayName ?? name,
8473
+ entityDefinition: {
8474
+ name,
8475
+ fields: fields.map(f => this.buildSchemaFieldPayload(f)),
8476
+ folderId: opts.folderKey ?? DATA_FABRIC_TENANT_FOLDER_ID,
8477
+ isRbacEnabled: opts.isRbacEnabled ?? false,
8478
+ isInsightsEnabled: opts.isAnalyticsEnabled ?? false,
8479
+ externalFields: opts.externalFields ?? [],
8480
+ },
8481
+ };
8482
+ const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPSERT, payload);
8483
+ return response.data;
8283
8484
  }
8284
8485
  /**
8285
- * @hidden
8286
- * @deprecated Use {@link deleteRecordsById} instead.
8486
+ * Deletes a Data Fabric entity and all its records
8487
+ *
8488
+ * @param id - UUID of the entity to delete
8489
+ * @returns Promise resolving when the entity is deleted
8490
+ *
8491
+ * @example
8492
+ * ```typescript
8493
+ * await entities.deleteById("<entityId>");
8494
+ * ```
8495
+ * @internal
8496
+ */
8497
+ async deleteById(id) {
8498
+ await this.delete(DATA_FABRIC_ENDPOINTS.ENTITY.DELETE(id));
8499
+ }
8500
+ /**
8501
+ * Updates an existing Data Fabric entity — schema and/or metadata.
8502
+ *
8503
+ * Provide any combination of schema fields (`addFields`, `removeFields`, `updateFields`) and
8504
+ * metadata fields (`displayName`, `description`, `isRbacEnabled`). Each group is applied
8505
+ * only when the corresponding fields are present.
8506
+ *
8507
+ * **Warning:** Schema changes (`addFields`, `removeFields`, `updateFields`) use a
8508
+ * read-modify-write pattern — concurrent calls on the same entity may silently
8509
+ * overwrite each other's changes.
8510
+ *
8511
+ * @param id - UUID of the entity to update
8512
+ * @param options - Changes to apply ({@link EntityUpdateByIdOptions})
8513
+ * @returns Promise resolving when the update is complete
8514
+ *
8515
+ * @example
8516
+ * ```typescript
8517
+ * // Schema-only
8518
+ * await entities.updateById("<entityId>", {
8519
+ * addFields: [{ fieldName: "notes", type: EntityFieldDataType.MULTILINE_TEXT }],
8520
+ * removeFields: [{ fieldName: "old_field" }],
8521
+ * });
8522
+ *
8523
+ * // Metadata-only
8524
+ * await entities.updateById("<entityId>", {
8525
+ * displayName: "My Updated Entity",
8526
+ * description: "Updated description",
8527
+ * });
8528
+ *
8529
+ * // Combined
8530
+ * await entities.updateById("<entityId>", {
8531
+ * updateFields: [{ id: "<fieldId>", displayName: "Unit Price", isRequired: true }],
8532
+ * displayName: "Price Catalog",
8533
+ * });
8534
+ * ```
8535
+ * @internal
8536
+ */
8537
+ async updateById(id, options) {
8538
+ const opts = options ?? {};
8539
+ const hasSchemaChanges = !!(opts.addFields?.length || opts.removeFields?.length || opts.updateFields?.length);
8540
+ const hasMetadataChanges = opts.displayName !== undefined || opts.description !== undefined || opts.isRbacEnabled !== undefined;
8541
+ if (hasSchemaChanges) {
8542
+ await this.applySchemaUpdate(id, opts);
8543
+ }
8544
+ if (hasMetadataChanges) {
8545
+ await this.patch(DATA_FABRIC_ENDPOINTS.ENTITY.UPDATE_METADATA(id), {
8546
+ ...(opts.displayName !== undefined && { displayName: opts.displayName }),
8547
+ ...(opts.description !== undefined && { description: opts.description }),
8548
+ ...(opts.isRbacEnabled !== undefined && { isRbacEnabled: opts.isRbacEnabled }),
8549
+ });
8550
+ }
8551
+ }
8552
+ /**
8553
+ * Fetches the current entity schema, applies the field delta, then posts the full updated schema.
8554
+ *
8555
+ * @param entityId - UUID of the entity to update
8556
+ * @param options - Field changes to apply
8557
+ * @private
8287
8558
  */
8288
- async deleteById(id, recordIds, options = {}) {
8289
- return this.deleteRecordsById(id, recordIds, options);
8559
+ async applySchemaUpdate(entityId, options) {
8560
+ const entityResponse = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.GET_BY_ID(entityId));
8561
+ const raw = entityResponse.data;
8562
+ // Carry forward existing non-system fields from GET response (skip system/primary-key fields)
8563
+ let fields = (raw.fields ?? [])
8564
+ .filter(f => !f.isSystemField && !f.isPrimaryKey);
8565
+ // Filter out removed fields
8566
+ if (options.removeFields?.length) {
8567
+ const removeSet = new Set(options.removeFields.map(r => r.fieldName));
8568
+ fields = fields.filter(f => !removeSet.has(f.name));
8569
+ }
8570
+ // Apply per-field metadata updates (matched by field ID)
8571
+ if (options.updateFields?.length) {
8572
+ const updateMap = new Map(options.updateFields.map(u => [u.id, u]));
8573
+ fields = fields.map(f => {
8574
+ const update = updateMap.get(f.id ?? '');
8575
+ if (!update)
8576
+ return f;
8577
+ return {
8578
+ ...f,
8579
+ ...(update.displayName !== undefined && { displayName: update.displayName }),
8580
+ ...(update.description !== undefined && { description: update.description }),
8581
+ ...(update.isRequired !== undefined && { isRequired: update.isRequired }),
8582
+ ...(update.isUnique !== undefined && { isUnique: update.isUnique }),
8583
+ ...(update.isRbacEnabled !== undefined && { isRbacEnabled: update.isRbacEnabled }),
8584
+ ...(update.isEncrypted !== undefined && { isEncrypted: update.isEncrypted }),
8585
+ ...(update.defaultValue !== undefined && { defaultValue: update.defaultValue }),
8586
+ };
8587
+ });
8588
+ }
8589
+ // Build and append new fields
8590
+ const newFields = [];
8591
+ if (options.addFields?.length) {
8592
+ for (const field of options.addFields) {
8593
+ this.validateName(field.fieldName, 'field');
8594
+ }
8595
+ newFields.push(...options.addFields.map(f => this.buildSchemaFieldPayload(f)));
8596
+ }
8597
+ await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPSERT, {
8598
+ displayName: raw.displayName,
8599
+ description: raw.description,
8600
+ entityDefinition: {
8601
+ id: entityId,
8602
+ name: raw.name,
8603
+ fields: [...fields, ...newFields],
8604
+ folderId: raw.folderId ?? DATA_FABRIC_TENANT_FOLDER_ID,
8605
+ isRbacEnabled: raw.isRbacEnabled ?? false,
8606
+ isInsightsEnabled: raw.isInsightsEnabled ?? false,
8607
+ externalFields: raw.externalFields ?? [],
8608
+ },
8609
+ });
8290
8610
  }
8291
8611
  /**
8292
8612
  * Orchestrates all field mapping transformations
@@ -8310,11 +8630,20 @@ class EntityService extends BaseService {
8310
8630
  metadata.fields = metadata.fields.map(field => {
8311
8631
  // Rename sqlType to fieldDataType
8312
8632
  let transformedField = transformData(field, EntityMap);
8313
- // Map SQL field type to friendly name
8633
+ // Map field type: prefer fieldDisplayType for types that share SQL types (File, ChoiceSet, AutoNumber)
8314
8634
  if (transformedField.fieldDataType?.name) {
8315
- const sqlTypeName = transformedField.fieldDataType.name;
8316
- if (EntityFieldTypeMap[sqlTypeName]) {
8317
- transformedField.fieldDataType.name = EntityFieldTypeMap[sqlTypeName];
8635
+ const displayTypeMapped = transformedField.fieldDisplayType
8636
+ ? FieldDisplayTypeToDataType[transformedField.fieldDisplayType]
8637
+ : undefined;
8638
+ if (displayTypeMapped) {
8639
+ transformedField.fieldDataType.name = displayTypeMapped;
8640
+ }
8641
+ else {
8642
+ const rawSqlTypeName = field.sqlType?.name;
8643
+ const mapped = rawSqlTypeName ? EntityFieldTypeMap[rawSqlTypeName] : undefined;
8644
+ if (mapped) {
8645
+ transformedField.fieldDataType.name = mapped;
8646
+ }
8318
8647
  }
8319
8648
  }
8320
8649
  this.transformNestedReferences(transformedField);
@@ -8358,7 +8687,44 @@ class EntityService extends BaseService {
8358
8687
  return externalSource;
8359
8688
  });
8360
8689
  }
8690
+ /** Converts a user-facing EntityCreateFieldOptions to the raw API field payload */
8691
+ buildSchemaFieldPayload(field) {
8692
+ this.validateName(field.fieldName, 'field');
8693
+ const mapping = EntitySchemaFieldTypeMap[field.type ?? exports.EntityFieldDataType.STRING];
8694
+ return {
8695
+ name: field.fieldName,
8696
+ displayName: field.displayName ?? field.fieldName,
8697
+ sqlType: { name: mapping.sqlTypeName },
8698
+ fieldDisplayType: mapping.fieldDisplayType,
8699
+ description: field.description ?? '',
8700
+ isRequired: field.isRequired ?? false,
8701
+ isUnique: field.isUnique ?? false,
8702
+ isRbacEnabled: field.isRbacEnabled ?? false,
8703
+ isEncrypted: field.isEncrypted ?? false,
8704
+ ...(field.defaultValue !== undefined && { defaultValue: field.defaultValue }),
8705
+ ...(field.choiceSetId !== undefined && { choiceSetId: field.choiceSetId }),
8706
+ ...(field.referenceEntityName !== undefined && { referenceEntityName: field.referenceEntityName }),
8707
+ ...(field.referenceFieldName !== undefined && { referenceFieldName: field.referenceFieldName }),
8708
+ };
8709
+ }
8710
+ validateName(name, context) {
8711
+ if (name.length < 3 || name.length > 100 || !/^[a-zA-Z]\w*$/.test(name)) {
8712
+ const suggestion = name.replace(/\W/g, '').replace(/^[0-9_]+/, '');
8713
+ const defaultName = `My${context.charAt(0).toUpperCase() + context.slice(1)}`;
8714
+ throw new ValidationError({
8715
+ message: `Invalid ${context} name '${name}'. Must start with a letter, contain only letters, numbers, and underscores, 3–100 characters (e.g., "${suggestion || defaultName}").`
8716
+ });
8717
+ }
8718
+ if (context === 'field' && EntityService.RESERVED_FIELD_NAMES.has(name)) {
8719
+ throw new ValidationError({
8720
+ message: `Field name '${name}' is reserved. Reserved names: ${[...EntityService.RESERVED_FIELD_NAMES].join(', ')}.`
8721
+ });
8722
+ }
8723
+ }
8361
8724
  }
8725
+ EntityService.RESERVED_FIELD_NAMES = new Set([
8726
+ 'Id', 'CreatedBy', 'CreateTime', 'UpdatedBy', 'UpdateTime'
8727
+ ]);
8362
8728
  __decorate([
8363
8729
  track('Entities.GetById')
8364
8730
  ], EntityService.prototype, "getById", null);
@@ -8386,6 +8752,12 @@ __decorate([
8386
8752
  __decorate([
8387
8753
  track('Entities.GetAll')
8388
8754
  ], EntityService.prototype, "getAll", null);
8755
+ __decorate([
8756
+ track('Entities.QueryRecordsById')
8757
+ ], EntityService.prototype, "queryRecordsById", null);
8758
+ __decorate([
8759
+ track('Entities.ImportRecordsById')
8760
+ ], EntityService.prototype, "importRecordsById", null);
8389
8761
  __decorate([
8390
8762
  track('Entities.DownloadAttachment')
8391
8763
  ], EntityService.prototype, "downloadAttachment", null);
@@ -8395,6 +8767,15 @@ __decorate([
8395
8767
  __decorate([
8396
8768
  track('Entities.DeleteAttachment')
8397
8769
  ], EntityService.prototype, "deleteAttachment", null);
8770
+ __decorate([
8771
+ track('Entities.Create')
8772
+ ], EntityService.prototype, "create", null);
8773
+ __decorate([
8774
+ track('Entities.DeleteById')
8775
+ ], EntityService.prototype, "deleteById", null);
8776
+ __decorate([
8777
+ track('Entities.UpdateById')
8778
+ ], EntityService.prototype, "updateById", null);
8398
8779
 
8399
8780
  class ChoiceSetService extends BaseService {
8400
8781
  /**
@@ -10962,6 +11343,36 @@ exports.BucketOptions = void 0;
10962
11343
  BucketOptions["AccessDataThroughOrchestrator"] = "AccessDataThroughOrchestrator";
10963
11344
  })(exports.BucketOptions || (exports.BucketOptions = {}));
10964
11345
 
11346
+ /**
11347
+ * Creates methods for a job response object.
11348
+ *
11349
+ * @param jobData - The raw job data from API
11350
+ * @param service - The job service instance
11351
+ * @returns Object containing job methods
11352
+ */
11353
+ function createJobMethods(jobData, service) {
11354
+ return {
11355
+ async getOutput() {
11356
+ if (!jobData.key)
11357
+ throw new Error('Job key is undefined');
11358
+ if (!jobData.folderId)
11359
+ throw new Error('Job folderId is undefined');
11360
+ return service.getOutput(jobData.key, jobData.folderId);
11361
+ },
11362
+ };
11363
+ }
11364
+ /**
11365
+ * Creates a job response with bound methods.
11366
+ *
11367
+ * @param jobData - The raw job data from API
11368
+ * @param service - The job service instance
11369
+ * @returns A job object with added methods
11370
+ */
11371
+ function createJobWithMethods(jobData, service) {
11372
+ const methods = createJobMethods(jobData, service);
11373
+ return Object.assign({}, jobData, methods);
11374
+ }
11375
+
10965
11376
  /**
10966
11377
  * Maps fields for Job entities to ensure consistent naming
10967
11378
  * Semantic renames only — case conversion handled by pascalToCamelCaseKeys()
@@ -10977,27 +11388,81 @@ const JobMap = {
10977
11388
  release: 'process',
10978
11389
  };
10979
11390
 
11391
+ /**
11392
+ * Maps fields for Attachment entities to ensure consistent naming
11393
+ */
11394
+ const AttachmentsMap = {
11395
+ creationTime: 'createdTime',
11396
+ lastModificationTime: 'lastModifiedTime'
11397
+ };
11398
+
11399
+ class AttachmentService extends BaseService {
11400
+ /**
11401
+ * Gets an attachment by ID
11402
+ * @param id - The UUID of the attachment to retrieve
11403
+ * @param options - Optional query parameters (expand, select)
11404
+ * @returns Promise resolving to the attachment
11405
+ *
11406
+ * @example
11407
+ * ```typescript
11408
+ * import { Attachments } from '@uipath/uipath-typescript/attachments';
11409
+ *
11410
+ * const attachments = new Attachments(sdk);
11411
+ * const attachment = await attachments.getById('12345678-1234-1234-1234-123456789abc');
11412
+ * ```
11413
+ */
11414
+ async getById(id, options = {}) {
11415
+ if (!id) {
11416
+ throw new ValidationError({ message: 'id is required for getById' });
11417
+ }
11418
+ // Prefix all keys in options with $ for OData
11419
+ const keysToPrefix = Object.keys(options);
11420
+ const apiOptions = addPrefixToKeys(options, ODATA_PREFIX, keysToPrefix);
11421
+ const response = await this.get(ORCHESTRATOR_ATTACHMENT_ENDPOINTS.GET_BY_ID(id), {
11422
+ params: apiOptions,
11423
+ });
11424
+ // Transform response from PascalCase to camelCase, then apply field maps
11425
+ const camelCased = pascalToCamelCaseKeys(response.data);
11426
+ camelCased.blobFileAccess = transformData(camelCased.blobFileAccess, BucketMap);
11427
+ return transformData(camelCased, AttachmentsMap);
11428
+ }
11429
+ }
11430
+ __decorate([
11431
+ track('Attachments.GetById')
11432
+ ], AttachmentService.prototype, "getById", null);
11433
+
10980
11434
  /**
10981
11435
  * Service for interacting with UiPath Orchestrator Jobs API
10982
11436
  */
10983
11437
  class JobService extends FolderScopedService {
10984
11438
  /**
10985
- * Gets all jobs across folders with optional filtering
11439
+ * Creates an instance of the Jobs service.
10986
11440
  *
10987
- * @param options - Query options including optional folderId and pagination options
10988
- * @returns Promise resolving to array of jobs or paginated response
11441
+ * @param instance - UiPath SDK instance providing authentication and configuration
11442
+ */
11443
+ constructor(instance) {
11444
+ super(instance);
11445
+ this.attachmentService = new AttachmentService(instance);
11446
+ }
11447
+ /**
11448
+ * Gets all jobs across folders with optional filtering and pagination.
10989
11449
  *
10990
- * @example
10991
- * ```typescript
10992
- * import { Jobs } from '@uipath/uipath-typescript/jobs';
11450
+ * Returns jobs with full details including state, timing, and input/output arguments.
11451
+ * Pass `folderId` to scope the query to a specific folder.
10993
11452
  *
10994
- * const jobs = new Jobs(sdk);
11453
+ * !!! info "Input and output fields are not included in `getAll` responses"
11454
+ * The `inputArguments`, `inputFile`, `outputArguments`, and `outputFile` fields will always be `null` in the `getAll` response. To retrieve a job's output, use the {@link getOutput} method with the job's `key` and `folderId`.
10995
11455
  *
11456
+ * @param options - Query options including optional folderId, filtering, and pagination options
11457
+ * @returns Promise resolving to either an array of jobs {@link NonPaginatedResponse}<{@link JobGetResponse}> or a {@link PaginatedResponse}<{@link JobGetResponse}> when pagination options are used.
11458
+ * {@link JobGetResponse}
11459
+ * @example
11460
+ * ```typescript
10996
11461
  * // Get all jobs
10997
11462
  * const allJobs = await jobs.getAll();
10998
11463
  *
10999
11464
  * // Get all jobs in a specific folder
11000
- * const folderJobs = await jobs.getAll({ folderId: 123 });
11465
+ * const folderJobs = await jobs.getAll({ folderId: <folderId> });
11001
11466
  *
11002
11467
  * // With filtering
11003
11468
  * const runningJobs = await jobs.getAll({
@@ -11011,10 +11476,19 @@ class JobService extends FolderScopedService {
11011
11476
  * if (page1.hasNextPage) {
11012
11477
  * const page2 = await jobs.getAll({ cursor: page1.nextCursor });
11013
11478
  * }
11479
+ *
11480
+ * // Jump to specific page
11481
+ * const page5 = await jobs.getAll({
11482
+ * jumpToPage: 5,
11483
+ * pageSize: 10
11484
+ * });
11014
11485
  * ```
11015
11486
  */
11016
11487
  async getAll(options) {
11017
- const transformJobResponse = (job) => transformData(pascalToCamelCaseKeys(job), JobMap);
11488
+ const transformJobResponse = (job) => {
11489
+ const rawJob = transformData(pascalToCamelCaseKeys(job), JobMap);
11490
+ return createJobWithMethods(rawJob, this);
11491
+ };
11018
11492
  return PaginationHelpers.getAll({
11019
11493
  serviceAccess: this.createPaginationServiceAccess(),
11020
11494
  getEndpoint: () => JOB_ENDPOINTS.GET_ALL,
@@ -11032,10 +11506,144 @@ class JobService extends FolderScopedService {
11032
11506
  },
11033
11507
  }, options);
11034
11508
  }
11509
+ /**
11510
+ * Gets a job by its unique key (GUID).
11511
+ *
11512
+ * Returns the full job details including state, timing, input/output arguments, and error information.
11513
+ * Use `expand` to include related entities like `robot`, or `machine`.
11514
+ *
11515
+ * @param id - The unique key (GUID) of the job to retrieve
11516
+ * @param folderId - The folder ID where the job resides
11517
+ * @param options - Optional query options for expanding or selecting fields
11518
+ * @returns Promise resolving to a {@link JobGetResponse} with full job details and bound methods
11519
+ *
11520
+ * @example
11521
+ * ```typescript
11522
+ * // Get a job by key
11523
+ * const job = await jobs.getById(<id>, <folderId>);
11524
+ * console.log(job.state, job.processName);
11525
+ * ```
11526
+ *
11527
+ * @example
11528
+ * ```typescript
11529
+ * // With expanded related entities
11530
+ * const job = await jobs.getById(<id>, <folderId>, {
11531
+ * expand: 'robot,machine'
11532
+ * });
11533
+ * console.log(job.robot?.name, job.machine?.name);
11534
+ * ```
11535
+ */
11536
+ async getById(id, folderId, options) {
11537
+ if (!id) {
11538
+ throw new ValidationError({ message: 'id is required for getById' });
11539
+ }
11540
+ if (!folderId) {
11541
+ throw new ValidationError({ message: 'folderId is required for getById' });
11542
+ }
11543
+ const headers = createHeaders({ [FOLDER_ID]: folderId });
11544
+ const keysToPrefix = Object.keys(options ?? {});
11545
+ const apiOptions = options ? addPrefixToKeys(options, ODATA_PREFIX, keysToPrefix) : {};
11546
+ const response = await this.get(JOB_ENDPOINTS.GET_BY_KEY(id), {
11547
+ params: apiOptions,
11548
+ headers,
11549
+ });
11550
+ const rawJob = transformData(pascalToCamelCaseKeys(response.data), JobMap);
11551
+ return createJobWithMethods(rawJob, this);
11552
+ }
11553
+ /**
11554
+ * Gets the output of a completed job.
11555
+ *
11556
+ * Retrieves the job's output arguments, handling both inline output (stored directly on the job
11557
+ * as a JSON string in `outputArguments`) and file-based output (stored as a blob attachment for
11558
+ * large outputs). Returns the parsed JSON output or `null` if the job has no output.
11559
+ *
11560
+ * @param jobKey - The unique key (GUID) of the job to retrieve output from
11561
+ * @param folderId - The folder ID where the job resides
11562
+ * @returns Promise resolving to the parsed output as `Record<string, unknown>`, or `null` if no output exists
11563
+ *
11564
+ * @example
11565
+ * ```typescript
11566
+ * // Get output from a completed job
11567
+ * const output = await jobs.getOutput(<jobKey>, <folderId>);
11568
+ *
11569
+ * if (output) {
11570
+ * console.log('Job output:', output);
11571
+ * }
11572
+ * ```
11573
+ *
11574
+ * @example
11575
+ * ```typescript
11576
+ * // Get output using bound method (jobKey and folderId are taken from the job object)
11577
+ * const allJobs = await jobs.getAll();
11578
+ * const completedJob = allJobs.items.find(j => j.state === JobState.Successful);
11579
+ *
11580
+ * if (completedJob) {
11581
+ * const output = await completedJob.getOutput();
11582
+ * }
11583
+ * ```
11584
+ */
11585
+ async getOutput(jobKey, folderId) {
11586
+ if (!jobKey) {
11587
+ throw new ValidationError({ message: 'jobKey is required for getOutput' });
11588
+ }
11589
+ const job = await this.getById(jobKey, folderId, { select: 'outputArguments,outputFile' });
11590
+ if (job.outputArguments) {
11591
+ try {
11592
+ return JSON.parse(job.outputArguments);
11593
+ }
11594
+ catch {
11595
+ throw new ServerError({ message: 'Failed to parse job output arguments as JSON' });
11596
+ }
11597
+ }
11598
+ if (job.outputFile) {
11599
+ return this.downloadOutputFile(job.outputFile);
11600
+ }
11601
+ return null;
11602
+ }
11603
+ /**
11604
+ * Downloads the output file content via the Attachments API.
11605
+ * 1. Fetches blob access info from the attachment using AttachmentService
11606
+ * 2. Downloads content from the presigned blob URI
11607
+ * 3. Parses and returns the JSON content
11608
+ */
11609
+ async downloadOutputFile(outputFileKey) {
11610
+ const attachment = await this.attachmentService.getById(outputFileKey);
11611
+ const blobAccess = attachment.blobFileAccess;
11612
+ if (!blobAccess?.uri) {
11613
+ return null;
11614
+ }
11615
+ const blobHeaders = { ...blobAccess.headers };
11616
+ // Add auth header if the blob URI requires authenticated access
11617
+ if (blobAccess.requiresAuth) {
11618
+ const token = await this.getValidAuthToken();
11619
+ blobHeaders['Authorization'] = `Bearer ${token}`;
11620
+ }
11621
+ const blobResponse = await fetch(blobAccess.uri, {
11622
+ method: 'GET',
11623
+ headers: blobHeaders,
11624
+ });
11625
+ if (!blobResponse.ok) {
11626
+ const errorInfo = await errorResponseParser.parse(blobResponse);
11627
+ throw ErrorFactory.createFromHttpStatus(blobResponse.status, errorInfo);
11628
+ }
11629
+ const content = await blobResponse.text();
11630
+ try {
11631
+ return JSON.parse(content);
11632
+ }
11633
+ catch {
11634
+ throw new ServerError({ message: 'Failed to parse job output file as JSON' });
11635
+ }
11636
+ }
11035
11637
  }
11036
11638
  __decorate([
11037
11639
  track('Jobs.GetAll')
11038
11640
  ], JobService.prototype, "getAll", null);
11641
+ __decorate([
11642
+ track('Jobs.GetById')
11643
+ ], JobService.prototype, "getById", null);
11644
+ __decorate([
11645
+ track('Jobs.GetOutput')
11646
+ ], JobService.prototype, "getOutput", null);
11039
11647
 
11040
11648
  /**
11041
11649
  * Enum for job sub-state
@@ -11062,6 +11670,22 @@ exports.ServerlessJobType = void 0;
11062
11670
  ServerlessJobType["PythonAgent"] = "PythonAgent";
11063
11671
  })(exports.ServerlessJobType || (exports.ServerlessJobType = {}));
11064
11672
 
11673
+ /**
11674
+ * Common enum for job state used across services
11675
+ */
11676
+ exports.JobState = void 0;
11677
+ (function (JobState) {
11678
+ JobState["Pending"] = "Pending";
11679
+ JobState["Running"] = "Running";
11680
+ JobState["Stopping"] = "Stopping";
11681
+ JobState["Terminating"] = "Terminating";
11682
+ JobState["Faulted"] = "Faulted";
11683
+ JobState["Successful"] = "Successful";
11684
+ JobState["Stopped"] = "Stopped";
11685
+ JobState["Suspended"] = "Suspended";
11686
+ JobState["Resumed"] = "Resumed";
11687
+ })(exports.JobState || (exports.JobState = {}));
11688
+
11065
11689
  /**
11066
11690
  * Maps fields for Process entities to ensure consistent naming
11067
11691
  */
@@ -11518,49 +12142,6 @@ __decorate([
11518
12142
  track('Queues.GetById')
11519
12143
  ], QueueService.prototype, "getById", null);
11520
12144
 
11521
- /**
11522
- * Maps fields for Attachment entities to ensure consistent naming
11523
- */
11524
- const AttachmentsMap = {
11525
- creationTime: 'createdTime',
11526
- lastModificationTime: 'lastModifiedTime'
11527
- };
11528
-
11529
- class AttachmentService extends BaseService {
11530
- /**
11531
- * Gets an attachment by ID
11532
- * @param id - The UUID of the attachment to retrieve
11533
- * @param options - Optional query parameters (expand, select)
11534
- * @returns Promise resolving to the attachment
11535
- *
11536
- * @example
11537
- * ```typescript
11538
- * import { Attachments } from '@uipath/uipath-typescript/attachments';
11539
- *
11540
- * const attachments = new Attachments(sdk);
11541
- * const attachment = await attachments.getById('12345678-1234-1234-1234-123456789abc');
11542
- * ```
11543
- */
11544
- async getById(id, options = {}) {
11545
- if (!id) {
11546
- throw new ValidationError({ message: 'id is required for getById' });
11547
- }
11548
- // Prefix all keys in options with $ for OData
11549
- const keysToPrefix = Object.keys(options);
11550
- const apiOptions = addPrefixToKeys(options, ODATA_PREFIX, keysToPrefix);
11551
- const response = await this.get(ORCHESTRATOR_ATTACHMENT_ENDPOINTS.GET_BY_ID(id), {
11552
- params: apiOptions,
11553
- });
11554
- // Transform response from PascalCase to camelCase, then apply field maps
11555
- const camelCased = pascalToCamelCaseKeys(response.data);
11556
- camelCased.blobFileAccess = transformData(camelCased.blobFileAccess, BucketMap);
11557
- return transformData(camelCased, AttachmentsMap);
11558
- }
11559
- }
11560
- __decorate([
11561
- track('Attachments.GetById')
11562
- ], AttachmentService.prototype, "getById", null);
11563
-
11564
12145
  /**
11565
12146
  * UiPath SDK - Legacy class providing all services through property getters.
11566
12147
  *
@@ -11676,22 +12257,6 @@ class UiPath extends UiPath$1 {
11676
12257
  }
11677
12258
  }
11678
12259
 
11679
- /**
11680
- * Common enum for job state used across services
11681
- */
11682
- exports.JobState = void 0;
11683
- (function (JobState) {
11684
- JobState["Pending"] = "Pending";
11685
- JobState["Running"] = "Running";
11686
- JobState["Stopping"] = "Stopping";
11687
- JobState["Terminating"] = "Terminating";
11688
- JobState["Faulted"] = "Faulted";
11689
- JobState["Successful"] = "Successful";
11690
- JobState["Stopped"] = "Stopped";
11691
- JobState["Suspended"] = "Suspended";
11692
- JobState["Resumed"] = "Resumed";
11693
- })(exports.JobState || (exports.JobState = {}));
11694
-
11695
12260
  /**
11696
12261
  * Common Constants for Conversational Agent
11697
12262
  */
@@ -12064,6 +12629,7 @@ exports.createAgentWithMethods = createAgentWithMethods;
12064
12629
  exports.createCaseInstanceWithMethods = createCaseInstanceWithMethods;
12065
12630
  exports.createConversationWithMethods = createConversationWithMethods;
12066
12631
  exports.createEntityWithMethods = createEntityWithMethods;
12632
+ exports.createJobWithMethods = createJobWithMethods;
12067
12633
  exports.createProcessInstanceWithMethods = createProcessInstanceWithMethods;
12068
12634
  exports.createProcessWithMethods = createProcessWithMethods;
12069
12635
  exports.createTaskWithMethods = createTaskWithMethods;