@uipath/uipath-typescript 1.3.11 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/dist/agent-memory/index.cjs +1765 -0
  2. package/dist/agent-memory/index.d.ts +588 -0
  3. package/dist/agent-memory/index.mjs +1763 -0
  4. package/dist/agents/index.cjs +1726 -0
  5. package/dist/agents/index.d.ts +502 -0
  6. package/dist/agents/index.mjs +1724 -0
  7. package/dist/assets/index.cjs +155 -30
  8. package/dist/assets/index.d.ts +84 -5
  9. package/dist/assets/index.mjs +155 -30
  10. package/dist/attachments/index.cjs +37 -6
  11. package/dist/attachments/index.d.ts +1 -0
  12. package/dist/attachments/index.mjs +37 -6
  13. package/dist/buckets/index.cjs +37 -6
  14. package/dist/buckets/index.d.ts +1 -0
  15. package/dist/buckets/index.mjs +37 -6
  16. package/dist/cases/index.cjs +141 -10
  17. package/dist/cases/index.d.ts +118 -7
  18. package/dist/cases/index.mjs +141 -11
  19. package/dist/conversational-agent/index.cjs +124 -57
  20. package/dist/conversational-agent/index.d.ts +190 -122
  21. package/dist/conversational-agent/index.mjs +124 -57
  22. package/dist/core/index.cjs +413 -105
  23. package/dist/core/index.d.ts +15 -0
  24. package/dist/core/index.mjs +413 -105
  25. package/dist/entities/index.cjs +122 -43
  26. package/dist/entities/index.d.ts +140 -35
  27. package/dist/entities/index.mjs +122 -43
  28. package/dist/feedback/index.cjs +37 -6
  29. package/dist/feedback/index.d.ts +1 -0
  30. package/dist/feedback/index.mjs +37 -6
  31. package/dist/governance/index.cjs +1782 -0
  32. package/dist/governance/index.d.ts +598 -0
  33. package/dist/governance/index.mjs +1780 -0
  34. package/dist/index.cjs +956 -283
  35. package/dist/index.d.ts +1138 -121
  36. package/dist/index.mjs +956 -284
  37. package/dist/index.umd.js +3113 -2423
  38. package/dist/jobs/index.cjs +37 -6
  39. package/dist/jobs/index.d.ts +1 -0
  40. package/dist/jobs/index.mjs +37 -6
  41. package/dist/maestro-processes/index.cjs +173 -18
  42. package/dist/maestro-processes/index.d.ts +131 -9
  43. package/dist/maestro-processes/index.mjs +173 -18
  44. package/dist/processes/index.cjs +37 -6
  45. package/dist/processes/index.d.ts +1 -0
  46. package/dist/processes/index.mjs +37 -6
  47. package/dist/queues/index.cjs +37 -6
  48. package/dist/queues/index.d.ts +1 -0
  49. package/dist/queues/index.mjs +37 -6
  50. package/dist/tasks/index.cjs +37 -6
  51. package/dist/tasks/index.d.ts +1 -0
  52. package/dist/tasks/index.mjs +37 -6
  53. package/dist/traces/index.cjs +37 -6
  54. package/dist/traces/index.d.ts +1 -0
  55. package/dist/traces/index.mjs +37 -6
  56. package/package.json +32 -2
@@ -958,6 +958,32 @@ function filterUndefined(obj) {
958
958
  */
959
959
  const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
960
960
  isBrowser && window.self != window.top && window.location.href.includes('source=ActionCenter');
961
+ const _params = isBrowser ? new URLSearchParams(window.location.search) : null;
962
+ /**
963
+ * True when the coded app has been loaded inside a host frame that explicitly
964
+ * opted into token delegation by adding `?host=embed` to the iframe src URL.
965
+ */
966
+ const isHostEmbedded = isBrowser && window.self !== window.top && _params?.get('host') === 'embed';
967
+ /**
968
+ * The validated parent origin, read from the `?basedomain=` query param set
969
+ * by the embedding host in the iframe src URL.
970
+ * Mirrors the same mechanism used by ActionCenterTokenManager.
971
+ * Non-null only when `?host=embed` is present and `?basedomain=` is a valid URL.
972
+ */
973
+ (() => {
974
+ if (!isHostEmbedded)
975
+ return null;
976
+ const basedomain = _params?.get('basedomain');
977
+ if (!basedomain)
978
+ return null;
979
+ try {
980
+ return new URL(basedomain).origin;
981
+ }
982
+ catch {
983
+ console.warn('embeddingOrigin: basedomain query param is not a valid URL', basedomain);
984
+ return null;
985
+ }
986
+ })();
961
987
 
962
988
  /**
963
989
  * Base64 encoding/decoding
@@ -1322,8 +1348,9 @@ class PaginationHelpers {
1322
1348
  });
1323
1349
  }
1324
1350
  // Extract and transform items from response
1325
- // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
1326
- const rawItems = Array.isArray(response.data) ? response.data : response.data?.[itemsField];
1351
+ // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N }).
1352
+ // itemsField may be a dotted path (e.g. 'data.agents') for nested envelopes.
1353
+ const rawItems = Array.isArray(response.data) ? response.data : resolveNestedField(response.data, itemsField);
1327
1354
  const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
1328
1355
  const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
1329
1356
  // Parse items - automatically handle JSON string responses
@@ -1369,7 +1396,7 @@ class PaginationHelpers {
1369
1396
  getEndpoint: config.getEndpoint,
1370
1397
  folderId,
1371
1398
  headers: config.headers,
1372
- paginationParams: cursor ? { cursor, pageSize } : jumpToPage ? { jumpToPage, pageSize } : { pageSize },
1399
+ paginationParams: cursor ? { cursor, pageSize } : jumpToPage !== undefined ? { jumpToPage, pageSize } : { pageSize },
1373
1400
  additionalParams: prefixedOptions,
1374
1401
  transformFn: config.transformFn,
1375
1402
  method: config.method,
@@ -1627,6 +1654,8 @@ class BaseService {
1627
1654
  // When true (default), converts pageNumber to a skip/offset value (e.g., page 3 with pageSize 10 → skip 20).
1628
1655
  // When false, passes pageNumber directly as the offset param — used by APIs that accept a page number instead of a record offset.
1629
1656
  const convertToSkip = paginationParams?.convertToSkip ?? true;
1657
+ // When true, sends pageNumber - 1 (for 0-based APIs). Default false (1-based).
1658
+ const zeroBased = paginationParams?.zeroBased ?? false;
1630
1659
  requestParams[pageSizeParam] = limitedPageSize;
1631
1660
  if (convertToSkip) {
1632
1661
  if (params.pageNumber && params.pageNumber > 1) {
@@ -1634,7 +1663,8 @@ class BaseService {
1634
1663
  }
1635
1664
  }
1636
1665
  else {
1637
- requestParams[offsetParam] = params.pageNumber || 1;
1666
+ const sdkPageNumber = params.pageNumber || 1;
1667
+ requestParams[offsetParam] = zeroBased ? sdkPageNumber - 1 : sdkPageNumber;
1638
1668
  }
1639
1669
  {
1640
1670
  requestParams[countParam] = true;
@@ -1663,8 +1693,9 @@ class BaseService {
1663
1693
  const totalCountField = fields.totalCountField || 'totalRecordCount';
1664
1694
  const continuationTokenField = fields.continuationTokenField || 'continuationToken';
1665
1695
  // Extract items and metadata
1666
- // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
1667
- const items = Array.isArray(response.data) ? response.data : (response.data[itemsField] || []);
1696
+ // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N }).
1697
+ // itemsField may be a dotted path (e.g. 'data.agents') for nested envelopes.
1698
+ const items = Array.isArray(response.data) ? response.data : (resolveNestedField(response.data, itemsField) || []);
1668
1699
  const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
1669
1700
  const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
1670
1701
  const continuationToken = response.data[continuationTokenField];
@@ -195,6 +195,7 @@ interface RequestWithPaginationOptions extends RequestSpec {
195
195
  tokenParam?: string;
196
196
  countParam?: string;
197
197
  convertToSkip?: boolean;
198
+ zeroBased?: boolean;
198
199
  };
199
200
  };
200
201
  }
@@ -956,6 +956,32 @@ function filterUndefined(obj) {
956
956
  */
957
957
  const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
958
958
  isBrowser && window.self != window.top && window.location.href.includes('source=ActionCenter');
959
+ const _params = isBrowser ? new URLSearchParams(window.location.search) : null;
960
+ /**
961
+ * True when the coded app has been loaded inside a host frame that explicitly
962
+ * opted into token delegation by adding `?host=embed` to the iframe src URL.
963
+ */
964
+ const isHostEmbedded = isBrowser && window.self !== window.top && _params?.get('host') === 'embed';
965
+ /**
966
+ * The validated parent origin, read from the `?basedomain=` query param set
967
+ * by the embedding host in the iframe src URL.
968
+ * Mirrors the same mechanism used by ActionCenterTokenManager.
969
+ * Non-null only when `?host=embed` is present and `?basedomain=` is a valid URL.
970
+ */
971
+ (() => {
972
+ if (!isHostEmbedded)
973
+ return null;
974
+ const basedomain = _params?.get('basedomain');
975
+ if (!basedomain)
976
+ return null;
977
+ try {
978
+ return new URL(basedomain).origin;
979
+ }
980
+ catch {
981
+ console.warn('embeddingOrigin: basedomain query param is not a valid URL', basedomain);
982
+ return null;
983
+ }
984
+ })();
959
985
 
960
986
  /**
961
987
  * Base64 encoding/decoding
@@ -1320,8 +1346,9 @@ class PaginationHelpers {
1320
1346
  });
1321
1347
  }
1322
1348
  // Extract and transform items from response
1323
- // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
1324
- const rawItems = Array.isArray(response.data) ? response.data : response.data?.[itemsField];
1349
+ // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N }).
1350
+ // itemsField may be a dotted path (e.g. 'data.agents') for nested envelopes.
1351
+ const rawItems = Array.isArray(response.data) ? response.data : resolveNestedField(response.data, itemsField);
1325
1352
  const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
1326
1353
  const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
1327
1354
  // Parse items - automatically handle JSON string responses
@@ -1367,7 +1394,7 @@ class PaginationHelpers {
1367
1394
  getEndpoint: config.getEndpoint,
1368
1395
  folderId,
1369
1396
  headers: config.headers,
1370
- paginationParams: cursor ? { cursor, pageSize } : jumpToPage ? { jumpToPage, pageSize } : { pageSize },
1397
+ paginationParams: cursor ? { cursor, pageSize } : jumpToPage !== undefined ? { jumpToPage, pageSize } : { pageSize },
1371
1398
  additionalParams: prefixedOptions,
1372
1399
  transformFn: config.transformFn,
1373
1400
  method: config.method,
@@ -1625,6 +1652,8 @@ class BaseService {
1625
1652
  // When true (default), converts pageNumber to a skip/offset value (e.g., page 3 with pageSize 10 → skip 20).
1626
1653
  // When false, passes pageNumber directly as the offset param — used by APIs that accept a page number instead of a record offset.
1627
1654
  const convertToSkip = paginationParams?.convertToSkip ?? true;
1655
+ // When true, sends pageNumber - 1 (for 0-based APIs). Default false (1-based).
1656
+ const zeroBased = paginationParams?.zeroBased ?? false;
1628
1657
  requestParams[pageSizeParam] = limitedPageSize;
1629
1658
  if (convertToSkip) {
1630
1659
  if (params.pageNumber && params.pageNumber > 1) {
@@ -1632,7 +1661,8 @@ class BaseService {
1632
1661
  }
1633
1662
  }
1634
1663
  else {
1635
- requestParams[offsetParam] = params.pageNumber || 1;
1664
+ const sdkPageNumber = params.pageNumber || 1;
1665
+ requestParams[offsetParam] = zeroBased ? sdkPageNumber - 1 : sdkPageNumber;
1636
1666
  }
1637
1667
  {
1638
1668
  requestParams[countParam] = true;
@@ -1661,8 +1691,9 @@ class BaseService {
1661
1691
  const totalCountField = fields.totalCountField || 'totalRecordCount';
1662
1692
  const continuationTokenField = fields.continuationTokenField || 'continuationToken';
1663
1693
  // Extract items and metadata
1664
- // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
1665
- const items = Array.isArray(response.data) ? response.data : (response.data[itemsField] || []);
1694
+ // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N }).
1695
+ // itemsField may be a dotted path (e.g. 'data.agents') for nested envelopes.
1696
+ const items = Array.isArray(response.data) ? response.data : (resolveNestedField(response.data, itemsField) || []);
1666
1697
  const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
1667
1698
  const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
1668
1699
  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
@@ -1324,8 +1350,9 @@ class PaginationHelpers {
1324
1350
  });
1325
1351
  }
1326
1352
  // Extract and transform items from response
1327
- // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
1328
- const rawItems = Array.isArray(response.data) ? response.data : response.data?.[itemsField];
1353
+ // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N }).
1354
+ // itemsField may be a dotted path (e.g. 'data.agents') for nested envelopes.
1355
+ const rawItems = Array.isArray(response.data) ? response.data : resolveNestedField(response.data, itemsField);
1329
1356
  const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
1330
1357
  const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
1331
1358
  // Parse items - automatically handle JSON string responses
@@ -1371,7 +1398,7 @@ class PaginationHelpers {
1371
1398
  getEndpoint: config.getEndpoint,
1372
1399
  folderId,
1373
1400
  headers: config.headers,
1374
- paginationParams: cursor ? { cursor, pageSize } : jumpToPage ? { jumpToPage, pageSize } : { pageSize },
1401
+ paginationParams: cursor ? { cursor, pageSize } : jumpToPage !== undefined ? { jumpToPage, pageSize } : { pageSize },
1375
1402
  additionalParams: prefixedOptions,
1376
1403
  transformFn: config.transformFn,
1377
1404
  method: config.method,
@@ -1629,6 +1656,8 @@ class BaseService {
1629
1656
  // When true (default), converts pageNumber to a skip/offset value (e.g., page 3 with pageSize 10 → skip 20).
1630
1657
  // When false, passes pageNumber directly as the offset param — used by APIs that accept a page number instead of a record offset.
1631
1658
  const convertToSkip = paginationParams?.convertToSkip ?? true;
1659
+ // When true, sends pageNumber - 1 (for 0-based APIs). Default false (1-based).
1660
+ const zeroBased = paginationParams?.zeroBased ?? false;
1632
1661
  requestParams[pageSizeParam] = limitedPageSize;
1633
1662
  if (convertToSkip) {
1634
1663
  if (params.pageNumber && params.pageNumber > 1) {
@@ -1636,7 +1665,8 @@ class BaseService {
1636
1665
  }
1637
1666
  }
1638
1667
  else {
1639
- requestParams[offsetParam] = params.pageNumber || 1;
1668
+ const sdkPageNumber = params.pageNumber || 1;
1669
+ requestParams[offsetParam] = zeroBased ? sdkPageNumber - 1 : sdkPageNumber;
1640
1670
  }
1641
1671
  {
1642
1672
  requestParams[countParam] = true;
@@ -1665,8 +1695,9 @@ class BaseService {
1665
1695
  const totalCountField = fields.totalCountField || 'totalRecordCount';
1666
1696
  const continuationTokenField = fields.continuationTokenField || 'continuationToken';
1667
1697
  // Extract items and metadata
1668
- // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
1669
- const items = Array.isArray(response.data) ? response.data : (response.data[itemsField] || []);
1698
+ // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N }).
1699
+ // itemsField may be a dotted path (e.g. 'data.agents') for nested envelopes.
1700
+ const items = Array.isArray(response.data) ? response.data : (resolveNestedField(response.data, itemsField) || []);
1670
1701
  const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
1671
1702
  const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
1672
1703
  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
@@ -1322,8 +1348,9 @@ class PaginationHelpers {
1322
1348
  });
1323
1349
  }
1324
1350
  // Extract and transform items from response
1325
- // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
1326
- const rawItems = Array.isArray(response.data) ? response.data : response.data?.[itemsField];
1351
+ // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N }).
1352
+ // itemsField may be a dotted path (e.g. 'data.agents') for nested envelopes.
1353
+ const rawItems = Array.isArray(response.data) ? response.data : resolveNestedField(response.data, itemsField);
1327
1354
  const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
1328
1355
  const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
1329
1356
  // Parse items - automatically handle JSON string responses
@@ -1369,7 +1396,7 @@ class PaginationHelpers {
1369
1396
  getEndpoint: config.getEndpoint,
1370
1397
  folderId,
1371
1398
  headers: config.headers,
1372
- paginationParams: cursor ? { cursor, pageSize } : jumpToPage ? { jumpToPage, pageSize } : { pageSize },
1399
+ paginationParams: cursor ? { cursor, pageSize } : jumpToPage !== undefined ? { jumpToPage, pageSize } : { pageSize },
1373
1400
  additionalParams: prefixedOptions,
1374
1401
  transformFn: config.transformFn,
1375
1402
  method: config.method,
@@ -1627,6 +1654,8 @@ class BaseService {
1627
1654
  // When true (default), converts pageNumber to a skip/offset value (e.g., page 3 with pageSize 10 → skip 20).
1628
1655
  // When false, passes pageNumber directly as the offset param — used by APIs that accept a page number instead of a record offset.
1629
1656
  const convertToSkip = paginationParams?.convertToSkip ?? true;
1657
+ // When true, sends pageNumber - 1 (for 0-based APIs). Default false (1-based).
1658
+ const zeroBased = paginationParams?.zeroBased ?? false;
1630
1659
  requestParams[pageSizeParam] = limitedPageSize;
1631
1660
  if (convertToSkip) {
1632
1661
  if (params.pageNumber && params.pageNumber > 1) {
@@ -1634,7 +1663,8 @@ class BaseService {
1634
1663
  }
1635
1664
  }
1636
1665
  else {
1637
- requestParams[offsetParam] = params.pageNumber || 1;
1666
+ const sdkPageNumber = params.pageNumber || 1;
1667
+ requestParams[offsetParam] = zeroBased ? sdkPageNumber - 1 : sdkPageNumber;
1638
1668
  }
1639
1669
  {
1640
1670
  requestParams[countParam] = true;
@@ -1663,8 +1693,9 @@ class BaseService {
1663
1693
  const totalCountField = fields.totalCountField || 'totalRecordCount';
1664
1694
  const continuationTokenField = fields.continuationTokenField || 'continuationToken';
1665
1695
  // Extract items and metadata
1666
- // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
1667
- const items = Array.isArray(response.data) ? response.data : (response.data[itemsField] || []);
1696
+ // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N }).
1697
+ // itemsField may be a dotted path (e.g. 'data.agents') for nested envelopes.
1698
+ const items = Array.isArray(response.data) ? response.data : (resolveNestedField(response.data, itemsField) || []);
1668
1699
  const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
1669
1700
  const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
1670
1701
  const continuationToken = response.data[continuationTokenField];
@@ -61,6 +61,7 @@ var ProcessType;
61
61
  */
62
62
  const ORCHESTRATOR_BASE = 'orchestrator_';
63
63
  const PIMS_BASE = 'pims_';
64
+ const LLMOPS_BASE = 'llmopstenant_';
64
65
  const INSIGHTS_RTM_BASE = 'insightsrtm_';
65
66
 
66
67
  /**
@@ -100,7 +101,7 @@ const MAESTRO_ENDPOINTS = {
100
101
  INSTANCES: {
101
102
  GET_ALL: `${PIMS_BASE}/api/v1/instances`,
102
103
  GET_BY_ID: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}`,
103
- GET_EXECUTION_HISTORY: (instanceId) => `${PIMS_BASE}/api/v1/spans/${instanceId}`,
104
+ GET_ELEMENT_EXECUTIONS: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/element-executions`,
104
105
  GET_BPMN: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/bpmn`,
105
106
  GET_VARIABLES: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/variables`,
106
107
  CANCEL: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/cancel`,
@@ -112,6 +113,9 @@ const MAESTRO_ENDPOINTS = {
112
113
  GET_BY_PROCESS: (processKey) => `${PIMS_BASE}/api/v1/incidents/process/${processKey}`,
113
114
  GET_BY_INSTANCE: (instanceId) => `${PIMS_BASE}/api/v1/instances/${instanceId}/incidents`,
114
115
  },
116
+ TRACES: {
117
+ GET_SPANS: (traceId) => `${LLMOPS_BASE}/api/Traces/spans?traceId=${traceId}`,
118
+ },
115
119
  CASES: {
116
120
  GET_CASE_JSON: (instanceId) => `${PIMS_BASE}/api/v1/cases/${instanceId}/case-json`,
117
121
  GET_ELEMENT_EXECUTIONS: (instanceId) => `${PIMS_BASE}/api/v1/element-executions/case-instances/${instanceId}`,
@@ -132,9 +136,45 @@ const MAESTRO_ENDPOINTS = {
132
136
  INSTANCE_STATUS_BY_DATE: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/InstanceStatusByDate`,
133
137
  /** Top processes ranked by total duration */
134
138
  TOP_PROCESSES_BY_DURATION: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/TopProcessesByDuration`,
139
+ /** Element count by status for agentic instances (process and case) */
140
+ ELEMENT_COUNT_BY_STATUS: `${INSIGHTS_RTM_BASE}/agenticInstanceStatus/ElementCountByStatus`,
135
141
  },
136
142
  };
137
143
 
144
+ /**
145
+ * Maestro Cases Models
146
+ * Model classes for Maestro cases
147
+ */
148
+ /**
149
+ * Creates methods for a case object
150
+ *
151
+ * @param caseData - The case data (response from API)
152
+ * @param service - The cases service instance
153
+ * @returns Object containing case methods
154
+ */
155
+ function createCaseMethods(caseData, service) {
156
+ return {
157
+ getElementStats(startTime, endTime, packageVersion) {
158
+ if (!caseData.processKey)
159
+ throw new Error('Process key is undefined');
160
+ if (!caseData.packageId)
161
+ throw new Error('Package ID is undefined');
162
+ return service.getElementStats(caseData.processKey, caseData.packageId, startTime, endTime, packageVersion);
163
+ }
164
+ };
165
+ }
166
+ /**
167
+ * Creates an actionable case by combining API case data with operational methods.
168
+ *
169
+ * @param caseData - The case data from API
170
+ * @param service - The cases service instance
171
+ * @returns A case object with added methods
172
+ */
173
+ function createCaseWithMethods(caseData, service) {
174
+ const methods = createCaseMethods(caseData, service);
175
+ return Object.assign({}, caseData, methods);
176
+ }
177
+
138
178
  /**
139
179
  * Builds the request body for Insights RTM "top" endpoints.
140
180
  *
@@ -181,6 +221,28 @@ async function fetchInstanceStatusTimeline(postFn, startTime, endTime, isCaseMan
181
221
  });
182
222
  return response.data ?? [];
183
223
  }
224
+ /**
225
+ * Builds the request body for the ElementCountByStatus endpoint.
226
+ *
227
+ * @param processKey - Process key to filter by
228
+ * @param packageId - Package identifier
229
+ * @param startTime - Start of the time range to query
230
+ * @param endTime - End of the time range to query
231
+ * @param packageVersion - Package version to filter by
232
+ * @returns Request body for the ElementCountByStatus endpoint
233
+ * @internal
234
+ */
235
+ function buildElementCountByStatusBody(processKey, packageId, startTime, endTime, packageVersion) {
236
+ return {
237
+ commonParams: {
238
+ processKey,
239
+ packageId,
240
+ startTime: startTime.getTime(),
241
+ endTime: endTime.getTime(),
242
+ version: packageVersion
243
+ }
244
+ };
245
+ }
184
246
 
185
247
  /**
186
248
  * Type guards for error response types
@@ -877,6 +939,32 @@ function processODataArrayResponse(oDataResponse, successData) {
877
939
  */
878
940
  const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
879
941
  isBrowser && window.self != window.top && window.location.href.includes('source=ActionCenter');
942
+ const _params = isBrowser ? new URLSearchParams(window.location.search) : null;
943
+ /**
944
+ * True when the coded app has been loaded inside a host frame that explicitly
945
+ * opted into token delegation by adding `?host=embed` to the iframe src URL.
946
+ */
947
+ const isHostEmbedded = isBrowser && window.self !== window.top && _params?.get('host') === 'embed';
948
+ /**
949
+ * The validated parent origin, read from the `?basedomain=` query param set
950
+ * by the embedding host in the iframe src URL.
951
+ * Mirrors the same mechanism used by ActionCenterTokenManager.
952
+ * Non-null only when `?host=embed` is present and `?basedomain=` is a valid URL.
953
+ */
954
+ (() => {
955
+ if (!isHostEmbedded)
956
+ return null;
957
+ const basedomain = _params?.get('basedomain');
958
+ if (!basedomain)
959
+ return null;
960
+ try {
961
+ return new URL(basedomain).origin;
962
+ }
963
+ catch {
964
+ console.warn('embeddingOrigin: basedomain query param is not a valid URL', basedomain);
965
+ return null;
966
+ }
967
+ })();
880
968
 
881
969
  /**
882
970
  * Base64 encoding/decoding
@@ -1584,8 +1672,9 @@ class PaginationHelpers {
1584
1672
  });
1585
1673
  }
1586
1674
  // Extract and transform items from response
1587
- // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
1588
- const rawItems = Array.isArray(response.data) ? response.data : response.data?.[itemsField];
1675
+ // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N }).
1676
+ // itemsField may be a dotted path (e.g. 'data.agents') for nested envelopes.
1677
+ const rawItems = Array.isArray(response.data) ? response.data : resolveNestedField(response.data, itemsField);
1589
1678
  const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
1590
1679
  const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
1591
1680
  // Parse items - automatically handle JSON string responses
@@ -1631,7 +1720,7 @@ class PaginationHelpers {
1631
1720
  getEndpoint: config.getEndpoint,
1632
1721
  folderId,
1633
1722
  headers: config.headers,
1634
- paginationParams: cursor ? { cursor, pageSize } : jumpToPage ? { jumpToPage, pageSize } : { pageSize },
1723
+ paginationParams: cursor ? { cursor, pageSize } : jumpToPage !== undefined ? { jumpToPage, pageSize } : { pageSize },
1635
1724
  additionalParams: prefixedOptions,
1636
1725
  transformFn: config.transformFn,
1637
1726
  method: config.method,
@@ -1889,6 +1978,8 @@ class BaseService {
1889
1978
  // When true (default), converts pageNumber to a skip/offset value (e.g., page 3 with pageSize 10 → skip 20).
1890
1979
  // When false, passes pageNumber directly as the offset param — used by APIs that accept a page number instead of a record offset.
1891
1980
  const convertToSkip = paginationParams?.convertToSkip ?? true;
1981
+ // When true, sends pageNumber - 1 (for 0-based APIs). Default false (1-based).
1982
+ const zeroBased = paginationParams?.zeroBased ?? false;
1892
1983
  requestParams[pageSizeParam] = limitedPageSize;
1893
1984
  if (convertToSkip) {
1894
1985
  if (params.pageNumber && params.pageNumber > 1) {
@@ -1896,7 +1987,8 @@ class BaseService {
1896
1987
  }
1897
1988
  }
1898
1989
  else {
1899
- requestParams[offsetParam] = params.pageNumber || 1;
1990
+ const sdkPageNumber = params.pageNumber || 1;
1991
+ requestParams[offsetParam] = zeroBased ? sdkPageNumber - 1 : sdkPageNumber;
1900
1992
  }
1901
1993
  {
1902
1994
  requestParams[countParam] = true;
@@ -1925,8 +2017,9 @@ class BaseService {
1925
2017
  const totalCountField = fields.totalCountField || 'totalRecordCount';
1926
2018
  const continuationTokenField = fields.continuationTokenField || 'continuationToken';
1927
2019
  // Extract items and metadata
1928
- // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
1929
- const items = Array.isArray(response.data) ? response.data : (response.data[itemsField] || []);
2020
+ // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N }).
2021
+ // itemsField may be a dotted path (e.g. 'data.agents') for nested envelopes.
2022
+ const items = Array.isArray(response.data) ? response.data : (resolveNestedField(response.data, itemsField) || []);
1930
2023
  const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
1931
2024
  const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
1932
2025
  const continuationToken = response.data[continuationTokenField];
@@ -2043,7 +2136,7 @@ function createParams(paramsObj = {}) {
2043
2136
  class CasesService extends BaseService {
2044
2137
  /**
2045
2138
  * Get all case management processes with their instance statistics
2046
- * @returns Promise resolving to array of Case objects
2139
+ * @returns Promise resolving to an array of {@link CaseGetAllWithMethodsResponse}
2047
2140
  *
2048
2141
  * @example
2049
2142
  * ```typescript
@@ -2067,10 +2160,10 @@ class CasesService extends BaseService {
2067
2160
  const response = await this.get(MAESTRO_ENDPOINTS.PROCESSES.GET_ALL, { params });
2068
2161
  // Extract processes array from response data and add name field
2069
2162
  const cases = response.data?.processes || [];
2070
- return cases.map(caseItem => ({
2163
+ return cases.map(caseItem => createCaseWithMethods({
2071
2164
  ...caseItem,
2072
2165
  name: this.extractCaseName(caseItem.packageId)
2073
- }));
2166
+ }, this));
2074
2167
  }
2075
2168
  /**
2076
2169
  * Get the top 5 case processes ranked by run count within a time range.
@@ -2289,6 +2382,40 @@ class CasesService extends BaseService {
2289
2382
  const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.TOP_PROCESSES_BY_DURATION, buildInsightsTopBody(startTime, endTime, true, options));
2290
2383
  return (data ?? []).map(process => ({ ...process, name: this.extractCaseName(process.packageId) }));
2291
2384
  }
2385
+ /**
2386
+ * Get element stats for case instances
2387
+ *
2388
+ * Returns per-element execution counts (success, fail, terminated, paused, in-progress) and
2389
+ * duration percentile metrics (min, max, avg, p50, p95, p99) for BPMN elements within a case.
2390
+ *
2391
+ * @param processKey - Process key to filter by
2392
+ * @param packageId - Package identifier
2393
+ * @param startTime - Start of the time range to query
2394
+ * @param endTime - End of the time range to query
2395
+ * @param packageVersion - Package version to filter by
2396
+ * @returns Promise resolving to an array of {@link ElementStats}
2397
+ * @example
2398
+ * ```typescript
2399
+ * // Get element metrics for a case
2400
+ * const elements = await cases.getElementStats(
2401
+ * '<processKey>',
2402
+ * '<packageId>',
2403
+ * new Date('2026-04-01'),
2404
+ * new Date(),
2405
+ * '1.0.1'
2406
+ * );
2407
+ *
2408
+ * // Find elements with failures
2409
+ * const failedElements = elements.filter(e => e.failCount > 0);
2410
+ * for (const element of failedElements) {
2411
+ * console.log(`Failed element: ${element.elementId}, failures: ${element.failCount}`);
2412
+ * }
2413
+ * ```
2414
+ */
2415
+ async getElementStats(processKey, packageId, startTime, endTime, packageVersion) {
2416
+ const { data } = await this.post(MAESTRO_ENDPOINTS.INSIGHTS.ELEMENT_COUNT_BY_STATUS, buildElementCountByStatusBody(processKey, packageId, startTime, endTime, packageVersion));
2417
+ return data ?? [];
2418
+ }
2292
2419
  /**
2293
2420
  * Extract a readable case name from the packageId
2294
2421
  * @param packageId - The full package identifier
@@ -2326,6 +2453,9 @@ __decorate([
2326
2453
  __decorate([
2327
2454
  track('Cases.GetTopExecutionDuration')
2328
2455
  ], CasesService.prototype, "getTopExecutionDuration", null);
2456
+ __decorate([
2457
+ track('Cases.GetElementStats')
2458
+ ], CasesService.prototype, "getElementStats", null);
2329
2459
 
2330
2460
  /**
2331
2461
  * Process Incident Status
@@ -3852,3 +3982,4 @@ exports.CaseInstancesService = CaseInstancesService;
3852
3982
  exports.Cases = CasesService;
3853
3983
  exports.CasesService = CasesService;
3854
3984
  exports.createCaseInstanceWithMethods = createCaseInstanceWithMethods;
3985
+ exports.createCaseWithMethods = createCaseWithMethods;