@cloudbase/manager-node 5.3.0 → 5.4.0-beta.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.
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/manager-node",
3
- "version": "5.3.0",
3
+ "version": "5.4.0-beta.1",
4
4
  "description": "The node manage service api for cloudbase.",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -47,6 +47,33 @@ interface IRunCommandsResult extends IResponseInfo {
47
47
  /** 返回结果,每个元素是一个 JSON 字符串 */
48
48
  Data: string[];
49
49
  }
50
+ /** ExecutePGSql 请求参数 */
51
+ interface IExecutePGSqlOptions {
52
+ /** 要执行的 SQL 语句 */
53
+ Sql: string;
54
+ /** 指定 role 执行 SQL(可选) */
55
+ Role?: string;
56
+ /** 云开发环境 ID(可选,不传则自动使用当前环境 ID) */
57
+ EnvId?: string;
58
+ }
59
+ /** ExecutePGSql 返回结果 */
60
+ interface IExecutePGSqlResult extends IResponseInfo {
61
+ /** 影响行数 */
62
+ AffectedRows: number;
63
+ /**
64
+ * 字段名列表
65
+ * 注意:此字段可能返回 null,表示取不到有效值
66
+ */
67
+ Columns: string[] | null;
68
+ /**
69
+ * 数据行。每一行数据都是一个 JSON 串,
70
+ * 将 JSON 进行反序列化将得到每列的值(值可能是 null 或字符串)
71
+ * 注意:此字段可能返回 null,表示取不到有效值
72
+ */
73
+ Rows: string[] | null;
74
+ /** SQL 执行耗时(单位:毫秒) */
75
+ ExecutionTimeMs: number;
76
+ }
50
77
  interface ICollectionInfo extends IResponseInfo {
51
78
  Collections: Array<TableInfo>;
52
79
  Pager: Pager;
@@ -174,5 +201,29 @@ export declare class DatabaseService {
174
201
  * @returns 执行结果,Data 为 JSON 字符串数组
175
202
  */
176
203
  runCommands(options: IRunCommandsOptions): Promise<IRunCommandsResult>;
204
+ /**
205
+ * 在 PostgreSQL 数据库上执行 SQL 语句
206
+ *
207
+ * @param options 执行参数
208
+ * @param options.Sql 要执行的 SQL 语句
209
+ * @param options.Role 指定 role 执行 SQL(可选)
210
+ * @param options.EnvId 环境 ID(可选,不传则自动使用当前环境 ID)
211
+ * @returns 执行结果,包含影响行数、字段列表、数据行及执行耗时
212
+ *
213
+ * @example
214
+ * // 创建表
215
+ * const res = await database.executePGSql({
216
+ * Sql: 'CREATE TABLE users (id SERIAL PRIMARY KEY, name TEXT NOT NULL)'
217
+ * })
218
+ *
219
+ * @example
220
+ * // 查询数据
221
+ * const res = await database.executePGSql({
222
+ * Sql: "SELECT * FROM users WHERE id = 1"
223
+ * })
224
+ * console.log(res.Columns) // ['id', 'name']
225
+ * console.log(res.Rows) // ['["1","Alice"]']
226
+ */
227
+ executePGSql(options: IExecutePGSqlOptions): Promise<IExecutePGSqlResult>;
177
228
  }
178
229
  export {};
@@ -1,5 +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
4
  export interface IProgressData {
4
5
  loaded: number;
5
6
  total: number;
@@ -448,6 +449,86 @@ export declare class StorageService {
448
449
  * @returns 搜索结果数组(包含文件和目录)
449
450
  */
450
451
  searchFiles(options: ISearchOptions): Promise<ISearchResult[]>;
452
+ /**
453
+ * 通过 CloudBase HTTP API 上传对象(Binary 直传)
454
+ * POST/PUT /v1/storages/object/:bucketId/*objectName
455
+ */
456
+ uploadObject(options: IUploadObjectHttpOptions): Promise<IUploadObjectHttpResult>;
457
+ /**
458
+ * 通过 CloudBase HTTP API 删除单个对象
459
+ * DELETE /v1/storages/object/:bucketId/*objectName
460
+ */
461
+ deleteObject(options: IDeleteObjectHttpOptions): Promise<IDeleteObjectHttpResult>;
462
+ /**
463
+ * 通过 CloudBase HTTP API 批量删除对象(单次最多 20 个)
464
+ * DELETE /v1/storages/object/:bucketId
465
+ */
466
+ deleteObjects(options: IDeleteObjectsHttpOptions): Promise<IDeletedObjectInfo[]>;
467
+ /**
468
+ * 通过 CloudBase HTTP API 复制对象
469
+ * POST /v1/storages/object/copy
470
+ */
471
+ copyObject(options: ICopyObjectHttpOptions): Promise<ICopyObjectHttpResult>;
472
+ /**
473
+ * 通过 CloudBase HTTP API 移动对象(复制后删除源对象,由服务端一次性完成)
474
+ * POST /v1/storages/object/move
475
+ */
476
+ moveObject(options: IMoveObjectHttpOptions): Promise<IMoveObjectHttpResult>;
477
+ /**
478
+ * 通过 CloudBase HTTP API 列出对象
479
+ * POST /v1/storages/object/list/:bucketId
480
+ */
481
+ listObjects(options: IListObjectsHttpOptions): Promise<IListObjectsHttpResult>;
482
+ /**
483
+ * 通过 CloudBase HTTP API 生成签名下载 URL
484
+ * POST /v1/storages/object/sign/:bucketId/*objectName
485
+ */
486
+ signObject(options: ISignObjectHttpOptions): Promise<ISignObjectHttpResult>;
487
+ /**
488
+ * 通过 CloudBase HTTP API 批量生成签名下载 URL
489
+ * POST /v1/storages/object/sign/:bucketId
490
+ */
491
+ signObjects(options: ISignObjectsHttpOptions): Promise<ISignObjectsHttpResult>;
492
+ /**
493
+ * 通过 CloudBase HTTP API 生成签名上传 URL
494
+ * POST /v1/storages/object/upload/sign/:bucketId/*objectName
495
+ */
496
+ signUploadObject(options: ISignUploadObjectHttpOptions): Promise<ISignUploadObjectHttpResult>;
497
+ /**
498
+ * 通过 CloudBase HTTP API 使用签名 URL 上传对象(无需 Authorization)
499
+ * PUT /v1/storages/object/upload/sign/:bucketId/*objectName?token=xxx
500
+ */
501
+ uploadObjectBySign(options: IUploadObjectBySignHttpOptions): Promise<IUploadObjectBySignHttpResult>;
502
+ /**
503
+ * 通过 CloudBase HTTP API 下载对象(需认证)
504
+ * GET/HEAD /v1/storages/object/authenticated/:bucketId/*objectName
505
+ */
506
+ downloadAuthenticatedObject(options: IDownloadAuthenticatedObjectHttpOptions): Promise<IDownloadObjectHttpResult>;
507
+ /**
508
+ * 通过 CloudBase HTTP API 下载对象(可选认证)
509
+ * GET/HEAD /v1/storages/object/:bucketId/*objectName
510
+ */
511
+ downloadObject(options: IDownloadObjectHttpOptions): Promise<IDownloadObjectHttpResult>;
512
+ /**
513
+ * 通过 CloudBase HTTP API 下载公开对象(无需认证)
514
+ * GET/HEAD /v1/storages/object/public/:bucketId/*objectName
515
+ */
516
+ downloadPublicObject(options: IDownloadPublicObjectHttpOptions): Promise<IDownloadObjectHttpResult>;
517
+ /**
518
+ * 通过 CloudBase HTTP API 使用签名 URL 下载对象(无需 Authorization)
519
+ * GET/HEAD /v1/storages/object/sign/:bucketId/*objectName?token=xxx
520
+ */
521
+ downloadObjectBySign(options: IDownloadObjectBySignHttpOptions): Promise<IDownloadObjectHttpResult>;
522
+ /**
523
+ * 通过 CloudBase HTTP API 获取对象元信息(需认证)
524
+ * GET/HEAD /v1/storages/object/info/authenticated/:bucketId/*objectName
525
+ */
526
+ getObjectInfoAuthenticated(options: IGetObjectInfoAuthenticatedHttpOptions): Promise<IGetObjectInfoHttpResult>;
527
+ /**
528
+ * 通过 CloudBase HTTP API 获取公开对象元信息(无需认证)
529
+ * GET /v1/storages/object/info/public/:bucketId/*objectName
530
+ */
531
+ getObjectInfoPublic(options: IGetObjectInfoPublicHttpOptions): Promise<IGetObjectInfoHttpResult>;
451
532
  /**
452
533
  * 获取 COS 配置
453
534
  */
@@ -0,0 +1,431 @@
1
+ export interface IUploadObjectHttpOptions {
2
+ /** Bucket ID */
3
+ bucketId: string;
4
+ /** 对象名,支持路径,例如 folder/file.png */
5
+ objectName: string;
6
+ /**
7
+ * 文件来源(二选一):
8
+ * - localPath:本地文件绝对/相对路径
9
+ * - body:Buffer 或可读流
10
+ */
11
+ localPath?: string;
12
+ body?: Buffer | NodeJS.ReadableStream;
13
+ /** MIME 类型,默认 application/octet-stream */
14
+ contentType?: string;
15
+ /** 文件字节数;不传时若为 localPath/Buffer 会自动推断 */
16
+ contentLength?: number;
17
+ /**
18
+ * 缓存控制;传 number 自动转换为 max-age=<value>,传 string 直接作为 Cache-Control 头值
19
+ */
20
+ cacheControl?: number | string;
21
+ /** 自定义 metadata(JSON 对象),将以 Base64 编码后放入 X-Metadata 头 */
22
+ metadata?: Record<string, any>;
23
+ /** 爬虫指令(X-Robots-Tag 头) */
24
+ xRobotsTag?: string;
25
+ /** POST 时是否允许覆盖(x-upsert: true) */
26
+ upsert?: boolean;
27
+ /** 使用 PUT 方法(始终覆盖,等价于 x-upsert: true) */
28
+ usePut?: boolean;
29
+ /**
30
+ * 鉴权令牌(Bearer Token),支持以下三种类型之一:
31
+ * - access_token:登录态访问令牌
32
+ * - apiKey:服务端管理员访问凭证(JWT 格式,可由 env.createApiKey 创建,长期有效)
33
+ * - publishableKey:前端匿名访问凭证
34
+ *
35
+ * 调用时以 `Authorization: Bearer <token>` 形式传递。
36
+ * ⚠️ apiKey 严禁在客户端使用。
37
+ */
38
+ accessToken: string;
39
+ /** 可选覆盖 envId,不传则取当前环境 */
40
+ envId?: string;
41
+ }
42
+ export interface IUploadObjectHttpResult {
43
+ Id: string;
44
+ Key: string;
45
+ }
46
+ /** 删除单个对象参数 */
47
+ export interface IDeleteObjectHttpOptions {
48
+ /** Bucket ID */
49
+ bucketId: string;
50
+ /** 对象名,支持路径,例如 folder/file.png */
51
+ objectName: string;
52
+ /** Bearer Token(access_token / apiKey / publishableKey 均可) */
53
+ accessToken: string;
54
+ /** 可选覆盖 envId */
55
+ envId?: string;
56
+ }
57
+ /** 删除单个对象响应 */
58
+ export interface IDeleteObjectHttpResult {
59
+ message: string;
60
+ }
61
+ /** 批量删除对象参数 */
62
+ export interface IDeleteObjectsHttpOptions {
63
+ /** Bucket ID */
64
+ bucketId: string;
65
+ /**
66
+ * 要删除的对象名列表,1 ~ 20 个。
67
+ * ⚠️ 官方文档字段名为 `prefixes`,但本质是完整 object name 的精确匹配(非前缀匹配)
68
+ */
69
+ prefixes: string[];
70
+ /** Bearer Token */
71
+ accessToken: string;
72
+ /** 可选覆盖 envId */
73
+ envId?: string;
74
+ }
75
+ /** 批量删除对象响应(单条) */
76
+ export interface IDeletedObjectInfo {
77
+ name: string;
78
+ bucket_id: string;
79
+ owner_id: string;
80
+ [key: string]: any;
81
+ }
82
+ /** 复制对象参数 */
83
+ export interface ICopyObjectHttpOptions {
84
+ /** 源 Bucket ID */
85
+ bucketId: string;
86
+ /** 源对象名 */
87
+ sourceKey: string;
88
+ /** 目标对象名 */
89
+ destinationKey: string;
90
+ /** 目标 Bucket ID,默认与源 Bucket 相同 */
91
+ destinationBucket?: string;
92
+ /**
93
+ * 系统 metadata(对应 DB 列 storage.objects.metadata),
94
+ * 仅在 copyMetadata=false 时生效:以源 metadata 为底,与请求 metadata 合并(同 key 覆盖)。
95
+ * COS 后端实际会识别的字段:cacheControl / mimetype / contentType。
96
+ * 通过 body.metadata 字段传递。
97
+ */
98
+ metadata?: Record<string, any>;
99
+ /**
100
+ * 用户自定义 metadata(对应 DB 列 storage.objects.user_metadata),
101
+ * 仅在 copyMetadata=false 时生效:**整体替换**目标对象的 user_metadata(不是合并)。
102
+ * 通过 x-metadata Header 传递,内部会 Base64(JSON) 编码。
103
+ */
104
+ userMetadata?: Record<string, any>;
105
+ /**
106
+ * 是否复制源对象的 metadata,默认 true。
107
+ * - true:直接继承源对象 metadata / user_metadata,请求里的 metadata 和 userMetadata 均被忽略
108
+ * - false:
109
+ * · metadata 字段(若传)与源 metadata 合并
110
+ * · userMetadata 字段(若传)整体替换源 user_metadata
111
+ */
112
+ copyMetadata?: boolean;
113
+ /** 是否允许覆盖目标位置已有对象(x-upsert: "true") */
114
+ upsert?: boolean;
115
+ /** Bearer Token(access_token / apiKey / publishableKey 均可) */
116
+ accessToken: string;
117
+ /** 可选覆盖 envId */
118
+ envId?: string;
119
+ }
120
+ /** 复制对象响应 */
121
+ export interface ICopyObjectHttpResult {
122
+ Id: string;
123
+ Key: string;
124
+ name: string;
125
+ bucket_id: string;
126
+ owner_id: string;
127
+ version: string;
128
+ id: string;
129
+ updated_at: string;
130
+ created_at: string;
131
+ last_accessed_at: string;
132
+ metadata: Record<string, any>;
133
+ user_metadata: Record<string, any>;
134
+ [key: string]: any;
135
+ }
136
+ /** 移动对象参数 */
137
+ export interface IMoveObjectHttpOptions {
138
+ /** 源 Bucket ID */
139
+ bucketId: string;
140
+ /** 源对象名 */
141
+ sourceKey: string;
142
+ /** 目标对象名 */
143
+ destinationKey: string;
144
+ /** 目标 Bucket ID,默认与源 Bucket 相同 */
145
+ destinationBucket?: string;
146
+ /** Bearer Token(access_token / apiKey / publishableKey 均可) */
147
+ accessToken: string;
148
+ /** 可选覆盖 envId */
149
+ envId?: string;
150
+ }
151
+ /** 移动对象响应 */
152
+ export interface IMoveObjectHttpResult {
153
+ message: string;
154
+ Id: string;
155
+ Key: string;
156
+ }
157
+ export type IListObjectsSortColumn = 'name' | 'created_at' | 'updated_at';
158
+ export type IListObjectsSortOrder = 'asc' | 'desc';
159
+ /** 列出对象参数 */
160
+ export interface IListObjectsHttpOptions {
161
+ /** Bucket ID(Path 参数) */
162
+ bucketId: string;
163
+ /** 路径前缀 */
164
+ prefix?: string;
165
+ /** 分页限制,1 ~ 1000 */
166
+ limit?: number;
167
+ /** 游标(由上一次响应的 nextCursor 提供) */
168
+ cursor?: string;
169
+ /** 是否使用 / 作为分隔符区分文件夹 */
170
+ withDelimiter?: boolean;
171
+ /** 排序选项 */
172
+ sortBy?: {
173
+ /** 允许值:name、created_at、updated_at */
174
+ column?: IListObjectsSortColumn;
175
+ /** 排序方向:asc(默认)、desc */
176
+ order?: IListObjectsSortOrder;
177
+ };
178
+ /** Bearer Token(access_token / apiKey / publishableKey 均可) */
179
+ accessToken: string;
180
+ /** 可选覆盖 envId */
181
+ envId?: string;
182
+ }
183
+ /** 列表中的“文件夹”条目 */
184
+ export interface IListObjectsFolderItem {
185
+ key: string;
186
+ name: string;
187
+ id: string | null;
188
+ updated_at: string | null;
189
+ created_at: string | null;
190
+ last_accessed_at: string | null;
191
+ metadata: Record<string, any> | null;
192
+ }
193
+ /** 列表中的“对象/文件”条目 */
194
+ export interface IListObjectsObjectItem {
195
+ name: string;
196
+ id: string;
197
+ updated_at: string;
198
+ created_at: string;
199
+ last_accessed_at: string;
200
+ metadata: Record<string, any>;
201
+ [key: string]: any;
202
+ }
203
+ /** 列出对象响应 */
204
+ export interface IListObjectsHttpResult {
205
+ folders: IListObjectsFolderItem[];
206
+ objects: IListObjectsObjectItem[];
207
+ hasNext: boolean;
208
+ nextCursor?: string;
209
+ nextCursorKey?: string;
210
+ [key: string]: any;
211
+ }
212
+ /** 生成签名下载 URL 参数 */
213
+ export interface ISignObjectHttpOptions {
214
+ /** Bucket ID(Path 参数) */
215
+ bucketId: string;
216
+ /** 对象名称(Path 参数) */
217
+ objectName: string;
218
+ /** 过期时间(秒),必须 >= 1 */
219
+ expiresIn: number;
220
+ /** Bearer Token(access_token / apiKey / publishableKey 均可) */
221
+ accessToken: string;
222
+ /** 可选覆盖 envId */
223
+ envId?: string;
224
+ }
225
+ /** 生成签名下载 URL 响应 */
226
+ export interface ISignObjectHttpResult {
227
+ signedURL: string;
228
+ }
229
+ /** 批量生成签名 URL 参数 */
230
+ export interface ISignObjectsHttpOptions {
231
+ /** Bucket ID(Path 参数) */
232
+ bucketId: string;
233
+ /** 过期时间(秒),必须 >= 1 */
234
+ expiresIn: number;
235
+ /** 对象名称列表,不能为空,最多 500 个 */
236
+ paths: string[];
237
+ /** Bearer Token(access_token / apiKey / publishableKey 均可) */
238
+ accessToken: string;
239
+ /** 可选覆盖 envId */
240
+ envId?: string;
241
+ }
242
+ /** 批量签名结果条目 */
243
+ export interface ISignedObjectItem {
244
+ path: string;
245
+ signedURL: string | null;
246
+ error: string | null;
247
+ [key: string]: any;
248
+ }
249
+ /** 批量生成签名 URL 响应 */
250
+ export type ISignObjectsHttpResult = ISignedObjectItem[];
251
+ /** 生成签名上传 URL 参数 */
252
+ export interface ISignUploadObjectHttpOptions {
253
+ /** Bucket ID(Path 参数) */
254
+ bucketId: string;
255
+ /** 对象名称(Path 参数) */
256
+ objectName: string;
257
+ /** "true" 时允许覆盖(x-upsert: true) */
258
+ upsert?: boolean;
259
+ /** Bearer Token(access_token / apiKey / publishableKey 均可) */
260
+ accessToken: string;
261
+ /** 可选覆盖 envId */
262
+ envId?: string;
263
+ }
264
+ /** 生成签名上传 URL 响应 */
265
+ export interface ISignUploadObjectHttpResult {
266
+ url: string;
267
+ token: string;
268
+ }
269
+ /** 通过签名 URL 上传参数 */
270
+ export interface IUploadObjectBySignHttpOptions {
271
+ /** Bucket ID(Path 参数) */
272
+ bucketId: string;
273
+ /** 对象名称(Path 参数) */
274
+ objectName: string;
275
+ /** 签名上传 token(Query 参数) */
276
+ token: string;
277
+ /** 文件来源(二选一):localPath 或 body */
278
+ localPath?: string;
279
+ body?: Buffer | NodeJS.ReadableStream;
280
+ /** MIME 类型,默认 application/octet-stream */
281
+ contentType?: string;
282
+ /** 文件字节数;不传时若为 localPath/Buffer 会自动推断 */
283
+ contentLength?: number;
284
+ /** 可选覆盖 envId */
285
+ envId?: string;
286
+ }
287
+ /** 通过签名 URL 上传响应 */
288
+ export interface IUploadObjectBySignHttpResult {
289
+ Key: string;
290
+ }
291
+ /** 下载方法,仅支持 GET / HEAD */
292
+ export type IDownloadObjectHttpMethod = 'GET' | 'HEAD';
293
+ /** 下载对象公共参数 */
294
+ export interface IDownloadObjectBaseHttpOptions {
295
+ /** Bucket ID(Path 参数) */
296
+ bucketId: string;
297
+ /** 对象名称(Path 参数) */
298
+ objectName: string;
299
+ /** HTTP 方法:GET 返回文件流;HEAD 仅返回响应头 */
300
+ method?: IDownloadObjectHttpMethod;
301
+ /** Query 参数:存在时触发浏览器下载,值作为下载文件名 */
302
+ download?: string;
303
+ /** 条件请求头:ETag 校验 */
304
+ ifNoneMatch?: string;
305
+ /** 条件请求头:修改时间校验 */
306
+ ifModifiedSince?: string;
307
+ /** 范围请求头(断点续传) */
308
+ range?: string;
309
+ /** 可选覆盖 envId */
310
+ envId?: string;
311
+ }
312
+ /** 下载对象(需认证)参数 */
313
+ export interface IDownloadAuthenticatedObjectHttpOptions extends IDownloadObjectBaseHttpOptions {
314
+ /** Bearer Token(access_token / apiKey / publishableKey 均可) */
315
+ accessToken: string;
316
+ }
317
+ /** 下载对象(可选认证)参数 */
318
+ export interface IDownloadObjectHttpOptions extends IDownloadObjectBaseHttpOptions {
319
+ /** Bearer Token(可选;不传时仅 public bucket 可访问) */
320
+ accessToken?: string;
321
+ }
322
+ /** 下载公开对象参数 */
323
+ export interface IDownloadPublicObjectHttpOptions {
324
+ /** Bucket ID(Path 参数,必须为 public bucket) */
325
+ bucketId: string;
326
+ /** 对象名称(Path 参数) */
327
+ objectName: string;
328
+ /** HTTP 方法:GET 返回文件流;HEAD 仅返回响应头 */
329
+ method?: IDownloadObjectHttpMethod;
330
+ /** Query 参数:存在时触发浏览器下载,值作为下载文件名 */
331
+ download?: string;
332
+ /** 可选覆盖 envId */
333
+ envId?: string;
334
+ }
335
+ /** 通过签名 URL 下载对象参数 */
336
+ export interface IDownloadObjectBySignHttpOptions {
337
+ /** Bucket ID(Path 参数) */
338
+ bucketId: string;
339
+ /** 对象名称(Path 参数) */
340
+ objectName: string;
341
+ /** 签名 token(Query 参数,必填) */
342
+ token: string;
343
+ /** HTTP 方法:GET 返回文件流;HEAD 仅返回响应头 */
344
+ method?: IDownloadObjectHttpMethod;
345
+ /** Query 参数:存在时触发浏览器下载,值作为下载文件名 */
346
+ download?: string;
347
+ /** 可选覆盖 envId */
348
+ envId?: string;
349
+ }
350
+ /** Storage 响应头(小写 key) */
351
+ export interface IStorageResponseHeaders {
352
+ /** 是否支持 Range 请求(断点续传) */
353
+ 'accept-ranges'?: string;
354
+ /** 缓存控制(HTTP 响应级别) */
355
+ 'cache-control'?: string;
356
+ /** 响应体字节数 */
357
+ 'content-length'?: string;
358
+ /** MIME 类型 */
359
+ 'content-type'?: string;
360
+ /** 响应时间(GMT) */
361
+ 'date'?: string;
362
+ /** 响应体 ETag */
363
+ etag?: string;
364
+ /** 对象最后修改时间 */
365
+ 'last-modified'?: string;
366
+ /** 服务器标识 */
367
+ server?: string;
368
+ /** CloudBase 请求追踪 ID */
369
+ 'x-cloudbase-request-id'?: string;
370
+ /** 通用请求追踪 ID */
371
+ 'x-request-id'?: string;
372
+ /** 爬虫指令 */
373
+ 'x-robots-tag'?: string;
374
+ /** 其他未枚举的头 */
375
+ [key: string]: string | undefined;
376
+ }
377
+ /** 下载对象响应(GET 返回流;HEAD 的 body 为 null) */
378
+ export interface IDownloadObjectHttpResult {
379
+ /** HTTP 状态码,例如 200 / 206 / 304 */
380
+ status: number;
381
+ /** 响应头(小写 key) */
382
+ headers: IStorageResponseHeaders;
383
+ /** GET 时为可读流,HEAD 时为 null */
384
+ body: NodeJS.ReadableStream | null;
385
+ }
386
+ /** 对象元信息(GET 响应 JSON) */
387
+ export interface IObjectInfoHttpPayload {
388
+ id: string;
389
+ name: string;
390
+ version: string;
391
+ bucket_id: string;
392
+ size: number;
393
+ content_type: string;
394
+ cache_control: string;
395
+ etag: string;
396
+ metadata: Record<string, any>;
397
+ last_modified: string;
398
+ created_at: string;
399
+ [key: string]: any;
400
+ }
401
+ /** 获取对象元信息(需认证)参数 */
402
+ export interface IGetObjectInfoAuthenticatedHttpOptions {
403
+ /** Bucket ID(Path 参数) */
404
+ bucketId: string;
405
+ /** 对象名称(Path 参数) */
406
+ objectName: string;
407
+ /** HTTP 方法:GET 返回 JSON;HEAD 仅返回响应头 */
408
+ method?: IDownloadObjectHttpMethod;
409
+ /** Bearer Token(access_token / apiKey / publishableKey 均可) */
410
+ accessToken: string;
411
+ /** 可选覆盖 envId */
412
+ envId?: string;
413
+ }
414
+ /** 获取公开对象元信息参数(仅支持 GET) */
415
+ export interface IGetObjectInfoPublicHttpOptions {
416
+ /** Bucket ID(Path 参数,必须为 public bucket) */
417
+ bucketId: string;
418
+ /** 对象名称(Path 参数) */
419
+ objectName: string;
420
+ /** 可选覆盖 envId */
421
+ envId?: string;
422
+ }
423
+ /** 获取对象元信息响应(HEAD 不返回 body) */
424
+ export interface IGetObjectInfoHttpResult {
425
+ /** HTTP 状态码,例如 200 / 304 */
426
+ status: number;
427
+ /** 响应头(小写 key) */
428
+ headers: IStorageResponseHeaders;
429
+ /** GET 时返回 JSON;HEAD 时为 null */
430
+ body: IObjectInfoHttpPayload | null;
431
+ }
@@ -1,9 +0,0 @@
1
- {
2
- "permissions": {
3
- "allow": [
4
- "Bash(TCB_BASE_URL=https://tcb.pre.tencentcloudapi.woa.com npm test -- --testPathPattern=cloudApp 2>&1)",
5
- "Bash(TCB_BASE_URL=https://tcb.pre.tencentcloudapi.woa.com npm test 2>&1)",
6
- "Bash(TCB_BASE_URL=https://tcb.pre.tencentcloudapi.woa.com npm test -- --testPathPattern=cloudApp --testNamePattern=\"获取版本列表\")"
7
- ]
8
- }
9
- }
@@ -1,8 +0,0 @@
1
- root = true
2
- [*]
3
- indent_style = space
4
- indent_size = 4
5
- end_of_line = lf
6
- charset = utf-8
7
- trim_trailing_whitespace = true
8
- insert_final_newline = true
@@ -1,3 +0,0 @@
1
- lib/
2
- types/
3
- node_modules
@@ -1,27 +0,0 @@
1
- module.exports = {
2
- extends: ['alloy', 'alloy/typescript'],
3
- rules: {
4
- indent: ['error', 4],
5
- semi: ['error', 'never'],
6
- complexity: ['error', { max: 40 }],
7
- 'no-useless-constructor': 'off',
8
- '@typescript-eslint/explicit-member-accessibility': 'off',
9
- '@typescript-eslint/explicit-function-return-type': 'off',
10
- '@typescript-eslint/interface-name-prefix': 'off',
11
- '@typescript-eslint/no-useless-constructor': 'off',
12
- '@typescript-eslint/no-duplicate-imports': 'off'
13
- },
14
- env: {
15
- es6: true,
16
- node: true,
17
- jest: true
18
- },
19
- overrides: [
20
- {
21
- files: ['*.js'],
22
- rules: {
23
- '@typescript-eslint/no-var-requires': 'off'
24
- }
25
- }
26
- ]
27
- }
@@ -1,31 +0,0 @@
1
- module.exports = {
2
- // 一行最多 100 字符
3
- printWidth: 100,
4
- // 使用 4 个空格缩进
5
- tabWidth: 4,
6
- // 不使用缩进符,而使用空格
7
- useTabs: false,
8
- // 行尾需要有分号
9
- semi: false,
10
- // 使用单引号
11
- singleQuote: true,
12
- // 对象的 key 仅在必要时用引号
13
- quoteProps: 'as-needed',
14
- // 末尾不需要逗号
15
- trailingComma: 'none',
16
- // 大括号内的首尾需要空格
17
- bracketSpacing: true,
18
- // 每个文件格式化的范围是文件的全部内容
19
- rangeStart: 0,
20
- rangeEnd: Infinity,
21
- // 不需要写文件开头的 @prettier
22
- requirePragma: false,
23
- // 不需要自动在文件开头插入 @prettier
24
- insertPragma: false,
25
- // 使用默认的折行标准
26
- proseWrap: 'preserve',
27
- // 换行符使用 lf
28
- endOfLine: 'lf',
29
- // 箭头括号
30
- arrowParens: 'avoid'
31
- }