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