@uipath/uipath-typescript 1.3.10 → 1.4.0
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 +1765 -0
- package/dist/agent-memory/index.d.ts +588 -0
- package/dist/agent-memory/index.mjs +1763 -0
- package/dist/agents/index.cjs +1726 -0
- package/dist/agents/index.d.ts +502 -0
- package/dist/agents/index.mjs +1724 -0
- package/dist/assets/index.cjs +155 -30
- package/dist/assets/index.d.ts +84 -5
- package/dist/assets/index.mjs +155 -30
- package/dist/attachments/index.cjs +37 -6
- package/dist/attachments/index.d.ts +1 -0
- package/dist/attachments/index.mjs +37 -6
- package/dist/buckets/index.cjs +37 -6
- package/dist/buckets/index.d.ts +1 -0
- package/dist/buckets/index.mjs +37 -6
- package/dist/cases/index.cjs +192 -10
- package/dist/cases/index.d.ts +208 -7
- package/dist/cases/index.mjs +192 -11
- package/dist/conversational-agent/index.cjs +124 -57
- package/dist/conversational-agent/index.d.ts +190 -122
- package/dist/conversational-agent/index.mjs +124 -57
- package/dist/core/index.cjs +413 -105
- package/dist/core/index.d.ts +15 -0
- package/dist/core/index.mjs +413 -105
- package/dist/entities/index.cjs +135 -70
- package/dist/entities/index.d.ts +146 -45
- package/dist/entities/index.mjs +135 -70
- package/dist/feedback/index.cjs +37 -6
- package/dist/feedback/index.d.ts +1 -0
- package/dist/feedback/index.mjs +37 -6
- package/dist/governance/index.cjs +1782 -0
- package/dist/governance/index.d.ts +598 -0
- package/dist/governance/index.mjs +1780 -0
- package/dist/index.cjs +1050 -291
- package/dist/index.d.ts +1313 -134
- package/dist/index.mjs +1050 -292
- package/dist/index.umd.js +4546 -3770
- package/dist/jobs/index.cjs +37 -6
- package/dist/jobs/index.d.ts +1 -0
- package/dist/jobs/index.mjs +37 -6
- package/dist/maestro-processes/index.cjs +224 -18
- package/dist/maestro-processes/index.d.ts +221 -9
- package/dist/maestro-processes/index.mjs +224 -18
- package/dist/processes/index.cjs +37 -6
- package/dist/processes/index.d.ts +1 -0
- package/dist/processes/index.mjs +37 -6
- package/dist/queues/index.cjs +37 -6
- package/dist/queues/index.d.ts +1 -0
- package/dist/queues/index.mjs +37 -6
- package/dist/tasks/index.cjs +37 -6
- package/dist/tasks/index.d.ts +1 -0
- package/dist/tasks/index.mjs +37 -6
- package/dist/traces/index.cjs +1933 -0
- package/dist/traces/index.d.ts +566 -0
- package/dist/traces/index.mjs +1931 -0
- package/package.json +42 -2
package/dist/entities/index.cjs
CHANGED
|
@@ -505,6 +505,7 @@ class ErrorFactory {
|
|
|
505
505
|
}
|
|
506
506
|
}
|
|
507
507
|
|
|
508
|
+
const FOLDER_KEY = 'X-UIPATH-FolderKey';
|
|
508
509
|
const FOLDER_ID = 'X-UIPATH-OrganizationUnitId';
|
|
509
510
|
const TRACEPARENT = 'traceparent';
|
|
510
511
|
const UIPATH_TRACEPARENT_ID = 'x-uipath-traceparent-id';
|
|
@@ -719,6 +720,32 @@ function filterUndefined(obj) {
|
|
|
719
720
|
*/
|
|
720
721
|
const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
721
722
|
isBrowser && window.self != window.top && window.location.href.includes('source=ActionCenter');
|
|
723
|
+
const _params = isBrowser ? new URLSearchParams(window.location.search) : null;
|
|
724
|
+
/**
|
|
725
|
+
* True when the coded app has been loaded inside a host frame that explicitly
|
|
726
|
+
* opted into token delegation by adding `?host=embed` to the iframe src URL.
|
|
727
|
+
*/
|
|
728
|
+
const isHostEmbedded = isBrowser && window.self !== window.top && _params?.get('host') === 'embed';
|
|
729
|
+
/**
|
|
730
|
+
* The validated parent origin, read from the `?basedomain=` query param set
|
|
731
|
+
* by the embedding host in the iframe src URL.
|
|
732
|
+
* Mirrors the same mechanism used by ActionCenterTokenManager.
|
|
733
|
+
* Non-null only when `?host=embed` is present and `?basedomain=` is a valid URL.
|
|
734
|
+
*/
|
|
735
|
+
(() => {
|
|
736
|
+
if (!isHostEmbedded)
|
|
737
|
+
return null;
|
|
738
|
+
const basedomain = _params?.get('basedomain');
|
|
739
|
+
if (!basedomain)
|
|
740
|
+
return null;
|
|
741
|
+
try {
|
|
742
|
+
return new URL(basedomain).origin;
|
|
743
|
+
}
|
|
744
|
+
catch {
|
|
745
|
+
console.warn('embeddingOrigin: basedomain query param is not a valid URL', basedomain);
|
|
746
|
+
return null;
|
|
747
|
+
}
|
|
748
|
+
})();
|
|
722
749
|
|
|
723
750
|
/**
|
|
724
751
|
* Base64 encoding/decoding
|
|
@@ -1300,8 +1327,9 @@ class PaginationHelpers {
|
|
|
1300
1327
|
});
|
|
1301
1328
|
}
|
|
1302
1329
|
// Extract and transform items from response
|
|
1303
|
-
// Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
|
|
1304
|
-
|
|
1330
|
+
// Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N }).
|
|
1331
|
+
// itemsField may be a dotted path (e.g. 'data.agents') for nested envelopes.
|
|
1332
|
+
const rawItems = Array.isArray(response.data) ? response.data : resolveNestedField(response.data, itemsField);
|
|
1305
1333
|
const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
|
|
1306
1334
|
const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
|
|
1307
1335
|
// Parse items - automatically handle JSON string responses
|
|
@@ -1347,7 +1375,7 @@ class PaginationHelpers {
|
|
|
1347
1375
|
getEndpoint: config.getEndpoint,
|
|
1348
1376
|
folderId,
|
|
1349
1377
|
headers: config.headers,
|
|
1350
|
-
paginationParams: cursor ? { cursor, pageSize } : jumpToPage ? { jumpToPage, pageSize } : { pageSize },
|
|
1378
|
+
paginationParams: cursor ? { cursor, pageSize } : jumpToPage !== undefined ? { jumpToPage, pageSize } : { pageSize },
|
|
1351
1379
|
additionalParams: prefixedOptions,
|
|
1352
1380
|
transformFn: config.transformFn,
|
|
1353
1381
|
method: config.method,
|
|
@@ -1605,6 +1633,8 @@ class BaseService {
|
|
|
1605
1633
|
// When true (default), converts pageNumber to a skip/offset value (e.g., page 3 with pageSize 10 → skip 20).
|
|
1606
1634
|
// When false, passes pageNumber directly as the offset param — used by APIs that accept a page number instead of a record offset.
|
|
1607
1635
|
const convertToSkip = paginationParams?.convertToSkip ?? true;
|
|
1636
|
+
// When true, sends pageNumber - 1 (for 0-based APIs). Default false (1-based).
|
|
1637
|
+
const zeroBased = paginationParams?.zeroBased ?? false;
|
|
1608
1638
|
requestParams[pageSizeParam] = limitedPageSize;
|
|
1609
1639
|
if (convertToSkip) {
|
|
1610
1640
|
if (params.pageNumber && params.pageNumber > 1) {
|
|
@@ -1612,7 +1642,8 @@ class BaseService {
|
|
|
1612
1642
|
}
|
|
1613
1643
|
}
|
|
1614
1644
|
else {
|
|
1615
|
-
|
|
1645
|
+
const sdkPageNumber = params.pageNumber || 1;
|
|
1646
|
+
requestParams[offsetParam] = zeroBased ? sdkPageNumber - 1 : sdkPageNumber;
|
|
1616
1647
|
}
|
|
1617
1648
|
{
|
|
1618
1649
|
requestParams[countParam] = true;
|
|
@@ -1641,8 +1672,9 @@ class BaseService {
|
|
|
1641
1672
|
const totalCountField = fields.totalCountField || 'totalRecordCount';
|
|
1642
1673
|
const continuationTokenField = fields.continuationTokenField || 'continuationToken';
|
|
1643
1674
|
// Extract items and metadata
|
|
1644
|
-
// Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
|
|
1645
|
-
|
|
1675
|
+
// Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N }).
|
|
1676
|
+
// itemsField may be a dotted path (e.g. 'data.agents') for nested envelopes.
|
|
1677
|
+
const items = Array.isArray(response.data) ? response.data : (resolveNestedField(response.data, itemsField) || []);
|
|
1646
1678
|
const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
|
|
1647
1679
|
const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
|
|
1648
1680
|
const continuationToken = response.data[continuationTokenField];
|
|
@@ -1725,12 +1757,12 @@ function createEntityMethods(entityData, service) {
|
|
|
1725
1757
|
throw new Error('Entity ID is undefined');
|
|
1726
1758
|
return service.deleteRecordsById(entityData.id, recordIds, options);
|
|
1727
1759
|
},
|
|
1728
|
-
async deleteRecord(recordId) {
|
|
1760
|
+
async deleteRecord(recordId, options) {
|
|
1729
1761
|
if (!entityData.id)
|
|
1730
1762
|
throw new Error('Entity ID is undefined');
|
|
1731
1763
|
if (!recordId)
|
|
1732
1764
|
throw new Error('Record ID is undefined');
|
|
1733
|
-
return service.deleteRecordById(entityData.id, recordId);
|
|
1765
|
+
return service.deleteRecordById(entityData.id, recordId, options);
|
|
1734
1766
|
},
|
|
1735
1767
|
async getAllRecords(options) {
|
|
1736
1768
|
if (!entityData.id)
|
|
@@ -1744,30 +1776,30 @@ function createEntityMethods(entityData, service) {
|
|
|
1744
1776
|
throw new Error('Record ID is undefined');
|
|
1745
1777
|
return service.getRecordById(entityData.id, recordId, options);
|
|
1746
1778
|
},
|
|
1747
|
-
async downloadAttachment(recordId, fieldName) {
|
|
1779
|
+
async downloadAttachment(recordId, fieldName, options) {
|
|
1748
1780
|
if (!entityData.id)
|
|
1749
1781
|
throw new Error('Entity ID is undefined');
|
|
1750
|
-
return service.downloadAttachment(entityData.id, recordId, fieldName);
|
|
1782
|
+
return service.downloadAttachment(entityData.id, recordId, fieldName, options);
|
|
1751
1783
|
},
|
|
1752
1784
|
async uploadAttachment(recordId, fieldName, file, options) {
|
|
1753
1785
|
if (!entityData.id)
|
|
1754
1786
|
throw new Error('Entity ID is undefined');
|
|
1755
1787
|
return service.uploadAttachment(entityData.id, recordId, fieldName, file, options);
|
|
1756
1788
|
},
|
|
1757
|
-
async deleteAttachment(recordId, fieldName) {
|
|
1789
|
+
async deleteAttachment(recordId, fieldName, options) {
|
|
1758
1790
|
if (!entityData.id)
|
|
1759
1791
|
throw new Error('Entity ID is undefined');
|
|
1760
|
-
return service.deleteAttachment(entityData.id, recordId, fieldName);
|
|
1792
|
+
return service.deleteAttachment(entityData.id, recordId, fieldName, options);
|
|
1761
1793
|
},
|
|
1762
1794
|
async queryRecords(options) {
|
|
1763
1795
|
if (!entityData.id)
|
|
1764
1796
|
throw new Error('Entity ID is undefined');
|
|
1765
1797
|
return service.queryRecordsById(entityData.id, options);
|
|
1766
1798
|
},
|
|
1767
|
-
async importRecords(file) {
|
|
1799
|
+
async importRecords(file, options) {
|
|
1768
1800
|
if (!entityData.id)
|
|
1769
1801
|
throw new Error('Entity ID is undefined');
|
|
1770
|
-
return service.importRecordsById(entityData.id, file);
|
|
1802
|
+
return service.importRecordsById(entityData.id, file, options);
|
|
1771
1803
|
},
|
|
1772
1804
|
async insert(data, options) {
|
|
1773
1805
|
return this.insertRecord(data, options);
|
|
@@ -1778,10 +1810,10 @@ function createEntityMethods(entityData, service) {
|
|
|
1778
1810
|
async getRecords(options) {
|
|
1779
1811
|
return this.getAllRecords(options);
|
|
1780
1812
|
},
|
|
1781
|
-
async delete() {
|
|
1813
|
+
async delete(options) {
|
|
1782
1814
|
if (!entityData.id)
|
|
1783
1815
|
throw new Error('Entity ID is undefined');
|
|
1784
|
-
return service.deleteById(entityData.id);
|
|
1816
|
+
return service.deleteById(entityData.id, options);
|
|
1785
1817
|
},
|
|
1786
1818
|
async update(options) {
|
|
1787
1819
|
if (!entityData.id)
|
|
@@ -2190,6 +2222,7 @@ class EntityService extends BaseService {
|
|
|
2190
2222
|
* Gets entity metadata by entity ID with attached operation methods
|
|
2191
2223
|
*
|
|
2192
2224
|
* @param id - UUID of the entity
|
|
2225
|
+
* @param options - Optional {@link EntityGetByIdOptions} (e.g. `folderKey` for folder-scoped entities)
|
|
2193
2226
|
* @returns Promise resolving to entity metadata with schema information and operation methods
|
|
2194
2227
|
*
|
|
2195
2228
|
* @example
|
|
@@ -2199,6 +2232,9 @@ class EntityService extends BaseService {
|
|
|
2199
2232
|
* const entities = new Entities(sdk);
|
|
2200
2233
|
* const entity = await entities.getById("<entityId>");
|
|
2201
2234
|
*
|
|
2235
|
+
* // Folder-scoped: pass the entity's folder key
|
|
2236
|
+
* const folderEntity = await entities.getById("<entityId>", { folderKey: "<folderKey>" });
|
|
2237
|
+
*
|
|
2202
2238
|
* // Call operations directly on the entity
|
|
2203
2239
|
* const records = await entity.getAllRecords();
|
|
2204
2240
|
*
|
|
@@ -2212,9 +2248,9 @@ class EntityService extends BaseService {
|
|
|
2212
2248
|
* ]);
|
|
2213
2249
|
* ```
|
|
2214
2250
|
*/
|
|
2215
|
-
async getById(id) {
|
|
2251
|
+
async getById(id, options) {
|
|
2216
2252
|
// Get entity metadata
|
|
2217
|
-
const response = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.GET_BY_ID(id));
|
|
2253
|
+
const response = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.GET_BY_ID(id), { headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }) });
|
|
2218
2254
|
// Apply EntityMap transformations
|
|
2219
2255
|
const metadata = transformData(response.data, EntityMap);
|
|
2220
2256
|
// Transform metadata with field mappers
|
|
@@ -2257,9 +2293,14 @@ class EntityService extends BaseService {
|
|
|
2257
2293
|
* ```
|
|
2258
2294
|
*/
|
|
2259
2295
|
async getAllRecords(entityId, options) {
|
|
2296
|
+
// folderKey is header-only — destructure it out so PaginationHelpers doesn't serialise it
|
|
2297
|
+
// into the query string as $folderKey.
|
|
2298
|
+
const { folderKey, ...rest } = options ?? {};
|
|
2299
|
+
const downstreamOptions = options === undefined ? undefined : rest;
|
|
2260
2300
|
return PaginationHelpers.getAll({
|
|
2261
2301
|
serviceAccess: this.createPaginationServiceAccess(),
|
|
2262
2302
|
getEndpoint: () => DATA_FABRIC_ENDPOINTS.ENTITY.GET_ENTITY_RECORDS(entityId),
|
|
2303
|
+
headers: createHeaders({ [FOLDER_KEY]: folderKey }),
|
|
2263
2304
|
pagination: {
|
|
2264
2305
|
paginationType: PaginationType.OFFSET,
|
|
2265
2306
|
itemsField: ENTITY_PAGINATION.ITEMS_FIELD,
|
|
@@ -2271,7 +2312,7 @@ class EntityService extends BaseService {
|
|
|
2271
2312
|
}
|
|
2272
2313
|
},
|
|
2273
2314
|
excludeFromPrefix: ['expansionLevel'] // Don't add ODATA prefix to expansionLevel
|
|
2274
|
-
},
|
|
2315
|
+
}, downstreamOptions);
|
|
2275
2316
|
}
|
|
2276
2317
|
/**
|
|
2277
2318
|
* Gets a single entity record by entity ID and record ID
|
|
@@ -2296,7 +2337,7 @@ class EntityService extends BaseService {
|
|
|
2296
2337
|
const params = createParams({
|
|
2297
2338
|
expansionLevel: options.expansionLevel
|
|
2298
2339
|
});
|
|
2299
|
-
const response = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.GET_RECORD_BY_ID(entityId, recordId), { params });
|
|
2340
|
+
const response = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.GET_RECORD_BY_ID(entityId, recordId), { params, headers: createHeaders({ [FOLDER_KEY]: options.folderKey }) });
|
|
2300
2341
|
return response.data;
|
|
2301
2342
|
}
|
|
2302
2343
|
/**
|
|
@@ -2328,7 +2369,7 @@ class EntityService extends BaseService {
|
|
|
2328
2369
|
});
|
|
2329
2370
|
const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.INSERT_BY_ID(id), data, {
|
|
2330
2371
|
params,
|
|
2331
|
-
|
|
2372
|
+
headers: createHeaders({ [FOLDER_KEY]: options.folderKey }),
|
|
2332
2373
|
});
|
|
2333
2374
|
return response.data;
|
|
2334
2375
|
}
|
|
@@ -2369,7 +2410,7 @@ class EntityService extends BaseService {
|
|
|
2369
2410
|
});
|
|
2370
2411
|
const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.BATCH_INSERT_BY_ID(id), data, {
|
|
2371
2412
|
params,
|
|
2372
|
-
|
|
2413
|
+
headers: createHeaders({ [FOLDER_KEY]: options.folderKey }),
|
|
2373
2414
|
});
|
|
2374
2415
|
return response.data;
|
|
2375
2416
|
}
|
|
@@ -2403,7 +2444,7 @@ class EntityService extends BaseService {
|
|
|
2403
2444
|
});
|
|
2404
2445
|
const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPDATE_RECORD_BY_ID(entityId, recordId), data, {
|
|
2405
2446
|
params,
|
|
2406
|
-
|
|
2447
|
+
headers: createHeaders({ [FOLDER_KEY]: options.folderKey }),
|
|
2407
2448
|
});
|
|
2408
2449
|
return response.data;
|
|
2409
2450
|
}
|
|
@@ -2445,7 +2486,7 @@ class EntityService extends BaseService {
|
|
|
2445
2486
|
});
|
|
2446
2487
|
const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPDATE_BY_ID(id), data, {
|
|
2447
2488
|
params,
|
|
2448
|
-
|
|
2489
|
+
headers: createHeaders({ [FOLDER_KEY]: options.folderKey }),
|
|
2449
2490
|
});
|
|
2450
2491
|
return response.data;
|
|
2451
2492
|
}
|
|
@@ -2477,7 +2518,7 @@ class EntityService extends BaseService {
|
|
|
2477
2518
|
});
|
|
2478
2519
|
const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.DELETE_BY_ID(id), recordIds, {
|
|
2479
2520
|
params,
|
|
2480
|
-
|
|
2521
|
+
headers: createHeaders({ [FOLDER_KEY]: options.folderKey }),
|
|
2481
2522
|
});
|
|
2482
2523
|
return response.data;
|
|
2483
2524
|
}
|
|
@@ -2489,6 +2530,7 @@ class EntityService extends BaseService {
|
|
|
2489
2530
|
*
|
|
2490
2531
|
* @param entityId - UUID of the entity
|
|
2491
2532
|
* @param recordId - UUID of the record to delete
|
|
2533
|
+
* @param options - Optional {@link EntityDeleteRecordByIdOptions} (e.g. `folderKey` for folder-scoped entities)
|
|
2492
2534
|
* @returns Promise resolving to void on success
|
|
2493
2535
|
* @example
|
|
2494
2536
|
* ```typescript
|
|
@@ -2497,10 +2539,13 @@ class EntityService extends BaseService {
|
|
|
2497
2539
|
* const entities = new Entities(sdk);
|
|
2498
2540
|
*
|
|
2499
2541
|
* await entities.deleteRecordById("<entityId>", "<recordId>");
|
|
2542
|
+
*
|
|
2543
|
+
* // Folder-scoped: pass the entity's folder key
|
|
2544
|
+
* await entities.deleteRecordById("<entityId>", "<recordId>", { folderKey: "<folderKey>" });
|
|
2500
2545
|
* ```
|
|
2501
2546
|
*/
|
|
2502
|
-
async deleteRecordById(entityId, recordId) {
|
|
2503
|
-
await this.delete(DATA_FABRIC_ENDPOINTS.ENTITY.DELETE_RECORD_BY_ID(entityId, recordId));
|
|
2547
|
+
async deleteRecordById(entityId, recordId, options) {
|
|
2548
|
+
await this.delete(DATA_FABRIC_ENDPOINTS.ENTITY.DELETE_RECORD_BY_ID(entityId, recordId), { headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }) });
|
|
2504
2549
|
}
|
|
2505
2550
|
/**
|
|
2506
2551
|
* Gets all entities in the system
|
|
@@ -2586,10 +2631,15 @@ class EntityService extends BaseService {
|
|
|
2586
2631
|
* ```
|
|
2587
2632
|
*/
|
|
2588
2633
|
async queryRecordsById(id, options) {
|
|
2634
|
+
// folderKey is header-only — destructure it out so PaginationHelpers doesn't include
|
|
2635
|
+
// it in the POST body alongside the query filters.
|
|
2636
|
+
const { folderKey, ...rest } = options ?? {};
|
|
2637
|
+
const downstreamOptions = options === undefined ? undefined : rest;
|
|
2589
2638
|
return PaginationHelpers.getAll({
|
|
2590
2639
|
serviceAccess: this.createPaginationServiceAccess(),
|
|
2591
2640
|
getEndpoint: () => DATA_FABRIC_ENDPOINTS.ENTITY.QUERY_BY_ID(id),
|
|
2592
2641
|
method: HTTP_METHODS.POST,
|
|
2642
|
+
headers: createHeaders({ [FOLDER_KEY]: folderKey }),
|
|
2593
2643
|
pagination: {
|
|
2594
2644
|
paginationType: PaginationType.OFFSET,
|
|
2595
2645
|
itemsField: ENTITY_PAGINATION.ITEMS_FIELD,
|
|
@@ -2601,13 +2651,14 @@ class EntityService extends BaseService {
|
|
|
2601
2651
|
}
|
|
2602
2652
|
},
|
|
2603
2653
|
excludeFromPrefix: ['expansionLevel', 'filterGroup', 'selectedFields', 'sortOptions', 'aggregates', 'groupBy']
|
|
2604
|
-
},
|
|
2654
|
+
}, downstreamOptions);
|
|
2605
2655
|
}
|
|
2606
2656
|
/**
|
|
2607
2657
|
* Imports records from a CSV file into an entity
|
|
2608
2658
|
*
|
|
2609
2659
|
* @param id - UUID of the entity
|
|
2610
2660
|
* @param file - CSV file to import (Blob, File, or Uint8Array)
|
|
2661
|
+
* @param options - Optional {@link EntityImportRecordsByIdOptions} (e.g. `folderKey` for folder-scoped entities)
|
|
2611
2662
|
* @returns Promise resolving to import result with record counts
|
|
2612
2663
|
*
|
|
2613
2664
|
* @example
|
|
@@ -2628,10 +2679,12 @@ class EntityService extends BaseService {
|
|
|
2628
2679
|
* if (result.errorFileLink) {
|
|
2629
2680
|
* console.log(`Error file link: ${result.errorFileLink}`);
|
|
2630
2681
|
* }
|
|
2682
|
+
*
|
|
2683
|
+
* // Folder-scoped entity: pass the entity's folder key
|
|
2684
|
+
* await entities.importRecordsById("<entityId>", fileInput.files[0], { folderKey: "<folderKey>" });
|
|
2631
2685
|
* ```
|
|
2632
|
-
* @internal
|
|
2633
2686
|
*/
|
|
2634
|
-
async importRecordsById(id, file) {
|
|
2687
|
+
async importRecordsById(id, file, options) {
|
|
2635
2688
|
const formData = new FormData();
|
|
2636
2689
|
if (file instanceof Uint8Array) {
|
|
2637
2690
|
formData.append('file', new Blob([file.buffer]));
|
|
@@ -2639,7 +2692,7 @@ class EntityService extends BaseService {
|
|
|
2639
2692
|
else {
|
|
2640
2693
|
formData.append('file', file);
|
|
2641
2694
|
}
|
|
2642
|
-
const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.BULK_UPLOAD_BY_ID(id), formData);
|
|
2695
|
+
const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.BULK_UPLOAD_BY_ID(id), formData, { headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }) });
|
|
2643
2696
|
return response.data;
|
|
2644
2697
|
}
|
|
2645
2698
|
/**
|
|
@@ -2648,6 +2701,7 @@ class EntityService extends BaseService {
|
|
|
2648
2701
|
* @param entityId - UUID of the entity
|
|
2649
2702
|
* @param recordId - UUID of the record containing the attachment
|
|
2650
2703
|
* @param fieldName - Name of the File-type field containing the attachment
|
|
2704
|
+
* @param options - Optional {@link EntityDownloadAttachmentOptions} (e.g. `folderKey` for folder-scoped entities)
|
|
2651
2705
|
* @returns Promise resolving to Blob containing the file content
|
|
2652
2706
|
*
|
|
2653
2707
|
* @example
|
|
@@ -2666,11 +2720,15 @@ class EntityService extends BaseService {
|
|
|
2666
2720
|
*
|
|
2667
2721
|
* // Download attachment for a specific record and field
|
|
2668
2722
|
* const blob = await entities.downloadAttachment(entityId, recordId, 'Documents');
|
|
2723
|
+
*
|
|
2724
|
+
* // Folder-scoped: pass the entity's folder key
|
|
2725
|
+
* const blob = await entities.downloadAttachment(entityId, recordId, 'Documents', { folderKey: "<folderKey>" });
|
|
2669
2726
|
* ```
|
|
2670
2727
|
*/
|
|
2671
|
-
async downloadAttachment(entityId, recordId, fieldName) {
|
|
2728
|
+
async downloadAttachment(entityId, recordId, fieldName, options) {
|
|
2672
2729
|
const response = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.DOWNLOAD_ATTACHMENT(entityId, recordId, fieldName), {
|
|
2673
|
-
responseType: RESPONSE_TYPES.BLOB
|
|
2730
|
+
responseType: RESPONSE_TYPES.BLOB,
|
|
2731
|
+
headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }),
|
|
2674
2732
|
});
|
|
2675
2733
|
return response.data;
|
|
2676
2734
|
}
|
|
@@ -2681,7 +2739,7 @@ class EntityService extends BaseService {
|
|
|
2681
2739
|
* @param recordId - UUID of the record to upload the attachment to
|
|
2682
2740
|
* @param fieldName - Name of the File-type field
|
|
2683
2741
|
* @param file - File to upload (Blob, File, or Uint8Array)
|
|
2684
|
-
* @param options - Optional {@link EntityUploadAttachmentOptions} (e.g. expansionLevel)
|
|
2742
|
+
* @param options - Optional {@link EntityUploadAttachmentOptions} (e.g. `expansionLevel`, `folderKey` for folder-scoped entities)
|
|
2685
2743
|
* @returns Promise resolving to {@link EntityUploadAttachmentResponse}
|
|
2686
2744
|
*
|
|
2687
2745
|
* @example
|
|
@@ -2700,6 +2758,9 @@ class EntityService extends BaseService {
|
|
|
2700
2758
|
*
|
|
2701
2759
|
* // Upload a file attachment
|
|
2702
2760
|
* const response = await entities.uploadAttachment(entityId, recordId, 'Documents', file);
|
|
2761
|
+
*
|
|
2762
|
+
* // Folder-scoped entity: pass the entity's folder key
|
|
2763
|
+
* await entities.uploadAttachment(entityId, recordId, 'Documents', file, { folderKey: "<folderKey>" });
|
|
2703
2764
|
* ```
|
|
2704
2765
|
*/
|
|
2705
2766
|
async uploadAttachment(entityId, recordId, fieldName, file, options) {
|
|
@@ -2711,7 +2772,10 @@ class EntityService extends BaseService {
|
|
|
2711
2772
|
formData.append('file', file);
|
|
2712
2773
|
}
|
|
2713
2774
|
const params = createParams({ expansionLevel: options?.expansionLevel });
|
|
2714
|
-
const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPLOAD_ATTACHMENT(entityId, recordId, fieldName), formData, {
|
|
2775
|
+
const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPLOAD_ATTACHMENT(entityId, recordId, fieldName), formData, {
|
|
2776
|
+
params,
|
|
2777
|
+
headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }),
|
|
2778
|
+
});
|
|
2715
2779
|
return response.data;
|
|
2716
2780
|
}
|
|
2717
2781
|
/**
|
|
@@ -2720,6 +2784,7 @@ class EntityService extends BaseService {
|
|
|
2720
2784
|
* @param entityId - UUID of the entity
|
|
2721
2785
|
* @param recordId - UUID of the record containing the attachment
|
|
2722
2786
|
* @param fieldName - Name of the File-type field containing the attachment
|
|
2787
|
+
* @param options - Optional {@link EntityDeleteAttachmentOptions} (e.g. `folderKey` for folder-scoped entities)
|
|
2723
2788
|
* @returns Promise resolving to {@link EntityDeleteAttachmentResponse}
|
|
2724
2789
|
*
|
|
2725
2790
|
* @example
|
|
@@ -2738,10 +2803,13 @@ class EntityService extends BaseService {
|
|
|
2738
2803
|
*
|
|
2739
2804
|
* // Delete attachment for a specific record and field
|
|
2740
2805
|
* await entities.deleteAttachment(entityId, recordId, 'Documents');
|
|
2806
|
+
*
|
|
2807
|
+
* // Folder-scoped: pass the entity's folder key
|
|
2808
|
+
* await entities.deleteAttachment(entityId, recordId, 'Documents', { folderKey: "<folderKey>" });
|
|
2741
2809
|
* ```
|
|
2742
2810
|
*/
|
|
2743
|
-
async deleteAttachment(entityId, recordId, fieldName) {
|
|
2744
|
-
const response = await this.delete(DATA_FABRIC_ENDPOINTS.ENTITY.DELETE_ATTACHMENT(entityId, recordId, fieldName));
|
|
2811
|
+
async deleteAttachment(entityId, recordId, fieldName, options) {
|
|
2812
|
+
const response = await this.delete(DATA_FABRIC_ENDPOINTS.ENTITY.DELETE_ATTACHMENT(entityId, recordId, fieldName), { headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }) });
|
|
2745
2813
|
return response.data;
|
|
2746
2814
|
}
|
|
2747
2815
|
/**
|
|
@@ -2791,10 +2859,6 @@ class EntityService extends BaseService {
|
|
|
2791
2859
|
* @internal
|
|
2792
2860
|
*/
|
|
2793
2861
|
async create(name, fields, options) {
|
|
2794
|
-
this.validateName(name, 'entity');
|
|
2795
|
-
for (const field of fields) {
|
|
2796
|
-
this.validateName(field.fieldName, 'field');
|
|
2797
|
-
}
|
|
2798
2862
|
const opts = options ?? {};
|
|
2799
2863
|
const payload = {
|
|
2800
2864
|
...(opts.description !== undefined && { description: opts.description }),
|
|
@@ -2808,23 +2872,27 @@ class EntityService extends BaseService {
|
|
|
2808
2872
|
externalFields: opts.externalFields ?? [],
|
|
2809
2873
|
},
|
|
2810
2874
|
};
|
|
2811
|
-
const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPSERT, payload);
|
|
2875
|
+
const response = await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPSERT, payload, { headers: createHeaders({ [FOLDER_KEY]: opts.folderKey }) });
|
|
2812
2876
|
return response.data;
|
|
2813
2877
|
}
|
|
2814
2878
|
/**
|
|
2815
2879
|
* Deletes a Data Fabric entity and all its records
|
|
2816
2880
|
*
|
|
2817
2881
|
* @param id - UUID of the entity to delete
|
|
2882
|
+
* @param options - Optional {@link EntityDeleteByIdOptions} (e.g. `folderKey` for folder-scoped entities)
|
|
2818
2883
|
* @returns Promise resolving when the entity is deleted
|
|
2819
2884
|
*
|
|
2820
2885
|
* @example
|
|
2821
2886
|
* ```typescript
|
|
2822
2887
|
* await entities.deleteById("<entityId>");
|
|
2888
|
+
*
|
|
2889
|
+
* // Folder-scoped: pass the entity's folder key
|
|
2890
|
+
* await entities.deleteById("<entityId>", { folderKey: "<folderKey>" });
|
|
2823
2891
|
* ```
|
|
2824
2892
|
* @internal
|
|
2825
2893
|
*/
|
|
2826
|
-
async deleteById(id) {
|
|
2827
|
-
await this.delete(DATA_FABRIC_ENDPOINTS.ENTITY.DELETE(id));
|
|
2894
|
+
async deleteById(id, options) {
|
|
2895
|
+
await this.delete(DATA_FABRIC_ENDPOINTS.ENTITY.DELETE(id), { headers: createHeaders({ [FOLDER_KEY]: options?.folderKey }) });
|
|
2828
2896
|
}
|
|
2829
2897
|
/**
|
|
2830
2898
|
* Updates an existing Data Fabric entity — schema and/or metadata.
|
|
@@ -2871,6 +2939,12 @@ class EntityService extends BaseService {
|
|
|
2871
2939
|
* { id: "<fieldId>", lengthLimit: 1000 },
|
|
2872
2940
|
* ],
|
|
2873
2941
|
* });
|
|
2942
|
+
*
|
|
2943
|
+
* // Folder-scoped entity: add a field to an entity that lives in a non-tenant folder
|
|
2944
|
+
* await entities.updateById("<entityId>", {
|
|
2945
|
+
* folderKey: "<folderKey>",
|
|
2946
|
+
* addFields: [{ fieldName: "notes", type: EntityFieldDataType.MULTILINE_TEXT }],
|
|
2947
|
+
* });
|
|
2874
2948
|
* ```
|
|
2875
2949
|
* @internal
|
|
2876
2950
|
*/
|
|
@@ -2886,7 +2960,7 @@ class EntityService extends BaseService {
|
|
|
2886
2960
|
...(opts.displayName !== undefined && { displayName: opts.displayName }),
|
|
2887
2961
|
...(opts.description !== undefined && { description: opts.description }),
|
|
2888
2962
|
...(opts.isRbacEnabled !== undefined && { isRbacEnabled: opts.isRbacEnabled }),
|
|
2889
|
-
});
|
|
2963
|
+
}, { headers: createHeaders({ [FOLDER_KEY]: opts.folderKey }) });
|
|
2890
2964
|
}
|
|
2891
2965
|
}
|
|
2892
2966
|
/**
|
|
@@ -2897,7 +2971,8 @@ class EntityService extends BaseService {
|
|
|
2897
2971
|
* @private
|
|
2898
2972
|
*/
|
|
2899
2973
|
async applySchemaUpdate(entityId, options) {
|
|
2900
|
-
const
|
|
2974
|
+
const folderHeaders = createHeaders({ [FOLDER_KEY]: options.folderKey });
|
|
2975
|
+
const entityResponse = await this.get(DATA_FABRIC_ENDPOINTS.ENTITY.GET_BY_ID(entityId), { headers: folderHeaders });
|
|
2901
2976
|
const raw = entityResponse.data;
|
|
2902
2977
|
// Carry forward existing non-system fields from GET response (skip system/primary-key fields)
|
|
2903
2978
|
let fields = (raw.fields ?? [])
|
|
@@ -2937,6 +3012,7 @@ class EntityService extends BaseService {
|
|
|
2937
3012
|
...(update.isUnique !== undefined && { isUnique: update.isUnique }),
|
|
2938
3013
|
...(update.isRbacEnabled !== undefined && { isRbacEnabled: update.isRbacEnabled }),
|
|
2939
3014
|
...(update.isEncrypted !== undefined && { isEncrypted: update.isEncrypted }),
|
|
3015
|
+
...(update.isHiddenField !== undefined && { isHiddenField: update.isHiddenField }),
|
|
2940
3016
|
...(update.defaultValue !== undefined && { defaultValue: update.defaultValue }),
|
|
2941
3017
|
...(hasConstraintUpdate && f.sqlType && { sqlType: { ...f.sqlType, ...constraintUpdate } }),
|
|
2942
3018
|
};
|
|
@@ -2945,9 +3021,6 @@ class EntityService extends BaseService {
|
|
|
2945
3021
|
// Build and append new fields
|
|
2946
3022
|
const newFields = [];
|
|
2947
3023
|
if (options.addFields?.length) {
|
|
2948
|
-
for (const field of options.addFields) {
|
|
2949
|
-
this.validateName(field.fieldName, 'field');
|
|
2950
|
-
}
|
|
2951
3024
|
newFields.push(...options.addFields.map(f => this.buildSchemaFieldPayload(f)));
|
|
2952
3025
|
}
|
|
2953
3026
|
await this.post(DATA_FABRIC_ENDPOINTS.ENTITY.UPSERT, {
|
|
@@ -2962,7 +3035,7 @@ class EntityService extends BaseService {
|
|
|
2962
3035
|
isInsightsEnabled: raw.isInsightsEnabled ?? false,
|
|
2963
3036
|
externalFields: raw.externalFields ?? [],
|
|
2964
3037
|
},
|
|
2965
|
-
});
|
|
3038
|
+
}, { headers: folderHeaders });
|
|
2966
3039
|
}
|
|
2967
3040
|
/**
|
|
2968
3041
|
* Orchestrates all field mapping transformations
|
|
@@ -3048,9 +3121,15 @@ class EntityService extends BaseService {
|
|
|
3048
3121
|
}
|
|
3049
3122
|
/** Converts a user-facing EntityCreateFieldOptions to the raw API field payload */
|
|
3050
3123
|
buildSchemaFieldPayload(field) {
|
|
3051
|
-
this.validateName(field.fieldName, 'field');
|
|
3052
3124
|
const fieldType = field.type ?? exports.EntityFieldDataType.STRING;
|
|
3053
3125
|
this.validateFieldConstraints(fieldType, field, field.fieldName);
|
|
3126
|
+
const isRelationship = fieldType === exports.EntityFieldDataType.RELATIONSHIP;
|
|
3127
|
+
const isFile = fieldType === exports.EntityFieldDataType.FILE;
|
|
3128
|
+
if ((isRelationship || isFile) && (!field.referenceEntityId || !field.referenceFieldId)) {
|
|
3129
|
+
throw new ValidationError({
|
|
3130
|
+
message: `Field '${field.fieldName}' of type ${fieldType} requires both referenceEntityId and referenceFieldId (UUIDs of the target entity and field).`,
|
|
3131
|
+
});
|
|
3132
|
+
}
|
|
3054
3133
|
const mapping = EntitySchemaFieldTypeMap[fieldType];
|
|
3055
3134
|
return {
|
|
3056
3135
|
name: field.fieldName,
|
|
@@ -3065,10 +3144,13 @@ class EntityService extends BaseService {
|
|
|
3065
3144
|
isUnique: field.isUnique ?? false,
|
|
3066
3145
|
isRbacEnabled: field.isRbacEnabled ?? false,
|
|
3067
3146
|
isEncrypted: field.isEncrypted ?? false,
|
|
3147
|
+
isHiddenField: field.isHiddenField ?? false,
|
|
3068
3148
|
...(field.defaultValue !== undefined && { defaultValue: field.defaultValue }),
|
|
3069
3149
|
...(field.choiceSetId !== undefined && { choiceSetId: field.choiceSetId }),
|
|
3070
|
-
...(
|
|
3071
|
-
...(
|
|
3150
|
+
...((isRelationship || isFile) && { isForeignKey: true }),
|
|
3151
|
+
...(isRelationship && { referenceType: exports.ReferenceType.ManyToOne }),
|
|
3152
|
+
...(field.referenceEntityId !== undefined && { referenceEntity: { id: field.referenceEntityId } }),
|
|
3153
|
+
...(field.referenceFieldId !== undefined && { referenceField: { id: field.referenceFieldId } }),
|
|
3072
3154
|
};
|
|
3073
3155
|
}
|
|
3074
3156
|
/**
|
|
@@ -3172,24 +3254,7 @@ class EntityService extends BaseService {
|
|
|
3172
3254
|
return {};
|
|
3173
3255
|
}
|
|
3174
3256
|
}
|
|
3175
|
-
validateName(name, context) {
|
|
3176
|
-
if (name.length < 3 || name.length > 100 || !/^[a-zA-Z]\w*$/.test(name)) {
|
|
3177
|
-
const suggestion = name.replace(/\W/g, '').replace(/^[0-9_]+/, '');
|
|
3178
|
-
const defaultName = `My${context.charAt(0).toUpperCase() + context.slice(1)}`;
|
|
3179
|
-
throw new ValidationError({
|
|
3180
|
-
message: `Invalid ${context} name '${name}'. Must start with a letter, contain only letters, numbers, and underscores, 3–100 characters (e.g., "${suggestion || defaultName}").`
|
|
3181
|
-
});
|
|
3182
|
-
}
|
|
3183
|
-
if (context === 'field' && EntityService.RESERVED_FIELD_NAMES.has(name)) {
|
|
3184
|
-
throw new ValidationError({
|
|
3185
|
-
message: `Field name '${name}' is reserved. Reserved names: ${[...EntityService.RESERVED_FIELD_NAMES].join(', ')}.`
|
|
3186
|
-
});
|
|
3187
|
-
}
|
|
3188
|
-
}
|
|
3189
3257
|
}
|
|
3190
|
-
EntityService.RESERVED_FIELD_NAMES = new Set([
|
|
3191
|
-
'Id', 'CreatedBy', 'CreateTime', 'UpdatedBy', 'UpdateTime'
|
|
3192
|
-
]);
|
|
3193
3258
|
__decorate([
|
|
3194
3259
|
track('Entities.GetById')
|
|
3195
3260
|
], EntityService.prototype, "getById", null);
|