@yvhitxcel/opencode-remote 0.15.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/README.md +82 -0
- package/bin/opencode-remote.js +70 -0
- package/bin/opencode-weixin.js +10 -0
- package/dist/AGENTS.md +20 -0
- package/dist/MEMORY.md +21 -0
- package/dist/bot-runner.js +180 -0
- package/dist/cli.js +256 -0
- package/dist/core/approval.js +95 -0
- package/dist/core/auth.js +119 -0
- package/dist/core/config.js +61 -0
- package/dist/core/notifications.js +134 -0
- package/dist/core/qiniu.js +267 -0
- package/dist/core/registry.js +86 -0
- package/dist/core/router.js +344 -0
- package/dist/core/session.js +403 -0
- package/dist/core/setup.js +418 -0
- package/dist/core/types.js +16 -0
- package/dist/feishu/adapter.js +72 -0
- package/dist/feishu/bot.js +168 -0
- package/dist/feishu/commands.js +601 -0
- package/dist/feishu/handler.js +380 -0
- package/dist/index.js +60 -0
- package/dist/opencode/client.js +823 -0
- package/dist/package-lock.json +762 -0
- package/dist/patch_spawn.js +28 -0
- package/dist/plugins/agents/acp/acp-adapter.js +42 -0
- package/dist/plugins/agents/claude-code/index.js +69 -0
- package/dist/plugins/agents/codex/index.js +44 -0
- package/dist/plugins/agents/copilot/index.js +44 -0
- package/dist/plugins/agents/opencode/index.js +66 -0
- package/dist/telegram/bot.js +288 -0
- package/dist/utils/message-split.js +38 -0
- package/dist/web/code-viewer.js +266 -0
- package/dist/weixin/adapter.js +135 -0
- package/dist/weixin/api.js +179 -0
- package/dist/weixin/bot.js +183 -0
- package/dist/weixin/commands.js +758 -0
- package/dist/weixin/handler.js +577 -0
- package/dist/weixin/node_modules/encodeurl/LICENSE +22 -0
- package/dist/weixin/node_modules/encodeurl/README.md +109 -0
- package/dist/weixin/node_modules/encodeurl/index.js +60 -0
- package/dist/weixin/node_modules/encodeurl/package.json +40 -0
- package/dist/weixin/node_modules/qiniu/.claude/settings.local.json +7 -0
- package/dist/weixin/node_modules/qiniu/.github/workflows/ci-test.yml +36 -0
- package/dist/weixin/node_modules/qiniu/.github/workflows/npm-publish.yml +20 -0
- package/dist/weixin/node_modules/qiniu/.github/workflows/version-check.yml +19 -0
- package/dist/weixin/node_modules/qiniu/.idea/MarsCodeWorkspaceAppSettings.xml +7 -0
- package/dist/weixin/node_modules/qiniu/.idea/codeStyles/Project.xml +44 -0
- package/dist/weixin/node_modules/qiniu/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/dist/weixin/node_modules/qiniu/.idea/git_toolbox_blame.xml +6 -0
- package/dist/weixin/node_modules/qiniu/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/dist/weixin/node_modules/qiniu/.idea/jsLibraryMappings.xml +6 -0
- package/dist/weixin/node_modules/qiniu/.idea/modules.xml +8 -0
- package/dist/weixin/node_modules/qiniu/.idea/nodejs-sdk.iml +12 -0
- package/dist/weixin/node_modules/qiniu/.idea/vcs.xml +6 -0
- package/dist/weixin/node_modules/qiniu/CHANGELOG.md +292 -0
- package/dist/weixin/node_modules/qiniu/README.md +56 -0
- package/dist/weixin/node_modules/qiniu/StorageResponseInterface.d.ts +239 -0
- package/dist/weixin/node_modules/qiniu/codecov.yml +28 -0
- package/dist/weixin/node_modules/qiniu/index.d.ts +1995 -0
- package/dist/weixin/node_modules/qiniu/index.js +32 -0
- package/dist/weixin/node_modules/qiniu/node_modules/encodeurl/HISTORY.md +14 -0
- package/dist/weixin/node_modules/qiniu/node_modules/encodeurl/LICENSE +22 -0
- package/dist/weixin/node_modules/qiniu/node_modules/encodeurl/README.md +128 -0
- package/dist/weixin/node_modules/qiniu/node_modules/encodeurl/index.js +60 -0
- package/dist/weixin/node_modules/qiniu/node_modules/encodeurl/package.json +40 -0
- package/dist/weixin/node_modules/qiniu/package.json +80 -0
- package/dist/weixin/node_modules/qiniu/qiniu/auth/digest.js +13 -0
- package/dist/weixin/node_modules/qiniu/qiniu/cdn.js +149 -0
- package/dist/weixin/node_modules/qiniu/qiniu/conf.js +254 -0
- package/dist/weixin/node_modules/qiniu/qiniu/fop.js +112 -0
- package/dist/weixin/node_modules/qiniu/qiniu/httpc/client.js +253 -0
- package/dist/weixin/node_modules/qiniu/qiniu/httpc/endpoint.js +66 -0
- package/dist/weixin/node_modules/qiniu/qiniu/httpc/endpointsProvider.js +27 -0
- package/dist/weixin/node_modules/qiniu/qiniu/httpc/endpointsRetryPolicy.js +76 -0
- package/dist/weixin/node_modules/qiniu/qiniu/httpc/middleware/base.js +31 -0
- package/dist/weixin/node_modules/qiniu/qiniu/httpc/middleware/index.js +9 -0
- package/dist/weixin/node_modules/qiniu/qiniu/httpc/middleware/qiniuAuth.js +53 -0
- package/dist/weixin/node_modules/qiniu/qiniu/httpc/middleware/retryDomains.js +101 -0
- package/dist/weixin/node_modules/qiniu/qiniu/httpc/middleware/ua.js +36 -0
- package/dist/weixin/node_modules/qiniu/qiniu/httpc/region.js +349 -0
- package/dist/weixin/node_modules/qiniu/qiniu/httpc/regionsProvider.js +788 -0
- package/dist/weixin/node_modules/qiniu/qiniu/httpc/regionsRetryPolicy.js +242 -0
- package/dist/weixin/node_modules/qiniu/qiniu/httpc/responseWrapper.js +40 -0
- package/dist/weixin/node_modules/qiniu/qiniu/retry/index.js +4 -0
- package/dist/weixin/node_modules/qiniu/qiniu/retry/retrier.js +99 -0
- package/dist/weixin/node_modules/qiniu/qiniu/retry/retryPolicy.js +55 -0
- package/dist/weixin/node_modules/qiniu/qiniu/rpc.js +237 -0
- package/dist/weixin/node_modules/qiniu/qiniu/rtc/app.js +123 -0
- package/dist/weixin/node_modules/qiniu/qiniu/rtc/credentials.js +57 -0
- package/dist/weixin/node_modules/qiniu/qiniu/rtc/room.js +118 -0
- package/dist/weixin/node_modules/qiniu/qiniu/rtc/util.js +16 -0
- package/dist/weixin/node_modules/qiniu/qiniu/sms/message.js +58 -0
- package/dist/weixin/node_modules/qiniu/qiniu/storage/form.js +442 -0
- package/dist/weixin/node_modules/qiniu/qiniu/storage/internal.js +214 -0
- package/dist/weixin/node_modules/qiniu/qiniu/storage/resume.js +1272 -0
- package/dist/weixin/node_modules/qiniu/qiniu/storage/rs.js +1764 -0
- package/dist/weixin/node_modules/qiniu/qiniu/util.js +382 -0
- package/dist/weixin/node_modules/qiniu/qiniu/zone.js +230 -0
- package/dist/weixin/node_modules/qiniu/tsconfig.json +112 -0
- package/dist/weixin/types.js +25 -0
- package/package.json +56 -0
|
@@ -0,0 +1,1995 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* typescript definition for qiniu 7.x
|
|
3
|
+
* @author xialeistudio<xialeistudio@gmail.com>
|
|
4
|
+
*/
|
|
5
|
+
import {Callback, RequestOptions} from 'urllib';
|
|
6
|
+
import {Agent as HttpAgent, IncomingMessage} from 'http';
|
|
7
|
+
import {Agent as HttpsAgent} from 'https';
|
|
8
|
+
import {Readable} from "stream";
|
|
9
|
+
import {
|
|
10
|
+
BatchOpsResult,
|
|
11
|
+
FetchObjectResult,
|
|
12
|
+
GetBucketCorsRulesResult,
|
|
13
|
+
GetBucketDomainsV3Result,
|
|
14
|
+
GetBucketEventsResult,
|
|
15
|
+
GetBucketInfoV2Result,
|
|
16
|
+
GetBucketQuotaResult,
|
|
17
|
+
GetBucketRulesResult,
|
|
18
|
+
GetBucketsResult,
|
|
19
|
+
GetObjectsResult,
|
|
20
|
+
StatObjectResult
|
|
21
|
+
} from "./StorageResponseInterface";
|
|
22
|
+
|
|
23
|
+
export declare type callback<T = any> = (e?: Error, respBody?: T, respInfo?: any) => void;
|
|
24
|
+
|
|
25
|
+
export declare namespace auth {
|
|
26
|
+
namespace digest {
|
|
27
|
+
interface MacOptions {
|
|
28
|
+
disableQiniuTimestampSignature?: boolean;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
class Mac {
|
|
32
|
+
accessKey: string;
|
|
33
|
+
secretKey: string;
|
|
34
|
+
options: MacOptions;
|
|
35
|
+
|
|
36
|
+
constructor(accessKey?: string, secretKey?: string, options?: MacOptions);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export declare namespace cdn {
|
|
42
|
+
class CdnManager {
|
|
43
|
+
mac: auth.digest.Mac;
|
|
44
|
+
|
|
45
|
+
constructor(mac?: auth.digest.Mac);
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* 获取域名日志下载链接
|
|
49
|
+
* @see http://developer.qiniu.com/article/fusion/api/log.html
|
|
50
|
+
*
|
|
51
|
+
* @param domains 域名列表 如:['obbid7qc6.qnssl.com','7xkh68.com1.z0.glb.clouddn.com']
|
|
52
|
+
* @param logDay logDay 如 2016-07-01
|
|
53
|
+
* @param callback callbackFunc(err, respBody, respInfo)
|
|
54
|
+
*/
|
|
55
|
+
getCdnLogList(domains: string[], logDay: string, callback: callback): void;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* 获取域名访问流量数据
|
|
59
|
+
* @see http://developer.qiniu.com/article/fusion/api/traffic-bandwidth.html#batch-flux
|
|
60
|
+
*
|
|
61
|
+
* @param startDate 开始日期,例如:2016-07-01
|
|
62
|
+
* @param endDate 结束日期,例如:2016-07-03
|
|
63
|
+
* @param granularity 粒度,取值:5min/hour/day
|
|
64
|
+
* @param domains 域名列表 domain = ['obbid7qc6.qnssl.com','obbid7qc6.qnssl.com'];
|
|
65
|
+
* @param callback callbackFunc(err, respBody, respInfo)
|
|
66
|
+
*/
|
|
67
|
+
getFluxData(startDate: string, endDate: string, granularity: string, domains: string[], callback: callback): void;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* 获取域名带宽数据
|
|
71
|
+
* @see http://developer.qiniu.com/article/fusion/api/traffic-bandwidth.html#batch-flux
|
|
72
|
+
* @param startDate 开始日期,例如:2016-07-01
|
|
73
|
+
* @param endDate 结束日期,例如:2016-07-03
|
|
74
|
+
* @param granularity 粒度,取值:5min/hour/day
|
|
75
|
+
* @param domains 域名列表 domain = ['obbid7qc6.qnssl.com','obbid7qc6.qnssl.com'];
|
|
76
|
+
* @param callback callbackFunc(err, respBody, respInfo)
|
|
77
|
+
*/
|
|
78
|
+
getBandwidthData(startDate: string, endDate: string, granularity: string, domains: string[], callback: callback): void;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* 预取文件链接
|
|
82
|
+
* @see http://developer.qiniu.com/article/fusion/api/prefetch.html
|
|
83
|
+
*
|
|
84
|
+
* @param urls 预取urls urls = ['http://obbid7qc6.qnssl.com/023','http://obbid7qc6.qnssl.com/025']
|
|
85
|
+
* @param callback callbackFunc(err, respBody, respInfo)
|
|
86
|
+
*/
|
|
87
|
+
prefetchUrls(urls: string[], callback: callback): void;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* 刷新链接
|
|
91
|
+
* @see http://developer.qiniu.com/article/fusion/api/refresh.html
|
|
92
|
+
*
|
|
93
|
+
* @param urls refreshUrls = ['http://obbid7qc6.qnssl.com/023','http://obbid7qc6.qnssl.com/025']
|
|
94
|
+
* @param callback callbackFunc(err, respBody, respInfo)
|
|
95
|
+
*/
|
|
96
|
+
refreshUrls(urls: string[], callback: callback): void;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* 刷新目录列表,每次最多不可以超过10个目录, 刷新目录需要额外开通权限,可以联系七牛技术支持处理
|
|
100
|
+
* @see http://developer.qiniu.com/article/fusion/api/refresh.html
|
|
101
|
+
*
|
|
102
|
+
* @param dirs refreshDirs = ['http://obbid7qc6.qnssl.com/wo/','http://obbid7qc6.qnssl.com/']
|
|
103
|
+
* @param callback callbackFunc(err, respBody, respInfo)
|
|
104
|
+
*/
|
|
105
|
+
refreshDirs(dirs: string[], callback: callback): void;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* 刷新目录和链接
|
|
109
|
+
* @param urls refreshUrls = ['http://obbid7qc6.qnssl.com/023','http://obbid7qc6.qnssl.com/025']
|
|
110
|
+
* @param dirs refreshDirs = ['http://obbid7qc6.qnssl.com/wo/','http://obbid7qc6.qnssl.com/']
|
|
111
|
+
* @param callback callbackFunc(err, respBody, respInfo)
|
|
112
|
+
*/
|
|
113
|
+
refreshUrlsAndDirs(urls: string[], dirs: string[], callback: callback): void;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* 构建标准的基于时间戳的防盗链
|
|
117
|
+
* @param domain 自定义域名,例如 http://img.abc.com
|
|
118
|
+
* @param fileName 待访问的原始文件名,必须是utf8编码,不需要进行urlencode
|
|
119
|
+
* @param query 业务自身的查询参数,必须是utf8编码,不需要进行urlencode, 例如 {aa:"23", attname:"11111111111111"}
|
|
120
|
+
* @param encryptKey 时间戳防盗链的签名密钥,从七牛后台获取
|
|
121
|
+
* @param deadline 链接的有效期时间戳,是以秒为单位的Unix时间戳
|
|
122
|
+
* @return signedUrl 最终的带时间戳防盗链的url
|
|
123
|
+
*/
|
|
124
|
+
createTimestampAntiLeechUrl(domain: string, fileName: string, query: any, encryptKey: string, deadline: number): string;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export declare namespace conf {
|
|
129
|
+
let ACCESS_KEY: string;
|
|
130
|
+
let SECRET_KEY: string;
|
|
131
|
+
let USER_AGENT: string;
|
|
132
|
+
let BLOCK_SIZE: number;
|
|
133
|
+
let FormMimeUrl: string;
|
|
134
|
+
let FormMimeJson: string;
|
|
135
|
+
let FormMimeRaw: string;
|
|
136
|
+
let RS_HOST: string;
|
|
137
|
+
let RPC_TIMEOUT: number;
|
|
138
|
+
|
|
139
|
+
interface getRegionsProviderOptions {
|
|
140
|
+
bucketName: string;
|
|
141
|
+
accessKey: string;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
interface ConfigOptions {
|
|
145
|
+
/**
|
|
146
|
+
* @default false
|
|
147
|
+
*/
|
|
148
|
+
useHttpsDomain?: boolean;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* 在使用前需要提前开通加速域名
|
|
152
|
+
* 详见:https://developer.qiniu.com/kodo/12656/transfer-acceleration
|
|
153
|
+
* @default false
|
|
154
|
+
*/
|
|
155
|
+
accelerateUploading?: boolean;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* @deprecated 实际已无加速上传能力,使用 accelerateUploading 代替
|
|
159
|
+
* @default true
|
|
160
|
+
*/
|
|
161
|
+
useCdnDomain?: boolean;
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* @default null
|
|
165
|
+
*/
|
|
166
|
+
ucEndpointsProvider?: httpc.EndpointsProvider;
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* @default null
|
|
170
|
+
*/
|
|
171
|
+
queryRegionsEndpointsProvider?: httpc.EndpointsProvider;
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* @deprecated use regionsProvider instead
|
|
175
|
+
* @default null
|
|
176
|
+
*/
|
|
177
|
+
zone?: Zone;
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* @deprecated
|
|
181
|
+
* @default -1
|
|
182
|
+
*/
|
|
183
|
+
zoneExpire?: number;
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* @default null
|
|
187
|
+
*/
|
|
188
|
+
regionsProvider?: httpc.RegionsProvider;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
class Config {
|
|
192
|
+
useHttpsDomain: boolean;
|
|
193
|
+
accelerateUploading: boolean;
|
|
194
|
+
/**
|
|
195
|
+
* @deprecated 实际已无加速上传能力,使用 accelerateUploading 代替
|
|
196
|
+
*/
|
|
197
|
+
useCdnDomain: boolean;
|
|
198
|
+
ucEndpointsProvider?: httpc.EndpointsProvider | null;
|
|
199
|
+
queryRegionsEndpointsProvider?: httpc.EndpointsProvider | null;
|
|
200
|
+
regionsProvider?: httpc.RegionsProvider | null;
|
|
201
|
+
regionsQueryResultCachePath?: string | null;
|
|
202
|
+
zone?: Zone | null;
|
|
203
|
+
zoneExpire?: number;
|
|
204
|
+
|
|
205
|
+
constructor(options?: ConfigOptions);
|
|
206
|
+
|
|
207
|
+
getUcEndpointsProvider(): httpc.EndpointsProvider;
|
|
208
|
+
|
|
209
|
+
getRegionsProvider(options?: getRegionsProviderOptions): Promise<httpc.RegionsProvider>
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
class Zone {
|
|
213
|
+
srcUpHosts: any;
|
|
214
|
+
cdnUpHosts: any;
|
|
215
|
+
ioHost: string;
|
|
216
|
+
rsHost: string;
|
|
217
|
+
rsfHost: string;
|
|
218
|
+
apiHost: string;
|
|
219
|
+
|
|
220
|
+
constructor(srcUpHosts?: any, cdnUpHosts?: any, ioHost?: string, rsHost?: string, rsfHost?: string, apiHost?: string);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export declare namespace form_up {
|
|
225
|
+
type UploadResult = httpc.ResponseWrapper
|
|
226
|
+
|
|
227
|
+
class FormUploader {
|
|
228
|
+
conf: conf.Config;
|
|
229
|
+
|
|
230
|
+
constructor(config?: conf.Config);
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
*
|
|
234
|
+
* @param uploadToken
|
|
235
|
+
* @param key
|
|
236
|
+
* @param fsStream
|
|
237
|
+
* @param putExtra
|
|
238
|
+
* @param callback
|
|
239
|
+
*/
|
|
240
|
+
putStream(
|
|
241
|
+
uploadToken: string,
|
|
242
|
+
key: string | null,
|
|
243
|
+
fsStream: NodeJS.ReadableStream,
|
|
244
|
+
putExtra: PutExtra | null,
|
|
245
|
+
callback?: callback
|
|
246
|
+
): Promise<UploadResult>;
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
*
|
|
250
|
+
* @param uploadToken
|
|
251
|
+
* @param key
|
|
252
|
+
* @param body
|
|
253
|
+
* @param putExtra
|
|
254
|
+
* @param callback
|
|
255
|
+
*/
|
|
256
|
+
put(
|
|
257
|
+
uploadToken: string,
|
|
258
|
+
key: string | null,
|
|
259
|
+
body: any,
|
|
260
|
+
putExtra: PutExtra | null,
|
|
261
|
+
callback?: callback
|
|
262
|
+
): Promise<UploadResult>;
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
*
|
|
266
|
+
* @param uploadToken
|
|
267
|
+
* @param body
|
|
268
|
+
* @param putExtra
|
|
269
|
+
* @param callback
|
|
270
|
+
*/
|
|
271
|
+
putWithoutKey(
|
|
272
|
+
uploadToken: string,
|
|
273
|
+
body: any,
|
|
274
|
+
putExtra: PutExtra | null,
|
|
275
|
+
callback?: callback
|
|
276
|
+
): Promise<UploadResult>;
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* 上传本地文件
|
|
280
|
+
* @param uploadToken 上传凭证
|
|
281
|
+
* @param key 目标文件名
|
|
282
|
+
* @param localFile 本地文件路径
|
|
283
|
+
* @param putExtra 额外选项
|
|
284
|
+
* @param callback
|
|
285
|
+
*/
|
|
286
|
+
putFile(
|
|
287
|
+
uploadToken: string,
|
|
288
|
+
key: string | null,
|
|
289
|
+
localFile: string,
|
|
290
|
+
putExtra: PutExtra | null,
|
|
291
|
+
callback?: callback
|
|
292
|
+
): Promise<UploadResult>;
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
*
|
|
296
|
+
* @param uploadToken
|
|
297
|
+
* @param localFile
|
|
298
|
+
* @param putExtra
|
|
299
|
+
* @param callback
|
|
300
|
+
*/
|
|
301
|
+
putFileWithoutKey(
|
|
302
|
+
uploadToken: string,
|
|
303
|
+
localFile: string,
|
|
304
|
+
putExtra: PutExtra | null,
|
|
305
|
+
callback?: callback
|
|
306
|
+
): Promise<UploadResult>;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
class PutExtra {
|
|
310
|
+
/**
|
|
311
|
+
* @default ''
|
|
312
|
+
*/
|
|
313
|
+
fname: string;
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* @default {}
|
|
317
|
+
*/
|
|
318
|
+
params: Record<string, string>;
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* @default null
|
|
322
|
+
*/
|
|
323
|
+
mimeType?: string;
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* @default null
|
|
327
|
+
*/
|
|
328
|
+
crc32?: string;
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* @default 0|false
|
|
332
|
+
*/
|
|
333
|
+
checkCrc?: number | boolean;
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* @default {}
|
|
337
|
+
*/
|
|
338
|
+
metadata?: Record<string, string>;
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* 上传可选参数
|
|
342
|
+
* @param fname 请求体中的文件的名称
|
|
343
|
+
* @param params 额外参数设置,参数名称必须以x:开头
|
|
344
|
+
* @param mimeType 指定文件的mimeType
|
|
345
|
+
* @param crc32 指定文件的crc32值
|
|
346
|
+
* @param checkCrc 指定是否检测文件的crc32值
|
|
347
|
+
* @param metadata 元数据设置,参数名称必须以 x-qn-meta-${name}: 开头
|
|
348
|
+
*/
|
|
349
|
+
constructor(fname?: string, params?: Record<string, string>, mimeType?: string, crc32?: string, checkCrc?: number | boolean, metadata?: Record<string, string>);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
export declare namespace resume_up {
|
|
354
|
+
type UploadResult = {
|
|
355
|
+
data: any;
|
|
356
|
+
resp: Omit<IncomingMessage, 'url'> & { requestUrls: string[] };
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
class ResumeUploader {
|
|
360
|
+
config: conf.Config;
|
|
361
|
+
|
|
362
|
+
constructor(config?: conf.Config);
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* 通过数据流的方式上传一个文件,如果不指定文件保存的 key,服务会自动生成一个key;
|
|
366
|
+
* 如果 putExtra 为 null,则默认使用使用分片 v2 进行上传
|
|
367
|
+
*
|
|
368
|
+
* @param uploadToken
|
|
369
|
+
* @param key
|
|
370
|
+
* @param rsStream
|
|
371
|
+
* @param rsStreamLen
|
|
372
|
+
* @param putExtra
|
|
373
|
+
* @param callback
|
|
374
|
+
*/
|
|
375
|
+
putStream(
|
|
376
|
+
uploadToken: string,
|
|
377
|
+
key: string | null,
|
|
378
|
+
rsStream: NodeJS.ReadableStream,
|
|
379
|
+
rsStreamLen: number,
|
|
380
|
+
putExtra: PutExtra | null,
|
|
381
|
+
callback?: callback
|
|
382
|
+
): Promise<UploadResult>;
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* 通过数据流的方式上传一个文件,如果不指定文件保存的 key,服务会自动生成一个key;
|
|
386
|
+
* 如果 putExtra 为 null,则默认使用使用分片 v2 进行上传
|
|
387
|
+
*
|
|
388
|
+
* @param uploadToken
|
|
389
|
+
* @param key
|
|
390
|
+
* @param rsStream
|
|
391
|
+
* @param rsStreamLen
|
|
392
|
+
* @param putExtra
|
|
393
|
+
* @param callback
|
|
394
|
+
*/
|
|
395
|
+
putStreamV2(
|
|
396
|
+
uploadToken: string,
|
|
397
|
+
key: string | null,
|
|
398
|
+
rsStream: NodeJS.ReadableStream,
|
|
399
|
+
rsStreamLen: number,
|
|
400
|
+
putExtra: PutExtra | null,
|
|
401
|
+
callback?: callback
|
|
402
|
+
): Promise<UploadResult>;
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* 上传一个文件,如果不指定文件保存的 key,服务会自动生成一个key;
|
|
406
|
+
* 如果 putExtra 为 null,则默认使用使用分片 v2 进行上传
|
|
407
|
+
*
|
|
408
|
+
* @param uploadToken
|
|
409
|
+
* @param key
|
|
410
|
+
* @param localFile
|
|
411
|
+
* @param putExtra
|
|
412
|
+
* @param callback
|
|
413
|
+
*/
|
|
414
|
+
putFile(
|
|
415
|
+
uploadToken: string,
|
|
416
|
+
key: string | null,
|
|
417
|
+
localFile: string,
|
|
418
|
+
putExtra: PutExtra | null,
|
|
419
|
+
callback?: callback
|
|
420
|
+
): Promise<UploadResult>;
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* 上传一个文件,不指定文件保存的 key,服务会自动生成一个key;
|
|
424
|
+
* 如果 putExtra 为 null,则默认使用使用分片 v2 进行上传
|
|
425
|
+
*
|
|
426
|
+
* @param uploadToken
|
|
427
|
+
* @param key
|
|
428
|
+
* @param localFile
|
|
429
|
+
* @param putExtra
|
|
430
|
+
* @param callback
|
|
431
|
+
*/
|
|
432
|
+
putFileV2(
|
|
433
|
+
uploadToken: string,
|
|
434
|
+
key: string | null,
|
|
435
|
+
localFile: string,
|
|
436
|
+
putExtra: PutExtra | null,
|
|
437
|
+
callback?: callback
|
|
438
|
+
): Promise<UploadResult>;
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
*
|
|
442
|
+
* @param uploadToken
|
|
443
|
+
* @param localFile
|
|
444
|
+
* @param putExtra
|
|
445
|
+
* @param callback
|
|
446
|
+
*/
|
|
447
|
+
putFileWithoutKey(
|
|
448
|
+
uploadToken: string,
|
|
449
|
+
localFile: string,
|
|
450
|
+
putExtra: PutExtra | null,
|
|
451
|
+
callback?: callback
|
|
452
|
+
): Promise<UploadResult>;
|
|
453
|
+
|
|
454
|
+
/**
|
|
455
|
+
* 上传一个文件,不指定文件保存的 key,服务会自动生成一个key;
|
|
456
|
+
* 如果 putExtra 为 null,则默认使用使用分片 v2 进行上传
|
|
457
|
+
*
|
|
458
|
+
* @param uploadToken
|
|
459
|
+
* @param localFile
|
|
460
|
+
* @param putExtra
|
|
461
|
+
* @param callback
|
|
462
|
+
*/
|
|
463
|
+
putFileWithoutKeyV2(
|
|
464
|
+
uploadToken: string,
|
|
465
|
+
localFile: string,
|
|
466
|
+
putExtra: PutExtra | null,
|
|
467
|
+
callback?: callback
|
|
468
|
+
): Promise<UploadResult>;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
class PutExtra {
|
|
472
|
+
/**
|
|
473
|
+
* @default ''
|
|
474
|
+
*/
|
|
475
|
+
fname?: string;
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* @default {}
|
|
479
|
+
*/
|
|
480
|
+
params?: Record<string, string>;
|
|
481
|
+
|
|
482
|
+
/**
|
|
483
|
+
* @default null
|
|
484
|
+
*/
|
|
485
|
+
mimeType?: string;
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
* @default null
|
|
489
|
+
* @deprecated 使用 `resumeRecorder` 与 `resumeKey` 代替
|
|
490
|
+
*/
|
|
491
|
+
resumeRecordFile?: string | null
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* @default null
|
|
495
|
+
*/
|
|
496
|
+
progressCallback?: ((uploadBytes: number, totalBytes: number) => void) | null
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* @default v1
|
|
500
|
+
*/
|
|
501
|
+
version?: string
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* @default 4 * 1024 * 1024
|
|
505
|
+
*/
|
|
506
|
+
partSize?: number
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* @default {}
|
|
510
|
+
*/
|
|
511
|
+
metadata?: Record<string, string>
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* 断点续传记录器,请通过 `createResumeRecorder` 或 `createResumeRecorderSync` 获取,优先级比 `resumeRecordFile` 低
|
|
515
|
+
* @default null
|
|
516
|
+
*/
|
|
517
|
+
resumeRecorder?: ResumeRecorder
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* 断点续传记录文件的具体文件名,不设置时会由当次上传自动生成
|
|
521
|
+
* @default null
|
|
522
|
+
*/
|
|
523
|
+
resumeKey?: string | null
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* 上传可选参数
|
|
527
|
+
* @param fname 请求体中的文件的名称
|
|
528
|
+
* @param params 额外参数设置,参数名称必须以x:开头
|
|
529
|
+
* @param mimeType 指定文件的mimeType
|
|
530
|
+
* @param resumeRecordFile
|
|
531
|
+
* @param progressCallback
|
|
532
|
+
* @param partSize 分片上传v2必传字段 默认大小为4MB 分片大小范围为1 MB - 1 GB
|
|
533
|
+
* @param version 分片上传版本 目前支持v1/v2版本 默认v1
|
|
534
|
+
* @param metadata 元数据设置,参数名称必须以 x-qn-meta-${name}: 开头
|
|
535
|
+
* @param resumeRecorder 断点续传记录器,请通过 `createResumeRecorder` 或 `createResumeRecorderSync` 获取,优先级比 `resumeRecordFile` 低
|
|
536
|
+
* @param resumeKey 断点续传记录文件的具体文件名,不设置时会由当次上传自动生成,推荐不设置
|
|
537
|
+
*/
|
|
538
|
+
constructor(fname?: string, params?: Record<string, string>, mimeType?: string, resumeRecordFile?: string,
|
|
539
|
+
progressCallback?: (uploadBytes: number, totalBytes: number) => void,
|
|
540
|
+
partSize?: number, version?: string, metadata?: Record<string, string>,
|
|
541
|
+
resumeRecorder?: ResumeRecorder, resumeKey?: string);
|
|
542
|
+
|
|
543
|
+
/**
|
|
544
|
+
* 上传可选参数
|
|
545
|
+
* @param fname 请求体中的文件的名称
|
|
546
|
+
* @param params 额外参数设置,参数名称必须以x:开头
|
|
547
|
+
* @param mimeType 指定文件的mimeType
|
|
548
|
+
* @param resumeRecordFile
|
|
549
|
+
* @param progressCallback
|
|
550
|
+
* @param partSize 分片上传v2必传字段 默认大小为4MB 分片大小范围为1 MB - 1 GB
|
|
551
|
+
* @param version 分片上传版本 目前支持v1/v2版本 默认v2
|
|
552
|
+
* @param metadata 元数据设置,参数名称必须以 x-qn-meta-${name}: 开头
|
|
553
|
+
* @param resumeRecorder 断点续传记录器,请通过 `createResumeRecorder` 或 `createResumeRecorderSync` 获取,优先级比 `resumeRecordFile` 低
|
|
554
|
+
* @param resumeKey 断点续传记录文件的具体文件名,不设置时会由当次上传自动生成,推荐不设置
|
|
555
|
+
*/
|
|
556
|
+
static create(fname?: string, params?: Record<string, string>, mimeType?: string, resumeRecordFile?: string,
|
|
557
|
+
progressCallback?: (uploadBytes: number, totalBytes: number) => void,
|
|
558
|
+
partSize?: number, version?: string, metadata?: Record<string, string>,
|
|
559
|
+
resumeRecorder?: ResumeRecorder, resumeKey?: string): PutExtra;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
/**
|
|
563
|
+
* 历史原因其方法当前仅支持了同步调用这一不推荐的使用方式,暂不公开具体内部信息,仅供 TypeScript 类型检查使用。
|
|
564
|
+
* 实际不存在这个类,未来会变更为 interface。
|
|
565
|
+
*/
|
|
566
|
+
abstract class ResumeRecorder {
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
/**
|
|
570
|
+
*
|
|
571
|
+
* @param baseDirPath 默认值为 `os.tmpdir()`,该方法若 baseDirPath 不存在将自动创建
|
|
572
|
+
*/
|
|
573
|
+
function createResumeRecorder(baseDirPath?: string): Promise<ResumeRecorder>
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* `createResumeRecorder` 的同步版本,不推荐使用
|
|
577
|
+
*/
|
|
578
|
+
function createResumeRecorderSync(baseDirPath?: string): ResumeRecorder
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
export declare namespace util {
|
|
582
|
+
function isTimestampExpired(timestamp: number): boolean;
|
|
583
|
+
|
|
584
|
+
/**
|
|
585
|
+
* 使用 UTC 时间来格式化日期时间
|
|
586
|
+
*
|
|
587
|
+
* @param date 与 new Date() 接受的参数一样,内部会使用 new Date(date) 生成日期时间对象
|
|
588
|
+
* @param layout 目前仅接受
|
|
589
|
+
* YYYY
|
|
590
|
+
* MM
|
|
591
|
+
* DD
|
|
592
|
+
* HH
|
|
593
|
+
* mm
|
|
594
|
+
* ss
|
|
595
|
+
* SSS
|
|
596
|
+
*/
|
|
597
|
+
function formatDateUTC(date: Date | number | string, layout?: string): string;
|
|
598
|
+
|
|
599
|
+
function encodedEntry(bucket: string, key?: string): string;
|
|
600
|
+
|
|
601
|
+
function getAKFromUptoken(uploadToken: string): string;
|
|
602
|
+
|
|
603
|
+
function getBucketFromUptoken(uploadToken: string): string;
|
|
604
|
+
|
|
605
|
+
function base64ToUrlSafe(v: string): string;
|
|
606
|
+
|
|
607
|
+
function urlSafeToBase64(v: string): string;
|
|
608
|
+
|
|
609
|
+
function urlsafeBase64Encode(jsonFlags: string): string;
|
|
610
|
+
|
|
611
|
+
function urlSafeBase64Decode(fromStr: string): string;
|
|
612
|
+
|
|
613
|
+
function hmacSha1(encodedFlags: string | Buffer, secretKey: string | Buffer): string;
|
|
614
|
+
|
|
615
|
+
function canonicalMimeHeaderKey(fieldName: string): string;
|
|
616
|
+
|
|
617
|
+
/**
|
|
618
|
+
* 创建AccessToken凭证
|
|
619
|
+
* @param mac AK&SK对象
|
|
620
|
+
* @param requestURI 请求URL
|
|
621
|
+
* @param reqBody 请求Body,仅当请求的ContentType为application/x-www-form-urlencoded 时才需要传入该参数
|
|
622
|
+
*/
|
|
623
|
+
function generateAccessToken(mac: auth.digest.Mac, requestURI: string, reqBody?: string): string;
|
|
624
|
+
|
|
625
|
+
|
|
626
|
+
/**
|
|
627
|
+
* 创建AccessToken凭证
|
|
628
|
+
* @param mac AK&SK对象
|
|
629
|
+
* @param requestURI 请求URL
|
|
630
|
+
* @param reqMethod 请求方法,例如 GET,POST
|
|
631
|
+
* @param reqContentType 请求类型,例如 application/json 或者 application/x-www-form-urlencoded
|
|
632
|
+
* @param reqBody 请求Body,仅当请求的 ContentType 为 application/json 或者 application/x-www-form-urlencoded 时才需要传入该参数
|
|
633
|
+
* @param reqHeaders 请求Headers,例如 {"X-Qiniu-Name": "Qiniu", "Content-Type": "application/x-www-form-urlencoded"}
|
|
634
|
+
*/
|
|
635
|
+
function generateAccessTokenV2(mac: auth.digest.Mac, requestURI: string, reqMethod: string, reqContentType: string, reqBody?: string, reqHeaders?: Record<string, string>): string;
|
|
636
|
+
|
|
637
|
+
/**
|
|
638
|
+
* 校验七牛上传回调的Authorization
|
|
639
|
+
* @param mac AK&SK对象
|
|
640
|
+
* @param requestURI 回调的URL中的requestURI
|
|
641
|
+
* @param reqBody 回调的URL中的requestURI 请求Body,仅当请求的ContentType为application/x-www-form-urlencoded时才需要传入该参数
|
|
642
|
+
* @param callbackAuth 回调时请求的Authorization头部值
|
|
643
|
+
* @param extra 当回调为 Qiniu 签名时需要传入
|
|
644
|
+
* @param extra.reqMethod 请求方法,例如 GET,POST
|
|
645
|
+
* @param extra.reqContentType 请求类型,例如 application/json 或者 application/x-www-form-urlencoded
|
|
646
|
+
* @param extra.reqHeaders 请求头部
|
|
647
|
+
*/
|
|
648
|
+
function isQiniuCallback(
|
|
649
|
+
mac: auth.digest.Mac,
|
|
650
|
+
requestURI: string,
|
|
651
|
+
reqBody: string | null,
|
|
652
|
+
callbackAuth: string,
|
|
653
|
+
extra?: {
|
|
654
|
+
reqMethod: string,
|
|
655
|
+
reqContentType?: string,
|
|
656
|
+
reqHeaders?: Record<string, string>
|
|
657
|
+
}
|
|
658
|
+
): boolean;
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
export declare namespace httpc {
|
|
662
|
+
interface ReqOpts<T = any> {
|
|
663
|
+
agent?: HttpAgent;
|
|
664
|
+
httpsAgent?: HttpsAgent;
|
|
665
|
+
url: string;
|
|
666
|
+
middlewares?: middleware.Middleware[];
|
|
667
|
+
callback?: Callback<T>;
|
|
668
|
+
urllibOptions: RequestOptions;
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
// responseWrapper.js
|
|
672
|
+
interface ResponseWrapperOptions<T = any> {
|
|
673
|
+
data: T;
|
|
674
|
+
resp: Omit<IncomingMessage, 'url'> & { requestUrls: string[] };
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
interface ResponseError {
|
|
678
|
+
error_code?: string,
|
|
679
|
+
error?: string,
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
class ResponseWrapper<T = any> {
|
|
683
|
+
data: T extends void ? undefined | ResponseError : T & ResponseError;
|
|
684
|
+
resp: Omit<IncomingMessage, 'url'> & { requestUrls: string[] };
|
|
685
|
+
|
|
686
|
+
constructor(options: ResponseWrapperOptions);
|
|
687
|
+
|
|
688
|
+
ok(): boolean;
|
|
689
|
+
|
|
690
|
+
needRetry(): boolean;
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
// middleware package
|
|
694
|
+
namespace middleware {
|
|
695
|
+
interface Middleware {
|
|
696
|
+
send<T>(
|
|
697
|
+
request: ReqOpts<T>,
|
|
698
|
+
next: (reqOpts: ReqOpts<T>) => Promise<ResponseWrapper<T>>
|
|
699
|
+
): Promise<ResponseWrapper<T>>;
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
/**
|
|
703
|
+
* 组合中间件为一个调用函数
|
|
704
|
+
* @param middlewares 中间件列表
|
|
705
|
+
* @param handler 请求函数
|
|
706
|
+
*/
|
|
707
|
+
function composeMiddlewares<T>(
|
|
708
|
+
middlewares: Middleware[],
|
|
709
|
+
handler: (reqOpts: ReqOpts<T>) => Promise<ResponseWrapper<T>>
|
|
710
|
+
): (reqOpts: ReqOpts<T>) => Promise<ResponseWrapper<T>>;
|
|
711
|
+
|
|
712
|
+
/**
|
|
713
|
+
* 设置 User-Agent 请求头中间件
|
|
714
|
+
*/
|
|
715
|
+
class UserAgentMiddleware implements Middleware {
|
|
716
|
+
constructor(sdkVersion: string);
|
|
717
|
+
|
|
718
|
+
send<T>(
|
|
719
|
+
request: httpc.ReqOpts<T>,
|
|
720
|
+
next: (reqOpts: httpc.ReqOpts<T>) => Promise<httpc.ResponseWrapper<T>>
|
|
721
|
+
): Promise<httpc.ResponseWrapper<T>>;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
interface RetryDomainsMiddlewareOptions {
|
|
725
|
+
backupDomains: string[];
|
|
726
|
+
maxRetryTimes: number;
|
|
727
|
+
retryCondition: () => boolean;
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
class RetryDomainsMiddleware implements Middleware {
|
|
731
|
+
/**
|
|
732
|
+
* 备用域名
|
|
733
|
+
*/
|
|
734
|
+
backupDomains: string[];
|
|
735
|
+
|
|
736
|
+
/**
|
|
737
|
+
* 最大重试次数,包括首次请求
|
|
738
|
+
*/
|
|
739
|
+
maxRetryTimes: number;
|
|
740
|
+
|
|
741
|
+
/**
|
|
742
|
+
* 是否可以重试,可以通过该函数配置更详细的重试规则
|
|
743
|
+
*/
|
|
744
|
+
retryCondition: () => boolean;
|
|
745
|
+
|
|
746
|
+
/**
|
|
747
|
+
* 已经重试的次数
|
|
748
|
+
* @private
|
|
749
|
+
*/
|
|
750
|
+
private _retriedTimes: number;
|
|
751
|
+
|
|
752
|
+
/**
|
|
753
|
+
* 实例化重试域名中间件
|
|
754
|
+
* @param retryDomainsOptions
|
|
755
|
+
*/
|
|
756
|
+
constructor(retryDomainsOptions: RetryDomainsMiddlewareOptions)
|
|
757
|
+
|
|
758
|
+
/**
|
|
759
|
+
* 重试域名中间件逻辑
|
|
760
|
+
* @param request
|
|
761
|
+
* @param next
|
|
762
|
+
*/
|
|
763
|
+
send<T>(
|
|
764
|
+
request: httpc.ReqOpts<T>,
|
|
765
|
+
next: (reqOpts: httpc.ReqOpts<T>) => Promise<httpc.ResponseWrapper<T>>
|
|
766
|
+
): Promise<httpc.ResponseWrapper<T>>;
|
|
767
|
+
|
|
768
|
+
/**
|
|
769
|
+
* 控制重试逻辑,主要为 {@link retryCondition} 服务。若没有设置 retryCondition,默认 2xx 才会终止重试
|
|
770
|
+
* @param err
|
|
771
|
+
* @param respWrapper
|
|
772
|
+
* @param reqOpts
|
|
773
|
+
* @private
|
|
774
|
+
*/
|
|
775
|
+
private _shouldRetry<T>(
|
|
776
|
+
err: Error | null,
|
|
777
|
+
respWrapper: ResponseWrapper<T>,
|
|
778
|
+
reqOpts: ReqOpts<T>
|
|
779
|
+
): boolean;
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
// client.js
|
|
784
|
+
interface HttpClientOptions {
|
|
785
|
+
httpAgent?: HttpAgent;
|
|
786
|
+
httpsAgent?: HttpsAgent;
|
|
787
|
+
middlewares?: middleware.Middleware[];
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
interface GetOptions<T = any> extends Omit<ReqOpts<T>, 'urllibOptions'> {
|
|
791
|
+
params: Record<string, string>;
|
|
792
|
+
headers: Record<string, string>;
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
interface PostOptions<T = any> extends Omit<ReqOpts<T>, 'urllibOptions'> {
|
|
796
|
+
data: string | Buffer | Readable;
|
|
797
|
+
headers: Record<string, string>;
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
interface PutOptions<T = any> extends Omit<ReqOpts<T>, 'urllibOptions'> {
|
|
801
|
+
data: string | Buffer | Readable;
|
|
802
|
+
headers: Record<string, string>
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
class HttpClient {
|
|
806
|
+
httpAgent: HttpAgent;
|
|
807
|
+
httpsAgent: HttpsAgent;
|
|
808
|
+
middlewares: middleware.Middleware[];
|
|
809
|
+
|
|
810
|
+
constructor(options: HttpClientOptions)
|
|
811
|
+
|
|
812
|
+
sendRequest(requestOptions: ReqOpts): Promise<ResponseWrapper>
|
|
813
|
+
|
|
814
|
+
get(getOptions: GetOptions, urllibOptions?: RequestOptions): Promise<ResponseWrapper>
|
|
815
|
+
|
|
816
|
+
post(postOptions: PostOptions, urllibOptions?: RequestOptions): Promise<ResponseWrapper>
|
|
817
|
+
|
|
818
|
+
put(putOptions: PutOptions, urllibOptions?: RequestOptions): Promise<ResponseWrapper>
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
// endpoint.js
|
|
822
|
+
interface EndpointOptions {
|
|
823
|
+
defaultScheme?: string;
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
interface EndpointPersistInfo {
|
|
827
|
+
host: string;
|
|
828
|
+
defaultScheme: string;
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
class Endpoint implements EndpointsProvider {
|
|
832
|
+
host: string;
|
|
833
|
+
defaultScheme: string;
|
|
834
|
+
|
|
835
|
+
constructor(host: string, options?: EndpointOptions);
|
|
836
|
+
|
|
837
|
+
getValue(options?: { scheme?: string }): string;
|
|
838
|
+
|
|
839
|
+
getEndpoints(): Promise<httpc.Endpoint[]>;
|
|
840
|
+
|
|
841
|
+
clone(): Endpoint;
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
// region.js
|
|
845
|
+
enum SERVICE_NAME {
|
|
846
|
+
UC = 'uc',
|
|
847
|
+
UP = 'up',
|
|
848
|
+
UP_ACC = 'up_acc',
|
|
849
|
+
IO = 'io',
|
|
850
|
+
RS = 'rs',
|
|
851
|
+
RSF = 'rsf',
|
|
852
|
+
API = 'api',
|
|
853
|
+
S3 = 's3'
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
interface RegionOptions {
|
|
857
|
+
regionId?: string;
|
|
858
|
+
s3RegionId?: string;
|
|
859
|
+
services?: Record<string, Endpoint[]>;
|
|
860
|
+
ttl?: number;
|
|
861
|
+
createTime?: Date;
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
interface RegionFromZoneOptions {
|
|
865
|
+
regionId?: string;
|
|
866
|
+
s3RegionId?: string;
|
|
867
|
+
ttl?: number;
|
|
868
|
+
preferredScheme?: 'http' | 'https' | string
|
|
869
|
+
isPreferCdnHost?: boolean;
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
interface RegionFromRegionIdOptions {
|
|
873
|
+
s3RegionId?: string;
|
|
874
|
+
ttl?: number;
|
|
875
|
+
createTime?: Date;
|
|
876
|
+
extendedServices?: Record<SERVICE_NAME | string, Endpoint[]>
|
|
877
|
+
preferredScheme?: 'http' | 'https' | string
|
|
878
|
+
isPreferCdnUpHost?: boolean
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
interface RegionPersistInfo {
|
|
882
|
+
regionId?: string;
|
|
883
|
+
s3RegionId?: string;
|
|
884
|
+
services: Record<SERVICE_NAME | string, EndpointPersistInfo[]>;
|
|
885
|
+
ttl: number;
|
|
886
|
+
createTime: number;
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
interface QueryRegionsRespData {
|
|
890
|
+
region: string;
|
|
891
|
+
ttl: number;
|
|
892
|
+
s3: {
|
|
893
|
+
domains: string[];
|
|
894
|
+
region_alias: string;
|
|
895
|
+
};
|
|
896
|
+
uc: {
|
|
897
|
+
domains: string[];
|
|
898
|
+
};
|
|
899
|
+
up: {
|
|
900
|
+
domains: string[];
|
|
901
|
+
};
|
|
902
|
+
io: {
|
|
903
|
+
domains: string[];
|
|
904
|
+
};
|
|
905
|
+
rs: {
|
|
906
|
+
domains: string[];
|
|
907
|
+
};
|
|
908
|
+
rsf: {
|
|
909
|
+
domains: string[];
|
|
910
|
+
};
|
|
911
|
+
api: {
|
|
912
|
+
domains: string[];
|
|
913
|
+
};
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
class Region implements RegionsProvider {
|
|
917
|
+
static fromZone(zone: conf.Zone, options?: RegionFromZoneOptions): Region;
|
|
918
|
+
|
|
919
|
+
static fromRegionId(regionId: string, options?: RegionFromRegionIdOptions): Region;
|
|
920
|
+
|
|
921
|
+
static merge(...r: Region[]): Region;
|
|
922
|
+
|
|
923
|
+
// non-unique
|
|
924
|
+
regionId?: string;
|
|
925
|
+
s3RegionId?: string;
|
|
926
|
+
services: Record<SERVICE_NAME | string, Endpoint[]>
|
|
927
|
+
|
|
928
|
+
ttl: number;
|
|
929
|
+
createTime: Date;
|
|
930
|
+
|
|
931
|
+
constructor(options: RegionOptions);
|
|
932
|
+
|
|
933
|
+
getRegions(): Promise<httpc.Region[]>;
|
|
934
|
+
|
|
935
|
+
clone(): Region;
|
|
936
|
+
|
|
937
|
+
merge(...r: Region[]): Region;
|
|
938
|
+
|
|
939
|
+
get isLive(): boolean;
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
// endpointProvider.js
|
|
943
|
+
interface EndpointsProvider {
|
|
944
|
+
getEndpoints(): Promise<Endpoint[]>
|
|
945
|
+
}
|
|
946
|
+
|
|
947
|
+
interface MutableEndpointsProvider extends EndpointsProvider {
|
|
948
|
+
setEndpoints(endpoints: Endpoint[]): Promise<void>
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
class StaticEndpointsProvider implements EndpointsProvider {
|
|
952
|
+
static fromRegion(region: Region, serviceName: SERVICE_NAME | string): StaticEndpointsProvider;
|
|
953
|
+
|
|
954
|
+
constructor(endpoints: Endpoint[]);
|
|
955
|
+
|
|
956
|
+
getEndpoints(): Promise<Endpoint[]>;
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
// regionsProvider.js
|
|
960
|
+
interface RegionsProvider {
|
|
961
|
+
getRegions(): Promise<Region[]>
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
interface MutableRegionsProvider extends RegionsProvider {
|
|
965
|
+
setRegions(regions: Region[]): Promise<void>
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
// StaticRegionsProvider
|
|
969
|
+
class StaticRegionsProvider implements RegionsProvider {
|
|
970
|
+
regions: Region[];
|
|
971
|
+
|
|
972
|
+
constructor(regions: Region[]);
|
|
973
|
+
|
|
974
|
+
getRegions(): Promise<Region[]>;
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
// CachedRegionsProviderOptions
|
|
978
|
+
interface CachedRegionsProviderOptions {
|
|
979
|
+
cacheKey: string;
|
|
980
|
+
baseRegionsProvider: RegionsProvider;
|
|
981
|
+
persistPath?: string;
|
|
982
|
+
shrinkInterval?: number; // ms
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
class CachedRegionsProvider implements MutableRegionsProvider {
|
|
986
|
+
static cleanupCache(options: {
|
|
987
|
+
isClearAll?: boolean,
|
|
988
|
+
/**
|
|
989
|
+
* if instance is not passed, it will clean up the default scoop.
|
|
990
|
+
*/
|
|
991
|
+
instance?: CachedRegionsProvider,
|
|
992
|
+
}): Promise<void>
|
|
993
|
+
|
|
994
|
+
cacheKey: string;
|
|
995
|
+
baseRegionsProvider: RegionsProvider;
|
|
996
|
+
|
|
997
|
+
lastShrinkAt: Date;
|
|
998
|
+
shrinkInterval: number;
|
|
999
|
+
|
|
1000
|
+
constructor(
|
|
1001
|
+
options: CachedRegionsProviderOptions
|
|
1002
|
+
);
|
|
1003
|
+
|
|
1004
|
+
setRegions(regions: Region[]): Promise<void>;
|
|
1005
|
+
|
|
1006
|
+
getRegions(): Promise<Region[]>;
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
// QueryRegionsProvider
|
|
1010
|
+
interface QueryRegionsProviderOptions {
|
|
1011
|
+
accessKey: string;
|
|
1012
|
+
bucketName: string;
|
|
1013
|
+
endpointsProvider: EndpointsProvider;
|
|
1014
|
+
preferredScheme?: 'http' | 'https' | string;
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
class QueryRegionsProvider implements RegionsProvider {
|
|
1018
|
+
accessKey: string;
|
|
1019
|
+
bucketName: string;
|
|
1020
|
+
endpointsProvider: EndpointsProvider;
|
|
1021
|
+
|
|
1022
|
+
constructor(options: QueryRegionsProviderOptions);
|
|
1023
|
+
|
|
1024
|
+
getRegions(): Promise<Region[]>;
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
export declare namespace rpc {
|
|
1029
|
+
type Headers = Record<string, string> & {
|
|
1030
|
+
'User-Agent'?: string;
|
|
1031
|
+
Connection?: string;
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
interface RequestOptions {
|
|
1035
|
+
headers: Headers;
|
|
1036
|
+
mac: auth.digest.Mac;
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
const qnHttpClient: httpc.HttpClient;
|
|
1040
|
+
|
|
1041
|
+
/**
|
|
1042
|
+
*
|
|
1043
|
+
* @param requestUrl 请求地址
|
|
1044
|
+
* @param headers 请求 headers
|
|
1045
|
+
* @param callbackFunc 回调函数
|
|
1046
|
+
*/
|
|
1047
|
+
function get(requestUrl: string, headers: Headers | null, callbackFunc: callback): void;
|
|
1048
|
+
|
|
1049
|
+
/**
|
|
1050
|
+
* @param requestUrl 请求地址
|
|
1051
|
+
* @param options 请求的配置
|
|
1052
|
+
* @param callbackFunc 回调函数
|
|
1053
|
+
*/
|
|
1054
|
+
function getWithOptions(
|
|
1055
|
+
requestUrl: string,
|
|
1056
|
+
options: RequestOptions | null,
|
|
1057
|
+
callbackFunc: callback
|
|
1058
|
+
): ReturnType<typeof get>;
|
|
1059
|
+
|
|
1060
|
+
/**
|
|
1061
|
+
*
|
|
1062
|
+
* @param requestUrl 请求地址
|
|
1063
|
+
* @param token 请求认证签名
|
|
1064
|
+
* @param callbackFunc 回调函数
|
|
1065
|
+
*/
|
|
1066
|
+
function getWithToken(requestUrl: string, token: string | null, callbackFunc: callback): void;
|
|
1067
|
+
|
|
1068
|
+
/**
|
|
1069
|
+
*
|
|
1070
|
+
* @param requestURI
|
|
1071
|
+
* @param requestForm
|
|
1072
|
+
* @param headers
|
|
1073
|
+
* @param callback
|
|
1074
|
+
*/
|
|
1075
|
+
function post(requestURI: string, requestForm: Buffer | string | NodeJS.ReadableStream | null, headers: Headers | null, callback: callback): void;
|
|
1076
|
+
|
|
1077
|
+
|
|
1078
|
+
/**
|
|
1079
|
+
* @param requestUrl 请求地址
|
|
1080
|
+
* @param requestForm 请求体
|
|
1081
|
+
* @param options 请求的配置
|
|
1082
|
+
* @param callbackFunc 回调函数
|
|
1083
|
+
*/
|
|
1084
|
+
function postWithOptions(
|
|
1085
|
+
requestUrl: string,
|
|
1086
|
+
requestForm: Buffer | string | NodeJS.ReadableStream | null,
|
|
1087
|
+
options: RequestOptions | null,
|
|
1088
|
+
callbackFunc: callback
|
|
1089
|
+
): ReturnType<typeof post>;
|
|
1090
|
+
|
|
1091
|
+
/**
|
|
1092
|
+
*
|
|
1093
|
+
* @param requestURI
|
|
1094
|
+
* @param requestForm
|
|
1095
|
+
* @param callback
|
|
1096
|
+
*/
|
|
1097
|
+
function postMultipart(requestURI: string, requestForm: Buffer | string | NodeJS.ReadableStream | null, callback: callback): void;
|
|
1098
|
+
|
|
1099
|
+
/**
|
|
1100
|
+
*
|
|
1101
|
+
* @param requestURI
|
|
1102
|
+
* @param requestForm
|
|
1103
|
+
* @param token
|
|
1104
|
+
* @param callback
|
|
1105
|
+
*/
|
|
1106
|
+
function postWithForm(requestURI: string, requestForm: Buffer | string | NodeJS.ReadableStream | null, token: string | null, callback: callback): void;
|
|
1107
|
+
|
|
1108
|
+
/**
|
|
1109
|
+
*
|
|
1110
|
+
* @param requestURI
|
|
1111
|
+
* @param token
|
|
1112
|
+
* @param callback
|
|
1113
|
+
*/
|
|
1114
|
+
function postWithoutForm(requestURI: string, token: string | null, callback: callback): void;
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
export declare namespace zone {
|
|
1118
|
+
//huadong
|
|
1119
|
+
const Zone_z0: conf.Zone;
|
|
1120
|
+
//huadong2
|
|
1121
|
+
const Zone_cn_east_2: conf.Zone;
|
|
1122
|
+
//huabei
|
|
1123
|
+
const Zone_z1: conf.Zone;
|
|
1124
|
+
//huanan
|
|
1125
|
+
const Zone_z2: conf.Zone;
|
|
1126
|
+
//beimei
|
|
1127
|
+
const Zone_na0: conf.Zone;
|
|
1128
|
+
//Southeast Asia
|
|
1129
|
+
const Zone_as0: conf.Zone;
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
export declare namespace fop {
|
|
1133
|
+
interface PfopOptions {
|
|
1134
|
+
/**
|
|
1135
|
+
* 回调业务服务器,通知处理结果
|
|
1136
|
+
*/
|
|
1137
|
+
notifyURL?: string;
|
|
1138
|
+
|
|
1139
|
+
/**
|
|
1140
|
+
* 结果是否强制覆盖已有的同名文件
|
|
1141
|
+
*/
|
|
1142
|
+
force?: boolean;
|
|
1143
|
+
|
|
1144
|
+
/**
|
|
1145
|
+
* 为 `1` 时开启闲时任务
|
|
1146
|
+
*/
|
|
1147
|
+
type?: number;
|
|
1148
|
+
|
|
1149
|
+
/**
|
|
1150
|
+
* 工作流模版 ID,与函数参数中的 fops 参数二选一
|
|
1151
|
+
*/
|
|
1152
|
+
workflowTemplateID?: string
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
class OperationManager {
|
|
1156
|
+
mac: auth.digest.Mac;
|
|
1157
|
+
config: conf.Config;
|
|
1158
|
+
|
|
1159
|
+
constructor(mac?: auth.digest.Mac, config?: conf.Config);
|
|
1160
|
+
|
|
1161
|
+
/**
|
|
1162
|
+
* 发送持久化数据处理请求
|
|
1163
|
+
* @param bucket 空间名称
|
|
1164
|
+
* @param key 文件名称
|
|
1165
|
+
* @param fops 处理指令集合,与 options.workflowTemplateID 二选一
|
|
1166
|
+
* @param pipeline 处理队列名称
|
|
1167
|
+
* @param options
|
|
1168
|
+
* @param callback
|
|
1169
|
+
*/
|
|
1170
|
+
pfop(
|
|
1171
|
+
bucket: string,
|
|
1172
|
+
key: string,
|
|
1173
|
+
fops: string[],
|
|
1174
|
+
pipeline: string,
|
|
1175
|
+
options: PfopOptions | null,
|
|
1176
|
+
callback: callback<{
|
|
1177
|
+
persistentId: string
|
|
1178
|
+
}>
|
|
1179
|
+
): void;
|
|
1180
|
+
|
|
1181
|
+
/**
|
|
1182
|
+
* 查询持久化数据处理进度
|
|
1183
|
+
* @param persistentId pfop 操作返回的持久化处理ID
|
|
1184
|
+
* @param callback
|
|
1185
|
+
*/
|
|
1186
|
+
prefop(
|
|
1187
|
+
persistentId: string,
|
|
1188
|
+
callback: callback<{
|
|
1189
|
+
id: string,
|
|
1190
|
+
pipeline: string,
|
|
1191
|
+
code: number,
|
|
1192
|
+
desc: string,
|
|
1193
|
+
reqid: string,
|
|
1194
|
+
inputBucket: string,
|
|
1195
|
+
inputKey: string,
|
|
1196
|
+
creationDate?: string,
|
|
1197
|
+
type?: number,
|
|
1198
|
+
taskFrom?: string,
|
|
1199
|
+
items: {
|
|
1200
|
+
cmd: string,
|
|
1201
|
+
code: number,
|
|
1202
|
+
desc: string,
|
|
1203
|
+
returnOld: number,
|
|
1204
|
+
error?: string,
|
|
1205
|
+
hash?: string,
|
|
1206
|
+
key?: string,
|
|
1207
|
+
}[]
|
|
1208
|
+
}>
|
|
1209
|
+
): void;
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
export declare namespace rs {
|
|
1214
|
+
interface ListPrefixOptions {
|
|
1215
|
+
/**
|
|
1216
|
+
* 列举的文件前缀
|
|
1217
|
+
*/
|
|
1218
|
+
prefix?: string;
|
|
1219
|
+
|
|
1220
|
+
/**
|
|
1221
|
+
* 上一次列举返回的位置标记
|
|
1222
|
+
*/
|
|
1223
|
+
marker?: any;
|
|
1224
|
+
|
|
1225
|
+
/**
|
|
1226
|
+
* 每次返回的最大列举文件数量
|
|
1227
|
+
*/
|
|
1228
|
+
limit?: number;
|
|
1229
|
+
|
|
1230
|
+
/**
|
|
1231
|
+
* 指定目录分隔符
|
|
1232
|
+
*/
|
|
1233
|
+
delimiter?: string;
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1236
|
+
type BucketEventName = 'put'
|
|
1237
|
+
| 'mkfile'
|
|
1238
|
+
| 'delete'
|
|
1239
|
+
| 'copy'
|
|
1240
|
+
| 'move'
|
|
1241
|
+
| 'append'
|
|
1242
|
+
| 'disable'
|
|
1243
|
+
| 'enable'
|
|
1244
|
+
| 'deleteMarkerCreate'
|
|
1245
|
+
| 'predelete'
|
|
1246
|
+
| 'restore:completed';
|
|
1247
|
+
|
|
1248
|
+
class BucketManager {
|
|
1249
|
+
mac: auth.digest.Mac;
|
|
1250
|
+
config: conf.Config;
|
|
1251
|
+
|
|
1252
|
+
constructor(mac?: auth.digest.Mac, config?: conf.Config);
|
|
1253
|
+
|
|
1254
|
+
/**
|
|
1255
|
+
* 获取资源信息
|
|
1256
|
+
* @see https://developer.qiniu.com/kodo/api/1308/stat
|
|
1257
|
+
*
|
|
1258
|
+
* @param bucket 空间名称
|
|
1259
|
+
* @param key 文件名称
|
|
1260
|
+
* @param callback
|
|
1261
|
+
*/
|
|
1262
|
+
stat(bucket: string, key: string, callback?: callback): Promise<httpc.ResponseWrapper<StatObjectResult>>;
|
|
1263
|
+
|
|
1264
|
+
/**
|
|
1265
|
+
* 修改文件的类型
|
|
1266
|
+
* @see https://developer.qiniu.com/kodo/api/1252/chgm
|
|
1267
|
+
*
|
|
1268
|
+
* @param bucket 空间名称
|
|
1269
|
+
* @param key 文件名称
|
|
1270
|
+
* @param newMime 新文件类型
|
|
1271
|
+
* @param callback
|
|
1272
|
+
*/
|
|
1273
|
+
changeMime(bucket: string, key: string, newMime: string, callback?: callback): Promise<httpc.ResponseWrapper<void>>;
|
|
1274
|
+
|
|
1275
|
+
/**
|
|
1276
|
+
* 修改文件的Headers
|
|
1277
|
+
* @see TODO
|
|
1278
|
+
*
|
|
1279
|
+
* @param bucket 空间名称
|
|
1280
|
+
* @param key 文件名称
|
|
1281
|
+
* @param headers Headers对象
|
|
1282
|
+
* @param callback
|
|
1283
|
+
*/
|
|
1284
|
+
changeHeaders(bucket: string, key: string, headers: {
|
|
1285
|
+
[k: string]: string
|
|
1286
|
+
}, callback?: callback): Promise<httpc.ResponseWrapper<void>>;
|
|
1287
|
+
|
|
1288
|
+
/**
|
|
1289
|
+
* 移动或重命名文件,当bucketSrc==bucketDest相同的时候,就是重命名文件操作
|
|
1290
|
+
* @see https://developer.qiniu.com/kodo/api/1288/move
|
|
1291
|
+
*
|
|
1292
|
+
* @param srcBucket 源空间名称
|
|
1293
|
+
* @param srcKey 源文件名称
|
|
1294
|
+
* @param destBucket 目标空间名称
|
|
1295
|
+
* @param destKey 目标文件名称
|
|
1296
|
+
* @param options
|
|
1297
|
+
* @param callback
|
|
1298
|
+
*/
|
|
1299
|
+
move(srcBucket: string, srcKey: string, destBucket: string, destKey: string, options: {
|
|
1300
|
+
force?: boolean
|
|
1301
|
+
} | null, callback?: callback): Promise<httpc.ResponseWrapper<void>>;
|
|
1302
|
+
|
|
1303
|
+
/**
|
|
1304
|
+
* 复制文件
|
|
1305
|
+
* @see https://developer.qiniu.com/kodo/api/1254/copy
|
|
1306
|
+
*
|
|
1307
|
+
* @param srcBucket 源空间名称
|
|
1308
|
+
* @param srcKey 源文件名称
|
|
1309
|
+
* @param destBucket 目标空间名称
|
|
1310
|
+
* @param destKey 目标文件名称
|
|
1311
|
+
* @param options
|
|
1312
|
+
* @param callback
|
|
1313
|
+
*/
|
|
1314
|
+
copy(srcBucket: string, srcKey: string, destBucket: string, destKey: string, options: {
|
|
1315
|
+
force?: boolean
|
|
1316
|
+
} | null, callback?: callback): Promise<httpc.ResponseWrapper<void>>;
|
|
1317
|
+
|
|
1318
|
+
/**
|
|
1319
|
+
* 删除资源
|
|
1320
|
+
* @see https://developer.qiniu.com/kodo/api/1257/delete
|
|
1321
|
+
*
|
|
1322
|
+
* @param bucket 空间名称
|
|
1323
|
+
* @param key 文件名称
|
|
1324
|
+
* @param callback
|
|
1325
|
+
*/
|
|
1326
|
+
delete(bucket: string, key: string, callback?: callback): Promise<httpc.ResponseWrapper<void>>;
|
|
1327
|
+
|
|
1328
|
+
/**
|
|
1329
|
+
* 设置文件删除的生命周期
|
|
1330
|
+
* @see https://developer.qiniu.com/kodo/api/1732/update-file-lifecycle
|
|
1331
|
+
*
|
|
1332
|
+
* @param bucket 空间名称
|
|
1333
|
+
* @param key 文件名称
|
|
1334
|
+
* @param days 有效期天数
|
|
1335
|
+
* @param callback
|
|
1336
|
+
*/
|
|
1337
|
+
deleteAfterDays(bucket: string, key: string, days: number, callback?: callback): Promise<httpc.ResponseWrapper<void>>;
|
|
1338
|
+
|
|
1339
|
+
/**
|
|
1340
|
+
* 设置文件的生命周期
|
|
1341
|
+
* @param { string } bucket - 空间名称
|
|
1342
|
+
* @param { string } key - 文件名称
|
|
1343
|
+
* @param { Object } options - 配置项
|
|
1344
|
+
* @param { number } options.toIaAfterDays - 多少天后将文件转为低频存储,设置为 -1 表示取消已设置的转低频存储的生命周期规则, 0 表示不修改转低频生命周期规则。
|
|
1345
|
+
* @param { number } options.toArchiveIRAfterDays - 多少天后将文件转为归档直读存储,设置为 -1 表示取消已设置的转归档直读存储的生命周期规则, 0 表示不修改转归档直读生命周期规则。
|
|
1346
|
+
* @param { number } options.toArchiveAfterDays - 多少天后将文件转为归档存储,设置为 -1 表示取消已设置的转归档存储的生命周期规则, 0 表示不修改转归档生命周期规则。
|
|
1347
|
+
* @param { number } options.toDeepArchiveAfterDays - 多少天后将文件转为深度归档存储,设置为 -1 表示取消已设置的转深度归档存储的生命周期规则, 0 表示不修改转深度归档生命周期规则。
|
|
1348
|
+
* @param { number } options.deleteAfterDays - 多少天后将文件删除,设置为 -1 表示取消已设置的删除存储的生命周期规则, 0 表示不修改删除存储的生命周期规则。
|
|
1349
|
+
* @param { Object } options.cond - 匹配条件,只有条件匹配才会设置成功
|
|
1350
|
+
* @param { string } options.cond.hash
|
|
1351
|
+
* @param { string } options.cond.mime
|
|
1352
|
+
* @param { number } options.cond.fsize
|
|
1353
|
+
* @param { number } options.cond.putTime
|
|
1354
|
+
* @param { function } callbackFunc - 回调函数
|
|
1355
|
+
*/
|
|
1356
|
+
setObjectLifeCycle(
|
|
1357
|
+
bucket: string,
|
|
1358
|
+
key: string,
|
|
1359
|
+
options: {
|
|
1360
|
+
toIaAfterDays?: number,
|
|
1361
|
+
toArchiveIRAfterDays?: number,
|
|
1362
|
+
toArchiveAfterDays?: number,
|
|
1363
|
+
toDeepArchiveAfterDays?: number,
|
|
1364
|
+
deleteAfterDays?: number
|
|
1365
|
+
cond?: {
|
|
1366
|
+
hash?: string,
|
|
1367
|
+
mime?: string,
|
|
1368
|
+
fsize?: number,
|
|
1369
|
+
putTime?: number
|
|
1370
|
+
}
|
|
1371
|
+
},
|
|
1372
|
+
callbackFunc?: callback
|
|
1373
|
+
): Promise<httpc.ResponseWrapper<void>>;
|
|
1374
|
+
|
|
1375
|
+
listBucketDomains(bucket: string, callbackFunc?: callback): Promise<httpc.ResponseWrapper<GetBucketDomainsV3Result>>
|
|
1376
|
+
|
|
1377
|
+
/**
|
|
1378
|
+
* 解冻归档存储文件
|
|
1379
|
+
* @param entry
|
|
1380
|
+
* @param freezeAfterDays
|
|
1381
|
+
* @param callbackFunc
|
|
1382
|
+
*/
|
|
1383
|
+
restoreAr(entry: string, freezeAfterDays: number, callbackFunc?: callback): Promise<httpc.ResponseWrapper<void>>;
|
|
1384
|
+
|
|
1385
|
+
/**
|
|
1386
|
+
* 抓取资源
|
|
1387
|
+
* @see https://developer.qiniu.com/kodo/api/1263/fetch
|
|
1388
|
+
*
|
|
1389
|
+
* @param resUrl 资源链接
|
|
1390
|
+
* @param bucket 空间名称
|
|
1391
|
+
* @param key 文件名称
|
|
1392
|
+
* @param callback
|
|
1393
|
+
*/
|
|
1394
|
+
fetch(resUrl: string, bucket: string, key: string, callback?: callback): Promise<httpc.ResponseWrapper<FetchObjectResult>>;
|
|
1395
|
+
|
|
1396
|
+
/**
|
|
1397
|
+
* 更新镜像副本
|
|
1398
|
+
* @see https://developer.qiniu.com/kodo/api/1293/prefetch
|
|
1399
|
+
*
|
|
1400
|
+
* @param bucket 空间名称
|
|
1401
|
+
* @param key 文件名称
|
|
1402
|
+
* @param callback
|
|
1403
|
+
*/
|
|
1404
|
+
prefetch(bucket: string, key: string, callback?: callback): Promise<httpc.ResponseWrapper<void>>;
|
|
1405
|
+
|
|
1406
|
+
/**
|
|
1407
|
+
* 修改文件的存储类型
|
|
1408
|
+
* @see https://developer.qiniu.com/kodo/api/3710/modify-the-file-type
|
|
1409
|
+
*
|
|
1410
|
+
* @param bucket 空间名称
|
|
1411
|
+
* @param key 文件名称
|
|
1412
|
+
* @param newType 0 表示标准存储;1 表示低频存储。
|
|
1413
|
+
* @param callback
|
|
1414
|
+
*/
|
|
1415
|
+
changeType(bucket: string, key: string, newType: number, callback?: callback): Promise<httpc.ResponseWrapper<void>>;
|
|
1416
|
+
|
|
1417
|
+
/**
|
|
1418
|
+
* 设置空间镜像源
|
|
1419
|
+
* @see https://developer.qiniu.com/kodo/api/1370/mirror
|
|
1420
|
+
*
|
|
1421
|
+
* @param bucket 空间名称
|
|
1422
|
+
* @param srcSiteUrl 镜像源地址
|
|
1423
|
+
* @param srcHost 镜像Host
|
|
1424
|
+
* @param callback
|
|
1425
|
+
*/
|
|
1426
|
+
image(bucket: string, srcSiteUrl: string, srcHost?: string, callback?: callback): Promise<httpc.ResponseWrapper<void>>;
|
|
1427
|
+
|
|
1428
|
+
/**
|
|
1429
|
+
* 取消设置空间镜像源
|
|
1430
|
+
* @see https://developer.qiniu.com/kodo/api/1370/mirror
|
|
1431
|
+
*
|
|
1432
|
+
* @param bucket 空间名称
|
|
1433
|
+
* @param callback
|
|
1434
|
+
*/
|
|
1435
|
+
unimage(bucket: string, callback?: callback): Promise<httpc.ResponseWrapper<void>>;
|
|
1436
|
+
|
|
1437
|
+
/**
|
|
1438
|
+
* 获取指定前缀的文件列表
|
|
1439
|
+
* @see https://developer.qiniu.com/kodo/api/1284/list
|
|
1440
|
+
*
|
|
1441
|
+
* @param bucket 空间名称
|
|
1442
|
+
* @param options 列举操作的可选参数
|
|
1443
|
+
* @param callback 回调函数
|
|
1444
|
+
*/
|
|
1445
|
+
listPrefix(bucket: string, options: ListPrefixOptions | null, callback?: callback): Promise<httpc.ResponseWrapper<GetObjectsResult>>;
|
|
1446
|
+
|
|
1447
|
+
/**
|
|
1448
|
+
* 获取制定前缀的文件列表 V2
|
|
1449
|
+
*
|
|
1450
|
+
* @deprecated API 可能返回仅包含 marker,不包含 item 或 dir 的项,请使用 {@link listPrefix}
|
|
1451
|
+
*
|
|
1452
|
+
* @param bucket 空间名称
|
|
1453
|
+
* @param options 列举操作的可选参数
|
|
1454
|
+
* @param callback 回调函数
|
|
1455
|
+
*/
|
|
1456
|
+
listPrefixV2(bucket: string, options: ListPrefixOptions | null, callback?: callback): Promise<httpc.ResponseWrapper<string>>;
|
|
1457
|
+
|
|
1458
|
+
/**
|
|
1459
|
+
* 批量文件管理请求,支持stat,chgm,chtype,delete,copy,move
|
|
1460
|
+
* @param operations
|
|
1461
|
+
* @param callback
|
|
1462
|
+
*/
|
|
1463
|
+
batch(operations: any, callback?: callback): Promise<httpc.ResponseWrapper<BatchOpsResult>>;
|
|
1464
|
+
|
|
1465
|
+
/**
|
|
1466
|
+
* 获取私有空间的下载链接
|
|
1467
|
+
* @param domain 空间绑定的域名,比如以http或https开头
|
|
1468
|
+
* @param fileName 原始文件名
|
|
1469
|
+
* @param deadline 文件有效期时间戳(单位秒)
|
|
1470
|
+
*/
|
|
1471
|
+
privateDownloadUrl(domain: string, fileName: string, deadline: number): string;
|
|
1472
|
+
|
|
1473
|
+
/**
|
|
1474
|
+
* 获取公开空间的下载链接
|
|
1475
|
+
* @param domain 空间绑定的域名,比如以http或https开头
|
|
1476
|
+
* @param fileName 原始文件名
|
|
1477
|
+
*/
|
|
1478
|
+
publicDownloadUrl(domain: string, fileName: string): string;
|
|
1479
|
+
|
|
1480
|
+
/**
|
|
1481
|
+
* /chstatus 修改文件状态
|
|
1482
|
+
* @param bucket - 空间名
|
|
1483
|
+
* @param key - 文件
|
|
1484
|
+
* @param status - 状态
|
|
1485
|
+
* @param callbackFunc - 回调函数
|
|
1486
|
+
*/
|
|
1487
|
+
updateObjectStatus(
|
|
1488
|
+
bucket: string,
|
|
1489
|
+
key: string,
|
|
1490
|
+
status: number,
|
|
1491
|
+
callbackFunc?: callback
|
|
1492
|
+
): Promise<httpc.ResponseWrapper<void>>
|
|
1493
|
+
|
|
1494
|
+
/**
|
|
1495
|
+
* 获取所有空间
|
|
1496
|
+
* @param callbackFunc
|
|
1497
|
+
*/
|
|
1498
|
+
listBucket(callbackFunc?: callback): Promise<httpc.ResponseWrapper<GetBucketsResult>>
|
|
1499
|
+
listBucket(options: {
|
|
1500
|
+
shared: string,
|
|
1501
|
+
tagCondition: Record<string, string>
|
|
1502
|
+
}, callbackFunc?: callback): Promise<httpc.ResponseWrapper<GetBucketsResult>>
|
|
1503
|
+
|
|
1504
|
+
/**
|
|
1505
|
+
* 创建空间
|
|
1506
|
+
* @param bucket 空间名
|
|
1507
|
+
* @param options 选项
|
|
1508
|
+
* @param options.regionId 区域 ID
|
|
1509
|
+
* @param callbackFunc 回调函数
|
|
1510
|
+
*/
|
|
1511
|
+
createBucket(
|
|
1512
|
+
bucket: string,
|
|
1513
|
+
options: {
|
|
1514
|
+
regionId: string
|
|
1515
|
+
},
|
|
1516
|
+
callbackFunc?: callback
|
|
1517
|
+
): Promise<httpc.ResponseWrapper<void>>
|
|
1518
|
+
|
|
1519
|
+
/**
|
|
1520
|
+
* 删除空间
|
|
1521
|
+
* @param bucket 空间名
|
|
1522
|
+
* @param callbackFunc 回调函数
|
|
1523
|
+
*/
|
|
1524
|
+
deleteBucket(
|
|
1525
|
+
bucket: string,
|
|
1526
|
+
callbackFunc?: callback
|
|
1527
|
+
): Promise<httpc.ResponseWrapper<void>>
|
|
1528
|
+
|
|
1529
|
+
/**
|
|
1530
|
+
* 获取空间详情
|
|
1531
|
+
* @param bucket - 空间名
|
|
1532
|
+
* @param callbackFunc
|
|
1533
|
+
*/
|
|
1534
|
+
getBucketInfo(bucket: string, callbackFunc?: callback): Promise<httpc.ResponseWrapper<GetBucketInfoV2Result>>
|
|
1535
|
+
|
|
1536
|
+
/**
|
|
1537
|
+
* rules/add 增加 bucket 规则
|
|
1538
|
+
*
|
|
1539
|
+
* @param bucket - 空间名
|
|
1540
|
+
*
|
|
1541
|
+
* @param options - 配置项
|
|
1542
|
+
* @param options.name - 规则名称 bucket 内唯一,长度小于50,不能为空,只能为字母、数字、下划线
|
|
1543
|
+
* @param options.prefix - 同一个 bucket 里面前缀不能重复
|
|
1544
|
+
* @param options.to_line_after_days - 指定文件上传多少天后转低频存储。指定为0表示不转低频存储
|
|
1545
|
+
* @param options.to_archive_ir_after_days - 指定文件上传多少天后转归档直读存储。指定为0表示不转归档直读存储
|
|
1546
|
+
* @param options.to_archive_after_days - 指定文件上传多少天后转归档存储。指定为0表示不转归档存储
|
|
1547
|
+
* @param options.to_deep_archive_after_days - 指定文件上传多少天后转深度归档存储。指定为0表示不转深度归档存储
|
|
1548
|
+
* @param options.delete_after_days - 指定上传文件多少天后删除,指定为0表示不删除,大于0表示多少天后删除
|
|
1549
|
+
* @param options.history_delete_after_days - 指定文件成为历史版本多少天后删除,指定为0表示不删除,大于0表示多少天后删除
|
|
1550
|
+
* @param options.history_to_line_after_days - 指定文件成为历史版本多少天后转低频存储。指定为0表示不转低频存储
|
|
1551
|
+
*
|
|
1552
|
+
* @param callbackFunc - 回调函数
|
|
1553
|
+
*/
|
|
1554
|
+
putBucketLifecycleRule(
|
|
1555
|
+
bucket: string,
|
|
1556
|
+
options: {
|
|
1557
|
+
name: string,
|
|
1558
|
+
prefix?: string,
|
|
1559
|
+
to_line_after_days?: number,
|
|
1560
|
+
to_archive_ir_after_days?: number,
|
|
1561
|
+
to_archive_after_days?: number,
|
|
1562
|
+
to_deep_archive_after_days?: number,
|
|
1563
|
+
delete_after_days?: number,
|
|
1564
|
+
history_delete_after_days?: number,
|
|
1565
|
+
history_to_line_after_days?: number,
|
|
1566
|
+
},
|
|
1567
|
+
callbackFunc?: callback
|
|
1568
|
+
): Promise<httpc.ResponseWrapper<void>>;
|
|
1569
|
+
|
|
1570
|
+
/** rules/delete 删除 bucket 规则
|
|
1571
|
+
* @param bucket - 空间名
|
|
1572
|
+
* @param name - 规则名称 bucket 内唯一,长度小于50,不能为空,只能为字母、数字、下划线
|
|
1573
|
+
* @param callbackFunc - 回调函数
|
|
1574
|
+
*/
|
|
1575
|
+
deleteBucketLifecycleRule(bucket: string, name: string, callbackFunc?: callback): Promise<httpc.ResponseWrapper<void>>;
|
|
1576
|
+
|
|
1577
|
+
/**
|
|
1578
|
+
* rules/update 更新 bucket 规则
|
|
1579
|
+
*
|
|
1580
|
+
* @param bucket - 空间名
|
|
1581
|
+
*
|
|
1582
|
+
* @param options - 配置项
|
|
1583
|
+
* @param options.name - 规则名称 bucket 内唯一,长度小于50,不能为空,只能为字母、数字、下划线
|
|
1584
|
+
* @param options.prefix - 同一个 bucket 里面前缀不能重复
|
|
1585
|
+
* @param options.to_line_after_days - 指定文件上传多少天后转低频存储。指定为0表示不转低频存储
|
|
1586
|
+
* @param options.to_archive_ir_after_days - 指定文件上传多少天后转归档直读存储。指定为0表示不转归档直读存储
|
|
1587
|
+
* @param options.to_archive_after_days - 指定文件上传多少天后转归档存储。指定为0表示不转归档存储
|
|
1588
|
+
* @param options.to_deep_archive_after_days - 指定文件上传多少天后转深度归档存储。指定为0表示不转深度归档存储
|
|
1589
|
+
* @param options.delete_after_days - 指定上传文件多少天后删除,指定为0表示不删除,大于0表示多少天后删除
|
|
1590
|
+
* @param options.history_delete_after_days - 指定文件成为历史版本多少天后删除,指定为0表示不删除,大于0表示多少天后删除
|
|
1591
|
+
* @param options.history_to_line_after_days - 指定文件成为历史版本多少天后转低频存储。指定为0表示不转低频存储
|
|
1592
|
+
*
|
|
1593
|
+
* @param callbackFunc - 回调函数
|
|
1594
|
+
*/
|
|
1595
|
+
updateBucketLifecycleRule(
|
|
1596
|
+
bucket: string,
|
|
1597
|
+
options: {
|
|
1598
|
+
name: string,
|
|
1599
|
+
prefix?: string,
|
|
1600
|
+
to_line_after_days?: number,
|
|
1601
|
+
to_archive_ir_after_days?: number,
|
|
1602
|
+
to_archive_after_days?: number,
|
|
1603
|
+
to_deep_archive_after_days?: number,
|
|
1604
|
+
delete_after_days?: number,
|
|
1605
|
+
history_delete_after_days?: number,
|
|
1606
|
+
history_to_line_after_days?: number,
|
|
1607
|
+
},
|
|
1608
|
+
callbackFunc?: callback
|
|
1609
|
+
): Promise<httpc.ResponseWrapper<void>>;
|
|
1610
|
+
|
|
1611
|
+
|
|
1612
|
+
/** rules/get - 获取 bucket 规则
|
|
1613
|
+
* @param bucket - 空间名
|
|
1614
|
+
* @param callbackFunc - 回调函数
|
|
1615
|
+
*/
|
|
1616
|
+
getBucketLifecycleRule(bucket: string, callbackFunc?: callback): Promise<httpc.ResponseWrapper<GetBucketRulesResult>>
|
|
1617
|
+
|
|
1618
|
+
/**
|
|
1619
|
+
* 添加事件通知
|
|
1620
|
+
* https://developer.qiniu.com/kodo/8610/dev-event-notification
|
|
1621
|
+
* @param bucket - 空间名
|
|
1622
|
+
* @param options - 配置项
|
|
1623
|
+
* @param options.name - 规则名称 bucket 内唯一,长度小于50,不能为空,只能为字母、数字、下划线
|
|
1624
|
+
* @param options.event - 事件类型,接受数组设置多个
|
|
1625
|
+
* @param options.callbackURL - 事件通知回调 URL,接受数组设置多个,失败依次重试
|
|
1626
|
+
* @param options.prefix - 可选,文件配置的前缀
|
|
1627
|
+
* @param options.suffix - 可选,文件配置的后缀
|
|
1628
|
+
* @param options.access_key - 可选,设置的话会对通知请求用对应的ak、sk进行签名
|
|
1629
|
+
* @param options.host - 可选,通知请求的host
|
|
1630
|
+
* @param callbackFunc - 回调函数
|
|
1631
|
+
*/
|
|
1632
|
+
putBucketEvent(
|
|
1633
|
+
bucket: string,
|
|
1634
|
+
options: {
|
|
1635
|
+
name: string,
|
|
1636
|
+
event: BucketEventName | BucketEventName[],
|
|
1637
|
+
callbackURL: string | string[],
|
|
1638
|
+
prefix?: string,
|
|
1639
|
+
suffix?: string,
|
|
1640
|
+
access_key?: string,
|
|
1641
|
+
host?: string,
|
|
1642
|
+
},
|
|
1643
|
+
callbackFunc?: callback,
|
|
1644
|
+
): Promise<httpc.ResponseWrapper<void>>
|
|
1645
|
+
|
|
1646
|
+
/**
|
|
1647
|
+
* 更新事件通知
|
|
1648
|
+
* https://developer.qiniu.com/kodo/8610/dev-event-notification
|
|
1649
|
+
* @param bucket - 空间名
|
|
1650
|
+
* @param options - 配置项
|
|
1651
|
+
* @param options.name - 规则名称 bucket 内唯一,长度小于50,不能为空,只能为字母、数字、下划线
|
|
1652
|
+
* @param options.event - 事件类型,接受数组设置多个
|
|
1653
|
+
* @param options.callbackURL - 事件通知回调 URL,接受数组设置多个,失败依次重试
|
|
1654
|
+
* @param options.prefix - 可选,文件配置的前缀
|
|
1655
|
+
* @param options.suffix - 可选,文件配置的后缀
|
|
1656
|
+
* @param options.access_key - 可选,设置的话会对通知请求用对应的ak、sk进行签名
|
|
1657
|
+
* @param options.host - 可选,通知请求的host
|
|
1658
|
+
* @param callbackFunc - 回调函数
|
|
1659
|
+
*/
|
|
1660
|
+
updateBucketEvent(
|
|
1661
|
+
bucket: string,
|
|
1662
|
+
options: {
|
|
1663
|
+
name: string,
|
|
1664
|
+
event?: BucketEventName | BucketEventName[],
|
|
1665
|
+
callbackURL?: string | string[],
|
|
1666
|
+
prefix?: string,
|
|
1667
|
+
suffix?: string,
|
|
1668
|
+
access_key?: string,
|
|
1669
|
+
host?: string,
|
|
1670
|
+
},
|
|
1671
|
+
callbackFunc?: callback,
|
|
1672
|
+
): Promise<httpc.ResponseWrapper<void>>
|
|
1673
|
+
|
|
1674
|
+
/**
|
|
1675
|
+
* 获取事件通知规则
|
|
1676
|
+
* https://developer.qiniu.com/kodo/8610/dev-event-notification
|
|
1677
|
+
*
|
|
1678
|
+
* @param bucket - 空间名
|
|
1679
|
+
* @param callbackFunc - 回调函数
|
|
1680
|
+
*/
|
|
1681
|
+
getBucketEvent(bucket: string, callbackFunc?: callback): Promise<httpc.ResponseWrapper<GetBucketEventsResult>>
|
|
1682
|
+
|
|
1683
|
+
/**
|
|
1684
|
+
* 删除事件通知规则
|
|
1685
|
+
* https://developer.qiniu.com/kodo/8610/dev-event-notification
|
|
1686
|
+
*
|
|
1687
|
+
* @param bucket - 空间名
|
|
1688
|
+
* @param name - 规则名称
|
|
1689
|
+
* @param callbackFunc - 回调函数
|
|
1690
|
+
*/
|
|
1691
|
+
deleteBucketEvent(bucket: string, name: string, callbackFunc?: callback): Promise<httpc.ResponseWrapper<void>>;
|
|
1692
|
+
|
|
1693
|
+
/**
|
|
1694
|
+
* @param bucket - 空间名
|
|
1695
|
+
* @param options - 配置
|
|
1696
|
+
*/
|
|
1697
|
+
putReferAntiLeech(
|
|
1698
|
+
bucket: string,
|
|
1699
|
+
options: {
|
|
1700
|
+
mode: number,
|
|
1701
|
+
norefer: number,
|
|
1702
|
+
pattern: string,
|
|
1703
|
+
}
|
|
1704
|
+
): Promise<httpc.ResponseWrapper<void>>;
|
|
1705
|
+
|
|
1706
|
+
/**
|
|
1707
|
+
* 设置 bucket 的 cors(跨域)规则
|
|
1708
|
+
* https://developer.qiniu.com/kodo/8539/set-the-cross-domain-resource-sharing
|
|
1709
|
+
* @param bucket - 空间名
|
|
1710
|
+
* @param body - 规则配置
|
|
1711
|
+
* @param body[].allowed_origin - 允许的域名
|
|
1712
|
+
* @param body[].allowed_method - 允许的请求方法;大小写不敏感
|
|
1713
|
+
* @param body[].allowed_header - 可选,允许的 header;默认不允许任何 header;大小写不敏感
|
|
1714
|
+
* @param body[].exposed_header - 可选,暴露的 header;默认 X-Log, X-Reqid;大小写不敏感
|
|
1715
|
+
* @param body[].max_age - 可选,结果可以缓存的时间;默认不缓存
|
|
1716
|
+
* @param callbackFunc - 回调函数
|
|
1717
|
+
*/
|
|
1718
|
+
putCorsRules(
|
|
1719
|
+
bucket: string,
|
|
1720
|
+
body: {
|
|
1721
|
+
allowed_origin: string[],
|
|
1722
|
+
allowed_method: string[],
|
|
1723
|
+
allowed_header?: string[],
|
|
1724
|
+
exposed_header?: string[],
|
|
1725
|
+
max_age?: number,
|
|
1726
|
+
}[],
|
|
1727
|
+
callbackFunc?: callback
|
|
1728
|
+
): Promise<httpc.ResponseWrapper<void>>
|
|
1729
|
+
|
|
1730
|
+
/**
|
|
1731
|
+
* 获取 bucket 的 cors(跨域)规则
|
|
1732
|
+
* https://developer.qiniu.com/kodo/8539/set-the-cross-domain-resource-sharing
|
|
1733
|
+
* @param bucket - 空间名
|
|
1734
|
+
* @param callbackFunc - 回调函数
|
|
1735
|
+
*/
|
|
1736
|
+
getCorsRules(bucket: string, callbackFunc?: callback): Promise<httpc.ResponseWrapper<GetBucketCorsRulesResult>>
|
|
1737
|
+
|
|
1738
|
+
/**
|
|
1739
|
+
* 设置空间原图保护
|
|
1740
|
+
* @param bucket 空间名
|
|
1741
|
+
* @param mode 为 1 表示开启原图保护,0 表示关闭
|
|
1742
|
+
* @param callbackFunc 回调函数
|
|
1743
|
+
*/
|
|
1744
|
+
putBucketAccessStyleMode(bucket: string, mode: number, callbackFunc?: callback): Promise<httpc.ResponseWrapper<void>>
|
|
1745
|
+
|
|
1746
|
+
/**
|
|
1747
|
+
* 设置缓存策略的 max-age 属性
|
|
1748
|
+
* @param bucket
|
|
1749
|
+
* @param options
|
|
1750
|
+
* @param options.maxAge 为 0 或者负数表示为默认值(31536000)
|
|
1751
|
+
* @param callbackFunc 回调函数
|
|
1752
|
+
*/
|
|
1753
|
+
putBucketMaxAge(
|
|
1754
|
+
bucket: string,
|
|
1755
|
+
options: {
|
|
1756
|
+
maxAge: number
|
|
1757
|
+
},
|
|
1758
|
+
callbackFunc?: callback
|
|
1759
|
+
): Promise<httpc.ResponseWrapper<void>>
|
|
1760
|
+
|
|
1761
|
+
/**
|
|
1762
|
+
* 设置空间私有属性
|
|
1763
|
+
* @param bucket
|
|
1764
|
+
* @param options
|
|
1765
|
+
* @param options.private 为 0 表示公开,为 1 表示私有,默认为 0
|
|
1766
|
+
* @param callbackFunc
|
|
1767
|
+
*/
|
|
1768
|
+
putBucketAccessMode(
|
|
1769
|
+
bucket: string,
|
|
1770
|
+
options?: {
|
|
1771
|
+
private?: number
|
|
1772
|
+
},
|
|
1773
|
+
callbackFunc?: callback
|
|
1774
|
+
): Promise<httpc.ResponseWrapper<void>>
|
|
1775
|
+
|
|
1776
|
+
/**
|
|
1777
|
+
* 设置配额
|
|
1778
|
+
* @param bucket 空间名称,不支持授权空间
|
|
1779
|
+
* @param options
|
|
1780
|
+
* @param options.size 空间存储量配额,参数传入 0 或不传表示不更改当前配置,传入 -1 表示取消限额,新创建的空间默认没有限额。
|
|
1781
|
+
* @param options.count 空间文件数配额,参数含义同<size>
|
|
1782
|
+
* @param callbackFunc 回调函数
|
|
1783
|
+
*/
|
|
1784
|
+
putBucketQuota(
|
|
1785
|
+
bucket: string,
|
|
1786
|
+
options?: {
|
|
1787
|
+
size?: number,
|
|
1788
|
+
count?: number
|
|
1789
|
+
},
|
|
1790
|
+
callbackFunc?: callback
|
|
1791
|
+
): Promise<httpc.ResponseWrapper<void>>
|
|
1792
|
+
|
|
1793
|
+
/**
|
|
1794
|
+
* 获取配额
|
|
1795
|
+
* @param bucket 空间名称,不支持授权空间
|
|
1796
|
+
* @param callbackFunc 回调函数
|
|
1797
|
+
*/
|
|
1798
|
+
getBucketQuota(
|
|
1799
|
+
bucket: string,
|
|
1800
|
+
callbackFunc?: callback
|
|
1801
|
+
): Promise<httpc.ResponseWrapper<GetBucketQuotaResult>>
|
|
1802
|
+
}
|
|
1803
|
+
|
|
1804
|
+
/**
|
|
1805
|
+
*
|
|
1806
|
+
* @param bucket
|
|
1807
|
+
* @param key
|
|
1808
|
+
*/
|
|
1809
|
+
function statOp(bucket: string, key: string): string;
|
|
1810
|
+
|
|
1811
|
+
/**
|
|
1812
|
+
*
|
|
1813
|
+
* @param bucket
|
|
1814
|
+
* @param key
|
|
1815
|
+
*/
|
|
1816
|
+
function deleteOp(bucket: string, key: string): string;
|
|
1817
|
+
|
|
1818
|
+
/**
|
|
1819
|
+
*
|
|
1820
|
+
* @param bucket
|
|
1821
|
+
* @param key
|
|
1822
|
+
* @param days
|
|
1823
|
+
*/
|
|
1824
|
+
function deleteAfterDaysOp(bucket: string, key: string, days: number): string;
|
|
1825
|
+
|
|
1826
|
+
/**
|
|
1827
|
+
*
|
|
1828
|
+
* @param bucket
|
|
1829
|
+
* @param key
|
|
1830
|
+
* @param newMime
|
|
1831
|
+
*/
|
|
1832
|
+
function changeMimeOp(bucket: string, key: string, newMime: string): string;
|
|
1833
|
+
|
|
1834
|
+
/**
|
|
1835
|
+
*
|
|
1836
|
+
* @param bucket
|
|
1837
|
+
* @param key
|
|
1838
|
+
* @param headers
|
|
1839
|
+
*/
|
|
1840
|
+
function changeHeadersOp(bucket: string, key: string, headers: { [k: string]: string }): string;
|
|
1841
|
+
|
|
1842
|
+
/**
|
|
1843
|
+
*
|
|
1844
|
+
* @param bucket
|
|
1845
|
+
* @param key
|
|
1846
|
+
* @param newType
|
|
1847
|
+
*/
|
|
1848
|
+
function changeTypeOp(bucket: string, key: string, newType: number): string;
|
|
1849
|
+
|
|
1850
|
+
/**
|
|
1851
|
+
*
|
|
1852
|
+
* @param srcBucket
|
|
1853
|
+
* @param srcKey
|
|
1854
|
+
* @param destBucket
|
|
1855
|
+
* @param destKey
|
|
1856
|
+
* @param options
|
|
1857
|
+
*/
|
|
1858
|
+
function moveOp(srcBucket: string, srcKey: string, destBucket: string, destKey: string, options?: {
|
|
1859
|
+
force?: boolean
|
|
1860
|
+
}): string;
|
|
1861
|
+
|
|
1862
|
+
/**
|
|
1863
|
+
*
|
|
1864
|
+
* @param srcBucket
|
|
1865
|
+
* @param srcKey
|
|
1866
|
+
* @param destBucket
|
|
1867
|
+
* @param destKey
|
|
1868
|
+
* @param options
|
|
1869
|
+
*/
|
|
1870
|
+
function copyOp(srcBucket: string, srcKey: string, destBucket: string, destKey: string, options?: {
|
|
1871
|
+
force?: boolean
|
|
1872
|
+
}): string;
|
|
1873
|
+
|
|
1874
|
+
interface PutPolicyOptions {
|
|
1875
|
+
scope?: string;
|
|
1876
|
+
isPrefixalScope?: number;
|
|
1877
|
+
expires?: number;
|
|
1878
|
+
insertOnly?: number;
|
|
1879
|
+
saveKey?: string;
|
|
1880
|
+
forceSaveKey?: boolean;
|
|
1881
|
+
endUser?: string;
|
|
1882
|
+
returnUrl?: string;
|
|
1883
|
+
returnBody?: string;
|
|
1884
|
+
callbackUrl?: string;
|
|
1885
|
+
callbackHost?: string;
|
|
1886
|
+
callbackBody?: string;
|
|
1887
|
+
callbackBodyType?: string;
|
|
1888
|
+
callbackFetchKey?: number;
|
|
1889
|
+
|
|
1890
|
+
persistentOps?: string;
|
|
1891
|
+
persistentNotifyUrl?: string;
|
|
1892
|
+
persistentPipeline?: string;
|
|
1893
|
+
persistentType?: number;
|
|
1894
|
+
persistentWorkflowTemplateID?: string;
|
|
1895
|
+
|
|
1896
|
+
fsizeLimit?: number;
|
|
1897
|
+
fsizeMin?: number;
|
|
1898
|
+
mimeLimit?: string;
|
|
1899
|
+
|
|
1900
|
+
detectMime?: number;
|
|
1901
|
+
deleteAfterDays?: number;
|
|
1902
|
+
fileType?: number;
|
|
1903
|
+
|
|
1904
|
+
// @deprecated
|
|
1905
|
+
transform?: string;
|
|
1906
|
+
// @deprecated
|
|
1907
|
+
transformFallbackMode?: string;
|
|
1908
|
+
// @deprecated
|
|
1909
|
+
transformFallbackKey?: string;
|
|
1910
|
+
|
|
1911
|
+
[key: string]: string | number | boolean | undefined;
|
|
1912
|
+
}
|
|
1913
|
+
|
|
1914
|
+
class PutPolicy {
|
|
1915
|
+
[k: string]: string | number | boolean | Function;
|
|
1916
|
+
|
|
1917
|
+
constructor(options?: PutPolicyOptions);
|
|
1918
|
+
|
|
1919
|
+
getFlags(): any;
|
|
1920
|
+
|
|
1921
|
+
uploadToken(mac?: auth.digest.Mac): string;
|
|
1922
|
+
}
|
|
1923
|
+
}
|
|
1924
|
+
|
|
1925
|
+
export declare namespace sms {
|
|
1926
|
+
namespace message {
|
|
1927
|
+
/**
|
|
1928
|
+
* 发送短信 (POST Message)
|
|
1929
|
+
* @link https://developer.qiniu.com/sms/5897/sms-api-send-message#1
|
|
1930
|
+
* @param reqBody
|
|
1931
|
+
* @param mac
|
|
1932
|
+
* @param callback
|
|
1933
|
+
*/
|
|
1934
|
+
function sendMessage(
|
|
1935
|
+
reqBody: {
|
|
1936
|
+
"template_id": string,
|
|
1937
|
+
"mobiles": string[],
|
|
1938
|
+
"parameters"?: Record<string, string>
|
|
1939
|
+
},
|
|
1940
|
+
mac: auth.digest.Mac,
|
|
1941
|
+
callback: Callback<{ job_id: string }>
|
|
1942
|
+
): void;
|
|
1943
|
+
|
|
1944
|
+
/**
|
|
1945
|
+
* 发送单条短信 (POST Single Message)
|
|
1946
|
+
* @link https://developer.qiniu.com/sms/5897/sms-api-send-message#2
|
|
1947
|
+
* @param reqBody
|
|
1948
|
+
* @param mac
|
|
1949
|
+
* @param callback
|
|
1950
|
+
*/
|
|
1951
|
+
function sendSingleMessage(
|
|
1952
|
+
reqBody: {
|
|
1953
|
+
"template_id": string,
|
|
1954
|
+
"mobile": string,
|
|
1955
|
+
"parameters"?: Record<string, string>
|
|
1956
|
+
},
|
|
1957
|
+
mac: auth.digest.Mac,
|
|
1958
|
+
callback: Callback<{ message_id: string }>
|
|
1959
|
+
): void;
|
|
1960
|
+
|
|
1961
|
+
/**
|
|
1962
|
+
* 发送国际/港澳台短信 (POST Oversea Message)
|
|
1963
|
+
* @link https://developer.qiniu.com/sms/5897/sms-api-send-message#3
|
|
1964
|
+
* @param reqBody
|
|
1965
|
+
* @param mac
|
|
1966
|
+
* @param callback
|
|
1967
|
+
*/
|
|
1968
|
+
function sendOverseaMessage(
|
|
1969
|
+
reqBody: {
|
|
1970
|
+
"template_id": string,
|
|
1971
|
+
"mobile": string,
|
|
1972
|
+
"parameters"?: Record<string, string>
|
|
1973
|
+
},
|
|
1974
|
+
mac: auth.digest.Mac,
|
|
1975
|
+
callback: Callback<{ message_id: string }>
|
|
1976
|
+
): void;
|
|
1977
|
+
|
|
1978
|
+
/**
|
|
1979
|
+
* 发送全文本短信(不需要传模版 ID) (POST Fulltext Message)
|
|
1980
|
+
* @link https://developer.qiniu.com/sms/5897/sms-api-send-message#4
|
|
1981
|
+
* @param reqBody
|
|
1982
|
+
* @param mac
|
|
1983
|
+
* @param callback
|
|
1984
|
+
*/
|
|
1985
|
+
function sendFulltextMessage(
|
|
1986
|
+
reqBody: {
|
|
1987
|
+
"mobiles": string[],
|
|
1988
|
+
"content": string,
|
|
1989
|
+
"template_type": string
|
|
1990
|
+
},
|
|
1991
|
+
mac: auth.digest.Mac,
|
|
1992
|
+
callback: Callback<{ job_id: string }>
|
|
1993
|
+
): void;
|
|
1994
|
+
}
|
|
1995
|
+
}
|