@uipath/tasks-tool 1.202.0 → 1.203.0-preview.160

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-h6cyrz61.js";
12
+ } from "./tool-pbamehqj.js";
13
13
  import {
14
14
  require_src
15
15
  } from "./tool-bndhpxxj.js";
@@ -4501,8 +4501,9 @@ var require_src6 = __commonJS(function(exports) {
4501
4501
  // package.json
4502
4502
  var package_default = {
4503
4503
  name: "@uipath/tasks-tool",
4504
+ author: "UiPath",
4504
4505
  license: "SEE LICENSE IN LICENSE.txt",
4505
- version: "1.202.0",
4506
+ version: "1.203.0-preview.160",
4506
4507
  description: "Manage Action Center tasks.",
4507
4508
  publishConfig: {
4508
4509
  registry: "https://npm.pkg.github.com/"
@@ -4531,7 +4532,7 @@ var package_default = {
4531
4532
  "@uipath/auth": "workspace:*",
4532
4533
  "@uipath/common": "workspace:*",
4533
4534
  "@uipath/orchestrator-sdk": "workspace:*",
4534
- "@uipath/uipath-typescript": "^1.6.1",
4535
+ "@uipath/uipath-typescript": "^1.7.1",
4535
4536
  commander: "^14.0.3",
4536
4537
  typescript: "^7.0.2"
4537
4538
  }
@@ -4968,7 +4969,7 @@ var allowsEval = cached(() => {
4968
4969
  return false;
4969
4970
  }
4970
4971
  });
4971
- function isPlainObject(o) {
4972
+ function isPlainObject$1(o) {
4972
4973
  if (isObject(o) === false)
4973
4974
  return false;
4974
4975
  const ctor = o.constructor;
@@ -4985,7 +4986,7 @@ function isPlainObject(o) {
4985
4986
  return true;
4986
4987
  }
4987
4988
  function shallowClone(o) {
4988
- if (isPlainObject(o))
4989
+ if (isPlainObject$1(o))
4989
4990
  return { ...o };
4990
4991
  if (Array.isArray(o))
4991
4992
  return [...o];
@@ -5073,7 +5074,7 @@ function omit(schema, mask) {
5073
5074
  return clone(schema, def);
5074
5075
  }
5075
5076
  function extend(schema, shape) {
5076
- if (!isPlainObject(shape)) {
5077
+ if (!isPlainObject$1(shape)) {
5077
5078
  throw new Error("Invalid input to extend: expected a plain object");
5078
5079
  }
5079
5080
  const checks = schema._zod.def.checks;
@@ -5096,7 +5097,7 @@ function extend(schema, shape) {
5096
5097
  return clone(schema, def);
5097
5098
  }
5098
5099
  function safeExtend(schema, shape) {
5099
- if (!isPlainObject(shape)) {
5100
+ if (!isPlainObject$1(shape)) {
5100
5101
  throw new Error("Invalid input to safeExtend: expected a plain object");
5101
5102
  }
5102
5103
  const def = mergeDefs(schema._zod.def, {
@@ -5433,6 +5434,7 @@ var string$1 = (params) => {
5433
5434
  const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
5434
5435
  return new RegExp(`^${regex}$`);
5435
5436
  };
5437
+ var boolean$1 = /^(?:true|false)$/i;
5436
5438
  var lowercase = /^[^A-Z]*$/;
5437
5439
  var uppercase = /^[^a-z]*$/;
5438
5440
  var $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
@@ -6101,6 +6103,26 @@ var $ZodJWT = /* @__PURE__ */ $constructor("$ZodJWT", (inst, def) => {
6101
6103
  });
6102
6104
  };
6103
6105
  });
6106
+ var $ZodBoolean = /* @__PURE__ */ $constructor("$ZodBoolean", (inst, def) => {
6107
+ $ZodType.init(inst, def);
6108
+ inst._zod.pattern = boolean$1;
6109
+ inst._zod.parse = (payload, _ctx) => {
6110
+ if (def.coerce)
6111
+ try {
6112
+ payload.value = Boolean(payload.value);
6113
+ } catch (_) {}
6114
+ const input = payload.value;
6115
+ if (typeof input === "boolean")
6116
+ return payload;
6117
+ payload.issues.push({
6118
+ expected: "boolean",
6119
+ code: "invalid_type",
6120
+ input,
6121
+ inst
6122
+ });
6123
+ return payload;
6124
+ };
6125
+ });
6104
6126
  var $ZodUnknown = /* @__PURE__ */ $constructor("$ZodUnknown", (inst, def) => {
6105
6127
  $ZodType.init(inst, def);
6106
6128
  inst._zod.parse = (payload) => payload;
@@ -6471,7 +6493,7 @@ function mergeValues(a, b) {
6471
6493
  if (a instanceof Date && b instanceof Date && +a === +b) {
6472
6494
  return { valid: true, data: a };
6473
6495
  }
6474
- if (isPlainObject(a) && isPlainObject(b)) {
6496
+ if (isPlainObject$1(a) && isPlainObject$1(b)) {
6475
6497
  const bKeys = Object.keys(b);
6476
6498
  const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
6477
6499
  const newObj = { ...a, ...b };
@@ -6826,7 +6848,7 @@ function handleRefineResult(result, payload, input, inst) {
6826
6848
  payload.issues.push(issue(_iss));
6827
6849
  }
6828
6850
  }
6829
- var _a;
6851
+ var _a$1;
6830
6852
 
6831
6853
  class $ZodRegistry {
6832
6854
  constructor() {
@@ -6871,7 +6893,7 @@ class $ZodRegistry {
6871
6893
  function registry() {
6872
6894
  return new $ZodRegistry;
6873
6895
  }
6874
- (_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
6896
+ (_a$1 = globalThis).__zod_globalRegistry ?? (_a$1.__zod_globalRegistry = registry());
6875
6897
  var globalRegistry = globalThis.__zod_globalRegistry;
6876
6898
  function _string(Class, params) {
6877
6899
  return new Class({
@@ -7116,6 +7138,12 @@ function _isoDuration(Class, params) {
7116
7138
  ...normalizeParams(params)
7117
7139
  });
7118
7140
  }
7141
+ function _boolean(Class, params) {
7142
+ return new Class({
7143
+ type: "boolean",
7144
+ ...normalizeParams(params)
7145
+ });
7146
+ }
7119
7147
  function _unknown(Class) {
7120
7148
  return new Class({
7121
7149
  type: "unknown"
@@ -7281,7 +7309,7 @@ function initializeContext(params) {
7281
7309
  };
7282
7310
  }
7283
7311
  function process2(schema, ctx, _params = { path: [], schemaPath: [] }) {
7284
- var _a2;
7312
+ var _a;
7285
7313
  const def = schema._zod.def;
7286
7314
  const seen = ctx.seen.get(schema);
7287
7315
  if (seen) {
@@ -7329,7 +7357,7 @@ function process2(schema, ctx, _params = { path: [], schemaPath: [] }) {
7329
7357
  delete result.schema.default;
7330
7358
  }
7331
7359
  if (ctx.io === "input" && result.schema._prefault)
7332
- (_a2 = result.schema).default ?? (_a2.default = result.schema._prefault);
7360
+ (_a = result.schema).default ?? (_a.default = result.schema._prefault);
7333
7361
  delete result.schema._prefault;
7334
7362
  const _result = ctx.seen.get(schema);
7335
7363
  return _result.schema;
@@ -7646,6 +7674,9 @@ var stringProcessor = (schema, ctx, _json, _params) => {
7646
7674
  }
7647
7675
  }
7648
7676
  };
7677
+ var booleanProcessor = (_schema, _ctx, json, _params) => {
7678
+ json.type = "boolean";
7679
+ };
7649
7680
  var neverProcessor = (_schema, _ctx, json, _params) => {
7650
7681
  json.not = {};
7651
7682
  };
@@ -8104,6 +8135,14 @@ var ZodJWT = /* @__PURE__ */ $constructor("ZodJWT", (inst, def) => {
8104
8135
  $ZodJWT.init(inst, def);
8105
8136
  ZodStringFormat.init(inst, def);
8106
8137
  });
8138
+ var ZodBoolean = /* @__PURE__ */ $constructor("ZodBoolean", (inst, def) => {
8139
+ $ZodBoolean.init(inst, def);
8140
+ ZodType.init(inst, def);
8141
+ inst._zod.processJSONSchema = (ctx, json, params) => booleanProcessor(inst, ctx, json);
8142
+ });
8143
+ function boolean(params) {
8144
+ return _boolean(ZodBoolean, params);
8145
+ }
8107
8146
  var ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
8108
8147
  $ZodUnknown.init(inst, def);
8109
8148
  ZodType.init(inst, def);
@@ -8414,7 +8453,8 @@ object({
8414
8453
  secret: string().optional(),
8415
8454
  clientId: string().optional(),
8416
8455
  redirectUri: string().url().optional(),
8417
- scope: string().optional()
8456
+ scope: string().optional(),
8457
+ enforceSso: boolean().optional()
8418
8458
  });
8419
8459
 
8420
8460
  class UiPathConfig {
@@ -8426,6 +8466,7 @@ class UiPathConfig {
8426
8466
  this.clientId = options.clientId;
8427
8467
  this.redirectUri = options.redirectUri;
8428
8468
  this.scope = options.scope;
8469
+ this.enforceSso = options.enforceSso;
8429
8470
  }
8430
8471
  }
8431
8472
 
@@ -8628,6 +8669,7 @@ var TaskType;
8628
8669
  TaskType2["DocumentValidation"] = "DocumentValidationTask";
8629
8670
  TaskType2["DocumentClassification"] = "DocumentClassificationTask";
8630
8671
  TaskType2["DataLabeling"] = "DataLabelingTask";
8672
+ TaskType2["QuickForm"] = "QuickFormTask";
8631
8673
  })(TaskType || (TaskType = {}));
8632
8674
  var TaskPriority;
8633
8675
  (function(TaskPriority2) {
@@ -8740,7 +8782,11 @@ var PROCESS_ENDPOINTS = {
8740
8782
  var QUEUE_ENDPOINTS = {
8741
8783
  GET_BY_FOLDER: `${ORCHESTRATOR_BASE}/odata/QueueDefinitions`,
8742
8784
  GET_ALL: `${ORCHESTRATOR_BASE}/odata/QueueDefinitions/UiPath.Server.Configuration.OData.GetQueuesAcrossFolders`,
8743
- GET_BY_ID: (id) => `${ORCHESTRATOR_BASE}/odata/QueueDefinitions(${id})`
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`
8744
8790
  };
8745
8791
  var JOB_ENDPOINTS = {
8746
8792
  GET_ALL: `${ORCHESTRATOR_BASE}/odata/Jobs`,
@@ -8787,6 +8833,10 @@ var MAESTRO_ENDPOINTS = {
8787
8833
  TRACES: {
8788
8834
  GET_SPANS: (traceId) => `${LLMOPS_BASE}/api/Traces/spans?traceId=${traceId}`
8789
8835
  },
8836
+ BUSINESS_APPS: {
8837
+ COLLECTION: `${PIMS_BASE}/api/v1/business-apps`,
8838
+ BY_ID: (businessAppId) => `${PIMS_BASE}/api/v1/business-apps/${businessAppId}`
8839
+ },
8790
8840
  CASES: {
8791
8841
  GET_CASE_JSON: (instanceId) => `${PIMS_BASE}/api/v1/cases/${instanceId}/case-json`,
8792
8842
  GET_ELEMENT_EXECUTIONS: (instanceId) => `${PIMS_BASE}/api/v1/element-executions/case-instances/${instanceId}`,
@@ -8821,13 +8871,24 @@ var DATA_FABRIC_ENDPOINTS = {
8821
8871
  DELETE_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/delete-batch`,
8822
8872
  UPSERT: `${DATAFABRIC_BASE}/api/Entity`,
8823
8873
  DELETE: (entityId) => `${DATAFABRIC_BASE}/api/Entity/${entityId}`,
8824
- UPDATE_METADATA: (entityId) => `${DATAFABRIC_BASE}/api/Entity/${entityId}/metadata`,
8874
+ UPDATE: (entityId) => `${DATAFABRIC_BASE}/api/Entity/${entityId}/metadata`,
8825
8875
  QUERY_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/query`,
8826
8876
  QUERY_BY_NAME: (entityName) => `${DATAFABRIC_BASE}/api/EntityService/${entityName}/query`,
8827
8877
  BULK_UPLOAD_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/bulk-upload`,
8828
8878
  DOWNLOAD_ATTACHMENT: (entityId, recordId, fieldName) => `${DATAFABRIC_BASE}/api/Attachment/entity/${entityId}/${recordId}/${fieldName}`,
8829
8879
  UPLOAD_ATTACHMENT: (entityId, recordId, fieldName) => `${DATAFABRIC_BASE}/api/Attachment/entity/${entityId}/${recordId}/${fieldName}`,
8830
- DELETE_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}`
8831
8892
  },
8832
8893
  CHOICESETS: {
8833
8894
  GET_ALL: `${DATAFABRIC_BASE}/api/Entity/choiceset`,
@@ -8850,7 +8911,8 @@ var DATA_FABRIC_ENDPOINTS = {
8850
8911
  };
8851
8912
  var IDENTITY_ENDPOINTS = {
8852
8913
  TOKEN: `${IDENTITY_BASE}/connect/token`,
8853
- AUTHORIZE: `${IDENTITY_BASE}/connect/authorize`
8914
+ AUTHORIZE: `${IDENTITY_BASE}/connect/authorize`,
8915
+ END_SESSION: `${IDENTITY_BASE}/connect/endsession`
8854
8916
  };
8855
8917
  var TASK_TYPE_ENDPOINTS = {
8856
8918
  [TaskType.Form]: TASK_ENDPOINTS.GET_TASK_FORM_BY_ID,
@@ -8858,7 +8920,8 @@ var TASK_TYPE_ENDPOINTS = {
8858
8920
  [TaskType.DocumentValidation]: TASK_ENDPOINTS.GET_GENERIC_TASK_BY_ID,
8859
8921
  [TaskType.DocumentClassification]: TASK_ENDPOINTS.GET_GENERIC_TASK_BY_ID,
8860
8922
  [TaskType.External]: TASK_ENDPOINTS.GET_GENERIC_TASK_BY_ID,
8861
- [TaskType.DataLabeling]: TASK_ENDPOINTS.GET_GENERIC_TASK_BY_ID
8923
+ [TaskType.DataLabeling]: TASK_ENDPOINTS.GET_GENERIC_TASK_BY_ID,
8924
+ [TaskType.QuickForm]: TASK_ENDPOINTS.GET_GENERIC_TASK_BY_ID
8862
8925
  };
8863
8926
  var ActionCenterEventNames;
8864
8927
  (function(ActionCenterEventNames2) {
@@ -8866,29 +8929,12 @@ var ActionCenterEventNames;
8866
8929
  ActionCenterEventNames2["REFRESHTOKEN"] = "AC.refreshToken";
8867
8930
  })(ActionCenterEventNames || (ActionCenterEventNames = {}));
8868
8931
  var AUTHENTICATION_TIMEOUT = 8000;
8869
- var ALLOWED_HOST_ORIGINS = new Set([
8870
- "https://alpha.uipath.com",
8871
- "https://staging.uipath.com",
8872
- "https://cloud.uipath.com"
8873
- ]);
8874
- function isValidHostOrigin(origin) {
8875
- if (!origin)
8876
- return false;
8877
- if (ALLOWED_HOST_ORIGINS.has(origin))
8878
- return true;
8879
- try {
8880
- return new URL(origin).hostname === "localhost";
8881
- } catch {
8882
- console.warn("isValidHostOrigin: received a malformed origin URL", origin);
8883
- return false;
8884
- }
8885
- }
8886
8932
  function isTokenExpired(tokenInfo) {
8887
8933
  if (!tokenInfo?.expiresAt)
8888
8934
  return true;
8889
8935
  return new Date >= tokenInfo.expiresAt;
8890
8936
  }
8891
- var trustedEmbeddingOrigin = isHostEmbedded && embeddingOrigin && isValidHostOrigin(embeddingOrigin) ? embeddingOrigin : null;
8937
+ var hostEmbeddingOrigin = isHostEmbedded && embeddingOrigin ? embeddingOrigin : null;
8892
8938
  function waitForMessage(filter, signal) {
8893
8939
  return new Promise((resolve, reject) => {
8894
8940
  const handler = (event) => {
@@ -8957,12 +9003,6 @@ class ActionCenterTokenManager {
8957
9003
  statusCode: HttpStatus.UNAUTHORIZED
8958
9004
  }));
8959
9005
  }
8960
- if (!isValidHostOrigin(parentOrigin)) {
8961
- return Promise.reject(new AuthenticationError({
8962
- message: "Cannot refresh token: basedomain is not a trusted UiPath host origin",
8963
- statusCode: HttpStatus.UNAUTHORIZED
8964
- }));
8965
- }
8966
9006
  const { promise } = requestHostToken({
8967
9007
  pinnedOrigin: parentOrigin,
8968
9008
  sendRequest: () => this.sendMessageToParent(ActionCenterEventNames.REFRESHTOKEN, {
@@ -8986,7 +9026,7 @@ class ActionCenterTokenManager {
8986
9026
  }
8987
9027
  }
8988
9028
  sendMessageToParent(eventType, content) {
8989
- if (window.parent && isValidHostOrigin(this.parentOrigin)) {
9029
+ if (window.parent && this.parentOrigin) {
8990
9030
  try {
8991
9031
  window.parent.postMessage({ eventType, content }, this.parentOrigin);
8992
9032
  } catch (error) {
@@ -9066,7 +9106,7 @@ class EmbeddedTokenManager {
9066
9106
  this.cancelRefresh?.();
9067
9107
  }
9068
9108
  }
9069
- var SDK_VERSION = "1.6.1";
9109
+ var SDK_VERSION = "1.7.1";
9070
9110
  var CLOUD_ROLE_NAME = "uipath-ts-sdk";
9071
9111
  var SDK_SERVICE_NAME = "UiPath.TypeScript.Sdk";
9072
9112
  var SDK_LOGGER_NAME = "uipath-ts-sdk-telemetry";
@@ -9132,19 +9172,21 @@ function base64UrlToBase64(value) {
9132
9172
  const base642 = value.replace(BASE64URL_DASH_RE, "+").replace(BASE64URL_UNDERSCORE_RE, "/");
9133
9173
  return base642.padEnd(base642.length + (4 - base642.length % 4) % 4, "=");
9134
9174
  }
9135
- function extractUserIdFromToken(token) {
9175
+ function decodeJwtClaims(token) {
9136
9176
  try {
9137
- const payload = token.split(".")[1];
9177
+ const payload = token?.split(".")[1];
9138
9178
  if (!payload) {
9139
- return "";
9179
+ return;
9140
9180
  }
9141
- const claims = JSON.parse(decodeBase64(base64UrlToBase64(payload)));
9142
- const sub = claims["sub"];
9143
- return typeof sub === "string" && sub ? sub : "";
9181
+ return JSON.parse(decodeBase64(base64UrlToBase64(payload)));
9144
9182
  } catch {
9145
- return "";
9183
+ return;
9146
9184
  }
9147
9185
  }
9186
+ function extractUserIdFromToken(token) {
9187
+ const sub = decodeJwtClaims(token)?.["sub"];
9188
+ return typeof sub === "string" && sub ? sub : "";
9189
+ }
9148
9190
 
9149
9191
  class TokenManager {
9150
9192
  constructor(executionContext, config2, isOAuth = false) {
@@ -9157,8 +9199,8 @@ class TokenManager {
9157
9199
  if (isInActionCenter) {
9158
9200
  this.actionCenterTokenManager = new ActionCenterTokenManager(config2, (tokenInfo) => this.setToken(tokenInfo));
9159
9201
  this.isOAuth = false;
9160
- } else if (trustedEmbeddingOrigin) {
9161
- this.embeddedTokenManager = new EmbeddedTokenManager(trustedEmbeddingOrigin, config2, (tokenInfo) => this.setToken(tokenInfo));
9202
+ } else if (hostEmbeddingOrigin) {
9203
+ this.embeddedTokenManager = new EmbeddedTokenManager(hostEmbeddingOrigin, config2, (tokenInfo) => this.setToken(tokenInfo));
9162
9204
  this.isOAuth = false;
9163
9205
  }
9164
9206
  }
@@ -9269,6 +9311,9 @@ class TokenManager {
9269
9311
  getToken() {
9270
9312
  return this.currentToken?.token;
9271
9313
  }
9314
+ getIdToken() {
9315
+ return this.currentToken?.idToken;
9316
+ }
9272
9317
  hasValidToken() {
9273
9318
  if (!this.currentToken) {
9274
9319
  return false;
@@ -9340,11 +9385,13 @@ class TokenManager {
9340
9385
  token: token.access_token,
9341
9386
  type: "oauth",
9342
9387
  expiresAt: new Date(Date.now() + token.expires_in * 1000),
9343
- refreshToken: token.refresh_token
9388
+ refreshToken: token.refresh_token,
9389
+ idToken: token.id_token ?? tokenInfo.idToken
9344
9390
  });
9345
9391
  return token;
9346
9392
  }
9347
9393
  }
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;
9348
9395
 
9349
9396
  class AuthService {
9350
9397
  constructor(config2, executionContext) {
@@ -9478,7 +9525,11 @@ class AuthService {
9478
9525
  hasValidToken() {
9479
9526
  return this.tokenManager.hasValidToken();
9480
9527
  }
9481
- logout() {
9528
+ logout(options) {
9529
+ const idTokenHint = options?.endSession ? this.tokenManager.getIdToken() : undefined;
9530
+ if (options?.endSession && isBrowser && !idTokenHint) {
9531
+ console.warn("endSession skipped — no OIDC ID token is available for this " + "session. Sign in again to enable it; only local authentication " + "state was cleared.");
9532
+ }
9482
9533
  this.tokenManager.clearToken();
9483
9534
  if (isBrowser) {
9484
9535
  try {
@@ -9488,6 +9539,12 @@ class AuthService {
9488
9539
  console.warn("Failed to clear OAuth context from session storage", error);
9489
9540
  }
9490
9541
  }
9542
+ if (options?.endSession && isBrowser && idTokenHint) {
9543
+ window.location.href = this._buildEndSessionUrl({
9544
+ idTokenHint,
9545
+ postLogoutRedirectUri: this.config.redirectUri
9546
+ });
9547
+ }
9491
9548
  }
9492
9549
  getToken() {
9493
9550
  if (!this.tokenManager.hasValidToken()) {
@@ -9531,10 +9588,27 @@ class AuthService {
9531
9588
  redirect_uri: params.redirectUri,
9532
9589
  code_challenge: params.codeChallenge,
9533
9590
  code_challenge_method: "S256",
9534
- scope: params.scope + " offline_access",
9591
+ scope: params.scope + " offline_access openid",
9535
9592
  state: params.state || this.generateCodeVerifier().slice(0, 16)
9536
9593
  });
9537
- return `${this.config.baseUrl}/${IDENTITY_ENDPOINTS.AUTHORIZE}?${queryParams.toString()}`;
9594
+ const authorizeUrl = `${this.config.baseUrl}/${IDENTITY_ENDPOINTS.AUTHORIZE}?${queryParams.toString()}`;
9595
+ if (!this.config.enforceSso) {
9596
+ return authorizeUrl;
9597
+ }
9598
+ const orgName = this.config.orgName;
9599
+ if (!GUID_REGEX$1.test(orgName)) {
9600
+ 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
+ return authorizeUrl;
9602
+ }
9603
+ return `${authorizeUrl}&acr_values=${encodeURIComponent(`tenant:${orgName}`)}`;
9604
+ }
9605
+ _buildEndSessionUrl(params) {
9606
+ const queryParams = new URLSearchParams;
9607
+ queryParams.set("id_token_hint", params.idTokenHint);
9608
+ if (params.postLogoutRedirectUri) {
9609
+ queryParams.set("post_logout_redirect_uri", params.postLogoutRedirectUri);
9610
+ }
9611
+ return `${this.config.baseUrl}/${IDENTITY_ENDPOINTS.END_SESSION}?${queryParams.toString()}`;
9538
9612
  }
9539
9613
  async _getAccessToken(params) {
9540
9614
  const body = new URLSearchParams({
@@ -9561,7 +9635,8 @@ class AuthService {
9561
9635
  token: token.access_token,
9562
9636
  type: "oauth",
9563
9637
  expiresAt: token.expires_in ? new Date(Date.now() + token.expires_in * 1000) : undefined,
9564
- refreshToken: token.refresh_token
9638
+ refreshToken: token.refresh_token,
9639
+ idToken: token.id_token
9565
9640
  });
9566
9641
  return token;
9567
9642
  }
@@ -9634,9 +9709,18 @@ function validateConfig(config2) {
9634
9709
  function isCompleteConfig(config2) {
9635
9710
  return hasRequiredBaseFields(config2) && hasValidAuthConfig(config2);
9636
9711
  }
9712
+ function compactConfig(config2) {
9713
+ return Object.fromEntries(Object.entries(config2).filter(([, value]) => value !== undefined));
9714
+ }
9637
9715
  function normalizeBaseUrl(url) {
9638
9716
  return url.endsWith("/") ? url.slice(0, -1) : url;
9639
9717
  }
9718
+ function missingConfigMessage() {
9719
+ if (isBrowser) {
9720
+ 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
+ }
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.";
9723
+ }
9640
9724
  var REGISTRY_KEY2 = Symbol.for("@uipath/sdk-internals-registry");
9641
9725
  var getGlobalStore = () => {
9642
9726
  const globalObj = globalThis;
@@ -9645,6 +9729,7 @@ var getGlobalStore = () => {
9645
9729
  }
9646
9730
  return globalObj[REGISTRY_KEY2];
9647
9731
  };
9732
+ var looksLikeUiPath = (instance) => typeof instance.initialize === "function";
9648
9733
 
9649
9734
  class SDKInternalsRegistry {
9650
9735
  static get store() {
@@ -9656,6 +9741,9 @@ class SDKInternalsRegistry {
9656
9741
  static get(instance) {
9657
9742
  const internals = this.store.get(instance);
9658
9743
  if (!internals) {
9744
+ if (looksLikeUiPath(instance)) {
9745
+ throw new Error("Cannot create a service: the UiPath instance was never configured. " + missingConfigMessage());
9746
+ }
9659
9747
  throw new Error("Invalid SDK instance. Make sure to pass a valid UiPath instance to the service constructor.");
9660
9748
  }
9661
9749
  return internals;
@@ -9673,6 +9761,10 @@ var UiPathMetaTags;
9673
9761
  UiPathMetaTags2["APP_BASE"] = "uipath:app-base";
9674
9762
  UiPathMetaTags2["FOLDER_KEY"] = "uipath:folder-key";
9675
9763
  })(UiPathMetaTags || (UiPathMetaTags = {}));
9764
+ var UiPathElementIds;
9765
+ (function(UiPathElementIds2) {
9766
+ UiPathElementIds2["RESOURCE_OVERRIDES"] = "uipath-overrides";
9767
+ })(UiPathElementIds || (UiPathElementIds = {}));
9676
9768
  function getMetaTagContent(name) {
9677
9769
  if (!isBrowser)
9678
9770
  return;
@@ -9693,7 +9785,54 @@ function loadFromMetaTags() {
9693
9785
  const hasAnyValue = Object.values(config2).some(Boolean);
9694
9786
  return hasAnyValue ? config2 : null;
9695
9787
  }
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
+ function isFunctionContext(value) {
9820
+ return "platform" in value || "robot" in value;
9821
+ }
9822
+ function configFromFunctionContext(context) {
9823
+ const { platform, robot } = context;
9824
+ if (!platform)
9825
+ return null;
9826
+ const config2 = {
9827
+ baseUrl: platform.baseUrl,
9828
+ orgName: platform.orgId,
9829
+ tenantName: platform.tenantId,
9830
+ secret: robot?.accessToken ?? undefined
9831
+ };
9832
+ return Object.values(config2).some(Boolean) ? config2 : null;
9833
+ }
9696
9834
  var _UiPath_instances;
9835
+ var _a;
9697
9836
  var _UiPath_config;
9698
9837
  var _UiPath_authService;
9699
9838
  var _UiPath_initialized;
@@ -9702,6 +9841,7 @@ var _UiPath_metaFolderKey;
9702
9841
  var _UiPath_metaOrgId;
9703
9842
  var _UiPath_metaTenantId;
9704
9843
  var _UiPath_initializeWithConfig;
9844
+ var _UiPath_mergeConfigSources;
9705
9845
  var _UiPath_loadConfig;
9706
9846
  var UiPath$1 = class UiPath {
9707
9847
  constructor(config2) {
@@ -9713,15 +9853,16 @@ var UiPath$1 = class UiPath {
9713
9853
  _UiPath_metaFolderKey.set(this, undefined);
9714
9854
  _UiPath_metaOrgId.set(this, undefined);
9715
9855
  _UiPath_metaTenantId.set(this, undefined);
9856
+ const resolved = config2 && isFunctionContext(config2) ? configFromFunctionContext(config2) ?? undefined : config2;
9716
9857
  const configFromMetaTags = loadFromMetaTags();
9717
9858
  __classPrivateFieldSet(this, _UiPath_metaFolderKey, configFromMetaTags?.folderKey, "f");
9718
9859
  __classPrivateFieldSet(this, _UiPath_metaOrgId, configFromMetaTags?.orgName, "f");
9719
9860
  __classPrivateFieldSet(this, _UiPath_metaTenantId, configFromMetaTags?.tenantName, "f");
9720
- const mergedConfig = config2 ? { ...configFromMetaTags, ...config2 } : configFromMetaTags;
9861
+ const mergedConfig = __classPrivateFieldGet(_a, _a, "m", _UiPath_mergeConfigSources).call(_a, configFromMetaTags, resolved);
9721
9862
  if (mergedConfig && isCompleteConfig(mergedConfig)) {
9722
9863
  __classPrivateFieldGet(this, _UiPath_instances, "m", _UiPath_initializeWithConfig).call(this, mergedConfig);
9723
- } else if (config2) {
9724
- __classPrivateFieldSet(this, _UiPath_partialConfig, config2, "f");
9864
+ } else if (resolved) {
9865
+ __classPrivateFieldSet(this, _UiPath_partialConfig, resolved, "f");
9725
9866
  }
9726
9867
  }
9727
9868
  async initialize() {
@@ -9786,18 +9927,18 @@ var UiPath$1 = class UiPath {
9786
9927
  destroy() {
9787
9928
  __classPrivateFieldGet(this, _UiPath_authService, "f")?.getTokenManager()?.destroy();
9788
9929
  }
9789
- logout() {
9930
+ logout(options) {
9790
9931
  if (__classPrivateFieldGet(this, _UiPath_config, "f") && hasSecretConfig(__classPrivateFieldGet(this, _UiPath_config, "f"))) {
9791
9932
  return;
9792
9933
  }
9793
- __classPrivateFieldGet(this, _UiPath_authService, "f")?.logout();
9934
+ __classPrivateFieldGet(this, _UiPath_authService, "f")?.logout(options);
9794
9935
  __classPrivateFieldSet(this, _UiPath_initialized, false, "f");
9795
9936
  }
9796
9937
  updateToken(tokenInfo) {
9797
9938
  __classPrivateFieldGet(this, _UiPath_authService, "f")?.updateToken(tokenInfo);
9798
9939
  }
9799
9940
  };
9800
- _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) {
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) {
9801
9942
  validateConfig(config2);
9802
9943
  const hasSecretAuth = hasSecretConfig(config2);
9803
9944
  const hasOAuthAuth = hasOAuthConfig(config2);
@@ -9808,7 +9949,8 @@ _UiPath_config = new WeakMap, _UiPath_authService = new WeakMap, _UiPath_initial
9808
9949
  secret: hasSecretAuth ? config2.secret : undefined,
9809
9950
  clientId: hasOAuthAuth ? config2.clientId : undefined,
9810
9951
  redirectUri: hasOAuthAuth ? config2.redirectUri : undefined,
9811
- scope: hasOAuthAuth ? config2.scope : undefined
9952
+ scope: hasOAuthAuth ? config2.scope : undefined,
9953
+ enforceSso: config2.enforceSso
9812
9954
  });
9813
9955
  const executionContext = new ExecutionContext;
9814
9956
  __classPrivateFieldSet(this, _UiPath_authService, new AuthService(internalConfig, executionContext), "f");
@@ -9834,18 +9976,35 @@ _UiPath_config = new WeakMap, _UiPath_authService = new WeakMap, _UiPath_initial
9834
9976
  redirectUri: hasOAuthAuth ? config2.redirectUri : undefined
9835
9977
  });
9836
9978
  trackEvent("Sdk.Auth");
9837
- if (hasSecretAuth || isInActionCenter || trustedEmbeddingOrigin) {
9979
+ if (hasSecretAuth || isInActionCenter || hostEmbeddingOrigin) {
9838
9980
  __classPrivateFieldGet(this, _UiPath_authService, "f").authenticateWithSecret(config2.secret ?? "");
9839
9981
  __classPrivateFieldSet(this, _UiPath_initialized, true, "f");
9840
9982
  }
9983
+ }, _UiPath_mergeConfigSources = function _UiPath_mergeConfigSources2(metaConfig, config2) {
9984
+ const layers = [loadFromEnvironment(), metaConfig, config2].filter((layer) => Boolean(layer)).map((layer) => compactConfig(layer));
9985
+ if (layers.length === 0)
9986
+ return;
9987
+ const merged = layers.reduce((acc, layer) => ({ ...acc, ...layer }), {});
9988
+ const namesSecret = config2 ? hasSecretConfig(config2) : false;
9989
+ const namesOAuth = Boolean(config2?.clientId || config2?.redirectUri || config2?.scope);
9990
+ if (namesSecret !== namesOAuth) {
9991
+ if (namesSecret) {
9992
+ delete merged.clientId;
9993
+ delete merged.redirectUri;
9994
+ delete merged.scope;
9995
+ } else {
9996
+ delete merged.secret;
9997
+ }
9998
+ }
9999
+ return merged;
9841
10000
  }, _UiPath_loadConfig = function _UiPath_loadConfig2() {
9842
10001
  const metaConfig = loadFromMetaTags();
9843
10002
  __classPrivateFieldSet(this, _UiPath_metaFolderKey, metaConfig?.folderKey, "f");
9844
10003
  __classPrivateFieldSet(this, _UiPath_metaOrgId, metaConfig?.orgName, "f");
9845
10004
  __classPrivateFieldSet(this, _UiPath_metaTenantId, metaConfig?.tenantName, "f");
9846
- const merged = { ...metaConfig, ...__classPrivateFieldGet(this, _UiPath_partialConfig, "f") };
9847
- if (!isCompleteConfig(merged)) {
9848
- throw new Error("UiPath SDK configuration not found. " + "Ensure @uipath/coded-apps plugin is set up in your bundler to inject configuration during development and build.");
10005
+ const merged = __classPrivateFieldGet(_a, _a, "m", _UiPath_mergeConfigSources).call(_a, metaConfig, __classPrivateFieldGet(this, _UiPath_partialConfig, "f"));
10006
+ if (!merged || !isCompleteConfig(merged)) {
10007
+ throw new Error(missingConfigMessage());
9849
10008
  }
9850
10009
  return merged;
9851
10010
  };
@@ -10023,8 +10182,177 @@ var RESPONSE_TYPES = {
10023
10182
  JSON: "json",
10024
10183
  TEXT: "text",
10025
10184
  BLOB: "blob",
10026
- ARRAYBUFFER: "arraybuffer"
10185
+ ARRAYBUFFER: "arraybuffer",
10186
+ STREAM: "stream"
10187
+ };
10188
+ function createParams(paramsObj = {}) {
10189
+ const params = {};
10190
+ for (const [key, value] of Object.entries(paramsObj)) {
10191
+ if (value !== undefined && value !== null) {
10192
+ params[key] = value;
10193
+ }
10194
+ }
10195
+ return params;
10196
+ }
10197
+ function toSearchParams(params) {
10198
+ const searchParams = new URLSearchParams;
10199
+ if (!params)
10200
+ return searchParams;
10201
+ for (const [key, value] of Object.entries(params)) {
10202
+ if (value === undefined || value === null)
10203
+ continue;
10204
+ if (Array.isArray(value)) {
10205
+ value.forEach((item) => {
10206
+ if (item !== undefined && item !== null)
10207
+ searchParams.append(key, String(item));
10208
+ });
10209
+ } else {
10210
+ searchParams.append(key, String(value));
10211
+ }
10212
+ }
10213
+ return searchParams;
10214
+ }
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
10027
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
+ }
10028
10356
 
10029
10357
  class ApiClient {
10030
10358
  constructor(config2, executionContext, tokenManager, clientConfig = {}) {
@@ -10059,28 +10387,16 @@ class ApiClient {
10059
10387
  [UIPATH_TRACEPARENT_ID]: traceparentValue,
10060
10388
  ...options.headers
10061
10389
  };
10062
- const searchParams = new URLSearchParams;
10063
- if (options.params) {
10064
- Object.entries(options.params).forEach(([key, value]) => {
10065
- if (Array.isArray(value)) {
10066
- value.forEach((item) => searchParams.append(key, String(item)));
10067
- } else {
10068
- searchParams.append(key, String(value));
10069
- }
10070
- });
10071
- }
10390
+ const searchParams = toSearchParams(options.params);
10072
10391
  const fullUrl = searchParams.toString() ? `${url}?${searchParams.toString()}` : url;
10073
10392
  let body = undefined;
10074
10393
  if (options.body) {
10075
10394
  body = isFormData ? options.body : JSON.stringify(options.body);
10076
10395
  }
10396
+ const retrySettings = resolveRetryOptions(options.retry ?? options.retryOptions, DEFAULT_API_CLIENT_RETRY);
10397
+ const timeoutMs = options.timeoutMs ?? options.timeoutOptions?.timeout;
10077
10398
  try {
10078
- const response = await fetch(fullUrl, {
10079
- method,
10080
- headers,
10081
- body,
10082
- signal: options.signal
10083
- });
10399
+ const response = await fetchWithRetry(fullUrl, { method, headers, body }, { retry: retrySettings, timeoutMs, signal: options.signal });
10084
10400
  if (!response.ok) {
10085
10401
  const errorInfo = await errorResponseParser.parse(response);
10086
10402
  throw ErrorFactory.createFromHttpStatus(response.status, errorInfo);
@@ -10796,36 +11112,36 @@ function createEntityMethods(entityData, service) {
10796
11112
  async insertRecord(data, options) {
10797
11113
  if (!entityData.id)
10798
11114
  throw new Error("Entity ID is undefined");
10799
- return service.insertRecordById(entityData.id, data, options);
11115
+ return service.insertRecord({ id: entityData.id }, data, options);
10800
11116
  },
10801
11117
  async insertRecords(data, options) {
10802
11118
  if (!entityData.id)
10803
11119
  throw new Error("Entity ID is undefined");
10804
- return service.insertRecordsById(entityData.id, data, options);
11120
+ return service.insertRecords({ id: entityData.id }, data, options);
10805
11121
  },
10806
11122
  async updateRecord(recordId, data, options) {
10807
11123
  if (!entityData.id)
10808
11124
  throw new Error("Entity ID is undefined");
10809
11125
  if (!recordId)
10810
11126
  throw new Error("Record ID is undefined");
10811
- return service.updateRecordById(entityData.id, recordId, data, options);
11127
+ return service.updateRecord({ id: entityData.id }, recordId, data, options);
10812
11128
  },
10813
11129
  async updateRecords(data, options) {
10814
11130
  if (!entityData.id)
10815
11131
  throw new Error("Entity ID is undefined");
10816
- return service.updateRecordsById(entityData.id, data, options);
11132
+ return service.updateRecords({ id: entityData.id }, data, options);
10817
11133
  },
10818
11134
  async deleteRecords(recordIds, options) {
10819
11135
  if (!entityData.id)
10820
11136
  throw new Error("Entity ID is undefined");
10821
- return service.deleteRecordsById(entityData.id, recordIds, options);
11137
+ return service.deleteRecords({ id: entityData.id }, recordIds, options);
10822
11138
  },
10823
11139
  async deleteRecord(recordId, options) {
10824
11140
  if (!entityData.id)
10825
11141
  throw new Error("Entity ID is undefined");
10826
11142
  if (!recordId)
10827
11143
  throw new Error("Record ID is undefined");
10828
- return service.deleteRecordById(entityData.id, recordId, options);
11144
+ return service.deleteRecord({ id: entityData.id }, recordId, options);
10829
11145
  },
10830
11146
  async getAllRecords(options) {
10831
11147
  if (!entityData.id)
@@ -10842,27 +11158,27 @@ function createEntityMethods(entityData, service) {
10842
11158
  async downloadAttachment(recordId, fieldName, options) {
10843
11159
  if (!entityData.id)
10844
11160
  throw new Error("Entity ID is undefined");
10845
- return service.downloadAttachment(entityData.id, recordId, fieldName, options);
11161
+ return service.downloadAttachment({ id: entityData.id }, recordId, fieldName, options);
10846
11162
  },
10847
11163
  async uploadAttachment(recordId, fieldName, file, options) {
10848
11164
  if (!entityData.id)
10849
11165
  throw new Error("Entity ID is undefined");
10850
- return service.uploadAttachment(entityData.id, recordId, fieldName, file, options);
11166
+ return service.uploadAttachment({ id: entityData.id }, recordId, fieldName, file, options);
10851
11167
  },
10852
11168
  async deleteAttachment(recordId, fieldName, options) {
10853
11169
  if (!entityData.id)
10854
11170
  throw new Error("Entity ID is undefined");
10855
- return service.deleteAttachment(entityData.id, recordId, fieldName, options);
11171
+ return service.deleteAttachment({ id: entityData.id }, recordId, fieldName, options);
10856
11172
  },
10857
11173
  async queryRecords(options) {
10858
11174
  if (!entityData.id)
10859
11175
  throw new Error("Entity ID is undefined");
10860
- return service.queryRecordsById(entityData.id, options);
11176
+ return service.queryRecords({ id: entityData.id }, options);
10861
11177
  },
10862
11178
  async importRecords(file, options) {
10863
11179
  if (!entityData.id)
10864
11180
  throw new Error("Entity ID is undefined");
10865
- return service.importRecordsById(entityData.id, file, options);
11181
+ return service.importRecords({ id: entityData.id }, file, options);
10866
11182
  },
10867
11183
  async insert(data, options) {
10868
11184
  return this.insertRecord(data, options);
@@ -10938,6 +11254,15 @@ var EntityAggregateFunction;
10938
11254
  EntityAggregateFunction2["Min"] = "MIN";
10939
11255
  EntityAggregateFunction2["Max"] = "MAX";
10940
11256
  })(EntityAggregateFunction || (EntityAggregateFunction = {}));
11257
+ var EntityHavingOperator;
11258
+ (function(EntityHavingOperator2) {
11259
+ EntityHavingOperator2["Equals"] = "=";
11260
+ EntityHavingOperator2["NotEquals"] = "!=";
11261
+ EntityHavingOperator2["GreaterThan"] = ">";
11262
+ EntityHavingOperator2["GreaterThanOrEqual"] = ">=";
11263
+ EntityHavingOperator2["LessThan"] = "<";
11264
+ EntityHavingOperator2["LessThanOrEqual"] = "<=";
11265
+ })(EntityHavingOperator || (EntityHavingOperator = {}));
10941
11266
  var EntityType;
10942
11267
  (function(EntityType2) {
10943
11268
  EntityType2["Entity"] = "Entity";
@@ -10968,15 +11293,6 @@ var JoinType;
10968
11293
  JoinType2["LeftJoin"] = "LeftJoin";
10969
11294
  JoinType2["InnerJoin"] = "InnerJoin";
10970
11295
  })(JoinType || (JoinType = {}));
10971
- function createParams(paramsObj = {}) {
10972
- const params = {};
10973
- for (const [key, value] of Object.entries(paramsObj)) {
10974
- if (value !== undefined && value !== null) {
10975
- params[key] = value;
10976
- }
10977
- }
10978
- return params;
10979
- }
10980
11296
  var EntityFieldConstraint;
10981
11297
  (function(EntityFieldConstraint2) {
10982
11298
  EntityFieldConstraint2["LengthLimit"] = "lengthLimit";
@@ -11115,95 +11431,84 @@ function toWireJoin(join, baseEntityName) {
11115
11431
  }
11116
11432
  };
11117
11433
  }
11434
+ function unwrapEntityRef(entityRef, callerLabel) {
11435
+ const { id, name } = entityRef ?? {};
11436
+ if (id && name) {
11437
+ throw new ValidationError({
11438
+ message: `${callerLabel}: entityRef must supply exactly one of 'id' or 'name', not both.`
11439
+ });
11440
+ }
11441
+ if (id) {
11442
+ return { byId: true, identifier: id };
11443
+ }
11444
+ if (name) {
11445
+ return { byId: false, identifier: name };
11446
+ }
11447
+ throw new ValidationError({
11448
+ message: `${callerLabel}: entityRef must supply exactly one of 'id' or 'name'.`
11449
+ });
11450
+ }
11118
11451
 
11119
11452
  class EntityService extends BaseService {
11120
11453
  async getById(id, options) {
11121
- const response = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.GET_BY_ID(id), { headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }) });
11122
- const metadata = transformData(response.data, EntityMap);
11123
- this.applyFieldMappings(metadata);
11124
- return createEntityWithMethods(metadata, this);
11454
+ return this.fetchEntityMetadata(DATA_FABRIC_ENDPOINTS.ENTITY.GET_BY_ID(id), options?.folderKey);
11455
+ }
11456
+ async getByName(entityName, options) {
11457
+ return this.fetchEntityMetadata(DATA_FABRIC_ENDPOINTS.ENTITY.GET_BY_NAME(entityName), options?.folderKey);
11125
11458
  }
11126
11459
  async getAllRecords(entityId, options) {
11127
- const { folderKey, ...rest } = options ?? {};
11128
- const downstreamOptions = options === undefined ? undefined : rest;
11129
- return PaginationHelpers.getAll({
11130
- serviceAccess: this.createPaginationServiceAccess(),
11131
- getEndpoint: () => DATA_FABRIC_ENDPOINTS.ENTITY.GET_ENTITY_RECORDS(entityId),
11132
- headers: createHeaders({ [FOLDER_KEY]: folderKey }),
11133
- pagination: {
11134
- paginationType: PaginationType.OFFSET,
11135
- itemsField: ENTITY_PAGINATION.ITEMS_FIELD,
11136
- totalCountField: ENTITY_PAGINATION.TOTAL_COUNT_FIELD,
11137
- paginationParams: {
11138
- pageSizeParam: ENTITY_OFFSET_PARAMS.PAGE_SIZE_PARAM,
11139
- offsetParam: ENTITY_OFFSET_PARAMS.OFFSET_PARAM,
11140
- countParam: ENTITY_OFFSET_PARAMS.COUNT_PARAM
11141
- }
11142
- },
11143
- excludeFromPrefix: ["expansionLevel"]
11144
- }, downstreamOptions);
11460
+ return this.getRecordsImpl(true, entityId, options);
11461
+ }
11462
+ async getRecordsByName(entityName, options) {
11463
+ return this.getRecordsImpl(false, entityName, options);
11145
11464
  }
11146
11465
  async getRecordById(entityId, recordId, options = {}) {
11147
- const params = createParams({
11148
- expansionLevel: options.expansionLevel
11149
- });
11150
- const response = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.GET_RECORD_BY_ID(entityId, recordId), { params, headers: createHeaders({ [FOLDER_KEY]: options.folderKey }) });
11151
- return response.data;
11466
+ return this.getRecordImpl(true, entityId, recordId, options);
11467
+ }
11468
+ async getRecordByName(entityName, recordId, options = {}) {
11469
+ return this.getRecordImpl(false, entityName, recordId, options);
11470
+ }
11471
+ async insertRecord(entityRef, data, options = {}) {
11472
+ const { byId, identifier } = unwrapEntityRef(entityRef, "Entities.insertRecord");
11473
+ return this.insertRecordImpl(byId, identifier, data, options);
11152
11474
  }
11153
11475
  async insertRecordById(id, data, options = {}) {
11154
- const params = createParams({
11155
- expansionLevel: options.expansionLevel
11156
- });
11157
- const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.INSERT_BY_ID(id), data, {
11158
- params,
11159
- headers: createHeaders({ [FOLDER_KEY]: options.folderKey })
11160
- });
11161
- return response.data;
11476
+ return this.insertRecordImpl(true, id, data, options);
11477
+ }
11478
+ async insertRecords(entityRef, data, options = {}) {
11479
+ const { byId, identifier } = unwrapEntityRef(entityRef, "Entities.insertRecords");
11480
+ return this.insertRecordsImpl(byId, identifier, data, options);
11162
11481
  }
11163
11482
  async insertRecordsById(id, data, options = {}) {
11164
- const params = createParams({
11165
- expansionLevel: options.expansionLevel,
11166
- failOnFirst: options.failOnFirst
11167
- });
11168
- const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.BATCH_INSERT_BY_ID(id), data, {
11169
- params,
11170
- headers: createHeaders({ [FOLDER_KEY]: options.folderKey })
11171
- });
11172
- return response.data;
11483
+ return this.insertRecordsImpl(true, id, data, options);
11484
+ }
11485
+ async updateRecord(entityRef, recordId, data, options = {}) {
11486
+ const { byId, identifier } = unwrapEntityRef(entityRef, "Entities.updateRecord");
11487
+ return this.updateRecordImpl(byId, identifier, recordId, data, options);
11173
11488
  }
11174
11489
  async updateRecordById(entityId, recordId, data, options = {}) {
11175
- const params = createParams({
11176
- expansionLevel: options.expansionLevel
11177
- });
11178
- const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPDATE_RECORD_BY_ID(entityId, recordId), data, {
11179
- params,
11180
- headers: createHeaders({ [FOLDER_KEY]: options.folderKey })
11181
- });
11182
- return response.data;
11490
+ return this.updateRecordImpl(true, entityId, recordId, data, options);
11491
+ }
11492
+ async updateRecords(entityRef, data, options = {}) {
11493
+ const { byId, identifier } = unwrapEntityRef(entityRef, "Entities.updateRecords");
11494
+ return this.updateRecordsImpl(byId, identifier, data, options);
11183
11495
  }
11184
11496
  async updateRecordsById(id, data, options = {}) {
11185
- const params = createParams({
11186
- expansionLevel: options.expansionLevel,
11187
- failOnFirst: options.failOnFirst
11188
- });
11189
- const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPDATE_BY_ID(id), data, {
11190
- params,
11191
- headers: createHeaders({ [FOLDER_KEY]: options.folderKey })
11192
- });
11193
- return response.data;
11497
+ return this.updateRecordsImpl(true, id, data, options);
11498
+ }
11499
+ async deleteRecords(entityRef, recordIds, options = {}) {
11500
+ const { byId, identifier } = unwrapEntityRef(entityRef, "Entities.deleteRecords");
11501
+ return this.deleteRecordsImpl(byId, identifier, recordIds, options);
11194
11502
  }
11195
11503
  async deleteRecordsById(id, recordIds, options = {}) {
11196
- const params = createParams({
11197
- failOnFirst: options.failOnFirst
11198
- });
11199
- const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.DELETE_BY_ID(id), recordIds, {
11200
- params,
11201
- headers: createHeaders({ [FOLDER_KEY]: options.folderKey })
11202
- });
11203
- return response.data;
11504
+ return this.deleteRecordsImpl(true, id, recordIds, options);
11505
+ }
11506
+ async deleteRecord(entityRef, recordId, options) {
11507
+ const { byId, identifier } = unwrapEntityRef(entityRef, "Entities.deleteRecord");
11508
+ return this.deleteRecordImpl(byId, identifier, recordId, options);
11204
11509
  }
11205
11510
  async deleteRecordById(entityId, recordId, options) {
11206
- await this.delete(DATA_FABRIC_ENDPOINTS.ENTITY.DELETE_RECORD_BY_ID(entityId, recordId), { headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }) });
11511
+ return this.deleteRecordImpl(true, entityId, recordId, options);
11207
11512
  }
11208
11513
  async getAll(options) {
11209
11514
  const endpoint = !options?.folderKey && options?.includeFolderEntities ? DATA_FABRIC_ENDPOINTS.ENTITY.GET_ALL_V2 : DATA_FABRIC_ENDPOINTS.ENTITY.GET_ALL;
@@ -11215,62 +11520,30 @@ class EntityService extends BaseService {
11215
11520
  });
11216
11521
  return entities;
11217
11522
  }
11523
+ async queryRecords(entityRef, options) {
11524
+ const { byId, identifier } = unwrapEntityRef(entityRef, "Entities.queryRecords");
11525
+ return this.queryRecordsImpl(byId, identifier, options);
11526
+ }
11218
11527
  async queryRecordsById(id, options) {
11219
- if (options?.joins && options.joins.length > MAX_QUERY_JOINS) {
11220
- throw new ValidationError({
11221
- message: `A maximum of ${MAX_QUERY_JOINS} joins is supported per query (received ${options.joins.length})`
11222
- });
11223
- }
11224
- if (options?.joins && options.joins.length > 0 && !options.selectedFields?.length && !options.aggregates?.length) {
11225
- throw new ValidationError({
11226
- message: 'Join queries require selectedFields or aggregates — reference fields as "<EntityName>.<FieldName>" (e.g. "Customer.name")'
11227
- });
11228
- }
11229
- const { folderKey, expansionLevel, ...rest } = options ?? {};
11230
- let getEndpoint = () => DATA_FABRIC_ENDPOINTS.ENTITY.QUERY_BY_ID(id);
11231
- if (options?.joins && options.joins.length > 0) {
11232
- const baseEntityName = await this.resolveEntityName(id, folderKey);
11233
- rest.joins = options.joins.map((join) => toWireJoin(join, baseEntityName));
11234
- getEndpoint = () => DATA_FABRIC_ENDPOINTS.ENTITY.QUERY_BY_NAME(baseEntityName);
11235
- }
11236
- const downstreamOptions = options === undefined ? undefined : rest;
11237
- return PaginationHelpers.getAll({
11238
- serviceAccess: this.createPaginationServiceAccess(),
11239
- getEndpoint,
11240
- method: HTTP_METHODS.POST,
11241
- headers: createHeaders({ [FOLDER_KEY]: folderKey }),
11242
- queryParams: createParams({ expansionLevel }),
11243
- pagination: {
11244
- paginationType: PaginationType.OFFSET,
11245
- itemsField: ENTITY_PAGINATION.ITEMS_FIELD,
11246
- totalCountField: ENTITY_PAGINATION.TOTAL_COUNT_FIELD,
11247
- paginationParams: {
11248
- pageSizeParam: ENTITY_OFFSET_PARAMS.PAGE_SIZE_PARAM,
11249
- offsetParam: ENTITY_OFFSET_PARAMS.OFFSET_PARAM,
11250
- countParam: ENTITY_OFFSET_PARAMS.COUNT_PARAM
11251
- }
11252
- },
11253
- excludeFromPrefix: ["filterGroup", "selectedFields", "sortOptions", "aggregates", "groupBy", "joins"]
11254
- }, downstreamOptions);
11528
+ return this.queryRecordsImpl(true, id, options);
11529
+ }
11530
+ async importRecords(entityRef, file, options) {
11531
+ const { byId, identifier } = unwrapEntityRef(entityRef, "Entities.importRecords");
11532
+ return this.importRecordsImpl(byId, identifier, file, options);
11255
11533
  }
11256
11534
  async importRecordsById(id, file, options) {
11257
- const formData = new FormData;
11258
- if (file instanceof Uint8Array) {
11259
- formData.append("file", new Blob([file.buffer]));
11260
- } else {
11261
- formData.append("file", file);
11262
- }
11263
- const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.BULK_UPLOAD_BY_ID(id), formData, { headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }) });
11264
- return response.data;
11535
+ return this.importRecordsImpl(true, id, file, options);
11265
11536
  }
11266
- async downloadAttachment(entityId, recordId, fieldName, options) {
11267
- const response = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.DOWNLOAD_ATTACHMENT(entityId, recordId, fieldName), {
11537
+ async downloadAttachment(entityRef, recordId, fieldName, options) {
11538
+ const { byId, identifier } = unwrapEntityRef(entityRef, "Entities.downloadAttachment");
11539
+ const response = await this.get(byId ? DATA_FABRIC_ENDPOINTS.ENTITY.DOWNLOAD_ATTACHMENT(identifier, recordId, fieldName) : DATA_FABRIC_ENDPOINTS.ENTITY.ATTACHMENT_BY_NAME(identifier, recordId, fieldName), {
11268
11540
  responseType: RESPONSE_TYPES.BLOB,
11269
11541
  headers: createHeaders({ [FOLDER_KEY]: options?.folderKey })
11270
11542
  });
11271
11543
  return response.data;
11272
11544
  }
11273
- async uploadAttachment(entityId, recordId, fieldName, file, options) {
11545
+ async uploadAttachment(entityRef, recordId, fieldName, file, options) {
11546
+ const { byId, identifier } = unwrapEntityRef(entityRef, "Entities.uploadAttachment");
11274
11547
  const formData = new FormData;
11275
11548
  if (file instanceof Uint8Array) {
11276
11549
  formData.append("file", new Blob([file.buffer]));
@@ -11278,14 +11551,15 @@ class EntityService extends BaseService {
11278
11551
  formData.append("file", file);
11279
11552
  }
11280
11553
  const params = createParams({ expansionLevel: options?.expansionLevel });
11281
- const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPLOAD_ATTACHMENT(entityId, recordId, fieldName), formData, {
11554
+ const response = await this.post(byId ? DATA_FABRIC_ENDPOINTS.ENTITY.UPLOAD_ATTACHMENT(identifier, recordId, fieldName) : DATA_FABRIC_ENDPOINTS.ENTITY.ATTACHMENT_BY_NAME(identifier, recordId, fieldName), formData, {
11282
11555
  params,
11283
11556
  headers: createHeaders({ [FOLDER_KEY]: options?.folderKey })
11284
11557
  });
11285
11558
  return response.data;
11286
11559
  }
11287
- async deleteAttachment(entityId, recordId, fieldName, options) {
11288
- const response = await this.delete(DATA_FABRIC_ENDPOINTS.ENTITY.DELETE_ATTACHMENT(entityId, recordId, fieldName), { headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }) });
11560
+ async deleteAttachment(entityRef, recordId, fieldName, options) {
11561
+ const { byId, identifier } = unwrapEntityRef(entityRef, "Entities.deleteAttachment");
11562
+ const response = await this.delete(byId ? DATA_FABRIC_ENDPOINTS.ENTITY.DELETE_ATTACHMENT(identifier, recordId, fieldName) : DATA_FABRIC_ENDPOINTS.ENTITY.ATTACHMENT_BY_NAME(identifier, recordId, fieldName), { headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }) });
11289
11563
  return response.data;
11290
11564
  }
11291
11565
  async getRecordsById(entityId, options) {
@@ -11322,11 +11596,16 @@ class EntityService extends BaseService {
11322
11596
  const opts = options ?? {};
11323
11597
  const hasSchemaChanges = !!(opts.addFields?.length || opts.removeFields?.length || opts.updateFields?.length);
11324
11598
  const hasMetadataChanges = opts.displayName !== undefined || opts.description !== undefined || opts.isRbacEnabled !== undefined;
11599
+ if (!hasSchemaChanges && !hasMetadataChanges) {
11600
+ throw new ValidationError({
11601
+ message: "updateById requires at least one change — pass addFields, removeFields, updateFields, displayName, description, or isRbacEnabled."
11602
+ });
11603
+ }
11325
11604
  if (hasSchemaChanges) {
11326
11605
  await this.applySchemaUpdate(id, opts);
11327
11606
  }
11328
11607
  if (hasMetadataChanges) {
11329
- await this.patch(DATA_FABRIC_ENDPOINTS.ENTITY.UPDATE_METADATA(id), {
11608
+ await this.patch(DATA_FABRIC_ENDPOINTS.ENTITY.UPDATE(id), {
11330
11609
  ...opts.displayName !== undefined && { displayName: opts.displayName },
11331
11610
  ...opts.description !== undefined && { description: opts.description },
11332
11611
  ...opts.isRbacEnabled !== undefined && { isRbacEnabled: opts.isRbacEnabled }
@@ -11339,10 +11618,24 @@ class EntityService extends BaseService {
11339
11618
  const raw = entityResponse.data;
11340
11619
  let fields = (raw.fields ?? []).filter((f) => !f.isSystemField && !f.isPrimaryKey);
11341
11620
  if (options.removeFields?.length) {
11621
+ const existingNames = new Set(fields.map((f) => f.name));
11622
+ const missing = options.removeFields.filter((r) => !existingNames.has(r.name)).map((r) => r.name);
11623
+ if (missing.length) {
11624
+ throw new ValidationError({
11625
+ message: `Cannot remove field(s) — no matching non-system field found for name(s): ${missing.join(", ")}.`
11626
+ });
11627
+ }
11342
11628
  const removeSet = new Set(options.removeFields.map((r) => r.name));
11343
11629
  fields = fields.filter((f) => !removeSet.has(f.name));
11344
11630
  }
11345
11631
  if (options.updateFields?.length) {
11632
+ const existingIds = new Set(fields.map((f) => f.id));
11633
+ const missing = options.updateFields.filter((u) => !existingIds.has(u.id)).map((u) => u.id);
11634
+ if (missing.length) {
11635
+ throw new ValidationError({
11636
+ message: `Cannot update field(s) — no matching non-system field found for id(s): ${missing.join(", ")}.`
11637
+ });
11638
+ }
11346
11639
  const updateMap = new Map(options.updateFields.map((u) => [u.id, u]));
11347
11640
  fields = fields.map((f) => {
11348
11641
  const update = updateMap.get(f.id ?? "");
@@ -11592,40 +11885,185 @@ class EntityService extends BaseService {
11592
11885
  return {};
11593
11886
  }
11594
11887
  }
11595
- }
11596
- __decorate([
11597
- track("Entities.GetById")
11888
+ async fetchEntityMetadata(endpoint, folderKey) {
11889
+ const response = await this.get(endpoint, { headers: createHeaders({ [FOLDER_KEY]: folderKey }) });
11890
+ const metadata = transformData(response.data, EntityMap);
11891
+ this.applyFieldMappings(metadata);
11892
+ return createEntityWithMethods(metadata, this);
11893
+ }
11894
+ getRecordsImpl(byId, identifier, options) {
11895
+ const { folderKey, ...rest } = options ?? {};
11896
+ const downstreamOptions = options === undefined ? undefined : rest;
11897
+ return PaginationHelpers.getAll({
11898
+ serviceAccess: this.createPaginationServiceAccess(),
11899
+ getEndpoint: () => byId ? DATA_FABRIC_ENDPOINTS.ENTITY.GET_ENTITY_RECORDS(identifier) : DATA_FABRIC_ENDPOINTS.ENTITY.GET_ENTITY_RECORDS_BY_NAME(identifier),
11900
+ headers: createHeaders({ [FOLDER_KEY]: folderKey }),
11901
+ pagination: {
11902
+ paginationType: PaginationType.OFFSET,
11903
+ itemsField: ENTITY_PAGINATION.ITEMS_FIELD,
11904
+ totalCountField: ENTITY_PAGINATION.TOTAL_COUNT_FIELD,
11905
+ paginationParams: {
11906
+ pageSizeParam: ENTITY_OFFSET_PARAMS.PAGE_SIZE_PARAM,
11907
+ offsetParam: ENTITY_OFFSET_PARAMS.OFFSET_PARAM,
11908
+ countParam: ENTITY_OFFSET_PARAMS.COUNT_PARAM
11909
+ }
11910
+ },
11911
+ excludeFromPrefix: ["expansionLevel"]
11912
+ }, downstreamOptions);
11913
+ }
11914
+ async getRecordImpl(byId, identifier, recordId, options) {
11915
+ const params = createParams({ expansionLevel: options.expansionLevel });
11916
+ const response = await this.get(byId ? DATA_FABRIC_ENDPOINTS.ENTITY.GET_RECORD_BY_ID(identifier, recordId) : DATA_FABRIC_ENDPOINTS.ENTITY.GET_RECORD_BY_NAME(identifier, recordId), { params, headers: createHeaders({ [FOLDER_KEY]: options.folderKey }) });
11917
+ return response.data;
11918
+ }
11919
+ async insertRecordImpl(byId, identifier, data, options) {
11920
+ const params = createParams({ expansionLevel: options.expansionLevel });
11921
+ const response = await this.post(byId ? DATA_FABRIC_ENDPOINTS.ENTITY.INSERT_BY_ID(identifier) : DATA_FABRIC_ENDPOINTS.ENTITY.INSERT_BY_NAME(identifier), data, { params, headers: createHeaders({ [FOLDER_KEY]: options.folderKey }) });
11922
+ return response.data;
11923
+ }
11924
+ async insertRecordsImpl(byId, identifier, data, options) {
11925
+ const params = createParams({ expansionLevel: options.expansionLevel, failOnFirst: options.failOnFirst });
11926
+ const response = await this.post(byId ? DATA_FABRIC_ENDPOINTS.ENTITY.BATCH_INSERT_BY_ID(identifier) : DATA_FABRIC_ENDPOINTS.ENTITY.BATCH_INSERT_BY_NAME(identifier), data, { params, headers: createHeaders({ [FOLDER_KEY]: options.folderKey }) });
11927
+ return response.data;
11928
+ }
11929
+ async updateRecordImpl(byId, identifier, recordId, data, options) {
11930
+ const params = createParams({ expansionLevel: options.expansionLevel });
11931
+ const response = await this.post(byId ? DATA_FABRIC_ENDPOINTS.ENTITY.UPDATE_RECORD_BY_ID(identifier, recordId) : DATA_FABRIC_ENDPOINTS.ENTITY.UPDATE_RECORD_BY_NAME(identifier, recordId), data, { params, headers: createHeaders({ [FOLDER_KEY]: options.folderKey }) });
11932
+ return response.data;
11933
+ }
11934
+ async updateRecordsImpl(byId, identifier, data, options) {
11935
+ const params = createParams({ expansionLevel: options.expansionLevel, failOnFirst: options.failOnFirst });
11936
+ 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
+ return response.data;
11938
+ }
11939
+ async deleteRecordsImpl(byId, identifier, recordIds, options) {
11940
+ const params = createParams({ failOnFirst: options.failOnFirst });
11941
+ 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 }) });
11942
+ return response.data;
11943
+ }
11944
+ async deleteRecordImpl(byId, identifier, recordId, options) {
11945
+ await this.delete(byId ? DATA_FABRIC_ENDPOINTS.ENTITY.DELETE_RECORD_BY_ID(identifier, recordId) : DATA_FABRIC_ENDPOINTS.ENTITY.DELETE_RECORD_BY_NAME(identifier, recordId), { headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }) });
11946
+ }
11947
+ async queryRecordsImpl(byId, identifier, options) {
11948
+ if (options?.joins && options.joins.length > MAX_QUERY_JOINS) {
11949
+ throw new ValidationError({
11950
+ message: `A maximum of ${MAX_QUERY_JOINS} joins is supported per query (received ${options.joins.length})`
11951
+ });
11952
+ }
11953
+ if (options?.joins && options.joins.length > 0 && !options.selectedFields?.length && !options.aggregates?.length) {
11954
+ throw new ValidationError({
11955
+ message: 'Join queries require selectedFields or aggregates — reference fields as "<EntityName>.<FieldName>" (e.g. "Customer.name")'
11956
+ });
11957
+ }
11958
+ if (options?.havingFilter && (!options.aggregates?.length || !options.groupBy?.length)) {
11959
+ throw new ValidationError({
11960
+ message: "havingFilter requires aggregates and groupBy — conditions reference declared aggregate aliases; use filterGroup for row-level conditions"
11961
+ });
11962
+ }
11963
+ const { folderKey, expansionLevel, ...rest } = options ?? {};
11964
+ let getEndpoint = () => byId ? DATA_FABRIC_ENDPOINTS.ENTITY.QUERY_BY_ID(identifier) : DATA_FABRIC_ENDPOINTS.ENTITY.QUERY_BY_NAME(identifier);
11965
+ if (options?.joins && options.joins.length > 0) {
11966
+ const baseEntityName = byId ? await this.resolveEntityName(identifier, folderKey) : identifier;
11967
+ rest.joins = options.joins.map((join) => toWireJoin(join, baseEntityName));
11968
+ getEndpoint = () => DATA_FABRIC_ENDPOINTS.ENTITY.QUERY_BY_NAME(baseEntityName);
11969
+ }
11970
+ const downstreamOptions = options === undefined ? undefined : rest;
11971
+ return PaginationHelpers.getAll({
11972
+ serviceAccess: this.createPaginationServiceAccess(),
11973
+ getEndpoint,
11974
+ method: HTTP_METHODS.POST,
11975
+ headers: createHeaders({ [FOLDER_KEY]: folderKey }),
11976
+ queryParams: createParams({ expansionLevel }),
11977
+ pagination: {
11978
+ paginationType: PaginationType.OFFSET,
11979
+ itemsField: ENTITY_PAGINATION.ITEMS_FIELD,
11980
+ totalCountField: ENTITY_PAGINATION.TOTAL_COUNT_FIELD,
11981
+ paginationParams: {
11982
+ pageSizeParam: ENTITY_OFFSET_PARAMS.PAGE_SIZE_PARAM,
11983
+ offsetParam: ENTITY_OFFSET_PARAMS.OFFSET_PARAM,
11984
+ countParam: ENTITY_OFFSET_PARAMS.COUNT_PARAM
11985
+ }
11986
+ },
11987
+ excludeFromPrefix: ["filterGroup", "selectedFields", "sortOptions", "aggregates", "groupBy", "joins", "havingFilter"]
11988
+ }, downstreamOptions);
11989
+ }
11990
+ async importRecordsImpl(byId, identifier, file, options) {
11991
+ const formData = new FormData;
11992
+ if (file instanceof Uint8Array) {
11993
+ formData.append("file", new Blob([file.buffer]));
11994
+ } else {
11995
+ formData.append("file", file);
11996
+ }
11997
+ const response = await this.post(byId ? DATA_FABRIC_ENDPOINTS.ENTITY.BULK_UPLOAD_BY_ID(identifier) : DATA_FABRIC_ENDPOINTS.ENTITY.BULK_UPLOAD_BY_NAME(identifier), formData, { headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }) });
11998
+ return response.data;
11999
+ }
12000
+ }
12001
+ __decorate([
12002
+ track("Entities.GetById")
11598
12003
  ], EntityService.prototype, "getById", null);
12004
+ __decorate([
12005
+ track("Entities.GetByName")
12006
+ ], EntityService.prototype, "getByName", null);
11599
12007
  __decorate([
11600
12008
  track("Entities.GetAllRecords")
11601
12009
  ], EntityService.prototype, "getAllRecords", null);
12010
+ __decorate([
12011
+ track("Entities.GetRecordsByName")
12012
+ ], EntityService.prototype, "getRecordsByName", null);
11602
12013
  __decorate([
11603
12014
  track("Entities.GetRecordById")
11604
12015
  ], EntityService.prototype, "getRecordById", null);
12016
+ __decorate([
12017
+ track("Entities.GetRecordByName")
12018
+ ], EntityService.prototype, "getRecordByName", null);
12019
+ __decorate([
12020
+ track("Entities.InsertRecord")
12021
+ ], EntityService.prototype, "insertRecord", null);
11605
12022
  __decorate([
11606
12023
  track("Entities.InsertRecordById")
11607
12024
  ], EntityService.prototype, "insertRecordById", null);
12025
+ __decorate([
12026
+ track("Entities.InsertRecords")
12027
+ ], EntityService.prototype, "insertRecords", null);
11608
12028
  __decorate([
11609
12029
  track("Entities.InsertRecordsById")
11610
12030
  ], EntityService.prototype, "insertRecordsById", null);
12031
+ __decorate([
12032
+ track("Entities.UpdateRecord")
12033
+ ], EntityService.prototype, "updateRecord", null);
11611
12034
  __decorate([
11612
12035
  track("Entities.UpdateRecordById")
11613
12036
  ], EntityService.prototype, "updateRecordById", null);
12037
+ __decorate([
12038
+ track("Entities.UpdateRecords")
12039
+ ], EntityService.prototype, "updateRecords", null);
11614
12040
  __decorate([
11615
12041
  track("Entities.UpdateRecordsById")
11616
12042
  ], EntityService.prototype, "updateRecordsById", null);
12043
+ __decorate([
12044
+ track("Entities.DeleteRecords")
12045
+ ], EntityService.prototype, "deleteRecords", null);
11617
12046
  __decorate([
11618
12047
  track("Entities.DeleteRecordsById")
11619
12048
  ], EntityService.prototype, "deleteRecordsById", null);
12049
+ __decorate([
12050
+ track("Entities.DeleteRecord")
12051
+ ], EntityService.prototype, "deleteRecord", null);
11620
12052
  __decorate([
11621
12053
  track("Entities.DeleteRecordById")
11622
12054
  ], EntityService.prototype, "deleteRecordById", null);
11623
12055
  __decorate([
11624
12056
  track("Entities.GetAll")
11625
12057
  ], EntityService.prototype, "getAll", null);
12058
+ __decorate([
12059
+ track("Entities.QueryRecords")
12060
+ ], EntityService.prototype, "queryRecords", null);
11626
12061
  __decorate([
11627
12062
  track("Entities.QueryRecordsById")
11628
12063
  ], EntityService.prototype, "queryRecordsById", null);
12064
+ __decorate([
12065
+ track("Entities.ImportRecords")
12066
+ ], EntityService.prototype, "importRecords", null);
11629
12067
  __decorate([
11630
12068
  track("Entities.ImportRecordsById")
11631
12069
  ], EntityService.prototype, "importRecordsById", null);
@@ -13069,6 +13507,74 @@ function validateName(resourceType, name) {
13069
13507
  }
13070
13508
  return trimmed;
13071
13509
  }
13510
+ 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
+ }
13072
13578
  var SINGLE_QUOTE_RE = /'/g;
13073
13579
 
13074
13580
  class FolderScopedService extends BaseService {
@@ -13085,20 +13591,23 @@ class FolderScopedService extends BaseService {
13085
13591
  }
13086
13592
  return response.data?.value;
13087
13593
  }
13088
- async getByNameLookup(resourceType, endpoint, name, options, transform2, responseFieldMap) {
13594
+ async getByNameLookup(resourceType, endpoint, name, options, transform2, responseFieldMap, callerLabel) {
13089
13595
  const validatedName = validateName(resourceType, name);
13090
13596
  const { folderId, folderKey, folderPath, ...queryOptions } = options;
13597
+ const override = resolveOverride(resourceType, validatedName, folderPath);
13598
+ const resolvedName = override?.name ?? validatedName;
13599
+ const resolvedFolderPath = override?.folderPath ?? folderPath;
13091
13600
  const headers = resolveFolderHeaders({
13092
13601
  folderId,
13093
13602
  folderKey,
13094
- folderPath,
13095
- resourceType: `${resourceType}.getByName`,
13603
+ folderPath: resolvedFolderPath,
13604
+ resourceType: callerLabel ?? `${resourceType}.getByName`,
13096
13605
  fallbackFolderKey: this.config.folderKey
13097
13606
  });
13098
13607
  const apiFieldOptions = responseFieldMap ? transformOptions(queryOptions, responseFieldMap) : queryOptions;
13099
13608
  const apiOptions = {
13100
13609
  ...addPrefixToKeys(apiFieldOptions, ODATA_PREFIX, Object.keys(apiFieldOptions)),
13101
- $filter: `Name eq '${validatedName.replace(SINGLE_QUOTE_RE, "''")}'`,
13610
+ $filter: `Name eq '${resolvedName.replace(SINGLE_QUOTE_RE, "''")}'`,
13102
13611
  $top: "1"
13103
13612
  };
13104
13613
  const response = await this.get(endpoint, {
@@ -13107,12 +13616,48 @@ class FolderScopedService extends BaseService {
13107
13616
  });
13108
13617
  const items = response.data?.value;
13109
13618
  if (!items?.length) {
13110
- const folderHint = describeFolderForError(folderId, folderKey, folderPath);
13619
+ const folderHint = describeFolderForError(folderId, folderKey, resolvedFolderPath);
13111
13620
  throw new NotFoundError({
13112
- message: `${resourceType} '${validatedName}' not found${folderHint}.`
13621
+ message: `${resourceType} '${resolvedName}' not found${folderHint}.`
13113
13622
  });
13114
13623
  }
13115
- return transform2(items[0]);
13624
+ return {
13625
+ result: transform2(items[0]),
13626
+ effectiveFolder: { folderId, folderKey, folderPath: resolvedFolderPath }
13627
+ };
13628
+ }
13629
+ async getByKeyLookup(resourceType, endpoint, key, options, transform2, responseFieldMap, callerLabel) {
13630
+ const label = callerLabel ?? `${resourceType}.getByKey`;
13631
+ const trimmedKey = key?.trim();
13632
+ if (!trimmedKey || !GUID_REGEX.test(trimmedKey)) {
13633
+ throw new ValidationError({ message: `${label}: key must be a GUID.` });
13634
+ }
13635
+ const { folderId, folderKey, folderPath, ...queryOptions } = options;
13636
+ const headers = resolveFolderHeaders({
13637
+ folderId,
13638
+ folderKey,
13639
+ folderPath,
13640
+ resourceType: label,
13641
+ fallbackFolderKey: this.config.folderKey
13642
+ });
13643
+ const apiFieldOptions = responseFieldMap ? transformOptions(queryOptions, responseFieldMap) : queryOptions;
13644
+ const apiOptions = {
13645
+ ...addPrefixToKeys(apiFieldOptions, ODATA_PREFIX, Object.keys(apiFieldOptions)),
13646
+ $filter: `Key eq ${trimmedKey}`,
13647
+ $top: "1"
13648
+ };
13649
+ const response = await this.get(endpoint, {
13650
+ headers,
13651
+ params: apiOptions
13652
+ });
13653
+ const items = response.data?.value;
13654
+ if (!items?.length) {
13655
+ throw new NotFoundError({ message: `${resourceType} with key '${trimmedKey}' not found.` });
13656
+ }
13657
+ return {
13658
+ result: transform2(items[0]),
13659
+ effectiveFolder: { folderId, folderKey, folderPath }
13660
+ };
13116
13661
  }
13117
13662
  }
13118
13663
  function describeFolderForError(folderId, folderKey, folderPath) {
@@ -13143,12 +13688,16 @@ class TaskService extends FolderScopedService {
13143
13688
  };
13144
13689
  }
13145
13690
  async create(task, folderId) {
13691
+ if (task.type === TaskType.QuickForm && !task.taskSchemaKey) {
13692
+ throw new ValidationError({ message: "taskSchemaKey is required when creating a QuickForm task." });
13693
+ }
13146
13694
  const headers = createHeaders({ [FOLDER_ID]: folderId });
13147
- const externalTask = {
13148
- ...task,
13149
- type: TaskType.External
13150
- };
13151
- const response = await this.post(TASK_ENDPOINTS.CREATE_GENERIC_TASK, externalTask, { headers });
13695
+ const { labels, type, ...rest } = task;
13696
+ const payload = { ...rest, type: type ?? TaskType.External };
13697
+ if (labels?.length) {
13698
+ payload.tags = labels.map((label) => ({ name: label, displayName: label, displayValue: label }));
13699
+ }
13700
+ const response = await this.post(TASK_ENDPOINTS.CREATE_GENERIC_TASK, payload, { headers });
13152
13701
  const normalizedData = transformData(response.data, TaskMap);
13153
13702
  const transformedData = applyDataTransforms(normalizedData, { field: "status", valueMap: TaskStatusMap });
13154
13703
  return createTaskWithMethods(transformedData, this);
@@ -13780,6 +14329,35 @@ var AssetValueType;
13780
14329
  AssetValueType2["Credential"] = "Credential";
13781
14330
  AssetValueType2["Secret"] = "Secret";
13782
14331
  })(AssetValueType || (AssetValueType = {}));
14332
+ async function resolveRefToId(ref, resolvers, callerLabel) {
14333
+ if (!ref) {
14334
+ throw new ValidationError({
14335
+ message: `${callerLabel}: ref must supply exactly one of 'id', 'name', or 'key'.`
14336
+ });
14337
+ }
14338
+ if ("id" in ref && ref.id != null) {
14339
+ return { id: ref.id, effectiveFolder: {} };
14340
+ }
14341
+ const stringVariants = [
14342
+ { variant: "name", resolver: resolvers.byName },
14343
+ { variant: "key", resolver: resolvers.byKey }
14344
+ ];
14345
+ for (const { variant, resolver } of stringVariants) {
14346
+ const value = ref[variant];
14347
+ if (!value)
14348
+ continue;
14349
+ if (!resolver) {
14350
+ throw new ValidationError({
14351
+ message: `${callerLabel}: this method does not support lookup by '${variant}'.`
14352
+ });
14353
+ }
14354
+ const { id, folderId, folderKey, folderPath } = await resolver(value);
14355
+ return { id, effectiveFolder: { folderId, folderKey, folderPath } };
14356
+ }
14357
+ throw new ValidationError({
14358
+ message: `${callerLabel}: ref must supply exactly one of 'id', 'name', or 'key'.`
14359
+ });
14360
+ }
13783
14361
  var AssetMap = {
13784
14362
  creationTime: "createdTime",
13785
14363
  lastModificationTime: "lastModifiedTime"
@@ -13818,7 +14396,41 @@ class AssetService extends FolderScopedService {
13818
14396
  return transformedAsset;
13819
14397
  }
13820
14398
  async getByName(name, options = {}) {
13821
- return this.getByNameLookup("Asset", ASSET_ENDPOINTS.GET_BY_FOLDER, name, options, (raw) => transformData(pascalToCamelCaseKeys(raw), AssetMap), AssetMap);
14399
+ const { result } = await this.getByNameLookup("Asset", ASSET_ENDPOINTS.GET_BY_FOLDER, name, options, (raw) => transformData(pascalToCamelCaseKeys(raw), AssetMap), AssetMap);
14400
+ return result;
14401
+ }
14402
+ async getByKey(key, options = {}) {
14403
+ const { result } = await this.getByKeyLookup("Asset", ASSET_ENDPOINTS.GET_BY_FOLDER, key, options, (raw) => transformData(pascalToCamelCaseKeys(raw), AssetMap), AssetMap);
14404
+ return result;
14405
+ }
14406
+ async updateValue(assetRef, newValue, options) {
14407
+ if (newValue === null || newValue === undefined) {
14408
+ throw new ValidationError({ message: "newValue is required for updateValue" });
14409
+ }
14410
+ let preFetched;
14411
+ const { id, effectiveFolder } = await resolveRefToId(assetRef, {
14412
+ byName: async (name) => {
14413
+ const { result: asset, effectiveFolder: folder } = await this.getByNameLookup("Asset", ASSET_ENDPOINTS.GET_BY_FOLDER, name, { folderId: options?.folderId, folderKey: options?.folderKey, folderPath: options?.folderPath }, (raw) => transformData(pascalToCamelCaseKeys(raw), AssetMap), AssetMap, "Assets.updateValue");
14414
+ preFetched = asset;
14415
+ return { id: asset.id, ...folder };
14416
+ },
14417
+ byKey: async (key) => {
14418
+ const { result: asset, effectiveFolder: folder } = await this.getByKeyLookup("Asset", ASSET_ENDPOINTS.GET_BY_FOLDER, key, { folderId: options?.folderId, folderKey: options?.folderKey, folderPath: options?.folderPath }, (raw) => transformData(pascalToCamelCaseKeys(raw), AssetMap), AssetMap, "Assets.updateValue");
14419
+ preFetched = asset;
14420
+ return { id: asset.id, ...folder };
14421
+ }
14422
+ }, "Assets.updateValue");
14423
+ if (id <= 0) {
14424
+ throw new ValidationError({ message: "Assets.updateValue: assetRef.id must be a positive number." });
14425
+ }
14426
+ const headers = resolveFolderHeaders({
14427
+ folderId: effectiveFolder.folderId ?? options?.folderId,
14428
+ folderKey: effectiveFolder.folderKey ?? options?.folderKey,
14429
+ folderPath: effectiveFolder.folderPath ?? options?.folderPath,
14430
+ resourceType: "Assets.updateValue",
14431
+ fallbackFolderKey: this.config.folderKey
14432
+ });
14433
+ await this.updateValueByResolvedId(id, newValue, headers, preFetched);
13822
14434
  }
13823
14435
  async updateValueById(id, newValue, options) {
13824
14436
  if (!id) {
@@ -13834,19 +14446,30 @@ class AssetService extends FolderScopedService {
13834
14446
  resourceType: "Assets.updateValueById",
13835
14447
  fallbackFolderKey: this.config.folderKey
13836
14448
  });
13837
- const existingResponse = await this.get(ASSET_ENDPOINTS.GET_BY_ID(id), { headers });
13838
- const existing = existingResponse.data;
13839
- const valueField = resolveValueField(id, existing.ValueType, newValue);
14449
+ await this.updateValueByResolvedId(id, newValue, headers);
14450
+ }
14451
+ async updateValueByResolvedId(id, newValue, headers, preFetched) {
14452
+ const shape = preFetched ?? await this.fetchAssetShape(id, headers);
14453
+ const valueField = resolveValueField(id, shape.valueType, newValue);
13840
14454
  const body = {
13841
14455
  Id: id,
13842
- Name: existing.Name,
13843
- ValueScope: existing.ValueScope,
13844
- ValueType: existing.ValueType,
13845
- Description: existing.Description,
14456
+ Name: shape.name,
14457
+ ValueScope: shape.valueScope,
14458
+ ValueType: shape.valueType,
14459
+ Description: shape.description,
13846
14460
  [valueField]: newValue
13847
14461
  };
13848
14462
  await this.put(ASSET_ENDPOINTS.GET_BY_ID(id), body, { headers });
13849
14463
  }
14464
+ async fetchAssetShape(id, headers) {
14465
+ const response = await this.get(ASSET_ENDPOINTS.GET_BY_ID(id), { headers });
14466
+ return {
14467
+ name: response.data.Name,
14468
+ valueScope: response.data.ValueScope,
14469
+ valueType: response.data.ValueType,
14470
+ description: response.data.Description
14471
+ };
14472
+ }
13850
14473
  }
13851
14474
  __decorate([
13852
14475
  track("Assets.GetAll")
@@ -13857,6 +14480,12 @@ __decorate([
13857
14480
  __decorate([
13858
14481
  track("Assets.GetByName")
13859
14482
  ], AssetService.prototype, "getByName", null);
14483
+ __decorate([
14484
+ track("Assets.GetByKey")
14485
+ ], AssetService.prototype, "getByKey", null);
14486
+ __decorate([
14487
+ track("Assets.UpdateValue")
14488
+ ], AssetService.prototype, "updateValue", null);
13860
14489
  __decorate([
13861
14490
  track("Assets.UpdateValueById")
13862
14491
  ], AssetService.prototype, "updateValueById", null);
@@ -13885,7 +14514,7 @@ function resolveValueField(id, valueType, newValue) {
13885
14514
  return "BoolValue";
13886
14515
  default:
13887
14516
  throw new ValidationError({
13888
- message: `updateValueById only supports Text, Integer, or Bool assets; asset ${id} has valueType ${valueType}`
14517
+ message: `Asset ${id} has valueType ${valueType}; only Text, Integer, and Bool are supported`
13889
14518
  });
13890
14519
  }
13891
14520
  }
@@ -13913,7 +14542,8 @@ class BucketService extends FolderScopedService {
13913
14542
  return pascalToCamelCaseKeys(response.data);
13914
14543
  }
13915
14544
  async getByName(name, options = {}) {
13916
- return this.getByNameLookup("Bucket", BUCKET_ENDPOINTS.GET_BY_FOLDER, name, options, (raw) => pascalToCamelCaseKeys(raw));
14545
+ const { result } = await this.getByNameLookup("Bucket", BUCKET_ENDPOINTS.GET_BY_FOLDER, name, options, (raw) => pascalToCamelCaseKeys(raw));
14546
+ return result;
13917
14547
  }
13918
14548
  async getAll(options) {
13919
14549
  const transformBucketResponse = (bucket) => pascalToCamelCaseKeys(bucket);
@@ -14780,7 +15410,8 @@ class ProcessService extends FolderScopedService {
14780
15410
  return transformedProcess;
14781
15411
  }
14782
15412
  async getByName(name, options = {}) {
14783
- return this.getByNameLookup("Process", PROCESS_ENDPOINTS.GET_ALL, name, options, (raw) => transformData(pascalToCamelCaseKeys(raw), ProcessMap), ProcessMap);
15413
+ const { result } = await this.getByNameLookup("Process", PROCESS_ENDPOINTS.GET_ALL, name, options, (raw) => transformData(pascalToCamelCaseKeys(raw), ProcessMap), ProcessMap);
15414
+ return result;
14784
15415
  }
14785
15416
  }
14786
15417
  __decorate([
@@ -14795,21 +15426,112 @@ __decorate([
14795
15426
  __decorate([
14796
15427
  track("Processes.GetByName")
14797
15428
  ], ProcessService.prototype, "getByName", null);
15429
+ var QueuePriority;
15430
+ (function(QueuePriority2) {
15431
+ QueuePriority2["High"] = "High";
15432
+ QueuePriority2["Normal"] = "Normal";
15433
+ QueuePriority2["Low"] = "Low";
15434
+ })(QueuePriority || (QueuePriority = {}));
15435
+ var QueueItemStatus;
15436
+ (function(QueueItemStatus2) {
15437
+ QueueItemStatus2["New"] = "New";
15438
+ QueueItemStatus2["InProgress"] = "InProgress";
15439
+ QueueItemStatus2["Failed"] = "Failed";
15440
+ QueueItemStatus2["Successful"] = "Successful";
15441
+ QueueItemStatus2["Abandoned"] = "Abandoned";
15442
+ QueueItemStatus2["Retried"] = "Retried";
15443
+ QueueItemStatus2["Deleted"] = "Deleted";
15444
+ })(QueueItemStatus || (QueueItemStatus = {}));
15445
+ var QueueItemReviewStatus;
15446
+ (function(QueueItemReviewStatus2) {
15447
+ QueueItemReviewStatus2["None"] = "None";
15448
+ QueueItemReviewStatus2["InReview"] = "InReview";
15449
+ QueueItemReviewStatus2["Verified"] = "Verified";
15450
+ QueueItemReviewStatus2["Retried"] = "Retried";
15451
+ })(QueueItemReviewStatus || (QueueItemReviewStatus = {}));
15452
+ var QueueExceptionType;
15453
+ (function(QueueExceptionType2) {
15454
+ QueueExceptionType2["ApplicationException"] = "ApplicationException";
15455
+ QueueExceptionType2["BusinessException"] = "BusinessException";
15456
+ })(QueueExceptionType || (QueueExceptionType = {}));
15457
+ var QueueTransactionOutcome;
15458
+ (function(QueueTransactionOutcome2) {
15459
+ QueueTransactionOutcome2["Successful"] = "Successful";
15460
+ QueueTransactionOutcome2["Failed"] = "Failed";
15461
+ })(QueueTransactionOutcome || (QueueTransactionOutcome = {}));
15462
+ function createQueueMethods(queueData, service) {
15463
+ return {
15464
+ async getAllItems(options) {
15465
+ if (!queueData.id)
15466
+ throw new ValidationError({ message: "Queue ID is undefined" });
15467
+ if (!queueData.folderId)
15468
+ throw new ValidationError({ message: "Folder ID is undefined" });
15469
+ return service.getAllItems(queueData.id, { ...options, folderId: queueData.folderId });
15470
+ },
15471
+ async insertItem(specificData, options) {
15472
+ if (!queueData.name)
15473
+ throw new ValidationError({ message: "Queue name is undefined" });
15474
+ if (!queueData.folderId)
15475
+ throw new ValidationError({ message: "Folder ID is undefined" });
15476
+ return service.insertItemByName(queueData.name, specificData, { ...options, folderId: queueData.folderId });
15477
+ },
15478
+ async startTransaction() {
15479
+ if (!queueData.name)
15480
+ throw new ValidationError({ message: "Queue name is undefined" });
15481
+ if (!queueData.folderId)
15482
+ throw new ValidationError({ message: "Folder ID is undefined" });
15483
+ return service.startTransaction({ name: queueData.name }, { folderId: queueData.folderId });
15484
+ },
15485
+ async completeTransaction(itemId, outcome, options) {
15486
+ if (!queueData.folderId)
15487
+ throw new ValidationError({ message: "Folder ID is undefined" });
15488
+ return service.completeTransaction(itemId, outcome, { ...options, folderId: queueData.folderId });
15489
+ }
15490
+ };
15491
+ }
15492
+ function createQueueWithMethods(queueData, service) {
15493
+ return Object.assign({}, queueData, createQueueMethods(queueData, service));
15494
+ }
14798
15495
  var QueueMap = {
14799
15496
  creationTime: "createdTime",
14800
15497
  organizationUnitId: "folderId",
14801
15498
  organizationUnitFullyQualifiedName: "folderName"
14802
15499
  };
15500
+ var QueueItemMap = {
15501
+ queueDefinitionId: "queueId",
15502
+ creationTime: "createdTime",
15503
+ organizationUnitId: "folderId",
15504
+ organizationUnitFullyQualifiedName: "folderName",
15505
+ startProcessing: "processingStartTime",
15506
+ endProcessing: "processingEndTime",
15507
+ processingException: "processingError"
15508
+ };
15509
+ var QueueItemProcessingErrorMap = {
15510
+ creationTime: "createdTime"
15511
+ };
15512
+ function transformQueueItem(queueItem) {
15513
+ const { SpecificContent, Output, SpecificData: _sd, OutputData: _od, ...rest } = queueItem;
15514
+ const transformed = transformData(pascalToCamelCaseKeys(rest), QueueItemMap);
15515
+ if (transformed.processingError) {
15516
+ transformed.processingError = transformData(transformed.processingError, QueueItemProcessingErrorMap);
15517
+ }
15518
+ transformed.specificData = SpecificContent ?? null;
15519
+ transformed.outputData = Output ?? null;
15520
+ return transformed;
15521
+ }
14803
15522
 
14804
15523
  class QueueService extends FolderScopedService {
14805
15524
  async getAll(options) {
14806
- const transformQueueResponse = (queue) => transformData(pascalToCamelCaseKeys(queue), QueueMap);
14807
- const apiOptions = options ? transformOptions(options, QueueMap) : options;
15525
+ const { folderId, folderKey, folderPath, ...queryOptions } = options ?? {};
15526
+ const hasFolderScope = folderId !== undefined || !!folderKey?.trim() || !!folderPath?.trim();
15527
+ const headers = hasFolderScope ? resolveFolderHeaders({ folderId, folderKey, folderPath, resourceType: "Queues.getAll" }) : undefined;
15528
+ const apiOptions = transformOptions(queryOptions, QueueMap);
14808
15529
  return PaginationHelpers.getAll({
14809
15530
  serviceAccess: this.createPaginationServiceAccess(),
14810
- getEndpoint: (folderId) => folderId ? QUEUE_ENDPOINTS.GET_BY_FOLDER : QUEUE_ENDPOINTS.GET_ALL,
15531
+ getEndpoint: () => hasFolderScope ? QUEUE_ENDPOINTS.GET_BY_FOLDER : QUEUE_ENDPOINTS.GET_ALL,
14811
15532
  getByFolderEndpoint: QUEUE_ENDPOINTS.GET_BY_FOLDER,
14812
- transformFn: transformQueueResponse,
15533
+ headers,
15534
+ transformFn: (queue) => createQueueWithMethods(transformData(pascalToCamelCaseKeys(queue), QueueMap), this),
14813
15535
  pagination: {
14814
15536
  paginationType: PaginationType.OFFSET,
14815
15537
  itemsField: ODATA_PAGINATION.ITEMS_FIELD,
@@ -14822,15 +15544,176 @@ class QueueService extends FolderScopedService {
14822
15544
  }
14823
15545
  }, apiOptions);
14824
15546
  }
14825
- async getById(id, folderId, options = {}) {
14826
- const headers = createHeaders({ [FOLDER_ID]: folderId });
14827
- const apiFieldOptions = transformOptions(options, QueueMap);
15547
+ async getById(id, folderIdOrOptions, options = {}) {
15548
+ if (typeof folderIdOrOptions === "number") {
15549
+ const headers2 = createHeaders({ [FOLDER_ID]: folderIdOrOptions });
15550
+ const apiFieldOptions2 = transformOptions(options, QueueMap);
15551
+ const apiOptions2 = addPrefixToKeys(apiFieldOptions2, ODATA_PREFIX, Object.keys(apiFieldOptions2));
15552
+ const response2 = await this.get(QUEUE_ENDPOINTS.GET_BY_ID(id), {
15553
+ headers: headers2,
15554
+ params: apiOptions2
15555
+ });
15556
+ return transformData(pascalToCamelCaseKeys(response2.data), QueueMap);
15557
+ }
15558
+ const { folderId, folderKey, folderPath, ...queryOptions } = folderIdOrOptions ?? {};
15559
+ const headers = resolveFolderHeaders({
15560
+ folderId,
15561
+ folderKey,
15562
+ folderPath,
15563
+ resourceType: "Queues.getById",
15564
+ fallbackFolderKey: this.config.folderKey
15565
+ });
15566
+ const apiFieldOptions = transformOptions(queryOptions, QueueMap);
14828
15567
  const apiOptions = addPrefixToKeys(apiFieldOptions, ODATA_PREFIX, Object.keys(apiFieldOptions));
14829
15568
  const response = await this.get(QUEUE_ENDPOINTS.GET_BY_ID(id), {
14830
15569
  headers,
14831
15570
  params: apiOptions
14832
15571
  });
14833
- return transformData(pascalToCamelCaseKeys(response.data), QueueMap);
15572
+ const rawQueue = transformData(pascalToCamelCaseKeys(response.data), QueueMap);
15573
+ return createQueueWithMethods(rawQueue, this);
15574
+ }
15575
+ async getByName(name, options = {}) {
15576
+ const { result } = await this.getByNameLookup("Queue", QUEUE_ENDPOINTS.GET_BY_FOLDER, name, options, (raw) => createQueueWithMethods(transformData(pascalToCamelCaseKeys(raw), QueueMap), this), QueueMap);
15577
+ return result;
15578
+ }
15579
+ async getByKey(key, options = {}) {
15580
+ const trimmedKey = key?.trim();
15581
+ if (!trimmedKey || !GUID_REGEX.test(trimmedKey)) {
15582
+ throw new ValidationError({ message: "key must be a GUID for getByKey" });
15583
+ }
15584
+ const { folderId, folderKey, folderPath, ...queryOptions } = options;
15585
+ const headers = resolveFolderHeaders({
15586
+ folderId,
15587
+ folderKey,
15588
+ folderPath,
15589
+ resourceType: "Queues.getByKey",
15590
+ fallbackFolderKey: this.config.folderKey
15591
+ });
15592
+ const apiFieldOptions = transformOptions(queryOptions, QueueMap);
15593
+ const apiOptions = {
15594
+ ...addPrefixToKeys(apiFieldOptions, ODATA_PREFIX, Object.keys(apiFieldOptions)),
15595
+ $filter: `Key eq ${trimmedKey}`,
15596
+ $top: "1"
15597
+ };
15598
+ const response = await this.get(QUEUE_ENDPOINTS.GET_BY_FOLDER, { headers, params: apiOptions });
15599
+ const items = response.data?.value;
15600
+ if (!items?.length) {
15601
+ throw new NotFoundError({ message: `Queue with key '${trimmedKey}' not found.` });
15602
+ }
15603
+ return createQueueWithMethods(transformData(pascalToCamelCaseKeys(items[0]), QueueMap), this);
15604
+ }
15605
+ async getAllItems(queueId, options) {
15606
+ if (!queueId) {
15607
+ throw new ValidationError({ message: "queueId is required for getAllItems" });
15608
+ }
15609
+ const { folderId, folderKey, folderPath, filter, ...restOptions } = options ?? {};
15610
+ const headers = resolveFolderHeaders({
15611
+ folderId,
15612
+ folderKey,
15613
+ folderPath,
15614
+ resourceType: "Queues.getAllItems",
15615
+ fallbackFolderKey: this.config.folderKey
15616
+ });
15617
+ const mergedFilter = filter ? `(${filter}) and queueId eq ${queueId}` : `queueId eq ${queueId}`;
15618
+ const apiOptions = transformOptions({ ...restOptions, filter: mergedFilter }, QueueItemMap);
15619
+ return PaginationHelpers.getAll({
15620
+ serviceAccess: this.createPaginationServiceAccess(),
15621
+ getEndpoint: () => QUEUE_ENDPOINTS.GET_ITEMS,
15622
+ getByFolderEndpoint: QUEUE_ENDPOINTS.GET_ITEMS,
15623
+ headers,
15624
+ transformFn: transformQueueItem,
15625
+ pagination: {
15626
+ paginationType: PaginationType.OFFSET,
15627
+ itemsField: ODATA_PAGINATION.ITEMS_FIELD,
15628
+ totalCountField: ODATA_PAGINATION.TOTAL_COUNT_FIELD,
15629
+ paginationParams: {
15630
+ pageSizeParam: ODATA_OFFSET_PARAMS.PAGE_SIZE_PARAM,
15631
+ offsetParam: ODATA_OFFSET_PARAMS.OFFSET_PARAM,
15632
+ countParam: ODATA_OFFSET_PARAMS.COUNT_PARAM
15633
+ }
15634
+ }
15635
+ }, apiOptions);
15636
+ }
15637
+ async insertItemByName(queueName, specificData, options = {}) {
15638
+ if (!queueName) {
15639
+ throw new ValidationError({ message: "queueName is required for insertItemByName" });
15640
+ }
15641
+ const headers = resolveFolderHeaders({
15642
+ folderId: options.folderId,
15643
+ folderKey: options.folderKey,
15644
+ folderPath: options.folderPath,
15645
+ resourceType: "Queues.insertItemByName",
15646
+ fallbackFolderKey: this.config.folderKey
15647
+ });
15648
+ const response = await this.post(QUEUE_ENDPOINTS.ADD_ITEM, {
15649
+ itemData: {
15650
+ Name: queueName,
15651
+ Priority: options.priority ?? QueuePriority.Normal,
15652
+ Reference: options.reference,
15653
+ Progress: options.progress,
15654
+ DeferDate: options.deferDate?.toISOString(),
15655
+ DueDate: options.dueDate?.toISOString(),
15656
+ RiskSlaDate: options.riskSlaDate?.toISOString(),
15657
+ SpecificContent: specificData
15658
+ }
15659
+ }, { headers });
15660
+ return transformQueueItem(response.data);
15661
+ }
15662
+ async startTransaction(queue, options = {}) {
15663
+ const headers = resolveFolderHeaders({
15664
+ folderId: options.folderId,
15665
+ folderKey: options.folderKey,
15666
+ folderPath: options.folderPath,
15667
+ resourceType: "Queues.startTransaction",
15668
+ fallbackFolderKey: this.config.folderKey
15669
+ });
15670
+ let queueName;
15671
+ if (queue?.name) {
15672
+ queueName = queue.name;
15673
+ } else if (queue?.id != null) {
15674
+ queueName = await this.resolveQueueName(queue.id, headers);
15675
+ } else {
15676
+ throw new ValidationError({ message: "queue id or name is required for startTransaction" });
15677
+ }
15678
+ const response = await this.post(QUEUE_ENDPOINTS.START_TRANSACTION, {
15679
+ transactionData: { Name: queueName }
15680
+ }, { headers });
15681
+ if (!response.data || typeof response.data !== "object") {
15682
+ return null;
15683
+ }
15684
+ return transformQueueItem(response.data);
15685
+ }
15686
+ async completeTransaction(itemId, outcome, options = {}) {
15687
+ if (!itemId) {
15688
+ throw new ValidationError({ message: "itemId is required for completeTransaction" });
15689
+ }
15690
+ const headers = resolveFolderHeaders({
15691
+ folderId: options.folderId,
15692
+ folderKey: options.folderKey,
15693
+ folderPath: options.folderPath,
15694
+ resourceType: "Queues.completeTransaction",
15695
+ fallbackFolderKey: this.config.folderKey
15696
+ });
15697
+ const transactionResult = {
15698
+ IsSuccessful: outcome === QueueTransactionOutcome.Successful,
15699
+ ProcessingException: options.processingError && {
15700
+ Reason: options.processingError.reason,
15701
+ Details: options.processingError.details,
15702
+ Type: options.processingError.type,
15703
+ AssociatedImageFilePath: options.processingError.associatedImageFilePath
15704
+ },
15705
+ DeferDate: options.deferDate?.toISOString(),
15706
+ DueDate: options.dueDate?.toISOString(),
15707
+ Progress: options.progress,
15708
+ OperationId: options.operationId,
15709
+ Output: options.outputData,
15710
+ Analytics: options.analytics
15711
+ };
15712
+ await this.post(QUEUE_ENDPOINTS.SET_TRANSACTION_RESULT(itemId), { transactionResult }, { headers });
15713
+ }
15714
+ async resolveQueueName(queueId, headers) {
15715
+ const response = await this.get(QUEUE_ENDPOINTS.GET_BY_ID(queueId), { headers, params: { $select: "Name" } });
15716
+ return response.data.Name;
14834
15717
  }
14835
15718
  }
14836
15719
  __decorate([
@@ -14839,6 +15722,24 @@ __decorate([
14839
15722
  __decorate([
14840
15723
  track("Queues.GetById")
14841
15724
  ], QueueService.prototype, "getById", null);
15725
+ __decorate([
15726
+ track("Queues.GetByName")
15727
+ ], QueueService.prototype, "getByName", null);
15728
+ __decorate([
15729
+ track("Queues.GetByKey")
15730
+ ], QueueService.prototype, "getByKey", null);
15731
+ __decorate([
15732
+ track("Queues.GetAllItems")
15733
+ ], QueueService.prototype, "getAllItems", null);
15734
+ __decorate([
15735
+ track("Queues.InsertItemByName")
15736
+ ], QueueService.prototype, "insertItemByName", null);
15737
+ __decorate([
15738
+ track("Queues.StartTransaction")
15739
+ ], QueueService.prototype, "startTransaction", null);
15740
+ __decorate([
15741
+ track("Queues.CompleteTransaction")
15742
+ ], QueueService.prototype, "completeTransaction", null);
14842
15743
  var TaskCatalogMap = {
14843
15744
  creationTime: "createdTime",
14844
15745
  lastModificationTime: "lastModifiedTime"
@@ -14885,7 +15786,8 @@ class TaskCatalogService extends FolderScopedService {
14885
15786
  return transformData(pascalToCamelCaseKeys(response.data), TaskCatalogMap);
14886
15787
  }
14887
15788
  async getByName(name, options = {}) {
14888
- return this.getByNameLookup("TaskCatalog", TASK_CATALOG_ENDPOINTS.GET_ALL, name, options, (raw) => transformData(pascalToCamelCaseKeys(raw), TaskCatalogMap), TaskCatalogMap);
15789
+ const { result } = await this.getByNameLookup("TaskCatalog", TASK_CATALOG_ENDPOINTS.GET_ALL, name, options, (raw) => transformData(pascalToCamelCaseKeys(raw), TaskCatalogMap), TaskCatalogMap);
15790
+ return result;
14889
15791
  }
14890
15792
  async create(name, options = {}) {
14891
15793
  if (!name) {
@@ -14909,7 +15811,7 @@ class TaskCatalogService extends FolderScopedService {
14909
15811
  throw new ValidationError({ message: "name is required for updateByName" });
14910
15812
  }
14911
15813
  const { folderId, folderKey, folderPath } = options;
14912
- const current = await this.getByNameLookup("TaskCatalog", TASK_CATALOG_ENDPOINTS.GET_ALL, name, { folderId, folderKey, folderPath }, (raw) => transformData(pascalToCamelCaseKeys(raw), TaskCatalogMap), TaskCatalogMap);
15814
+ const { result: current } = await this.getByNameLookup("TaskCatalog", TASK_CATALOG_ENDPOINTS.GET_ALL, name, { folderId, folderKey, folderPath }, (raw) => transformData(pascalToCamelCaseKeys(raw), TaskCatalogMap), TaskCatalogMap);
14913
15815
  return this.update(current, options);
14914
15816
  }
14915
15817
  async update(current, options) {
@@ -15054,6 +15956,13 @@ var AgentMap = {
15054
15956
  var UserSettingsMap = {
15055
15957
  ...CommonFieldMap
15056
15958
  };
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 = {}));
15057
15966
  var FeedbackStatus;
15058
15967
  (function(FeedbackStatus2) {
15059
15968
  FeedbackStatus2[FeedbackStatus2["Pending"] = 0] = "Pending";
@@ -15611,6 +16520,7 @@ var TaskType2;
15611
16520
  TaskType3["DocumentValidation"] = "DocumentValidationTask";
15612
16521
  TaskType3["DocumentClassification"] = "DocumentClassificationTask";
15613
16522
  TaskType3["DataLabeling"] = "DataLabelingTask";
16523
+ TaskType3["QuickForm"] = "QuickFormTask";
15614
16524
  })(TaskType2 || (TaskType2 = {}));
15615
16525
  var TaskPriority2;
15616
16526
  (function(TaskPriority3) {
@@ -15719,7 +16629,8 @@ var TASK_TYPE_ENDPOINTS2 = {
15719
16629
  [TaskType2.DocumentValidation]: TASK_ENDPOINTS2.GET_GENERIC_TASK_BY_ID,
15720
16630
  [TaskType2.DocumentClassification]: TASK_ENDPOINTS2.GET_GENERIC_TASK_BY_ID,
15721
16631
  [TaskType2.External]: TASK_ENDPOINTS2.GET_GENERIC_TASK_BY_ID,
15722
- [TaskType2.DataLabeling]: TASK_ENDPOINTS2.GET_GENERIC_TASK_BY_ID
16632
+ [TaskType2.DataLabeling]: TASK_ENDPOINTS2.GET_GENERIC_TASK_BY_ID,
16633
+ [TaskType2.QuickForm]: TASK_ENDPOINTS2.GET_GENERIC_TASK_BY_ID
15723
16634
  };
15724
16635
  var ActionCenterEventNames2;
15725
16636
  (function(ActionCenterEventNames3) {
@@ -15829,7 +16740,8 @@ var RESPONSE_TYPES2 = {
15829
16740
  JSON: "json",
15830
16741
  TEXT: "text",
15831
16742
  BLOB: "blob",
15832
- ARRAYBUFFER: "arraybuffer"
16743
+ ARRAYBUFFER: "arraybuffer",
16744
+ STREAM: "stream"
15833
16745
  };
15834
16746
  function createHeaders2(headersObj) {
15835
16747
  const headers = {};
@@ -16416,6 +17328,165 @@ class ErrorFactory2 {
16416
17328
  return new NetworkError2({ message });
16417
17329
  }
16418
17330
  }
17331
+ function toSearchParams2(params) {
17332
+ const searchParams = new URLSearchParams;
17333
+ if (!params)
17334
+ return searchParams;
17335
+ for (const [key, value] of Object.entries(params)) {
17336
+ if (value === undefined || value === null)
17337
+ continue;
17338
+ if (Array.isArray(value)) {
17339
+ value.forEach((item) => {
17340
+ if (item !== undefined && item !== null)
17341
+ searchParams.append(key, String(item));
17342
+ });
17343
+ } else {
17344
+ searchParams.append(key, String(value));
17345
+ }
17346
+ }
17347
+ return searchParams;
17348
+ }
17349
+ var DEFAULT_RETRYABLE_STATUS_CODES2 = [408, 429, 500, 502, 503, 504];
17350
+ var DEFAULT_RETRY_METHODS2 = ["GET", "HEAD", "PUT", "DELETE", "OPTIONS"];
17351
+ var DEFAULT_RETRY_OPTIONS2 = {
17352
+ maxRetries: 2,
17353
+ initialDelayMs: 500,
17354
+ backoffStrategy: "exponential",
17355
+ backoffFactor: 2,
17356
+ backoffMaxDelayMs: 30000,
17357
+ retryableStatusCodes: DEFAULT_RETRYABLE_STATUS_CODES2,
17358
+ retryMethods: DEFAULT_RETRY_METHODS2,
17359
+ retryNetworkErrors: true,
17360
+ respectRetryAfter: true,
17361
+ maxRetryAfterMs: Infinity
17362
+ };
17363
+ var DEFAULT_API_CLIENT_RETRY2 = {
17364
+ ...DEFAULT_RETRY_OPTIONS2,
17365
+ maxRetries: 0
17366
+ };
17367
+ function resolveRetryOptions2(settings, defaults = DEFAULT_RETRY_OPTIONS2) {
17368
+ if (!settings)
17369
+ return defaults;
17370
+ const { retryDelay, useExponentialBackoff, ...live } = settings;
17371
+ const resolved = { ...defaults };
17372
+ for (const [key, value] of Object.entries(live)) {
17373
+ if (value !== undefined) {
17374
+ resolved[key] = value;
17375
+ }
17376
+ }
17377
+ if (retryDelay !== undefined && live.initialDelayMs === undefined) {
17378
+ resolved.initialDelayMs = retryDelay;
17379
+ }
17380
+ if (useExponentialBackoff !== undefined && live.backoffStrategy === undefined) {
17381
+ resolved.backoffStrategy = useExponentialBackoff ? "exponential" : "constant";
17382
+ }
17383
+ return resolved;
17384
+ }
17385
+ function computeBackoffDelay2(attempt, settings) {
17386
+ const base = Math.max(0, settings.initialDelayMs);
17387
+ let delay;
17388
+ switch (settings.backoffStrategy) {
17389
+ case "constant":
17390
+ delay = base;
17391
+ break;
17392
+ case "linear":
17393
+ delay = base * (attempt + 1);
17394
+ break;
17395
+ default:
17396
+ delay = base * Math.pow(settings.backoffFactor, attempt);
17397
+ }
17398
+ return Math.min(delay, settings.backoffMaxDelayMs);
17399
+ }
17400
+ function parseRetryAfter2(value, now = Date.now()) {
17401
+ const trimmed = value?.trim();
17402
+ if (!trimmed)
17403
+ return;
17404
+ const seconds = Number(trimmed);
17405
+ if (Number.isFinite(seconds))
17406
+ return Math.max(0, seconds * 1000);
17407
+ const date2 = Date.parse(trimmed);
17408
+ if (Number.isNaN(date2))
17409
+ return;
17410
+ return Math.max(0, date2 - now);
17411
+ }
17412
+ function wait2(durationMs) {
17413
+ return new Promise((resolve) => setTimeout(resolve, Math.max(0, durationMs)));
17414
+ }
17415
+ var RETRY_AFTER2 = "retry-after";
17416
+ function createAttemptSignal2(timeoutMs, external) {
17417
+ if (timeoutMs === undefined || !Number.isFinite(timeoutMs))
17418
+ return { signal: external, dispose: () => {} };
17419
+ const controller = new AbortController;
17420
+ const timer = setTimeout(() => controller.abort(new Error(`Request timeout after ${timeoutMs}ms`)), timeoutMs);
17421
+ const onExternalAbort = () => controller.abort(external?.reason);
17422
+ if (external) {
17423
+ if (external.aborted) {
17424
+ controller.abort(external.reason);
17425
+ } else {
17426
+ external.addEventListener("abort", onExternalAbort);
17427
+ }
17428
+ }
17429
+ return {
17430
+ signal: controller.signal,
17431
+ dispose: () => {
17432
+ clearTimeout(timer);
17433
+ external?.removeEventListener("abort", onExternalAbort);
17434
+ }
17435
+ };
17436
+ }
17437
+ function delayBeforeRetry2(durationMs, signal) {
17438
+ if (!signal)
17439
+ return wait2(durationMs);
17440
+ if (signal.aborted)
17441
+ return Promise.reject(signal.reason);
17442
+ return new Promise((resolve, reject) => {
17443
+ const onAbort = () => {
17444
+ clearTimeout(timer);
17445
+ reject(signal.reason);
17446
+ };
17447
+ const timer = setTimeout(() => {
17448
+ signal.removeEventListener("abort", onAbort);
17449
+ resolve();
17450
+ }, Math.max(0, durationMs));
17451
+ signal.addEventListener("abort", onAbort);
17452
+ });
17453
+ }
17454
+ async function fetchWithRetry2(url, init, options) {
17455
+ const settings = options.retry;
17456
+ const method = (init.method ?? "GET").toUpperCase();
17457
+ const retriesAllowed = settings.retryMethods.includes(method) ? Math.max(0, settings.maxRetries) : 0;
17458
+ let attempt = 0;
17459
+ for (;; ) {
17460
+ const { signal, dispose } = createAttemptSignal2(options.timeoutMs, options.signal);
17461
+ let response;
17462
+ let failure;
17463
+ try {
17464
+ response = await fetch(url, { ...init, signal });
17465
+ } catch (error) {
17466
+ failure = error;
17467
+ } finally {
17468
+ dispose();
17469
+ }
17470
+ if (options.signal?.aborted && failure !== undefined)
17471
+ throw failure;
17472
+ if (response && !settings.retryableStatusCodes.includes(response.status))
17473
+ return response;
17474
+ if (failure !== undefined && !settings.retryNetworkErrors)
17475
+ throw failure;
17476
+ if (attempt >= retriesAllowed) {
17477
+ if (response)
17478
+ return response;
17479
+ throw failure;
17480
+ }
17481
+ const retryAfter = settings.respectRetryAfter && response ? parseRetryAfter2(response.headers.get(RETRY_AFTER2)) : undefined;
17482
+ const delay = retryAfter !== undefined ? Math.min(retryAfter, settings.maxRetryAfterMs) : computeBackoffDelay2(attempt, settings);
17483
+ response?.body?.cancel().catch((error) => {
17484
+ console.warn("[UiPath SDK] Could not release a discarded response body:", error);
17485
+ });
17486
+ await delayBeforeRetry2(delay, options.signal);
17487
+ attempt++;
17488
+ }
17489
+ }
16419
17490
 
16420
17491
  class ApiClient2 {
16421
17492
  constructor(config2, executionContext, tokenManager, clientConfig = {}) {
@@ -16450,28 +17521,16 @@ class ApiClient2 {
16450
17521
  [UIPATH_TRACEPARENT_ID2]: traceparentValue,
16451
17522
  ...options.headers
16452
17523
  };
16453
- const searchParams = new URLSearchParams;
16454
- if (options.params) {
16455
- Object.entries(options.params).forEach(([key, value]) => {
16456
- if (Array.isArray(value)) {
16457
- value.forEach((item) => searchParams.append(key, String(item)));
16458
- } else {
16459
- searchParams.append(key, String(value));
16460
- }
16461
- });
16462
- }
17524
+ const searchParams = toSearchParams2(options.params);
16463
17525
  const fullUrl = searchParams.toString() ? `${url}?${searchParams.toString()}` : url;
16464
17526
  let body = undefined;
16465
17527
  if (options.body) {
16466
17528
  body = isFormData ? options.body : JSON.stringify(options.body);
16467
17529
  }
17530
+ const retrySettings = resolveRetryOptions2(options.retry ?? options.retryOptions, DEFAULT_API_CLIENT_RETRY2);
17531
+ const timeoutMs = options.timeoutMs ?? options.timeoutOptions?.timeout;
16468
17532
  try {
16469
- const response = await fetch(fullUrl, {
16470
- method,
16471
- headers,
16472
- body,
16473
- signal: options.signal
16474
- });
17533
+ const response = await fetchWithRetry2(fullUrl, { method, headers, body }, { retry: retrySettings, timeoutMs, signal: options.signal });
16475
17534
  if (!response.ok) {
16476
17535
  const errorInfo = await errorResponseParser2.parse(response);
16477
17536
  throw ErrorFactory2.createFromHttpStatus(response.status, errorInfo);
@@ -16585,6 +17644,12 @@ class PaginationManager2 {
16585
17644
  return result;
16586
17645
  }
16587
17646
  }
17647
+ function missingConfigMessage2() {
17648
+ if (isBrowser2) {
17649
+ 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
+ }
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.";
17652
+ }
16588
17653
  var REGISTRY_KEY3 = Symbol.for("@uipath/sdk-internals-registry");
16589
17654
  var getGlobalStore2 = () => {
16590
17655
  const globalObj = globalThis;
@@ -16593,6 +17658,7 @@ var getGlobalStore2 = () => {
16593
17658
  }
16594
17659
  return globalObj[REGISTRY_KEY3];
16595
17660
  };
17661
+ var looksLikeUiPath2 = (instance) => typeof instance.initialize === "function";
16596
17662
 
16597
17663
  class SDKInternalsRegistry2 {
16598
17664
  static get store() {
@@ -16604,6 +17670,9 @@ class SDKInternalsRegistry2 {
16604
17670
  static get(instance) {
16605
17671
  const internals = this.store.get(instance);
16606
17672
  if (!internals) {
17673
+ if (looksLikeUiPath2(instance)) {
17674
+ throw new Error("Cannot create a service: the UiPath instance was never configured. " + missingConfigMessage2());
17675
+ }
16607
17676
  throw new Error("Invalid SDK instance. Make sure to pass a valid UiPath instance to the service constructor.");
16608
17677
  }
16609
17678
  return internals;
@@ -16790,6 +17859,90 @@ function validateName2(resourceType, name) {
16790
17859
  }
16791
17860
  return trimmed;
16792
17861
  }
17862
+ 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
+ function isPlainObject2(value) {
17880
+ return typeof value === "object" && value !== null && !Array.isArray(value);
17881
+ }
17882
+ function asResourceOverrides2(value) {
17883
+ if (!isPlainObject2(value))
17884
+ return;
17885
+ const table2 = {};
17886
+ for (const [key, properties] of Object.entries(value)) {
17887
+ if (!isPlainObject2(properties))
17888
+ continue;
17889
+ const bag = {};
17890
+ for (const [property, propertyValue] of Object.entries(properties)) {
17891
+ if (typeof propertyValue === "string")
17892
+ bag[property] = propertyValue;
17893
+ }
17894
+ table2[key] = bag;
17895
+ }
17896
+ return Object.keys(table2).length > 0 ? table2 : undefined;
17897
+ }
17898
+ function readFromDocument2() {
17899
+ if (!isBrowser2)
17900
+ return;
17901
+ const text = document.getElementById(UiPathElementIds2.RESOURCE_OVERRIDES)?.textContent;
17902
+ if (!text)
17903
+ return;
17904
+ try {
17905
+ return asResourceOverrides2(JSON.parse(text));
17906
+ } catch (error) {
17907
+ console.warn(`[UiPath SDK] Failed to parse <script id="${UiPathElementIds2.RESOURCE_OVERRIDES}"> as JSON — proceeding without overrides:`, error);
17908
+ return;
17909
+ }
17910
+ }
17911
+ var table2;
17912
+ var loaded2 = false;
17913
+ var pageOverrides2 = () => {
17914
+ if (!loaded2) {
17915
+ loaded2 = true;
17916
+ table2 = readFromDocument2();
17917
+ }
17918
+ return table2;
17919
+ };
17920
+ var RESOURCE_OVERWRITES_KEY2 = Symbol.for("uipath.resourceOverwrites.v1");
17921
+ function readOverrides2() {
17922
+ const slot = globalThis[RESOURCE_OVERWRITES_KEY2];
17923
+ const source = typeof slot === "function" ? slot : pageOverrides2;
17924
+ try {
17925
+ return source();
17926
+ } catch (error) {
17927
+ console.warn("[UiPath SDK] Override source threw — proceeding without overrides:", error);
17928
+ return;
17929
+ }
17930
+ }
17931
+ function resolveOverride2(resourceType, name, folderPath) {
17932
+ const table3 = readOverrides2();
17933
+ if (!table3)
17934
+ return;
17935
+ const bindingType = resourceType.toLowerCase();
17936
+ const scopedKey = folderPath ? `${bindingType}.${name}.${folderPath}` : undefined;
17937
+ const unscopedKey = `${bindingType}.${name}`;
17938
+ const entry = (scopedKey && table3[scopedKey]) ?? table3[unscopedKey];
17939
+ if (!entry)
17940
+ return;
17941
+ return {
17942
+ name: entry.name,
17943
+ folderPath: entry.folderPath
17944
+ };
17945
+ }
16793
17946
  var SINGLE_QUOTE_RE2 = /'/g;
16794
17947
 
16795
17948
  class FolderScopedService2 extends BaseService2 {
@@ -16806,20 +17959,23 @@ class FolderScopedService2 extends BaseService2 {
16806
17959
  }
16807
17960
  return response.data?.value;
16808
17961
  }
16809
- async getByNameLookup(resourceType, endpoint, name, options, transform2, responseFieldMap) {
17962
+ async getByNameLookup(resourceType, endpoint, name, options, transform2, responseFieldMap, callerLabel) {
16810
17963
  const validatedName = validateName2(resourceType, name);
16811
17964
  const { folderId, folderKey, folderPath, ...queryOptions } = options;
17965
+ const override = resolveOverride2(resourceType, validatedName, folderPath);
17966
+ const resolvedName = override?.name ?? validatedName;
17967
+ const resolvedFolderPath = override?.folderPath ?? folderPath;
16812
17968
  const headers = resolveFolderHeaders2({
16813
17969
  folderId,
16814
17970
  folderKey,
16815
- folderPath,
16816
- resourceType: `${resourceType}.getByName`,
17971
+ folderPath: resolvedFolderPath,
17972
+ resourceType: callerLabel ?? `${resourceType}.getByName`,
16817
17973
  fallbackFolderKey: this.config.folderKey
16818
17974
  });
16819
17975
  const apiFieldOptions = responseFieldMap ? transformOptions2(queryOptions, responseFieldMap) : queryOptions;
16820
17976
  const apiOptions = {
16821
17977
  ...addPrefixToKeys2(apiFieldOptions, ODATA_PREFIX2, Object.keys(apiFieldOptions)),
16822
- $filter: `Name eq '${validatedName.replace(SINGLE_QUOTE_RE2, "''")}'`,
17978
+ $filter: `Name eq '${resolvedName.replace(SINGLE_QUOTE_RE2, "''")}'`,
16823
17979
  $top: "1"
16824
17980
  };
16825
17981
  const response = await this.get(endpoint, {
@@ -16828,12 +17984,48 @@ class FolderScopedService2 extends BaseService2 {
16828
17984
  });
16829
17985
  const items = response.data?.value;
16830
17986
  if (!items?.length) {
16831
- const folderHint = describeFolderForError2(folderId, folderKey, folderPath);
17987
+ const folderHint = describeFolderForError2(folderId, folderKey, resolvedFolderPath);
16832
17988
  throw new NotFoundError2({
16833
- message: `${resourceType} '${validatedName}' not found${folderHint}.`
17989
+ message: `${resourceType} '${resolvedName}' not found${folderHint}.`
16834
17990
  });
16835
17991
  }
16836
- return transform2(items[0]);
17992
+ return {
17993
+ result: transform2(items[0]),
17994
+ effectiveFolder: { folderId, folderKey, folderPath: resolvedFolderPath }
17995
+ };
17996
+ }
17997
+ async getByKeyLookup(resourceType, endpoint, key, options, transform2, responseFieldMap, callerLabel) {
17998
+ const label = callerLabel ?? `${resourceType}.getByKey`;
17999
+ const trimmedKey = key?.trim();
18000
+ if (!trimmedKey || !GUID_REGEX2.test(trimmedKey)) {
18001
+ throw new ValidationError2({ message: `${label}: key must be a GUID.` });
18002
+ }
18003
+ const { folderId, folderKey, folderPath, ...queryOptions } = options;
18004
+ const headers = resolveFolderHeaders2({
18005
+ folderId,
18006
+ folderKey,
18007
+ folderPath,
18008
+ resourceType: label,
18009
+ fallbackFolderKey: this.config.folderKey
18010
+ });
18011
+ const apiFieldOptions = responseFieldMap ? transformOptions2(queryOptions, responseFieldMap) : queryOptions;
18012
+ const apiOptions = {
18013
+ ...addPrefixToKeys2(apiFieldOptions, ODATA_PREFIX2, Object.keys(apiFieldOptions)),
18014
+ $filter: `Key eq ${trimmedKey}`,
18015
+ $top: "1"
18016
+ };
18017
+ const response = await this.get(endpoint, {
18018
+ headers,
18019
+ params: apiOptions
18020
+ });
18021
+ const items = response.data?.value;
18022
+ if (!items?.length) {
18023
+ throw new NotFoundError2({ message: `${resourceType} with key '${trimmedKey}' not found.` });
18024
+ }
18025
+ return {
18026
+ result: transform2(items[0]),
18027
+ effectiveFolder: { folderId, folderKey, folderPath }
18028
+ };
16837
18029
  }
16838
18030
  }
16839
18031
  function describeFolderForError2(folderId, folderKey, folderPath) {
@@ -16864,12 +18056,16 @@ class TaskService2 extends FolderScopedService2 {
16864
18056
  };
16865
18057
  }
16866
18058
  async create(task, folderId) {
18059
+ if (task.type === TaskType2.QuickForm && !task.taskSchemaKey) {
18060
+ throw new ValidationError2({ message: "taskSchemaKey is required when creating a QuickForm task." });
18061
+ }
16867
18062
  const headers = createHeaders2({ [FOLDER_ID2]: folderId });
16868
- const externalTask = {
16869
- ...task,
16870
- type: TaskType2.External
16871
- };
16872
- const response = await this.post(TASK_ENDPOINTS2.CREATE_GENERIC_TASK, externalTask, { headers });
18063
+ const { labels, type, ...rest } = task;
18064
+ const payload = { ...rest, type: type ?? TaskType2.External };
18065
+ if (labels?.length) {
18066
+ payload.tags = labels.map((label) => ({ name: label, displayName: label, displayValue: label }));
18067
+ }
18068
+ const response = await this.post(TASK_ENDPOINTS2.CREATE_GENERIC_TASK, payload, { headers });
16873
18069
  const normalizedData = transformData2(response.data, TaskMap2);
16874
18070
  const transformedData = applyDataTransforms2(normalizedData, { field: "status", valueMap: TaskStatusMap2 });
16875
18071
  return createTaskWithMethods2(transformedData, this);
@@ -17212,7 +18408,8 @@ class TaskCatalogService2 extends FolderScopedService2 {
17212
18408
  return transformData2(pascalToCamelCaseKeys2(response.data), TaskCatalogMap2);
17213
18409
  }
17214
18410
  async getByName(name, options = {}) {
17215
- return this.getByNameLookup("TaskCatalog", TASK_CATALOG_ENDPOINTS2.GET_ALL, name, options, (raw) => transformData2(pascalToCamelCaseKeys2(raw), TaskCatalogMap2), TaskCatalogMap2);
18411
+ const { result } = await this.getByNameLookup("TaskCatalog", TASK_CATALOG_ENDPOINTS2.GET_ALL, name, options, (raw) => transformData2(pascalToCamelCaseKeys2(raw), TaskCatalogMap2), TaskCatalogMap2);
18412
+ return result;
17216
18413
  }
17217
18414
  async create(name, options = {}) {
17218
18415
  if (!name) {
@@ -17236,7 +18433,7 @@ class TaskCatalogService2 extends FolderScopedService2 {
17236
18433
  throw new ValidationError2({ message: "name is required for updateByName" });
17237
18434
  }
17238
18435
  const { folderId, folderKey, folderPath } = options;
17239
- const current = await this.getByNameLookup("TaskCatalog", TASK_CATALOG_ENDPOINTS2.GET_ALL, name, { folderId, folderKey, folderPath }, (raw) => transformData2(pascalToCamelCaseKeys2(raw), TaskCatalogMap2), TaskCatalogMap2);
18436
+ const { result: current } = await this.getByNameLookup("TaskCatalog", TASK_CATALOG_ENDPOINTS2.GET_ALL, name, { folderId, folderKey, folderPath }, (raw) => transformData2(pascalToCamelCaseKeys2(raw), TaskCatalogMap2), TaskCatalogMap2);
17240
18437
  return this.update(current, options);
17241
18438
  }
17242
18439
  async update(current, options) {
@@ -17400,11 +18597,11 @@ async function resolveFolderScope(options) {
17400
18597
  return parseIntArg(options.folderId, "--folder-id");
17401
18598
  }
17402
18599
  if (options.folderKey !== undefined) {
17403
- const { resolveFolderIdByKey } = await import("./folder-resolver-xsyrk9rg.js");
18600
+ const { resolveFolderIdByKey } = await import("./folder-resolver-v3hx6eqb.js");
17404
18601
  return resolveFolderIdByKey(options.folderKey, options.tenant);
17405
18602
  }
17406
18603
  if (options.folderPath !== undefined) {
17407
- const { resolveFolderIdByPath } = await import("./folder-resolver-xsyrk9rg.js");
18604
+ const { resolveFolderIdByPath } = await import("./folder-resolver-v3hx6eqb.js");
17408
18605
  return resolveFolderIdByPath(options.folderPath, options.tenant);
17409
18606
  }
17410
18607
  return;
@@ -17424,7 +18621,7 @@ async function resolveFolderId(options, missingFolderInstructions = DEFAULT_FOLD
17424
18621
  processContext.exit(1);
17425
18622
  return null;
17426
18623
  }
17427
- const { pickFolderInteractively } = await import("./folder-picker-interactive-m0ntqfw0.js");
18624
+ const { pickFolderInteractively } = await import("./folder-picker-interactive-g7r2c8ct.js");
17428
18625
  return pickFolderInteractively(options.tenant);
17429
18626
  }
17430
18627
 
@@ -18246,4 +19443,4 @@ var registerCommands = async (program) => {
18246
19443
 
18247
19444
  export { metadata, registerCommands };
18248
19445
 
18249
- //# debugId=EE23460BFEA9C91C64756E2164756E21
19446
+ //# debugId=23D099BBD08C1FEA64756E2164756E21