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