@uipath/tasks-tool 1.204.0-preview.254 → 1.205.0-preview.256

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.
@@ -9,7 +9,7 @@ import {
9
9
  extractErrorMessageSync,
10
10
  getLoginStatusAsync,
11
11
  processContext
12
- } from "./tool-x7dndnx8.js";
12
+ } from "./tool-s6dm918n.js";
13
13
  import {
14
14
  require_src
15
15
  } from "./tool-bndhpxxj.js";
@@ -4503,7 +4503,7 @@ var package_default = {
4503
4503
  name: "@uipath/tasks-tool",
4504
4504
  author: "UiPath",
4505
4505
  license: "SEE LICENSE IN LICENSE.txt",
4506
- version: "1.204.0-preview.254",
4506
+ version: "1.205.0-preview.256",
4507
4507
  description: "Manage Action Center tasks.",
4508
4508
  publishConfig: {
4509
4509
  registry: "https://npm.pkg.github.com/"
@@ -4532,7 +4532,7 @@ var package_default = {
4532
4532
  "@uipath/auth": "workspace:*",
4533
4533
  "@uipath/common": "workspace:*",
4534
4534
  "@uipath/orchestrator-sdk": "workspace:*",
4535
- "@uipath/uipath-typescript": "^1.7.1",
4535
+ "@uipath/uipath-typescript": "^1.8.0",
4536
4536
  commander: "^14.0.3",
4537
4537
  typescript: "^7.0.2"
4538
4538
  }
@@ -8450,6 +8450,7 @@ object({
8450
8450
  baseUrl: string().url().default("https://cloud.uipath.com"),
8451
8451
  orgName: string().min(1),
8452
8452
  tenantName: string().min(1),
8453
+ organizationId: string().optional(),
8453
8454
  secret: string().optional(),
8454
8455
  clientId: string().optional(),
8455
8456
  redirectUri: string().url().optional(),
@@ -8462,6 +8463,7 @@ class UiPathConfig {
8462
8463
  this.baseUrl = options.baseUrl;
8463
8464
  this.orgName = options.orgName;
8464
8465
  this.tenantName = options.tenantName;
8466
+ this.organizationId = options.organizationId;
8465
8467
  this.secret = options.secret;
8466
8468
  this.clientId = options.clientId;
8467
8469
  this.redirectUri = options.redirectUri;
@@ -8506,6 +8508,11 @@ var AUTH_STORAGE_KEYS = {
8506
8508
  OAUTH_CONTEXT: "uipath_sdk_oauth_context",
8507
8509
  CODE_VERIFIER: "uipath_sdk_code_verifier"
8508
8510
  };
8511
+ var TOKEN_EXPIRY_BUFFER_MS = 60 * 1000;
8512
+ function getExpiryMs(expiresAt) {
8513
+ const ms = expiresAt instanceof Date ? expiresAt.getTime() : new Date(expiresAt).getTime();
8514
+ return Number.isNaN(ms) ? 0 : ms;
8515
+ }
8509
8516
  function hasOAuthConfig(config2) {
8510
8517
  return Boolean(config2.clientId && config2.redirectUri && config2.scope);
8511
8518
  }
@@ -8764,50 +8771,61 @@ var TASK_NOTE_ENDPOINTS = {
8764
8771
  GET_BY_TASK_ID: (taskId) => `${ORCHESTRATOR_BASE}/odata/TaskNotes/UiPath.Server.Configuration.OData.GetByTaskId(taskId=${taskId})`,
8765
8772
  CREATE: `${ORCHESTRATOR_BASE}/odata/TaskNotes/UiPath.Server.Configuration.OData.CreateTaskNote`
8766
8773
  };
8767
- var BUCKET_ENDPOINTS = {
8768
- GET_BY_FOLDER: `${ORCHESTRATOR_BASE}/odata/Buckets`,
8769
- GET_ALL: `${ORCHESTRATOR_BASE}/odata/Buckets/UiPath.Server.Configuration.OData.GetBucketsAcrossFolders`,
8770
- GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})`,
8771
- GET_FILE_META_DATA: (id) => `${ORCHESTRATOR_BASE}/api/Buckets/${id}/ListFiles`,
8772
- GET_READ_URI: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})/UiPath.Server.Configuration.OData.GetReadUri`,
8773
- GET_WRITE_URI: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})/UiPath.Server.Configuration.OData.GetWriteUri`,
8774
- DELETE_FILE: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})/UiPath.Server.Configuration.OData.DeleteFile`,
8775
- GET_FILES: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})/UiPath.Server.Configuration.OData.GetFiles`
8776
- };
8777
- var PROCESS_ENDPOINTS = {
8778
- GET_ALL: `${ORCHESTRATOR_BASE}/odata/Releases`,
8779
- START_PROCESS: `${ORCHESTRATOR_BASE}/odata/Jobs/UiPath.Server.Configuration.OData.StartJobs`,
8780
- GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/Releases(${id})`
8781
- };
8782
- var QUEUE_ENDPOINTS = {
8783
- GET_BY_FOLDER: `${ORCHESTRATOR_BASE}/odata/QueueDefinitions`,
8784
- GET_ALL: `${ORCHESTRATOR_BASE}/odata/QueueDefinitions/UiPath.Server.Configuration.OData.GetQueuesAcrossFolders`,
8785
- GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/QueueDefinitions(${id})`,
8786
- GET_ITEMS: `${ORCHESTRATOR_BASE}/odata/QueueItems`,
8787
- ADD_ITEM: `${ORCHESTRATOR_BASE}/odata/Queues/UiPathODataSvc.AddQueueItem`,
8788
- START_TRANSACTION: `${ORCHESTRATOR_BASE}/odata/Queues/UiPathODataSvc.StartTransaction`,
8789
- SET_TRANSACTION_RESULT: (itemId) => `${ORCHESTRATOR_BASE}/odata/Queues(${itemId})/UiPathODataSvc.SetTransactionResult`
8790
- };
8791
- var JOB_ENDPOINTS = {
8792
- GET_ALL: `${ORCHESTRATOR_BASE}/odata/Jobs`,
8793
- GET_BY_KEY: (identifier) => `${ORCHESTRATOR_BASE}/odata/Jobs/UiPath.Server.Configuration.OData.GetByKey(identifier=${identifier})`,
8794
- STOP: `${ORCHESTRATOR_BASE}/odata/Jobs/UiPath.Server.Configuration.OData.StopJobs`,
8795
- RESUME: `${ORCHESTRATOR_BASE}/odata/Jobs/UiPath.Server.Configuration.OData.ResumeJob`,
8796
- RESTART: `${ORCHESTRATOR_BASE}/odata/Jobs/UiPath.Server.Configuration.OData.RestartJob`,
8797
- ATTACHMENTS: {
8798
- GET_BY_JOB_KEY: `${ORCHESTRATOR_BASE}/api/JobAttachments/GetByJobKey`,
8799
- LINK: `${ORCHESTRATOR_BASE}/api/JobAttachments/Post`
8774
+ var DATA_FABRIC_TENANT_FOLDER_ID = "00000000-0000-0000-0000-000000000000";
8775
+ var DATA_FABRIC_ENDPOINTS = {
8776
+ ENTITY: {
8777
+ GET_ALL: `${DATAFABRIC_BASE}/api/Entity`,
8778
+ GET_ALL_V3: `${DATAFABRIC_BASE}/api/v3/entities`,
8779
+ GET_ENTITY_RECORDS: (entityId) => `${DATAFABRIC_BASE}/api/v3/entities/entity/${entityId}/read`,
8780
+ GET_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/v3/entities/${entityId}`,
8781
+ GET_RECORD_BY_ID: (entityId, recordId) => `${DATAFABRIC_BASE}/api/v3/entities/entity/${entityId}/read/${recordId}`,
8782
+ INSERT_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/v3/entities/entity/${entityId}/insert`,
8783
+ BATCH_INSERT_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/v3/entities/entity/${entityId}/insert-batch`,
8784
+ UPDATE_RECORD_BY_ID: (entityId, recordId) => `${DATAFABRIC_BASE}/api/v3/entities/entity/${entityId}/update/${recordId}`,
8785
+ UPDATE_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/v3/entities/entity/${entityId}/update-batch`,
8786
+ DELETE_RECORD_BY_ID: (entityId, recordId) => `${DATAFABRIC_BASE}/api/v3/entities/entity/${entityId}/delete/${recordId}`,
8787
+ DELETE_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/v3/entities/entity/${entityId}/delete-batch`,
8788
+ UPSERT: `${DATAFABRIC_BASE}/api/v3/entities`,
8789
+ DELETE: (entityId) => `${DATAFABRIC_BASE}/api/v3/entities/${entityId}`,
8790
+ UPDATE_METADATA: (entityId) => `${DATAFABRIC_BASE}/api/v3/entities/${entityId}/metadata`,
8791
+ QUERY_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/v3/entities/entity/${entityId}/query`,
8792
+ QUERY_BY_NAME: (entityName) => `${DATAFABRIC_BASE}/api/v3/entities/${entityName}/query`,
8793
+ BULK_UPLOAD_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/bulk-upload`,
8794
+ DOWNLOAD_ATTACHMENT: (entityId, recordId, fieldName) => `${DATAFABRIC_BASE}/api/Attachment/entity/${entityId}/${recordId}/${fieldName}`,
8795
+ UPLOAD_ATTACHMENT: (entityId, recordId, fieldName) => `${DATAFABRIC_BASE}/api/Attachment/entity/${entityId}/${recordId}/${fieldName}`,
8796
+ DELETE_ATTACHMENT: (entityId, recordId, fieldName) => `${DATAFABRIC_BASE}/api/Attachment/entity/${entityId}/${recordId}/${fieldName}`,
8797
+ GET_BY_NAME: (entityName) => `${DATAFABRIC_BASE}/api/v3/entities/${entityName}/metadata`,
8798
+ GET_ENTITY_RECORDS_BY_NAME: (entityName) => `${DATAFABRIC_BASE}/api/v3/entities/${entityName}/read`,
8799
+ GET_RECORD_BY_NAME: (entityName, recordId) => `${DATAFABRIC_BASE}/api/v3/entities/${entityName}/read/${recordId}`,
8800
+ INSERT_BY_NAME: (entityName) => `${DATAFABRIC_BASE}/api/v3/entities/${entityName}/insert`,
8801
+ BATCH_INSERT_BY_NAME: (entityName) => `${DATAFABRIC_BASE}/api/v3/entities/${entityName}/insert-batch`,
8802
+ UPDATE_RECORD_BY_NAME: (entityName, recordId) => `${DATAFABRIC_BASE}/api/v3/entities/${entityName}/update/${recordId}`,
8803
+ UPDATE_BY_NAME: (entityName) => `${DATAFABRIC_BASE}/api/v3/entities/${entityName}/update-batch`,
8804
+ DELETE_RECORD_BY_NAME: (entityName, recordId) => `${DATAFABRIC_BASE}/api/v3/entities/${entityName}/delete/${recordId}`,
8805
+ DELETE_BY_NAME: (entityName) => `${DATAFABRIC_BASE}/api/v3/entities/${entityName}/delete-batch`,
8806
+ BULK_UPLOAD_BY_NAME: (entityName) => `${DATAFABRIC_BASE}/api/EntityService/${entityName}/bulk-upload`,
8807
+ UPSERT_RECORD_BY_NAME: (entityName) => `${DATAFABRIC_BASE}/api/v3/entities/${entityName}/upsert`,
8808
+ ATTACHMENT_BY_NAME: (entityName, recordId, fieldName) => `${DATAFABRIC_BASE}/api/Attachment/${entityName}/${recordId}/${fieldName}`
8809
+ },
8810
+ CHOICESETS: {
8811
+ GET_ALL: `${DATAFABRIC_BASE}/api/Entity/choiceset`,
8812
+ GET_BY_ID: (choiceSetId) => `${DATAFABRIC_BASE}/api/v3/entities/entity/${choiceSetId}/query_expansion`,
8813
+ CREATE: `${DATAFABRIC_BASE}/api/Entity/choiceset`,
8814
+ UPDATE: (choiceSetId) => `${DATAFABRIC_BASE}/api/v3/entities/${choiceSetId}/metadata`,
8815
+ DELETE: (choiceSetId) => `${DATAFABRIC_BASE}/api/v3/entities/${choiceSetId}`,
8816
+ INSERT_BY_NAME: (choiceSetName) => `${DATAFABRIC_BASE}/api/EntityService/${choiceSetName}/choiceset/insert`,
8817
+ UPDATE_BY_NAME: (choiceSetName, valueId) => `${DATAFABRIC_BASE}/api/EntityService/${choiceSetName}/choiceset/${valueId}/update`,
8818
+ DELETE_BY_ID: (choiceSetId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${choiceSetId}/choiceset/delete`
8819
+ },
8820
+ ROLES: {
8821
+ GET_ALL: `${DATAFABRIC_BASE}/api/v2/Role`
8822
+ },
8823
+ DIRECTORY: {
8824
+ GET_ALL: `${DATAFABRIC_BASE}/api/Directory`,
8825
+ ASSIGN_ROLES: `${DATAFABRIC_BASE}/api/Directory/Role`,
8826
+ REVOKE_ROLES: `${DATAFABRIC_BASE}/api/Directory/RevokeRole`
8800
8827
  }
8801
8828
  };
8802
- var ASSET_ENDPOINTS = {
8803
- GET_BY_FOLDER: `${ORCHESTRATOR_BASE}/odata/Assets/UiPath.Server.Configuration.OData.GetFiltered`,
8804
- GET_ALL: `${ORCHESTRATOR_BASE}/odata/Assets/UiPath.Server.Configuration.OData.GetAssetsAcrossFolders`,
8805
- GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/Assets(${id})`
8806
- };
8807
- var ORCHESTRATOR_ATTACHMENT_ENDPOINTS = {
8808
- GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/Attachments(${id})`,
8809
- CREATE: `${ORCHESTRATOR_BASE}/odata/Attachments`
8810
- };
8811
8829
  var MAESTRO_ENDPOINTS = {
8812
8830
  PROCESSES: {
8813
8831
  GET_ALL: `${PIMS_BASE}/api/v1/processes/summary`,
@@ -8855,60 +8873,50 @@ var MAESTRO_ENDPOINTS = {
8855
8873
  INCIDENTS_BY_TIME_WINDOW: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/IncidentsByTimeWindow`
8856
8874
  }
8857
8875
  };
8858
- var DATA_FABRIC_TENANT_FOLDER_ID = "00000000-0000-0000-0000-000000000000";
8859
- var DATA_FABRIC_ENDPOINTS = {
8860
- ENTITY: {
8861
- GET_ALL: `${DATAFABRIC_BASE}/api/Entity`,
8862
- GET_ALL_V2: `${DATAFABRIC_BASE}/api/v2/Entity`,
8863
- GET_ENTITY_RECORDS: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/read`,
8864
- GET_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/Entity/${entityId}`,
8865
- GET_RECORD_BY_ID: (entityId, recordId) => `${DATAFABRIC_BASE}/api/v2/EntityService/entity/${entityId}/read/${recordId}`,
8866
- INSERT_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/insert`,
8867
- BATCH_INSERT_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/insert-batch`,
8868
- UPDATE_RECORD_BY_ID: (entityId, recordId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/update/${recordId}`,
8869
- UPDATE_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/update-batch`,
8870
- DELETE_RECORD_BY_ID: (entityId, recordId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/delete/${recordId}`,
8871
- DELETE_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/delete-batch`,
8872
- UPSERT: `${DATAFABRIC_BASE}/api/Entity`,
8873
- DELETE: (entityId) => `${DATAFABRIC_BASE}/api/Entity/${entityId}`,
8874
- UPDATE: (entityId) => `${DATAFABRIC_BASE}/api/Entity/${entityId}/metadata`,
8875
- QUERY_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/query`,
8876
- QUERY_BY_NAME: (entityName) => `${DATAFABRIC_BASE}/api/EntityService/${entityName}/query`,
8877
- BULK_UPLOAD_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/bulk-upload`,
8878
- DOWNLOAD_ATTACHMENT: (entityId, recordId, fieldName) => `${DATAFABRIC_BASE}/api/Attachment/entity/${entityId}/${recordId}/${fieldName}`,
8879
- UPLOAD_ATTACHMENT: (entityId, recordId, fieldName) => `${DATAFABRIC_BASE}/api/Attachment/entity/${entityId}/${recordId}/${fieldName}`,
8880
- DELETE_ATTACHMENT: (entityId, recordId, fieldName) => `${DATAFABRIC_BASE}/api/Attachment/entity/${entityId}/${recordId}/${fieldName}`,
8881
- GET_BY_NAME: (entityName) => `${DATAFABRIC_BASE}/api/Entity/${entityName}/metadata`,
8882
- GET_ENTITY_RECORDS_BY_NAME: (entityName) => `${DATAFABRIC_BASE}/api/EntityService/${entityName}/read`,
8883
- GET_RECORD_BY_NAME: (entityName, recordId) => `${DATAFABRIC_BASE}/api/v2/EntityService/${entityName}/read/${recordId}`,
8884
- INSERT_BY_NAME: (entityName) => `${DATAFABRIC_BASE}/api/EntityService/${entityName}/insert`,
8885
- BATCH_INSERT_BY_NAME: (entityName) => `${DATAFABRIC_BASE}/api/EntityService/${entityName}/insert-batch`,
8886
- UPDATE_RECORD_BY_NAME: (entityName, recordId) => `${DATAFABRIC_BASE}/api/EntityService/${entityName}/update/${recordId}`,
8887
- UPDATE_BY_NAME: (entityName) => `${DATAFABRIC_BASE}/api/EntityService/${entityName}/update-batch`,
8888
- DELETE_RECORD_BY_NAME: (entityName, recordId) => `${DATAFABRIC_BASE}/api/EntityService/${entityName}/delete/${recordId}`,
8889
- DELETE_BY_NAME: (entityName) => `${DATAFABRIC_BASE}/api/EntityService/${entityName}/delete-batch`,
8890
- BULK_UPLOAD_BY_NAME: (entityName) => `${DATAFABRIC_BASE}/api/EntityService/${entityName}/bulk-upload`,
8891
- ATTACHMENT_BY_NAME: (entityName, recordId, fieldName) => `${DATAFABRIC_BASE}/api/Attachment/${entityName}/${recordId}/${fieldName}`
8892
- },
8893
- CHOICESETS: {
8894
- GET_ALL: `${DATAFABRIC_BASE}/api/Entity/choiceset`,
8895
- GET_BY_ID: (choiceSetId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${choiceSetId}/query_expansion`,
8896
- CREATE: `${DATAFABRIC_BASE}/api/Entity/choiceset`,
8897
- UPDATE: (choiceSetId) => `${DATAFABRIC_BASE}/api/Entity/${choiceSetId}/metadata`,
8898
- DELETE: (choiceSetId) => `${DATAFABRIC_BASE}/api/Entity/${choiceSetId}/delete`,
8899
- INSERT_BY_NAME: (choiceSetName) => `${DATAFABRIC_BASE}/api/EntityService/${choiceSetName}/choiceset/insert`,
8900
- UPDATE_BY_NAME: (choiceSetName, valueId) => `${DATAFABRIC_BASE}/api/EntityService/${choiceSetName}/choiceset/${valueId}/update`,
8901
- DELETE_BY_ID: (choiceSetId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${choiceSetId}/choiceset/delete`
8902
- },
8903
- ROLES: {
8904
- GET_ALL: `${DATAFABRIC_BASE}/api/v2/Role`
8905
- },
8906
- DIRECTORY: {
8907
- GET_ALL: `${DATAFABRIC_BASE}/api/Directory`,
8908
- ASSIGN_ROLES: `${DATAFABRIC_BASE}/api/Directory/Role`,
8909
- REVOKE_ROLES: `${DATAFABRIC_BASE}/api/Directory/RevokeRole`
8876
+ var BUCKET_ENDPOINTS = {
8877
+ GET_BY_FOLDER: `${ORCHESTRATOR_BASE}/odata/Buckets`,
8878
+ GET_ALL: `${ORCHESTRATOR_BASE}/odata/Buckets/UiPath.Server.Configuration.OData.GetBucketsAcrossFolders`,
8879
+ GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})`,
8880
+ GET_FILE_META_DATA: (id) => `${ORCHESTRATOR_BASE}/api/Buckets/${id}/ListFiles`,
8881
+ GET_READ_URI: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})/UiPath.Server.Configuration.OData.GetReadUri`,
8882
+ GET_WRITE_URI: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})/UiPath.Server.Configuration.OData.GetWriteUri`,
8883
+ DELETE_FILE: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})/UiPath.Server.Configuration.OData.DeleteFile`,
8884
+ GET_FILES: (id) => `${ORCHESTRATOR_BASE}/odata/Buckets(${id})/UiPath.Server.Configuration.OData.GetFiles`
8885
+ };
8886
+ var PROCESS_ENDPOINTS = {
8887
+ GET_ALL: `${ORCHESTRATOR_BASE}/odata/Releases`,
8888
+ START_PROCESS: `${ORCHESTRATOR_BASE}/odata/Jobs/UiPath.Server.Configuration.OData.StartJobs`,
8889
+ GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/Releases(${id})`
8890
+ };
8891
+ var QUEUE_ENDPOINTS = {
8892
+ GET_BY_FOLDER: `${ORCHESTRATOR_BASE}/odata/QueueDefinitions`,
8893
+ GET_ALL: `${ORCHESTRATOR_BASE}/odata/QueueDefinitions/UiPath.Server.Configuration.OData.GetQueuesAcrossFolders`,
8894
+ GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/QueueDefinitions(${id})`,
8895
+ GET_ITEMS: `${ORCHESTRATOR_BASE}/odata/QueueItems`,
8896
+ ADD_ITEM: `${ORCHESTRATOR_BASE}/odata/Queues/UiPathODataSvc.AddQueueItem`,
8897
+ START_TRANSACTION: `${ORCHESTRATOR_BASE}/odata/Queues/UiPathODataSvc.StartTransaction`,
8898
+ SET_TRANSACTION_RESULT: (itemId) => `${ORCHESTRATOR_BASE}/odata/Queues(${itemId})/UiPathODataSvc.SetTransactionResult`
8899
+ };
8900
+ var JOB_ENDPOINTS = {
8901
+ GET_ALL: `${ORCHESTRATOR_BASE}/odata/Jobs`,
8902
+ GET_BY_KEY: (identifier) => `${ORCHESTRATOR_BASE}/odata/Jobs/UiPath.Server.Configuration.OData.GetByKey(identifier=${identifier})`,
8903
+ STOP: `${ORCHESTRATOR_BASE}/odata/Jobs/UiPath.Server.Configuration.OData.StopJobs`,
8904
+ RESUME: `${ORCHESTRATOR_BASE}/odata/Jobs/UiPath.Server.Configuration.OData.ResumeJob`,
8905
+ RESTART: `${ORCHESTRATOR_BASE}/odata/Jobs/UiPath.Server.Configuration.OData.RestartJob`,
8906
+ ATTACHMENTS: {
8907
+ GET_BY_JOB_KEY: `${ORCHESTRATOR_BASE}/api/JobAttachments/GetByJobKey`,
8908
+ LINK: `${ORCHESTRATOR_BASE}/api/JobAttachments/Post`
8910
8909
  }
8911
8910
  };
8911
+ var ASSET_ENDPOINTS = {
8912
+ GET_BY_FOLDER: `${ORCHESTRATOR_BASE}/odata/Assets/UiPath.Server.Configuration.OData.GetFiltered`,
8913
+ GET_ALL: `${ORCHESTRATOR_BASE}/odata/Assets/UiPath.Server.Configuration.OData.GetAssetsAcrossFolders`,
8914
+ GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/Assets(${id})`
8915
+ };
8916
+ var ORCHESTRATOR_ATTACHMENT_ENDPOINTS = {
8917
+ GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/Attachments(${id})`,
8918
+ CREATE: `${ORCHESTRATOR_BASE}/odata/Attachments`
8919
+ };
8912
8920
  var IDENTITY_ENDPOINTS = {
8913
8921
  TOKEN: `${IDENTITY_BASE}/connect/token`,
8914
8922
  AUTHORIZE: `${IDENTITY_BASE}/connect/authorize`,
@@ -9106,7 +9114,7 @@ class EmbeddedTokenManager {
9106
9114
  this.cancelRefresh?.();
9107
9115
  }
9108
9116
  }
9109
- var SDK_VERSION = "1.7.1";
9117
+ var SDK_VERSION = "1.8.0";
9110
9118
  var CLOUD_ROLE_NAME = "uipath-ts-sdk";
9111
9119
  var SDK_SERVICE_NAME = "UiPath.TypeScript.Sdk";
9112
9120
  var SDK_LOGGER_NAME = "uipath-ts-sdk-telemetry";
@@ -9204,11 +9212,11 @@ class TokenManager {
9204
9212
  this.isOAuth = false;
9205
9213
  }
9206
9214
  }
9207
- isTokenExpired(tokenInfo) {
9215
+ isTokenExpired(tokenInfo, bufferMs = 0) {
9208
9216
  if (!tokenInfo?.expiresAt) {
9209
9217
  return false;
9210
9218
  }
9211
- return new Date >= tokenInfo.expiresAt;
9219
+ return Date.now() >= getExpiryMs(tokenInfo.expiresAt) - bufferMs;
9212
9220
  }
9213
9221
  async getValidToken() {
9214
9222
  const tokenInfo = this.executionContext.get("tokenInfo");
@@ -9226,7 +9234,8 @@ class TokenManager {
9226
9234
  if (tokenInfo.type === "secret") {
9227
9235
  return tokenInfo.token;
9228
9236
  }
9229
- if (!this.isTokenExpired(tokenInfo)) {
9237
+ const expiryBuffer = hasOAuthConfig(this.config) && tokenInfo.refreshToken ? TOKEN_EXPIRY_BUFFER_MS : 0;
9238
+ if (!this.isTokenExpired(tokenInfo, expiryBuffer)) {
9230
9239
  return tokenInfo.token;
9231
9240
  }
9232
9241
  try {
@@ -9391,7 +9400,7 @@ class TokenManager {
9391
9400
  return token;
9392
9401
  }
9393
9402
  }
9394
- var GUID_REGEX$1 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
9403
+ var GUID_REGEX$2 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
9395
9404
 
9396
9405
  class AuthService {
9397
9406
  constructor(config2, executionContext) {
@@ -9596,7 +9605,7 @@ class AuthService {
9596
9605
  return authorizeUrl;
9597
9606
  }
9598
9607
  const orgName = this.config.orgName;
9599
- if (!GUID_REGEX$1.test(orgName)) {
9608
+ if (!GUID_REGEX$2.test(orgName)) {
9600
9609
  console.warn(`[UiPath SDK] enforceSso was ignored: orgName "${orgName}" is not an organization id. ` + "Pass the organization id (GUID) as orgName to sign in through the org's identity provider.");
9601
9610
  return authorizeUrl;
9602
9611
  }
@@ -9685,6 +9694,58 @@ class AuthService {
9685
9694
  window.history.replaceState({}, "", url.toString());
9686
9695
  }
9687
9696
  }
9697
+ var UiPathMetaTags;
9698
+ (function(UiPathMetaTags2) {
9699
+ UiPathMetaTags2["CLIENT_ID"] = "uipath:client-id";
9700
+ UiPathMetaTags2["SCOPE"] = "uipath:scope";
9701
+ UiPathMetaTags2["ORG_NAME"] = "uipath:org-name";
9702
+ UiPathMetaTags2["ORG_ID"] = "uipath:org-id";
9703
+ UiPathMetaTags2["TENANT_NAME"] = "uipath:tenant-name";
9704
+ UiPathMetaTags2["BASE_URL"] = "uipath:base-url";
9705
+ UiPathMetaTags2["REDIRECT_URI"] = "uipath:redirect-uri";
9706
+ UiPathMetaTags2["CDN_BASE"] = "uipath:cdn-base";
9707
+ UiPathMetaTags2["APP_BASE"] = "uipath:app-base";
9708
+ UiPathMetaTags2["FOLDER_KEY"] = "uipath:folder-key";
9709
+ })(UiPathMetaTags || (UiPathMetaTags = {}));
9710
+ var UiPathElementIds;
9711
+ (function(UiPathElementIds2) {
9712
+ UiPathElementIds2["RESOURCE_OVERRIDES"] = "uipath-overrides";
9713
+ })(UiPathElementIds || (UiPathElementIds = {}));
9714
+ function readEnv(name) {
9715
+ const globals = globalThis;
9716
+ try {
9717
+ const fromNode = globals.process?.env?.[name];
9718
+ if (fromNode)
9719
+ return fromNode;
9720
+ } catch {}
9721
+ try {
9722
+ const fromDeno = globals.Deno?.env?.get?.(name);
9723
+ if (fromDeno)
9724
+ return fromDeno;
9725
+ } catch {}
9726
+ return;
9727
+ }
9728
+ var UiPathEnvVars = {
9729
+ BASE_URL: "UIPATH_BASE_URL",
9730
+ ORG_NAME: "UIPATH_ORG_NAME",
9731
+ TENANT_NAME: "UIPATH_TENANT_NAME",
9732
+ ACCESS_TOKEN: "UIPATH_ACCESS_TOKEN"
9733
+ };
9734
+ function loadFromEnvironment() {
9735
+ if (isBrowser)
9736
+ return null;
9737
+ const config2 = {
9738
+ baseUrl: readEnv(UiPathEnvVars.BASE_URL),
9739
+ orgName: readEnv(UiPathEnvVars.ORG_NAME),
9740
+ tenantName: readEnv(UiPathEnvVars.TENANT_NAME),
9741
+ secret: readEnv(UiPathEnvVars.ACCESS_TOKEN)
9742
+ };
9743
+ return Object.values(config2).some(Boolean) ? config2 : null;
9744
+ }
9745
+ var BASE_FIELDS = ["baseUrl", "orgName", "tenantName"];
9746
+ var OAUTH_FIELDS = ["clientId", "redirectUri", "scope"];
9747
+ var AUTH_FIELDS = ["secret", ...OAUTH_FIELDS];
9748
+ var HTTP_PROTOCOLS = new Set(["http:", "https:"]);
9688
9749
  function hasRequiredBaseFields(config2) {
9689
9750
  return Boolean(config2.baseUrl && config2.orgName && config2.tenantName);
9690
9751
  }
@@ -9693,18 +9754,28 @@ function hasValidAuthConfig(config2) {
9693
9754
  const hasOAuth = hasOAuthConfig(config2);
9694
9755
  return hasSecret !== hasOAuth;
9695
9756
  }
9696
- function validateConfig(config2) {
9697
- if (!hasRequiredBaseFields(config2)) {
9698
- throw new Error("Missing required configuration: baseUrl, orgName, and tenantName are required");
9699
- }
9700
- const hasSecret = hasSecretConfig(config2);
9701
- const hasOAuth = hasOAuthConfig(config2);
9702
- if (hasSecret && hasOAuth) {
9703
- throw new Error("Invalid configuration: cannot provide both secret and OAuth credentials. Choose one authentication method.");
9757
+ function nonBlank(value) {
9758
+ const trimmed = value?.trim();
9759
+ return trimmed ? trimmed : undefined;
9760
+ }
9761
+ function toHttpOrigin(value) {
9762
+ let url;
9763
+ try {
9764
+ url = new URL(value);
9765
+ } catch (error) {
9766
+ console.warn(`[UiPath SDK] baseUrl "${value}" is not a URL:`, error);
9767
+ return null;
9704
9768
  }
9705
- if (!hasSecret && !hasOAuth) {
9706
- throw new Error("Invalid configuration: must provide either secret or OAuth credentials (clientId, redirectUri, and scope)");
9769
+ if (!HTTP_PROTOCOLS.has(url.protocol)) {
9770
+ console.warn(`[UiPath SDK] baseUrl "${value}" is not an http(s) URL; ignored.`);
9771
+ return null;
9707
9772
  }
9773
+ return url.origin;
9774
+ }
9775
+ function joinNames(names) {
9776
+ if (names.length <= 1)
9777
+ return names.join("");
9778
+ return `${names.slice(0, -1).join(", ")} and ${names.slice(-1).join("")}`;
9708
9779
  }
9709
9780
  function isCompleteConfig(config2) {
9710
9781
  return hasRequiredBaseFields(config2) && hasValidAuthConfig(config2);
@@ -9715,56 +9786,449 @@ function compactConfig(config2) {
9715
9786
  function normalizeBaseUrl(url) {
9716
9787
  return url.endsWith("/") ? url.slice(0, -1) : url;
9717
9788
  }
9718
- function missingConfigMessage() {
9789
+ function describeGaps(found) {
9790
+ const gaps = [];
9791
+ const missingBase = BASE_FIELDS.filter((field) => !found[field]);
9792
+ if (missingBase.length > 0)
9793
+ gaps.push(`missing ${missingBase.join(", ")}`);
9794
+ const foundSecret = hasSecretConfig(found);
9795
+ const foundOAuth = hasOAuthConfig(found);
9796
+ if (!foundSecret && !foundOAuth) {
9797
+ const named = OAUTH_FIELDS.filter((field) => found[field]);
9798
+ gaps.push(named.length > 0 ? `the OAuth configuration is incomplete — ${named.join(", ")} set, ` + `${OAUTH_FIELDS.filter((field) => !found[field]).join(", ")} missing` : "no authentication method set (needs `secret`, or clientId, redirectUri and scope)");
9799
+ }
9800
+ return gaps.join("; ");
9801
+ }
9802
+ function missingConfigMessage(found, context) {
9803
+ if (context) {
9804
+ return missingContextMessage(found ?? {}, context);
9805
+ }
9719
9806
  if (isBrowser) {
9807
+ if (found && hasRequiredBaseFields(found) && !hasSecretConfig(found)) {
9808
+ const missing = [];
9809
+ if (!found.clientId)
9810
+ missing.push("clientId");
9811
+ if (!found.redirectUri)
9812
+ missing.push("redirectUri");
9813
+ if (missing.length > 0 && (found.clientId || found.redirectUri || found.scope)) {
9814
+ const fields = missing.join(" and ");
9815
+ const verb = missing.length > 1 ? "are" : "is";
9816
+ const clientHint = missing.includes("clientId") ? " clientId must be a non-confidential OAuth client, or pass one with --client-id at deploy." : "";
9817
+ return `UiPath SDK configuration is incomplete: ${fields} ${verb} empty. Set ${missing.length > 1 ? "them" : "it"} in uipath.json and redeploy.${clientHint}`;
9818
+ }
9819
+ }
9720
9820
  return "UiPath SDK configuration not found. " + "Ensure @uipath/coded-apps plugin is set up in your bundler to inject configuration during development and build.";
9721
9821
  }
9722
- return "UiPath SDK configuration not found. " + "In a UiPath coded function, pass the handler context: new UiPath(ctx). " + "Otherwise pass { baseUrl, orgName, tenantName, secret }, " + "or set UIPATH_BASE_URL, UIPATH_ORG_NAME, UIPATH_TENANT_NAME and UIPATH_ACCESS_TOKEN.";
9822
+ const guidance = "In a UiPath coded function, pass the handler context: new UiPath(ctx). " + "Otherwise pass { baseUrl, orgName, tenantName, secret }, " + "or set UIPATH_BASE_URL, UIPATH_ORG_NAME, UIPATH_TENANT_NAME and UIPATH_ACCESS_TOKEN.";
9823
+ if (!found)
9824
+ return `UiPath SDK configuration not found. ${guidance}`;
9825
+ return `UiPath SDK configuration is incomplete: ${describeGaps(found)}. ${guidance}`;
9826
+ }
9827
+ function missingContextMessage(config2, context) {
9828
+ const missing = [];
9829
+ if (!hasRequiredBaseFields(config2)) {
9830
+ if (!context.platform) {
9831
+ const variables = [];
9832
+ if (!config2.baseUrl)
9833
+ variables.push(UiPathEnvVars.BASE_URL);
9834
+ if (!config2.orgName)
9835
+ variables.push(UiPathEnvVars.ORG_NAME);
9836
+ if (!config2.tenantName)
9837
+ variables.push(UiPathEnvVars.TENANT_NAME);
9838
+ missing.push(`ctx.platform is null (or set ${joinNames(variables)})`);
9839
+ } else {
9840
+ if (!config2.baseUrl) {
9841
+ const baseUrl = nonBlank(context.platform.baseUrl);
9842
+ const problem = baseUrl === undefined ? "is empty" : `"${baseUrl}" is not an http(s) URL`;
9843
+ missing.push(`ctx.platform.baseUrl ${problem} (or set ${UiPathEnvVars.BASE_URL})`);
9844
+ }
9845
+ if (!config2.orgName)
9846
+ missing.push(`ctx.platform.orgId is empty (or set ${UiPathEnvVars.ORG_NAME})`);
9847
+ if (!config2.tenantName)
9848
+ missing.push(`ctx.platform.tenantId is empty (or set ${UiPathEnvVars.TENANT_NAME})`);
9849
+ }
9850
+ }
9851
+ if (!hasSecretConfig(config2) && !hasOAuthConfig(config2)) {
9852
+ missing.push(`ctx.robot.accessToken is null (or set ${UiPathEnvVars.ACCESS_TOKEN})`);
9853
+ }
9854
+ if (missing.length === 0) {
9855
+ return "UiPath SDK configuration is incomplete: " + "the handler context passed to new UiPath(ctx) does not form a complete configuration.";
9856
+ }
9857
+ return `UiPath SDK configuration is incomplete: ${missing.join("; ")}. ` + "A deployed Function receives these coordinates on the handler context; a local run sets the variables named.";
9858
+ }
9859
+ var AUTH_FIELD_SOURCES = {
9860
+ secret: { envVar: UiPathEnvVars.ACCESS_TOKEN },
9861
+ clientId: { metaTag: UiPathMetaTags.CLIENT_ID },
9862
+ redirectUri: { metaTag: UiPathMetaTags.REDIRECT_URI },
9863
+ scope: { metaTag: UiPathMetaTags.SCOPE }
9864
+ };
9865
+ function sourceOf(field, sources) {
9866
+ if (sources.config?.[field])
9867
+ return "the constructor argument";
9868
+ const { metaTag, envVar } = AUTH_FIELD_SOURCES[field];
9869
+ if (metaTag && sources.metaConfig?.[field])
9870
+ return `<meta name="${metaTag}">`;
9871
+ if (envVar && sources.environment?.[field])
9872
+ return `the ${envVar} environment variable`;
9873
+ return;
9874
+ }
9875
+ function conflictingAuthMessage(sources) {
9876
+ const inventory = AUTH_FIELDS.map((field) => ({ field, source: sourceOf(field, sources) })).filter((entry) => Boolean(entry.source)).map(({ field, source }) => ` ${field}: ${source}`).join(`
9877
+ `);
9878
+ const namedOAuth = AUTH_FIELDS.filter((field) => field !== "secret" && Boolean(sources.config?.[field]));
9879
+ const remedy = namedOAuth.length > 0 ? `Remove ${namedOAuth.join(", ")} from the constructor argument to authenticate with secret, ` + "or remove secret to authenticate with OAuth." : "Pass exactly one authentication method.";
9880
+ return "Invalid UiPath SDK configuration: it carries both authentication methods. " + `The SDK authenticates with secret, or with OAuth (clientId, redirectUri and scope), never both.
9881
+ ` + `${inventory}
9882
+ ` + "Every field the constructor argument leaves unset is inherited from the meta tags and the " + "environment, so naming one field of each method ends up carrying both. " + remedy;
9883
+ }
9884
+ var FOLDER_KEY = "X-UIPATH-FolderKey";
9885
+ var FOLDER_PATH_ENCODED = "X-UIPATH-FolderPath-Encoded";
9886
+ var FOLDER_ID = "X-UIPATH-OrganizationUnitId";
9887
+ var TRACEPARENT = "traceparent";
9888
+ var UIPATH_TRACEPARENT_ID = "x-uipath-traceparent-id";
9889
+ var CONTENT_TYPES = {
9890
+ JSON: "application/json",
9891
+ XML: "application/xml",
9892
+ OCTET_STREAM: "application/octet-stream"
9893
+ };
9894
+ var RESPONSE_TYPES = {
9895
+ JSON: "json",
9896
+ TEXT: "text",
9897
+ BLOB: "blob",
9898
+ ARRAYBUFFER: "arraybuffer",
9899
+ STREAM: "stream"
9900
+ };
9901
+ var DEFAULT_RETRYABLE_STATUS_CODES = [408, 429, 500, 502, 503, 504];
9902
+ var DEFAULT_RETRY_METHODS = ["GET", "HEAD", "PUT", "DELETE", "OPTIONS"];
9903
+ var DEFAULT_RETRY_OPTIONS = {
9904
+ maxRetries: 2,
9905
+ initialDelayMs: 500,
9906
+ backoffStrategy: "exponential",
9907
+ backoffFactor: 2,
9908
+ backoffMaxDelayMs: 30000,
9909
+ retryableStatusCodes: DEFAULT_RETRYABLE_STATUS_CODES,
9910
+ retryMethods: DEFAULT_RETRY_METHODS,
9911
+ retryNetworkErrors: true,
9912
+ respectRetryAfter: true,
9913
+ maxRetryAfterMs: Infinity
9914
+ };
9915
+ var DEFAULT_API_CLIENT_RETRY = {
9916
+ ...DEFAULT_RETRY_OPTIONS,
9917
+ maxRetries: 0
9918
+ };
9919
+ function resolveRetryOptions(settings, defaults = DEFAULT_RETRY_OPTIONS) {
9920
+ if (!settings)
9921
+ return defaults;
9922
+ const { retryDelay, useExponentialBackoff, ...live } = settings;
9923
+ const resolved = { ...defaults };
9924
+ for (const [key, value] of Object.entries(live)) {
9925
+ if (value !== undefined) {
9926
+ resolved[key] = value;
9927
+ }
9928
+ }
9929
+ if (retryDelay !== undefined && live.initialDelayMs === undefined) {
9930
+ resolved.initialDelayMs = retryDelay;
9931
+ }
9932
+ if (useExponentialBackoff !== undefined && live.backoffStrategy === undefined) {
9933
+ resolved.backoffStrategy = useExponentialBackoff ? "exponential" : "constant";
9934
+ }
9935
+ return resolved;
9936
+ }
9937
+ function computeBackoffDelay(attempt, settings) {
9938
+ const base = Math.max(0, settings.initialDelayMs);
9939
+ let delay;
9940
+ switch (settings.backoffStrategy) {
9941
+ case "constant":
9942
+ delay = base;
9943
+ break;
9944
+ case "linear":
9945
+ delay = base * (attempt + 1);
9946
+ break;
9947
+ default:
9948
+ delay = base * Math.pow(settings.backoffFactor, attempt);
9949
+ }
9950
+ return Math.min(delay, settings.backoffMaxDelayMs);
9951
+ }
9952
+ function parseRetryAfter(value, now = Date.now()) {
9953
+ const trimmed = value?.trim();
9954
+ if (!trimmed)
9955
+ return;
9956
+ const seconds = Number(trimmed);
9957
+ if (Number.isFinite(seconds))
9958
+ return Math.max(0, seconds * 1000);
9959
+ const date2 = Date.parse(trimmed);
9960
+ if (Number.isNaN(date2))
9961
+ return;
9962
+ return Math.max(0, date2 - now);
9963
+ }
9964
+ function wait(durationMs) {
9965
+ return new Promise((resolve) => setTimeout(resolve, Math.max(0, durationMs)));
9966
+ }
9967
+ var RETRY_AFTER = "retry-after";
9968
+ function createAttemptSignal(timeoutMs, external) {
9969
+ if (timeoutMs === undefined || !Number.isFinite(timeoutMs))
9970
+ return { signal: external, dispose: () => {} };
9971
+ const controller = new AbortController;
9972
+ const timer = setTimeout(() => controller.abort(new Error(`Request timeout after ${timeoutMs}ms`)), timeoutMs);
9973
+ const onExternalAbort = () => controller.abort(external?.reason);
9974
+ if (external) {
9975
+ if (external.aborted) {
9976
+ controller.abort(external.reason);
9977
+ } else {
9978
+ external.addEventListener("abort", onExternalAbort);
9979
+ }
9980
+ }
9981
+ return {
9982
+ signal: controller.signal,
9983
+ dispose: () => {
9984
+ clearTimeout(timer);
9985
+ external?.removeEventListener("abort", onExternalAbort);
9986
+ }
9987
+ };
9988
+ }
9989
+ function delayBeforeRetry(durationMs, signal) {
9990
+ if (!signal)
9991
+ return wait(durationMs);
9992
+ if (signal.aborted)
9993
+ return Promise.reject(signal.reason);
9994
+ return new Promise((resolve, reject) => {
9995
+ const onAbort = () => {
9996
+ clearTimeout(timer);
9997
+ reject(signal.reason);
9998
+ };
9999
+ const timer = setTimeout(() => {
10000
+ signal.removeEventListener("abort", onAbort);
10001
+ resolve();
10002
+ }, Math.max(0, durationMs));
10003
+ signal.addEventListener("abort", onAbort);
10004
+ });
10005
+ }
10006
+ async function fetchWithRetry(url, init, options) {
10007
+ const settings = options.retry;
10008
+ const method = (init.method ?? "GET").toUpperCase();
10009
+ const retriesAllowed = settings.retryMethods.includes(method) ? Math.max(0, settings.maxRetries) : 0;
10010
+ let attempt = 0;
10011
+ for (;; ) {
10012
+ const { signal, dispose } = createAttemptSignal(options.timeoutMs, options.signal);
10013
+ let response;
10014
+ let failure;
10015
+ try {
10016
+ response = await fetch(url, { ...init, signal });
10017
+ } catch (error) {
10018
+ failure = error;
10019
+ } finally {
10020
+ dispose();
10021
+ }
10022
+ if (options.signal?.aborted && failure !== undefined)
10023
+ throw failure;
10024
+ if (response && !settings.retryableStatusCodes.includes(response.status))
10025
+ return response;
10026
+ if (failure !== undefined && !settings.retryNetworkErrors)
10027
+ throw failure;
10028
+ if (attempt >= retriesAllowed) {
10029
+ if (response)
10030
+ return response;
10031
+ throw failure;
10032
+ }
10033
+ const retryAfter = settings.respectRetryAfter && response ? parseRetryAfter(response.headers.get(RETRY_AFTER)) : undefined;
10034
+ const delay = retryAfter !== undefined ? Math.min(retryAfter, settings.maxRetryAfterMs) : computeBackoffDelay(attempt, settings);
10035
+ response?.body?.cancel().catch((error) => {
10036
+ console.warn("[UiPath SDK] Could not release a discarded response body:", error);
10037
+ });
10038
+ await delayBeforeRetry(delay, options.signal);
10039
+ attempt++;
10040
+ }
9723
10041
  }
10042
+ var _OrganizationIdResolver_instances;
10043
+ var _OrganizationIdResolver_organizationId;
10044
+ var _OrganizationIdResolver_resolve;
10045
+ var GUID_REGEX$1 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
10046
+ var DASH_REGEX = /-/g;
10047
+ var UNDERSCORE_REGEX = /_/g;
10048
+ var WHITESPACE_REGEX = /\s+/g;
10049
+ var ORGANIZATION_LOOKUP_CLIENT_ID = "1119a927-10ab-4543-bd1a-ad6bfbbc27f4";
10050
+ var ORGANIZATION_LOOKUP_REDIRECT_PATH = "portal_/api/tokenFactory/callback";
10051
+ var UNREGISTERED_ORGANIZATION_PATH = "/portal_/unregistered";
10052
+ var TENANT_ACR_PREFIX = "tenant:";
10053
+ var MAX_REDIRECT_HOPS = 3;
10054
+ var IDENTITY_ERROR_ID_PARAM = "errorId";
10055
+ var IDENTITY_ERROR_CODE_PARAM = "errorCode";
10056
+ var BODY_SNIPPET_LENGTH = 160;
10057
+ var CONFIG_HINT = "Set `organizationId` in the SDK configuration.";
10058
+ function isAuthorizeRequest(url) {
10059
+ return url.pathname.endsWith(`/${IDENTITY_ENDPOINTS.AUTHORIZE}`);
10060
+ }
10061
+ function withoutQuery(url) {
10062
+ const parsed = new URL(url);
10063
+ return `${parsed.origin}${parsed.pathname}`;
10064
+ }
10065
+ function readIdentityError(url) {
10066
+ const errorId = url.searchParams.get(IDENTITY_ERROR_ID_PARAM);
10067
+ if (errorId) {
10068
+ try {
10069
+ const base642 = errorId.replace(DASH_REGEX, "+").replace(UNDERSCORE_REGEX, "/");
10070
+ const json = decodeBase64(base642.padEnd(base642.length + (4 - base642.length % 4) % 4, "="));
10071
+ const data = JSON.parse(json).Data;
10072
+ const error = typeof data?.Error === "string" ? data.Error : undefined;
10073
+ const description = typeof data?.ErrorDescription === "string" ? data.ErrorDescription : undefined;
10074
+ if (error) {
10075
+ return description ? `${error} (${description})` : error;
10076
+ }
10077
+ } catch {
10078
+ return url.searchParams.get(IDENTITY_ERROR_CODE_PARAM) ?? undefined;
10079
+ }
10080
+ }
10081
+ return url.searchParams.get(IDENTITY_ERROR_CODE_PARAM) ?? undefined;
10082
+ }
10083
+ async function describeResponse(response) {
10084
+ const body = (await response.text().catch(() => "")).replace(WHITESPACE_REGEX, " ").trim();
10085
+ return body ? `HTTP ${response.status}: ${body.slice(0, BODY_SNIPPET_LENGTH)}` : `HTTP ${response.status}`;
10086
+ }
10087
+ function randomUrlSafeToken() {
10088
+ return `${crypto.randomUUID()}${crypto.randomUUID()}`.replace(DASH_REGEX, "");
10089
+ }
10090
+ function tracingHeaders() {
10091
+ const traceId = crypto.randomUUID().replace(DASH_REGEX, "");
10092
+ const spanId = crypto.randomUUID().replace(DASH_REGEX, "").slice(0, 16);
10093
+ const traceparent = `00-${traceId}-${spanId}-01`;
10094
+ return { [TRACEPARENT]: traceparent, [UIPATH_TRACEPARENT_ID]: traceparent };
10095
+ }
10096
+ function buildAuthorizeUrl(baseUrl, orgName) {
10097
+ const params = new URLSearchParams({
10098
+ response_type: "code",
10099
+ client_id: ORGANIZATION_LOOKUP_CLIENT_ID,
10100
+ redirect_uri: `${baseUrl}/${ORGANIZATION_LOOKUP_REDIRECT_PATH}`,
10101
+ scope: "openid",
10102
+ code_challenge: randomUrlSafeToken(),
10103
+ code_challenge_method: "S256",
10104
+ state: randomUrlSafeToken(),
10105
+ acr_values: `tenantName:${orgName}`
10106
+ });
10107
+ return `${baseUrl}/${IDENTITY_ENDPOINTS.AUTHORIZE}?${params.toString()}`;
10108
+ }
10109
+ function extractOrganizationId(location) {
10110
+ const acrValues = [location.searchParams.get("acr_values")];
10111
+ const returnUrl = location.searchParams.get("returnUrl");
10112
+ if (returnUrl) {
10113
+ acrValues.push(new URL(returnUrl, location.origin).searchParams.get("acr_values"));
10114
+ }
10115
+ for (const acr of acrValues) {
10116
+ for (const token of acr?.split(" ") ?? []) {
10117
+ if (token.startsWith(TENANT_ACR_PREFIX)) {
10118
+ const candidate = token.slice(TENANT_ACR_PREFIX.length);
10119
+ if (GUID_REGEX$1.test(candidate)) {
10120
+ return candidate;
10121
+ }
10122
+ }
10123
+ }
10124
+ }
10125
+ return;
10126
+ }
10127
+ async function lookupOrganizationIdForPat(baseUrl, orgName) {
10128
+ let url = buildAuthorizeUrl(baseUrl, orgName);
10129
+ for (let hop = 0;hop < MAX_REDIRECT_HOPS; hop++) {
10130
+ const response = await fetchWithRetry(url, { redirect: "manual", headers: tracingHeaders() }, { retry: DEFAULT_RETRY_OPTIONS });
10131
+ const location = response.headers.get("location");
10132
+ if (!location) {
10133
+ throw new ValidationError({
10134
+ message: `Could not resolve the organization id for '${orgName}': Identity answered ` + `${await describeResponse(response)} instead of redirecting. ${CONFIG_HINT}`
10135
+ });
10136
+ }
10137
+ const target = new URL(location, url);
10138
+ const organizationId = extractOrganizationId(target);
10139
+ if (organizationId) {
10140
+ return organizationId;
10141
+ }
10142
+ if (target.pathname.startsWith(UNREGISTERED_ORGANIZATION_PATH)) {
10143
+ throw new ValidationError({ message: `Organization '${orgName}' was not found at ${baseUrl}.` });
10144
+ }
10145
+ const identityError = readIdentityError(target);
10146
+ if (identityError) {
10147
+ throw new ValidationError({
10148
+ message: `Could not resolve the organization id for '${orgName}': Identity rejected the lookup ` + `with ${identityError}. ${CONFIG_HINT}`
10149
+ });
10150
+ }
10151
+ url = isAuthorizeRequest(target) ? buildAuthorizeUrl(target.origin, orgName) : target.toString();
10152
+ }
10153
+ throw new ValidationError({
10154
+ message: `Could not resolve the organization id for '${orgName}': gave up after ${MAX_REDIRECT_HOPS} ` + `redirects (last: ${withoutQuery(url)}). ${CONFIG_HINT}`
10155
+ });
10156
+ }
10157
+
10158
+ class OrganizationIdResolver {
10159
+ constructor(config2, tokenManager) {
10160
+ _OrganizationIdResolver_instances.add(this);
10161
+ this.config = config2;
10162
+ this.tokenManager = tokenManager;
10163
+ _OrganizationIdResolver_organizationId.set(this, undefined);
10164
+ }
10165
+ resolve() {
10166
+ if (!__classPrivateFieldGet(this, _OrganizationIdResolver_organizationId, "f")) {
10167
+ __classPrivateFieldSet(this, _OrganizationIdResolver_organizationId, __classPrivateFieldGet(this, _OrganizationIdResolver_instances, "m", _OrganizationIdResolver_resolve).call(this).catch((error) => {
10168
+ __classPrivateFieldSet(this, _OrganizationIdResolver_organizationId, undefined, "f");
10169
+ throw error;
10170
+ }), "f");
10171
+ }
10172
+ return __classPrivateFieldGet(this, _OrganizationIdResolver_organizationId, "f");
10173
+ }
10174
+ }
10175
+ _OrganizationIdResolver_organizationId = new WeakMap, _OrganizationIdResolver_instances = new WeakSet, _OrganizationIdResolver_resolve = async function _OrganizationIdResolver_resolve2() {
10176
+ const { organizationId, orgName, baseUrl } = this.config;
10177
+ if (organizationId) {
10178
+ return organizationId;
10179
+ }
10180
+ if (GUID_REGEX$1.test(orgName)) {
10181
+ return orgName;
10182
+ }
10183
+ const claimed = decodeJwtClaims(this.tokenManager.getToken())?.prt_id;
10184
+ if (typeof claimed === "string" && GUID_REGEX$1.test(claimed)) {
10185
+ return claimed;
10186
+ }
10187
+ return lookupOrganizationIdForPat(baseUrl, orgName);
10188
+ };
9724
10189
  var REGISTRY_KEY2 = Symbol.for("@uipath/sdk-internals-registry");
10190
+ var UNCONFIGURED_KEY = Symbol.for("@uipath/sdk-unconfigured-reason");
10191
+ var globalStores = () => globalThis;
9725
10192
  var getGlobalStore = () => {
9726
- const globalObj = globalThis;
9727
- if (!globalObj[REGISTRY_KEY2]) {
9728
- globalObj[REGISTRY_KEY2] = new WeakMap;
9729
- }
9730
- return globalObj[REGISTRY_KEY2];
10193
+ var _a;
10194
+ return (_a = globalStores())[REGISTRY_KEY2] ?? (_a[REGISTRY_KEY2] = new WeakMap);
10195
+ };
10196
+ var getUnconfiguredStore = () => {
10197
+ var _a;
10198
+ return (_a = globalStores())[UNCONFIGURED_KEY] ?? (_a[UNCONFIGURED_KEY] = new WeakMap);
9731
10199
  };
9732
10200
  var looksLikeUiPath = (instance) => typeof instance.initialize === "function";
9733
10201
 
9734
10202
  class SDKInternalsRegistry {
9735
- static get store() {
9736
- return getGlobalStore();
9737
- }
9738
10203
  static set(instance, internals) {
9739
10204
  this.store.set(instance, internals);
9740
10205
  }
10206
+ static setUnconfigured(instance, reason) {
10207
+ this.unconfigured.set(instance, reason);
10208
+ }
9741
10209
  static get(instance) {
9742
10210
  const internals = this.store.get(instance);
9743
10211
  if (!internals) {
9744
- if (looksLikeUiPath(instance)) {
9745
- throw new Error("Cannot create a service: the UiPath instance was never configured. " + missingConfigMessage());
10212
+ const reason = this.unconfigured.get(instance);
10213
+ if (reason !== undefined || looksLikeUiPath(instance)) {
10214
+ throw new Error("Cannot create a service: the UiPath instance was never configured. " + (reason ?? missingConfigMessage()));
9746
10215
  }
9747
10216
  throw new Error("Invalid SDK instance. Make sure to pass a valid UiPath instance to the service constructor.");
9748
10217
  }
9749
10218
  return internals;
9750
10219
  }
10220
+ static getOrganizationIdResolver(instance) {
10221
+ const internals = this.get(instance);
10222
+ internals.organizationIdResolver ?? (internals.organizationIdResolver = new OrganizationIdResolver(internals.config, internals.tokenManager));
10223
+ return internals.organizationIdResolver;
10224
+ }
10225
+ static get store() {
10226
+ return getGlobalStore();
10227
+ }
10228
+ static get unconfigured() {
10229
+ return getUnconfiguredStore();
10230
+ }
9751
10231
  }
9752
- var UiPathMetaTags;
9753
- (function(UiPathMetaTags2) {
9754
- UiPathMetaTags2["CLIENT_ID"] = "uipath:client-id";
9755
- UiPathMetaTags2["SCOPE"] = "uipath:scope";
9756
- UiPathMetaTags2["ORG_NAME"] = "uipath:org-name";
9757
- UiPathMetaTags2["TENANT_NAME"] = "uipath:tenant-name";
9758
- UiPathMetaTags2["BASE_URL"] = "uipath:base-url";
9759
- UiPathMetaTags2["REDIRECT_URI"] = "uipath:redirect-uri";
9760
- UiPathMetaTags2["CDN_BASE"] = "uipath:cdn-base";
9761
- UiPathMetaTags2["APP_BASE"] = "uipath:app-base";
9762
- UiPathMetaTags2["FOLDER_KEY"] = "uipath:folder-key";
9763
- })(UiPathMetaTags || (UiPathMetaTags = {}));
9764
- var UiPathElementIds;
9765
- (function(UiPathElementIds2) {
9766
- UiPathElementIds2["RESOURCE_OVERRIDES"] = "uipath-overrides";
9767
- })(UiPathElementIds || (UiPathElementIds = {}));
9768
10232
  function getMetaTagContent(name) {
9769
10233
  if (!isBrowser)
9770
10234
  return;
@@ -9777,6 +10241,7 @@ function loadFromMetaTags() {
9777
10241
  clientId: getMetaTagContent(UiPathMetaTags.CLIENT_ID),
9778
10242
  scope: getMetaTagContent(UiPathMetaTags.SCOPE),
9779
10243
  orgName: getMetaTagContent(UiPathMetaTags.ORG_NAME),
10244
+ organizationId: getMetaTagContent(UiPathMetaTags.ORG_ID),
9780
10245
  tenantName: getMetaTagContent(UiPathMetaTags.TENANT_NAME),
9781
10246
  baseUrl: getMetaTagContent(UiPathMetaTags.BASE_URL),
9782
10247
  redirectUri: getMetaTagContent(UiPathMetaTags.REDIRECT_URI),
@@ -9785,52 +10250,23 @@ function loadFromMetaTags() {
9785
10250
  const hasAnyValue = Object.values(config2).some(Boolean);
9786
10251
  return hasAnyValue ? config2 : null;
9787
10252
  }
9788
- function readEnv(name) {
9789
- const globals = globalThis;
9790
- try {
9791
- const fromNode = globals.process?.env?.[name];
9792
- if (fromNode)
9793
- return fromNode;
9794
- } catch {}
9795
- try {
9796
- const fromDeno = globals.Deno?.env?.get?.(name);
9797
- if (fromDeno)
9798
- return fromDeno;
9799
- } catch {}
9800
- return;
9801
- }
9802
- var UiPathEnvVars = {
9803
- BASE_URL: "UIPATH_BASE_URL",
9804
- ORG_NAME: "UIPATH_ORG_NAME",
9805
- TENANT_NAME: "UIPATH_TENANT_NAME",
9806
- ACCESS_TOKEN: "UIPATH_ACCESS_TOKEN"
9807
- };
9808
- function loadFromEnvironment() {
9809
- if (isBrowser)
9810
- return null;
9811
- const config2 = {
9812
- baseUrl: readEnv(UiPathEnvVars.BASE_URL),
9813
- orgName: readEnv(UiPathEnvVars.ORG_NAME),
9814
- tenantName: readEnv(UiPathEnvVars.TENANT_NAME),
9815
- secret: readEnv(UiPathEnvVars.ACCESS_TOKEN)
9816
- };
9817
- return Object.values(config2).some(Boolean) ? config2 : null;
9818
- }
9819
10253
  function isFunctionContext(value) {
9820
10254
  return "platform" in value || "robot" in value;
9821
10255
  }
9822
10256
  function configFromFunctionContext(context) {
9823
10257
  const { platform, robot } = context;
9824
- if (!platform)
9825
- return null;
10258
+ const baseUrl = nonBlank(platform?.baseUrl);
9826
10259
  const config2 = {
9827
- baseUrl: platform.baseUrl,
9828
- orgName: platform.orgId,
9829
- tenantName: platform.tenantId,
9830
- secret: robot?.accessToken ?? undefined
10260
+ baseUrl: baseUrl === undefined ? undefined : toHttpOrigin(baseUrl) ?? undefined,
10261
+ orgName: nonBlank(platform?.orgId),
10262
+ tenantName: nonBlank(platform?.tenantId),
10263
+ secret: nonBlank(robot?.accessToken)
9831
10264
  };
9832
10265
  return Object.values(config2).some(Boolean) ? config2 : null;
9833
10266
  }
10267
+ function folderKeyFromFunctionContext(context) {
10268
+ return nonBlank(context.platform?.folderKey);
10269
+ }
9834
10270
  var _UiPath_instances;
9835
10271
  var _a;
9836
10272
  var _UiPath_config;
@@ -9838,6 +10274,8 @@ var _UiPath_authService;
9838
10274
  var _UiPath_initialized;
9839
10275
  var _UiPath_partialConfig;
9840
10276
  var _UiPath_metaFolderKey;
10277
+ var _UiPath_contextFolderKey;
10278
+ var _UiPath_functionContext;
9841
10279
  var _UiPath_metaOrgId;
9842
10280
  var _UiPath_metaTenantId;
9843
10281
  var _UiPath_initializeWithConfig;
@@ -9851,18 +10289,30 @@ var UiPath$1 = class UiPath {
9851
10289
  _UiPath_initialized.set(this, false);
9852
10290
  _UiPath_partialConfig.set(this, undefined);
9853
10291
  _UiPath_metaFolderKey.set(this, undefined);
10292
+ _UiPath_contextFolderKey.set(this, undefined);
10293
+ _UiPath_functionContext.set(this, undefined);
9854
10294
  _UiPath_metaOrgId.set(this, undefined);
9855
10295
  _UiPath_metaTenantId.set(this, undefined);
9856
- const resolved = config2 && isFunctionContext(config2) ? configFromFunctionContext(config2) ?? undefined : config2;
10296
+ let resolved;
10297
+ if (config2 && isFunctionContext(config2)) {
10298
+ __classPrivateFieldSet(this, _UiPath_functionContext, config2, "f");
10299
+ __classPrivateFieldSet(this, _UiPath_contextFolderKey, folderKeyFromFunctionContext(config2), "f");
10300
+ resolved = configFromFunctionContext(config2) ?? undefined;
10301
+ } else {
10302
+ resolved = config2;
10303
+ }
9857
10304
  const configFromMetaTags = loadFromMetaTags();
9858
10305
  __classPrivateFieldSet(this, _UiPath_metaFolderKey, configFromMetaTags?.folderKey, "f");
9859
- __classPrivateFieldSet(this, _UiPath_metaOrgId, configFromMetaTags?.orgName, "f");
10306
+ __classPrivateFieldSet(this, _UiPath_metaOrgId, configFromMetaTags?.organizationId ?? configFromMetaTags?.orgName, "f");
9860
10307
  __classPrivateFieldSet(this, _UiPath_metaTenantId, configFromMetaTags?.tenantName, "f");
9861
10308
  const mergedConfig = __classPrivateFieldGet(_a, _a, "m", _UiPath_mergeConfigSources).call(_a, configFromMetaTags, resolved);
9862
10309
  if (mergedConfig && isCompleteConfig(mergedConfig)) {
9863
10310
  __classPrivateFieldGet(this, _UiPath_instances, "m", _UiPath_initializeWithConfig).call(this, mergedConfig);
9864
- } else if (resolved) {
9865
- __classPrivateFieldSet(this, _UiPath_partialConfig, resolved, "f");
10311
+ } else {
10312
+ if (resolved) {
10313
+ __classPrivateFieldSet(this, _UiPath_partialConfig, resolved, "f");
10314
+ }
10315
+ SDKInternalsRegistry.setUnconfigured(this, missingConfigMessage(mergedConfig, __classPrivateFieldGet(this, _UiPath_functionContext, "f")));
9866
10316
  }
9867
10317
  }
9868
10318
  async initialize() {
@@ -9938,14 +10388,14 @@ var UiPath$1 = class UiPath {
9938
10388
  __classPrivateFieldGet(this, _UiPath_authService, "f")?.updateToken(tokenInfo);
9939
10389
  }
9940
10390
  };
9941
- _a = UiPath$1, _UiPath_config = new WeakMap, _UiPath_authService = new WeakMap, _UiPath_initialized = new WeakMap, _UiPath_partialConfig = new WeakMap, _UiPath_metaFolderKey = new WeakMap, _UiPath_metaOrgId = new WeakMap, _UiPath_metaTenantId = new WeakMap, _UiPath_instances = new WeakSet, _UiPath_initializeWithConfig = function _UiPath_initializeWithConfig2(config2) {
9942
- validateConfig(config2);
10391
+ _a = UiPath$1, _UiPath_config = new WeakMap, _UiPath_authService = new WeakMap, _UiPath_initialized = new WeakMap, _UiPath_partialConfig = new WeakMap, _UiPath_metaFolderKey = new WeakMap, _UiPath_contextFolderKey = new WeakMap, _UiPath_functionContext = new WeakMap, _UiPath_metaOrgId = new WeakMap, _UiPath_metaTenantId = new WeakMap, _UiPath_instances = new WeakSet, _UiPath_initializeWithConfig = function _UiPath_initializeWithConfig2(config2) {
9943
10392
  const hasSecretAuth = hasSecretConfig(config2);
9944
10393
  const hasOAuthAuth = hasOAuthConfig(config2);
9945
10394
  const internalConfig = new UiPathConfig({
9946
10395
  baseUrl: normalizeBaseUrl(config2.baseUrl),
9947
10396
  orgName: config2.orgName,
9948
10397
  tenantName: config2.tenantName,
10398
+ organizationId: config2.organizationId,
9949
10399
  secret: hasSecretAuth ? config2.secret : undefined,
9950
10400
  clientId: hasOAuthAuth ? config2.clientId : undefined,
9951
10401
  redirectUri: hasOAuthAuth ? config2.redirectUri : undefined,
@@ -9959,7 +10409,8 @@ _a = UiPath$1, _UiPath_config = new WeakMap, _UiPath_authService = new WeakMap,
9959
10409
  config: internalConfig,
9960
10410
  context: executionContext,
9961
10411
  tokenManager: __classPrivateFieldGet(this, _UiPath_authService, "f").getTokenManager(),
9962
- folderKey: __classPrivateFieldGet(this, _UiPath_metaFolderKey, "f")
10412
+ folderKey: __classPrivateFieldGet(this, _UiPath_contextFolderKey, "f") ?? __classPrivateFieldGet(this, _UiPath_metaFolderKey, "f"),
10413
+ metaFolderKey: __classPrivateFieldGet(this, _UiPath_metaFolderKey, "f")
9963
10414
  });
9964
10415
  this.config = {
9965
10416
  baseUrl: internalConfig.baseUrl,
@@ -9981,7 +10432,8 @@ _a = UiPath$1, _UiPath_config = new WeakMap, _UiPath_authService = new WeakMap,
9981
10432
  __classPrivateFieldSet(this, _UiPath_initialized, true, "f");
9982
10433
  }
9983
10434
  }, _UiPath_mergeConfigSources = function _UiPath_mergeConfigSources2(metaConfig, config2) {
9984
- const layers = [loadFromEnvironment(), metaConfig, config2].filter((layer) => Boolean(layer)).map((layer) => compactConfig(layer));
10435
+ const environment = loadFromEnvironment();
10436
+ const layers = [environment, metaConfig, config2].filter((layer) => Boolean(layer)).map((layer) => compactConfig(layer));
9985
10437
  if (layers.length === 0)
9986
10438
  return;
9987
10439
  const merged = layers.reduce((acc, layer) => ({ ...acc, ...layer }), {});
@@ -9996,15 +10448,20 @@ _a = UiPath$1, _UiPath_config = new WeakMap, _UiPath_authService = new WeakMap,
9996
10448
  delete merged.secret;
9997
10449
  }
9998
10450
  }
10451
+ const mergedHasSecret = hasSecretConfig(merged);
10452
+ const mergedHasOAuth = hasOAuthConfig(merged);
10453
+ if (mergedHasSecret && mergedHasOAuth) {
10454
+ throw new Error(conflictingAuthMessage({ config: config2, metaConfig, environment }));
10455
+ }
9999
10456
  return merged;
10000
10457
  }, _UiPath_loadConfig = function _UiPath_loadConfig2() {
10001
10458
  const metaConfig = loadFromMetaTags();
10002
10459
  __classPrivateFieldSet(this, _UiPath_metaFolderKey, metaConfig?.folderKey, "f");
10003
- __classPrivateFieldSet(this, _UiPath_metaOrgId, metaConfig?.orgName, "f");
10460
+ __classPrivateFieldSet(this, _UiPath_metaOrgId, metaConfig?.organizationId ?? metaConfig?.orgName, "f");
10004
10461
  __classPrivateFieldSet(this, _UiPath_metaTenantId, metaConfig?.tenantName, "f");
10005
10462
  const merged = __classPrivateFieldGet(_a, _a, "m", _UiPath_mergeConfigSources).call(_a, metaConfig, __classPrivateFieldGet(this, _UiPath_partialConfig, "f"));
10006
10463
  if (!merged || !isCompleteConfig(merged)) {
10007
- throw new Error(missingConfigMessage());
10464
+ throw new Error(missingConfigMessage(merged, __classPrivateFieldGet(this, _UiPath_functionContext, "f")));
10008
10465
  }
10009
10466
  return merged;
10010
10467
  };
@@ -10154,37 +10611,20 @@ class ErrorFactory {
10154
10611
  });
10155
10612
  }
10156
10613
  }
10157
- static createNetworkError(error) {
10158
- let message = ErrorMessages.NETWORK_ERROR;
10159
- if (error instanceof Error) {
10160
- if (error.name === ErrorNames.ABORT_ERROR) {
10161
- message = ErrorMessages.REQUEST_ABORTED;
10162
- } else if (error.message.includes("timeout")) {
10163
- message = ErrorMessages.REQUEST_TIMEOUT;
10164
- } else {
10165
- message = error.message;
10166
- }
10167
- }
10168
- return new NetworkError({ message });
10169
- }
10170
- }
10171
- var FOLDER_KEY = "X-UIPATH-FolderKey";
10172
- var FOLDER_PATH_ENCODED = "X-UIPATH-FolderPath-Encoded";
10173
- var FOLDER_ID = "X-UIPATH-OrganizationUnitId";
10174
- var TRACEPARENT = "traceparent";
10175
- var UIPATH_TRACEPARENT_ID = "x-uipath-traceparent-id";
10176
- var CONTENT_TYPES = {
10177
- JSON: "application/json",
10178
- XML: "application/xml",
10179
- OCTET_STREAM: "application/octet-stream"
10180
- };
10181
- var RESPONSE_TYPES = {
10182
- JSON: "json",
10183
- TEXT: "text",
10184
- BLOB: "blob",
10185
- ARRAYBUFFER: "arraybuffer",
10186
- STREAM: "stream"
10187
- };
10614
+ static createNetworkError(error) {
10615
+ let message = ErrorMessages.NETWORK_ERROR;
10616
+ if (error instanceof Error) {
10617
+ if (error.name === ErrorNames.ABORT_ERROR) {
10618
+ message = ErrorMessages.REQUEST_ABORTED;
10619
+ } else if (error.message.includes("timeout")) {
10620
+ message = ErrorMessages.REQUEST_TIMEOUT;
10621
+ } else {
10622
+ message = error.message;
10623
+ }
10624
+ }
10625
+ return new NetworkError({ message });
10626
+ }
10627
+ }
10188
10628
  function createParams(paramsObj = {}) {
10189
10629
  const params = {};
10190
10630
  for (const [key, value] of Object.entries(paramsObj)) {
@@ -10212,148 +10652,6 @@ function toSearchParams(params) {
10212
10652
  }
10213
10653
  return searchParams;
10214
10654
  }
10215
- var DEFAULT_RETRYABLE_STATUS_CODES = [408, 429, 500, 502, 503, 504];
10216
- var DEFAULT_RETRY_METHODS = ["GET", "HEAD", "PUT", "DELETE", "OPTIONS"];
10217
- var DEFAULT_RETRY_OPTIONS = {
10218
- maxRetries: 2,
10219
- initialDelayMs: 500,
10220
- backoffStrategy: "exponential",
10221
- backoffFactor: 2,
10222
- backoffMaxDelayMs: 30000,
10223
- retryableStatusCodes: DEFAULT_RETRYABLE_STATUS_CODES,
10224
- retryMethods: DEFAULT_RETRY_METHODS,
10225
- retryNetworkErrors: true,
10226
- respectRetryAfter: true,
10227
- maxRetryAfterMs: Infinity
10228
- };
10229
- var DEFAULT_API_CLIENT_RETRY = {
10230
- ...DEFAULT_RETRY_OPTIONS,
10231
- maxRetries: 0
10232
- };
10233
- function resolveRetryOptions(settings, defaults = DEFAULT_RETRY_OPTIONS) {
10234
- if (!settings)
10235
- return defaults;
10236
- const { retryDelay, useExponentialBackoff, ...live } = settings;
10237
- const resolved = { ...defaults };
10238
- for (const [key, value] of Object.entries(live)) {
10239
- if (value !== undefined) {
10240
- resolved[key] = value;
10241
- }
10242
- }
10243
- if (retryDelay !== undefined && live.initialDelayMs === undefined) {
10244
- resolved.initialDelayMs = retryDelay;
10245
- }
10246
- if (useExponentialBackoff !== undefined && live.backoffStrategy === undefined) {
10247
- resolved.backoffStrategy = useExponentialBackoff ? "exponential" : "constant";
10248
- }
10249
- return resolved;
10250
- }
10251
- function computeBackoffDelay(attempt, settings) {
10252
- const base = Math.max(0, settings.initialDelayMs);
10253
- let delay;
10254
- switch (settings.backoffStrategy) {
10255
- case "constant":
10256
- delay = base;
10257
- break;
10258
- case "linear":
10259
- delay = base * (attempt + 1);
10260
- break;
10261
- default:
10262
- delay = base * Math.pow(settings.backoffFactor, attempt);
10263
- }
10264
- return Math.min(delay, settings.backoffMaxDelayMs);
10265
- }
10266
- function parseRetryAfter(value, now = Date.now()) {
10267
- const trimmed = value?.trim();
10268
- if (!trimmed)
10269
- return;
10270
- const seconds = Number(trimmed);
10271
- if (Number.isFinite(seconds))
10272
- return Math.max(0, seconds * 1000);
10273
- const date2 = Date.parse(trimmed);
10274
- if (Number.isNaN(date2))
10275
- return;
10276
- return Math.max(0, date2 - now);
10277
- }
10278
- function wait(durationMs) {
10279
- return new Promise((resolve) => setTimeout(resolve, Math.max(0, durationMs)));
10280
- }
10281
- var RETRY_AFTER = "retry-after";
10282
- function createAttemptSignal(timeoutMs, external) {
10283
- if (timeoutMs === undefined || !Number.isFinite(timeoutMs))
10284
- return { signal: external, dispose: () => {} };
10285
- const controller = new AbortController;
10286
- const timer = setTimeout(() => controller.abort(new Error(`Request timeout after ${timeoutMs}ms`)), timeoutMs);
10287
- const onExternalAbort = () => controller.abort(external?.reason);
10288
- if (external) {
10289
- if (external.aborted) {
10290
- controller.abort(external.reason);
10291
- } else {
10292
- external.addEventListener("abort", onExternalAbort);
10293
- }
10294
- }
10295
- return {
10296
- signal: controller.signal,
10297
- dispose: () => {
10298
- clearTimeout(timer);
10299
- external?.removeEventListener("abort", onExternalAbort);
10300
- }
10301
- };
10302
- }
10303
- function delayBeforeRetry(durationMs, signal) {
10304
- if (!signal)
10305
- return wait(durationMs);
10306
- if (signal.aborted)
10307
- return Promise.reject(signal.reason);
10308
- return new Promise((resolve, reject) => {
10309
- const onAbort = () => {
10310
- clearTimeout(timer);
10311
- reject(signal.reason);
10312
- };
10313
- const timer = setTimeout(() => {
10314
- signal.removeEventListener("abort", onAbort);
10315
- resolve();
10316
- }, Math.max(0, durationMs));
10317
- signal.addEventListener("abort", onAbort);
10318
- });
10319
- }
10320
- async function fetchWithRetry(url, init, options) {
10321
- const settings = options.retry;
10322
- const method = (init.method ?? "GET").toUpperCase();
10323
- const retriesAllowed = settings.retryMethods.includes(method) ? Math.max(0, settings.maxRetries) : 0;
10324
- let attempt = 0;
10325
- for (;; ) {
10326
- const { signal, dispose } = createAttemptSignal(options.timeoutMs, options.signal);
10327
- let response;
10328
- let failure;
10329
- try {
10330
- response = await fetch(url, { ...init, signal });
10331
- } catch (error) {
10332
- failure = error;
10333
- } finally {
10334
- dispose();
10335
- }
10336
- if (options.signal?.aborted && failure !== undefined)
10337
- throw failure;
10338
- if (response && !settings.retryableStatusCodes.includes(response.status))
10339
- return response;
10340
- if (failure !== undefined && !settings.retryNetworkErrors)
10341
- throw failure;
10342
- if (attempt >= retriesAllowed) {
10343
- if (response)
10344
- return response;
10345
- throw failure;
10346
- }
10347
- const retryAfter = settings.respectRetryAfter && response ? parseRetryAfter(response.headers.get(RETRY_AFTER)) : undefined;
10348
- const delay = retryAfter !== undefined ? Math.min(retryAfter, settings.maxRetryAfterMs) : computeBackoffDelay(attempt, settings);
10349
- response?.body?.cancel().catch((error) => {
10350
- console.warn("[UiPath SDK] Could not release a discarded response body:", error);
10351
- });
10352
- await delayBeforeRetry(delay, options.signal);
10353
- attempt++;
10354
- }
10355
- }
10356
-
10357
10655
  class ApiClient {
10358
10656
  constructor(config2, executionContext, tokenManager, clientConfig = {}) {
10359
10657
  this.config = config2;
@@ -10945,9 +11243,9 @@ var _BaseService_apiClient;
10945
11243
  class BaseService {
10946
11244
  constructor(instance, headers) {
10947
11245
  _BaseService_apiClient.set(this, undefined);
10948
- const { config: config2, context, tokenManager, folderKey } = SDKInternalsRegistry.get(instance);
11246
+ const { config: config2, context, tokenManager, folderKey, metaFolderKey } = SDKInternalsRegistry.get(instance);
10949
11247
  __classPrivateFieldSet(this, _BaseService_apiClient, new ApiClient(config2, context, tokenManager, headers ? { headers } : {}), "f");
10950
- this.config = { folderKey };
11248
+ this.config = { folderKey, metaFolderKey };
10951
11249
  }
10952
11250
  async getValidAuthToken() {
10953
11251
  return __classPrivateFieldGet(this, _BaseService_apiClient, "f").getValidToken();
@@ -11036,7 +11334,7 @@ class BaseService {
11036
11334
  limitedPageSize = getLimitedPageSize(params.pageSize);
11037
11335
  const pageSizeParam = paginationParams?.pageSizeParam || ODATA_OFFSET_PARAMS.PAGE_SIZE_PARAM;
11038
11336
  const offsetParam = paginationParams?.offsetParam || ODATA_OFFSET_PARAMS.OFFSET_PARAM;
11039
- const countParam = paginationParams?.countParam || ODATA_OFFSET_PARAMS.COUNT_PARAM;
11337
+ const countParam = paginationParams && "countParam" in paginationParams ? paginationParams.countParam : ODATA_OFFSET_PARAMS.COUNT_PARAM;
11040
11338
  const convertToSkip = paginationParams?.convertToSkip ?? true;
11041
11339
  const zeroBased = paginationParams?.zeroBased ?? false;
11042
11340
  requestParams[pageSizeParam] = limitedPageSize;
@@ -11048,7 +11346,7 @@ class BaseService {
11048
11346
  const sdkPageNumber = params.pageNumber || 1;
11049
11347
  requestParams[offsetParam] = zeroBased ? sdkPageNumber - 1 : sdkPageNumber;
11050
11348
  }
11051
- {
11349
+ if (countParam) {
11052
11350
  requestParams[countParam] = true;
11053
11351
  }
11054
11352
  break;
@@ -11131,6 +11429,11 @@ function createEntityMethods(entityData, service) {
11131
11429
  throw new Error("Entity ID is undefined");
11132
11430
  return service.updateRecords({ id: entityData.id }, data, options);
11133
11431
  },
11432
+ async upsert(data, options) {
11433
+ if (!entityData.name)
11434
+ throw new Error("Entity name is undefined");
11435
+ return service.upsert({ name: entityData.name }, data, options);
11436
+ },
11134
11437
  async deleteRecords(recordIds, options) {
11135
11438
  if (!entityData.id)
11136
11439
  throw new Error("Entity ID is undefined");
@@ -11263,6 +11566,11 @@ var EntityHavingOperator;
11263
11566
  EntityHavingOperator2["LessThan"] = "<";
11264
11567
  EntityHavingOperator2["LessThanOrEqual"] = "<=";
11265
11568
  })(EntityHavingOperator || (EntityHavingOperator = {}));
11569
+ var EntityMultiEntityWriteOperation;
11570
+ (function(EntityMultiEntityWriteOperation2) {
11571
+ EntityMultiEntityWriteOperation2["Insert"] = "Insert";
11572
+ EntityMultiEntityWriteOperation2["Update"] = "Update";
11573
+ })(EntityMultiEntityWriteOperation || (EntityMultiEntityWriteOperation = {}));
11266
11574
  var EntityType;
11267
11575
  (function(EntityType2) {
11268
11576
  EntityType2["Entity"] = "Entity";
@@ -11270,6 +11578,12 @@ var EntityType;
11270
11578
  EntityType2["InternalEntity"] = "InternalEntity";
11271
11579
  EntityType2["SystemEntity"] = "SystemEntity";
11272
11580
  })(EntityType || (EntityType = {}));
11581
+ var EntityClass;
11582
+ (function(EntityClass2) {
11583
+ EntityClass2["Native"] = "Native";
11584
+ EntityClass2["Federated"] = "Federated";
11585
+ EntityClass2["Case"] = "Case";
11586
+ })(EntityClass || (EntityClass = {}));
11273
11587
  var ReferenceType;
11274
11588
  (function(ReferenceType2) {
11275
11589
  ReferenceType2["ManyToOne"] = "ManyToOne";
@@ -11293,6 +11607,11 @@ var JoinType;
11293
11607
  JoinType2["LeftJoin"] = "LeftJoin";
11294
11608
  JoinType2["InnerJoin"] = "InnerJoin";
11295
11609
  })(JoinType || (JoinType = {}));
11610
+ var EntityClassId;
11611
+ (function(EntityClassId2) {
11612
+ EntityClassId2[EntityClassId2["Native"] = 9] = "Native";
11613
+ EntityClassId2[EntityClassId2["Federated"] = 10] = "Federated";
11614
+ })(EntityClassId || (EntityClassId = {}));
11296
11615
  var EntityFieldConstraint;
11297
11616
  (function(EntityFieldConstraint2) {
11298
11617
  EntityFieldConstraint2["LengthLimit"] = "lengthLimit";
@@ -11416,6 +11735,77 @@ var EntityFieldTypeMap = {
11416
11735
  [SqlFieldType.MULTILINE]: EntityFieldDataType.MULTILINE_TEXT,
11417
11736
  [SqlFieldType.MULTILINE_MAX]: EntityFieldDataType.MULTILINE_MAX
11418
11737
  };
11738
+ var EntityClassToIdMap = {
11739
+ [EntityClass.Native]: EntityClassId.Native,
11740
+ [EntityClass.Federated]: EntityClassId.Federated
11741
+ };
11742
+ function isPlainObject(value) {
11743
+ return typeof value === "object" && value !== null && !Array.isArray(value);
11744
+ }
11745
+ function asResourceOverrides(value) {
11746
+ if (!isPlainObject(value))
11747
+ return;
11748
+ const table = {};
11749
+ for (const [key, properties] of Object.entries(value)) {
11750
+ if (!isPlainObject(properties))
11751
+ continue;
11752
+ const bag = {};
11753
+ for (const [property, propertyValue] of Object.entries(properties)) {
11754
+ if (typeof propertyValue === "string")
11755
+ bag[property] = propertyValue;
11756
+ }
11757
+ table[key] = bag;
11758
+ }
11759
+ return Object.keys(table).length > 0 ? table : undefined;
11760
+ }
11761
+ function readFromDocument() {
11762
+ if (!isBrowser)
11763
+ return;
11764
+ const text = document.getElementById(UiPathElementIds.RESOURCE_OVERRIDES)?.textContent;
11765
+ if (!text)
11766
+ return;
11767
+ try {
11768
+ return asResourceOverrides(JSON.parse(text));
11769
+ } catch (error) {
11770
+ console.warn(`[UiPath SDK] Failed to parse <script id="${UiPathElementIds.RESOURCE_OVERRIDES}"> as JSON — proceeding without overrides:`, error);
11771
+ return;
11772
+ }
11773
+ }
11774
+ var table;
11775
+ var loaded = false;
11776
+ var pageOverrides = () => {
11777
+ if (!loaded) {
11778
+ loaded = true;
11779
+ table = readFromDocument();
11780
+ }
11781
+ return table;
11782
+ };
11783
+ var RESOURCE_OVERWRITES_KEY = Symbol.for("uipath.resourceOverwrites.v1");
11784
+ function readOverrides() {
11785
+ const slot = globalThis[RESOURCE_OVERWRITES_KEY];
11786
+ const source = typeof slot === "function" ? slot : pageOverrides;
11787
+ try {
11788
+ return source();
11789
+ } catch (error) {
11790
+ console.warn("[UiPath SDK] Override source threw — proceeding without overrides:", error);
11791
+ return;
11792
+ }
11793
+ }
11794
+ function resolveOverride(resourceType, name, folderPath) {
11795
+ const table2 = readOverrides();
11796
+ if (!table2)
11797
+ return;
11798
+ const bindingType = resourceType.toLowerCase();
11799
+ const scopedKey = folderPath ? `${bindingType}.${name}.${folderPath}` : undefined;
11800
+ const unscopedKey = `${bindingType}.${name}`;
11801
+ const entry = (scopedKey && table2[scopedKey]) ?? table2[unscopedKey];
11802
+ if (!entry)
11803
+ return;
11804
+ return {
11805
+ name: entry.name,
11806
+ folderPath: entry.folderPath
11807
+ };
11808
+ }
11419
11809
  var JOIN_TYPE_WIRE = {
11420
11810
  [JoinType.LeftJoin]: "LEFT",
11421
11811
  [JoinType.InnerJoin]: "INNER"
@@ -11431,6 +11821,39 @@ function toWireJoin(join, baseEntityName) {
11431
11821
  }
11432
11822
  };
11433
11823
  }
11824
+ function externalSourceObjectName(source) {
11825
+ return source.externalObjectDetail?.externalObjectName;
11826
+ }
11827
+ function externalSourceFieldName(field) {
11828
+ const def = field.fieldDefinition;
11829
+ return def?.name ?? def?.Name;
11830
+ }
11831
+ function externalSourceMappedName(field) {
11832
+ const m = field.externalFieldMappingDetail ?? field.ExternalFieldMappingDetail;
11833
+ return m?.externalFieldName ?? m?.ExternalFieldName;
11834
+ }
11835
+ function sourceConnId(s) {
11836
+ const ext = s.externalConnectionDetail;
11837
+ const nat = s.nativeConnectionDetail;
11838
+ return ext?.connectionId ?? nat?.entityId;
11839
+ }
11840
+ function carryForwardSource(source) {
11841
+ const fields = (source.fields ?? []).map((f) => {
11842
+ const fieldDefinition = { ...f.fieldDefinition };
11843
+ if (fieldDefinition.fieldDisplayType === undefined && fieldDefinition.FieldDisplayType === undefined) {
11844
+ fieldDefinition.fieldDisplayType = FieldDisplayType.Basic;
11845
+ }
11846
+ if (fieldDefinition.description === undefined && fieldDefinition.Description === undefined) {
11847
+ fieldDefinition.description = "";
11848
+ }
11849
+ return { ...f, fieldDefinition };
11850
+ });
11851
+ return { ...source, fields };
11852
+ }
11853
+ function applyEntityNameOverride(entityName) {
11854
+ const override = resolveOverride("Entity", entityName);
11855
+ return override?.name ?? entityName;
11856
+ }
11434
11857
  function unwrapEntityRef(entityRef, callerLabel) {
11435
11858
  const { id, name } = entityRef ?? {};
11436
11859
  if (id && name) {
@@ -11442,7 +11865,7 @@ function unwrapEntityRef(entityRef, callerLabel) {
11442
11865
  return { byId: true, identifier: id };
11443
11866
  }
11444
11867
  if (name) {
11445
- return { byId: false, identifier: name };
11868
+ return { byId: false, identifier: applyEntityNameOverride(name) };
11446
11869
  }
11447
11870
  throw new ValidationError({
11448
11871
  message: `${callerLabel}: entityRef must supply exactly one of 'id' or 'name'.`
@@ -11454,19 +11877,19 @@ class EntityService extends BaseService {
11454
11877
  return this.fetchEntityMetadata(DATA_FABRIC_ENDPOINTS.ENTITY.GET_BY_ID(id), options?.folderKey);
11455
11878
  }
11456
11879
  async getByName(entityName, options) {
11457
- return this.fetchEntityMetadata(DATA_FABRIC_ENDPOINTS.ENTITY.GET_BY_NAME(entityName), options?.folderKey);
11880
+ return this.fetchEntityMetadata(DATA_FABRIC_ENDPOINTS.ENTITY.GET_BY_NAME(applyEntityNameOverride(entityName)), options?.folderKey);
11458
11881
  }
11459
11882
  async getAllRecords(entityId, options) {
11460
11883
  return this.getRecordsImpl(true, entityId, options);
11461
11884
  }
11462
11885
  async getRecordsByName(entityName, options) {
11463
- return this.getRecordsImpl(false, entityName, options);
11886
+ return this.getRecordsImpl(false, applyEntityNameOverride(entityName), options);
11464
11887
  }
11465
11888
  async getRecordById(entityId, recordId, options = {}) {
11466
11889
  return this.getRecordImpl(true, entityId, recordId, options);
11467
11890
  }
11468
11891
  async getRecordByName(entityName, recordId, options = {}) {
11469
- return this.getRecordImpl(false, entityName, recordId, options);
11892
+ return this.getRecordImpl(false, applyEntityNameOverride(entityName), recordId, options);
11470
11893
  }
11471
11894
  async insertRecord(entityRef, data, options = {}) {
11472
11895
  const { byId, identifier } = unwrapEntityRef(entityRef, "Entities.insertRecord");
@@ -11496,6 +11919,11 @@ class EntityService extends BaseService {
11496
11919
  async updateRecordsById(id, data, options = {}) {
11497
11920
  return this.updateRecordsImpl(true, id, data, options);
11498
11921
  }
11922
+ async upsert(entityRef, data, options = {}) {
11923
+ const { byId, identifier } = unwrapEntityRef(entityRef, "Entities.upsert");
11924
+ const entityName = byId ? await this.resolveEntityName(identifier, options.folderKey) : identifier;
11925
+ return this.upsertImpl(entityName, data, options);
11926
+ }
11499
11927
  async deleteRecords(entityRef, recordIds, options = {}) {
11500
11928
  const { byId, identifier } = unwrapEntityRef(entityRef, "Entities.deleteRecords");
11501
11929
  return this.deleteRecordsImpl(byId, identifier, recordIds, options);
@@ -11511,7 +11939,7 @@ class EntityService extends BaseService {
11511
11939
  return this.deleteRecordImpl(true, entityId, recordId, options);
11512
11940
  }
11513
11941
  async getAll(options) {
11514
- const endpoint = !options?.folderKey && options?.includeFolderEntities ? DATA_FABRIC_ENDPOINTS.ENTITY.GET_ALL_V2 : DATA_FABRIC_ENDPOINTS.ENTITY.GET_ALL;
11942
+ const endpoint = options?.folderKey || options?.includeFolderEntities ? DATA_FABRIC_ENDPOINTS.ENTITY.GET_ALL_V3 : DATA_FABRIC_ENDPOINTS.ENTITY.GET_ALL;
11515
11943
  const response = await this.get(endpoint, { headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }) });
11516
11944
  const entities = response.data.map((entity) => {
11517
11945
  const metadata = transformData(entity, EntityMap);
@@ -11573,7 +12001,22 @@ class EntityService extends BaseService {
11573
12001
  }
11574
12002
  async create(name, fields, options) {
11575
12003
  const opts = options ?? {};
12004
+ let entityClassId;
12005
+ if (opts.entityClass !== undefined) {
12006
+ entityClassId = EntityClassToIdMap[opts.entityClass];
12007
+ if (entityClassId === undefined) {
12008
+ throw new ValidationError({
12009
+ message: `entityClass '${opts.entityClass}' is not creatable. Use EntityClass.Native or EntityClass.Federated.`
12010
+ });
12011
+ }
12012
+ }
12013
+ if (opts.entityClass === EntityClass.Federated && !opts.externalFields?.length) {
12014
+ throw new ValidationError({
12015
+ message: "Federated entities require at least one external source in `externalFields`."
12016
+ });
12017
+ }
11576
12018
  const fieldPayloads = await this.buildFieldsWithReferenceMeta(fields);
12019
+ const externalFields = await this.buildExternalSourcesPayload(opts.externalFields);
11577
12020
  const payload = {
11578
12021
  ...opts.description !== undefined && { description: opts.description },
11579
12022
  displayName: opts.displayName ?? name,
@@ -11583,7 +12026,9 @@ class EntityService extends BaseService {
11583
12026
  folderId: opts.folderKey ?? DATA_FABRIC_TENANT_FOLDER_ID,
11584
12027
  isRbacEnabled: opts.isRbacEnabled ?? false,
11585
12028
  isInsightsEnabled: opts.isAnalyticsEnabled ?? false,
11586
- externalFields: opts.externalFields ?? []
12029
+ externalFields,
12030
+ ...entityClassId !== undefined && { entityClassId },
12031
+ ...opts.sourceJoinConditionDetails !== undefined && { sourceJoinConditionDetails: opts.sourceJoinConditionDetails }
11587
12032
  }
11588
12033
  };
11589
12034
  const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPSERT, payload, { headers: createHeaders({ [FOLDER_KEY]: opts.folderKey }) });
@@ -11594,18 +12039,19 @@ class EntityService extends BaseService {
11594
12039
  }
11595
12040
  async updateById(id, options) {
11596
12041
  const opts = options ?? {};
11597
- const hasSchemaChanges = !!(opts.addFields?.length || opts.removeFields?.length || opts.updateFields?.length);
12042
+ const hasFederatedChanges = !!(opts.addExternalSources?.length || opts.removeExternalSources?.length || opts.addExternalFields?.length || opts.removeExternalFields?.length || opts.addSourceJoins?.length || opts.updateSourceJoin?.length || opts.replaceSourceJoins !== undefined || opts.updateExternalConnection?.length);
12043
+ const hasSchemaChanges = !!(opts.addFields?.length || opts.removeFields?.length || opts.updateFields?.length) || hasFederatedChanges;
11598
12044
  const hasMetadataChanges = opts.displayName !== undefined || opts.description !== undefined || opts.isRbacEnabled !== undefined;
11599
12045
  if (!hasSchemaChanges && !hasMetadataChanges) {
11600
12046
  throw new ValidationError({
11601
- message: "updateById requires at least one change — pass addFields, removeFields, updateFields, displayName, description, or isRbacEnabled."
12047
+ message: "updateById requires at least one change — pass addFields, removeFields, updateFields, displayName, description, isRbacEnabled, or a federated source/join delta (addExternalSources, removeExternalSources, addExternalFields, removeExternalFields, addSourceJoins, updateSourceJoin, replaceSourceJoins, updateExternalConnection)."
11602
12048
  });
11603
12049
  }
11604
12050
  if (hasSchemaChanges) {
11605
12051
  await this.applySchemaUpdate(id, opts);
11606
12052
  }
11607
12053
  if (hasMetadataChanges) {
11608
- await this.patch(DATA_FABRIC_ENDPOINTS.ENTITY.UPDATE(id), {
12054
+ await this.patch(DATA_FABRIC_ENDPOINTS.ENTITY.UPDATE_METADATA(id), {
11609
12055
  ...opts.displayName !== undefined && { displayName: opts.displayName },
11610
12056
  ...opts.description !== undefined && { description: opts.description },
11611
12057
  ...opts.isRbacEnabled !== undefined && { isRbacEnabled: opts.isRbacEnabled }
@@ -11616,7 +12062,7 @@ class EntityService extends BaseService {
11616
12062
  const folderHeaders = createHeaders({ [FOLDER_KEY]: options.folderKey });
11617
12063
  const entityResponse = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.GET_BY_ID(entityId), { headers: folderHeaders });
11618
12064
  const raw = entityResponse.data;
11619
- let fields = (raw.fields ?? []).filter((f) => !f.isSystemField && !f.isPrimaryKey);
12065
+ let fields = (raw.fields ?? []).filter((f) => !f.isSystemField && !f.isPrimaryKey && !f.isExternalField);
11620
12066
  if (options.removeFields?.length) {
11621
12067
  const existingNames = new Set(fields.map((f) => f.name));
11622
12068
  const missing = options.removeFields.filter((r) => !existingNames.has(r.name)).map((r) => r.name);
@@ -11674,6 +12120,7 @@ class EntityService extends BaseService {
11674
12120
  if (options.addFields?.length) {
11675
12121
  newFields.push(...await this.buildFieldsWithReferenceMeta(options.addFields));
11676
12122
  }
12123
+ const federated = await this.buildFederatedUpsertParts(raw, options);
11677
12124
  await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPSERT, {
11678
12125
  displayName: raw.displayName,
11679
12126
  description: raw.description,
@@ -11684,13 +12131,132 @@ class EntityService extends BaseService {
11684
12131
  folderId: raw.folderId ?? DATA_FABRIC_TENANT_FOLDER_ID,
11685
12132
  isRbacEnabled: raw.isRbacEnabled ?? false,
11686
12133
  isInsightsEnabled: raw.isInsightsEnabled ?? false,
11687
- externalFields: raw.externalFields ?? []
12134
+ externalFields: federated.externalFields,
12135
+ ...federated.entityClassId !== undefined && { entityClassId: federated.entityClassId },
12136
+ ...federated.sourceJoinConditionDetails !== undefined && { sourceJoinConditionDetails: federated.sourceJoinConditionDetails }
11688
12137
  }
11689
12138
  }, { headers: folderHeaders });
11690
12139
  }
11691
- async resolveEntityName(id, folderKey) {
11692
- const response = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.GET_BY_ID(id), { headers: createHeaders({ [FOLDER_KEY]: folderKey }) });
11693
- return transformData(response.data, EntityMap).name;
12140
+ async resolveEntityName(id, folderKey) {
12141
+ const response = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.GET_BY_ID(id), { headers: createHeaders({ [FOLDER_KEY]: folderKey }) });
12142
+ return transformData(response.data, EntityMap).name;
12143
+ }
12144
+ async buildFederatedUpsertParts(raw, options) {
12145
+ let externalFields = (raw.externalFields ?? []).map((s) => carryForwardSource({ ...s }));
12146
+ let joins = this.translateSourceJoins(raw);
12147
+ const entityClassId = raw.entityClass ? EntityClassToIdMap[raw.entityClass] : undefined;
12148
+ const findSource = (ref) => externalFields.find((s) => externalSourceObjectName(s) === ref.sourceObjectName && sourceConnId(s) === ref.sourceConnectionId);
12149
+ const notFound = (action, ref) => new ValidationError({ message: `Cannot ${action}: no source '${ref.sourceObjectName}' with connection '${ref.sourceConnectionId}' on the entity.` });
12150
+ if (options.replaceSourceJoins !== undefined && (options.addSourceJoins?.length || options.updateSourceJoin?.length)) {
12151
+ throw new ValidationError({ message: "replaceSourceJoins sets the entity's complete join set, so it cannot be combined with addSourceJoins or updateSourceJoin." });
12152
+ }
12153
+ if (options.addExternalSources?.length) {
12154
+ externalFields.push(...await this.buildExternalSourcesPayload(options.addExternalSources));
12155
+ }
12156
+ if (options.removeExternalSources?.length) {
12157
+ const removeKeys = new Set(options.removeExternalSources.map((r) => `${r.sourceObjectName} ${r.sourceConnectionId}`));
12158
+ externalFields = externalFields.filter((s) => !removeKeys.has(`${externalSourceObjectName(s) ?? ""} ${sourceConnId(s) ?? ""}`));
12159
+ joins = joins.filter((j) => !removeKeys.has(`${j.sourceObjectName} ${j.sourceObjectConnectionId}`) && !removeKeys.has(`${j.relatedSourceObjectName} ${j.relatedSourceObjectConnectionId}`));
12160
+ }
12161
+ if (options.addExternalFields?.length) {
12162
+ for (const add of options.addExternalFields) {
12163
+ const src = findSource(add);
12164
+ if (!src)
12165
+ throw notFound("add fields", add);
12166
+ const builtFields = await this.buildExternalFieldsPayload(add.fields);
12167
+ const existing = src.fields ?? [];
12168
+ src.fields = [...existing, ...builtFields];
12169
+ }
12170
+ }
12171
+ if (options.removeExternalFields?.length) {
12172
+ for (const rem of options.removeExternalFields) {
12173
+ const src = findSource(rem);
12174
+ if (!src)
12175
+ throw notFound("remove fields", rem);
12176
+ const drop = new Set(rem.fieldNames);
12177
+ const all = src.fields ?? [];
12178
+ const dropExternal = new Set(all.filter((f) => drop.has(externalSourceFieldName(f) ?? "")).map((f) => externalSourceMappedName(f) ?? ""));
12179
+ src.fields = all.filter((f) => !drop.has(externalSourceFieldName(f) ?? ""));
12180
+ joins = joins.filter((j) => !(j.sourceObjectName === rem.sourceObjectName && j.sourceObjectConnectionId === rem.sourceConnectionId && dropExternal.has(j.sourceJoinField)) && !(j.relatedSourceObjectName === rem.sourceObjectName && j.relatedSourceObjectConnectionId === rem.sourceConnectionId && dropExternal.has(j.relatedSourceJoinField)));
12181
+ }
12182
+ }
12183
+ if (options.addSourceJoins?.length) {
12184
+ joins.push(...options.addSourceJoins.map((j) => ({ ...j })));
12185
+ }
12186
+ if (options.replaceSourceJoins !== undefined) {
12187
+ joins = options.replaceSourceJoins.map((j) => ({ ...j }));
12188
+ }
12189
+ if (options.updateSourceJoin?.length) {
12190
+ for (const up of options.updateSourceJoin) {
12191
+ const join = joins.find((j) => j.sourceObjectName === up.sourceObjectName && j.sourceObjectConnectionId === up.sourceConnectionId && j.relatedSourceObjectName === up.relatedSourceObjectName && j.relatedSourceObjectConnectionId === up.relatedSourceConnectionId);
12192
+ if (!join)
12193
+ throw new ValidationError({ message: `Cannot update join: no join between '${up.sourceObjectName}' (${up.sourceConnectionId}) and '${up.relatedSourceObjectName}' (${up.relatedSourceConnectionId}).` });
12194
+ if (up.sourceJoinField !== undefined)
12195
+ join.sourceJoinField = up.sourceJoinField;
12196
+ if (up.relatedSourceJoinField !== undefined)
12197
+ join.relatedSourceJoinField = up.relatedSourceJoinField;
12198
+ }
12199
+ }
12200
+ if (options.updateExternalConnection?.length) {
12201
+ for (const swap of options.updateExternalConnection) {
12202
+ const src = findSource(swap);
12203
+ if (!src)
12204
+ throw notFound("replace connection", swap);
12205
+ if (src.nativeConnectionDetail !== undefined) {
12206
+ throw new ValidationError({ message: `Cannot replace connection: source '${swap.sourceObjectName}' is a native (entity-backed) source, not a connector source.` });
12207
+ }
12208
+ const existingConn = src.externalConnectionDetail;
12209
+ src.externalConnectionDetail = {
12210
+ ...existingConn,
12211
+ connectionId: swap.newConnectionId,
12212
+ ...swap.newElementInstanceId !== undefined && { elementInstanceId: swap.newElementInstanceId },
12213
+ ...swap.newFolderKey !== undefined && { folderKey: swap.newFolderKey },
12214
+ ...swap.newConnectionName !== undefined && { connectionName: swap.newConnectionName }
12215
+ };
12216
+ const oldConnId = swap.sourceConnectionId;
12217
+ const newConnId = swap.newConnectionId;
12218
+ for (const j of joins) {
12219
+ if (j.sourceObjectName === swap.sourceObjectName && j.sourceObjectConnectionId === oldConnId)
12220
+ j.sourceObjectConnectionId = newConnId;
12221
+ if (j.relatedSourceObjectName === swap.sourceObjectName && j.relatedSourceObjectConnectionId === oldConnId)
12222
+ j.relatedSourceObjectConnectionId = newConnId;
12223
+ }
12224
+ }
12225
+ }
12226
+ externalFields = externalFields.map((s) => ({
12227
+ ...s,
12228
+ externalObjectDetail: { ...s.externalObjectDetail, isPrimarySource: false }
12229
+ }));
12230
+ return {
12231
+ externalFields,
12232
+ ...entityClassId !== undefined && { entityClassId },
12233
+ ...joins.length > 0 && { sourceJoinConditionDetails: joins }
12234
+ };
12235
+ }
12236
+ translateSourceJoins(raw) {
12237
+ const byObjectId = new Map;
12238
+ for (const source of raw.externalFields ?? []) {
12239
+ const objectId = source.externalObjectDetail?.id;
12240
+ if (!objectId)
12241
+ continue;
12242
+ byObjectId.set(objectId, {
12243
+ name: source.externalObjectDetail?.externalObjectName,
12244
+ connectionId: source.externalConnectionDetail?.connectionId ?? source.nativeConnectionDetail?.entityId
12245
+ });
12246
+ }
12247
+ return (raw.sourceJoinCriterias ?? []).map((join) => {
12248
+ const src = byObjectId.get(join.sourceObjectId ?? "");
12249
+ const related = byObjectId.get(join.relatedSourceObjectId ?? "");
12250
+ return {
12251
+ sourceObjectName: src?.name,
12252
+ sourceJoinField: join.joinFieldName,
12253
+ sourceObjectConnectionId: src?.connectionId,
12254
+ joinType: join.joinType,
12255
+ relatedSourceObjectName: related?.name,
12256
+ relatedSourceJoinField: join.relatedSourceFieldName,
12257
+ relatedSourceObjectConnectionId: related?.connectionId
12258
+ };
12259
+ });
11694
12260
  }
11695
12261
  applyFieldMappings(metadata) {
11696
12262
  this.mapFieldTypes(metadata);
@@ -11749,6 +12315,24 @@ class EntityService extends BaseService {
11749
12315
  const metas = await Promise.all(fields.map((f) => this.buildReferenceMeta(f)));
11750
12316
  return fields.map((f, i) => this.buildSchemaFieldPayload(f, metas[i]));
11751
12317
  }
12318
+ async buildExternalFieldsPayload(fields) {
12319
+ const list = fields ?? [];
12320
+ const fieldDefs = await this.buildFieldsWithReferenceMeta(list.map((f) => f.field));
12321
+ return list.map((f, i) => ({
12322
+ fieldDefinition: fieldDefs[i],
12323
+ externalFieldMappingDetail: f.externalFieldMappingDetail
12324
+ }));
12325
+ }
12326
+ async buildExternalSourcesPayload(sources) {
12327
+ if (!sources?.length)
12328
+ return [];
12329
+ return Promise.all(sources.map(async (source) => ({
12330
+ fields: await this.buildExternalFieldsPayload(source.fields),
12331
+ externalObjectDetail: source.externalObjectDetail,
12332
+ ...source.externalConnectionDetail !== undefined && { externalConnectionDetail: source.externalConnectionDetail },
12333
+ ...source.nativeConnectionDetail !== undefined && { nativeConnectionDetail: source.nativeConnectionDetail }
12334
+ })));
12335
+ }
11752
12336
  async buildReferenceMeta(field) {
11753
12337
  if (field.referenceFolderKey === undefined)
11754
12338
  return;
@@ -11936,6 +12520,11 @@ class EntityService extends BaseService {
11936
12520
  const response = await this.post(byId ? DATA_FABRIC_ENDPOINTS.ENTITY.UPDATE_BY_ID(identifier) : DATA_FABRIC_ENDPOINTS.ENTITY.UPDATE_BY_NAME(identifier), data, { params, headers: createHeaders({ [FOLDER_KEY]: options.folderKey }) });
11937
12521
  return response.data;
11938
12522
  }
12523
+ async upsertImpl(entityName, data, options) {
12524
+ const params = createParams({ expansionLevel: options.expansionLevel });
12525
+ const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPSERT_RECORD_BY_NAME(entityName), data, { params, headers: createHeaders({ [FOLDER_KEY]: options.folderKey }) });
12526
+ return response.data;
12527
+ }
11939
12528
  async deleteRecordsImpl(byId, identifier, recordIds, options) {
11940
12529
  const params = createParams({ failOnFirst: options.failOnFirst });
11941
12530
  const response = await this.post(byId ? DATA_FABRIC_ENDPOINTS.ENTITY.DELETE_BY_ID(identifier) : DATA_FABRIC_ENDPOINTS.ENTITY.DELETE_BY_NAME(identifier), recordIds, { params, headers: createHeaders({ [FOLDER_KEY]: options.folderKey }) });
@@ -12040,6 +12629,9 @@ __decorate([
12040
12629
  __decorate([
12041
12630
  track("Entities.UpdateRecordsById")
12042
12631
  ], EntityService.prototype, "updateRecordsById", null);
12632
+ __decorate([
12633
+ track("Entities.Upsert")
12634
+ ], EntityService.prototype, "upsert", null);
12043
12635
  __decorate([
12044
12636
  track("Entities.DeleteRecords")
12045
12637
  ], EntityService.prototype, "deleteRecords", null);
@@ -12147,7 +12739,7 @@ class ChoiceSetService extends BaseService {
12147
12739
  }, { headers: createHeaders({ [FOLDER_KEY]: options.folderKey }) });
12148
12740
  }
12149
12741
  async deleteById(choiceSetId, options) {
12150
- await this.post(DATA_FABRIC_ENDPOINTS.CHOICESETS.DELETE(choiceSetId), {}, { headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }) });
12742
+ await this.delete(DATA_FABRIC_ENDPOINTS.CHOICESETS.DELETE(choiceSetId), { headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }) });
12151
12743
  }
12152
12744
  async insertValueById(choiceSetId, name, options) {
12153
12745
  const choiceSetName = await this.resolveChoiceSetName(choiceSetId, options?.folderKey);
@@ -13508,73 +14100,6 @@ function validateName(resourceType, name) {
13508
14100
  return trimmed;
13509
14101
  }
13510
14102
  var GUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
13511
- function isPlainObject(value) {
13512
- return typeof value === "object" && value !== null && !Array.isArray(value);
13513
- }
13514
- function asResourceOverrides(value) {
13515
- if (!isPlainObject(value))
13516
- return;
13517
- const table = {};
13518
- for (const [key, properties] of Object.entries(value)) {
13519
- if (!isPlainObject(properties))
13520
- continue;
13521
- const bag = {};
13522
- for (const [property, propertyValue] of Object.entries(properties)) {
13523
- if (typeof propertyValue === "string")
13524
- bag[property] = propertyValue;
13525
- }
13526
- table[key] = bag;
13527
- }
13528
- return Object.keys(table).length > 0 ? table : undefined;
13529
- }
13530
- function readFromDocument() {
13531
- if (!isBrowser)
13532
- return;
13533
- const text = document.getElementById(UiPathElementIds.RESOURCE_OVERRIDES)?.textContent;
13534
- if (!text)
13535
- return;
13536
- try {
13537
- return asResourceOverrides(JSON.parse(text));
13538
- } catch (error) {
13539
- console.warn(`[UiPath SDK] Failed to parse <script id="${UiPathElementIds.RESOURCE_OVERRIDES}"> as JSON — proceeding without overrides:`, error);
13540
- return;
13541
- }
13542
- }
13543
- var table;
13544
- var loaded = false;
13545
- var pageOverrides = () => {
13546
- if (!loaded) {
13547
- loaded = true;
13548
- table = readFromDocument();
13549
- }
13550
- return table;
13551
- };
13552
- var RESOURCE_OVERWRITES_KEY = Symbol.for("uipath.resourceOverwrites.v1");
13553
- function readOverrides() {
13554
- const slot = globalThis[RESOURCE_OVERWRITES_KEY];
13555
- const source = typeof slot === "function" ? slot : pageOverrides;
13556
- try {
13557
- return source();
13558
- } catch (error) {
13559
- console.warn("[UiPath SDK] Override source threw — proceeding without overrides:", error);
13560
- return;
13561
- }
13562
- }
13563
- function resolveOverride(resourceType, name, folderPath) {
13564
- const table2 = readOverrides();
13565
- if (!table2)
13566
- return;
13567
- const bindingType = resourceType.toLowerCase();
13568
- const scopedKey = folderPath ? `${bindingType}.${name}.${folderPath}` : undefined;
13569
- const unscopedKey = `${bindingType}.${name}`;
13570
- const entry = (scopedKey && table2[scopedKey]) ?? table2[unscopedKey];
13571
- if (!entry)
13572
- return;
13573
- return {
13574
- name: entry.name,
13575
- folderPath: entry.folderPath
13576
- };
13577
- }
13578
14103
  var SINGLE_QUOTE_RE = /'/g;
13579
14104
 
13580
14105
  class FolderScopedService extends BaseService {
@@ -13616,7 +14141,7 @@ class FolderScopedService extends BaseService {
13616
14141
  });
13617
14142
  const items = response.data?.value;
13618
14143
  if (!items?.length) {
13619
- const folderHint = describeFolderForError(folderId, folderKey, resolvedFolderPath);
14144
+ const folderHint = describeFolderForError(folderId, headers[FOLDER_KEY], resolvedFolderPath);
13620
14145
  throw new NotFoundError({
13621
14146
  message: `${resourceType} '${resolvedName}' not found${folderHint}.`
13622
14147
  });
@@ -14564,10 +15089,7 @@ class BucketService extends FolderScopedService {
14564
15089
  }
14565
15090
  }, options);
14566
15091
  }
14567
- async getFileMetaData(bucketId, optionsOrFolderId, legacyOptions) {
14568
- if (!bucketId) {
14569
- throw new ValidationError({ message: "bucketId is required for getFileMetaData" });
14570
- }
15092
+ async getFileMetaData(bucketIdOrRef, optionsOrFolderId, legacyOptions) {
14571
15093
  let folderId;
14572
15094
  let folderKey;
14573
15095
  let folderPath;
@@ -14579,10 +15101,14 @@ class BucketService extends FolderScopedService {
14579
15101
  const opts = optionsOrFolderId ?? {};
14580
15102
  ({ folderId, folderKey, folderPath, ...restOptions } = opts);
14581
15103
  }
15104
+ const { id: bucketId, effectiveFolder } = await this.resolveBucketRef(bucketIdOrRef, { folderId, folderKey, folderPath }, "Buckets.getFileMetaData");
15105
+ if (bucketId <= 0) {
15106
+ throw new ValidationError({ message: "Buckets.getFileMetaData: bucketId must be a positive number." });
15107
+ }
14582
15108
  const headers = resolveFolderHeaders({
14583
- folderId,
14584
- folderKey,
14585
- folderPath,
15109
+ folderId: effectiveFolder.folderId ?? folderId,
15110
+ folderKey: effectiveFolder.folderKey ?? folderKey,
15111
+ folderPath: effectiveFolder.folderPath ?? folderPath,
14586
15112
  resourceType: "Buckets.getFileMetaData",
14587
15113
  fallbackFolderKey: this.config.folderKey
14588
15114
  });
@@ -14605,35 +15131,43 @@ class BucketService extends FolderScopedService {
14605
15131
  headers
14606
15132
  }, apiRestOptions);
14607
15133
  }
14608
- async uploadFile(bucketIdOrOptions, path, content, options) {
14609
- let bucketId;
15134
+ async uploadFile(firstArg, path, content, options) {
15135
+ let bucketIdOrRef;
14610
15136
  let resolvedPath;
14611
15137
  let resolvedContent;
14612
15138
  let folderId;
14613
15139
  let folderKey;
14614
15140
  let folderPath;
14615
- if (bucketIdOrOptions !== null && typeof bucketIdOrOptions === "object") {
14616
- ({ bucketId, path: resolvedPath, content: resolvedContent, folderId, folderKey, folderPath } = bucketIdOrOptions);
15141
+ const isDeprecatedOptionsForm = firstArg !== null && typeof firstArg === "object" && "bucketId" in firstArg;
15142
+ if (isDeprecatedOptionsForm) {
15143
+ const opts = firstArg;
15144
+ bucketIdOrRef = opts.bucketId;
15145
+ resolvedPath = opts.path;
15146
+ resolvedContent = opts.content;
15147
+ folderId = opts.folderId;
15148
+ folderKey = opts.folderKey;
15149
+ folderPath = opts.folderPath;
14617
15150
  } else {
14618
- bucketId = bucketIdOrOptions;
15151
+ bucketIdOrRef = firstArg;
14619
15152
  resolvedPath = path;
14620
15153
  resolvedContent = content;
14621
15154
  const opts = options ?? {};
14622
15155
  ({ folderId, folderKey, folderPath } = opts);
14623
15156
  }
14624
- if (!bucketId) {
14625
- throw new ValidationError({ message: "bucketId is required for uploadFile" });
14626
- }
14627
15157
  if (!resolvedPath) {
14628
15158
  throw new ValidationError({ message: "path is required for uploadFile" });
14629
15159
  }
14630
15160
  if (!resolvedContent) {
14631
15161
  throw new ValidationError({ message: "content is required for uploadFile" });
14632
15162
  }
15163
+ const { id: bucketId, effectiveFolder } = await this.resolveBucketRef(bucketIdOrRef, { folderId, folderKey, folderPath }, "Buckets.uploadFile");
15164
+ if (bucketId <= 0) {
15165
+ throw new ValidationError({ message: "Buckets.uploadFile: bucketId must be a positive number." });
15166
+ }
14633
15167
  const headers = resolveFolderHeaders({
14634
- folderId,
14635
- folderKey,
14636
- folderPath,
15168
+ folderId: effectiveFolder.folderId ?? folderId,
15169
+ folderKey: effectiveFolder.folderKey ?? folderKey,
15170
+ folderPath: effectiveFolder.folderPath ?? folderPath,
14637
15171
  resourceType: "Buckets.uploadFile",
14638
15172
  fallbackFolderKey: this.config.folderKey
14639
15173
  });
@@ -14648,17 +15182,19 @@ class BucketService extends FolderScopedService {
14648
15182
  statusCode: response.status
14649
15183
  };
14650
15184
  }
14651
- async getReadUri(bucketIdOrOptions, path, options) {
14652
- let bucketId;
15185
+ async getReadUri(firstArg, path, options) {
15186
+ let bucketIdOrRef;
14653
15187
  let resolvedPath;
14654
15188
  let folderId;
14655
15189
  let folderKey;
14656
15190
  let folderPath;
14657
15191
  let expiryInMinutes;
14658
15192
  let restOptions;
14659
- if (bucketIdOrOptions !== null && typeof bucketIdOrOptions === "object") {
14660
- const { bucketId: bid, path: p, expiryInMinutes: e, folderId: fid, folderKey: fkey, folderPath: fpath, ...rest } = bucketIdOrOptions;
14661
- bucketId = bid;
15193
+ const isDeprecatedOptionsForm = firstArg !== null && typeof firstArg === "object" && "bucketId" in firstArg;
15194
+ if (isDeprecatedOptionsForm) {
15195
+ const opts = firstArg;
15196
+ const { bucketId: bid, path: p, expiryInMinutes: e, folderId: fid, folderKey: fkey, folderPath: fpath, ...rest } = opts;
15197
+ bucketIdOrRef = bid;
14662
15198
  resolvedPath = p;
14663
15199
  expiryInMinutes = e;
14664
15200
  folderId = fid;
@@ -14666,15 +15202,22 @@ class BucketService extends FolderScopedService {
14666
15202
  folderPath = fpath;
14667
15203
  restOptions = rest;
14668
15204
  } else {
14669
- bucketId = bucketIdOrOptions;
15205
+ bucketIdOrRef = firstArg;
14670
15206
  resolvedPath = path;
14671
15207
  const opts = options ?? {};
14672
15208
  ({ expiryInMinutes, folderId, folderKey, folderPath, ...restOptions } = opts);
14673
15209
  }
15210
+ const { id: bucketId, effectiveFolder } = await this.resolveBucketRef(bucketIdOrRef, { folderId, folderKey, folderPath }, "Buckets.getReadUri");
15211
+ if (bucketId <= 0) {
15212
+ throw new ValidationError({ message: "Buckets.getReadUri: bucketId must be a positive number." });
15213
+ }
15214
+ if (!resolvedPath) {
15215
+ throw new ValidationError({ message: "path is required for getReadUri" });
15216
+ }
14674
15217
  const headers = resolveFolderHeaders({
14675
- folderId,
14676
- folderKey,
14677
- folderPath,
15218
+ folderId: effectiveFolder.folderId ?? folderId,
15219
+ folderKey: effectiveFolder.folderKey ?? folderKey,
15220
+ folderPath: effectiveFolder.folderPath ?? folderPath,
14678
15221
  resourceType: "Buckets.getReadUri",
14679
15222
  fallbackFolderKey: this.config.folderKey
14680
15223
  });
@@ -14702,12 +15245,6 @@ class BucketService extends FolderScopedService {
14702
15245
  });
14703
15246
  }
14704
15247
  async _getUri(endpoint, bucketId, path, headers, queryOptions = {}) {
14705
- if (!bucketId) {
14706
- throw new ValidationError({ message: "bucketId is required for getUri" });
14707
- }
14708
- if (!path) {
14709
- throw new ValidationError({ message: "path is required for getUri" });
14710
- }
14711
15248
  const queryParams = filterUndefined({
14712
15249
  path,
14713
15250
  ...queryOptions
@@ -14722,15 +15259,16 @@ class BucketService extends FolderScopedService {
14722
15259
  }
14723
15260
  return transformedData;
14724
15261
  }
14725
- async getFiles(bucketId, options) {
14726
- if (!bucketId) {
14727
- throw new ValidationError({ message: "bucketId is required for getFiles" });
14728
- }
15262
+ async getFiles(bucketIdOrRef, options) {
14729
15263
  const { folderId, folderKey, folderPath, ...restOptions } = options ?? {};
15264
+ const { id: bucketId, effectiveFolder } = await this.resolveBucketRef(bucketIdOrRef, { folderId, folderKey, folderPath }, "Buckets.getFiles");
15265
+ if (bucketId <= 0) {
15266
+ throw new ValidationError({ message: "Buckets.getFiles: bucketId must be a positive number." });
15267
+ }
14730
15268
  const headers = resolveFolderHeaders({
14731
- folderId,
14732
- folderKey,
14733
- folderPath,
15269
+ folderId: effectiveFolder.folderId ?? folderId,
15270
+ folderKey: effectiveFolder.folderKey ?? folderKey,
15271
+ folderPath: effectiveFolder.folderPath ?? folderPath,
14734
15272
  resourceType: "Buckets.getFiles",
14735
15273
  fallbackFolderKey: this.config.folderKey
14736
15274
  });
@@ -14754,17 +15292,18 @@ class BucketService extends FolderScopedService {
14754
15292
  headers
14755
15293
  }, { ...apiRestOptions, directory: "/", recursive: true });
14756
15294
  }
14757
- async deleteFile(bucketId, path, options) {
14758
- if (!bucketId) {
14759
- throw new ValidationError({ message: "bucketId is required for deleteFile" });
14760
- }
15295
+ async deleteFile(bucketIdOrRef, path, options) {
14761
15296
  if (!path) {
14762
15297
  throw new ValidationError({ message: "path is required for deleteFile" });
14763
15298
  }
15299
+ const { id: bucketId, effectiveFolder } = await this.resolveBucketRef(bucketIdOrRef, { folderId: options?.folderId, folderKey: options?.folderKey, folderPath: options?.folderPath }, "Buckets.deleteFile");
15300
+ if (bucketId <= 0) {
15301
+ throw new ValidationError({ message: "Buckets.deleteFile: bucketId must be a positive number." });
15302
+ }
14764
15303
  const headers = resolveFolderHeaders({
14765
- folderId: options?.folderId,
14766
- folderKey: options?.folderKey,
14767
- folderPath: options?.folderPath,
15304
+ folderId: effectiveFolder.folderId ?? options?.folderId,
15305
+ folderKey: effectiveFolder.folderKey ?? options?.folderKey,
15306
+ folderPath: effectiveFolder.folderPath ?? options?.folderPath,
14768
15307
  resourceType: "Buckets.deleteFile",
14769
15308
  fallbackFolderKey: this.config.folderKey
14770
15309
  });
@@ -14782,6 +15321,17 @@ class BucketService extends FolderScopedService {
14782
15321
  };
14783
15322
  return this._getUri(BUCKET_ENDPOINTS.GET_WRITE_URI(bucketId), bucketId, path, headers, queryOptions);
14784
15323
  }
15324
+ async resolveBucketRef(bucketIdOrRef, folderScope, callerLabel) {
15325
+ if (bucketIdOrRef == null || typeof bucketIdOrRef === "number") {
15326
+ return { id: bucketIdOrRef ?? 0, effectiveFolder: {} };
15327
+ }
15328
+ return resolveRefToId(bucketIdOrRef, {
15329
+ byName: async (name) => {
15330
+ const { result, effectiveFolder } = await this.getByNameLookup("Bucket", BUCKET_ENDPOINTS.GET_BY_FOLDER, name, folderScope, (raw) => pascalToCamelCaseKeys(raw), undefined, callerLabel);
15331
+ return { id: result.id, ...effectiveFolder };
15332
+ }
15333
+ }, callerLabel);
15334
+ }
14785
15335
  }
14786
15336
  __decorate([
14787
15337
  track("Buckets.GetById")
@@ -15328,6 +15878,13 @@ var JobState;
15328
15878
  JobState2["Cancelled"] = "Cancelled";
15329
15879
  JobState2["Unknown"] = "Unknown";
15330
15880
  })(JobState || (JobState = {}));
15881
+ var ConnectionState;
15882
+ (function(ConnectionState2) {
15883
+ ConnectionState2["Enabled"] = "Enabled";
15884
+ ConnectionState2["Disabled"] = "Disabled";
15885
+ ConnectionState2["Expired"] = "Expired";
15886
+ ConnectionState2["Failed"] = "Failed";
15887
+ })(ConnectionState || (ConnectionState = {}));
15331
15888
  var ProcessMap = {
15332
15889
  lastModificationTime: "lastModifiedTime",
15333
15890
  creationTime: "createdTime",
@@ -15363,14 +15920,34 @@ class ProcessService extends FolderScopedService {
15363
15920
  }
15364
15921
  }, apiOptions);
15365
15922
  }
15366
- async start(request, optionsOrFolderId, legacyOptions) {
15923
+ async start(firstArg, optionsOrFolderId, legacyOptions) {
15924
+ const looksLikeRef = isProcessRef(firstArg);
15925
+ const looksLikeLegacy = isLegacyStartRequest(firstArg);
15926
+ if (!looksLikeRef && !looksLikeLegacy) {
15927
+ throw new ValidationError({
15928
+ message: "Processes.start: first argument must be a ProcessRef (`{ name }` or `{ key }`) or a ProcessStartRequest (`{ processKey }` or `{ processName }`)."
15929
+ });
15930
+ }
15367
15931
  let folderId;
15368
15932
  let folderKey;
15369
15933
  let folderPath;
15370
- let queryOptions;
15934
+ let queryOptions = {};
15935
+ let startInfoExtras = {};
15371
15936
  if (typeof optionsOrFolderId === "number") {
15372
15937
  folderId = optionsOrFolderId;
15373
15938
  queryOptions = legacyOptions ?? {};
15939
+ } else if (looksLikeRef) {
15940
+ const { folderId: fid, folderKey: fkey, folderPath: fpath, expand, select, filter, orderby, ...restStartInfo } = optionsOrFolderId ?? {};
15941
+ folderId = fid;
15942
+ folderKey = fkey;
15943
+ folderPath = fpath;
15944
+ queryOptions = {
15945
+ ...expand !== undefined && { expand },
15946
+ ...select !== undefined && { select },
15947
+ ...filter !== undefined && { filter },
15948
+ ...orderby !== undefined && { orderby }
15949
+ };
15950
+ startInfoExtras = restStartInfo;
15374
15951
  } else {
15375
15952
  const { folderId: fid, folderKey: fkey, folderPath: fpath, ...rest } = optionsOrFolderId ?? {};
15376
15953
  folderId = fid;
@@ -15378,17 +15955,20 @@ class ProcessService extends FolderScopedService {
15378
15955
  folderPath = fpath;
15379
15956
  queryOptions = rest;
15380
15957
  }
15958
+ const identity = looksLikeRef ? resolveProcessRefIdentity(firstArg, folderPath) : resolveLegacyIdentity(firstArg, folderPath);
15381
15959
  const headers = resolveFolderHeaders({
15382
15960
  folderId,
15383
15961
  folderKey,
15384
- folderPath,
15385
- resourceType: "processes.start",
15962
+ folderPath: identity.folderPath ?? folderPath,
15963
+ resourceType: "Processes.start",
15386
15964
  fallbackFolderKey: this.config.folderKey
15387
15965
  });
15388
- const apiRequest = transformRequest(request, ProcessMap);
15389
- const requestBody = {
15390
- startInfo: apiRequest
15391
- };
15966
+ const startInfoSdk = looksLikeRef ? { ...startInfoExtras, ...identity.identity } : { ...firstArg, ...identity.identity };
15967
+ if (!looksLikeRef && identity.dropProcessKey) {
15968
+ delete startInfoSdk.processKey;
15969
+ }
15970
+ const apiRequest = transformRequest(startInfoSdk, ProcessMap);
15971
+ const requestBody = { startInfo: apiRequest };
15392
15972
  const apiFieldOptions = transformOptions(queryOptions, ProcessMap);
15393
15973
  const apiOptions = addPrefixToKeys(apiFieldOptions, ODATA_PREFIX, Object.keys(apiFieldOptions));
15394
15974
  const response = await this.post(PROCESS_ENDPOINTS.START_PROCESS, requestBody, {
@@ -15406,8 +15986,7 @@ class ProcessService extends FolderScopedService {
15406
15986
  headers,
15407
15987
  params: apiOptions
15408
15988
  });
15409
- const transformedProcess = transformData(pascalToCamelCaseKeys(response.data), ProcessMap);
15410
- return transformedProcess;
15989
+ return transformData(pascalToCamelCaseKeys(response.data), ProcessMap);
15411
15990
  }
15412
15991
  async getByName(name, options = {}) {
15413
15992
  const { result } = await this.getByNameLookup("Process", PROCESS_ENDPOINTS.GET_ALL, name, options, (raw) => transformData(pascalToCamelCaseKeys(raw), ProcessMap), ProcessMap);
@@ -15426,6 +16005,64 @@ __decorate([
15426
16005
  __decorate([
15427
16006
  track("Processes.GetByName")
15428
16007
  ], ProcessService.prototype, "getByName", null);
16008
+ function isProcessRef(arg) {
16009
+ if (arg == null || typeof arg !== "object")
16010
+ return false;
16011
+ const obj = arg;
16012
+ if ("processKey" in obj || "processName" in obj)
16013
+ return false;
16014
+ return "name" in obj || "key" in obj;
16015
+ }
16016
+ function resolveProcessRefIdentity(processRef, folderPath) {
16017
+ const name = "name" in processRef ? processRef.name : undefined;
16018
+ const key = "key" in processRef ? processRef.key : undefined;
16019
+ if (name) {
16020
+ const override = resolveOverride("Process", name, folderPath);
16021
+ return {
16022
+ identity: { processName: override?.name ?? name },
16023
+ folderPath: override?.folderPath
16024
+ };
16025
+ }
16026
+ if (key) {
16027
+ return { identity: { processKey: key } };
16028
+ }
16029
+ throw new ValidationError({
16030
+ message: "Processes.start: processRef must supply a non-empty `name` or `key`."
16031
+ });
16032
+ }
16033
+ function isLegacyStartRequest(arg) {
16034
+ if (arg == null || typeof arg !== "object")
16035
+ return false;
16036
+ const obj = arg;
16037
+ return "processKey" in obj || "processName" in obj;
16038
+ }
16039
+ function resolveLegacyIdentity(request, folderPath) {
16040
+ if (request.processName) {
16041
+ const name = request.processName;
16042
+ const override = resolveOverride("Process", name, folderPath);
16043
+ if (override?.name) {
16044
+ return {
16045
+ identity: { processName: override.name },
16046
+ folderPath: override?.folderPath,
16047
+ dropProcessKey: true
16048
+ };
16049
+ }
16050
+ return { identity: {}, folderPath: override?.folderPath };
16051
+ }
16052
+ if (request.processKey) {
16053
+ const key = request.processKey;
16054
+ const override = resolveOverride("Process", key, folderPath);
16055
+ if (override?.name) {
16056
+ return {
16057
+ identity: { processName: override.name },
16058
+ folderPath: override?.folderPath,
16059
+ dropProcessKey: true
16060
+ };
16061
+ }
16062
+ return { identity: {}, folderPath: override?.folderPath };
16063
+ }
16064
+ return { identity: {} };
16065
+ }
15429
16066
  var QueuePriority;
15430
16067
  (function(QueuePriority2) {
15431
16068
  QueuePriority2["High"] = "High";
@@ -15903,6 +16540,32 @@ var FunctionHttpMethod;
15903
16540
  FunctionHttpMethod2["Patch"] = "Patch";
15904
16541
  FunctionHttpMethod2["Delete"] = "Delete";
15905
16542
  })(FunctionHttpMethod || (FunctionHttpMethod = {}));
16543
+ var FolderType;
16544
+ (function(FolderType2) {
16545
+ FolderType2["Standard"] = "Standard";
16546
+ FolderType2["Personal"] = "Personal";
16547
+ FolderType2["Virtual"] = "Virtual";
16548
+ FolderType2["Solution"] = "Solution";
16549
+ FolderType2["DebugSolution"] = "DebugSolution";
16550
+ })(FolderType || (FolderType = {}));
16551
+ var FolderProvisionType;
16552
+ (function(FolderProvisionType2) {
16553
+ FolderProvisionType2["Manual"] = "Manual";
16554
+ FolderProvisionType2["Automatic"] = "Automatic";
16555
+ })(FolderProvisionType || (FolderProvisionType = {}));
16556
+ var FolderPermissionModel;
16557
+ (function(FolderPermissionModel2) {
16558
+ FolderPermissionModel2["InheritFromTenant"] = "InheritFromTenant";
16559
+ FolderPermissionModel2["FineGrained"] = "FineGrained";
16560
+ })(FolderPermissionModel || (FolderPermissionModel = {}));
16561
+ var FolderFeedType;
16562
+ (function(FolderFeedType2) {
16563
+ FolderFeedType2["Undefined"] = "Undefined";
16564
+ FolderFeedType2["Processes"] = "Processes";
16565
+ FolderFeedType2["Libraries"] = "Libraries";
16566
+ FolderFeedType2["PersonalWorkspace"] = "PersonalWorkspace";
16567
+ FolderFeedType2["FolderHierarchy"] = "FolderHierarchy";
16568
+ })(FolderFeedType || (FolderFeedType = {}));
15906
16569
  var CommonFieldMap = {
15907
16570
  createdAt: "createdTime",
15908
16571
  updatedAt: "updatedTime"
@@ -15956,13 +16619,6 @@ var AgentMap = {
15956
16619
  var UserSettingsMap = {
15957
16620
  ...CommonFieldMap
15958
16621
  };
15959
- var ConnectionState;
15960
- (function(ConnectionState2) {
15961
- ConnectionState2["Enabled"] = "Enabled";
15962
- ConnectionState2["Disabled"] = "Disabled";
15963
- ConnectionState2["Expired"] = "Expired";
15964
- ConnectionState2["Failed"] = "Failed";
15965
- })(ConnectionState || (ConnectionState = {}));
15966
16622
  var FeedbackStatus;
15967
16623
  (function(FeedbackStatus2) {
15968
16624
  FeedbackStatus2[FeedbackStatus2["Pending"] = 0] = "Pending";
@@ -16251,6 +16907,109 @@ var PlatformSettingKey;
16251
16907
  PlatformSettingKey2["UserCasePinnedInstancesByTenant"] = "UserCase.PinnedInstancesByTenant";
16252
16908
  PlatformSettingKey2["UserCaseInstancesTableFiltersByTenant"] = "UserCase.InstancesTableFiltersByTenant";
16253
16909
  })(PlatformSettingKey || (PlatformSettingKey = {}));
16910
+ var PlatformUserType;
16911
+ (function(PlatformUserType2) {
16912
+ PlatformUserType2["User"] = "user";
16913
+ PlatformUserType2["Robot"] = "robot";
16914
+ PlatformUserType2["DirectoryUser"] = "directoryUser";
16915
+ PlatformUserType2["DirectoryGroup"] = "directoryGroup";
16916
+ PlatformUserType2["RobotAccount"] = "robotAccount";
16917
+ PlatformUserType2["Application"] = "application";
16918
+ })(PlatformUserType || (PlatformUserType = {}));
16919
+ var PlatformUserCategory;
16920
+ (function(PlatformUserCategory2) {
16921
+ PlatformUserCategory2["Local"] = "local";
16922
+ PlatformUserCategory2["LinkedLocal"] = "linkedLocal";
16923
+ PlatformUserCategory2["Directory"] = "directory";
16924
+ })(PlatformUserCategory || (PlatformUserCategory = {}));
16925
+ var PlatformUserSortField;
16926
+ (function(PlatformUserSortField2) {
16927
+ PlatformUserSortField2["Id"] = "Id";
16928
+ PlatformUserSortField2["UserName"] = "UserName";
16929
+ PlatformUserSortField2["Email"] = "Email";
16930
+ PlatformUserSortField2["EmailConfirmed"] = "EmailConfirmed";
16931
+ PlatformUserSortField2["Name"] = "Name";
16932
+ PlatformUserSortField2["Surname"] = "Surname";
16933
+ PlatformUserSortField2["DisplayName"] = "DisplayName";
16934
+ PlatformUserSortField2["CreatedTime"] = "CreationTime";
16935
+ PlatformUserSortField2["LastModifiedTime"] = "LastModificationTime";
16936
+ PlatformUserSortField2["LastLoginTime"] = "LastLoginTime";
16937
+ PlatformUserSortField2["IsActive"] = "IsActive";
16938
+ PlatformUserSortField2["Type"] = "Type";
16939
+ PlatformUserSortField2["Category"] = "Category";
16940
+ PlatformUserSortField2["InvitationAccepted"] = "InvitationAccepted";
16941
+ })(PlatformUserSortField || (PlatformUserSortField = {}));
16942
+ var PlatformUserSortOrder;
16943
+ (function(PlatformUserSortOrder2) {
16944
+ PlatformUserSortOrder2["Ascending"] = "asc";
16945
+ PlatformUserSortOrder2["Descending"] = "desc";
16946
+ })(PlatformUserSortOrder || (PlatformUserSortOrder = {}));
16947
+ var PlatformRoleType;
16948
+ (function(PlatformRoleType2) {
16949
+ PlatformRoleType2["BuiltIn"] = "BUILTIN";
16950
+ PlatformRoleType2["Platform"] = "PLATFORM";
16951
+ PlatformRoleType2["Custom"] = "CUSTOM";
16952
+ })(PlatformRoleType || (PlatformRoleType = {}));
16953
+ var PlatformRoleScopeType;
16954
+ (function(PlatformRoleScopeType2) {
16955
+ PlatformRoleScopeType2["Organization"] = "ORGANIZATION";
16956
+ PlatformRoleScopeType2["Tenant"] = "TENANT";
16957
+ PlatformRoleScopeType2["Project"] = "PROJECT";
16958
+ PlatformRoleScopeType2["Process"] = "PROCESS";
16959
+ PlatformRoleScopeType2["App"] = "APP";
16960
+ PlatformRoleScopeType2["Mixed"] = "MIXED";
16961
+ })(PlatformRoleScopeType || (PlatformRoleScopeType = {}));
16962
+ var PlatformActionScopeType;
16963
+ (function(PlatformActionScopeType2) {
16964
+ PlatformActionScopeType2["Any"] = "ANY";
16965
+ PlatformActionScopeType2["None"] = "NONE";
16966
+ PlatformActionScopeType2["Organization"] = "ORGANIZATION";
16967
+ PlatformActionScopeType2["Tenant"] = "TENANT";
16968
+ PlatformActionScopeType2["Folder"] = "FOLDER";
16969
+ PlatformActionScopeType2["Project"] = "PROJECT";
16970
+ PlatformActionScopeType2["Process"] = "PROCESS";
16971
+ })(PlatformActionScopeType || (PlatformActionScopeType = {}));
16972
+ var PlatformPrincipalType;
16973
+ (function(PlatformPrincipalType2) {
16974
+ PlatformPrincipalType2["User"] = "User";
16975
+ PlatformPrincipalType2["Group"] = "Group";
16976
+ PlatformPrincipalType2["ExternalApplication"] = "ExternalApplication";
16977
+ PlatformPrincipalType2["Robot"] = "Robot";
16978
+ })(PlatformPrincipalType || (PlatformPrincipalType = {}));
16979
+ var PlatformRoleSortField;
16980
+ (function(PlatformRoleSortField2) {
16981
+ PlatformRoleSortField2["Id"] = "Id";
16982
+ PlatformRoleSortField2["Name"] = "OriginalRoleName";
16983
+ PlatformRoleSortField2["UniqueName"] = "UniqueName";
16984
+ PlatformRoleSortField2["Description"] = "Description";
16985
+ PlatformRoleSortField2["Type"] = "Type";
16986
+ PlatformRoleSortField2["ScopeType"] = "ScopeType";
16987
+ PlatformRoleSortField2["OrganizationId"] = "OrganizationId";
16988
+ PlatformRoleSortField2["TenantId"] = "TenantId";
16989
+ PlatformRoleSortField2["OwnerService"] = "OwnerService";
16990
+ PlatformRoleSortField2["OwnerServiceId"] = "OwnerServiceId";
16991
+ PlatformRoleSortField2["CreatedBy"] = "CreatedBy";
16992
+ PlatformRoleSortField2["CreatedTime"] = "CreatedOn";
16993
+ PlatformRoleSortField2["UpdatedBy"] = "UpdatedBy";
16994
+ PlatformRoleSortField2["UpdatedTime"] = "UpdatedOn";
16995
+ })(PlatformRoleSortField || (PlatformRoleSortField = {}));
16996
+ var PlatformRoleSortOrder;
16997
+ (function(PlatformRoleSortOrder2) {
16998
+ PlatformRoleSortOrder2["Ascending"] = "Asc";
16999
+ PlatformRoleSortOrder2["Descending"] = "Desc";
17000
+ })(PlatformRoleSortOrder || (PlatformRoleSortOrder = {}));
17001
+ var PlatformGroupType;
17002
+ (function(PlatformGroupType2) {
17003
+ PlatformGroupType2["BuiltIn"] = "builtIn";
17004
+ PlatformGroupType2["Custom"] = "custom";
17005
+ })(PlatformGroupType || (PlatformGroupType = {}));
17006
+ var LifeCycleStage;
17007
+ (function(LifeCycleStage2) {
17008
+ LifeCycleStage2["PREVIEW"] = "PREVIEW";
17009
+ LifeCycleStage2["GA"] = "GA";
17010
+ LifeCycleStage2["DEPRECATED"] = "DEPRECATED";
17011
+ LifeCycleStage2["CUSTOM"] = "CUSTOM";
17012
+ })(LifeCycleStage || (LifeCycleStage = {}));
16254
17013
  var SpanStatus;
16255
17014
  (function(SpanStatus2) {
16256
17015
  SpanStatus2["Unset"] = "Unset";
@@ -16333,6 +17092,7 @@ var AgentGovernanceSection;
16333
17092
  AgentGovernanceSection2["Action"] = "action";
16334
17093
  AgentGovernanceSection2["Mode"] = "mode";
16335
17094
  })(AgentGovernanceSection || (AgentGovernanceSection = {}));
17095
+ var HOST_KEY = Symbol.for("uipath.host.v1");
16336
17096
 
16337
17097
  // ../../node_modules/@uipath/uipath-typescript/dist/tasks/index.mjs
16338
17098
  function __decorate2(decorators, target, key, desc) {
@@ -16591,6 +17351,7 @@ var TaskMap2 = {
16591
17351
  };
16592
17352
  var DEFAULT_TASK_EXPAND2 = "AssignedToUser,CreatorUser,LastModifierUser";
16593
17353
  var ORCHESTRATOR_BASE2 = "orchestrator_";
17354
+ var IDENTITY_BASE2 = "identity_";
16594
17355
  var TASK_ENDPOINTS2 = {
16595
17356
  CREATE_GENERIC_TASK: `${ORCHESTRATOR_BASE2}/tasks/GenericTasks/CreateTask`,
16596
17357
  GET_TASK_USERS: (folderId) => `${ORCHESTRATOR_BASE2}/odata/Tasks/UiPath.Server.Configuration.OData.GetTaskUsers(organizationUnitId=${folderId})`,
@@ -16623,6 +17384,9 @@ var TASK_NOTE_ENDPOINTS2 = {
16623
17384
  GET_BY_TASK_ID: (taskId) => `${ORCHESTRATOR_BASE2}/odata/TaskNotes/UiPath.Server.Configuration.OData.GetByTaskId(taskId=${taskId})`,
16624
17385
  CREATE: `${ORCHESTRATOR_BASE2}/odata/TaskNotes/UiPath.Server.Configuration.OData.CreateTaskNote`
16625
17386
  };
17387
+ var IDENTITY_ENDPOINTS2 = {
17388
+ AUTHORIZE: `${IDENTITY_BASE2}/connect/authorize`
17389
+ };
16626
17390
  var TASK_TYPE_ENDPOINTS2 = {
16627
17391
  [TaskType2.Form]: TASK_ENDPOINTS2.GET_TASK_FORM_BY_ID,
16628
17392
  [TaskType2.App]: TASK_ENDPOINTS2.GET_APP_TASK_BY_ID,
@@ -17644,48 +18408,246 @@ class PaginationManager2 {
17644
18408
  return result;
17645
18409
  }
17646
18410
  }
17647
- function missingConfigMessage2() {
18411
+ var UiPathMetaTags2;
18412
+ (function(UiPathMetaTags3) {
18413
+ UiPathMetaTags3["CLIENT_ID"] = "uipath:client-id";
18414
+ UiPathMetaTags3["SCOPE"] = "uipath:scope";
18415
+ UiPathMetaTags3["ORG_NAME"] = "uipath:org-name";
18416
+ UiPathMetaTags3["ORG_ID"] = "uipath:org-id";
18417
+ UiPathMetaTags3["TENANT_NAME"] = "uipath:tenant-name";
18418
+ UiPathMetaTags3["BASE_URL"] = "uipath:base-url";
18419
+ UiPathMetaTags3["REDIRECT_URI"] = "uipath:redirect-uri";
18420
+ UiPathMetaTags3["CDN_BASE"] = "uipath:cdn-base";
18421
+ UiPathMetaTags3["APP_BASE"] = "uipath:app-base";
18422
+ UiPathMetaTags3["FOLDER_KEY"] = "uipath:folder-key";
18423
+ })(UiPathMetaTags2 || (UiPathMetaTags2 = {}));
18424
+ var UiPathElementIds2;
18425
+ (function(UiPathElementIds3) {
18426
+ UiPathElementIds3["RESOURCE_OVERRIDES"] = "uipath-overrides";
18427
+ })(UiPathElementIds2 || (UiPathElementIds2 = {}));
18428
+ function missingConfigMessage2(found, context) {
17648
18429
  if (isBrowser2) {
17649
18430
  return "UiPath SDK configuration not found. " + "Ensure @uipath/coded-apps plugin is set up in your bundler to inject configuration during development and build.";
17650
18431
  }
17651
- return "UiPath SDK configuration not found. " + "In a UiPath coded function, pass the handler context: new UiPath(ctx). " + "Otherwise pass { baseUrl, orgName, tenantName, secret }, " + "or set UIPATH_BASE_URL, UIPATH_ORG_NAME, UIPATH_TENANT_NAME and UIPATH_ACCESS_TOKEN.";
18432
+ const guidance = "In a UiPath coded function, pass the handler context: new UiPath(ctx). " + "Otherwise pass { baseUrl, orgName, tenantName, secret }, " + "or set UIPATH_BASE_URL, UIPATH_ORG_NAME, UIPATH_TENANT_NAME and UIPATH_ACCESS_TOKEN.";
18433
+ return `UiPath SDK configuration not found. ${guidance}`;
18434
+ }
18435
+ UiPathMetaTags2.CLIENT_ID, UiPathMetaTags2.REDIRECT_URI, UiPathMetaTags2.SCOPE;
18436
+ var BASE64URL_DASH_RE2 = /-/g;
18437
+ var BASE64URL_UNDERSCORE_RE2 = /_/g;
18438
+ function base64UrlToBase642(value) {
18439
+ const base642 = value.replace(BASE64URL_DASH_RE2, "+").replace(BASE64URL_UNDERSCORE_RE2, "/");
18440
+ return base642.padEnd(base642.length + (4 - base642.length % 4) % 4, "=");
18441
+ }
18442
+ function decodeJwtClaims2(token) {
18443
+ try {
18444
+ const payload = token?.split(".")[1];
18445
+ if (!payload) {
18446
+ return;
18447
+ }
18448
+ return JSON.parse(decodeBase642(base64UrlToBase642(payload)));
18449
+ } catch {
18450
+ return;
18451
+ }
18452
+ }
18453
+ var _OrganizationIdResolver_instances2;
18454
+ var _OrganizationIdResolver_organizationId2;
18455
+ var _OrganizationIdResolver_resolve3;
18456
+ var GUID_REGEX$12 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
18457
+ var DASH_REGEX2 = /-/g;
18458
+ var UNDERSCORE_REGEX2 = /_/g;
18459
+ var WHITESPACE_REGEX2 = /\s+/g;
18460
+ var ORGANIZATION_LOOKUP_CLIENT_ID2 = "1119a927-10ab-4543-bd1a-ad6bfbbc27f4";
18461
+ var ORGANIZATION_LOOKUP_REDIRECT_PATH2 = "portal_/api/tokenFactory/callback";
18462
+ var UNREGISTERED_ORGANIZATION_PATH2 = "/portal_/unregistered";
18463
+ var TENANT_ACR_PREFIX2 = "tenant:";
18464
+ var MAX_REDIRECT_HOPS2 = 3;
18465
+ var IDENTITY_ERROR_ID_PARAM2 = "errorId";
18466
+ var IDENTITY_ERROR_CODE_PARAM2 = "errorCode";
18467
+ var BODY_SNIPPET_LENGTH2 = 160;
18468
+ var CONFIG_HINT2 = "Set `organizationId` in the SDK configuration.";
18469
+ function isAuthorizeRequest2(url) {
18470
+ return url.pathname.endsWith(`/${IDENTITY_ENDPOINTS2.AUTHORIZE}`);
18471
+ }
18472
+ function withoutQuery2(url) {
18473
+ const parsed = new URL(url);
18474
+ return `${parsed.origin}${parsed.pathname}`;
18475
+ }
18476
+ function readIdentityError2(url) {
18477
+ const errorId = url.searchParams.get(IDENTITY_ERROR_ID_PARAM2);
18478
+ if (errorId) {
18479
+ try {
18480
+ const base642 = errorId.replace(DASH_REGEX2, "+").replace(UNDERSCORE_REGEX2, "/");
18481
+ const json = decodeBase642(base642.padEnd(base642.length + (4 - base642.length % 4) % 4, "="));
18482
+ const data = JSON.parse(json).Data;
18483
+ const error = typeof data?.Error === "string" ? data.Error : undefined;
18484
+ const description = typeof data?.ErrorDescription === "string" ? data.ErrorDescription : undefined;
18485
+ if (error) {
18486
+ return description ? `${error} (${description})` : error;
18487
+ }
18488
+ } catch {
18489
+ return url.searchParams.get(IDENTITY_ERROR_CODE_PARAM2) ?? undefined;
18490
+ }
18491
+ }
18492
+ return url.searchParams.get(IDENTITY_ERROR_CODE_PARAM2) ?? undefined;
18493
+ }
18494
+ async function describeResponse2(response) {
18495
+ const body = (await response.text().catch(() => "")).replace(WHITESPACE_REGEX2, " ").trim();
18496
+ return body ? `HTTP ${response.status}: ${body.slice(0, BODY_SNIPPET_LENGTH2)}` : `HTTP ${response.status}`;
18497
+ }
18498
+ function randomUrlSafeToken2() {
18499
+ return `${crypto.randomUUID()}${crypto.randomUUID()}`.replace(DASH_REGEX2, "");
18500
+ }
18501
+ function tracingHeaders2() {
18502
+ const traceId = crypto.randomUUID().replace(DASH_REGEX2, "");
18503
+ const spanId = crypto.randomUUID().replace(DASH_REGEX2, "").slice(0, 16);
18504
+ const traceparent = `00-${traceId}-${spanId}-01`;
18505
+ return { [TRACEPARENT2]: traceparent, [UIPATH_TRACEPARENT_ID2]: traceparent };
18506
+ }
18507
+ function buildAuthorizeUrl2(baseUrl, orgName) {
18508
+ const params = new URLSearchParams({
18509
+ response_type: "code",
18510
+ client_id: ORGANIZATION_LOOKUP_CLIENT_ID2,
18511
+ redirect_uri: `${baseUrl}/${ORGANIZATION_LOOKUP_REDIRECT_PATH2}`,
18512
+ scope: "openid",
18513
+ code_challenge: randomUrlSafeToken2(),
18514
+ code_challenge_method: "S256",
18515
+ state: randomUrlSafeToken2(),
18516
+ acr_values: `tenantName:${orgName}`
18517
+ });
18518
+ return `${baseUrl}/${IDENTITY_ENDPOINTS2.AUTHORIZE}?${params.toString()}`;
18519
+ }
18520
+ function extractOrganizationId2(location) {
18521
+ const acrValues = [location.searchParams.get("acr_values")];
18522
+ const returnUrl = location.searchParams.get("returnUrl");
18523
+ if (returnUrl) {
18524
+ acrValues.push(new URL(returnUrl, location.origin).searchParams.get("acr_values"));
18525
+ }
18526
+ for (const acr of acrValues) {
18527
+ for (const token of acr?.split(" ") ?? []) {
18528
+ if (token.startsWith(TENANT_ACR_PREFIX2)) {
18529
+ const candidate = token.slice(TENANT_ACR_PREFIX2.length);
18530
+ if (GUID_REGEX$12.test(candidate)) {
18531
+ return candidate;
18532
+ }
18533
+ }
18534
+ }
18535
+ }
18536
+ return;
18537
+ }
18538
+ async function lookupOrganizationIdForPat2(baseUrl, orgName) {
18539
+ let url = buildAuthorizeUrl2(baseUrl, orgName);
18540
+ for (let hop = 0;hop < MAX_REDIRECT_HOPS2; hop++) {
18541
+ const response = await fetchWithRetry2(url, { redirect: "manual", headers: tracingHeaders2() }, { retry: DEFAULT_RETRY_OPTIONS2 });
18542
+ const location = response.headers.get("location");
18543
+ if (!location) {
18544
+ throw new ValidationError2({
18545
+ message: `Could not resolve the organization id for '${orgName}': Identity answered ` + `${await describeResponse2(response)} instead of redirecting. ${CONFIG_HINT2}`
18546
+ });
18547
+ }
18548
+ const target = new URL(location, url);
18549
+ const organizationId = extractOrganizationId2(target);
18550
+ if (organizationId) {
18551
+ return organizationId;
18552
+ }
18553
+ if (target.pathname.startsWith(UNREGISTERED_ORGANIZATION_PATH2)) {
18554
+ throw new ValidationError2({ message: `Organization '${orgName}' was not found at ${baseUrl}.` });
18555
+ }
18556
+ const identityError = readIdentityError2(target);
18557
+ if (identityError) {
18558
+ throw new ValidationError2({
18559
+ message: `Could not resolve the organization id for '${orgName}': Identity rejected the lookup ` + `with ${identityError}. ${CONFIG_HINT2}`
18560
+ });
18561
+ }
18562
+ url = isAuthorizeRequest2(target) ? buildAuthorizeUrl2(target.origin, orgName) : target.toString();
18563
+ }
18564
+ throw new ValidationError2({
18565
+ message: `Could not resolve the organization id for '${orgName}': gave up after ${MAX_REDIRECT_HOPS2} ` + `redirects (last: ${withoutQuery2(url)}). ${CONFIG_HINT2}`
18566
+ });
18567
+ }
18568
+
18569
+ class OrganizationIdResolver2 {
18570
+ constructor(config2, tokenManager) {
18571
+ _OrganizationIdResolver_instances2.add(this);
18572
+ this.config = config2;
18573
+ this.tokenManager = tokenManager;
18574
+ _OrganizationIdResolver_organizationId2.set(this, undefined);
18575
+ }
18576
+ resolve() {
18577
+ if (!__classPrivateFieldGet2(this, _OrganizationIdResolver_organizationId2, "f")) {
18578
+ __classPrivateFieldSet2(this, _OrganizationIdResolver_organizationId2, __classPrivateFieldGet2(this, _OrganizationIdResolver_instances2, "m", _OrganizationIdResolver_resolve3).call(this).catch((error) => {
18579
+ __classPrivateFieldSet2(this, _OrganizationIdResolver_organizationId2, undefined, "f");
18580
+ throw error;
18581
+ }), "f");
18582
+ }
18583
+ return __classPrivateFieldGet2(this, _OrganizationIdResolver_organizationId2, "f");
18584
+ }
17652
18585
  }
18586
+ _OrganizationIdResolver_organizationId2 = new WeakMap, _OrganizationIdResolver_instances2 = new WeakSet, _OrganizationIdResolver_resolve3 = async function _OrganizationIdResolver_resolve4() {
18587
+ const { organizationId, orgName, baseUrl } = this.config;
18588
+ if (organizationId) {
18589
+ return organizationId;
18590
+ }
18591
+ if (GUID_REGEX$12.test(orgName)) {
18592
+ return orgName;
18593
+ }
18594
+ const claimed = decodeJwtClaims2(this.tokenManager.getToken())?.prt_id;
18595
+ if (typeof claimed === "string" && GUID_REGEX$12.test(claimed)) {
18596
+ return claimed;
18597
+ }
18598
+ return lookupOrganizationIdForPat2(baseUrl, orgName);
18599
+ };
17653
18600
  var REGISTRY_KEY3 = Symbol.for("@uipath/sdk-internals-registry");
18601
+ var UNCONFIGURED_KEY2 = Symbol.for("@uipath/sdk-unconfigured-reason");
18602
+ var globalStores2 = () => globalThis;
17654
18603
  var getGlobalStore2 = () => {
17655
- const globalObj = globalThis;
17656
- if (!globalObj[REGISTRY_KEY3]) {
17657
- globalObj[REGISTRY_KEY3] = new WeakMap;
17658
- }
17659
- return globalObj[REGISTRY_KEY3];
18604
+ var _a2;
18605
+ return (_a2 = globalStores2())[REGISTRY_KEY3] ?? (_a2[REGISTRY_KEY3] = new WeakMap);
18606
+ };
18607
+ var getUnconfiguredStore2 = () => {
18608
+ var _a2;
18609
+ return (_a2 = globalStores2())[UNCONFIGURED_KEY2] ?? (_a2[UNCONFIGURED_KEY2] = new WeakMap);
17660
18610
  };
17661
18611
  var looksLikeUiPath2 = (instance) => typeof instance.initialize === "function";
17662
18612
 
17663
18613
  class SDKInternalsRegistry2 {
17664
- static get store() {
17665
- return getGlobalStore2();
17666
- }
17667
18614
  static set(instance, internals) {
17668
18615
  this.store.set(instance, internals);
17669
18616
  }
18617
+ static setUnconfigured(instance, reason) {
18618
+ this.unconfigured.set(instance, reason);
18619
+ }
17670
18620
  static get(instance) {
17671
18621
  const internals = this.store.get(instance);
17672
18622
  if (!internals) {
17673
- if (looksLikeUiPath2(instance)) {
17674
- throw new Error("Cannot create a service: the UiPath instance was never configured. " + missingConfigMessage2());
18623
+ const reason = this.unconfigured.get(instance);
18624
+ if (reason !== undefined || looksLikeUiPath2(instance)) {
18625
+ throw new Error("Cannot create a service: the UiPath instance was never configured. " + (reason ?? missingConfigMessage2()));
17675
18626
  }
17676
18627
  throw new Error("Invalid SDK instance. Make sure to pass a valid UiPath instance to the service constructor.");
17677
18628
  }
17678
18629
  return internals;
17679
18630
  }
18631
+ static getOrganizationIdResolver(instance) {
18632
+ const internals = this.get(instance);
18633
+ internals.organizationIdResolver ?? (internals.organizationIdResolver = new OrganizationIdResolver2(internals.config, internals.tokenManager));
18634
+ return internals.organizationIdResolver;
18635
+ }
18636
+ static get store() {
18637
+ return getGlobalStore2();
18638
+ }
18639
+ static get unconfigured() {
18640
+ return getUnconfiguredStore2();
18641
+ }
17680
18642
  }
17681
18643
  var _BaseService_apiClient2;
17682
18644
 
17683
18645
  class BaseService2 {
17684
18646
  constructor(instance, headers) {
17685
18647
  _BaseService_apiClient2.set(this, undefined);
17686
- const { config: config2, context, tokenManager, folderKey } = SDKInternalsRegistry2.get(instance);
18648
+ const { config: config2, context, tokenManager, folderKey, metaFolderKey } = SDKInternalsRegistry2.get(instance);
17687
18649
  __classPrivateFieldSet2(this, _BaseService_apiClient2, new ApiClient2(config2, context, tokenManager, headers ? { headers } : {}), "f");
17688
- this.config = { folderKey };
18650
+ this.config = { folderKey, metaFolderKey };
17689
18651
  }
17690
18652
  async getValidAuthToken() {
17691
18653
  return __classPrivateFieldGet2(this, _BaseService_apiClient2, "f").getValidToken();
@@ -17774,7 +18736,7 @@ class BaseService2 {
17774
18736
  limitedPageSize = getLimitedPageSize2(params.pageSize);
17775
18737
  const pageSizeParam = paginationParams?.pageSizeParam || ODATA_OFFSET_PARAMS2.PAGE_SIZE_PARAM;
17776
18738
  const offsetParam = paginationParams?.offsetParam || ODATA_OFFSET_PARAMS2.OFFSET_PARAM;
17777
- const countParam = paginationParams?.countParam || ODATA_OFFSET_PARAMS2.COUNT_PARAM;
18739
+ const countParam = paginationParams && "countParam" in paginationParams ? paginationParams.countParam : ODATA_OFFSET_PARAMS2.COUNT_PARAM;
17778
18740
  const convertToSkip = paginationParams?.convertToSkip ?? true;
17779
18741
  const zeroBased = paginationParams?.zeroBased ?? false;
17780
18742
  requestParams[pageSizeParam] = limitedPageSize;
@@ -17786,7 +18748,7 @@ class BaseService2 {
17786
18748
  const sdkPageNumber = params.pageNumber || 1;
17787
18749
  requestParams[offsetParam] = zeroBased ? sdkPageNumber - 1 : sdkPageNumber;
17788
18750
  }
17789
- {
18751
+ if (countParam) {
17790
18752
  requestParams[countParam] = true;
17791
18753
  }
17792
18754
  break;
@@ -17860,22 +18822,6 @@ function validateName2(resourceType, name) {
17860
18822
  return trimmed;
17861
18823
  }
17862
18824
  var GUID_REGEX2 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
17863
- var UiPathMetaTags2;
17864
- (function(UiPathMetaTags3) {
17865
- UiPathMetaTags3["CLIENT_ID"] = "uipath:client-id";
17866
- UiPathMetaTags3["SCOPE"] = "uipath:scope";
17867
- UiPathMetaTags3["ORG_NAME"] = "uipath:org-name";
17868
- UiPathMetaTags3["TENANT_NAME"] = "uipath:tenant-name";
17869
- UiPathMetaTags3["BASE_URL"] = "uipath:base-url";
17870
- UiPathMetaTags3["REDIRECT_URI"] = "uipath:redirect-uri";
17871
- UiPathMetaTags3["CDN_BASE"] = "uipath:cdn-base";
17872
- UiPathMetaTags3["APP_BASE"] = "uipath:app-base";
17873
- UiPathMetaTags3["FOLDER_KEY"] = "uipath:folder-key";
17874
- })(UiPathMetaTags2 || (UiPathMetaTags2 = {}));
17875
- var UiPathElementIds2;
17876
- (function(UiPathElementIds3) {
17877
- UiPathElementIds3["RESOURCE_OVERRIDES"] = "uipath-overrides";
17878
- })(UiPathElementIds2 || (UiPathElementIds2 = {}));
17879
18825
  function isPlainObject2(value) {
17880
18826
  return typeof value === "object" && value !== null && !Array.isArray(value);
17881
18827
  }
@@ -17984,7 +18930,7 @@ class FolderScopedService2 extends BaseService2 {
17984
18930
  });
17985
18931
  const items = response.data?.value;
17986
18932
  if (!items?.length) {
17987
- const folderHint = describeFolderForError2(folderId, folderKey, resolvedFolderPath);
18933
+ const folderHint = describeFolderForError2(folderId, headers[FOLDER_KEY2], resolvedFolderPath);
17988
18934
  throw new NotFoundError2({
17989
18935
  message: `${resourceType} '${resolvedName}' not found${folderHint}.`
17990
18936
  });
@@ -18597,11 +19543,11 @@ async function resolveFolderScope(options) {
18597
19543
  return parseIntArg(options.folderId, "--folder-id");
18598
19544
  }
18599
19545
  if (options.folderKey !== undefined) {
18600
- const { resolveFolderIdByKey } = await import("./folder-resolver-x3tk8v3w.js");
19546
+ const { resolveFolderIdByKey } = await import("./folder-resolver-m2j9csxn.js");
18601
19547
  return resolveFolderIdByKey(options.folderKey, options.tenant);
18602
19548
  }
18603
19549
  if (options.folderPath !== undefined) {
18604
- const { resolveFolderIdByPath } = await import("./folder-resolver-x3tk8v3w.js");
19550
+ const { resolveFolderIdByPath } = await import("./folder-resolver-m2j9csxn.js");
18605
19551
  return resolveFolderIdByPath(options.folderPath, options.tenant);
18606
19552
  }
18607
19553
  return;
@@ -18621,7 +19567,7 @@ async function resolveFolderId(options, missingFolderInstructions = DEFAULT_FOLD
18621
19567
  processContext.exit(1);
18622
19568
  return null;
18623
19569
  }
18624
- const { pickFolderInteractively } = await import("./folder-picker-interactive-sxhrahj5.js");
19570
+ const { pickFolderInteractively } = await import("./folder-picker-interactive-2x6yr0wh.js");
18625
19571
  return pickFolderInteractively(options.tenant);
18626
19572
  }
18627
19573
 
@@ -19443,4 +20389,4 @@ var registerCommands = async (program) => {
19443
20389
 
19444
20390
  export { metadata, registerCommands };
19445
20391
 
19446
- //# debugId=1E6B5B1756648EEB64756E2164756E21
20392
+ //# debugId=9BD45B63674E541364756E2164756E21