@cloudbase/manager-node 4.2.10 → 4.2.12
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/access/index.js +9 -9
- package/lib/cloudBaseRun/index.js +3 -3
- package/lib/database/index.js +1 -1
- package/lib/env/index.js +9 -8
- package/lib/environment.js +4 -4
- package/lib/function/index.js +39 -36
- package/lib/function/packer.js +42 -9
- package/lib/hosting/index.js +19 -19
- package/lib/index.js +14 -14
- package/lib/interfaces/index.js +6 -2
- package/lib/storage/index.js +38 -38
- package/lib/user/index.js +7 -7
- package/lib/utils/auth.js +1 -2
- package/lib/utils/cloud-api-request.js +5 -5
- package/lib/utils/cloudbase-request.js +3 -4
- package/lib/utils/envLazy.js +1 -2
- package/lib/utils/fs.js +5 -6
- package/lib/utils/http-request.js +4 -5
- package/lib/utils/index.js +15 -11
- package/lib/utils/runenv.js +1 -2
- package/lib/utils/uuid.js +2 -3
- package/package.json +5 -4
- package/types/env/index.d.ts +1 -1
- package/types/function/types.d.ts +1 -1
- package/types/hosting/index.d.ts +3 -4
- package/types/storage/index.d.ts +3 -4
- package/types/user/types.d.ts +1 -1
- package/types/utils/fs.d.ts +1 -1
- package/types/utils/http-request.d.ts +2 -1
- package/types/utils/parallel.d.ts +1 -1
package/lib/access/index.js
CHANGED
|
@@ -114,28 +114,28 @@ class AccessService {
|
|
|
114
114
|
};
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
|
+
exports.AccessService = AccessService;
|
|
117
118
|
__decorate([
|
|
118
|
-
utils_1.preLazy()
|
|
119
|
+
(0, utils_1.preLazy)()
|
|
119
120
|
], AccessService.prototype, "createAccess", null);
|
|
120
121
|
__decorate([
|
|
121
|
-
utils_1.preLazy()
|
|
122
|
+
(0, utils_1.preLazy)()
|
|
122
123
|
], AccessService.prototype, "getDomainList", null);
|
|
123
124
|
__decorate([
|
|
124
|
-
utils_1.preLazy()
|
|
125
|
+
(0, utils_1.preLazy)()
|
|
125
126
|
], AccessService.prototype, "getAccessList", null);
|
|
126
127
|
__decorate([
|
|
127
|
-
utils_1.preLazy()
|
|
128
|
+
(0, utils_1.preLazy)()
|
|
128
129
|
], AccessService.prototype, "switchAuth", null);
|
|
129
130
|
__decorate([
|
|
130
|
-
utils_1.preLazy()
|
|
131
|
+
(0, utils_1.preLazy)()
|
|
131
132
|
], AccessService.prototype, "switchPathAuth", null);
|
|
132
133
|
__decorate([
|
|
133
|
-
utils_1.preLazy()
|
|
134
|
+
(0, utils_1.preLazy)()
|
|
134
135
|
], AccessService.prototype, "deleteAccess", null);
|
|
135
136
|
__decorate([
|
|
136
|
-
utils_1.preLazy()
|
|
137
|
+
(0, utils_1.preLazy)()
|
|
137
138
|
], AccessService.prototype, "addCustomDomain", null);
|
|
138
139
|
__decorate([
|
|
139
|
-
utils_1.preLazy()
|
|
140
|
+
(0, utils_1.preLazy)()
|
|
140
141
|
], AccessService.prototype, "deleteCustomDomain", null);
|
|
141
|
-
exports.AccessService = AccessService;
|
|
@@ -19,7 +19,7 @@ class CloudBaseRunService {
|
|
|
19
19
|
return this.tcbService.request('ModifyCloudBaseRunServerFlowConf', {
|
|
20
20
|
EnvId: envId,
|
|
21
21
|
ServerName: options.serverName,
|
|
22
|
-
VersionFlowItems: utils_1.upperCaseObjKey(options.versionFlowItems)
|
|
22
|
+
VersionFlowItems: (0, utils_1.upperCaseObjKey)(options.versionFlowItems)
|
|
23
23
|
// TrafficType: options.trafficType
|
|
24
24
|
});
|
|
25
25
|
}
|
|
@@ -30,7 +30,7 @@ class CloudBaseRunService {
|
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
+
exports.CloudBaseRunService = CloudBaseRunService;
|
|
33
34
|
__decorate([
|
|
34
|
-
utils_1.preLazy()
|
|
35
|
+
(0, utils_1.preLazy)()
|
|
35
36
|
], CloudBaseRunService.prototype, "modifyServerFlow", null);
|
|
36
|
-
exports.CloudBaseRunService = CloudBaseRunService;
|
package/lib/database/index.js
CHANGED
|
@@ -218,6 +218,7 @@ class DatabaseService {
|
|
|
218
218
|
return this.dbOpService.request('DatabaseMigrateExport', Object.assign({ CollectionName: collectionName, FilePath: filePath, FileType: fileType, EnvId: this.envId }, options));
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
|
+
exports.DatabaseService = DatabaseService;
|
|
221
222
|
DatabaseService.tcbServiceVersion = {
|
|
222
223
|
service: 'tcb',
|
|
223
224
|
version: '2018-06-08'
|
|
@@ -241,4 +242,3 @@ __decorate([
|
|
|
241
242
|
__decorate([
|
|
242
243
|
preLazy()
|
|
243
244
|
], DatabaseService.prototype, "listCollections", null);
|
|
244
|
-
exports.DatabaseService = DatabaseService;
|
package/lib/env/index.js
CHANGED
|
@@ -134,6 +134,7 @@ class EnvService {
|
|
|
134
134
|
}
|
|
135
135
|
const { EnvList, RequestId } = await this.cloudService.request('DescribeEnvs', params);
|
|
136
136
|
return {
|
|
137
|
+
// @ts-ignore
|
|
137
138
|
EnvInfo: (EnvList === null || EnvList === void 0 ? void 0 : EnvList.length) ? EnvList[0] : {},
|
|
138
139
|
RequestId
|
|
139
140
|
};
|
|
@@ -177,7 +178,7 @@ class EnvService {
|
|
|
177
178
|
// 平台, “QQ" "WECHAT-OPEN" "WECHAT-PUBLIC"
|
|
178
179
|
Platform: platform,
|
|
179
180
|
PlatformId: appId,
|
|
180
|
-
PlatformSecret: finalAppSecret ? utils_1.rsaEncrypt(finalAppSecret) : undefined,
|
|
181
|
+
PlatformSecret: finalAppSecret ? (0, utils_1.rsaEncrypt)(finalAppSecret) : undefined,
|
|
181
182
|
Status: 'ENABLE'
|
|
182
183
|
});
|
|
183
184
|
}
|
|
@@ -205,7 +206,7 @@ class EnvService {
|
|
|
205
206
|
finalAppSecret = 'anonymous';
|
|
206
207
|
}
|
|
207
208
|
appId && (params.PlatformId = appId);
|
|
208
|
-
finalAppSecret && (params.PlatformSecret = utils_1.rsaEncrypt(finalAppSecret));
|
|
209
|
+
finalAppSecret && (params.PlatformSecret = (0, utils_1.rsaEncrypt)(finalAppSecret));
|
|
209
210
|
return this.cloudService.request('UpdateLoginConfig', params);
|
|
210
211
|
}
|
|
211
212
|
// 创建自定义登录私钥
|
|
@@ -259,12 +260,12 @@ class EnvService {
|
|
|
259
260
|
SecretId: secretId,
|
|
260
261
|
SecretKey: secretKey,
|
|
261
262
|
SecurityToken: token,
|
|
262
|
-
Domain: constant_1.USE_INTERNAL_ENDPOINT ? "{Bucket}.cos-internal.{Region}.tencentcos.cn" /* INTERNAL */ : "{Bucket}.cos.{Region}.tencentcos.cn" /* PUBLIC */,
|
|
263
|
+
Domain: constant_1.USE_INTERNAL_ENDPOINT ? "{Bucket}.cos-internal.{Region}.tencentcos.cn" /* COS_ENDPOINT.INTERNAL */ : "{Bucket}.cos.{Region}.tencentcos.cn" /* COS_ENDPOINT.PUBLIC */,
|
|
263
264
|
};
|
|
264
265
|
if (constant_1.COS_SDK_PROTOCOL) {
|
|
265
|
-
cosConfig.Protocol = constant_1.COS_SDK_PROTOCOL.endsWith(':')
|
|
266
|
+
cosConfig.Protocol = (constant_1.COS_SDK_PROTOCOL.endsWith(':')
|
|
266
267
|
? constant_1.COS_SDK_PROTOCOL.toLowerCase()
|
|
267
|
-
: constant_1.COS_SDK_PROTOCOL.toLowerCase() + ':';
|
|
268
|
+
: constant_1.COS_SDK_PROTOCOL.toLowerCase() + ':');
|
|
268
269
|
}
|
|
269
270
|
if (constant_1.USE_INTERNAL_ENDPOINT) {
|
|
270
271
|
cosConfig.Protocol = 'http:';
|
|
@@ -283,10 +284,10 @@ class EnvService {
|
|
|
283
284
|
};
|
|
284
285
|
}
|
|
285
286
|
}
|
|
287
|
+
exports.EnvService = EnvService;
|
|
286
288
|
__decorate([
|
|
287
|
-
utils_1.preLazy()
|
|
289
|
+
(0, utils_1.preLazy)()
|
|
288
290
|
], EnvService.prototype, "createEnvDomain", null);
|
|
289
291
|
__decorate([
|
|
290
|
-
utils_1.preLazy()
|
|
292
|
+
(0, utils_1.preLazy)()
|
|
291
293
|
], EnvService.prototype, "deleteEnvDomain", null);
|
|
292
|
-
exports.EnvService = EnvService;
|
package/lib/environment.js
CHANGED
|
@@ -94,11 +94,11 @@ class Environment {
|
|
|
94
94
|
const envId = this.getEnvId();
|
|
95
95
|
if (!secretId || !secretKey) {
|
|
96
96
|
// 未主动传入密钥,从环境变量中读取
|
|
97
|
-
const envSecretId = utils_1.getEnvVar(constant_1.ENV_NAME.ENV_SECRETID);
|
|
98
|
-
const envSecretKey = utils_1.getEnvVar(constant_1.ENV_NAME.ENV_SECRETKEY);
|
|
99
|
-
const envToken = utils_1.getEnvVar(constant_1.ENV_NAME.ENV_SESSIONTOKEN);
|
|
97
|
+
const envSecretId = (0, utils_1.getEnvVar)(constant_1.ENV_NAME.ENV_SECRETID);
|
|
98
|
+
const envSecretKey = (0, utils_1.getEnvVar)(constant_1.ENV_NAME.ENV_SECRETKEY);
|
|
99
|
+
const envToken = (0, utils_1.getEnvVar)(constant_1.ENV_NAME.ENV_SESSIONTOKEN);
|
|
100
100
|
if (!envSecretId || !envSecretKey) {
|
|
101
|
-
if (utils_1.getRuntime() === constant_1.RUN_ENV.SCF) {
|
|
101
|
+
if ((0, utils_1.getRuntime)() === constant_1.RUN_ENV.SCF) {
|
|
102
102
|
throw new Error('missing authoration key, redeploy the function');
|
|
103
103
|
}
|
|
104
104
|
else {
|
package/lib/function/index.js
CHANGED
|
@@ -295,8 +295,11 @@ class FunctionService {
|
|
|
295
295
|
const subnets = await this.getSubnets(VpcId);
|
|
296
296
|
const vpc = vpcs.find(item => item.VpcId === VpcId);
|
|
297
297
|
const subnet = subnets.find(item => item.SubnetId === SubnetId);
|
|
298
|
+
// FIXME: 这里的 vpc 和 subnet 不应该是 string 吧,它是 vpcs 和 subnets 的项啊
|
|
298
299
|
data.VpcConfig = {
|
|
300
|
+
// @ts-ignore
|
|
299
301
|
vpc,
|
|
302
|
+
// @ts-ignore
|
|
300
303
|
subnet
|
|
301
304
|
};
|
|
302
305
|
}
|
|
@@ -554,22 +557,22 @@ class FunctionService {
|
|
|
554
557
|
if (base64Content) {
|
|
555
558
|
base64 = base64Content;
|
|
556
559
|
}
|
|
557
|
-
else if (utils_1.isDirectory(contentPath)) {
|
|
560
|
+
else if ((0, utils_1.isDirectory)(contentPath)) {
|
|
558
561
|
// 压缩文件夹
|
|
559
562
|
const dirName = path_1.default.parse(contentPath).name;
|
|
560
563
|
const dest = path_1.default.join(process.cwd(), `temp-${dirName}.zip`);
|
|
561
564
|
// ZIP 文件存在,删除 ZIP 文件
|
|
562
|
-
if (utils_1.checkFullAccess(dest)) {
|
|
563
|
-
utils_1.delSync(dest);
|
|
565
|
+
if ((0, utils_1.checkFullAccess)(dest)) {
|
|
566
|
+
(0, utils_1.delSync)(dest);
|
|
564
567
|
}
|
|
565
|
-
await utils_1.compressToZip({
|
|
568
|
+
await (0, utils_1.compressToZip)({
|
|
566
569
|
dirPath: contentPath,
|
|
567
570
|
outputPath: dest
|
|
568
571
|
});
|
|
569
572
|
// 转换成 base64
|
|
570
573
|
const fileBuffer = await fs_1.default.promises.readFile(dest);
|
|
571
574
|
base64 = fileBuffer.toString('base64');
|
|
572
|
-
utils_1.delSync(dest);
|
|
575
|
+
(0, utils_1.delSync)(dest);
|
|
573
576
|
}
|
|
574
577
|
else {
|
|
575
578
|
const fileType = path_1.default.extname(contentPath);
|
|
@@ -829,7 +832,7 @@ class FunctionService {
|
|
|
829
832
|
}
|
|
830
833
|
catch (e) {
|
|
831
834
|
if (count < 3) {
|
|
832
|
-
await utils_1.sleep(500);
|
|
835
|
+
await (0, utils_1.sleep)(500);
|
|
833
836
|
const res = await this.retryCreateTrigger(name, triggers, count + 1);
|
|
834
837
|
return res;
|
|
835
838
|
}
|
|
@@ -932,91 +935,91 @@ class FunctionService {
|
|
|
932
935
|
});
|
|
933
936
|
}
|
|
934
937
|
}
|
|
938
|
+
exports.FunctionService = FunctionService;
|
|
935
939
|
__decorate([
|
|
936
|
-
utils_1.preLazy()
|
|
940
|
+
(0, utils_1.preLazy)()
|
|
937
941
|
], FunctionService.prototype, "updateFunctionIncrementalCode", null);
|
|
938
942
|
__decorate([
|
|
939
|
-
utils_1.preLazy()
|
|
943
|
+
(0, utils_1.preLazy)()
|
|
940
944
|
], FunctionService.prototype, "createFunction", null);
|
|
941
945
|
__decorate([
|
|
942
|
-
utils_1.preLazy()
|
|
946
|
+
(0, utils_1.preLazy)()
|
|
943
947
|
], FunctionService.prototype, "getFunctionList", null);
|
|
944
948
|
__decorate([
|
|
945
|
-
utils_1.preLazy()
|
|
949
|
+
(0, utils_1.preLazy)()
|
|
946
950
|
], FunctionService.prototype, "listFunctions", null);
|
|
947
951
|
__decorate([
|
|
948
|
-
utils_1.preLazy()
|
|
952
|
+
(0, utils_1.preLazy)()
|
|
949
953
|
], FunctionService.prototype, "deleteFunction", null);
|
|
950
954
|
__decorate([
|
|
951
|
-
utils_1.preLazy()
|
|
955
|
+
(0, utils_1.preLazy)()
|
|
952
956
|
], FunctionService.prototype, "getFunctionDetail", null);
|
|
953
957
|
__decorate([
|
|
954
|
-
utils_1.preLazy()
|
|
958
|
+
(0, utils_1.preLazy)()
|
|
955
959
|
], FunctionService.prototype, "getFunctionLogs", null);
|
|
956
960
|
__decorate([
|
|
957
|
-
utils_1.preLazy()
|
|
961
|
+
(0, utils_1.preLazy)()
|
|
958
962
|
], FunctionService.prototype, "updateFunctionConfig", null);
|
|
959
963
|
__decorate([
|
|
960
|
-
utils_1.preLazy()
|
|
964
|
+
(0, utils_1.preLazy)()
|
|
961
965
|
], FunctionService.prototype, "updateFunctionCode", null);
|
|
962
966
|
__decorate([
|
|
963
|
-
utils_1.preLazy()
|
|
967
|
+
(0, utils_1.preLazy)()
|
|
964
968
|
], FunctionService.prototype, "invokeFunction", null);
|
|
965
969
|
__decorate([
|
|
966
|
-
utils_1.preLazy()
|
|
970
|
+
(0, utils_1.preLazy)()
|
|
967
971
|
], FunctionService.prototype, "copyFunction", null);
|
|
968
972
|
__decorate([
|
|
969
|
-
utils_1.preLazy()
|
|
973
|
+
(0, utils_1.preLazy)()
|
|
970
974
|
], FunctionService.prototype, "createFunctionTriggers", null);
|
|
971
975
|
__decorate([
|
|
972
|
-
utils_1.preLazy()
|
|
976
|
+
(0, utils_1.preLazy)()
|
|
973
977
|
], FunctionService.prototype, "deleteFunctionTrigger", null);
|
|
974
978
|
__decorate([
|
|
975
|
-
utils_1.preLazy()
|
|
979
|
+
(0, utils_1.preLazy)()
|
|
976
980
|
], FunctionService.prototype, "getFunctionDownloadUrl", null);
|
|
977
981
|
__decorate([
|
|
978
|
-
utils_1.preLazy()
|
|
982
|
+
(0, utils_1.preLazy)()
|
|
979
983
|
], FunctionService.prototype, "createLayer", null);
|
|
980
984
|
__decorate([
|
|
981
|
-
utils_1.preLazy()
|
|
985
|
+
(0, utils_1.preLazy)()
|
|
982
986
|
], FunctionService.prototype, "deleteLayerVersion", null);
|
|
983
987
|
__decorate([
|
|
984
|
-
utils_1.preLazy()
|
|
988
|
+
(0, utils_1.preLazy)()
|
|
985
989
|
], FunctionService.prototype, "listLayerVersions", null);
|
|
986
990
|
__decorate([
|
|
987
|
-
utils_1.preLazy()
|
|
991
|
+
(0, utils_1.preLazy)()
|
|
988
992
|
], FunctionService.prototype, "listLayers", null);
|
|
989
993
|
__decorate([
|
|
990
|
-
utils_1.preLazy()
|
|
994
|
+
(0, utils_1.preLazy)()
|
|
991
995
|
], FunctionService.prototype, "getLayerVersion", null);
|
|
992
996
|
__decorate([
|
|
993
|
-
utils_1.preLazy()
|
|
997
|
+
(0, utils_1.preLazy)()
|
|
994
998
|
], FunctionService.prototype, "setProvisionedConcurrencyConfig", null);
|
|
995
999
|
__decorate([
|
|
996
|
-
utils_1.preLazy()
|
|
1000
|
+
(0, utils_1.preLazy)()
|
|
997
1001
|
], FunctionService.prototype, "getProvisionedConcurrencyConfig", null);
|
|
998
1002
|
__decorate([
|
|
999
|
-
utils_1.preLazy()
|
|
1003
|
+
(0, utils_1.preLazy)()
|
|
1000
1004
|
], FunctionService.prototype, "deleteProvisionedConcurrencyConfig", null);
|
|
1001
1005
|
__decorate([
|
|
1002
|
-
utils_1.preLazy()
|
|
1006
|
+
(0, utils_1.preLazy)()
|
|
1003
1007
|
], FunctionService.prototype, "publishVersion", null);
|
|
1004
1008
|
__decorate([
|
|
1005
|
-
utils_1.preLazy()
|
|
1009
|
+
(0, utils_1.preLazy)()
|
|
1006
1010
|
], FunctionService.prototype, "listVersionByFunction", null);
|
|
1007
1011
|
__decorate([
|
|
1008
|
-
utils_1.preLazy()
|
|
1012
|
+
(0, utils_1.preLazy)()
|
|
1009
1013
|
], FunctionService.prototype, "updateFunctionAliasConfig", null);
|
|
1010
1014
|
__decorate([
|
|
1011
|
-
utils_1.preLazy()
|
|
1015
|
+
(0, utils_1.preLazy)()
|
|
1012
1016
|
], FunctionService.prototype, "getFunctionAlias", null);
|
|
1013
1017
|
__decorate([
|
|
1014
|
-
utils_1.preLazy()
|
|
1018
|
+
(0, utils_1.preLazy)()
|
|
1015
1019
|
], FunctionService.prototype, "createAccessPath", null);
|
|
1016
1020
|
__decorate([
|
|
1017
|
-
utils_1.preLazy()
|
|
1021
|
+
(0, utils_1.preLazy)()
|
|
1018
1022
|
], FunctionService.prototype, "getCodeParams", null);
|
|
1019
1023
|
__decorate([
|
|
1020
|
-
utils_1.preLazy()
|
|
1024
|
+
(0, utils_1.preLazy)()
|
|
1021
1025
|
], FunctionService.prototype, "getTempCosInfo", null);
|
|
1022
|
-
exports.FunctionService = FunctionService;
|
package/lib/function/packer.js
CHANGED
|
@@ -1,4 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
37
|
};
|
|
@@ -11,6 +44,7 @@ const make_dir_1 = __importDefault(require("make-dir"));
|
|
|
11
44
|
const util_1 = __importDefault(require("util"));
|
|
12
45
|
const utils_1 = require("../utils");
|
|
13
46
|
const error_1 = require("../error");
|
|
47
|
+
const os = __importStar(require("os"));
|
|
14
48
|
// 10 MB
|
|
15
49
|
exports.BIG_FILE_SIZE = 10485760;
|
|
16
50
|
exports.API_MAX_SIZE = 52428800;
|
|
@@ -18,8 +52,9 @@ var CodeType;
|
|
|
18
52
|
(function (CodeType) {
|
|
19
53
|
CodeType[CodeType["File"] = 0] = "File";
|
|
20
54
|
CodeType[CodeType["JavaFile"] = 1] = "JavaFile";
|
|
21
|
-
})(CodeType
|
|
55
|
+
})(CodeType || (exports.CodeType = CodeType = {}));
|
|
22
56
|
const TEMPDIR_NAME = '.cloudbase_temp';
|
|
57
|
+
const TEMPDIR = os.tmpdir();
|
|
23
58
|
/**
|
|
24
59
|
* 将函数代码转换成 Base64 编码
|
|
25
60
|
* 普通文件:Node,PHP
|
|
@@ -34,16 +69,14 @@ class FunctionPacker {
|
|
|
34
69
|
this.incrementalPath = incrementalPath;
|
|
35
70
|
this.funcPath = functionPath ? functionPath : path_1.default.resolve(root, name);
|
|
36
71
|
// 每个函数采用不同的文件夹
|
|
37
|
-
this.tmpPath =
|
|
38
|
-
? path_1.default.join(root, `${TEMPDIR_NAME}_${name}`)
|
|
39
|
-
: path_1.default.join(process.cwd(), `${TEMPDIR_NAME}_${name}`);
|
|
72
|
+
this.tmpPath = path_1.default.join(TEMPDIR, `${TEMPDIR_NAME}_${name}`);
|
|
40
73
|
}
|
|
41
74
|
async compressFiles() {
|
|
42
|
-
utils_1.checkFullAccess(this.funcPath, true);
|
|
75
|
+
(0, utils_1.checkFullAccess)(this.funcPath, true);
|
|
43
76
|
// 清除原打包文件
|
|
44
77
|
this.clean();
|
|
45
78
|
// 确保目标路径存在
|
|
46
|
-
await make_dir_1.default(this.tmpPath);
|
|
79
|
+
await (0, make_dir_1.default)(this.tmpPath);
|
|
47
80
|
// 生成 name.zip 文件
|
|
48
81
|
this.zipFilePath = path_1.default.resolve(this.tmpPath, `${this.name}.zip`);
|
|
49
82
|
const zipOption = {
|
|
@@ -54,7 +87,7 @@ class FunctionPacker {
|
|
|
54
87
|
if (this.incrementalPath) {
|
|
55
88
|
zipOption.pattern = this.incrementalPath;
|
|
56
89
|
}
|
|
57
|
-
await utils_1.compressToZip(zipOption);
|
|
90
|
+
await (0, utils_1.compressToZip)(zipOption);
|
|
58
91
|
}
|
|
59
92
|
// 获取 Java 代码
|
|
60
93
|
getJavaFile() {
|
|
@@ -62,8 +95,8 @@ class FunctionPacker {
|
|
|
62
95
|
// funcPath 可能以 .jar 或 .zip 结尾
|
|
63
96
|
const filePath = funcPath.replace(/\.jar$|\.zip$/g, '');
|
|
64
97
|
// Java 代码为 jar 或 zip 包
|
|
65
|
-
const jarExist = utils_1.checkFullAccess(`${filePath}.jar`);
|
|
66
|
-
const zipExist = utils_1.checkFullAccess(`${filePath}.zip`);
|
|
98
|
+
const jarExist = (0, utils_1.checkFullAccess)(`${filePath}.jar`);
|
|
99
|
+
const zipExist = (0, utils_1.checkFullAccess)(`${filePath}.zip`);
|
|
67
100
|
if (!jarExist && !zipExist) {
|
|
68
101
|
throw new error_1.CloudBaseError('未找到部署函数的 Jar 或者 ZIP 格式文件!');
|
|
69
102
|
}
|
package/lib/hosting/index.js
CHANGED
|
@@ -23,7 +23,7 @@ const HostingStatusMap = {
|
|
|
23
23
|
online: '上线',
|
|
24
24
|
destroying: '销毁中',
|
|
25
25
|
offline: '下线',
|
|
26
|
-
create_fail: '初始化失败',
|
|
26
|
+
create_fail: '初始化失败', // eslint-disable-line
|
|
27
27
|
destroy_fail: '销毁失败' // eslint-disable-line
|
|
28
28
|
};
|
|
29
29
|
class HostingService {
|
|
@@ -140,8 +140,8 @@ class HostingService {
|
|
|
140
140
|
if (localPath) {
|
|
141
141
|
const resolvePath = path_1.default.resolve(localPath);
|
|
142
142
|
// 检查路径是否存在
|
|
143
|
-
utils_1.checkReadable(resolvePath, true);
|
|
144
|
-
if (utils_1.isDirectory(resolvePath)) {
|
|
143
|
+
(0, utils_1.checkReadable)(resolvePath, true);
|
|
144
|
+
if ((0, utils_1.isDirectory)(resolvePath)) {
|
|
145
145
|
return storageService.uploadDirectoryCustom({
|
|
146
146
|
localPath: resolvePath,
|
|
147
147
|
cloudPath,
|
|
@@ -220,7 +220,7 @@ class HostingService {
|
|
|
220
220
|
const { cloudPath, localPath } = options;
|
|
221
221
|
if (localPath) {
|
|
222
222
|
const fileDir = path_1.default.dirname(localPath);
|
|
223
|
-
utils_1.checkFullAccess(fileDir, true);
|
|
223
|
+
(0, utils_1.checkFullAccess)(fileDir, true);
|
|
224
224
|
}
|
|
225
225
|
const envConfig = this.environment.lazyEnvironmentConfig;
|
|
226
226
|
const cacheHosting = envDomainCache.get(envConfig.EnvId);
|
|
@@ -237,7 +237,7 @@ class HostingService {
|
|
|
237
237
|
}
|
|
238
238
|
const url = new URL(cloudPath, `https://${CdnDomain}`).toString();
|
|
239
239
|
const { proxy } = await this.environment.getAuthConfig();
|
|
240
|
-
const res = await utils_1.fetchStream(url, {}, proxy);
|
|
240
|
+
const res = await (0, utils_1.fetchStream)(url, {}, proxy);
|
|
241
241
|
// localPath 不存在时,返回 ReadableStream
|
|
242
242
|
if (!localPath) {
|
|
243
243
|
return res.body;
|
|
@@ -280,7 +280,7 @@ class HostingService {
|
|
|
280
280
|
const localFilePath = path_1.default.join(resolveLocalPath, fileRelativePath);
|
|
281
281
|
// 创建文件的父文件夹
|
|
282
282
|
const fileDir = path_1.default.dirname(localFilePath);
|
|
283
|
-
await make_dir_1.default(fileDir);
|
|
283
|
+
await (0, make_dir_1.default)(fileDir);
|
|
284
284
|
return this.downloadFile({
|
|
285
285
|
cloudPath: file.Key,
|
|
286
286
|
localPath: localFilePath
|
|
@@ -424,40 +424,40 @@ class HostingService {
|
|
|
424
424
|
return cloudPath[cloudPath.length - 1] === '/' ? cloudPath : `${cloudPath}/`;
|
|
425
425
|
}
|
|
426
426
|
}
|
|
427
|
+
exports.HostingService = HostingService;
|
|
427
428
|
__decorate([
|
|
428
|
-
utils_1.preLazy()
|
|
429
|
+
(0, utils_1.preLazy)()
|
|
429
430
|
], HostingService.prototype, "getInfo", null);
|
|
430
431
|
__decorate([
|
|
431
|
-
utils_1.preLazy()
|
|
432
|
+
(0, utils_1.preLazy)()
|
|
432
433
|
], HostingService.prototype, "enableService", null);
|
|
433
434
|
__decorate([
|
|
434
|
-
utils_1.preLazy()
|
|
435
|
+
(0, utils_1.preLazy)()
|
|
435
436
|
], HostingService.prototype, "listFiles", null);
|
|
436
437
|
__decorate([
|
|
437
|
-
utils_1.preLazy()
|
|
438
|
+
(0, utils_1.preLazy)()
|
|
438
439
|
], HostingService.prototype, "destroyService", null);
|
|
439
440
|
__decorate([
|
|
440
|
-
utils_1.preLazy()
|
|
441
|
+
(0, utils_1.preLazy)()
|
|
441
442
|
], HostingService.prototype, "uploadFiles", null);
|
|
442
443
|
__decorate([
|
|
443
|
-
utils_1.preLazy()
|
|
444
|
+
(0, utils_1.preLazy)()
|
|
444
445
|
], HostingService.prototype, "deleteFiles", null);
|
|
445
446
|
__decorate([
|
|
446
|
-
utils_1.preLazy()
|
|
447
|
+
(0, utils_1.preLazy)()
|
|
447
448
|
], HostingService.prototype, "downloadFile", null);
|
|
448
449
|
__decorate([
|
|
449
|
-
utils_1.preLazy()
|
|
450
|
+
(0, utils_1.preLazy)()
|
|
450
451
|
], HostingService.prototype, "downloadDirectory", null);
|
|
451
452
|
__decorate([
|
|
452
|
-
utils_1.preLazy()
|
|
453
|
+
(0, utils_1.preLazy)()
|
|
453
454
|
], HostingService.prototype, "walkLocalDir", null);
|
|
454
455
|
__decorate([
|
|
455
|
-
utils_1.preLazy()
|
|
456
|
+
(0, utils_1.preLazy)()
|
|
456
457
|
], HostingService.prototype, "CreateHostingDomain", null);
|
|
457
458
|
__decorate([
|
|
458
|
-
utils_1.preLazy()
|
|
459
|
+
(0, utils_1.preLazy)()
|
|
459
460
|
], HostingService.prototype, "deleteHostingDomain", null);
|
|
460
461
|
__decorate([
|
|
461
|
-
utils_1.preLazy()
|
|
462
|
+
(0, utils_1.preLazy)()
|
|
462
463
|
], HostingService.prototype, "checkStatus", null);
|
|
463
|
-
exports.HostingService = HostingService;
|
package/lib/index.js
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
const context_1 = require("./context");
|
|
3
3
|
const environmentManager_1 = require("./environmentManager");
|
|
4
4
|
class CloudBase {
|
|
5
|
+
/**
|
|
6
|
+
* init 初始化 为单例
|
|
7
|
+
*
|
|
8
|
+
* @static
|
|
9
|
+
* @param {ManagerConfig} config
|
|
10
|
+
* @returns {CloudBase}
|
|
11
|
+
* @memberof CloudBase
|
|
12
|
+
*/
|
|
13
|
+
static init(config) {
|
|
14
|
+
if (!CloudBase.cloudBase) {
|
|
15
|
+
CloudBase.cloudBase = new CloudBase(config);
|
|
16
|
+
}
|
|
17
|
+
return CloudBase.cloudBase;
|
|
18
|
+
}
|
|
5
19
|
constructor(config = {}) {
|
|
6
20
|
this.cloudBaseConfig = {};
|
|
7
21
|
let { secretId, secretKey, token, envId, proxy, region, envType } = config;
|
|
@@ -23,20 +37,6 @@ class CloudBase {
|
|
|
23
37
|
this.environmentManager = new environmentManager_1.EnvironmentManager(this.context);
|
|
24
38
|
this.environmentManager.add(envId || '');
|
|
25
39
|
}
|
|
26
|
-
/**
|
|
27
|
-
* init 初始化 为单例
|
|
28
|
-
*
|
|
29
|
-
* @static
|
|
30
|
-
* @param {ManagerConfig} config
|
|
31
|
-
* @returns {CloudBase}
|
|
32
|
-
* @memberof CloudBase
|
|
33
|
-
*/
|
|
34
|
-
static init(config) {
|
|
35
|
-
if (!CloudBase.cloudBase) {
|
|
36
|
-
CloudBase.cloudBase = new CloudBase(config);
|
|
37
|
-
}
|
|
38
|
-
return CloudBase.cloudBase;
|
|
39
|
-
}
|
|
40
40
|
addEnvironment(envId) {
|
|
41
41
|
this.environmentManager.add(envId);
|
|
42
42
|
}
|
package/lib/interfaces/index.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
8
12
|
}));
|
|
9
13
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
15
|
};
|
|
12
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
17
|
__exportStar(require("./function.interface"), exports);
|
package/lib/storage/index.js
CHANGED
|
@@ -76,13 +76,13 @@ class StorageService {
|
|
|
76
76
|
const { localPath, cloudPath, bucket, region, onProgress, fileId = true } = options;
|
|
77
77
|
let localFilePath = '';
|
|
78
78
|
let resolveLocalPath = path_1.default.resolve(localPath);
|
|
79
|
-
utils_1.checkFullAccess(resolveLocalPath, true);
|
|
79
|
+
(0, utils_1.checkFullAccess)(resolveLocalPath, true);
|
|
80
80
|
// 如果 localPath 是一个文件夹,尝试在文件下寻找 cloudPath 中的文件
|
|
81
81
|
const fileStats = fs_1.default.statSync(resolveLocalPath);
|
|
82
82
|
if (fileStats.isDirectory()) {
|
|
83
83
|
const fileName = path_1.default.parse(cloudPath).base;
|
|
84
84
|
const attemptFilePath = path_1.default.join(localPath, fileName);
|
|
85
|
-
if (utils_1.checkFullAccess(attemptFilePath)) {
|
|
85
|
+
if ((0, utils_1.checkFullAccess)(attemptFilePath)) {
|
|
86
86
|
localFilePath = path_1.default.resolve(attemptFilePath);
|
|
87
87
|
}
|
|
88
88
|
}
|
|
@@ -191,7 +191,7 @@ class StorageService {
|
|
|
191
191
|
const fileKeyPath = filePath.replace(resolveLocalPath, '').replace(/\\/g, '/');
|
|
192
192
|
// 解析 cloudPath
|
|
193
193
|
let cloudFileKey = path_1.default.join(cloudPath, fileKeyPath).replace(/\\/g, '/');
|
|
194
|
-
if (utils_1.isDirectory(filePath)) {
|
|
194
|
+
if ((0, utils_1.isDirectory)(filePath)) {
|
|
195
195
|
cloudFileKey = this.getCloudKey(cloudFileKey);
|
|
196
196
|
return {
|
|
197
197
|
filePath,
|
|
@@ -358,11 +358,11 @@ class StorageService {
|
|
|
358
358
|
const { cloudPath, localPath } = options;
|
|
359
359
|
const resolveLocalPath = path_1.default.resolve(localPath);
|
|
360
360
|
const fileDir = path_1.default.dirname(localPath);
|
|
361
|
-
utils_1.checkFullAccess(fileDir, true);
|
|
361
|
+
(0, utils_1.checkFullAccess)(fileDir, true);
|
|
362
362
|
const urlList = await this.getTemporaryUrl([cloudPath]);
|
|
363
363
|
const { url } = urlList[0];
|
|
364
364
|
const { proxy } = await this.environment.getAuthConfig();
|
|
365
|
-
const res = await utils_1.fetchStream(url, {}, proxy);
|
|
365
|
+
const res = await (0, utils_1.fetchStream)(url, {}, proxy);
|
|
366
366
|
// localPath 不存在时,返回 ReadableStream
|
|
367
367
|
if (!localPath) {
|
|
368
368
|
return res.body;
|
|
@@ -386,7 +386,7 @@ class StorageService {
|
|
|
386
386
|
async downloadDirectory(options) {
|
|
387
387
|
const { cloudPath, localPath, parallel = 20 } = options;
|
|
388
388
|
const resolveLocalPath = path_1.default.resolve(localPath);
|
|
389
|
-
utils_1.checkFullAccess(resolveLocalPath, true);
|
|
389
|
+
(0, utils_1.checkFullAccess)(resolveLocalPath, true);
|
|
390
390
|
const cloudDirectoryKey = this.getCloudKey(cloudPath);
|
|
391
391
|
const files = await this.walkCloudDir(cloudDirectoryKey);
|
|
392
392
|
const promises = files.map(file => async () => {
|
|
@@ -462,7 +462,7 @@ class StorageService {
|
|
|
462
462
|
max_age: item.maxAge
|
|
463
463
|
}));
|
|
464
464
|
const config = this.environment.getAuthConfig();
|
|
465
|
-
const res = await utils_1.cloudBaseRequest({
|
|
465
|
+
const res = await (0, utils_1.cloudBaseRequest)({
|
|
466
466
|
config,
|
|
467
467
|
params: {
|
|
468
468
|
file_list: data,
|
|
@@ -492,7 +492,7 @@ class StorageService {
|
|
|
492
492
|
const { bucket, env } = this.getStorageConfig();
|
|
493
493
|
const fileIdList = cloudPathList.map(filePath => this.cloudPathToFileId(filePath));
|
|
494
494
|
const config = this.environment.getAuthConfig();
|
|
495
|
-
const res = await utils_1.cloudBaseRequest({
|
|
495
|
+
const res = await (0, utils_1.cloudBaseRequest)({
|
|
496
496
|
config,
|
|
497
497
|
params: {
|
|
498
498
|
action: 'storage.batchDeleteFile',
|
|
@@ -738,7 +738,7 @@ class StorageService {
|
|
|
738
738
|
*/
|
|
739
739
|
async getUploadMetadata(path) {
|
|
740
740
|
const config = this.environment.getAuthConfig();
|
|
741
|
-
const res = await utils_1.cloudBaseRequest({
|
|
741
|
+
const res = await (0, utils_1.cloudBaseRequest)({
|
|
742
742
|
config,
|
|
743
743
|
params: {
|
|
744
744
|
path,
|
|
@@ -847,12 +847,12 @@ class StorageService {
|
|
|
847
847
|
SecretKey: secretKey,
|
|
848
848
|
Proxy: cosProxy || proxy,
|
|
849
849
|
SecurityToken: token,
|
|
850
|
-
Domain: constant_1.USE_INTERNAL_ENDPOINT ? "{Bucket}.cos-internal.{Region}.tencentcos.cn" /* INTERNAL */ : "{Bucket}.cos.{Region}.tencentcos.cn" /* PUBLIC */,
|
|
850
|
+
Domain: constant_1.USE_INTERNAL_ENDPOINT ? "{Bucket}.cos-internal.{Region}.tencentcos.cn" /* COS_ENDPOINT.INTERNAL */ : "{Bucket}.cos.{Region}.tencentcos.cn" /* COS_ENDPOINT.PUBLIC */,
|
|
851
851
|
};
|
|
852
852
|
if (constant_1.COS_SDK_PROTOCOL) {
|
|
853
|
-
cosConfig.Protocol = constant_1.COS_SDK_PROTOCOL.endsWith(':')
|
|
853
|
+
cosConfig.Protocol = (constant_1.COS_SDK_PROTOCOL.endsWith(':')
|
|
854
854
|
? constant_1.COS_SDK_PROTOCOL.toLowerCase()
|
|
855
|
-
: constant_1.COS_SDK_PROTOCOL.toLowerCase() + ':';
|
|
855
|
+
: constant_1.COS_SDK_PROTOCOL.toLowerCase() + ':');
|
|
856
856
|
}
|
|
857
857
|
if (constant_1.USE_INTERNAL_ENDPOINT) {
|
|
858
858
|
cosConfig.Protocol = 'http:';
|
|
@@ -861,7 +861,7 @@ class StorageService {
|
|
|
861
861
|
if (constant_1.COS_SDK_KEEPALIVE) {
|
|
862
862
|
cosConfig.KeepAlive = { true: true, false: false }[constant_1.COS_SDK_KEEPALIVE];
|
|
863
863
|
}
|
|
864
|
-
else if (runenv_1.checkIsInScf()) {
|
|
864
|
+
else if ((0, runenv_1.checkIsInScf)()) {
|
|
865
865
|
cosConfig.KeepAlive = false;
|
|
866
866
|
}
|
|
867
867
|
return new cos_nodejs_sdk_v5_1.default(cosConfig);
|
|
@@ -965,7 +965,7 @@ class StorageService {
|
|
|
965
965
|
const localFilePath = path_1.default.join(resolveLocalPath, fileRelativePath);
|
|
966
966
|
// 创建文件的父文件夹
|
|
967
967
|
const fileDir = path_1.default.dirname(localFilePath);
|
|
968
|
-
await make_dir_1.default(fileDir);
|
|
968
|
+
await (0, make_dir_1.default)(fileDir);
|
|
969
969
|
return this.downloadFile({
|
|
970
970
|
cloudPath: file.Key,
|
|
971
971
|
localPath: localFilePath
|
|
@@ -982,73 +982,73 @@ class StorageService {
|
|
|
982
982
|
return resultErrorArr;
|
|
983
983
|
}
|
|
984
984
|
}
|
|
985
|
+
exports.StorageService = StorageService;
|
|
985
986
|
__decorate([
|
|
986
|
-
utils_1.preLazy()
|
|
987
|
+
(0, utils_1.preLazy)()
|
|
987
988
|
], StorageService.prototype, "uploadFile", null);
|
|
988
989
|
__decorate([
|
|
989
|
-
utils_1.preLazy()
|
|
990
|
+
(0, utils_1.preLazy)()
|
|
990
991
|
], StorageService.prototype, "uploadFiles", null);
|
|
991
992
|
__decorate([
|
|
992
|
-
utils_1.preLazy()
|
|
993
|
+
(0, utils_1.preLazy)()
|
|
993
994
|
], StorageService.prototype, "uploadFileCustom", null);
|
|
994
995
|
__decorate([
|
|
995
|
-
utils_1.preLazy()
|
|
996
|
+
(0, utils_1.preLazy)()
|
|
996
997
|
], StorageService.prototype, "uploadDirectory", null);
|
|
997
998
|
__decorate([
|
|
998
|
-
utils_1.preLazy()
|
|
999
|
+
(0, utils_1.preLazy)()
|
|
999
1000
|
], StorageService.prototype, "uploadDirectoryCustom", null);
|
|
1000
1001
|
__decorate([
|
|
1001
|
-
utils_1.preLazy()
|
|
1002
|
+
(0, utils_1.preLazy)()
|
|
1002
1003
|
], StorageService.prototype, "uploadFilesCustom", null);
|
|
1003
1004
|
__decorate([
|
|
1004
|
-
utils_1.preLazy()
|
|
1005
|
+
(0, utils_1.preLazy)()
|
|
1005
1006
|
], StorageService.prototype, "createCloudDirectroy", null);
|
|
1006
1007
|
__decorate([
|
|
1007
|
-
utils_1.preLazy()
|
|
1008
|
+
(0, utils_1.preLazy)()
|
|
1008
1009
|
], StorageService.prototype, "createCloudDirectroyCustom", null);
|
|
1009
1010
|
__decorate([
|
|
1010
|
-
utils_1.preLazy()
|
|
1011
|
+
(0, utils_1.preLazy)()
|
|
1011
1012
|
], StorageService.prototype, "downloadFile", null);
|
|
1012
1013
|
__decorate([
|
|
1013
|
-
utils_1.preLazy()
|
|
1014
|
+
(0, utils_1.preLazy)()
|
|
1014
1015
|
], StorageService.prototype, "downloadDirectory", null);
|
|
1015
1016
|
__decorate([
|
|
1016
|
-
utils_1.preLazy()
|
|
1017
|
+
(0, utils_1.preLazy)()
|
|
1017
1018
|
], StorageService.prototype, "listDirectoryFiles", null);
|
|
1018
1019
|
__decorate([
|
|
1019
|
-
utils_1.preLazy()
|
|
1020
|
+
(0, utils_1.preLazy)()
|
|
1020
1021
|
], StorageService.prototype, "getTemporaryUrl", null);
|
|
1021
1022
|
__decorate([
|
|
1022
|
-
utils_1.preLazy()
|
|
1023
|
+
(0, utils_1.preLazy)()
|
|
1023
1024
|
], StorageService.prototype, "deleteFile", null);
|
|
1024
1025
|
__decorate([
|
|
1025
|
-
utils_1.preLazy()
|
|
1026
|
+
(0, utils_1.preLazy)()
|
|
1026
1027
|
], StorageService.prototype, "deleteFileCustom", null);
|
|
1027
1028
|
__decorate([
|
|
1028
|
-
utils_1.preLazy()
|
|
1029
|
+
(0, utils_1.preLazy)()
|
|
1029
1030
|
], StorageService.prototype, "getFileInfo", null);
|
|
1030
1031
|
__decorate([
|
|
1031
|
-
utils_1.preLazy()
|
|
1032
|
+
(0, utils_1.preLazy)()
|
|
1032
1033
|
], StorageService.prototype, "deleteDirectory", null);
|
|
1033
1034
|
__decorate([
|
|
1034
|
-
utils_1.preLazy()
|
|
1035
|
+
(0, utils_1.preLazy)()
|
|
1035
1036
|
], StorageService.prototype, "deleteDirectoryCustom", null);
|
|
1036
1037
|
__decorate([
|
|
1037
|
-
utils_1.preLazy()
|
|
1038
|
+
(0, utils_1.preLazy)()
|
|
1038
1039
|
], StorageService.prototype, "getStorageAcl", null);
|
|
1039
1040
|
__decorate([
|
|
1040
|
-
utils_1.preLazy()
|
|
1041
|
+
(0, utils_1.preLazy)()
|
|
1041
1042
|
], StorageService.prototype, "setStorageAcl", null);
|
|
1042
1043
|
__decorate([
|
|
1043
|
-
utils_1.preLazy()
|
|
1044
|
+
(0, utils_1.preLazy)()
|
|
1044
1045
|
], StorageService.prototype, "walkCloudDir", null);
|
|
1045
1046
|
__decorate([
|
|
1046
|
-
utils_1.preLazy()
|
|
1047
|
+
(0, utils_1.preLazy)()
|
|
1047
1048
|
], StorageService.prototype, "walkCloudDirCustom", null);
|
|
1048
1049
|
__decorate([
|
|
1049
|
-
utils_1.preLazy()
|
|
1050
|
+
(0, utils_1.preLazy)()
|
|
1050
1051
|
], StorageService.prototype, "putBucketWebsite", null);
|
|
1051
1052
|
__decorate([
|
|
1052
|
-
utils_1.preLazy()
|
|
1053
|
+
(0, utils_1.preLazy)()
|
|
1053
1054
|
], StorageService.prototype, "getBucket", null);
|
|
1054
|
-
exports.StorageService = StorageService;
|
package/lib/user/index.js
CHANGED
|
@@ -115,22 +115,22 @@ class UserService {
|
|
|
115
115
|
return typeof obj === 'string' && obj.trim().length > 0;
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
|
+
exports.UserService = UserService;
|
|
118
119
|
__decorate([
|
|
119
|
-
utils_1.preLazy()
|
|
120
|
+
(0, utils_1.preLazy)()
|
|
120
121
|
], UserService.prototype, "getEndUserList", null);
|
|
121
122
|
__decorate([
|
|
122
|
-
utils_1.preLazy()
|
|
123
|
+
(0, utils_1.preLazy)()
|
|
123
124
|
], UserService.prototype, "setEndUserStatus", null);
|
|
124
125
|
__decorate([
|
|
125
|
-
utils_1.preLazy()
|
|
126
|
+
(0, utils_1.preLazy)()
|
|
126
127
|
], UserService.prototype, "deleteEndUsers", null);
|
|
127
128
|
__decorate([
|
|
128
|
-
utils_1.preLazy()
|
|
129
|
+
(0, utils_1.preLazy)()
|
|
129
130
|
], UserService.prototype, "createEndUser", null);
|
|
130
131
|
__decorate([
|
|
131
|
-
utils_1.preLazy()
|
|
132
|
+
(0, utils_1.preLazy)()
|
|
132
133
|
], UserService.prototype, "modifyEndUser", null);
|
|
133
134
|
__decorate([
|
|
134
|
-
utils_1.preLazy()
|
|
135
|
+
(0, utils_1.preLazy)()
|
|
135
136
|
], UserService.prototype, "updateEndUser", null);
|
|
136
|
-
exports.UserService = UserService;
|
package/lib/utils/auth.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getAuth =
|
|
6
|
+
exports.getAuth = getAuth;
|
|
7
7
|
const crypto_1 = __importDefault(require("crypto"));
|
|
8
8
|
function camSafeUrlEncode(str) {
|
|
9
9
|
return encodeURIComponent(str)
|
|
@@ -94,4 +94,3 @@ function getAuth(options) {
|
|
|
94
94
|
].join('&');
|
|
95
95
|
return authorization;
|
|
96
96
|
}
|
|
97
|
-
exports.getAuth = getAuth;
|
|
@@ -94,11 +94,11 @@ class CloudService {
|
|
|
94
94
|
// request执行时一般处于main函数内部,取环境变量逻辑写这里更可靠
|
|
95
95
|
if (!secretId || !secretKey) {
|
|
96
96
|
// 未主动传入密钥,从环境变量中读取
|
|
97
|
-
const envSecretId = utils_1.getEnvVar(constant_1.ENV_NAME.ENV_SECRETID);
|
|
98
|
-
const envSecretKey = utils_1.getEnvVar(constant_1.ENV_NAME.ENV_SECRETKEY);
|
|
99
|
-
const envToken = utils_1.getEnvVar(constant_1.ENV_NAME.ENV_SESSIONTOKEN);
|
|
97
|
+
const envSecretId = (0, utils_1.getEnvVar)(constant_1.ENV_NAME.ENV_SECRETID);
|
|
98
|
+
const envSecretKey = (0, utils_1.getEnvVar)(constant_1.ENV_NAME.ENV_SECRETKEY);
|
|
99
|
+
const envToken = (0, utils_1.getEnvVar)(constant_1.ENV_NAME.ENV_SESSIONTOKEN);
|
|
100
100
|
if (!envSecretId || !envSecretKey) {
|
|
101
|
-
if (utils_1.getRuntime() === constant_1.RUN_ENV.SCF) {
|
|
101
|
+
if ((0, utils_1.getRuntime)() === constant_1.RUN_ENV.SCF) {
|
|
102
102
|
throw new Error('missing authoration key, redeploy the function');
|
|
103
103
|
}
|
|
104
104
|
else {
|
|
@@ -181,7 +181,7 @@ class CloudService {
|
|
|
181
181
|
}
|
|
182
182
|
const sign = this.getRequestSign(timestamp);
|
|
183
183
|
config.headers['Authorization'] = sign;
|
|
184
|
-
return http_request_1.fetch(this.url, config, proxy);
|
|
184
|
+
return (0, http_request_1.fetch)(this.url, config, proxy);
|
|
185
185
|
}
|
|
186
186
|
getRequestSign(timestamp) {
|
|
187
187
|
const { method = 'POST', url, service, secretId, secretKey } = this;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.cloudBaseRequest =
|
|
3
|
+
exports.cloudBaseRequest = cloudBaseRequest;
|
|
4
4
|
const auth_1 = require("./auth");
|
|
5
5
|
const http_request_1 = require("./http-request");
|
|
6
6
|
const SUPPORT_REGIONS = ['ap-shanghai', 'ap-guangzhou'];
|
|
@@ -57,13 +57,12 @@ async function cloudBaseRequest(options) {
|
|
|
57
57
|
params: requestData,
|
|
58
58
|
headers: requestHeaders
|
|
59
59
|
};
|
|
60
|
-
const authorization = auth_1.getAuth(authData);
|
|
60
|
+
const authorization = (0, auth_1.getAuth)(authData);
|
|
61
61
|
const requestBody = Object.assign(Object.assign({}, requestData), { sessionToken: token, authorization });
|
|
62
|
-
const res = await http_request_1.fetch(url, {
|
|
62
|
+
const res = await (0, http_request_1.fetch)(url, {
|
|
63
63
|
method,
|
|
64
64
|
body: JSON.stringify(requestBody),
|
|
65
65
|
headers: requestHeaders
|
|
66
66
|
}, process.env.TCB_ADMIN_PROXY || proxy);
|
|
67
67
|
return res;
|
|
68
68
|
}
|
|
69
|
-
exports.cloudBaseRequest = cloudBaseRequest;
|
package/lib/utils/envLazy.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.preLazy =
|
|
3
|
+
exports.preLazy = preLazy;
|
|
4
4
|
function preLazy() {
|
|
5
5
|
return function (target, propertyKey, descriptor) {
|
|
6
6
|
let oldFunc = descriptor.value;
|
|
@@ -15,4 +15,3 @@ function preLazy() {
|
|
|
15
15
|
};
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
|
-
exports.preLazy = preLazy;
|
package/lib/utils/fs.js
CHANGED
|
@@ -3,7 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.checkFullAccess = checkFullAccess;
|
|
7
|
+
exports.checkReadable = checkReadable;
|
|
8
|
+
exports.isDirectory = isDirectory;
|
|
9
|
+
exports.formateFileSize = formateFileSize;
|
|
10
|
+
exports.delSync = delSync;
|
|
7
11
|
const fs_1 = __importDefault(require("fs"));
|
|
8
12
|
const error_1 = require("../error");
|
|
9
13
|
const del_1 = __importDefault(require("del"));
|
|
@@ -25,7 +29,6 @@ function checkFullAccess(dest, throwError = false) {
|
|
|
25
29
|
}
|
|
26
30
|
}
|
|
27
31
|
}
|
|
28
|
-
exports.checkFullAccess = checkFullAccess;
|
|
29
32
|
// 检查路径是否可以写
|
|
30
33
|
function checkReadable(dest, throwError = false) {
|
|
31
34
|
try {
|
|
@@ -43,12 +46,10 @@ function checkReadable(dest, throwError = false) {
|
|
|
43
46
|
}
|
|
44
47
|
}
|
|
45
48
|
}
|
|
46
|
-
exports.checkReadable = checkReadable;
|
|
47
49
|
function isDirectory(dest) {
|
|
48
50
|
checkFullAccess(dest, true);
|
|
49
51
|
return fs_1.default.statSync(dest).isDirectory();
|
|
50
52
|
}
|
|
51
|
-
exports.isDirectory = isDirectory;
|
|
52
53
|
function formateFileSize(size, unit) {
|
|
53
54
|
const unitMap = {
|
|
54
55
|
KB: 1024,
|
|
@@ -57,8 +58,6 @@ function formateFileSize(size, unit) {
|
|
|
57
58
|
};
|
|
58
59
|
return Number(size / unitMap[unit]).toFixed(2);
|
|
59
60
|
}
|
|
60
|
-
exports.formateFileSize = formateFileSize;
|
|
61
61
|
function delSync(patterns) {
|
|
62
62
|
del_1.default.sync(patterns, { force: true });
|
|
63
63
|
}
|
|
64
|
-
exports.delSync = delSync;
|
|
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.fetch = fetch;
|
|
7
|
+
exports.fetchStream = fetchStream;
|
|
7
8
|
const url_1 = require("url");
|
|
8
9
|
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
9
10
|
const https_proxy_agent_1 = require("https-proxy-agent");
|
|
@@ -18,7 +19,7 @@ async function fetch(url, config = {}, proxy) {
|
|
|
18
19
|
let json;
|
|
19
20
|
let text;
|
|
20
21
|
try {
|
|
21
|
-
const res = await node_fetch_1.default(escapeUrl, config);
|
|
22
|
+
const res = await (0, node_fetch_1.default)(escapeUrl, config);
|
|
22
23
|
text = await res.text();
|
|
23
24
|
json = JSON.parse(text);
|
|
24
25
|
}
|
|
@@ -32,13 +33,11 @@ async function fetch(url, config = {}, proxy) {
|
|
|
32
33
|
}
|
|
33
34
|
return json;
|
|
34
35
|
}
|
|
35
|
-
exports.fetch = fetch;
|
|
36
36
|
async function fetchStream(url, config = {}, proxy) {
|
|
37
37
|
if (proxy || process.env.http_proxy) {
|
|
38
38
|
config.agent = new https_proxy_agent_1.HttpsProxyAgent(proxy || process.env.http_proxy);
|
|
39
39
|
}
|
|
40
40
|
// 解决中文编码问题
|
|
41
41
|
const escapeUrl = new url_1.URL(url).toString();
|
|
42
|
-
return node_fetch_1.default(escapeUrl, config);
|
|
42
|
+
return (0, node_fetch_1.default)(escapeUrl, config);
|
|
43
43
|
}
|
|
44
|
-
exports.fetchStream = fetchStream;
|
package/lib/utils/index.js
CHANGED
|
@@ -1,19 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
8
12
|
}));
|
|
9
13
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
15
|
};
|
|
12
16
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
18
|
};
|
|
15
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.
|
|
20
|
+
exports.guid6 = void 0;
|
|
21
|
+
exports.compressToZip = compressToZip;
|
|
22
|
+
exports.getRuntime = getRuntime;
|
|
23
|
+
exports.getEnvVar = getEnvVar;
|
|
24
|
+
exports.rsaEncrypt = rsaEncrypt;
|
|
25
|
+
exports.sleep = sleep;
|
|
26
|
+
exports.upperCaseStringFisrt = upperCaseStringFisrt;
|
|
27
|
+
exports.upperCaseObjKey = upperCaseObjKey;
|
|
17
28
|
const fs_1 = __importDefault(require("fs"));
|
|
18
29
|
const archiver_1 = __importDefault(require("archiver"));
|
|
19
30
|
const crypto_1 = __importDefault(require("crypto"));
|
|
@@ -30,7 +41,7 @@ async function compressToZip(option) {
|
|
|
30
41
|
const { dirPath, outputPath, ignore, pattern = '**/*' } = option;
|
|
31
42
|
return new Promise((resolve, reject) => {
|
|
32
43
|
const output = fs_1.default.createWriteStream(outputPath);
|
|
33
|
-
const archive = archiver_1.default('zip');
|
|
44
|
+
const archive = (0, archiver_1.default)('zip');
|
|
34
45
|
output.on('close', function () {
|
|
35
46
|
resolve({
|
|
36
47
|
zipPath: outputPath,
|
|
@@ -51,15 +62,12 @@ async function compressToZip(option) {
|
|
|
51
62
|
archive.finalize();
|
|
52
63
|
});
|
|
53
64
|
}
|
|
54
|
-
exports.compressToZip = compressToZip;
|
|
55
65
|
function getRuntime() {
|
|
56
66
|
return process.env[constant_1.ENV_NAME.ENV_RUNENV];
|
|
57
67
|
}
|
|
58
|
-
exports.getRuntime = getRuntime;
|
|
59
68
|
function getEnvVar(envName) {
|
|
60
69
|
return process.env[envName];
|
|
61
70
|
}
|
|
62
|
-
exports.getEnvVar = getEnvVar;
|
|
63
71
|
function rsaEncrypt(data) {
|
|
64
72
|
const buffer = Buffer.from(data);
|
|
65
73
|
const encrypted = crypto_1.default.publicEncrypt({
|
|
@@ -68,7 +76,6 @@ function rsaEncrypt(data) {
|
|
|
68
76
|
}, buffer);
|
|
69
77
|
return encrypted.toString('base64');
|
|
70
78
|
}
|
|
71
|
-
exports.rsaEncrypt = rsaEncrypt;
|
|
72
79
|
function sleep(time) {
|
|
73
80
|
return new Promise(resolve => {
|
|
74
81
|
setTimeout(() => {
|
|
@@ -76,11 +83,9 @@ function sleep(time) {
|
|
|
76
83
|
}, time);
|
|
77
84
|
});
|
|
78
85
|
}
|
|
79
|
-
exports.sleep = sleep;
|
|
80
86
|
function upperCaseStringFisrt(str) {
|
|
81
87
|
return str.slice(0, 1).toUpperCase().concat(str.slice(1));
|
|
82
88
|
}
|
|
83
|
-
exports.upperCaseStringFisrt = upperCaseStringFisrt;
|
|
84
89
|
function upperCaseObjKey(object) {
|
|
85
90
|
const type = Object.prototype.toString.call(object).slice(8, -1);
|
|
86
91
|
if (type === 'Object') {
|
|
@@ -100,4 +105,3 @@ function upperCaseObjKey(object) {
|
|
|
100
105
|
}
|
|
101
106
|
return object;
|
|
102
107
|
}
|
|
103
|
-
exports.upperCaseObjKey = upperCaseObjKey;
|
package/lib/utils/runenv.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.checkIsInScf =
|
|
3
|
+
exports.checkIsInScf = checkIsInScf;
|
|
4
4
|
function checkIsInScf() {
|
|
5
5
|
// TENCENTCLOUD_RUNENV
|
|
6
6
|
return process.env.TENCENTCLOUD_RUNENV === 'SCF';
|
|
7
7
|
}
|
|
8
|
-
exports.checkIsInScf = checkIsInScf;
|
package/lib/utils/uuid.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.guid6 = guid6;
|
|
4
|
+
exports.uuidv4 = uuidv4;
|
|
4
5
|
// 环境 uuid
|
|
5
6
|
function guid6() {
|
|
6
7
|
return Math.floor((1 + Math.random()) * 0x1000000)
|
|
7
8
|
.toString(16)
|
|
8
9
|
.substring(1);
|
|
9
10
|
}
|
|
10
|
-
exports.guid6 = guid6;
|
|
11
11
|
function uuidv4() {
|
|
12
12
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
13
13
|
const r = (Math.random() * 16) | 0;
|
|
@@ -15,4 +15,3 @@ function uuidv4() {
|
|
|
15
15
|
return v.toString(16);
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
|
-
exports.uuidv4 = uuidv4;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/manager-node",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.12",
|
|
4
4
|
"description": "The node manage service api for cloudbase.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -31,12 +31,12 @@
|
|
|
31
31
|
"lint-staged": "^9.2.5",
|
|
32
32
|
"rimraf": "^3.0.0",
|
|
33
33
|
"ts-jest": "^24.1.0",
|
|
34
|
-
"typescript": "^
|
|
34
|
+
"typescript": "^5.8.3"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@cloudbase/database": "^0.6.2",
|
|
38
38
|
"archiver": "^3.1.1",
|
|
39
|
-
"cos-nodejs-sdk-v5": "2.14.0",
|
|
39
|
+
"cos-nodejs-sdk-v5": "^2.14.0",
|
|
40
40
|
"del": "^5.1.0",
|
|
41
41
|
"https-proxy-agent": "^5.0.1",
|
|
42
42
|
"make-dir": "^3.0.0",
|
|
@@ -55,5 +55,6 @@
|
|
|
55
55
|
"eslint --fix",
|
|
56
56
|
"git add"
|
|
57
57
|
]
|
|
58
|
-
}
|
|
58
|
+
},
|
|
59
|
+
"packageManager": "yarn@1.22.22"
|
|
59
60
|
}
|
package/types/env/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Environment } from '../environment';
|
|
2
2
|
import { IResponseInfo, AuthDomain, EnvInfo, LoginConfigItem, ICheckTcbServiceRes, ICreatePostpayRes } from '../interfaces';
|
|
3
|
-
|
|
3
|
+
type SOURCE = 'miniapp' | 'qcloud';
|
|
4
4
|
interface IDeleteDomainRes {
|
|
5
5
|
RequestId: string;
|
|
6
6
|
Deleted: number;
|
|
@@ -60,7 +60,7 @@ export interface IFunctionLog {
|
|
|
60
60
|
export interface ILogFilter {
|
|
61
61
|
RetCode?: 'not0' | 'is0' | 'TimeLimitExceeded' | 'ResourceLimitExceeded' | 'UserCodeException';
|
|
62
62
|
}
|
|
63
|
-
export
|
|
63
|
+
export type IRegion = number;
|
|
64
64
|
export interface IEnvVariable {
|
|
65
65
|
Key: string;
|
|
66
66
|
Value: string;
|
package/types/hosting/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { Environment } from '../environment';
|
|
3
2
|
import { IListFileInfo } from '../interfaces';
|
|
4
3
|
export interface IProgressData {
|
|
@@ -7,8 +6,8 @@ export interface IProgressData {
|
|
|
7
6
|
speed: number;
|
|
8
7
|
percent: number;
|
|
9
8
|
}
|
|
10
|
-
export
|
|
11
|
-
export
|
|
9
|
+
export type OnProgress = (progressData: IProgressData) => void;
|
|
10
|
+
export type OnFileFinish = (error: Error, res: any, fileData: any) => void;
|
|
12
11
|
export interface IHostingFileOptions {
|
|
13
12
|
localPath: string;
|
|
14
13
|
cloudPath?: string;
|
|
@@ -37,7 +36,7 @@ export interface IHostingFilesOptions {
|
|
|
37
36
|
retryCount?: number;
|
|
38
37
|
retryInterval?: number;
|
|
39
38
|
}
|
|
40
|
-
export
|
|
39
|
+
export type IHostingOptions = IHostingFileOptions | IHostingFilesOptions;
|
|
41
40
|
export interface IHostingCloudOptions {
|
|
42
41
|
cloudPath: string;
|
|
43
42
|
isDir: boolean;
|
package/types/storage/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { Environment } from '../environment';
|
|
3
2
|
import { IUploadMetadata, IListFileInfo, IFileInfo, ITempUrlInfo, IResponseInfo } from '../interfaces';
|
|
4
3
|
export interface IProgressData {
|
|
@@ -60,9 +59,9 @@ export interface IGetBucketOpions {
|
|
|
60
59
|
marker?: string;
|
|
61
60
|
maxKeys?: number;
|
|
62
61
|
}
|
|
63
|
-
export
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
export type AclType = 'READONLY' | 'PRIVATE' | 'ADMINWRITE' | 'ADMINONLY';
|
|
63
|
+
type OnProgress = (progressData: IProgressData) => void;
|
|
64
|
+
type OnFileFinish = (error: Error, res: any, fileData: any) => void;
|
|
66
65
|
export declare class StorageService {
|
|
67
66
|
private environment;
|
|
68
67
|
private tcbService;
|
package/types/user/types.d.ts
CHANGED
package/types/utils/fs.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
type SizeUnit = 'MB' | 'GB';
|
|
2
2
|
export declare function checkFullAccess(dest: string, throwError?: boolean): boolean;
|
|
3
3
|
export declare function checkReadable(dest: string, throwError?: boolean): boolean;
|
|
4
4
|
export declare function isDirectory(dest: string): boolean;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
+
import _fetch from 'node-fetch';
|
|
1
2
|
export declare function fetch(url: string, config: Record<string, any>, proxy: any): Promise<any>;
|
|
2
|
-
export declare function fetchStream(url: string, config: Record<string, any>, proxy: any): Promise<
|
|
3
|
+
export declare function fetchStream(url: string, config: Record<string, any>, proxy: any): Promise<_fetch.Response>;
|