@uipath/uipath-typescript 1.3.11 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-memory/index.cjs +1772 -0
- package/dist/agent-memory/index.d.ts +588 -0
- package/dist/agent-memory/index.mjs +1770 -0
- package/dist/agents/index.cjs +1995 -0
- package/dist/agents/index.d.ts +961 -0
- package/dist/agents/index.mjs +1993 -0
- package/dist/assets/index.cjs +171 -39
- package/dist/assets/index.d.ts +84 -5
- package/dist/assets/index.mjs +171 -39
- package/dist/attachments/index.cjs +53 -15
- package/dist/attachments/index.d.ts +1 -0
- package/dist/attachments/index.mjs +53 -15
- package/dist/buckets/index.cjs +151 -130
- package/dist/buckets/index.d.ts +198 -84
- package/dist/buckets/index.mjs +151 -130
- package/dist/cases/index.cjs +220 -23
- package/dist/cases/index.d.ts +148 -10
- package/dist/cases/index.mjs +220 -24
- package/dist/conversational-agent/index.cjs +140 -66
- package/dist/conversational-agent/index.d.ts +190 -122
- package/dist/conversational-agent/index.mjs +140 -66
- package/dist/core/index.cjs +445 -108
- package/dist/core/index.d.ts +15 -0
- package/dist/core/index.mjs +445 -108
- package/dist/entities/index.cjs +365 -102
- package/dist/entities/index.d.ts +446 -114
- package/dist/entities/index.mjs +365 -102
- package/dist/feedback/index.cjs +53 -15
- package/dist/feedback/index.d.ts +1 -0
- package/dist/feedback/index.mjs +53 -15
- package/dist/governance/index.cjs +1789 -0
- package/dist/governance/index.d.ts +598 -0
- package/dist/governance/index.mjs +1787 -0
- package/dist/index.cjs +1453 -444
- package/dist/index.d.ts +4150 -1742
- package/dist/index.mjs +1452 -445
- package/dist/index.umd.js +5035 -4009
- package/dist/jobs/index.cjs +53 -15
- package/dist/jobs/index.d.ts +1 -0
- package/dist/jobs/index.mjs +53 -15
- package/dist/maestro-processes/index.cjs +189 -27
- package/dist/maestro-processes/index.d.ts +131 -9
- package/dist/maestro-processes/index.mjs +189 -27
- package/dist/orchestrator-du-module/index.cjs +1788 -0
- package/dist/orchestrator-du-module/index.d.ts +757 -0
- package/dist/orchestrator-du-module/index.mjs +1785 -0
- package/dist/processes/index.cjs +53 -15
- package/dist/processes/index.d.ts +1 -0
- package/dist/processes/index.mjs +53 -15
- package/dist/queues/index.cjs +53 -15
- package/dist/queues/index.d.ts +1 -0
- package/dist/queues/index.mjs +53 -15
- package/dist/tasks/index.cjs +116 -19
- package/dist/tasks/index.d.ts +110 -4
- package/dist/tasks/index.mjs +117 -20
- package/dist/traces/index.cjs +340 -15
- package/dist/traces/index.d.ts +483 -2
- package/dist/traces/index.mjs +339 -16
- 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
|
|
@@ -4470,6 +4496,24 @@ var TaskActivityType;
|
|
|
4470
4496
|
TaskActivityType["BulkCompleted"] = "BulkCompleted";
|
|
4471
4497
|
TaskActivityType["FirstOpened"] = "FirstOpened";
|
|
4472
4498
|
})(TaskActivityType || (TaskActivityType = {}));
|
|
4499
|
+
/**
|
|
4500
|
+
* Defines how a task assignment is distributed.
|
|
4501
|
+
*
|
|
4502
|
+
* Defaults to {@link TaskAssignmentCriteria.SingleUser} (a direct single-user
|
|
4503
|
+
* assignment) when not specified. The group-based criteria tell Action Center
|
|
4504
|
+
* how to distribute the task across the members of a directory group.
|
|
4505
|
+
*/
|
|
4506
|
+
var TaskAssignmentCriteria;
|
|
4507
|
+
(function (TaskAssignmentCriteria) {
|
|
4508
|
+
/** Assigned to a single user, like a direct assignment. */
|
|
4509
|
+
TaskAssignmentCriteria["SingleUser"] = "SingleUser";
|
|
4510
|
+
/** Assigned to the group member with the fewest pending tasks. */
|
|
4511
|
+
TaskAssignmentCriteria["Workload"] = "Workload";
|
|
4512
|
+
/** Assigned to all users in the group. */
|
|
4513
|
+
TaskAssignmentCriteria["AllUsers"] = "AllUsers";
|
|
4514
|
+
/** Assigned in a round-robin manner across the group's members. */
|
|
4515
|
+
TaskAssignmentCriteria["RoundRobin"] = "RoundRobin";
|
|
4516
|
+
})(TaskAssignmentCriteria || (TaskAssignmentCriteria = {}));
|
|
4473
4517
|
|
|
4474
4518
|
/**
|
|
4475
4519
|
* Base path constants for different services
|
|
@@ -4478,6 +4522,7 @@ const ORCHESTRATOR_BASE = 'orchestrator_';
|
|
|
4478
4522
|
const PIMS_BASE = 'pims_';
|
|
4479
4523
|
const DATAFABRIC_BASE = 'datafabric_';
|
|
4480
4524
|
const IDENTITY_BASE = 'identity_';
|
|
4525
|
+
const LLMOPS_BASE = 'llmopstenant_';
|
|
4481
4526
|
const INSIGHTS_RTM_BASE = 'insightsrtm_';
|
|
4482
4527
|
|
|
4483
4528
|
/**
|
|
@@ -4570,7 +4615,7 @@ const MAESTRO_ENDPOINTS = {
|
|
|
4570
4615
|
INSTANCES: {
|
|
4571
4616
|
GET_ALL: `${PIMS_BASE}/api/v1/instances`,
|
|
4572
4617
|
GET_BY_ID: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}`,
|
|
4573
|
-
|
|
4618
|
+
GET_ELEMENT_EXECUTIONS: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/element-executions`,
|
|
4574
4619
|
GET_BPMN: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/bpmn`,
|
|
4575
4620
|
GET_VARIABLES: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/variables`,
|
|
4576
4621
|
CANCEL: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/cancel`,
|
|
@@ -4582,6 +4627,9 @@ const MAESTRO_ENDPOINTS = {
|
|
|
4582
4627
|
GET_BY_PROCESS: (processKey) => `${PIMS_BASE}/api/v1/incidents/process/${processKey}`,
|
|
4583
4628
|
GET_BY_INSTANCE: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/incidents`,
|
|
4584
4629
|
},
|
|
4630
|
+
TRACES: {
|
|
4631
|
+
GET_SPANS: (traceId) => `${LLMOPS_BASE}/api/Traces/spans?traceId=${traceId}`,
|
|
4632
|
+
},
|
|
4585
4633
|
CASES: {
|
|
4586
4634
|
GET_CASE_JSON: (instanceId) => `${PIMS_BASE}/api/v1/cases/${instanceId}/case-json`,
|
|
4587
4635
|
GET_ELEMENT_EXECUTIONS: (instanceId) => `${PIMS_BASE}/api/v1/element-executions/case-instances/${instanceId}`,
|
|
@@ -4602,6 +4650,8 @@ const MAESTRO_ENDPOINTS = {
|
|
|
4602
4650
|
INSTANCE_STATUS_BY_DATE: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/InstanceStatusByDate`,
|
|
4603
4651
|
/** Top processes ranked by total duration */
|
|
4604
4652
|
TOP_PROCESSES_BY_DURATION: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/TopProcessesByDuration`,
|
|
4653
|
+
/** Element count by status for agentic instances (process and case) */
|
|
4654
|
+
ELEMENT_COUNT_BY_STATUS: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/ElementCountByStatus`,
|
|
4605
4655
|
},
|
|
4606
4656
|
};
|
|
4607
4657
|
|
|
@@ -4620,6 +4670,9 @@ const DATA_FABRIC_TENANT_FOLDER_ID = '00000000-0000-0000-0000-000000000000';
|
|
|
4620
4670
|
const DATA_FABRIC_ENDPOINTS = {
|
|
4621
4671
|
ENTITY: {
|
|
4622
4672
|
GET_ALL: `${DATAFABRIC_BASE}/api/Entity`,
|
|
4673
|
+
// Lists tenant-level and folder-level entities together.
|
|
4674
|
+
// Used by getAll when includeFolderEntities is true.
|
|
4675
|
+
GET_ALL_V2: `${DATAFABRIC_BASE}/api/v2/Entity`,
|
|
4623
4676
|
GET_ENTITY_RECORDS: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/read`,
|
|
4624
4677
|
GET_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/Entity/${entityId}`,
|
|
4625
4678
|
GET_RECORD_BY_ID: (entityId, recordId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/read/${recordId}`,
|
|
@@ -4676,6 +4729,105 @@ var ActionCenterEventNames;
|
|
|
4676
4729
|
})(ActionCenterEventNames || (ActionCenterEventNames = {}));
|
|
4677
4730
|
|
|
4678
4731
|
const AUTHENTICATION_TIMEOUT = 8000;
|
|
4732
|
+
const ALLOWED_HOST_ORIGINS = new Set([
|
|
4733
|
+
'https://alpha.uipath.com',
|
|
4734
|
+
'https://staging.uipath.com',
|
|
4735
|
+
'https://cloud.uipath.com',
|
|
4736
|
+
]);
|
|
4737
|
+
/**
|
|
4738
|
+
* Returns true if the origin is a trusted UiPath host that may initiate
|
|
4739
|
+
* token delegation. Mirrors the same allowlist used by ActionCenterTokenManager.
|
|
4740
|
+
*/
|
|
4741
|
+
function isValidHostOrigin(origin) {
|
|
4742
|
+
if (!origin)
|
|
4743
|
+
return false;
|
|
4744
|
+
if (ALLOWED_HOST_ORIGINS.has(origin))
|
|
4745
|
+
return true;
|
|
4746
|
+
try {
|
|
4747
|
+
return new URL(origin).hostname === 'localhost';
|
|
4748
|
+
}
|
|
4749
|
+
catch {
|
|
4750
|
+
console.warn('isValidHostOrigin: received a malformed origin URL', origin);
|
|
4751
|
+
return false;
|
|
4752
|
+
}
|
|
4753
|
+
}
|
|
4754
|
+
function isTokenExpired(tokenInfo) {
|
|
4755
|
+
if (!tokenInfo?.expiresAt)
|
|
4756
|
+
return true;
|
|
4757
|
+
return new Date() >= tokenInfo.expiresAt;
|
|
4758
|
+
}
|
|
4759
|
+
/**
|
|
4760
|
+
* The validated host origin when the app is running as a trusted, generic
|
|
4761
|
+
* host-embedded app (`?host=embed&basedomain=<origin>` with an allowlisted
|
|
4762
|
+
* UiPath origin); otherwise null. Shared by TokenManager (to create the
|
|
4763
|
+
* EmbeddedTokenManager) and UiPath init (to seed an empty token so getValidToken
|
|
4764
|
+
* can bootstrap the postMessage token flow), which previously duplicated this
|
|
4765
|
+
* condition inline.
|
|
4766
|
+
*/
|
|
4767
|
+
const trustedEmbeddingOrigin = isHostEmbedded && embeddingOrigin && isValidHostOrigin(embeddingOrigin) ? embeddingOrigin : null;
|
|
4768
|
+
/**
|
|
4769
|
+
* Waits for the next window message that satisfies `filter`.
|
|
4770
|
+
* Rejects if the AbortSignal fires before a matching message arrives.
|
|
4771
|
+
*/
|
|
4772
|
+
function waitForMessage(filter, signal) {
|
|
4773
|
+
return new Promise((resolve, reject) => {
|
|
4774
|
+
const handler = (event) => {
|
|
4775
|
+
if (!filter(event))
|
|
4776
|
+
return;
|
|
4777
|
+
window.removeEventListener('message', handler);
|
|
4778
|
+
resolve(event);
|
|
4779
|
+
};
|
|
4780
|
+
signal.addEventListener('abort', () => {
|
|
4781
|
+
window.removeEventListener('message', handler);
|
|
4782
|
+
reject(signal.reason);
|
|
4783
|
+
}, { once: true });
|
|
4784
|
+
window.addEventListener('message', handler);
|
|
4785
|
+
});
|
|
4786
|
+
}
|
|
4787
|
+
/**
|
|
4788
|
+
* Sends a token-refresh request to a parent host frame and waits for the
|
|
4789
|
+
* response. Handles timeout, origin filtering, and listener cleanup.
|
|
4790
|
+
*
|
|
4791
|
+
* Both ActionCenterTokenManager and EmbeddedTokenManager delegate to this
|
|
4792
|
+
* function; they differ only in the event names and message shape they use.
|
|
4793
|
+
*/
|
|
4794
|
+
function requestHostToken(options) {
|
|
4795
|
+
const { pinnedOrigin, sendRequest, responseEventType, extractToken, onTokenRefreshed } = options;
|
|
4796
|
+
const controller = new AbortController();
|
|
4797
|
+
const cancel = () => controller.abort(new AuthenticationError({
|
|
4798
|
+
message: 'Token refresh cancelled',
|
|
4799
|
+
statusCode: HttpStatus.UNAUTHORIZED,
|
|
4800
|
+
}));
|
|
4801
|
+
const promise = (async () => {
|
|
4802
|
+
const timer = setTimeout(() => controller.abort(new AuthenticationError({
|
|
4803
|
+
message: `Token refresh timed out after ${AUTHENTICATION_TIMEOUT}ms waiting for host response`,
|
|
4804
|
+
statusCode: HttpStatus.UNAUTHORIZED,
|
|
4805
|
+
})), AUTHENTICATION_TIMEOUT);
|
|
4806
|
+
try {
|
|
4807
|
+
// Register listener before sending — avoids any race between send and response
|
|
4808
|
+
const responsePromise = waitForMessage(event => event.origin === pinnedOrigin && event.data?.eventType === responseEventType, controller.signal);
|
|
4809
|
+
sendRequest();
|
|
4810
|
+
const event = await responsePromise;
|
|
4811
|
+
const token = extractToken(event.data);
|
|
4812
|
+
if (!token) {
|
|
4813
|
+
throw new AuthenticationError({
|
|
4814
|
+
message: 'Host responded but did not include a valid access token',
|
|
4815
|
+
statusCode: HttpStatus.UNAUTHORIZED,
|
|
4816
|
+
});
|
|
4817
|
+
}
|
|
4818
|
+
// type: 'secret' intentionally prevents the SDK's internal OAuth refresh path
|
|
4819
|
+
// from running — the host manager owns the refresh cycle via requestHostToken.
|
|
4820
|
+
// This mirrors the same pattern used by ActionCenterTokenManager.
|
|
4821
|
+
onTokenRefreshed({ token: token.accessToken, type: 'secret', expiresAt: token.expiresAt });
|
|
4822
|
+
return token.accessToken;
|
|
4823
|
+
}
|
|
4824
|
+
finally {
|
|
4825
|
+
clearTimeout(timer);
|
|
4826
|
+
}
|
|
4827
|
+
})();
|
|
4828
|
+
return { promise, cancel };
|
|
4829
|
+
}
|
|
4830
|
+
|
|
4679
4831
|
class ActionCenterTokenManager {
|
|
4680
4832
|
constructor(config, onTokenRefreshed) {
|
|
4681
4833
|
this.config = config;
|
|
@@ -4684,84 +4836,334 @@ class ActionCenterTokenManager {
|
|
|
4684
4836
|
this.refreshPromise = null;
|
|
4685
4837
|
}
|
|
4686
4838
|
async refreshAccessToken(tokenInfo) {
|
|
4687
|
-
if (!
|
|
4839
|
+
if (!isTokenExpired(tokenInfo)) {
|
|
4688
4840
|
return tokenInfo.token;
|
|
4689
4841
|
}
|
|
4690
4842
|
if (this.refreshPromise) {
|
|
4691
4843
|
return this.refreshPromise;
|
|
4692
4844
|
}
|
|
4693
|
-
|
|
4694
|
-
|
|
4845
|
+
const parentOrigin = this.parentOrigin;
|
|
4846
|
+
if (!parentOrigin) {
|
|
4847
|
+
return Promise.reject(new AuthenticationError({
|
|
4848
|
+
message: 'Cannot refresh token: basedomain query parameter is missing',
|
|
4849
|
+
statusCode: HttpStatus.UNAUTHORIZED,
|
|
4850
|
+
}));
|
|
4851
|
+
}
|
|
4852
|
+
// Guard before requestHostToken registers the inbound listener — an untrusted
|
|
4853
|
+
// basedomain would otherwise leave the listener live for the full timeout window,
|
|
4854
|
+
// accepting a forged TOKENREFRESHED from that origin.
|
|
4855
|
+
if (!isValidHostOrigin(parentOrigin)) {
|
|
4856
|
+
return Promise.reject(new AuthenticationError({
|
|
4857
|
+
message: 'Cannot refresh token: basedomain is not a trusted UiPath host origin',
|
|
4858
|
+
statusCode: HttpStatus.UNAUTHORIZED,
|
|
4859
|
+
}));
|
|
4860
|
+
}
|
|
4861
|
+
const { promise } = requestHostToken({
|
|
4862
|
+
pinnedOrigin: parentOrigin,
|
|
4863
|
+
sendRequest: () => this.sendMessageToParent(ActionCenterEventNames.REFRESHTOKEN, {
|
|
4695
4864
|
clientId: this.config.clientId,
|
|
4696
4865
|
scope: this.config.scope,
|
|
4697
|
-
}
|
|
4698
|
-
|
|
4699
|
-
|
|
4700
|
-
|
|
4701
|
-
|
|
4702
|
-
|
|
4703
|
-
|
|
4704
|
-
|
|
4705
|
-
|
|
4706
|
-
const { accessToken, expiresAt } = event.data.content.token;
|
|
4707
|
-
this.onTokenRefreshed({ token: accessToken, type: 'secret', expiresAt });
|
|
4708
|
-
resolve(accessToken);
|
|
4709
|
-
}
|
|
4710
|
-
else {
|
|
4711
|
-
reject(new AuthenticationError({
|
|
4712
|
-
message: 'Failed to fetch access token',
|
|
4713
|
-
statusCode: HttpStatus.UNAUTHORIZED,
|
|
4714
|
-
}));
|
|
4715
|
-
}
|
|
4716
|
-
this.refreshPromise = null;
|
|
4717
|
-
this.cleanup(messageListener);
|
|
4718
|
-
};
|
|
4719
|
-
const timer = setTimeout(() => {
|
|
4720
|
-
reject(new AuthenticationError({
|
|
4721
|
-
message: 'Failed to fetch access token',
|
|
4722
|
-
statusCode: HttpStatus.UNAUTHORIZED,
|
|
4723
|
-
}));
|
|
4724
|
-
this.refreshPromise = null;
|
|
4725
|
-
this.cleanup(messageListener);
|
|
4726
|
-
}, AUTHENTICATION_TIMEOUT);
|
|
4727
|
-
window.addEventListener('message', messageListener);
|
|
4866
|
+
}),
|
|
4867
|
+
responseEventType: ActionCenterEventNames.TOKENREFRESHED,
|
|
4868
|
+
extractToken: (data) => {
|
|
4869
|
+
const token = data?.content?.token;
|
|
4870
|
+
if (!token?.accessToken)
|
|
4871
|
+
return undefined;
|
|
4872
|
+
return { accessToken: token.accessToken, expiresAt: token.expiresAt };
|
|
4873
|
+
},
|
|
4874
|
+
onTokenRefreshed: this.onTokenRefreshed,
|
|
4728
4875
|
});
|
|
4729
|
-
|
|
4730
|
-
|
|
4731
|
-
|
|
4732
|
-
|
|
4733
|
-
|
|
4876
|
+
this.refreshPromise = promise;
|
|
4877
|
+
try {
|
|
4878
|
+
return await this.refreshPromise;
|
|
4879
|
+
}
|
|
4880
|
+
finally {
|
|
4881
|
+
this.refreshPromise = null;
|
|
4734
4882
|
}
|
|
4735
|
-
return new Date() >= tokenInfo.expiresAt;
|
|
4736
4883
|
}
|
|
4737
4884
|
sendMessageToParent(eventType, content) {
|
|
4738
|
-
if (window.parent &&
|
|
4885
|
+
if (window.parent && isValidHostOrigin(this.parentOrigin)) {
|
|
4739
4886
|
try {
|
|
4740
4887
|
window.parent.postMessage({ eventType, content }, this.parentOrigin);
|
|
4741
4888
|
}
|
|
4742
4889
|
catch (error) {
|
|
4743
|
-
console.warn('
|
|
4890
|
+
console.warn('ActionCenterTokenManager: postMessage to host failed', JSON.stringify(error));
|
|
4744
4891
|
}
|
|
4745
4892
|
}
|
|
4746
4893
|
}
|
|
4747
|
-
|
|
4748
|
-
|
|
4894
|
+
}
|
|
4895
|
+
|
|
4896
|
+
/**
|
|
4897
|
+
* Event names and payload types for the UIP.* postMessage protocol used
|
|
4898
|
+
* when a coded app is embedded inside a UiPath host (e.g. Governance Portal, Insights UI).
|
|
4899
|
+
*
|
|
4900
|
+
* Flow — app-initiated, mirrors the Action Center protocol:
|
|
4901
|
+
* App → Host: UIP.refreshToken (requests a token; carries clientId + scope
|
|
4902
|
+
* so the host knows which OAuth client to use)
|
|
4903
|
+
* Host → App: UIP.tokenRefreshed (delivers the access token)
|
|
4904
|
+
*
|
|
4905
|
+
* Detection: the host signals embedding via `?host=embed&basedomain=<origin>` in
|
|
4906
|
+
* the iframe src URL. No explicit init message from the host is required.
|
|
4907
|
+
*/
|
|
4908
|
+
var UipEmbeddedEventNames;
|
|
4909
|
+
(function (UipEmbeddedEventNames) {
|
|
4910
|
+
UipEmbeddedEventNames["REFRESH_TOKEN"] = "UIP.refreshToken";
|
|
4911
|
+
UipEmbeddedEventNames["TOKEN_REFRESHED"] = "UIP.tokenRefreshed";
|
|
4912
|
+
})(UipEmbeddedEventNames || (UipEmbeddedEventNames = {}));
|
|
4913
|
+
|
|
4914
|
+
function parseExpiresAt(raw) {
|
|
4915
|
+
const d = new Date(raw);
|
|
4916
|
+
if (isNaN(d.getTime())) {
|
|
4917
|
+
console.warn('EmbeddedTokenManager: host sent a malformed expiresAt value — treating token as already expired', raw);
|
|
4918
|
+
return new Date(0);
|
|
4919
|
+
}
|
|
4920
|
+
return d;
|
|
4921
|
+
}
|
|
4922
|
+
function extractToken(data) {
|
|
4923
|
+
const token = data?.content?.token;
|
|
4924
|
+
if (!token?.accessToken)
|
|
4925
|
+
return undefined;
|
|
4926
|
+
return { accessToken: token.accessToken, expiresAt: parseExpiresAt(token.expiresAt) };
|
|
4927
|
+
}
|
|
4928
|
+
/**
|
|
4929
|
+
* Handles token delegation for coded apps embedded inside a UiPath host
|
|
4930
|
+
* (e.g. Governance Portal, Insights UI).
|
|
4931
|
+
*
|
|
4932
|
+
* Detection: the host signals embedding via `?host=embed&basedomain=<origin>`
|
|
4933
|
+
* in the iframe src URL. `parentOrigin` is read from `?basedomain=` and validated
|
|
4934
|
+
* against the trusted UiPath host allowlist before this manager is constructed.
|
|
4935
|
+
* This mirrors the mechanism used by ActionCenterTokenManager.
|
|
4936
|
+
*
|
|
4937
|
+
* On every token expiry the SDK sends `UIP.refreshToken` with `clientId` and
|
|
4938
|
+
* `scope`; the host performs silent SSO and responds with `UIP.tokenRefreshed`.
|
|
4939
|
+
*/
|
|
4940
|
+
class EmbeddedTokenManager {
|
|
4941
|
+
/**
|
|
4942
|
+
* @param parentOrigin Validated UiPath host origin from the `?basedomain=` query parameter.
|
|
4943
|
+
* @param config SDK configuration — `clientId` and `scope` are required and forwarded
|
|
4944
|
+
* in every `UIP.refreshToken` request so the host knows which OAuth client to use.
|
|
4945
|
+
* @param onTokenRefreshed Called with the refreshed TokenInfo so the caller
|
|
4946
|
+
* can persist it in the execution context.
|
|
4947
|
+
* @throws {AuthenticationError} if `config.clientId` or `config.scope` are not set.
|
|
4948
|
+
*/
|
|
4949
|
+
constructor(parentOrigin, config, onTokenRefreshed) {
|
|
4950
|
+
this.parentOrigin = parentOrigin;
|
|
4951
|
+
this.onTokenRefreshed = onTokenRefreshed;
|
|
4952
|
+
this.refreshPromise = null;
|
|
4953
|
+
this.cancelRefresh = null;
|
|
4954
|
+
if (!config.clientId || !config.scope) {
|
|
4955
|
+
throw new ValidationError({
|
|
4956
|
+
message: 'EmbeddedTokenManager requires clientId and scope to be configured for host-delegated authentication',
|
|
4957
|
+
});
|
|
4958
|
+
}
|
|
4959
|
+
this.clientId = config.clientId;
|
|
4960
|
+
this.scope = config.scope;
|
|
4749
4961
|
}
|
|
4750
|
-
|
|
4751
|
-
|
|
4752
|
-
|
|
4753
|
-
return false;
|
|
4962
|
+
async refreshAccessToken(tokenInfo) {
|
|
4963
|
+
if (!isTokenExpired(tokenInfo)) {
|
|
4964
|
+
return tokenInfo.token;
|
|
4754
4965
|
}
|
|
4755
|
-
if (
|
|
4756
|
-
return
|
|
4966
|
+
if (this.refreshPromise) {
|
|
4967
|
+
return this.refreshPromise;
|
|
4757
4968
|
}
|
|
4969
|
+
const { promise, cancel } = requestHostToken({
|
|
4970
|
+
pinnedOrigin: this.parentOrigin,
|
|
4971
|
+
sendRequest: () => {
|
|
4972
|
+
try {
|
|
4973
|
+
const message = {
|
|
4974
|
+
eventType: UipEmbeddedEventNames.REFRESH_TOKEN,
|
|
4975
|
+
content: { clientId: this.clientId, scope: this.scope },
|
|
4976
|
+
};
|
|
4977
|
+
window.parent.postMessage(message, this.parentOrigin);
|
|
4978
|
+
}
|
|
4979
|
+
catch (error) {
|
|
4980
|
+
console.warn('EmbeddedTokenManager: postMessage to host failed', error);
|
|
4981
|
+
}
|
|
4982
|
+
},
|
|
4983
|
+
responseEventType: UipEmbeddedEventNames.TOKEN_REFRESHED,
|
|
4984
|
+
extractToken,
|
|
4985
|
+
onTokenRefreshed: this.onTokenRefreshed,
|
|
4986
|
+
});
|
|
4987
|
+
this.cancelRefresh = cancel;
|
|
4988
|
+
this.refreshPromise = promise;
|
|
4758
4989
|
try {
|
|
4759
|
-
|
|
4760
|
-
return url.hostname === 'localhost';
|
|
4990
|
+
return await this.refreshPromise;
|
|
4761
4991
|
}
|
|
4762
|
-
|
|
4763
|
-
|
|
4992
|
+
finally {
|
|
4993
|
+
this.refreshPromise = null;
|
|
4994
|
+
this.cancelRefresh = null;
|
|
4995
|
+
}
|
|
4996
|
+
}
|
|
4997
|
+
/** Cancels any in-flight token-refresh request. */
|
|
4998
|
+
destroy() {
|
|
4999
|
+
this.cancelRefresh?.();
|
|
5000
|
+
}
|
|
5001
|
+
}
|
|
5002
|
+
|
|
5003
|
+
/**
|
|
5004
|
+
* SDK Telemetry constants.
|
|
5005
|
+
*
|
|
5006
|
+
* Only the SDK's identity (version, service name, role name, …) lives
|
|
5007
|
+
* here. The Application Insights connection string is injected into
|
|
5008
|
+
* `@uipath/core-telemetry` itself at publish time, and the generic attribute
|
|
5009
|
+
* keys (`Version`, `Service`, `CloudOrganizationName`, …) are owned by
|
|
5010
|
+
* `@uipath/core-telemetry` and consumed there — they are not part of the
|
|
5011
|
+
* SDK's public API.
|
|
5012
|
+
*/
|
|
5013
|
+
/** SDK version placeholder — patched by the SDK publish workflow. */
|
|
5014
|
+
const SDK_VERSION = '1.4.1';
|
|
5015
|
+
const CLOUD_ROLE_NAME = 'uipath-ts-sdk';
|
|
5016
|
+
const SDK_SERVICE_NAME = 'UiPath.TypeScript.Sdk';
|
|
5017
|
+
const SDK_LOGGER_NAME = 'uipath-ts-sdk-telemetry';
|
|
5018
|
+
const SDK_RUN_EVENT = 'Sdk.Run';
|
|
5019
|
+
|
|
5020
|
+
/**
|
|
5021
|
+
* UiPath TypeScript SDK Telemetry
|
|
5022
|
+
*
|
|
5023
|
+
* Constructs the SDK's own `TelemetryClient` and binds the SDK-local
|
|
5024
|
+
* `track` / `trackEvent` to it. Each consumer of `@uipath/core-telemetry`
|
|
5025
|
+
* does this independently, so events carry their own consumer's identity
|
|
5026
|
+
* and tenant context.
|
|
5027
|
+
*/
|
|
5028
|
+
// Keyed by `CLOUD_ROLE_NAME` so every SDK subpath bundle resolves to the
|
|
5029
|
+
// same `TelemetryClient` instance at runtime. A single `initialize(...)`
|
|
5030
|
+
// from the `UiPath` constructor therefore wires up `@track` decorators
|
|
5031
|
+
// across every subpath bundle (`assets`, `feedback`, `tasks`, …).
|
|
5032
|
+
const sdkClient = getOrCreateClient(CLOUD_ROLE_NAME);
|
|
5033
|
+
const track = createTrack(sdkClient);
|
|
5034
|
+
const trackEvent = createTrackEvent(sdkClient);
|
|
5035
|
+
const telemetryClient = {
|
|
5036
|
+
initialize(context) {
|
|
5037
|
+
sdkClient.initialize({
|
|
5038
|
+
sdkVersion: SDK_VERSION,
|
|
5039
|
+
serviceName: SDK_SERVICE_NAME,
|
|
5040
|
+
cloudRoleName: CLOUD_ROLE_NAME,
|
|
5041
|
+
loggerName: SDK_LOGGER_NAME,
|
|
5042
|
+
defaultEventName: SDK_RUN_EVENT,
|
|
5043
|
+
context,
|
|
5044
|
+
});
|
|
5045
|
+
},
|
|
5046
|
+
/**
|
|
5047
|
+
* Sets the authenticated user's id so every subsequently emitted event
|
|
5048
|
+
* carries it as `CloudUserId`.
|
|
5049
|
+
*/
|
|
5050
|
+
setUserId(userId) {
|
|
5051
|
+
sdkClient.setUserId(userId);
|
|
5052
|
+
},
|
|
5053
|
+
};
|
|
5054
|
+
|
|
5055
|
+
/**
|
|
5056
|
+
* Base64 encoding/decoding
|
|
5057
|
+
*/
|
|
5058
|
+
/**
|
|
5059
|
+
* Encodes a string to base64
|
|
5060
|
+
* @param str - The string to encode
|
|
5061
|
+
* @returns Base64 encoded string
|
|
5062
|
+
*/
|
|
5063
|
+
function encodeBase64(str) {
|
|
5064
|
+
// TextEncoder for UTF-8 encoding (works in both browser and Node.js)
|
|
5065
|
+
const encoder = new TextEncoder();
|
|
5066
|
+
const data = encoder.encode(str);
|
|
5067
|
+
// Convert Uint8Array to base64
|
|
5068
|
+
if (isBrowser) {
|
|
5069
|
+
// Browser environment
|
|
5070
|
+
// Convert Uint8Array to binary string then to base64
|
|
5071
|
+
const binaryString = Array.from(data, byte => String.fromCharCode(byte)).join('');
|
|
5072
|
+
return btoa(binaryString);
|
|
5073
|
+
}
|
|
5074
|
+
else {
|
|
5075
|
+
// Node.js environment
|
|
5076
|
+
return Buffer.from(data).toString('base64');
|
|
5077
|
+
}
|
|
5078
|
+
}
|
|
5079
|
+
/**
|
|
5080
|
+
* Decodes a base64 string
|
|
5081
|
+
* @param base64 - The base64 string to decode
|
|
5082
|
+
* @returns Decoded string
|
|
5083
|
+
*/
|
|
5084
|
+
function decodeBase64(base64) {
|
|
5085
|
+
let bytes;
|
|
5086
|
+
if (isBrowser) {
|
|
5087
|
+
// Browser environment
|
|
5088
|
+
const binaryString = atob(base64);
|
|
5089
|
+
bytes = new Uint8Array(binaryString.length);
|
|
5090
|
+
for (let i = 0; i < binaryString.length; i++) {
|
|
5091
|
+
bytes[i] = binaryString.charCodeAt(i);
|
|
5092
|
+
}
|
|
5093
|
+
}
|
|
5094
|
+
else {
|
|
5095
|
+
// Node.js environment
|
|
5096
|
+
bytes = new Uint8Array(Buffer.from(base64, 'base64'));
|
|
5097
|
+
}
|
|
5098
|
+
// TextDecoder for UTF-8 decoding (works in both browser and Node.js)
|
|
5099
|
+
const decoder = new TextDecoder();
|
|
5100
|
+
return decoder.decode(bytes);
|
|
5101
|
+
}
|
|
5102
|
+
|
|
5103
|
+
/**
|
|
5104
|
+
* Encodes a folder path for the `X-UIPATH-FolderPath-Encoded` header.
|
|
5105
|
+
*
|
|
5106
|
+
* Orchestrator decodes this header as **base64-encoded UTF-16 LE bytes**
|
|
5107
|
+
* (see `HttpHeadersProviderExtensions.GetDecoded` + `OrganizationUnitProvider`
|
|
5108
|
+
* in the Orchestrator repo, which call `Encoding.Unicode.GetString(...)`).
|
|
5109
|
+
* URL-encoding is NOT what the server expects — it must be base64-of-UTF-16-LE
|
|
5110
|
+
* bytes.
|
|
5111
|
+
*
|
|
5112
|
+
* @param folderPath - The folder path (e.g. 'Shared/Finance')
|
|
5113
|
+
* @returns Base64 string suitable for the `X-UIPATH-FolderPath-Encoded` header
|
|
5114
|
+
*/
|
|
5115
|
+
function encodeFolderPathHeader(folderPath) {
|
|
5116
|
+
// Force little-endian regardless of host byte order. `Uint16Array` viewed
|
|
5117
|
+
// as `Uint8Array` would use the host's native order — correct on LE hosts
|
|
5118
|
+
// (x86/ARM-LE) but wrong on BE hosts. `DataView.setUint16(..., true)`
|
|
5119
|
+
// pins LE.
|
|
5120
|
+
const buf = new ArrayBuffer(folderPath.length * 2);
|
|
5121
|
+
const view = new DataView(buf);
|
|
5122
|
+
for (let i = 0; i < folderPath.length; i++) {
|
|
5123
|
+
view.setUint16(i * 2, folderPath.charCodeAt(i), true);
|
|
5124
|
+
}
|
|
5125
|
+
const bytes = new Uint8Array(buf);
|
|
5126
|
+
let binary = '';
|
|
5127
|
+
for (let i = 0; i < bytes.byteLength; i++) {
|
|
5128
|
+
binary += String.fromCharCode(bytes[i]);
|
|
5129
|
+
}
|
|
5130
|
+
// btoa is browser-native; Node 16+ also has it as a global
|
|
5131
|
+
return btoa(binary);
|
|
5132
|
+
}
|
|
5133
|
+
|
|
5134
|
+
/**
|
|
5135
|
+
* JWT decoding helpers — payload inspection only, no signature verification.
|
|
5136
|
+
*/
|
|
5137
|
+
const BASE64URL_DASH_RE = /-/g;
|
|
5138
|
+
const BASE64URL_UNDERSCORE_RE = /_/g;
|
|
5139
|
+
/**
|
|
5140
|
+
* Converts a base64url-encoded JWT segment to standard base64 with padding.
|
|
5141
|
+
*/
|
|
5142
|
+
function base64UrlToBase64(value) {
|
|
5143
|
+
const base64 = value
|
|
5144
|
+
.replace(BASE64URL_DASH_RE, '+')
|
|
5145
|
+
.replace(BASE64URL_UNDERSCORE_RE, '/');
|
|
5146
|
+
return base64.padEnd(base64.length + ((4 - (base64.length % 4)) % 4), '=');
|
|
5147
|
+
}
|
|
5148
|
+
/**
|
|
5149
|
+
* Extracts the user id (`sub` claim) from a JWT access token payload.
|
|
5150
|
+
* Returns an empty string for opaque (non-JWT) tokens or malformed payloads.
|
|
5151
|
+
*
|
|
5152
|
+
* @param token - The access token to inspect
|
|
5153
|
+
* @returns The user id, or an empty string if it cannot be extracted
|
|
5154
|
+
*/
|
|
5155
|
+
function extractUserIdFromToken(token) {
|
|
5156
|
+
try {
|
|
5157
|
+
const payload = token.split('.')[1];
|
|
5158
|
+
if (!payload) {
|
|
5159
|
+
return '';
|
|
4764
5160
|
}
|
|
5161
|
+
const claims = JSON.parse(decodeBase64(base64UrlToBase64(payload)));
|
|
5162
|
+
const sub = claims['sub'];
|
|
5163
|
+
return typeof sub === 'string' && sub ? sub : '';
|
|
5164
|
+
}
|
|
5165
|
+
catch {
|
|
5166
|
+
return '';
|
|
4765
5167
|
}
|
|
4766
5168
|
}
|
|
4767
5169
|
|
|
@@ -4784,10 +5186,15 @@ class TokenManager {
|
|
|
4784
5186
|
this.isOAuth = isOAuth;
|
|
4785
5187
|
this.refreshPromise = null;
|
|
4786
5188
|
this.actionCenterTokenManager = null;
|
|
5189
|
+
this.embeddedTokenManager = null;
|
|
4787
5190
|
if (isInActionCenter) {
|
|
4788
5191
|
this.actionCenterTokenManager = new ActionCenterTokenManager(config, (tokenInfo) => this.setToken(tokenInfo));
|
|
4789
5192
|
this.isOAuth = false;
|
|
4790
5193
|
}
|
|
5194
|
+
else if (trustedEmbeddingOrigin) {
|
|
5195
|
+
this.embeddedTokenManager = new EmbeddedTokenManager(trustedEmbeddingOrigin, config, tokenInfo => this.setToken(tokenInfo));
|
|
5196
|
+
this.isOAuth = false;
|
|
5197
|
+
}
|
|
4791
5198
|
}
|
|
4792
5199
|
/**
|
|
4793
5200
|
* Checks if a token is expired
|
|
@@ -4818,6 +5225,10 @@ class TokenManager {
|
|
|
4818
5225
|
if (this.actionCenterTokenManager) {
|
|
4819
5226
|
return await this.actionCenterTokenManager.refreshAccessToken(tokenInfo);
|
|
4820
5227
|
}
|
|
5228
|
+
// Generic embedded path — active whenever the app is embedded in a UiPath host page
|
|
5229
|
+
if (this.embeddedTokenManager) {
|
|
5230
|
+
return await this.embeddedTokenManager.refreshAccessToken(tokenInfo);
|
|
5231
|
+
}
|
|
4821
5232
|
// For secret-based tokens, they never expire
|
|
4822
5233
|
if (tokenInfo.type === 'secret') {
|
|
4823
5234
|
return tokenInfo.token;
|
|
@@ -4956,6 +5367,13 @@ class TokenManager {
|
|
|
4956
5367
|
}
|
|
4957
5368
|
return true;
|
|
4958
5369
|
}
|
|
5370
|
+
/**
|
|
5371
|
+
* Releases resources held by this instance.
|
|
5372
|
+
* Must be called when the TokenManager is no longer needed to prevent listener leaks.
|
|
5373
|
+
*/
|
|
5374
|
+
destroy() {
|
|
5375
|
+
this.embeddedTokenManager?.destroy();
|
|
5376
|
+
}
|
|
4959
5377
|
/**
|
|
4960
5378
|
* Clears the current token
|
|
4961
5379
|
*/
|
|
@@ -4977,6 +5395,7 @@ class TokenManager {
|
|
|
4977
5395
|
*/
|
|
4978
5396
|
_updateExecutionContext(tokenInfo) {
|
|
4979
5397
|
this.executionContext.set('tokenInfo', tokenInfo);
|
|
5398
|
+
telemetryClient.setUserId(extractUserIdFromToken(tokenInfo.token));
|
|
4980
5399
|
}
|
|
4981
5400
|
/**
|
|
4982
5401
|
* Refreshes the access token using the stored refresh token.
|
|
@@ -5006,6 +5425,9 @@ class TokenManager {
|
|
|
5006
5425
|
* Internal method to perform the actual token refresh
|
|
5007
5426
|
*/
|
|
5008
5427
|
async _doRefreshToken() {
|
|
5428
|
+
// Destructure before the type guard — hasOAuthConfig narrows this.config to
|
|
5429
|
+
// { clientId, redirectUri, scope } which does not include BaseConfig fields.
|
|
5430
|
+
const { orgName, baseUrl } = this.config;
|
|
5009
5431
|
// Check if we're in OAuth flow
|
|
5010
5432
|
if (!hasOAuthConfig(this.config)) {
|
|
5011
5433
|
throw new Error('refreshAccessToken is only available in OAuth flow');
|
|
@@ -5015,13 +5437,12 @@ class TokenManager {
|
|
|
5015
5437
|
if (!tokenInfo?.refreshToken) {
|
|
5016
5438
|
throw new Error('No refresh token available. User may need to re-authenticate.');
|
|
5017
5439
|
}
|
|
5018
|
-
const orgName = this.config.orgName;
|
|
5019
5440
|
const body = new URLSearchParams({
|
|
5020
5441
|
grant_type: 'refresh_token',
|
|
5021
5442
|
client_id: this.config.clientId,
|
|
5022
5443
|
refresh_token: tokenInfo.refreshToken
|
|
5023
5444
|
});
|
|
5024
|
-
const response = await fetch(`${
|
|
5445
|
+
const response = await fetch(`${baseUrl}/${orgName}/identity_/connect/token`, {
|
|
5025
5446
|
method: 'POST',
|
|
5026
5447
|
headers: {
|
|
5027
5448
|
'Content-Type': 'application/x-www-form-urlencoded'
|
|
@@ -5481,51 +5902,6 @@ function normalizeBaseUrl(url) {
|
|
|
5481
5902
|
return url.endsWith('/') ? url.slice(0, -1) : url;
|
|
5482
5903
|
}
|
|
5483
5904
|
|
|
5484
|
-
/**
|
|
5485
|
-
* SDK Telemetry constants.
|
|
5486
|
-
*
|
|
5487
|
-
* Only the SDK's identity (version, service name, role name, …) lives
|
|
5488
|
-
* here. The Application Insights connection string is injected into
|
|
5489
|
-
* `@uipath/core-telemetry` itself at publish time, and the generic attribute
|
|
5490
|
-
* keys (`Version`, `Service`, `CloudOrganizationName`, …) are owned by
|
|
5491
|
-
* `@uipath/core-telemetry` and consumed there — they are not part of the
|
|
5492
|
-
* SDK's public API.
|
|
5493
|
-
*/
|
|
5494
|
-
/** SDK version placeholder — patched by the SDK publish workflow. */
|
|
5495
|
-
const SDK_VERSION = '1.3.11';
|
|
5496
|
-
const CLOUD_ROLE_NAME = 'uipath-ts-sdk';
|
|
5497
|
-
const SDK_SERVICE_NAME = 'UiPath.TypeScript.Sdk';
|
|
5498
|
-
const SDK_LOGGER_NAME = 'uipath-ts-sdk-telemetry';
|
|
5499
|
-
const SDK_RUN_EVENT = 'Sdk.Run';
|
|
5500
|
-
|
|
5501
|
-
/**
|
|
5502
|
-
* UiPath TypeScript SDK Telemetry
|
|
5503
|
-
*
|
|
5504
|
-
* Constructs the SDK's own `TelemetryClient` and binds the SDK-local
|
|
5505
|
-
* `track` / `trackEvent` to it. Each consumer of `@uipath/core-telemetry`
|
|
5506
|
-
* does this independently, so events carry their own consumer's identity
|
|
5507
|
-
* and tenant context.
|
|
5508
|
-
*/
|
|
5509
|
-
// Keyed by `CLOUD_ROLE_NAME` so every SDK subpath bundle resolves to the
|
|
5510
|
-
// same `TelemetryClient` instance at runtime. A single `initialize(...)`
|
|
5511
|
-
// from the `UiPath` constructor therefore wires up `@track` decorators
|
|
5512
|
-
// across every subpath bundle (`assets`, `feedback`, `tasks`, …).
|
|
5513
|
-
const sdkClient = getOrCreateClient(CLOUD_ROLE_NAME);
|
|
5514
|
-
const track = createTrack(sdkClient);
|
|
5515
|
-
const trackEvent = createTrackEvent(sdkClient);
|
|
5516
|
-
const telemetryClient = {
|
|
5517
|
-
initialize(context) {
|
|
5518
|
-
sdkClient.initialize({
|
|
5519
|
-
sdkVersion: SDK_VERSION,
|
|
5520
|
-
serviceName: SDK_SERVICE_NAME,
|
|
5521
|
-
cloudRoleName: CLOUD_ROLE_NAME,
|
|
5522
|
-
loggerName: SDK_LOGGER_NAME,
|
|
5523
|
-
defaultEventName: SDK_RUN_EVENT,
|
|
5524
|
-
context,
|
|
5525
|
-
});
|
|
5526
|
-
},
|
|
5527
|
-
};
|
|
5528
|
-
|
|
5529
5905
|
/**
|
|
5530
5906
|
* SDK Internals Registry - Internal registry for SDK instances
|
|
5531
5907
|
*
|
|
@@ -5635,7 +6011,7 @@ function loadFromMetaTags() {
|
|
|
5635
6011
|
return hasAnyValue ? config : null;
|
|
5636
6012
|
}
|
|
5637
6013
|
|
|
5638
|
-
var _UiPath_instances, _UiPath_config, _UiPath_authService, _UiPath_initialized, _UiPath_partialConfig, _UiPath_multiLogin, _UiPath_metaFolderKey, _UiPath_initializeWithConfig, _UiPath_loadConfig;
|
|
6014
|
+
var _UiPath_instances, _UiPath_config, _UiPath_authService, _UiPath_initialized, _UiPath_partialConfig, _UiPath_multiLogin, _UiPath_metaFolderKey, _UiPath_metaOrgId, _UiPath_metaTenantId, _UiPath_initializeWithConfig, _UiPath_loadConfig;
|
|
5639
6015
|
/**
|
|
5640
6016
|
* UiPath - Core SDK class for authentication and configuration management.
|
|
5641
6017
|
*
|
|
@@ -5680,9 +6056,18 @@ let UiPath$1 = class UiPath {
|
|
|
5680
6056
|
// deployments). Not accepted via the public constructor; lives here so the
|
|
5681
6057
|
// SDK can flow it through to BaseService.config without polluting BaseConfig.
|
|
5682
6058
|
_UiPath_metaFolderKey.set(this, void 0);
|
|
6059
|
+
// Org/tenant ids captured from the meta tags before the constructor config
|
|
6060
|
+
// is merged in. The `uipath:org-name`/`uipath:tenant-name` meta tags always
|
|
6061
|
+
// carry org/tenant *ids* in coded-app deployments, whereas a
|
|
6062
|
+
// constructor-supplied `orgName`/`tenantName` may be actual names — so the
|
|
6063
|
+
// telemetry ids must be read from the meta tags.
|
|
6064
|
+
_UiPath_metaOrgId.set(this, void 0);
|
|
6065
|
+
_UiPath_metaTenantId.set(this, void 0);
|
|
5683
6066
|
// Load configuration from meta tags
|
|
5684
6067
|
const configFromMetaTags = loadFromMetaTags();
|
|
5685
6068
|
__classPrivateFieldSet(this, _UiPath_metaFolderKey, configFromMetaTags?.folderKey, "f");
|
|
6069
|
+
__classPrivateFieldSet(this, _UiPath_metaOrgId, configFromMetaTags?.orgName, "f");
|
|
6070
|
+
__classPrivateFieldSet(this, _UiPath_metaTenantId, configFromMetaTags?.tenantName, "f");
|
|
5686
6071
|
// Merge configuration: constructor config overrides meta tags
|
|
5687
6072
|
const mergedConfig = config ? { ...configFromMetaTags, ...config } : configFromMetaTags;
|
|
5688
6073
|
if (mergedConfig && isCompleteConfig(mergedConfig)) {
|
|
@@ -5789,6 +6174,13 @@ let UiPath$1 = class UiPath {
|
|
|
5789
6174
|
getToken() {
|
|
5790
6175
|
return __classPrivateFieldGet(this, _UiPath_authService, "f")?.getToken();
|
|
5791
6176
|
}
|
|
6177
|
+
/**
|
|
6178
|
+
* Releases resources held by this SDK instance.
|
|
6179
|
+
* Cancels any in-flight token-refresh request. Call this when the coded app is unmounted.
|
|
6180
|
+
*/
|
|
6181
|
+
destroy() {
|
|
6182
|
+
__classPrivateFieldGet(this, _UiPath_authService, "f")?.getTokenManager()?.destroy();
|
|
6183
|
+
}
|
|
5792
6184
|
/**
|
|
5793
6185
|
* Logout from the SDK, clearing all authentication state.
|
|
5794
6186
|
* After calling this method, the user will need to re-initialize to authenticate again.
|
|
@@ -5811,7 +6203,7 @@ let UiPath$1 = class UiPath {
|
|
|
5811
6203
|
__classPrivateFieldGet(this, _UiPath_authService, "f")?.updateToken(tokenInfo);
|
|
5812
6204
|
}
|
|
5813
6205
|
};
|
|
5814
|
-
_UiPath_config = new WeakMap(), _UiPath_authService = new WeakMap(), _UiPath_initialized = new WeakMap(), _UiPath_partialConfig = new WeakMap(), _UiPath_multiLogin = new WeakMap(), _UiPath_metaFolderKey = new WeakMap(), _UiPath_instances = new WeakSet(), _UiPath_initializeWithConfig = function _UiPath_initializeWithConfig(config) {
|
|
6206
|
+
_UiPath_config = new WeakMap(), _UiPath_authService = new WeakMap(), _UiPath_initialized = new WeakMap(), _UiPath_partialConfig = new WeakMap(), _UiPath_multiLogin = new WeakMap(), _UiPath_metaFolderKey = new WeakMap(), _UiPath_metaOrgId = new WeakMap(), _UiPath_metaTenantId = new WeakMap(), _UiPath_instances = new WeakSet(), _UiPath_initializeWithConfig = function _UiPath_initializeWithConfig(config) {
|
|
5815
6207
|
// Validate and normalize the configuration
|
|
5816
6208
|
validateConfig(config);
|
|
5817
6209
|
const hasSecretAuth = hasSecretConfig(config);
|
|
@@ -5847,9 +6239,11 @@ _UiPath_config = new WeakMap(), _UiPath_authService = new WeakMap(), _UiPath_ini
|
|
|
5847
6239
|
orgName: internalConfig.orgName,
|
|
5848
6240
|
tenantName: internalConfig.tenantName
|
|
5849
6241
|
};
|
|
5850
|
-
// Initialize telemetry with SDK configuration
|
|
6242
|
+
// Initialize telemetry with SDK configuration.
|
|
5851
6243
|
telemetryClient.initialize({
|
|
5852
6244
|
baseUrl: config.baseUrl,
|
|
6245
|
+
orgId: __classPrivateFieldGet(this, _UiPath_metaOrgId, "f"),
|
|
6246
|
+
tenantId: __classPrivateFieldGet(this, _UiPath_metaTenantId, "f"),
|
|
5853
6247
|
orgName: config.orgName,
|
|
5854
6248
|
tenantName: config.tenantName,
|
|
5855
6249
|
clientId: hasOAuthAuth ? config.clientId : undefined,
|
|
@@ -5857,10 +6251,12 @@ _UiPath_config = new WeakMap(), _UiPath_authService = new WeakMap(), _UiPath_ini
|
|
|
5857
6251
|
});
|
|
5858
6252
|
// Track SDK initialization
|
|
5859
6253
|
trackEvent('Sdk.Auth');
|
|
5860
|
-
/** Auto-initialize for secret-based auth
|
|
5861
|
-
* When viewed in Action Center
|
|
6254
|
+
/** Auto-initialize for secret-based auth, Action Center, and generic host-embedded apps.
|
|
6255
|
+
* When viewed in Action Center or embedded in a UiPath host frame via the UIP protocol,
|
|
6256
|
+
* initialize tokenInfo with an empty token so getValidToken() can bootstrap via postMessage.
|
|
6257
|
+
* When an sdk call is made, the host passes the token to the sdk.
|
|
5862
6258
|
*/
|
|
5863
|
-
if (hasSecretAuth || isInActionCenter) {
|
|
6259
|
+
if (hasSecretAuth || isInActionCenter || trustedEmbeddingOrigin) {
|
|
5864
6260
|
__classPrivateFieldGet(this, _UiPath_authService, "f").authenticateWithSecret(config.secret ?? '');
|
|
5865
6261
|
__classPrivateFieldSet(this, _UiPath_initialized, true, "f");
|
|
5866
6262
|
}
|
|
@@ -5868,6 +6264,8 @@ _UiPath_config = new WeakMap(), _UiPath_authService = new WeakMap(), _UiPath_ini
|
|
|
5868
6264
|
// Load from meta tags
|
|
5869
6265
|
const metaConfig = loadFromMetaTags();
|
|
5870
6266
|
__classPrivateFieldSet(this, _UiPath_metaFolderKey, metaConfig?.folderKey, "f");
|
|
6267
|
+
__classPrivateFieldSet(this, _UiPath_metaOrgId, metaConfig?.orgName, "f");
|
|
6268
|
+
__classPrivateFieldSet(this, _UiPath_metaTenantId, metaConfig?.tenantName, "f");
|
|
5871
6269
|
// Merge with any partial config from constructor (constructor overrides meta tags)
|
|
5872
6270
|
const merged = { ...metaConfig, ...__classPrivateFieldGet(this, _UiPath_partialConfig, "f") };
|
|
5873
6271
|
if (!isCompleteConfig(merged)) {
|
|
@@ -6337,54 +6735,6 @@ function processODataArrayResponse(oDataResponse, successData) {
|
|
|
6337
6735
|
};
|
|
6338
6736
|
}
|
|
6339
6737
|
|
|
6340
|
-
/**
|
|
6341
|
-
* Base64 encoding/decoding
|
|
6342
|
-
*/
|
|
6343
|
-
/**
|
|
6344
|
-
* Encodes a string to base64
|
|
6345
|
-
* @param str - The string to encode
|
|
6346
|
-
* @returns Base64 encoded string
|
|
6347
|
-
*/
|
|
6348
|
-
function encodeBase64(str) {
|
|
6349
|
-
// TextEncoder for UTF-8 encoding (works in both browser and Node.js)
|
|
6350
|
-
const encoder = new TextEncoder();
|
|
6351
|
-
const data = encoder.encode(str);
|
|
6352
|
-
// Convert Uint8Array to base64
|
|
6353
|
-
if (isBrowser) {
|
|
6354
|
-
// Browser environment
|
|
6355
|
-
// Convert Uint8Array to binary string then to base64
|
|
6356
|
-
const binaryString = Array.from(data, byte => String.fromCharCode(byte)).join('');
|
|
6357
|
-
return btoa(binaryString);
|
|
6358
|
-
}
|
|
6359
|
-
else {
|
|
6360
|
-
// Node.js environment
|
|
6361
|
-
return Buffer.from(data).toString('base64');
|
|
6362
|
-
}
|
|
6363
|
-
}
|
|
6364
|
-
/**
|
|
6365
|
-
* Decodes a base64 string
|
|
6366
|
-
* @param base64 - The base64 string to decode
|
|
6367
|
-
* @returns Decoded string
|
|
6368
|
-
*/
|
|
6369
|
-
function decodeBase64(base64) {
|
|
6370
|
-
let bytes;
|
|
6371
|
-
if (isBrowser) {
|
|
6372
|
-
// Browser environment
|
|
6373
|
-
const binaryString = atob(base64);
|
|
6374
|
-
bytes = new Uint8Array(binaryString.length);
|
|
6375
|
-
for (let i = 0; i < binaryString.length; i++) {
|
|
6376
|
-
bytes[i] = binaryString.charCodeAt(i);
|
|
6377
|
-
}
|
|
6378
|
-
}
|
|
6379
|
-
else {
|
|
6380
|
-
// Node.js environment
|
|
6381
|
-
bytes = new Uint8Array(Buffer.from(base64, 'base64'));
|
|
6382
|
-
}
|
|
6383
|
-
// TextDecoder for UTF-8 decoding (works in both browser and Node.js)
|
|
6384
|
-
const decoder = new TextDecoder();
|
|
6385
|
-
return decoder.decode(bytes);
|
|
6386
|
-
}
|
|
6387
|
-
|
|
6388
6738
|
/**
|
|
6389
6739
|
* PaginationManager handles the conversion between uniform cursor-based pagination
|
|
6390
6740
|
* and the specific pagination type for each service
|
|
@@ -7132,12 +7482,18 @@ class PaginationHelpers {
|
|
|
7132
7482
|
* @returns Promise resolving to a paginated result
|
|
7133
7483
|
*/
|
|
7134
7484
|
static async getAllPaginated(params) {
|
|
7135
|
-
const { serviceAccess, getEndpoint, folderId, headers: providedHeaders, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
|
|
7485
|
+
const { serviceAccess, getEndpoint, folderId, headers: providedHeaders, paginationParams, additionalParams, queryParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
|
|
7136
7486
|
const endpoint = getEndpoint(folderId);
|
|
7137
7487
|
const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
|
|
7488
|
+
// On POST, the caller's options go in the body; queryParams stays in the URL.
|
|
7489
|
+
// On GET, everything is URL — queryParams merges with additionalParams.
|
|
7490
|
+
const isPost = method === HTTP_METHODS.POST;
|
|
7491
|
+
const requestSpec = isPost
|
|
7492
|
+
? { body: additionalParams, params: queryParams }
|
|
7493
|
+
: { params: { ...additionalParams, ...queryParams } };
|
|
7138
7494
|
const paginatedResponse = await serviceAccess.requestWithPagination(method, endpoint, paginationParams, {
|
|
7139
7495
|
headers,
|
|
7140
|
-
|
|
7496
|
+
...requestSpec,
|
|
7141
7497
|
pagination: {
|
|
7142
7498
|
paginationType: options.paginationType || PaginationType.OFFSET,
|
|
7143
7499
|
itemsField: options.itemsField || DEFAULT_ITEMS_FIELD,
|
|
@@ -7162,7 +7518,7 @@ class PaginationHelpers {
|
|
|
7162
7518
|
* @returns Promise resolving to an object with data and totalCount
|
|
7163
7519
|
*/
|
|
7164
7520
|
static async getAllNonPaginated(params) {
|
|
7165
|
-
const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, headers: providedHeaders, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
|
|
7521
|
+
const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, headers: providedHeaders, additionalParams, queryParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
|
|
7166
7522
|
// Set default field names
|
|
7167
7523
|
const itemsField = options.itemsField || DEFAULT_ITEMS_FIELD;
|
|
7168
7524
|
const totalCountField = options.totalCountField || DEFAULT_TOTAL_COUNT_FIELD;
|
|
@@ -7172,17 +7528,18 @@ class PaginationHelpers {
|
|
|
7172
7528
|
// Make the API call based on method
|
|
7173
7529
|
let response;
|
|
7174
7530
|
if (method === HTTP_METHODS.POST) {
|
|
7175
|
-
response = await serviceAccess.post(endpoint, additionalParams, { headers });
|
|
7531
|
+
response = await serviceAccess.post(endpoint, additionalParams, { headers, params: queryParams });
|
|
7176
7532
|
}
|
|
7177
7533
|
else {
|
|
7178
7534
|
response = await serviceAccess.get(endpoint, {
|
|
7179
|
-
params: additionalParams,
|
|
7535
|
+
params: { ...additionalParams, ...queryParams },
|
|
7180
7536
|
headers
|
|
7181
7537
|
});
|
|
7182
7538
|
}
|
|
7183
7539
|
// Extract and transform items from response
|
|
7184
|
-
// Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
|
|
7185
|
-
|
|
7540
|
+
// Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N }).
|
|
7541
|
+
// itemsField may be a dotted path (e.g. 'data.agents') for nested envelopes.
|
|
7542
|
+
const rawItems = Array.isArray(response.data) ? response.data : resolveNestedField(response.data, itemsField);
|
|
7186
7543
|
const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
|
|
7187
7544
|
const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
|
|
7188
7545
|
// Parse items - automatically handle JSON string responses
|
|
@@ -7228,8 +7585,9 @@ class PaginationHelpers {
|
|
|
7228
7585
|
getEndpoint: config.getEndpoint,
|
|
7229
7586
|
folderId,
|
|
7230
7587
|
headers: config.headers,
|
|
7231
|
-
paginationParams: cursor ? { cursor, pageSize } : jumpToPage ? { jumpToPage, pageSize } : { pageSize },
|
|
7588
|
+
paginationParams: cursor ? { cursor, pageSize } : jumpToPage !== undefined ? { jumpToPage, pageSize } : { pageSize },
|
|
7232
7589
|
additionalParams: prefixedOptions,
|
|
7590
|
+
queryParams: config.queryParams,
|
|
7233
7591
|
transformFn: config.transformFn,
|
|
7234
7592
|
method: config.method,
|
|
7235
7593
|
options: {
|
|
@@ -7247,6 +7605,7 @@ class PaginationHelpers {
|
|
|
7247
7605
|
folderId,
|
|
7248
7606
|
headers: config.headers,
|
|
7249
7607
|
additionalParams: prefixedOptions,
|
|
7608
|
+
queryParams: config.queryParams,
|
|
7250
7609
|
transformFn: config.transformFn,
|
|
7251
7610
|
method: config.method,
|
|
7252
7611
|
options: {
|
|
@@ -7383,18 +7742,17 @@ class BaseService {
|
|
|
7383
7742
|
const params = this.validateAndPreparePaginationParams(paginationType, paginationOptions);
|
|
7384
7743
|
// Prepare request parameters based on pagination type
|
|
7385
7744
|
const requestParams = this.preparePaginationRequestParams(paginationType, params, options.pagination);
|
|
7386
|
-
//
|
|
7745
|
+
// Route pagination state to wherever the API expects it (body for POST, URL for GET).
|
|
7746
|
+
// Caller-supplied options.body / options.params are respected as-is — the api-client
|
|
7747
|
+
// already handles params (URL) and body (request body) independently for every method.
|
|
7387
7748
|
if (method.toUpperCase() === 'POST') {
|
|
7388
7749
|
const existingBody = (options.body && typeof options.body === 'object') ? options.body : {};
|
|
7389
7750
|
options.body = {
|
|
7390
7751
|
...existingBody,
|
|
7391
|
-
...options.params,
|
|
7392
7752
|
...requestParams
|
|
7393
7753
|
};
|
|
7394
|
-
options.params = undefined;
|
|
7395
7754
|
}
|
|
7396
7755
|
else {
|
|
7397
|
-
// Merge pagination parameters with existing parameters
|
|
7398
7756
|
options.params = {
|
|
7399
7757
|
...options.params,
|
|
7400
7758
|
...requestParams
|
|
@@ -7431,6 +7789,8 @@ class BaseService {
|
|
|
7431
7789
|
// When true (default), converts pageNumber to a skip/offset value (e.g., page 3 with pageSize 10 → skip 20).
|
|
7432
7790
|
// When false, passes pageNumber directly as the offset param — used by APIs that accept a page number instead of a record offset.
|
|
7433
7791
|
const convertToSkip = paginationParams?.convertToSkip ?? true;
|
|
7792
|
+
// When true, sends pageNumber - 1 (for 0-based APIs). Default false (1-based).
|
|
7793
|
+
const zeroBased = paginationParams?.zeroBased ?? false;
|
|
7434
7794
|
requestParams[pageSizeParam] = limitedPageSize;
|
|
7435
7795
|
if (convertToSkip) {
|
|
7436
7796
|
if (params.pageNumber && params.pageNumber > 1) {
|
|
@@ -7438,7 +7798,8 @@ class BaseService {
|
|
|
7438
7798
|
}
|
|
7439
7799
|
}
|
|
7440
7800
|
else {
|
|
7441
|
-
|
|
7801
|
+
const sdkPageNumber = params.pageNumber || 1;
|
|
7802
|
+
requestParams[offsetParam] = zeroBased ? sdkPageNumber - 1 : sdkPageNumber;
|
|
7442
7803
|
}
|
|
7443
7804
|
{
|
|
7444
7805
|
requestParams[countParam] = true;
|
|
@@ -7467,8 +7828,9 @@ class BaseService {
|
|
|
7467
7828
|
const totalCountField = fields.totalCountField || 'totalRecordCount';
|
|
7468
7829
|
const continuationTokenField = fields.continuationTokenField || 'continuationToken';
|
|
7469
7830
|
// Extract items and metadata
|
|
7470
|
-
// Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
|
|
7471
|
-
|
|
7831
|
+
// Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N }).
|
|
7832
|
+
// itemsField may be a dotted path (e.g. 'data.agents') for nested envelopes.
|
|
7833
|
+
const items = Array.isArray(response.data) ? response.data : (resolveNestedField(response.data, itemsField) || []);
|
|
7472
7834
|
const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
|
|
7473
7835
|
const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
|
|
7474
7836
|
const continuationToken = response.data[continuationTokenField];
|
|
@@ -7551,12 +7913,12 @@ function createEntityMethods(entityData, service) {
|
|
|
7551
7913
|
throw new Error('Entity ID is undefined');
|
|
7552
7914
|
return service.deleteRecordsById(entityData.id, recordIds, options);
|
|
7553
7915
|
},
|
|
7554
|
-
async deleteRecord(recordId) {
|
|
7916
|
+
async deleteRecord(recordId, options) {
|
|
7555
7917
|
if (!entityData.id)
|
|
7556
7918
|
throw new Error('Entity ID is undefined');
|
|
7557
7919
|
if (!recordId)
|
|
7558
7920
|
throw new Error('Record ID is undefined');
|
|
7559
|
-
return service.deleteRecordById(entityData.id, recordId);
|
|
7921
|
+
return service.deleteRecordById(entityData.id, recordId, options);
|
|
7560
7922
|
},
|
|
7561
7923
|
async getAllRecords(options) {
|
|
7562
7924
|
if (!entityData.id)
|
|
@@ -7570,30 +7932,30 @@ function createEntityMethods(entityData, service) {
|
|
|
7570
7932
|
throw new Error('Record ID is undefined');
|
|
7571
7933
|
return service.getRecordById(entityData.id, recordId, options);
|
|
7572
7934
|
},
|
|
7573
|
-
async downloadAttachment(recordId, fieldName) {
|
|
7935
|
+
async downloadAttachment(recordId, fieldName, options) {
|
|
7574
7936
|
if (!entityData.id)
|
|
7575
7937
|
throw new Error('Entity ID is undefined');
|
|
7576
|
-
return service.downloadAttachment(entityData.id, recordId, fieldName);
|
|
7938
|
+
return service.downloadAttachment(entityData.id, recordId, fieldName, options);
|
|
7577
7939
|
},
|
|
7578
7940
|
async uploadAttachment(recordId, fieldName, file, options) {
|
|
7579
7941
|
if (!entityData.id)
|
|
7580
7942
|
throw new Error('Entity ID is undefined');
|
|
7581
7943
|
return service.uploadAttachment(entityData.id, recordId, fieldName, file, options);
|
|
7582
7944
|
},
|
|
7583
|
-
async deleteAttachment(recordId, fieldName) {
|
|
7945
|
+
async deleteAttachment(recordId, fieldName, options) {
|
|
7584
7946
|
if (!entityData.id)
|
|
7585
7947
|
throw new Error('Entity ID is undefined');
|
|
7586
|
-
return service.deleteAttachment(entityData.id, recordId, fieldName);
|
|
7948
|
+
return service.deleteAttachment(entityData.id, recordId, fieldName, options);
|
|
7587
7949
|
},
|
|
7588
7950
|
async queryRecords(options) {
|
|
7589
7951
|
if (!entityData.id)
|
|
7590
7952
|
throw new Error('Entity ID is undefined');
|
|
7591
7953
|
return service.queryRecordsById(entityData.id, options);
|
|
7592
7954
|
},
|
|
7593
|
-
async importRecords(file) {
|
|
7955
|
+
async importRecords(file, options) {
|
|
7594
7956
|
if (!entityData.id)
|
|
7595
7957
|
throw new Error('Entity ID is undefined');
|
|
7596
|
-
return service.importRecordsById(entityData.id, file);
|
|
7958
|
+
return service.importRecordsById(entityData.id, file, options);
|
|
7597
7959
|
},
|
|
7598
7960
|
async insert(data, options) {
|
|
7599
7961
|
return this.insertRecord(data, options);
|
|
@@ -7604,10 +7966,10 @@ function createEntityMethods(entityData, service) {
|
|
|
7604
7966
|
async getRecords(options) {
|
|
7605
7967
|
return this.getAllRecords(options);
|
|
7606
7968
|
},
|
|
7607
|
-
async delete() {
|
|
7969
|
+
async delete(options) {
|
|
7608
7970
|
if (!entityData.id)
|
|
7609
7971
|
throw new Error('Entity ID is undefined');
|
|
7610
|
-
return service.deleteById(entityData.id);
|
|
7972
|
+
return service.deleteById(entityData.id, options);
|
|
7611
7973
|
},
|
|
7612
7974
|
async update(options) {
|
|
7613
7975
|
if (!entityData.id)
|
|
@@ -7804,6 +8166,14 @@ var SqlFieldType;
|
|
|
7804
8166
|
SqlFieldType["MULTILINE"] = "MULTILINE";
|
|
7805
8167
|
})(SqlFieldType || (SqlFieldType = {}));
|
|
7806
8168
|
|
|
8169
|
+
/**
|
|
8170
|
+
* Numeric type IDs that pair with {@link EntityType} on reference payloads
|
|
8171
|
+
* (entityType + entityTypeId travel together in `referenceEntity` /
|
|
8172
|
+
* `referenceChoiceSet` bodies on cross-folder schema upserts).
|
|
8173
|
+
*/
|
|
8174
|
+
const ENTITY_TYPE_IDS = {
|
|
8175
|
+
[EntityType.ChoiceSet]: 1,
|
|
8176
|
+
};
|
|
7807
8177
|
/**
|
|
7808
8178
|
* Maps fields for Entities
|
|
7809
8179
|
*/
|
|
@@ -7937,6 +8307,7 @@ class EntityService extends BaseService {
|
|
|
7937
8307
|
* Gets entity metadata by entity ID with attached operation methods
|
|
7938
8308
|
*
|
|
7939
8309
|
* @param id - UUID of the entity
|
|
8310
|
+
* @param options - Optional {@link EntityGetByIdOptions} (e.g. `folderKey` for folder-scoped entities) The `folderKey` property is **experimental**.
|
|
7940
8311
|
* @returns Promise resolving to entity metadata with schema information and operation methods
|
|
7941
8312
|
*
|
|
7942
8313
|
* @example
|
|
@@ -7946,6 +8317,9 @@ class EntityService extends BaseService {
|
|
|
7946
8317
|
* const entities = new Entities(sdk);
|
|
7947
8318
|
* const entity = await entities.getById("<entityId>");
|
|
7948
8319
|
*
|
|
8320
|
+
* // Folder-scoped: pass the entity's folder key
|
|
8321
|
+
* const folderEntity = await entities.getById("<entityId>", { folderKey: "<folderKey>" });
|
|
8322
|
+
*
|
|
7949
8323
|
* // Call operations directly on the entity
|
|
7950
8324
|
* const records = await entity.getAllRecords();
|
|
7951
8325
|
*
|
|
@@ -7959,9 +8333,9 @@ class EntityService extends BaseService {
|
|
|
7959
8333
|
* ]);
|
|
7960
8334
|
* ```
|
|
7961
8335
|
*/
|
|
7962
|
-
async getById(id) {
|
|
8336
|
+
async getById(id, options) {
|
|
7963
8337
|
// Get entity metadata
|
|
7964
|
-
const response = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.GET_BY_ID(id));
|
|
8338
|
+
const response = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.GET_BY_ID(id), { headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }) });
|
|
7965
8339
|
// Apply EntityMap transformations
|
|
7966
8340
|
const metadata = transformData(response.data, EntityMap);
|
|
7967
8341
|
// Transform metadata with field mappers
|
|
@@ -7973,7 +8347,7 @@ class EntityService extends BaseService {
|
|
|
7973
8347
|
* Gets entity records by entity ID
|
|
7974
8348
|
*
|
|
7975
8349
|
* @param entityId - UUID of the entity
|
|
7976
|
-
* @param options - Query options including expansionLevel and pagination options
|
|
8350
|
+
* @param options - Query options including expansionLevel and pagination options The `folderKey` property is **experimental**.
|
|
7977
8351
|
* @returns Promise resolving to an array of entity records or paginated response
|
|
7978
8352
|
*
|
|
7979
8353
|
* @example
|
|
@@ -8001,12 +8375,20 @@ class EntityService extends BaseService {
|
|
|
8001
8375
|
* cursor: paginatedResponse.nextCursor,
|
|
8002
8376
|
* expansionLevel: 1
|
|
8003
8377
|
* });
|
|
8378
|
+
*
|
|
8379
|
+
* // Folder-scoped entity: pass the entity's folder key
|
|
8380
|
+
* const records = await entities.getAllRecords("<entityId>", { folderKey: "<folderKey>" });
|
|
8004
8381
|
* ```
|
|
8005
8382
|
*/
|
|
8006
8383
|
async getAllRecords(entityId, options) {
|
|
8384
|
+
// folderKey is header-only — destructure it out so PaginationHelpers doesn't serialise it
|
|
8385
|
+
// into the query string as $folderKey.
|
|
8386
|
+
const { folderKey, ...rest } = options ?? {};
|
|
8387
|
+
const downstreamOptions = options === undefined ? undefined : rest;
|
|
8007
8388
|
return PaginationHelpers.getAll({
|
|
8008
8389
|
serviceAccess: this.createPaginationServiceAccess(),
|
|
8009
8390
|
getEndpoint: () => DATA_FABRIC_ENDPOINTS.ENTITY.GET_ENTITY_RECORDS(entityId),
|
|
8391
|
+
headers: createHeaders({ [FOLDER_KEY]: folderKey }),
|
|
8010
8392
|
pagination: {
|
|
8011
8393
|
paginationType: PaginationType.OFFSET,
|
|
8012
8394
|
itemsField: ENTITY_PAGINATION.ITEMS_FIELD,
|
|
@@ -8018,14 +8400,14 @@ class EntityService extends BaseService {
|
|
|
8018
8400
|
}
|
|
8019
8401
|
},
|
|
8020
8402
|
excludeFromPrefix: ['expansionLevel'] // Don't add ODATA prefix to expansionLevel
|
|
8021
|
-
},
|
|
8403
|
+
}, downstreamOptions);
|
|
8022
8404
|
}
|
|
8023
8405
|
/**
|
|
8024
8406
|
* Gets a single entity record by entity ID and record ID
|
|
8025
8407
|
*
|
|
8026
8408
|
* @param entityId - UUID of the entity
|
|
8027
8409
|
* @param recordId - UUID of the record
|
|
8028
|
-
* @param options - Query options including expansionLevel
|
|
8410
|
+
* @param options - Query options including `expansionLevel` and `folderKey` The `folderKey` property is **experimental**.
|
|
8029
8411
|
* @returns Promise resolving to the entity record
|
|
8030
8412
|
*
|
|
8031
8413
|
* @example
|
|
@@ -8037,13 +8419,18 @@ class EntityService extends BaseService {
|
|
|
8037
8419
|
* const record = await sdk.entities.getRecordById(<entityId>, <recordId>, {
|
|
8038
8420
|
* expansionLevel: 1
|
|
8039
8421
|
* });
|
|
8422
|
+
*
|
|
8423
|
+
* // Folder-scoped entity: pass the entity's folder key
|
|
8424
|
+
* const record = await sdk.entities.getRecordById(<entityId>, <recordId>, {
|
|
8425
|
+
* folderKey: "<folderKey>"
|
|
8426
|
+
* });
|
|
8040
8427
|
* ```
|
|
8041
8428
|
*/
|
|
8042
8429
|
async getRecordById(entityId, recordId, options = {}) {
|
|
8043
8430
|
const params = createParams({
|
|
8044
8431
|
expansionLevel: options.expansionLevel
|
|
8045
8432
|
});
|
|
8046
|
-
const response = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.GET_RECORD_BY_ID(entityId, recordId), { params });
|
|
8433
|
+
const response = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.GET_RECORD_BY_ID(entityId, recordId), { params, headers: createHeaders({ [FOLDER_KEY]: options.folderKey }) });
|
|
8047
8434
|
return response.data;
|
|
8048
8435
|
}
|
|
8049
8436
|
/**
|
|
@@ -8051,7 +8438,7 @@ class EntityService extends BaseService {
|
|
|
8051
8438
|
*
|
|
8052
8439
|
* @param entityId - UUID of the entity
|
|
8053
8440
|
* @param data - Record to insert
|
|
8054
|
-
* @param options - Insert options
|
|
8441
|
+
* @param options - Insert options The `folderKey` property is **experimental**.
|
|
8055
8442
|
* @returns Promise resolving to the inserted record with generated record ID
|
|
8056
8443
|
*
|
|
8057
8444
|
* @example
|
|
@@ -8067,6 +8454,11 @@ class EntityService extends BaseService {
|
|
|
8067
8454
|
* const result = await entities.insertRecordById("<entityId>", { name: "John", age: 30 }, {
|
|
8068
8455
|
* expansionLevel: 1
|
|
8069
8456
|
* });
|
|
8457
|
+
*
|
|
8458
|
+
* // Folder-scoped entity: pass the entity's folder key
|
|
8459
|
+
* await entities.insertRecordById("<entityId>", { name: "John", age: 30 }, {
|
|
8460
|
+
* folderKey: "<folderKey>"
|
|
8461
|
+
* });
|
|
8070
8462
|
* ```
|
|
8071
8463
|
*/
|
|
8072
8464
|
async insertRecordById(id, data, options = {}) {
|
|
@@ -8075,7 +8467,7 @@ class EntityService extends BaseService {
|
|
|
8075
8467
|
});
|
|
8076
8468
|
const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.INSERT_BY_ID(id), data, {
|
|
8077
8469
|
params,
|
|
8078
|
-
|
|
8470
|
+
headers: createHeaders({ [FOLDER_KEY]: options.folderKey }),
|
|
8079
8471
|
});
|
|
8080
8472
|
return response.data;
|
|
8081
8473
|
}
|
|
@@ -8084,7 +8476,7 @@ class EntityService extends BaseService {
|
|
|
8084
8476
|
*
|
|
8085
8477
|
* @param entityId - UUID of the entity
|
|
8086
8478
|
* @param data - Array of records to insert
|
|
8087
|
-
* @param options - Insert options
|
|
8479
|
+
* @param options - Insert options The `folderKey` property is **experimental**.
|
|
8088
8480
|
* @returns Promise resolving to insert response
|
|
8089
8481
|
*
|
|
8090
8482
|
* @example
|
|
@@ -8107,6 +8499,12 @@ class EntityService extends BaseService {
|
|
|
8107
8499
|
* expansionLevel: 1,
|
|
8108
8500
|
* failOnFirst: true
|
|
8109
8501
|
* });
|
|
8502
|
+
*
|
|
8503
|
+
* // Folder-scoped entity: pass the entity's folder key
|
|
8504
|
+
* await entities.insertRecordsById("<entityId>", [
|
|
8505
|
+
* { name: "John", age: 30 },
|
|
8506
|
+
* { name: "Jane", age: 25 }
|
|
8507
|
+
* ], { folderKey: "<folderKey>" });
|
|
8110
8508
|
* ```
|
|
8111
8509
|
*/
|
|
8112
8510
|
async insertRecordsById(id, data, options = {}) {
|
|
@@ -8116,7 +8514,7 @@ class EntityService extends BaseService {
|
|
|
8116
8514
|
});
|
|
8117
8515
|
const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.BATCH_INSERT_BY_ID(id), data, {
|
|
8118
8516
|
params,
|
|
8119
|
-
|
|
8517
|
+
headers: createHeaders({ [FOLDER_KEY]: options.folderKey }),
|
|
8120
8518
|
});
|
|
8121
8519
|
return response.data;
|
|
8122
8520
|
}
|
|
@@ -8126,7 +8524,7 @@ class EntityService extends BaseService {
|
|
|
8126
8524
|
* @param entityId - UUID of the entity
|
|
8127
8525
|
* @param recordId - UUID of the record to update
|
|
8128
8526
|
* @param data - Key-value pairs of fields to update
|
|
8129
|
-
* @param options - Update options
|
|
8527
|
+
* @param options - Update options The `folderKey` property is **experimental**.
|
|
8130
8528
|
* @returns Promise resolving to the updated record
|
|
8131
8529
|
*
|
|
8132
8530
|
* @example
|
|
@@ -8142,6 +8540,11 @@ class EntityService extends BaseService {
|
|
|
8142
8540
|
* const result = await entities.updateRecordById("<entityId>", "<recordId>", { name: "John Updated", age: 31 }, {
|
|
8143
8541
|
* expansionLevel: 1
|
|
8144
8542
|
* });
|
|
8543
|
+
*
|
|
8544
|
+
* // Folder-scoped entity: pass the entity's folder key
|
|
8545
|
+
* await entities.updateRecordById("<entityId>", "<recordId>", { name: "John Updated" }, {
|
|
8546
|
+
* folderKey: "<folderKey>"
|
|
8547
|
+
* });
|
|
8145
8548
|
* ```
|
|
8146
8549
|
*/
|
|
8147
8550
|
async updateRecordById(entityId, recordId, data, options = {}) {
|
|
@@ -8150,7 +8553,7 @@ class EntityService extends BaseService {
|
|
|
8150
8553
|
});
|
|
8151
8554
|
const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPDATE_RECORD_BY_ID(entityId, recordId), data, {
|
|
8152
8555
|
params,
|
|
8153
|
-
|
|
8556
|
+
headers: createHeaders({ [FOLDER_KEY]: options.folderKey }),
|
|
8154
8557
|
});
|
|
8155
8558
|
return response.data;
|
|
8156
8559
|
}
|
|
@@ -8160,7 +8563,7 @@ class EntityService extends BaseService {
|
|
|
8160
8563
|
* @param entityId - UUID of the entity
|
|
8161
8564
|
* @param data - Array of records to update. Each record MUST contain the record Id,
|
|
8162
8565
|
* otherwise the update will fail.
|
|
8163
|
-
* @param options - Update options
|
|
8566
|
+
* @param options - Update options The `folderKey` property is **experimental**.
|
|
8164
8567
|
* @returns Promise resolving to update response
|
|
8165
8568
|
*
|
|
8166
8569
|
* @example
|
|
@@ -8183,6 +8586,11 @@ class EntityService extends BaseService {
|
|
|
8183
8586
|
* expansionLevel: 1,
|
|
8184
8587
|
* failOnFirst: true
|
|
8185
8588
|
* });
|
|
8589
|
+
*
|
|
8590
|
+
* // Folder-scoped entity: pass the entity's folder key
|
|
8591
|
+
* await entities.updateRecordsById("<entityId>", [
|
|
8592
|
+
* { Id: "123", name: "John Updated" }
|
|
8593
|
+
* ], { folderKey: "<folderKey>" });
|
|
8186
8594
|
* ```
|
|
8187
8595
|
*/
|
|
8188
8596
|
async updateRecordsById(id, data, options = {}) {
|
|
@@ -8192,7 +8600,7 @@ class EntityService extends BaseService {
|
|
|
8192
8600
|
});
|
|
8193
8601
|
const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPDATE_BY_ID(id), data, {
|
|
8194
8602
|
params,
|
|
8195
|
-
|
|
8603
|
+
headers: createHeaders({ [FOLDER_KEY]: options.folderKey }),
|
|
8196
8604
|
});
|
|
8197
8605
|
return response.data;
|
|
8198
8606
|
}
|
|
@@ -8203,7 +8611,7 @@ class EntityService extends BaseService {
|
|
|
8203
8611
|
*
|
|
8204
8612
|
* @param entityId - UUID of the entity
|
|
8205
8613
|
* @param recordIds - Array of record UUIDs to delete
|
|
8206
|
-
* @param options - Delete options
|
|
8614
|
+
* @param options - Delete options The `folderKey` property is **experimental**.
|
|
8207
8615
|
* @returns Promise resolving to delete response
|
|
8208
8616
|
*
|
|
8209
8617
|
* @example
|
|
@@ -8216,6 +8624,11 @@ class EntityService extends BaseService {
|
|
|
8216
8624
|
* const result = await entities.deleteRecordsById("<entityId>", [
|
|
8217
8625
|
* "<recordId-1>", "<recordId-2>"
|
|
8218
8626
|
* ]);
|
|
8627
|
+
*
|
|
8628
|
+
* // Folder-scoped entity: pass the entity's folder key
|
|
8629
|
+
* await entities.deleteRecordsById("<entityId>", [
|
|
8630
|
+
* "<recordId-1>", "<recordId-2>"
|
|
8631
|
+
* ], { folderKey: "<folderKey>" });
|
|
8219
8632
|
* ```
|
|
8220
8633
|
*/
|
|
8221
8634
|
async deleteRecordsById(id, recordIds, options = {}) {
|
|
@@ -8224,7 +8637,7 @@ class EntityService extends BaseService {
|
|
|
8224
8637
|
});
|
|
8225
8638
|
const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.DELETE_BY_ID(id), recordIds, {
|
|
8226
8639
|
params,
|
|
8227
|
-
|
|
8640
|
+
headers: createHeaders({ [FOLDER_KEY]: options.folderKey }),
|
|
8228
8641
|
});
|
|
8229
8642
|
return response.data;
|
|
8230
8643
|
}
|
|
@@ -8236,6 +8649,7 @@ class EntityService extends BaseService {
|
|
|
8236
8649
|
*
|
|
8237
8650
|
* @param entityId - UUID of the entity
|
|
8238
8651
|
* @param recordId - UUID of the record to delete
|
|
8652
|
+
* @param options - Optional {@link EntityDeleteRecordByIdOptions} (e.g. `folderKey` for folder-scoped entities) The `folderKey` property is **experimental**.
|
|
8239
8653
|
* @returns Promise resolving to void on success
|
|
8240
8654
|
* @example
|
|
8241
8655
|
* ```typescript
|
|
@@ -8244,14 +8658,23 @@ class EntityService extends BaseService {
|
|
|
8244
8658
|
* const entities = new Entities(sdk);
|
|
8245
8659
|
*
|
|
8246
8660
|
* await entities.deleteRecordById("<entityId>", "<recordId>");
|
|
8661
|
+
*
|
|
8662
|
+
* // Folder-scoped: pass the entity's folder key
|
|
8663
|
+
* await entities.deleteRecordById("<entityId>", "<recordId>", { folderKey: "<folderKey>" });
|
|
8247
8664
|
* ```
|
|
8248
8665
|
*/
|
|
8249
|
-
async deleteRecordById(entityId, recordId) {
|
|
8250
|
-
await this.delete(DATA_FABRIC_ENDPOINTS.ENTITY.DELETE_RECORD_BY_ID(entityId, recordId));
|
|
8666
|
+
async deleteRecordById(entityId, recordId, options) {
|
|
8667
|
+
await this.delete(DATA_FABRIC_ENDPOINTS.ENTITY.DELETE_RECORD_BY_ID(entityId, recordId), { headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }) });
|
|
8251
8668
|
}
|
|
8252
8669
|
/**
|
|
8253
|
-
* Gets
|
|
8670
|
+
* Gets entities in the tenant.
|
|
8254
8671
|
*
|
|
8672
|
+
* Three call modes:
|
|
8673
|
+
* - `getAll()` — default. Returns only tenant-level entities.
|
|
8674
|
+
* - `getAll({ folderKey: "<uuid>" })` — preferred for folder-scoped data. Returns only entities in that folder.
|
|
8675
|
+
* - `getAll({ includeFolderEntities: true })` — returns tenant-level **and** folder-level entities together. `folderKey` is preferred over `includeFolderEntities` when both are set.
|
|
8676
|
+
*
|
|
8677
|
+
* @param options - Optional {@link EntityGetAllOptions} (`folderKey` to list a single folder's entities — preferred when scoping to a folder; `includeFolderEntities: true` to list tenant + folder entities together) The `folderKey` property is **experimental**.
|
|
8255
8678
|
* @returns Promise resolving to an array of entity metadata
|
|
8256
8679
|
*
|
|
8257
8680
|
* @example
|
|
@@ -8260,15 +8683,29 @@ class EntityService extends BaseService {
|
|
|
8260
8683
|
*
|
|
8261
8684
|
* const entities = new Entities(sdk);
|
|
8262
8685
|
*
|
|
8263
|
-
* //
|
|
8264
|
-
* const
|
|
8686
|
+
* // Tenant-only (default)
|
|
8687
|
+
* const tenantEntities = await entities.getAll();
|
|
8688
|
+
*
|
|
8689
|
+
* // A single folder's entities (preferred when targeting a specific folder)
|
|
8690
|
+
* const folderEntities = await entities.getAll({ folderKey: "<folderKey>" });
|
|
8691
|
+
*
|
|
8692
|
+
* // Tenant + folder entities together
|
|
8693
|
+
* const allEntities = await entities.getAll({ includeFolderEntities: true });
|
|
8265
8694
|
*
|
|
8266
8695
|
* // Call operations on an entity
|
|
8267
|
-
* const records = await
|
|
8696
|
+
* const records = await tenantEntities[0].getAllRecords();
|
|
8268
8697
|
* ```
|
|
8269
8698
|
*/
|
|
8270
|
-
async getAll() {
|
|
8271
|
-
|
|
8699
|
+
async getAll(options) {
|
|
8700
|
+
// folderKey is preferred over includeFolderEntities: when present, scope to that folder
|
|
8701
|
+
// via the v1 endpoint + header. Only when no folderKey is given AND includeFolderEntities
|
|
8702
|
+
// is explicitly true does the SDK switch to the v2 endpoint (returns tenant + folder
|
|
8703
|
+
// entities together). Default (no options or includeFolderEntities omitted) stays on
|
|
8704
|
+
// the v1 endpoint = tenant only.
|
|
8705
|
+
const endpoint = !options?.folderKey && options?.includeFolderEntities
|
|
8706
|
+
? DATA_FABRIC_ENDPOINTS.ENTITY.GET_ALL_V2
|
|
8707
|
+
: DATA_FABRIC_ENDPOINTS.ENTITY.GET_ALL;
|
|
8708
|
+
const response = await this.get(endpoint, { headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }) });
|
|
8272
8709
|
// Apply transformations
|
|
8273
8710
|
const entities = response.data.map(entity => {
|
|
8274
8711
|
// Transform each entity
|
|
@@ -8283,7 +8720,7 @@ class EntityService extends BaseService {
|
|
|
8283
8720
|
* Queries entity records with filters, sorting, aggregates, and pagination
|
|
8284
8721
|
*
|
|
8285
8722
|
* @param id - UUID of the entity
|
|
8286
|
-
* @param options - Query options including filterGroup, selectedFields, sortOptions, aggregates, groupBy, and pagination
|
|
8723
|
+
* @param options - Query options including filterGroup, selectedFields, sortOptions, aggregates, groupBy, and pagination The `folderKey` property is **experimental**.
|
|
8287
8724
|
* @returns Promise resolving to {@link NonPaginatedResponse} without pagination options,
|
|
8288
8725
|
* or {@link PaginatedResponse} when `pageSize`, `cursor`, or `jumpToPage` are provided
|
|
8289
8726
|
*
|
|
@@ -8330,13 +8767,24 @@ class EntityService extends BaseService {
|
|
|
8330
8767
|
* { function: EntityAggregateFunction.Avg, field: "amount", alias: "avgAmount" },
|
|
8331
8768
|
* ],
|
|
8332
8769
|
* });
|
|
8770
|
+
*
|
|
8771
|
+
* // Folder-scoped entity: pass the entity's folder key
|
|
8772
|
+
* await entities.queryRecordsById("<entityId>", {
|
|
8773
|
+
* filterGroup: { queryFilters: [{ fieldName: "status", operator: QueryFilterOperator.Equals, value: "active" }] },
|
|
8774
|
+
* folderKey: "<folderKey>",
|
|
8775
|
+
* });
|
|
8333
8776
|
* ```
|
|
8334
8777
|
*/
|
|
8335
8778
|
async queryRecordsById(id, options) {
|
|
8779
|
+
// folderKey is header-only; expansionLevel must be sent as a query param by PaginationHelpers.
|
|
8780
|
+
const { folderKey, expansionLevel, ...rest } = options ?? {};
|
|
8781
|
+
const downstreamOptions = options === undefined ? undefined : rest;
|
|
8336
8782
|
return PaginationHelpers.getAll({
|
|
8337
8783
|
serviceAccess: this.createPaginationServiceAccess(),
|
|
8338
8784
|
getEndpoint: () => DATA_FABRIC_ENDPOINTS.ENTITY.QUERY_BY_ID(id),
|
|
8339
8785
|
method: HTTP_METHODS.POST,
|
|
8786
|
+
headers: createHeaders({ [FOLDER_KEY]: folderKey }),
|
|
8787
|
+
queryParams: createParams({ expansionLevel }),
|
|
8340
8788
|
pagination: {
|
|
8341
8789
|
paginationType: PaginationType.OFFSET,
|
|
8342
8790
|
itemsField: ENTITY_PAGINATION.ITEMS_FIELD,
|
|
@@ -8347,14 +8795,15 @@ class EntityService extends BaseService {
|
|
|
8347
8795
|
countParam: ENTITY_OFFSET_PARAMS.COUNT_PARAM
|
|
8348
8796
|
}
|
|
8349
8797
|
},
|
|
8350
|
-
excludeFromPrefix: ['
|
|
8351
|
-
},
|
|
8798
|
+
excludeFromPrefix: ['filterGroup', 'selectedFields', 'sortOptions', 'aggregates', 'groupBy']
|
|
8799
|
+
}, downstreamOptions);
|
|
8352
8800
|
}
|
|
8353
8801
|
/**
|
|
8354
8802
|
* Imports records from a CSV file into an entity
|
|
8355
8803
|
*
|
|
8356
8804
|
* @param id - UUID of the entity
|
|
8357
8805
|
* @param file - CSV file to import (Blob, File, or Uint8Array)
|
|
8806
|
+
* @param options - Optional {@link EntityImportRecordsByIdOptions} (e.g. `folderKey` for folder-scoped entities) The `folderKey` property is **experimental**.
|
|
8358
8807
|
* @returns Promise resolving to import result with record counts
|
|
8359
8808
|
*
|
|
8360
8809
|
* @example
|
|
@@ -8375,10 +8824,12 @@ class EntityService extends BaseService {
|
|
|
8375
8824
|
* if (result.errorFileLink) {
|
|
8376
8825
|
* console.log(`Error file link: ${result.errorFileLink}`);
|
|
8377
8826
|
* }
|
|
8827
|
+
*
|
|
8828
|
+
* // Folder-scoped entity: pass the entity's folder key
|
|
8829
|
+
* await entities.importRecordsById("<entityId>", fileInput.files[0], { folderKey: "<folderKey>" });
|
|
8378
8830
|
* ```
|
|
8379
|
-
* @internal
|
|
8380
8831
|
*/
|
|
8381
|
-
async importRecordsById(id, file) {
|
|
8832
|
+
async importRecordsById(id, file, options) {
|
|
8382
8833
|
const formData = new FormData();
|
|
8383
8834
|
if (file instanceof Uint8Array) {
|
|
8384
8835
|
formData.append('file', new Blob([file.buffer]));
|
|
@@ -8386,7 +8837,7 @@ class EntityService extends BaseService {
|
|
|
8386
8837
|
else {
|
|
8387
8838
|
formData.append('file', file);
|
|
8388
8839
|
}
|
|
8389
|
-
const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.BULK_UPLOAD_BY_ID(id), formData);
|
|
8840
|
+
const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.BULK_UPLOAD_BY_ID(id), formData, { headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }) });
|
|
8390
8841
|
return response.data;
|
|
8391
8842
|
}
|
|
8392
8843
|
/**
|
|
@@ -8395,6 +8846,7 @@ class EntityService extends BaseService {
|
|
|
8395
8846
|
* @param entityId - UUID of the entity
|
|
8396
8847
|
* @param recordId - UUID of the record containing the attachment
|
|
8397
8848
|
* @param fieldName - Name of the File-type field containing the attachment
|
|
8849
|
+
* @param options - Optional {@link EntityDownloadAttachmentOptions} (e.g. `folderKey` for folder-scoped entities) The `folderKey` property is **experimental**.
|
|
8398
8850
|
* @returns Promise resolving to Blob containing the file content
|
|
8399
8851
|
*
|
|
8400
8852
|
* @example
|
|
@@ -8413,11 +8865,15 @@ class EntityService extends BaseService {
|
|
|
8413
8865
|
*
|
|
8414
8866
|
* // Download attachment for a specific record and field
|
|
8415
8867
|
* const blob = await entities.downloadAttachment(entityId, recordId, 'Documents');
|
|
8868
|
+
*
|
|
8869
|
+
* // Folder-scoped: pass the entity's folder key
|
|
8870
|
+
* const blob = await entities.downloadAttachment(entityId, recordId, 'Documents', { folderKey: "<folderKey>" });
|
|
8416
8871
|
* ```
|
|
8417
8872
|
*/
|
|
8418
|
-
async downloadAttachment(entityId, recordId, fieldName) {
|
|
8873
|
+
async downloadAttachment(entityId, recordId, fieldName, options) {
|
|
8419
8874
|
const response = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.DOWNLOAD_ATTACHMENT(entityId, recordId, fieldName), {
|
|
8420
|
-
responseType: RESPONSE_TYPES.BLOB
|
|
8875
|
+
responseType: RESPONSE_TYPES.BLOB,
|
|
8876
|
+
headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }),
|
|
8421
8877
|
});
|
|
8422
8878
|
return response.data;
|
|
8423
8879
|
}
|
|
@@ -8428,7 +8884,7 @@ class EntityService extends BaseService {
|
|
|
8428
8884
|
* @param recordId - UUID of the record to upload the attachment to
|
|
8429
8885
|
* @param fieldName - Name of the File-type field
|
|
8430
8886
|
* @param file - File to upload (Blob, File, or Uint8Array)
|
|
8431
|
-
* @param options - Optional {@link EntityUploadAttachmentOptions} (e.g. expansionLevel)
|
|
8887
|
+
* @param options - Optional {@link EntityUploadAttachmentOptions} (e.g. `expansionLevel`, `folderKey` for folder-scoped entities) The `folderKey` property is **experimental**.
|
|
8432
8888
|
* @returns Promise resolving to {@link EntityUploadAttachmentResponse}
|
|
8433
8889
|
*
|
|
8434
8890
|
* @example
|
|
@@ -8447,6 +8903,9 @@ class EntityService extends BaseService {
|
|
|
8447
8903
|
*
|
|
8448
8904
|
* // Upload a file attachment
|
|
8449
8905
|
* const response = await entities.uploadAttachment(entityId, recordId, 'Documents', file);
|
|
8906
|
+
*
|
|
8907
|
+
* // Folder-scoped entity: pass the entity's folder key
|
|
8908
|
+
* await entities.uploadAttachment(entityId, recordId, 'Documents', file, { folderKey: "<folderKey>" });
|
|
8450
8909
|
* ```
|
|
8451
8910
|
*/
|
|
8452
8911
|
async uploadAttachment(entityId, recordId, fieldName, file, options) {
|
|
@@ -8458,7 +8917,10 @@ class EntityService extends BaseService {
|
|
|
8458
8917
|
formData.append('file', file);
|
|
8459
8918
|
}
|
|
8460
8919
|
const params = createParams({ expansionLevel: options?.expansionLevel });
|
|
8461
|
-
const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPLOAD_ATTACHMENT(entityId, recordId, fieldName), formData, {
|
|
8920
|
+
const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPLOAD_ATTACHMENT(entityId, recordId, fieldName), formData, {
|
|
8921
|
+
params,
|
|
8922
|
+
headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }),
|
|
8923
|
+
});
|
|
8462
8924
|
return response.data;
|
|
8463
8925
|
}
|
|
8464
8926
|
/**
|
|
@@ -8467,6 +8929,7 @@ class EntityService extends BaseService {
|
|
|
8467
8929
|
* @param entityId - UUID of the entity
|
|
8468
8930
|
* @param recordId - UUID of the record containing the attachment
|
|
8469
8931
|
* @param fieldName - Name of the File-type field containing the attachment
|
|
8932
|
+
* @param options - Optional {@link EntityDeleteAttachmentOptions} (e.g. `folderKey` for folder-scoped entities) The `folderKey` property is **experimental**.
|
|
8470
8933
|
* @returns Promise resolving to {@link EntityDeleteAttachmentResponse}
|
|
8471
8934
|
*
|
|
8472
8935
|
* @example
|
|
@@ -8485,10 +8948,13 @@ class EntityService extends BaseService {
|
|
|
8485
8948
|
*
|
|
8486
8949
|
* // Delete attachment for a specific record and field
|
|
8487
8950
|
* await entities.deleteAttachment(entityId, recordId, 'Documents');
|
|
8951
|
+
*
|
|
8952
|
+
* // Folder-scoped: pass the entity's folder key
|
|
8953
|
+
* await entities.deleteAttachment(entityId, recordId, 'Documents', { folderKey: "<folderKey>" });
|
|
8488
8954
|
* ```
|
|
8489
8955
|
*/
|
|
8490
|
-
async deleteAttachment(entityId, recordId, fieldName) {
|
|
8491
|
-
const response = await this.delete(DATA_FABRIC_ENDPOINTS.ENTITY.DELETE_ATTACHMENT(entityId, recordId, fieldName));
|
|
8956
|
+
async deleteAttachment(entityId, recordId, fieldName, options) {
|
|
8957
|
+
const response = await this.delete(DATA_FABRIC_ENDPOINTS.ENTITY.DELETE_ATTACHMENT(entityId, recordId, fieldName), { headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }) });
|
|
8492
8958
|
return response.data;
|
|
8493
8959
|
}
|
|
8494
8960
|
/**
|
|
@@ -8518,7 +8984,7 @@ class EntityService extends BaseService {
|
|
|
8518
8984
|
* @param name - Entity name — must start with a letter and contain
|
|
8519
8985
|
* only letters, numbers, and underscores (e.g., `"productCatalog"`).
|
|
8520
8986
|
* @param fields - Array of field definitions
|
|
8521
|
-
* @param options - Optional entity-level settings ({@link EntityCreateOptions})
|
|
8987
|
+
* @param options - Optional entity-level settings ({@link EntityCreateOptions}) The `folderKey` property is **experimental**.
|
|
8522
8988
|
* @returns Promise resolving to the ID of the created entity
|
|
8523
8989
|
*
|
|
8524
8990
|
* @example
|
|
@@ -8534,40 +9000,63 @@ class EntityService extends BaseService {
|
|
|
8534
9000
|
* { fieldName: "price", type: EntityFieldDataType.DECIMAL, decimalPrecision: 4, maxValue: 999999, minValue: 0 },
|
|
8535
9001
|
* { fieldName: "quantity", type: EntityFieldDataType.INTEGER, maxValue: 10000, minValue: 1, defaultValue: "0" },
|
|
8536
9002
|
* ]);
|
|
9003
|
+
*
|
|
9004
|
+
* // Cross-folder references — link a folder-scoped entity to entities and
|
|
9005
|
+
* // system choice sets that live in another folder or at the tenant level.
|
|
9006
|
+
* await entities.create("orderLine", [
|
|
9007
|
+
* {
|
|
9008
|
+
* fieldName: "order",
|
|
9009
|
+
* type: EntityFieldDataType.RELATIONSHIP,
|
|
9010
|
+
* referenceEntityId: "<orderEntityId>",
|
|
9011
|
+
* referenceFieldId: "<orderEntityPkId>",
|
|
9012
|
+
* referenceFolderKey: "<otherFolderKey>", // target lives in a different folder
|
|
9013
|
+
* },
|
|
9014
|
+
* {
|
|
9015
|
+
* fieldName: "userType",
|
|
9016
|
+
* type: EntityFieldDataType.CHOICE_SET_SINGLE,
|
|
9017
|
+
* choiceSetId: "<systemUserTypeChoiceSetId>", // tenant-level system choice set
|
|
9018
|
+
* // referenceFolderKey omitted → SDK looks up the target at tenant scope
|
|
9019
|
+
* },
|
|
9020
|
+
* ], { folderKey: "<sourceFolderKey>" });
|
|
8537
9021
|
* ```
|
|
8538
9022
|
* @internal
|
|
8539
9023
|
*/
|
|
8540
9024
|
async create(name, fields, options) {
|
|
8541
9025
|
const opts = options ?? {};
|
|
9026
|
+
const fieldPayloads = await this.buildFieldsWithReferenceMeta(fields);
|
|
8542
9027
|
const payload = {
|
|
8543
9028
|
...(opts.description !== undefined && { description: opts.description }),
|
|
8544
9029
|
displayName: opts.displayName ?? name,
|
|
8545
9030
|
entityDefinition: {
|
|
8546
9031
|
name,
|
|
8547
|
-
fields:
|
|
9032
|
+
fields: fieldPayloads,
|
|
8548
9033
|
folderId: opts.folderKey ?? DATA_FABRIC_TENANT_FOLDER_ID,
|
|
8549
9034
|
isRbacEnabled: opts.isRbacEnabled ?? false,
|
|
8550
9035
|
isInsightsEnabled: opts.isAnalyticsEnabled ?? false,
|
|
8551
9036
|
externalFields: opts.externalFields ?? [],
|
|
8552
9037
|
},
|
|
8553
9038
|
};
|
|
8554
|
-
const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPSERT, payload);
|
|
9039
|
+
const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPSERT, payload, { headers: createHeaders({ [FOLDER_KEY]: opts.folderKey }) });
|
|
8555
9040
|
return response.data;
|
|
8556
9041
|
}
|
|
8557
9042
|
/**
|
|
8558
9043
|
* Deletes a Data Fabric entity and all its records
|
|
8559
9044
|
*
|
|
8560
9045
|
* @param id - UUID of the entity to delete
|
|
9046
|
+
* @param options - Optional {@link EntityDeleteByIdOptions} (e.g. `folderKey` for folder-scoped entities) The `folderKey` property is **experimental**.
|
|
8561
9047
|
* @returns Promise resolving when the entity is deleted
|
|
8562
9048
|
*
|
|
8563
9049
|
* @example
|
|
8564
9050
|
* ```typescript
|
|
8565
9051
|
* await entities.deleteById("<entityId>");
|
|
9052
|
+
*
|
|
9053
|
+
* // Folder-scoped: pass the entity's folder key
|
|
9054
|
+
* await entities.deleteById("<entityId>", { folderKey: "<folderKey>" });
|
|
8566
9055
|
* ```
|
|
8567
9056
|
* @internal
|
|
8568
9057
|
*/
|
|
8569
|
-
async deleteById(id) {
|
|
8570
|
-
await this.delete(DATA_FABRIC_ENDPOINTS.ENTITY.DELETE(id));
|
|
9058
|
+
async deleteById(id, options) {
|
|
9059
|
+
await this.delete(DATA_FABRIC_ENDPOINTS.ENTITY.DELETE(id), { headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }) });
|
|
8571
9060
|
}
|
|
8572
9061
|
/**
|
|
8573
9062
|
* Updates an existing Data Fabric entity — schema and/or metadata.
|
|
@@ -8581,7 +9070,7 @@ class EntityService extends BaseService {
|
|
|
8581
9070
|
* overwrite each other's changes.
|
|
8582
9071
|
*
|
|
8583
9072
|
* @param id - UUID of the entity to update
|
|
8584
|
-
* @param options - Changes to apply ({@link EntityUpdateByIdOptions})
|
|
9073
|
+
* @param options - Changes to apply ({@link EntityUpdateByIdOptions}) The `folderKey` property is **experimental**.
|
|
8585
9074
|
* @returns Promise resolving when the update is complete
|
|
8586
9075
|
*
|
|
8587
9076
|
* @example
|
|
@@ -8614,6 +9103,12 @@ class EntityService extends BaseService {
|
|
|
8614
9103
|
* { id: "<fieldId>", lengthLimit: 1000 },
|
|
8615
9104
|
* ],
|
|
8616
9105
|
* });
|
|
9106
|
+
*
|
|
9107
|
+
* // Folder-scoped entity: add a field to an entity that lives in a non-tenant folder
|
|
9108
|
+
* await entities.updateById("<entityId>", {
|
|
9109
|
+
* folderKey: "<folderKey>",
|
|
9110
|
+
* addFields: [{ fieldName: "notes", type: EntityFieldDataType.MULTILINE_TEXT }],
|
|
9111
|
+
* });
|
|
8617
9112
|
* ```
|
|
8618
9113
|
* @internal
|
|
8619
9114
|
*/
|
|
@@ -8629,7 +9124,7 @@ class EntityService extends BaseService {
|
|
|
8629
9124
|
...(opts.displayName !== undefined && { displayName: opts.displayName }),
|
|
8630
9125
|
...(opts.description !== undefined && { description: opts.description }),
|
|
8631
9126
|
...(opts.isRbacEnabled !== undefined && { isRbacEnabled: opts.isRbacEnabled }),
|
|
8632
|
-
});
|
|
9127
|
+
}, { headers: createHeaders({ [FOLDER_KEY]: opts.folderKey }) });
|
|
8633
9128
|
}
|
|
8634
9129
|
}
|
|
8635
9130
|
/**
|
|
@@ -8640,7 +9135,8 @@ class EntityService extends BaseService {
|
|
|
8640
9135
|
* @private
|
|
8641
9136
|
*/
|
|
8642
9137
|
async applySchemaUpdate(entityId, options) {
|
|
8643
|
-
const
|
|
9138
|
+
const folderHeaders = createHeaders({ [FOLDER_KEY]: options.folderKey });
|
|
9139
|
+
const entityResponse = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.GET_BY_ID(entityId), { headers: folderHeaders });
|
|
8644
9140
|
const raw = entityResponse.data;
|
|
8645
9141
|
// Carry forward existing non-system fields from GET response (skip system/primary-key fields)
|
|
8646
9142
|
let fields = (raw.fields ?? [])
|
|
@@ -8686,10 +9182,9 @@ class EntityService extends BaseService {
|
|
|
8686
9182
|
};
|
|
8687
9183
|
});
|
|
8688
9184
|
}
|
|
8689
|
-
// Build and append new fields
|
|
8690
9185
|
const newFields = [];
|
|
8691
9186
|
if (options.addFields?.length) {
|
|
8692
|
-
newFields.push(...
|
|
9187
|
+
newFields.push(...await this.buildFieldsWithReferenceMeta(options.addFields));
|
|
8693
9188
|
}
|
|
8694
9189
|
await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPSERT, {
|
|
8695
9190
|
displayName: raw.displayName,
|
|
@@ -8703,7 +9198,7 @@ class EntityService extends BaseService {
|
|
|
8703
9198
|
isInsightsEnabled: raw.isInsightsEnabled ?? false,
|
|
8704
9199
|
externalFields: raw.externalFields ?? [],
|
|
8705
9200
|
},
|
|
8706
|
-
});
|
|
9201
|
+
}, { headers: folderHeaders });
|
|
8707
9202
|
}
|
|
8708
9203
|
/**
|
|
8709
9204
|
* Orchestrates all field mapping transformations
|
|
@@ -8787,8 +9282,39 @@ class EntityService extends BaseService {
|
|
|
8787
9282
|
return externalSource;
|
|
8788
9283
|
});
|
|
8789
9284
|
}
|
|
9285
|
+
async buildFieldsWithReferenceMeta(fields) {
|
|
9286
|
+
const metas = await Promise.all(fields.map(f => this.buildReferenceMeta(f)));
|
|
9287
|
+
return fields.map((f, i) => this.buildSchemaFieldPayload(f, metas[i]));
|
|
9288
|
+
}
|
|
9289
|
+
// Choice-set targets resolve server-side by NAME (the API rejects cross-folder
|
|
9290
|
+
// refs with empty target name even when folderId is supplied), so the SDK
|
|
9291
|
+
// fetches the name once for each cross-folder choice-set field. Relationship
|
|
9292
|
+
// targets resolve by folderId — no lookup needed.
|
|
9293
|
+
async buildReferenceMeta(field) {
|
|
9294
|
+
if (field.referenceFolderKey === undefined)
|
|
9295
|
+
return undefined;
|
|
9296
|
+
if (field.referenceEntityId === undefined && field.choiceSetId === undefined)
|
|
9297
|
+
return undefined;
|
|
9298
|
+
const folderId = field.referenceFolderKey;
|
|
9299
|
+
const meta = {};
|
|
9300
|
+
if (field.referenceEntityId !== undefined) {
|
|
9301
|
+
meta.referenceEntity = { id: field.referenceEntityId, folderId };
|
|
9302
|
+
}
|
|
9303
|
+
if (field.choiceSetId !== undefined) {
|
|
9304
|
+
const lookupFolderKey = folderId === DATA_FABRIC_TENANT_FOLDER_ID ? undefined : folderId;
|
|
9305
|
+
const target = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.GET_BY_ID(field.choiceSetId), { headers: createHeaders({ [FOLDER_KEY]: lookupFolderKey }) });
|
|
9306
|
+
meta.referenceChoiceSet = {
|
|
9307
|
+
id: field.choiceSetId,
|
|
9308
|
+
name: target.data.name,
|
|
9309
|
+
folderId,
|
|
9310
|
+
entityType: EntityType.ChoiceSet,
|
|
9311
|
+
entityTypeId: ENTITY_TYPE_IDS[EntityType.ChoiceSet],
|
|
9312
|
+
};
|
|
9313
|
+
}
|
|
9314
|
+
return meta;
|
|
9315
|
+
}
|
|
8790
9316
|
/** Converts a user-facing EntityCreateFieldOptions to the raw API field payload */
|
|
8791
|
-
buildSchemaFieldPayload(field) {
|
|
9317
|
+
buildSchemaFieldPayload(field, refMeta) {
|
|
8792
9318
|
const fieldType = field.type ?? EntityFieldDataType.STRING;
|
|
8793
9319
|
this.validateFieldConstraints(fieldType, field, field.fieldName);
|
|
8794
9320
|
const isRelationship = fieldType === EntityFieldDataType.RELATIONSHIP;
|
|
@@ -8799,6 +9325,10 @@ class EntityService extends BaseService {
|
|
|
8799
9325
|
});
|
|
8800
9326
|
}
|
|
8801
9327
|
const mapping = EntitySchemaFieldTypeMap[fieldType];
|
|
9328
|
+
// Prefer the resolved {id, name, folderId} body so cross-folder targets resolve
|
|
9329
|
+
// server-side; fall back to a bare {id} when no meta was fetched.
|
|
9330
|
+
const referenceEntityBody = refMeta?.referenceEntity ?? (field.referenceEntityId === undefined ? undefined : { id: field.referenceEntityId });
|
|
9331
|
+
const referenceChoiceSetBody = refMeta?.referenceChoiceSet;
|
|
8802
9332
|
return {
|
|
8803
9333
|
name: field.fieldName,
|
|
8804
9334
|
displayName: field.displayName ?? field.fieldName,
|
|
@@ -8817,7 +9347,8 @@ class EntityService extends BaseService {
|
|
|
8817
9347
|
...(field.choiceSetId !== undefined && { choiceSetId: field.choiceSetId }),
|
|
8818
9348
|
...((isRelationship || isFile) && { isForeignKey: true }),
|
|
8819
9349
|
...(isRelationship && { referenceType: ReferenceType.ManyToOne }),
|
|
8820
|
-
...(
|
|
9350
|
+
...(referenceEntityBody !== undefined && { referenceEntity: referenceEntityBody }),
|
|
9351
|
+
...(referenceChoiceSetBody !== undefined && { referenceChoiceSet: referenceChoiceSetBody }),
|
|
8821
9352
|
...(field.referenceFieldId !== undefined && { referenceField: { id: field.referenceFieldId } }),
|
|
8822
9353
|
};
|
|
8823
9354
|
}
|
|
@@ -8980,8 +9511,14 @@ __decorate([
|
|
|
8980
9511
|
|
|
8981
9512
|
class ChoiceSetService extends BaseService {
|
|
8982
9513
|
/**
|
|
8983
|
-
* Gets
|
|
9514
|
+
* Gets choice sets in the tenant.
|
|
8984
9515
|
*
|
|
9516
|
+
* Three call modes:
|
|
9517
|
+
* - `getAll()` — default. Returns only tenant-level choice sets.
|
|
9518
|
+
* - `getAll({ folderKey: "<uuid>" })` — preferred for folder-scoped data. Returns only choice sets in that folder.
|
|
9519
|
+
* - `getAll({ includeFolderChoiceSets: true })` — returns tenant-level **and** folder-level choice sets together. `folderKey` is preferred over `includeFolderChoiceSets` when both are set.
|
|
9520
|
+
*
|
|
9521
|
+
* @param options - Optional {@link ChoiceSetGetAllOptions} (`folderKey` to list a single folder's choice sets — preferred when scoping to a folder; `includeFolderChoiceSets: true` to list tenant + folder choice sets together) The `folderKey` property is **experimental**.
|
|
8985
9522
|
* @returns Promise resolving to an array of choice set metadata
|
|
8986
9523
|
*
|
|
8987
9524
|
* @example
|
|
@@ -8990,18 +9527,33 @@ class ChoiceSetService extends BaseService {
|
|
|
8990
9527
|
*
|
|
8991
9528
|
* const choiceSets = new ChoiceSets(sdk);
|
|
8992
9529
|
*
|
|
8993
|
-
* //
|
|
8994
|
-
* const
|
|
9530
|
+
* // Tenant-only (default)
|
|
9531
|
+
* const tenantChoiceSets = await choiceSets.getAll();
|
|
8995
9532
|
*
|
|
8996
|
-
* //
|
|
8997
|
-
*
|
|
8998
|
-
*
|
|
8999
|
-
*
|
|
9000
|
-
* });
|
|
9533
|
+
* // A single folder's choice sets (preferred when targeting a specific folder)
|
|
9534
|
+
* const folderChoiceSets = await choiceSets.getAll({ folderKey: "<folderKey>" });
|
|
9535
|
+
*
|
|
9536
|
+
* // Tenant + folder choice sets together
|
|
9537
|
+
* const allChoiceSets = await choiceSets.getAll({ includeFolderChoiceSets: true });
|
|
9001
9538
|
* ```
|
|
9002
9539
|
*/
|
|
9003
|
-
async getAll() {
|
|
9004
|
-
|
|
9540
|
+
async getAll(options) {
|
|
9541
|
+
return this.fetchAllChoiceSets(options);
|
|
9542
|
+
}
|
|
9543
|
+
/**
|
|
9544
|
+
* Internal helper that performs the choice-set fetch. Kept separate from the
|
|
9545
|
+
* public `getAll()` so that internal callers (e.g. `resolveChoiceSetName`)
|
|
9546
|
+
* can reuse it without triggering double `@track` telemetry.
|
|
9547
|
+
*/
|
|
9548
|
+
async fetchAllChoiceSets(options) {
|
|
9549
|
+
// The choice-set endpoint returns cross-scope results when called without
|
|
9550
|
+
// a folder header. To stay tenant-only by default, send the tenant-marker
|
|
9551
|
+
// UUID as the folder key unless the caller explicitly opts into cross-scope
|
|
9552
|
+
// via includeFolderChoiceSets: true. folderKey is preferred over
|
|
9553
|
+
// includeFolderChoiceSets when both are set.
|
|
9554
|
+
const folderKey = options?.folderKey
|
|
9555
|
+
?? (options?.includeFolderChoiceSets ? undefined : DATA_FABRIC_TENANT_FOLDER_ID);
|
|
9556
|
+
const rawResponse = await this.get(DATA_FABRIC_ENDPOINTS.CHOICESETS.GET_ALL, { headers: createHeaders({ [FOLDER_KEY]: folderKey }) });
|
|
9005
9557
|
// Transform field names
|
|
9006
9558
|
const data = rawResponse.data || [];
|
|
9007
9559
|
return data.map(choiceSet => transformData(choiceSet, EntityMap));
|
|
@@ -9014,7 +9566,7 @@ class ChoiceSetService extends BaseService {
|
|
|
9014
9566
|
* - A PaginatedResponse with navigation cursors (when any pagination parameter is provided)
|
|
9015
9567
|
*
|
|
9016
9568
|
* @param choiceSetId - UUID of the choice set
|
|
9017
|
-
* @param options - Pagination options
|
|
9569
|
+
* @param options - Pagination options and optional `folderKey` for folder-scoped choice sets The `folderKey` property is **experimental**.
|
|
9018
9570
|
* @returns Promise resolving to choice set values or paginated result
|
|
9019
9571
|
*
|
|
9020
9572
|
* @example
|
|
@@ -9043,6 +9595,9 @@ class ChoiceSetService extends BaseService {
|
|
|
9043
9595
|
* if (page1.hasNextPage) {
|
|
9044
9596
|
* const page2 = await choiceSets.getById(choiceSetId, { cursor: page1.nextCursor });
|
|
9045
9597
|
* }
|
|
9598
|
+
*
|
|
9599
|
+
* // Folder-scoped choice set
|
|
9600
|
+
* const folderValues = await choiceSets.getById(choiceSetId, { folderKey: "<folderKey>" });
|
|
9046
9601
|
* ```
|
|
9047
9602
|
*/
|
|
9048
9603
|
async getById(choiceSetId, options) {
|
|
@@ -9051,11 +9606,16 @@ class ChoiceSetService extends BaseService {
|
|
|
9051
9606
|
const camelCased = pascalToCamelCaseKeys(item);
|
|
9052
9607
|
return transformData(camelCased, EntityMap);
|
|
9053
9608
|
};
|
|
9609
|
+
// folderKey is header-only — destructure it out so PaginationHelpers doesn't
|
|
9610
|
+
// include it in the POST body alongside pagination params.
|
|
9611
|
+
const { folderKey, ...rest } = options ?? {};
|
|
9612
|
+
const downstreamOptions = options === undefined ? undefined : rest;
|
|
9054
9613
|
return PaginationHelpers.getAll({
|
|
9055
9614
|
serviceAccess: this.createPaginationServiceAccess(),
|
|
9056
9615
|
getEndpoint: () => DATA_FABRIC_ENDPOINTS.CHOICESETS.GET_BY_ID(choiceSetId),
|
|
9057
9616
|
transformFn,
|
|
9058
9617
|
method: HTTP_METHODS.POST,
|
|
9618
|
+
headers: createHeaders({ [FOLDER_KEY]: folderKey }),
|
|
9059
9619
|
pagination: {
|
|
9060
9620
|
paginationType: PaginationType.OFFSET,
|
|
9061
9621
|
itemsField: CHOICESET_VALUES_PAGINATION.ITEMS_FIELD,
|
|
@@ -9066,7 +9626,7 @@ class ChoiceSetService extends BaseService {
|
|
|
9066
9626
|
countParam: ENTITY_OFFSET_PARAMS.COUNT_PARAM
|
|
9067
9627
|
}
|
|
9068
9628
|
}
|
|
9069
|
-
},
|
|
9629
|
+
}, downstreamOptions);
|
|
9070
9630
|
}
|
|
9071
9631
|
/**
|
|
9072
9632
|
* Creates a new Data Fabric choice set
|
|
@@ -9074,7 +9634,7 @@ class ChoiceSetService extends BaseService {
|
|
|
9074
9634
|
* @param name - Choice set name. Must start with a
|
|
9075
9635
|
* letter, may contain only letters, numbers, and underscores, length
|
|
9076
9636
|
* 3–100 characters (e.g., `"expenseTypes"`).
|
|
9077
|
-
* @param options - Optional choice-set-level settings ({@link ChoiceSetCreateOptions})
|
|
9637
|
+
* @param options - Optional choice-set-level settings ({@link ChoiceSetCreateOptions}) The `folderKey` property is **experimental**.
|
|
9078
9638
|
* @returns Promise resolving to the UUID of the created choice set
|
|
9079
9639
|
*
|
|
9080
9640
|
* @example
|
|
@@ -9105,7 +9665,7 @@ class ChoiceSetService extends BaseService {
|
|
|
9105
9665
|
folderId: opts.folderKey ?? DATA_FABRIC_TENANT_FOLDER_ID,
|
|
9106
9666
|
},
|
|
9107
9667
|
};
|
|
9108
|
-
const response = await this.post(DATA_FABRIC_ENDPOINTS.CHOICESETS.CREATE, payload);
|
|
9668
|
+
const response = await this.post(DATA_FABRIC_ENDPOINTS.CHOICESETS.CREATE, payload, { headers: createHeaders({ [FOLDER_KEY]: opts.folderKey }) });
|
|
9109
9669
|
return response.data;
|
|
9110
9670
|
}
|
|
9111
9671
|
/**
|
|
@@ -9115,7 +9675,7 @@ class ChoiceSetService extends BaseService {
|
|
|
9115
9675
|
* the call throws `ValidationError` if both are omitted.
|
|
9116
9676
|
*
|
|
9117
9677
|
* @param choiceSetId - UUID of the choice set to update
|
|
9118
|
-
* @param options - Metadata fields to change ({@link ChoiceSetUpdateOptions})
|
|
9678
|
+
* @param options - Metadata fields to change ({@link ChoiceSetUpdateOptions}) The `folderKey` property is **experimental**.
|
|
9119
9679
|
* @returns Promise resolving when the update is complete
|
|
9120
9680
|
*
|
|
9121
9681
|
* @example
|
|
@@ -9140,12 +9700,13 @@ class ChoiceSetService extends BaseService {
|
|
|
9140
9700
|
await this.patch(DATA_FABRIC_ENDPOINTS.CHOICESETS.UPDATE(choiceSetId), {
|
|
9141
9701
|
...(options.displayName !== undefined && { displayName: options.displayName }),
|
|
9142
9702
|
...(options.description !== undefined && { description: options.description }),
|
|
9143
|
-
});
|
|
9703
|
+
}, { headers: createHeaders({ [FOLDER_KEY]: options.folderKey }) });
|
|
9144
9704
|
}
|
|
9145
9705
|
/**
|
|
9146
9706
|
* Deletes a Data Fabric choice set and all its values.
|
|
9147
9707
|
*
|
|
9148
9708
|
* @param choiceSetId - UUID of the choice set to delete
|
|
9709
|
+
* @param options - Optional {@link ChoiceSetDeleteByIdOptions} (e.g. `folderKey` for folder-scoped choice sets) The `folderKey` property is **experimental**.
|
|
9149
9710
|
* @returns Promise resolving when the choice set is deleted
|
|
9150
9711
|
*
|
|
9151
9712
|
* @example
|
|
@@ -9155,18 +9716,21 @@ class ChoiceSetService extends BaseService {
|
|
|
9155
9716
|
* const expenseTypes = allChoiceSets.find(cs => cs.name === 'expense_types');
|
|
9156
9717
|
*
|
|
9157
9718
|
* await choicesets.deleteById(expenseTypes.id);
|
|
9719
|
+
*
|
|
9720
|
+
* // Folder-scoped choice set
|
|
9721
|
+
* await choicesets.deleteById(expenseTypes.id, { folderKey: "<folderKey>" });
|
|
9158
9722
|
* ```
|
|
9159
9723
|
* @internal
|
|
9160
9724
|
*/
|
|
9161
|
-
async deleteById(choiceSetId) {
|
|
9162
|
-
await this.post(DATA_FABRIC_ENDPOINTS.CHOICESETS.DELETE(choiceSetId), {});
|
|
9725
|
+
async deleteById(choiceSetId, options) {
|
|
9726
|
+
await this.post(DATA_FABRIC_ENDPOINTS.CHOICESETS.DELETE(choiceSetId), {}, { headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }) });
|
|
9163
9727
|
}
|
|
9164
9728
|
/**
|
|
9165
9729
|
* Inserts a single value into a choice set.
|
|
9166
9730
|
*
|
|
9167
9731
|
* @param choiceSetId - UUID of the parent choice set
|
|
9168
9732
|
* @param name - Identifier name of the new value (e.g., `"TRAVEL"`)
|
|
9169
|
-
* @param options - Optional fields ({@link ChoiceSetValueInsertOptions})
|
|
9733
|
+
* @param options - Optional fields ({@link ChoiceSetValueInsertOptions}) The `folderKey` property is **experimental**.
|
|
9170
9734
|
* @returns Promise resolving to the inserted value ({@link ChoiceSetValueInsertResponse})
|
|
9171
9735
|
*
|
|
9172
9736
|
* @example
|
|
@@ -9179,16 +9743,22 @@ class ChoiceSetService extends BaseService {
|
|
|
9179
9743
|
* displayName: 'Travel',
|
|
9180
9744
|
* });
|
|
9181
9745
|
* console.log(inserted.id);
|
|
9746
|
+
*
|
|
9747
|
+
* // Folder-scoped choice set: folderKey is required on the wire
|
|
9748
|
+
* await choicesets.insertValueById(expenseTypes.id, 'TRAVEL', {
|
|
9749
|
+
* displayName: 'Travel',
|
|
9750
|
+
* folderKey: "<folderKey>",
|
|
9751
|
+
* });
|
|
9182
9752
|
* ```
|
|
9183
9753
|
* @internal
|
|
9184
9754
|
*/
|
|
9185
9755
|
async insertValueById(choiceSetId, name, options) {
|
|
9186
|
-
const choiceSetName = await this.resolveChoiceSetName(choiceSetId);
|
|
9756
|
+
const choiceSetName = await this.resolveChoiceSetName(choiceSetId, options?.folderKey);
|
|
9187
9757
|
const payload = {
|
|
9188
9758
|
Name: name,
|
|
9189
9759
|
...(options?.displayName !== undefined && { DisplayName: options.displayName }),
|
|
9190
9760
|
};
|
|
9191
|
-
const response = await this.post(DATA_FABRIC_ENDPOINTS.CHOICESETS.INSERT_BY_NAME(choiceSetName), payload);
|
|
9761
|
+
const response = await this.post(DATA_FABRIC_ENDPOINTS.CHOICESETS.INSERT_BY_NAME(choiceSetName), payload, { headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }) });
|
|
9192
9762
|
const camelCased = pascalToCamelCaseKeys(response.data);
|
|
9193
9763
|
return transformData(camelCased, EntityMap);
|
|
9194
9764
|
}
|
|
@@ -9201,6 +9771,7 @@ class ChoiceSetService extends BaseService {
|
|
|
9201
9771
|
* @param choiceSetId - UUID of the parent choice set
|
|
9202
9772
|
* @param valueId - UUID of the value to update
|
|
9203
9773
|
* @param displayName - New human-readable display name for the value
|
|
9774
|
+
* @param options - Optional {@link ChoiceSetValueUpdateOptions} — pass `folderKey` for folder-scoped choice sets; omit for tenant-level. The `folderKey` property is **experimental**.
|
|
9204
9775
|
* @returns Promise resolving to the updated value ({@link ChoiceSetValueUpdateResponse})
|
|
9205
9776
|
*
|
|
9206
9777
|
* @example
|
|
@@ -9212,13 +9783,18 @@ class ChoiceSetService extends BaseService {
|
|
|
9212
9783
|
* const travel = values.items.find(v => v.name === 'TRAVEL');
|
|
9213
9784
|
*
|
|
9214
9785
|
* await choicesets.updateValueById(expenseTypes.id, travel.id, 'Business Travel');
|
|
9786
|
+
*
|
|
9787
|
+
* // Folder-scoped choice set: folderKey is required on the wire
|
|
9788
|
+
* await choicesets.updateValueById(expenseTypes.id, travel.id, 'Business Travel', {
|
|
9789
|
+
* folderKey: "<folderKey>",
|
|
9790
|
+
* });
|
|
9215
9791
|
* ```
|
|
9216
9792
|
* @internal
|
|
9217
9793
|
*/
|
|
9218
|
-
async updateValueById(choiceSetId, valueId, displayName) {
|
|
9219
|
-
const choiceSetName = await this.resolveChoiceSetName(choiceSetId);
|
|
9794
|
+
async updateValueById(choiceSetId, valueId, displayName, options) {
|
|
9795
|
+
const choiceSetName = await this.resolveChoiceSetName(choiceSetId, options?.folderKey);
|
|
9220
9796
|
const payload = { DisplayName: displayName };
|
|
9221
|
-
const response = await this.post(DATA_FABRIC_ENDPOINTS.CHOICESETS.UPDATE_BY_NAME(choiceSetName, valueId), payload);
|
|
9797
|
+
const response = await this.post(DATA_FABRIC_ENDPOINTS.CHOICESETS.UPDATE_BY_NAME(choiceSetName, valueId), payload, { headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }) });
|
|
9222
9798
|
const camelCased = pascalToCamelCaseKeys(response.data);
|
|
9223
9799
|
return transformData(camelCased, EntityMap);
|
|
9224
9800
|
}
|
|
@@ -9227,6 +9803,7 @@ class ChoiceSetService extends BaseService {
|
|
|
9227
9803
|
*
|
|
9228
9804
|
* @param choiceSetId - UUID of the parent choice set
|
|
9229
9805
|
* @param valueIds - Array of value UUIDs to delete
|
|
9806
|
+
* @param options - Optional {@link ChoiceSetValueDeleteOptions} (e.g. `folderKey` for folder-scoped choice sets) The `folderKey` property is **experimental**.
|
|
9230
9807
|
* @returns Promise resolving when the values are deleted
|
|
9231
9808
|
*
|
|
9232
9809
|
* @example
|
|
@@ -9236,14 +9813,20 @@ class ChoiceSetService extends BaseService {
|
|
|
9236
9813
|
* const idsToDelete = values.items.slice(0, 2).map(v => v.id);
|
|
9237
9814
|
*
|
|
9238
9815
|
* await choicesets.deleteValuesById('<choiceSetId>', idsToDelete);
|
|
9816
|
+
*
|
|
9817
|
+
* // Folder-scoped choice set
|
|
9818
|
+
* await choicesets.deleteValuesById('<choiceSetId>', idsToDelete, { folderKey: "<folderKey>" });
|
|
9239
9819
|
* ```
|
|
9240
9820
|
* @internal
|
|
9241
9821
|
*/
|
|
9242
|
-
async deleteValuesById(choiceSetId, valueIds) {
|
|
9243
|
-
await this.post(DATA_FABRIC_ENDPOINTS.CHOICESETS.DELETE_BY_ID(choiceSetId), valueIds);
|
|
9822
|
+
async deleteValuesById(choiceSetId, valueIds, options) {
|
|
9823
|
+
await this.post(DATA_FABRIC_ENDPOINTS.CHOICESETS.DELETE_BY_ID(choiceSetId), valueIds, { headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }) });
|
|
9244
9824
|
}
|
|
9245
|
-
async resolveChoiceSetName(choiceSetId) {
|
|
9246
|
-
|
|
9825
|
+
async resolveChoiceSetName(choiceSetId, folderKey) {
|
|
9826
|
+
// Use the un-tracked helper directly so we don't fire a duplicate
|
|
9827
|
+
// `Choicesets.GetAll` telemetry event for every insertValueById /
|
|
9828
|
+
// updateValueById call.
|
|
9829
|
+
const all = await this.fetchAllChoiceSets(folderKey === undefined ? undefined : { folderKey });
|
|
9247
9830
|
const match = all.find(cs => cs.id === choiceSetId);
|
|
9248
9831
|
if (!match) {
|
|
9249
9832
|
throw new NotFoundError({ message: `Choice set with id '${choiceSetId}' not found.` });
|
|
@@ -9295,6 +9878,13 @@ function createProcessMethods(processData, service) {
|
|
|
9295
9878
|
if (!processData.folderKey)
|
|
9296
9879
|
throw new Error('Folder key is undefined');
|
|
9297
9880
|
return service.getIncidents(processData.processKey, processData.folderKey);
|
|
9881
|
+
},
|
|
9882
|
+
getElementStats(startTime, endTime, packageVersion) {
|
|
9883
|
+
if (!processData.processKey)
|
|
9884
|
+
throw new Error('Process key is undefined');
|
|
9885
|
+
if (!processData.packageId)
|
|
9886
|
+
throw new Error('Package ID is undefined');
|
|
9887
|
+
return service.getElementStats(processData.processKey, processData.packageId, startTime, endTime, packageVersion);
|
|
9298
9888
|
}
|
|
9299
9889
|
};
|
|
9300
9890
|
}
|
|
@@ -9356,6 +9946,28 @@ async function fetchInstanceStatusTimeline(postFn, startTime, endTime, isCaseMan
|
|
|
9356
9946
|
});
|
|
9357
9947
|
return response.data ?? [];
|
|
9358
9948
|
}
|
|
9949
|
+
/**
|
|
9950
|
+
* Builds the request body for the ElementCountByStatus endpoint.
|
|
9951
|
+
*
|
|
9952
|
+
* @param processKey - Process key to filter by
|
|
9953
|
+
* @param packageId - Package identifier
|
|
9954
|
+
* @param startTime - Start of the time range to query
|
|
9955
|
+
* @param endTime - End of the time range to query
|
|
9956
|
+
* @param packageVersion - Package version to filter by
|
|
9957
|
+
* @returns Request body for the ElementCountByStatus endpoint
|
|
9958
|
+
* @internal
|
|
9959
|
+
*/
|
|
9960
|
+
function buildElementCountByStatusBody(processKey, packageId, startTime, endTime, packageVersion) {
|
|
9961
|
+
return {
|
|
9962
|
+
commonParams: {
|
|
9963
|
+
processKey,
|
|
9964
|
+
packageId,
|
|
9965
|
+
startTime: startTime.getTime(),
|
|
9966
|
+
endTime: endTime.getTime(),
|
|
9967
|
+
version: packageVersion
|
|
9968
|
+
}
|
|
9969
|
+
};
|
|
9970
|
+
}
|
|
9359
9971
|
|
|
9360
9972
|
/**
|
|
9361
9973
|
* Maps fields for Incident entities
|
|
@@ -9520,7 +10132,9 @@ function createProcessInstanceMethods(instanceData, service) {
|
|
|
9520
10132
|
async getExecutionHistory() {
|
|
9521
10133
|
if (!instanceData.instanceId)
|
|
9522
10134
|
throw new Error('Process instance ID is undefined');
|
|
9523
|
-
|
|
10135
|
+
if (!instanceData.folderKey)
|
|
10136
|
+
throw new Error('Process instance folder key is undefined');
|
|
10137
|
+
return service.getExecutionHistory(instanceData.instanceId, instanceData.folderKey);
|
|
9524
10138
|
},
|
|
9525
10139
|
async getBpmn() {
|
|
9526
10140
|
if (!instanceData.instanceId)
|
|
@@ -9586,6 +10200,40 @@ var DebugMode;
|
|
|
9586
10200
|
DebugMode["SingleStep"] = "SingleStep";
|
|
9587
10201
|
})(DebugMode || (DebugMode = {}));
|
|
9588
10202
|
|
|
10203
|
+
/**
|
|
10204
|
+
* Maestro Cases Models
|
|
10205
|
+
* Model classes for Maestro cases
|
|
10206
|
+
*/
|
|
10207
|
+
/**
|
|
10208
|
+
* Creates methods for a case object
|
|
10209
|
+
*
|
|
10210
|
+
* @param caseData - The case data (response from API)
|
|
10211
|
+
* @param service - The cases service instance
|
|
10212
|
+
* @returns Object containing case methods
|
|
10213
|
+
*/
|
|
10214
|
+
function createCaseMethods(caseData, service) {
|
|
10215
|
+
return {
|
|
10216
|
+
getElementStats(startTime, endTime, packageVersion) {
|
|
10217
|
+
if (!caseData.processKey)
|
|
10218
|
+
throw new Error('Process key is undefined');
|
|
10219
|
+
if (!caseData.packageId)
|
|
10220
|
+
throw new Error('Package ID is undefined');
|
|
10221
|
+
return service.getElementStats(caseData.processKey, caseData.packageId, startTime, endTime, packageVersion);
|
|
10222
|
+
}
|
|
10223
|
+
};
|
|
10224
|
+
}
|
|
10225
|
+
/**
|
|
10226
|
+
* Creates an actionable case by combining API case data with operational methods.
|
|
10227
|
+
*
|
|
10228
|
+
* @param caseData - The case data from API
|
|
10229
|
+
* @param service - The cases service instance
|
|
10230
|
+
* @returns A case object with added methods
|
|
10231
|
+
*/
|
|
10232
|
+
function createCaseWithMethods(caseData, service) {
|
|
10233
|
+
const methods = createCaseMethods(caseData, service);
|
|
10234
|
+
return Object.assign({}, caseData, methods);
|
|
10235
|
+
}
|
|
10236
|
+
|
|
9589
10237
|
/**
|
|
9590
10238
|
* Case Instance Types
|
|
9591
10239
|
* Types and interfaces for Maestro case instance management
|
|
@@ -9797,12 +10445,6 @@ const ProcessInstanceMap = {
|
|
|
9797
10445
|
createdAt: 'createdTime',
|
|
9798
10446
|
updatedAt: 'updatedTime'
|
|
9799
10447
|
};
|
|
9800
|
-
/**
|
|
9801
|
-
* Maps fields for Process Instance Execution History to ensure consistent naming
|
|
9802
|
-
*/
|
|
9803
|
-
const ProcessInstanceExecutionHistoryMap = {
|
|
9804
|
-
startTime: 'startedTime'
|
|
9805
|
-
};
|
|
9806
10448
|
|
|
9807
10449
|
class ProcessInstancesService extends BaseService {
|
|
9808
10450
|
/**
|
|
@@ -9883,11 +10525,66 @@ class ProcessInstancesService extends BaseService {
|
|
|
9883
10525
|
/**
|
|
9884
10526
|
* Get execution history (spans) for a process instance
|
|
9885
10527
|
* @param instanceId The ID of the instance to get history for
|
|
9886
|
-
* @
|
|
10528
|
+
* @param folderKey The folder key for authorization
|
|
10529
|
+
* @returns Promise resolving to execution history
|
|
10530
|
+
* {@link ProcessInstanceExecutionHistoryResponse}
|
|
10531
|
+
* @example
|
|
10532
|
+
* ```typescript
|
|
10533
|
+
* // Get execution history for a process instance
|
|
10534
|
+
* const history = await processInstances.getExecutionHistory(
|
|
10535
|
+
* <instanceId>,
|
|
10536
|
+
* <folderKey>
|
|
10537
|
+
* );
|
|
10538
|
+
*
|
|
10539
|
+
* // Analyze execution timeline
|
|
10540
|
+
* history.forEach(span => {
|
|
10541
|
+
* console.log(`Activity: ${span.name}`);
|
|
10542
|
+
* console.log(`Start: ${span.startedTime}`);
|
|
10543
|
+
* console.log(`End: ${span.endTime}`);
|
|
10544
|
+
* });
|
|
10545
|
+
* ```
|
|
9887
10546
|
*/
|
|
9888
|
-
async getExecutionHistory(instanceId) {
|
|
9889
|
-
const
|
|
9890
|
-
|
|
10547
|
+
async getExecutionHistory(instanceId, folderKey) {
|
|
10548
|
+
const headers = createHeaders({ [FOLDER_KEY]: folderKey });
|
|
10549
|
+
const elementExecResponse = await this.get(MAESTRO_ENDPOINTS.INSTANCES.GET_ELEMENT_EXECUTIONS(instanceId), { headers });
|
|
10550
|
+
const traceId = elementExecResponse.data.traceId;
|
|
10551
|
+
const spansResponse = await this.get(MAESTRO_ENDPOINTS.TRACES.GET_SPANS(traceId), { headers });
|
|
10552
|
+
// Build span lookup keyed by elementRunId extracted from Attributes JSON
|
|
10553
|
+
const spanMap = new Map();
|
|
10554
|
+
for (const span of spansResponse.data) {
|
|
10555
|
+
try {
|
|
10556
|
+
const attrs = span.Attributes ? JSON.parse(span.Attributes) : null;
|
|
10557
|
+
if (attrs?.elementRunId) {
|
|
10558
|
+
spanMap.set(attrs.elementRunId, span);
|
|
10559
|
+
}
|
|
10560
|
+
}
|
|
10561
|
+
catch {
|
|
10562
|
+
// skip spans with unparseable Attributes — they won't match any elementRunId
|
|
10563
|
+
}
|
|
10564
|
+
}
|
|
10565
|
+
const results = [];
|
|
10566
|
+
for (const elementExec of elementExecResponse.data.elementExecutions) {
|
|
10567
|
+
for (const run of elementExec.elementRuns) {
|
|
10568
|
+
const span = spanMap.get(run.elementRunId);
|
|
10569
|
+
if (span) {
|
|
10570
|
+
results.push(this.mapSpanToHistory(span));
|
|
10571
|
+
}
|
|
10572
|
+
}
|
|
10573
|
+
}
|
|
10574
|
+
return results;
|
|
10575
|
+
}
|
|
10576
|
+
mapSpanToHistory(span) {
|
|
10577
|
+
return {
|
|
10578
|
+
id: span.Id,
|
|
10579
|
+
traceId: span.TraceId,
|
|
10580
|
+
parentId: span.ParentId,
|
|
10581
|
+
name: span.Name,
|
|
10582
|
+
startedTime: span.StartTime,
|
|
10583
|
+
endTime: span.EndTime,
|
|
10584
|
+
attributes: span.Attributes,
|
|
10585
|
+
updatedTime: span.UpdatedAt,
|
|
10586
|
+
expiredTime: span.ExpiryTimeUtc,
|
|
10587
|
+
};
|
|
9891
10588
|
}
|
|
9892
10589
|
/**
|
|
9893
10590
|
* Get BPMN XML file for a process instance
|
|
@@ -10379,6 +11076,41 @@ class MaestroProcessesService extends BaseService {
|
|
|
10379
11076
|
const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.TOP_PROCESSES_BY_DURATION, buildInsightsTopBody(startTime, endTime, false, options));
|
|
10380
11077
|
return (data ?? []).map(process => ({ ...process, name: process.packageId }));
|
|
10381
11078
|
}
|
|
11079
|
+
/**
|
|
11080
|
+
* Get element stats for process instances
|
|
11081
|
+
*
|
|
11082
|
+
* Returns per-element execution counts (success, fail, terminated, paused, in-progress) and
|
|
11083
|
+
* duration percentile metrics (min, max, avg, p50, p95, p99) for BPMN elements within a process.
|
|
11084
|
+
*
|
|
11085
|
+
* @param processKey - Process key to filter by
|
|
11086
|
+
* @param packageId - Package identifier
|
|
11087
|
+
* @param startTime - Start of the time range to query
|
|
11088
|
+
* @param endTime - End of the time range to query
|
|
11089
|
+
* @param packageVersion - Package version to filter by
|
|
11090
|
+
* @returns Promise resolving to an array of {@link ElementStats}
|
|
11091
|
+
* @example
|
|
11092
|
+
* ```typescript
|
|
11093
|
+
* // Get element metrics for a process
|
|
11094
|
+
* const elements = await maestroProcesses.getElementStats(
|
|
11095
|
+
* '<processKey>',
|
|
11096
|
+
* '<packageId>',
|
|
11097
|
+
* new Date('2026-04-01'),
|
|
11098
|
+
* new Date(),
|
|
11099
|
+
* '1.0.1'
|
|
11100
|
+
* );
|
|
11101
|
+
*
|
|
11102
|
+
* // Analyze element performance
|
|
11103
|
+
* for (const element of elements) {
|
|
11104
|
+
* console.log(`Element: ${element.elementId}`);
|
|
11105
|
+
* console.log(` Success: ${element.successCount}, Failed: ${element.failCount}`);
|
|
11106
|
+
* console.log(` Avg duration: ${element.avgDurationMs}ms, P95: ${element.p95DurationMs}ms`);
|
|
11107
|
+
* }
|
|
11108
|
+
* ```
|
|
11109
|
+
*/
|
|
11110
|
+
async getElementStats(processKey, packageId, startTime, endTime, packageVersion) {
|
|
11111
|
+
const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.ELEMENT_COUNT_BY_STATUS, buildElementCountByStatusBody(processKey, packageId, startTime, endTime, packageVersion));
|
|
11112
|
+
return data ?? [];
|
|
11113
|
+
}
|
|
10382
11114
|
}
|
|
10383
11115
|
__decorate([
|
|
10384
11116
|
track('MaestroProcesses.GetAll')
|
|
@@ -10401,6 +11133,9 @@ __decorate([
|
|
|
10401
11133
|
__decorate([
|
|
10402
11134
|
track('MaestroProcesses.GetTopExecutionDuration')
|
|
10403
11135
|
], MaestroProcessesService.prototype, "getTopExecutionDuration", null);
|
|
11136
|
+
__decorate([
|
|
11137
|
+
track('MaestroProcesses.GetElementStats')
|
|
11138
|
+
], MaestroProcessesService.prototype, "getElementStats", null);
|
|
10404
11139
|
|
|
10405
11140
|
/**
|
|
10406
11141
|
* Service class for Maestro Process Incidents
|
|
@@ -10456,7 +11191,7 @@ var ProcessType;
|
|
|
10456
11191
|
class CasesService extends BaseService {
|
|
10457
11192
|
/**
|
|
10458
11193
|
* Get all case management processes with their instance statistics
|
|
10459
|
-
* @returns Promise resolving to array of
|
|
11194
|
+
* @returns Promise resolving to an array of {@link CaseGetAllWithMethodsResponse}
|
|
10460
11195
|
*
|
|
10461
11196
|
* @example
|
|
10462
11197
|
* ```typescript
|
|
@@ -10480,10 +11215,10 @@ class CasesService extends BaseService {
|
|
|
10480
11215
|
const response = await this.get(MAESTRO_ENDPOINTS.PROCESSES.GET_ALL, { params });
|
|
10481
11216
|
// Extract processes array from response data and add name field
|
|
10482
11217
|
const cases = response.data?.processes || [];
|
|
10483
|
-
return cases.map(caseItem => ({
|
|
11218
|
+
return cases.map(caseItem => createCaseWithMethods({
|
|
10484
11219
|
...caseItem,
|
|
10485
11220
|
name: this.extractCaseName(caseItem.packageId)
|
|
10486
|
-
}));
|
|
11221
|
+
}, this));
|
|
10487
11222
|
}
|
|
10488
11223
|
/**
|
|
10489
11224
|
* Get the top 5 case processes ranked by run count within a time range.
|
|
@@ -10702,6 +11437,40 @@ class CasesService extends BaseService {
|
|
|
10702
11437
|
const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.TOP_PROCESSES_BY_DURATION, buildInsightsTopBody(startTime, endTime, true, options));
|
|
10703
11438
|
return (data ?? []).map(process => ({ ...process, name: this.extractCaseName(process.packageId) }));
|
|
10704
11439
|
}
|
|
11440
|
+
/**
|
|
11441
|
+
* Get element stats for case instances
|
|
11442
|
+
*
|
|
11443
|
+
* Returns per-element execution counts (success, fail, terminated, paused, in-progress) and
|
|
11444
|
+
* duration percentile metrics (min, max, avg, p50, p95, p99) for BPMN elements within a case.
|
|
11445
|
+
*
|
|
11446
|
+
* @param processKey - Process key to filter by
|
|
11447
|
+
* @param packageId - Package identifier
|
|
11448
|
+
* @param startTime - Start of the time range to query
|
|
11449
|
+
* @param endTime - End of the time range to query
|
|
11450
|
+
* @param packageVersion - Package version to filter by
|
|
11451
|
+
* @returns Promise resolving to an array of {@link ElementStats}
|
|
11452
|
+
* @example
|
|
11453
|
+
* ```typescript
|
|
11454
|
+
* // Get element metrics for a case
|
|
11455
|
+
* const elements = await cases.getElementStats(
|
|
11456
|
+
* '<processKey>',
|
|
11457
|
+
* '<packageId>',
|
|
11458
|
+
* new Date('2026-04-01'),
|
|
11459
|
+
* new Date(),
|
|
11460
|
+
* '1.0.1'
|
|
11461
|
+
* );
|
|
11462
|
+
*
|
|
11463
|
+
* // Find elements with failures
|
|
11464
|
+
* const failedElements = elements.filter(e => e.failCount > 0);
|
|
11465
|
+
* for (const element of failedElements) {
|
|
11466
|
+
* console.log(`Failed element: ${element.elementId}, failures: ${element.failCount}`);
|
|
11467
|
+
* }
|
|
11468
|
+
* ```
|
|
11469
|
+
*/
|
|
11470
|
+
async getElementStats(processKey, packageId, startTime, endTime, packageVersion) {
|
|
11471
|
+
const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.ELEMENT_COUNT_BY_STATUS, buildElementCountByStatusBody(processKey, packageId, startTime, endTime, packageVersion));
|
|
11472
|
+
return data ?? [];
|
|
11473
|
+
}
|
|
10705
11474
|
/**
|
|
10706
11475
|
* Extract a readable case name from the packageId
|
|
10707
11476
|
* @param packageId - The full package identifier
|
|
@@ -10739,6 +11508,9 @@ __decorate([
|
|
|
10739
11508
|
__decorate([
|
|
10740
11509
|
track('Cases.GetTopExecutionDuration')
|
|
10741
11510
|
], CasesService.prototype, "getTopExecutionDuration", null);
|
|
11511
|
+
__decorate([
|
|
11512
|
+
track('Cases.GetElementStats')
|
|
11513
|
+
], CasesService.prototype, "getElementStats", null);
|
|
10742
11514
|
|
|
10743
11515
|
/**
|
|
10744
11516
|
* Maps fields for Case Instance entities to ensure consistent naming
|
|
@@ -10823,17 +11595,19 @@ function createTaskMethods(taskData, service) {
|
|
|
10823
11595
|
async assign(options) {
|
|
10824
11596
|
if (!taskData.id)
|
|
10825
11597
|
throw new Error('Task ID is undefined');
|
|
11598
|
+
const criteria = options.assignmentCriteria !== undefined ? { assignmentCriteria: options.assignmentCriteria } : {};
|
|
10826
11599
|
const assignmentOptions = 'userId' in options && options.userId !== undefined
|
|
10827
|
-
? { taskId: taskData.id, userId: options.userId }
|
|
10828
|
-
: { taskId: taskData.id, userNameOrEmail: options.userNameOrEmail };
|
|
11600
|
+
? { taskId: taskData.id, userId: options.userId, ...criteria }
|
|
11601
|
+
: { taskId: taskData.id, userNameOrEmail: options.userNameOrEmail, ...criteria };
|
|
10829
11602
|
return service.assign(assignmentOptions);
|
|
10830
11603
|
},
|
|
10831
11604
|
async reassign(options) {
|
|
10832
11605
|
if (!taskData.id)
|
|
10833
11606
|
throw new Error('Task ID is undefined');
|
|
11607
|
+
const criteria = options.assignmentCriteria !== undefined ? { assignmentCriteria: options.assignmentCriteria } : {};
|
|
10834
11608
|
const assignmentOptions = 'userId' in options && options.userId !== undefined
|
|
10835
|
-
? { taskId: taskData.id, userId: options.userId }
|
|
10836
|
-
: { taskId: taskData.id, userNameOrEmail: options.userNameOrEmail };
|
|
11609
|
+
? { taskId: taskData.id, userId: options.userId, ...criteria }
|
|
11610
|
+
: { taskId: taskData.id, userNameOrEmail: options.userNameOrEmail, ...criteria };
|
|
10837
11611
|
return service.reassign(assignmentOptions);
|
|
10838
11612
|
},
|
|
10839
11613
|
async unassign() {
|
|
@@ -11146,6 +11920,26 @@ class TaskService extends BaseService {
|
|
|
11146
11920
|
* }
|
|
11147
11921
|
* ]);
|
|
11148
11922
|
* ```
|
|
11923
|
+
*
|
|
11924
|
+
* @example Group assignment
|
|
11925
|
+
* ```typescript
|
|
11926
|
+
* import { TaskAssignmentCriteria } from '@uipath/uipath-typescript/tasks';
|
|
11927
|
+
*
|
|
11928
|
+
* // Assign to a directory group by userId + criteria — Action Center
|
|
11929
|
+
* // distributes the task across the group's members based on the criteria
|
|
11930
|
+
* const result = await tasks.assign({
|
|
11931
|
+
* taskId: 123,
|
|
11932
|
+
* userId: 456, // a DirectoryGroup id from tasks.getUsers()
|
|
11933
|
+
* assignmentCriteria: TaskAssignmentCriteria.AllUsers
|
|
11934
|
+
* });
|
|
11935
|
+
*
|
|
11936
|
+
* // ...or identify the group by name instead of id
|
|
11937
|
+
* const result2 = await tasks.assign({
|
|
11938
|
+
* taskId: 123,
|
|
11939
|
+
* userNameOrEmail: "My Group",
|
|
11940
|
+
* assignmentCriteria: TaskAssignmentCriteria.AllUsers
|
|
11941
|
+
* });
|
|
11942
|
+
* ```
|
|
11149
11943
|
*/
|
|
11150
11944
|
async assign(taskAssignments) {
|
|
11151
11945
|
// Normalize input to array
|
|
@@ -11197,6 +11991,25 @@ class TaskService extends BaseService {
|
|
|
11197
11991
|
* }
|
|
11198
11992
|
* ]);
|
|
11199
11993
|
* ```
|
|
11994
|
+
*
|
|
11995
|
+
* @example Group reassignment
|
|
11996
|
+
* ```typescript
|
|
11997
|
+
* import { TaskAssignmentCriteria } from '@uipath/uipath-typescript/tasks';
|
|
11998
|
+
*
|
|
11999
|
+
* // Reassign to a directory group by userId + criteria
|
|
12000
|
+
* const result = await tasks.reassign({
|
|
12001
|
+
* taskId: 123,
|
|
12002
|
+
* userId: 456, // a DirectoryGroup id from tasks.getUsers()
|
|
12003
|
+
* assignmentCriteria: TaskAssignmentCriteria.AllUsers
|
|
12004
|
+
* });
|
|
12005
|
+
*
|
|
12006
|
+
* // ...or identify the group by name instead of id
|
|
12007
|
+
* const result2 = await tasks.reassign({
|
|
12008
|
+
* taskId: 123,
|
|
12009
|
+
* userNameOrEmail: "My Group",
|
|
12010
|
+
* assignmentCriteria: TaskAssignmentCriteria.AllUsers
|
|
12011
|
+
* });
|
|
12012
|
+
* ```
|
|
11200
12013
|
*/
|
|
11201
12014
|
async reassign(taskAssignments) {
|
|
11202
12015
|
// Normalize input to array
|
|
@@ -11947,37 +12760,6 @@ function validateName(resourceType, name) {
|
|
|
11947
12760
|
return trimmed;
|
|
11948
12761
|
}
|
|
11949
12762
|
|
|
11950
|
-
/**
|
|
11951
|
-
* Encodes a folder path for the `X-UIPATH-FolderPath-Encoded` header.
|
|
11952
|
-
*
|
|
11953
|
-
* Orchestrator decodes this header as **base64-encoded UTF-16 LE bytes**
|
|
11954
|
-
* (see `HttpHeadersProviderExtensions.GetDecoded` + `OrganizationUnitProvider`
|
|
11955
|
-
* in the Orchestrator repo, which call `Encoding.Unicode.GetString(...)`).
|
|
11956
|
-
* URL-encoding is NOT what the server expects — it must be base64-of-UTF-16-LE
|
|
11957
|
-
* bytes.
|
|
11958
|
-
*
|
|
11959
|
-
* @param folderPath - The folder path (e.g. 'Shared/Finance')
|
|
11960
|
-
* @returns Base64 string suitable for the `X-UIPATH-FolderPath-Encoded` header
|
|
11961
|
-
*/
|
|
11962
|
-
function encodeFolderPathHeader(folderPath) {
|
|
11963
|
-
// Force little-endian regardless of host byte order. `Uint16Array` viewed
|
|
11964
|
-
// as `Uint8Array` would use the host's native order — correct on LE hosts
|
|
11965
|
-
// (x86/ARM-LE) but wrong on BE hosts. `DataView.setUint16(..., true)`
|
|
11966
|
-
// pins LE.
|
|
11967
|
-
const buf = new ArrayBuffer(folderPath.length * 2);
|
|
11968
|
-
const view = new DataView(buf);
|
|
11969
|
-
for (let i = 0; i < folderPath.length; i++) {
|
|
11970
|
-
view.setUint16(i * 2, folderPath.charCodeAt(i), true);
|
|
11971
|
-
}
|
|
11972
|
-
const bytes = new Uint8Array(buf);
|
|
11973
|
-
let binary = '';
|
|
11974
|
-
for (let i = 0; i < bytes.byteLength; i++) {
|
|
11975
|
-
binary += String.fromCharCode(bytes[i]);
|
|
11976
|
-
}
|
|
11977
|
-
// btoa is browser-native; Node 16+ also has it as a global
|
|
11978
|
-
return btoa(binary);
|
|
11979
|
-
}
|
|
11980
|
-
|
|
11981
12763
|
/**
|
|
11982
12764
|
* Resolves folder context into the appropriate Orchestrator folder headers.
|
|
11983
12765
|
*
|
|
@@ -12125,6 +12907,26 @@ function describeFolderForError(folderId, folderKey, folderPath) {
|
|
|
12125
12907
|
return '';
|
|
12126
12908
|
}
|
|
12127
12909
|
|
|
12910
|
+
/**
|
|
12911
|
+
* Enum for Asset Value Scope
|
|
12912
|
+
*/
|
|
12913
|
+
var AssetValueScope;
|
|
12914
|
+
(function (AssetValueScope) {
|
|
12915
|
+
AssetValueScope["Global"] = "Global";
|
|
12916
|
+
AssetValueScope["PerRobot"] = "PerRobot";
|
|
12917
|
+
})(AssetValueScope || (AssetValueScope = {}));
|
|
12918
|
+
/**
|
|
12919
|
+
* Enum for Asset Value Type
|
|
12920
|
+
*/
|
|
12921
|
+
var AssetValueType;
|
|
12922
|
+
(function (AssetValueType) {
|
|
12923
|
+
AssetValueType["Text"] = "Text";
|
|
12924
|
+
AssetValueType["Bool"] = "Bool";
|
|
12925
|
+
AssetValueType["Integer"] = "Integer";
|
|
12926
|
+
AssetValueType["Credential"] = "Credential";
|
|
12927
|
+
AssetValueType["Secret"] = "Secret";
|
|
12928
|
+
})(AssetValueType || (AssetValueType = {}));
|
|
12929
|
+
|
|
12128
12930
|
/**
|
|
12129
12931
|
* Maps fields for Asset entities to ensure consistent naming
|
|
12130
12932
|
*/
|
|
@@ -12249,6 +13051,68 @@ class AssetService extends FolderScopedService {
|
|
|
12249
13051
|
async getByName(name, options = {}) {
|
|
12250
13052
|
return this.getByNameLookup('Asset', ASSET_ENDPOINTS.GET_BY_FOLDER, name, options, (raw) => transformData(pascalToCamelCaseKeys(raw), AssetMap));
|
|
12251
13053
|
}
|
|
13054
|
+
/**
|
|
13055
|
+
* Updates the value of an existing asset by ID.
|
|
13056
|
+
*
|
|
13057
|
+
* Fetches the asset internally to determine its type, then updates only the value while
|
|
13058
|
+
* preserving the asset's name, scope, and description.
|
|
13059
|
+
*
|
|
13060
|
+
* **Supported value types:** `Text`, `Integer`, and `Bool` only. Other types
|
|
13061
|
+
* (`Credential`, `Secret`) throw a `ValidationError`.
|
|
13062
|
+
*
|
|
13063
|
+
* The `newValue` runtime type must match the asset's `valueType`:
|
|
13064
|
+
* - `Text` → `string`
|
|
13065
|
+
* - `Integer` → `number` (integer)
|
|
13066
|
+
* - `Bool` → `boolean`
|
|
13067
|
+
*
|
|
13068
|
+
* @param id - Asset ID
|
|
13069
|
+
* @param newValue - New value to apply (string for `Text`, number for `Integer`, boolean for `Bool`)
|
|
13070
|
+
* @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`)
|
|
13071
|
+
* @returns Promise resolving when the asset has been updated
|
|
13072
|
+
*
|
|
13073
|
+
* @example
|
|
13074
|
+
* ```typescript
|
|
13075
|
+
* import { Assets } from '@uipath/uipath-typescript/assets';
|
|
13076
|
+
*
|
|
13077
|
+
* const assets = new Assets(sdk);
|
|
13078
|
+
*
|
|
13079
|
+
* // Update a Text asset by folder ID
|
|
13080
|
+
* await assets.updateValueById(<assetId>, 'new-value', { folderId: <folderId> });
|
|
13081
|
+
*
|
|
13082
|
+
* // Update an Integer asset by folder key (GUID)
|
|
13083
|
+
* await assets.updateValueById(<assetId>, 42, { folderKey: '5f6dadf1-3677-49dc-8aca-c2999dd4b3ba' });
|
|
13084
|
+
*
|
|
13085
|
+
* // Update a Bool asset by folder path
|
|
13086
|
+
* await assets.updateValueById(<assetId>, true, { folderPath: 'Shared/Finance' });
|
|
13087
|
+
* ```
|
|
13088
|
+
*/
|
|
13089
|
+
async updateValueById(id, newValue, options) {
|
|
13090
|
+
if (!id) {
|
|
13091
|
+
throw new ValidationError({ message: 'id is required for updateValueById' });
|
|
13092
|
+
}
|
|
13093
|
+
if (newValue === null || newValue === undefined) {
|
|
13094
|
+
throw new ValidationError({ message: 'newValue is required for updateValueById' });
|
|
13095
|
+
}
|
|
13096
|
+
const headers = resolveFolderHeaders({
|
|
13097
|
+
folderId: options?.folderId,
|
|
13098
|
+
folderKey: options?.folderKey,
|
|
13099
|
+
folderPath: options?.folderPath,
|
|
13100
|
+
resourceType: 'Assets.updateValueById',
|
|
13101
|
+
fallbackFolderKey: this.config.folderKey,
|
|
13102
|
+
});
|
|
13103
|
+
const existingResponse = await this.get(ASSET_ENDPOINTS.GET_BY_ID(id), { headers });
|
|
13104
|
+
const existing = existingResponse.data;
|
|
13105
|
+
const valueField = resolveValueField(id, existing.ValueType, newValue);
|
|
13106
|
+
const body = {
|
|
13107
|
+
Id: id,
|
|
13108
|
+
Name: existing.Name,
|
|
13109
|
+
ValueScope: existing.ValueScope,
|
|
13110
|
+
ValueType: existing.ValueType,
|
|
13111
|
+
Description: existing.Description,
|
|
13112
|
+
[valueField]: newValue,
|
|
13113
|
+
};
|
|
13114
|
+
await this.put(ASSET_ENDPOINTS.GET_BY_ID(id), body, { headers });
|
|
13115
|
+
}
|
|
12252
13116
|
}
|
|
12253
13117
|
__decorate([
|
|
12254
13118
|
track('Assets.GetAll')
|
|
@@ -12259,30 +13123,42 @@ __decorate([
|
|
|
12259
13123
|
__decorate([
|
|
12260
13124
|
track('Assets.GetByName')
|
|
12261
13125
|
], AssetService.prototype, "getByName", null);
|
|
12262
|
-
|
|
12263
|
-
|
|
12264
|
-
|
|
12265
|
-
*/
|
|
12266
|
-
var AssetValueScope;
|
|
12267
|
-
(function (AssetValueScope) {
|
|
12268
|
-
AssetValueScope["Global"] = "Global";
|
|
12269
|
-
AssetValueScope["PerRobot"] = "PerRobot";
|
|
12270
|
-
})(AssetValueScope || (AssetValueScope = {}));
|
|
13126
|
+
__decorate([
|
|
13127
|
+
track('Assets.UpdateValueById')
|
|
13128
|
+
], AssetService.prototype, "updateValueById", null);
|
|
12271
13129
|
/**
|
|
12272
|
-
*
|
|
13130
|
+
* Maps the asset's `valueType` to the PUT body field carrying the new value, validating
|
|
13131
|
+
* that the new value's runtime type matches the asset type.
|
|
12273
13132
|
*/
|
|
12274
|
-
|
|
12275
|
-
|
|
12276
|
-
|
|
12277
|
-
|
|
12278
|
-
|
|
12279
|
-
|
|
12280
|
-
|
|
12281
|
-
|
|
12282
|
-
|
|
12283
|
-
|
|
12284
|
-
|
|
12285
|
-
|
|
13133
|
+
function resolveValueField(id, valueType, newValue) {
|
|
13134
|
+
switch (valueType) {
|
|
13135
|
+
case AssetValueType.Text:
|
|
13136
|
+
if (typeof newValue !== 'string') {
|
|
13137
|
+
throw new ValidationError({
|
|
13138
|
+
message: `Asset ${id} has valueType Text; newValue must be a string, got ${typeof newValue}`,
|
|
13139
|
+
});
|
|
13140
|
+
}
|
|
13141
|
+
return 'StringValue';
|
|
13142
|
+
case AssetValueType.Integer:
|
|
13143
|
+
if (typeof newValue !== 'number' || !Number.isInteger(newValue)) {
|
|
13144
|
+
throw new ValidationError({
|
|
13145
|
+
message: `Asset ${id} has valueType Integer; newValue must be an integer number, got ${typeof newValue}`,
|
|
13146
|
+
});
|
|
13147
|
+
}
|
|
13148
|
+
return 'IntValue';
|
|
13149
|
+
case AssetValueType.Bool:
|
|
13150
|
+
if (typeof newValue !== 'boolean') {
|
|
13151
|
+
throw new ValidationError({
|
|
13152
|
+
message: `Asset ${id} has valueType Bool; newValue must be a boolean, got ${typeof newValue}`,
|
|
13153
|
+
});
|
|
13154
|
+
}
|
|
13155
|
+
return 'BoolValue';
|
|
13156
|
+
default:
|
|
13157
|
+
throw new ValidationError({
|
|
13158
|
+
message: `updateValueById only supports Text, Integer, or Bool assets; asset ${id} has valueType ${valueType}`,
|
|
13159
|
+
});
|
|
13160
|
+
}
|
|
13161
|
+
}
|
|
12286
13162
|
|
|
12287
13163
|
/**
|
|
12288
13164
|
* Maps fields for Bucket entities to ensure consistent naming
|
|
@@ -12419,48 +13295,32 @@ class BucketService extends FolderScopedService {
|
|
|
12419
13295
|
}
|
|
12420
13296
|
}, options);
|
|
12421
13297
|
}
|
|
12422
|
-
|
|
12423
|
-
* Gets metadata for files in a bucket with optional filtering and pagination
|
|
12424
|
-
*
|
|
12425
|
-
* The method returns either:
|
|
12426
|
-
* - A NonPaginatedResponse with items array (when no pagination parameters are provided)
|
|
12427
|
-
* - A PaginatedResponse with navigation cursors (when any pagination parameter is provided)
|
|
12428
|
-
*
|
|
12429
|
-
* @param bucketId - The ID of the bucket to get file metadata from
|
|
12430
|
-
* @param folderId - Required folder ID for organization unit context
|
|
12431
|
-
* @param options - Optional parameters for filtering, pagination and access URL generation
|
|
12432
|
-
* @returns Promise resolving to the list of file metadata in the bucket or paginated result
|
|
12433
|
-
*
|
|
12434
|
-
* @example
|
|
12435
|
-
* ```typescript
|
|
12436
|
-
* import { Buckets } from '@uipath/uipath-typescript/buckets';
|
|
12437
|
-
*
|
|
12438
|
-
* const buckets = new Buckets(sdk);
|
|
12439
|
-
*
|
|
12440
|
-
* // Get metadata for all files in a bucket
|
|
12441
|
-
* const fileMetadata = await buckets.getFileMetaData(123, 456);
|
|
12442
|
-
*
|
|
12443
|
-
* // Get file metadata with a specific prefix
|
|
12444
|
-
* const fileMetadata = await buckets.getFileMetaData(123, 456, {
|
|
12445
|
-
* prefix: '/folder1'
|
|
12446
|
-
* });
|
|
12447
|
-
*
|
|
12448
|
-
* // First page with pagination
|
|
12449
|
-
* const page1 = await buckets.getFileMetaData(123, 456, { pageSize: 10 });
|
|
12450
|
-
*
|
|
12451
|
-
* // Navigate using cursor
|
|
12452
|
-
* if (page1.hasNextPage) {
|
|
12453
|
-
* const page2 = await buckets.getFileMetaData(123, 456, { cursor: page1.nextCursor });
|
|
12454
|
-
* }
|
|
12455
|
-
* ```
|
|
12456
|
-
*/
|
|
12457
|
-
async getFileMetaData(bucketId, folderId, options) {
|
|
13298
|
+
async getFileMetaData(bucketId, optionsOrFolderId, legacyOptions) {
|
|
12458
13299
|
if (!bucketId) {
|
|
12459
13300
|
throw new ValidationError({ message: 'bucketId is required for getFileMetaData' });
|
|
12460
13301
|
}
|
|
12461
|
-
|
|
12462
|
-
|
|
13302
|
+
// Normalize the two overload forms into a single internal shape.
|
|
13303
|
+
let folderId;
|
|
13304
|
+
let folderKey;
|
|
13305
|
+
let folderPath;
|
|
13306
|
+
let restOptions;
|
|
13307
|
+
if (typeof optionsOrFolderId === 'number') {
|
|
13308
|
+
// Deprecated positional form: getFileMetaData(bucketId, folderId, options?)
|
|
13309
|
+
folderId = optionsOrFolderId;
|
|
13310
|
+
restOptions = (legacyOptions ?? {});
|
|
13311
|
+
}
|
|
13312
|
+
else {
|
|
13313
|
+
// Preferred form: getFileMetaData(bucketId, options?)
|
|
13314
|
+
const opts = optionsOrFolderId ?? {};
|
|
13315
|
+
({ folderId, folderKey, folderPath, ...restOptions } = opts);
|
|
12463
13316
|
}
|
|
13317
|
+
const headers = resolveFolderHeaders({
|
|
13318
|
+
folderId,
|
|
13319
|
+
folderKey,
|
|
13320
|
+
folderPath,
|
|
13321
|
+
resourceType: 'Buckets.getFileMetaData',
|
|
13322
|
+
fallbackFolderKey: this.config.folderKey,
|
|
13323
|
+
});
|
|
12464
13324
|
// Transformation function for blob items
|
|
12465
13325
|
const transformBlobItem = (item) => transformData(item, BucketMap);
|
|
12466
13326
|
return PaginationHelpers.getAll({
|
|
@@ -12476,93 +13336,97 @@ class BucketService extends FolderScopedService {
|
|
|
12476
13336
|
tokenParam: BUCKET_TOKEN_PARAMS.TOKEN_PARAM
|
|
12477
13337
|
}
|
|
12478
13338
|
},
|
|
12479
|
-
excludeFromPrefix: ['prefix'] // Bucket-specific param, not OData
|
|
12480
|
-
|
|
13339
|
+
excludeFromPrefix: ['prefix'], // Bucket-specific param, not OData
|
|
13340
|
+
headers,
|
|
13341
|
+
}, restOptions);
|
|
12481
13342
|
}
|
|
12482
|
-
|
|
12483
|
-
|
|
12484
|
-
|
|
12485
|
-
|
|
12486
|
-
|
|
12487
|
-
|
|
12488
|
-
|
|
12489
|
-
|
|
12490
|
-
|
|
12491
|
-
|
|
12492
|
-
|
|
12493
|
-
|
|
12494
|
-
|
|
12495
|
-
|
|
12496
|
-
|
|
12497
|
-
|
|
12498
|
-
|
|
12499
|
-
|
|
12500
|
-
|
|
12501
|
-
|
|
12502
|
-
*
|
|
12503
|
-
* // In Node env with Buffer
|
|
12504
|
-
* const buffer = Buffer.from('file content');
|
|
12505
|
-
* const result = await buckets.uploadFile({
|
|
12506
|
-
* bucketId: 123,
|
|
12507
|
-
* folderId: 456,
|
|
12508
|
-
* path: '/folder/example.txt',
|
|
12509
|
-
* content: buffer
|
|
12510
|
-
* });
|
|
12511
|
-
* ```
|
|
12512
|
-
*/
|
|
12513
|
-
async uploadFile(options) {
|
|
12514
|
-
const { bucketId, folderId, path, content } = options;
|
|
13343
|
+
async uploadFile(bucketIdOrOptions, path, content, options) {
|
|
13344
|
+
// Normalize the two overload forms into a single internal shape.
|
|
13345
|
+
let bucketId;
|
|
13346
|
+
let resolvedPath;
|
|
13347
|
+
let resolvedContent;
|
|
13348
|
+
let folderId;
|
|
13349
|
+
let folderKey;
|
|
13350
|
+
let folderPath;
|
|
13351
|
+
if (bucketIdOrOptions !== null && typeof bucketIdOrOptions === 'object') {
|
|
13352
|
+
// Deprecated options-only form: uploadFile({ bucketId, path, content, ... })
|
|
13353
|
+
({ bucketId, path: resolvedPath, content: resolvedContent, folderId, folderKey, folderPath } = bucketIdOrOptions);
|
|
13354
|
+
}
|
|
13355
|
+
else {
|
|
13356
|
+
// Preferred positional form: uploadFile(bucketId, path, content, options?)
|
|
13357
|
+
bucketId = bucketIdOrOptions;
|
|
13358
|
+
resolvedPath = path;
|
|
13359
|
+
resolvedContent = content;
|
|
13360
|
+
const opts = options ?? {};
|
|
13361
|
+
({ folderId, folderKey, folderPath } = opts);
|
|
13362
|
+
}
|
|
12515
13363
|
if (!bucketId) {
|
|
12516
13364
|
throw new ValidationError({ message: 'bucketId is required for uploadFile' });
|
|
12517
13365
|
}
|
|
12518
|
-
if (!
|
|
12519
|
-
throw new ValidationError({ message: 'folderId is required for uploadFile' });
|
|
12520
|
-
}
|
|
12521
|
-
if (!path) {
|
|
13366
|
+
if (!resolvedPath) {
|
|
12522
13367
|
throw new ValidationError({ message: 'path is required for uploadFile' });
|
|
12523
13368
|
}
|
|
12524
|
-
if (!
|
|
13369
|
+
if (!resolvedContent) {
|
|
12525
13370
|
throw new ValidationError({ message: 'content is required for uploadFile' });
|
|
12526
13371
|
}
|
|
13372
|
+
const headers = resolveFolderHeaders({
|
|
13373
|
+
folderId,
|
|
13374
|
+
folderKey,
|
|
13375
|
+
folderPath,
|
|
13376
|
+
resourceType: 'Buckets.uploadFile',
|
|
13377
|
+
fallbackFolderKey: this.config.folderKey,
|
|
13378
|
+
});
|
|
12527
13379
|
const uriResponse = await this._getWriteUri({
|
|
12528
13380
|
bucketId,
|
|
12529
|
-
|
|
12530
|
-
|
|
13381
|
+
path: resolvedPath,
|
|
13382
|
+
headers,
|
|
12531
13383
|
});
|
|
12532
13384
|
// Upload file to the provided URI
|
|
12533
|
-
const response = await this._uploadToUri(uriResponse,
|
|
13385
|
+
const response = await this._uploadToUri(uriResponse, resolvedContent);
|
|
12534
13386
|
return {
|
|
12535
13387
|
success: response.status >= 200 && response.status < 300,
|
|
12536
13388
|
statusCode: response.status
|
|
12537
13389
|
};
|
|
12538
13390
|
}
|
|
12539
|
-
|
|
12540
|
-
|
|
12541
|
-
|
|
12542
|
-
|
|
12543
|
-
|
|
12544
|
-
|
|
12545
|
-
|
|
12546
|
-
|
|
12547
|
-
|
|
12548
|
-
|
|
12549
|
-
|
|
12550
|
-
|
|
12551
|
-
|
|
12552
|
-
|
|
12553
|
-
|
|
12554
|
-
|
|
12555
|
-
|
|
12556
|
-
|
|
12557
|
-
|
|
12558
|
-
|
|
12559
|
-
|
|
12560
|
-
|
|
13391
|
+
async getReadUri(bucketIdOrOptions, path, options) {
|
|
13392
|
+
// Normalize the two overload forms into a single internal shape.
|
|
13393
|
+
let bucketId;
|
|
13394
|
+
let resolvedPath;
|
|
13395
|
+
let folderId;
|
|
13396
|
+
let folderKey;
|
|
13397
|
+
let folderPath;
|
|
13398
|
+
let expiryInMinutes;
|
|
13399
|
+
let restOptions;
|
|
13400
|
+
if (bucketIdOrOptions !== null && typeof bucketIdOrOptions === 'object') {
|
|
13401
|
+
// Deprecated options-only form: getReadUri({ bucketId, path, ... })
|
|
13402
|
+
const { bucketId: bid, path: p, expiryInMinutes: e, folderId: fid, folderKey: fkey, folderPath: fpath, ...rest } = bucketIdOrOptions;
|
|
13403
|
+
bucketId = bid;
|
|
13404
|
+
resolvedPath = p;
|
|
13405
|
+
expiryInMinutes = e;
|
|
13406
|
+
folderId = fid;
|
|
13407
|
+
folderKey = fkey;
|
|
13408
|
+
folderPath = fpath;
|
|
13409
|
+
restOptions = rest;
|
|
13410
|
+
}
|
|
13411
|
+
else {
|
|
13412
|
+
// Preferred positional form: getReadUri(bucketId, path, options?)
|
|
13413
|
+
bucketId = bucketIdOrOptions;
|
|
13414
|
+
resolvedPath = path;
|
|
13415
|
+
const opts = options ?? {};
|
|
13416
|
+
({ expiryInMinutes, folderId, folderKey, folderPath, ...restOptions } = opts);
|
|
13417
|
+
}
|
|
13418
|
+
const headers = resolveFolderHeaders({
|
|
13419
|
+
folderId,
|
|
13420
|
+
folderKey,
|
|
13421
|
+
folderPath,
|
|
13422
|
+
resourceType: 'Buckets.getReadUri',
|
|
13423
|
+
fallbackFolderKey: this.config.folderKey,
|
|
13424
|
+
});
|
|
12561
13425
|
const queryOptions = {
|
|
12562
13426
|
expiryInMinutes,
|
|
12563
13427
|
...addPrefixToKeys(restOptions, ODATA_PREFIX, Object.keys(restOptions))
|
|
12564
13428
|
};
|
|
12565
|
-
return this._getUri(BUCKET_ENDPOINTS.GET_READ_URI(bucketId), bucketId,
|
|
13429
|
+
return this._getUri(BUCKET_ENDPOINTS.GET_READ_URI(bucketId), bucketId, resolvedPath, headers, queryOptions);
|
|
12566
13430
|
}
|
|
12567
13431
|
/**
|
|
12568
13432
|
* Uploads content to the provided URI
|
|
@@ -12592,23 +13456,18 @@ class BucketService extends FolderScopedService {
|
|
|
12592
13456
|
* Private method to handle common URI request logic
|
|
12593
13457
|
* @param endpoint - The API endpoint to call
|
|
12594
13458
|
* @param bucketId - The bucket ID
|
|
12595
|
-
* @param folderId - The folder ID
|
|
12596
13459
|
* @param path - The file path
|
|
13460
|
+
* @param headers - Pre-built folder-context headers (built via `resolveFolderHeaders`)
|
|
12597
13461
|
* @param queryOptions - Additional query parameters
|
|
12598
13462
|
* @returns Promise resolving to blob file access information
|
|
12599
13463
|
*/
|
|
12600
|
-
async _getUri(endpoint, bucketId,
|
|
13464
|
+
async _getUri(endpoint, bucketId, path, headers, queryOptions = {}) {
|
|
12601
13465
|
if (!bucketId) {
|
|
12602
13466
|
throw new ValidationError({ message: 'bucketId is required for getUri' });
|
|
12603
13467
|
}
|
|
12604
|
-
if (!folderId) {
|
|
12605
|
-
throw new ValidationError({ message: 'folderId is required for getUri' });
|
|
12606
|
-
}
|
|
12607
13468
|
if (!path) {
|
|
12608
13469
|
throw new ValidationError({ message: 'path is required for getUri' });
|
|
12609
13470
|
}
|
|
12610
|
-
// Create headers with required folder ID
|
|
12611
|
-
const headers = createHeaders({ [FOLDER_ID]: folderId });
|
|
12612
13471
|
// Filter out undefined values and build query params
|
|
12613
13472
|
const queryParams = filterUndefined({
|
|
12614
13473
|
path,
|
|
@@ -12743,16 +13602,16 @@ class BucketService extends FolderScopedService {
|
|
|
12743
13602
|
/**
|
|
12744
13603
|
* Gets a direct upload URL for a file in the bucket
|
|
12745
13604
|
*
|
|
12746
|
-
* @param options - Contains bucketId,
|
|
13605
|
+
* @param options - Contains bucketId, file path, optional expiry time, and pre-built folder-context headers
|
|
12747
13606
|
* @returns Promise resolving to blob file access information
|
|
12748
13607
|
*/
|
|
12749
13608
|
async _getWriteUri(options) {
|
|
12750
|
-
const { bucketId,
|
|
13609
|
+
const { bucketId, path, expiryInMinutes, headers, ...restOptions } = options;
|
|
12751
13610
|
const queryOptions = {
|
|
12752
13611
|
expiryInMinutes,
|
|
12753
13612
|
...addPrefixToKeys(restOptions, ODATA_PREFIX, Object.keys(restOptions))
|
|
12754
13613
|
};
|
|
12755
|
-
return this._getUri(BUCKET_ENDPOINTS.GET_WRITE_URI(bucketId), bucketId,
|
|
13614
|
+
return this._getUri(BUCKET_ENDPOINTS.GET_WRITE_URI(bucketId), bucketId, path, headers, queryOptions);
|
|
12756
13615
|
}
|
|
12757
13616
|
}
|
|
12758
13617
|
__decorate([
|
|
@@ -14199,6 +15058,57 @@ var FeedbackStatus;
|
|
|
14199
15058
|
FeedbackStatus[FeedbackStatus["Dismissed"] = 2] = "Dismissed";
|
|
14200
15059
|
})(FeedbackStatus || (FeedbackStatus = {}));
|
|
14201
15060
|
|
|
15061
|
+
/**
|
|
15062
|
+
* Columns available for ordering results.
|
|
15063
|
+
*/
|
|
15064
|
+
var AgentListSortColumn;
|
|
15065
|
+
(function (AgentListSortColumn) {
|
|
15066
|
+
AgentListSortColumn["AgentName"] = "AgentName";
|
|
15067
|
+
AgentListSortColumn["ParentProcess"] = "ParentProcess";
|
|
15068
|
+
AgentListSortColumn["LastRun"] = "LastRun";
|
|
15069
|
+
AgentListSortColumn["HealthScore"] = "HealthScore";
|
|
15070
|
+
AgentListSortColumn["LastIncident"] = "LastIncident";
|
|
15071
|
+
AgentListSortColumn["FolderName"] = "FolderName";
|
|
15072
|
+
/** Quantity of AGU (Agent Units) consumed */
|
|
15073
|
+
AgentListSortColumn["QuantityAGU"] = "QuantityAGU";
|
|
15074
|
+
/** Quantity of PLTU (Platform Units) consumed */
|
|
15075
|
+
AgentListSortColumn["QuantityPLTU"] = "QuantityPLTU";
|
|
15076
|
+
AgentListSortColumn["FolderPath"] = "FolderPath";
|
|
15077
|
+
})(AgentListSortColumn || (AgentListSortColumn = {}));
|
|
15078
|
+
/**
|
|
15079
|
+
* Columns available for ordering / grouping the agent errors list.
|
|
15080
|
+
*/
|
|
15081
|
+
var AgentErrorSortColumn;
|
|
15082
|
+
(function (AgentErrorSortColumn) {
|
|
15083
|
+
AgentErrorSortColumn["AgentId"] = "AgentId";
|
|
15084
|
+
AgentErrorSortColumn["AgentName"] = "AgentName";
|
|
15085
|
+
AgentErrorSortColumn["ParentProcessName"] = "ParentProcessName";
|
|
15086
|
+
AgentErrorSortColumn["ErrorTitle"] = "ErrorTitle";
|
|
15087
|
+
AgentErrorSortColumn["FirstSeenStartTime"] = "FirstSeenStartTime";
|
|
15088
|
+
AgentErrorSortColumn["ExecutionCount"] = "ExecutionCount";
|
|
15089
|
+
AgentErrorSortColumn["Type"] = "Type";
|
|
15090
|
+
AgentErrorSortColumn["FirstSeenFolderName"] = "FirstSeenFolderName";
|
|
15091
|
+
AgentErrorSortColumn["FirstSeenFolderPath"] = "FirstSeenFolderPath";
|
|
15092
|
+
AgentErrorSortColumn["LastSeenStartTime"] = "LastSeenStartTime";
|
|
15093
|
+
AgentErrorSortColumn["LastSeenFolderName"] = "LastSeenFolderName";
|
|
15094
|
+
AgentErrorSortColumn["LastSeenFolderPath"] = "LastSeenFolderPath";
|
|
15095
|
+
})(AgentErrorSortColumn || (AgentErrorSortColumn = {}));
|
|
15096
|
+
|
|
15097
|
+
/**
|
|
15098
|
+
* Types for the Agent Memory metrics service.
|
|
15099
|
+
*/
|
|
15100
|
+
/**
|
|
15101
|
+
* Execution kind to filter Agent Memory queries by. Omit to include both
|
|
15102
|
+
* Debug and Runtime executions.
|
|
15103
|
+
*/
|
|
15104
|
+
var AgentMemoryExecutionType;
|
|
15105
|
+
(function (AgentMemoryExecutionType) {
|
|
15106
|
+
/** Executions produced during agent debugging sessions. */
|
|
15107
|
+
AgentMemoryExecutionType["Debug"] = "Debug";
|
|
15108
|
+
/** Executions produced during production runtime. */
|
|
15109
|
+
AgentMemoryExecutionType["Runtime"] = "Runtime";
|
|
15110
|
+
})(AgentMemoryExecutionType || (AgentMemoryExecutionType = {}));
|
|
15111
|
+
|
|
14202
15112
|
// Auto-generated from the OpenAPI spec — do not edit manually.
|
|
14203
15113
|
var DocumentActionPriority;
|
|
14204
15114
|
(function (DocumentActionPriority) {
|
|
@@ -14470,6 +15380,103 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
14470
15380
|
get WordGroupType () { return WordGroupType; }
|
|
14471
15381
|
});
|
|
14472
15382
|
|
|
15383
|
+
/**
|
|
15384
|
+
* Governance Service Types
|
|
15385
|
+
*
|
|
15386
|
+
* Public types exposed via `@uipath/uipath-typescript/governance`.
|
|
15387
|
+
*/
|
|
15388
|
+
var PolicyEvaluationResult;
|
|
15389
|
+
(function (PolicyEvaluationResult) {
|
|
15390
|
+
/** Active policy permitted the action. */
|
|
15391
|
+
PolicyEvaluationResult["Allow"] = "Allow";
|
|
15392
|
+
/** Active policy blocked the action. */
|
|
15393
|
+
PolicyEvaluationResult["Deny"] = "Deny";
|
|
15394
|
+
/** Simulated (NoOp) policy would have permitted the action. */
|
|
15395
|
+
PolicyEvaluationResult["SimulatedAllow"] = "SimulatedAllow";
|
|
15396
|
+
/** Simulated (NoOp) policy would have blocked the action. */
|
|
15397
|
+
PolicyEvaluationResult["SimulatedDeny"] = "SimulatedDeny";
|
|
15398
|
+
})(PolicyEvaluationResult || (PolicyEvaluationResult = {}));
|
|
15399
|
+
|
|
15400
|
+
/** Status of a span: whether it completed successfully, with an error, or was not set. */
|
|
15401
|
+
var SpanStatus;
|
|
15402
|
+
(function (SpanStatus) {
|
|
15403
|
+
SpanStatus["Unset"] = "Unset";
|
|
15404
|
+
SpanStatus["Ok"] = "Ok";
|
|
15405
|
+
SpanStatus["Error"] = "Error";
|
|
15406
|
+
/** Span is still in progress. */
|
|
15407
|
+
SpanStatus["Running"] = "Running";
|
|
15408
|
+
/** Span data is hidden from the caller due to tenant/folder permission rules. */
|
|
15409
|
+
SpanStatus["Restricted"] = "Restricted";
|
|
15410
|
+
/** Span was cancelled before completion. */
|
|
15411
|
+
SpanStatus["Cancelled"] = "Cancelled";
|
|
15412
|
+
})(SpanStatus || (SpanStatus = {}));
|
|
15413
|
+
/** Platform source that produced the span. */
|
|
15414
|
+
var SpanSource;
|
|
15415
|
+
(function (SpanSource) {
|
|
15416
|
+
SpanSource["Testing"] = "Testing";
|
|
15417
|
+
SpanSource["Agents"] = "Agents";
|
|
15418
|
+
SpanSource["ProcessOrchestration"] = "ProcessOrchestration";
|
|
15419
|
+
SpanSource["ApiWorkflows"] = "ApiWorkflows";
|
|
15420
|
+
SpanSource["Robots"] = "Robots";
|
|
15421
|
+
SpanSource["ConversationalAgentsService"] = "ConversationalAgentsService";
|
|
15422
|
+
SpanSource["IntegrationServiceTrigger"] = "IntegrationServiceTrigger";
|
|
15423
|
+
SpanSource["Playground"] = "Playground";
|
|
15424
|
+
SpanSource["Governance"] = "Governance";
|
|
15425
|
+
/** Intelligent Experience Platform — unstructured and complex document processing source. */
|
|
15426
|
+
SpanSource["IXPUnstructuredAndComplexDocuments"] = "IXPUnstructuredAndComplexDocuments";
|
|
15427
|
+
/** Agents authored in code (as opposed to visual/no-code designers). */
|
|
15428
|
+
SpanSource["CodedAgents"] = "CodedAgents";
|
|
15429
|
+
/** Intelligent Experience Platform — communications mining source. */
|
|
15430
|
+
SpanSource["IXPCommunicationsMining"] = "IXPCommunicationsMining";
|
|
15431
|
+
/** UiPath Context Grounding — span produced by the Enterprise Context Service for RAG/knowledge-base operations. */
|
|
15432
|
+
SpanSource["EnterpriseContextService"] = "EnterpriseContextService";
|
|
15433
|
+
/** Model Context Protocol — span produced by an MCP server integration. */
|
|
15434
|
+
SpanSource["MCP"] = "MCP";
|
|
15435
|
+
/** Agent-to-Agent — span produced by an A2A protocol call between agents. */
|
|
15436
|
+
SpanSource["A2A"] = "A2A";
|
|
15437
|
+
/** Serverless — span produced by a serverless function execution. */
|
|
15438
|
+
SpanSource["Serverless"] = "Serverless";
|
|
15439
|
+
})(SpanSource || (SpanSource = {}));
|
|
15440
|
+
/** Minimum severity level of events captured in the span. */
|
|
15441
|
+
var SpanVerbosityLevel;
|
|
15442
|
+
(function (SpanVerbosityLevel) {
|
|
15443
|
+
SpanVerbosityLevel["Verbose"] = "Verbose";
|
|
15444
|
+
SpanVerbosityLevel["Trace"] = "Trace";
|
|
15445
|
+
SpanVerbosityLevel["Information"] = "Information";
|
|
15446
|
+
SpanVerbosityLevel["Warning"] = "Warning";
|
|
15447
|
+
SpanVerbosityLevel["Error"] = "Error";
|
|
15448
|
+
SpanVerbosityLevel["Critical"] = "Critical";
|
|
15449
|
+
SpanVerbosityLevel["Off"] = "Off";
|
|
15450
|
+
})(SpanVerbosityLevel || (SpanVerbosityLevel = {}));
|
|
15451
|
+
/** Whether the span was produced during a debug or production runtime. */
|
|
15452
|
+
var SpanExecutionType;
|
|
15453
|
+
(function (SpanExecutionType) {
|
|
15454
|
+
SpanExecutionType["Debug"] = "Debug";
|
|
15455
|
+
SpanExecutionType["Runtime"] = "Runtime";
|
|
15456
|
+
})(SpanExecutionType || (SpanExecutionType = {}));
|
|
15457
|
+
/** Whether the caller has permission to read this span's data. */
|
|
15458
|
+
var SpanPermissionStatus;
|
|
15459
|
+
(function (SpanPermissionStatus) {
|
|
15460
|
+
SpanPermissionStatus["Allow"] = "Allow";
|
|
15461
|
+
/** Some span fields are redacted due to permission constraints (e.g. attributes visible but payload hidden). */
|
|
15462
|
+
SpanPermissionStatus["PartialBlock"] = "PartialBlock";
|
|
15463
|
+
SpanPermissionStatus["Block"] = "Block";
|
|
15464
|
+
})(SpanPermissionStatus || (SpanPermissionStatus = {}));
|
|
15465
|
+
/** Storage provider that created or manages the attachment. */
|
|
15466
|
+
var SpanAttachmentProvider;
|
|
15467
|
+
(function (SpanAttachmentProvider) {
|
|
15468
|
+
SpanAttachmentProvider["Orchestrator"] = "Orchestrator";
|
|
15469
|
+
/** Span attachment stored by the observability platform. */
|
|
15470
|
+
SpanAttachmentProvider["LLMOps"] = "LLMOps";
|
|
15471
|
+
})(SpanAttachmentProvider || (SpanAttachmentProvider = {}));
|
|
15472
|
+
/** Whether the attachment is an input, output, or neither. */
|
|
15473
|
+
var SpanAttachmentDirection;
|
|
15474
|
+
(function (SpanAttachmentDirection) {
|
|
15475
|
+
SpanAttachmentDirection["None"] = "None";
|
|
15476
|
+
SpanAttachmentDirection["In"] = "In";
|
|
15477
|
+
SpanAttachmentDirection["Out"] = "Out";
|
|
15478
|
+
})(SpanAttachmentDirection || (SpanAttachmentDirection = {}));
|
|
15479
|
+
|
|
14473
15480
|
/**
|
|
14474
15481
|
* Asset resolution utilities for UiPath Coded Apps
|
|
14475
15482
|
*
|
|
@@ -14545,4 +15552,4 @@ function getAppBase() {
|
|
|
14545
15552
|
return getMetaTagContent(UiPathMetaTags.APP_BASE) || '/';
|
|
14546
15553
|
}
|
|
14547
15554
|
|
|
14548
|
-
export { AgentMap, AssetValueScope, AssetValueType, AuthenticationError, AuthorizationError, BucketOptions, CitationErrorType, ConversationGetAllFilterMap, ConversationMap, DEFAULT_ITEMS_FIELD, DEFAULT_PAGE_SIZE, DEFAULT_TOTAL_COUNT_FIELD, DataDirectionType, DebugMode, index as DuFramework, EntityAggregateFunction, EntityFieldDataType, EntityType, ErrorType, EscalationActionType, EscalationRecipientScope, EscalationTriggerType, ExchangeMap, FeedbackRating, FeedbackStatus, FieldDisplayType, HttpStatus, InputStreamSpeechSensitivity, InstanceFinalStatus, InstanceStatus, InterruptType, JobPriority, JobSourceType, JobState, JobSubState, JobType, JoinType, LogicalOperator$1 as LogicalOperator, MAX_PAGE_SIZE, MessageMap, MessageRole, NetworkError, NotFoundError, PackageSourceType, PackageType, ProcessIncidentSeverity, ProcessIncidentStatus, ProcessIncidentType, QueryFilterOperator, RateLimitError, ReferenceType, RemoteControlAccess, RobotSize, RuntimeType, SLADurationUnit, ServerError, ServerlessJobType, SlaSummaryStatus, SortOrder, StageTaskType, StartStrategy, StopStrategy, TargetFramework, TaskActivityType, TaskPriority, TaskSlaCriteria, TaskSlaStatus, TaskSourceName, TaskStatus, TaskType, TaskUserType, TimeInterval, UiPath, UiPathError, UiPathMetaTags, UserSettingsMap, ValidationError, createAgentWithMethods, createCaseInstanceWithMethods, createConversationWithMethods, createEntityWithMethods, createJobWithMethods, createProcessInstanceWithMethods, createProcessWithMethods, createTaskWithMethods, getAppBase, getAsset, getErrorDetails, getLimitedPageSize, isAuthenticationError, isAuthorizationError, isNetworkError, isNotFoundError, isRateLimitError, isServerError, isUiPathError, isValidationError, loadFromMetaTags, telemetryClient, track, trackEvent };
|
|
15555
|
+
export { AgentErrorSortColumn, AgentListSortColumn, AgentMap, AgentMemoryExecutionType, SpanExecutionType as AgentTraceExecutionType, 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, SpanAttachmentDirection, SpanAttachmentProvider, SpanExecutionType, SpanPermissionStatus, SpanSource, SpanStatus, SpanVerbosityLevel, StageTaskType, StartStrategy, StopStrategy, TargetFramework, TaskActivityType, TaskAssignmentCriteria, 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 };
|