@cloudbase/manager-node 5.10.4 → 5.10.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/changelog_content_en.md +2 -2
- package/jest.config.js +4 -2
- package/jest.config.unit.js +2 -1
- package/lib/database/index.js +33 -9
- package/lib/docs/index.js +18 -3
- package/lib/env/index.js +126 -42
- package/lib/error-docs.js +11 -1
- package/lib/error-types.js +2 -0
- package/lib/function/index.js +5 -1
- package/lib/storage/index.js +394 -13
- package/package.json +2 -1
- package/scripts/check-error-codes.cjs +80 -0
- package/types/database/type.d.ts +17 -8
- package/types/docs/index.d.ts +5 -0
- package/types/env/index.d.ts +21 -2
- package/types/env/type.d.ts +94 -0
- package/types/error-docs.d.ts +3 -1
- package/types/error-types.d.ts +6 -0
- package/types/monitor/types.d.ts +2 -2
- package/types/storage/index.d.ts +6 -1
- package/types/storage/type.d.ts +76 -1
package/CHANGELOG.md
CHANGED
package/changelog_content_en.md
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
## [5.10.
|
|
1
|
+
## [5.10.5] 2026-11-18
|
|
2
2
|
|
|
3
|
-
- [Added] [TODO: translate]
|
|
3
|
+
- [Added] [TODO: translate] env: 新增环境访问控制配置查询与修改接口
|
package/jest.config.js
CHANGED
|
@@ -12,11 +12,13 @@ module.exports = {
|
|
|
12
12
|
testEnvironment: 'node',
|
|
13
13
|
testPathIgnorePatterns: [
|
|
14
14
|
// PG 集成测试 / smoke 测试需要 PostgreSQL 环境,流水线默认跳过
|
|
15
|
-
'pg-storage-integration\\.test\\.ts$',
|
|
15
|
+
'pg-storage-(tus-)?integration\\.test\\.ts$',
|
|
16
16
|
// MySQL 集成测试依赖账号的 MySQL 开通白名单与 cynosdb 操作权限:
|
|
17
17
|
// 流水线账号调 createMySQL 返回「操作不支持,当前用户不在 MySQL 开通白名单内」,
|
|
18
18
|
// 属环境权限缺失而非代码缺陷,故整体跳过(本地需验证时用 --testPathIgnorePatterns 覆盖)
|
|
19
|
-
'test/mysql/.*\\.test\\.ts$'
|
|
19
|
+
'test/mysql/.*\\.test\\.ts$',
|
|
20
|
+
// 环境访问控制集成测试依赖企业版环境,流水线账号无企业版权限,默认跳过
|
|
21
|
+
'test/env/access-control\\.test\\.ts$'
|
|
20
22
|
],
|
|
21
23
|
// https://github.com/facebook/jest/issues/5164
|
|
22
24
|
globalSetup: './test/global-setup-hook.ts',
|
package/jest.config.unit.js
CHANGED
package/lib/database/index.js
CHANGED
|
@@ -398,7 +398,6 @@ class DatabaseService {
|
|
|
398
398
|
* @returns 预览结果(Pending、Applied、Conflicts、Executable)
|
|
399
399
|
*/
|
|
400
400
|
async previewPGUserMigrations(options) {
|
|
401
|
-
var _a;
|
|
402
401
|
const { EnvId, Migrations, IncludeAll } = options;
|
|
403
402
|
if (!Array.isArray(Migrations) || Migrations.length === 0) {
|
|
404
403
|
(0, error_1.throwInvalidParam)('Migrations 至少需要 1 条');
|
|
@@ -410,11 +409,24 @@ class DatabaseService {
|
|
|
410
409
|
if (!/^[a-z_]+$/.test(migration.Name)) {
|
|
411
410
|
(0, error_1.throwInvalidParam)('Migration.Name 只允许小写字母和下划线');
|
|
412
411
|
}
|
|
412
|
+
}
|
|
413
|
+
const envId = EnvId || this.envId;
|
|
414
|
+
const remote = await this.listAllPGUserMigrations({ EnvId: envId });
|
|
415
|
+
const appliedVersions = new Set(remote.Migrations.map(migration => migration.Version));
|
|
416
|
+
const migrations = Migrations.map(migration => {
|
|
417
|
+
var _a;
|
|
418
|
+
if (appliedVersions.has(migration.Version)) {
|
|
419
|
+
return {
|
|
420
|
+
Version: migration.Version,
|
|
421
|
+
Name: migration.Name
|
|
422
|
+
};
|
|
423
|
+
}
|
|
413
424
|
if (!((_a = migration.Query) === null || _a === void 0 ? void 0 : _a.trim())) {
|
|
414
|
-
(0, error_1.throwInvalidParam)(
|
|
425
|
+
(0, error_1.throwInvalidParam)(`Migration.Query 不能为空(Version: ${migration.Version})`);
|
|
415
426
|
}
|
|
416
|
-
|
|
417
|
-
|
|
427
|
+
return Object.assign({}, migration);
|
|
428
|
+
});
|
|
429
|
+
return this.dbOpService.request('PreviewPGUserMigrations', Object.assign({ EnvId: envId, Migrations: migrations }, (IncludeAll !== undefined ? { IncludeAll } : {})));
|
|
418
430
|
}
|
|
419
431
|
/**
|
|
420
432
|
* 批量应用 PG 用户 migrations
|
|
@@ -422,7 +434,6 @@ class DatabaseService {
|
|
|
422
434
|
* @returns 任务信息(TaskId、RequestId)
|
|
423
435
|
*/
|
|
424
436
|
async pushPGUserMigrations(options) {
|
|
425
|
-
var _a;
|
|
426
437
|
const { EnvId, Migrations, LockTimeoutMs, StatementTimeoutMs, IncludeAll } = options;
|
|
427
438
|
if (!Array.isArray(Migrations) || Migrations.length === 0) {
|
|
428
439
|
(0, error_1.throwInvalidParam)('Migrations 至少需要 1 条');
|
|
@@ -434,9 +445,6 @@ class DatabaseService {
|
|
|
434
445
|
if (!/^[a-z_]+$/.test(migration.Name)) {
|
|
435
446
|
(0, error_1.throwInvalidParam)('Migration.Name 只允许小写字母和下划线');
|
|
436
447
|
}
|
|
437
|
-
if (!((_a = migration.Query) === null || _a === void 0 ? void 0 : _a.trim())) {
|
|
438
|
-
(0, error_1.throwInvalidParam)('Migration.Query 不能为空');
|
|
439
|
-
}
|
|
440
448
|
}
|
|
441
449
|
if (LockTimeoutMs !== undefined && LockTimeoutMs < 0) {
|
|
442
450
|
(0, error_1.throwInvalidParam)('LockTimeoutMs 不能小于 0');
|
|
@@ -444,7 +452,23 @@ class DatabaseService {
|
|
|
444
452
|
if (StatementTimeoutMs !== undefined && StatementTimeoutMs < 0) {
|
|
445
453
|
(0, error_1.throwInvalidParam)('StatementTimeoutMs 不能小于 0');
|
|
446
454
|
}
|
|
447
|
-
|
|
455
|
+
const envId = EnvId || this.envId;
|
|
456
|
+
const remote = await this.listAllPGUserMigrations({ EnvId: envId });
|
|
457
|
+
const appliedVersions = new Set(remote.Migrations.map(migration => migration.Version));
|
|
458
|
+
const migrations = Migrations.map(migration => {
|
|
459
|
+
var _a;
|
|
460
|
+
if (appliedVersions.has(migration.Version)) {
|
|
461
|
+
return {
|
|
462
|
+
Version: migration.Version,
|
|
463
|
+
Name: migration.Name
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
if (!((_a = migration.Query) === null || _a === void 0 ? void 0 : _a.trim())) {
|
|
467
|
+
(0, error_1.throwInvalidParam)(`Migration.Query 不能为空(Version: ${migration.Version})`);
|
|
468
|
+
}
|
|
469
|
+
return Object.assign({}, migration);
|
|
470
|
+
});
|
|
471
|
+
return this.dbOpService.request('PushPGUserMigrations', Object.assign(Object.assign(Object.assign({ EnvId: envId, Migrations: migrations }, (LockTimeoutMs !== undefined ? { LockTimeoutMs } : {})), (StatementTimeoutMs !== undefined ? { StatementTimeoutMs } : {})), (IncludeAll !== undefined ? { IncludeAll } : {})));
|
|
448
472
|
}
|
|
449
473
|
/**
|
|
450
474
|
* 修复 PG 用户 migration history,仅维护 user_schema_migrations 记录,不执行 SQL
|
package/lib/docs/index.js
CHANGED
|
@@ -96,11 +96,26 @@ class DocsService {
|
|
|
96
96
|
}
|
|
97
97
|
(0, error_1.throwNotFound)(`未找到模块或文档 "${input}"`);
|
|
98
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* 请求目标只由 DOCS_BASE_URL 决定:解析后丢弃入参带来的 scheme / host / userinfo / port,
|
|
101
|
+
* 只保留 pathname + search + hash 再拼回固定 origin。调用方无论如何都选不了主机。
|
|
102
|
+
*/
|
|
103
|
+
resolveDocsRequestUrl(docPath) {
|
|
104
|
+
const parsed = new URL(docPath, `${DOCS_BASE_URL}/`);
|
|
105
|
+
return new URL(`${parsed.pathname}${parsed.search}${parsed.hash}`, DOCS_BASE_URL).toString();
|
|
106
|
+
}
|
|
99
107
|
async readDoc(docPath) {
|
|
100
108
|
const normalizedPath = docPath.endsWith('.md') ? docPath : `${docPath}/index.md`;
|
|
101
|
-
|
|
102
|
-
const
|
|
103
|
-
|
|
109
|
+
const url = this.resolveDocsRequestUrl(normalizedPath);
|
|
110
|
+
const res = await (0, http_request_1.fetchStream)(url, {
|
|
111
|
+
redirect: 'manual',
|
|
112
|
+
size: 2 * 1024 * 1024,
|
|
113
|
+
signal: AbortSignal.timeout(10000),
|
|
114
|
+
});
|
|
115
|
+
// 自动跟随重定向会让请求离开官方站,这里把 3xx 当失败处理
|
|
116
|
+
if (res.status >= 300 && res.status < 400) {
|
|
117
|
+
(0, error_1.throwNotFound)('文档地址不允许重定向');
|
|
118
|
+
}
|
|
104
119
|
let text = await res.text();
|
|
105
120
|
// 移除 UTF-8 BOM
|
|
106
121
|
if (text.charCodeAt(0) === 0xFEFF) {
|
package/lib/env/index.js
CHANGED
|
@@ -32,6 +32,7 @@ class EnvService {
|
|
|
32
32
|
this.billingService = new billing_1.BillingService(environment.cloudBaseContext);
|
|
33
33
|
this.certificateCloudService = new utils_1.CloudService(environment.cloudBaseContext, 'ssl', '2019-12-05');
|
|
34
34
|
this.tokenCache = new Map();
|
|
35
|
+
this.tokenInflight = new Map();
|
|
35
36
|
}
|
|
36
37
|
/**
|
|
37
38
|
* 列出所有环境
|
|
@@ -452,65 +453,90 @@ class EnvService {
|
|
|
452
453
|
* @param {string} credentials.secretId 密钥ID
|
|
453
454
|
* @param {string} credentials.secretKey 密钥Key
|
|
454
455
|
* @param {string} [credentials.token] sessionToken
|
|
456
|
+
* @param {string} [envId] 目标环境 ID,不传则使用当前环境
|
|
455
457
|
* @returns {Promise<string>} 访问令牌
|
|
456
458
|
*/
|
|
457
|
-
async getAdminAccessToken(credentials) {
|
|
459
|
+
async getAdminAccessToken(credentials, envId = this.envId) {
|
|
458
460
|
const { secretId, secretKey, token } = credentials || this.environment.cloudBaseContext;
|
|
459
461
|
if (!secretId || !secretKey) {
|
|
460
462
|
(0, error_1.throwInvalidParam)('missing secretId or secretKey of tencent cloud');
|
|
461
463
|
}
|
|
462
|
-
const envId = this.envId;
|
|
463
464
|
const cacheKey = `access_token_secret_${envId}_${secretId}`;
|
|
464
465
|
const cached = this.tokenCache.get(cacheKey);
|
|
465
466
|
if (cached && cached.expiry > Date.now()) {
|
|
466
467
|
return cached.token;
|
|
467
468
|
}
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
const
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
isCloudApi: true,
|
|
489
|
-
});
|
|
490
|
-
headers['Authorization'] = `${authorization}, Timestamp=${signTimestamp}${token ? `, Token=${token}` : ''}`;
|
|
491
|
-
headers['X-Signature-Expires'] = 600;
|
|
492
|
-
headers['X-Timestamp'] = signTimestamp;
|
|
493
|
-
try {
|
|
494
|
-
const response = await (0, http_request_1.fetch)(url, {
|
|
469
|
+
// 同一 env + secretId 已有换取请求在进行时直接复用,避免并发调用(如并发上传、缓存过期的瞬间)各自换一次
|
|
470
|
+
const inflight = this.tokenInflight.get(cacheKey);
|
|
471
|
+
if (inflight) {
|
|
472
|
+
return inflight;
|
|
473
|
+
}
|
|
474
|
+
const request = (async () => {
|
|
475
|
+
const host = `${envId}${this.environment.cloudBaseContext.isInternalEndpoint()
|
|
476
|
+
? '.api.intl.tcloudbasegateway.com'
|
|
477
|
+
: '.api.tcloudbasegateway.com'}`;
|
|
478
|
+
const url = `https://${host}/auth/v1/token/clientCredential`;
|
|
479
|
+
const method = 'POST';
|
|
480
|
+
const headers = {
|
|
481
|
+
'Content-Type': 'application/json',
|
|
482
|
+
Host: host,
|
|
483
|
+
};
|
|
484
|
+
const data = { grant_type: 'client_credentials' };
|
|
485
|
+
const timestamp = Math.floor(new Date().getTime() / 1000) - 1;
|
|
486
|
+
const { authorization, timestamp: signTimestamp } = (0, signature_nodejs_1.sign)({
|
|
487
|
+
secretId,
|
|
488
|
+
secretKey,
|
|
495
489
|
method,
|
|
490
|
+
url,
|
|
496
491
|
headers,
|
|
497
|
-
|
|
492
|
+
params: data,
|
|
493
|
+
timestamp,
|
|
494
|
+
withSignedParams: false,
|
|
495
|
+
isCloudApi: true,
|
|
498
496
|
});
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
497
|
+
headers['Authorization'] = `${authorization}, Timestamp=${signTimestamp}${token ? `, Token=${token}` : ''}`;
|
|
498
|
+
headers['X-Signature-Expires'] = 600;
|
|
499
|
+
headers['X-Timestamp'] = signTimestamp;
|
|
500
|
+
try {
|
|
501
|
+
// utils/http-request 的 fetch 返回的已是解析后的 JSON,不是 Response
|
|
502
|
+
const res = await (0, http_request_1.fetch)(url, {
|
|
503
|
+
method,
|
|
504
|
+
headers,
|
|
505
|
+
body: JSON.stringify(data),
|
|
506
506
|
});
|
|
507
|
+
const access_token = res === null || res === void 0 ? void 0 : res.access_token;
|
|
508
|
+
const expires_in = (res === null || res === void 0 ? void 0 : res.expires_in) || 0;
|
|
509
|
+
if (!access_token) {
|
|
510
|
+
// 只取排查需要的字段,不拼完整响应体:错误信息会进 stderr、上层日志与错误上报
|
|
511
|
+
const errCode = (res === null || res === void 0 ? void 0 : res.code) || (res === null || res === void 0 ? void 0 : res.error) || (res === null || res === void 0 ? void 0 : res.Code) || 'unknown';
|
|
512
|
+
const errMessage = (res === null || res === void 0 ? void 0 : res.message) || (res === null || res === void 0 ? void 0 : res.error_description) || (res === null || res === void 0 ? void 0 : res.Message) || '';
|
|
513
|
+
const requestId = (res === null || res === void 0 ? void 0 : res.request_id) || (res === null || res === void 0 ? void 0 : res.requestId) || (res === null || res === void 0 ? void 0 : res.RequestId) || '';
|
|
514
|
+
(0, error_1.throwApiError)(`获取管理员访问令牌失败: ${errCode}${errMessage ? ` ${errMessage}` : ''} ` +
|
|
515
|
+
`(envId=${envId}${requestId ? `, requestId=${requestId}` : ''})`);
|
|
516
|
+
}
|
|
517
|
+
if (expires_in) {
|
|
518
|
+
this.tokenCache.set(cacheKey, {
|
|
519
|
+
token: access_token,
|
|
520
|
+
expiry: Date.now() + (expires_in * 1000) / 2,
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
return access_token;
|
|
524
|
+
}
|
|
525
|
+
catch (e) {
|
|
526
|
+
// 错误信息走 stderr,且保留完整堆栈;stdout 只留给结构化输出
|
|
527
|
+
console.error(e);
|
|
528
|
+
throw e;
|
|
507
529
|
}
|
|
508
|
-
|
|
530
|
+
})();
|
|
531
|
+
this.tokenInflight.set(cacheKey, request);
|
|
532
|
+
try {
|
|
533
|
+
return await request;
|
|
509
534
|
}
|
|
510
|
-
|
|
511
|
-
//
|
|
512
|
-
|
|
513
|
-
|
|
535
|
+
finally {
|
|
536
|
+
// 成功或失败都移除,失败后下次调用会重新换取
|
|
537
|
+
if (this.tokenInflight.get(cacheKey) === request) {
|
|
538
|
+
this.tokenInflight.delete(cacheKey);
|
|
539
|
+
}
|
|
514
540
|
}
|
|
515
541
|
}
|
|
516
542
|
// 创建自定义登录私钥
|
|
@@ -919,6 +945,64 @@ class EnvService {
|
|
|
919
945
|
Domain
|
|
920
946
|
});
|
|
921
947
|
}
|
|
948
|
+
/**
|
|
949
|
+
* 查询环境访问控制配置(域名来源)
|
|
950
|
+
* 返回指定环境下默认域名在公网(PUBLIC)、VPC、办公网(WOA)三种来源的当前访问策略
|
|
951
|
+
* @param {DescribeEnvAccessControlParams} params 查询参数
|
|
952
|
+
* @returns {Promise<DescribeEnvAccessControlRes>} 当前生效的配置
|
|
953
|
+
*/
|
|
954
|
+
async describeEnvAccessControl(params = {}) {
|
|
955
|
+
const EnvId = params.EnvId || this.envId;
|
|
956
|
+
if (!EnvId) {
|
|
957
|
+
(0, error_1.throwInvalidParam)('EnvId is required');
|
|
958
|
+
}
|
|
959
|
+
return this.cloudService.request('DescribeEnvAccessControl', {
|
|
960
|
+
EnvId
|
|
961
|
+
});
|
|
962
|
+
}
|
|
963
|
+
/**
|
|
964
|
+
* 修改环境访问控制配置(域名来源)
|
|
965
|
+
* 影响指定环境下默认域名的访问来源策略,Action 为 OPEN 放通、CLOSE 拦截:
|
|
966
|
+
* - SourceType = PUBLIC 时,控制公网请求(拦截后公网访问默认域名返回 403)
|
|
967
|
+
* - SourceType = VPC 时,可选通过 VPCWhiteList 配置 VPC 白名单,不传表示不修改
|
|
968
|
+
* 各来源是否可改以服务端为准,WX(微信)与 WOA(办公网)为产品内部来源,后端暂未开放
|
|
969
|
+
* @param {ModifyEnvAccessControlParams} params 修改参数
|
|
970
|
+
* @returns {Promise<ModifyEnvAccessControlRes>} 影响行数与修改后生效的配置
|
|
971
|
+
*/
|
|
972
|
+
async modifyEnvAccessControl(params) {
|
|
973
|
+
const { EnvId = this.envId, Sources } = params;
|
|
974
|
+
if (!EnvId) {
|
|
975
|
+
(0, error_1.throwInvalidParam)('EnvId is required');
|
|
976
|
+
}
|
|
977
|
+
if (!Array.isArray(Sources) || Sources.length === 0) {
|
|
978
|
+
(0, error_1.throwInvalidParam)('Sources is required and must be a non-empty array');
|
|
979
|
+
}
|
|
980
|
+
// 校验 Sources 内部字段的合法性
|
|
981
|
+
const validActions = ['OPEN', 'CLOSE'];
|
|
982
|
+
const validWoAAuths = ['FORCE_AUTH', 'NO_AUTH'];
|
|
983
|
+
for (const source of Sources) {
|
|
984
|
+
if (!source) {
|
|
985
|
+
(0, error_1.throwInvalidParam)('Sources must not contain empty item');
|
|
986
|
+
}
|
|
987
|
+
if (source.Action !== undefined && !validActions.includes(source.Action)) {
|
|
988
|
+
(0, error_1.throwInvalidParam)(`Action must be one of ${validActions.join(' | ')}`);
|
|
989
|
+
}
|
|
990
|
+
if (source.WOAAuth !== undefined && !validWoAAuths.includes(source.WOAAuth)) {
|
|
991
|
+
(0, error_1.throwInvalidParam)(`WOAAuth must be one of ${validWoAAuths.join(' | ')}`);
|
|
992
|
+
}
|
|
993
|
+
// WOAAuth 仅 SourceType 为 WOA 且 Action 为 OPEN 时生效,强制鉴权时必须传 AuthToken
|
|
994
|
+
if (source.SourceType === 'WOA' &&
|
|
995
|
+
source.Action === 'OPEN' &&
|
|
996
|
+
source.WOAAuth === 'FORCE_AUTH' &&
|
|
997
|
+
!source.AuthToken) {
|
|
998
|
+
(0, error_1.throwInvalidParam)('AuthToken is required when WOAAuth is FORCE_AUTH');
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
return this.cloudService.request('ModifyEnvAccessControl', {
|
|
1002
|
+
EnvId,
|
|
1003
|
+
Sources
|
|
1004
|
+
});
|
|
1005
|
+
}
|
|
922
1006
|
// 获取 COS CORS 域名
|
|
923
1007
|
async getCOSDomains() {
|
|
924
1008
|
const cos = this.getCos();
|
package/lib/error-docs.js
CHANGED
|
@@ -88,8 +88,10 @@ const CONTROL_PLANE_CODES = new Set([
|
|
|
88
88
|
/**
|
|
89
89
|
* 数据面(运行时)错误码全量清单。
|
|
90
90
|
*
|
|
91
|
-
* 来源:`cloudbase-docs/docs/error-code/basic.md
|
|
91
|
+
* 来源:`cloudbase-docs/docs/error-code/basic.md`,
|
|
92
92
|
* 与服务端事实源 `tcblinker/internal/tcberror/tcberror.go` 对齐。
|
|
93
|
+
* 与线上单码页(`docs.cloudbase.net/error-code/{CODE}`)的一致性用
|
|
94
|
+
* `node scripts/check-error-codes.cjs` 核对,勿再手抄整表。
|
|
93
95
|
* 每个码在文档站都有独立页面:`https://docs.cloudbase.net/error-code/{CODE}`。
|
|
94
96
|
*
|
|
95
97
|
* ⚠️ 仅在 `source === 'runtime'` 时使用本表。因为其中 `INVALID_*`(21 个)、
|
|
@@ -102,10 +104,12 @@ exports.RUNTIME_ERROR_CODES = new Set([
|
|
|
102
104
|
'ACCESS_TOKEN_INVALID',
|
|
103
105
|
'ACCESS_TOKEN_KID_INVALID',
|
|
104
106
|
'ACTION_FORBIDDEN',
|
|
107
|
+
'AI_CHANNEL_NOT_ALLOWED',
|
|
105
108
|
'AI_MODEL_CONFIG_MISSING',
|
|
106
109
|
'AI_MODEL_DISABLED',
|
|
107
110
|
'AI_MODEL_NOT_FOUND',
|
|
108
111
|
'AI_MODEL_NOT_SUPPORTED',
|
|
112
|
+
'AI_MODEL_PARAM_INVALID',
|
|
109
113
|
'AI_MODEL_PARAM_REQUIRED',
|
|
110
114
|
'APIS_GET_OPENAPI_SCHEMA_ERROR',
|
|
111
115
|
'APIS_PARSE_OPENAPI_SCHEMA_ERROR',
|
|
@@ -134,13 +138,16 @@ exports.RUNTIME_ERROR_CODES = new Set([
|
|
|
134
138
|
'DATABASE_INVALID_OPERRATOR',
|
|
135
139
|
'DATABASE_PERMISSION_DENIED',
|
|
136
140
|
'DATABASE_REQUEST_FAILED',
|
|
141
|
+
'DATABASE_RESOURCE_ISOLATED',
|
|
137
142
|
'DATABASE_TIMEOUT',
|
|
138
143
|
'DATABASE_TRANSACTION_CONFLICT',
|
|
139
144
|
'DATABASE_TRANSACTION_FAIL',
|
|
140
145
|
'DEFAULT_DOMAIN_EXPIRED',
|
|
141
146
|
'ENV_ABNORMAL',
|
|
142
147
|
'ENV_FEATURE_NOT_CONFIGURED',
|
|
148
|
+
'ENV_ISOLATED',
|
|
143
149
|
'ENV_NOT_READY',
|
|
150
|
+
'ENV_SUSPENDED',
|
|
144
151
|
'ERR_ABORT_HANDLER',
|
|
145
152
|
'EXCEED_AUTHORITY',
|
|
146
153
|
'EXCEED_CONCURRENT_REQUEST_LIMIT',
|
|
@@ -175,6 +182,7 @@ exports.RUNTIME_ERROR_CODES = new Set([
|
|
|
175
182
|
'FUNCTIONS_NAME_MISSING', // 调用时未指定函数名
|
|
176
183
|
'FUNCTIONS_PERMISSION_DENIED', // 无权限调用该云函数
|
|
177
184
|
'FUNCTIONS_RESERVED_PATH', // 使用了云函数保留路径
|
|
185
|
+
'GATEWAY_ROUTE_DISABLED',
|
|
178
186
|
'HTTPSERVICE_NONACTIVATED',
|
|
179
187
|
'INTERNAL_REQUEST_FAIL',
|
|
180
188
|
'INVALID_ACCESS_TOKEN',
|
|
@@ -200,6 +208,7 @@ exports.RUNTIME_ERROR_CODES = new Set([
|
|
|
200
208
|
'INVALID_WX_ACCESS_TOKEN',
|
|
201
209
|
'LOGIN_MANNER_UNREGISTED',
|
|
202
210
|
'MISSING_CREDENTIALS',
|
|
211
|
+
'MISSING_REQUIRED_PARAM',
|
|
203
212
|
'OBJECT_ALREADY_EXIST',
|
|
204
213
|
'OBJECT_BATCH_TOO_LARGE',
|
|
205
214
|
'OBJECT_NOT_EXIST',
|
|
@@ -215,6 +224,7 @@ exports.RUNTIME_ERROR_CODES = new Set([
|
|
|
215
224
|
'RESOURCE_NOT_FOUND',
|
|
216
225
|
'RESOURCE_NOT_INITIAL',
|
|
217
226
|
'RequestLimitExceeded',
|
|
227
|
+
'SDK_UPGRADE_REQUIRED',
|
|
218
228
|
'SERVER_TIMEOUT',
|
|
219
229
|
'SERVICE_CHARGE_OVERDUE',
|
|
220
230
|
'SERVICE_ENDPOINT_NOT_FOUND',
|
package/lib/error-types.js
CHANGED
|
@@ -18,6 +18,8 @@ exports.ERROR_TYPES = {
|
|
|
18
18
|
apiError: { code: 'API_ERROR' },
|
|
19
19
|
credentialError: { code: 'MISSING_CREDENTIAL' },
|
|
20
20
|
fileError: { code: 'FILE_READ_ERROR' },
|
|
21
|
+
uploadPaused: { code: 'UPLOAD_PAUSED' },
|
|
22
|
+
uploadAborted: { code: 'UPLOAD_ABORTED' },
|
|
21
23
|
/**
|
|
22
24
|
* 部署前未找到构建产物(目录不存在或为空)。
|
|
23
25
|
*
|
package/lib/function/index.js
CHANGED
|
@@ -2085,11 +2085,15 @@ class FunctionService {
|
|
|
2085
2085
|
* @private
|
|
2086
2086
|
*/
|
|
2087
2087
|
async putZipFileToUrl(putUrl, zipFilePath) {
|
|
2088
|
+
const { size } = await fs_1.default.promises.stat(zipFilePath);
|
|
2088
2089
|
return (0, utils_1.fetchStream)(putUrl, {
|
|
2089
2090
|
method: 'PUT',
|
|
2090
2091
|
body: fs_1.default.createReadStream(zipFilePath),
|
|
2091
2092
|
headers: {
|
|
2092
|
-
'Content-Type': 'application/zip'
|
|
2093
|
+
'Content-Type': 'application/zip',
|
|
2094
|
+
// ReadStream 无法被 node-fetch 推导长度,默认会走 chunked;
|
|
2095
|
+
// CBF 预签名 COS PutUrl 缺少 Content-Length 会直接返回 403 AccessDenied
|
|
2096
|
+
'Content-Length': String(size)
|
|
2093
2097
|
},
|
|
2094
2098
|
timeout: 120000
|
|
2095
2099
|
});
|