@uipath/uipath-typescript 1.3.11 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/dist/agent-memory/index.cjs +1765 -0
  2. package/dist/agent-memory/index.d.ts +588 -0
  3. package/dist/agent-memory/index.mjs +1763 -0
  4. package/dist/agents/index.cjs +1726 -0
  5. package/dist/agents/index.d.ts +502 -0
  6. package/dist/agents/index.mjs +1724 -0
  7. package/dist/assets/index.cjs +155 -30
  8. package/dist/assets/index.d.ts +84 -5
  9. package/dist/assets/index.mjs +155 -30
  10. package/dist/attachments/index.cjs +37 -6
  11. package/dist/attachments/index.d.ts +1 -0
  12. package/dist/attachments/index.mjs +37 -6
  13. package/dist/buckets/index.cjs +37 -6
  14. package/dist/buckets/index.d.ts +1 -0
  15. package/dist/buckets/index.mjs +37 -6
  16. package/dist/cases/index.cjs +141 -10
  17. package/dist/cases/index.d.ts +118 -7
  18. package/dist/cases/index.mjs +141 -11
  19. package/dist/conversational-agent/index.cjs +124 -57
  20. package/dist/conversational-agent/index.d.ts +190 -122
  21. package/dist/conversational-agent/index.mjs +124 -57
  22. package/dist/core/index.cjs +413 -105
  23. package/dist/core/index.d.ts +15 -0
  24. package/dist/core/index.mjs +413 -105
  25. package/dist/entities/index.cjs +122 -43
  26. package/dist/entities/index.d.ts +140 -35
  27. package/dist/entities/index.mjs +122 -43
  28. package/dist/feedback/index.cjs +37 -6
  29. package/dist/feedback/index.d.ts +1 -0
  30. package/dist/feedback/index.mjs +37 -6
  31. package/dist/governance/index.cjs +1782 -0
  32. package/dist/governance/index.d.ts +598 -0
  33. package/dist/governance/index.mjs +1780 -0
  34. package/dist/index.cjs +956 -283
  35. package/dist/index.d.ts +1138 -121
  36. package/dist/index.mjs +956 -284
  37. package/dist/index.umd.js +3113 -2423
  38. package/dist/jobs/index.cjs +37 -6
  39. package/dist/jobs/index.d.ts +1 -0
  40. package/dist/jobs/index.mjs +37 -6
  41. package/dist/maestro-processes/index.cjs +173 -18
  42. package/dist/maestro-processes/index.d.ts +131 -9
  43. package/dist/maestro-processes/index.mjs +173 -18
  44. package/dist/processes/index.cjs +37 -6
  45. package/dist/processes/index.d.ts +1 -0
  46. package/dist/processes/index.mjs +37 -6
  47. package/dist/queues/index.cjs +37 -6
  48. package/dist/queues/index.d.ts +1 -0
  49. package/dist/queues/index.mjs +37 -6
  50. package/dist/tasks/index.cjs +37 -6
  51. package/dist/tasks/index.d.ts +1 -0
  52. package/dist/tasks/index.mjs +37 -6
  53. package/dist/traces/index.cjs +37 -6
  54. package/dist/traces/index.d.ts +1 -0
  55. package/dist/traces/index.mjs +37 -6
  56. package/package.json +32 -2
package/dist/index.mjs CHANGED
@@ -4018,7 +4018,7 @@ object({
4018
4018
  secret: string().optional(),
4019
4019
  clientId: string().optional(),
4020
4020
  redirectUri: string().url().optional(),
4021
- scope: string().optional()
4021
+ scope: string().optional(),
4022
4022
  });
4023
4023
  class UiPathConfig {
4024
4024
  constructor(options) {
@@ -4069,6 +4069,32 @@ class ExecutionContext {
4069
4069
  */
4070
4070
  const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
4071
4071
  const isInActionCenter = isBrowser && window.self != window.top && window.location.href.includes('source=ActionCenter');
4072
+ const _params = isBrowser ? new URLSearchParams(window.location.search) : null;
4073
+ /**
4074
+ * True when the coded app has been loaded inside a host frame that explicitly
4075
+ * opted into token delegation by adding `?host=embed` to the iframe src URL.
4076
+ */
4077
+ const isHostEmbedded = isBrowser && window.self !== window.top && _params?.get('host') === 'embed';
4078
+ /**
4079
+ * The validated parent origin, read from the `?basedomain=` query param set
4080
+ * by the embedding host in the iframe src URL.
4081
+ * Mirrors the same mechanism used by ActionCenterTokenManager.
4082
+ * Non-null only when `?host=embed` is present and `?basedomain=` is a valid URL.
4083
+ */
4084
+ const embeddingOrigin = (() => {
4085
+ if (!isHostEmbedded)
4086
+ return null;
4087
+ const basedomain = _params?.get('basedomain');
4088
+ if (!basedomain)
4089
+ return null;
4090
+ try {
4091
+ return new URL(basedomain).origin;
4092
+ }
4093
+ catch {
4094
+ console.warn('embeddingOrigin: basedomain query param is not a valid URL', basedomain);
4095
+ return null;
4096
+ }
4097
+ })();
4072
4098
 
4073
4099
  /**
4074
4100
  * Session storage keys used by the auth module
@@ -4478,6 +4504,7 @@ const ORCHESTRATOR_BASE = 'orchestrator_';
4478
4504
  const PIMS_BASE = 'pims_';
4479
4505
  const DATAFABRIC_BASE = 'datafabric_';
4480
4506
  const IDENTITY_BASE = 'identity_';
4507
+ const LLMOPS_BASE = 'llmopstenant_';
4481
4508
  const INSIGHTS_RTM_BASE = 'insightsrtm_';
4482
4509
 
4483
4510
  /**
@@ -4570,7 +4597,7 @@ const MAESTRO_ENDPOINTS = {
4570
4597
  INSTANCES: {
4571
4598
  GET_ALL: `${PIMS_BASE}/api/v1/instances`,
4572
4599
  GET_BY_ID: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}`,
4573
- GET_EXECUTION_HISTORY: (instanceId) => `${PIMS_BASE}/api/v1/spans/${instanceId}`,
4600
+ GET_ELEMENT_EXECUTIONS: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/element-executions`,
4574
4601
  GET_BPMN: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/bpmn`,
4575
4602
  GET_VARIABLES: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/variables`,
4576
4603
  CANCEL: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/cancel`,
@@ -4582,6 +4609,9 @@ const MAESTRO_ENDPOINTS = {
4582
4609
  GET_BY_PROCESS: (processKey) => `${PIMS_BASE}/api/v1/incidents/process/${processKey}`,
4583
4610
  GET_BY_INSTANCE: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/incidents`,
4584
4611
  },
4612
+ TRACES: {
4613
+ GET_SPANS: (traceId) => `${LLMOPS_BASE}/api/Traces/spans?traceId=${traceId}`,
4614
+ },
4585
4615
  CASES: {
4586
4616
  GET_CASE_JSON: (instanceId) => `${PIMS_BASE}/api/v1/cases/${instanceId}/case-json`,
4587
4617
  GET_ELEMENT_EXECUTIONS: (instanceId) => `${PIMS_BASE}/api/v1/element-executions/case-instances/${instanceId}`,
@@ -4602,6 +4632,8 @@ const MAESTRO_ENDPOINTS = {
4602
4632
  INSTANCE_STATUS_BY_DATE: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/InstanceStatusByDate`,
4603
4633
  /** Top processes ranked by total duration */
4604
4634
  TOP_PROCESSES_BY_DURATION: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/TopProcessesByDuration`,
4635
+ /** Element count by status for agentic instances (process and case) */
4636
+ ELEMENT_COUNT_BY_STATUS: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/ElementCountByStatus`,
4605
4637
  },
4606
4638
  };
4607
4639
 
@@ -4676,6 +4708,96 @@ var ActionCenterEventNames;
4676
4708
  })(ActionCenterEventNames || (ActionCenterEventNames = {}));
4677
4709
 
4678
4710
  const AUTHENTICATION_TIMEOUT = 8000;
4711
+ const ALLOWED_HOST_ORIGINS = new Set([
4712
+ 'https://alpha.uipath.com',
4713
+ 'https://staging.uipath.com',
4714
+ 'https://cloud.uipath.com',
4715
+ ]);
4716
+ /**
4717
+ * Returns true if the origin is a trusted UiPath host that may initiate
4718
+ * token delegation. Mirrors the same allowlist used by ActionCenterTokenManager.
4719
+ */
4720
+ function isValidHostOrigin(origin) {
4721
+ if (!origin)
4722
+ return false;
4723
+ if (ALLOWED_HOST_ORIGINS.has(origin))
4724
+ return true;
4725
+ try {
4726
+ return new URL(origin).hostname === 'localhost';
4727
+ }
4728
+ catch {
4729
+ console.warn('isValidHostOrigin: received a malformed origin URL', origin);
4730
+ return false;
4731
+ }
4732
+ }
4733
+ function isTokenExpired(tokenInfo) {
4734
+ if (!tokenInfo?.expiresAt)
4735
+ return true;
4736
+ return new Date() >= tokenInfo.expiresAt;
4737
+ }
4738
+ /**
4739
+ * Waits for the next window message that satisfies `filter`.
4740
+ * Rejects if the AbortSignal fires before a matching message arrives.
4741
+ */
4742
+ function waitForMessage(filter, signal) {
4743
+ return new Promise((resolve, reject) => {
4744
+ const handler = (event) => {
4745
+ if (!filter(event))
4746
+ return;
4747
+ window.removeEventListener('message', handler);
4748
+ resolve(event);
4749
+ };
4750
+ signal.addEventListener('abort', () => {
4751
+ window.removeEventListener('message', handler);
4752
+ reject(signal.reason);
4753
+ }, { once: true });
4754
+ window.addEventListener('message', handler);
4755
+ });
4756
+ }
4757
+ /**
4758
+ * Sends a token-refresh request to a parent host frame and waits for the
4759
+ * response. Handles timeout, origin filtering, and listener cleanup.
4760
+ *
4761
+ * Both ActionCenterTokenManager and EmbeddedTokenManager delegate to this
4762
+ * function; they differ only in the event names and message shape they use.
4763
+ */
4764
+ function requestHostToken(options) {
4765
+ const { pinnedOrigin, sendRequest, responseEventType, extractToken, onTokenRefreshed } = options;
4766
+ const controller = new AbortController();
4767
+ const cancel = () => controller.abort(new AuthenticationError({
4768
+ message: 'Token refresh cancelled',
4769
+ statusCode: HttpStatus.UNAUTHORIZED,
4770
+ }));
4771
+ const promise = (async () => {
4772
+ const timer = setTimeout(() => controller.abort(new AuthenticationError({
4773
+ message: `Token refresh timed out after ${AUTHENTICATION_TIMEOUT}ms waiting for host response`,
4774
+ statusCode: HttpStatus.UNAUTHORIZED,
4775
+ })), AUTHENTICATION_TIMEOUT);
4776
+ try {
4777
+ // Register listener before sending — avoids any race between send and response
4778
+ const responsePromise = waitForMessage(event => event.origin === pinnedOrigin && event.data?.eventType === responseEventType, controller.signal);
4779
+ sendRequest();
4780
+ const event = await responsePromise;
4781
+ const token = extractToken(event.data);
4782
+ if (!token) {
4783
+ throw new AuthenticationError({
4784
+ message: 'Host responded but did not include a valid access token',
4785
+ statusCode: HttpStatus.UNAUTHORIZED,
4786
+ });
4787
+ }
4788
+ // type: 'secret' intentionally prevents the SDK's internal OAuth refresh path
4789
+ // from running — the host manager owns the refresh cycle via requestHostToken.
4790
+ // This mirrors the same pattern used by ActionCenterTokenManager.
4791
+ onTokenRefreshed({ token: token.accessToken, type: 'secret', expiresAt: token.expiresAt });
4792
+ return token.accessToken;
4793
+ }
4794
+ finally {
4795
+ clearTimeout(timer);
4796
+ }
4797
+ })();
4798
+ return { promise, cancel };
4799
+ }
4800
+
4679
4801
  class ActionCenterTokenManager {
4680
4802
  constructor(config, onTokenRefreshed) {
4681
4803
  this.config = config;
@@ -4684,85 +4806,335 @@ class ActionCenterTokenManager {
4684
4806
  this.refreshPromise = null;
4685
4807
  }
4686
4808
  async refreshAccessToken(tokenInfo) {
4687
- if (!this.isTokenExpired(tokenInfo)) {
4809
+ if (!isTokenExpired(tokenInfo)) {
4688
4810
  return tokenInfo.token;
4689
4811
  }
4690
4812
  if (this.refreshPromise) {
4691
4813
  return this.refreshPromise;
4692
4814
  }
4693
- this.refreshPromise = new Promise((resolve, reject) => {
4694
- const content = {
4815
+ const parentOrigin = this.parentOrigin;
4816
+ if (!parentOrigin) {
4817
+ return Promise.reject(new AuthenticationError({
4818
+ message: 'Cannot refresh token: basedomain query parameter is missing',
4819
+ statusCode: HttpStatus.UNAUTHORIZED,
4820
+ }));
4821
+ }
4822
+ // Guard before requestHostToken registers the inbound listener — an untrusted
4823
+ // basedomain would otherwise leave the listener live for the full timeout window,
4824
+ // accepting a forged TOKENREFRESHED from that origin.
4825
+ if (!isValidHostOrigin(parentOrigin)) {
4826
+ return Promise.reject(new AuthenticationError({
4827
+ message: 'Cannot refresh token: basedomain is not a trusted UiPath host origin',
4828
+ statusCode: HttpStatus.UNAUTHORIZED,
4829
+ }));
4830
+ }
4831
+ const { promise } = requestHostToken({
4832
+ pinnedOrigin: parentOrigin,
4833
+ sendRequest: () => this.sendMessageToParent(ActionCenterEventNames.REFRESHTOKEN, {
4695
4834
  clientId: this.config.clientId,
4696
4835
  scope: this.config.scope,
4697
- };
4698
- this.sendMessageToParent(ActionCenterEventNames.REFRESHTOKEN, content);
4699
- const messageListener = (event) => {
4700
- if (event.origin !== this.parentOrigin)
4701
- return;
4702
- if (event.data?.eventType !== ActionCenterEventNames.TOKENREFRESHED)
4703
- return;
4704
- clearTimeout(timer);
4705
- if (event.data?.content?.token) {
4706
- const { accessToken, expiresAt } = event.data.content.token;
4707
- this.onTokenRefreshed({ token: accessToken, type: 'secret', expiresAt });
4708
- resolve(accessToken);
4709
- }
4710
- else {
4711
- reject(new AuthenticationError({
4712
- message: 'Failed to fetch access token',
4713
- statusCode: HttpStatus.UNAUTHORIZED,
4714
- }));
4715
- }
4716
- this.refreshPromise = null;
4717
- this.cleanup(messageListener);
4718
- };
4719
- const timer = setTimeout(() => {
4720
- reject(new AuthenticationError({
4721
- message: 'Failed to fetch access token',
4722
- statusCode: HttpStatus.UNAUTHORIZED,
4723
- }));
4724
- this.refreshPromise = null;
4725
- this.cleanup(messageListener);
4726
- }, AUTHENTICATION_TIMEOUT);
4727
- window.addEventListener('message', messageListener);
4836
+ }),
4837
+ responseEventType: ActionCenterEventNames.TOKENREFRESHED,
4838
+ extractToken: (data) => {
4839
+ const token = data?.content?.token;
4840
+ if (!token?.accessToken)
4841
+ return undefined;
4842
+ return { accessToken: token.accessToken, expiresAt: token.expiresAt };
4843
+ },
4844
+ onTokenRefreshed: this.onTokenRefreshed,
4728
4845
  });
4729
- return this.refreshPromise;
4730
- }
4731
- isTokenExpired(tokenInfo) {
4732
- if (!tokenInfo?.expiresAt) {
4733
- return true;
4846
+ this.refreshPromise = promise;
4847
+ try {
4848
+ return await this.refreshPromise;
4849
+ }
4850
+ finally {
4851
+ this.refreshPromise = null;
4734
4852
  }
4735
- return new Date() >= tokenInfo.expiresAt;
4736
4853
  }
4737
4854
  sendMessageToParent(eventType, content) {
4738
- if (window.parent && this.isValidOrigin(this.parentOrigin)) {
4855
+ if (window.parent && isValidHostOrigin(this.parentOrigin)) {
4739
4856
  try {
4740
4857
  window.parent.postMessage({ eventType, content }, this.parentOrigin);
4741
4858
  }
4742
4859
  catch (error) {
4743
- console.warn('Failed to send message to Action Center', JSON.stringify(error));
4860
+ console.warn('ActionCenterTokenManager: postMessage to host failed', JSON.stringify(error));
4744
4861
  }
4745
4862
  }
4746
4863
  }
4747
- cleanup(messageListener) {
4748
- window.removeEventListener('message', messageListener);
4864
+ }
4865
+
4866
+ /**
4867
+ * Event names and payload types for the UIP.* postMessage protocol used
4868
+ * when a coded app is embedded inside a UiPath host (e.g. Governance Portal, Insights UI).
4869
+ *
4870
+ * Flow — app-initiated, mirrors the Action Center protocol:
4871
+ * App → Host: UIP.refreshToken (requests a token; carries clientId + scope
4872
+ * so the host knows which OAuth client to use)
4873
+ * Host → App: UIP.tokenRefreshed (delivers the access token)
4874
+ *
4875
+ * Detection: the host signals embedding via `?host=embed&basedomain=<origin>` in
4876
+ * the iframe src URL. No explicit init message from the host is required.
4877
+ */
4878
+ var UipEmbeddedEventNames;
4879
+ (function (UipEmbeddedEventNames) {
4880
+ UipEmbeddedEventNames["REFRESH_TOKEN"] = "UIP.refreshToken";
4881
+ UipEmbeddedEventNames["TOKEN_REFRESHED"] = "UIP.tokenRefreshed";
4882
+ })(UipEmbeddedEventNames || (UipEmbeddedEventNames = {}));
4883
+
4884
+ function parseExpiresAt(raw) {
4885
+ const d = new Date(raw);
4886
+ if (isNaN(d.getTime())) {
4887
+ console.warn('EmbeddedTokenManager: host sent a malformed expiresAt value — treating token as already expired', raw);
4888
+ return new Date(0);
4889
+ }
4890
+ return d;
4891
+ }
4892
+ function extractToken(data) {
4893
+ const token = data?.content?.token;
4894
+ if (!token?.accessToken)
4895
+ return undefined;
4896
+ return { accessToken: token.accessToken, expiresAt: parseExpiresAt(token.expiresAt) };
4897
+ }
4898
+ /**
4899
+ * Handles token delegation for coded apps embedded inside a UiPath host
4900
+ * (e.g. Governance Portal, Insights UI).
4901
+ *
4902
+ * Detection: the host signals embedding via `?host=embed&basedomain=<origin>`
4903
+ * in the iframe src URL. `parentOrigin` is read from `?basedomain=` and validated
4904
+ * against the trusted UiPath host allowlist before this manager is constructed.
4905
+ * This mirrors the mechanism used by ActionCenterTokenManager.
4906
+ *
4907
+ * On every token expiry the SDK sends `UIP.refreshToken` with `clientId` and
4908
+ * `scope`; the host performs silent SSO and responds with `UIP.tokenRefreshed`.
4909
+ */
4910
+ class EmbeddedTokenManager {
4911
+ /**
4912
+ * @param parentOrigin Validated UiPath host origin from the `?basedomain=` query parameter.
4913
+ * @param config SDK configuration — `clientId` and `scope` are required and forwarded
4914
+ * in every `UIP.refreshToken` request so the host knows which OAuth client to use.
4915
+ * @param onTokenRefreshed Called with the refreshed TokenInfo so the caller
4916
+ * can persist it in the execution context.
4917
+ * @throws {AuthenticationError} if `config.clientId` or `config.scope` are not set.
4918
+ */
4919
+ constructor(parentOrigin, config, onTokenRefreshed) {
4920
+ this.parentOrigin = parentOrigin;
4921
+ this.onTokenRefreshed = onTokenRefreshed;
4922
+ this.refreshPromise = null;
4923
+ this.cancelRefresh = null;
4924
+ if (!config.clientId || !config.scope) {
4925
+ throw new ValidationError({
4926
+ message: 'EmbeddedTokenManager requires clientId and scope to be configured for host-delegated authentication',
4927
+ });
4928
+ }
4929
+ this.clientId = config.clientId;
4930
+ this.scope = config.scope;
4749
4931
  }
4750
- isValidOrigin(origin) {
4751
- const ALLOWED_ORIGINS = ['https://alpha.uipath.com', 'https://staging.uipath.com', 'https://cloud.uipath.com'];
4752
- if (!origin) {
4753
- return false;
4932
+ async refreshAccessToken(tokenInfo) {
4933
+ if (!isTokenExpired(tokenInfo)) {
4934
+ return tokenInfo.token;
4754
4935
  }
4755
- if (ALLOWED_ORIGINS.includes(origin)) {
4756
- return true;
4936
+ if (this.refreshPromise) {
4937
+ return this.refreshPromise;
4757
4938
  }
4939
+ const { promise, cancel } = requestHostToken({
4940
+ pinnedOrigin: this.parentOrigin,
4941
+ sendRequest: () => {
4942
+ try {
4943
+ const message = {
4944
+ eventType: UipEmbeddedEventNames.REFRESH_TOKEN,
4945
+ content: { clientId: this.clientId, scope: this.scope },
4946
+ };
4947
+ window.parent.postMessage(message, this.parentOrigin);
4948
+ }
4949
+ catch (error) {
4950
+ console.warn('EmbeddedTokenManager: postMessage to host failed', error);
4951
+ }
4952
+ },
4953
+ responseEventType: UipEmbeddedEventNames.TOKEN_REFRESHED,
4954
+ extractToken,
4955
+ onTokenRefreshed: this.onTokenRefreshed,
4956
+ });
4957
+ this.cancelRefresh = cancel;
4958
+ this.refreshPromise = promise;
4758
4959
  try {
4759
- const url = new URL(origin);
4760
- return url.hostname === 'localhost';
4960
+ return await this.refreshPromise;
4761
4961
  }
4762
- catch {
4763
- return false;
4962
+ finally {
4963
+ this.refreshPromise = null;
4964
+ this.cancelRefresh = null;
4965
+ }
4966
+ }
4967
+ /** Cancels any in-flight token-refresh request. */
4968
+ destroy() {
4969
+ this.cancelRefresh?.();
4970
+ }
4971
+ }
4972
+
4973
+ /**
4974
+ * SDK Telemetry constants.
4975
+ *
4976
+ * Only the SDK's identity (version, service name, role name, …) lives
4977
+ * here. The Application Insights connection string is injected into
4978
+ * `@uipath/core-telemetry` itself at publish time, and the generic attribute
4979
+ * keys (`Version`, `Service`, `CloudOrganizationName`, …) are owned by
4980
+ * `@uipath/core-telemetry` and consumed there — they are not part of the
4981
+ * SDK's public API.
4982
+ */
4983
+ /** SDK version placeholder — patched by the SDK publish workflow. */
4984
+ const SDK_VERSION = '1.4.0';
4985
+ const CLOUD_ROLE_NAME = 'uipath-ts-sdk';
4986
+ const SDK_SERVICE_NAME = 'UiPath.TypeScript.Sdk';
4987
+ const SDK_LOGGER_NAME = 'uipath-ts-sdk-telemetry';
4988
+ const SDK_RUN_EVENT = 'Sdk.Run';
4989
+
4990
+ /**
4991
+ * UiPath TypeScript SDK Telemetry
4992
+ *
4993
+ * Constructs the SDK's own `TelemetryClient` and binds the SDK-local
4994
+ * `track` / `trackEvent` to it. Each consumer of `@uipath/core-telemetry`
4995
+ * does this independently, so events carry their own consumer's identity
4996
+ * and tenant context.
4997
+ */
4998
+ // Keyed by `CLOUD_ROLE_NAME` so every SDK subpath bundle resolves to the
4999
+ // same `TelemetryClient` instance at runtime. A single `initialize(...)`
5000
+ // from the `UiPath` constructor therefore wires up `@track` decorators
5001
+ // across every subpath bundle (`assets`, `feedback`, `tasks`, …).
5002
+ const sdkClient = getOrCreateClient(CLOUD_ROLE_NAME);
5003
+ const track = createTrack(sdkClient);
5004
+ const trackEvent = createTrackEvent(sdkClient);
5005
+ const telemetryClient = {
5006
+ initialize(context) {
5007
+ sdkClient.initialize({
5008
+ sdkVersion: SDK_VERSION,
5009
+ serviceName: SDK_SERVICE_NAME,
5010
+ cloudRoleName: CLOUD_ROLE_NAME,
5011
+ loggerName: SDK_LOGGER_NAME,
5012
+ defaultEventName: SDK_RUN_EVENT,
5013
+ context,
5014
+ });
5015
+ },
5016
+ /**
5017
+ * Sets the authenticated user's id so every subsequently emitted event
5018
+ * carries it as `CloudUserId`.
5019
+ */
5020
+ setUserId(userId) {
5021
+ sdkClient.setUserId(userId);
5022
+ },
5023
+ };
5024
+
5025
+ /**
5026
+ * Base64 encoding/decoding
5027
+ */
5028
+ /**
5029
+ * Encodes a string to base64
5030
+ * @param str - The string to encode
5031
+ * @returns Base64 encoded string
5032
+ */
5033
+ function encodeBase64(str) {
5034
+ // TextEncoder for UTF-8 encoding (works in both browser and Node.js)
5035
+ const encoder = new TextEncoder();
5036
+ const data = encoder.encode(str);
5037
+ // Convert Uint8Array to base64
5038
+ if (isBrowser) {
5039
+ // Browser environment
5040
+ // Convert Uint8Array to binary string then to base64
5041
+ const binaryString = Array.from(data, byte => String.fromCharCode(byte)).join('');
5042
+ return btoa(binaryString);
5043
+ }
5044
+ else {
5045
+ // Node.js environment
5046
+ return Buffer.from(data).toString('base64');
5047
+ }
5048
+ }
5049
+ /**
5050
+ * Decodes a base64 string
5051
+ * @param base64 - The base64 string to decode
5052
+ * @returns Decoded string
5053
+ */
5054
+ function decodeBase64(base64) {
5055
+ let bytes;
5056
+ if (isBrowser) {
5057
+ // Browser environment
5058
+ const binaryString = atob(base64);
5059
+ bytes = new Uint8Array(binaryString.length);
5060
+ for (let i = 0; i < binaryString.length; i++) {
5061
+ bytes[i] = binaryString.charCodeAt(i);
4764
5062
  }
4765
5063
  }
5064
+ else {
5065
+ // Node.js environment
5066
+ bytes = new Uint8Array(Buffer.from(base64, 'base64'));
5067
+ }
5068
+ // TextDecoder for UTF-8 decoding (works in both browser and Node.js)
5069
+ const decoder = new TextDecoder();
5070
+ return decoder.decode(bytes);
5071
+ }
5072
+
5073
+ /**
5074
+ * Encodes a folder path for the `X-UIPATH-FolderPath-Encoded` header.
5075
+ *
5076
+ * Orchestrator decodes this header as **base64-encoded UTF-16 LE bytes**
5077
+ * (see `HttpHeadersProviderExtensions.GetDecoded` + `OrganizationUnitProvider`
5078
+ * in the Orchestrator repo, which call `Encoding.Unicode.GetString(...)`).
5079
+ * URL-encoding is NOT what the server expects — it must be base64-of-UTF-16-LE
5080
+ * bytes.
5081
+ *
5082
+ * @param folderPath - The folder path (e.g. 'Shared/Finance')
5083
+ * @returns Base64 string suitable for the `X-UIPATH-FolderPath-Encoded` header
5084
+ */
5085
+ function encodeFolderPathHeader(folderPath) {
5086
+ // Force little-endian regardless of host byte order. `Uint16Array` viewed
5087
+ // as `Uint8Array` would use the host's native order — correct on LE hosts
5088
+ // (x86/ARM-LE) but wrong on BE hosts. `DataView.setUint16(..., true)`
5089
+ // pins LE.
5090
+ const buf = new ArrayBuffer(folderPath.length * 2);
5091
+ const view = new DataView(buf);
5092
+ for (let i = 0; i < folderPath.length; i++) {
5093
+ view.setUint16(i * 2, folderPath.charCodeAt(i), true);
5094
+ }
5095
+ const bytes = new Uint8Array(buf);
5096
+ let binary = '';
5097
+ for (let i = 0; i < bytes.byteLength; i++) {
5098
+ binary += String.fromCharCode(bytes[i]);
5099
+ }
5100
+ // btoa is browser-native; Node 16+ also has it as a global
5101
+ return btoa(binary);
5102
+ }
5103
+
5104
+ /**
5105
+ * JWT decoding helpers — payload inspection only, no signature verification.
5106
+ */
5107
+ const BASE64URL_DASH_RE = /-/g;
5108
+ const BASE64URL_UNDERSCORE_RE = /_/g;
5109
+ /**
5110
+ * Converts a base64url-encoded JWT segment to standard base64 with padding.
5111
+ */
5112
+ function base64UrlToBase64(value) {
5113
+ const base64 = value
5114
+ .replace(BASE64URL_DASH_RE, '+')
5115
+ .replace(BASE64URL_UNDERSCORE_RE, '/');
5116
+ return base64.padEnd(base64.length + ((4 - (base64.length % 4)) % 4), '=');
5117
+ }
5118
+ /**
5119
+ * Extracts the user id (`sub` claim) from a JWT access token payload.
5120
+ * Returns an empty string for opaque (non-JWT) tokens or malformed payloads.
5121
+ *
5122
+ * @param token - The access token to inspect
5123
+ * @returns The user id, or an empty string if it cannot be extracted
5124
+ */
5125
+ function extractUserIdFromToken(token) {
5126
+ try {
5127
+ const payload = token.split('.')[1];
5128
+ if (!payload) {
5129
+ return '';
5130
+ }
5131
+ const claims = JSON.parse(decodeBase64(base64UrlToBase64(payload)));
5132
+ const sub = claims['sub'];
5133
+ return typeof sub === 'string' && sub ? sub : '';
5134
+ }
5135
+ catch {
5136
+ return '';
5137
+ }
4766
5138
  }
4767
5139
 
4768
5140
  /**
@@ -4784,10 +5156,15 @@ class TokenManager {
4784
5156
  this.isOAuth = isOAuth;
4785
5157
  this.refreshPromise = null;
4786
5158
  this.actionCenterTokenManager = null;
5159
+ this.embeddedTokenManager = null;
4787
5160
  if (isInActionCenter) {
4788
5161
  this.actionCenterTokenManager = new ActionCenterTokenManager(config, (tokenInfo) => this.setToken(tokenInfo));
4789
5162
  this.isOAuth = false;
4790
5163
  }
5164
+ else if (isHostEmbedded && embeddingOrigin && isValidHostOrigin(embeddingOrigin)) {
5165
+ this.embeddedTokenManager = new EmbeddedTokenManager(embeddingOrigin, config, tokenInfo => this.setToken(tokenInfo));
5166
+ this.isOAuth = false;
5167
+ }
4791
5168
  }
4792
5169
  /**
4793
5170
  * Checks if a token is expired
@@ -4818,6 +5195,10 @@ class TokenManager {
4818
5195
  if (this.actionCenterTokenManager) {
4819
5196
  return await this.actionCenterTokenManager.refreshAccessToken(tokenInfo);
4820
5197
  }
5198
+ // Generic embedded path — active whenever the app is embedded in a UiPath host page
5199
+ if (this.embeddedTokenManager) {
5200
+ return await this.embeddedTokenManager.refreshAccessToken(tokenInfo);
5201
+ }
4821
5202
  // For secret-based tokens, they never expire
4822
5203
  if (tokenInfo.type === 'secret') {
4823
5204
  return tokenInfo.token;
@@ -4956,6 +5337,13 @@ class TokenManager {
4956
5337
  }
4957
5338
  return true;
4958
5339
  }
5340
+ /**
5341
+ * Releases resources held by this instance.
5342
+ * Must be called when the TokenManager is no longer needed to prevent listener leaks.
5343
+ */
5344
+ destroy() {
5345
+ this.embeddedTokenManager?.destroy();
5346
+ }
4959
5347
  /**
4960
5348
  * Clears the current token
4961
5349
  */
@@ -4977,6 +5365,7 @@ class TokenManager {
4977
5365
  */
4978
5366
  _updateExecutionContext(tokenInfo) {
4979
5367
  this.executionContext.set('tokenInfo', tokenInfo);
5368
+ telemetryClient.setUserId(extractUserIdFromToken(tokenInfo.token));
4980
5369
  }
4981
5370
  /**
4982
5371
  * Refreshes the access token using the stored refresh token.
@@ -5006,6 +5395,9 @@ class TokenManager {
5006
5395
  * Internal method to perform the actual token refresh
5007
5396
  */
5008
5397
  async _doRefreshToken() {
5398
+ // Destructure before the type guard — hasOAuthConfig narrows this.config to
5399
+ // { clientId, redirectUri, scope } which does not include BaseConfig fields.
5400
+ const { orgName, baseUrl } = this.config;
5009
5401
  // Check if we're in OAuth flow
5010
5402
  if (!hasOAuthConfig(this.config)) {
5011
5403
  throw new Error('refreshAccessToken is only available in OAuth flow');
@@ -5015,13 +5407,12 @@ class TokenManager {
5015
5407
  if (!tokenInfo?.refreshToken) {
5016
5408
  throw new Error('No refresh token available. User may need to re-authenticate.');
5017
5409
  }
5018
- const orgName = this.config.orgName;
5019
5410
  const body = new URLSearchParams({
5020
5411
  grant_type: 'refresh_token',
5021
5412
  client_id: this.config.clientId,
5022
5413
  refresh_token: tokenInfo.refreshToken
5023
5414
  });
5024
- const response = await fetch(`${this.config.baseUrl}/${orgName}/identity_/connect/token`, {
5415
+ const response = await fetch(`${baseUrl}/${orgName}/identity_/connect/token`, {
5025
5416
  method: 'POST',
5026
5417
  headers: {
5027
5418
  'Content-Type': 'application/x-www-form-urlencoded'
@@ -5481,51 +5872,6 @@ function normalizeBaseUrl(url) {
5481
5872
  return url.endsWith('/') ? url.slice(0, -1) : url;
5482
5873
  }
5483
5874
 
5484
- /**
5485
- * SDK Telemetry constants.
5486
- *
5487
- * Only the SDK's identity (version, service name, role name, …) lives
5488
- * here. The Application Insights connection string is injected into
5489
- * `@uipath/core-telemetry` itself at publish time, and the generic attribute
5490
- * keys (`Version`, `Service`, `CloudOrganizationName`, …) are owned by
5491
- * `@uipath/core-telemetry` and consumed there — they are not part of the
5492
- * SDK's public API.
5493
- */
5494
- /** SDK version placeholder — patched by the SDK publish workflow. */
5495
- const SDK_VERSION = '1.3.11';
5496
- const CLOUD_ROLE_NAME = 'uipath-ts-sdk';
5497
- const SDK_SERVICE_NAME = 'UiPath.TypeScript.Sdk';
5498
- const SDK_LOGGER_NAME = 'uipath-ts-sdk-telemetry';
5499
- const SDK_RUN_EVENT = 'Sdk.Run';
5500
-
5501
- /**
5502
- * UiPath TypeScript SDK Telemetry
5503
- *
5504
- * Constructs the SDK's own `TelemetryClient` and binds the SDK-local
5505
- * `track` / `trackEvent` to it. Each consumer of `@uipath/core-telemetry`
5506
- * does this independently, so events carry their own consumer's identity
5507
- * and tenant context.
5508
- */
5509
- // Keyed by `CLOUD_ROLE_NAME` so every SDK subpath bundle resolves to the
5510
- // same `TelemetryClient` instance at runtime. A single `initialize(...)`
5511
- // from the `UiPath` constructor therefore wires up `@track` decorators
5512
- // across every subpath bundle (`assets`, `feedback`, `tasks`, …).
5513
- const sdkClient = getOrCreateClient(CLOUD_ROLE_NAME);
5514
- const track = createTrack(sdkClient);
5515
- const trackEvent = createTrackEvent(sdkClient);
5516
- const telemetryClient = {
5517
- initialize(context) {
5518
- sdkClient.initialize({
5519
- sdkVersion: SDK_VERSION,
5520
- serviceName: SDK_SERVICE_NAME,
5521
- cloudRoleName: CLOUD_ROLE_NAME,
5522
- loggerName: SDK_LOGGER_NAME,
5523
- defaultEventName: SDK_RUN_EVENT,
5524
- context,
5525
- });
5526
- },
5527
- };
5528
-
5529
5875
  /**
5530
5876
  * SDK Internals Registry - Internal registry for SDK instances
5531
5877
  *
@@ -5635,7 +5981,7 @@ function loadFromMetaTags() {
5635
5981
  return hasAnyValue ? config : null;
5636
5982
  }
5637
5983
 
5638
- var _UiPath_instances, _UiPath_config, _UiPath_authService, _UiPath_initialized, _UiPath_partialConfig, _UiPath_multiLogin, _UiPath_metaFolderKey, _UiPath_initializeWithConfig, _UiPath_loadConfig;
5984
+ var _UiPath_instances, _UiPath_config, _UiPath_authService, _UiPath_initialized, _UiPath_partialConfig, _UiPath_multiLogin, _UiPath_metaFolderKey, _UiPath_metaOrgId, _UiPath_metaTenantId, _UiPath_initializeWithConfig, _UiPath_loadConfig;
5639
5985
  /**
5640
5986
  * UiPath - Core SDK class for authentication and configuration management.
5641
5987
  *
@@ -5680,9 +6026,18 @@ let UiPath$1 = class UiPath {
5680
6026
  // deployments). Not accepted via the public constructor; lives here so the
5681
6027
  // SDK can flow it through to BaseService.config without polluting BaseConfig.
5682
6028
  _UiPath_metaFolderKey.set(this, void 0);
6029
+ // Org/tenant ids captured from the meta tags before the constructor config
6030
+ // is merged in. The `uipath:org-name`/`uipath:tenant-name` meta tags always
6031
+ // carry org/tenant *ids* in coded-app deployments, whereas a
6032
+ // constructor-supplied `orgName`/`tenantName` may be actual names — so the
6033
+ // telemetry ids must be read from the meta tags.
6034
+ _UiPath_metaOrgId.set(this, void 0);
6035
+ _UiPath_metaTenantId.set(this, void 0);
5683
6036
  // Load configuration from meta tags
5684
6037
  const configFromMetaTags = loadFromMetaTags();
5685
6038
  __classPrivateFieldSet(this, _UiPath_metaFolderKey, configFromMetaTags?.folderKey, "f");
6039
+ __classPrivateFieldSet(this, _UiPath_metaOrgId, configFromMetaTags?.orgName, "f");
6040
+ __classPrivateFieldSet(this, _UiPath_metaTenantId, configFromMetaTags?.tenantName, "f");
5686
6041
  // Merge configuration: constructor config overrides meta tags
5687
6042
  const mergedConfig = config ? { ...configFromMetaTags, ...config } : configFromMetaTags;
5688
6043
  if (mergedConfig && isCompleteConfig(mergedConfig)) {
@@ -5789,6 +6144,13 @@ let UiPath$1 = class UiPath {
5789
6144
  getToken() {
5790
6145
  return __classPrivateFieldGet(this, _UiPath_authService, "f")?.getToken();
5791
6146
  }
6147
+ /**
6148
+ * Releases resources held by this SDK instance.
6149
+ * Cancels any in-flight token-refresh request. Call this when the coded app is unmounted.
6150
+ */
6151
+ destroy() {
6152
+ __classPrivateFieldGet(this, _UiPath_authService, "f")?.getTokenManager()?.destroy();
6153
+ }
5792
6154
  /**
5793
6155
  * Logout from the SDK, clearing all authentication state.
5794
6156
  * After calling this method, the user will need to re-initialize to authenticate again.
@@ -5811,7 +6173,7 @@ let UiPath$1 = class UiPath {
5811
6173
  __classPrivateFieldGet(this, _UiPath_authService, "f")?.updateToken(tokenInfo);
5812
6174
  }
5813
6175
  };
5814
- _UiPath_config = new WeakMap(), _UiPath_authService = new WeakMap(), _UiPath_initialized = new WeakMap(), _UiPath_partialConfig = new WeakMap(), _UiPath_multiLogin = new WeakMap(), _UiPath_metaFolderKey = new WeakMap(), _UiPath_instances = new WeakSet(), _UiPath_initializeWithConfig = function _UiPath_initializeWithConfig(config) {
6176
+ _UiPath_config = new WeakMap(), _UiPath_authService = new WeakMap(), _UiPath_initialized = new WeakMap(), _UiPath_partialConfig = new WeakMap(), _UiPath_multiLogin = new WeakMap(), _UiPath_metaFolderKey = new WeakMap(), _UiPath_metaOrgId = new WeakMap(), _UiPath_metaTenantId = new WeakMap(), _UiPath_instances = new WeakSet(), _UiPath_initializeWithConfig = function _UiPath_initializeWithConfig(config) {
5815
6177
  // Validate and normalize the configuration
5816
6178
  validateConfig(config);
5817
6179
  const hasSecretAuth = hasSecretConfig(config);
@@ -5847,9 +6209,11 @@ _UiPath_config = new WeakMap(), _UiPath_authService = new WeakMap(), _UiPath_ini
5847
6209
  orgName: internalConfig.orgName,
5848
6210
  tenantName: internalConfig.tenantName
5849
6211
  };
5850
- // Initialize telemetry with SDK configuration
6212
+ // Initialize telemetry with SDK configuration.
5851
6213
  telemetryClient.initialize({
5852
6214
  baseUrl: config.baseUrl,
6215
+ orgId: __classPrivateFieldGet(this, _UiPath_metaOrgId, "f"),
6216
+ tenantId: __classPrivateFieldGet(this, _UiPath_metaTenantId, "f"),
5853
6217
  orgName: config.orgName,
5854
6218
  tenantName: config.tenantName,
5855
6219
  clientId: hasOAuthAuth ? config.clientId : undefined,
@@ -5868,6 +6232,8 @@ _UiPath_config = new WeakMap(), _UiPath_authService = new WeakMap(), _UiPath_ini
5868
6232
  // Load from meta tags
5869
6233
  const metaConfig = loadFromMetaTags();
5870
6234
  __classPrivateFieldSet(this, _UiPath_metaFolderKey, metaConfig?.folderKey, "f");
6235
+ __classPrivateFieldSet(this, _UiPath_metaOrgId, metaConfig?.orgName, "f");
6236
+ __classPrivateFieldSet(this, _UiPath_metaTenantId, metaConfig?.tenantName, "f");
5871
6237
  // Merge with any partial config from constructor (constructor overrides meta tags)
5872
6238
  const merged = { ...metaConfig, ...__classPrivateFieldGet(this, _UiPath_partialConfig, "f") };
5873
6239
  if (!isCompleteConfig(merged)) {
@@ -6315,74 +6681,26 @@ function filterUndefined(obj) {
6315
6681
  result[key] = value;
6316
6682
  }
6317
6683
  }
6318
- return result;
6319
- }
6320
- /**
6321
- * Helper function for OData responses that ALWAYS return 200 with array indication
6322
- * Empty array = success, Non-empty array = error
6323
- * Used for task assignment APIs that don't use HTTP status codes for errors
6324
- */
6325
- function processODataArrayResponse(oDataResponse, successData) {
6326
- // Empty array = success
6327
- if (oDataResponse.value.length === 0) {
6328
- return {
6329
- success: true,
6330
- data: successData
6331
- };
6332
- }
6333
- // Non-empty array = error details
6334
- return {
6335
- success: false,
6336
- data: oDataResponse.value
6337
- };
6338
- }
6339
-
6340
- /**
6341
- * Base64 encoding/decoding
6342
- */
6343
- /**
6344
- * Encodes a string to base64
6345
- * @param str - The string to encode
6346
- * @returns Base64 encoded string
6347
- */
6348
- function encodeBase64(str) {
6349
- // TextEncoder for UTF-8 encoding (works in both browser and Node.js)
6350
- const encoder = new TextEncoder();
6351
- const data = encoder.encode(str);
6352
- // Convert Uint8Array to base64
6353
- if (isBrowser) {
6354
- // Browser environment
6355
- // Convert Uint8Array to binary string then to base64
6356
- const binaryString = Array.from(data, byte => String.fromCharCode(byte)).join('');
6357
- return btoa(binaryString);
6358
- }
6359
- else {
6360
- // Node.js environment
6361
- return Buffer.from(data).toString('base64');
6362
- }
6363
- }
6364
- /**
6365
- * Decodes a base64 string
6366
- * @param base64 - The base64 string to decode
6367
- * @returns Decoded string
6368
- */
6369
- function decodeBase64(base64) {
6370
- let bytes;
6371
- if (isBrowser) {
6372
- // Browser environment
6373
- const binaryString = atob(base64);
6374
- bytes = new Uint8Array(binaryString.length);
6375
- for (let i = 0; i < binaryString.length; i++) {
6376
- bytes[i] = binaryString.charCodeAt(i);
6377
- }
6378
- }
6379
- else {
6380
- // Node.js environment
6381
- bytes = new Uint8Array(Buffer.from(base64, 'base64'));
6684
+ return result;
6685
+ }
6686
+ /**
6687
+ * Helper function for OData responses that ALWAYS return 200 with array indication
6688
+ * Empty array = success, Non-empty array = error
6689
+ * Used for task assignment APIs that don't use HTTP status codes for errors
6690
+ */
6691
+ function processODataArrayResponse(oDataResponse, successData) {
6692
+ // Empty array = success
6693
+ if (oDataResponse.value.length === 0) {
6694
+ return {
6695
+ success: true,
6696
+ data: successData
6697
+ };
6382
6698
  }
6383
- // TextDecoder for UTF-8 decoding (works in both browser and Node.js)
6384
- const decoder = new TextDecoder();
6385
- return decoder.decode(bytes);
6699
+ // Non-empty array = error details
6700
+ return {
6701
+ success: false,
6702
+ data: oDataResponse.value
6703
+ };
6386
6704
  }
6387
6705
 
6388
6706
  /**
@@ -7181,8 +7499,9 @@ class PaginationHelpers {
7181
7499
  });
7182
7500
  }
7183
7501
  // Extract and transform items from response
7184
- // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
7185
- const rawItems = Array.isArray(response.data) ? response.data : response.data?.[itemsField];
7502
+ // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N }).
7503
+ // itemsField may be a dotted path (e.g. 'data.agents') for nested envelopes.
7504
+ const rawItems = Array.isArray(response.data) ? response.data : resolveNestedField(response.data, itemsField);
7186
7505
  const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
7187
7506
  const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
7188
7507
  // Parse items - automatically handle JSON string responses
@@ -7228,7 +7547,7 @@ class PaginationHelpers {
7228
7547
  getEndpoint: config.getEndpoint,
7229
7548
  folderId,
7230
7549
  headers: config.headers,
7231
- paginationParams: cursor ? { cursor, pageSize } : jumpToPage ? { jumpToPage, pageSize } : { pageSize },
7550
+ paginationParams: cursor ? { cursor, pageSize } : jumpToPage !== undefined ? { jumpToPage, pageSize } : { pageSize },
7232
7551
  additionalParams: prefixedOptions,
7233
7552
  transformFn: config.transformFn,
7234
7553
  method: config.method,
@@ -7431,6 +7750,8 @@ class BaseService {
7431
7750
  // When true (default), converts pageNumber to a skip/offset value (e.g., page 3 with pageSize 10 → skip 20).
7432
7751
  // When false, passes pageNumber directly as the offset param — used by APIs that accept a page number instead of a record offset.
7433
7752
  const convertToSkip = paginationParams?.convertToSkip ?? true;
7753
+ // When true, sends pageNumber - 1 (for 0-based APIs). Default false (1-based).
7754
+ const zeroBased = paginationParams?.zeroBased ?? false;
7434
7755
  requestParams[pageSizeParam] = limitedPageSize;
7435
7756
  if (convertToSkip) {
7436
7757
  if (params.pageNumber && params.pageNumber > 1) {
@@ -7438,7 +7759,8 @@ class BaseService {
7438
7759
  }
7439
7760
  }
7440
7761
  else {
7441
- requestParams[offsetParam] = params.pageNumber || 1;
7762
+ const sdkPageNumber = params.pageNumber || 1;
7763
+ requestParams[offsetParam] = zeroBased ? sdkPageNumber - 1 : sdkPageNumber;
7442
7764
  }
7443
7765
  {
7444
7766
  requestParams[countParam] = true;
@@ -7467,8 +7789,9 @@ class BaseService {
7467
7789
  const totalCountField = fields.totalCountField || 'totalRecordCount';
7468
7790
  const continuationTokenField = fields.continuationTokenField || 'continuationToken';
7469
7791
  // Extract items and metadata
7470
- // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
7471
- const items = Array.isArray(response.data) ? response.data : (response.data[itemsField] || []);
7792
+ // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N }).
7793
+ // itemsField may be a dotted path (e.g. 'data.agents') for nested envelopes.
7794
+ const items = Array.isArray(response.data) ? response.data : (resolveNestedField(response.data, itemsField) || []);
7472
7795
  const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
7473
7796
  const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
7474
7797
  const continuationToken = response.data[continuationTokenField];
@@ -7551,12 +7874,12 @@ function createEntityMethods(entityData, service) {
7551
7874
  throw new Error('Entity ID is undefined');
7552
7875
  return service.deleteRecordsById(entityData.id, recordIds, options);
7553
7876
  },
7554
- async deleteRecord(recordId) {
7877
+ async deleteRecord(recordId, options) {
7555
7878
  if (!entityData.id)
7556
7879
  throw new Error('Entity ID is undefined');
7557
7880
  if (!recordId)
7558
7881
  throw new Error('Record ID is undefined');
7559
- return service.deleteRecordById(entityData.id, recordId);
7882
+ return service.deleteRecordById(entityData.id, recordId, options);
7560
7883
  },
7561
7884
  async getAllRecords(options) {
7562
7885
  if (!entityData.id)
@@ -7570,30 +7893,30 @@ function createEntityMethods(entityData, service) {
7570
7893
  throw new Error('Record ID is undefined');
7571
7894
  return service.getRecordById(entityData.id, recordId, options);
7572
7895
  },
7573
- async downloadAttachment(recordId, fieldName) {
7896
+ async downloadAttachment(recordId, fieldName, options) {
7574
7897
  if (!entityData.id)
7575
7898
  throw new Error('Entity ID is undefined');
7576
- return service.downloadAttachment(entityData.id, recordId, fieldName);
7899
+ return service.downloadAttachment(entityData.id, recordId, fieldName, options);
7577
7900
  },
7578
7901
  async uploadAttachment(recordId, fieldName, file, options) {
7579
7902
  if (!entityData.id)
7580
7903
  throw new Error('Entity ID is undefined');
7581
7904
  return service.uploadAttachment(entityData.id, recordId, fieldName, file, options);
7582
7905
  },
7583
- async deleteAttachment(recordId, fieldName) {
7906
+ async deleteAttachment(recordId, fieldName, options) {
7584
7907
  if (!entityData.id)
7585
7908
  throw new Error('Entity ID is undefined');
7586
- return service.deleteAttachment(entityData.id, recordId, fieldName);
7909
+ return service.deleteAttachment(entityData.id, recordId, fieldName, options);
7587
7910
  },
7588
7911
  async queryRecords(options) {
7589
7912
  if (!entityData.id)
7590
7913
  throw new Error('Entity ID is undefined');
7591
7914
  return service.queryRecordsById(entityData.id, options);
7592
7915
  },
7593
- async importRecords(file) {
7916
+ async importRecords(file, options) {
7594
7917
  if (!entityData.id)
7595
7918
  throw new Error('Entity ID is undefined');
7596
- return service.importRecordsById(entityData.id, file);
7919
+ return service.importRecordsById(entityData.id, file, options);
7597
7920
  },
7598
7921
  async insert(data, options) {
7599
7922
  return this.insertRecord(data, options);
@@ -7604,10 +7927,10 @@ function createEntityMethods(entityData, service) {
7604
7927
  async getRecords(options) {
7605
7928
  return this.getAllRecords(options);
7606
7929
  },
7607
- async delete() {
7930
+ async delete(options) {
7608
7931
  if (!entityData.id)
7609
7932
  throw new Error('Entity ID is undefined');
7610
- return service.deleteById(entityData.id);
7933
+ return service.deleteById(entityData.id, options);
7611
7934
  },
7612
7935
  async update(options) {
7613
7936
  if (!entityData.id)
@@ -7937,6 +8260,7 @@ class EntityService extends BaseService {
7937
8260
  * Gets entity metadata by entity ID with attached operation methods
7938
8261
  *
7939
8262
  * @param id - UUID of the entity
8263
+ * @param options - Optional {@link EntityGetByIdOptions} (e.g. `folderKey` for folder-scoped entities)
7940
8264
  * @returns Promise resolving to entity metadata with schema information and operation methods
7941
8265
  *
7942
8266
  * @example
@@ -7946,6 +8270,9 @@ class EntityService extends BaseService {
7946
8270
  * const entities = new Entities(sdk);
7947
8271
  * const entity = await entities.getById("<entityId>");
7948
8272
  *
8273
+ * // Folder-scoped: pass the entity's folder key
8274
+ * const folderEntity = await entities.getById("<entityId>", { folderKey: "<folderKey>" });
8275
+ *
7949
8276
  * // Call operations directly on the entity
7950
8277
  * const records = await entity.getAllRecords();
7951
8278
  *
@@ -7959,9 +8286,9 @@ class EntityService extends BaseService {
7959
8286
  * ]);
7960
8287
  * ```
7961
8288
  */
7962
- async getById(id) {
8289
+ async getById(id, options) {
7963
8290
  // Get entity metadata
7964
- const response = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.GET_BY_ID(id));
8291
+ const response = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.GET_BY_ID(id), { headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }) });
7965
8292
  // Apply EntityMap transformations
7966
8293
  const metadata = transformData(response.data, EntityMap);
7967
8294
  // Transform metadata with field mappers
@@ -8004,9 +8331,14 @@ class EntityService extends BaseService {
8004
8331
  * ```
8005
8332
  */
8006
8333
  async getAllRecords(entityId, options) {
8334
+ // folderKey is header-only — destructure it out so PaginationHelpers doesn't serialise it
8335
+ // into the query string as $folderKey.
8336
+ const { folderKey, ...rest } = options ?? {};
8337
+ const downstreamOptions = options === undefined ? undefined : rest;
8007
8338
  return PaginationHelpers.getAll({
8008
8339
  serviceAccess: this.createPaginationServiceAccess(),
8009
8340
  getEndpoint: () => DATA_FABRIC_ENDPOINTS.ENTITY.GET_ENTITY_RECORDS(entityId),
8341
+ headers: createHeaders({ [FOLDER_KEY]: folderKey }),
8010
8342
  pagination: {
8011
8343
  paginationType: PaginationType.OFFSET,
8012
8344
  itemsField: ENTITY_PAGINATION.ITEMS_FIELD,
@@ -8018,7 +8350,7 @@ class EntityService extends BaseService {
8018
8350
  }
8019
8351
  },
8020
8352
  excludeFromPrefix: ['expansionLevel'] // Don't add ODATA prefix to expansionLevel
8021
- }, options);
8353
+ }, downstreamOptions);
8022
8354
  }
8023
8355
  /**
8024
8356
  * Gets a single entity record by entity ID and record ID
@@ -8043,7 +8375,7 @@ class EntityService extends BaseService {
8043
8375
  const params = createParams({
8044
8376
  expansionLevel: options.expansionLevel
8045
8377
  });
8046
- const response = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.GET_RECORD_BY_ID(entityId, recordId), { params });
8378
+ const response = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.GET_RECORD_BY_ID(entityId, recordId), { params, headers: createHeaders({ [FOLDER_KEY]: options.folderKey }) });
8047
8379
  return response.data;
8048
8380
  }
8049
8381
  /**
@@ -8075,7 +8407,7 @@ class EntityService extends BaseService {
8075
8407
  });
8076
8408
  const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.INSERT_BY_ID(id), data, {
8077
8409
  params,
8078
- ...options
8410
+ headers: createHeaders({ [FOLDER_KEY]: options.folderKey }),
8079
8411
  });
8080
8412
  return response.data;
8081
8413
  }
@@ -8116,7 +8448,7 @@ class EntityService extends BaseService {
8116
8448
  });
8117
8449
  const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.BATCH_INSERT_BY_ID(id), data, {
8118
8450
  params,
8119
- ...options
8451
+ headers: createHeaders({ [FOLDER_KEY]: options.folderKey }),
8120
8452
  });
8121
8453
  return response.data;
8122
8454
  }
@@ -8150,7 +8482,7 @@ class EntityService extends BaseService {
8150
8482
  });
8151
8483
  const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPDATE_RECORD_BY_ID(entityId, recordId), data, {
8152
8484
  params,
8153
- ...options
8485
+ headers: createHeaders({ [FOLDER_KEY]: options.folderKey }),
8154
8486
  });
8155
8487
  return response.data;
8156
8488
  }
@@ -8192,7 +8524,7 @@ class EntityService extends BaseService {
8192
8524
  });
8193
8525
  const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPDATE_BY_ID(id), data, {
8194
8526
  params,
8195
- ...options
8527
+ headers: createHeaders({ [FOLDER_KEY]: options.folderKey }),
8196
8528
  });
8197
8529
  return response.data;
8198
8530
  }
@@ -8224,7 +8556,7 @@ class EntityService extends BaseService {
8224
8556
  });
8225
8557
  const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.DELETE_BY_ID(id), recordIds, {
8226
8558
  params,
8227
- ...options
8559
+ headers: createHeaders({ [FOLDER_KEY]: options.folderKey }),
8228
8560
  });
8229
8561
  return response.data;
8230
8562
  }
@@ -8236,6 +8568,7 @@ class EntityService extends BaseService {
8236
8568
  *
8237
8569
  * @param entityId - UUID of the entity
8238
8570
  * @param recordId - UUID of the record to delete
8571
+ * @param options - Optional {@link EntityDeleteRecordByIdOptions} (e.g. `folderKey` for folder-scoped entities)
8239
8572
  * @returns Promise resolving to void on success
8240
8573
  * @example
8241
8574
  * ```typescript
@@ -8244,10 +8577,13 @@ class EntityService extends BaseService {
8244
8577
  * const entities = new Entities(sdk);
8245
8578
  *
8246
8579
  * await entities.deleteRecordById("<entityId>", "<recordId>");
8580
+ *
8581
+ * // Folder-scoped: pass the entity's folder key
8582
+ * await entities.deleteRecordById("<entityId>", "<recordId>", { folderKey: "<folderKey>" });
8247
8583
  * ```
8248
8584
  */
8249
- async deleteRecordById(entityId, recordId) {
8250
- await this.delete(DATA_FABRIC_ENDPOINTS.ENTITY.DELETE_RECORD_BY_ID(entityId, recordId));
8585
+ async deleteRecordById(entityId, recordId, options) {
8586
+ await this.delete(DATA_FABRIC_ENDPOINTS.ENTITY.DELETE_RECORD_BY_ID(entityId, recordId), { headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }) });
8251
8587
  }
8252
8588
  /**
8253
8589
  * Gets all entities in the system
@@ -8333,10 +8669,15 @@ class EntityService extends BaseService {
8333
8669
  * ```
8334
8670
  */
8335
8671
  async queryRecordsById(id, options) {
8672
+ // folderKey is header-only — destructure it out so PaginationHelpers doesn't include
8673
+ // it in the POST body alongside the query filters.
8674
+ const { folderKey, ...rest } = options ?? {};
8675
+ const downstreamOptions = options === undefined ? undefined : rest;
8336
8676
  return PaginationHelpers.getAll({
8337
8677
  serviceAccess: this.createPaginationServiceAccess(),
8338
8678
  getEndpoint: () => DATA_FABRIC_ENDPOINTS.ENTITY.QUERY_BY_ID(id),
8339
8679
  method: HTTP_METHODS.POST,
8680
+ headers: createHeaders({ [FOLDER_KEY]: folderKey }),
8340
8681
  pagination: {
8341
8682
  paginationType: PaginationType.OFFSET,
8342
8683
  itemsField: ENTITY_PAGINATION.ITEMS_FIELD,
@@ -8348,13 +8689,14 @@ class EntityService extends BaseService {
8348
8689
  }
8349
8690
  },
8350
8691
  excludeFromPrefix: ['expansionLevel', 'filterGroup', 'selectedFields', 'sortOptions', 'aggregates', 'groupBy']
8351
- }, options);
8692
+ }, downstreamOptions);
8352
8693
  }
8353
8694
  /**
8354
8695
  * Imports records from a CSV file into an entity
8355
8696
  *
8356
8697
  * @param id - UUID of the entity
8357
8698
  * @param file - CSV file to import (Blob, File, or Uint8Array)
8699
+ * @param options - Optional {@link EntityImportRecordsByIdOptions} (e.g. `folderKey` for folder-scoped entities)
8358
8700
  * @returns Promise resolving to import result with record counts
8359
8701
  *
8360
8702
  * @example
@@ -8375,10 +8717,12 @@ class EntityService extends BaseService {
8375
8717
  * if (result.errorFileLink) {
8376
8718
  * console.log(`Error file link: ${result.errorFileLink}`);
8377
8719
  * }
8720
+ *
8721
+ * // Folder-scoped entity: pass the entity's folder key
8722
+ * await entities.importRecordsById("<entityId>", fileInput.files[0], { folderKey: "<folderKey>" });
8378
8723
  * ```
8379
- * @internal
8380
8724
  */
8381
- async importRecordsById(id, file) {
8725
+ async importRecordsById(id, file, options) {
8382
8726
  const formData = new FormData();
8383
8727
  if (file instanceof Uint8Array) {
8384
8728
  formData.append('file', new Blob([file.buffer]));
@@ -8386,7 +8730,7 @@ class EntityService extends BaseService {
8386
8730
  else {
8387
8731
  formData.append('file', file);
8388
8732
  }
8389
- const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.BULK_UPLOAD_BY_ID(id), formData);
8733
+ const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.BULK_UPLOAD_BY_ID(id), formData, { headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }) });
8390
8734
  return response.data;
8391
8735
  }
8392
8736
  /**
@@ -8395,6 +8739,7 @@ class EntityService extends BaseService {
8395
8739
  * @param entityId - UUID of the entity
8396
8740
  * @param recordId - UUID of the record containing the attachment
8397
8741
  * @param fieldName - Name of the File-type field containing the attachment
8742
+ * @param options - Optional {@link EntityDownloadAttachmentOptions} (e.g. `folderKey` for folder-scoped entities)
8398
8743
  * @returns Promise resolving to Blob containing the file content
8399
8744
  *
8400
8745
  * @example
@@ -8413,11 +8758,15 @@ class EntityService extends BaseService {
8413
8758
  *
8414
8759
  * // Download attachment for a specific record and field
8415
8760
  * const blob = await entities.downloadAttachment(entityId, recordId, 'Documents');
8761
+ *
8762
+ * // Folder-scoped: pass the entity's folder key
8763
+ * const blob = await entities.downloadAttachment(entityId, recordId, 'Documents', { folderKey: "<folderKey>" });
8416
8764
  * ```
8417
8765
  */
8418
- async downloadAttachment(entityId, recordId, fieldName) {
8766
+ async downloadAttachment(entityId, recordId, fieldName, options) {
8419
8767
  const response = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.DOWNLOAD_ATTACHMENT(entityId, recordId, fieldName), {
8420
- responseType: RESPONSE_TYPES.BLOB
8768
+ responseType: RESPONSE_TYPES.BLOB,
8769
+ headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }),
8421
8770
  });
8422
8771
  return response.data;
8423
8772
  }
@@ -8428,7 +8777,7 @@ class EntityService extends BaseService {
8428
8777
  * @param recordId - UUID of the record to upload the attachment to
8429
8778
  * @param fieldName - Name of the File-type field
8430
8779
  * @param file - File to upload (Blob, File, or Uint8Array)
8431
- * @param options - Optional {@link EntityUploadAttachmentOptions} (e.g. expansionLevel)
8780
+ * @param options - Optional {@link EntityUploadAttachmentOptions} (e.g. `expansionLevel`, `folderKey` for folder-scoped entities)
8432
8781
  * @returns Promise resolving to {@link EntityUploadAttachmentResponse}
8433
8782
  *
8434
8783
  * @example
@@ -8447,6 +8796,9 @@ class EntityService extends BaseService {
8447
8796
  *
8448
8797
  * // Upload a file attachment
8449
8798
  * const response = await entities.uploadAttachment(entityId, recordId, 'Documents', file);
8799
+ *
8800
+ * // Folder-scoped entity: pass the entity's folder key
8801
+ * await entities.uploadAttachment(entityId, recordId, 'Documents', file, { folderKey: "<folderKey>" });
8450
8802
  * ```
8451
8803
  */
8452
8804
  async uploadAttachment(entityId, recordId, fieldName, file, options) {
@@ -8458,7 +8810,10 @@ class EntityService extends BaseService {
8458
8810
  formData.append('file', file);
8459
8811
  }
8460
8812
  const params = createParams({ expansionLevel: options?.expansionLevel });
8461
- const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPLOAD_ATTACHMENT(entityId, recordId, fieldName), formData, { params });
8813
+ const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPLOAD_ATTACHMENT(entityId, recordId, fieldName), formData, {
8814
+ params,
8815
+ headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }),
8816
+ });
8462
8817
  return response.data;
8463
8818
  }
8464
8819
  /**
@@ -8467,6 +8822,7 @@ class EntityService extends BaseService {
8467
8822
  * @param entityId - UUID of the entity
8468
8823
  * @param recordId - UUID of the record containing the attachment
8469
8824
  * @param fieldName - Name of the File-type field containing the attachment
8825
+ * @param options - Optional {@link EntityDeleteAttachmentOptions} (e.g. `folderKey` for folder-scoped entities)
8470
8826
  * @returns Promise resolving to {@link EntityDeleteAttachmentResponse}
8471
8827
  *
8472
8828
  * @example
@@ -8485,10 +8841,13 @@ class EntityService extends BaseService {
8485
8841
  *
8486
8842
  * // Delete attachment for a specific record and field
8487
8843
  * await entities.deleteAttachment(entityId, recordId, 'Documents');
8844
+ *
8845
+ * // Folder-scoped: pass the entity's folder key
8846
+ * await entities.deleteAttachment(entityId, recordId, 'Documents', { folderKey: "<folderKey>" });
8488
8847
  * ```
8489
8848
  */
8490
- async deleteAttachment(entityId, recordId, fieldName) {
8491
- const response = await this.delete(DATA_FABRIC_ENDPOINTS.ENTITY.DELETE_ATTACHMENT(entityId, recordId, fieldName));
8849
+ async deleteAttachment(entityId, recordId, fieldName, options) {
8850
+ const response = await this.delete(DATA_FABRIC_ENDPOINTS.ENTITY.DELETE_ATTACHMENT(entityId, recordId, fieldName), { headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }) });
8492
8851
  return response.data;
8493
8852
  }
8494
8853
  /**
@@ -8551,23 +8910,27 @@ class EntityService extends BaseService {
8551
8910
  externalFields: opts.externalFields ?? [],
8552
8911
  },
8553
8912
  };
8554
- const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPSERT, payload);
8913
+ const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPSERT, payload, { headers: createHeaders({ [FOLDER_KEY]: opts.folderKey }) });
8555
8914
  return response.data;
8556
8915
  }
8557
8916
  /**
8558
8917
  * Deletes a Data Fabric entity and all its records
8559
8918
  *
8560
8919
  * @param id - UUID of the entity to delete
8920
+ * @param options - Optional {@link EntityDeleteByIdOptions} (e.g. `folderKey` for folder-scoped entities)
8561
8921
  * @returns Promise resolving when the entity is deleted
8562
8922
  *
8563
8923
  * @example
8564
8924
  * ```typescript
8565
8925
  * await entities.deleteById("<entityId>");
8926
+ *
8927
+ * // Folder-scoped: pass the entity's folder key
8928
+ * await entities.deleteById("<entityId>", { folderKey: "<folderKey>" });
8566
8929
  * ```
8567
8930
  * @internal
8568
8931
  */
8569
- async deleteById(id) {
8570
- await this.delete(DATA_FABRIC_ENDPOINTS.ENTITY.DELETE(id));
8932
+ async deleteById(id, options) {
8933
+ await this.delete(DATA_FABRIC_ENDPOINTS.ENTITY.DELETE(id), { headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }) });
8571
8934
  }
8572
8935
  /**
8573
8936
  * Updates an existing Data Fabric entity — schema and/or metadata.
@@ -8614,6 +8977,12 @@ class EntityService extends BaseService {
8614
8977
  * { id: "<fieldId>", lengthLimit: 1000 },
8615
8978
  * ],
8616
8979
  * });
8980
+ *
8981
+ * // Folder-scoped entity: add a field to an entity that lives in a non-tenant folder
8982
+ * await entities.updateById("<entityId>", {
8983
+ * folderKey: "<folderKey>",
8984
+ * addFields: [{ fieldName: "notes", type: EntityFieldDataType.MULTILINE_TEXT }],
8985
+ * });
8617
8986
  * ```
8618
8987
  * @internal
8619
8988
  */
@@ -8629,7 +8998,7 @@ class EntityService extends BaseService {
8629
8998
  ...(opts.displayName !== undefined && { displayName: opts.displayName }),
8630
8999
  ...(opts.description !== undefined && { description: opts.description }),
8631
9000
  ...(opts.isRbacEnabled !== undefined && { isRbacEnabled: opts.isRbacEnabled }),
8632
- });
9001
+ }, { headers: createHeaders({ [FOLDER_KEY]: opts.folderKey }) });
8633
9002
  }
8634
9003
  }
8635
9004
  /**
@@ -8640,7 +9009,8 @@ class EntityService extends BaseService {
8640
9009
  * @private
8641
9010
  */
8642
9011
  async applySchemaUpdate(entityId, options) {
8643
- const entityResponse = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.GET_BY_ID(entityId));
9012
+ const folderHeaders = createHeaders({ [FOLDER_KEY]: options.folderKey });
9013
+ const entityResponse = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.GET_BY_ID(entityId), { headers: folderHeaders });
8644
9014
  const raw = entityResponse.data;
8645
9015
  // Carry forward existing non-system fields from GET response (skip system/primary-key fields)
8646
9016
  let fields = (raw.fields ?? [])
@@ -8703,7 +9073,7 @@ class EntityService extends BaseService {
8703
9073
  isInsightsEnabled: raw.isInsightsEnabled ?? false,
8704
9074
  externalFields: raw.externalFields ?? [],
8705
9075
  },
8706
- });
9076
+ }, { headers: folderHeaders });
8707
9077
  }
8708
9078
  /**
8709
9079
  * Orchestrates all field mapping transformations
@@ -9295,6 +9665,13 @@ function createProcessMethods(processData, service) {
9295
9665
  if (!processData.folderKey)
9296
9666
  throw new Error('Folder key is undefined');
9297
9667
  return service.getIncidents(processData.processKey, processData.folderKey);
9668
+ },
9669
+ getElementStats(startTime, endTime, packageVersion) {
9670
+ if (!processData.processKey)
9671
+ throw new Error('Process key is undefined');
9672
+ if (!processData.packageId)
9673
+ throw new Error('Package ID is undefined');
9674
+ return service.getElementStats(processData.processKey, processData.packageId, startTime, endTime, packageVersion);
9298
9675
  }
9299
9676
  };
9300
9677
  }
@@ -9356,6 +9733,28 @@ async function fetchInstanceStatusTimeline(postFn, startTime, endTime, isCaseMan
9356
9733
  });
9357
9734
  return response.data ?? [];
9358
9735
  }
9736
+ /**
9737
+ * Builds the request body for the ElementCountByStatus endpoint.
9738
+ *
9739
+ * @param processKey - Process key to filter by
9740
+ * @param packageId - Package identifier
9741
+ * @param startTime - Start of the time range to query
9742
+ * @param endTime - End of the time range to query
9743
+ * @param packageVersion - Package version to filter by
9744
+ * @returns Request body for the ElementCountByStatus endpoint
9745
+ * @internal
9746
+ */
9747
+ function buildElementCountByStatusBody(processKey, packageId, startTime, endTime, packageVersion) {
9748
+ return {
9749
+ commonParams: {
9750
+ processKey,
9751
+ packageId,
9752
+ startTime: startTime.getTime(),
9753
+ endTime: endTime.getTime(),
9754
+ version: packageVersion
9755
+ }
9756
+ };
9757
+ }
9359
9758
 
9360
9759
  /**
9361
9760
  * Maps fields for Incident entities
@@ -9520,7 +9919,9 @@ function createProcessInstanceMethods(instanceData, service) {
9520
9919
  async getExecutionHistory() {
9521
9920
  if (!instanceData.instanceId)
9522
9921
  throw new Error('Process instance ID is undefined');
9523
- return service.getExecutionHistory(instanceData.instanceId);
9922
+ if (!instanceData.folderKey)
9923
+ throw new Error('Process instance folder key is undefined');
9924
+ return service.getExecutionHistory(instanceData.instanceId, instanceData.folderKey);
9524
9925
  },
9525
9926
  async getBpmn() {
9526
9927
  if (!instanceData.instanceId)
@@ -9586,6 +9987,40 @@ var DebugMode;
9586
9987
  DebugMode["SingleStep"] = "SingleStep";
9587
9988
  })(DebugMode || (DebugMode = {}));
9588
9989
 
9990
+ /**
9991
+ * Maestro Cases Models
9992
+ * Model classes for Maestro cases
9993
+ */
9994
+ /**
9995
+ * Creates methods for a case object
9996
+ *
9997
+ * @param caseData - The case data (response from API)
9998
+ * @param service - The cases service instance
9999
+ * @returns Object containing case methods
10000
+ */
10001
+ function createCaseMethods(caseData, service) {
10002
+ return {
10003
+ getElementStats(startTime, endTime, packageVersion) {
10004
+ if (!caseData.processKey)
10005
+ throw new Error('Process key is undefined');
10006
+ if (!caseData.packageId)
10007
+ throw new Error('Package ID is undefined');
10008
+ return service.getElementStats(caseData.processKey, caseData.packageId, startTime, endTime, packageVersion);
10009
+ }
10010
+ };
10011
+ }
10012
+ /**
10013
+ * Creates an actionable case by combining API case data with operational methods.
10014
+ *
10015
+ * @param caseData - The case data from API
10016
+ * @param service - The cases service instance
10017
+ * @returns A case object with added methods
10018
+ */
10019
+ function createCaseWithMethods(caseData, service) {
10020
+ const methods = createCaseMethods(caseData, service);
10021
+ return Object.assign({}, caseData, methods);
10022
+ }
10023
+
9589
10024
  /**
9590
10025
  * Case Instance Types
9591
10026
  * Types and interfaces for Maestro case instance management
@@ -9797,12 +10232,6 @@ const ProcessInstanceMap = {
9797
10232
  createdAt: 'createdTime',
9798
10233
  updatedAt: 'updatedTime'
9799
10234
  };
9800
- /**
9801
- * Maps fields for Process Instance Execution History to ensure consistent naming
9802
- */
9803
- const ProcessInstanceExecutionHistoryMap = {
9804
- startTime: 'startedTime'
9805
- };
9806
10235
 
9807
10236
  class ProcessInstancesService extends BaseService {
9808
10237
  /**
@@ -9883,11 +10312,66 @@ class ProcessInstancesService extends BaseService {
9883
10312
  /**
9884
10313
  * Get execution history (spans) for a process instance
9885
10314
  * @param instanceId The ID of the instance to get history for
9886
- * @returns Promise<ProcessInstanceExecutionHistoryResponse[]>
10315
+ * @param folderKey The folder key for authorization
10316
+ * @returns Promise resolving to execution history
10317
+ * {@link ProcessInstanceExecutionHistoryResponse}
10318
+ * @example
10319
+ * ```typescript
10320
+ * // Get execution history for a process instance
10321
+ * const history = await processInstances.getExecutionHistory(
10322
+ * <instanceId>,
10323
+ * <folderKey>
10324
+ * );
10325
+ *
10326
+ * // Analyze execution timeline
10327
+ * history.forEach(span => {
10328
+ * console.log(`Activity: ${span.name}`);
10329
+ * console.log(`Start: ${span.startedTime}`);
10330
+ * console.log(`End: ${span.endTime}`);
10331
+ * });
10332
+ * ```
9887
10333
  */
9888
- async getExecutionHistory(instanceId) {
9889
- const response = await this.get(MAESTRO_ENDPOINTS.INSTANCES.GET_EXECUTION_HISTORY(instanceId));
9890
- return response.data.map(historyItem => transformData(historyItem, ProcessInstanceExecutionHistoryMap));
10334
+ async getExecutionHistory(instanceId, folderKey) {
10335
+ const headers = createHeaders({ [FOLDER_KEY]: folderKey });
10336
+ const elementExecResponse = await this.get(MAESTRO_ENDPOINTS.INSTANCES.GET_ELEMENT_EXECUTIONS(instanceId), { headers });
10337
+ const traceId = elementExecResponse.data.traceId;
10338
+ const spansResponse = await this.get(MAESTRO_ENDPOINTS.TRACES.GET_SPANS(traceId), { headers });
10339
+ // Build span lookup keyed by elementRunId extracted from Attributes JSON
10340
+ const spanMap = new Map();
10341
+ for (const span of spansResponse.data) {
10342
+ try {
10343
+ const attrs = span.Attributes ? JSON.parse(span.Attributes) : null;
10344
+ if (attrs?.elementRunId) {
10345
+ spanMap.set(attrs.elementRunId, span);
10346
+ }
10347
+ }
10348
+ catch {
10349
+ // skip spans with unparseable Attributes — they won't match any elementRunId
10350
+ }
10351
+ }
10352
+ const results = [];
10353
+ for (const elementExec of elementExecResponse.data.elementExecutions) {
10354
+ for (const run of elementExec.elementRuns) {
10355
+ const span = spanMap.get(run.elementRunId);
10356
+ if (span) {
10357
+ results.push(this.mapSpanToHistory(span));
10358
+ }
10359
+ }
10360
+ }
10361
+ return results;
10362
+ }
10363
+ mapSpanToHistory(span) {
10364
+ return {
10365
+ id: span.Id,
10366
+ traceId: span.TraceId,
10367
+ parentId: span.ParentId,
10368
+ name: span.Name,
10369
+ startedTime: span.StartTime,
10370
+ endTime: span.EndTime,
10371
+ attributes: span.Attributes,
10372
+ updatedTime: span.UpdatedAt,
10373
+ expiredTime: span.ExpiryTimeUtc,
10374
+ };
9891
10375
  }
9892
10376
  /**
9893
10377
  * Get BPMN XML file for a process instance
@@ -10379,6 +10863,41 @@ class MaestroProcessesService extends BaseService {
10379
10863
  const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.TOP_PROCESSES_BY_DURATION, buildInsightsTopBody(startTime, endTime, false, options));
10380
10864
  return (data ?? []).map(process => ({ ...process, name: process.packageId }));
10381
10865
  }
10866
+ /**
10867
+ * Get element stats for process instances
10868
+ *
10869
+ * Returns per-element execution counts (success, fail, terminated, paused, in-progress) and
10870
+ * duration percentile metrics (min, max, avg, p50, p95, p99) for BPMN elements within a process.
10871
+ *
10872
+ * @param processKey - Process key to filter by
10873
+ * @param packageId - Package identifier
10874
+ * @param startTime - Start of the time range to query
10875
+ * @param endTime - End of the time range to query
10876
+ * @param packageVersion - Package version to filter by
10877
+ * @returns Promise resolving to an array of {@link ElementStats}
10878
+ * @example
10879
+ * ```typescript
10880
+ * // Get element metrics for a process
10881
+ * const elements = await maestroProcesses.getElementStats(
10882
+ * '<processKey>',
10883
+ * '<packageId>',
10884
+ * new Date('2026-04-01'),
10885
+ * new Date(),
10886
+ * '1.0.1'
10887
+ * );
10888
+ *
10889
+ * // Analyze element performance
10890
+ * for (const element of elements) {
10891
+ * console.log(`Element: ${element.elementId}`);
10892
+ * console.log(` Success: ${element.successCount}, Failed: ${element.failCount}`);
10893
+ * console.log(` Avg duration: ${element.avgDurationMs}ms, P95: ${element.p95DurationMs}ms`);
10894
+ * }
10895
+ * ```
10896
+ */
10897
+ async getElementStats(processKey, packageId, startTime, endTime, packageVersion) {
10898
+ const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.ELEMENT_COUNT_BY_STATUS, buildElementCountByStatusBody(processKey, packageId, startTime, endTime, packageVersion));
10899
+ return data ?? [];
10900
+ }
10382
10901
  }
10383
10902
  __decorate([
10384
10903
  track('MaestroProcesses.GetAll')
@@ -10401,6 +10920,9 @@ __decorate([
10401
10920
  __decorate([
10402
10921
  track('MaestroProcesses.GetTopExecutionDuration')
10403
10922
  ], MaestroProcessesService.prototype, "getTopExecutionDuration", null);
10923
+ __decorate([
10924
+ track('MaestroProcesses.GetElementStats')
10925
+ ], MaestroProcessesService.prototype, "getElementStats", null);
10404
10926
 
10405
10927
  /**
10406
10928
  * Service class for Maestro Process Incidents
@@ -10456,7 +10978,7 @@ var ProcessType;
10456
10978
  class CasesService extends BaseService {
10457
10979
  /**
10458
10980
  * Get all case management processes with their instance statistics
10459
- * @returns Promise resolving to array of Case objects
10981
+ * @returns Promise resolving to an array of {@link CaseGetAllWithMethodsResponse}
10460
10982
  *
10461
10983
  * @example
10462
10984
  * ```typescript
@@ -10480,10 +11002,10 @@ class CasesService extends BaseService {
10480
11002
  const response = await this.get(MAESTRO_ENDPOINTS.PROCESSES.GET_ALL, { params });
10481
11003
  // Extract processes array from response data and add name field
10482
11004
  const cases = response.data?.processes || [];
10483
- return cases.map(caseItem => ({
11005
+ return cases.map(caseItem => createCaseWithMethods({
10484
11006
  ...caseItem,
10485
11007
  name: this.extractCaseName(caseItem.packageId)
10486
- }));
11008
+ }, this));
10487
11009
  }
10488
11010
  /**
10489
11011
  * Get the top 5 case processes ranked by run count within a time range.
@@ -10702,6 +11224,40 @@ class CasesService extends BaseService {
10702
11224
  const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.TOP_PROCESSES_BY_DURATION, buildInsightsTopBody(startTime, endTime, true, options));
10703
11225
  return (data ?? []).map(process => ({ ...process, name: this.extractCaseName(process.packageId) }));
10704
11226
  }
11227
+ /**
11228
+ * Get element stats for case instances
11229
+ *
11230
+ * Returns per-element execution counts (success, fail, terminated, paused, in-progress) and
11231
+ * duration percentile metrics (min, max, avg, p50, p95, p99) for BPMN elements within a case.
11232
+ *
11233
+ * @param processKey - Process key to filter by
11234
+ * @param packageId - Package identifier
11235
+ * @param startTime - Start of the time range to query
11236
+ * @param endTime - End of the time range to query
11237
+ * @param packageVersion - Package version to filter by
11238
+ * @returns Promise resolving to an array of {@link ElementStats}
11239
+ * @example
11240
+ * ```typescript
11241
+ * // Get element metrics for a case
11242
+ * const elements = await cases.getElementStats(
11243
+ * '<processKey>',
11244
+ * '<packageId>',
11245
+ * new Date('2026-04-01'),
11246
+ * new Date(),
11247
+ * '1.0.1'
11248
+ * );
11249
+ *
11250
+ * // Find elements with failures
11251
+ * const failedElements = elements.filter(e => e.failCount > 0);
11252
+ * for (const element of failedElements) {
11253
+ * console.log(`Failed element: ${element.elementId}, failures: ${element.failCount}`);
11254
+ * }
11255
+ * ```
11256
+ */
11257
+ async getElementStats(processKey, packageId, startTime, endTime, packageVersion) {
11258
+ const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.ELEMENT_COUNT_BY_STATUS, buildElementCountByStatusBody(processKey, packageId, startTime, endTime, packageVersion));
11259
+ return data ?? [];
11260
+ }
10705
11261
  /**
10706
11262
  * Extract a readable case name from the packageId
10707
11263
  * @param packageId - The full package identifier
@@ -10739,6 +11295,9 @@ __decorate([
10739
11295
  __decorate([
10740
11296
  track('Cases.GetTopExecutionDuration')
10741
11297
  ], CasesService.prototype, "getTopExecutionDuration", null);
11298
+ __decorate([
11299
+ track('Cases.GetElementStats')
11300
+ ], CasesService.prototype, "getElementStats", null);
10742
11301
 
10743
11302
  /**
10744
11303
  * Maps fields for Case Instance entities to ensure consistent naming
@@ -11947,37 +12506,6 @@ function validateName(resourceType, name) {
11947
12506
  return trimmed;
11948
12507
  }
11949
12508
 
11950
- /**
11951
- * Encodes a folder path for the `X-UIPATH-FolderPath-Encoded` header.
11952
- *
11953
- * Orchestrator decodes this header as **base64-encoded UTF-16 LE bytes**
11954
- * (see `HttpHeadersProviderExtensions.GetDecoded` + `OrganizationUnitProvider`
11955
- * in the Orchestrator repo, which call `Encoding.Unicode.GetString(...)`).
11956
- * URL-encoding is NOT what the server expects — it must be base64-of-UTF-16-LE
11957
- * bytes.
11958
- *
11959
- * @param folderPath - The folder path (e.g. 'Shared/Finance')
11960
- * @returns Base64 string suitable for the `X-UIPATH-FolderPath-Encoded` header
11961
- */
11962
- function encodeFolderPathHeader(folderPath) {
11963
- // Force little-endian regardless of host byte order. `Uint16Array` viewed
11964
- // as `Uint8Array` would use the host's native order — correct on LE hosts
11965
- // (x86/ARM-LE) but wrong on BE hosts. `DataView.setUint16(..., true)`
11966
- // pins LE.
11967
- const buf = new ArrayBuffer(folderPath.length * 2);
11968
- const view = new DataView(buf);
11969
- for (let i = 0; i < folderPath.length; i++) {
11970
- view.setUint16(i * 2, folderPath.charCodeAt(i), true);
11971
- }
11972
- const bytes = new Uint8Array(buf);
11973
- let binary = '';
11974
- for (let i = 0; i < bytes.byteLength; i++) {
11975
- binary += String.fromCharCode(bytes[i]);
11976
- }
11977
- // btoa is browser-native; Node 16+ also has it as a global
11978
- return btoa(binary);
11979
- }
11980
-
11981
12509
  /**
11982
12510
  * Resolves folder context into the appropriate Orchestrator folder headers.
11983
12511
  *
@@ -12125,6 +12653,26 @@ function describeFolderForError(folderId, folderKey, folderPath) {
12125
12653
  return '';
12126
12654
  }
12127
12655
 
12656
+ /**
12657
+ * Enum for Asset Value Scope
12658
+ */
12659
+ var AssetValueScope;
12660
+ (function (AssetValueScope) {
12661
+ AssetValueScope["Global"] = "Global";
12662
+ AssetValueScope["PerRobot"] = "PerRobot";
12663
+ })(AssetValueScope || (AssetValueScope = {}));
12664
+ /**
12665
+ * Enum for Asset Value Type
12666
+ */
12667
+ var AssetValueType;
12668
+ (function (AssetValueType) {
12669
+ AssetValueType["Text"] = "Text";
12670
+ AssetValueType["Bool"] = "Bool";
12671
+ AssetValueType["Integer"] = "Integer";
12672
+ AssetValueType["Credential"] = "Credential";
12673
+ AssetValueType["Secret"] = "Secret";
12674
+ })(AssetValueType || (AssetValueType = {}));
12675
+
12128
12676
  /**
12129
12677
  * Maps fields for Asset entities to ensure consistent naming
12130
12678
  */
@@ -12249,6 +12797,68 @@ class AssetService extends FolderScopedService {
12249
12797
  async getByName(name, options = {}) {
12250
12798
  return this.getByNameLookup('Asset', ASSET_ENDPOINTS.GET_BY_FOLDER, name, options, (raw) => transformData(pascalToCamelCaseKeys(raw), AssetMap));
12251
12799
  }
12800
+ /**
12801
+ * Updates the value of an existing asset by ID.
12802
+ *
12803
+ * Fetches the asset internally to determine its type, then updates only the value while
12804
+ * preserving the asset's name, scope, and description.
12805
+ *
12806
+ * **Supported value types:** `Text`, `Integer`, and `Bool` only. Other types
12807
+ * (`Credential`, `Secret`) throw a `ValidationError`.
12808
+ *
12809
+ * The `newValue` runtime type must match the asset's `valueType`:
12810
+ * - `Text` → `string`
12811
+ * - `Integer` → `number` (integer)
12812
+ * - `Bool` → `boolean`
12813
+ *
12814
+ * @param id - Asset ID
12815
+ * @param newValue - New value to apply (string for `Text`, number for `Integer`, boolean for `Bool`)
12816
+ * @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`)
12817
+ * @returns Promise resolving when the asset has been updated
12818
+ *
12819
+ * @example
12820
+ * ```typescript
12821
+ * import { Assets } from '@uipath/uipath-typescript/assets';
12822
+ *
12823
+ * const assets = new Assets(sdk);
12824
+ *
12825
+ * // Update a Text asset by folder ID
12826
+ * await assets.updateValueById(<assetId>, 'new-value', { folderId: <folderId> });
12827
+ *
12828
+ * // Update an Integer asset by folder key (GUID)
12829
+ * await assets.updateValueById(<assetId>, 42, { folderKey: '5f6dadf1-3677-49dc-8aca-c2999dd4b3ba' });
12830
+ *
12831
+ * // Update a Bool asset by folder path
12832
+ * await assets.updateValueById(<assetId>, true, { folderPath: 'Shared/Finance' });
12833
+ * ```
12834
+ */
12835
+ async updateValueById(id, newValue, options) {
12836
+ if (!id) {
12837
+ throw new ValidationError({ message: 'id is required for updateValueById' });
12838
+ }
12839
+ if (newValue === null || newValue === undefined) {
12840
+ throw new ValidationError({ message: 'newValue is required for updateValueById' });
12841
+ }
12842
+ const headers = resolveFolderHeaders({
12843
+ folderId: options?.folderId,
12844
+ folderKey: options?.folderKey,
12845
+ folderPath: options?.folderPath,
12846
+ resourceType: 'Assets.updateValueById',
12847
+ fallbackFolderKey: this.config.folderKey,
12848
+ });
12849
+ const existingResponse = await this.get(ASSET_ENDPOINTS.GET_BY_ID(id), { headers });
12850
+ const existing = existingResponse.data;
12851
+ const valueField = resolveValueField(id, existing.ValueType, newValue);
12852
+ const body = {
12853
+ Id: id,
12854
+ Name: existing.Name,
12855
+ ValueScope: existing.ValueScope,
12856
+ ValueType: existing.ValueType,
12857
+ Description: existing.Description,
12858
+ [valueField]: newValue,
12859
+ };
12860
+ await this.put(ASSET_ENDPOINTS.GET_BY_ID(id), body, { headers });
12861
+ }
12252
12862
  }
12253
12863
  __decorate([
12254
12864
  track('Assets.GetAll')
@@ -12259,30 +12869,42 @@ __decorate([
12259
12869
  __decorate([
12260
12870
  track('Assets.GetByName')
12261
12871
  ], AssetService.prototype, "getByName", null);
12262
-
12263
- /**
12264
- * Enum for Asset Value Scope
12265
- */
12266
- var AssetValueScope;
12267
- (function (AssetValueScope) {
12268
- AssetValueScope["Global"] = "Global";
12269
- AssetValueScope["PerRobot"] = "PerRobot";
12270
- })(AssetValueScope || (AssetValueScope = {}));
12872
+ __decorate([
12873
+ track('Assets.UpdateValueById')
12874
+ ], AssetService.prototype, "updateValueById", null);
12271
12875
  /**
12272
- * Enum for Asset Value Type
12876
+ * Maps the asset's `valueType` to the PUT body field carrying the new value, validating
12877
+ * that the new value's runtime type matches the asset type.
12273
12878
  */
12274
- var AssetValueType;
12275
- (function (AssetValueType) {
12276
- AssetValueType["DBConnectionString"] = "DBConnectionString";
12277
- AssetValueType["HttpConnectionString"] = "HttpConnectionString";
12278
- AssetValueType["Text"] = "Text";
12279
- AssetValueType["Bool"] = "Bool";
12280
- AssetValueType["Integer"] = "Integer";
12281
- AssetValueType["Credential"] = "Credential";
12282
- AssetValueType["WindowsCredential"] = "WindowsCredential";
12283
- AssetValueType["KeyValueList"] = "KeyValueList";
12284
- AssetValueType["Secret"] = "Secret";
12285
- })(AssetValueType || (AssetValueType = {}));
12879
+ function resolveValueField(id, valueType, newValue) {
12880
+ switch (valueType) {
12881
+ case AssetValueType.Text:
12882
+ if (typeof newValue !== 'string') {
12883
+ throw new ValidationError({
12884
+ message: `Asset ${id} has valueType Text; newValue must be a string, got ${typeof newValue}`,
12885
+ });
12886
+ }
12887
+ return 'StringValue';
12888
+ case AssetValueType.Integer:
12889
+ if (typeof newValue !== 'number' || !Number.isInteger(newValue)) {
12890
+ throw new ValidationError({
12891
+ message: `Asset ${id} has valueType Integer; newValue must be an integer number, got ${typeof newValue}`,
12892
+ });
12893
+ }
12894
+ return 'IntValue';
12895
+ case AssetValueType.Bool:
12896
+ if (typeof newValue !== 'boolean') {
12897
+ throw new ValidationError({
12898
+ message: `Asset ${id} has valueType Bool; newValue must be a boolean, got ${typeof newValue}`,
12899
+ });
12900
+ }
12901
+ return 'BoolValue';
12902
+ default:
12903
+ throw new ValidationError({
12904
+ message: `updateValueById only supports Text, Integer, or Bool assets; asset ${id} has valueType ${valueType}`,
12905
+ });
12906
+ }
12907
+ }
12286
12908
 
12287
12909
  /**
12288
12910
  * Maps fields for Bucket entities to ensure consistent naming
@@ -14199,6 +14821,39 @@ var FeedbackStatus;
14199
14821
  FeedbackStatus[FeedbackStatus["Dismissed"] = 2] = "Dismissed";
14200
14822
  })(FeedbackStatus || (FeedbackStatus = {}));
14201
14823
 
14824
+ /**
14825
+ * Columns available for ordering results.
14826
+ */
14827
+ var AgentListSortColumn;
14828
+ (function (AgentListSortColumn) {
14829
+ AgentListSortColumn["AgentName"] = "AgentName";
14830
+ AgentListSortColumn["ParentProcess"] = "ParentProcess";
14831
+ AgentListSortColumn["LastRun"] = "LastRun";
14832
+ AgentListSortColumn["HealthScore"] = "HealthScore";
14833
+ AgentListSortColumn["LastIncident"] = "LastIncident";
14834
+ AgentListSortColumn["FolderName"] = "FolderName";
14835
+ /** Quantity of AGU (Agent Units) consumed */
14836
+ AgentListSortColumn["QuantityAGU"] = "QuantityAGU";
14837
+ /** Quantity of PLTU (Platform Units) consumed */
14838
+ AgentListSortColumn["QuantityPLTU"] = "QuantityPLTU";
14839
+ AgentListSortColumn["FolderPath"] = "FolderPath";
14840
+ })(AgentListSortColumn || (AgentListSortColumn = {}));
14841
+
14842
+ /**
14843
+ * Types for the Agent Memory metrics service.
14844
+ */
14845
+ /**
14846
+ * Execution kind to filter Agent Memory queries by. Omit to include both
14847
+ * Debug and Runtime executions.
14848
+ */
14849
+ var AgentMemoryExecutionType;
14850
+ (function (AgentMemoryExecutionType) {
14851
+ /** Executions produced during agent debugging sessions. */
14852
+ AgentMemoryExecutionType["Debug"] = "Debug";
14853
+ /** Executions produced during production runtime. */
14854
+ AgentMemoryExecutionType["Runtime"] = "Runtime";
14855
+ })(AgentMemoryExecutionType || (AgentMemoryExecutionType = {}));
14856
+
14202
14857
  // Auto-generated from the OpenAPI spec — do not edit manually.
14203
14858
  var DocumentActionPriority;
14204
14859
  (function (DocumentActionPriority) {
@@ -14470,6 +15125,23 @@ var index = /*#__PURE__*/Object.freeze({
14470
15125
  get WordGroupType () { return WordGroupType; }
14471
15126
  });
14472
15127
 
15128
+ /**
15129
+ * Governance Service Types
15130
+ *
15131
+ * Public types exposed via `@uipath/uipath-typescript/governance`.
15132
+ */
15133
+ var PolicyEvaluationResult;
15134
+ (function (PolicyEvaluationResult) {
15135
+ /** Active policy permitted the action. */
15136
+ PolicyEvaluationResult["Allow"] = "Allow";
15137
+ /** Active policy blocked the action. */
15138
+ PolicyEvaluationResult["Deny"] = "Deny";
15139
+ /** Simulated (NoOp) policy would have permitted the action. */
15140
+ PolicyEvaluationResult["SimulatedAllow"] = "SimulatedAllow";
15141
+ /** Simulated (NoOp) policy would have blocked the action. */
15142
+ PolicyEvaluationResult["SimulatedDeny"] = "SimulatedDeny";
15143
+ })(PolicyEvaluationResult || (PolicyEvaluationResult = {}));
15144
+
14473
15145
  /**
14474
15146
  * Asset resolution utilities for UiPath Coded Apps
14475
15147
  *
@@ -14545,4 +15217,4 @@ function getAppBase() {
14545
15217
  return getMetaTagContent(UiPathMetaTags.APP_BASE) || '/';
14546
15218
  }
14547
15219
 
14548
- export { AgentMap, AssetValueScope, AssetValueType, AuthenticationError, AuthorizationError, BucketOptions, CitationErrorType, ConversationGetAllFilterMap, ConversationMap, DEFAULT_ITEMS_FIELD, DEFAULT_PAGE_SIZE, DEFAULT_TOTAL_COUNT_FIELD, DataDirectionType, DebugMode, index as DuFramework, EntityAggregateFunction, EntityFieldDataType, EntityType, ErrorType, EscalationActionType, EscalationRecipientScope, EscalationTriggerType, ExchangeMap, FeedbackRating, FeedbackStatus, FieldDisplayType, HttpStatus, InputStreamSpeechSensitivity, InstanceFinalStatus, InstanceStatus, InterruptType, JobPriority, JobSourceType, JobState, JobSubState, JobType, JoinType, LogicalOperator$1 as LogicalOperator, MAX_PAGE_SIZE, MessageMap, MessageRole, NetworkError, NotFoundError, PackageSourceType, PackageType, ProcessIncidentSeverity, ProcessIncidentStatus, ProcessIncidentType, QueryFilterOperator, RateLimitError, ReferenceType, RemoteControlAccess, RobotSize, RuntimeType, SLADurationUnit, ServerError, ServerlessJobType, SlaSummaryStatus, SortOrder, StageTaskType, StartStrategy, StopStrategy, TargetFramework, TaskActivityType, TaskPriority, TaskSlaCriteria, TaskSlaStatus, TaskSourceName, TaskStatus, TaskType, TaskUserType, TimeInterval, UiPath, UiPathError, UiPathMetaTags, UserSettingsMap, ValidationError, createAgentWithMethods, createCaseInstanceWithMethods, createConversationWithMethods, createEntityWithMethods, createJobWithMethods, createProcessInstanceWithMethods, createProcessWithMethods, createTaskWithMethods, getAppBase, getAsset, getErrorDetails, getLimitedPageSize, isAuthenticationError, isAuthorizationError, isNetworkError, isNotFoundError, isRateLimitError, isServerError, isUiPathError, isValidationError, loadFromMetaTags, telemetryClient, track, trackEvent };
15220
+ export { AgentListSortColumn, AgentMap, AgentMemoryExecutionType, AssetValueScope, AssetValueType, AuthenticationError, AuthorizationError, BucketOptions, CitationErrorType, ConversationGetAllFilterMap, ConversationMap, DEFAULT_ITEMS_FIELD, DEFAULT_PAGE_SIZE, DEFAULT_TOTAL_COUNT_FIELD, DataDirectionType, DebugMode, index as DuFramework, EntityAggregateFunction, EntityFieldDataType, EntityType, ErrorType, EscalationActionType, EscalationRecipientScope, EscalationTriggerType, ExchangeMap, FeedbackRating, FeedbackStatus, FieldDisplayType, HttpStatus, InputStreamSpeechSensitivity, InstanceFinalStatus, InstanceStatus, InterruptType, JobPriority, JobSourceType, JobState, JobSubState, JobType, JoinType, LogicalOperator$1 as LogicalOperator, MAX_PAGE_SIZE, MessageMap, MessageRole, NetworkError, NotFoundError, PackageSourceType, PackageType, PolicyEvaluationResult, ProcessIncidentSeverity, ProcessIncidentStatus, ProcessIncidentType, QueryFilterOperator, RateLimitError, ReferenceType, RemoteControlAccess, RobotSize, RuntimeType, SLADurationUnit, ServerError, ServerlessJobType, SlaSummaryStatus, SortOrder, StageTaskType, StartStrategy, StopStrategy, TargetFramework, TaskActivityType, TaskPriority, TaskSlaCriteria, TaskSlaStatus, TaskSourceName, TaskStatus, TaskType, TaskUserType, TimeInterval, UiPath, UiPathError, UiPathMetaTags, UserSettingsMap, ValidationError, createAgentWithMethods, createCaseInstanceWithMethods, createCaseWithMethods, createConversationWithMethods, createEntityWithMethods, createJobWithMethods, createProcessInstanceWithMethods, createProcessWithMethods, createTaskWithMethods, getAppBase, getAsset, getErrorDetails, getLimitedPageSize, isAuthenticationError, isAuthorizationError, isNetworkError, isNotFoundError, isRateLimitError, isServerError, isUiPathError, isValidationError, loadFromMetaTags, telemetryClient, track, trackEvent };