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