@uipath/uipath-typescript 1.3.10 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/dist/agent-memory/index.cjs +1765 -0
  2. package/dist/agent-memory/index.d.ts +588 -0
  3. package/dist/agent-memory/index.mjs +1763 -0
  4. package/dist/agents/index.cjs +1726 -0
  5. package/dist/agents/index.d.ts +502 -0
  6. package/dist/agents/index.mjs +1724 -0
  7. package/dist/assets/index.cjs +155 -30
  8. package/dist/assets/index.d.ts +84 -5
  9. package/dist/assets/index.mjs +155 -30
  10. package/dist/attachments/index.cjs +37 -6
  11. package/dist/attachments/index.d.ts +1 -0
  12. package/dist/attachments/index.mjs +37 -6
  13. package/dist/buckets/index.cjs +37 -6
  14. package/dist/buckets/index.d.ts +1 -0
  15. package/dist/buckets/index.mjs +37 -6
  16. package/dist/cases/index.cjs +192 -10
  17. package/dist/cases/index.d.ts +208 -7
  18. package/dist/cases/index.mjs +192 -11
  19. package/dist/conversational-agent/index.cjs +124 -57
  20. package/dist/conversational-agent/index.d.ts +190 -122
  21. package/dist/conversational-agent/index.mjs +124 -57
  22. package/dist/core/index.cjs +413 -105
  23. package/dist/core/index.d.ts +15 -0
  24. package/dist/core/index.mjs +413 -105
  25. package/dist/entities/index.cjs +135 -70
  26. package/dist/entities/index.d.ts +146 -45
  27. package/dist/entities/index.mjs +135 -70
  28. package/dist/feedback/index.cjs +37 -6
  29. package/dist/feedback/index.d.ts +1 -0
  30. package/dist/feedback/index.mjs +37 -6
  31. package/dist/governance/index.cjs +1782 -0
  32. package/dist/governance/index.d.ts +598 -0
  33. package/dist/governance/index.mjs +1780 -0
  34. package/dist/index.cjs +1050 -291
  35. package/dist/index.d.ts +1313 -134
  36. package/dist/index.mjs +1050 -292
  37. package/dist/index.umd.js +4546 -3770
  38. package/dist/jobs/index.cjs +37 -6
  39. package/dist/jobs/index.d.ts +1 -0
  40. package/dist/jobs/index.mjs +37 -6
  41. package/dist/maestro-processes/index.cjs +224 -18
  42. package/dist/maestro-processes/index.d.ts +221 -9
  43. package/dist/maestro-processes/index.mjs +224 -18
  44. package/dist/processes/index.cjs +37 -6
  45. package/dist/processes/index.d.ts +1 -0
  46. package/dist/processes/index.mjs +37 -6
  47. package/dist/queues/index.cjs +37 -6
  48. package/dist/queues/index.d.ts +1 -0
  49. package/dist/queues/index.mjs +37 -6
  50. package/dist/tasks/index.cjs +37 -6
  51. package/dist/tasks/index.d.ts +1 -0
  52. package/dist/tasks/index.mjs +37 -6
  53. package/dist/traces/index.cjs +1933 -0
  54. package/dist/traces/index.d.ts +566 -0
  55. package/dist/traces/index.mjs +1931 -0
  56. package/package.json +42 -2
@@ -46,6 +46,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
46
46
  * Base path constants for different services
47
47
  */
48
48
  const PIMS_BASE = 'pims_';
49
+ const LLMOPS_BASE = 'llmopstenant_';
49
50
  const INSIGHTS_RTM_BASE = 'insightsrtm_';
50
51
 
51
52
  /**
@@ -60,7 +61,7 @@ const MAESTRO_ENDPOINTS = {
60
61
  INSTANCES: {
61
62
  GET_ALL: `${PIMS_BASE}/api/v1/instances`,
62
63
  GET_BY_ID: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}`,
63
- GET_EXECUTION_HISTORY: (instanceId) => `${PIMS_BASE}/api/v1/spans/${instanceId}`,
64
+ GET_ELEMENT_EXECUTIONS: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/element-executions`,
64
65
  GET_BPMN: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/bpmn`,
65
66
  GET_VARIABLES: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/variables`,
66
67
  CANCEL: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/cancel`,
@@ -72,15 +73,22 @@ const MAESTRO_ENDPOINTS = {
72
73
  GET_BY_PROCESS: (processKey) => `${PIMS_BASE}/api/v1/incidents/process/${processKey}`,
73
74
  GET_BY_INSTANCE: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/incidents`,
74
75
  },
76
+ TRACES: {
77
+ GET_SPANS: (traceId) => `${LLMOPS_BASE}/api/Traces/spans?traceId=${traceId}`,
78
+ },
75
79
  INSIGHTS: {
76
80
  /** Top processes ranked by run count */
77
81
  TOP_PROCESSES_BY_RUN_COUNT: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/TopProcessesByRunCount`,
78
82
  /** Top processes ranked by failure count */
79
83
  TOP_PROCESSES_WITH_FAILURE: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/TopProcesseswithFailure`,
84
+ /** Top elements ranked by failure count */
85
+ TOP_ELEMENTS_WITH_FAILURE: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/TopElementswithFailure`,
80
86
  /** Instance status aggregated by date for time-series charts */
81
87
  INSTANCE_STATUS_BY_DATE: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/InstanceStatusByDate`,
82
88
  /** Top processes ranked by total duration */
83
89
  TOP_PROCESSES_BY_DURATION: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/TopProcessesByDuration`,
90
+ /** Element count by status for agentic instances (process and case) */
91
+ ELEMENT_COUNT_BY_STATUS: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/ElementCountByStatus`,
84
92
  },
85
93
  };
86
94
 
@@ -103,6 +111,13 @@ function createProcessMethods(processData, service) {
103
111
  if (!processData.folderKey)
104
112
  throw new Error('Folder key is undefined');
105
113
  return service.getIncidents(processData.processKey, processData.folderKey);
114
+ },
115
+ getElementStats(startTime, endTime, packageVersion) {
116
+ if (!processData.processKey)
117
+ throw new Error('Process key is undefined');
118
+ if (!processData.packageId)
119
+ throw new Error('Package ID is undefined');
120
+ return service.getElementStats(processData.processKey, processData.packageId, startTime, endTime, packageVersion);
106
121
  }
107
122
  };
108
123
  }
@@ -164,6 +179,28 @@ async function fetchInstanceStatusTimeline(postFn, startTime, endTime, isCaseMan
164
179
  });
165
180
  return response.data ?? [];
166
181
  }
182
+ /**
183
+ * Builds the request body for the ElementCountByStatus endpoint.
184
+ *
185
+ * @param processKey - Process key to filter by
186
+ * @param packageId - Package identifier
187
+ * @param startTime - Start of the time range to query
188
+ * @param endTime - End of the time range to query
189
+ * @param packageVersion - Package version to filter by
190
+ * @returns Request body for the ElementCountByStatus endpoint
191
+ * @internal
192
+ */
193
+ function buildElementCountByStatusBody(processKey, packageId, startTime, endTime, packageVersion) {
194
+ return {
195
+ commonParams: {
196
+ processKey,
197
+ packageId,
198
+ startTime: startTime.getTime(),
199
+ endTime: endTime.getTime(),
200
+ version: packageVersion
201
+ }
202
+ };
203
+ }
167
204
 
168
205
  /**
169
206
  * Common constants used across the SDK
@@ -1156,6 +1193,32 @@ function filterUndefined(obj) {
1156
1193
  */
1157
1194
  const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
1158
1195
  isBrowser && window.self != window.top && window.location.href.includes('source=ActionCenter');
1196
+ const _params = isBrowser ? new URLSearchParams(window.location.search) : null;
1197
+ /**
1198
+ * True when the coded app has been loaded inside a host frame that explicitly
1199
+ * opted into token delegation by adding `?host=embed` to the iframe src URL.
1200
+ */
1201
+ const isHostEmbedded = isBrowser && window.self !== window.top && _params?.get('host') === 'embed';
1202
+ /**
1203
+ * The validated parent origin, read from the `?basedomain=` query param set
1204
+ * by the embedding host in the iframe src URL.
1205
+ * Mirrors the same mechanism used by ActionCenterTokenManager.
1206
+ * Non-null only when `?host=embed` is present and `?basedomain=` is a valid URL.
1207
+ */
1208
+ (() => {
1209
+ if (!isHostEmbedded)
1210
+ return null;
1211
+ const basedomain = _params?.get('basedomain');
1212
+ if (!basedomain)
1213
+ return null;
1214
+ try {
1215
+ return new URL(basedomain).origin;
1216
+ }
1217
+ catch {
1218
+ console.warn('embeddingOrigin: basedomain query param is not a valid URL', basedomain);
1219
+ return null;
1220
+ }
1221
+ })();
1159
1222
 
1160
1223
  /**
1161
1224
  * Base64 encoding/decoding
@@ -1482,8 +1545,9 @@ class PaginationHelpers {
1482
1545
  });
1483
1546
  }
1484
1547
  // Extract and transform items from response
1485
- // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
1486
- const rawItems = Array.isArray(response.data) ? response.data : response.data?.[itemsField];
1548
+ // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N }).
1549
+ // itemsField may be a dotted path (e.g. 'data.agents') for nested envelopes.
1550
+ const rawItems = Array.isArray(response.data) ? response.data : resolveNestedField(response.data, itemsField);
1487
1551
  const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
1488
1552
  const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
1489
1553
  // Parse items - automatically handle JSON string responses
@@ -1529,7 +1593,7 @@ class PaginationHelpers {
1529
1593
  getEndpoint: config.getEndpoint,
1530
1594
  folderId,
1531
1595
  headers: config.headers,
1532
- paginationParams: cursor ? { cursor, pageSize } : jumpToPage ? { jumpToPage, pageSize } : { pageSize },
1596
+ paginationParams: cursor ? { cursor, pageSize } : jumpToPage !== undefined ? { jumpToPage, pageSize } : { pageSize },
1533
1597
  additionalParams: prefixedOptions,
1534
1598
  transformFn: config.transformFn,
1535
1599
  method: config.method,
@@ -1787,6 +1851,8 @@ class BaseService {
1787
1851
  // When true (default), converts pageNumber to a skip/offset value (e.g., page 3 with pageSize 10 → skip 20).
1788
1852
  // When false, passes pageNumber directly as the offset param — used by APIs that accept a page number instead of a record offset.
1789
1853
  const convertToSkip = paginationParams?.convertToSkip ?? true;
1854
+ // When true, sends pageNumber - 1 (for 0-based APIs). Default false (1-based).
1855
+ const zeroBased = paginationParams?.zeroBased ?? false;
1790
1856
  requestParams[pageSizeParam] = limitedPageSize;
1791
1857
  if (convertToSkip) {
1792
1858
  if (params.pageNumber && params.pageNumber > 1) {
@@ -1794,7 +1860,8 @@ class BaseService {
1794
1860
  }
1795
1861
  }
1796
1862
  else {
1797
- requestParams[offsetParam] = params.pageNumber || 1;
1863
+ const sdkPageNumber = params.pageNumber || 1;
1864
+ requestParams[offsetParam] = zeroBased ? sdkPageNumber - 1 : sdkPageNumber;
1798
1865
  }
1799
1866
  {
1800
1867
  requestParams[countParam] = true;
@@ -1823,8 +1890,9 @@ class BaseService {
1823
1890
  const totalCountField = fields.totalCountField || 'totalRecordCount';
1824
1891
  const continuationTokenField = fields.continuationTokenField || 'continuationToken';
1825
1892
  // Extract items and metadata
1826
- // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
1827
- const items = Array.isArray(response.data) ? response.data : (response.data[itemsField] || []);
1893
+ // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N }).
1894
+ // itemsField may be a dotted path (e.g. 'data.agents') for nested envelopes.
1895
+ const items = Array.isArray(response.data) ? response.data : (resolveNestedField(response.data, itemsField) || []);
1828
1896
  const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
1829
1897
  const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
1830
1898
  const continuationToken = response.data[continuationTokenField];
@@ -1911,7 +1979,9 @@ function createProcessInstanceMethods(instanceData, service) {
1911
1979
  async getExecutionHistory() {
1912
1980
  if (!instanceData.instanceId)
1913
1981
  throw new Error('Process instance ID is undefined');
1914
- return service.getExecutionHistory(instanceData.instanceId);
1982
+ if (!instanceData.folderKey)
1983
+ throw new Error('Process instance folder key is undefined');
1984
+ return service.getExecutionHistory(instanceData.instanceId, instanceData.folderKey);
1915
1985
  },
1916
1986
  async getBpmn() {
1917
1987
  if (!instanceData.instanceId)
@@ -2108,12 +2178,6 @@ const ProcessInstanceMap = {
2108
2178
  createdAt: 'createdTime',
2109
2179
  updatedAt: 'updatedTime'
2110
2180
  };
2111
- /**
2112
- * Maps fields for Process Instance Execution History to ensure consistent naming
2113
- */
2114
- const ProcessInstanceExecutionHistoryMap = {
2115
- startTime: 'startedTime'
2116
- };
2117
2181
 
2118
2182
  class ProcessInstancesService extends BaseService {
2119
2183
  /**
@@ -2194,11 +2258,66 @@ class ProcessInstancesService extends BaseService {
2194
2258
  /**
2195
2259
  * Get execution history (spans) for a process instance
2196
2260
  * @param instanceId The ID of the instance to get history for
2197
- * @returns Promise<ProcessInstanceExecutionHistoryResponse[]>
2261
+ * @param folderKey The folder key for authorization
2262
+ * @returns Promise resolving to execution history
2263
+ * {@link ProcessInstanceExecutionHistoryResponse}
2264
+ * @example
2265
+ * ```typescript
2266
+ * // Get execution history for a process instance
2267
+ * const history = await processInstances.getExecutionHistory(
2268
+ * <instanceId>,
2269
+ * <folderKey>
2270
+ * );
2271
+ *
2272
+ * // Analyze execution timeline
2273
+ * history.forEach(span => {
2274
+ * console.log(`Activity: ${span.name}`);
2275
+ * console.log(`Start: ${span.startedTime}`);
2276
+ * console.log(`End: ${span.endTime}`);
2277
+ * });
2278
+ * ```
2198
2279
  */
2199
- async getExecutionHistory(instanceId) {
2200
- const response = await this.get(MAESTRO_ENDPOINTS.INSTANCES.GET_EXECUTION_HISTORY(instanceId));
2201
- return response.data.map(historyItem => transformData(historyItem, ProcessInstanceExecutionHistoryMap));
2280
+ async getExecutionHistory(instanceId, folderKey) {
2281
+ const headers = createHeaders({ [FOLDER_KEY]: folderKey });
2282
+ const elementExecResponse = await this.get(MAESTRO_ENDPOINTS.INSTANCES.GET_ELEMENT_EXECUTIONS(instanceId), { headers });
2283
+ const traceId = elementExecResponse.data.traceId;
2284
+ const spansResponse = await this.get(MAESTRO_ENDPOINTS.TRACES.GET_SPANS(traceId), { headers });
2285
+ // Build span lookup keyed by elementRunId extracted from Attributes JSON
2286
+ const spanMap = new Map();
2287
+ for (const span of spansResponse.data) {
2288
+ try {
2289
+ const attrs = span.Attributes ? JSON.parse(span.Attributes) : null;
2290
+ if (attrs?.elementRunId) {
2291
+ spanMap.set(attrs.elementRunId, span);
2292
+ }
2293
+ }
2294
+ catch {
2295
+ // skip spans with unparseable Attributes — they won't match any elementRunId
2296
+ }
2297
+ }
2298
+ const results = [];
2299
+ for (const elementExec of elementExecResponse.data.elementExecutions) {
2300
+ for (const run of elementExec.elementRuns) {
2301
+ const span = spanMap.get(run.elementRunId);
2302
+ if (span) {
2303
+ results.push(this.mapSpanToHistory(span));
2304
+ }
2305
+ }
2306
+ }
2307
+ return results;
2308
+ }
2309
+ mapSpanToHistory(span) {
2310
+ return {
2311
+ id: span.Id,
2312
+ traceId: span.TraceId,
2313
+ parentId: span.ParentId,
2314
+ name: span.Name,
2315
+ startedTime: span.StartTime,
2316
+ endTime: span.EndTime,
2317
+ attributes: span.Attributes,
2318
+ updatedTime: span.UpdatedAt,
2319
+ expiredTime: span.ExpiryTimeUtc,
2320
+ };
2202
2321
  }
2203
2322
  /**
2204
2323
  * Get BPMN XML file for a process instance
@@ -2514,6 +2633,52 @@ class MaestroProcessesService extends BaseService {
2514
2633
  const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.TOP_PROCESSES_BY_RUN_COUNT, buildInsightsTopBody(startTime, endTime, false, options));
2515
2634
  return (data ?? []).map(process => ({ ...process, name: process.packageId }));
2516
2635
  }
2636
+ /**
2637
+ * Get the top 10 BPMN elements ranked by failure count within a time range.
2638
+ *
2639
+ * Returns an array of up to 10 elements sorted by how many times they failed,
2640
+ * useful for identifying the most error-prone activities in processes.
2641
+ *
2642
+ * @param startTime - Start of the time range to query
2643
+ * @param endTime - End of the time range to query
2644
+ * @param options - Optional filters (packageId, processKey, version)
2645
+ * @returns Promise resolving to an array of {@link ElementGetTopFailedCountResponse}
2646
+ * @example
2647
+ * ```typescript
2648
+ * import { MaestroProcesses } from '@uipath/uipath-typescript/maestro-processes';
2649
+ *
2650
+ * const maestroProcesses = new MaestroProcesses(sdk);
2651
+ *
2652
+ * // Get top failing elements for the last 7 days
2653
+ * const topFailing = await maestroProcesses.getTopElementFailedCount(
2654
+ * new Date(Date.now() - 7 * 24 * 60 * 60 * 1000),
2655
+ * new Date()
2656
+ * );
2657
+ *
2658
+ * for (const element of topFailing) {
2659
+ * console.log(`${element.elementName} (${element.elementType}): ${element.failedCount} failures`);
2660
+ * }
2661
+ * ```
2662
+ *
2663
+ * @example
2664
+ * ```typescript
2665
+ * // Get top failing elements for a specific process
2666
+ * const filtered = await maestroProcesses.getTopElementFailedCount(
2667
+ * new Date(Date.now() - 7 * 24 * 60 * 60 * 1000),
2668
+ * new Date(),
2669
+ * { processKey: '<processKey>' }
2670
+ * );
2671
+ * ```
2672
+ */
2673
+ async getTopElementFailedCount(startTime, endTime, options) {
2674
+ const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.TOP_ELEMENTS_WITH_FAILURE, buildInsightsTopBody(startTime, endTime, false, options));
2675
+ return (data ?? []).map(item => ({
2676
+ elementName: item.elementName,
2677
+ elementType: item.elementType,
2678
+ processKey: item.processKey,
2679
+ failedCount: item.count,
2680
+ }));
2681
+ }
2517
2682
  /**
2518
2683
  * Get all instances status counts aggregated by date for maestro processes.
2519
2684
  *
@@ -2644,6 +2809,41 @@ class MaestroProcessesService extends BaseService {
2644
2809
  const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.TOP_PROCESSES_BY_DURATION, buildInsightsTopBody(startTime, endTime, false, options));
2645
2810
  return (data ?? []).map(process => ({ ...process, name: process.packageId }));
2646
2811
  }
2812
+ /**
2813
+ * Get element stats for process instances
2814
+ *
2815
+ * Returns per-element execution counts (success, fail, terminated, paused, in-progress) and
2816
+ * duration percentile metrics (min, max, avg, p50, p95, p99) for BPMN elements within a process.
2817
+ *
2818
+ * @param processKey - Process key to filter by
2819
+ * @param packageId - Package identifier
2820
+ * @param startTime - Start of the time range to query
2821
+ * @param endTime - End of the time range to query
2822
+ * @param packageVersion - Package version to filter by
2823
+ * @returns Promise resolving to an array of {@link ElementStats}
2824
+ * @example
2825
+ * ```typescript
2826
+ * // Get element metrics for a process
2827
+ * const elements = await maestroProcesses.getElementStats(
2828
+ * '<processKey>',
2829
+ * '<packageId>',
2830
+ * new Date('2026-04-01'),
2831
+ * new Date(),
2832
+ * '1.0.1'
2833
+ * );
2834
+ *
2835
+ * // Analyze element performance
2836
+ * for (const element of elements) {
2837
+ * console.log(`Element: ${element.elementId}`);
2838
+ * console.log(` Success: ${element.successCount}, Failed: ${element.failCount}`);
2839
+ * console.log(` Avg duration: ${element.avgDurationMs}ms, P95: ${element.p95DurationMs}ms`);
2840
+ * }
2841
+ * ```
2842
+ */
2843
+ async getElementStats(processKey, packageId, startTime, endTime, packageVersion) {
2844
+ const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.ELEMENT_COUNT_BY_STATUS, buildElementCountByStatusBody(processKey, packageId, startTime, endTime, packageVersion));
2845
+ return data ?? [];
2846
+ }
2647
2847
  }
2648
2848
  __decorate([
2649
2849
  track('MaestroProcesses.GetAll')
@@ -2654,6 +2854,9 @@ __decorate([
2654
2854
  __decorate([
2655
2855
  track('MaestroProcesses.GetTopRunCount')
2656
2856
  ], MaestroProcessesService.prototype, "getTopRunCount", null);
2857
+ __decorate([
2858
+ track('MaestroProcesses.GetTopElementFailedCount')
2859
+ ], MaestroProcessesService.prototype, "getTopElementFailedCount", null);
2657
2860
  __decorate([
2658
2861
  track('MaestroProcesses.GetInstanceStatusTimeline')
2659
2862
  ], MaestroProcessesService.prototype, "getInstanceStatusTimeline", null);
@@ -2663,6 +2866,9 @@ __decorate([
2663
2866
  __decorate([
2664
2867
  track('MaestroProcesses.GetTopExecutionDuration')
2665
2868
  ], MaestroProcessesService.prototype, "getTopExecutionDuration", null);
2869
+ __decorate([
2870
+ track('MaestroProcesses.GetElementStats')
2871
+ ], MaestroProcessesService.prototype, "getElementStats", null);
2666
2872
 
2667
2873
  /**
2668
2874
  * Service class for Maestro Process Incidents
@@ -721,6 +721,32 @@ function filterUndefined(obj) {
721
721
  */
722
722
  const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
723
723
  isBrowser && window.self != window.top && window.location.href.includes('source=ActionCenter');
724
+ const _params = isBrowser ? new URLSearchParams(window.location.search) : null;
725
+ /**
726
+ * True when the coded app has been loaded inside a host frame that explicitly
727
+ * opted into token delegation by adding `?host=embed` to the iframe src URL.
728
+ */
729
+ const isHostEmbedded = isBrowser && window.self !== window.top && _params?.get('host') === 'embed';
730
+ /**
731
+ * The validated parent origin, read from the `?basedomain=` query param set
732
+ * by the embedding host in the iframe src URL.
733
+ * Mirrors the same mechanism used by ActionCenterTokenManager.
734
+ * Non-null only when `?host=embed` is present and `?basedomain=` is a valid URL.
735
+ */
736
+ (() => {
737
+ if (!isHostEmbedded)
738
+ return null;
739
+ const basedomain = _params?.get('basedomain');
740
+ if (!basedomain)
741
+ return null;
742
+ try {
743
+ return new URL(basedomain).origin;
744
+ }
745
+ catch {
746
+ console.warn('embeddingOrigin: basedomain query param is not a valid URL', basedomain);
747
+ return null;
748
+ }
749
+ })();
724
750
 
725
751
  /**
726
752
  * Base64 encoding/decoding
@@ -1344,8 +1370,9 @@ class PaginationHelpers {
1344
1370
  });
1345
1371
  }
1346
1372
  // Extract and transform items from response
1347
- // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
1348
- const rawItems = Array.isArray(response.data) ? response.data : response.data?.[itemsField];
1373
+ // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N }).
1374
+ // itemsField may be a dotted path (e.g. 'data.agents') for nested envelopes.
1375
+ const rawItems = Array.isArray(response.data) ? response.data : resolveNestedField(response.data, itemsField);
1349
1376
  const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
1350
1377
  const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
1351
1378
  // Parse items - automatically handle JSON string responses
@@ -1391,7 +1418,7 @@ class PaginationHelpers {
1391
1418
  getEndpoint: config.getEndpoint,
1392
1419
  folderId,
1393
1420
  headers: config.headers,
1394
- paginationParams: cursor ? { cursor, pageSize } : jumpToPage ? { jumpToPage, pageSize } : { pageSize },
1421
+ paginationParams: cursor ? { cursor, pageSize } : jumpToPage !== undefined ? { jumpToPage, pageSize } : { pageSize },
1395
1422
  additionalParams: prefixedOptions,
1396
1423
  transformFn: config.transformFn,
1397
1424
  method: config.method,
@@ -1649,6 +1676,8 @@ class BaseService {
1649
1676
  // When true (default), converts pageNumber to a skip/offset value (e.g., page 3 with pageSize 10 → skip 20).
1650
1677
  // When false, passes pageNumber directly as the offset param — used by APIs that accept a page number instead of a record offset.
1651
1678
  const convertToSkip = paginationParams?.convertToSkip ?? true;
1679
+ // When true, sends pageNumber - 1 (for 0-based APIs). Default false (1-based).
1680
+ const zeroBased = paginationParams?.zeroBased ?? false;
1652
1681
  requestParams[pageSizeParam] = limitedPageSize;
1653
1682
  if (convertToSkip) {
1654
1683
  if (params.pageNumber && params.pageNumber > 1) {
@@ -1656,7 +1685,8 @@ class BaseService {
1656
1685
  }
1657
1686
  }
1658
1687
  else {
1659
- requestParams[offsetParam] = params.pageNumber || 1;
1688
+ const sdkPageNumber = params.pageNumber || 1;
1689
+ requestParams[offsetParam] = zeroBased ? sdkPageNumber - 1 : sdkPageNumber;
1660
1690
  }
1661
1691
  {
1662
1692
  requestParams[countParam] = true;
@@ -1685,8 +1715,9 @@ class BaseService {
1685
1715
  const totalCountField = fields.totalCountField || 'totalRecordCount';
1686
1716
  const continuationTokenField = fields.continuationTokenField || 'continuationToken';
1687
1717
  // Extract items and metadata
1688
- // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
1689
- const items = Array.isArray(response.data) ? response.data : (response.data[itemsField] || []);
1718
+ // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N }).
1719
+ // itemsField may be a dotted path (e.g. 'data.agents') for nested envelopes.
1720
+ const items = Array.isArray(response.data) ? response.data : (resolveNestedField(response.data, itemsField) || []);
1690
1721
  const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
1691
1722
  const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
1692
1723
  const continuationToken = response.data[continuationTokenField];
@@ -107,6 +107,7 @@ interface RequestWithPaginationOptions extends RequestSpec {
107
107
  tokenParam?: string;
108
108
  countParam?: string;
109
109
  convertToSkip?: boolean;
110
+ zeroBased?: boolean;
110
111
  };
111
112
  };
112
113
  }
@@ -719,6 +719,32 @@ function filterUndefined(obj) {
719
719
  */
720
720
  const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
721
721
  isBrowser && window.self != window.top && window.location.href.includes('source=ActionCenter');
722
+ const _params = isBrowser ? new URLSearchParams(window.location.search) : null;
723
+ /**
724
+ * True when the coded app has been loaded inside a host frame that explicitly
725
+ * opted into token delegation by adding `?host=embed` to the iframe src URL.
726
+ */
727
+ const isHostEmbedded = isBrowser && window.self !== window.top && _params?.get('host') === 'embed';
728
+ /**
729
+ * The validated parent origin, read from the `?basedomain=` query param set
730
+ * by the embedding host in the iframe src URL.
731
+ * Mirrors the same mechanism used by ActionCenterTokenManager.
732
+ * Non-null only when `?host=embed` is present and `?basedomain=` is a valid URL.
733
+ */
734
+ (() => {
735
+ if (!isHostEmbedded)
736
+ return null;
737
+ const basedomain = _params?.get('basedomain');
738
+ if (!basedomain)
739
+ return null;
740
+ try {
741
+ return new URL(basedomain).origin;
742
+ }
743
+ catch {
744
+ console.warn('embeddingOrigin: basedomain query param is not a valid URL', basedomain);
745
+ return null;
746
+ }
747
+ })();
722
748
 
723
749
  /**
724
750
  * Base64 encoding/decoding
@@ -1342,8 +1368,9 @@ class PaginationHelpers {
1342
1368
  });
1343
1369
  }
1344
1370
  // Extract and transform items from response
1345
- // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
1346
- const rawItems = Array.isArray(response.data) ? response.data : response.data?.[itemsField];
1371
+ // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N }).
1372
+ // itemsField may be a dotted path (e.g. 'data.agents') for nested envelopes.
1373
+ const rawItems = Array.isArray(response.data) ? response.data : resolveNestedField(response.data, itemsField);
1347
1374
  const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
1348
1375
  const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
1349
1376
  // Parse items - automatically handle JSON string responses
@@ -1389,7 +1416,7 @@ class PaginationHelpers {
1389
1416
  getEndpoint: config.getEndpoint,
1390
1417
  folderId,
1391
1418
  headers: config.headers,
1392
- paginationParams: cursor ? { cursor, pageSize } : jumpToPage ? { jumpToPage, pageSize } : { pageSize },
1419
+ paginationParams: cursor ? { cursor, pageSize } : jumpToPage !== undefined ? { jumpToPage, pageSize } : { pageSize },
1393
1420
  additionalParams: prefixedOptions,
1394
1421
  transformFn: config.transformFn,
1395
1422
  method: config.method,
@@ -1647,6 +1674,8 @@ class BaseService {
1647
1674
  // When true (default), converts pageNumber to a skip/offset value (e.g., page 3 with pageSize 10 → skip 20).
1648
1675
  // When false, passes pageNumber directly as the offset param — used by APIs that accept a page number instead of a record offset.
1649
1676
  const convertToSkip = paginationParams?.convertToSkip ?? true;
1677
+ // When true, sends pageNumber - 1 (for 0-based APIs). Default false (1-based).
1678
+ const zeroBased = paginationParams?.zeroBased ?? false;
1650
1679
  requestParams[pageSizeParam] = limitedPageSize;
1651
1680
  if (convertToSkip) {
1652
1681
  if (params.pageNumber && params.pageNumber > 1) {
@@ -1654,7 +1683,8 @@ class BaseService {
1654
1683
  }
1655
1684
  }
1656
1685
  else {
1657
- requestParams[offsetParam] = params.pageNumber || 1;
1686
+ const sdkPageNumber = params.pageNumber || 1;
1687
+ requestParams[offsetParam] = zeroBased ? sdkPageNumber - 1 : sdkPageNumber;
1658
1688
  }
1659
1689
  {
1660
1690
  requestParams[countParam] = true;
@@ -1683,8 +1713,9 @@ class BaseService {
1683
1713
  const totalCountField = fields.totalCountField || 'totalRecordCount';
1684
1714
  const continuationTokenField = fields.continuationTokenField || 'continuationToken';
1685
1715
  // Extract items and metadata
1686
- // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
1687
- const items = Array.isArray(response.data) ? response.data : (response.data[itemsField] || []);
1716
+ // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N }).
1717
+ // itemsField may be a dotted path (e.g. 'data.agents') for nested envelopes.
1718
+ const items = Array.isArray(response.data) ? response.data : (resolveNestedField(response.data, itemsField) || []);
1688
1719
  const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
1689
1720
  const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
1690
1721
  const continuationToken = response.data[continuationTokenField];
@@ -721,6 +721,32 @@ function filterUndefined(obj) {
721
721
  */
722
722
  const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
723
723
  isBrowser && window.self != window.top && window.location.href.includes('source=ActionCenter');
724
+ const _params = isBrowser ? new URLSearchParams(window.location.search) : null;
725
+ /**
726
+ * True when the coded app has been loaded inside a host frame that explicitly
727
+ * opted into token delegation by adding `?host=embed` to the iframe src URL.
728
+ */
729
+ const isHostEmbedded = isBrowser && window.self !== window.top && _params?.get('host') === 'embed';
730
+ /**
731
+ * The validated parent origin, read from the `?basedomain=` query param set
732
+ * by the embedding host in the iframe src URL.
733
+ * Mirrors the same mechanism used by ActionCenterTokenManager.
734
+ * Non-null only when `?host=embed` is present and `?basedomain=` is a valid URL.
735
+ */
736
+ (() => {
737
+ if (!isHostEmbedded)
738
+ return null;
739
+ const basedomain = _params?.get('basedomain');
740
+ if (!basedomain)
741
+ return null;
742
+ try {
743
+ return new URL(basedomain).origin;
744
+ }
745
+ catch {
746
+ console.warn('embeddingOrigin: basedomain query param is not a valid URL', basedomain);
747
+ return null;
748
+ }
749
+ })();
724
750
 
725
751
  /**
726
752
  * Base64 encoding/decoding
@@ -1281,8 +1307,9 @@ class PaginationHelpers {
1281
1307
  });
1282
1308
  }
1283
1309
  // Extract and transform items from response
1284
- // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
1285
- const rawItems = Array.isArray(response.data) ? response.data : response.data?.[itemsField];
1310
+ // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N }).
1311
+ // itemsField may be a dotted path (e.g. 'data.agents') for nested envelopes.
1312
+ const rawItems = Array.isArray(response.data) ? response.data : resolveNestedField(response.data, itemsField);
1286
1313
  const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
1287
1314
  const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
1288
1315
  // Parse items - automatically handle JSON string responses
@@ -1328,7 +1355,7 @@ class PaginationHelpers {
1328
1355
  getEndpoint: config.getEndpoint,
1329
1356
  folderId,
1330
1357
  headers: config.headers,
1331
- paginationParams: cursor ? { cursor, pageSize } : jumpToPage ? { jumpToPage, pageSize } : { pageSize },
1358
+ paginationParams: cursor ? { cursor, pageSize } : jumpToPage !== undefined ? { jumpToPage, pageSize } : { pageSize },
1332
1359
  additionalParams: prefixedOptions,
1333
1360
  transformFn: config.transformFn,
1334
1361
  method: config.method,
@@ -1586,6 +1613,8 @@ class BaseService {
1586
1613
  // When true (default), converts pageNumber to a skip/offset value (e.g., page 3 with pageSize 10 → skip 20).
1587
1614
  // When false, passes pageNumber directly as the offset param — used by APIs that accept a page number instead of a record offset.
1588
1615
  const convertToSkip = paginationParams?.convertToSkip ?? true;
1616
+ // When true, sends pageNumber - 1 (for 0-based APIs). Default false (1-based).
1617
+ const zeroBased = paginationParams?.zeroBased ?? false;
1589
1618
  requestParams[pageSizeParam] = limitedPageSize;
1590
1619
  if (convertToSkip) {
1591
1620
  if (params.pageNumber && params.pageNumber > 1) {
@@ -1593,7 +1622,8 @@ class BaseService {
1593
1622
  }
1594
1623
  }
1595
1624
  else {
1596
- requestParams[offsetParam] = params.pageNumber || 1;
1625
+ const sdkPageNumber = params.pageNumber || 1;
1626
+ requestParams[offsetParam] = zeroBased ? sdkPageNumber - 1 : sdkPageNumber;
1597
1627
  }
1598
1628
  {
1599
1629
  requestParams[countParam] = true;
@@ -1622,8 +1652,9 @@ class BaseService {
1622
1652
  const totalCountField = fields.totalCountField || 'totalRecordCount';
1623
1653
  const continuationTokenField = fields.continuationTokenField || 'continuationToken';
1624
1654
  // Extract items and metadata
1625
- // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
1626
- const items = Array.isArray(response.data) ? response.data : (response.data[itemsField] || []);
1655
+ // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N }).
1656
+ // itemsField may be a dotted path (e.g. 'data.agents') for nested envelopes.
1657
+ const items = Array.isArray(response.data) ? response.data : (resolveNestedField(response.data, itemsField) || []);
1627
1658
  const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
1628
1659
  const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
1629
1660
  const continuationToken = response.data[continuationTokenField];
@@ -107,6 +107,7 @@ interface RequestWithPaginationOptions extends RequestSpec {
107
107
  tokenParam?: string;
108
108
  countParam?: string;
109
109
  convertToSkip?: boolean;
110
+ zeroBased?: boolean;
110
111
  };
111
112
  };
112
113
  }