@uipath/uipath-typescript 1.3.9 → 1.3.11
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.
- package/dist/assets/index.cjs +19 -6
- package/dist/assets/index.mjs +19 -6
- package/dist/attachments/index.cjs +19 -6
- package/dist/attachments/index.mjs +19 -6
- package/dist/buckets/index.cjs +141 -6
- package/dist/buckets/index.d.ts +164 -1
- package/dist/buckets/index.mjs +141 -6
- package/dist/cases/index.cjs +70 -6
- package/dist/cases/index.d.ts +91 -1
- package/dist/cases/index.mjs +70 -6
- package/dist/conversational-agent/index.cjs +19 -6
- package/dist/conversational-agent/index.mjs +19 -6
- package/dist/core/index.cjs +1 -1
- package/dist/core/index.mjs +1 -1
- package/dist/entities/index.cjs +239 -34
- package/dist/entities/index.d.ts +311 -12
- package/dist/entities/index.mjs +239 -34
- package/dist/feedback/index.cjs +19 -6
- package/dist/feedback/index.mjs +19 -6
- package/dist/index.cjs +490 -64
- package/dist/index.d.ts +714 -36
- package/dist/index.mjs +490 -64
- package/dist/index.umd.js +491 -65
- package/dist/jobs/index.cjs +19 -6
- package/dist/jobs/index.mjs +19 -6
- package/dist/maestro-processes/index.cjs +70 -6
- package/dist/maestro-processes/index.d.ts +91 -1
- package/dist/maestro-processes/index.mjs +70 -6
- package/dist/processes/index.cjs +47 -35
- package/dist/processes/index.d.ts +76 -26
- package/dist/processes/index.mjs +47 -35
- package/dist/queues/index.cjs +19 -6
- package/dist/queues/index.mjs +19 -6
- package/dist/tasks/index.cjs +19 -6
- package/dist/tasks/index.mjs +19 -6
- package/dist/traces/index.cjs +1902 -0
- package/dist/traces/index.d.ts +565 -0
- package/dist/traces/index.mjs +1900 -0
- package/package.json +12 -2
package/dist/entities/index.cjs
CHANGED
|
@@ -611,14 +611,25 @@ class ApiClient {
|
|
|
611
611
|
if (!text) {
|
|
612
612
|
return undefined;
|
|
613
613
|
}
|
|
614
|
-
|
|
614
|
+
try {
|
|
615
|
+
return JSON.parse(text);
|
|
616
|
+
}
|
|
617
|
+
catch (error) {
|
|
618
|
+
if (error instanceof SyntaxError) {
|
|
619
|
+
throw new ServerError({
|
|
620
|
+
message: `Server returned non-JSON response (${response.status} ${response.url}): ${error.message}`,
|
|
621
|
+
statusCode: response.status,
|
|
622
|
+
});
|
|
623
|
+
}
|
|
624
|
+
throw error;
|
|
625
|
+
}
|
|
615
626
|
}
|
|
616
627
|
catch (error) {
|
|
617
628
|
// If it's already one of our errors, re-throw it
|
|
618
629
|
if (error.type && error.type.includes('Error')) {
|
|
619
630
|
throw error;
|
|
620
631
|
}
|
|
621
|
-
// Otherwise, it's
|
|
632
|
+
// Otherwise, it's a genuine network/fetch failure
|
|
622
633
|
throw ErrorFactory.createNetworkError(error);
|
|
623
634
|
}
|
|
624
635
|
}
|
|
@@ -1240,9 +1251,9 @@ class PaginationHelpers {
|
|
|
1240
1251
|
* @returns Promise resolving to a paginated result
|
|
1241
1252
|
*/
|
|
1242
1253
|
static async getAllPaginated(params) {
|
|
1243
|
-
const { serviceAccess, getEndpoint, folderId, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
|
|
1254
|
+
const { serviceAccess, getEndpoint, folderId, headers: providedHeaders, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
|
|
1244
1255
|
const endpoint = getEndpoint(folderId);
|
|
1245
|
-
const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
|
|
1256
|
+
const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
|
|
1246
1257
|
const paginatedResponse = await serviceAccess.requestWithPagination(method, endpoint, paginationParams, {
|
|
1247
1258
|
headers,
|
|
1248
1259
|
params: additionalParams,
|
|
@@ -1270,13 +1281,13 @@ class PaginationHelpers {
|
|
|
1270
1281
|
* @returns Promise resolving to an object with data and totalCount
|
|
1271
1282
|
*/
|
|
1272
1283
|
static async getAllNonPaginated(params) {
|
|
1273
|
-
const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
|
|
1284
|
+
const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, headers: providedHeaders, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
|
|
1274
1285
|
// Set default field names
|
|
1275
1286
|
const itemsField = options.itemsField || DEFAULT_ITEMS_FIELD;
|
|
1276
1287
|
const totalCountField = options.totalCountField || DEFAULT_TOTAL_COUNT_FIELD;
|
|
1277
1288
|
// Determine endpoint and headers based on folderId
|
|
1278
1289
|
const endpoint = folderId ? getByFolderEndpoint : getAllEndpoint;
|
|
1279
|
-
const headers = folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {};
|
|
1290
|
+
const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
|
|
1280
1291
|
// Make the API call based on method
|
|
1281
1292
|
let response;
|
|
1282
1293
|
if (method === HTTP_METHODS.POST) {
|
|
@@ -1335,6 +1346,7 @@ class PaginationHelpers {
|
|
|
1335
1346
|
serviceAccess: config.serviceAccess,
|
|
1336
1347
|
getEndpoint: config.getEndpoint,
|
|
1337
1348
|
folderId,
|
|
1349
|
+
headers: config.headers,
|
|
1338
1350
|
paginationParams: cursor ? { cursor, pageSize } : jumpToPage ? { jumpToPage, pageSize } : { pageSize },
|
|
1339
1351
|
additionalParams: prefixedOptions,
|
|
1340
1352
|
transformFn: config.transformFn,
|
|
@@ -1352,6 +1364,7 @@ class PaginationHelpers {
|
|
|
1352
1364
|
getAllEndpoint: config.getEndpoint(),
|
|
1353
1365
|
getByFolderEndpoint: byFolderEndpoint,
|
|
1354
1366
|
folderId,
|
|
1367
|
+
headers: config.headers,
|
|
1355
1368
|
additionalParams: prefixedOptions,
|
|
1356
1369
|
transformFn: config.transformFn,
|
|
1357
1370
|
method: config.method,
|
|
@@ -1938,6 +1951,12 @@ const DATA_FABRIC_ENDPOINTS = {
|
|
|
1938
1951
|
CHOICESETS: {
|
|
1939
1952
|
GET_ALL: `${DATAFABRIC_BASE}/api/Entity/choiceset`,
|
|
1940
1953
|
GET_BY_ID: (choiceSetId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${choiceSetId}/query_expansion`,
|
|
1954
|
+
CREATE: `${DATAFABRIC_BASE}/api/Entity/choiceset`,
|
|
1955
|
+
UPDATE: (choiceSetId) => `${DATAFABRIC_BASE}/api/Entity/${choiceSetId}/metadata`,
|
|
1956
|
+
DELETE: (choiceSetId) => `${DATAFABRIC_BASE}/api/Entity/${choiceSetId}/delete`,
|
|
1957
|
+
INSERT_BY_NAME: (choiceSetName) => `${DATAFABRIC_BASE}/api/EntityService/${choiceSetName}/choiceset/insert`,
|
|
1958
|
+
UPDATE_BY_NAME: (choiceSetName, valueId) => `${DATAFABRIC_BASE}/api/EntityService/${choiceSetName}/choiceset/${valueId}/update`,
|
|
1959
|
+
DELETE_BY_ID: (choiceSetId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${choiceSetId}/choiceset/delete`,
|
|
1941
1960
|
},
|
|
1942
1961
|
};
|
|
1943
1962
|
|
|
@@ -2772,10 +2791,6 @@ class EntityService extends BaseService {
|
|
|
2772
2791
|
* @internal
|
|
2773
2792
|
*/
|
|
2774
2793
|
async create(name, fields, options) {
|
|
2775
|
-
this.validateName(name, 'entity');
|
|
2776
|
-
for (const field of fields) {
|
|
2777
|
-
this.validateName(field.fieldName, 'field');
|
|
2778
|
-
}
|
|
2779
2794
|
const opts = options ?? {};
|
|
2780
2795
|
const payload = {
|
|
2781
2796
|
...(opts.description !== undefined && { description: opts.description }),
|
|
@@ -2918,6 +2933,7 @@ class EntityService extends BaseService {
|
|
|
2918
2933
|
...(update.isUnique !== undefined && { isUnique: update.isUnique }),
|
|
2919
2934
|
...(update.isRbacEnabled !== undefined && { isRbacEnabled: update.isRbacEnabled }),
|
|
2920
2935
|
...(update.isEncrypted !== undefined && { isEncrypted: update.isEncrypted }),
|
|
2936
|
+
...(update.isHiddenField !== undefined && { isHiddenField: update.isHiddenField }),
|
|
2921
2937
|
...(update.defaultValue !== undefined && { defaultValue: update.defaultValue }),
|
|
2922
2938
|
...(hasConstraintUpdate && f.sqlType && { sqlType: { ...f.sqlType, ...constraintUpdate } }),
|
|
2923
2939
|
};
|
|
@@ -2926,9 +2942,6 @@ class EntityService extends BaseService {
|
|
|
2926
2942
|
// Build and append new fields
|
|
2927
2943
|
const newFields = [];
|
|
2928
2944
|
if (options.addFields?.length) {
|
|
2929
|
-
for (const field of options.addFields) {
|
|
2930
|
-
this.validateName(field.fieldName, 'field');
|
|
2931
|
-
}
|
|
2932
2945
|
newFields.push(...options.addFields.map(f => this.buildSchemaFieldPayload(f)));
|
|
2933
2946
|
}
|
|
2934
2947
|
await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPSERT, {
|
|
@@ -3029,9 +3042,15 @@ class EntityService extends BaseService {
|
|
|
3029
3042
|
}
|
|
3030
3043
|
/** Converts a user-facing EntityCreateFieldOptions to the raw API field payload */
|
|
3031
3044
|
buildSchemaFieldPayload(field) {
|
|
3032
|
-
this.validateName(field.fieldName, 'field');
|
|
3033
3045
|
const fieldType = field.type ?? exports.EntityFieldDataType.STRING;
|
|
3034
3046
|
this.validateFieldConstraints(fieldType, field, field.fieldName);
|
|
3047
|
+
const isRelationship = fieldType === exports.EntityFieldDataType.RELATIONSHIP;
|
|
3048
|
+
const isFile = fieldType === exports.EntityFieldDataType.FILE;
|
|
3049
|
+
if ((isRelationship || isFile) && (!field.referenceEntityId || !field.referenceFieldId)) {
|
|
3050
|
+
throw new ValidationError({
|
|
3051
|
+
message: `Field '${field.fieldName}' of type ${fieldType} requires both referenceEntityId and referenceFieldId (UUIDs of the target entity and field).`,
|
|
3052
|
+
});
|
|
3053
|
+
}
|
|
3035
3054
|
const mapping = EntitySchemaFieldTypeMap[fieldType];
|
|
3036
3055
|
return {
|
|
3037
3056
|
name: field.fieldName,
|
|
@@ -3046,10 +3065,13 @@ class EntityService extends BaseService {
|
|
|
3046
3065
|
isUnique: field.isUnique ?? false,
|
|
3047
3066
|
isRbacEnabled: field.isRbacEnabled ?? false,
|
|
3048
3067
|
isEncrypted: field.isEncrypted ?? false,
|
|
3068
|
+
isHiddenField: field.isHiddenField ?? false,
|
|
3049
3069
|
...(field.defaultValue !== undefined && { defaultValue: field.defaultValue }),
|
|
3050
3070
|
...(field.choiceSetId !== undefined && { choiceSetId: field.choiceSetId }),
|
|
3051
|
-
...(
|
|
3052
|
-
...(
|
|
3071
|
+
...((isRelationship || isFile) && { isForeignKey: true }),
|
|
3072
|
+
...(isRelationship && { referenceType: exports.ReferenceType.ManyToOne }),
|
|
3073
|
+
...(field.referenceEntityId !== undefined && { referenceEntity: { id: field.referenceEntityId } }),
|
|
3074
|
+
...(field.referenceFieldId !== undefined && { referenceField: { id: field.referenceFieldId } }),
|
|
3053
3075
|
};
|
|
3054
3076
|
}
|
|
3055
3077
|
/**
|
|
@@ -3153,24 +3175,7 @@ class EntityService extends BaseService {
|
|
|
3153
3175
|
return {};
|
|
3154
3176
|
}
|
|
3155
3177
|
}
|
|
3156
|
-
validateName(name, context) {
|
|
3157
|
-
if (name.length < 3 || name.length > 100 || !/^[a-zA-Z]\w*$/.test(name)) {
|
|
3158
|
-
const suggestion = name.replace(/\W/g, '').replace(/^[0-9_]+/, '');
|
|
3159
|
-
const defaultName = `My${context.charAt(0).toUpperCase() + context.slice(1)}`;
|
|
3160
|
-
throw new ValidationError({
|
|
3161
|
-
message: `Invalid ${context} name '${name}'. Must start with a letter, contain only letters, numbers, and underscores, 3–100 characters (e.g., "${suggestion || defaultName}").`
|
|
3162
|
-
});
|
|
3163
|
-
}
|
|
3164
|
-
if (context === 'field' && EntityService.RESERVED_FIELD_NAMES.has(name)) {
|
|
3165
|
-
throw new ValidationError({
|
|
3166
|
-
message: `Field name '${name}' is reserved. Reserved names: ${[...EntityService.RESERVED_FIELD_NAMES].join(', ')}.`
|
|
3167
|
-
});
|
|
3168
|
-
}
|
|
3169
|
-
}
|
|
3170
3178
|
}
|
|
3171
|
-
EntityService.RESERVED_FIELD_NAMES = new Set([
|
|
3172
|
-
'Id', 'CreatedBy', 'CreateTime', 'UpdatedBy', 'UpdateTime'
|
|
3173
|
-
]);
|
|
3174
3179
|
__decorate([
|
|
3175
3180
|
track('Entities.GetById')
|
|
3176
3181
|
], EntityService.prototype, "getById", null);
|
|
@@ -3267,7 +3272,7 @@ class ChoiceSetService extends BaseService {
|
|
|
3267
3272
|
*
|
|
3268
3273
|
* @example
|
|
3269
3274
|
* ```typescript
|
|
3270
|
-
* import { ChoiceSets } from '@uipath/uipath-typescript/
|
|
3275
|
+
* import { ChoiceSets } from '@uipath/uipath-typescript/entities';
|
|
3271
3276
|
*
|
|
3272
3277
|
* const choiceSets = new ChoiceSets(sdk);
|
|
3273
3278
|
*
|
|
@@ -3316,6 +3321,188 @@ class ChoiceSetService extends BaseService {
|
|
|
3316
3321
|
}
|
|
3317
3322
|
}, options);
|
|
3318
3323
|
}
|
|
3324
|
+
/**
|
|
3325
|
+
* Creates a new Data Fabric choice set
|
|
3326
|
+
*
|
|
3327
|
+
* @param name - Choice set name. Must start with a
|
|
3328
|
+
* letter, may contain only letters, numbers, and underscores, length
|
|
3329
|
+
* 3–100 characters (e.g., `"expenseTypes"`).
|
|
3330
|
+
* @param options - Optional choice-set-level settings ({@link ChoiceSetCreateOptions})
|
|
3331
|
+
* @returns Promise resolving to the UUID of the created choice set
|
|
3332
|
+
*
|
|
3333
|
+
* @example
|
|
3334
|
+
* ```typescript
|
|
3335
|
+
* import { ChoiceSets } from '@uipath/uipath-typescript/entities';
|
|
3336
|
+
*
|
|
3337
|
+
* const choicesets = new ChoiceSets(sdk);
|
|
3338
|
+
*
|
|
3339
|
+
* // Minimal create
|
|
3340
|
+
* const expenseTypesId = await choicesets.create("expense_types");
|
|
3341
|
+
*
|
|
3342
|
+
* // With display name and description
|
|
3343
|
+
* const priorityLevelsId = await choicesets.create("priority_levels", {
|
|
3344
|
+
* displayName: "Priority Levels",
|
|
3345
|
+
* description: "Ticket priority categories",
|
|
3346
|
+
* });
|
|
3347
|
+
* ```
|
|
3348
|
+
* @internal
|
|
3349
|
+
*/
|
|
3350
|
+
async create(name, options) {
|
|
3351
|
+
const opts = options ?? {};
|
|
3352
|
+
const payload = {
|
|
3353
|
+
...(opts.description !== undefined && { description: opts.description }),
|
|
3354
|
+
...(opts.displayName !== undefined && { displayName: opts.displayName }),
|
|
3355
|
+
entityDefinition: {
|
|
3356
|
+
name,
|
|
3357
|
+
fields: [],
|
|
3358
|
+
folderId: opts.folderKey ?? DATA_FABRIC_TENANT_FOLDER_ID,
|
|
3359
|
+
},
|
|
3360
|
+
};
|
|
3361
|
+
const response = await this.post(DATA_FABRIC_ENDPOINTS.CHOICESETS.CREATE, payload);
|
|
3362
|
+
return response.data;
|
|
3363
|
+
}
|
|
3364
|
+
/**
|
|
3365
|
+
* Updates an existing choice set's metadata (display name and/or description).
|
|
3366
|
+
*
|
|
3367
|
+
* **At least one of `displayName` or `description` must be provided** —
|
|
3368
|
+
* the call throws `ValidationError` if both are omitted.
|
|
3369
|
+
*
|
|
3370
|
+
* @param choiceSetId - UUID of the choice set to update
|
|
3371
|
+
* @param options - Metadata fields to change ({@link ChoiceSetUpdateOptions})
|
|
3372
|
+
* @returns Promise resolving when the update is complete
|
|
3373
|
+
*
|
|
3374
|
+
* @example
|
|
3375
|
+
* ```typescript
|
|
3376
|
+
* // First, get the choice set ID using getAll()
|
|
3377
|
+
* const allChoiceSets = await choicesets.getAll();
|
|
3378
|
+
* const expenseTypes = allChoiceSets.find(cs => cs.name === 'expense_types');
|
|
3379
|
+
*
|
|
3380
|
+
* await choicesets.updateById(expenseTypes.id, {
|
|
3381
|
+
* displayName: "Expense Categories",
|
|
3382
|
+
* description: "Updated description",
|
|
3383
|
+
* });
|
|
3384
|
+
* ```
|
|
3385
|
+
* @internal
|
|
3386
|
+
*/
|
|
3387
|
+
async updateById(choiceSetId, options) {
|
|
3388
|
+
if (options.displayName === undefined && options.description === undefined) {
|
|
3389
|
+
throw new ValidationError({
|
|
3390
|
+
message: 'updateById requires at least one of displayName or description.',
|
|
3391
|
+
});
|
|
3392
|
+
}
|
|
3393
|
+
await this.patch(DATA_FABRIC_ENDPOINTS.CHOICESETS.UPDATE(choiceSetId), {
|
|
3394
|
+
...(options.displayName !== undefined && { displayName: options.displayName }),
|
|
3395
|
+
...(options.description !== undefined && { description: options.description }),
|
|
3396
|
+
});
|
|
3397
|
+
}
|
|
3398
|
+
/**
|
|
3399
|
+
* Deletes a Data Fabric choice set and all its values.
|
|
3400
|
+
*
|
|
3401
|
+
* @param choiceSetId - UUID of the choice set to delete
|
|
3402
|
+
* @returns Promise resolving when the choice set is deleted
|
|
3403
|
+
*
|
|
3404
|
+
* @example
|
|
3405
|
+
* ```typescript
|
|
3406
|
+
* // First, get the choice set ID using getAll()
|
|
3407
|
+
* const allChoiceSets = await choicesets.getAll();
|
|
3408
|
+
* const expenseTypes = allChoiceSets.find(cs => cs.name === 'expense_types');
|
|
3409
|
+
*
|
|
3410
|
+
* await choicesets.deleteById(expenseTypes.id);
|
|
3411
|
+
* ```
|
|
3412
|
+
* @internal
|
|
3413
|
+
*/
|
|
3414
|
+
async deleteById(choiceSetId) {
|
|
3415
|
+
await this.post(DATA_FABRIC_ENDPOINTS.CHOICESETS.DELETE(choiceSetId), {});
|
|
3416
|
+
}
|
|
3417
|
+
/**
|
|
3418
|
+
* Inserts a single value into a choice set.
|
|
3419
|
+
*
|
|
3420
|
+
* @param choiceSetId - UUID of the parent choice set
|
|
3421
|
+
* @param name - Identifier name of the new value (e.g., `"TRAVEL"`)
|
|
3422
|
+
* @param options - Optional fields ({@link ChoiceSetValueInsertOptions})
|
|
3423
|
+
* @returns Promise resolving to the inserted value ({@link ChoiceSetValueInsertResponse})
|
|
3424
|
+
*
|
|
3425
|
+
* @example
|
|
3426
|
+
* ```typescript
|
|
3427
|
+
* // First, get the choice set ID using getAll()
|
|
3428
|
+
* const allChoiceSets = await choicesets.getAll();
|
|
3429
|
+
* const expenseTypes = allChoiceSets.find(cs => cs.name === 'expense_types');
|
|
3430
|
+
*
|
|
3431
|
+
* const inserted = await choicesets.insertValueById(expenseTypes.id, 'TRAVEL', {
|
|
3432
|
+
* displayName: 'Travel',
|
|
3433
|
+
* });
|
|
3434
|
+
* console.log(inserted.id);
|
|
3435
|
+
* ```
|
|
3436
|
+
* @internal
|
|
3437
|
+
*/
|
|
3438
|
+
async insertValueById(choiceSetId, name, options) {
|
|
3439
|
+
const choiceSetName = await this.resolveChoiceSetName(choiceSetId);
|
|
3440
|
+
const payload = {
|
|
3441
|
+
Name: name,
|
|
3442
|
+
...(options?.displayName !== undefined && { DisplayName: options.displayName }),
|
|
3443
|
+
};
|
|
3444
|
+
const response = await this.post(DATA_FABRIC_ENDPOINTS.CHOICESETS.INSERT_BY_NAME(choiceSetName), payload);
|
|
3445
|
+
const camelCased = pascalToCamelCaseKeys(response.data);
|
|
3446
|
+
return transformData(camelCased, EntityMap);
|
|
3447
|
+
}
|
|
3448
|
+
/**
|
|
3449
|
+
* Updates an existing choice-set value's display name.
|
|
3450
|
+
*
|
|
3451
|
+
* Only `displayName` is mutable; the value's `name` (identifier) is fixed at
|
|
3452
|
+
* insert time and cannot be changed.
|
|
3453
|
+
*
|
|
3454
|
+
* @param choiceSetId - UUID of the parent choice set
|
|
3455
|
+
* @param valueId - UUID of the value to update
|
|
3456
|
+
* @param displayName - New human-readable display name for the value
|
|
3457
|
+
* @returns Promise resolving to the updated value ({@link ChoiceSetValueUpdateResponse})
|
|
3458
|
+
*
|
|
3459
|
+
* @example
|
|
3460
|
+
* ```typescript
|
|
3461
|
+
* // Get the choice set ID from getAll() and the value ID from getById()
|
|
3462
|
+
* const allChoiceSets = await choicesets.getAll();
|
|
3463
|
+
* const expenseTypes = allChoiceSets.find(cs => cs.name === 'expense_types');
|
|
3464
|
+
* const values = await choicesets.getById(expenseTypes.id);
|
|
3465
|
+
* const travel = values.items.find(v => v.name === 'TRAVEL');
|
|
3466
|
+
*
|
|
3467
|
+
* await choicesets.updateValueById(expenseTypes.id, travel.id, 'Business Travel');
|
|
3468
|
+
* ```
|
|
3469
|
+
* @internal
|
|
3470
|
+
*/
|
|
3471
|
+
async updateValueById(choiceSetId, valueId, displayName) {
|
|
3472
|
+
const choiceSetName = await this.resolveChoiceSetName(choiceSetId);
|
|
3473
|
+
const payload = { DisplayName: displayName };
|
|
3474
|
+
const response = await this.post(DATA_FABRIC_ENDPOINTS.CHOICESETS.UPDATE_BY_NAME(choiceSetName, valueId), payload);
|
|
3475
|
+
const camelCased = pascalToCamelCaseKeys(response.data);
|
|
3476
|
+
return transformData(camelCased, EntityMap);
|
|
3477
|
+
}
|
|
3478
|
+
/**
|
|
3479
|
+
* Deletes one or more values from a choice set.
|
|
3480
|
+
*
|
|
3481
|
+
* @param choiceSetId - UUID of the parent choice set
|
|
3482
|
+
* @param valueIds - Array of value UUIDs to delete
|
|
3483
|
+
* @returns Promise resolving when the values are deleted
|
|
3484
|
+
*
|
|
3485
|
+
* @example
|
|
3486
|
+
* ```typescript
|
|
3487
|
+
* // Get the value IDs from getById()
|
|
3488
|
+
* const values = await choicesets.getById('<choiceSetId>');
|
|
3489
|
+
* const idsToDelete = values.items.slice(0, 2).map(v => v.id);
|
|
3490
|
+
*
|
|
3491
|
+
* await choicesets.deleteValuesById('<choiceSetId>', idsToDelete);
|
|
3492
|
+
* ```
|
|
3493
|
+
* @internal
|
|
3494
|
+
*/
|
|
3495
|
+
async deleteValuesById(choiceSetId, valueIds) {
|
|
3496
|
+
await this.post(DATA_FABRIC_ENDPOINTS.CHOICESETS.DELETE_BY_ID(choiceSetId), valueIds);
|
|
3497
|
+
}
|
|
3498
|
+
async resolveChoiceSetName(choiceSetId) {
|
|
3499
|
+
const all = await this.getAll();
|
|
3500
|
+
const match = all.find(cs => cs.id === choiceSetId);
|
|
3501
|
+
if (!match) {
|
|
3502
|
+
throw new NotFoundError({ message: `Choice set with id '${choiceSetId}' not found.` });
|
|
3503
|
+
}
|
|
3504
|
+
return match.name;
|
|
3505
|
+
}
|
|
3319
3506
|
}
|
|
3320
3507
|
__decorate([
|
|
3321
3508
|
track('Choicesets.GetAll')
|
|
@@ -3323,6 +3510,24 @@ __decorate([
|
|
|
3323
3510
|
__decorate([
|
|
3324
3511
|
track('Choicesets.GetById')
|
|
3325
3512
|
], ChoiceSetService.prototype, "getById", null);
|
|
3513
|
+
__decorate([
|
|
3514
|
+
track('Choicesets.Create')
|
|
3515
|
+
], ChoiceSetService.prototype, "create", null);
|
|
3516
|
+
__decorate([
|
|
3517
|
+
track('Choicesets.UpdateById')
|
|
3518
|
+
], ChoiceSetService.prototype, "updateById", null);
|
|
3519
|
+
__decorate([
|
|
3520
|
+
track('Choicesets.DeleteById')
|
|
3521
|
+
], ChoiceSetService.prototype, "deleteById", null);
|
|
3522
|
+
__decorate([
|
|
3523
|
+
track('Choicesets.InsertValueById')
|
|
3524
|
+
], ChoiceSetService.prototype, "insertValueById", null);
|
|
3525
|
+
__decorate([
|
|
3526
|
+
track('Choicesets.UpdateValueById')
|
|
3527
|
+
], ChoiceSetService.prototype, "updateValueById", null);
|
|
3528
|
+
__decorate([
|
|
3529
|
+
track('Choicesets.DeleteValuesById')
|
|
3530
|
+
], ChoiceSetService.prototype, "deleteValuesById", null);
|
|
3326
3531
|
|
|
3327
3532
|
exports.ChoiceSetService = ChoiceSetService;
|
|
3328
3533
|
exports.ChoiceSets = ChoiceSetService;
|