@cloudbase/manager-node 4.4.5 → 4.4.7-beta.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/lib/constant.js +6 -1
- package/lib/env/index.js +25 -0
- package/lib/function/index.js +4 -1
- package/lib/utils/index.js +12 -7
- package/package.json +3 -3
- package/types/constant.d.ts +5 -0
- package/types/env/index.d.ts +55 -0
- package/types/function/types.d.ts +4 -0
package/lib/constant.js
CHANGED
|
@@ -47,7 +47,12 @@ exports.SCF_STATUS = {
|
|
|
47
47
|
ACTIVE: 'Active',
|
|
48
48
|
CREATING: 'Creating',
|
|
49
49
|
UPDATING: 'Updating',
|
|
50
|
-
CREATE_FAILED: 'CreateFailed'
|
|
50
|
+
CREATE_FAILED: 'CreateFailed',
|
|
51
|
+
UPDATE_FAILED: 'UpdateFailed',
|
|
52
|
+
PUBLISHING: 'Publishing',
|
|
53
|
+
PUBLISH_FAILED: 'PublishFailed',
|
|
54
|
+
DELETING: 'Deleting',
|
|
55
|
+
DELETE_FAILED: 'DeleteFailed'
|
|
51
56
|
};
|
|
52
57
|
// 是否使用内网域名
|
|
53
58
|
exports.USE_INTERNAL_ENDPOINT = "USE_INTERNAL_ENDPOINT" in process.env;
|
package/lib/env/index.js
CHANGED
|
@@ -21,6 +21,7 @@ class EnvService {
|
|
|
21
21
|
this.envId = environment.getEnvId();
|
|
22
22
|
this.envType = environment.getEnvType();
|
|
23
23
|
this.cloudService = new utils_1.CloudService(environment.cloudBaseContext, 'tcb', '2018-06-08');
|
|
24
|
+
this.commonService = environment.getCommonService("lowcode", "2021-01-08");
|
|
24
25
|
}
|
|
25
26
|
/**
|
|
26
27
|
* 列出所有环境
|
|
@@ -152,6 +153,7 @@ class EnvService {
|
|
|
152
153
|
}
|
|
153
154
|
/**
|
|
154
155
|
* 拉取登录配置列表
|
|
156
|
+
* @deprecated 请使用 getLoginConfigListV2 代替
|
|
155
157
|
* @returns {Promise<IEnvLoginConfigRes>}
|
|
156
158
|
*/
|
|
157
159
|
async getLoginConfigList() {
|
|
@@ -159,6 +161,17 @@ class EnvService {
|
|
|
159
161
|
EnvId: this.envId
|
|
160
162
|
});
|
|
161
163
|
}
|
|
164
|
+
/**
|
|
165
|
+
* 拉取登录配置列表
|
|
166
|
+
*/
|
|
167
|
+
async getLoginConfigListV2() {
|
|
168
|
+
return this.commonService.call({
|
|
169
|
+
Action: 'DescribeLoginStrategy',
|
|
170
|
+
Param: {
|
|
171
|
+
EnvId: this.envId
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
}
|
|
162
175
|
/**
|
|
163
176
|
* 创建登录方式
|
|
164
177
|
* 'WECHAT-OPEN':微信开放平台
|
|
@@ -189,6 +202,7 @@ class EnvService {
|
|
|
189
202
|
* @param {string} [appId=''] 微信 appId,可选
|
|
190
203
|
* @param {string} [appSecret=''] 微信 appSecret,可选
|
|
191
204
|
* @returns {Promise<IResponseInfo>}
|
|
205
|
+
* @deprecated 请使用 updateLoginConfigV2 代替
|
|
192
206
|
*/
|
|
193
207
|
/* eslint-disable-next-line */
|
|
194
208
|
async updateLoginConfig(configId, status = 'ENABLE', appId = '', appSecret = '') {
|
|
@@ -209,6 +223,17 @@ class EnvService {
|
|
|
209
223
|
finalAppSecret && (params.PlatformSecret = (0, utils_1.rsaEncrypt)(finalAppSecret));
|
|
210
224
|
return this.cloudService.request('UpdateLoginConfig', params);
|
|
211
225
|
}
|
|
226
|
+
/**
|
|
227
|
+
* 更新登录方式配置
|
|
228
|
+
* @param {IModifyLoginStrategy} options
|
|
229
|
+
* @returns {Promise<boolean>}
|
|
230
|
+
*/
|
|
231
|
+
async updateLoginConfigV2(options) {
|
|
232
|
+
return this.commonService.call({
|
|
233
|
+
Action: 'ModifyLoginStrategy',
|
|
234
|
+
Param: options
|
|
235
|
+
});
|
|
236
|
+
}
|
|
212
237
|
// 创建自定义登录私钥
|
|
213
238
|
async createCustomLoginKeys() {
|
|
214
239
|
return this.cloudService.request('CreateCustomLoginKeys', {
|
package/lib/function/index.js
CHANGED
|
@@ -995,12 +995,15 @@ class FunctionService {
|
|
|
995
995
|
}, 300000);
|
|
996
996
|
ticker = setInterval(async () => {
|
|
997
997
|
try {
|
|
998
|
-
const { Status } = await this.getFunctionDetail(funcName, codeSecret);
|
|
998
|
+
const { Status, StatusDesc, StatusReasons } = await this.getFunctionDetail(funcName, codeSecret);
|
|
999
999
|
// 更新中
|
|
1000
1000
|
if (Status === constant_1.SCF_STATUS.CREATING || Status === constant_1.SCF_STATUS.UPDATING)
|
|
1001
1001
|
return;
|
|
1002
1002
|
// 创建失败
|
|
1003
1003
|
if (Status === constant_1.SCF_STATUS.CREATE_FAILED) {
|
|
1004
|
+
StatusDesc && console.log(`函数状态描述: ${StatusDesc}`);
|
|
1005
|
+
const errorDetails = StatusReasons.map(item => `[${item.ErrorCode}] ${item.ErrorMessage}`).join('\n');
|
|
1006
|
+
console.error(`函数创建失败信息: ${errorDetails}`);
|
|
1004
1007
|
throw new error_1.CloudBaseError('云函数创建失败');
|
|
1005
1008
|
}
|
|
1006
1009
|
// 函数状态正常
|
package/lib/utils/index.js
CHANGED
|
@@ -89,12 +89,14 @@ async function downloadAndExtractRemoteZip(downloadUrl, targetPath) {
|
|
|
89
89
|
await fs_extra_1.default.ensureDir(dirPath);
|
|
90
90
|
// 使用流式解压,避免大文件内存问题
|
|
91
91
|
await new Promise((resolve, reject) => {
|
|
92
|
-
let
|
|
93
|
-
let
|
|
92
|
+
let totalEntries = 0; // 总条目数(文件+目录)
|
|
93
|
+
let processedEntries = 0; // 已处理条目数
|
|
94
|
+
let streamEnded = false; // 流是否结束
|
|
94
95
|
downloadResponse
|
|
95
96
|
.body.pipe(unzipper_1.default.Parse())
|
|
96
97
|
.on('error', reject)
|
|
97
98
|
.on('entry', async (entry) => {
|
|
99
|
+
totalEntries++;
|
|
98
100
|
const filePath = path_1.default.join(dirPath, entry.path);
|
|
99
101
|
try {
|
|
100
102
|
// 确保父目录存在(处理嵌套目录情况)
|
|
@@ -102,15 +104,15 @@ async function downloadAndExtractRemoteZip(downloadUrl, targetPath) {
|
|
|
102
104
|
// 如果是目录则创建,否则写入文件
|
|
103
105
|
if (entry.type === 'Directory') {
|
|
104
106
|
await fs_extra_1.default.ensureDir(filePath);
|
|
105
|
-
|
|
107
|
+
processedEntries++;
|
|
108
|
+
checkCompletion();
|
|
106
109
|
}
|
|
107
110
|
else {
|
|
108
|
-
fileCount++;
|
|
109
111
|
entry
|
|
110
112
|
.pipe(fs_extra_1.default.createWriteStream(filePath))
|
|
111
113
|
.on('error', reject)
|
|
112
114
|
.on('finish', () => {
|
|
113
|
-
|
|
115
|
+
processedEntries++;
|
|
114
116
|
checkCompletion();
|
|
115
117
|
});
|
|
116
118
|
}
|
|
@@ -119,9 +121,12 @@ async function downloadAndExtractRemoteZip(downloadUrl, targetPath) {
|
|
|
119
121
|
reject(err);
|
|
120
122
|
}
|
|
121
123
|
})
|
|
122
|
-
.on('close',
|
|
124
|
+
.on('close', () => {
|
|
125
|
+
streamEnded = true;
|
|
126
|
+
checkCompletion();
|
|
127
|
+
});
|
|
123
128
|
function checkCompletion() {
|
|
124
|
-
if (
|
|
129
|
+
if (streamEnded && totalEntries === processedEntries) {
|
|
125
130
|
resolve('');
|
|
126
131
|
}
|
|
127
132
|
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/manager-node",
|
|
3
|
-
"version": "4.4.
|
|
3
|
+
"version": "4.4.7-beta.0",
|
|
4
4
|
"description": "The node manage service api for cloudbase.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"build": "rimraf lib types && npx tsc",
|
|
8
|
-
"test:coverage": "jest --runInBand --detectOpenHandles --coverage --testTimeout=
|
|
9
|
-
"test": "jest --runInBand --detectOpenHandles --testTimeout=
|
|
8
|
+
"test:coverage": "jest --runInBand --detectOpenHandles --coverage --testTimeout=100000",
|
|
9
|
+
"test": "jest --runInBand --detectOpenHandles --testTimeout=100000",
|
|
10
10
|
"lint": "eslint \"./**/*.ts\"",
|
|
11
11
|
"lint:fix": "eslint --fix \"./**/*.ts\"",
|
|
12
12
|
"prepublishOnly": "npm run build",
|
package/types/constant.d.ts
CHANGED
|
@@ -34,6 +34,11 @@ export declare const SCF_STATUS: {
|
|
|
34
34
|
CREATING: string;
|
|
35
35
|
UPDATING: string;
|
|
36
36
|
CREATE_FAILED: string;
|
|
37
|
+
UPDATE_FAILED: string;
|
|
38
|
+
PUBLISHING: string;
|
|
39
|
+
PUBLISH_FAILED: string;
|
|
40
|
+
DELETING: string;
|
|
41
|
+
DELETE_FAILED: string;
|
|
37
42
|
};
|
|
38
43
|
export declare const USE_INTERNAL_ENDPOINT: boolean;
|
|
39
44
|
export declare const enum COS_ENDPOINT {
|
package/types/env/index.d.ts
CHANGED
|
@@ -17,6 +17,48 @@ interface IEnvLoginConfigRes {
|
|
|
17
17
|
RequestId: string;
|
|
18
18
|
ConfigList: LoginConfigItem[];
|
|
19
19
|
}
|
|
20
|
+
interface VerificationConfig {
|
|
21
|
+
Type: string;
|
|
22
|
+
Name: string;
|
|
23
|
+
Method: string;
|
|
24
|
+
}
|
|
25
|
+
interface MFALoginConfig {
|
|
26
|
+
On: string;
|
|
27
|
+
Sms: string;
|
|
28
|
+
Email: string;
|
|
29
|
+
RequiredBindPhone: string;
|
|
30
|
+
Topt: string;
|
|
31
|
+
}
|
|
32
|
+
interface PasswordUpdateLoginConfig {
|
|
33
|
+
FirstLoginUpdate: boolean;
|
|
34
|
+
PeriodUpdate: boolean;
|
|
35
|
+
PeriodValue: number;
|
|
36
|
+
PeriodType: string;
|
|
37
|
+
}
|
|
38
|
+
interface ILoginStrategy {
|
|
39
|
+
Data: {
|
|
40
|
+
PhoneLogin: boolean;
|
|
41
|
+
EmailLogin: boolean;
|
|
42
|
+
AnonymousLogin: boolean;
|
|
43
|
+
UsernameLogin: boolean;
|
|
44
|
+
PhoneNumberLogin: boolean;
|
|
45
|
+
Mfa: boolean;
|
|
46
|
+
SmsVerificationConfig: VerificationConfig;
|
|
47
|
+
MfaConfig?: MFALoginConfig;
|
|
48
|
+
PwdUpdateStrategy?: PasswordUpdateLoginConfig;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
interface IModifyLoginStrategy {
|
|
52
|
+
EnvId: string;
|
|
53
|
+
PhoneNumberLogin: boolean;
|
|
54
|
+
EmailLogin: boolean;
|
|
55
|
+
AnonymousLogin: boolean;
|
|
56
|
+
UserNameLogin: boolean;
|
|
57
|
+
SmsVerificationConfig?: VerificationConfig;
|
|
58
|
+
Mfa?: boolean;
|
|
59
|
+
MfaConfig?: MFALoginConfig;
|
|
60
|
+
PwdUpdateStrategy?: PasswordUpdateLoginConfig;
|
|
61
|
+
}
|
|
20
62
|
interface IInitParam {
|
|
21
63
|
Channel?: string;
|
|
22
64
|
Source?: string;
|
|
@@ -26,6 +68,7 @@ export declare class EnvService {
|
|
|
26
68
|
private envId;
|
|
27
69
|
private cloudService;
|
|
28
70
|
private envType?;
|
|
71
|
+
private commonService;
|
|
29
72
|
constructor(environment: Environment);
|
|
30
73
|
/**
|
|
31
74
|
* 列出所有环境
|
|
@@ -92,9 +135,14 @@ export declare class EnvService {
|
|
|
92
135
|
updateEnvInfo(alias: string): Promise<IResponseInfo>;
|
|
93
136
|
/**
|
|
94
137
|
* 拉取登录配置列表
|
|
138
|
+
* @deprecated 请使用 getLoginConfigListV2 代替
|
|
95
139
|
* @returns {Promise<IEnvLoginConfigRes>}
|
|
96
140
|
*/
|
|
97
141
|
getLoginConfigList(): Promise<IEnvLoginConfigRes>;
|
|
142
|
+
/**
|
|
143
|
+
* 拉取登录配置列表
|
|
144
|
+
*/
|
|
145
|
+
getLoginConfigListV2(): Promise<ILoginStrategy>;
|
|
98
146
|
/**
|
|
99
147
|
* 创建登录方式
|
|
100
148
|
* 'WECHAT-OPEN':微信开放平台
|
|
@@ -112,8 +160,15 @@ export declare class EnvService {
|
|
|
112
160
|
* @param {string} [appId=''] 微信 appId,可选
|
|
113
161
|
* @param {string} [appSecret=''] 微信 appSecret,可选
|
|
114
162
|
* @returns {Promise<IResponseInfo>}
|
|
163
|
+
* @deprecated 请使用 updateLoginConfigV2 代替
|
|
115
164
|
*/
|
|
116
165
|
updateLoginConfig(configId: string, status?: string, appId?: string, appSecret?: string): Promise<IResponseInfo>;
|
|
166
|
+
/**
|
|
167
|
+
* 更新登录方式配置
|
|
168
|
+
* @param {IModifyLoginStrategy} options
|
|
169
|
+
* @returns {Promise<boolean>}
|
|
170
|
+
*/
|
|
171
|
+
updateLoginConfigV2(options: IModifyLoginStrategy): Promise<boolean>;
|
|
117
172
|
createCustomLoginKeys(): Promise<{
|
|
118
173
|
PrivateKey: string;
|
|
119
174
|
KeyID: string;
|