@cloudbase/manager-node 5.8.7-beta.0 → 5.8.8-beta.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/lib/env/index.js +9 -28
- package/lib/hosting/index.js +53 -32
- package/lib/storage/index.js +135 -99
- package/lib/utils/storage-config.js +73 -0
- package/package.json +1 -1
- package/types/env/index.d.ts +7 -16
- package/types/env/type.d.ts +0 -56
- package/types/hosting/index.d.ts +8 -1
- package/types/interfaces/tcb.interface.d.ts +1 -0
- package/types/storage/index.d.ts +20 -2
- package/types/storage/type.d.ts +2 -0
- package/types/utils/storage-config.d.ts +36 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toPhysicalKey = toPhysicalKey;
|
|
4
|
+
exports.toLogicalPath = toLogicalPath;
|
|
5
|
+
exports.resolveStorageConfig = resolveStorageConfig;
|
|
6
|
+
exports.resolveBucketConfig = resolveBucketConfig;
|
|
7
|
+
const error_1 = require("../error");
|
|
8
|
+
function trimSlashes(p) {
|
|
9
|
+
return p.replace(/^\/+|\/+$/g, '');
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* 逻辑路径 → COS 物理 Key:共享桶环境拼上 basePath 前缀,basePath 为空时原样返回
|
|
13
|
+
* cloudPath 为空或为 '/' 时返回 `${basePath}/`,即共享桶内本环境的根目录
|
|
14
|
+
*/
|
|
15
|
+
function toPhysicalKey(basePath, cloudPath = '') {
|
|
16
|
+
const base = trimSlashes(basePath || '');
|
|
17
|
+
if (!base) {
|
|
18
|
+
return cloudPath;
|
|
19
|
+
}
|
|
20
|
+
return `${base}/${cloudPath.replace(/^\/+/, '')}`;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* COS 物理 Key → 逻辑路径:去掉 basePath 前缀,basePath 为空或 Key 不在前缀下时原样返回
|
|
24
|
+
*/
|
|
25
|
+
function toLogicalPath(basePath, key) {
|
|
26
|
+
const base = trimSlashes(basePath || '');
|
|
27
|
+
const prefix = `${base}/`;
|
|
28
|
+
if (!base || !key || !key.startsWith(prefix)) {
|
|
29
|
+
return key;
|
|
30
|
+
}
|
|
31
|
+
return key.slice(prefix.length);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* 解析环境的有效云存储配置
|
|
35
|
+
* 共享桶环境(Storages[0].Bucket 为空且 ExternalStorage.Enabled 为 true)下,桶名、地域、BasePath 从 ExternalStorage 读取;
|
|
36
|
+
* 普通环境保持读取 Storages[0].Bucket / Region,basePath 为空串
|
|
37
|
+
*/
|
|
38
|
+
function resolveStorageConfig(envConfig) {
|
|
39
|
+
var _a;
|
|
40
|
+
// 环境信息由带 @preLazy 的方法首次调用时加载,直接调用 getStorageConfig 可能早于加载
|
|
41
|
+
if (!envConfig) {
|
|
42
|
+
throw new error_1.CloudBaseError('环境信息尚未加载,无法获取存储配置,请先调用任一存储方法(如 listDirectoryFiles)或 environment.lazyInit() 完成初始化');
|
|
43
|
+
}
|
|
44
|
+
const storage = (_a = envConfig.Storages) === null || _a === void 0 ? void 0 : _a[0];
|
|
45
|
+
if (!storage) {
|
|
46
|
+
throw new error_1.CloudBaseError(`环境 ${envConfig === null || envConfig === void 0 ? void 0 : envConfig.EnvId} 未查询到云存储资源(Storages 为空),请确认环境 ID 正确且环境已开通云存储`);
|
|
47
|
+
}
|
|
48
|
+
return Object.assign({ env: envConfig.EnvId }, resolveBucketConfig({
|
|
49
|
+
envId: envConfig.EnvId,
|
|
50
|
+
bucket: storage.Bucket,
|
|
51
|
+
region: storage.Region,
|
|
52
|
+
externalStorage: storage.ExternalStorage
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* 按共享桶规则解析有效桶,云存储(Storages)与静态托管(DescribeStaticStore)共用
|
|
57
|
+
* bucket 为空且 externalStorage.Enabled 为 true 时使用 ExternalStorage,否则使用环境自有桶,basePath 为空串
|
|
58
|
+
*/
|
|
59
|
+
function resolveBucketConfig(options) {
|
|
60
|
+
const { envId, bucket, region, externalStorage } = options;
|
|
61
|
+
if (!bucket && (externalStorage === null || externalStorage === void 0 ? void 0 : externalStorage.Enabled) === true) {
|
|
62
|
+
// 线上存在已启用外部存储但未返回桶名的环境,继续执行会在 COS 调用时报 missing param Bucket
|
|
63
|
+
if (!externalStorage.BucketName) {
|
|
64
|
+
throw new error_1.CloudBaseError(`环境 ${envId} 已启用外部存储(ExternalStorage),但未返回存储桶名称(BucketName),无法访问存储桶,请联系平台检查该环境的共享桶配置`);
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
bucket: externalStorage.BucketName,
|
|
68
|
+
region: externalStorage.Region,
|
|
69
|
+
basePath: externalStorage.BasePath || ''
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
return { bucket, region, basePath: '' };
|
|
73
|
+
}
|
package/package.json
CHANGED
package/types/env/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Environment } from '../environment';
|
|
2
2
|
import { IResponseInfo, AuthDomain, EnvInfo, LoginConfigItem, ICheckTcbServiceRes, ICreatePostpayRes, EnvBillingInfoItem, PriceResult } from '../interfaces';
|
|
3
|
-
import { CalculatePackageCreatePriceParams, CalculatePackageRenewPriceParams, CalculatePackageModifyPriceParams, DescribeHttpServiceRouteParams, DescribeHttpServiceRouteRes, VerifyHttpServiceRouteParams, VerifyHttpServiceRouteRes, CreateHttpServiceRouteParams, CreateHttpServiceRouteRes, ModifyHttpServiceRouteParams, ModifyHttpServiceRouteRes, DeleteHttpServiceRouteParams, DeleteHttpServiceRouteRes,
|
|
3
|
+
import { CalculatePackageCreatePriceParams, CalculatePackageRenewPriceParams, CalculatePackageModifyPriceParams, DescribeHttpServiceRouteParams, DescribeHttpServiceRouteRes, VerifyHttpServiceRouteParams, VerifyHttpServiceRouteRes, CreateHttpServiceRouteParams, CreateHttpServiceRouteRes, ModifyHttpServiceRouteParams, ModifyHttpServiceRouteRes, DeleteHttpServiceRouteParams, DeleteHttpServiceRouteRes, BindCustomDomainParams, BindCustomDomainRes, DeleteCustomDomainParams, DeleteCustomDomainRes, DescribeCertificatesParams, DescribeCertificatesRes } from './type';
|
|
4
4
|
import { CreateBillingDealParams, CreateEnvParams, BaasPackageInfo, DescribeBaasPackageListParams, ModifyEnvPlanParams, RenewEnvParams, DestroyEnvParams, DescribeEnvsParams, DescribeEnvInfoParams, DescribeEnvInfoResponse, DescribeEnvAccountCircleParams, DescribeEnvAccountCircleRes, DescribeCreditsUsageDetailParams, EnvPkgCreditsUsage } from '../interfaces/tcb.interface';
|
|
5
5
|
type SOURCE = 'miniapp' | 'qcloud';
|
|
6
6
|
interface IDeleteDomainRes {
|
|
@@ -864,8 +864,14 @@ export declare class EnvService {
|
|
|
864
864
|
*/
|
|
865
865
|
describeBillingInfo(params: {
|
|
866
866
|
EnvId?: string;
|
|
867
|
+
/** 分页条数 */
|
|
868
|
+
Limit?: number;
|
|
869
|
+
/** 分页偏移 */
|
|
870
|
+
Offset?: number;
|
|
867
871
|
}): Promise<{
|
|
868
872
|
EnvBillingInfoList: EnvBillingInfoItem[];
|
|
873
|
+
/** 环境总数(实测与实际可翻页的条数不一致,不宜直接作为总数展示) */
|
|
874
|
+
Total?: number;
|
|
869
875
|
RequestId: string;
|
|
870
876
|
}>;
|
|
871
877
|
/**
|
|
@@ -922,21 +928,6 @@ export declare class EnvService {
|
|
|
922
928
|
* @returns {Promise<DeleteHttpServiceRouteRes>}
|
|
923
929
|
*/
|
|
924
930
|
deleteHttpServiceRoute(params: DeleteHttpServiceRouteParams): Promise<DeleteHttpServiceRouteRes>;
|
|
925
|
-
/**
|
|
926
|
-
* 清除HTTP访问服务域名缓存
|
|
927
|
-
* 支持 CDN 和 EO 两种缓存类型。CDN 仅支持 PURGE_URL 刷新方式;PURGE_PREFIX / PURGE_HOST 仅 EO 支持
|
|
928
|
-
* 清除缓存后会生成任务ID,可通过 DescribeHTTPServiceCachePurgeTask 查询任务进度和详细信息
|
|
929
|
-
* @param {PurgeHttpServiceCacheParams} params 清除缓存参数
|
|
930
|
-
* @returns {Promise<PurgeHttpServiceCacheRes>}
|
|
931
|
-
*/
|
|
932
|
-
purgeHttpServiceCache(params: PurgeHttpServiceCacheParams): Promise<PurgeHttpServiceCacheRes>;
|
|
933
|
-
/**
|
|
934
|
-
* 查询HTTP访问服务域名缓存清除任务详情
|
|
935
|
-
* 通过 purgeHttpServiceCache 清除域名缓存后,可传入任务ID查询清除任务状态、时间、缓存类型等信息;也可不传任务ID查询历史任务记录
|
|
936
|
-
* @param {DescribeHttpServiceCachePurgeTaskParams} params 查询参数
|
|
937
|
-
* @returns {Promise<DescribeHttpServiceCachePurgeTaskRes>}
|
|
938
|
-
*/
|
|
939
|
-
describeHttpServiceCachePurgeTask(params: DescribeHttpServiceCachePurgeTaskParams): Promise<DescribeHttpServiceCachePurgeTaskRes>;
|
|
940
931
|
/**
|
|
941
932
|
* 绑定自定义域名到HTTP访问服务
|
|
942
933
|
* 底层调用 CreateHTTPServiceRoute API,专用于域名绑定场景
|
package/types/env/type.d.ts
CHANGED
|
@@ -414,62 +414,6 @@ export interface DeleteHttpServiceRouteParams {
|
|
|
414
414
|
export interface DeleteHttpServiceRouteRes {
|
|
415
415
|
RequestId: string;
|
|
416
416
|
}
|
|
417
|
-
/**
|
|
418
|
-
* PurgeHTTPServiceCache 请求参数
|
|
419
|
-
* 用于清除HTTP访问服务域名缓存,支持 CDN 和 EO 两种缓存类型
|
|
420
|
-
*/
|
|
421
|
-
export interface PurgeHttpServiceCacheParams {
|
|
422
|
-
EnvId: string;
|
|
423
|
-
Domain: string;
|
|
424
|
-
CacheType: 'CDN' | 'EO';
|
|
425
|
-
PurgeType: 'PURGE_URL' | 'PURGE_PREFIX' | 'PURGE_HOST';
|
|
426
|
-
Targets: string[];
|
|
427
|
-
}
|
|
428
|
-
/**
|
|
429
|
-
* PurgeHTTPServiceCache 返回结果
|
|
430
|
-
*/
|
|
431
|
-
export interface PurgeHttpServiceCacheRes {
|
|
432
|
-
CacheType: 'CDN' | 'EO';
|
|
433
|
-
TaskId: string;
|
|
434
|
-
RequestId: string;
|
|
435
|
-
}
|
|
436
|
-
/**
|
|
437
|
-
* 缓存清除任务详情
|
|
438
|
-
*/
|
|
439
|
-
export interface HTTPServiceCachePurgeTask {
|
|
440
|
-
TaskId: string;
|
|
441
|
-
CacheType: 'CDN' | 'EO';
|
|
442
|
-
Status: 'PROCESSING' | 'SUCCESS' | 'FAILED' | 'TIMEOUT' | 'CANCELED';
|
|
443
|
-
PurgeType: 'PURGE_URL' | 'PURGE_PREFIX' | 'PURGE_HOST';
|
|
444
|
-
Method: 'INVALIDATE' | 'DELETE';
|
|
445
|
-
Targets: string[];
|
|
446
|
-
FailReason?: string;
|
|
447
|
-
CreateTime: string;
|
|
448
|
-
UpdateTime: string;
|
|
449
|
-
}
|
|
450
|
-
/**
|
|
451
|
-
* DescribeHTTPServiceCachePurgeTask 请求参数
|
|
452
|
-
* 用于查询HTTPService域名缓存清除任务详情
|
|
453
|
-
*/
|
|
454
|
-
export interface DescribeHttpServiceCachePurgeTaskParams {
|
|
455
|
-
EnvId: string;
|
|
456
|
-
Domain: string;
|
|
457
|
-
CacheType: 'CDN' | 'EO';
|
|
458
|
-
TaskId?: string;
|
|
459
|
-
PurgeType?: 'PURGE_URL' | 'PURGE_PREFIX' | 'PURGE_HOST';
|
|
460
|
-
StartTime?: string;
|
|
461
|
-
EndTime?: string;
|
|
462
|
-
Offset?: number;
|
|
463
|
-
Limit?: number;
|
|
464
|
-
}
|
|
465
|
-
/**
|
|
466
|
-
* DescribeHTTPServiceCachePurgeTask 返回结果
|
|
467
|
-
*/
|
|
468
|
-
export interface DescribeHttpServiceCachePurgeTaskRes {
|
|
469
|
-
Tasks: HTTPServiceCachePurgeTask[];
|
|
470
|
-
TotalCount: number;
|
|
471
|
-
RequestId: string;
|
|
472
|
-
}
|
|
473
417
|
/**
|
|
474
418
|
* 绑定自定义域名的域名参数
|
|
475
419
|
* 与 HTTPServiceDomainParam 类似,但不包含 Routes(绑定域名场景)
|
package/types/hosting/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Environment } from '../environment';
|
|
2
|
-
import { IListFileInfo } from '../interfaces';
|
|
2
|
+
import { ExternalStorage, IListFileInfo } from '../interfaces';
|
|
3
3
|
export interface IProgressData {
|
|
4
4
|
loaded: number;
|
|
5
5
|
total: number;
|
|
@@ -116,10 +116,12 @@ export interface IHostingInfo {
|
|
|
116
116
|
CdnDomain: string;
|
|
117
117
|
Bucket: string;
|
|
118
118
|
Regoin: string;
|
|
119
|
+
Region?: string;
|
|
119
120
|
Status: string;
|
|
120
121
|
MaxDomain: number;
|
|
121
122
|
Id: number;
|
|
122
123
|
PolicyId: number;
|
|
124
|
+
ExternalStorage?: ExternalStorage;
|
|
123
125
|
}
|
|
124
126
|
export interface IRoutingRules {
|
|
125
127
|
keyPrefixEquals?: string;
|
|
@@ -261,6 +263,11 @@ export declare class HostingService {
|
|
|
261
263
|
* 检查 hosting 服务状态
|
|
262
264
|
*/
|
|
263
265
|
private checkStatus;
|
|
266
|
+
/**
|
|
267
|
+
* 检查 hosting 服务状态并解析有效桶,兼容共享桶(ExternalStorage)环境
|
|
268
|
+
* 静态托管的共享桶与 BasePath 独立于云存储,不能复用 StorageService.getStorageConfig
|
|
269
|
+
*/
|
|
270
|
+
private getHostingBucket;
|
|
264
271
|
/**
|
|
265
272
|
* 获取配置
|
|
266
273
|
*/
|
package/types/storage/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Environment } from '../environment';
|
|
2
2
|
import { IUploadMetadata, IListFileInfo, IFileInfo, ITempUrlInfo, IResponseInfo } from '../interfaces';
|
|
3
|
+
import { IStorageConfig } from '../utils/storage-config';
|
|
3
4
|
import { IUploadObjectHttpOptions, IUploadObjectHttpResult, IDeleteObjectHttpOptions, IDeleteObjectHttpResult, IDeleteObjectsHttpOptions, IDeletedObjectInfo, ICopyObjectHttpOptions, ICopyObjectHttpResult, IMoveObjectHttpOptions, IMoveObjectHttpResult, IListObjectsHttpOptions, IListObjectsHttpResult, ISignObjectHttpOptions, ISignObjectHttpResult, ISignObjectsHttpOptions, ISignObjectsHttpResult, ISignUploadObjectHttpOptions, ISignUploadObjectHttpResult, IUploadObjectBySignHttpOptions, IUploadObjectBySignHttpResult, IDownloadAuthenticatedObjectHttpOptions, IDownloadObjectHttpOptions, IDownloadPublicObjectHttpOptions, IDownloadObjectBySignHttpOptions, IDownloadObjectHttpResult, IGetObjectInfoAuthenticatedHttpOptions, IGetObjectInfoPublicHttpOptions, IGetObjectInfoHttpResult, IConsistentUploadOptions, IConsistentUploadResult, ILocalManifestItem, IManifestDiffResult, IManifestVerifyResult, IPruneResult, IRemoteManifestItem } from './type';
|
|
4
5
|
export interface IProgressData {
|
|
5
6
|
loaded: number;
|
|
@@ -34,12 +35,19 @@ export interface IFilesOptions extends IOptions {
|
|
|
34
35
|
export interface ICustomOptions {
|
|
35
36
|
bucket: string;
|
|
36
37
|
region: string;
|
|
38
|
+
/**
|
|
39
|
+
* 共享桶(ExternalStorage)内的目录前缀。*Custom 方法不会自动读取环境的 BasePath,
|
|
40
|
+
* 未传时按 COS 原始 Key 处理;传入后入参按逻辑路径处理,返回的 Key 映射回逻辑路径
|
|
41
|
+
*/
|
|
42
|
+
basePath?: string;
|
|
37
43
|
}
|
|
38
44
|
export interface IWalkCloudDirOptions {
|
|
39
45
|
prefix: string;
|
|
40
46
|
bucket: string;
|
|
41
47
|
region: string;
|
|
42
48
|
marker?: string;
|
|
49
|
+
/** 同 ICustomOptions.basePath */
|
|
50
|
+
basePath?: string;
|
|
43
51
|
}
|
|
44
52
|
export interface IGetRemoteManifestOptions extends ICustomOptions {
|
|
45
53
|
/** 云端前缀,无前导斜杠(如 'dist');空串表示整桶 */
|
|
@@ -104,6 +112,8 @@ export interface IGetBucketOpions {
|
|
|
104
112
|
prefix?: string;
|
|
105
113
|
marker?: string;
|
|
106
114
|
maxKeys?: number;
|
|
115
|
+
/** 同 ICustomOptions.basePath:传入后 prefix / marker 按逻辑路径处理,返回的 Contents.Key、NextMarker 映射回逻辑路径 */
|
|
116
|
+
basePath?: string;
|
|
107
117
|
}
|
|
108
118
|
export type AclType = 'READONLY' | 'PRIVATE' | 'ADMINWRITE' | 'ADMINONLY' | 'CUSTOM';
|
|
109
119
|
export interface IStorageAclRule {
|
|
@@ -202,6 +212,7 @@ export declare class StorageService {
|
|
|
202
212
|
getRemoteManifest(prefix: string): Promise<IRemoteManifestItem[]>;
|
|
203
213
|
/**
|
|
204
214
|
* 获取远端 manifest,支持自定义 Bucket 和 Region。prefix 规则同 getRemoteManifest。
|
|
215
|
+
* 不会自动拼接环境的共享桶 BasePath,需要时显式传入 basePath
|
|
205
216
|
*/
|
|
206
217
|
getRemoteManifestCustom(options: IGetRemoteManifestOptions): Promise<IRemoteManifestItem[]>;
|
|
207
218
|
/**
|
|
@@ -291,6 +302,7 @@ export declare class StorageService {
|
|
|
291
302
|
uploadFiles(options: IFilesOptions): Promise<void>;
|
|
292
303
|
/**
|
|
293
304
|
* 上传文件,支持自定义 Bucket 和 Region
|
|
305
|
+
* 不会自动拼接环境的共享桶 BasePath,需要时显式传入 basePath;fileId 始终按逻辑路径 cloudPath 获取
|
|
294
306
|
* @param {string} localPath
|
|
295
307
|
* @param {string} cloudPath
|
|
296
308
|
* @param {string} bucket
|
|
@@ -311,6 +323,7 @@ export declare class StorageService {
|
|
|
311
323
|
uploadDirectory(options: IFileOptions): Promise<void>;
|
|
312
324
|
/**
|
|
313
325
|
* 上传文件夹,支持自定义 Region 和 Bucket
|
|
326
|
+
* 不会自动拼接环境的共享桶 BasePath,需要时显式传入 basePath
|
|
314
327
|
* @param {string} localPath
|
|
315
328
|
* @param {string} cloudPath
|
|
316
329
|
* @param {number} parallel
|
|
@@ -348,6 +361,7 @@ export declare class StorageService {
|
|
|
348
361
|
createCloudDirectroy(cloudPath: string): Promise<void>;
|
|
349
362
|
/**
|
|
350
363
|
* 创建一个空的文件夹,支持自定义 Region 和 Bucket
|
|
364
|
+
* 不会自动拼接环境的共享桶 BasePath,需要时显式传入 basePath
|
|
351
365
|
* @param {string} cloudPath
|
|
352
366
|
* @param {string} bucket
|
|
353
367
|
* @param {string} region
|
|
@@ -400,6 +414,7 @@ export declare class StorageService {
|
|
|
400
414
|
deleteFile(cloudPathList: string[]): Promise<void>;
|
|
401
415
|
/**
|
|
402
416
|
* 删除文件,可以指定 Bucket 和 Region
|
|
417
|
+
* 不会自动拼接环境的共享桶 BasePath,cloudPathList 按 COS 原始 Key 处理
|
|
403
418
|
* @param {string[]} cloudPathList
|
|
404
419
|
* @param {string} bucket
|
|
405
420
|
* @param {string} region
|
|
@@ -425,6 +440,7 @@ export declare class StorageService {
|
|
|
425
440
|
}>;
|
|
426
441
|
/**
|
|
427
442
|
* 删除文件,可以指定 bucket 和 region
|
|
443
|
+
* 不会自动拼接环境的共享桶 BasePath,需要时显式传入 basePath;返回的 Key 为逻辑路径
|
|
428
444
|
* @param {string} cloudPath
|
|
429
445
|
* @param {string} bucket
|
|
430
446
|
* @param {string} region
|
|
@@ -497,6 +513,7 @@ export declare class StorageService {
|
|
|
497
513
|
walkCloudDir(prefix: string, marker?: string): Promise<IListFileInfo[]>;
|
|
498
514
|
/**
|
|
499
515
|
* 遍历云端文件夹,支持自定义 Bucket 和 Region
|
|
516
|
+
* 不会自动拼接环境的共享桶 BasePath,需要时显式传入 basePath;传入后返回的 Key 为逻辑路径
|
|
500
517
|
* @param {string} prefix
|
|
501
518
|
* @param {string} [marker]
|
|
502
519
|
* @param {string} bucket
|
|
@@ -686,9 +703,10 @@ export declare class StorageService {
|
|
|
686
703
|
*/
|
|
687
704
|
private cloudPathToFileId;
|
|
688
705
|
/**
|
|
689
|
-
*
|
|
706
|
+
* 获取存储桶配置,兼容共享桶(ExternalStorage)环境
|
|
707
|
+
* basePath 为共享桶内的目录前缀,普通环境为空串
|
|
690
708
|
*/
|
|
691
|
-
|
|
709
|
+
getStorageConfig(): IStorageConfig;
|
|
692
710
|
/**
|
|
693
711
|
* 带重试功能的上传多文件函数
|
|
694
712
|
* @param uploadFiles sdk上传函数
|
package/types/storage/type.d.ts
CHANGED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { EnvInfo, ExternalStorage } from '../interfaces';
|
|
2
|
+
export interface IStorageConfig {
|
|
3
|
+
env: string;
|
|
4
|
+
region: string;
|
|
5
|
+
bucket: string;
|
|
6
|
+
basePath: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* 逻辑路径 → COS 物理 Key:共享桶环境拼上 basePath 前缀,basePath 为空时原样返回
|
|
10
|
+
* cloudPath 为空或为 '/' 时返回 `${basePath}/`,即共享桶内本环境的根目录
|
|
11
|
+
*/
|
|
12
|
+
export declare function toPhysicalKey(basePath: string, cloudPath?: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* COS 物理 Key → 逻辑路径:去掉 basePath 前缀,basePath 为空或 Key 不在前缀下时原样返回
|
|
15
|
+
*/
|
|
16
|
+
export declare function toLogicalPath(basePath: string, key: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* 解析环境的有效云存储配置
|
|
19
|
+
* 共享桶环境(Storages[0].Bucket 为空且 ExternalStorage.Enabled 为 true)下,桶名、地域、BasePath 从 ExternalStorage 读取;
|
|
20
|
+
* 普通环境保持读取 Storages[0].Bucket / Region,basePath 为空串
|
|
21
|
+
*/
|
|
22
|
+
export declare function resolveStorageConfig(envConfig: EnvInfo): IStorageConfig;
|
|
23
|
+
/**
|
|
24
|
+
* 按共享桶规则解析有效桶,云存储(Storages)与静态托管(DescribeStaticStore)共用
|
|
25
|
+
* bucket 为空且 externalStorage.Enabled 为 true 时使用 ExternalStorage,否则使用环境自有桶,basePath 为空串
|
|
26
|
+
*/
|
|
27
|
+
export declare function resolveBucketConfig(options: {
|
|
28
|
+
envId: string;
|
|
29
|
+
bucket: string;
|
|
30
|
+
region: string;
|
|
31
|
+
externalStorage?: ExternalStorage;
|
|
32
|
+
}): {
|
|
33
|
+
bucket: string;
|
|
34
|
+
region: string;
|
|
35
|
+
basePath: string;
|
|
36
|
+
};
|