@cloudbase/manager-node 5.10.4 → 5.10.6
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/CHANGELOG.md +8 -0
- package/changelog_content_en.md +2 -2
- package/jest.config.js +4 -2
- package/jest.config.unit.js +2 -1
- package/lib/database/index.js +33 -9
- package/lib/docs/index.js +18 -3
- package/lib/env/index.js +126 -42
- package/lib/error-docs.js +11 -1
- package/lib/error-types.js +2 -0
- package/lib/function/index.js +5 -1
- package/lib/storage/index.js +394 -13
- package/package.json +2 -1
- package/scripts/check-error-codes.cjs +80 -0
- package/types/database/type.d.ts +17 -8
- package/types/docs/index.d.ts +5 -0
- package/types/env/index.d.ts +21 -2
- package/types/env/type.d.ts +94 -0
- package/types/error-docs.d.ts +3 -1
- package/types/error-types.d.ts +6 -0
- package/types/monitor/types.d.ts +2 -2
- package/types/storage/index.d.ts +6 -1
- package/types/storage/type.d.ts +76 -1
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, PurgeHttpServiceCacheParams, PurgeHttpServiceCacheRes, DescribeHttpServiceCachePurgeTaskParams, DescribeHttpServiceCachePurgeTaskRes, BindCustomDomainParams, BindCustomDomainRes, DeleteCustomDomainParams, DeleteCustomDomainRes, DescribeCertificatesParams, DescribeCertificatesRes } from './type';
|
|
3
|
+
import { CalculatePackageCreatePriceParams, CalculatePackageRenewPriceParams, CalculatePackageModifyPriceParams, DescribeHttpServiceRouteParams, DescribeHttpServiceRouteRes, VerifyHttpServiceRouteParams, VerifyHttpServiceRouteRes, CreateHttpServiceRouteParams, CreateHttpServiceRouteRes, ModifyHttpServiceRouteParams, ModifyHttpServiceRouteRes, DeleteHttpServiceRouteParams, DeleteHttpServiceRouteRes, PurgeHttpServiceCacheParams, PurgeHttpServiceCacheRes, DescribeHttpServiceCachePurgeTaskParams, DescribeHttpServiceCachePurgeTaskRes, BindCustomDomainParams, BindCustomDomainRes, DeleteCustomDomainParams, DeleteCustomDomainRes, DescribeCertificatesParams, DescribeCertificatesRes, ModifyEnvAccessControlParams, ModifyEnvAccessControlRes, DescribeEnvAccessControlParams, DescribeEnvAccessControlRes } from './type';
|
|
4
4
|
import { CreateBillingDealParams, CreateEnvParams, BaasPackageInfo, DescribeBaasPackageListParams, ModifyEnvPlanParams, RenewEnvParams, DestroyEnvParams, DescribeEnvsParams, DescribeEnvInfoParams, DescribeEnvInfoResponse, DescribeEnvAccountCircleParams, DescribeEnvAccountCircleRes, DescribeCreditsUsageDetailParams, DescribeCreditsUsageParams, DescribeCreditsUsageRes, EnvPkgCreditsUsage } from '../interfaces/tcb.interface';
|
|
5
5
|
type SOURCE = 'miniapp' | 'qcloud';
|
|
6
6
|
interface IDeleteDomainRes {
|
|
@@ -561,6 +561,7 @@ export declare class EnvService {
|
|
|
561
561
|
private billingService;
|
|
562
562
|
private certificateCloudService;
|
|
563
563
|
private tokenCache;
|
|
564
|
+
private tokenInflight;
|
|
564
565
|
constructor(environment: Environment);
|
|
565
566
|
/**
|
|
566
567
|
* 列出所有环境
|
|
@@ -796,13 +797,14 @@ export declare class EnvService {
|
|
|
796
797
|
* @param {string} credentials.secretId 密钥ID
|
|
797
798
|
* @param {string} credentials.secretKey 密钥Key
|
|
798
799
|
* @param {string} [credentials.token] sessionToken
|
|
800
|
+
* @param {string} [envId] 目标环境 ID,不传则使用当前环境
|
|
799
801
|
* @returns {Promise<string>} 访问令牌
|
|
800
802
|
*/
|
|
801
803
|
getAdminAccessToken(credentials?: {
|
|
802
804
|
secretId: string;
|
|
803
805
|
secretKey: string;
|
|
804
806
|
token?: string;
|
|
805
|
-
}): Promise<string>;
|
|
807
|
+
}, envId?: string): Promise<string>;
|
|
806
808
|
createCustomLoginKeys(): Promise<{
|
|
807
809
|
PrivateKey: string;
|
|
808
810
|
KeyID: string;
|
|
@@ -965,6 +967,23 @@ export declare class EnvService {
|
|
|
965
967
|
* @returns {Promise<DeleteCustomDomainRes>}
|
|
966
968
|
*/
|
|
967
969
|
deleteCustomDomain(params: DeleteCustomDomainParams): Promise<DeleteCustomDomainRes>;
|
|
970
|
+
/**
|
|
971
|
+
* 查询环境访问控制配置(域名来源)
|
|
972
|
+
* 返回指定环境下默认域名在公网(PUBLIC)、VPC、办公网(WOA)三种来源的当前访问策略
|
|
973
|
+
* @param {DescribeEnvAccessControlParams} params 查询参数
|
|
974
|
+
* @returns {Promise<DescribeEnvAccessControlRes>} 当前生效的配置
|
|
975
|
+
*/
|
|
976
|
+
describeEnvAccessControl(params?: DescribeEnvAccessControlParams): Promise<DescribeEnvAccessControlRes>;
|
|
977
|
+
/**
|
|
978
|
+
* 修改环境访问控制配置(域名来源)
|
|
979
|
+
* 影响指定环境下默认域名的访问来源策略,Action 为 OPEN 放通、CLOSE 拦截:
|
|
980
|
+
* - SourceType = PUBLIC 时,控制公网请求(拦截后公网访问默认域名返回 403)
|
|
981
|
+
* - SourceType = VPC 时,可选通过 VPCWhiteList 配置 VPC 白名单,不传表示不修改
|
|
982
|
+
* 各来源是否可改以服务端为准,WX(微信)与 WOA(办公网)为产品内部来源,后端暂未开放
|
|
983
|
+
* @param {ModifyEnvAccessControlParams} params 修改参数
|
|
984
|
+
* @returns {Promise<ModifyEnvAccessControlRes>} 影响行数与修改后生效的配置
|
|
985
|
+
*/
|
|
986
|
+
modifyEnvAccessControl(params: ModifyEnvAccessControlParams): Promise<ModifyEnvAccessControlRes>;
|
|
968
987
|
private getCOSDomains;
|
|
969
988
|
private modifyCosCorsDomain;
|
|
970
989
|
private getCos;
|
package/types/env/type.d.ts
CHANGED
|
@@ -565,3 +565,97 @@ export interface DeleteCustomDomainParams {
|
|
|
565
565
|
export interface DeleteCustomDomainRes {
|
|
566
566
|
RequestId: string;
|
|
567
567
|
}
|
|
568
|
+
/**
|
|
569
|
+
* 访问来源类型
|
|
570
|
+
* - PUBLIC: 公网链路访问配置
|
|
571
|
+
* - VPC: VPC 链路访问配置
|
|
572
|
+
* - WX: 微信侧来源访问配置(产品内部来源,当前未对外开放,仅查询会返回)
|
|
573
|
+
* - WOA: 办公网链路访问配置(产品内部来源,当前未对外开放,仅查询会返回)
|
|
574
|
+
*/
|
|
575
|
+
export type EnvAccessSourceType = 'PUBLIC' | 'VPC' | 'WX' | 'WOA';
|
|
576
|
+
/**
|
|
577
|
+
* 开关动作
|
|
578
|
+
* - OPEN: 放通
|
|
579
|
+
* - CLOSE: 拦截
|
|
580
|
+
*/
|
|
581
|
+
export type EnvAccessControlAction = 'OPEN' | 'CLOSE';
|
|
582
|
+
/**
|
|
583
|
+
* 办公网(WOA)鉴权模式
|
|
584
|
+
* - FORCE_AUTH: 强制鉴权
|
|
585
|
+
* - NO_AUTH: 不鉴权
|
|
586
|
+
*/
|
|
587
|
+
export type EnvAccessWoAAuth = 'FORCE_AUTH' | 'NO_AUTH';
|
|
588
|
+
/**
|
|
589
|
+
* VPC 信息(对应数据结构 VPCInfo)
|
|
590
|
+
*/
|
|
591
|
+
export interface EnvAccessVpcItem {
|
|
592
|
+
UniqVpcId: string;
|
|
593
|
+
Region: string;
|
|
594
|
+
}
|
|
595
|
+
/**
|
|
596
|
+
* VPC 白名单配置(对应数据结构 VPCWhiteListConfig)
|
|
597
|
+
* - Action = OPEN:开启白名单,VPCs 必填,覆盖写入
|
|
598
|
+
* - Action = CLOSE:关闭白名单,VPCs 填入时覆盖写入
|
|
599
|
+
*/
|
|
600
|
+
export interface EnvAccessVpcWhiteList {
|
|
601
|
+
Action?: EnvAccessControlAction;
|
|
602
|
+
VPCs?: EnvAccessVpcItem[];
|
|
603
|
+
}
|
|
604
|
+
/**
|
|
605
|
+
* 访问来源配置
|
|
606
|
+
* SourceType 决定实际生效的字段:
|
|
607
|
+
* - PUBLIC: 由 Action 控制公网请求放通/拦截
|
|
608
|
+
* - VPC: 由 Action 控制 VPC 请求放通/拦截,VPCWhiteList 控制白名单(不传表示不修改)
|
|
609
|
+
* - WOA / WX: 产品内部来源,后端暂未开放修改
|
|
610
|
+
*/
|
|
611
|
+
export interface EnvAccessSourceSetting {
|
|
612
|
+
SourceType: EnvAccessSourceType;
|
|
613
|
+
Action?: EnvAccessControlAction;
|
|
614
|
+
WOAAuth?: EnvAccessWoAAuth;
|
|
615
|
+
AuthToken?: string;
|
|
616
|
+
VPCWhiteList?: EnvAccessVpcWhiteList;
|
|
617
|
+
}
|
|
618
|
+
/**
|
|
619
|
+
* 当前生效的访问来源配置(DescribeEnvAccessControl / ModifyEnvAccessControl 的 Current)
|
|
620
|
+
* 未配置的枚举字段接口会返回空字符串,VPCWhiteList 也可能为 null,故此处按返回值放宽
|
|
621
|
+
*/
|
|
622
|
+
export type EnvAccessCurrentSetting = Array<{
|
|
623
|
+
SourceType: EnvAccessSourceType;
|
|
624
|
+
Action?: string;
|
|
625
|
+
WOAAuth?: string;
|
|
626
|
+
AuthToken?: string;
|
|
627
|
+
VPCWhiteList?: {
|
|
628
|
+
Action?: string;
|
|
629
|
+
VPCs?: EnvAccessVpcItem[] | null;
|
|
630
|
+
} | null;
|
|
631
|
+
}>;
|
|
632
|
+
/**
|
|
633
|
+
* DescribeEnvAccessControl 请求参数
|
|
634
|
+
* 查询环境的默认域名访问来源策略(公网、VPC、办公网)
|
|
635
|
+
*/
|
|
636
|
+
export interface DescribeEnvAccessControlParams {
|
|
637
|
+
EnvId?: string;
|
|
638
|
+
}
|
|
639
|
+
/**
|
|
640
|
+
* DescribeEnvAccessControl 返回结果
|
|
641
|
+
*/
|
|
642
|
+
export interface DescribeEnvAccessControlRes {
|
|
643
|
+
Current: EnvAccessCurrentSetting;
|
|
644
|
+
RequestId: string;
|
|
645
|
+
}
|
|
646
|
+
/**
|
|
647
|
+
* ModifyEnvAccessControl 请求参数
|
|
648
|
+
* 修改环境的默认域名访问来源策略(公网开关、VPC 白名单、办公网鉴权)
|
|
649
|
+
*/
|
|
650
|
+
export interface ModifyEnvAccessControlParams {
|
|
651
|
+
EnvId?: string;
|
|
652
|
+
Sources: EnvAccessSourceSetting[];
|
|
653
|
+
}
|
|
654
|
+
/**
|
|
655
|
+
* ModifyEnvAccessControl 返回结果
|
|
656
|
+
*/
|
|
657
|
+
export interface ModifyEnvAccessControlRes {
|
|
658
|
+
AffectedRows: number;
|
|
659
|
+
Current: EnvAccessCurrentSetting;
|
|
660
|
+
RequestId: string;
|
|
661
|
+
}
|
package/types/error-docs.d.ts
CHANGED
|
@@ -38,8 +38,10 @@ export declare const RUNTIME_ERROR_CODE_DOC_BASE = "https://docs.cloudbase.net/e
|
|
|
38
38
|
/**
|
|
39
39
|
* 数据面(运行时)错误码全量清单。
|
|
40
40
|
*
|
|
41
|
-
* 来源:`cloudbase-docs/docs/error-code/basic.md
|
|
41
|
+
* 来源:`cloudbase-docs/docs/error-code/basic.md`,
|
|
42
42
|
* 与服务端事实源 `tcblinker/internal/tcberror/tcberror.go` 对齐。
|
|
43
|
+
* 与线上单码页(`docs.cloudbase.net/error-code/{CODE}`)的一致性用
|
|
44
|
+
* `node scripts/check-error-codes.cjs` 核对,勿再手抄整表。
|
|
43
45
|
* 每个码在文档站都有独立页面:`https://docs.cloudbase.net/error-code/{CODE}`。
|
|
44
46
|
*
|
|
45
47
|
* ⚠️ 仅在 `source === 'runtime'` 时使用本表。因为其中 `INVALID_*`(21 个)、
|
package/types/error-types.d.ts
CHANGED
|
@@ -27,6 +27,12 @@ export declare const ERROR_TYPES: {
|
|
|
27
27
|
readonly fileError: {
|
|
28
28
|
readonly code: "FILE_READ_ERROR";
|
|
29
29
|
};
|
|
30
|
+
readonly uploadPaused: {
|
|
31
|
+
readonly code: "UPLOAD_PAUSED";
|
|
32
|
+
};
|
|
33
|
+
readonly uploadAborted: {
|
|
34
|
+
readonly code: "UPLOAD_ABORTED";
|
|
35
|
+
};
|
|
30
36
|
/**
|
|
31
37
|
* 部署前未找到构建产物(目录不存在或为空)。
|
|
32
38
|
*
|
package/types/monitor/types.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 监控指标名称
|
|
3
3
|
*
|
|
4
|
-
* 文档型数据库 / SQL型数据库 / 云函数 / 云托管 / 静态网站 / 身份认证 / API调用 / HTTP网关 / 大模型 / 知识库 / 用户登录 / 环境QPS / 数据库连接器 / 网关
|
|
4
|
+
* 文档型数据库 / SQL型数据库 / 云函数 / 云托管 / 静态网站 / 身份认证 / API调用 / HTTP网关 / 大模型 / 知识库 / 用户登录 / 环境QPS / 数据库连接器 / PostgreSQL / 网关
|
|
5
5
|
*/
|
|
6
|
-
export type MetricName = 'DbRead' | 'DbWrite' | 'DbCostTime10ms' | 'DbCostTime50ms' | 'DbCostTime100ms' | 'DbSizepkg' | 'MysqlStorageUsage' | 'MysqlCCU' | 'MysqlCpuUsageRate' | 'MysqlDbConnections' | 'MysqlMemoryUse' | 'MysqlSlowQueries' | 'MysqlTps' | 'MysqlQps' | 'FunctionCU' | 'FunctionInvocation' | 'FunctionFlux' | 'FunctionThrottle' | 'FunctionConcurrentExecutions' | 'FunctionTimeout' | 'FunctionGBs' | 'FunctionError' | 'FunctionDuration' | 'FunctionConcurrencyMemoryMB' | 'FunctionMemOverFlow' | 'FunctionIdleProvisioned' | 'FunctionProvisionedConcurrency' | 'TkeRspTimeService' | 'TkeCpuUsedService' | 'TkeMemUsedService' | 'TkeQPSService' | 'TkePodNumService' | 'TkeHttpServiceNatPkg' | 'TkeCUUsedService' | 'TkeInvokeNumService' | 'TkeHttpErrorService' | 'StaticFsFluxPkg' | 'StaticFsSizePkg' | 'AuthInvocationNumPkg' | 'GwCloudDevelopmentSecureCallsInvocation' | 'GwWXInvocation' | 'GwCloudDevelopmentStandardCallsInvocation' | 'AIPromptTokenNumPkg' | 'AICompletionTokenNumPkg' | 'AITotalTokenNumPkg' | 'KnowledgeBaseCapacity' | 'DayActiveLoginAnonymousUser' | 'DayActiveLoginAllUser' | 'DayActiveLoginExternalUser' | 'DayActiveLoginInternalUser' | 'EnvQPSAll' | 'MongoConnectorRead' | 'MongoConnectorWrite' | 'MongoConnectorCostTime10ms' | 'MongoConnectorCostTime50ms' | 'MongoConnectorCostTime100ms' | 'MongoConnectorInvokeNum' | 'GatewayTraceEnvQPS' | 'GatewayShowAPIInvokeNum' | 'GatewayShowAPICostTotal' | 'GatewayShowAPIHTTP2XX' | 'GatewayShowAPIHTTPError' | 'GatewayTraceAccessSourceQPS' | 'GatewayShowHttpInvokeNum' | 'GatewayShowHttpCostTotal' | 'GatewayShowHttpHTTP2XX' | 'GatewayShowHttpHTTPError' | 'GatewayTraceResourceQPS' | (string & {});
|
|
6
|
+
export type MetricName = 'DbRead' | 'DbWrite' | 'DbCostTime10ms' | 'DbCostTime50ms' | 'DbCostTime100ms' | 'DbSizepkg' | 'MysqlStorageUsage' | 'MysqlCCU' | 'MysqlCpuUsageRate' | 'MysqlDbConnections' | 'MysqlMemoryUse' | 'MysqlSlowQueries' | 'MysqlTps' | 'MysqlQps' | 'FunctionCU' | 'FunctionInvocation' | 'FunctionFlux' | 'FunctionThrottle' | 'FunctionConcurrentExecutions' | 'FunctionTimeout' | 'FunctionGBs' | 'FunctionError' | 'FunctionDuration' | 'FunctionConcurrencyMemoryMB' | 'FunctionMemOverFlow' | 'FunctionIdleProvisioned' | 'FunctionProvisionedConcurrency' | 'TkeRspTimeService' | 'TkeCpuUsedService' | 'TkeMemUsedService' | 'TkeQPSService' | 'TkePodNumService' | 'TkeHttpServiceNatPkg' | 'TkeCUUsedService' | 'TkeInvokeNumService' | 'TkeHttpErrorService' | 'StaticFsFluxPkg' | 'StaticFsSizePkg' | 'AuthInvocationNumPkg' | 'GwCloudDevelopmentSecureCallsInvocation' | 'GwWXInvocation' | 'GwCloudDevelopmentStandardCallsInvocation' | 'AIPromptTokenNumPkg' | 'AICompletionTokenNumPkg' | 'AITotalTokenNumPkg' | 'KnowledgeBaseCapacity' | 'DayActiveLoginAnonymousUser' | 'DayActiveLoginAllUser' | 'DayActiveLoginExternalUser' | 'DayActiveLoginInternalUser' | 'EnvQPSAll' | 'MongoConnectorRead' | 'MongoConnectorWrite' | 'MongoConnectorCostTime10ms' | 'MongoConnectorCostTime50ms' | 'MongoConnectorCostTime100ms' | 'MongoConnectorInvokeNum' | 'PostgreSQLCpu' | 'PostgreSQLMemory' | 'PostgreSQLStorageCurve' | 'PostgreSQLConnections' | 'PostgreSQLActiveConns' | 'PostgreSQLIdleConns' | 'PostgreSQLMemoryRate' | 'PostgreSQLStorageRate' | 'PostgreSQLQps' | 'PostgreSQLTps' | 'PostgreSQLReadWriteCalls' | 'PostgreSQLReadCalls' | 'PostgreSQLWriteCalls' | 'PostgreSQLSqlRuntimeAvg' | 'PostgreSQLSqlRuntimeMax' | 'PostgreSQLSqlRuntimeMin' | 'PostgreSQLSlowQueryCnt' | 'PostgreSQLLongQuery' | 'PostgreSQLLongXact' | 'PostgreSQLLongWaiting' | 'PostgreSQLDeadlocks' | 'GatewayTraceEnvQPS' | 'GatewayShowAPIInvokeNum' | 'GatewayShowAPICostTotal' | 'GatewayShowAPIHTTP2XX' | 'GatewayShowAPIHTTPError' | 'GatewayTraceAccessSourceQPS' | 'GatewayShowHttpInvokeNum' | 'GatewayShowHttpCostTotal' | 'GatewayShowHttpHTTP2XX' | 'GatewayShowHttpHTTPError' | 'GatewayTraceResourceQPS' | (string & {});
|
|
7
7
|
/** 统计周期(秒) */
|
|
8
8
|
export type MetricPeriod = 300 | 3600 | 86400;
|
|
9
9
|
/** DescribeCurveData 请求参数 */
|
package/types/storage/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Environment } from '../environment';
|
|
2
2
|
import { IUploadMetadata, IListFileInfo, IFileInfo, ITempUrlInfo, IResponseInfo } from '../interfaces';
|
|
3
3
|
import { IStorageConfig } from '../utils/storage-config';
|
|
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
|
+
import { IUploadObjectHttpOptions, IUploadObjectHttpResult, IUploadObjectResumableOptions, IUploadObjectResumableResult, 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';
|
|
5
5
|
export interface IProgressData {
|
|
6
6
|
loaded: number;
|
|
7
7
|
total: number;
|
|
@@ -630,6 +630,11 @@ export declare class StorageService {
|
|
|
630
630
|
* POST/PUT /v1/storages/object/:bucketId/*objectName
|
|
631
631
|
*/
|
|
632
632
|
uploadObject(options: IUploadObjectHttpOptions): Promise<IUploadObjectHttpResult>;
|
|
633
|
+
/**
|
|
634
|
+
* 通过 CloudBase HTTP API 断点续传上传对象(TUS 协议)
|
|
635
|
+
* POST / PATCH / HEAD /v1/storages/upload/resumable
|
|
636
|
+
*/
|
|
637
|
+
uploadObjectResumable(options: IUploadObjectResumableOptions): Promise<IUploadObjectResumableResult>;
|
|
633
638
|
/**
|
|
634
639
|
* 通过 CloudBase HTTP API 删除单个对象
|
|
635
640
|
* DELETE /v1/storages/object/:bucketId/*objectName
|
package/types/storage/type.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export interface IUploadObjectHttpOptions {
|
|
|
15
15
|
/** 文件字节数;不传时若为 localPath/Buffer 会自动推断 */
|
|
16
16
|
contentLength?: number;
|
|
17
17
|
/**
|
|
18
|
-
* 缓存控制;传 number
|
|
18
|
+
* 缓存控制;传 number 或纯数字字符串自动转换为 max-age=<value>,其他 string 直接作为 Cache-Control 头值。
|
|
19
19
|
* 不传(含空字符串)时默认 3600(即 max-age=3600);传 0 表示 max-age=0
|
|
20
20
|
*/
|
|
21
21
|
cacheControl?: number | string;
|
|
@@ -547,3 +547,78 @@ export interface IGetObjectInfoHttpResult {
|
|
|
547
547
|
/** GET 时返回 JSON;HEAD 时为 null */
|
|
548
548
|
body: IObjectInfoHttpPayload | null;
|
|
549
549
|
}
|
|
550
|
+
/** 断点续传进度 */
|
|
551
|
+
export interface IResumableUploadProgress {
|
|
552
|
+
/** 已上传字节数;只增不减(重试重传期间停在原处),上传中最多为 total - 1 */
|
|
553
|
+
loaded: number;
|
|
554
|
+
/** 文件总字节数 */
|
|
555
|
+
total: number;
|
|
556
|
+
/** 本次上传速度,字节/秒(续传时不含之前已传部分) */
|
|
557
|
+
speed: number;
|
|
558
|
+
/** 进度,0 ~ 1;为 1 表示上传已成功,只在最后一次回调中出现一次 */
|
|
559
|
+
percent: number;
|
|
560
|
+
/**
|
|
561
|
+
* 本次从第几个字节开始上传,用于提示"从 xx% 继续"。
|
|
562
|
+
* 0 表示从第 0 字节传起:可能是新开单、旧会话已失效,也可能是续上了一个服务端尚未收到数据的旧会话(三者传输量相同)。
|
|
563
|
+
* 是否续传由 SDK 自动处理,调用方无需据此决定重传
|
|
564
|
+
*/
|
|
565
|
+
resumedFrom: number;
|
|
566
|
+
}
|
|
567
|
+
/** 中止信号,兼容原生 AbortController.signal(@types/node 12 没有 AbortSignal 类型) */
|
|
568
|
+
export interface IAbortSignalLike {
|
|
569
|
+
readonly aborted: boolean;
|
|
570
|
+
addEventListener: (type: 'abort', listener: () => void) => void;
|
|
571
|
+
/** 有则在上传结束时移除监听,避免同一个 signal 用于多次上传时监听器累积 */
|
|
572
|
+
removeEventListener?: (type: 'abort', listener: () => void) => void;
|
|
573
|
+
}
|
|
574
|
+
/** 断点续传上传参数 */
|
|
575
|
+
export interface IUploadObjectResumableOptions {
|
|
576
|
+
/** Bucket ID */
|
|
577
|
+
bucketId: string;
|
|
578
|
+
/** 对象名,支持路径,例如 videos/big.mp4 */
|
|
579
|
+
objectName: string;
|
|
580
|
+
/** 本地文件路径(仅支持文件,不支持 Buffer / 流) */
|
|
581
|
+
localPath: string;
|
|
582
|
+
/**
|
|
583
|
+
* Bearer Token(access_token / apiKey / publishableKey),⚠️ apiKey 严禁在客户端使用。
|
|
584
|
+
* 不传时用初始化时的 secretId/secretKey 换取管理员 token(存储网关只认 Bearer,不认签名)
|
|
585
|
+
*/
|
|
586
|
+
accessToken?: string;
|
|
587
|
+
/** 可选覆盖 envId,不传则取当前环境 */
|
|
588
|
+
envId?: string;
|
|
589
|
+
/** MIME 类型,不传按文件后缀推断 */
|
|
590
|
+
contentType?: string;
|
|
591
|
+
/** 缓存时长(秒),默认 3600;支持 3600、"3600"、"max-age=3600" 和 "no-cache"(原样存为 no-cache),其他写法抛 INVALID_PARAM */
|
|
592
|
+
cacheControl?: number | string;
|
|
593
|
+
/** 自定义 metadata(JSON 对象) */
|
|
594
|
+
metadata?: Record<string, any>;
|
|
595
|
+
/** 目标已存在时是否覆盖,默认 false。覆盖与非覆盖的续传记录互相独立:中断后需用相同的 upsert 值再调用才会续传 */
|
|
596
|
+
upsert?: boolean;
|
|
597
|
+
/** 进度回调 */
|
|
598
|
+
onProgress?: (progress: IResumableUploadProgress) => void;
|
|
599
|
+
/**
|
|
600
|
+
* 触发后停止上传。默认是暂停:断开当前请求,保留服务端已传部分和本地记录,方法以 UPLOAD_PAUSED 报错结束,
|
|
601
|
+
* 之后用相同参数再调用即可从断点继续(服务端会话过期后会自动从头传)
|
|
602
|
+
*/
|
|
603
|
+
abortSignal?: IAbortSignalLike;
|
|
604
|
+
/**
|
|
605
|
+
* 为 true 时 abortSignal 触发改为终止:通知服务端清理已传部分并删除本地记录(DELETE 最多等 5 秒),
|
|
606
|
+
* 方法以 UPLOAD_ABORTED 报错结束,下次调用从头上传。默认 false
|
|
607
|
+
*/
|
|
608
|
+
terminateOnAbort?: boolean;
|
|
609
|
+
}
|
|
610
|
+
/** 断点续传上传结果(服务端完成响应不带对象 Id,需要时可调 getObjectInfoAuthenticated) */
|
|
611
|
+
export interface IUploadObjectResumableResult {
|
|
612
|
+
/** Bucket ID */
|
|
613
|
+
bucketId: string;
|
|
614
|
+
/** 对象名 */
|
|
615
|
+
objectName: string;
|
|
616
|
+
/** 文件总字节数 */
|
|
617
|
+
size: number;
|
|
618
|
+
/**
|
|
619
|
+
* 本次从第几个字节开始上传,用于提示"从 xx% 继续"。
|
|
620
|
+
* 0 表示从第 0 字节传起:可能是新开单、旧会话已失效,也可能是续上了一个服务端尚未收到数据的旧会话(三者传输量相同)。
|
|
621
|
+
* 是否续传由 SDK 自动处理,调用方无需据此决定重传
|
|
622
|
+
*/
|
|
623
|
+
resumedFrom: number;
|
|
624
|
+
}
|