@uipath/uipath-typescript 1.4.2 → 1.5.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/README.md +7 -1
- package/dist/agent-memory/index.d.ts +4 -1
- package/dist/agents/index.cjs +341 -6
- package/dist/agents/index.d.ts +717 -16
- package/dist/agents/index.mjs +342 -7
- package/dist/assets/index.cjs +132 -15
- package/dist/assets/index.d.ts +12 -1
- package/dist/assets/index.mjs +132 -15
- package/dist/attachments/index.cjs +120 -12
- package/dist/attachments/index.mjs +120 -12
- package/dist/buckets/index.cjs +136 -15
- package/dist/buckets/index.d.ts +12 -1
- package/dist/buckets/index.mjs +136 -15
- package/dist/cases/index.cjs +1203 -938
- package/dist/cases/index.d.ts +325 -45
- package/dist/cases/index.mjs +1203 -938
- package/dist/conversational-agent/index.cjs +48 -10
- package/dist/conversational-agent/index.d.ts +117 -6
- package/dist/conversational-agent/index.mjs +48 -10
- package/dist/core/index.cjs +1 -1
- package/dist/core/index.mjs +1 -1
- package/dist/entities/index.cjs +448 -9
- package/dist/entities/index.d.ts +441 -1
- package/dist/entities/index.mjs +447 -10
- package/dist/feedback/index.cjs +25 -9
- package/dist/feedback/index.mjs +25 -9
- package/dist/index.cjs +1281 -330
- package/dist/index.d.ts +1988 -143
- package/dist/index.mjs +1282 -331
- package/dist/index.umd.js +1230 -279
- package/dist/jobs/index.cjs +141 -19
- package/dist/jobs/index.d.ts +22 -6
- package/dist/jobs/index.mjs +141 -19
- package/dist/maestro-processes/index.cjs +553 -354
- package/dist/maestro-processes/index.d.ts +376 -47
- package/dist/maestro-processes/index.mjs +553 -354
- package/dist/notifications/index.cjs +2012 -0
- package/dist/notifications/index.d.ts +615 -0
- package/dist/notifications/index.mjs +2010 -0
- package/dist/processes/index.cjs +118 -18
- package/dist/processes/index.d.ts +18 -2
- package/dist/processes/index.mjs +118 -18
- package/dist/queues/index.cjs +131 -14
- package/dist/queues/index.d.ts +12 -1
- package/dist/queues/index.mjs +131 -14
- package/dist/tasks/index.cjs +125 -13
- package/dist/tasks/index.d.ts +4 -1
- package/dist/tasks/index.mjs +125 -13
- package/dist/traces/index.cjs +220 -6
- package/dist/traces/index.d.ts +360 -25
- package/dist/traces/index.mjs +221 -7
- package/package.json +14 -4
package/dist/agents/index.mjs
CHANGED
|
@@ -1602,6 +1602,25 @@ class BaseService {
|
|
|
1602
1602
|
}
|
|
1603
1603
|
_BaseService_apiClient = new WeakMap();
|
|
1604
1604
|
|
|
1605
|
+
/**
|
|
1606
|
+
* Common enum for job state used across services
|
|
1607
|
+
*/
|
|
1608
|
+
var JobState;
|
|
1609
|
+
(function (JobState) {
|
|
1610
|
+
JobState["Pending"] = "Pending";
|
|
1611
|
+
JobState["Running"] = "Running";
|
|
1612
|
+
JobState["Stopping"] = "Stopping";
|
|
1613
|
+
JobState["Terminating"] = "Terminating";
|
|
1614
|
+
JobState["Faulted"] = "Faulted";
|
|
1615
|
+
JobState["Successful"] = "Successful";
|
|
1616
|
+
JobState["Stopped"] = "Stopped";
|
|
1617
|
+
JobState["Suspended"] = "Suspended";
|
|
1618
|
+
JobState["Resumed"] = "Resumed";
|
|
1619
|
+
JobState["Cancelled"] = "Cancelled";
|
|
1620
|
+
/** Server-side fallback for an unrecognized or missing job state. */
|
|
1621
|
+
JobState["Unknown"] = "Unknown";
|
|
1622
|
+
})(JobState || (JobState = {}));
|
|
1623
|
+
|
|
1605
1624
|
/**
|
|
1606
1625
|
* Base path constants for different services
|
|
1607
1626
|
*/
|
|
@@ -1617,10 +1636,20 @@ const AGENTS_ENDPOINTS = {
|
|
|
1617
1636
|
GET_INCIDENTS: `${INSIGHTS_RTM_BASE}/Agents/incidents`,
|
|
1618
1637
|
/** Time-series of error counts grouped by agent over the requested window. */
|
|
1619
1638
|
GET_ERRORS_TIMELINE: `${INSIGHTS_RTM_BASE}/Agents/errors`,
|
|
1620
|
-
/** Time-series of
|
|
1639
|
+
/** Time-series of Agent Units consumption over the requested window. */
|
|
1621
1640
|
GET_CONSUMPTION_TIMELINE: `${INSIGHTS_RTM_BASE}/Agents/consumptionTimeline`,
|
|
1622
1641
|
/** Time-series of agent latency (per-percentile) over the requested window. */
|
|
1623
1642
|
GET_LATENCY_TIMELINE: `${INSIGHTS_RTM_BASE}/Agents/latencyTimeline`,
|
|
1643
|
+
/** Top-N agents by error count over the requested window. */
|
|
1644
|
+
GET_TOP_ERROR_COUNT: `${INSIGHTS_RTM_BASE}/Agents/topErroredAgents`,
|
|
1645
|
+
/** Top-N agents by unit consumption over the requested window. */
|
|
1646
|
+
GET_TOP_CONSUMPTION: `${INSIGHTS_RTM_BASE}/Agents/consumption`,
|
|
1647
|
+
/** Distribution of incidents across types (errors, escalations, policy). */
|
|
1648
|
+
GET_INCIDENT_DISTRIBUTION: `${INSIGHTS_RTM_BASE}/Agents/incidentDistribution`,
|
|
1649
|
+
/** Aggregate per-agent and overall job/success/duration summary over the requested window. */
|
|
1650
|
+
GET_SUMMARY: `${INSIGHTS_RTM_BASE}/Agents/summary`,
|
|
1651
|
+
/** Aggregate Agent Units and Platform Units consumption per agent over the requested window. */
|
|
1652
|
+
GET_UNIT_CONSUMPTION_SUMMARY: `${INSIGHTS_RTM_BASE}/Agents/summary/unit-consumption`,
|
|
1624
1653
|
};
|
|
1625
1654
|
|
|
1626
1655
|
/**
|
|
@@ -1652,6 +1681,33 @@ const sdkClient = getOrCreateClient(CLOUD_ROLE_NAME);
|
|
|
1652
1681
|
const track = createTrack(sdkClient);
|
|
1653
1682
|
createTrackEvent(sdkClient);
|
|
1654
1683
|
|
|
1684
|
+
const JOB_STATUS_ALIASES = {
|
|
1685
|
+
Success: JobState.Successful,
|
|
1686
|
+
};
|
|
1687
|
+
const VALID_JOB_STATES = new Set(Object.values(JobState));
|
|
1688
|
+
/**
|
|
1689
|
+
* Permissively maps a raw `lastJobStatus` string to a {@link JobState}. Known
|
|
1690
|
+
* aliases are translated first, canonical values pass through, and anything
|
|
1691
|
+
* unrecognized falls back to {@link JobState.Unknown} rather than throwing.
|
|
1692
|
+
*/
|
|
1693
|
+
function toJobState(raw) {
|
|
1694
|
+
if (Object.prototype.hasOwnProperty.call(JOB_STATUS_ALIASES, raw))
|
|
1695
|
+
return JOB_STATUS_ALIASES[raw];
|
|
1696
|
+
if (VALID_JOB_STATES.has(raw))
|
|
1697
|
+
return raw;
|
|
1698
|
+
return JobState.Unknown;
|
|
1699
|
+
}
|
|
1700
|
+
/**
|
|
1701
|
+
* Transforms a raw summary period into the public shape, normalizing every
|
|
1702
|
+
* agent's raw `lastJobStatus` string to a {@link JobState}. Tolerates a missing
|
|
1703
|
+
* `agents` array (treated as empty).
|
|
1704
|
+
*/
|
|
1705
|
+
function normalizeSummaryPeriod(period) {
|
|
1706
|
+
return {
|
|
1707
|
+
...period,
|
|
1708
|
+
agents: (period.agents ?? []).map((agent) => ({ ...agent, lastJobStatus: toJobState(agent.lastJobStatus) })),
|
|
1709
|
+
};
|
|
1710
|
+
}
|
|
1655
1711
|
/**
|
|
1656
1712
|
* Service for interacting with the UiPath Agents API.
|
|
1657
1713
|
*/
|
|
@@ -1833,7 +1889,7 @@ class AgentService extends BaseService {
|
|
|
1833
1889
|
return response.data.data;
|
|
1834
1890
|
}
|
|
1835
1891
|
/**
|
|
1836
|
-
* Retrieves a time-series of
|
|
1892
|
+
* Retrieves a time-series of Agent Units consumption over the requested window.
|
|
1837
1893
|
*
|
|
1838
1894
|
* @param startTime - Inclusive lower bound for the query window
|
|
1839
1895
|
* @param endTime - Exclusive upper bound for the query window
|
|
@@ -1845,13 +1901,13 @@ class AgentService extends BaseService {
|
|
|
1845
1901
|
*
|
|
1846
1902
|
* const agents = new Agents(sdk);
|
|
1847
1903
|
*
|
|
1848
|
-
* //
|
|
1904
|
+
* // Agent Units consumption timeline in May 2025
|
|
1849
1905
|
* const result = await agents.getConsumptionTimeline(
|
|
1850
1906
|
* new Date('2025-05-01T00:00:00Z'),
|
|
1851
1907
|
* new Date('2025-06-01T00:00:00Z'),
|
|
1852
1908
|
* );
|
|
1853
1909
|
* result.forEach((point) => {
|
|
1854
|
-
* console.log(`${point.timeSlice}: ${point.aguConsumption}
|
|
1910
|
+
* console.log(`${point.timeSlice}: ${point.aguConsumption} Agent Units`);
|
|
1855
1911
|
* });
|
|
1856
1912
|
* ```
|
|
1857
1913
|
* @example
|
|
@@ -1913,6 +1969,246 @@ class AgentService extends BaseService {
|
|
|
1913
1969
|
const response = await this.post(AGENTS_ENDPOINTS.GET_LATENCY_TIMELINE, body);
|
|
1914
1970
|
return response.data.data;
|
|
1915
1971
|
}
|
|
1972
|
+
/**
|
|
1973
|
+
* Retrieves the top-N agents ranked by error count over the requested window.
|
|
1974
|
+
*
|
|
1975
|
+
* @param startTime - Inclusive lower bound for the query window
|
|
1976
|
+
* @param endTime - Exclusive upper bound for the query window
|
|
1977
|
+
* @param options - Optional filters
|
|
1978
|
+
* @returns Promise resolving to {@link AgentGetTopErrorCountResponse}
|
|
1979
|
+
* @example
|
|
1980
|
+
* ```typescript
|
|
1981
|
+
* import { Agents } from '@uipath/uipath-typescript/agents';
|
|
1982
|
+
*
|
|
1983
|
+
* const agents = new Agents(sdk);
|
|
1984
|
+
*
|
|
1985
|
+
* // Top agents by error count in May 2025
|
|
1986
|
+
* const result = await agents.getTopErrorCount(
|
|
1987
|
+
* new Date('2025-05-01T00:00:00Z'),
|
|
1988
|
+
* new Date('2025-06-01T00:00:00Z'),
|
|
1989
|
+
* );
|
|
1990
|
+
* result.data.forEach((agent) => {
|
|
1991
|
+
* console.log(`${agent.name}: ${agent.count} errors`);
|
|
1992
|
+
* });
|
|
1993
|
+
* ```
|
|
1994
|
+
* @example
|
|
1995
|
+
* ```typescript
|
|
1996
|
+
* // Scope to specific folders and top 5 agents
|
|
1997
|
+
* const result = await agents.getTopErrorCount(
|
|
1998
|
+
* new Date('2025-05-01T00:00:00Z'),
|
|
1999
|
+
* new Date('2025-06-01T00:00:00Z'),
|
|
2000
|
+
* {
|
|
2001
|
+
* folderKeys: ['<folderKey1>'],
|
|
2002
|
+
* limit: 5,
|
|
2003
|
+
* },
|
|
2004
|
+
* );
|
|
2005
|
+
* ```
|
|
2006
|
+
*/
|
|
2007
|
+
async getTopErrorCount(startTime, endTime, options) {
|
|
2008
|
+
const body = this.buildAgentFilterBody(startTime, endTime, options);
|
|
2009
|
+
const response = await this.post(AGENTS_ENDPOINTS.GET_TOP_ERROR_COUNT, body);
|
|
2010
|
+
return response.data;
|
|
2011
|
+
}
|
|
2012
|
+
/**
|
|
2013
|
+
* Retrieves the top-N agents ranked by unit consumption over the requested window.
|
|
2014
|
+
*
|
|
2015
|
+
* @param startTime - Inclusive lower bound for the query window
|
|
2016
|
+
* @param endTime - Exclusive upper bound for the query window
|
|
2017
|
+
* @param options - Optional filters
|
|
2018
|
+
* @returns Promise resolving to {@link AgentGetTopConsumptionResponse}
|
|
2019
|
+
* @example
|
|
2020
|
+
* ```typescript
|
|
2021
|
+
* import { Agents } from '@uipath/uipath-typescript/agents';
|
|
2022
|
+
*
|
|
2023
|
+
* const agents = new Agents(sdk);
|
|
2024
|
+
*
|
|
2025
|
+
* // Top agents by consumption in May 2025
|
|
2026
|
+
* const result = await agents.getTopConsumption(
|
|
2027
|
+
* new Date('2025-05-01T00:00:00Z'),
|
|
2028
|
+
* new Date('2025-06-01T00:00:00Z'),
|
|
2029
|
+
* );
|
|
2030
|
+
* console.log(`Total consumed: ${result.totalConsumed}`);
|
|
2031
|
+
* result.agents.forEach((agent) => {
|
|
2032
|
+
* console.log(`${agent.agentName}: ${agent.consumedQuantity}`);
|
|
2033
|
+
* });
|
|
2034
|
+
* ```
|
|
2035
|
+
* @example
|
|
2036
|
+
* ```typescript
|
|
2037
|
+
* import { Agents, AgentType } from '@uipath/uipath-typescript/agents';
|
|
2038
|
+
*
|
|
2039
|
+
* const agents = new Agents(sdk);
|
|
2040
|
+
*
|
|
2041
|
+
* // Top 5 healthy autonomous agents by consumption
|
|
2042
|
+
* const result = await agents.getTopConsumption(
|
|
2043
|
+
* new Date('2025-05-01T00:00:00Z'),
|
|
2044
|
+
* new Date('2025-06-01T00:00:00Z'),
|
|
2045
|
+
* {
|
|
2046
|
+
* limit: 5,
|
|
2047
|
+
* healthy: true,
|
|
2048
|
+
* agentTypes: [AgentType.Autonomous],
|
|
2049
|
+
* },
|
|
2050
|
+
* );
|
|
2051
|
+
* ```
|
|
2052
|
+
*/
|
|
2053
|
+
async getTopConsumption(startTime, endTime, options) {
|
|
2054
|
+
const body = this.buildAgentFilterBody(startTime, endTime, options);
|
|
2055
|
+
if (options?.healthy !== undefined)
|
|
2056
|
+
body.healthy = options.healthy;
|
|
2057
|
+
if (options?.healthThreshold !== undefined)
|
|
2058
|
+
body.healthThreshold = options.healthThreshold;
|
|
2059
|
+
if (options?.agentTypes?.length)
|
|
2060
|
+
body.agentTypes = options.agentTypes.join(',');
|
|
2061
|
+
const response = await this.post(AGENTS_ENDPOINTS.GET_TOP_CONSUMPTION, body);
|
|
2062
|
+
return response.data.data;
|
|
2063
|
+
}
|
|
2064
|
+
/**
|
|
2065
|
+
* Retrieves breakdown of agent incidents count — errors, escalations,
|
|
2066
|
+
* and policy violations over a requested window.
|
|
2067
|
+
*
|
|
2068
|
+
* @param startTime - Inclusive lower bound for the query window
|
|
2069
|
+
* @param endTime - Exclusive upper bound for the query window
|
|
2070
|
+
* @param options - Optional filters
|
|
2071
|
+
* @returns Promise resolving to {@link AgentGetIncidentDistributionResponse}
|
|
2072
|
+
* @example
|
|
2073
|
+
* ```typescript
|
|
2074
|
+
* import { Agents } from '@uipath/uipath-typescript/agents';
|
|
2075
|
+
*
|
|
2076
|
+
* const agents = new Agents(sdk);
|
|
2077
|
+
*
|
|
2078
|
+
* // Incident distribution in May 2025
|
|
2079
|
+
* const result = await agents.getIncidentDistribution(
|
|
2080
|
+
* new Date('2025-05-01T00:00:00Z'),
|
|
2081
|
+
* new Date('2025-06-01T00:00:00Z'),
|
|
2082
|
+
* );
|
|
2083
|
+
* console.log(`Errors: ${result.errorCount}, Escalations: ${result.escalationCount}, Policy: ${result.policyCount}`);
|
|
2084
|
+
* ```
|
|
2085
|
+
* @example
|
|
2086
|
+
* ```typescript
|
|
2087
|
+
* // Scope to specific folders
|
|
2088
|
+
* const result = await agents.getIncidentDistribution(
|
|
2089
|
+
* new Date('2025-05-01T00:00:00Z'),
|
|
2090
|
+
* new Date('2025-06-01T00:00:00Z'),
|
|
2091
|
+
* {
|
|
2092
|
+
* folderKeys: ['<folderKey1>'],
|
|
2093
|
+
* },
|
|
2094
|
+
* );
|
|
2095
|
+
* ```
|
|
2096
|
+
*/
|
|
2097
|
+
async getIncidentDistribution(startTime, endTime, options) {
|
|
2098
|
+
const body = this.buildAgentFilterBody(startTime, endTime, options);
|
|
2099
|
+
const response = await this.post(AGENTS_ENDPOINTS.GET_INCIDENT_DISTRIBUTION, body);
|
|
2100
|
+
return response.data.data;
|
|
2101
|
+
}
|
|
2102
|
+
/**
|
|
2103
|
+
* Retrieves a job-execution summary for the requested window: overall totals
|
|
2104
|
+
* (total jobs, successful jobs, success rate, average duration) alongside a
|
|
2105
|
+
* per-agent breakdown. When `lookbackPeriodAnalysis` is enabled, a comparable
|
|
2106
|
+
* summary for the preceding window of equal length is included too.
|
|
2107
|
+
*
|
|
2108
|
+
* @param startTime - Inclusive lower bound for the query window
|
|
2109
|
+
* @param endTime - Exclusive upper bound for the query window
|
|
2110
|
+
* @param options - Optional filters
|
|
2111
|
+
* @returns Promise resolving to {@link AgentGetSummaryResponse}
|
|
2112
|
+
* @example
|
|
2113
|
+
* ```typescript
|
|
2114
|
+
* import { Agents } from '@uipath/uipath-typescript/agents';
|
|
2115
|
+
*
|
|
2116
|
+
* const agents = new Agents(sdk);
|
|
2117
|
+
*
|
|
2118
|
+
* // Summary for May 2025
|
|
2119
|
+
* const result = await agents.getSummary(
|
|
2120
|
+
* new Date('2025-05-01T00:00:00Z'),
|
|
2121
|
+
* new Date('2025-06-01T00:00:00Z'),
|
|
2122
|
+
* );
|
|
2123
|
+
* console.log(`Success rate: ${result.currentPeriodSummary.successRate}%`);
|
|
2124
|
+
* ```
|
|
2125
|
+
* @example
|
|
2126
|
+
* ```typescript
|
|
2127
|
+
* import { Agents, AgentExecutionType } from '@uipath/uipath-typescript/agents';
|
|
2128
|
+
*
|
|
2129
|
+
* const agents = new Agents(sdk);
|
|
2130
|
+
*
|
|
2131
|
+
* // Runtime-only summary with lookback comparison
|
|
2132
|
+
* const result = await agents.getSummary(
|
|
2133
|
+
* new Date('2025-05-01T00:00:00Z'),
|
|
2134
|
+
* new Date('2025-06-01T00:00:00Z'),
|
|
2135
|
+
* {
|
|
2136
|
+
* lookbackPeriodAnalysis: true,
|
|
2137
|
+
* executionType: AgentExecutionType.Runtime,
|
|
2138
|
+
* },
|
|
2139
|
+
* );
|
|
2140
|
+
* ```
|
|
2141
|
+
*/
|
|
2142
|
+
async getSummary(startTime, endTime, options) {
|
|
2143
|
+
const body = this.buildAgentFilterBody(startTime, endTime, options);
|
|
2144
|
+
if (options?.lookbackPeriodAnalysis !== undefined)
|
|
2145
|
+
body.lookbackPeriodAnalysis = options.lookbackPeriodAnalysis;
|
|
2146
|
+
if (options?.processKey !== undefined)
|
|
2147
|
+
body.processKey = options.processKey;
|
|
2148
|
+
if (options?.folderKey !== undefined)
|
|
2149
|
+
body.folderKey = options.folderKey;
|
|
2150
|
+
if (options?.executionType !== undefined)
|
|
2151
|
+
body.executionType = options.executionType;
|
|
2152
|
+
const response = await this.post(AGENTS_ENDPOINTS.GET_SUMMARY, body);
|
|
2153
|
+
const summary = response.data.data;
|
|
2154
|
+
return {
|
|
2155
|
+
currentPeriodSummary: normalizeSummaryPeriod(summary.currentPeriodSummary),
|
|
2156
|
+
lookbackPeriodSummary: summary.lookbackPeriodSummary
|
|
2157
|
+
? normalizeSummaryPeriod(summary.lookbackPeriodSummary)
|
|
2158
|
+
: undefined,
|
|
2159
|
+
};
|
|
2160
|
+
}
|
|
2161
|
+
/**
|
|
2162
|
+
* Retrieves an aggregate Agent Units and Platform Units consumption summary per agent over the
|
|
2163
|
+
* requested window.
|
|
2164
|
+
*
|
|
2165
|
+
* @param startTime - Inclusive lower bound for the query window
|
|
2166
|
+
* @param endTime - Exclusive upper bound for the query window
|
|
2167
|
+
* @param options - Optional filters
|
|
2168
|
+
* @returns Promise resolving to {@link AgentGetUnitConsumptionSummaryResponse}
|
|
2169
|
+
* @example
|
|
2170
|
+
* ```typescript
|
|
2171
|
+
* import { Agents } from '@uipath/uipath-typescript/agents';
|
|
2172
|
+
*
|
|
2173
|
+
* const agents = new Agents(sdk);
|
|
2174
|
+
*
|
|
2175
|
+
* // Unit consumption summary for May 2025
|
|
2176
|
+
* const result = await agents.getUnitConsumptionSummary(
|
|
2177
|
+
* new Date('2025-05-01T00:00:00Z'),
|
|
2178
|
+
* new Date('2025-06-01T00:00:00Z'),
|
|
2179
|
+
* );
|
|
2180
|
+
* console.log(`Agent Units complete jobs: ${result.currentPeriodSummary.totalAgentUnitConsumption.completeJobs}`);
|
|
2181
|
+
* ```
|
|
2182
|
+
* @example
|
|
2183
|
+
* ```typescript
|
|
2184
|
+
* import { Agents, AgentExecutionType } from '@uipath/uipath-typescript/agents';
|
|
2185
|
+
*
|
|
2186
|
+
* const agents = new Agents(sdk);
|
|
2187
|
+
*
|
|
2188
|
+
* // Runtime-only summary with lookback comparison
|
|
2189
|
+
* const result = await agents.getUnitConsumptionSummary(
|
|
2190
|
+
* new Date('2025-05-01T00:00:00Z'),
|
|
2191
|
+
* new Date('2025-06-01T00:00:00Z'),
|
|
2192
|
+
* {
|
|
2193
|
+
* lookbackPeriodAnalysis: true,
|
|
2194
|
+
* executionType: AgentExecutionType.Runtime,
|
|
2195
|
+
* },
|
|
2196
|
+
* );
|
|
2197
|
+
* ```
|
|
2198
|
+
*/
|
|
2199
|
+
async getUnitConsumptionSummary(startTime, endTime, options) {
|
|
2200
|
+
const body = this.buildAgentFilterBody(startTime, endTime, options);
|
|
2201
|
+
if (options?.lookbackPeriodAnalysis !== undefined)
|
|
2202
|
+
body.lookbackPeriodAnalysis = options.lookbackPeriodAnalysis;
|
|
2203
|
+
if (options?.processKey !== undefined)
|
|
2204
|
+
body.processKey = options.processKey;
|
|
2205
|
+
if (options?.folderKey !== undefined)
|
|
2206
|
+
body.folderKey = options.folderKey;
|
|
2207
|
+
if (options?.executionType !== undefined)
|
|
2208
|
+
body.executionType = options.executionType;
|
|
2209
|
+
const response = await this.post(AGENTS_ENDPOINTS.GET_UNIT_CONSUMPTION_SUMMARY, body);
|
|
2210
|
+
return response.data.data;
|
|
2211
|
+
}
|
|
1916
2212
|
/**
|
|
1917
2213
|
* Builds the common POST request body shared by the agent filter endpoints —
|
|
1918
2214
|
* the required time window plus any optional folder/agent/project/process
|
|
@@ -1953,6 +2249,21 @@ __decorate([
|
|
|
1953
2249
|
__decorate([
|
|
1954
2250
|
track('Agents.GetLatencyTimeline')
|
|
1955
2251
|
], AgentService.prototype, "getLatencyTimeline", null);
|
|
2252
|
+
__decorate([
|
|
2253
|
+
track('Agents.GetTopErrorCount')
|
|
2254
|
+
], AgentService.prototype, "getTopErrorCount", null);
|
|
2255
|
+
__decorate([
|
|
2256
|
+
track('Agents.GetTopConsumption')
|
|
2257
|
+
], AgentService.prototype, "getTopConsumption", null);
|
|
2258
|
+
__decorate([
|
|
2259
|
+
track('Agents.GetIncidentDistribution')
|
|
2260
|
+
], AgentService.prototype, "getIncidentDistribution", null);
|
|
2261
|
+
__decorate([
|
|
2262
|
+
track('Agents.GetSummary')
|
|
2263
|
+
], AgentService.prototype, "getSummary", null);
|
|
2264
|
+
__decorate([
|
|
2265
|
+
track('Agents.GetUnitConsumptionSummary')
|
|
2266
|
+
], AgentService.prototype, "getUnitConsumptionSummary", null);
|
|
1956
2267
|
|
|
1957
2268
|
/**
|
|
1958
2269
|
* Columns available for ordering results.
|
|
@@ -1965,9 +2276,9 @@ var AgentListSortColumn;
|
|
|
1965
2276
|
AgentListSortColumn["HealthScore"] = "HealthScore";
|
|
1966
2277
|
AgentListSortColumn["LastIncident"] = "LastIncident";
|
|
1967
2278
|
AgentListSortColumn["FolderName"] = "FolderName";
|
|
1968
|
-
/** Quantity of
|
|
2279
|
+
/** Quantity of Agent Units consumed */
|
|
1969
2280
|
AgentListSortColumn["QuantityAGU"] = "QuantityAGU";
|
|
1970
|
-
/** Quantity of
|
|
2281
|
+
/** Quantity of Platform Units consumed */
|
|
1971
2282
|
AgentListSortColumn["QuantityPLTU"] = "QuantityPLTU";
|
|
1972
2283
|
AgentListSortColumn["FolderPath"] = "FolderPath";
|
|
1973
2284
|
})(AgentListSortColumn || (AgentListSortColumn = {}));
|
|
@@ -1989,5 +2300,29 @@ var AgentErrorSortColumn;
|
|
|
1989
2300
|
AgentErrorSortColumn["LastSeenFolderName"] = "LastSeenFolderName";
|
|
1990
2301
|
AgentErrorSortColumn["LastSeenFolderPath"] = "LastSeenFolderPath";
|
|
1991
2302
|
})(AgentErrorSortColumn || (AgentErrorSortColumn = {}));
|
|
2303
|
+
/**
|
|
2304
|
+
* Agent type, used to filter consumption results.
|
|
2305
|
+
*
|
|
2306
|
+
* Wire format is the string name, per the API's `StringEnumConverter` serialization.
|
|
2307
|
+
*/
|
|
2308
|
+
var AgentType;
|
|
2309
|
+
(function (AgentType) {
|
|
2310
|
+
AgentType["Autonomous"] = "Autonomous";
|
|
2311
|
+
AgentType["Conversational"] = "Conversational";
|
|
2312
|
+
AgentType["Coded"] = "Coded";
|
|
2313
|
+
})(AgentType || (AgentType = {}));
|
|
2314
|
+
/**
|
|
2315
|
+
* Job execution mode filter accepted by the summary endpoints.
|
|
2316
|
+
*
|
|
2317
|
+
* Wire format is the string name (`"Debug"` / `"Runtime"`), per the API's
|
|
2318
|
+
* `StringEnumConverter` serialization.
|
|
2319
|
+
*/
|
|
2320
|
+
var AgentExecutionType;
|
|
2321
|
+
(function (AgentExecutionType) {
|
|
2322
|
+
/** Test runs */
|
|
2323
|
+
AgentExecutionType["Debug"] = "Debug";
|
|
2324
|
+
/** Production runs */
|
|
2325
|
+
AgentExecutionType["Runtime"] = "Runtime";
|
|
2326
|
+
})(AgentExecutionType || (AgentExecutionType = {}));
|
|
1992
2327
|
|
|
1993
|
-
export { AgentErrorSortColumn, AgentListSortColumn, AgentService as Agents };
|
|
2328
|
+
export { AgentErrorSortColumn, AgentExecutionType, AgentListSortColumn, AgentType, AgentService as Agents };
|
package/dist/assets/index.cjs
CHANGED
|
@@ -956,7 +956,16 @@ const BUCKET_TOKEN_PARAMS = {
|
|
|
956
956
|
* Returns the original value if parsing fails.
|
|
957
957
|
*/
|
|
958
958
|
/**
|
|
959
|
-
* Transforms data by
|
|
959
|
+
* Transforms data by renaming each key in `data` exactly once, using the
|
|
960
|
+
* mapping (`sourceField → targetField`). Keys not present in the mapping
|
|
961
|
+
* pass through unchanged. The original (pre-rename) key is dropped — the
|
|
962
|
+
* result contains only the renamed key.
|
|
963
|
+
*
|
|
964
|
+
* Each rename is independent. If the mapping happens to contain chained
|
|
965
|
+
* entries (`a → b` and `b → c`), they do NOT compose: a field named `a`
|
|
966
|
+
* in `data` becomes `b` (not `c`), because the renames are applied based
|
|
967
|
+
* on the original data's keys, not the running result.
|
|
968
|
+
*
|
|
960
969
|
* @param data The source data to transform
|
|
961
970
|
* @param fieldMapping Object mapping source field names to target field names
|
|
962
971
|
* @returns Transformed data with mapped field names
|
|
@@ -979,21 +988,28 @@ const BUCKET_TOKEN_PARAMS = {
|
|
|
979
988
|
* // { userId: '123', name: 'john' },
|
|
980
989
|
* // { userId: '456', name: 'jane' }
|
|
981
990
|
* // ]
|
|
991
|
+
*
|
|
992
|
+
* // No chaining — `a → b` does not become `a → c` even if the map has `b → c`.
|
|
993
|
+
* transformData({ a: 1 }, { a: 'b', b: 'c' });
|
|
994
|
+
* // result = { b: 1 }
|
|
982
995
|
* ```
|
|
983
996
|
*/
|
|
984
997
|
function transformData(data, fieldMapping) {
|
|
998
|
+
// Pass null/undefined through unchanged — callers (e.g. AttachmentService.getById)
|
|
999
|
+
// may invoke this on optional fields that an OData `select` excluded.
|
|
1000
|
+
if (data == null) {
|
|
1001
|
+
return data;
|
|
1002
|
+
}
|
|
985
1003
|
// Handle array of objects
|
|
986
1004
|
if (Array.isArray(data)) {
|
|
987
1005
|
return data.map(item => transformData(item, fieldMapping));
|
|
988
1006
|
}
|
|
989
|
-
//
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
result[targetField] = value;
|
|
996
|
-
}
|
|
1007
|
+
// Walk the ORIGINAL data's keys, look up each in the mapping. One rename
|
|
1008
|
+
// per data key — no mutation of an in-progress result, so chains can't form.
|
|
1009
|
+
const result = {};
|
|
1010
|
+
for (const [key, value] of Object.entries(data)) {
|
|
1011
|
+
const renamedKey = fieldMapping[key] ?? key;
|
|
1012
|
+
result[renamedKey] = value;
|
|
997
1013
|
}
|
|
998
1014
|
return result;
|
|
999
1015
|
}
|
|
@@ -1103,6 +1119,97 @@ function addPrefixToKeys(obj, prefix, keys) {
|
|
|
1103
1119
|
}
|
|
1104
1120
|
return result;
|
|
1105
1121
|
}
|
|
1122
|
+
/**
|
|
1123
|
+
* Creates a new map with the keys and values reversed
|
|
1124
|
+
* @param map The original map to reverse
|
|
1125
|
+
* @returns A new map with keys and values swapped
|
|
1126
|
+
*
|
|
1127
|
+
* @example
|
|
1128
|
+
* ```typescript
|
|
1129
|
+
* const original = { key1: 'value1', key2: 'value2' };
|
|
1130
|
+
* const reversed = reverseMap(original);
|
|
1131
|
+
* // reversed = { value1: 'key1', value2: 'key2' }
|
|
1132
|
+
* ```
|
|
1133
|
+
*/
|
|
1134
|
+
function reverseMap(map) {
|
|
1135
|
+
return Object.entries(map).reduce((acc, [key, value]) => {
|
|
1136
|
+
acc[value] = key;
|
|
1137
|
+
return acc;
|
|
1138
|
+
}, {});
|
|
1139
|
+
}
|
|
1140
|
+
/**
|
|
1141
|
+
* OData query-string keys whose values may contain field identifiers that
|
|
1142
|
+
* need rewriting from SDK names → API names.
|
|
1143
|
+
*/
|
|
1144
|
+
const ODATA_FIELD_PARAM_KEYS = ['filter', 'orderby', 'select', 'expand'];
|
|
1145
|
+
/**
|
|
1146
|
+
* Matches one token at a time in an OData expression:
|
|
1147
|
+
* 1. A single-quoted string literal, allowing the `''` escape sequence —
|
|
1148
|
+
* consumed atomically so identifiers inside the literal can't match.
|
|
1149
|
+
* 2. An OData identifier (`[A-Za-z_][A-Za-z0-9_]*`).
|
|
1150
|
+
* Anything else (whitespace, operators, parens, commas) is left alone by
|
|
1151
|
+
* `String.prototype.replace`, which only substitutes matched substrings.
|
|
1152
|
+
*/
|
|
1153
|
+
const ODATA_TOKEN_RE = /'(?:[^']|'')*'|[A-Za-z_][A-Za-z0-9_]*/g;
|
|
1154
|
+
/**
|
|
1155
|
+
* Rewrites SDK field identifiers to API field identifiers inside an OData
|
|
1156
|
+
* expression string (`$filter`, `$orderby`, `$select`, `$expand`).
|
|
1157
|
+
*
|
|
1158
|
+
* Field maps (e.g. `JobMap`) rename API fields → SDK fields on responses, so
|
|
1159
|
+
* SDK consumers see the renamed names. Without this rewrite, the same name
|
|
1160
|
+
* in a `filter` string would be forwarded verbatim and the API (which still
|
|
1161
|
+
* uses the original name) would reject it.
|
|
1162
|
+
*
|
|
1163
|
+
* Quoted string literals (with the OData `''` escape) are preserved exactly:
|
|
1164
|
+
* the token regex consumes them whole, so identifiers inside literals never
|
|
1165
|
+
* match. Identifier tokens are looked up in the reversed field map.
|
|
1166
|
+
*
|
|
1167
|
+
* @example
|
|
1168
|
+
* ```typescript
|
|
1169
|
+
* const requestMap = { processName: 'releaseName' };
|
|
1170
|
+
* rewriteODataIdentifiers("processName eq 'processName'", requestMap);
|
|
1171
|
+
* // "releaseName eq 'processName'" — identifier rewritten, literal preserved
|
|
1172
|
+
* ```
|
|
1173
|
+
*/
|
|
1174
|
+
function rewriteODataIdentifiers(expression, requestMap) {
|
|
1175
|
+
if (!expression)
|
|
1176
|
+
return expression;
|
|
1177
|
+
return expression.replace(ODATA_TOKEN_RE, (match) => match.startsWith("'") ? match : (requestMap[match] ?? match));
|
|
1178
|
+
}
|
|
1179
|
+
/**
|
|
1180
|
+
* Symmetric counterpart of {@link transformRequest} for OData query options:
|
|
1181
|
+
* rewrites SDK field identifiers inside the recognized OData string params
|
|
1182
|
+
* (`filter`, `orderby`, `select`, `expand`) to their API names using the
|
|
1183
|
+
* reversed form of a response field map. Returns a shallow copy with the
|
|
1184
|
+
* relevant values rewritten; other keys pass through unchanged.
|
|
1185
|
+
*
|
|
1186
|
+
* Use at the OData edge so SDK consumers can refer to renamed fields by
|
|
1187
|
+
* their SDK name throughout — for reading the response and for filtering /
|
|
1188
|
+
* sorting / projecting / expanding.
|
|
1189
|
+
*
|
|
1190
|
+
* @param options The OData query options as authored with SDK field names
|
|
1191
|
+
* @param responseMap The response field map (API → SDK); reversed internally
|
|
1192
|
+
*
|
|
1193
|
+
* @example
|
|
1194
|
+
* ```typescript
|
|
1195
|
+
* // JobMap renames releaseName → processName on responses.
|
|
1196
|
+
* transformOptions({ filter: "processName eq 'X'" }, JobMap);
|
|
1197
|
+
* // { filter: "releaseName eq 'X'" }
|
|
1198
|
+
* ```
|
|
1199
|
+
*/
|
|
1200
|
+
function transformOptions(options, responseMap) {
|
|
1201
|
+
const requestMap = reverseMap(responseMap);
|
|
1202
|
+
if (Object.keys(requestMap).length === 0)
|
|
1203
|
+
return options;
|
|
1204
|
+
const result = { ...options };
|
|
1205
|
+
for (const key of ODATA_FIELD_PARAM_KEYS) {
|
|
1206
|
+
const value = result[key];
|
|
1207
|
+
if (typeof value === 'string') {
|
|
1208
|
+
result[key] = rewriteODataIdentifiers(value, requestMap);
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
return result;
|
|
1212
|
+
}
|
|
1106
1213
|
|
|
1107
1214
|
/**
|
|
1108
1215
|
* Constants used throughout the pagination system
|
|
@@ -1866,9 +1973,12 @@ class FolderScopedService extends BaseService {
|
|
|
1866
1973
|
* @param name - Resource name to search for
|
|
1867
1974
|
* @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`) + OData query options (`expand`, `select`)
|
|
1868
1975
|
* @param transform - Maps a raw OData item to the typed response (e.g. PascalCase → camelCase via field map)
|
|
1976
|
+
* @param responseFieldMap - Optional response field map (API → SDK), reversed internally by
|
|
1977
|
+
* `transformOptions` to rewrite SDK field names back to API names in user-supplied
|
|
1978
|
+
* `expand` / `select` (symmetric counterpart to `transform`)
|
|
1869
1979
|
* @throws ValidationError when inputs are malformed; NotFoundError when no match
|
|
1870
1980
|
*/
|
|
1871
|
-
async getByNameLookup(resourceType, endpoint, name, options, transform) {
|
|
1981
|
+
async getByNameLookup(resourceType, endpoint, name, options, transform, responseFieldMap) {
|
|
1872
1982
|
const validatedName = validateName(resourceType, name);
|
|
1873
1983
|
const { folderId, folderKey, folderPath, ...queryOptions } = options;
|
|
1874
1984
|
const headers = resolveFolderHeaders({
|
|
@@ -1878,8 +1988,11 @@ class FolderScopedService extends BaseService {
|
|
|
1878
1988
|
resourceType: `${resourceType}.getByName`,
|
|
1879
1989
|
fallbackFolderKey: this.config.folderKey,
|
|
1880
1990
|
});
|
|
1991
|
+
const apiFieldOptions = responseFieldMap
|
|
1992
|
+
? transformOptions(queryOptions, responseFieldMap)
|
|
1993
|
+
: queryOptions;
|
|
1881
1994
|
const apiOptions = {
|
|
1882
|
-
...addPrefixToKeys(
|
|
1995
|
+
...addPrefixToKeys(apiFieldOptions, ODATA_PREFIX, Object.keys(apiFieldOptions)),
|
|
1883
1996
|
'$filter': `Name eq '${validatedName.replace(SINGLE_QUOTE_RE, "''")}'`,
|
|
1884
1997
|
'$top': '1',
|
|
1885
1998
|
};
|
|
@@ -2025,6 +2138,10 @@ class AssetService extends FolderScopedService {
|
|
|
2025
2138
|
async getAll(options) {
|
|
2026
2139
|
// Transformation function for assets
|
|
2027
2140
|
const transformAssetResponse = (asset) => transformData(pascalToCamelCaseKeys(asset), AssetMap);
|
|
2141
|
+
// Rewrite renamed SDK field names → API names inside OData strings
|
|
2142
|
+
// before delegating, mirroring the transformRequest pattern used for
|
|
2143
|
+
// request bodies.
|
|
2144
|
+
const apiOptions = options ? transformOptions(options, AssetMap) : options;
|
|
2028
2145
|
return PaginationHelpers.getAll({
|
|
2029
2146
|
serviceAccess: this.createPaginationServiceAccess(),
|
|
2030
2147
|
getEndpoint: (folderId) => folderId ? ASSET_ENDPOINTS.GET_BY_FOLDER : ASSET_ENDPOINTS.GET_ALL,
|
|
@@ -2040,7 +2157,7 @@ class AssetService extends FolderScopedService {
|
|
|
2040
2157
|
countParam: ODATA_OFFSET_PARAMS.COUNT_PARAM
|
|
2041
2158
|
}
|
|
2042
2159
|
}
|
|
2043
|
-
},
|
|
2160
|
+
}, apiOptions);
|
|
2044
2161
|
}
|
|
2045
2162
|
/**
|
|
2046
2163
|
* Gets a single asset by ID
|
|
@@ -2062,8 +2179,8 @@ class AssetService extends FolderScopedService {
|
|
|
2062
2179
|
*/
|
|
2063
2180
|
async getById(id, folderId, options = {}) {
|
|
2064
2181
|
const headers = createHeaders({ [FOLDER_ID]: folderId });
|
|
2065
|
-
const
|
|
2066
|
-
const apiOptions = addPrefixToKeys(
|
|
2182
|
+
const apiFieldOptions = transformOptions(options, AssetMap);
|
|
2183
|
+
const apiOptions = addPrefixToKeys(apiFieldOptions, ODATA_PREFIX, Object.keys(apiFieldOptions));
|
|
2067
2184
|
const response = await this.get(ASSET_ENDPOINTS.GET_BY_ID(id), {
|
|
2068
2185
|
headers,
|
|
2069
2186
|
params: apiOptions
|
|
@@ -2098,7 +2215,7 @@ class AssetService extends FolderScopedService {
|
|
|
2098
2215
|
* ```
|
|
2099
2216
|
*/
|
|
2100
2217
|
async getByName(name, options = {}) {
|
|
2101
|
-
return this.getByNameLookup('Asset', ASSET_ENDPOINTS.GET_BY_FOLDER, name, options, (raw) => transformData(pascalToCamelCaseKeys(raw), AssetMap));
|
|
2218
|
+
return this.getByNameLookup('Asset', ASSET_ENDPOINTS.GET_BY_FOLDER, name, options, (raw) => transformData(pascalToCamelCaseKeys(raw), AssetMap), AssetMap);
|
|
2102
2219
|
}
|
|
2103
2220
|
/**
|
|
2104
2221
|
* Updates the value of an existing asset by ID.
|
package/dist/assets/index.d.ts
CHANGED
|
@@ -326,6 +326,14 @@ interface FolderScopedOptions extends BaseOptions {
|
|
|
326
326
|
folderPath?: string;
|
|
327
327
|
}
|
|
328
328
|
|
|
329
|
+
/**
|
|
330
|
+
* Type for field mapping configuration
|
|
331
|
+
* Maps source field names to target field names
|
|
332
|
+
*/
|
|
333
|
+
type FieldMapping = {
|
|
334
|
+
[sourceField: string]: string;
|
|
335
|
+
};
|
|
336
|
+
|
|
329
337
|
/**
|
|
330
338
|
* Base service for services that need folder-specific functionality.
|
|
331
339
|
*
|
|
@@ -367,9 +375,12 @@ declare class FolderScopedService extends BaseService {
|
|
|
367
375
|
* @param name - Resource name to search for
|
|
368
376
|
* @param options - Folder scoping (`folderId` / `folderKey` / `folderPath`) + OData query options (`expand`, `select`)
|
|
369
377
|
* @param transform - Maps a raw OData item to the typed response (e.g. PascalCase → camelCase via field map)
|
|
378
|
+
* @param responseFieldMap - Optional response field map (API → SDK), reversed internally by
|
|
379
|
+
* `transformOptions` to rewrite SDK field names back to API names in user-supplied
|
|
380
|
+
* `expand` / `select` (symmetric counterpart to `transform`)
|
|
370
381
|
* @throws ValidationError when inputs are malformed; NotFoundError when no match
|
|
371
382
|
*/
|
|
372
|
-
protected getByNameLookup<TRaw extends object, T>(resourceType: string, endpoint: string, name: string, options: FolderScopedOptions, transform: (raw: TRaw) => T): Promise<T>;
|
|
383
|
+
protected getByNameLookup<TRaw extends object, T>(resourceType: string, endpoint: string, name: string, options: FolderScopedOptions, transform: (raw: TRaw) => T, responseFieldMap?: FieldMapping): Promise<T>;
|
|
373
384
|
}
|
|
374
385
|
|
|
375
386
|
/**
|