@uipath/uipath-typescript 1.3.8 → 1.3.10

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 (41) hide show
  1. package/dist/assets/index.cjs +44 -276
  2. package/dist/assets/index.mjs +44 -276
  3. package/dist/attachments/index.cjs +42 -273
  4. package/dist/attachments/index.mjs +42 -273
  5. package/dist/buckets/index.cjs +195 -276
  6. package/dist/buckets/index.d.ts +213 -1
  7. package/dist/buckets/index.mjs +195 -276
  8. package/dist/cases/index.cjs +427 -343
  9. package/dist/cases/index.d.ts +534 -2
  10. package/dist/cases/index.mjs +428 -344
  11. package/dist/conversational-agent/index.cjs +90 -287
  12. package/dist/conversational-agent/index.d.ts +62 -12
  13. package/dist/conversational-agent/index.mjs +90 -288
  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 +251 -277
  21. package/dist/entities/index.d.ts +305 -2
  22. package/dist/entities/index.mjs +251 -277
  23. package/dist/feedback/index.cjs +42 -274
  24. package/dist/feedback/index.mjs +42 -274
  25. package/dist/index.cjs +998 -351
  26. package/dist/index.d.ts +2159 -762
  27. package/dist/index.mjs +998 -337
  28. package/dist/index.umd.js +1208 -237
  29. package/dist/jobs/index.cjs +44 -276
  30. package/dist/jobs/index.mjs +44 -276
  31. package/dist/maestro-processes/index.cjs +1761 -1717
  32. package/dist/maestro-processes/index.d.ts +430 -2
  33. package/dist/maestro-processes/index.mjs +1762 -1718
  34. package/dist/processes/index.cjs +72 -305
  35. package/dist/processes/index.d.ts +76 -26
  36. package/dist/processes/index.mjs +72 -305
  37. package/dist/queues/index.cjs +44 -276
  38. package/dist/queues/index.mjs +44 -276
  39. package/dist/tasks/index.cjs +44 -276
  40. package/dist/tasks/index.mjs +44 -276
  41. 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.
@@ -609,14 +609,25 @@ class ApiClient {
609
609
  if (!text) {
610
610
  return undefined;
611
611
  }
612
- return JSON.parse(text);
612
+ try {
613
+ return JSON.parse(text);
614
+ }
615
+ catch (error) {
616
+ if (error instanceof SyntaxError) {
617
+ throw new ServerError({
618
+ message: `Server returned non-JSON response (${response.status} ${response.url}): ${error.message}`,
619
+ statusCode: response.status,
620
+ });
621
+ }
622
+ throw error;
623
+ }
613
624
  }
614
625
  catch (error) {
615
626
  // If it's already one of our errors, re-throw it
616
627
  if (error.type && error.type.includes('Error')) {
617
628
  throw error;
618
629
  }
619
- // Otherwise, it's likely a network error
630
+ // Otherwise, it's a genuine network/fetch failure
620
631
  throw ErrorFactory.createNetworkError(error);
621
632
  }
622
633
  }
@@ -1238,9 +1249,9 @@ class PaginationHelpers {
1238
1249
  * @returns Promise resolving to a paginated result
1239
1250
  */
1240
1251
  static async getAllPaginated(params) {
1241
- const { serviceAccess, getEndpoint, folderId, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1252
+ const { serviceAccess, getEndpoint, folderId, headers: providedHeaders, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1242
1253
  const endpoint = getEndpoint(folderId);
1243
- const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
1254
+ const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
1244
1255
  const paginatedResponse = await serviceAccess.requestWithPagination(method, endpoint, paginationParams, {
1245
1256
  headers,
1246
1257
  params: additionalParams,
@@ -1268,13 +1279,13 @@ class PaginationHelpers {
1268
1279
  * @returns Promise resolving to an object with data and totalCount
1269
1280
  */
1270
1281
  static async getAllNonPaginated(params) {
1271
- const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1282
+ const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, headers: providedHeaders, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
1272
1283
  // Set default field names
1273
1284
  const itemsField = options.itemsField || DEFAULT_ITEMS_FIELD;
1274
1285
  const totalCountField = options.totalCountField || DEFAULT_TOTAL_COUNT_FIELD;
1275
1286
  // Determine endpoint and headers based on folderId
1276
1287
  const endpoint = folderId ? getByFolderEndpoint : getAllEndpoint;
1277
- const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
1288
+ const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
1278
1289
  // Make the API call based on method
1279
1290
  let response;
1280
1291
  if (method === HTTP_METHODS.POST) {
@@ -1333,6 +1344,7 @@ class PaginationHelpers {
1333
1344
  serviceAccess: config.serviceAccess,
1334
1345
  getEndpoint: config.getEndpoint,
1335
1346
  folderId,
1347
+ headers: config.headers,
1336
1348
  paginationParams: cursor ? { cursor, pageSize } : jumpToPage ? { jumpToPage, pageSize } : { pageSize },
1337
1349
  additionalParams: prefixedOptions,
1338
1350
  transformFn: config.transformFn,
@@ -1350,6 +1362,7 @@ class PaginationHelpers {
1350
1362
  getAllEndpoint: config.getEndpoint(),
1351
1363
  getByFolderEndpoint: byFolderEndpoint,
1352
1364
  folderId,
1365
+ headers: config.headers,
1353
1366
  additionalParams: prefixedOptions,
1354
1367
  transformFn: config.transformFn,
1355
1368
  method: config.method,
@@ -1936,6 +1949,12 @@ const DATA_FABRIC_ENDPOINTS = {
1936
1949
  CHOICESETS: {
1937
1950
  GET_ALL: `${DATAFABRIC_BASE}/api/Entity/choiceset`,
1938
1951
  GET_BY_ID: (choiceSetId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${choiceSetId}/query_expansion`,
1952
+ CREATE: `${DATAFABRIC_BASE}/api/Entity/choiceset`,
1953
+ UPDATE: (choiceSetId) => `${DATAFABRIC_BASE}/api/Entity/${choiceSetId}/metadata`,
1954
+ DELETE: (choiceSetId) => `${DATAFABRIC_BASE}/api/Entity/${choiceSetId}/delete`,
1955
+ INSERT_BY_NAME: (choiceSetName) => `${DATAFABRIC_BASE}/api/EntityService/${choiceSetName}/choiceset/insert`,
1956
+ UPDATE_BY_NAME: (choiceSetName, valueId) => `${DATAFABRIC_BASE}/api/EntityService/${choiceSetName}/choiceset/${valueId}/update`,
1957
+ DELETE_BY_ID: (choiceSetId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${choiceSetId}/choiceset/delete`,
1939
1958
  },
1940
1959
  };
1941
1960
 
@@ -2133,278 +2152,33 @@ const EntityFieldTypeMap = {
2133
2152
  };
2134
2153
 
2135
2154
  /**
2136
- * SDK Telemetry constants
2137
- */
2138
- // Connection string placeholder that will be replaced during build
2139
- 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";
2140
- // SDK Version placeholder
2141
- const SDK_VERSION = "1.3.8";
2142
- const VERSION = "Version";
2143
- const SERVICE = "Service";
2144
- const CLOUD_ORGANIZATION_NAME = "CloudOrganizationName";
2145
- const CLOUD_TENANT_NAME = "CloudTenantName";
2146
- const CLOUD_URL = "CloudUrl";
2147
- const CLOUD_CLIENT_ID = "CloudClientId";
2148
- const CLOUD_REDIRECT_URI = "CloudRedirectUri";
2149
- const APP_NAME = "ApplicationName";
2150
- const CLOUD_ROLE_NAME = "uipath-ts-sdk";
2151
- // Service and logger names
2152
- const SDK_SERVICE_NAME = "UiPath.TypeScript.Sdk";
2153
- const SDK_LOGGER_NAME = "uipath-ts-sdk-telemetry";
2154
- // Event names
2155
- const SDK_RUN_EVENT = "Sdk.Run";
2156
- // Default value for unknown/empty attributes
2157
- const UNKNOWN = "";
2158
-
2159
- /**
2160
- * Log exporter that sends ALL logs as Application Insights custom events
2161
- */
2162
- class ApplicationInsightsEventExporter {
2163
- constructor(connectionString) {
2164
- this.connectionString = connectionString;
2165
- }
2166
- export(logs, resultCallback) {
2167
- try {
2168
- logs.forEach(logRecord => {
2169
- this.sendAsCustomEvent(logRecord);
2170
- });
2171
- resultCallback({ code: 0 });
2172
- }
2173
- catch (error) {
2174
- console.debug('Failed to export logs to Application Insights:', error);
2175
- resultCallback({ code: 2, error });
2176
- }
2177
- }
2178
- shutdown() {
2179
- return Promise.resolve();
2180
- }
2181
- sendAsCustomEvent(logRecord) {
2182
- // Get event name from body or attributes
2183
- const eventName = logRecord.body || SDK_RUN_EVENT;
2184
- const payload = {
2185
- name: 'Microsoft.ApplicationInsights.Event',
2186
- time: new Date().toISOString(),
2187
- iKey: this.extractInstrumentationKey(),
2188
- data: {
2189
- baseType: 'EventData',
2190
- baseData: {
2191
- ver: 2,
2192
- name: eventName,
2193
- properties: this.convertAttributesToProperties(logRecord.attributes || {})
2194
- }
2195
- },
2196
- tags: {
2197
- 'ai.cloud.role': CLOUD_ROLE_NAME,
2198
- 'ai.cloud.roleInstance': SDK_VERSION
2199
- }
2200
- };
2201
- this.sendToApplicationInsights(payload);
2202
- }
2203
- extractInstrumentationKey() {
2204
- const match = this.connectionString.match(/InstrumentationKey=([^;]+)/);
2205
- return match ? match[1] : '';
2206
- }
2207
- convertAttributesToProperties(attributes) {
2208
- const properties = {};
2209
- Object.entries(attributes || {}).forEach(([key, value]) => {
2210
- properties[key] = String(value);
2211
- });
2212
- return properties;
2213
- }
2214
- async sendToApplicationInsights(payload) {
2215
- try {
2216
- const ingestionEndpoint = this.extractIngestionEndpoint();
2217
- if (!ingestionEndpoint) {
2218
- console.debug('No ingestion endpoint found in connection string');
2219
- return;
2220
- }
2221
- const url = `${ingestionEndpoint}/v2/track`;
2222
- const response = await fetch(url, {
2223
- method: 'POST',
2224
- headers: {
2225
- 'Content-Type': 'application/json',
2226
- },
2227
- body: JSON.stringify(payload)
2228
- });
2229
- if (!response.ok) {
2230
- console.debug(`Failed to send event telemetry: ${response.status} ${response.statusText}`);
2231
- }
2232
- }
2233
- catch (error) {
2234
- console.debug('Error sending event telemetry to Application Insights:', error);
2235
- }
2236
- }
2237
- extractIngestionEndpoint() {
2238
- const match = this.connectionString.match(/IngestionEndpoint=([^;]+)/);
2239
- return match ? match[1] : '';
2240
- }
2241
- }
2242
- /**
2243
- * Singleton telemetry client
2244
- */
2245
- class TelemetryClient {
2246
- constructor() {
2247
- this.isInitialized = false;
2248
- }
2249
- static getInstance() {
2250
- if (!TelemetryClient.instance) {
2251
- TelemetryClient.instance = new TelemetryClient();
2252
- }
2253
- return TelemetryClient.instance;
2254
- }
2255
- /**
2256
- * Initialize telemetry
2257
- */
2258
- initialize(config) {
2259
- if (this.isInitialized) {
2260
- return;
2261
- }
2262
- this.isInitialized = true;
2263
- if (config) {
2264
- this.telemetryContext = config;
2265
- }
2266
- try {
2267
- const connectionString = this.getConnectionString();
2268
- if (!connectionString) {
2269
- return;
2270
- }
2271
- this.setupTelemetryProvider(connectionString);
2272
- }
2273
- catch (error) {
2274
- // Silent failure - telemetry errors shouldn't break functionality
2275
- console.debug('Failed to initialize OpenTelemetry:', error);
2276
- }
2277
- }
2278
- getConnectionString() {
2279
- const connectionString = CONNECTION_STRING;
2280
- return connectionString;
2281
- }
2282
- setupTelemetryProvider(connectionString) {
2283
- const exporter = new ApplicationInsightsEventExporter(connectionString);
2284
- const processor = new BatchLogRecordProcessor(exporter);
2285
- this.logProvider = new LoggerProvider({
2286
- processors: [processor]
2287
- });
2288
- this.logger = this.logProvider.getLogger(SDK_LOGGER_NAME);
2289
- }
2290
- /**
2291
- * Track a telemetry event
2292
- */
2293
- track(eventName, name, extraAttributes = {}) {
2294
- try {
2295
- // Skip if logger not initialized
2296
- if (!this.logger) {
2297
- return;
2298
- }
2299
- const finalDisplayName = name || eventName;
2300
- const attributes = this.getEnrichedAttributes(extraAttributes, eventName);
2301
- // Emit as log
2302
- this.logger.emit({
2303
- body: finalDisplayName,
2304
- attributes: attributes,
2305
- timestamp: Date.now(),
2306
- });
2307
- }
2308
- catch (error) {
2309
- // Silent failure
2310
- console.debug('Failed to track telemetry event:', error);
2311
- }
2312
- }
2313
- /**
2314
- * Get enriched attributes for telemetry events
2315
- */
2316
- getEnrichedAttributes(extraAttributes, eventName) {
2317
- const attributes = {
2318
- [APP_NAME]: SDK_SERVICE_NAME,
2319
- [VERSION]: SDK_VERSION,
2320
- [SERVICE]: eventName,
2321
- [CLOUD_URL]: this.createCloudUrl(),
2322
- [CLOUD_ORGANIZATION_NAME]: this.telemetryContext?.orgName || UNKNOWN,
2323
- [CLOUD_TENANT_NAME]: this.telemetryContext?.tenantName || UNKNOWN,
2324
- [CLOUD_REDIRECT_URI]: this.telemetryContext?.redirectUri || UNKNOWN,
2325
- [CLOUD_CLIENT_ID]: this.telemetryContext?.clientId || UNKNOWN,
2326
- ...extraAttributes,
2327
- };
2328
- return attributes;
2329
- }
2330
- /**
2331
- * Create cloud URL from base URL, organization ID, and tenant ID
2332
- */
2333
- createCloudUrl() {
2334
- const baseUrl = this.telemetryContext?.baseUrl;
2335
- const orgId = this.telemetryContext?.orgName;
2336
- const tenantId = this.telemetryContext?.tenantName;
2337
- if (!baseUrl || !orgId || !tenantId) {
2338
- return UNKNOWN;
2339
- }
2340
- return `${baseUrl}/${orgId}/${tenantId}`;
2341
- }
2342
- }
2343
- // Export singleton instance
2344
- const telemetryClient = TelemetryClient.getInstance();
2155
+ * SDK Telemetry constants.
2156
+ *
2157
+ * Only the SDK's identity (version, service name, role name, …) lives
2158
+ * here. The Application Insights connection string is injected into
2159
+ * `@uipath/core-telemetry` itself at publish time, and the generic attribute
2160
+ * keys (`Version`, `Service`, `CloudOrganizationName`, …) are owned by
2161
+ * `@uipath/core-telemetry` and consumed there — they are not part of the
2162
+ * SDK's public API.
2163
+ */
2164
+ /** SDK version placeholder — patched by the SDK publish workflow. */
2165
+ const CLOUD_ROLE_NAME = 'uipath-ts-sdk';
2345
2166
 
2346
2167
  /**
2347
- * SDK Track decorator and function for telemetry
2348
- */
2349
- /**
2350
- * Common tracking logic shared between method and function decorators
2351
- */
2352
- function createTrackedFunction(originalFunction, nameOrOptions, fallbackName, opts) {
2353
- return function (...args) {
2354
- // Determine if we should track this call
2355
- let shouldTrack = true;
2356
- if (opts.condition !== undefined) {
2357
- if (typeof opts.condition === 'function') {
2358
- shouldTrack = opts.condition.apply(this, args);
2359
- }
2360
- else {
2361
- shouldTrack = opts.condition;
2362
- }
2363
- }
2364
- // Track the event if enabled
2365
- if (shouldTrack) {
2366
- // Use the full name provided in the decorator (e.g., "Queue.GetAll")
2367
- const serviceMethod = typeof nameOrOptions === 'string'
2368
- ? nameOrOptions
2369
- : fallbackName;
2370
- // Use 'Sdk.Run' as the name and serviceMethod as the service
2371
- telemetryClient.track(serviceMethod, SDK_RUN_EVENT, opts.attributes);
2372
- }
2373
- // Execute the original function
2374
- return originalFunction.apply(this, args);
2375
- };
2376
- }
2377
- /**
2378
- * Track decorator that can be used to automatically track function calls
2379
- *
2380
- * Usage:
2381
- * @track("Service.Method")
2382
- * function myFunction() { ... }
2383
- *
2384
- * @track("Queue.GetAll")
2385
- * async getAll() { ... }
2168
+ * UiPath TypeScript SDK Telemetry
2386
2169
  *
2387
- * @track("Tasks.Create")
2388
- * async create() { ... }
2389
- *
2390
- * @track("Assets.Update", { condition: false })
2391
- * function myFunction() { ... }
2392
- *
2393
- * @track("Processes.Start", { attributes: { customProp: "value" } })
2394
- * function myFunction() { ... }
2395
- */
2396
- function track(nameOrOptions, options) {
2397
- return function decorator(_target, propertyKey, descriptor) {
2398
- const opts = typeof nameOrOptions === 'object' ? nameOrOptions : {};
2399
- if (descriptor && typeof descriptor.value === 'function') {
2400
- // Method decorator
2401
- descriptor.value = createTrackedFunction(descriptor.value, nameOrOptions, propertyKey || 'unknown_method', opts);
2402
- return descriptor;
2403
- }
2404
- // Function decorator
2405
- return (originalFunction) => createTrackedFunction(originalFunction, nameOrOptions, originalFunction.name || 'unknown_function', opts);
2406
- };
2407
- }
2170
+ * Constructs the SDK's own `TelemetryClient` and binds the SDK-local
2171
+ * `track` / `trackEvent` to it. Each consumer of `@uipath/core-telemetry`
2172
+ * does this independently, so events carry their own consumer's identity
2173
+ * and tenant context.
2174
+ */
2175
+ // Keyed by `CLOUD_ROLE_NAME` so every SDK subpath bundle resolves to the
2176
+ // same `TelemetryClient` instance at runtime. A single `initialize(...)`
2177
+ // from the `UiPath` constructor therefore wires up `@track` decorators
2178
+ // across every subpath bundle (`assets`, `feedback`, `tasks`, …).
2179
+ const sdkClient = getOrCreateClient(CLOUD_ROLE_NAME);
2180
+ const track = createTrack(sdkClient);
2181
+ createTrackEvent(sdkClient);
2408
2182
 
2409
2183
  /**
2410
2184
  * Service for interacting with the Data Fabric Entity API
@@ -3510,7 +3284,7 @@ class ChoiceSetService extends BaseService {
3510
3284
  *
3511
3285
  * @example
3512
3286
  * ```typescript
3513
- * import { ChoiceSets } from '@uipath/uipath-typescript/choicesets';
3287
+ * import { ChoiceSets } from '@uipath/uipath-typescript/entities';
3514
3288
  *
3515
3289
  * const choiceSets = new ChoiceSets(sdk);
3516
3290
  *
@@ -3559,6 +3333,188 @@ class ChoiceSetService extends BaseService {
3559
3333
  }
3560
3334
  }, options);
3561
3335
  }
3336
+ /**
3337
+ * Creates a new Data Fabric choice set
3338
+ *
3339
+ * @param name - Choice set name. Must start with a
3340
+ * letter, may contain only letters, numbers, and underscores, length
3341
+ * 3–100 characters (e.g., `"expenseTypes"`).
3342
+ * @param options - Optional choice-set-level settings ({@link ChoiceSetCreateOptions})
3343
+ * @returns Promise resolving to the UUID of the created choice set
3344
+ *
3345
+ * @example
3346
+ * ```typescript
3347
+ * import { ChoiceSets } from '@uipath/uipath-typescript/entities';
3348
+ *
3349
+ * const choicesets = new ChoiceSets(sdk);
3350
+ *
3351
+ * // Minimal create
3352
+ * const expenseTypesId = await choicesets.create("expense_types");
3353
+ *
3354
+ * // With display name and description
3355
+ * const priorityLevelsId = await choicesets.create("priority_levels", {
3356
+ * displayName: "Priority Levels",
3357
+ * description: "Ticket priority categories",
3358
+ * });
3359
+ * ```
3360
+ * @internal
3361
+ */
3362
+ async create(name, options) {
3363
+ const opts = options ?? {};
3364
+ const payload = {
3365
+ ...(opts.description !== undefined && { description: opts.description }),
3366
+ ...(opts.displayName !== undefined && { displayName: opts.displayName }),
3367
+ entityDefinition: {
3368
+ name,
3369
+ fields: [],
3370
+ folderId: opts.folderKey ?? DATA_FABRIC_TENANT_FOLDER_ID,
3371
+ },
3372
+ };
3373
+ const response = await this.post(DATA_FABRIC_ENDPOINTS.CHOICESETS.CREATE, payload);
3374
+ return response.data;
3375
+ }
3376
+ /**
3377
+ * Updates an existing choice set's metadata (display name and/or description).
3378
+ *
3379
+ * **At least one of `displayName` or `description` must be provided** —
3380
+ * the call throws `ValidationError` if both are omitted.
3381
+ *
3382
+ * @param choiceSetId - UUID of the choice set to update
3383
+ * @param options - Metadata fields to change ({@link ChoiceSetUpdateOptions})
3384
+ * @returns Promise resolving when the update is complete
3385
+ *
3386
+ * @example
3387
+ * ```typescript
3388
+ * // First, get the choice set ID using getAll()
3389
+ * const allChoiceSets = await choicesets.getAll();
3390
+ * const expenseTypes = allChoiceSets.find(cs => cs.name === 'expense_types');
3391
+ *
3392
+ * await choicesets.updateById(expenseTypes.id, {
3393
+ * displayName: "Expense Categories",
3394
+ * description: "Updated description",
3395
+ * });
3396
+ * ```
3397
+ * @internal
3398
+ */
3399
+ async updateById(choiceSetId, options) {
3400
+ if (options.displayName === undefined && options.description === undefined) {
3401
+ throw new ValidationError({
3402
+ message: 'updateById requires at least one of displayName or description.',
3403
+ });
3404
+ }
3405
+ await this.patch(DATA_FABRIC_ENDPOINTS.CHOICESETS.UPDATE(choiceSetId), {
3406
+ ...(options.displayName !== undefined && { displayName: options.displayName }),
3407
+ ...(options.description !== undefined && { description: options.description }),
3408
+ });
3409
+ }
3410
+ /**
3411
+ * Deletes a Data Fabric choice set and all its values.
3412
+ *
3413
+ * @param choiceSetId - UUID of the choice set to delete
3414
+ * @returns Promise resolving when the choice set is deleted
3415
+ *
3416
+ * @example
3417
+ * ```typescript
3418
+ * // First, get the choice set ID using getAll()
3419
+ * const allChoiceSets = await choicesets.getAll();
3420
+ * const expenseTypes = allChoiceSets.find(cs => cs.name === 'expense_types');
3421
+ *
3422
+ * await choicesets.deleteById(expenseTypes.id);
3423
+ * ```
3424
+ * @internal
3425
+ */
3426
+ async deleteById(choiceSetId) {
3427
+ await this.post(DATA_FABRIC_ENDPOINTS.CHOICESETS.DELETE(choiceSetId), {});
3428
+ }
3429
+ /**
3430
+ * Inserts a single value into a choice set.
3431
+ *
3432
+ * @param choiceSetId - UUID of the parent choice set
3433
+ * @param name - Identifier name of the new value (e.g., `"TRAVEL"`)
3434
+ * @param options - Optional fields ({@link ChoiceSetValueInsertOptions})
3435
+ * @returns Promise resolving to the inserted value ({@link ChoiceSetValueInsertResponse})
3436
+ *
3437
+ * @example
3438
+ * ```typescript
3439
+ * // First, get the choice set ID using getAll()
3440
+ * const allChoiceSets = await choicesets.getAll();
3441
+ * const expenseTypes = allChoiceSets.find(cs => cs.name === 'expense_types');
3442
+ *
3443
+ * const inserted = await choicesets.insertValueById(expenseTypes.id, 'TRAVEL', {
3444
+ * displayName: 'Travel',
3445
+ * });
3446
+ * console.log(inserted.id);
3447
+ * ```
3448
+ * @internal
3449
+ */
3450
+ async insertValueById(choiceSetId, name, options) {
3451
+ const choiceSetName = await this.resolveChoiceSetName(choiceSetId);
3452
+ const payload = {
3453
+ Name: name,
3454
+ ...(options?.displayName !== undefined && { DisplayName: options.displayName }),
3455
+ };
3456
+ const response = await this.post(DATA_FABRIC_ENDPOINTS.CHOICESETS.INSERT_BY_NAME(choiceSetName), payload);
3457
+ const camelCased = pascalToCamelCaseKeys(response.data);
3458
+ return transformData(camelCased, EntityMap);
3459
+ }
3460
+ /**
3461
+ * Updates an existing choice-set value's display name.
3462
+ *
3463
+ * Only `displayName` is mutable; the value's `name` (identifier) is fixed at
3464
+ * insert time and cannot be changed.
3465
+ *
3466
+ * @param choiceSetId - UUID of the parent choice set
3467
+ * @param valueId - UUID of the value to update
3468
+ * @param displayName - New human-readable display name for the value
3469
+ * @returns Promise resolving to the updated value ({@link ChoiceSetValueUpdateResponse})
3470
+ *
3471
+ * @example
3472
+ * ```typescript
3473
+ * // Get the choice set ID from getAll() and the value ID from getById()
3474
+ * const allChoiceSets = await choicesets.getAll();
3475
+ * const expenseTypes = allChoiceSets.find(cs => cs.name === 'expense_types');
3476
+ * const values = await choicesets.getById(expenseTypes.id);
3477
+ * const travel = values.items.find(v => v.name === 'TRAVEL');
3478
+ *
3479
+ * await choicesets.updateValueById(expenseTypes.id, travel.id, 'Business Travel');
3480
+ * ```
3481
+ * @internal
3482
+ */
3483
+ async updateValueById(choiceSetId, valueId, displayName) {
3484
+ const choiceSetName = await this.resolveChoiceSetName(choiceSetId);
3485
+ const payload = { DisplayName: displayName };
3486
+ const response = await this.post(DATA_FABRIC_ENDPOINTS.CHOICESETS.UPDATE_BY_NAME(choiceSetName, valueId), payload);
3487
+ const camelCased = pascalToCamelCaseKeys(response.data);
3488
+ return transformData(camelCased, EntityMap);
3489
+ }
3490
+ /**
3491
+ * Deletes one or more values from a choice set.
3492
+ *
3493
+ * @param choiceSetId - UUID of the parent choice set
3494
+ * @param valueIds - Array of value UUIDs to delete
3495
+ * @returns Promise resolving when the values are deleted
3496
+ *
3497
+ * @example
3498
+ * ```typescript
3499
+ * // Get the value IDs from getById()
3500
+ * const values = await choicesets.getById('<choiceSetId>');
3501
+ * const idsToDelete = values.items.slice(0, 2).map(v => v.id);
3502
+ *
3503
+ * await choicesets.deleteValuesById('<choiceSetId>', idsToDelete);
3504
+ * ```
3505
+ * @internal
3506
+ */
3507
+ async deleteValuesById(choiceSetId, valueIds) {
3508
+ await this.post(DATA_FABRIC_ENDPOINTS.CHOICESETS.DELETE_BY_ID(choiceSetId), valueIds);
3509
+ }
3510
+ async resolveChoiceSetName(choiceSetId) {
3511
+ const all = await this.getAll();
3512
+ const match = all.find(cs => cs.id === choiceSetId);
3513
+ if (!match) {
3514
+ throw new NotFoundError({ message: `Choice set with id '${choiceSetId}' not found.` });
3515
+ }
3516
+ return match.name;
3517
+ }
3562
3518
  }
3563
3519
  __decorate([
3564
3520
  track('Choicesets.GetAll')
@@ -3566,5 +3522,23 @@ __decorate([
3566
3522
  __decorate([
3567
3523
  track('Choicesets.GetById')
3568
3524
  ], ChoiceSetService.prototype, "getById", null);
3525
+ __decorate([
3526
+ track('Choicesets.Create')
3527
+ ], ChoiceSetService.prototype, "create", null);
3528
+ __decorate([
3529
+ track('Choicesets.UpdateById')
3530
+ ], ChoiceSetService.prototype, "updateById", null);
3531
+ __decorate([
3532
+ track('Choicesets.DeleteById')
3533
+ ], ChoiceSetService.prototype, "deleteById", null);
3534
+ __decorate([
3535
+ track('Choicesets.InsertValueById')
3536
+ ], ChoiceSetService.prototype, "insertValueById", null);
3537
+ __decorate([
3538
+ track('Choicesets.UpdateValueById')
3539
+ ], ChoiceSetService.prototype, "updateValueById", null);
3540
+ __decorate([
3541
+ track('Choicesets.DeleteValuesById')
3542
+ ], ChoiceSetService.prototype, "deleteValuesById", null);
3569
3543
 
3570
3544
  export { ChoiceSetService, ChoiceSetService as ChoiceSets, DataDirectionType, EntityService as Entities, EntityAggregateFunction, EntityFieldDataType, EntityService, EntityType, FieldDisplayType, JoinType, LogicalOperator, QueryFilterOperator, ReferenceType, createEntityWithMethods };