@uipath/uipath-typescript 1.3.10 → 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.
- package/dist/agent-memory/index.cjs +1765 -0
- package/dist/agent-memory/index.d.ts +588 -0
- package/dist/agent-memory/index.mjs +1763 -0
- package/dist/agents/index.cjs +1726 -0
- package/dist/agents/index.d.ts +502 -0
- package/dist/agents/index.mjs +1724 -0
- package/dist/assets/index.cjs +155 -30
- package/dist/assets/index.d.ts +84 -5
- package/dist/assets/index.mjs +155 -30
- package/dist/attachments/index.cjs +37 -6
- package/dist/attachments/index.d.ts +1 -0
- package/dist/attachments/index.mjs +37 -6
- package/dist/buckets/index.cjs +37 -6
- package/dist/buckets/index.d.ts +1 -0
- package/dist/buckets/index.mjs +37 -6
- package/dist/cases/index.cjs +192 -10
- package/dist/cases/index.d.ts +208 -7
- package/dist/cases/index.mjs +192 -11
- package/dist/conversational-agent/index.cjs +124 -57
- package/dist/conversational-agent/index.d.ts +190 -122
- package/dist/conversational-agent/index.mjs +124 -57
- package/dist/core/index.cjs +413 -105
- package/dist/core/index.d.ts +15 -0
- package/dist/core/index.mjs +413 -105
- package/dist/entities/index.cjs +135 -70
- package/dist/entities/index.d.ts +146 -45
- package/dist/entities/index.mjs +135 -70
- package/dist/feedback/index.cjs +37 -6
- package/dist/feedback/index.d.ts +1 -0
- package/dist/feedback/index.mjs +37 -6
- package/dist/governance/index.cjs +1782 -0
- package/dist/governance/index.d.ts +598 -0
- package/dist/governance/index.mjs +1780 -0
- package/dist/index.cjs +1050 -291
- package/dist/index.d.ts +1313 -134
- package/dist/index.mjs +1050 -292
- package/dist/index.umd.js +4546 -3770
- package/dist/jobs/index.cjs +37 -6
- package/dist/jobs/index.d.ts +1 -0
- package/dist/jobs/index.mjs +37 -6
- package/dist/maestro-processes/index.cjs +224 -18
- package/dist/maestro-processes/index.d.ts +221 -9
- package/dist/maestro-processes/index.mjs +224 -18
- package/dist/processes/index.cjs +37 -6
- package/dist/processes/index.d.ts +1 -0
- package/dist/processes/index.mjs +37 -6
- package/dist/queues/index.cjs +37 -6
- package/dist/queues/index.d.ts +1 -0
- package/dist/queues/index.mjs +37 -6
- package/dist/tasks/index.cjs +37 -6
- package/dist/tasks/index.d.ts +1 -0
- package/dist/tasks/index.mjs +37 -6
- package/dist/traces/index.cjs +1933 -0
- package/dist/traces/index.d.ts +566 -0
- package/dist/traces/index.mjs +1931 -0
- package/package.json +42 -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
|
-
|
|
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}`,
|
|
@@ -4596,10 +4626,14 @@ const MAESTRO_ENDPOINTS = {
|
|
|
4596
4626
|
TOP_PROCESSES_BY_RUN_COUNT: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/TopProcessesByRunCount`,
|
|
4597
4627
|
/** Top processes ranked by failure count */
|
|
4598
4628
|
TOP_PROCESSES_WITH_FAILURE: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/TopProcesseswithFailure`,
|
|
4629
|
+
/** Top elements ranked by failure count */
|
|
4630
|
+
TOP_ELEMENTS_WITH_FAILURE: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/TopElementswithFailure`,
|
|
4599
4631
|
/** Instance status aggregated by date for time-series charts */
|
|
4600
4632
|
INSTANCE_STATUS_BY_DATE: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/InstanceStatusByDate`,
|
|
4601
4633
|
/** Top processes ranked by total duration */
|
|
4602
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`,
|
|
4603
4637
|
},
|
|
4604
4638
|
};
|
|
4605
4639
|
|
|
@@ -4674,6 +4708,96 @@ var ActionCenterEventNames;
|
|
|
4674
4708
|
})(ActionCenterEventNames || (ActionCenterEventNames = {}));
|
|
4675
4709
|
|
|
4676
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
|
+
|
|
4677
4801
|
class ActionCenterTokenManager {
|
|
4678
4802
|
constructor(config, onTokenRefreshed) {
|
|
4679
4803
|
this.config = config;
|
|
@@ -4682,84 +4806,334 @@ class ActionCenterTokenManager {
|
|
|
4682
4806
|
this.refreshPromise = null;
|
|
4683
4807
|
}
|
|
4684
4808
|
async refreshAccessToken(tokenInfo) {
|
|
4685
|
-
if (!
|
|
4809
|
+
if (!isTokenExpired(tokenInfo)) {
|
|
4686
4810
|
return tokenInfo.token;
|
|
4687
4811
|
}
|
|
4688
4812
|
if (this.refreshPromise) {
|
|
4689
4813
|
return this.refreshPromise;
|
|
4690
4814
|
}
|
|
4691
|
-
|
|
4692
|
-
|
|
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, {
|
|
4693
4834
|
clientId: this.config.clientId,
|
|
4694
4835
|
scope: this.config.scope,
|
|
4695
|
-
}
|
|
4696
|
-
|
|
4697
|
-
|
|
4698
|
-
|
|
4699
|
-
|
|
4700
|
-
|
|
4701
|
-
|
|
4702
|
-
|
|
4703
|
-
|
|
4704
|
-
const { accessToken, expiresAt } = event.data.content.token;
|
|
4705
|
-
this.onTokenRefreshed({ token: accessToken, type: 'secret', expiresAt });
|
|
4706
|
-
resolve(accessToken);
|
|
4707
|
-
}
|
|
4708
|
-
else {
|
|
4709
|
-
reject(new AuthenticationError({
|
|
4710
|
-
message: 'Failed to fetch access token',
|
|
4711
|
-
statusCode: HttpStatus.UNAUTHORIZED,
|
|
4712
|
-
}));
|
|
4713
|
-
}
|
|
4714
|
-
this.refreshPromise = null;
|
|
4715
|
-
this.cleanup(messageListener);
|
|
4716
|
-
};
|
|
4717
|
-
const timer = setTimeout(() => {
|
|
4718
|
-
reject(new AuthenticationError({
|
|
4719
|
-
message: 'Failed to fetch access token',
|
|
4720
|
-
statusCode: HttpStatus.UNAUTHORIZED,
|
|
4721
|
-
}));
|
|
4722
|
-
this.refreshPromise = null;
|
|
4723
|
-
this.cleanup(messageListener);
|
|
4724
|
-
}, AUTHENTICATION_TIMEOUT);
|
|
4725
|
-
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,
|
|
4726
4845
|
});
|
|
4727
|
-
|
|
4728
|
-
|
|
4729
|
-
|
|
4730
|
-
|
|
4731
|
-
|
|
4846
|
+
this.refreshPromise = promise;
|
|
4847
|
+
try {
|
|
4848
|
+
return await this.refreshPromise;
|
|
4849
|
+
}
|
|
4850
|
+
finally {
|
|
4851
|
+
this.refreshPromise = null;
|
|
4732
4852
|
}
|
|
4733
|
-
return new Date() >= tokenInfo.expiresAt;
|
|
4734
4853
|
}
|
|
4735
4854
|
sendMessageToParent(eventType, content) {
|
|
4736
|
-
if (window.parent &&
|
|
4855
|
+
if (window.parent && isValidHostOrigin(this.parentOrigin)) {
|
|
4737
4856
|
try {
|
|
4738
4857
|
window.parent.postMessage({ eventType, content }, this.parentOrigin);
|
|
4739
4858
|
}
|
|
4740
4859
|
catch (error) {
|
|
4741
|
-
console.warn('
|
|
4860
|
+
console.warn('ActionCenterTokenManager: postMessage to host failed', JSON.stringify(error));
|
|
4742
4861
|
}
|
|
4743
4862
|
}
|
|
4744
4863
|
}
|
|
4745
|
-
|
|
4746
|
-
|
|
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;
|
|
4747
4931
|
}
|
|
4748
|
-
|
|
4749
|
-
|
|
4750
|
-
|
|
4751
|
-
return false;
|
|
4932
|
+
async refreshAccessToken(tokenInfo) {
|
|
4933
|
+
if (!isTokenExpired(tokenInfo)) {
|
|
4934
|
+
return tokenInfo.token;
|
|
4752
4935
|
}
|
|
4753
|
-
if (
|
|
4754
|
-
return
|
|
4936
|
+
if (this.refreshPromise) {
|
|
4937
|
+
return this.refreshPromise;
|
|
4755
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;
|
|
4756
4959
|
try {
|
|
4757
|
-
|
|
4758
|
-
return url.hostname === 'localhost';
|
|
4960
|
+
return await this.refreshPromise;
|
|
4759
4961
|
}
|
|
4760
|
-
|
|
4761
|
-
|
|
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);
|
|
5062
|
+
}
|
|
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 '';
|
|
4762
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 '';
|
|
4763
5137
|
}
|
|
4764
5138
|
}
|
|
4765
5139
|
|
|
@@ -4782,10 +5156,15 @@ class TokenManager {
|
|
|
4782
5156
|
this.isOAuth = isOAuth;
|
|
4783
5157
|
this.refreshPromise = null;
|
|
4784
5158
|
this.actionCenterTokenManager = null;
|
|
5159
|
+
this.embeddedTokenManager = null;
|
|
4785
5160
|
if (isInActionCenter) {
|
|
4786
5161
|
this.actionCenterTokenManager = new ActionCenterTokenManager(config, (tokenInfo) => this.setToken(tokenInfo));
|
|
4787
5162
|
this.isOAuth = false;
|
|
4788
5163
|
}
|
|
5164
|
+
else if (isHostEmbedded && embeddingOrigin && isValidHostOrigin(embeddingOrigin)) {
|
|
5165
|
+
this.embeddedTokenManager = new EmbeddedTokenManager(embeddingOrigin, config, tokenInfo => this.setToken(tokenInfo));
|
|
5166
|
+
this.isOAuth = false;
|
|
5167
|
+
}
|
|
4789
5168
|
}
|
|
4790
5169
|
/**
|
|
4791
5170
|
* Checks if a token is expired
|
|
@@ -4816,6 +5195,10 @@ class TokenManager {
|
|
|
4816
5195
|
if (this.actionCenterTokenManager) {
|
|
4817
5196
|
return await this.actionCenterTokenManager.refreshAccessToken(tokenInfo);
|
|
4818
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
|
+
}
|
|
4819
5202
|
// For secret-based tokens, they never expire
|
|
4820
5203
|
if (tokenInfo.type === 'secret') {
|
|
4821
5204
|
return tokenInfo.token;
|
|
@@ -4954,6 +5337,13 @@ class TokenManager {
|
|
|
4954
5337
|
}
|
|
4955
5338
|
return true;
|
|
4956
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
|
+
}
|
|
4957
5347
|
/**
|
|
4958
5348
|
* Clears the current token
|
|
4959
5349
|
*/
|
|
@@ -4975,6 +5365,7 @@ class TokenManager {
|
|
|
4975
5365
|
*/
|
|
4976
5366
|
_updateExecutionContext(tokenInfo) {
|
|
4977
5367
|
this.executionContext.set('tokenInfo', tokenInfo);
|
|
5368
|
+
telemetryClient.setUserId(extractUserIdFromToken(tokenInfo.token));
|
|
4978
5369
|
}
|
|
4979
5370
|
/**
|
|
4980
5371
|
* Refreshes the access token using the stored refresh token.
|
|
@@ -5004,6 +5395,9 @@ class TokenManager {
|
|
|
5004
5395
|
* Internal method to perform the actual token refresh
|
|
5005
5396
|
*/
|
|
5006
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;
|
|
5007
5401
|
// Check if we're in OAuth flow
|
|
5008
5402
|
if (!hasOAuthConfig(this.config)) {
|
|
5009
5403
|
throw new Error('refreshAccessToken is only available in OAuth flow');
|
|
@@ -5013,13 +5407,12 @@ class TokenManager {
|
|
|
5013
5407
|
if (!tokenInfo?.refreshToken) {
|
|
5014
5408
|
throw new Error('No refresh token available. User may need to re-authenticate.');
|
|
5015
5409
|
}
|
|
5016
|
-
const orgName = this.config.orgName;
|
|
5017
5410
|
const body = new URLSearchParams({
|
|
5018
5411
|
grant_type: 'refresh_token',
|
|
5019
5412
|
client_id: this.config.clientId,
|
|
5020
5413
|
refresh_token: tokenInfo.refreshToken
|
|
5021
5414
|
});
|
|
5022
|
-
const response = await fetch(`${
|
|
5415
|
+
const response = await fetch(`${baseUrl}/${orgName}/identity_/connect/token`, {
|
|
5023
5416
|
method: 'POST',
|
|
5024
5417
|
headers: {
|
|
5025
5418
|
'Content-Type': 'application/x-www-form-urlencoded'
|
|
@@ -5479,51 +5872,6 @@ function normalizeBaseUrl(url) {
|
|
|
5479
5872
|
return url.endsWith('/') ? url.slice(0, -1) : url;
|
|
5480
5873
|
}
|
|
5481
5874
|
|
|
5482
|
-
/**
|
|
5483
|
-
* SDK Telemetry constants.
|
|
5484
|
-
*
|
|
5485
|
-
* Only the SDK's identity (version, service name, role name, …) lives
|
|
5486
|
-
* here. The Application Insights connection string is injected into
|
|
5487
|
-
* `@uipath/core-telemetry` itself at publish time, and the generic attribute
|
|
5488
|
-
* keys (`Version`, `Service`, `CloudOrganizationName`, …) are owned by
|
|
5489
|
-
* `@uipath/core-telemetry` and consumed there — they are not part of the
|
|
5490
|
-
* SDK's public API.
|
|
5491
|
-
*/
|
|
5492
|
-
/** SDK version placeholder — patched by the SDK publish workflow. */
|
|
5493
|
-
const SDK_VERSION = '1.3.10';
|
|
5494
|
-
const CLOUD_ROLE_NAME = 'uipath-ts-sdk';
|
|
5495
|
-
const SDK_SERVICE_NAME = 'UiPath.TypeScript.Sdk';
|
|
5496
|
-
const SDK_LOGGER_NAME = 'uipath-ts-sdk-telemetry';
|
|
5497
|
-
const SDK_RUN_EVENT = 'Sdk.Run';
|
|
5498
|
-
|
|
5499
|
-
/**
|
|
5500
|
-
* UiPath TypeScript SDK Telemetry
|
|
5501
|
-
*
|
|
5502
|
-
* Constructs the SDK's own `TelemetryClient` and binds the SDK-local
|
|
5503
|
-
* `track` / `trackEvent` to it. Each consumer of `@uipath/core-telemetry`
|
|
5504
|
-
* does this independently, so events carry their own consumer's identity
|
|
5505
|
-
* and tenant context.
|
|
5506
|
-
*/
|
|
5507
|
-
// Keyed by `CLOUD_ROLE_NAME` so every SDK subpath bundle resolves to the
|
|
5508
|
-
// same `TelemetryClient` instance at runtime. A single `initialize(...)`
|
|
5509
|
-
// from the `UiPath` constructor therefore wires up `@track` decorators
|
|
5510
|
-
// across every subpath bundle (`assets`, `feedback`, `tasks`, …).
|
|
5511
|
-
const sdkClient = getOrCreateClient(CLOUD_ROLE_NAME);
|
|
5512
|
-
const track = createTrack(sdkClient);
|
|
5513
|
-
const trackEvent = createTrackEvent(sdkClient);
|
|
5514
|
-
const telemetryClient = {
|
|
5515
|
-
initialize(context) {
|
|
5516
|
-
sdkClient.initialize({
|
|
5517
|
-
sdkVersion: SDK_VERSION,
|
|
5518
|
-
serviceName: SDK_SERVICE_NAME,
|
|
5519
|
-
cloudRoleName: CLOUD_ROLE_NAME,
|
|
5520
|
-
loggerName: SDK_LOGGER_NAME,
|
|
5521
|
-
defaultEventName: SDK_RUN_EVENT,
|
|
5522
|
-
context,
|
|
5523
|
-
});
|
|
5524
|
-
},
|
|
5525
|
-
};
|
|
5526
|
-
|
|
5527
5875
|
/**
|
|
5528
5876
|
* SDK Internals Registry - Internal registry for SDK instances
|
|
5529
5877
|
*
|
|
@@ -5633,7 +5981,7 @@ function loadFromMetaTags() {
|
|
|
5633
5981
|
return hasAnyValue ? config : null;
|
|
5634
5982
|
}
|
|
5635
5983
|
|
|
5636
|
-
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;
|
|
5637
5985
|
/**
|
|
5638
5986
|
* UiPath - Core SDK class for authentication and configuration management.
|
|
5639
5987
|
*
|
|
@@ -5678,9 +6026,18 @@ let UiPath$1 = class UiPath {
|
|
|
5678
6026
|
// deployments). Not accepted via the public constructor; lives here so the
|
|
5679
6027
|
// SDK can flow it through to BaseService.config without polluting BaseConfig.
|
|
5680
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);
|
|
5681
6036
|
// Load configuration from meta tags
|
|
5682
6037
|
const configFromMetaTags = loadFromMetaTags();
|
|
5683
6038
|
__classPrivateFieldSet(this, _UiPath_metaFolderKey, configFromMetaTags?.folderKey, "f");
|
|
6039
|
+
__classPrivateFieldSet(this, _UiPath_metaOrgId, configFromMetaTags?.orgName, "f");
|
|
6040
|
+
__classPrivateFieldSet(this, _UiPath_metaTenantId, configFromMetaTags?.tenantName, "f");
|
|
5684
6041
|
// Merge configuration: constructor config overrides meta tags
|
|
5685
6042
|
const mergedConfig = config ? { ...configFromMetaTags, ...config } : configFromMetaTags;
|
|
5686
6043
|
if (mergedConfig && isCompleteConfig(mergedConfig)) {
|
|
@@ -5787,6 +6144,13 @@ let UiPath$1 = class UiPath {
|
|
|
5787
6144
|
getToken() {
|
|
5788
6145
|
return __classPrivateFieldGet(this, _UiPath_authService, "f")?.getToken();
|
|
5789
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
|
+
}
|
|
5790
6154
|
/**
|
|
5791
6155
|
* Logout from the SDK, clearing all authentication state.
|
|
5792
6156
|
* After calling this method, the user will need to re-initialize to authenticate again.
|
|
@@ -5809,7 +6173,7 @@ let UiPath$1 = class UiPath {
|
|
|
5809
6173
|
__classPrivateFieldGet(this, _UiPath_authService, "f")?.updateToken(tokenInfo);
|
|
5810
6174
|
}
|
|
5811
6175
|
};
|
|
5812
|
-
_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) {
|
|
5813
6177
|
// Validate and normalize the configuration
|
|
5814
6178
|
validateConfig(config);
|
|
5815
6179
|
const hasSecretAuth = hasSecretConfig(config);
|
|
@@ -5845,9 +6209,11 @@ _UiPath_config = new WeakMap(), _UiPath_authService = new WeakMap(), _UiPath_ini
|
|
|
5845
6209
|
orgName: internalConfig.orgName,
|
|
5846
6210
|
tenantName: internalConfig.tenantName
|
|
5847
6211
|
};
|
|
5848
|
-
// Initialize telemetry with SDK configuration
|
|
6212
|
+
// Initialize telemetry with SDK configuration.
|
|
5849
6213
|
telemetryClient.initialize({
|
|
5850
6214
|
baseUrl: config.baseUrl,
|
|
6215
|
+
orgId: __classPrivateFieldGet(this, _UiPath_metaOrgId, "f"),
|
|
6216
|
+
tenantId: __classPrivateFieldGet(this, _UiPath_metaTenantId, "f"),
|
|
5851
6217
|
orgName: config.orgName,
|
|
5852
6218
|
tenantName: config.tenantName,
|
|
5853
6219
|
clientId: hasOAuthAuth ? config.clientId : undefined,
|
|
@@ -5866,6 +6232,8 @@ _UiPath_config = new WeakMap(), _UiPath_authService = new WeakMap(), _UiPath_ini
|
|
|
5866
6232
|
// Load from meta tags
|
|
5867
6233
|
const metaConfig = loadFromMetaTags();
|
|
5868
6234
|
__classPrivateFieldSet(this, _UiPath_metaFolderKey, metaConfig?.folderKey, "f");
|
|
6235
|
+
__classPrivateFieldSet(this, _UiPath_metaOrgId, metaConfig?.orgName, "f");
|
|
6236
|
+
__classPrivateFieldSet(this, _UiPath_metaTenantId, metaConfig?.tenantName, "f");
|
|
5869
6237
|
// Merge with any partial config from constructor (constructor overrides meta tags)
|
|
5870
6238
|
const merged = { ...metaConfig, ...__classPrivateFieldGet(this, _UiPath_partialConfig, "f") };
|
|
5871
6239
|
if (!isCompleteConfig(merged)) {
|
|
@@ -6335,54 +6703,6 @@ function processODataArrayResponse(oDataResponse, successData) {
|
|
|
6335
6703
|
};
|
|
6336
6704
|
}
|
|
6337
6705
|
|
|
6338
|
-
/**
|
|
6339
|
-
* Base64 encoding/decoding
|
|
6340
|
-
*/
|
|
6341
|
-
/**
|
|
6342
|
-
* Encodes a string to base64
|
|
6343
|
-
* @param str - The string to encode
|
|
6344
|
-
* @returns Base64 encoded string
|
|
6345
|
-
*/
|
|
6346
|
-
function encodeBase64(str) {
|
|
6347
|
-
// TextEncoder for UTF-8 encoding (works in both browser and Node.js)
|
|
6348
|
-
const encoder = new TextEncoder();
|
|
6349
|
-
const data = encoder.encode(str);
|
|
6350
|
-
// Convert Uint8Array to base64
|
|
6351
|
-
if (isBrowser) {
|
|
6352
|
-
// Browser environment
|
|
6353
|
-
// Convert Uint8Array to binary string then to base64
|
|
6354
|
-
const binaryString = Array.from(data, byte => String.fromCharCode(byte)).join('');
|
|
6355
|
-
return btoa(binaryString);
|
|
6356
|
-
}
|
|
6357
|
-
else {
|
|
6358
|
-
// Node.js environment
|
|
6359
|
-
return Buffer.from(data).toString('base64');
|
|
6360
|
-
}
|
|
6361
|
-
}
|
|
6362
|
-
/**
|
|
6363
|
-
* Decodes a base64 string
|
|
6364
|
-
* @param base64 - The base64 string to decode
|
|
6365
|
-
* @returns Decoded string
|
|
6366
|
-
*/
|
|
6367
|
-
function decodeBase64(base64) {
|
|
6368
|
-
let bytes;
|
|
6369
|
-
if (isBrowser) {
|
|
6370
|
-
// Browser environment
|
|
6371
|
-
const binaryString = atob(base64);
|
|
6372
|
-
bytes = new Uint8Array(binaryString.length);
|
|
6373
|
-
for (let i = 0; i < binaryString.length; i++) {
|
|
6374
|
-
bytes[i] = binaryString.charCodeAt(i);
|
|
6375
|
-
}
|
|
6376
|
-
}
|
|
6377
|
-
else {
|
|
6378
|
-
// Node.js environment
|
|
6379
|
-
bytes = new Uint8Array(Buffer.from(base64, 'base64'));
|
|
6380
|
-
}
|
|
6381
|
-
// TextDecoder for UTF-8 decoding (works in both browser and Node.js)
|
|
6382
|
-
const decoder = new TextDecoder();
|
|
6383
|
-
return decoder.decode(bytes);
|
|
6384
|
-
}
|
|
6385
|
-
|
|
6386
6706
|
/**
|
|
6387
6707
|
* PaginationManager handles the conversion between uniform cursor-based pagination
|
|
6388
6708
|
* and the specific pagination type for each service
|
|
@@ -7179,8 +7499,9 @@ class PaginationHelpers {
|
|
|
7179
7499
|
});
|
|
7180
7500
|
}
|
|
7181
7501
|
// Extract and transform items from response
|
|
7182
|
-
// Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
|
|
7183
|
-
|
|
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);
|
|
7184
7505
|
const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
|
|
7185
7506
|
const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
|
|
7186
7507
|
// Parse items - automatically handle JSON string responses
|
|
@@ -7226,7 +7547,7 @@ class PaginationHelpers {
|
|
|
7226
7547
|
getEndpoint: config.getEndpoint,
|
|
7227
7548
|
folderId,
|
|
7228
7549
|
headers: config.headers,
|
|
7229
|
-
paginationParams: cursor ? { cursor, pageSize } : jumpToPage ? { jumpToPage, pageSize } : { pageSize },
|
|
7550
|
+
paginationParams: cursor ? { cursor, pageSize } : jumpToPage !== undefined ? { jumpToPage, pageSize } : { pageSize },
|
|
7230
7551
|
additionalParams: prefixedOptions,
|
|
7231
7552
|
transformFn: config.transformFn,
|
|
7232
7553
|
method: config.method,
|
|
@@ -7429,6 +7750,8 @@ class BaseService {
|
|
|
7429
7750
|
// When true (default), converts pageNumber to a skip/offset value (e.g., page 3 with pageSize 10 → skip 20).
|
|
7430
7751
|
// When false, passes pageNumber directly as the offset param — used by APIs that accept a page number instead of a record offset.
|
|
7431
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;
|
|
7432
7755
|
requestParams[pageSizeParam] = limitedPageSize;
|
|
7433
7756
|
if (convertToSkip) {
|
|
7434
7757
|
if (params.pageNumber && params.pageNumber > 1) {
|
|
@@ -7436,7 +7759,8 @@ class BaseService {
|
|
|
7436
7759
|
}
|
|
7437
7760
|
}
|
|
7438
7761
|
else {
|
|
7439
|
-
|
|
7762
|
+
const sdkPageNumber = params.pageNumber || 1;
|
|
7763
|
+
requestParams[offsetParam] = zeroBased ? sdkPageNumber - 1 : sdkPageNumber;
|
|
7440
7764
|
}
|
|
7441
7765
|
{
|
|
7442
7766
|
requestParams[countParam] = true;
|
|
@@ -7465,8 +7789,9 @@ class BaseService {
|
|
|
7465
7789
|
const totalCountField = fields.totalCountField || 'totalRecordCount';
|
|
7466
7790
|
const continuationTokenField = fields.continuationTokenField || 'continuationToken';
|
|
7467
7791
|
// Extract items and metadata
|
|
7468
|
-
// Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
|
|
7469
|
-
|
|
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) || []);
|
|
7470
7795
|
const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
|
|
7471
7796
|
const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
|
|
7472
7797
|
const continuationToken = response.data[continuationTokenField];
|
|
@@ -7549,12 +7874,12 @@ function createEntityMethods(entityData, service) {
|
|
|
7549
7874
|
throw new Error('Entity ID is undefined');
|
|
7550
7875
|
return service.deleteRecordsById(entityData.id, recordIds, options);
|
|
7551
7876
|
},
|
|
7552
|
-
async deleteRecord(recordId) {
|
|
7877
|
+
async deleteRecord(recordId, options) {
|
|
7553
7878
|
if (!entityData.id)
|
|
7554
7879
|
throw new Error('Entity ID is undefined');
|
|
7555
7880
|
if (!recordId)
|
|
7556
7881
|
throw new Error('Record ID is undefined');
|
|
7557
|
-
return service.deleteRecordById(entityData.id, recordId);
|
|
7882
|
+
return service.deleteRecordById(entityData.id, recordId, options);
|
|
7558
7883
|
},
|
|
7559
7884
|
async getAllRecords(options) {
|
|
7560
7885
|
if (!entityData.id)
|
|
@@ -7568,30 +7893,30 @@ function createEntityMethods(entityData, service) {
|
|
|
7568
7893
|
throw new Error('Record ID is undefined');
|
|
7569
7894
|
return service.getRecordById(entityData.id, recordId, options);
|
|
7570
7895
|
},
|
|
7571
|
-
async downloadAttachment(recordId, fieldName) {
|
|
7896
|
+
async downloadAttachment(recordId, fieldName, options) {
|
|
7572
7897
|
if (!entityData.id)
|
|
7573
7898
|
throw new Error('Entity ID is undefined');
|
|
7574
|
-
return service.downloadAttachment(entityData.id, recordId, fieldName);
|
|
7899
|
+
return service.downloadAttachment(entityData.id, recordId, fieldName, options);
|
|
7575
7900
|
},
|
|
7576
7901
|
async uploadAttachment(recordId, fieldName, file, options) {
|
|
7577
7902
|
if (!entityData.id)
|
|
7578
7903
|
throw new Error('Entity ID is undefined');
|
|
7579
7904
|
return service.uploadAttachment(entityData.id, recordId, fieldName, file, options);
|
|
7580
7905
|
},
|
|
7581
|
-
async deleteAttachment(recordId, fieldName) {
|
|
7906
|
+
async deleteAttachment(recordId, fieldName, options) {
|
|
7582
7907
|
if (!entityData.id)
|
|
7583
7908
|
throw new Error('Entity ID is undefined');
|
|
7584
|
-
return service.deleteAttachment(entityData.id, recordId, fieldName);
|
|
7909
|
+
return service.deleteAttachment(entityData.id, recordId, fieldName, options);
|
|
7585
7910
|
},
|
|
7586
7911
|
async queryRecords(options) {
|
|
7587
7912
|
if (!entityData.id)
|
|
7588
7913
|
throw new Error('Entity ID is undefined');
|
|
7589
7914
|
return service.queryRecordsById(entityData.id, options);
|
|
7590
7915
|
},
|
|
7591
|
-
async importRecords(file) {
|
|
7916
|
+
async importRecords(file, options) {
|
|
7592
7917
|
if (!entityData.id)
|
|
7593
7918
|
throw new Error('Entity ID is undefined');
|
|
7594
|
-
return service.importRecordsById(entityData.id, file);
|
|
7919
|
+
return service.importRecordsById(entityData.id, file, options);
|
|
7595
7920
|
},
|
|
7596
7921
|
async insert(data, options) {
|
|
7597
7922
|
return this.insertRecord(data, options);
|
|
@@ -7602,10 +7927,10 @@ function createEntityMethods(entityData, service) {
|
|
|
7602
7927
|
async getRecords(options) {
|
|
7603
7928
|
return this.getAllRecords(options);
|
|
7604
7929
|
},
|
|
7605
|
-
async delete() {
|
|
7930
|
+
async delete(options) {
|
|
7606
7931
|
if (!entityData.id)
|
|
7607
7932
|
throw new Error('Entity ID is undefined');
|
|
7608
|
-
return service.deleteById(entityData.id);
|
|
7933
|
+
return service.deleteById(entityData.id, options);
|
|
7609
7934
|
},
|
|
7610
7935
|
async update(options) {
|
|
7611
7936
|
if (!entityData.id)
|
|
@@ -7935,6 +8260,7 @@ class EntityService extends BaseService {
|
|
|
7935
8260
|
* Gets entity metadata by entity ID with attached operation methods
|
|
7936
8261
|
*
|
|
7937
8262
|
* @param id - UUID of the entity
|
|
8263
|
+
* @param options - Optional {@link EntityGetByIdOptions} (e.g. `folderKey` for folder-scoped entities)
|
|
7938
8264
|
* @returns Promise resolving to entity metadata with schema information and operation methods
|
|
7939
8265
|
*
|
|
7940
8266
|
* @example
|
|
@@ -7944,6 +8270,9 @@ class EntityService extends BaseService {
|
|
|
7944
8270
|
* const entities = new Entities(sdk);
|
|
7945
8271
|
* const entity = await entities.getById("<entityId>");
|
|
7946
8272
|
*
|
|
8273
|
+
* // Folder-scoped: pass the entity's folder key
|
|
8274
|
+
* const folderEntity = await entities.getById("<entityId>", { folderKey: "<folderKey>" });
|
|
8275
|
+
*
|
|
7947
8276
|
* // Call operations directly on the entity
|
|
7948
8277
|
* const records = await entity.getAllRecords();
|
|
7949
8278
|
*
|
|
@@ -7957,9 +8286,9 @@ class EntityService extends BaseService {
|
|
|
7957
8286
|
* ]);
|
|
7958
8287
|
* ```
|
|
7959
8288
|
*/
|
|
7960
|
-
async getById(id) {
|
|
8289
|
+
async getById(id, options) {
|
|
7961
8290
|
// Get entity metadata
|
|
7962
|
-
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 }) });
|
|
7963
8292
|
// Apply EntityMap transformations
|
|
7964
8293
|
const metadata = transformData(response.data, EntityMap);
|
|
7965
8294
|
// Transform metadata with field mappers
|
|
@@ -8002,9 +8331,14 @@ class EntityService extends BaseService {
|
|
|
8002
8331
|
* ```
|
|
8003
8332
|
*/
|
|
8004
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;
|
|
8005
8338
|
return PaginationHelpers.getAll({
|
|
8006
8339
|
serviceAccess: this.createPaginationServiceAccess(),
|
|
8007
8340
|
getEndpoint: () => DATA_FABRIC_ENDPOINTS.ENTITY.GET_ENTITY_RECORDS(entityId),
|
|
8341
|
+
headers: createHeaders({ [FOLDER_KEY]: folderKey }),
|
|
8008
8342
|
pagination: {
|
|
8009
8343
|
paginationType: PaginationType.OFFSET,
|
|
8010
8344
|
itemsField: ENTITY_PAGINATION.ITEMS_FIELD,
|
|
@@ -8016,7 +8350,7 @@ class EntityService extends BaseService {
|
|
|
8016
8350
|
}
|
|
8017
8351
|
},
|
|
8018
8352
|
excludeFromPrefix: ['expansionLevel'] // Don't add ODATA prefix to expansionLevel
|
|
8019
|
-
},
|
|
8353
|
+
}, downstreamOptions);
|
|
8020
8354
|
}
|
|
8021
8355
|
/**
|
|
8022
8356
|
* Gets a single entity record by entity ID and record ID
|
|
@@ -8041,7 +8375,7 @@ class EntityService extends BaseService {
|
|
|
8041
8375
|
const params = createParams({
|
|
8042
8376
|
expansionLevel: options.expansionLevel
|
|
8043
8377
|
});
|
|
8044
|
-
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 }) });
|
|
8045
8379
|
return response.data;
|
|
8046
8380
|
}
|
|
8047
8381
|
/**
|
|
@@ -8073,7 +8407,7 @@ class EntityService extends BaseService {
|
|
|
8073
8407
|
});
|
|
8074
8408
|
const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.INSERT_BY_ID(id), data, {
|
|
8075
8409
|
params,
|
|
8076
|
-
|
|
8410
|
+
headers: createHeaders({ [FOLDER_KEY]: options.folderKey }),
|
|
8077
8411
|
});
|
|
8078
8412
|
return response.data;
|
|
8079
8413
|
}
|
|
@@ -8114,7 +8448,7 @@ class EntityService extends BaseService {
|
|
|
8114
8448
|
});
|
|
8115
8449
|
const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.BATCH_INSERT_BY_ID(id), data, {
|
|
8116
8450
|
params,
|
|
8117
|
-
|
|
8451
|
+
headers: createHeaders({ [FOLDER_KEY]: options.folderKey }),
|
|
8118
8452
|
});
|
|
8119
8453
|
return response.data;
|
|
8120
8454
|
}
|
|
@@ -8148,7 +8482,7 @@ class EntityService extends BaseService {
|
|
|
8148
8482
|
});
|
|
8149
8483
|
const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPDATE_RECORD_BY_ID(entityId, recordId), data, {
|
|
8150
8484
|
params,
|
|
8151
|
-
|
|
8485
|
+
headers: createHeaders({ [FOLDER_KEY]: options.folderKey }),
|
|
8152
8486
|
});
|
|
8153
8487
|
return response.data;
|
|
8154
8488
|
}
|
|
@@ -8190,7 +8524,7 @@ class EntityService extends BaseService {
|
|
|
8190
8524
|
});
|
|
8191
8525
|
const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPDATE_BY_ID(id), data, {
|
|
8192
8526
|
params,
|
|
8193
|
-
|
|
8527
|
+
headers: createHeaders({ [FOLDER_KEY]: options.folderKey }),
|
|
8194
8528
|
});
|
|
8195
8529
|
return response.data;
|
|
8196
8530
|
}
|
|
@@ -8222,7 +8556,7 @@ class EntityService extends BaseService {
|
|
|
8222
8556
|
});
|
|
8223
8557
|
const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.DELETE_BY_ID(id), recordIds, {
|
|
8224
8558
|
params,
|
|
8225
|
-
|
|
8559
|
+
headers: createHeaders({ [FOLDER_KEY]: options.folderKey }),
|
|
8226
8560
|
});
|
|
8227
8561
|
return response.data;
|
|
8228
8562
|
}
|
|
@@ -8234,6 +8568,7 @@ class EntityService extends BaseService {
|
|
|
8234
8568
|
*
|
|
8235
8569
|
* @param entityId - UUID of the entity
|
|
8236
8570
|
* @param recordId - UUID of the record to delete
|
|
8571
|
+
* @param options - Optional {@link EntityDeleteRecordByIdOptions} (e.g. `folderKey` for folder-scoped entities)
|
|
8237
8572
|
* @returns Promise resolving to void on success
|
|
8238
8573
|
* @example
|
|
8239
8574
|
* ```typescript
|
|
@@ -8242,10 +8577,13 @@ class EntityService extends BaseService {
|
|
|
8242
8577
|
* const entities = new Entities(sdk);
|
|
8243
8578
|
*
|
|
8244
8579
|
* await entities.deleteRecordById("<entityId>", "<recordId>");
|
|
8580
|
+
*
|
|
8581
|
+
* // Folder-scoped: pass the entity's folder key
|
|
8582
|
+
* await entities.deleteRecordById("<entityId>", "<recordId>", { folderKey: "<folderKey>" });
|
|
8245
8583
|
* ```
|
|
8246
8584
|
*/
|
|
8247
|
-
async deleteRecordById(entityId, recordId) {
|
|
8248
|
-
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 }) });
|
|
8249
8587
|
}
|
|
8250
8588
|
/**
|
|
8251
8589
|
* Gets all entities in the system
|
|
@@ -8331,10 +8669,15 @@ class EntityService extends BaseService {
|
|
|
8331
8669
|
* ```
|
|
8332
8670
|
*/
|
|
8333
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;
|
|
8334
8676
|
return PaginationHelpers.getAll({
|
|
8335
8677
|
serviceAccess: this.createPaginationServiceAccess(),
|
|
8336
8678
|
getEndpoint: () => DATA_FABRIC_ENDPOINTS.ENTITY.QUERY_BY_ID(id),
|
|
8337
8679
|
method: HTTP_METHODS.POST,
|
|
8680
|
+
headers: createHeaders({ [FOLDER_KEY]: folderKey }),
|
|
8338
8681
|
pagination: {
|
|
8339
8682
|
paginationType: PaginationType.OFFSET,
|
|
8340
8683
|
itemsField: ENTITY_PAGINATION.ITEMS_FIELD,
|
|
@@ -8346,13 +8689,14 @@ class EntityService extends BaseService {
|
|
|
8346
8689
|
}
|
|
8347
8690
|
},
|
|
8348
8691
|
excludeFromPrefix: ['expansionLevel', 'filterGroup', 'selectedFields', 'sortOptions', 'aggregates', 'groupBy']
|
|
8349
|
-
},
|
|
8692
|
+
}, downstreamOptions);
|
|
8350
8693
|
}
|
|
8351
8694
|
/**
|
|
8352
8695
|
* Imports records from a CSV file into an entity
|
|
8353
8696
|
*
|
|
8354
8697
|
* @param id - UUID of the entity
|
|
8355
8698
|
* @param file - CSV file to import (Blob, File, or Uint8Array)
|
|
8699
|
+
* @param options - Optional {@link EntityImportRecordsByIdOptions} (e.g. `folderKey` for folder-scoped entities)
|
|
8356
8700
|
* @returns Promise resolving to import result with record counts
|
|
8357
8701
|
*
|
|
8358
8702
|
* @example
|
|
@@ -8373,10 +8717,12 @@ class EntityService extends BaseService {
|
|
|
8373
8717
|
* if (result.errorFileLink) {
|
|
8374
8718
|
* console.log(`Error file link: ${result.errorFileLink}`);
|
|
8375
8719
|
* }
|
|
8720
|
+
*
|
|
8721
|
+
* // Folder-scoped entity: pass the entity's folder key
|
|
8722
|
+
* await entities.importRecordsById("<entityId>", fileInput.files[0], { folderKey: "<folderKey>" });
|
|
8376
8723
|
* ```
|
|
8377
|
-
* @internal
|
|
8378
8724
|
*/
|
|
8379
|
-
async importRecordsById(id, file) {
|
|
8725
|
+
async importRecordsById(id, file, options) {
|
|
8380
8726
|
const formData = new FormData();
|
|
8381
8727
|
if (file instanceof Uint8Array) {
|
|
8382
8728
|
formData.append('file', new Blob([file.buffer]));
|
|
@@ -8384,7 +8730,7 @@ class EntityService extends BaseService {
|
|
|
8384
8730
|
else {
|
|
8385
8731
|
formData.append('file', file);
|
|
8386
8732
|
}
|
|
8387
|
-
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 }) });
|
|
8388
8734
|
return response.data;
|
|
8389
8735
|
}
|
|
8390
8736
|
/**
|
|
@@ -8393,6 +8739,7 @@ class EntityService extends BaseService {
|
|
|
8393
8739
|
* @param entityId - UUID of the entity
|
|
8394
8740
|
* @param recordId - UUID of the record containing the attachment
|
|
8395
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)
|
|
8396
8743
|
* @returns Promise resolving to Blob containing the file content
|
|
8397
8744
|
*
|
|
8398
8745
|
* @example
|
|
@@ -8411,11 +8758,15 @@ class EntityService extends BaseService {
|
|
|
8411
8758
|
*
|
|
8412
8759
|
* // Download attachment for a specific record and field
|
|
8413
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>" });
|
|
8414
8764
|
* ```
|
|
8415
8765
|
*/
|
|
8416
|
-
async downloadAttachment(entityId, recordId, fieldName) {
|
|
8766
|
+
async downloadAttachment(entityId, recordId, fieldName, options) {
|
|
8417
8767
|
const response = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.DOWNLOAD_ATTACHMENT(entityId, recordId, fieldName), {
|
|
8418
|
-
responseType: RESPONSE_TYPES.BLOB
|
|
8768
|
+
responseType: RESPONSE_TYPES.BLOB,
|
|
8769
|
+
headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }),
|
|
8419
8770
|
});
|
|
8420
8771
|
return response.data;
|
|
8421
8772
|
}
|
|
@@ -8426,7 +8777,7 @@ class EntityService extends BaseService {
|
|
|
8426
8777
|
* @param recordId - UUID of the record to upload the attachment to
|
|
8427
8778
|
* @param fieldName - Name of the File-type field
|
|
8428
8779
|
* @param file - File to upload (Blob, File, or Uint8Array)
|
|
8429
|
-
* @param options - Optional {@link EntityUploadAttachmentOptions} (e.g. expansionLevel)
|
|
8780
|
+
* @param options - Optional {@link EntityUploadAttachmentOptions} (e.g. `expansionLevel`, `folderKey` for folder-scoped entities)
|
|
8430
8781
|
* @returns Promise resolving to {@link EntityUploadAttachmentResponse}
|
|
8431
8782
|
*
|
|
8432
8783
|
* @example
|
|
@@ -8445,6 +8796,9 @@ class EntityService extends BaseService {
|
|
|
8445
8796
|
*
|
|
8446
8797
|
* // Upload a file attachment
|
|
8447
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>" });
|
|
8448
8802
|
* ```
|
|
8449
8803
|
*/
|
|
8450
8804
|
async uploadAttachment(entityId, recordId, fieldName, file, options) {
|
|
@@ -8456,7 +8810,10 @@ class EntityService extends BaseService {
|
|
|
8456
8810
|
formData.append('file', file);
|
|
8457
8811
|
}
|
|
8458
8812
|
const params = createParams({ expansionLevel: options?.expansionLevel });
|
|
8459
|
-
const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPLOAD_ATTACHMENT(entityId, recordId, fieldName), formData, {
|
|
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
|
+
});
|
|
8460
8817
|
return response.data;
|
|
8461
8818
|
}
|
|
8462
8819
|
/**
|
|
@@ -8465,6 +8822,7 @@ class EntityService extends BaseService {
|
|
|
8465
8822
|
* @param entityId - UUID of the entity
|
|
8466
8823
|
* @param recordId - UUID of the record containing the attachment
|
|
8467
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)
|
|
8468
8826
|
* @returns Promise resolving to {@link EntityDeleteAttachmentResponse}
|
|
8469
8827
|
*
|
|
8470
8828
|
* @example
|
|
@@ -8483,10 +8841,13 @@ class EntityService extends BaseService {
|
|
|
8483
8841
|
*
|
|
8484
8842
|
* // Delete attachment for a specific record and field
|
|
8485
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>" });
|
|
8486
8847
|
* ```
|
|
8487
8848
|
*/
|
|
8488
|
-
async deleteAttachment(entityId, recordId, fieldName) {
|
|
8489
|
-
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 }) });
|
|
8490
8851
|
return response.data;
|
|
8491
8852
|
}
|
|
8492
8853
|
/**
|
|
@@ -8536,10 +8897,6 @@ class EntityService extends BaseService {
|
|
|
8536
8897
|
* @internal
|
|
8537
8898
|
*/
|
|
8538
8899
|
async create(name, fields, options) {
|
|
8539
|
-
this.validateName(name, 'entity');
|
|
8540
|
-
for (const field of fields) {
|
|
8541
|
-
this.validateName(field.fieldName, 'field');
|
|
8542
|
-
}
|
|
8543
8900
|
const opts = options ?? {};
|
|
8544
8901
|
const payload = {
|
|
8545
8902
|
...(opts.description !== undefined && { description: opts.description }),
|
|
@@ -8553,23 +8910,27 @@ class EntityService extends BaseService {
|
|
|
8553
8910
|
externalFields: opts.externalFields ?? [],
|
|
8554
8911
|
},
|
|
8555
8912
|
};
|
|
8556
|
-
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 }) });
|
|
8557
8914
|
return response.data;
|
|
8558
8915
|
}
|
|
8559
8916
|
/**
|
|
8560
8917
|
* Deletes a Data Fabric entity and all its records
|
|
8561
8918
|
*
|
|
8562
8919
|
* @param id - UUID of the entity to delete
|
|
8920
|
+
* @param options - Optional {@link EntityDeleteByIdOptions} (e.g. `folderKey` for folder-scoped entities)
|
|
8563
8921
|
* @returns Promise resolving when the entity is deleted
|
|
8564
8922
|
*
|
|
8565
8923
|
* @example
|
|
8566
8924
|
* ```typescript
|
|
8567
8925
|
* await entities.deleteById("<entityId>");
|
|
8926
|
+
*
|
|
8927
|
+
* // Folder-scoped: pass the entity's folder key
|
|
8928
|
+
* await entities.deleteById("<entityId>", { folderKey: "<folderKey>" });
|
|
8568
8929
|
* ```
|
|
8569
8930
|
* @internal
|
|
8570
8931
|
*/
|
|
8571
|
-
async deleteById(id) {
|
|
8572
|
-
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 }) });
|
|
8573
8934
|
}
|
|
8574
8935
|
/**
|
|
8575
8936
|
* Updates an existing Data Fabric entity — schema and/or metadata.
|
|
@@ -8616,6 +8977,12 @@ class EntityService extends BaseService {
|
|
|
8616
8977
|
* { id: "<fieldId>", lengthLimit: 1000 },
|
|
8617
8978
|
* ],
|
|
8618
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
|
+
* });
|
|
8619
8986
|
* ```
|
|
8620
8987
|
* @internal
|
|
8621
8988
|
*/
|
|
@@ -8631,7 +8998,7 @@ class EntityService extends BaseService {
|
|
|
8631
8998
|
...(opts.displayName !== undefined && { displayName: opts.displayName }),
|
|
8632
8999
|
...(opts.description !== undefined && { description: opts.description }),
|
|
8633
9000
|
...(opts.isRbacEnabled !== undefined && { isRbacEnabled: opts.isRbacEnabled }),
|
|
8634
|
-
});
|
|
9001
|
+
}, { headers: createHeaders({ [FOLDER_KEY]: opts.folderKey }) });
|
|
8635
9002
|
}
|
|
8636
9003
|
}
|
|
8637
9004
|
/**
|
|
@@ -8642,7 +9009,8 @@ class EntityService extends BaseService {
|
|
|
8642
9009
|
* @private
|
|
8643
9010
|
*/
|
|
8644
9011
|
async applySchemaUpdate(entityId, options) {
|
|
8645
|
-
const
|
|
9012
|
+
const folderHeaders = createHeaders({ [FOLDER_KEY]: options.folderKey });
|
|
9013
|
+
const entityResponse = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.GET_BY_ID(entityId), { headers: folderHeaders });
|
|
8646
9014
|
const raw = entityResponse.data;
|
|
8647
9015
|
// Carry forward existing non-system fields from GET response (skip system/primary-key fields)
|
|
8648
9016
|
let fields = (raw.fields ?? [])
|
|
@@ -8682,6 +9050,7 @@ class EntityService extends BaseService {
|
|
|
8682
9050
|
...(update.isUnique !== undefined && { isUnique: update.isUnique }),
|
|
8683
9051
|
...(update.isRbacEnabled !== undefined && { isRbacEnabled: update.isRbacEnabled }),
|
|
8684
9052
|
...(update.isEncrypted !== undefined && { isEncrypted: update.isEncrypted }),
|
|
9053
|
+
...(update.isHiddenField !== undefined && { isHiddenField: update.isHiddenField }),
|
|
8685
9054
|
...(update.defaultValue !== undefined && { defaultValue: update.defaultValue }),
|
|
8686
9055
|
...(hasConstraintUpdate && f.sqlType && { sqlType: { ...f.sqlType, ...constraintUpdate } }),
|
|
8687
9056
|
};
|
|
@@ -8690,9 +9059,6 @@ class EntityService extends BaseService {
|
|
|
8690
9059
|
// Build and append new fields
|
|
8691
9060
|
const newFields = [];
|
|
8692
9061
|
if (options.addFields?.length) {
|
|
8693
|
-
for (const field of options.addFields) {
|
|
8694
|
-
this.validateName(field.fieldName, 'field');
|
|
8695
|
-
}
|
|
8696
9062
|
newFields.push(...options.addFields.map(f => this.buildSchemaFieldPayload(f)));
|
|
8697
9063
|
}
|
|
8698
9064
|
await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPSERT, {
|
|
@@ -8707,7 +9073,7 @@ class EntityService extends BaseService {
|
|
|
8707
9073
|
isInsightsEnabled: raw.isInsightsEnabled ?? false,
|
|
8708
9074
|
externalFields: raw.externalFields ?? [],
|
|
8709
9075
|
},
|
|
8710
|
-
});
|
|
9076
|
+
}, { headers: folderHeaders });
|
|
8711
9077
|
}
|
|
8712
9078
|
/**
|
|
8713
9079
|
* Orchestrates all field mapping transformations
|
|
@@ -8793,9 +9159,15 @@ class EntityService extends BaseService {
|
|
|
8793
9159
|
}
|
|
8794
9160
|
/** Converts a user-facing EntityCreateFieldOptions to the raw API field payload */
|
|
8795
9161
|
buildSchemaFieldPayload(field) {
|
|
8796
|
-
this.validateName(field.fieldName, 'field');
|
|
8797
9162
|
const fieldType = field.type ?? EntityFieldDataType.STRING;
|
|
8798
9163
|
this.validateFieldConstraints(fieldType, field, field.fieldName);
|
|
9164
|
+
const isRelationship = fieldType === EntityFieldDataType.RELATIONSHIP;
|
|
9165
|
+
const isFile = fieldType === EntityFieldDataType.FILE;
|
|
9166
|
+
if ((isRelationship || isFile) && (!field.referenceEntityId || !field.referenceFieldId)) {
|
|
9167
|
+
throw new ValidationError({
|
|
9168
|
+
message: `Field '${field.fieldName}' of type ${fieldType} requires both referenceEntityId and referenceFieldId (UUIDs of the target entity and field).`,
|
|
9169
|
+
});
|
|
9170
|
+
}
|
|
8799
9171
|
const mapping = EntitySchemaFieldTypeMap[fieldType];
|
|
8800
9172
|
return {
|
|
8801
9173
|
name: field.fieldName,
|
|
@@ -8810,10 +9182,13 @@ class EntityService extends BaseService {
|
|
|
8810
9182
|
isUnique: field.isUnique ?? false,
|
|
8811
9183
|
isRbacEnabled: field.isRbacEnabled ?? false,
|
|
8812
9184
|
isEncrypted: field.isEncrypted ?? false,
|
|
9185
|
+
isHiddenField: field.isHiddenField ?? false,
|
|
8813
9186
|
...(field.defaultValue !== undefined && { defaultValue: field.defaultValue }),
|
|
8814
9187
|
...(field.choiceSetId !== undefined && { choiceSetId: field.choiceSetId }),
|
|
8815
|
-
...(
|
|
8816
|
-
...(
|
|
9188
|
+
...((isRelationship || isFile) && { isForeignKey: true }),
|
|
9189
|
+
...(isRelationship && { referenceType: ReferenceType.ManyToOne }),
|
|
9190
|
+
...(field.referenceEntityId !== undefined && { referenceEntity: { id: field.referenceEntityId } }),
|
|
9191
|
+
...(field.referenceFieldId !== undefined && { referenceField: { id: field.referenceFieldId } }),
|
|
8817
9192
|
};
|
|
8818
9193
|
}
|
|
8819
9194
|
/**
|
|
@@ -8917,24 +9292,7 @@ class EntityService extends BaseService {
|
|
|
8917
9292
|
return {};
|
|
8918
9293
|
}
|
|
8919
9294
|
}
|
|
8920
|
-
validateName(name, context) {
|
|
8921
|
-
if (name.length < 3 || name.length > 100 || !/^[a-zA-Z]\w*$/.test(name)) {
|
|
8922
|
-
const suggestion = name.replace(/\W/g, '').replace(/^[0-9_]+/, '');
|
|
8923
|
-
const defaultName = `My${context.charAt(0).toUpperCase() + context.slice(1)}`;
|
|
8924
|
-
throw new ValidationError({
|
|
8925
|
-
message: `Invalid ${context} name '${name}'. Must start with a letter, contain only letters, numbers, and underscores, 3–100 characters (e.g., "${suggestion || defaultName}").`
|
|
8926
|
-
});
|
|
8927
|
-
}
|
|
8928
|
-
if (context === 'field' && EntityService.RESERVED_FIELD_NAMES.has(name)) {
|
|
8929
|
-
throw new ValidationError({
|
|
8930
|
-
message: `Field name '${name}' is reserved. Reserved names: ${[...EntityService.RESERVED_FIELD_NAMES].join(', ')}.`
|
|
8931
|
-
});
|
|
8932
|
-
}
|
|
8933
|
-
}
|
|
8934
9295
|
}
|
|
8935
|
-
EntityService.RESERVED_FIELD_NAMES = new Set([
|
|
8936
|
-
'Id', 'CreatedBy', 'CreateTime', 'UpdatedBy', 'UpdateTime'
|
|
8937
|
-
]);
|
|
8938
9296
|
__decorate([
|
|
8939
9297
|
track('Entities.GetById')
|
|
8940
9298
|
], EntityService.prototype, "getById", null);
|
|
@@ -9307,6 +9665,13 @@ function createProcessMethods(processData, service) {
|
|
|
9307
9665
|
if (!processData.folderKey)
|
|
9308
9666
|
throw new Error('Folder key is undefined');
|
|
9309
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);
|
|
9310
9675
|
}
|
|
9311
9676
|
};
|
|
9312
9677
|
}
|
|
@@ -9368,6 +9733,28 @@ async function fetchInstanceStatusTimeline(postFn, startTime, endTime, isCaseMan
|
|
|
9368
9733
|
});
|
|
9369
9734
|
return response.data ?? [];
|
|
9370
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
|
+
}
|
|
9371
9758
|
|
|
9372
9759
|
/**
|
|
9373
9760
|
* Maps fields for Incident entities
|
|
@@ -9532,7 +9919,9 @@ function createProcessInstanceMethods(instanceData, service) {
|
|
|
9532
9919
|
async getExecutionHistory() {
|
|
9533
9920
|
if (!instanceData.instanceId)
|
|
9534
9921
|
throw new Error('Process instance ID is undefined');
|
|
9535
|
-
|
|
9922
|
+
if (!instanceData.folderKey)
|
|
9923
|
+
throw new Error('Process instance folder key is undefined');
|
|
9924
|
+
return service.getExecutionHistory(instanceData.instanceId, instanceData.folderKey);
|
|
9536
9925
|
},
|
|
9537
9926
|
async getBpmn() {
|
|
9538
9927
|
if (!instanceData.instanceId)
|
|
@@ -9598,6 +9987,40 @@ var DebugMode;
|
|
|
9598
9987
|
DebugMode["SingleStep"] = "SingleStep";
|
|
9599
9988
|
})(DebugMode || (DebugMode = {}));
|
|
9600
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
|
+
|
|
9601
10024
|
/**
|
|
9602
10025
|
* Case Instance Types
|
|
9603
10026
|
* Types and interfaces for Maestro case instance management
|
|
@@ -9809,12 +10232,6 @@ const ProcessInstanceMap = {
|
|
|
9809
10232
|
createdAt: 'createdTime',
|
|
9810
10233
|
updatedAt: 'updatedTime'
|
|
9811
10234
|
};
|
|
9812
|
-
/**
|
|
9813
|
-
* Maps fields for Process Instance Execution History to ensure consistent naming
|
|
9814
|
-
*/
|
|
9815
|
-
const ProcessInstanceExecutionHistoryMap = {
|
|
9816
|
-
startTime: 'startedTime'
|
|
9817
|
-
};
|
|
9818
10235
|
|
|
9819
10236
|
class ProcessInstancesService extends BaseService {
|
|
9820
10237
|
/**
|
|
@@ -9895,11 +10312,66 @@ class ProcessInstancesService extends BaseService {
|
|
|
9895
10312
|
/**
|
|
9896
10313
|
* Get execution history (spans) for a process instance
|
|
9897
10314
|
* @param instanceId The ID of the instance to get history for
|
|
9898
|
-
* @
|
|
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
|
+
* ```
|
|
9899
10333
|
*/
|
|
9900
|
-
async getExecutionHistory(instanceId) {
|
|
9901
|
-
const
|
|
9902
|
-
|
|
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
|
+
};
|
|
9903
10375
|
}
|
|
9904
10376
|
/**
|
|
9905
10377
|
* Get BPMN XML file for a process instance
|
|
@@ -10215,6 +10687,52 @@ class MaestroProcessesService extends BaseService {
|
|
|
10215
10687
|
const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.TOP_PROCESSES_BY_RUN_COUNT, buildInsightsTopBody(startTime, endTime, false, options));
|
|
10216
10688
|
return (data ?? []).map(process => ({ ...process, name: process.packageId }));
|
|
10217
10689
|
}
|
|
10690
|
+
/**
|
|
10691
|
+
* Get the top 10 BPMN elements ranked by failure count within a time range.
|
|
10692
|
+
*
|
|
10693
|
+
* Returns an array of up to 10 elements sorted by how many times they failed,
|
|
10694
|
+
* useful for identifying the most error-prone activities in processes.
|
|
10695
|
+
*
|
|
10696
|
+
* @param startTime - Start of the time range to query
|
|
10697
|
+
* @param endTime - End of the time range to query
|
|
10698
|
+
* @param options - Optional filters (packageId, processKey, version)
|
|
10699
|
+
* @returns Promise resolving to an array of {@link ElementGetTopFailedCountResponse}
|
|
10700
|
+
* @example
|
|
10701
|
+
* ```typescript
|
|
10702
|
+
* import { MaestroProcesses } from '@uipath/uipath-typescript/maestro-processes';
|
|
10703
|
+
*
|
|
10704
|
+
* const maestroProcesses = new MaestroProcesses(sdk);
|
|
10705
|
+
*
|
|
10706
|
+
* // Get top failing elements for the last 7 days
|
|
10707
|
+
* const topFailing = await maestroProcesses.getTopElementFailedCount(
|
|
10708
|
+
* new Date(Date.now() - 7 * 24 * 60 * 60 * 1000),
|
|
10709
|
+
* new Date()
|
|
10710
|
+
* );
|
|
10711
|
+
*
|
|
10712
|
+
* for (const element of topFailing) {
|
|
10713
|
+
* console.log(`${element.elementName} (${element.elementType}): ${element.failedCount} failures`);
|
|
10714
|
+
* }
|
|
10715
|
+
* ```
|
|
10716
|
+
*
|
|
10717
|
+
* @example
|
|
10718
|
+
* ```typescript
|
|
10719
|
+
* // Get top failing elements for a specific process
|
|
10720
|
+
* const filtered = await maestroProcesses.getTopElementFailedCount(
|
|
10721
|
+
* new Date(Date.now() - 7 * 24 * 60 * 60 * 1000),
|
|
10722
|
+
* new Date(),
|
|
10723
|
+
* { processKey: '<processKey>' }
|
|
10724
|
+
* );
|
|
10725
|
+
* ```
|
|
10726
|
+
*/
|
|
10727
|
+
async getTopElementFailedCount(startTime, endTime, options) {
|
|
10728
|
+
const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.TOP_ELEMENTS_WITH_FAILURE, buildInsightsTopBody(startTime, endTime, false, options));
|
|
10729
|
+
return (data ?? []).map(item => ({
|
|
10730
|
+
elementName: item.elementName,
|
|
10731
|
+
elementType: item.elementType,
|
|
10732
|
+
processKey: item.processKey,
|
|
10733
|
+
failedCount: item.count,
|
|
10734
|
+
}));
|
|
10735
|
+
}
|
|
10218
10736
|
/**
|
|
10219
10737
|
* Get all instances status counts aggregated by date for maestro processes.
|
|
10220
10738
|
*
|
|
@@ -10345,6 +10863,41 @@ class MaestroProcessesService extends BaseService {
|
|
|
10345
10863
|
const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.TOP_PROCESSES_BY_DURATION, buildInsightsTopBody(startTime, endTime, false, options));
|
|
10346
10864
|
return (data ?? []).map(process => ({ ...process, name: process.packageId }));
|
|
10347
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
|
+
}
|
|
10348
10901
|
}
|
|
10349
10902
|
__decorate([
|
|
10350
10903
|
track('MaestroProcesses.GetAll')
|
|
@@ -10355,6 +10908,9 @@ __decorate([
|
|
|
10355
10908
|
__decorate([
|
|
10356
10909
|
track('MaestroProcesses.GetTopRunCount')
|
|
10357
10910
|
], MaestroProcessesService.prototype, "getTopRunCount", null);
|
|
10911
|
+
__decorate([
|
|
10912
|
+
track('MaestroProcesses.GetTopElementFailedCount')
|
|
10913
|
+
], MaestroProcessesService.prototype, "getTopElementFailedCount", null);
|
|
10358
10914
|
__decorate([
|
|
10359
10915
|
track('MaestroProcesses.GetInstanceStatusTimeline')
|
|
10360
10916
|
], MaestroProcessesService.prototype, "getInstanceStatusTimeline", null);
|
|
@@ -10364,6 +10920,9 @@ __decorate([
|
|
|
10364
10920
|
__decorate([
|
|
10365
10921
|
track('MaestroProcesses.GetTopExecutionDuration')
|
|
10366
10922
|
], MaestroProcessesService.prototype, "getTopExecutionDuration", null);
|
|
10923
|
+
__decorate([
|
|
10924
|
+
track('MaestroProcesses.GetElementStats')
|
|
10925
|
+
], MaestroProcessesService.prototype, "getElementStats", null);
|
|
10367
10926
|
|
|
10368
10927
|
/**
|
|
10369
10928
|
* Service class for Maestro Process Incidents
|
|
@@ -10419,7 +10978,7 @@ var ProcessType;
|
|
|
10419
10978
|
class CasesService extends BaseService {
|
|
10420
10979
|
/**
|
|
10421
10980
|
* Get all case management processes with their instance statistics
|
|
10422
|
-
* @returns Promise resolving to array of
|
|
10981
|
+
* @returns Promise resolving to an array of {@link CaseGetAllWithMethodsResponse}
|
|
10423
10982
|
*
|
|
10424
10983
|
* @example
|
|
10425
10984
|
* ```typescript
|
|
@@ -10443,10 +11002,10 @@ class CasesService extends BaseService {
|
|
|
10443
11002
|
const response = await this.get(MAESTRO_ENDPOINTS.PROCESSES.GET_ALL, { params });
|
|
10444
11003
|
// Extract processes array from response data and add name field
|
|
10445
11004
|
const cases = response.data?.processes || [];
|
|
10446
|
-
return cases.map(caseItem => ({
|
|
11005
|
+
return cases.map(caseItem => createCaseWithMethods({
|
|
10447
11006
|
...caseItem,
|
|
10448
11007
|
name: this.extractCaseName(caseItem.packageId)
|
|
10449
|
-
}));
|
|
11008
|
+
}, this));
|
|
10450
11009
|
}
|
|
10451
11010
|
/**
|
|
10452
11011
|
* Get the top 5 case processes ranked by run count within a time range.
|
|
@@ -10489,6 +11048,52 @@ class CasesService extends BaseService {
|
|
|
10489
11048
|
const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.TOP_PROCESSES_BY_RUN_COUNT, buildInsightsTopBody(startTime, endTime, true, options));
|
|
10490
11049
|
return (data ?? []).map(process => ({ ...process, name: this.extractCaseName(process.packageId) }));
|
|
10491
11050
|
}
|
|
11051
|
+
/**
|
|
11052
|
+
* Get the top 10 BPMN elements ranked by failure count within a time range.
|
|
11053
|
+
*
|
|
11054
|
+
* Returns an array of up to 10 elements sorted by how many times they failed,
|
|
11055
|
+
* useful for identifying the most error-prone activities in case processes.
|
|
11056
|
+
*
|
|
11057
|
+
* @param startTime - Start of the time range to query
|
|
11058
|
+
* @param endTime - End of the time range to query
|
|
11059
|
+
* @param options - Optional filters (packageId, processKey, version)
|
|
11060
|
+
* @returns Promise resolving to an array of {@link ElementGetTopFailedCountResponse}
|
|
11061
|
+
* @example
|
|
11062
|
+
* ```typescript
|
|
11063
|
+
* import { Cases } from '@uipath/uipath-typescript/cases';
|
|
11064
|
+
*
|
|
11065
|
+
* const cases = new Cases(sdk);
|
|
11066
|
+
*
|
|
11067
|
+
* // Get top failing elements for the last 7 days
|
|
11068
|
+
* const topFailing = await cases.getTopElementFailedCount(
|
|
11069
|
+
* new Date(Date.now() - 7 * 24 * 60 * 60 * 1000),
|
|
11070
|
+
* new Date()
|
|
11071
|
+
* );
|
|
11072
|
+
*
|
|
11073
|
+
* for (const element of topFailing) {
|
|
11074
|
+
* console.log(`${element.elementName} (${element.elementType}): ${element.failedCount} failures`);
|
|
11075
|
+
* }
|
|
11076
|
+
* ```
|
|
11077
|
+
*
|
|
11078
|
+
* @example
|
|
11079
|
+
* ```typescript
|
|
11080
|
+
* // Get top failing elements for a specific process
|
|
11081
|
+
* const filtered = await cases.getTopElementFailedCount(
|
|
11082
|
+
* new Date(Date.now() - 7 * 24 * 60 * 60 * 1000),
|
|
11083
|
+
* new Date(),
|
|
11084
|
+
* { processKey: '<processKey>' }
|
|
11085
|
+
* );
|
|
11086
|
+
* ```
|
|
11087
|
+
*/
|
|
11088
|
+
async getTopElementFailedCount(startTime, endTime, options) {
|
|
11089
|
+
const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.TOP_ELEMENTS_WITH_FAILURE, buildInsightsTopBody(startTime, endTime, true, options));
|
|
11090
|
+
return (data ?? []).map(item => ({
|
|
11091
|
+
elementName: item.elementName,
|
|
11092
|
+
elementType: item.elementType,
|
|
11093
|
+
processKey: item.processKey,
|
|
11094
|
+
failedCount: item.count,
|
|
11095
|
+
}));
|
|
11096
|
+
}
|
|
10492
11097
|
/**
|
|
10493
11098
|
* Get all instances status counts aggregated by date for case management processes.
|
|
10494
11099
|
*
|
|
@@ -10619,6 +11224,40 @@ class CasesService extends BaseService {
|
|
|
10619
11224
|
const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.TOP_PROCESSES_BY_DURATION, buildInsightsTopBody(startTime, endTime, true, options));
|
|
10620
11225
|
return (data ?? []).map(process => ({ ...process, name: this.extractCaseName(process.packageId) }));
|
|
10621
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
|
+
}
|
|
10622
11261
|
/**
|
|
10623
11262
|
* Extract a readable case name from the packageId
|
|
10624
11263
|
* @param packageId - The full package identifier
|
|
@@ -10644,6 +11283,9 @@ __decorate([
|
|
|
10644
11283
|
__decorate([
|
|
10645
11284
|
track('Cases.GetTopRunCount')
|
|
10646
11285
|
], CasesService.prototype, "getTopRunCount", null);
|
|
11286
|
+
__decorate([
|
|
11287
|
+
track('Cases.GetTopElementFailedCount')
|
|
11288
|
+
], CasesService.prototype, "getTopElementFailedCount", null);
|
|
10647
11289
|
__decorate([
|
|
10648
11290
|
track('Cases.GetInstanceStatusTimeline')
|
|
10649
11291
|
], CasesService.prototype, "getInstanceStatusTimeline", null);
|
|
@@ -10653,6 +11295,9 @@ __decorate([
|
|
|
10653
11295
|
__decorate([
|
|
10654
11296
|
track('Cases.GetTopExecutionDuration')
|
|
10655
11297
|
], CasesService.prototype, "getTopExecutionDuration", null);
|
|
11298
|
+
__decorate([
|
|
11299
|
+
track('Cases.GetElementStats')
|
|
11300
|
+
], CasesService.prototype, "getElementStats", null);
|
|
10656
11301
|
|
|
10657
11302
|
/**
|
|
10658
11303
|
* Maps fields for Case Instance entities to ensure consistent naming
|
|
@@ -11861,37 +12506,6 @@ function validateName(resourceType, name) {
|
|
|
11861
12506
|
return trimmed;
|
|
11862
12507
|
}
|
|
11863
12508
|
|
|
11864
|
-
/**
|
|
11865
|
-
* Encodes a folder path for the `X-UIPATH-FolderPath-Encoded` header.
|
|
11866
|
-
*
|
|
11867
|
-
* Orchestrator decodes this header as **base64-encoded UTF-16 LE bytes**
|
|
11868
|
-
* (see `HttpHeadersProviderExtensions.GetDecoded` + `OrganizationUnitProvider`
|
|
11869
|
-
* in the Orchestrator repo, which call `Encoding.Unicode.GetString(...)`).
|
|
11870
|
-
* URL-encoding is NOT what the server expects — it must be base64-of-UTF-16-LE
|
|
11871
|
-
* bytes.
|
|
11872
|
-
*
|
|
11873
|
-
* @param folderPath - The folder path (e.g. 'Shared/Finance')
|
|
11874
|
-
* @returns Base64 string suitable for the `X-UIPATH-FolderPath-Encoded` header
|
|
11875
|
-
*/
|
|
11876
|
-
function encodeFolderPathHeader(folderPath) {
|
|
11877
|
-
// Force little-endian regardless of host byte order. `Uint16Array` viewed
|
|
11878
|
-
// as `Uint8Array` would use the host's native order — correct on LE hosts
|
|
11879
|
-
// (x86/ARM-LE) but wrong on BE hosts. `DataView.setUint16(..., true)`
|
|
11880
|
-
// pins LE.
|
|
11881
|
-
const buf = new ArrayBuffer(folderPath.length * 2);
|
|
11882
|
-
const view = new DataView(buf);
|
|
11883
|
-
for (let i = 0; i < folderPath.length; i++) {
|
|
11884
|
-
view.setUint16(i * 2, folderPath.charCodeAt(i), true);
|
|
11885
|
-
}
|
|
11886
|
-
const bytes = new Uint8Array(buf);
|
|
11887
|
-
let binary = '';
|
|
11888
|
-
for (let i = 0; i < bytes.byteLength; i++) {
|
|
11889
|
-
binary += String.fromCharCode(bytes[i]);
|
|
11890
|
-
}
|
|
11891
|
-
// btoa is browser-native; Node 16+ also has it as a global
|
|
11892
|
-
return btoa(binary);
|
|
11893
|
-
}
|
|
11894
|
-
|
|
11895
12509
|
/**
|
|
11896
12510
|
* Resolves folder context into the appropriate Orchestrator folder headers.
|
|
11897
12511
|
*
|
|
@@ -12039,6 +12653,26 @@ function describeFolderForError(folderId, folderKey, folderPath) {
|
|
|
12039
12653
|
return '';
|
|
12040
12654
|
}
|
|
12041
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
|
+
|
|
12042
12676
|
/**
|
|
12043
12677
|
* Maps fields for Asset entities to ensure consistent naming
|
|
12044
12678
|
*/
|
|
@@ -12163,6 +12797,68 @@ class AssetService extends FolderScopedService {
|
|
|
12163
12797
|
async getByName(name, options = {}) {
|
|
12164
12798
|
return this.getByNameLookup('Asset', ASSET_ENDPOINTS.GET_BY_FOLDER, name, options, (raw) => transformData(pascalToCamelCaseKeys(raw), AssetMap));
|
|
12165
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
|
+
}
|
|
12166
12862
|
}
|
|
12167
12863
|
__decorate([
|
|
12168
12864
|
track('Assets.GetAll')
|
|
@@ -12173,30 +12869,42 @@ __decorate([
|
|
|
12173
12869
|
__decorate([
|
|
12174
12870
|
track('Assets.GetByName')
|
|
12175
12871
|
], AssetService.prototype, "getByName", null);
|
|
12176
|
-
|
|
12177
|
-
|
|
12178
|
-
|
|
12179
|
-
*/
|
|
12180
|
-
var AssetValueScope;
|
|
12181
|
-
(function (AssetValueScope) {
|
|
12182
|
-
AssetValueScope["Global"] = "Global";
|
|
12183
|
-
AssetValueScope["PerRobot"] = "PerRobot";
|
|
12184
|
-
})(AssetValueScope || (AssetValueScope = {}));
|
|
12872
|
+
__decorate([
|
|
12873
|
+
track('Assets.UpdateValueById')
|
|
12874
|
+
], AssetService.prototype, "updateValueById", null);
|
|
12185
12875
|
/**
|
|
12186
|
-
*
|
|
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.
|
|
12187
12878
|
*/
|
|
12188
|
-
|
|
12189
|
-
|
|
12190
|
-
|
|
12191
|
-
|
|
12192
|
-
|
|
12193
|
-
|
|
12194
|
-
|
|
12195
|
-
|
|
12196
|
-
|
|
12197
|
-
|
|
12198
|
-
|
|
12199
|
-
|
|
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
|
+
}
|
|
12200
12908
|
|
|
12201
12909
|
/**
|
|
12202
12910
|
* Maps fields for Bucket entities to ensure consistent naming
|
|
@@ -14113,6 +14821,39 @@ var FeedbackStatus;
|
|
|
14113
14821
|
FeedbackStatus[FeedbackStatus["Dismissed"] = 2] = "Dismissed";
|
|
14114
14822
|
})(FeedbackStatus || (FeedbackStatus = {}));
|
|
14115
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
|
+
|
|
14116
14857
|
// Auto-generated from the OpenAPI spec — do not edit manually.
|
|
14117
14858
|
var DocumentActionPriority;
|
|
14118
14859
|
(function (DocumentActionPriority) {
|
|
@@ -14384,6 +15125,23 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
14384
15125
|
get WordGroupType () { return WordGroupType; }
|
|
14385
15126
|
});
|
|
14386
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
|
+
|
|
14387
15145
|
/**
|
|
14388
15146
|
* Asset resolution utilities for UiPath Coded Apps
|
|
14389
15147
|
*
|
|
@@ -14459,4 +15217,4 @@ function getAppBase() {
|
|
|
14459
15217
|
return getMetaTagContent(UiPathMetaTags.APP_BASE) || '/';
|
|
14460
15218
|
}
|
|
14461
15219
|
|
|
14462
|
-
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 };
|