@uipath/uipath-typescript 1.3.7 → 1.3.9

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 (47) hide show
  1. package/dist/assets/index.cjs +64 -274
  2. package/dist/assets/index.d.ts +1 -0
  3. package/dist/assets/index.mjs +64 -274
  4. package/dist/attachments/index.cjs +62 -271
  5. package/dist/attachments/index.d.ts +1 -0
  6. package/dist/attachments/index.mjs +62 -271
  7. package/dist/buckets/index.cjs +93 -274
  8. package/dist/buckets/index.d.ts +51 -1
  9. package/dist/buckets/index.mjs +93 -274
  10. package/dist/cases/index.cjs +580 -336
  11. package/dist/cases/index.d.ts +690 -3
  12. package/dist/cases/index.mjs +581 -337
  13. package/dist/conversational-agent/index.cjs +110 -285
  14. package/dist/conversational-agent/index.d.ts +63 -12
  15. package/dist/conversational-agent/index.mjs +110 -286
  16. package/dist/core/index.cjs +39 -289
  17. package/dist/core/index.d.ts +9 -98
  18. package/dist/core/index.mjs +40 -275
  19. package/dist/document-understanding/index.cjs +18 -1
  20. package/dist/document-understanding/index.d.ts +636 -610
  21. package/dist/document-understanding/index.mjs +18 -1
  22. package/dist/entities/index.cjs +64 -274
  23. package/dist/entities/index.d.ts +1 -0
  24. package/dist/entities/index.mjs +64 -274
  25. package/dist/feedback/index.cjs +313 -276
  26. package/dist/feedback/index.d.ts +418 -12
  27. package/dist/feedback/index.mjs +313 -276
  28. package/dist/index.cjs +777 -297
  29. package/dist/index.d.ts +2005 -721
  30. package/dist/index.mjs +777 -283
  31. package/dist/index.umd.js +966 -162
  32. package/dist/jobs/index.cjs +64 -274
  33. package/dist/jobs/index.d.ts +1 -0
  34. package/dist/jobs/index.mjs +64 -274
  35. package/dist/maestro-processes/index.cjs +1789 -1686
  36. package/dist/maestro-processes/index.d.ts +431 -2
  37. package/dist/maestro-processes/index.mjs +1790 -1687
  38. package/dist/processes/index.cjs +64 -274
  39. package/dist/processes/index.d.ts +1 -0
  40. package/dist/processes/index.mjs +64 -274
  41. package/dist/queues/index.cjs +64 -274
  42. package/dist/queues/index.d.ts +1 -0
  43. package/dist/queues/index.mjs +64 -274
  44. package/dist/tasks/index.cjs +64 -274
  45. package/dist/tasks/index.d.ts +1 -0
  46. package/dist/tasks/index.mjs +64 -274
  47. package/package.json +8 -10
@@ -1,4 +1,4 @@
1
- import { BatchLogRecordProcessor, LoggerProvider } from '@opentelemetry/sdk-logs';
1
+ import { getOrCreateClient, createTrack, createTrackEvent } from '@uipath/core-telemetry';
2
2
 
3
3
  /******************************************************************************
4
4
  Copyright (c) Microsoft Corporation.
@@ -650,6 +650,27 @@ var PaginationType;
650
650
  /**
651
651
  * Collection of utility functions for working with objects
652
652
  */
653
+ /**
654
+ * Resolves a field value from an object, supporting both direct keys (e.g., '@odata.count')
655
+ * and dot-separated nested paths (e.g., 'pagination.totalCount').
656
+ * Direct key match takes priority over nested traversal.
657
+ */
658
+ function resolveNestedField(data, fieldPath) {
659
+ if (!data) {
660
+ return undefined;
661
+ }
662
+ if (fieldPath in data) {
663
+ return data[fieldPath];
664
+ }
665
+ if (!fieldPath.includes('.')) {
666
+ return undefined;
667
+ }
668
+ let value = data;
669
+ for (const part of fieldPath.split('.')) {
670
+ value = value?.[part];
671
+ }
672
+ return value;
673
+ }
653
674
  /**
654
675
  * Filters out undefined values from an object
655
676
  * @param obj The source object
@@ -871,6 +892,15 @@ const ODATA_OFFSET_PARAMS = {
871
892
  /** OData count parameter name */
872
893
  COUNT_PARAM: '$count'
873
894
  };
895
+ /**
896
+ * Feedback category pagination response shape constants
897
+ */
898
+ const FEEDBACK_CATEGORY_PAGINATION = {
899
+ /** Field name for items in feedback category response */
900
+ ITEMS_FIELD: 'categories',
901
+ /** Field name for total count in feedback category response */
902
+ TOTAL_COUNT_FIELD: 'totalCount'
903
+ };
874
904
  /**
875
905
  * Feedback OFFSET pagination parameter names (take/skip style)
876
906
  */
@@ -892,6 +922,10 @@ const BUCKET_TOKEN_PARAMS = {
892
922
  TOKEN_PARAM: 'continuationToken'
893
923
  };
894
924
 
925
+ /**
926
+ * Converts a UTC timestamp string (e.g., "5/8/2026 11:20:17 AM") to ISO 8601 UTC format.
927
+ * Returns the original value if parsing fails.
928
+ */
895
929
  /**
896
930
  * Transforms data by mapping fields according to the provided field mapping
897
931
  * @param data The source data to transform
@@ -1164,7 +1198,8 @@ class PaginationHelpers {
1164
1198
  // Extract and transform items from response
1165
1199
  // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
1166
1200
  const rawItems = Array.isArray(response.data) ? response.data : response.data?.[itemsField];
1167
- const totalCount = Array.isArray(response.data) ? undefined : response.data?.[totalCountField];
1201
+ const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
1202
+ const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
1168
1203
  // Parse items - automatically handle JSON string responses
1169
1204
  const parsedItems = typeof rawItems === 'string' ? JSON.parse(rawItems) : (rawItems || []);
1170
1205
  const items = transformFn ? parsedItems.map(transformFn) : parsedItems;
@@ -1461,9 +1496,17 @@ class BaseService {
1461
1496
  const pageSizeParam = paginationParams?.pageSizeParam || ODATA_OFFSET_PARAMS.PAGE_SIZE_PARAM;
1462
1497
  const offsetParam = paginationParams?.offsetParam || ODATA_OFFSET_PARAMS.OFFSET_PARAM;
1463
1498
  const countParam = paginationParams?.countParam || ODATA_OFFSET_PARAMS.COUNT_PARAM;
1499
+ // When true (default), converts pageNumber to a skip/offset value (e.g., page 3 with pageSize 10 → skip 20).
1500
+ // When false, passes pageNumber directly as the offset param — used by APIs that accept a page number instead of a record offset.
1501
+ const convertToSkip = paginationParams?.convertToSkip ?? true;
1464
1502
  requestParams[pageSizeParam] = limitedPageSize;
1465
- if (params.pageNumber && params.pageNumber > 1) {
1466
- requestParams[offsetParam] = (params.pageNumber - 1) * limitedPageSize;
1503
+ if (convertToSkip) {
1504
+ if (params.pageNumber && params.pageNumber > 1) {
1505
+ requestParams[offsetParam] = (params.pageNumber - 1) * limitedPageSize;
1506
+ }
1507
+ }
1508
+ else {
1509
+ requestParams[offsetParam] = params.pageNumber || 1;
1467
1510
  }
1468
1511
  {
1469
1512
  requestParams[countParam] = true;
@@ -1494,7 +1537,8 @@ class BaseService {
1494
1537
  // Extract items and metadata
1495
1538
  // Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
1496
1539
  const items = Array.isArray(response.data) ? response.data : (response.data[itemsField] || []);
1497
- const totalCount = Array.isArray(response.data) ? undefined : response.data[totalCountField];
1540
+ const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
1541
+ const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
1498
1542
  const continuationToken = response.data[continuationTokenField];
1499
1543
  // Determine if there are more pages
1500
1544
  const hasMore = this.determineHasMorePages(paginationType, {
@@ -1558,281 +1602,44 @@ const LLMOPS_BASE = 'llmopstenant_';
1558
1602
  const FEEDBACK_ENDPOINTS = {
1559
1603
  GET_ALL: `${LLMOPS_BASE}/api/Feedback`,
1560
1604
  GET_BY_ID: (id) => `${LLMOPS_BASE}/api/Feedback/${id}`,
1605
+ SUBMIT: `${LLMOPS_BASE}/api/Feedback`,
1606
+ UPDATE: (id) => `${LLMOPS_BASE}/api/Feedback/${id}`,
1607
+ DELETE: (id) => `${LLMOPS_BASE}/api/Feedback/${id}`,
1608
+ CATEGORY: {
1609
+ GET_ALL: `${LLMOPS_BASE}/api/Feedback/category`,
1610
+ CREATE: `${LLMOPS_BASE}/api/Feedback/category`,
1611
+ DELETE: (id) => `${LLMOPS_BASE}/api/Feedback/category/${id}`,
1612
+ },
1561
1613
  };
1562
1614
 
1563
1615
  /**
1564
- * SDK Telemetry constants
1616
+ * SDK Telemetry constants.
1617
+ *
1618
+ * Only the SDK's identity (version, service name, role name, …) lives
1619
+ * here. The Application Insights connection string is injected into
1620
+ * `@uipath/core-telemetry` itself at publish time, and the generic attribute
1621
+ * keys (`Version`, `Service`, `CloudOrganizationName`, …) are owned by
1622
+ * `@uipath/core-telemetry` and consumed there — they are not part of the
1623
+ * SDK's public API.
1565
1624
  */
1566
- // Connection string placeholder that will be replaced during build
1567
- const CONNECTION_STRING = "InstrumentationKey=a6efa11d-1feb-4508-9738-e13e12dcae5e;IngestionEndpoint=https://westeurope-5.in.applicationinsights.azure.com/;LiveEndpoint=https://westeurope.livediagnostics.monitor.azure.com/;ApplicationId=7c58eb1c-9581-4ba6-839e-11725848a037";
1568
- // SDK Version placeholder
1569
- const SDK_VERSION = "1.3.7";
1570
- const VERSION = "Version";
1571
- const SERVICE = "Service";
1572
- const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
1573
- const CLOUD_TENANT_NAME = "CloudTenantName";
1574
- const CLOUD_URL = "CloudUrl";
1575
- const CLOUD_CLIENT_ID = "CloudClientId";
1576
- const CLOUD_REDIRECT_URI = "CloudRedirectUri";
1577
- const APP_NAME = "ApplicationName";
1578
- const CLOUD_ROLE_NAME = "uipath-ts-sdk";
1579
- // Service and logger names
1580
- const SDK_SERVICE_NAME = "UiPath.TypeScript.Sdk";
1581
- const SDK_LOGGER_NAME = "uipath-ts-sdk-telemetry";
1582
- // Event names
1583
- const SDK_RUN_EVENT = "Sdk.Run";
1584
- // Default value for unknown/empty attributes
1585
- const UNKNOWN = "";
1625
+ /** SDK version placeholder patched by the SDK publish workflow. */
1626
+ const CLOUD_ROLE_NAME = 'uipath-ts-sdk';
1586
1627
 
1587
1628
  /**
1588
- * Log exporter that sends ALL logs as Application Insights custom events
1589
- */
1590
- class ApplicationInsightsEventExporter {
1591
- constructor(connectionString) {
1592
- this.connectionString = connectionString;
1593
- }
1594
- export(logs, resultCallback) {
1595
- try {
1596
- logs.forEach(logRecord => {
1597
- this.sendAsCustomEvent(logRecord);
1598
- });
1599
- resultCallback({ code: 0 });
1600
- }
1601
- catch (error) {
1602
- console.debug('Failed to export logs to Application Insights:', error);
1603
- resultCallback({ code: 2, error });
1604
- }
1605
- }
1606
- shutdown() {
1607
- return Promise.resolve();
1608
- }
1609
- sendAsCustomEvent(logRecord) {
1610
- // Get event name from body or attributes
1611
- const eventName = logRecord.body || SDK_RUN_EVENT;
1612
- const payload = {
1613
- name: 'Microsoft.ApplicationInsights.Event',
1614
- time: new Date().toISOString(),
1615
- iKey: this.extractInstrumentationKey(),
1616
- data: {
1617
- baseType: 'EventData',
1618
- baseData: {
1619
- ver: 2,
1620
- name: eventName,
1621
- properties: this.convertAttributesToProperties(logRecord.attributes || {})
1622
- }
1623
- },
1624
- tags: {
1625
- 'ai.cloud.role': CLOUD_ROLE_NAME,
1626
- 'ai.cloud.roleInstance': SDK_VERSION
1627
- }
1628
- };
1629
- this.sendToApplicationInsights(payload);
1630
- }
1631
- extractInstrumentationKey() {
1632
- const match = this.connectionString.match(/InstrumentationKey=([^;]+)/);
1633
- return match ? match[1] : '';
1634
- }
1635
- convertAttributesToProperties(attributes) {
1636
- const properties = {};
1637
- Object.entries(attributes || {}).forEach(([key, value]) => {
1638
- properties[key] = String(value);
1639
- });
1640
- return properties;
1641
- }
1642
- async sendToApplicationInsights(payload) {
1643
- try {
1644
- const ingestionEndpoint = this.extractIngestionEndpoint();
1645
- if (!ingestionEndpoint) {
1646
- console.debug('No ingestion endpoint found in connection string');
1647
- return;
1648
- }
1649
- const url = `${ingestionEndpoint}/v2/track`;
1650
- const response = await fetch(url, {
1651
- method: 'POST',
1652
- headers: {
1653
- 'Content-Type': 'application/json',
1654
- },
1655
- body: JSON.stringify(payload)
1656
- });
1657
- if (!response.ok) {
1658
- console.debug(`Failed to send event telemetry: ${response.status} ${response.statusText}`);
1659
- }
1660
- }
1661
- catch (error) {
1662
- console.debug('Error sending event telemetry to Application Insights:', error);
1663
- }
1664
- }
1665
- extractIngestionEndpoint() {
1666
- const match = this.connectionString.match(/IngestionEndpoint=([^;]+)/);
1667
- return match ? match[1] : '';
1668
- }
1669
- }
1670
- /**
1671
- * Singleton telemetry client
1672
- */
1673
- class TelemetryClient {
1674
- constructor() {
1675
- this.isInitialized = false;
1676
- }
1677
- static getInstance() {
1678
- if (!TelemetryClient.instance) {
1679
- TelemetryClient.instance = new TelemetryClient();
1680
- }
1681
- return TelemetryClient.instance;
1682
- }
1683
- /**
1684
- * Initialize telemetry
1685
- */
1686
- initialize(config) {
1687
- if (this.isInitialized) {
1688
- return;
1689
- }
1690
- this.isInitialized = true;
1691
- if (config) {
1692
- this.telemetryContext = config;
1693
- }
1694
- try {
1695
- const connectionString = this.getConnectionString();
1696
- if (!connectionString) {
1697
- return;
1698
- }
1699
- this.setupTelemetryProvider(connectionString);
1700
- }
1701
- catch (error) {
1702
- // Silent failure - telemetry errors shouldn't break functionality
1703
- console.debug('Failed to initialize OpenTelemetry:', error);
1704
- }
1705
- }
1706
- getConnectionString() {
1707
- const connectionString = CONNECTION_STRING;
1708
- return connectionString;
1709
- }
1710
- setupTelemetryProvider(connectionString) {
1711
- const exporter = new ApplicationInsightsEventExporter(connectionString);
1712
- const processor = new BatchLogRecordProcessor(exporter);
1713
- this.logProvider = new LoggerProvider({
1714
- processors: [processor]
1715
- });
1716
- this.logger = this.logProvider.getLogger(SDK_LOGGER_NAME);
1717
- }
1718
- /**
1719
- * Track a telemetry event
1720
- */
1721
- track(eventName, name, extraAttributes = {}) {
1722
- try {
1723
- // Skip if logger not initialized
1724
- if (!this.logger) {
1725
- return;
1726
- }
1727
- const finalDisplayName = name || eventName;
1728
- const attributes = this.getEnrichedAttributes(extraAttributes, eventName);
1729
- // Emit as log
1730
- this.logger.emit({
1731
- body: finalDisplayName,
1732
- attributes: attributes,
1733
- timestamp: Date.now(),
1734
- });
1735
- }
1736
- catch (error) {
1737
- // Silent failure
1738
- console.debug('Failed to track telemetry event:', error);
1739
- }
1740
- }
1741
- /**
1742
- * Get enriched attributes for telemetry events
1743
- */
1744
- getEnrichedAttributes(extraAttributes, eventName) {
1745
- const attributes = {
1746
- [APP_NAME]: SDK_SERVICE_NAME,
1747
- [VERSION]: SDK_VERSION,
1748
- [SERVICE]: eventName,
1749
- [CLOUD_URL]: this.createCloudUrl(),
1750
- [CLOUD_ORGANIZATION_NAME]: this.telemetryContext?.orgName || UNKNOWN,
1751
- [CLOUD_TENANT_NAME]: this.telemetryContext?.tenantName || UNKNOWN,
1752
- [CLOUD_REDIRECT_URI]: this.telemetryContext?.redirectUri || UNKNOWN,
1753
- [CLOUD_CLIENT_ID]: this.telemetryContext?.clientId || UNKNOWN,
1754
- ...extraAttributes,
1755
- };
1756
- return attributes;
1757
- }
1758
- /**
1759
- * Create cloud URL from base URL, organization ID, and tenant ID
1760
- */
1761
- createCloudUrl() {
1762
- const baseUrl = this.telemetryContext?.baseUrl;
1763
- const orgId = this.telemetryContext?.orgName;
1764
- const tenantId = this.telemetryContext?.tenantName;
1765
- if (!baseUrl || !orgId || !tenantId) {
1766
- return UNKNOWN;
1767
- }
1768
- return `${baseUrl}/${orgId}/${tenantId}`;
1769
- }
1770
- }
1771
- // Export singleton instance
1772
- const telemetryClient = TelemetryClient.getInstance();
1773
-
1774
- /**
1775
- * SDK Track decorator and function for telemetry
1776
- */
1777
- /**
1778
- * Common tracking logic shared between method and function decorators
1779
- */
1780
- function createTrackedFunction(originalFunction, nameOrOptions, fallbackName, opts) {
1781
- return function (...args) {
1782
- // Determine if we should track this call
1783
- let shouldTrack = true;
1784
- if (opts.condition !== undefined) {
1785
- if (typeof opts.condition === 'function') {
1786
- shouldTrack = opts.condition.apply(this, args);
1787
- }
1788
- else {
1789
- shouldTrack = opts.condition;
1790
- }
1791
- }
1792
- // Track the event if enabled
1793
- if (shouldTrack) {
1794
- // Use the full name provided in the decorator (e.g., "Queue.GetAll")
1795
- const serviceMethod = typeof nameOrOptions === 'string'
1796
- ? nameOrOptions
1797
- : fallbackName;
1798
- // Use 'Sdk.Run' as the name and serviceMethod as the service
1799
- telemetryClient.track(serviceMethod, SDK_RUN_EVENT, opts.attributes);
1800
- }
1801
- // Execute the original function
1802
- return originalFunction.apply(this, args);
1803
- };
1804
- }
1805
- /**
1806
- * Track decorator that can be used to automatically track function calls
1807
- *
1808
- * Usage:
1809
- * @track("Service.Method")
1810
- * function myFunction() { ... }
1811
- *
1812
- * @track("Queue.GetAll")
1813
- * async getAll() { ... }
1629
+ * UiPath TypeScript SDK Telemetry
1814
1630
  *
1815
- * @track("Tasks.Create")
1816
- * async create() { ... }
1817
- *
1818
- * @track("Assets.Update", { condition: false })
1819
- * function myFunction() { ... }
1820
- *
1821
- * @track("Processes.Start", { attributes: { customProp: "value" } })
1822
- * function myFunction() { ... }
1631
+ * Constructs the SDK's own `TelemetryClient` and binds the SDK-local
1632
+ * `track` / `trackEvent` to it. Each consumer of `@uipath/core-telemetry`
1633
+ * does this independently, so events carry their own consumer's identity
1634
+ * and tenant context.
1823
1635
  */
1824
- function track(nameOrOptions, options) {
1825
- return function decorator(_target, propertyKey, descriptor) {
1826
- const opts = typeof nameOrOptions === 'object' ? nameOrOptions : {};
1827
- if (descriptor && typeof descriptor.value === 'function') {
1828
- // Method decorator
1829
- descriptor.value = createTrackedFunction(descriptor.value, nameOrOptions, propertyKey || 'unknown_method', opts);
1830
- return descriptor;
1831
- }
1832
- // Function decorator
1833
- return (originalFunction) => createTrackedFunction(originalFunction, nameOrOptions, originalFunction.name || 'unknown_function', opts);
1834
- };
1835
- }
1636
+ // Keyed by `CLOUD_ROLE_NAME` so every SDK subpath bundle resolves to the
1637
+ // same `TelemetryClient` instance at runtime. A single `initialize(...)`
1638
+ // from the `UiPath` constructor therefore wires up `@track` decorators
1639
+ // across every subpath bundle (`assets`, `feedback`, `tasks`, …).
1640
+ const sdkClient = getOrCreateClient(CLOUD_ROLE_NAME);
1641
+ const track = createTrack(sdkClient);
1642
+ createTrackEvent(sdkClient);
1836
1643
 
1837
1644
  /**
1838
1645
  * Service for interacting with UiPath Agent Feedback API
@@ -1842,10 +1649,10 @@ class FeedbackService extends BaseService {
1842
1649
  * Gets all feedback across all agents in the tenant, with optional filters.
1843
1650
  *
1844
1651
  * Retrieves a list of feedback entries, optionally filtered by agent, trace, span, status, or agent version.
1845
- * When no pagination options are provided, the API returns up to 100 items. When pagination options are provided without a pageSize, the SDK defaults to 50 items per page.
1652
+ * When no pagination options are provided, the SDK returns up to 100 items. When pagination options are provided without a pageSize, the SDK defaults to 50 items per page.
1846
1653
  *
1847
1654
  * @param options - Optional query parameters for filtering and pagination
1848
- * @returns Promise resolving to {@link NonPaginatedResponse} of {@link FeedbackGetResponse} without pagination options, or {@link PaginatedResponse} of {@link FeedbackGetResponse} when pagination options are used.
1655
+ * @returns Promise resolving to {@link NonPaginatedResponse} of {@link FeedbackResponse} without pagination options, or {@link PaginatedResponse} of {@link FeedbackResponse} when pagination options are used.
1849
1656
  * @example
1850
1657
  * ```typescript
1851
1658
  * import { Feedback, FeedbackStatus } from '@uipath/uipath-typescript/feedback';
@@ -1897,7 +1704,7 @@ class FeedbackService extends BaseService {
1897
1704
  *
1898
1705
  * @param id - Feedback ID (GUID) of the feedback entry
1899
1706
  * @param options - Required options including folderKey for folder-level authorization {@link FeedbackOptions}
1900
- * @returns Promise resolving to {@link FeedbackGetResponse}
1707
+ * @returns Promise resolving to {@link FeedbackResponse}
1901
1708
  * @example
1902
1709
  * ```typescript
1903
1710
  * import { Feedback } from '@uipath/uipath-typescript/feedback';
@@ -1915,11 +1722,223 @@ class FeedbackService extends BaseService {
1915
1722
  async getById(id, options) {
1916
1723
  if (!id)
1917
1724
  throw new ValidationError({ message: 'Feedback ID is required for getById' });
1918
- if (!options?.folderKey)
1725
+ if (!options.folderKey)
1919
1726
  throw new ValidationError({ message: 'folderKey is required for getById' });
1920
1727
  const response = await this.get(FEEDBACK_ENDPOINTS.GET_BY_ID(id), { headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }) });
1921
1728
  return transformData(response.data, FeedbackMap);
1922
1729
  }
1730
+ /**
1731
+ * Submits a feedback entry.
1732
+ *
1733
+ * @param traceId - Trace identifier linking feedback to a specific agent execution
1734
+ * @param isPositive - Whether the feedback is positive (thumbs up) or negative (thumbs down)
1735
+ * @param options - Additional feedback data and folderKey for authorization {@link FeedbackSubmitOptions}
1736
+ * @returns Promise resolving to the submitted {@link FeedbackResponse}
1737
+ * @example
1738
+ * ```typescript
1739
+ * import { Feedback } from '@uipath/uipath-typescript/feedback';
1740
+ *
1741
+ * const feedback = new Feedback(sdk);
1742
+ *
1743
+ * // Obtain traceId and folderKey from an existing feedback entry
1744
+ * const allFeedback = await feedback.getAll({ pageSize: 1 });
1745
+ * const traceId = allFeedback.items[0].traceId;
1746
+ * const folderKey = allFeedback.items[0].folderKey!;
1747
+ *
1748
+ * const item = await feedback.submit(traceId, true, { folderKey });
1749
+ * console.log(item.id, item.status);
1750
+ * ```
1751
+ */
1752
+ async submit(traceId, isPositive, options) {
1753
+ if (!traceId)
1754
+ throw new ValidationError({ message: 'traceId is required for submit' });
1755
+ if (!options.folderKey)
1756
+ throw new ValidationError({ message: 'folderKey is required for submit' });
1757
+ const { folderKey, ...rest } = options;
1758
+ const response = await this.post(FEEDBACK_ENDPOINTS.SUBMIT, { traceId, isPositive, ...rest }, { headers: createHeaders({ [FOLDER_KEY]: folderKey }) });
1759
+ return transformData(response.data, FeedbackMap);
1760
+ }
1761
+ /**
1762
+ * Updates already submitted feedback.
1763
+ *
1764
+ * @param id - Feedback ID (GUID) of the entry to update
1765
+ * @param isPositive - Whether the feedback is positive (thumbs up) or negative (thumbs down)
1766
+ * @param options - Updated feedback data and folderKey for authorization {@link FeedbackUpdateOptions}
1767
+ * @returns Promise resolving to the updated {@link FeedbackResponse}
1768
+ * @example
1769
+ * ```typescript
1770
+ * import { Feedback } from '@uipath/uipath-typescript/feedback';
1771
+ *
1772
+ * const feedback = new Feedback(sdk);
1773
+ *
1774
+ * const allFeedback = await feedback.getAll({ pageSize: 1 });
1775
+ * const feedbackId = allFeedback.items[0].id;
1776
+ * const folderKey = allFeedback.items[0].folderKey!;
1777
+ *
1778
+ * const updated = await feedback.updateById(feedbackId, false, {
1779
+ * comment: 'On reflection, not great.',
1780
+ * folderKey,
1781
+ * });
1782
+ * console.log(updated.isPositive, updated.comment);
1783
+ * ```
1784
+ */
1785
+ async updateById(id, isPositive, options) {
1786
+ if (!id)
1787
+ throw new ValidationError({ message: 'Feedback ID is required for updateById' });
1788
+ if (!options.folderKey)
1789
+ throw new ValidationError({ message: 'folderKey is required for updateById' });
1790
+ const { folderKey, ...rest } = options;
1791
+ const response = await this.post(FEEDBACK_ENDPOINTS.UPDATE(id), { isPositive, ...rest }, { headers: createHeaders({ [FOLDER_KEY]: folderKey }) });
1792
+ return transformData(response.data, FeedbackMap);
1793
+ }
1794
+ /**
1795
+ * Deletes a feedback entry by its ID.
1796
+ *
1797
+ * @param id - Feedback ID (GUID) of the entry to delete
1798
+ * @param options - Required options including folderKey for folder-level authorization {@link FeedbackOptions}
1799
+ * @returns Promise resolving to void on success
1800
+ * @example
1801
+ * ```typescript
1802
+ * import { Feedback } from '@uipath/uipath-typescript/feedback';
1803
+ *
1804
+ * const feedback = new Feedback(sdk);
1805
+ *
1806
+ * const allFeedback = await feedback.getAll({ pageSize: 1 });
1807
+ * const feedbackId = allFeedback.items[0].id;
1808
+ * const folderKey = allFeedback.items[0].folderKey!;
1809
+ *
1810
+ * await feedback.deleteById(feedbackId, { folderKey });
1811
+ * ```
1812
+ */
1813
+ async deleteById(id, options) {
1814
+ if (!id)
1815
+ throw new ValidationError({ message: 'Feedback ID is required for deleteById' });
1816
+ if (!options.folderKey)
1817
+ throw new ValidationError({ message: 'folderKey is required for deleteById' });
1818
+ await this.delete(FEEDBACK_ENDPOINTS.DELETE(id), { headers: createHeaders({ [FOLDER_KEY]: options.folderKey }) });
1819
+ }
1820
+ /**
1821
+ * Creates a new feedback category.
1822
+ *
1823
+ * Custom categories can be used to label feedback entries beyond the default system categories.
1824
+ * Once created, reference the category by its `id` when submitting or updating feedback.
1825
+ * If `isPositive` and `isNegative` are omitted, the backend defaults both to `true`.
1826
+ *
1827
+ * @param category - Name of the category to create (max 256 characters, unique per tenant)
1828
+ * @param options - Optional flags controlling whether the category applies to positive and/or negative feedback {@link FeedbackCreateCategoryOptions}
1829
+ * @returns Promise resolving to the created {@link FeedbackCategoryResponse}
1830
+ * @example
1831
+ * ```typescript
1832
+ * import { Feedback } from '@uipath/uipath-typescript/feedback';
1833
+ *
1834
+ * const feedback = new Feedback(sdk);
1835
+ *
1836
+ * // Minimum — applies to both positive and negative feedback by default
1837
+ * const category = await feedback.createCategory('Hallucination');
1838
+ * console.log(category.id, category.category);
1839
+ *
1840
+ * // With explicit flags
1841
+ * const negativeOnly = await feedback.createCategory('Off-topic', {
1842
+ * isPositive: false,
1843
+ * isNegative: true,
1844
+ * });
1845
+ * ```
1846
+ */
1847
+ async createCategory(category, options) {
1848
+ if (!category)
1849
+ throw new ValidationError({ message: 'category name is required for createCategory' });
1850
+ const body = { category };
1851
+ if (options?.isPositive !== undefined)
1852
+ body.isPositive = options.isPositive;
1853
+ if (options?.isNegative !== undefined)
1854
+ body.isNegative = options.isNegative;
1855
+ const response = await this.post(FEEDBACK_ENDPOINTS.CATEGORY.CREATE, body);
1856
+ return transformData(response.data, FeedbackMap);
1857
+ }
1858
+ /**
1859
+ * Gets all feedback categories for the tenant.
1860
+ *
1861
+ * Returns both system default categories (Output, Agent Error, Agent Plan Execution)
1862
+ * and any custom categories created for this tenant.
1863
+ * When no pagination options are provided, the SDK returns up to 100 items. When pagination options are provided without a pageSize, the SDK defaults to 50 items per page.
1864
+ *
1865
+ * @param options - Optional filters and pagination options {@link FeedbackGetCategoriesOptions}
1866
+ * @returns Promise resolving to {@link NonPaginatedResponse} of {@link FeedbackCategoryResponse} without pagination options, or {@link PaginatedResponse} of {@link FeedbackCategoryResponse} when pagination options are used.
1867
+ * @example
1868
+ * ```typescript
1869
+ * import { Feedback } from '@uipath/uipath-typescript/feedback';
1870
+ *
1871
+ * const feedback = new Feedback(sdk);
1872
+ *
1873
+ * // Get all categories
1874
+ * const categories = await feedback.getCategories();
1875
+ * console.log(categories.items.map(c => c.category));
1876
+ *
1877
+ * // Get only categories applicable to negative feedback
1878
+ * const negativeCategories = await feedback.getCategories({ isNegative: true });
1879
+ *
1880
+ * // Paginated
1881
+ * const page1 = await feedback.getCategories({ pageSize: 10 });
1882
+ * ```
1883
+ */
1884
+ async getCategories(options) {
1885
+ const transformCategory = (item) => transformData(item, FeedbackMap);
1886
+ return PaginationHelpers.getAll({
1887
+ serviceAccess: this.createPaginationServiceAccess(),
1888
+ getEndpoint: () => FEEDBACK_ENDPOINTS.CATEGORY.GET_ALL,
1889
+ transformFn: transformCategory,
1890
+ pagination: {
1891
+ paginationType: PaginationType.OFFSET,
1892
+ itemsField: FEEDBACK_CATEGORY_PAGINATION.ITEMS_FIELD,
1893
+ totalCountField: FEEDBACK_CATEGORY_PAGINATION.TOTAL_COUNT_FIELD,
1894
+ paginationParams: {
1895
+ pageSizeParam: FEEDBACK_OFFSET_PARAMS.PAGE_SIZE_PARAM,
1896
+ offsetParam: FEEDBACK_OFFSET_PARAMS.OFFSET_PARAM,
1897
+ countParam: FEEDBACK_OFFSET_PARAMS.COUNT_PARAM,
1898
+ },
1899
+ },
1900
+ excludeFromPrefix: Object.keys(options || {}),
1901
+ }, options);
1902
+ }
1903
+ /**
1904
+ * Deletes a feedback category by its ID.
1905
+ *
1906
+ * System default categories (Output, Agent Error, Agent Plan Execution) cannot be deleted —
1907
+ * attempting to do so throws a `409 Conflict` error.
1908
+ * Use `forceDelete` to delete a custom category that already has feedback entries associated with it.
1909
+ *
1910
+ * @param id - Category ID (GUID) of the category to delete
1911
+ * @param options - Optional deletion options {@link FeedbackDeleteCategoryOptions}
1912
+ * @returns Promise resolving to void on success
1913
+ * @example
1914
+ * ```typescript
1915
+ * import { Feedback } from '@uipath/uipath-typescript/feedback';
1916
+ *
1917
+ * const feedback = new Feedback(sdk);
1918
+ *
1919
+ * // Only custom categories (isDefault: false) can be deleted
1920
+ * const categories = await feedback.getCategories();
1921
+ * const customCategory = categories.items.find(c => !c.isDefault);
1922
+ * if (customCategory) {
1923
+ * await feedback.deleteCategory(customCategory.id);
1924
+ * }
1925
+ * ```
1926
+ * @example
1927
+ * ```typescript
1928
+ * // Force-delete a custom category that has associated feedback entries
1929
+ * const categories = await feedback.getCategories();
1930
+ * const customCategory = categories.items.find(c => !c.isDefault);
1931
+ * if (customCategory) {
1932
+ * await feedback.deleteCategory(customCategory.id, { forceDelete: true });
1933
+ * }
1934
+ * ```
1935
+ */
1936
+ async deleteCategory(id, options) {
1937
+ if (!id)
1938
+ throw new ValidationError({ message: 'Category ID is required for deleteCategory' });
1939
+ const params = options?.forceDelete !== undefined ? { forceDelete: options.forceDelete } : undefined;
1940
+ await this.delete(FEEDBACK_ENDPOINTS.CATEGORY.DELETE(id), { params });
1941
+ }
1923
1942
  }
1924
1943
  __decorate([
1925
1944
  track('Feedback.GetAll')
@@ -1927,6 +1946,24 @@ __decorate([
1927
1946
  __decorate([
1928
1947
  track('Feedback.GetById')
1929
1948
  ], FeedbackService.prototype, "getById", null);
1949
+ __decorate([
1950
+ track('Feedback.Submit')
1951
+ ], FeedbackService.prototype, "submit", null);
1952
+ __decorate([
1953
+ track('Feedback.UpdateById')
1954
+ ], FeedbackService.prototype, "updateById", null);
1955
+ __decorate([
1956
+ track('Feedback.DeleteById')
1957
+ ], FeedbackService.prototype, "deleteById", null);
1958
+ __decorate([
1959
+ track('Feedback.CreateCategory')
1960
+ ], FeedbackService.prototype, "createCategory", null);
1961
+ __decorate([
1962
+ track('Feedback.GetCategories')
1963
+ ], FeedbackService.prototype, "getCategories", null);
1964
+ __decorate([
1965
+ track('Feedback.DeleteCategory')
1966
+ ], FeedbackService.prototype, "deleteCategory", null);
1930
1967
 
1931
1968
  /**
1932
1969
  * Status of a feedback entry in the review workflow