@uipath/uipath-typescript 1.3.8 → 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 (39) hide show
  1. package/dist/assets/index.cjs +25 -270
  2. package/dist/assets/index.mjs +25 -270
  3. package/dist/attachments/index.cjs +23 -267
  4. package/dist/attachments/index.mjs +23 -267
  5. package/dist/buckets/index.cjs +54 -270
  6. package/dist/buckets/index.d.ts +50 -1
  7. package/dist/buckets/index.mjs +54 -270
  8. package/dist/cases/index.cjs +408 -337
  9. package/dist/cases/index.d.ts +534 -2
  10. package/dist/cases/index.mjs +409 -338
  11. package/dist/conversational-agent/index.cjs +71 -281
  12. package/dist/conversational-agent/index.d.ts +62 -12
  13. package/dist/conversational-agent/index.mjs +71 -282
  14. package/dist/core/index.cjs +39 -289
  15. package/dist/core/index.d.ts +9 -98
  16. package/dist/core/index.mjs +40 -275
  17. package/dist/document-understanding/index.cjs +18 -1
  18. package/dist/document-understanding/index.d.ts +636 -610
  19. package/dist/document-understanding/index.mjs +18 -1
  20. package/dist/entities/index.cjs +25 -270
  21. package/dist/entities/index.mjs +25 -270
  22. package/dist/feedback/index.cjs +23 -268
  23. package/dist/feedback/index.mjs +23 -268
  24. package/dist/index.cjs +600 -293
  25. package/dist/index.d.ts +1603 -722
  26. package/dist/index.mjs +600 -279
  27. package/dist/index.umd.js +789 -158
  28. package/dist/jobs/index.cjs +25 -270
  29. package/dist/jobs/index.mjs +25 -270
  30. package/dist/maestro-processes/index.cjs +1751 -1720
  31. package/dist/maestro-processes/index.d.ts +430 -2
  32. package/dist/maestro-processes/index.mjs +1752 -1721
  33. package/dist/processes/index.cjs +25 -270
  34. package/dist/processes/index.mjs +25 -270
  35. package/dist/queues/index.cjs +25 -270
  36. package/dist/queues/index.mjs +25 -270
  37. package/dist/tasks/index.cjs +25 -270
  38. package/dist/tasks/index.mjs +25 -270
  39. 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
  import { io } from 'socket.io-client';
3
3
 
4
4
  /******************************************************************************
@@ -44,278 +44,33 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
44
44
  };
45
45
 
46
46
  /**
47
- * SDK Telemetry constants
48
- */
49
- // Connection string placeholder that will be replaced during build
50
- 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";
51
- // SDK Version placeholder
52
- const SDK_VERSION = "1.3.8";
53
- const VERSION = "Version";
54
- const SERVICE = "Service";
55
- const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
56
- const CLOUD_TENANT_NAME = "CloudTenantName";
57
- const CLOUD_URL = "CloudUrl";
58
- const CLOUD_CLIENT_ID = "CloudClientId";
59
- const CLOUD_REDIRECT_URI = "CloudRedirectUri";
60
- const APP_NAME = "ApplicationName";
61
- const CLOUD_ROLE_NAME = "uipath-ts-sdk";
62
- // Service and logger names
63
- const SDK_SERVICE_NAME = "UiPath.TypeScript.Sdk";
64
- const SDK_LOGGER_NAME = "uipath-ts-sdk-telemetry";
65
- // Event names
66
- const SDK_RUN_EVENT = "Sdk.Run";
67
- // Default value for unknown/empty attributes
68
- const UNKNOWN = "";
69
-
70
- /**
71
- * Log exporter that sends ALL logs as Application Insights custom events
72
- */
73
- class ApplicationInsightsEventExporter {
74
- constructor(connectionString) {
75
- this.connectionString = connectionString;
76
- }
77
- export(logs, resultCallback) {
78
- try {
79
- logs.forEach(logRecord => {
80
- this.sendAsCustomEvent(logRecord);
81
- });
82
- resultCallback({ code: 0 });
83
- }
84
- catch (error) {
85
- console.debug('Failed to export logs to Application Insights:', error);
86
- resultCallback({ code: 2, error });
87
- }
88
- }
89
- shutdown() {
90
- return Promise.resolve();
91
- }
92
- sendAsCustomEvent(logRecord) {
93
- // Get event name from body or attributes
94
- const eventName = logRecord.body || SDK_RUN_EVENT;
95
- const payload = {
96
- name: 'Microsoft.ApplicationInsights.Event',
97
- time: new Date().toISOString(),
98
- iKey: this.extractInstrumentationKey(),
99
- data: {
100
- baseType: 'EventData',
101
- baseData: {
102
- ver: 2,
103
- name: eventName,
104
- properties: this.convertAttributesToProperties(logRecord.attributes || {})
105
- }
106
- },
107
- tags: {
108
- 'ai.cloud.role': CLOUD_ROLE_NAME,
109
- 'ai.cloud.roleInstance': SDK_VERSION
110
- }
111
- };
112
- this.sendToApplicationInsights(payload);
113
- }
114
- extractInstrumentationKey() {
115
- const match = this.connectionString.match(/InstrumentationKey=([^;]+)/);
116
- return match ? match[1] : '';
117
- }
118
- convertAttributesToProperties(attributes) {
119
- const properties = {};
120
- Object.entries(attributes || {}).forEach(([key, value]) => {
121
- properties[key] = String(value);
122
- });
123
- return properties;
124
- }
125
- async sendToApplicationInsights(payload) {
126
- try {
127
- const ingestionEndpoint = this.extractIngestionEndpoint();
128
- if (!ingestionEndpoint) {
129
- console.debug('No ingestion endpoint found in connection string');
130
- return;
131
- }
132
- const url = `${ingestionEndpoint}/v2/track`;
133
- const response = await fetch(url, {
134
- method: 'POST',
135
- headers: {
136
- 'Content-Type': 'application/json',
137
- },
138
- body: JSON.stringify(payload)
139
- });
140
- if (!response.ok) {
141
- console.debug(`Failed to send event telemetry: ${response.status} ${response.statusText}`);
142
- }
143
- }
144
- catch (error) {
145
- console.debug('Error sending event telemetry to Application Insights:', error);
146
- }
147
- }
148
- extractIngestionEndpoint() {
149
- const match = this.connectionString.match(/IngestionEndpoint=([^;]+)/);
150
- return match ? match[1] : '';
151
- }
152
- }
153
- /**
154
- * Singleton telemetry client
155
- */
156
- class TelemetryClient {
157
- constructor() {
158
- this.isInitialized = false;
159
- }
160
- static getInstance() {
161
- if (!TelemetryClient.instance) {
162
- TelemetryClient.instance = new TelemetryClient();
163
- }
164
- return TelemetryClient.instance;
165
- }
166
- /**
167
- * Initialize telemetry
168
- */
169
- initialize(config) {
170
- if (this.isInitialized) {
171
- return;
172
- }
173
- this.isInitialized = true;
174
- if (config) {
175
- this.telemetryContext = config;
176
- }
177
- try {
178
- const connectionString = this.getConnectionString();
179
- if (!connectionString) {
180
- return;
181
- }
182
- this.setupTelemetryProvider(connectionString);
183
- }
184
- catch (error) {
185
- // Silent failure - telemetry errors shouldn't break functionality
186
- console.debug('Failed to initialize OpenTelemetry:', error);
187
- }
188
- }
189
- getConnectionString() {
190
- const connectionString = CONNECTION_STRING;
191
- return connectionString;
192
- }
193
- setupTelemetryProvider(connectionString) {
194
- const exporter = new ApplicationInsightsEventExporter(connectionString);
195
- const processor = new BatchLogRecordProcessor(exporter);
196
- this.logProvider = new LoggerProvider({
197
- processors: [processor]
198
- });
199
- this.logger = this.logProvider.getLogger(SDK_LOGGER_NAME);
200
- }
201
- /**
202
- * Track a telemetry event
203
- */
204
- track(eventName, name, extraAttributes = {}) {
205
- try {
206
- // Skip if logger not initialized
207
- if (!this.logger) {
208
- return;
209
- }
210
- const finalDisplayName = name || eventName;
211
- const attributes = this.getEnrichedAttributes(extraAttributes, eventName);
212
- // Emit as log
213
- this.logger.emit({
214
- body: finalDisplayName,
215
- attributes: attributes,
216
- timestamp: Date.now(),
217
- });
218
- }
219
- catch (error) {
220
- // Silent failure
221
- console.debug('Failed to track telemetry event:', error);
222
- }
223
- }
224
- /**
225
- * Get enriched attributes for telemetry events
226
- */
227
- getEnrichedAttributes(extraAttributes, eventName) {
228
- const attributes = {
229
- [APP_NAME]: SDK_SERVICE_NAME,
230
- [VERSION]: SDK_VERSION,
231
- [SERVICE]: eventName,
232
- [CLOUD_URL]: this.createCloudUrl(),
233
- [CLOUD_ORGANIZATION_NAME]: this.telemetryContext?.orgName || UNKNOWN,
234
- [CLOUD_TENANT_NAME]: this.telemetryContext?.tenantName || UNKNOWN,
235
- [CLOUD_REDIRECT_URI]: this.telemetryContext?.redirectUri || UNKNOWN,
236
- [CLOUD_CLIENT_ID]: this.telemetryContext?.clientId || UNKNOWN,
237
- ...extraAttributes,
238
- };
239
- return attributes;
240
- }
241
- /**
242
- * Create cloud URL from base URL, organization ID, and tenant ID
243
- */
244
- createCloudUrl() {
245
- const baseUrl = this.telemetryContext?.baseUrl;
246
- const orgId = this.telemetryContext?.orgName;
247
- const tenantId = this.telemetryContext?.tenantName;
248
- if (!baseUrl || !orgId || !tenantId) {
249
- return UNKNOWN;
250
- }
251
- return `${baseUrl}/${orgId}/${tenantId}`;
252
- }
253
- }
254
- // Export singleton instance
255
- const telemetryClient = TelemetryClient.getInstance();
47
+ * SDK Telemetry constants.
48
+ *
49
+ * Only the SDK's identity (version, service name, role name, …) lives
50
+ * here. The Application Insights connection string is injected into
51
+ * `@uipath/core-telemetry` itself at publish time, and the generic attribute
52
+ * keys (`Version`, `Service`, `CloudOrganizationName`, …) are owned by
53
+ * `@uipath/core-telemetry` and consumed there — they are not part of the
54
+ * SDK's public API.
55
+ */
56
+ /** SDK version placeholder — patched by the SDK publish workflow. */
57
+ const CLOUD_ROLE_NAME = 'uipath-ts-sdk';
256
58
 
257
59
  /**
258
- * SDK Track decorator and function for telemetry
259
- */
260
- /**
261
- * Common tracking logic shared between method and function decorators
262
- */
263
- function createTrackedFunction(originalFunction, nameOrOptions, fallbackName, opts) {
264
- return function (...args) {
265
- // Determine if we should track this call
266
- let shouldTrack = true;
267
- if (opts.condition !== undefined) {
268
- if (typeof opts.condition === 'function') {
269
- shouldTrack = opts.condition.apply(this, args);
270
- }
271
- else {
272
- shouldTrack = opts.condition;
273
- }
274
- }
275
- // Track the event if enabled
276
- if (shouldTrack) {
277
- // Use the full name provided in the decorator (e.g., "Queue.GetAll")
278
- const serviceMethod = typeof nameOrOptions === 'string'
279
- ? nameOrOptions
280
- : fallbackName;
281
- // Use 'Sdk.Run' as the name and serviceMethod as the service
282
- telemetryClient.track(serviceMethod, SDK_RUN_EVENT, opts.attributes);
283
- }
284
- // Execute the original function
285
- return originalFunction.apply(this, args);
286
- };
287
- }
288
- /**
289
- * Track decorator that can be used to automatically track function calls
290
- *
291
- * Usage:
292
- * @track("Service.Method")
293
- * function myFunction() { ... }
294
- *
295
- * @track("Queue.GetAll")
296
- * async getAll() { ... }
297
- *
298
- * @track("Tasks.Create")
299
- * async create() { ... }
60
+ * UiPath TypeScript SDK Telemetry
300
61
  *
301
- * @track("Assets.Update", { condition: false })
302
- * function myFunction() { ... }
303
- *
304
- * @track("Processes.Start", { attributes: { customProp: "value" } })
305
- * function myFunction() { ... }
306
- */
307
- function track(nameOrOptions, options) {
308
- return function decorator(_target, propertyKey, descriptor) {
309
- const opts = typeof nameOrOptions === 'object' ? nameOrOptions : {};
310
- if (descriptor && typeof descriptor.value === 'function') {
311
- // Method decorator
312
- descriptor.value = createTrackedFunction(descriptor.value, nameOrOptions, propertyKey || 'unknown_method', opts);
313
- return descriptor;
314
- }
315
- // Function decorator
316
- return (originalFunction) => createTrackedFunction(originalFunction, nameOrOptions, originalFunction.name || 'unknown_function', opts);
317
- };
318
- }
62
+ * Constructs the SDK's own `TelemetryClient` and binds the SDK-local
63
+ * `track` / `trackEvent` to it. Each consumer of `@uipath/core-telemetry`
64
+ * does this independently, so events carry their own consumer's identity
65
+ * and tenant context.
66
+ */
67
+ // Keyed by `CLOUD_ROLE_NAME` so every SDK subpath bundle resolves to the
68
+ // same `TelemetryClient` instance at runtime. A single `initialize(...)`
69
+ // from the `UiPath` constructor therefore wires up `@track` decorators
70
+ // across every subpath bundle (`assets`, `feedback`, `tasks`, …).
71
+ const sdkClient = getOrCreateClient(CLOUD_ROLE_NAME);
72
+ const track = createTrack(sdkClient);
73
+ createTrackEvent(sdkClient);
319
74
 
320
75
  /**
321
76
  * Type guards for error response types
@@ -2008,6 +1763,17 @@ const ConversationMap = {
2008
1763
  lastActivityAt: 'lastActivityTime',
2009
1764
  agentReleaseId: 'agentId'
2010
1765
  };
1766
+ /**
1767
+ * Maps API filter param names (left) to SDK-facing names (right) for the conversation list endpoint.
1768
+ * Used by `getAll` to translate SDK filters to the field names the backend expects. Kept separate
1769
+ * from `ConversationMap` because `label`/`search` would otherwise collide with the `label` field
1770
+ * on create/update payloads.
1771
+ */
1772
+ const ConversationGetAllFilterMap = {
1773
+ agentReleaseKey: 'agentKey',
1774
+ agentReleaseId: 'agentId',
1775
+ search: 'label'
1776
+ };
2011
1777
  /**
2012
1778
  * Maps fields for Exchange entity to ensure consistent SDK naming
2013
1779
  */
@@ -6197,24 +5963,43 @@ class ConversationService extends BaseService {
6197
5963
  * @param options - Options for querying conversations including optional pagination parameters
6198
5964
  * @returns Promise resolving to either an array of conversations {@link NonPaginatedResponse}<{@link ConversationGetResponse}> or a {@link PaginatedResponse}<{@link ConversationGetResponse}> when pagination options are used
6199
5965
  *
6200
- * @example
5966
+ * @example Basic usage - get all conversations
6201
5967
  * ```typescript
6202
- * // Get all conversations (non-paginated)
6203
5968
  * const allConversations = await conversationalAgent.conversations.getAll();
6204
5969
  *
6205
- * // Get conversations with sorting
6206
- * const sortedConversations = await conversationalAgent.conversations.getAll({ sort: SortOrder.Descending });
5970
+ * for (const conversation of allConversations.items) {
5971
+ * console.log(`${conversation.label} - created: ${conversation.createdTime}`);
5972
+ * }
5973
+ * ```
6207
5974
  *
6208
- * // First page with pagination
6209
- * const firstPageOfConversations = await conversationalAgent.conversations.getAll({ pageSize: 10 });
5975
+ * @example With pagination
5976
+ * ```typescript
5977
+ * // First page
5978
+ * const firstPage = await conversationalAgent.conversations.getAll({ pageSize: 10 });
6210
5979
  *
6211
5980
  * // Navigate using cursor
6212
- * if (firstPageOfConversations.hasNextPage) {
6213
- * const nextPageOfConversations = await conversationalAgent.conversations.getAll({
6214
- * cursor: firstPageOfConversations.nextCursor
5981
+ * if (firstPage.hasNextPage) {
5982
+ * const nextPage = await conversationalAgent.conversations.getAll({
5983
+ * cursor: firstPage.nextCursor
6215
5984
  * });
6216
5985
  * }
6217
5986
  * ```
5987
+ *
5988
+ * @example Sorted with limit
5989
+ * ```typescript
5990
+ * const result = await conversationalAgent.conversations.getAll({
5991
+ * sort: SortOrder.Descending,
5992
+ * pageSize: 20
5993
+ * });
5994
+ * ```
5995
+ *
5996
+ * @example Filter by agent and search by label
5997
+ * ```typescript
5998
+ * const filtered = await conversationalAgent.conversations.getAll({
5999
+ * agentId: <agentId>,
6000
+ * label: 'budget'
6001
+ * });
6002
+ * ```
6218
6003
  */
6219
6004
  async getAll(options) {
6220
6005
  // Transform function to convert API timestamps to SDK naming convention and add methods
@@ -6222,6 +6007,10 @@ class ConversationService extends BaseService {
6222
6007
  const transformedData = transformData(conversation, ConversationMap);
6223
6008
  return createConversationWithMethods(transformedData, this, this, this._exchangeService);
6224
6009
  };
6010
+ // Translate SDK filter names (agentKey/agentId/label) to backend names before forwarding
6011
+ const apiOptions = options
6012
+ ? transformRequest(options, ConversationGetAllFilterMap)
6013
+ : undefined;
6225
6014
  return PaginationHelpers.getAll({
6226
6015
  serviceAccess: this.createPaginationServiceAccess(),
6227
6016
  getEndpoint: () => CONVERSATION_ENDPOINTS.LIST,
@@ -6235,8 +6024,8 @@ class ConversationService extends BaseService {
6235
6024
  tokenParam: CONVERSATIONAL_TOKEN_PARAMS.TOKEN_PARAM
6236
6025
  }
6237
6026
  },
6238
- excludeFromPrefix: Object.keys(options || {}) // Conversational params are not OData
6239
- }, options);
6027
+ excludeFromPrefix: Object.keys(apiOptions || {}) // Conversational params are not OData
6028
+ }, apiOptions);
6240
6029
  }
6241
6030
  /**
6242
6031
  * Updates a conversation by ID
@@ -6804,4 +6593,4 @@ __decorate([
6804
6593
  track('ConversationalAgent.GetById')
6805
6594
  ], ConversationalAgentService.prototype, "getById", null);
6806
6595
 
6807
- export { AgentMap, AsyncInputStreamEventHelper, AsyncInputStreamEventHelperImpl, AsyncToolCallEventHelper, AsyncToolCallEventHelperImpl, CitationErrorType, ContentPartEventHelper, ContentPartEventHelperImpl, ContentPartHelper, ConversationEventHelperBase, ConversationEventHelperManager, ConversationEventHelperManagerImpl, ConversationEventInvalidOperationError, ConversationEventValidationError, ConversationMap, ConversationalAgentService as ConversationalAgent, ConversationalAgentService, EventErrorId, ExchangeEventHelper, ExchangeEventHelperImpl, ExchangeMap, ExchangeService, ExchangeService as Exchanges, FeedbackRating, InputStreamSpeechSensitivity, InterruptType, LogLevel, MessageEventHelper, MessageEventHelperImpl, MessageMap, MessageRole, MessageService, MessageService as Messages, SessionEventHelper, SessionEventHelperImpl, SortOrder, ToolCallEventHelper, ToolCallEventHelperImpl, UserSettingsService as UserSettings, UserSettingsMap, UserSettingsService, assertCitationSourceMedia, assertCitationSourceUrl, assertExternalValue, assertInlineValue, createAgentWithMethods, createConversationWithMethods, isCitationSourceMedia, isCitationSourceUrl, isExternalValue, isInlineValue, transformExchange, transformExchanges, transformMessage };
6596
+ export { AgentMap, AsyncInputStreamEventHelper, AsyncInputStreamEventHelperImpl, AsyncToolCallEventHelper, AsyncToolCallEventHelperImpl, CitationErrorType, ContentPartEventHelper, ContentPartEventHelperImpl, ContentPartHelper, ConversationEventHelperBase, ConversationEventHelperManager, ConversationEventHelperManagerImpl, ConversationEventInvalidOperationError, ConversationEventValidationError, ConversationGetAllFilterMap, ConversationMap, ConversationalAgentService as ConversationalAgent, ConversationalAgentService, EventErrorId, ExchangeEventHelper, ExchangeEventHelperImpl, ExchangeMap, ExchangeService, ExchangeService as Exchanges, FeedbackRating, InputStreamSpeechSensitivity, InterruptType, LogLevel, MessageEventHelper, MessageEventHelperImpl, MessageMap, MessageRole, MessageService, MessageService as Messages, SessionEventHelper, SessionEventHelperImpl, SortOrder, ToolCallEventHelper, ToolCallEventHelperImpl, UserSettingsService as UserSettings, UserSettingsMap, UserSettingsService, assertCitationSourceMedia, assertCitationSourceUrl, assertExternalValue, assertInlineValue, createAgentWithMethods, createConversationWithMethods, isCitationSourceMedia, isCitationSourceUrl, isExternalValue, isInlineValue, transformExchange, transformExchanges, transformMessage };