@uipath/uipath-typescript 1.4.0 → 1.4.2
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/agent-memory/index.cjs +16 -9
- package/dist/agent-memory/index.mjs +16 -9
- package/dist/agents/index.cjs +278 -9
- package/dist/agents/index.d.ts +465 -6
- package/dist/agents/index.mjs +279 -10
- package/dist/assets/index.cjs +16 -9
- package/dist/assets/index.mjs +16 -9
- package/dist/attachments/index.cjs +16 -9
- package/dist/attachments/index.mjs +16 -9
- package/dist/buckets/index.cjs +114 -124
- package/dist/buckets/index.d.ts +197 -84
- package/dist/buckets/index.mjs +114 -124
- package/dist/cases/index.cjs +79 -13
- package/dist/cases/index.d.ts +30 -3
- package/dist/cases/index.mjs +79 -13
- package/dist/conversational-agent/index.cjs +16 -9
- package/dist/conversational-agent/index.mjs +16 -9
- package/dist/core/index.cjs +35 -6
- package/dist/core/index.mjs +35 -6
- package/dist/document-understanding/index.cjs +84 -84
- package/dist/document-understanding/index.d.ts +2 -1
- package/dist/document-understanding/index.mjs +1 -1
- package/dist/entities/index.cjs +253 -69
- package/dist/entities/index.d.ts +343 -116
- package/dist/entities/index.mjs +253 -69
- package/dist/feedback/index.cjs +16 -9
- package/dist/feedback/index.mjs +16 -9
- package/dist/governance/index.cjs +16 -9
- package/dist/governance/index.mjs +16 -9
- package/dist/index.cjs +529 -193
- package/dist/index.d.ts +2141 -750
- package/dist/index.mjs +529 -194
- package/dist/index.umd.js +529 -193
- package/dist/jobs/index.cjs +16 -9
- package/dist/jobs/index.mjs +16 -9
- package/dist/maestro-processes/index.cjs +16 -9
- package/dist/maestro-processes/index.mjs +16 -9
- package/dist/orchestrator-du-module/index.cjs +1788 -0
- package/dist/orchestrator-du-module/index.d.ts +757 -0
- package/dist/orchestrator-du-module/index.mjs +1785 -0
- package/dist/processes/index.cjs +16 -9
- package/dist/processes/index.mjs +16 -9
- package/dist/queues/index.cjs +16 -9
- package/dist/queues/index.mjs +16 -9
- package/dist/tasks/index.cjs +79 -13
- package/dist/tasks/index.d.ts +109 -4
- package/dist/tasks/index.mjs +80 -14
- package/dist/traces/index.cjs +303 -9
- package/dist/traces/index.d.ts +482 -2
- package/dist/traces/index.mjs +302 -10
- package/package.json +11 -1
package/dist/entities/index.mjs
CHANGED
|
@@ -1276,12 +1276,18 @@ class PaginationHelpers {
|
|
|
1276
1276
|
* @returns Promise resolving to a paginated result
|
|
1277
1277
|
*/
|
|
1278
1278
|
static async getAllPaginated(params) {
|
|
1279
|
-
const { serviceAccess, getEndpoint, folderId, headers: providedHeaders, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
|
|
1279
|
+
const { serviceAccess, getEndpoint, folderId, headers: providedHeaders, paginationParams, additionalParams, queryParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
|
|
1280
1280
|
const endpoint = getEndpoint(folderId);
|
|
1281
1281
|
const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
|
|
1282
|
+
// On POST, the caller's options go in the body; queryParams stays in the URL.
|
|
1283
|
+
// On GET, everything is URL — queryParams merges with additionalParams.
|
|
1284
|
+
const isPost = method === HTTP_METHODS.POST;
|
|
1285
|
+
const requestSpec = isPost
|
|
1286
|
+
? { body: additionalParams, params: queryParams }
|
|
1287
|
+
: { params: { ...additionalParams, ...queryParams } };
|
|
1282
1288
|
const paginatedResponse = await serviceAccess.requestWithPagination(method, endpoint, paginationParams, {
|
|
1283
1289
|
headers,
|
|
1284
|
-
|
|
1290
|
+
...requestSpec,
|
|
1285
1291
|
pagination: {
|
|
1286
1292
|
paginationType: options.paginationType || PaginationType.OFFSET,
|
|
1287
1293
|
itemsField: options.itemsField || DEFAULT_ITEMS_FIELD,
|
|
@@ -1306,7 +1312,7 @@ class PaginationHelpers {
|
|
|
1306
1312
|
* @returns Promise resolving to an object with data and totalCount
|
|
1307
1313
|
*/
|
|
1308
1314
|
static async getAllNonPaginated(params) {
|
|
1309
|
-
const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, headers: providedHeaders, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
|
|
1315
|
+
const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, headers: providedHeaders, additionalParams, queryParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
|
|
1310
1316
|
// Set default field names
|
|
1311
1317
|
const itemsField = options.itemsField || DEFAULT_ITEMS_FIELD;
|
|
1312
1318
|
const totalCountField = options.totalCountField || DEFAULT_TOTAL_COUNT_FIELD;
|
|
@@ -1316,11 +1322,11 @@ class PaginationHelpers {
|
|
|
1316
1322
|
// Make the API call based on method
|
|
1317
1323
|
let response;
|
|
1318
1324
|
if (method === HTTP_METHODS.POST) {
|
|
1319
|
-
response = await serviceAccess.post(endpoint, additionalParams, { headers });
|
|
1325
|
+
response = await serviceAccess.post(endpoint, additionalParams, { headers, params: queryParams });
|
|
1320
1326
|
}
|
|
1321
1327
|
else {
|
|
1322
1328
|
response = await serviceAccess.get(endpoint, {
|
|
1323
|
-
params: additionalParams,
|
|
1329
|
+
params: { ...additionalParams, ...queryParams },
|
|
1324
1330
|
headers
|
|
1325
1331
|
});
|
|
1326
1332
|
}
|
|
@@ -1375,6 +1381,7 @@ class PaginationHelpers {
|
|
|
1375
1381
|
headers: config.headers,
|
|
1376
1382
|
paginationParams: cursor ? { cursor, pageSize } : jumpToPage !== undefined ? { jumpToPage, pageSize } : { pageSize },
|
|
1377
1383
|
additionalParams: prefixedOptions,
|
|
1384
|
+
queryParams: config.queryParams,
|
|
1378
1385
|
transformFn: config.transformFn,
|
|
1379
1386
|
method: config.method,
|
|
1380
1387
|
options: {
|
|
@@ -1392,6 +1399,7 @@ class PaginationHelpers {
|
|
|
1392
1399
|
folderId,
|
|
1393
1400
|
headers: config.headers,
|
|
1394
1401
|
additionalParams: prefixedOptions,
|
|
1402
|
+
queryParams: config.queryParams,
|
|
1395
1403
|
transformFn: config.transformFn,
|
|
1396
1404
|
method: config.method,
|
|
1397
1405
|
options: {
|
|
@@ -1583,18 +1591,17 @@ class BaseService {
|
|
|
1583
1591
|
const params = this.validateAndPreparePaginationParams(paginationType, paginationOptions);
|
|
1584
1592
|
// Prepare request parameters based on pagination type
|
|
1585
1593
|
const requestParams = this.preparePaginationRequestParams(paginationType, params, options.pagination);
|
|
1586
|
-
//
|
|
1594
|
+
// Route pagination state to wherever the API expects it (body for POST, URL for GET).
|
|
1595
|
+
// Caller-supplied options.body / options.params are respected as-is — the api-client
|
|
1596
|
+
// already handles params (URL) and body (request body) independently for every method.
|
|
1587
1597
|
if (method.toUpperCase() === 'POST') {
|
|
1588
1598
|
const existingBody = (options.body && typeof options.body === 'object') ? options.body : {};
|
|
1589
1599
|
options.body = {
|
|
1590
1600
|
...existingBody,
|
|
1591
|
-
...options.params,
|
|
1592
1601
|
...requestParams
|
|
1593
1602
|
};
|
|
1594
|
-
options.params = undefined;
|
|
1595
1603
|
}
|
|
1596
1604
|
else {
|
|
1597
|
-
// Merge pagination parameters with existing parameters
|
|
1598
1605
|
options.params = {
|
|
1599
1606
|
...options.params,
|
|
1600
1607
|
...requestParams
|
|
@@ -1960,6 +1967,9 @@ const DATA_FABRIC_TENANT_FOLDER_ID = '00000000-0000-0000-0000-000000000000';
|
|
|
1960
1967
|
const DATA_FABRIC_ENDPOINTS = {
|
|
1961
1968
|
ENTITY: {
|
|
1962
1969
|
GET_ALL: `${DATAFABRIC_BASE}/api/Entity`,
|
|
1970
|
+
// Lists tenant-level and folder-level entities together.
|
|
1971
|
+
// Used by getAll when includeFolderEntities is true.
|
|
1972
|
+
GET_ALL_V2: `${DATAFABRIC_BASE}/api/v2/Entity`,
|
|
1963
1973
|
GET_ENTITY_RECORDS: (entityId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/read`,
|
|
1964
1974
|
GET_BY_ID: (entityId) => `${DATAFABRIC_BASE}/api/Entity/${entityId}`,
|
|
1965
1975
|
GET_RECORD_BY_ID: (entityId, recordId) => `${DATAFABRIC_BASE}/api/EntityService/entity/${entityId}/read/${recordId}`,
|
|
@@ -2058,6 +2068,14 @@ var SqlFieldType;
|
|
|
2058
2068
|
SqlFieldType["MULTILINE"] = "MULTILINE";
|
|
2059
2069
|
})(SqlFieldType || (SqlFieldType = {}));
|
|
2060
2070
|
|
|
2071
|
+
/**
|
|
2072
|
+
* Numeric type IDs that pair with {@link EntityType} on reference payloads
|
|
2073
|
+
* (entityType + entityTypeId travel together in `referenceEntity` /
|
|
2074
|
+
* `referenceChoiceSet` bodies on cross-folder schema upserts).
|
|
2075
|
+
*/
|
|
2076
|
+
const ENTITY_TYPE_IDS = {
|
|
2077
|
+
[EntityType.ChoiceSet]: 1,
|
|
2078
|
+
};
|
|
2061
2079
|
/**
|
|
2062
2080
|
* Maps fields for Entities
|
|
2063
2081
|
*/
|
|
@@ -2220,7 +2238,7 @@ class EntityService extends BaseService {
|
|
|
2220
2238
|
* Gets entity metadata by entity ID with attached operation methods
|
|
2221
2239
|
*
|
|
2222
2240
|
* @param id - UUID of the entity
|
|
2223
|
-
* @param options - Optional {@link EntityGetByIdOptions} (e.g. `folderKey` for folder-scoped entities)
|
|
2241
|
+
* @param options - Optional {@link EntityGetByIdOptions} (e.g. `folderKey` for folder-scoped entities) The `folderKey` property is **experimental**.
|
|
2224
2242
|
* @returns Promise resolving to entity metadata with schema information and operation methods
|
|
2225
2243
|
*
|
|
2226
2244
|
* @example
|
|
@@ -2260,7 +2278,7 @@ class EntityService extends BaseService {
|
|
|
2260
2278
|
* Gets entity records by entity ID
|
|
2261
2279
|
*
|
|
2262
2280
|
* @param entityId - UUID of the entity
|
|
2263
|
-
* @param options - Query options including expansionLevel and pagination options
|
|
2281
|
+
* @param options - Query options including expansionLevel and pagination options The `folderKey` property is **experimental**.
|
|
2264
2282
|
* @returns Promise resolving to an array of entity records or paginated response
|
|
2265
2283
|
*
|
|
2266
2284
|
* @example
|
|
@@ -2288,6 +2306,9 @@ class EntityService extends BaseService {
|
|
|
2288
2306
|
* cursor: paginatedResponse.nextCursor,
|
|
2289
2307
|
* expansionLevel: 1
|
|
2290
2308
|
* });
|
|
2309
|
+
*
|
|
2310
|
+
* // Folder-scoped entity: pass the entity's folder key
|
|
2311
|
+
* const records = await entities.getAllRecords("<entityId>", { folderKey: "<folderKey>" });
|
|
2291
2312
|
* ```
|
|
2292
2313
|
*/
|
|
2293
2314
|
async getAllRecords(entityId, options) {
|
|
@@ -2317,7 +2338,7 @@ class EntityService extends BaseService {
|
|
|
2317
2338
|
*
|
|
2318
2339
|
* @param entityId - UUID of the entity
|
|
2319
2340
|
* @param recordId - UUID of the record
|
|
2320
|
-
* @param options - Query options including expansionLevel
|
|
2341
|
+
* @param options - Query options including `expansionLevel` and `folderKey` The `folderKey` property is **experimental**.
|
|
2321
2342
|
* @returns Promise resolving to the entity record
|
|
2322
2343
|
*
|
|
2323
2344
|
* @example
|
|
@@ -2329,6 +2350,11 @@ class EntityService extends BaseService {
|
|
|
2329
2350
|
* const record = await sdk.entities.getRecordById(<entityId>, <recordId>, {
|
|
2330
2351
|
* expansionLevel: 1
|
|
2331
2352
|
* });
|
|
2353
|
+
*
|
|
2354
|
+
* // Folder-scoped entity: pass the entity's folder key
|
|
2355
|
+
* const record = await sdk.entities.getRecordById(<entityId>, <recordId>, {
|
|
2356
|
+
* folderKey: "<folderKey>"
|
|
2357
|
+
* });
|
|
2332
2358
|
* ```
|
|
2333
2359
|
*/
|
|
2334
2360
|
async getRecordById(entityId, recordId, options = {}) {
|
|
@@ -2343,7 +2369,7 @@ class EntityService extends BaseService {
|
|
|
2343
2369
|
*
|
|
2344
2370
|
* @param entityId - UUID of the entity
|
|
2345
2371
|
* @param data - Record to insert
|
|
2346
|
-
* @param options - Insert options
|
|
2372
|
+
* @param options - Insert options The `folderKey` property is **experimental**.
|
|
2347
2373
|
* @returns Promise resolving to the inserted record with generated record ID
|
|
2348
2374
|
*
|
|
2349
2375
|
* @example
|
|
@@ -2359,6 +2385,11 @@ class EntityService extends BaseService {
|
|
|
2359
2385
|
* const result = await entities.insertRecordById("<entityId>", { name: "John", age: 30 }, {
|
|
2360
2386
|
* expansionLevel: 1
|
|
2361
2387
|
* });
|
|
2388
|
+
*
|
|
2389
|
+
* // Folder-scoped entity: pass the entity's folder key
|
|
2390
|
+
* await entities.insertRecordById("<entityId>", { name: "John", age: 30 }, {
|
|
2391
|
+
* folderKey: "<folderKey>"
|
|
2392
|
+
* });
|
|
2362
2393
|
* ```
|
|
2363
2394
|
*/
|
|
2364
2395
|
async insertRecordById(id, data, options = {}) {
|
|
@@ -2376,7 +2407,7 @@ class EntityService extends BaseService {
|
|
|
2376
2407
|
*
|
|
2377
2408
|
* @param entityId - UUID of the entity
|
|
2378
2409
|
* @param data - Array of records to insert
|
|
2379
|
-
* @param options - Insert options
|
|
2410
|
+
* @param options - Insert options The `folderKey` property is **experimental**.
|
|
2380
2411
|
* @returns Promise resolving to insert response
|
|
2381
2412
|
*
|
|
2382
2413
|
* @example
|
|
@@ -2399,6 +2430,12 @@ class EntityService extends BaseService {
|
|
|
2399
2430
|
* expansionLevel: 1,
|
|
2400
2431
|
* failOnFirst: true
|
|
2401
2432
|
* });
|
|
2433
|
+
*
|
|
2434
|
+
* // Folder-scoped entity: pass the entity's folder key
|
|
2435
|
+
* await entities.insertRecordsById("<entityId>", [
|
|
2436
|
+
* { name: "John", age: 30 },
|
|
2437
|
+
* { name: "Jane", age: 25 }
|
|
2438
|
+
* ], { folderKey: "<folderKey>" });
|
|
2402
2439
|
* ```
|
|
2403
2440
|
*/
|
|
2404
2441
|
async insertRecordsById(id, data, options = {}) {
|
|
@@ -2418,7 +2455,7 @@ class EntityService extends BaseService {
|
|
|
2418
2455
|
* @param entityId - UUID of the entity
|
|
2419
2456
|
* @param recordId - UUID of the record to update
|
|
2420
2457
|
* @param data - Key-value pairs of fields to update
|
|
2421
|
-
* @param options - Update options
|
|
2458
|
+
* @param options - Update options The `folderKey` property is **experimental**.
|
|
2422
2459
|
* @returns Promise resolving to the updated record
|
|
2423
2460
|
*
|
|
2424
2461
|
* @example
|
|
@@ -2434,6 +2471,11 @@ class EntityService extends BaseService {
|
|
|
2434
2471
|
* const result = await entities.updateRecordById("<entityId>", "<recordId>", { name: "John Updated", age: 31 }, {
|
|
2435
2472
|
* expansionLevel: 1
|
|
2436
2473
|
* });
|
|
2474
|
+
*
|
|
2475
|
+
* // Folder-scoped entity: pass the entity's folder key
|
|
2476
|
+
* await entities.updateRecordById("<entityId>", "<recordId>", { name: "John Updated" }, {
|
|
2477
|
+
* folderKey: "<folderKey>"
|
|
2478
|
+
* });
|
|
2437
2479
|
* ```
|
|
2438
2480
|
*/
|
|
2439
2481
|
async updateRecordById(entityId, recordId, data, options = {}) {
|
|
@@ -2452,7 +2494,7 @@ class EntityService extends BaseService {
|
|
|
2452
2494
|
* @param entityId - UUID of the entity
|
|
2453
2495
|
* @param data - Array of records to update. Each record MUST contain the record Id,
|
|
2454
2496
|
* otherwise the update will fail.
|
|
2455
|
-
* @param options - Update options
|
|
2497
|
+
* @param options - Update options The `folderKey` property is **experimental**.
|
|
2456
2498
|
* @returns Promise resolving to update response
|
|
2457
2499
|
*
|
|
2458
2500
|
* @example
|
|
@@ -2475,6 +2517,11 @@ class EntityService extends BaseService {
|
|
|
2475
2517
|
* expansionLevel: 1,
|
|
2476
2518
|
* failOnFirst: true
|
|
2477
2519
|
* });
|
|
2520
|
+
*
|
|
2521
|
+
* // Folder-scoped entity: pass the entity's folder key
|
|
2522
|
+
* await entities.updateRecordsById("<entityId>", [
|
|
2523
|
+
* { Id: "123", name: "John Updated" }
|
|
2524
|
+
* ], { folderKey: "<folderKey>" });
|
|
2478
2525
|
* ```
|
|
2479
2526
|
*/
|
|
2480
2527
|
async updateRecordsById(id, data, options = {}) {
|
|
@@ -2495,7 +2542,7 @@ class EntityService extends BaseService {
|
|
|
2495
2542
|
*
|
|
2496
2543
|
* @param entityId - UUID of the entity
|
|
2497
2544
|
* @param recordIds - Array of record UUIDs to delete
|
|
2498
|
-
* @param options - Delete options
|
|
2545
|
+
* @param options - Delete options The `folderKey` property is **experimental**.
|
|
2499
2546
|
* @returns Promise resolving to delete response
|
|
2500
2547
|
*
|
|
2501
2548
|
* @example
|
|
@@ -2508,6 +2555,11 @@ class EntityService extends BaseService {
|
|
|
2508
2555
|
* const result = await entities.deleteRecordsById("<entityId>", [
|
|
2509
2556
|
* "<recordId-1>", "<recordId-2>"
|
|
2510
2557
|
* ]);
|
|
2558
|
+
*
|
|
2559
|
+
* // Folder-scoped entity: pass the entity's folder key
|
|
2560
|
+
* await entities.deleteRecordsById("<entityId>", [
|
|
2561
|
+
* "<recordId-1>", "<recordId-2>"
|
|
2562
|
+
* ], { folderKey: "<folderKey>" });
|
|
2511
2563
|
* ```
|
|
2512
2564
|
*/
|
|
2513
2565
|
async deleteRecordsById(id, recordIds, options = {}) {
|
|
@@ -2528,7 +2580,7 @@ class EntityService extends BaseService {
|
|
|
2528
2580
|
*
|
|
2529
2581
|
* @param entityId - UUID of the entity
|
|
2530
2582
|
* @param recordId - UUID of the record to delete
|
|
2531
|
-
* @param options - Optional {@link EntityDeleteRecordByIdOptions} (e.g. `folderKey` for folder-scoped entities)
|
|
2583
|
+
* @param options - Optional {@link EntityDeleteRecordByIdOptions} (e.g. `folderKey` for folder-scoped entities) The `folderKey` property is **experimental**.
|
|
2532
2584
|
* @returns Promise resolving to void on success
|
|
2533
2585
|
* @example
|
|
2534
2586
|
* ```typescript
|
|
@@ -2546,8 +2598,14 @@ class EntityService extends BaseService {
|
|
|
2546
2598
|
await this.delete(DATA_FABRIC_ENDPOINTS.ENTITY.DELETE_RECORD_BY_ID(entityId, recordId), { headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }) });
|
|
2547
2599
|
}
|
|
2548
2600
|
/**
|
|
2549
|
-
* Gets
|
|
2601
|
+
* Gets entities in the tenant.
|
|
2602
|
+
*
|
|
2603
|
+
* Three call modes:
|
|
2604
|
+
* - `getAll()` — default. Returns only tenant-level entities.
|
|
2605
|
+
* - `getAll({ folderKey: "<uuid>" })` — preferred for folder-scoped data. Returns only entities in that folder.
|
|
2606
|
+
* - `getAll({ includeFolderEntities: true })` — returns tenant-level **and** folder-level entities together. `folderKey` is preferred over `includeFolderEntities` when both are set.
|
|
2550
2607
|
*
|
|
2608
|
+
* @param options - Optional {@link EntityGetAllOptions} (`folderKey` to list a single folder's entities — preferred when scoping to a folder; `includeFolderEntities: true` to list tenant + folder entities together) The `folderKey` property is **experimental**.
|
|
2551
2609
|
* @returns Promise resolving to an array of entity metadata
|
|
2552
2610
|
*
|
|
2553
2611
|
* @example
|
|
@@ -2556,15 +2614,29 @@ class EntityService extends BaseService {
|
|
|
2556
2614
|
*
|
|
2557
2615
|
* const entities = new Entities(sdk);
|
|
2558
2616
|
*
|
|
2559
|
-
* //
|
|
2560
|
-
* const
|
|
2617
|
+
* // Tenant-only (default)
|
|
2618
|
+
* const tenantEntities = await entities.getAll();
|
|
2619
|
+
*
|
|
2620
|
+
* // A single folder's entities (preferred when targeting a specific folder)
|
|
2621
|
+
* const folderEntities = await entities.getAll({ folderKey: "<folderKey>" });
|
|
2622
|
+
*
|
|
2623
|
+
* // Tenant + folder entities together
|
|
2624
|
+
* const allEntities = await entities.getAll({ includeFolderEntities: true });
|
|
2561
2625
|
*
|
|
2562
2626
|
* // Call operations on an entity
|
|
2563
|
-
* const records = await
|
|
2627
|
+
* const records = await tenantEntities[0].getAllRecords();
|
|
2564
2628
|
* ```
|
|
2565
2629
|
*/
|
|
2566
|
-
async getAll() {
|
|
2567
|
-
|
|
2630
|
+
async getAll(options) {
|
|
2631
|
+
// folderKey is preferred over includeFolderEntities: when present, scope to that folder
|
|
2632
|
+
// via the v1 endpoint + header. Only when no folderKey is given AND includeFolderEntities
|
|
2633
|
+
// is explicitly true does the SDK switch to the v2 endpoint (returns tenant + folder
|
|
2634
|
+
// entities together). Default (no options or includeFolderEntities omitted) stays on
|
|
2635
|
+
// the v1 endpoint = tenant only.
|
|
2636
|
+
const endpoint = !options?.folderKey && options?.includeFolderEntities
|
|
2637
|
+
? DATA_FABRIC_ENDPOINTS.ENTITY.GET_ALL_V2
|
|
2638
|
+
: DATA_FABRIC_ENDPOINTS.ENTITY.GET_ALL;
|
|
2639
|
+
const response = await this.get(endpoint, { headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }) });
|
|
2568
2640
|
// Apply transformations
|
|
2569
2641
|
const entities = response.data.map(entity => {
|
|
2570
2642
|
// Transform each entity
|
|
@@ -2579,7 +2651,7 @@ class EntityService extends BaseService {
|
|
|
2579
2651
|
* Queries entity records with filters, sorting, aggregates, and pagination
|
|
2580
2652
|
*
|
|
2581
2653
|
* @param id - UUID of the entity
|
|
2582
|
-
* @param options - Query options including filterGroup, selectedFields, sortOptions, aggregates, groupBy, and pagination
|
|
2654
|
+
* @param options - Query options including filterGroup, selectedFields, sortOptions, aggregates, groupBy, and pagination The `folderKey` property is **experimental**.
|
|
2583
2655
|
* @returns Promise resolving to {@link NonPaginatedResponse} without pagination options,
|
|
2584
2656
|
* or {@link PaginatedResponse} when `pageSize`, `cursor`, or `jumpToPage` are provided
|
|
2585
2657
|
*
|
|
@@ -2626,18 +2698,24 @@ class EntityService extends BaseService {
|
|
|
2626
2698
|
* { function: EntityAggregateFunction.Avg, field: "amount", alias: "avgAmount" },
|
|
2627
2699
|
* ],
|
|
2628
2700
|
* });
|
|
2701
|
+
*
|
|
2702
|
+
* // Folder-scoped entity: pass the entity's folder key
|
|
2703
|
+
* await entities.queryRecordsById("<entityId>", {
|
|
2704
|
+
* filterGroup: { queryFilters: [{ fieldName: "status", operator: QueryFilterOperator.Equals, value: "active" }] },
|
|
2705
|
+
* folderKey: "<folderKey>",
|
|
2706
|
+
* });
|
|
2629
2707
|
* ```
|
|
2630
2708
|
*/
|
|
2631
2709
|
async queryRecordsById(id, options) {
|
|
2632
|
-
// folderKey is header-only
|
|
2633
|
-
|
|
2634
|
-
const { folderKey, ...rest } = options ?? {};
|
|
2710
|
+
// folderKey is header-only; expansionLevel must be sent as a query param by PaginationHelpers.
|
|
2711
|
+
const { folderKey, expansionLevel, ...rest } = options ?? {};
|
|
2635
2712
|
const downstreamOptions = options === undefined ? undefined : rest;
|
|
2636
2713
|
return PaginationHelpers.getAll({
|
|
2637
2714
|
serviceAccess: this.createPaginationServiceAccess(),
|
|
2638
2715
|
getEndpoint: () => DATA_FABRIC_ENDPOINTS.ENTITY.QUERY_BY_ID(id),
|
|
2639
2716
|
method: HTTP_METHODS.POST,
|
|
2640
2717
|
headers: createHeaders({ [FOLDER_KEY]: folderKey }),
|
|
2718
|
+
queryParams: createParams({ expansionLevel }),
|
|
2641
2719
|
pagination: {
|
|
2642
2720
|
paginationType: PaginationType.OFFSET,
|
|
2643
2721
|
itemsField: ENTITY_PAGINATION.ITEMS_FIELD,
|
|
@@ -2648,7 +2726,7 @@ class EntityService extends BaseService {
|
|
|
2648
2726
|
countParam: ENTITY_OFFSET_PARAMS.COUNT_PARAM
|
|
2649
2727
|
}
|
|
2650
2728
|
},
|
|
2651
|
-
excludeFromPrefix: ['
|
|
2729
|
+
excludeFromPrefix: ['filterGroup', 'selectedFields', 'sortOptions', 'aggregates', 'groupBy']
|
|
2652
2730
|
}, downstreamOptions);
|
|
2653
2731
|
}
|
|
2654
2732
|
/**
|
|
@@ -2656,7 +2734,7 @@ class EntityService extends BaseService {
|
|
|
2656
2734
|
*
|
|
2657
2735
|
* @param id - UUID of the entity
|
|
2658
2736
|
* @param file - CSV file to import (Blob, File, or Uint8Array)
|
|
2659
|
-
* @param options - Optional {@link EntityImportRecordsByIdOptions} (e.g. `folderKey` for folder-scoped entities)
|
|
2737
|
+
* @param options - Optional {@link EntityImportRecordsByIdOptions} (e.g. `folderKey` for folder-scoped entities) The `folderKey` property is **experimental**.
|
|
2660
2738
|
* @returns Promise resolving to import result with record counts
|
|
2661
2739
|
*
|
|
2662
2740
|
* @example
|
|
@@ -2699,7 +2777,7 @@ class EntityService extends BaseService {
|
|
|
2699
2777
|
* @param entityId - UUID of the entity
|
|
2700
2778
|
* @param recordId - UUID of the record containing the attachment
|
|
2701
2779
|
* @param fieldName - Name of the File-type field containing the attachment
|
|
2702
|
-
* @param options - Optional {@link EntityDownloadAttachmentOptions} (e.g. `folderKey` for folder-scoped entities)
|
|
2780
|
+
* @param options - Optional {@link EntityDownloadAttachmentOptions} (e.g. `folderKey` for folder-scoped entities) The `folderKey` property is **experimental**.
|
|
2703
2781
|
* @returns Promise resolving to Blob containing the file content
|
|
2704
2782
|
*
|
|
2705
2783
|
* @example
|
|
@@ -2737,7 +2815,7 @@ class EntityService extends BaseService {
|
|
|
2737
2815
|
* @param recordId - UUID of the record to upload the attachment to
|
|
2738
2816
|
* @param fieldName - Name of the File-type field
|
|
2739
2817
|
* @param file - File to upload (Blob, File, or Uint8Array)
|
|
2740
|
-
* @param options - Optional {@link EntityUploadAttachmentOptions} (e.g. `expansionLevel`, `folderKey` for folder-scoped entities)
|
|
2818
|
+
* @param options - Optional {@link EntityUploadAttachmentOptions} (e.g. `expansionLevel`, `folderKey` for folder-scoped entities) The `folderKey` property is **experimental**.
|
|
2741
2819
|
* @returns Promise resolving to {@link EntityUploadAttachmentResponse}
|
|
2742
2820
|
*
|
|
2743
2821
|
* @example
|
|
@@ -2782,7 +2860,7 @@ class EntityService extends BaseService {
|
|
|
2782
2860
|
* @param entityId - UUID of the entity
|
|
2783
2861
|
* @param recordId - UUID of the record containing the attachment
|
|
2784
2862
|
* @param fieldName - Name of the File-type field containing the attachment
|
|
2785
|
-
* @param options - Optional {@link EntityDeleteAttachmentOptions} (e.g. `folderKey` for folder-scoped entities)
|
|
2863
|
+
* @param options - Optional {@link EntityDeleteAttachmentOptions} (e.g. `folderKey` for folder-scoped entities) The `folderKey` property is **experimental**.
|
|
2786
2864
|
* @returns Promise resolving to {@link EntityDeleteAttachmentResponse}
|
|
2787
2865
|
*
|
|
2788
2866
|
* @example
|
|
@@ -2837,7 +2915,7 @@ class EntityService extends BaseService {
|
|
|
2837
2915
|
* @param name - Entity name — must start with a letter and contain
|
|
2838
2916
|
* only letters, numbers, and underscores (e.g., `"productCatalog"`).
|
|
2839
2917
|
* @param fields - Array of field definitions
|
|
2840
|
-
* @param options - Optional entity-level settings ({@link EntityCreateOptions})
|
|
2918
|
+
* @param options - Optional entity-level settings ({@link EntityCreateOptions}) The `folderKey` property is **experimental**.
|
|
2841
2919
|
* @returns Promise resolving to the ID of the created entity
|
|
2842
2920
|
*
|
|
2843
2921
|
* @example
|
|
@@ -2853,17 +2931,36 @@ class EntityService extends BaseService {
|
|
|
2853
2931
|
* { fieldName: "price", type: EntityFieldDataType.DECIMAL, decimalPrecision: 4, maxValue: 999999, minValue: 0 },
|
|
2854
2932
|
* { fieldName: "quantity", type: EntityFieldDataType.INTEGER, maxValue: 10000, minValue: 1, defaultValue: "0" },
|
|
2855
2933
|
* ]);
|
|
2934
|
+
*
|
|
2935
|
+
* // Cross-folder references — link a folder-scoped entity to entities and
|
|
2936
|
+
* // system choice sets that live in another folder or at the tenant level.
|
|
2937
|
+
* await entities.create("orderLine", [
|
|
2938
|
+
* {
|
|
2939
|
+
* fieldName: "order",
|
|
2940
|
+
* type: EntityFieldDataType.RELATIONSHIP,
|
|
2941
|
+
* referenceEntityId: "<orderEntityId>",
|
|
2942
|
+
* referenceFieldId: "<orderEntityPkId>",
|
|
2943
|
+
* referenceFolderKey: "<otherFolderKey>", // target lives in a different folder
|
|
2944
|
+
* },
|
|
2945
|
+
* {
|
|
2946
|
+
* fieldName: "userType",
|
|
2947
|
+
* type: EntityFieldDataType.CHOICE_SET_SINGLE,
|
|
2948
|
+
* choiceSetId: "<systemUserTypeChoiceSetId>", // tenant-level system choice set
|
|
2949
|
+
* // referenceFolderKey omitted → SDK looks up the target at tenant scope
|
|
2950
|
+
* },
|
|
2951
|
+
* ], { folderKey: "<sourceFolderKey>" });
|
|
2856
2952
|
* ```
|
|
2857
2953
|
* @internal
|
|
2858
2954
|
*/
|
|
2859
2955
|
async create(name, fields, options) {
|
|
2860
2956
|
const opts = options ?? {};
|
|
2957
|
+
const fieldPayloads = await this.buildFieldsWithReferenceMeta(fields);
|
|
2861
2958
|
const payload = {
|
|
2862
2959
|
...(opts.description !== undefined && { description: opts.description }),
|
|
2863
2960
|
displayName: opts.displayName ?? name,
|
|
2864
2961
|
entityDefinition: {
|
|
2865
2962
|
name,
|
|
2866
|
-
fields:
|
|
2963
|
+
fields: fieldPayloads,
|
|
2867
2964
|
folderId: opts.folderKey ?? DATA_FABRIC_TENANT_FOLDER_ID,
|
|
2868
2965
|
isRbacEnabled: opts.isRbacEnabled ?? false,
|
|
2869
2966
|
isInsightsEnabled: opts.isAnalyticsEnabled ?? false,
|
|
@@ -2877,7 +2974,7 @@ class EntityService extends BaseService {
|
|
|
2877
2974
|
* Deletes a Data Fabric entity and all its records
|
|
2878
2975
|
*
|
|
2879
2976
|
* @param id - UUID of the entity to delete
|
|
2880
|
-
* @param options - Optional {@link EntityDeleteByIdOptions} (e.g. `folderKey` for folder-scoped entities)
|
|
2977
|
+
* @param options - Optional {@link EntityDeleteByIdOptions} (e.g. `folderKey` for folder-scoped entities) The `folderKey` property is **experimental**.
|
|
2881
2978
|
* @returns Promise resolving when the entity is deleted
|
|
2882
2979
|
*
|
|
2883
2980
|
* @example
|
|
@@ -2904,7 +3001,7 @@ class EntityService extends BaseService {
|
|
|
2904
3001
|
* overwrite each other's changes.
|
|
2905
3002
|
*
|
|
2906
3003
|
* @param id - UUID of the entity to update
|
|
2907
|
-
* @param options - Changes to apply ({@link EntityUpdateByIdOptions})
|
|
3004
|
+
* @param options - Changes to apply ({@link EntityUpdateByIdOptions}) The `folderKey` property is **experimental**.
|
|
2908
3005
|
* @returns Promise resolving when the update is complete
|
|
2909
3006
|
*
|
|
2910
3007
|
* @example
|
|
@@ -3016,10 +3113,9 @@ class EntityService extends BaseService {
|
|
|
3016
3113
|
};
|
|
3017
3114
|
});
|
|
3018
3115
|
}
|
|
3019
|
-
// Build and append new fields
|
|
3020
3116
|
const newFields = [];
|
|
3021
3117
|
if (options.addFields?.length) {
|
|
3022
|
-
newFields.push(...
|
|
3118
|
+
newFields.push(...await this.buildFieldsWithReferenceMeta(options.addFields));
|
|
3023
3119
|
}
|
|
3024
3120
|
await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPSERT, {
|
|
3025
3121
|
displayName: raw.displayName,
|
|
@@ -3117,8 +3213,39 @@ class EntityService extends BaseService {
|
|
|
3117
3213
|
return externalSource;
|
|
3118
3214
|
});
|
|
3119
3215
|
}
|
|
3216
|
+
async buildFieldsWithReferenceMeta(fields) {
|
|
3217
|
+
const metas = await Promise.all(fields.map(f => this.buildReferenceMeta(f)));
|
|
3218
|
+
return fields.map((f, i) => this.buildSchemaFieldPayload(f, metas[i]));
|
|
3219
|
+
}
|
|
3220
|
+
// Choice-set targets resolve server-side by NAME (the API rejects cross-folder
|
|
3221
|
+
// refs with empty target name even when folderId is supplied), so the SDK
|
|
3222
|
+
// fetches the name once for each cross-folder choice-set field. Relationship
|
|
3223
|
+
// targets resolve by folderId — no lookup needed.
|
|
3224
|
+
async buildReferenceMeta(field) {
|
|
3225
|
+
if (field.referenceFolderKey === undefined)
|
|
3226
|
+
return undefined;
|
|
3227
|
+
if (field.referenceEntityId === undefined && field.choiceSetId === undefined)
|
|
3228
|
+
return undefined;
|
|
3229
|
+
const folderId = field.referenceFolderKey;
|
|
3230
|
+
const meta = {};
|
|
3231
|
+
if (field.referenceEntityId !== undefined) {
|
|
3232
|
+
meta.referenceEntity = { id: field.referenceEntityId, folderId };
|
|
3233
|
+
}
|
|
3234
|
+
if (field.choiceSetId !== undefined) {
|
|
3235
|
+
const lookupFolderKey = folderId === DATA_FABRIC_TENANT_FOLDER_ID ? undefined : folderId;
|
|
3236
|
+
const target = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.GET_BY_ID(field.choiceSetId), { headers: createHeaders({ [FOLDER_KEY]: lookupFolderKey }) });
|
|
3237
|
+
meta.referenceChoiceSet = {
|
|
3238
|
+
id: field.choiceSetId,
|
|
3239
|
+
name: target.data.name,
|
|
3240
|
+
folderId,
|
|
3241
|
+
entityType: EntityType.ChoiceSet,
|
|
3242
|
+
entityTypeId: ENTITY_TYPE_IDS[EntityType.ChoiceSet],
|
|
3243
|
+
};
|
|
3244
|
+
}
|
|
3245
|
+
return meta;
|
|
3246
|
+
}
|
|
3120
3247
|
/** Converts a user-facing EntityCreateFieldOptions to the raw API field payload */
|
|
3121
|
-
buildSchemaFieldPayload(field) {
|
|
3248
|
+
buildSchemaFieldPayload(field, refMeta) {
|
|
3122
3249
|
const fieldType = field.type ?? EntityFieldDataType.STRING;
|
|
3123
3250
|
this.validateFieldConstraints(fieldType, field, field.fieldName);
|
|
3124
3251
|
const isRelationship = fieldType === EntityFieldDataType.RELATIONSHIP;
|
|
@@ -3129,6 +3256,10 @@ class EntityService extends BaseService {
|
|
|
3129
3256
|
});
|
|
3130
3257
|
}
|
|
3131
3258
|
const mapping = EntitySchemaFieldTypeMap[fieldType];
|
|
3259
|
+
// Prefer the resolved {id, name, folderId} body so cross-folder targets resolve
|
|
3260
|
+
// server-side; fall back to a bare {id} when no meta was fetched.
|
|
3261
|
+
const referenceEntityBody = refMeta?.referenceEntity ?? (field.referenceEntityId === undefined ? undefined : { id: field.referenceEntityId });
|
|
3262
|
+
const referenceChoiceSetBody = refMeta?.referenceChoiceSet;
|
|
3132
3263
|
return {
|
|
3133
3264
|
name: field.fieldName,
|
|
3134
3265
|
displayName: field.displayName ?? field.fieldName,
|
|
@@ -3147,7 +3278,8 @@ class EntityService extends BaseService {
|
|
|
3147
3278
|
...(field.choiceSetId !== undefined && { choiceSetId: field.choiceSetId }),
|
|
3148
3279
|
...((isRelationship || isFile) && { isForeignKey: true }),
|
|
3149
3280
|
...(isRelationship && { referenceType: ReferenceType.ManyToOne }),
|
|
3150
|
-
...(
|
|
3281
|
+
...(referenceEntityBody !== undefined && { referenceEntity: referenceEntityBody }),
|
|
3282
|
+
...(referenceChoiceSetBody !== undefined && { referenceChoiceSet: referenceChoiceSetBody }),
|
|
3151
3283
|
...(field.referenceFieldId !== undefined && { referenceField: { id: field.referenceFieldId } }),
|
|
3152
3284
|
};
|
|
3153
3285
|
}
|
|
@@ -3310,8 +3442,14 @@ __decorate([
|
|
|
3310
3442
|
|
|
3311
3443
|
class ChoiceSetService extends BaseService {
|
|
3312
3444
|
/**
|
|
3313
|
-
* Gets
|
|
3445
|
+
* Gets choice sets in the tenant.
|
|
3446
|
+
*
|
|
3447
|
+
* Three call modes:
|
|
3448
|
+
* - `getAll()` — default. Returns only tenant-level choice sets.
|
|
3449
|
+
* - `getAll({ folderKey: "<uuid>" })` — preferred for folder-scoped data. Returns only choice sets in that folder.
|
|
3450
|
+
* - `getAll({ includeFolderChoiceSets: true })` — returns tenant-level **and** folder-level choice sets together. `folderKey` is preferred over `includeFolderChoiceSets` when both are set.
|
|
3314
3451
|
*
|
|
3452
|
+
* @param options - Optional {@link ChoiceSetGetAllOptions} (`folderKey` to list a single folder's choice sets — preferred when scoping to a folder; `includeFolderChoiceSets: true` to list tenant + folder choice sets together) The `folderKey` property is **experimental**.
|
|
3315
3453
|
* @returns Promise resolving to an array of choice set metadata
|
|
3316
3454
|
*
|
|
3317
3455
|
* @example
|
|
@@ -3320,18 +3458,33 @@ class ChoiceSetService extends BaseService {
|
|
|
3320
3458
|
*
|
|
3321
3459
|
* const choiceSets = new ChoiceSets(sdk);
|
|
3322
3460
|
*
|
|
3323
|
-
* //
|
|
3324
|
-
* const
|
|
3461
|
+
* // Tenant-only (default)
|
|
3462
|
+
* const tenantChoiceSets = await choiceSets.getAll();
|
|
3325
3463
|
*
|
|
3326
|
-
* //
|
|
3327
|
-
*
|
|
3328
|
-
*
|
|
3329
|
-
*
|
|
3330
|
-
* });
|
|
3464
|
+
* // A single folder's choice sets (preferred when targeting a specific folder)
|
|
3465
|
+
* const folderChoiceSets = await choiceSets.getAll({ folderKey: "<folderKey>" });
|
|
3466
|
+
*
|
|
3467
|
+
* // Tenant + folder choice sets together
|
|
3468
|
+
* const allChoiceSets = await choiceSets.getAll({ includeFolderChoiceSets: true });
|
|
3331
3469
|
* ```
|
|
3332
3470
|
*/
|
|
3333
|
-
async getAll() {
|
|
3334
|
-
|
|
3471
|
+
async getAll(options) {
|
|
3472
|
+
return this.fetchAllChoiceSets(options);
|
|
3473
|
+
}
|
|
3474
|
+
/**
|
|
3475
|
+
* Internal helper that performs the choice-set fetch. Kept separate from the
|
|
3476
|
+
* public `getAll()` so that internal callers (e.g. `resolveChoiceSetName`)
|
|
3477
|
+
* can reuse it without triggering double `@track` telemetry.
|
|
3478
|
+
*/
|
|
3479
|
+
async fetchAllChoiceSets(options) {
|
|
3480
|
+
// The choice-set endpoint returns cross-scope results when called without
|
|
3481
|
+
// a folder header. To stay tenant-only by default, send the tenant-marker
|
|
3482
|
+
// UUID as the folder key unless the caller explicitly opts into cross-scope
|
|
3483
|
+
// via includeFolderChoiceSets: true. folderKey is preferred over
|
|
3484
|
+
// includeFolderChoiceSets when both are set.
|
|
3485
|
+
const folderKey = options?.folderKey
|
|
3486
|
+
?? (options?.includeFolderChoiceSets ? undefined : DATA_FABRIC_TENANT_FOLDER_ID);
|
|
3487
|
+
const rawResponse = await this.get(DATA_FABRIC_ENDPOINTS.CHOICESETS.GET_ALL, { headers: createHeaders({ [FOLDER_KEY]: folderKey }) });
|
|
3335
3488
|
// Transform field names
|
|
3336
3489
|
const data = rawResponse.data || [];
|
|
3337
3490
|
return data.map(choiceSet => transformData(choiceSet, EntityMap));
|
|
@@ -3344,7 +3497,7 @@ class ChoiceSetService extends BaseService {
|
|
|
3344
3497
|
* - A PaginatedResponse with navigation cursors (when any pagination parameter is provided)
|
|
3345
3498
|
*
|
|
3346
3499
|
* @param choiceSetId - UUID of the choice set
|
|
3347
|
-
* @param options - Pagination options
|
|
3500
|
+
* @param options - Pagination options and optional `folderKey` for folder-scoped choice sets The `folderKey` property is **experimental**.
|
|
3348
3501
|
* @returns Promise resolving to choice set values or paginated result
|
|
3349
3502
|
*
|
|
3350
3503
|
* @example
|
|
@@ -3373,6 +3526,9 @@ class ChoiceSetService extends BaseService {
|
|
|
3373
3526
|
* if (page1.hasNextPage) {
|
|
3374
3527
|
* const page2 = await choiceSets.getById(choiceSetId, { cursor: page1.nextCursor });
|
|
3375
3528
|
* }
|
|
3529
|
+
*
|
|
3530
|
+
* // Folder-scoped choice set
|
|
3531
|
+
* const folderValues = await choiceSets.getById(choiceSetId, { folderKey: "<folderKey>" });
|
|
3376
3532
|
* ```
|
|
3377
3533
|
*/
|
|
3378
3534
|
async getById(choiceSetId, options) {
|
|
@@ -3381,11 +3537,16 @@ class ChoiceSetService extends BaseService {
|
|
|
3381
3537
|
const camelCased = pascalToCamelCaseKeys(item);
|
|
3382
3538
|
return transformData(camelCased, EntityMap);
|
|
3383
3539
|
};
|
|
3540
|
+
// folderKey is header-only — destructure it out so PaginationHelpers doesn't
|
|
3541
|
+
// include it in the POST body alongside pagination params.
|
|
3542
|
+
const { folderKey, ...rest } = options ?? {};
|
|
3543
|
+
const downstreamOptions = options === undefined ? undefined : rest;
|
|
3384
3544
|
return PaginationHelpers.getAll({
|
|
3385
3545
|
serviceAccess: this.createPaginationServiceAccess(),
|
|
3386
3546
|
getEndpoint: () => DATA_FABRIC_ENDPOINTS.CHOICESETS.GET_BY_ID(choiceSetId),
|
|
3387
3547
|
transformFn,
|
|
3388
3548
|
method: HTTP_METHODS.POST,
|
|
3549
|
+
headers: createHeaders({ [FOLDER_KEY]: folderKey }),
|
|
3389
3550
|
pagination: {
|
|
3390
3551
|
paginationType: PaginationType.OFFSET,
|
|
3391
3552
|
itemsField: CHOICESET_VALUES_PAGINATION.ITEMS_FIELD,
|
|
@@ -3396,7 +3557,7 @@ class ChoiceSetService extends BaseService {
|
|
|
3396
3557
|
countParam: ENTITY_OFFSET_PARAMS.COUNT_PARAM
|
|
3397
3558
|
}
|
|
3398
3559
|
}
|
|
3399
|
-
},
|
|
3560
|
+
}, downstreamOptions);
|
|
3400
3561
|
}
|
|
3401
3562
|
/**
|
|
3402
3563
|
* Creates a new Data Fabric choice set
|
|
@@ -3404,7 +3565,7 @@ class ChoiceSetService extends BaseService {
|
|
|
3404
3565
|
* @param name - Choice set name. Must start with a
|
|
3405
3566
|
* letter, may contain only letters, numbers, and underscores, length
|
|
3406
3567
|
* 3–100 characters (e.g., `"expenseTypes"`).
|
|
3407
|
-
* @param options - Optional choice-set-level settings ({@link ChoiceSetCreateOptions})
|
|
3568
|
+
* @param options - Optional choice-set-level settings ({@link ChoiceSetCreateOptions}) The `folderKey` property is **experimental**.
|
|
3408
3569
|
* @returns Promise resolving to the UUID of the created choice set
|
|
3409
3570
|
*
|
|
3410
3571
|
* @example
|
|
@@ -3435,7 +3596,7 @@ class ChoiceSetService extends BaseService {
|
|
|
3435
3596
|
folderId: opts.folderKey ?? DATA_FABRIC_TENANT_FOLDER_ID,
|
|
3436
3597
|
},
|
|
3437
3598
|
};
|
|
3438
|
-
const response = await this.post(DATA_FABRIC_ENDPOINTS.CHOICESETS.CREATE, payload);
|
|
3599
|
+
const response = await this.post(DATA_FABRIC_ENDPOINTS.CHOICESETS.CREATE, payload, { headers: createHeaders({ [FOLDER_KEY]: opts.folderKey }) });
|
|
3439
3600
|
return response.data;
|
|
3440
3601
|
}
|
|
3441
3602
|
/**
|
|
@@ -3445,7 +3606,7 @@ class ChoiceSetService extends BaseService {
|
|
|
3445
3606
|
* the call throws `ValidationError` if both are omitted.
|
|
3446
3607
|
*
|
|
3447
3608
|
* @param choiceSetId - UUID of the choice set to update
|
|
3448
|
-
* @param options - Metadata fields to change ({@link ChoiceSetUpdateOptions})
|
|
3609
|
+
* @param options - Metadata fields to change ({@link ChoiceSetUpdateOptions}) The `folderKey` property is **experimental**.
|
|
3449
3610
|
* @returns Promise resolving when the update is complete
|
|
3450
3611
|
*
|
|
3451
3612
|
* @example
|
|
@@ -3470,12 +3631,13 @@ class ChoiceSetService extends BaseService {
|
|
|
3470
3631
|
await this.patch(DATA_FABRIC_ENDPOINTS.CHOICESETS.UPDATE(choiceSetId), {
|
|
3471
3632
|
...(options.displayName !== undefined && { displayName: options.displayName }),
|
|
3472
3633
|
...(options.description !== undefined && { description: options.description }),
|
|
3473
|
-
});
|
|
3634
|
+
}, { headers: createHeaders({ [FOLDER_KEY]: options.folderKey }) });
|
|
3474
3635
|
}
|
|
3475
3636
|
/**
|
|
3476
3637
|
* Deletes a Data Fabric choice set and all its values.
|
|
3477
3638
|
*
|
|
3478
3639
|
* @param choiceSetId - UUID of the choice set to delete
|
|
3640
|
+
* @param options - Optional {@link ChoiceSetDeleteByIdOptions} (e.g. `folderKey` for folder-scoped choice sets) The `folderKey` property is **experimental**.
|
|
3479
3641
|
* @returns Promise resolving when the choice set is deleted
|
|
3480
3642
|
*
|
|
3481
3643
|
* @example
|
|
@@ -3485,18 +3647,21 @@ class ChoiceSetService extends BaseService {
|
|
|
3485
3647
|
* const expenseTypes = allChoiceSets.find(cs => cs.name === 'expense_types');
|
|
3486
3648
|
*
|
|
3487
3649
|
* await choicesets.deleteById(expenseTypes.id);
|
|
3650
|
+
*
|
|
3651
|
+
* // Folder-scoped choice set
|
|
3652
|
+
* await choicesets.deleteById(expenseTypes.id, { folderKey: "<folderKey>" });
|
|
3488
3653
|
* ```
|
|
3489
3654
|
* @internal
|
|
3490
3655
|
*/
|
|
3491
|
-
async deleteById(choiceSetId) {
|
|
3492
|
-
await this.post(DATA_FABRIC_ENDPOINTS.CHOICESETS.DELETE(choiceSetId), {});
|
|
3656
|
+
async deleteById(choiceSetId, options) {
|
|
3657
|
+
await this.post(DATA_FABRIC_ENDPOINTS.CHOICESETS.DELETE(choiceSetId), {}, { headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }) });
|
|
3493
3658
|
}
|
|
3494
3659
|
/**
|
|
3495
3660
|
* Inserts a single value into a choice set.
|
|
3496
3661
|
*
|
|
3497
3662
|
* @param choiceSetId - UUID of the parent choice set
|
|
3498
3663
|
* @param name - Identifier name of the new value (e.g., `"TRAVEL"`)
|
|
3499
|
-
* @param options - Optional fields ({@link ChoiceSetValueInsertOptions})
|
|
3664
|
+
* @param options - Optional fields ({@link ChoiceSetValueInsertOptions}) The `folderKey` property is **experimental**.
|
|
3500
3665
|
* @returns Promise resolving to the inserted value ({@link ChoiceSetValueInsertResponse})
|
|
3501
3666
|
*
|
|
3502
3667
|
* @example
|
|
@@ -3509,16 +3674,22 @@ class ChoiceSetService extends BaseService {
|
|
|
3509
3674
|
* displayName: 'Travel',
|
|
3510
3675
|
* });
|
|
3511
3676
|
* console.log(inserted.id);
|
|
3677
|
+
*
|
|
3678
|
+
* // Folder-scoped choice set: folderKey is required on the wire
|
|
3679
|
+
* await choicesets.insertValueById(expenseTypes.id, 'TRAVEL', {
|
|
3680
|
+
* displayName: 'Travel',
|
|
3681
|
+
* folderKey: "<folderKey>",
|
|
3682
|
+
* });
|
|
3512
3683
|
* ```
|
|
3513
3684
|
* @internal
|
|
3514
3685
|
*/
|
|
3515
3686
|
async insertValueById(choiceSetId, name, options) {
|
|
3516
|
-
const choiceSetName = await this.resolveChoiceSetName(choiceSetId);
|
|
3687
|
+
const choiceSetName = await this.resolveChoiceSetName(choiceSetId, options?.folderKey);
|
|
3517
3688
|
const payload = {
|
|
3518
3689
|
Name: name,
|
|
3519
3690
|
...(options?.displayName !== undefined && { DisplayName: options.displayName }),
|
|
3520
3691
|
};
|
|
3521
|
-
const response = await this.post(DATA_FABRIC_ENDPOINTS.CHOICESETS.INSERT_BY_NAME(choiceSetName), payload);
|
|
3692
|
+
const response = await this.post(DATA_FABRIC_ENDPOINTS.CHOICESETS.INSERT_BY_NAME(choiceSetName), payload, { headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }) });
|
|
3522
3693
|
const camelCased = pascalToCamelCaseKeys(response.data);
|
|
3523
3694
|
return transformData(camelCased, EntityMap);
|
|
3524
3695
|
}
|
|
@@ -3531,6 +3702,7 @@ class ChoiceSetService extends BaseService {
|
|
|
3531
3702
|
* @param choiceSetId - UUID of the parent choice set
|
|
3532
3703
|
* @param valueId - UUID of the value to update
|
|
3533
3704
|
* @param displayName - New human-readable display name for the value
|
|
3705
|
+
* @param options - Optional {@link ChoiceSetValueUpdateOptions} — pass `folderKey` for folder-scoped choice sets; omit for tenant-level. The `folderKey` property is **experimental**.
|
|
3534
3706
|
* @returns Promise resolving to the updated value ({@link ChoiceSetValueUpdateResponse})
|
|
3535
3707
|
*
|
|
3536
3708
|
* @example
|
|
@@ -3542,13 +3714,18 @@ class ChoiceSetService extends BaseService {
|
|
|
3542
3714
|
* const travel = values.items.find(v => v.name === 'TRAVEL');
|
|
3543
3715
|
*
|
|
3544
3716
|
* await choicesets.updateValueById(expenseTypes.id, travel.id, 'Business Travel');
|
|
3717
|
+
*
|
|
3718
|
+
* // Folder-scoped choice set: folderKey is required on the wire
|
|
3719
|
+
* await choicesets.updateValueById(expenseTypes.id, travel.id, 'Business Travel', {
|
|
3720
|
+
* folderKey: "<folderKey>",
|
|
3721
|
+
* });
|
|
3545
3722
|
* ```
|
|
3546
3723
|
* @internal
|
|
3547
3724
|
*/
|
|
3548
|
-
async updateValueById(choiceSetId, valueId, displayName) {
|
|
3549
|
-
const choiceSetName = await this.resolveChoiceSetName(choiceSetId);
|
|
3725
|
+
async updateValueById(choiceSetId, valueId, displayName, options) {
|
|
3726
|
+
const choiceSetName = await this.resolveChoiceSetName(choiceSetId, options?.folderKey);
|
|
3550
3727
|
const payload = { DisplayName: displayName };
|
|
3551
|
-
const response = await this.post(DATA_FABRIC_ENDPOINTS.CHOICESETS.UPDATE_BY_NAME(choiceSetName, valueId), payload);
|
|
3728
|
+
const response = await this.post(DATA_FABRIC_ENDPOINTS.CHOICESETS.UPDATE_BY_NAME(choiceSetName, valueId), payload, { headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }) });
|
|
3552
3729
|
const camelCased = pascalToCamelCaseKeys(response.data);
|
|
3553
3730
|
return transformData(camelCased, EntityMap);
|
|
3554
3731
|
}
|
|
@@ -3557,6 +3734,7 @@ class ChoiceSetService extends BaseService {
|
|
|
3557
3734
|
*
|
|
3558
3735
|
* @param choiceSetId - UUID of the parent choice set
|
|
3559
3736
|
* @param valueIds - Array of value UUIDs to delete
|
|
3737
|
+
* @param options - Optional {@link ChoiceSetValueDeleteOptions} (e.g. `folderKey` for folder-scoped choice sets) The `folderKey` property is **experimental**.
|
|
3560
3738
|
* @returns Promise resolving when the values are deleted
|
|
3561
3739
|
*
|
|
3562
3740
|
* @example
|
|
@@ -3566,14 +3744,20 @@ class ChoiceSetService extends BaseService {
|
|
|
3566
3744
|
* const idsToDelete = values.items.slice(0, 2).map(v => v.id);
|
|
3567
3745
|
*
|
|
3568
3746
|
* await choicesets.deleteValuesById('<choiceSetId>', idsToDelete);
|
|
3747
|
+
*
|
|
3748
|
+
* // Folder-scoped choice set
|
|
3749
|
+
* await choicesets.deleteValuesById('<choiceSetId>', idsToDelete, { folderKey: "<folderKey>" });
|
|
3569
3750
|
* ```
|
|
3570
3751
|
* @internal
|
|
3571
3752
|
*/
|
|
3572
|
-
async deleteValuesById(choiceSetId, valueIds) {
|
|
3573
|
-
await this.post(DATA_FABRIC_ENDPOINTS.CHOICESETS.DELETE_BY_ID(choiceSetId), valueIds);
|
|
3753
|
+
async deleteValuesById(choiceSetId, valueIds, options) {
|
|
3754
|
+
await this.post(DATA_FABRIC_ENDPOINTS.CHOICESETS.DELETE_BY_ID(choiceSetId), valueIds, { headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }) });
|
|
3574
3755
|
}
|
|
3575
|
-
async resolveChoiceSetName(choiceSetId) {
|
|
3576
|
-
|
|
3756
|
+
async resolveChoiceSetName(choiceSetId, folderKey) {
|
|
3757
|
+
// Use the un-tracked helper directly so we don't fire a duplicate
|
|
3758
|
+
// `Choicesets.GetAll` telemetry event for every insertValueById /
|
|
3759
|
+
// updateValueById call.
|
|
3760
|
+
const all = await this.fetchAllChoiceSets(folderKey === undefined ? undefined : { folderKey });
|
|
3577
3761
|
const match = all.find(cs => cs.id === choiceSetId);
|
|
3578
3762
|
if (!match) {
|
|
3579
3763
|
throw new NotFoundError({ message: `Choice set with id '${choiceSetId}' not found.` });
|