@uipath/uipath-typescript 1.3.11 → 1.4.1
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 +1772 -0
- package/dist/agent-memory/index.d.ts +588 -0
- package/dist/agent-memory/index.mjs +1770 -0
- package/dist/agents/index.cjs +1995 -0
- package/dist/agents/index.d.ts +961 -0
- package/dist/agents/index.mjs +1993 -0
- package/dist/assets/index.cjs +171 -39
- package/dist/assets/index.d.ts +84 -5
- package/dist/assets/index.mjs +171 -39
- package/dist/attachments/index.cjs +53 -15
- package/dist/attachments/index.d.ts +1 -0
- package/dist/attachments/index.mjs +53 -15
- package/dist/buckets/index.cjs +151 -130
- package/dist/buckets/index.d.ts +198 -84
- package/dist/buckets/index.mjs +151 -130
- package/dist/cases/index.cjs +220 -23
- package/dist/cases/index.d.ts +148 -10
- package/dist/cases/index.mjs +220 -24
- package/dist/conversational-agent/index.cjs +140 -66
- package/dist/conversational-agent/index.d.ts +190 -122
- package/dist/conversational-agent/index.mjs +140 -66
- package/dist/core/index.cjs +445 -108
- package/dist/core/index.d.ts +15 -0
- package/dist/core/index.mjs +445 -108
- package/dist/entities/index.cjs +365 -102
- package/dist/entities/index.d.ts +446 -114
- package/dist/entities/index.mjs +365 -102
- package/dist/feedback/index.cjs +53 -15
- package/dist/feedback/index.d.ts +1 -0
- package/dist/feedback/index.mjs +53 -15
- package/dist/governance/index.cjs +1789 -0
- package/dist/governance/index.d.ts +598 -0
- package/dist/governance/index.mjs +1787 -0
- package/dist/index.cjs +1453 -444
- package/dist/index.d.ts +4150 -1742
- package/dist/index.mjs +1452 -445
- package/dist/index.umd.js +5035 -4009
- package/dist/jobs/index.cjs +53 -15
- package/dist/jobs/index.d.ts +1 -0
- package/dist/jobs/index.mjs +53 -15
- package/dist/maestro-processes/index.cjs +189 -27
- package/dist/maestro-processes/index.d.ts +131 -9
- package/dist/maestro-processes/index.mjs +189 -27
- 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 +53 -15
- package/dist/processes/index.d.ts +1 -0
- package/dist/processes/index.mjs +53 -15
- package/dist/queues/index.cjs +53 -15
- package/dist/queues/index.d.ts +1 -0
- package/dist/queues/index.mjs +53 -15
- package/dist/tasks/index.cjs +116 -19
- package/dist/tasks/index.d.ts +110 -4
- package/dist/tasks/index.mjs +117 -20
- package/dist/traces/index.cjs +340 -15
- package/dist/traces/index.d.ts +483 -2
- package/dist/traces/index.mjs +339 -16
- package/package.json +42 -2
package/dist/buckets/index.cjs
CHANGED
|
@@ -721,6 +721,32 @@ function filterUndefined(obj) {
|
|
|
721
721
|
*/
|
|
722
722
|
const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
723
723
|
isBrowser && window.self != window.top && window.location.href.includes('source=ActionCenter');
|
|
724
|
+
const _params = isBrowser ? new URLSearchParams(window.location.search) : null;
|
|
725
|
+
/**
|
|
726
|
+
* True when the coded app has been loaded inside a host frame that explicitly
|
|
727
|
+
* opted into token delegation by adding `?host=embed` to the iframe src URL.
|
|
728
|
+
*/
|
|
729
|
+
const isHostEmbedded = isBrowser && window.self !== window.top && _params?.get('host') === 'embed';
|
|
730
|
+
/**
|
|
731
|
+
* The validated parent origin, read from the `?basedomain=` query param set
|
|
732
|
+
* by the embedding host in the iframe src URL.
|
|
733
|
+
* Mirrors the same mechanism used by ActionCenterTokenManager.
|
|
734
|
+
* Non-null only when `?host=embed` is present and `?basedomain=` is a valid URL.
|
|
735
|
+
*/
|
|
736
|
+
(() => {
|
|
737
|
+
if (!isHostEmbedded)
|
|
738
|
+
return null;
|
|
739
|
+
const basedomain = _params?.get('basedomain');
|
|
740
|
+
if (!basedomain)
|
|
741
|
+
return null;
|
|
742
|
+
try {
|
|
743
|
+
return new URL(basedomain).origin;
|
|
744
|
+
}
|
|
745
|
+
catch {
|
|
746
|
+
console.warn('embeddingOrigin: basedomain query param is not a valid URL', basedomain);
|
|
747
|
+
return null;
|
|
748
|
+
}
|
|
749
|
+
})();
|
|
724
750
|
|
|
725
751
|
/**
|
|
726
752
|
* Base64 encoding/decoding
|
|
@@ -1275,12 +1301,18 @@ class PaginationHelpers {
|
|
|
1275
1301
|
* @returns Promise resolving to a paginated result
|
|
1276
1302
|
*/
|
|
1277
1303
|
static async getAllPaginated(params) {
|
|
1278
|
-
const { serviceAccess, getEndpoint, folderId, headers: providedHeaders, paginationParams, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
|
|
1304
|
+
const { serviceAccess, getEndpoint, folderId, headers: providedHeaders, paginationParams, additionalParams, queryParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
|
|
1279
1305
|
const endpoint = getEndpoint(folderId);
|
|
1280
1306
|
const headers = providedHeaders ?? (folderId ? createHeaders({ [FOLDER_ID]: folderId }) : {});
|
|
1307
|
+
// On POST, the caller's options go in the body; queryParams stays in the URL.
|
|
1308
|
+
// On GET, everything is URL — queryParams merges with additionalParams.
|
|
1309
|
+
const isPost = method === HTTP_METHODS.POST;
|
|
1310
|
+
const requestSpec = isPost
|
|
1311
|
+
? { body: additionalParams, params: queryParams }
|
|
1312
|
+
: { params: { ...additionalParams, ...queryParams } };
|
|
1281
1313
|
const paginatedResponse = await serviceAccess.requestWithPagination(method, endpoint, paginationParams, {
|
|
1282
1314
|
headers,
|
|
1283
|
-
|
|
1315
|
+
...requestSpec,
|
|
1284
1316
|
pagination: {
|
|
1285
1317
|
paginationType: options.paginationType || PaginationType.OFFSET,
|
|
1286
1318
|
itemsField: options.itemsField || DEFAULT_ITEMS_FIELD,
|
|
@@ -1305,7 +1337,7 @@ class PaginationHelpers {
|
|
|
1305
1337
|
* @returns Promise resolving to an object with data and totalCount
|
|
1306
1338
|
*/
|
|
1307
1339
|
static async getAllNonPaginated(params) {
|
|
1308
|
-
const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, headers: providedHeaders, additionalParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
|
|
1340
|
+
const { serviceAccess, getAllEndpoint, getByFolderEndpoint, folderId, headers: providedHeaders, additionalParams, queryParams, transformFn, method = HTTP_METHODS.GET, options = {} } = params;
|
|
1309
1341
|
// Set default field names
|
|
1310
1342
|
const itemsField = options.itemsField || DEFAULT_ITEMS_FIELD;
|
|
1311
1343
|
const totalCountField = options.totalCountField || DEFAULT_TOTAL_COUNT_FIELD;
|
|
@@ -1315,17 +1347,18 @@ class PaginationHelpers {
|
|
|
1315
1347
|
// Make the API call based on method
|
|
1316
1348
|
let response;
|
|
1317
1349
|
if (method === HTTP_METHODS.POST) {
|
|
1318
|
-
response = await serviceAccess.post(endpoint, additionalParams, { headers });
|
|
1350
|
+
response = await serviceAccess.post(endpoint, additionalParams, { headers, params: queryParams });
|
|
1319
1351
|
}
|
|
1320
1352
|
else {
|
|
1321
1353
|
response = await serviceAccess.get(endpoint, {
|
|
1322
|
-
params: additionalParams,
|
|
1354
|
+
params: { ...additionalParams, ...queryParams },
|
|
1323
1355
|
headers
|
|
1324
1356
|
});
|
|
1325
1357
|
}
|
|
1326
1358
|
// Extract and transform items from response
|
|
1327
|
-
// Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
|
|
1328
|
-
|
|
1359
|
+
// Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N }).
|
|
1360
|
+
// itemsField may be a dotted path (e.g. 'data.agents') for nested envelopes.
|
|
1361
|
+
const rawItems = Array.isArray(response.data) ? response.data : resolveNestedField(response.data, itemsField);
|
|
1329
1362
|
const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
|
|
1330
1363
|
const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
|
|
1331
1364
|
// Parse items - automatically handle JSON string responses
|
|
@@ -1371,8 +1404,9 @@ class PaginationHelpers {
|
|
|
1371
1404
|
getEndpoint: config.getEndpoint,
|
|
1372
1405
|
folderId,
|
|
1373
1406
|
headers: config.headers,
|
|
1374
|
-
paginationParams: cursor ? { cursor, pageSize } : jumpToPage ? { jumpToPage, pageSize } : { pageSize },
|
|
1407
|
+
paginationParams: cursor ? { cursor, pageSize } : jumpToPage !== undefined ? { jumpToPage, pageSize } : { pageSize },
|
|
1375
1408
|
additionalParams: prefixedOptions,
|
|
1409
|
+
queryParams: config.queryParams,
|
|
1376
1410
|
transformFn: config.transformFn,
|
|
1377
1411
|
method: config.method,
|
|
1378
1412
|
options: {
|
|
@@ -1390,6 +1424,7 @@ class PaginationHelpers {
|
|
|
1390
1424
|
folderId,
|
|
1391
1425
|
headers: config.headers,
|
|
1392
1426
|
additionalParams: prefixedOptions,
|
|
1427
|
+
queryParams: config.queryParams,
|
|
1393
1428
|
transformFn: config.transformFn,
|
|
1394
1429
|
method: config.method,
|
|
1395
1430
|
options: {
|
|
@@ -1581,18 +1616,17 @@ class BaseService {
|
|
|
1581
1616
|
const params = this.validateAndPreparePaginationParams(paginationType, paginationOptions);
|
|
1582
1617
|
// Prepare request parameters based on pagination type
|
|
1583
1618
|
const requestParams = this.preparePaginationRequestParams(paginationType, params, options.pagination);
|
|
1584
|
-
//
|
|
1619
|
+
// Route pagination state to wherever the API expects it (body for POST, URL for GET).
|
|
1620
|
+
// Caller-supplied options.body / options.params are respected as-is — the api-client
|
|
1621
|
+
// already handles params (URL) and body (request body) independently for every method.
|
|
1585
1622
|
if (method.toUpperCase() === 'POST') {
|
|
1586
1623
|
const existingBody = (options.body && typeof options.body === 'object') ? options.body : {};
|
|
1587
1624
|
options.body = {
|
|
1588
1625
|
...existingBody,
|
|
1589
|
-
...options.params,
|
|
1590
1626
|
...requestParams
|
|
1591
1627
|
};
|
|
1592
|
-
options.params = undefined;
|
|
1593
1628
|
}
|
|
1594
1629
|
else {
|
|
1595
|
-
// Merge pagination parameters with existing parameters
|
|
1596
1630
|
options.params = {
|
|
1597
1631
|
...options.params,
|
|
1598
1632
|
...requestParams
|
|
@@ -1629,6 +1663,8 @@ class BaseService {
|
|
|
1629
1663
|
// When true (default), converts pageNumber to a skip/offset value (e.g., page 3 with pageSize 10 → skip 20).
|
|
1630
1664
|
// When false, passes pageNumber directly as the offset param — used by APIs that accept a page number instead of a record offset.
|
|
1631
1665
|
const convertToSkip = paginationParams?.convertToSkip ?? true;
|
|
1666
|
+
// When true, sends pageNumber - 1 (for 0-based APIs). Default false (1-based).
|
|
1667
|
+
const zeroBased = paginationParams?.zeroBased ?? false;
|
|
1632
1668
|
requestParams[pageSizeParam] = limitedPageSize;
|
|
1633
1669
|
if (convertToSkip) {
|
|
1634
1670
|
if (params.pageNumber && params.pageNumber > 1) {
|
|
@@ -1636,7 +1672,8 @@ class BaseService {
|
|
|
1636
1672
|
}
|
|
1637
1673
|
}
|
|
1638
1674
|
else {
|
|
1639
|
-
|
|
1675
|
+
const sdkPageNumber = params.pageNumber || 1;
|
|
1676
|
+
requestParams[offsetParam] = zeroBased ? sdkPageNumber - 1 : sdkPageNumber;
|
|
1640
1677
|
}
|
|
1641
1678
|
{
|
|
1642
1679
|
requestParams[countParam] = true;
|
|
@@ -1665,8 +1702,9 @@ class BaseService {
|
|
|
1665
1702
|
const totalCountField = fields.totalCountField || 'totalRecordCount';
|
|
1666
1703
|
const continuationTokenField = fields.continuationTokenField || 'continuationToken';
|
|
1667
1704
|
// Extract items and metadata
|
|
1668
|
-
// Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N })
|
|
1669
|
-
|
|
1705
|
+
// Handle both plain array responses and envelope responses ({ value: [...], totalRecordCount: N }).
|
|
1706
|
+
// itemsField may be a dotted path (e.g. 'data.agents') for nested envelopes.
|
|
1707
|
+
const items = Array.isArray(response.data) ? response.data : (resolveNestedField(response.data, itemsField) || []);
|
|
1670
1708
|
const rawTotalCount = Array.isArray(response.data) ? undefined : resolveNestedField(response.data, totalCountField);
|
|
1671
1709
|
const totalCount = typeof rawTotalCount === 'number' ? rawTotalCount : undefined;
|
|
1672
1710
|
const continuationToken = response.data[continuationTokenField];
|
|
@@ -2101,48 +2139,32 @@ class BucketService extends FolderScopedService {
|
|
|
2101
2139
|
}
|
|
2102
2140
|
}, options);
|
|
2103
2141
|
}
|
|
2104
|
-
|
|
2105
|
-
* Gets metadata for files in a bucket with optional filtering and pagination
|
|
2106
|
-
*
|
|
2107
|
-
* The method returns either:
|
|
2108
|
-
* - A NonPaginatedResponse with items array (when no pagination parameters are provided)
|
|
2109
|
-
* - A PaginatedResponse with navigation cursors (when any pagination parameter is provided)
|
|
2110
|
-
*
|
|
2111
|
-
* @param bucketId - The ID of the bucket to get file metadata from
|
|
2112
|
-
* @param folderId - Required folder ID for organization unit context
|
|
2113
|
-
* @param options - Optional parameters for filtering, pagination and access URL generation
|
|
2114
|
-
* @returns Promise resolving to the list of file metadata in the bucket or paginated result
|
|
2115
|
-
*
|
|
2116
|
-
* @example
|
|
2117
|
-
* ```typescript
|
|
2118
|
-
* import { Buckets } from '@uipath/uipath-typescript/buckets';
|
|
2119
|
-
*
|
|
2120
|
-
* const buckets = new Buckets(sdk);
|
|
2121
|
-
*
|
|
2122
|
-
* // Get metadata for all files in a bucket
|
|
2123
|
-
* const fileMetadata = await buckets.getFileMetaData(123, 456);
|
|
2124
|
-
*
|
|
2125
|
-
* // Get file metadata with a specific prefix
|
|
2126
|
-
* const fileMetadata = await buckets.getFileMetaData(123, 456, {
|
|
2127
|
-
* prefix: '/folder1'
|
|
2128
|
-
* });
|
|
2129
|
-
*
|
|
2130
|
-
* // First page with pagination
|
|
2131
|
-
* const page1 = await buckets.getFileMetaData(123, 456, { pageSize: 10 });
|
|
2132
|
-
*
|
|
2133
|
-
* // Navigate using cursor
|
|
2134
|
-
* if (page1.hasNextPage) {
|
|
2135
|
-
* const page2 = await buckets.getFileMetaData(123, 456, { cursor: page1.nextCursor });
|
|
2136
|
-
* }
|
|
2137
|
-
* ```
|
|
2138
|
-
*/
|
|
2139
|
-
async getFileMetaData(bucketId, folderId, options) {
|
|
2142
|
+
async getFileMetaData(bucketId, optionsOrFolderId, legacyOptions) {
|
|
2140
2143
|
if (!bucketId) {
|
|
2141
2144
|
throw new ValidationError({ message: 'bucketId is required for getFileMetaData' });
|
|
2142
2145
|
}
|
|
2143
|
-
|
|
2144
|
-
|
|
2146
|
+
// Normalize the two overload forms into a single internal shape.
|
|
2147
|
+
let folderId;
|
|
2148
|
+
let folderKey;
|
|
2149
|
+
let folderPath;
|
|
2150
|
+
let restOptions;
|
|
2151
|
+
if (typeof optionsOrFolderId === 'number') {
|
|
2152
|
+
// Deprecated positional form: getFileMetaData(bucketId, folderId, options?)
|
|
2153
|
+
folderId = optionsOrFolderId;
|
|
2154
|
+
restOptions = (legacyOptions ?? {});
|
|
2155
|
+
}
|
|
2156
|
+
else {
|
|
2157
|
+
// Preferred form: getFileMetaData(bucketId, options?)
|
|
2158
|
+
const opts = optionsOrFolderId ?? {};
|
|
2159
|
+
({ folderId, folderKey, folderPath, ...restOptions } = opts);
|
|
2145
2160
|
}
|
|
2161
|
+
const headers = resolveFolderHeaders({
|
|
2162
|
+
folderId,
|
|
2163
|
+
folderKey,
|
|
2164
|
+
folderPath,
|
|
2165
|
+
resourceType: 'Buckets.getFileMetaData',
|
|
2166
|
+
fallbackFolderKey: this.config.folderKey,
|
|
2167
|
+
});
|
|
2146
2168
|
// Transformation function for blob items
|
|
2147
2169
|
const transformBlobItem = (item) => transformData(item, BucketMap);
|
|
2148
2170
|
return PaginationHelpers.getAll({
|
|
@@ -2158,93 +2180,97 @@ class BucketService extends FolderScopedService {
|
|
|
2158
2180
|
tokenParam: BUCKET_TOKEN_PARAMS.TOKEN_PARAM
|
|
2159
2181
|
}
|
|
2160
2182
|
},
|
|
2161
|
-
excludeFromPrefix: ['prefix'] // Bucket-specific param, not OData
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
* // In Node env with Buffer
|
|
2186
|
-
* const buffer = Buffer.from('file content');
|
|
2187
|
-
* const result = await buckets.uploadFile({
|
|
2188
|
-
* bucketId: 123,
|
|
2189
|
-
* folderId: 456,
|
|
2190
|
-
* path: '/folder/example.txt',
|
|
2191
|
-
* content: buffer
|
|
2192
|
-
* });
|
|
2193
|
-
* ```
|
|
2194
|
-
*/
|
|
2195
|
-
async uploadFile(options) {
|
|
2196
|
-
const { bucketId, folderId, path, content } = options;
|
|
2183
|
+
excludeFromPrefix: ['prefix'], // Bucket-specific param, not OData
|
|
2184
|
+
headers,
|
|
2185
|
+
}, restOptions);
|
|
2186
|
+
}
|
|
2187
|
+
async uploadFile(bucketIdOrOptions, path, content, options) {
|
|
2188
|
+
// Normalize the two overload forms into a single internal shape.
|
|
2189
|
+
let bucketId;
|
|
2190
|
+
let resolvedPath;
|
|
2191
|
+
let resolvedContent;
|
|
2192
|
+
let folderId;
|
|
2193
|
+
let folderKey;
|
|
2194
|
+
let folderPath;
|
|
2195
|
+
if (bucketIdOrOptions !== null && typeof bucketIdOrOptions === 'object') {
|
|
2196
|
+
// Deprecated options-only form: uploadFile({ bucketId, path, content, ... })
|
|
2197
|
+
({ bucketId, path: resolvedPath, content: resolvedContent, folderId, folderKey, folderPath } = bucketIdOrOptions);
|
|
2198
|
+
}
|
|
2199
|
+
else {
|
|
2200
|
+
// Preferred positional form: uploadFile(bucketId, path, content, options?)
|
|
2201
|
+
bucketId = bucketIdOrOptions;
|
|
2202
|
+
resolvedPath = path;
|
|
2203
|
+
resolvedContent = content;
|
|
2204
|
+
const opts = options ?? {};
|
|
2205
|
+
({ folderId, folderKey, folderPath } = opts);
|
|
2206
|
+
}
|
|
2197
2207
|
if (!bucketId) {
|
|
2198
2208
|
throw new ValidationError({ message: 'bucketId is required for uploadFile' });
|
|
2199
2209
|
}
|
|
2200
|
-
if (!
|
|
2201
|
-
throw new ValidationError({ message: 'folderId is required for uploadFile' });
|
|
2202
|
-
}
|
|
2203
|
-
if (!path) {
|
|
2210
|
+
if (!resolvedPath) {
|
|
2204
2211
|
throw new ValidationError({ message: 'path is required for uploadFile' });
|
|
2205
2212
|
}
|
|
2206
|
-
if (!
|
|
2213
|
+
if (!resolvedContent) {
|
|
2207
2214
|
throw new ValidationError({ message: 'content is required for uploadFile' });
|
|
2208
2215
|
}
|
|
2216
|
+
const headers = resolveFolderHeaders({
|
|
2217
|
+
folderId,
|
|
2218
|
+
folderKey,
|
|
2219
|
+
folderPath,
|
|
2220
|
+
resourceType: 'Buckets.uploadFile',
|
|
2221
|
+
fallbackFolderKey: this.config.folderKey,
|
|
2222
|
+
});
|
|
2209
2223
|
const uriResponse = await this._getWriteUri({
|
|
2210
2224
|
bucketId,
|
|
2211
|
-
|
|
2212
|
-
|
|
2225
|
+
path: resolvedPath,
|
|
2226
|
+
headers,
|
|
2213
2227
|
});
|
|
2214
2228
|
// Upload file to the provided URI
|
|
2215
|
-
const response = await this._uploadToUri(uriResponse,
|
|
2229
|
+
const response = await this._uploadToUri(uriResponse, resolvedContent);
|
|
2216
2230
|
return {
|
|
2217
2231
|
success: response.status >= 200 && response.status < 300,
|
|
2218
2232
|
statusCode: response.status
|
|
2219
2233
|
};
|
|
2220
2234
|
}
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2235
|
+
async getReadUri(bucketIdOrOptions, path, options) {
|
|
2236
|
+
// Normalize the two overload forms into a single internal shape.
|
|
2237
|
+
let bucketId;
|
|
2238
|
+
let resolvedPath;
|
|
2239
|
+
let folderId;
|
|
2240
|
+
let folderKey;
|
|
2241
|
+
let folderPath;
|
|
2242
|
+
let expiryInMinutes;
|
|
2243
|
+
let restOptions;
|
|
2244
|
+
if (bucketIdOrOptions !== null && typeof bucketIdOrOptions === 'object') {
|
|
2245
|
+
// Deprecated options-only form: getReadUri({ bucketId, path, ... })
|
|
2246
|
+
const { bucketId: bid, path: p, expiryInMinutes: e, folderId: fid, folderKey: fkey, folderPath: fpath, ...rest } = bucketIdOrOptions;
|
|
2247
|
+
bucketId = bid;
|
|
2248
|
+
resolvedPath = p;
|
|
2249
|
+
expiryInMinutes = e;
|
|
2250
|
+
folderId = fid;
|
|
2251
|
+
folderKey = fkey;
|
|
2252
|
+
folderPath = fpath;
|
|
2253
|
+
restOptions = rest;
|
|
2254
|
+
}
|
|
2255
|
+
else {
|
|
2256
|
+
// Preferred positional form: getReadUri(bucketId, path, options?)
|
|
2257
|
+
bucketId = bucketIdOrOptions;
|
|
2258
|
+
resolvedPath = path;
|
|
2259
|
+
const opts = options ?? {};
|
|
2260
|
+
({ expiryInMinutes, folderId, folderKey, folderPath, ...restOptions } = opts);
|
|
2261
|
+
}
|
|
2262
|
+
const headers = resolveFolderHeaders({
|
|
2263
|
+
folderId,
|
|
2264
|
+
folderKey,
|
|
2265
|
+
folderPath,
|
|
2266
|
+
resourceType: 'Buckets.getReadUri',
|
|
2267
|
+
fallbackFolderKey: this.config.folderKey,
|
|
2268
|
+
});
|
|
2243
2269
|
const queryOptions = {
|
|
2244
2270
|
expiryInMinutes,
|
|
2245
2271
|
...addPrefixToKeys(restOptions, ODATA_PREFIX, Object.keys(restOptions))
|
|
2246
2272
|
};
|
|
2247
|
-
return this._getUri(BUCKET_ENDPOINTS.GET_READ_URI(bucketId), bucketId,
|
|
2273
|
+
return this._getUri(BUCKET_ENDPOINTS.GET_READ_URI(bucketId), bucketId, resolvedPath, headers, queryOptions);
|
|
2248
2274
|
}
|
|
2249
2275
|
/**
|
|
2250
2276
|
* Uploads content to the provided URI
|
|
@@ -2274,23 +2300,18 @@ class BucketService extends FolderScopedService {
|
|
|
2274
2300
|
* Private method to handle common URI request logic
|
|
2275
2301
|
* @param endpoint - The API endpoint to call
|
|
2276
2302
|
* @param bucketId - The bucket ID
|
|
2277
|
-
* @param folderId - The folder ID
|
|
2278
2303
|
* @param path - The file path
|
|
2304
|
+
* @param headers - Pre-built folder-context headers (built via `resolveFolderHeaders`)
|
|
2279
2305
|
* @param queryOptions - Additional query parameters
|
|
2280
2306
|
* @returns Promise resolving to blob file access information
|
|
2281
2307
|
*/
|
|
2282
|
-
async _getUri(endpoint, bucketId,
|
|
2308
|
+
async _getUri(endpoint, bucketId, path, headers, queryOptions = {}) {
|
|
2283
2309
|
if (!bucketId) {
|
|
2284
2310
|
throw new ValidationError({ message: 'bucketId is required for getUri' });
|
|
2285
2311
|
}
|
|
2286
|
-
if (!folderId) {
|
|
2287
|
-
throw new ValidationError({ message: 'folderId is required for getUri' });
|
|
2288
|
-
}
|
|
2289
2312
|
if (!path) {
|
|
2290
2313
|
throw new ValidationError({ message: 'path is required for getUri' });
|
|
2291
2314
|
}
|
|
2292
|
-
// Create headers with required folder ID
|
|
2293
|
-
const headers = createHeaders({ [FOLDER_ID]: folderId });
|
|
2294
2315
|
// Filter out undefined values and build query params
|
|
2295
2316
|
const queryParams = filterUndefined({
|
|
2296
2317
|
path,
|
|
@@ -2425,16 +2446,16 @@ class BucketService extends FolderScopedService {
|
|
|
2425
2446
|
/**
|
|
2426
2447
|
* Gets a direct upload URL for a file in the bucket
|
|
2427
2448
|
*
|
|
2428
|
-
* @param options - Contains bucketId,
|
|
2449
|
+
* @param options - Contains bucketId, file path, optional expiry time, and pre-built folder-context headers
|
|
2429
2450
|
* @returns Promise resolving to blob file access information
|
|
2430
2451
|
*/
|
|
2431
2452
|
async _getWriteUri(options) {
|
|
2432
|
-
const { bucketId,
|
|
2453
|
+
const { bucketId, path, expiryInMinutes, headers, ...restOptions } = options;
|
|
2433
2454
|
const queryOptions = {
|
|
2434
2455
|
expiryInMinutes,
|
|
2435
2456
|
...addPrefixToKeys(restOptions, ODATA_PREFIX, Object.keys(restOptions))
|
|
2436
2457
|
};
|
|
2437
|
-
return this._getUri(BUCKET_ENDPOINTS.GET_WRITE_URI(bucketId), bucketId,
|
|
2458
|
+
return this._getUri(BUCKET_ENDPOINTS.GET_WRITE_URI(bucketId), bucketId, path, headers, queryOptions);
|
|
2438
2459
|
}
|
|
2439
2460
|
}
|
|
2440
2461
|
__decorate([
|