@cloudbase/manager-node 5.8.0-beta.2 → 5.8.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/CHANGELOG.md +29 -0
- package/lib/env/index.js +27 -0
- package/lib/function/index.js +98 -91
- package/lib/hosting/index.js +21 -1
- package/lib/storage/helper.js +52 -0
- package/lib/storage/index.js +449 -5
- package/package.json +2 -2
- package/types/env/index.d.ts +17 -1
- package/types/env/type.d.ts +257 -3
- package/types/function/index.d.ts +36 -36
- package/types/hosting/index.d.ts +8 -0
- package/types/storage/helper.d.ts +20 -0
- package/types/storage/index.d.ts +124 -2
- package/types/storage/type.d.ts +115 -0
package/types/env/type.d.ts
CHANGED
|
@@ -14,6 +14,169 @@ export interface CalculatePackageModifyPriceParams {
|
|
|
14
14
|
envId: string;
|
|
15
15
|
currency?: 'CNY' | 'USD';
|
|
16
16
|
}
|
|
17
|
+
/** 获取 SSL 证书列表请求参数。 */
|
|
18
|
+
export interface DescribeCertificatesParams {
|
|
19
|
+
/** 分页偏移量,从 0 开始。 */
|
|
20
|
+
Offset?: number;
|
|
21
|
+
/** 每页数量,范围为 1 至 1000。 */
|
|
22
|
+
Limit?: number;
|
|
23
|
+
/** 模糊匹配证书 ID、备注名称或证书域名。 */
|
|
24
|
+
SearchKey?: string;
|
|
25
|
+
/** 证书类型:CA 为客户端证书,SVR 为服务器证书。 */
|
|
26
|
+
CertificateType?: 'CA' | 'SVR';
|
|
27
|
+
/** 项目 ID。 */
|
|
28
|
+
ProjectId?: number;
|
|
29
|
+
/** 按证书到期时间排序。 */
|
|
30
|
+
ExpirationSort?: 'ASC' | 'DESC';
|
|
31
|
+
/** 证书状态筛选。 */
|
|
32
|
+
CertificateStatus?: number[];
|
|
33
|
+
/** 是否仅返回可部署证书:1 是,0 否。 */
|
|
34
|
+
Deployable?: 0 | 1;
|
|
35
|
+
/** 是否仅返回上传托管证书:1 是,0 否。 */
|
|
36
|
+
Upload?: 0 | 1;
|
|
37
|
+
/** 是否仅返回可续期证书:1 是,0 否。 */
|
|
38
|
+
Renew?: 0 | 1;
|
|
39
|
+
/** 来源筛选。 */
|
|
40
|
+
FilterSource?: 'upload' | 'buy';
|
|
41
|
+
/** 是否仅返回国密证书:1 是,0 否。 */
|
|
42
|
+
IsSM?: 0 | 1;
|
|
43
|
+
/** 是否仅返回即将过期证书:1 是,0 否。 */
|
|
44
|
+
FilterExpiring?: 0 | 1;
|
|
45
|
+
/** 是否仅返回可托管证书:1 是,0 否。 */
|
|
46
|
+
Hostable?: 0 | 1;
|
|
47
|
+
/** 标签筛选条件。 */
|
|
48
|
+
Tags?: Array<{
|
|
49
|
+
TagKey: string;
|
|
50
|
+
TagValue?: string;
|
|
51
|
+
}>;
|
|
52
|
+
/** 是否仅返回等待签发证书:1 是,0 否。 */
|
|
53
|
+
IsPendingIssue?: 0 | 1;
|
|
54
|
+
/** 指定证书 ID 列表。 */
|
|
55
|
+
CertIds?: string[];
|
|
56
|
+
/** 订阅服务 ID。 */
|
|
57
|
+
ServiceId?: string;
|
|
58
|
+
}
|
|
59
|
+
/** Certificates.CertificateExtra:证书扩展信息。 */
|
|
60
|
+
export interface CertificateExtra {
|
|
61
|
+
DomainNumber: string;
|
|
62
|
+
OriginCertificateId: string | null;
|
|
63
|
+
ReplacedBy: string | null;
|
|
64
|
+
ReplacedFor: string | null;
|
|
65
|
+
RenewOrder: string | null;
|
|
66
|
+
SMCert: number;
|
|
67
|
+
CompanyType: number;
|
|
68
|
+
ServiceRenewCertificateId: string;
|
|
69
|
+
ServiceOriginCertificateId: string;
|
|
70
|
+
}
|
|
71
|
+
/** Certificates.ProjectInfo:项目信息。 */
|
|
72
|
+
export interface ProjectInfo {
|
|
73
|
+
ProjectName: string;
|
|
74
|
+
ProjectCreatorUin: number;
|
|
75
|
+
ProjectCreateTime: string;
|
|
76
|
+
ProjectResume: string;
|
|
77
|
+
OwnerUin: number;
|
|
78
|
+
ProjectId: string;
|
|
79
|
+
}
|
|
80
|
+
/** Certificates.PreAuditInfo:证书预审核信息。 */
|
|
81
|
+
export interface PreAuditInfo {
|
|
82
|
+
TotalPeriod: number;
|
|
83
|
+
NowPeriod: number;
|
|
84
|
+
ManagerId: string;
|
|
85
|
+
}
|
|
86
|
+
/** Certificates.HostingConfig:托管配置。 */
|
|
87
|
+
export interface HostingConfig {
|
|
88
|
+
ReplaceTime?: number;
|
|
89
|
+
MessageTypes?: number[];
|
|
90
|
+
ReplaceStartTime?: string;
|
|
91
|
+
ReplaceEndTime?: string;
|
|
92
|
+
}
|
|
93
|
+
/** Certificates.SupportDownloadType:支持下载的服务器格式。 */
|
|
94
|
+
export interface SupportDownloadType {
|
|
95
|
+
NGINX: boolean;
|
|
96
|
+
APACHE: boolean;
|
|
97
|
+
TOMCAT: boolean;
|
|
98
|
+
IIS: boolean;
|
|
99
|
+
JKS: boolean;
|
|
100
|
+
OTHER: boolean;
|
|
101
|
+
ROOT: boolean;
|
|
102
|
+
}
|
|
103
|
+
/** Certificates.Tags:标签信息。 */
|
|
104
|
+
export interface CertificateTag {
|
|
105
|
+
TagKey: string;
|
|
106
|
+
TagValue: string;
|
|
107
|
+
}
|
|
108
|
+
/** SSL 证书列表项,对应 DescribeCertificates 响应中的 Certificates 元素。 */
|
|
109
|
+
export interface Certificates {
|
|
110
|
+
OwnerUin: string;
|
|
111
|
+
ProjectId: string;
|
|
112
|
+
From: string;
|
|
113
|
+
PackageType: string;
|
|
114
|
+
CertificateType: 'CA' | 'SVR';
|
|
115
|
+
ProductZhName: string;
|
|
116
|
+
Domain: string;
|
|
117
|
+
Alias: string;
|
|
118
|
+
Status: number;
|
|
119
|
+
CertificateExtra: CertificateExtra;
|
|
120
|
+
VulnerabilityStatus: 'INACTIVE' | 'ACTIVE';
|
|
121
|
+
StatusMsg: string;
|
|
122
|
+
VerifyType: 'DNS_AUTO' | 'DNS' | 'FILE' | 'DNS_PROXY' | 'FILE_PROXY';
|
|
123
|
+
CertBeginTime: string;
|
|
124
|
+
CertEndTime: string;
|
|
125
|
+
ValidityPeriod: string;
|
|
126
|
+
InsertTime: string;
|
|
127
|
+
CertificateId: string;
|
|
128
|
+
SubjectAltName: string[];
|
|
129
|
+
PackageTypeName: string;
|
|
130
|
+
StatusName: string;
|
|
131
|
+
IsVip: boolean;
|
|
132
|
+
IsDv: boolean;
|
|
133
|
+
IsWildcard: boolean;
|
|
134
|
+
IsVulnerability: boolean;
|
|
135
|
+
RenewAble: boolean;
|
|
136
|
+
ProjectInfo: ProjectInfo;
|
|
137
|
+
BoundResource: string[];
|
|
138
|
+
Deployable: boolean;
|
|
139
|
+
Tags: CertificateTag[];
|
|
140
|
+
IsIgnore: boolean;
|
|
141
|
+
IsSM: boolean;
|
|
142
|
+
EncryptAlgorithm: string;
|
|
143
|
+
CAEncryptAlgorithms: string[];
|
|
144
|
+
CAEndTimes: string[];
|
|
145
|
+
CACommonNames: string[];
|
|
146
|
+
PreAuditInfo: PreAuditInfo;
|
|
147
|
+
AutoRenewFlag: number;
|
|
148
|
+
HostingStatus: number;
|
|
149
|
+
HostingCompleteTime: string;
|
|
150
|
+
HostingRenewCertId: string;
|
|
151
|
+
HasRenewOrder: string;
|
|
152
|
+
ReplaceOriCertIsDelete: boolean;
|
|
153
|
+
IsExpiring: boolean;
|
|
154
|
+
DVAuthDeadline: string;
|
|
155
|
+
ValidationPassedTime: string;
|
|
156
|
+
CertSANs: string[];
|
|
157
|
+
AwaitingValidationMsg: string;
|
|
158
|
+
AllowDownload: boolean;
|
|
159
|
+
IsDNSPODResolve: boolean;
|
|
160
|
+
IsPackage: boolean;
|
|
161
|
+
KeyPasswordCustomFlag: boolean;
|
|
162
|
+
SupportDownloadType: SupportDownloadType;
|
|
163
|
+
CertRevokedTime: string;
|
|
164
|
+
HostingResourceTypes: string[];
|
|
165
|
+
HostingConfig: HostingConfig | null;
|
|
166
|
+
IsHostingUploadRenewCert: boolean;
|
|
167
|
+
ServiceId: string;
|
|
168
|
+
ServiceStatus: 'initing' | 'running' | 'expired' | 'refunded' | 'nearExpire';
|
|
169
|
+
CertServiceBeginTime: string;
|
|
170
|
+
CertServiceEndTime: string;
|
|
171
|
+
CertServiceShareEnabled: boolean;
|
|
172
|
+
CertServiceValidCertificateCount: number;
|
|
173
|
+
}
|
|
174
|
+
/** 获取 SSL 证书列表响应。 */
|
|
175
|
+
export interface DescribeCertificatesRes {
|
|
176
|
+
TotalCount: number;
|
|
177
|
+
Certificates: Certificates[];
|
|
178
|
+
RequestId: string;
|
|
179
|
+
}
|
|
17
180
|
/**
|
|
18
181
|
* 客户端限频配置
|
|
19
182
|
*/
|
|
@@ -35,18 +198,43 @@ export interface HTTPServicePathRewrite {
|
|
|
35
198
|
StaticStorePrefix?: string;
|
|
36
199
|
Prefix?: string;
|
|
37
200
|
}
|
|
201
|
+
/**
|
|
202
|
+
* HTTP 访问服务路由添加 header 配置
|
|
203
|
+
*/
|
|
204
|
+
export interface HTTPServiceHeaderToAdd {
|
|
205
|
+
Key?: string;
|
|
206
|
+
Value?: string;
|
|
207
|
+
Action?: 'APPEND_IF_EXISTS_OR_ADD' | 'ADD_IF_ABSENT' | 'OVERWRITE_IF_EXISTS_OR_ADD' | 'OVERWRITE_IF_EXISTS';
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* HTTP 访问服务路由 headers 处理配置
|
|
211
|
+
*/
|
|
212
|
+
export interface HTTPServiceHeadersHandler {
|
|
213
|
+
RequestHeadersToAdd?: HTTPServiceHeaderToAdd[];
|
|
214
|
+
RequestHeadersToRemove?: string[];
|
|
215
|
+
ResponseHeadersToAdd?: HTTPServiceHeaderToAdd[];
|
|
216
|
+
ResponseHeadersToRemove?: string[];
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* HTTP访问服务路由扩展字段
|
|
220
|
+
*/
|
|
221
|
+
export interface HTTPServiceExtension {
|
|
222
|
+
HeadersHandler?: HTTPServiceHeadersHandler;
|
|
223
|
+
[key: string]: unknown;
|
|
224
|
+
}
|
|
38
225
|
/**
|
|
39
226
|
* HTTP访问服务路由信息
|
|
40
227
|
*/
|
|
41
228
|
export interface HTTPServiceRoute {
|
|
42
229
|
Path: string;
|
|
43
230
|
PathRewrite?: HTTPServicePathRewrite;
|
|
44
|
-
UpstreamResourceType: 'SCF' | 'CBR' | 'STATIC_STORE' | 'WEB_SCF' | 'LH';
|
|
231
|
+
UpstreamResourceType: 'SCF' | 'CBR' | 'STATIC_STORE' | 'WEB_SCF' | 'LH' | 'STORAGE';
|
|
45
232
|
UpstreamResourceName: string;
|
|
46
233
|
EnableSafeDomain: boolean;
|
|
47
234
|
EnableAuth: boolean;
|
|
48
235
|
EnablePathTransmission: boolean;
|
|
49
236
|
QPSPolicy?: HTTPServiceRouteQPSPolicy;
|
|
237
|
+
Extension?: HTTPServiceExtension;
|
|
50
238
|
Enable: boolean;
|
|
51
239
|
CreateTime: string;
|
|
52
240
|
UpdateTime: string;
|
|
@@ -57,7 +245,7 @@ export interface HTTPServiceRoute {
|
|
|
57
245
|
export interface HTTPServiceDomain {
|
|
58
246
|
Domain: string;
|
|
59
247
|
DomainType: 'HTTPSERVICE' | 'CBR' | 'ANYSERVICE' | 'AI_AGENT' | 'VM' | 'INTEGRATION_CALLBACK';
|
|
60
|
-
AccessType: 'DIRECT' | 'CDN' | 'CUSTOM';
|
|
248
|
+
AccessType: 'DIRECT' | 'CDN' | 'CUSTOM' | 'EO';
|
|
61
249
|
CertId: string;
|
|
62
250
|
Protocol: 'HTTP_AND_HTTPS' | 'HTTP_TO_HTTPS' | 'HTTPS_TO_HTTP';
|
|
63
251
|
Cname: string;
|
|
@@ -66,6 +254,7 @@ export interface HTTPServiceDomain {
|
|
|
66
254
|
Status: 'PROCESSING' | 'FAIL' | 'SUCCESS';
|
|
67
255
|
DNSStatus: 'OK' | 'INVALID';
|
|
68
256
|
Routes?: HTTPServiceRoute[];
|
|
257
|
+
Extension?: HTTPServiceExtension;
|
|
69
258
|
CreateTime: string;
|
|
70
259
|
UpdateTime: string;
|
|
71
260
|
}
|
|
@@ -99,13 +288,14 @@ export interface DescribeHttpServiceRouteRes {
|
|
|
99
288
|
*/
|
|
100
289
|
export interface HTTPServiceRouteParam {
|
|
101
290
|
Path: string;
|
|
102
|
-
UpstreamResourceType?: 'SCF' | 'CBR' | 'STATIC_STORE' | 'WEB_SCF' | 'LH';
|
|
291
|
+
UpstreamResourceType?: 'SCF' | 'CBR' | 'STATIC_STORE' | 'WEB_SCF' | 'LH' | 'STORAGE';
|
|
103
292
|
UpstreamResourceName?: string;
|
|
104
293
|
PathRewrite?: HTTPServicePathRewrite;
|
|
105
294
|
EnableSafeDomain?: boolean;
|
|
106
295
|
EnableAuth?: boolean;
|
|
107
296
|
EnablePathTransmission?: boolean;
|
|
108
297
|
QPSPolicy?: HTTPServiceRouteQPSPolicy;
|
|
298
|
+
Extension?: HTTPServiceExtension;
|
|
109
299
|
Enable?: boolean;
|
|
110
300
|
}
|
|
111
301
|
/**
|
|
@@ -119,6 +309,70 @@ export interface HTTPServiceDomainParam {
|
|
|
119
309
|
CustomCname?: string;
|
|
120
310
|
Enable?: boolean;
|
|
121
311
|
Routes?: HTTPServiceRouteParam[];
|
|
312
|
+
Extension?: HTTPServiceExtension;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* 前置校验检查状态
|
|
316
|
+
*/
|
|
317
|
+
export type VerifyHttpServiceRouteCheckStatus = 'PASS' | 'SKIPPED' | 'FAIL';
|
|
318
|
+
/**
|
|
319
|
+
* 前置校验失败原因
|
|
320
|
+
*/
|
|
321
|
+
export type VerifyHttpServiceRouteCheckCode = 'INTERNAL_CHECK_ERROR' | 'OWNERSHIP_DNS_LOOKUP_FAILED' | 'OWNERSHIP_VERIFY_FAILED' | 'CERT_VERIFY_FAILED' | 'QUOTA_EXCEEDED' | 'ROUTE_CONFLICT' | 'DOMAIN_IN_USE' | 'NON_INTERNAL_ACCOUNT' | 'DOMAIN_IN_BLACKLIST' | 'CDN_RESOURCE_PROCESSING' | 'CDN_RESOURCE_OFFLINE' | 'EO_OWNERSHIP_VERIFY_FAILED' | 'EO_DOMAIN_NOT_ICP' | 'EO_DOMAIN_IN_USE';
|
|
322
|
+
/**
|
|
323
|
+
* 域名归属权 DNS 验证指引
|
|
324
|
+
*/
|
|
325
|
+
export interface OwnershipVerificationDnsInfo {
|
|
326
|
+
Subdomain?: string;
|
|
327
|
+
RecordType?: string;
|
|
328
|
+
RecordValue?: string;
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* 域名归属权文件验证指引
|
|
332
|
+
*/
|
|
333
|
+
export interface OwnershipVerificationFileInfo {
|
|
334
|
+
Path?: string;
|
|
335
|
+
Content?: string;
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* 域名归属权验证指引
|
|
339
|
+
*/
|
|
340
|
+
export interface OwnershipVerificationInfo {
|
|
341
|
+
Domain?: string;
|
|
342
|
+
DnsVerification?: OwnershipVerificationDnsInfo[];
|
|
343
|
+
FileVerification?: OwnershipVerificationFileInfo[];
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* VerifyHTTPServiceRoute 单项前置校验结果
|
|
347
|
+
*/
|
|
348
|
+
export interface VerifyHttpServiceRouteCheckItem {
|
|
349
|
+
Status: VerifyHttpServiceRouteCheckStatus;
|
|
350
|
+
Code?: VerifyHttpServiceRouteCheckCode;
|
|
351
|
+
Message?: string;
|
|
352
|
+
OwnershipVerification?: OwnershipVerificationInfo;
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* VerifyHTTPServiceRoute 请求参数
|
|
356
|
+
*/
|
|
357
|
+
export interface VerifyHttpServiceRouteParams {
|
|
358
|
+
EnvId: string;
|
|
359
|
+
Domain: HTTPServiceDomainParam;
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* VerifyHTTPServiceRoute 返回结果
|
|
363
|
+
*/
|
|
364
|
+
export interface VerifyHttpServiceRouteRes {
|
|
365
|
+
Passed: boolean;
|
|
366
|
+
Ownership: VerifyHttpServiceRouteCheckItem;
|
|
367
|
+
Cert: VerifyHttpServiceRouteCheckItem;
|
|
368
|
+
Quota: VerifyHttpServiceRouteCheckItem;
|
|
369
|
+
RouteConflict: VerifyHttpServiceRouteCheckItem;
|
|
370
|
+
DomainConflict: VerifyHttpServiceRouteCheckItem;
|
|
371
|
+
InternalAccount: VerifyHttpServiceRouteCheckItem;
|
|
372
|
+
Blacklist: VerifyHttpServiceRouteCheckItem;
|
|
373
|
+
CDNResource: VerifyHttpServiceRouteCheckItem;
|
|
374
|
+
EO: VerifyHttpServiceRouteCheckItem;
|
|
375
|
+
RequestId: string;
|
|
122
376
|
}
|
|
123
377
|
/**
|
|
124
378
|
* CreateHTTPServiceRoute 请求参数
|
|
@@ -317,46 +317,46 @@ export declare class FunctionService {
|
|
|
317
317
|
codeSecret: any;
|
|
318
318
|
}): Promise<IFunctionInfo[]>;
|
|
319
319
|
/**
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
320
|
+
* 获取函数日志
|
|
321
|
+
* @deprecated 底层 GetFunctionLogs 接口已下线,请使用 env.getLogService().searchClsLog() 查询云函数日志
|
|
322
|
+
* @param {{
|
|
323
|
+
* name: string
|
|
324
|
+
* offset: number
|
|
325
|
+
* limit: number
|
|
326
|
+
* order: string
|
|
327
|
+
* orderBy: string
|
|
328
|
+
* startTime: string
|
|
329
|
+
* endTime: string
|
|
330
|
+
* requestId: string
|
|
331
|
+
* }} options
|
|
332
|
+
* @returns {Promise<IFunctionLogRes>}
|
|
333
|
+
*/
|
|
334
334
|
getFunctionLogs(_options: IFunctionLogOptions): Promise<IFunctionLogRes>;
|
|
335
335
|
/**
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
336
|
+
* 获取函数日志 ID 列表
|
|
337
|
+
* @deprecated 底层 GetFunctionLogs 接口已下线,请使用 env.getLogService().searchClsLog() 查询云函数日志
|
|
338
|
+
* @param {{
|
|
339
|
+
* name: string
|
|
340
|
+
* offset: number
|
|
341
|
+
* limit: number
|
|
342
|
+
* startTime: string
|
|
343
|
+
* endTime: string
|
|
344
|
+
* requestId: string
|
|
345
|
+
* qualifier: string
|
|
346
|
+
* }} options
|
|
347
|
+
* @returns {Promise<IFunctionLogResV2>}
|
|
348
|
+
*/
|
|
349
349
|
getFunctionLogsV2(_options: IFunctionLogOptionsV2): Promise<IFunctionLogResV2>;
|
|
350
350
|
/**
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
351
|
+
* 根据函数日志 ID 查询日志详情
|
|
352
|
+
* @deprecated 底层 GetFunctionLogDetail 接口已下线,请使用 env.getLogService().searchClsLog() 查询云函数日志
|
|
353
|
+
* @param {{
|
|
354
|
+
* startTime: string
|
|
355
|
+
* endTime: string
|
|
356
|
+
* logRequestId: string
|
|
357
|
+
* }} options
|
|
358
|
+
* @returns {Promise<IFunctionLogDetailRes>}
|
|
359
|
+
*/
|
|
360
360
|
getFunctionLogDetail(_options: IFunctionLogDetailOptions): Promise<IFunctionLogDetailRes>;
|
|
361
361
|
/**
|
|
362
362
|
* 获取函数的完整调用日志
|
package/types/hosting/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export type OnFileFinish = (error: Error, res: any, fileData: any) => void;
|
|
|
11
11
|
export interface IHostingFileOptions {
|
|
12
12
|
localPath: string;
|
|
13
13
|
cloudPath?: string;
|
|
14
|
+
entryFiles?: string[];
|
|
14
15
|
parallel?: number;
|
|
15
16
|
files?: {
|
|
16
17
|
localPath: string;
|
|
@@ -21,10 +22,14 @@ export interface IHostingFileOptions {
|
|
|
21
22
|
ignore?: string | string[];
|
|
22
23
|
retryCount?: number;
|
|
23
24
|
retryInterval?: number;
|
|
25
|
+
verify?: boolean;
|
|
26
|
+
safe?: boolean;
|
|
27
|
+
prune?: boolean;
|
|
24
28
|
}
|
|
25
29
|
export interface IHostingFilesOptions {
|
|
26
30
|
localPath?: string;
|
|
27
31
|
cloudPath?: string;
|
|
32
|
+
entryFiles?: string[];
|
|
28
33
|
parallel?: number;
|
|
29
34
|
files: {
|
|
30
35
|
localPath: string;
|
|
@@ -35,6 +40,9 @@ export interface IHostingFilesOptions {
|
|
|
35
40
|
ignore?: string | string[];
|
|
36
41
|
retryCount?: number;
|
|
37
42
|
retryInterval?: number;
|
|
43
|
+
verify?: boolean;
|
|
44
|
+
safe?: boolean;
|
|
45
|
+
prune?: boolean;
|
|
38
46
|
}
|
|
39
47
|
export type IHostingOptions = IHostingFileOptions | IHostingFilesOptions;
|
|
40
48
|
export interface IHostingCloudOptions {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 流式计算文件 MD5(32 位小写十六进制),不将整个文件读入内存
|
|
3
|
+
*/
|
|
4
|
+
export declare function md5File(filePath: string): Promise<string>;
|
|
5
|
+
/**
|
|
6
|
+
* 将目录上传文件拆分为资源组和入口组,确保入口文件最后上传
|
|
7
|
+
*/
|
|
8
|
+
export declare function splitEntryUploadFiles(files: Array<{
|
|
9
|
+
localPath: string;
|
|
10
|
+
cloudPath: string;
|
|
11
|
+
}>, entryFiles?: string[]): {
|
|
12
|
+
resourceFiles: Array<{
|
|
13
|
+
localPath: string;
|
|
14
|
+
cloudPath: string;
|
|
15
|
+
}>;
|
|
16
|
+
entryUploadFiles: Array<{
|
|
17
|
+
localPath: string;
|
|
18
|
+
cloudPath: string;
|
|
19
|
+
}>;
|
|
20
|
+
};
|
package/types/storage/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Environment } from '../environment';
|
|
2
2
|
import { IUploadMetadata, IListFileInfo, IFileInfo, ITempUrlInfo, IResponseInfo } from '../interfaces';
|
|
3
|
-
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 } from './type';
|
|
3
|
+
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
4
|
export interface IProgressData {
|
|
5
5
|
loaded: number;
|
|
6
6
|
total: number;
|
|
@@ -17,6 +17,7 @@ export interface IOptions {
|
|
|
17
17
|
export interface IFileOptions extends IOptions {
|
|
18
18
|
localPath: string;
|
|
19
19
|
cloudPath?: string;
|
|
20
|
+
entryFiles?: string[];
|
|
20
21
|
parallel?: number;
|
|
21
22
|
retryCount?: number;
|
|
22
23
|
retryInterval?: number;
|
|
@@ -40,6 +41,44 @@ export interface IWalkCloudDirOptions {
|
|
|
40
41
|
region: string;
|
|
41
42
|
marker?: string;
|
|
42
43
|
}
|
|
44
|
+
export interface IGetRemoteManifestOptions extends ICustomOptions {
|
|
45
|
+
/** 云端前缀,无前导斜杠(如 'dist');空串表示整桶 */
|
|
46
|
+
prefix: string;
|
|
47
|
+
/** 列举起始 Marker;默认 '/' 会排除 . 开头的 Key,列举备份目录时需传 '' */
|
|
48
|
+
marker?: string;
|
|
49
|
+
}
|
|
50
|
+
/** 一致性发布:远端备份选项 */
|
|
51
|
+
export interface IBackupRemoteOptions extends IGetRemoteManifestOptions {
|
|
52
|
+
/** 备份目标前缀,须以 .cloudbase-backup/ 开头,如 .cloudbase-backup/1724073600000/ */
|
|
53
|
+
backupPrefix: string;
|
|
54
|
+
/** 复制并发数,默认 20 */
|
|
55
|
+
parallel?: number;
|
|
56
|
+
}
|
|
57
|
+
/** 一致性发布:从备份恢复选项 */
|
|
58
|
+
export interface IRestoreFromBackupOptions extends ICustomOptions {
|
|
59
|
+
/** 备份前缀,与 backupRemote 所传一致 */
|
|
60
|
+
backupPrefix: string;
|
|
61
|
+
/** 待恢复的覆盖文件 Key(相对桶根),来自 diffManifest().overwritten */
|
|
62
|
+
overwrittenKeys: string[];
|
|
63
|
+
/** 待删除的新增文件 Key(相对桶根),来自 diffManifest().added */
|
|
64
|
+
addedKeys: string[];
|
|
65
|
+
/** 恢复复制并发数,默认 20 */
|
|
66
|
+
parallel?: number;
|
|
67
|
+
}
|
|
68
|
+
/** 一致性发布:清理备份选项 */
|
|
69
|
+
export interface ICleanupBackupOptions extends ICustomOptions {
|
|
70
|
+
/** 需要清理的备份前缀,与 backupRemote 所传一致 */
|
|
71
|
+
backupPrefix: string;
|
|
72
|
+
}
|
|
73
|
+
/** 一致性发布:远端冗余文件清理选项 */
|
|
74
|
+
export interface IPruneRemoteOptions extends ICustomOptions {
|
|
75
|
+
/** 限定清理范围的前缀,无前导斜杠;空串表示根目录 */
|
|
76
|
+
prefix: string;
|
|
77
|
+
/** 待删除 Key(相对桶根),来自 diffManifest().removed;越界与备份 Key 会被自动过滤 */
|
|
78
|
+
removedKeys: string[];
|
|
79
|
+
/** 删除并发数,默认 20 */
|
|
80
|
+
parallel?: number;
|
|
81
|
+
}
|
|
43
82
|
export interface IRoutingRules {
|
|
44
83
|
keyPrefixEquals?: string;
|
|
45
84
|
httpErrorCodeReturnedEquals?: string;
|
|
@@ -151,10 +190,92 @@ export interface ISearchResult {
|
|
|
151
190
|
}
|
|
152
191
|
type OnProgress = (progressData: IProgressData) => void;
|
|
153
192
|
type OnFileFinish = (error: Error, res: any, fileData: any) => void;
|
|
193
|
+
export { md5File } from './helper';
|
|
154
194
|
export declare class StorageService {
|
|
155
195
|
private environment;
|
|
156
196
|
private tcbService;
|
|
157
197
|
constructor(environment: Environment);
|
|
198
|
+
/**
|
|
199
|
+
* 获取远端 manifest(默认 Storage 桶):返回指定前缀下文件的 key / etag / size,
|
|
200
|
+
* 过滤目录占位对象。prefix 无前导斜杠,空串表示整桶(Hosting 桶请用 getRemoteManifestCustom)。
|
|
201
|
+
*/
|
|
202
|
+
getRemoteManifest(prefix: string): Promise<IRemoteManifestItem[]>;
|
|
203
|
+
/**
|
|
204
|
+
* 获取远端 manifest,支持自定义 Bucket 和 Region。prefix 规则同 getRemoteManifest。
|
|
205
|
+
*/
|
|
206
|
+
getRemoteManifestCustom(options: IGetRemoteManifestOptions): Promise<IRemoteManifestItem[]>;
|
|
207
|
+
/**
|
|
208
|
+
* 生成本地 manifest:计算每个文件的云端 Key、MD5 与 Size。
|
|
209
|
+
* - filePaths 须来自 walkLocalDir(localPath),目录不计入
|
|
210
|
+
* - key = cloudPath + 文件相对路径;cloudPath 为空表示桶根
|
|
211
|
+
* - MD5 以受控并发计算,避免阻塞事件循环
|
|
212
|
+
*/
|
|
213
|
+
buildLocalManifest(options: {
|
|
214
|
+
localPath: string;
|
|
215
|
+
cloudPath?: string;
|
|
216
|
+
filePaths: string[];
|
|
217
|
+
parallel?: number;
|
|
218
|
+
}): Promise<ILocalManifestItem[]>;
|
|
219
|
+
/**
|
|
220
|
+
* 计算本地 manifest 与远端 manifest 的差异:
|
|
221
|
+
* - added:本地有、远端无;overwritten:两边都有;removed:远端有、本地无
|
|
222
|
+
* - 两份 manifest 的 key 须基于同一 cloudPath(removed 自动排除 .cloudbase-backup/)
|
|
223
|
+
*/
|
|
224
|
+
diffManifest(localManifest: ILocalManifestItem[], remoteManifest: IRemoteManifestItem[]): IManifestDiffResult;
|
|
225
|
+
/**
|
|
226
|
+
* 校验远端 manifest 与本地 manifest 是否一致:
|
|
227
|
+
* - 远端缺失 → missing;ETag 为纯 MD5 → 按 md5 比对;分块上传 ETag → 降级按 size 比对
|
|
228
|
+
*/
|
|
229
|
+
verifyManifest(localManifest: ILocalManifestItem[], remoteManifest: IRemoteManifestItem[]): IManifestVerifyResult;
|
|
230
|
+
/**
|
|
231
|
+
* 将指定前缀下的远端文件服务端复制到备份前缀(不产生下载流量)。
|
|
232
|
+
* 始终跳过 .cloudbase-backup/ 下的历史备份,避免根目录发布时递归备份。
|
|
233
|
+
*/
|
|
234
|
+
backupRemote(options: IBackupRemoteOptions): Promise<void>;
|
|
235
|
+
/**
|
|
236
|
+
* 从备份恢复被覆盖旧文件(服务端复制回原 Key),并删除本次新增文件。
|
|
237
|
+
* 任一阶段失败都会抛错,由上层决定是否保留备份供人工恢复。
|
|
238
|
+
*/
|
|
239
|
+
restoreFromBackup(options: IRestoreFromBackupOptions): Promise<void>;
|
|
240
|
+
/**
|
|
241
|
+
* 删除备份前缀下的全部对象。
|
|
242
|
+
* 备份目录以 . 开头,内部使用空 Marker 列举,不受默认排除规则影响。
|
|
243
|
+
*/
|
|
244
|
+
cleanupBackup(options: ICleanupBackupOptions): Promise<void>;
|
|
245
|
+
/**
|
|
246
|
+
* 清理发布后远端残留的冗余文件。
|
|
247
|
+
* 仅删除 removedKeys 中位于 prefix 范围内的 Key,排除 .cloudbase-backup/;
|
|
248
|
+
* 单个删除失败记入 failedKeys,不影响其他文件。
|
|
249
|
+
*/
|
|
250
|
+
pruneRemote(options: IPruneRemoteOptions): Promise<IPruneResult>;
|
|
251
|
+
/**
|
|
252
|
+
* 一致性目录上传编排(safe、verify、prune)
|
|
253
|
+
*
|
|
254
|
+
* 执行流程(按顺序):
|
|
255
|
+
* 1. 扫描本地目录,生成 manifest(key/md5/size)
|
|
256
|
+
* 2. safe 或 prune 开启时:拉取远端快照 manifest,与本地做 diff
|
|
257
|
+
* (safe 用 diff 判定回滚范围;prune 用 diff.removed 判定待清理文件)
|
|
258
|
+
* 3. safe 开启时:将远端文件服务端复制到备份前缀 .cloudbase-backup/<时间戳>/
|
|
259
|
+
* 4. 执行目录上传(资源文件先传,入口文件 entries 最后传)
|
|
260
|
+
* 5. verify 开启时:重新拉取远端 manifest,逐文件校验 ETag/MD5 与 size
|
|
261
|
+
* 6. 上传与校验全部成功后,prune 开启时:删除 diff.removed 中仍冗余的远端文件
|
|
262
|
+
* 7. 返回 uploadedKeys / verified / backupPrefix / prune 结果
|
|
263
|
+
*
|
|
264
|
+
* 失败时的行为:
|
|
265
|
+
* - 步骤 4/5 失败且 safe 开启:自动从备份回滚(恢复被覆盖文件、删除本次新增
|
|
266
|
+
* 文件),回滚成功后抛出“已自动回滚”错误,备份保留供人工核查
|
|
267
|
+
* - 回滚失败:保留备份并在错误信息中给出备份位置,供人工恢复
|
|
268
|
+
* - 备份一律不由本编排自动清理,均需调用方确认后通过 cleanupBackup 显式删除
|
|
269
|
+
* - prune 仅在步骤 4/5 全部成功后执行,失败发布绝不会触发远端删除
|
|
270
|
+
*
|
|
271
|
+
* ⚠️ 危险参数:prune
|
|
272
|
+
* prune 会删除云端 cloudPath 前缀下、本次本地构建中不存在的全部文件。
|
|
273
|
+
* 若调用方误传了错误的 localPath/cloudPath,整目录都会被判定为“冗余”而删除。
|
|
274
|
+
* 发布成功后备份默认保留、不自动清理:prune 误删的文件可从备份前缀
|
|
275
|
+
* (.cloudbase-backup/<时间戳>/)人工恢复;调用方确认无误后应通过
|
|
276
|
+
* cleanupBackup 显式清理备份。调用方(CLI)仍须在开启 prune 前要求用户二次确认。
|
|
277
|
+
*/
|
|
278
|
+
uploadDirectoryConsistent(options: IConsistentUploadOptions): Promise<IConsistentUploadResult>;
|
|
158
279
|
/**
|
|
159
280
|
* 上传文件
|
|
160
281
|
* localPath 为文件夹时,会尝试在文件夹中寻找 cloudPath 中的文件名
|
|
@@ -311,6 +432,8 @@ export declare class StorageService {
|
|
|
311
432
|
*/
|
|
312
433
|
deleteDirectoryCustom(options: {
|
|
313
434
|
cloudPath: string;
|
|
435
|
+
/** 列举起始 Marker,默认 '/' 会排除 . 开头的 Key;清理备份目录时需传 '' */
|
|
436
|
+
marker?: string;
|
|
314
437
|
} & ICustomOptions): Promise<{
|
|
315
438
|
Deleted: {
|
|
316
439
|
Key: string;
|
|
@@ -595,4 +718,3 @@ export declare class StorageService {
|
|
|
595
718
|
private inferMimeByMagicBytes;
|
|
596
719
|
private assertValidContentType;
|
|
597
720
|
}
|
|
598
|
-
export {};
|