@cloudbase/cli 2.10.0-beta.0 → 2.11.0-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/auth/login.js +51 -65
- package/lib/auth/logout.js +3 -14
- package/lib/commands/account/login.js +136 -149
- package/lib/commands/account/logout.js +3 -14
- package/lib/commands/ag/base.js +203 -0
- package/lib/commands/ag/create.js +301 -0
- package/lib/commands/ag/debug/index.html +699 -0
- package/lib/commands/ag/delete.js +200 -0
- package/lib/commands/ag/deploy.js +185 -0
- package/lib/commands/ag/detail.js +113 -0
- package/lib/commands/ag/index.js +22 -0
- package/lib/commands/ag/list.js +155 -0
- package/lib/commands/ag/run.js +644 -0
- package/lib/commands/ai/index.js +76 -95
- package/lib/commands/cloudfunction/base.js +182 -203
- package/lib/commands/cloudrun/base.js +578 -603
- package/lib/commands/common.js +48 -63
- package/lib/commands/config/delete.js +16 -27
- package/lib/commands/config/get.js +13 -24
- package/lib/commands/config/list.js +16 -27
- package/lib/commands/config/set.js +33 -44
- package/lib/commands/db/base.js +221 -240
- package/lib/commands/env/base.js +36 -49
- package/lib/commands/env/domain.js +79 -94
- package/lib/commands/env/login.js +120 -135
- package/lib/commands/framework/index.js +32 -49
- package/lib/commands/fun/base.js +223 -244
- package/lib/commands/functions/alias/getRoute.js +33 -44
- package/lib/commands/functions/alias/setRoute.js +36 -47
- package/lib/commands/functions/code-download.js +43 -54
- package/lib/commands/functions/code-update.js +23 -34
- package/lib/commands/functions/concurrency/delete.js +11 -22
- package/lib/commands/functions/concurrency/list.js +20 -31
- package/lib/commands/functions/concurrency/set.js +13 -24
- package/lib/commands/functions/config-update.js +30 -41
- package/lib/commands/functions/copy.js +12 -23
- package/lib/commands/functions/delete.js +30 -41
- package/lib/commands/functions/deploy.js +184 -202
- package/lib/commands/functions/detail.js +23 -34
- package/lib/commands/functions/invoke.js +69 -75
- package/lib/commands/functions/layer/bind.js +102 -105
- package/lib/commands/functions/layer/create.js +29 -35
- package/lib/commands/functions/layer/delete.js +42 -48
- package/lib/commands/functions/layer/download.js +52 -58
- package/lib/commands/functions/layer/list.js +44 -50
- package/lib/commands/functions/layer/sort.js +39 -45
- package/lib/commands/functions/list.js +25 -36
- package/lib/commands/functions/log.js +65 -73
- package/lib/commands/functions/run.js +118 -116
- package/lib/commands/functions/trigger-create.js +32 -43
- package/lib/commands/functions/trigger-delete.js +50 -61
- package/lib/commands/functions/version/list.js +29 -40
- package/lib/commands/functions/version/publish.js +11 -22
- package/lib/commands/gateway/create.js +50 -61
- package/lib/commands/gateway/delete.js +38 -49
- package/lib/commands/gateway/domain.js +65 -80
- package/lib/commands/gateway/list.js +31 -42
- package/lib/commands/gateway/switch.js +48 -61
- package/lib/commands/helpers/init.js +226 -249
- package/lib/commands/helpers/new.js +35 -46
- package/lib/commands/helpers/open.js +22 -33
- package/lib/commands/hosting/hosting.js +157 -178
- package/lib/commands/index.js +1 -0
- package/lib/commands/lowcode/app.js +114 -144
- package/lib/commands/lowcode/comps.js +136 -127
- package/lib/commands/lowcode/utils.js +11 -22
- package/lib/commands/pull/pull.js +33 -46
- package/lib/commands/run/delete.js +35 -46
- package/lib/commands/run/image/delete.js +32 -39
- package/lib/commands/run/image/download.js +26 -33
- package/lib/commands/run/image/list.js +41 -48
- package/lib/commands/run/image/upload.js +26 -33
- package/lib/commands/run/list.js +32 -43
- package/lib/commands/run/service/config.js +17 -28
- package/lib/commands/run/service/deploy.js +15 -26
- package/lib/commands/run/service/list.js +48 -59
- package/lib/commands/run/service/update.js +7 -18
- package/lib/commands/run/standalonegateway/create.js +35 -42
- package/lib/commands/run/standalonegateway/destroy.js +23 -30
- package/lib/commands/run/standalonegateway/list.js +19 -26
- package/lib/commands/run/standalonegateway/package.js +31 -38
- package/lib/commands/run/standalonegateway/turn.js +27 -34
- package/lib/commands/run/version/create.js +198 -205
- package/lib/commands/run/version/delete.js +31 -38
- package/lib/commands/run/version/list.js +42 -49
- package/lib/commands/run/version/modify.js +27 -34
- package/lib/commands/run/version/update.js +201 -208
- package/lib/commands/runf/base.js +216 -237
- package/lib/commands/self-update.js +59 -72
- package/lib/commands/smart.js +66 -79
- package/lib/commands/storage/storage.js +192 -219
- package/lib/commands/third/thirdAttach.js +16 -27
- package/lib/commands/utils.js +119 -149
- package/lib/db/index.js +48 -67
- package/lib/decorators/captureError.js +10 -21
- package/lib/decorators/guard.js +11 -22
- package/lib/decorators/injectParams.js +29 -40
- package/lib/decorators/params/common.js +5 -2
- package/lib/decorators/params/index.js +3 -12
- package/lib/env/domain.js +13 -28
- package/lib/env/index.js +25 -44
- package/lib/env/login.js +30 -45
- package/lib/function/alias.js +31 -44
- package/lib/function/base.js +187 -215
- package/lib/function/code.js +8 -19
- package/lib/function/concurrency.js +43 -58
- package/lib/function/create.js +43 -53
- package/lib/function/delete.js +22 -35
- package/lib/function/layer/attach.js +33 -46
- package/lib/function/layer/create.js +34 -45
- package/lib/function/layer/delete.js +5 -16
- package/lib/function/layer/download.js +11 -22
- package/lib/function/layer/list.js +12 -25
- package/lib/function/layer/sort.js +6 -17
- package/lib/function/trigger.js +65 -82
- package/lib/function/update.js +24 -32
- package/lib/function/version.js +29 -42
- package/lib/function/vpc.js +12 -25
- package/lib/gateway/index.js +77 -104
- package/lib/hosting.js +157 -188
- package/lib/run/delete.js +3 -12
- package/lib/run/image/build.js +6 -15
- package/lib/run/image/delete.js +3 -12
- package/lib/run/image/info.js +3 -12
- package/lib/run/image/list.js +6 -15
- package/lib/run/list.js +19 -30
- package/lib/run/repo.js +6 -15
- package/lib/run/service/common.js +160 -173
- package/lib/run/service/config.js +44 -57
- package/lib/run/service/deployPackage.js +33 -44
- package/lib/run/service/list.js +8 -14
- package/lib/run/service/showLogs.js +69 -90
- package/lib/run/service/update.js +50 -63
- package/lib/run/standalonegateway/create.js +3 -12
- package/lib/run/standalonegateway/destroy.js +3 -12
- package/lib/run/standalonegateway/list.js +3 -12
- package/lib/run/standalonegateway/package/list.js +3 -12
- package/lib/run/standalonegateway/turn/off.js +3 -12
- package/lib/run/standalonegateway/turn/on.js +3 -12
- package/lib/run/version/create.js +41 -31
- package/lib/run/version/delete.js +3 -12
- package/lib/run/version/list.js +3 -12
- package/lib/run/version/modify.js +3 -12
- package/lib/run/version/repo.js +6 -15
- package/lib/run/version/update.js +37 -26
- package/lib/storage.js +62 -93
- package/lib/third/index.js +6 -17
- package/lib/utils/ai/banner.js +49 -60
- package/lib/utils/ai/claudeWindows.js +2 -2
- package/lib/utils/ai/config.js +169 -206
- package/lib/utils/ai/ensureFiles.js +6 -17
- package/lib/utils/ai/env.js +16 -27
- package/lib/utils/ai/envLocalManager.js +35 -52
- package/lib/utils/ai/router.js +927 -1005
- package/lib/utils/ai/setup.js +527 -563
- package/lib/utils/auth.js +3 -14
- package/lib/utils/checkTcbrEnv.js +20 -31
- package/lib/utils/cli-table.js +6 -1
- package/lib/utils/config.js +4 -13
- package/lib/utils/dts.js +98 -113
- package/lib/utils/env.js +154 -175
- package/lib/utils/function-packer.js +29 -42
- package/lib/utils/log.js +10 -21
- package/lib/utils/mcp-config-modifier.js +105 -120
- package/lib/utils/net/cloud-api-request.js +15 -23
- package/lib/utils/net/credential.js +26 -39
- package/lib/utils/net/http-request.js +63 -80
- package/lib/utils/net/manager-service.js +22 -35
- package/lib/utils/notice.js +16 -27
- package/lib/utils/output/loading.js +3 -12
- package/lib/utils/parallel.js +32 -43
- package/lib/utils/platform/mac.js +4 -15
- package/lib/utils/platform/port.js +4 -15
- package/lib/utils/prompt/select.js +6 -15
- package/lib/utils/report.js +28 -33
- package/lib/utils/reporter/agree.js +11 -22
- package/lib/utils/reporter/download.js +17 -28
- package/lib/utils/reporter/usage.js +12 -23
- package/lib/utils/store/auth.js +17 -30
- package/lib/utils/store/config.js +11 -25
- package/lib/utils/store/db.js +17 -36
- package/lib/utils/tcbrApi/callTcbrApi.js +19 -28
- package/lib/utils/template-manager.js +215 -242
- package/lib/utils/template.js +81 -96
- package/lib/utils/tools/common.js +45 -56
- package/lib/utils/tools/time.js +5 -16
- package/lib/utils/url.js +10 -4
- package/package.json +2 -2
- package/specs/ag-command/design.md +421 -0
- package/specs/ag-command/doc.md +204 -0
- package/specs/ag-command/requirements.md +173 -0
- package/specs/ag-command/summary.md +174 -0
- package/specs/ag-command/tasks.md +197 -0
- package/specs/ag-command/usage-guide.md +420 -0
- package/tsconfig.json +1 -1
- package/types/commands/ag/base.d.ts +44 -0
- package/types/commands/ag/create.d.ts +25 -0
- package/types/commands/ag/delete.d.ts +32 -0
- package/types/commands/ag/deploy.d.ts +31 -0
- package/types/commands/ag/detail.d.ts +28 -0
- package/types/commands/ag/index.d.ts +6 -0
- package/types/commands/ag/list.d.ts +35 -0
- package/types/commands/ag/run.d.ts +52 -0
- package/types/commands/cloudrun/base.d.ts +10 -0
- package/types/commands/index.d.ts +1 -0
package/lib/function/trigger.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.batchDeleteTriggers = exports.deleteFunctionTrigger = exports.batchCreateTriggers = exports.createFunctionTriggers = void 0;
|
|
13
4
|
const utils_1 = require("../utils");
|
|
@@ -15,92 +6,84 @@ const logger_1 = require("../logger");
|
|
|
15
6
|
const error_1 = require("../error");
|
|
16
7
|
const i18n_1 = require("../i18n");
|
|
17
8
|
const scfService = utils_1.CloudApiService.getInstance('scf');
|
|
18
|
-
function createFunctionTriggers(options) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
9
|
+
async function createFunctionTriggers(options) {
|
|
10
|
+
const { functionName, triggers = [], envId } = options;
|
|
11
|
+
const parsedTriggers = triggers.map(item => {
|
|
12
|
+
if (item.type !== 'timer') {
|
|
13
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('不支持的触发器类型 [{{type}}],目前仅支持定时触发器(timer)!', { type: item.type }));
|
|
14
|
+
}
|
|
15
|
+
return {
|
|
16
|
+
TriggerName: item.name,
|
|
17
|
+
Type: item.type,
|
|
18
|
+
TriggerDesc: item.config
|
|
19
|
+
};
|
|
20
|
+
});
|
|
21
|
+
try {
|
|
22
|
+
await scfService.request('BatchCreateTrigger', {
|
|
23
|
+
FunctionName: functionName,
|
|
24
|
+
Namespace: envId,
|
|
25
|
+
Triggers: JSON.stringify(parsedTriggers),
|
|
26
|
+
Count: parsedTriggers.length
|
|
30
27
|
});
|
|
28
|
+
}
|
|
29
|
+
catch (e) {
|
|
30
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('[{{name}}] 创建触发器失败:{{error}}', { name: functionName, error: e.message }), {
|
|
31
|
+
action: e.action,
|
|
32
|
+
code: e.code
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.createFunctionTriggers = createFunctionTriggers;
|
|
37
|
+
async function batchCreateTriggers(options) {
|
|
38
|
+
const { functions, envId } = options;
|
|
39
|
+
const promises = functions.map(func => (async () => {
|
|
31
40
|
try {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
Count: parsedTriggers.length
|
|
41
|
+
await createFunctionTriggers({
|
|
42
|
+
functionName: func.name,
|
|
43
|
+
triggers: func.triggers,
|
|
44
|
+
envId
|
|
37
45
|
});
|
|
46
|
+
(0, logger_1.successLog)((0, i18n_1.t)('[{{name}}] 创建云函数触发器成功!', { name: func.name }));
|
|
38
47
|
}
|
|
39
48
|
catch (e) {
|
|
40
|
-
throw new error_1.CloudBaseError(
|
|
41
|
-
action: e.action,
|
|
42
|
-
code: e.code
|
|
43
|
-
});
|
|
49
|
+
throw new error_1.CloudBaseError(e.message);
|
|
44
50
|
}
|
|
45
|
-
});
|
|
51
|
+
})());
|
|
52
|
+
await Promise.all(promises);
|
|
46
53
|
}
|
|
47
|
-
exports.
|
|
48
|
-
function
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
+
exports.batchCreateTriggers = batchCreateTriggers;
|
|
55
|
+
async function deleteFunctionTrigger(options) {
|
|
56
|
+
const { functionName, triggerName, envId } = options;
|
|
57
|
+
try {
|
|
58
|
+
await scfService.request('DeleteTrigger', {
|
|
59
|
+
FunctionName: functionName,
|
|
60
|
+
Namespace: envId,
|
|
61
|
+
TriggerName: triggerName,
|
|
62
|
+
Type: 'timer'
|
|
63
|
+
});
|
|
64
|
+
(0, logger_1.successLog)((0, i18n_1.t)('[{{name}}] 删除云函数触发器 {{trigger}} 成功!', { name: functionName, trigger: triggerName }));
|
|
65
|
+
}
|
|
66
|
+
catch (e) {
|
|
67
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('[{{name}}] 删除触发器失败:{{error}}', { name: functionName, error: e.message }));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.deleteFunctionTrigger = deleteFunctionTrigger;
|
|
71
|
+
async function batchDeleteTriggers(options) {
|
|
72
|
+
const { functions, envId } = options;
|
|
73
|
+
const promises = functions.map(func => (async () => {
|
|
74
|
+
try {
|
|
75
|
+
func.triggers.forEach(async (trigger) => {
|
|
76
|
+
await deleteFunctionTrigger({
|
|
54
77
|
functionName: func.name,
|
|
55
|
-
|
|
78
|
+
triggerName: trigger.name,
|
|
56
79
|
envId
|
|
57
80
|
});
|
|
58
|
-
(0, logger_1.successLog)((0, i18n_1.t)('[{{name}}] 创建云函数触发器成功!', { name: func.name }));
|
|
59
|
-
}
|
|
60
|
-
catch (e) {
|
|
61
|
-
throw new error_1.CloudBaseError(e.message);
|
|
62
|
-
}
|
|
63
|
-
}))());
|
|
64
|
-
yield Promise.all(promises);
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
exports.batchCreateTriggers = batchCreateTriggers;
|
|
68
|
-
function deleteFunctionTrigger(options) {
|
|
69
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
-
const { functionName, triggerName, envId } = options;
|
|
71
|
-
try {
|
|
72
|
-
yield scfService.request('DeleteTrigger', {
|
|
73
|
-
FunctionName: functionName,
|
|
74
|
-
Namespace: envId,
|
|
75
|
-
TriggerName: triggerName,
|
|
76
|
-
Type: 'timer'
|
|
77
81
|
});
|
|
78
|
-
(0, logger_1.successLog)((0, i18n_1.t)('[{{name}}] 删除云函数触发器 {{trigger}} 成功!', { name: functionName, trigger: triggerName }));
|
|
79
82
|
}
|
|
80
83
|
catch (e) {
|
|
81
|
-
throw new error_1.CloudBaseError(
|
|
84
|
+
throw new error_1.CloudBaseError(e.message);
|
|
82
85
|
}
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
exports.deleteFunctionTrigger = deleteFunctionTrigger;
|
|
86
|
-
function batchDeleteTriggers(options) {
|
|
87
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
88
|
-
const { functions, envId } = options;
|
|
89
|
-
const promises = functions.map(func => (() => __awaiter(this, void 0, void 0, function* () {
|
|
90
|
-
try {
|
|
91
|
-
func.triggers.forEach((trigger) => __awaiter(this, void 0, void 0, function* () {
|
|
92
|
-
yield deleteFunctionTrigger({
|
|
93
|
-
functionName: func.name,
|
|
94
|
-
triggerName: trigger.name,
|
|
95
|
-
envId
|
|
96
|
-
});
|
|
97
|
-
}));
|
|
98
|
-
}
|
|
99
|
-
catch (e) {
|
|
100
|
-
throw new error_1.CloudBaseError(e.message);
|
|
101
|
-
}
|
|
102
|
-
}))());
|
|
103
|
-
yield Promise.all(promises);
|
|
104
|
-
});
|
|
86
|
+
})());
|
|
87
|
+
await Promise.all(promises);
|
|
105
88
|
}
|
|
106
89
|
exports.batchDeleteTriggers = batchDeleteTriggers;
|
package/lib/function/update.js
CHANGED
|
@@ -1,41 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.updateFunctionCode = void 0;
|
|
13
4
|
const error_1 = require("../error");
|
|
14
5
|
const base_1 = require("./base");
|
|
15
6
|
const i18n_1 = require("../i18n");
|
|
16
|
-
function updateFunctionCode(options) {
|
|
7
|
+
async function updateFunctionCode(options) {
|
|
17
8
|
var _a;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
9
|
+
const { functionRootPath = '', envId, base64Code = '', codeSecret } = options;
|
|
10
|
+
const func = {
|
|
11
|
+
...(_a = options === null || options === void 0 ? void 0 : options.func) === null || _a === void 0 ? void 0 : _a.config,
|
|
12
|
+
...options.func
|
|
13
|
+
};
|
|
14
|
+
const funcName = func.name;
|
|
15
|
+
if (codeSecret && !/^[A-Za-z0-9+=/]{1,160}$/.test(codeSecret)) {
|
|
16
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('CodeSecret 格式错误,格式为 1-160 位大小字母,数字+=/'));
|
|
17
|
+
}
|
|
18
|
+
const scfService = await (0, base_1.getFunctionService)(envId);
|
|
19
|
+
try {
|
|
20
|
+
await scfService.updateFunctionCode({
|
|
21
|
+
func,
|
|
22
|
+
functionRootPath,
|
|
23
|
+
base64Code,
|
|
24
|
+
codeSecret
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
catch (e) {
|
|
28
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('[{{name}}] 函数代码更新失败: {{error}}', { name: funcName, error: e.message }), {
|
|
29
|
+
code: e.code
|
|
30
|
+
});
|
|
31
|
+
}
|
|
40
32
|
}
|
|
41
33
|
exports.updateFunctionCode = updateFunctionCode;
|
package/lib/function/version.js
CHANGED
|
@@ -1,52 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.listFunctionVersions = exports.publishVersion = void 0;
|
|
13
4
|
const error_1 = require("../error");
|
|
14
5
|
const base_1 = require("./base");
|
|
15
6
|
const i18n_1 = require("../i18n");
|
|
16
|
-
function publishVersion(options) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
});
|
|
7
|
+
async function publishVersion(options) {
|
|
8
|
+
const { envId, functionName, description = '' } = options;
|
|
9
|
+
const scfService = await (0, base_1.getFunctionService)(envId);
|
|
10
|
+
try {
|
|
11
|
+
await scfService.publishVersion({
|
|
12
|
+
functionName,
|
|
13
|
+
description
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
catch (e) {
|
|
17
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('[{{name}}] 函数发布新版本失败: {{error}}', { name: functionName, error: e.message }), {
|
|
18
|
+
code: e.code
|
|
19
|
+
});
|
|
20
|
+
}
|
|
32
21
|
}
|
|
33
22
|
exports.publishVersion = publishVersion;
|
|
34
|
-
function listFunctionVersions(options) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
});
|
|
23
|
+
async function listFunctionVersions(options) {
|
|
24
|
+
const { envId, functionName, offset = 0, limit = 20 } = options;
|
|
25
|
+
const scfService = await (0, base_1.getFunctionService)(envId);
|
|
26
|
+
try {
|
|
27
|
+
return scfService.listVersionByFunction({
|
|
28
|
+
functionName,
|
|
29
|
+
offset,
|
|
30
|
+
limit
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
catch (e) {
|
|
34
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('[{{name}}] 查看函数版本列表失败: {{error}}', { name: functionName, error: e.message }), {
|
|
35
|
+
code: e.code
|
|
36
|
+
});
|
|
37
|
+
}
|
|
51
38
|
}
|
|
52
39
|
exports.listFunctionVersions = listFunctionVersions;
|
package/lib/function/vpc.js
CHANGED
|
@@ -1,35 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.getSubnets = exports.getVpcs = void 0;
|
|
13
4
|
const utils_1 = require("../utils");
|
|
14
5
|
const vpcService = utils_1.CloudApiService.getInstance('vpc');
|
|
15
|
-
function getVpcs() {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return VpcSet;
|
|
19
|
-
});
|
|
6
|
+
async function getVpcs() {
|
|
7
|
+
const { VpcSet } = await vpcService.request('DescribeVpcs');
|
|
8
|
+
return VpcSet;
|
|
20
9
|
}
|
|
21
10
|
exports.getVpcs = getVpcs;
|
|
22
|
-
function getSubnets(vpcId) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
]
|
|
31
|
-
});
|
|
32
|
-
return SubnetSet;
|
|
11
|
+
async function getSubnets(vpcId) {
|
|
12
|
+
const { SubnetSet } = await vpcService.request('DescribeSubnets', {
|
|
13
|
+
Filters: [
|
|
14
|
+
{
|
|
15
|
+
Name: 'vpc-id',
|
|
16
|
+
Values: [vpcId]
|
|
17
|
+
}
|
|
18
|
+
]
|
|
33
19
|
});
|
|
20
|
+
return SubnetSet;
|
|
34
21
|
}
|
|
35
22
|
exports.getSubnets = getSubnets;
|
package/lib/gateway/index.js
CHANGED
|
@@ -1,136 +1,109 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.unbindGatewayDomain = exports.queryGatewayDomain = exports.bindGatewayDomain = exports.deleteGateway = exports.queryGateway = exports.createGateway = exports.getHttpServicePrivilege = exports.switchHttpServiceAuth = exports.switchHttpService = void 0;
|
|
13
4
|
const utils_1 = require("../utils");
|
|
14
5
|
const tcbService = utils_1.CloudApiService.getInstance('tcb');
|
|
15
|
-
function switchHttpService(options) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
]
|
|
28
|
-
});
|
|
29
|
-
return res;
|
|
6
|
+
async function switchHttpService(options) {
|
|
7
|
+
const { envId, enable } = options;
|
|
8
|
+
const value = enable ? 'true' : 'false';
|
|
9
|
+
const res = await tcbService.request('ModifyCloudBaseGWPrivilege', {
|
|
10
|
+
ServiceId: envId,
|
|
11
|
+
EnableService: enable,
|
|
12
|
+
Options: [
|
|
13
|
+
{
|
|
14
|
+
Key: 'serviceswitch',
|
|
15
|
+
Value: value
|
|
16
|
+
}
|
|
17
|
+
]
|
|
30
18
|
});
|
|
19
|
+
return res;
|
|
31
20
|
}
|
|
32
21
|
exports.switchHttpService = switchHttpService;
|
|
33
|
-
function switchHttpServiceAuth(options) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
]
|
|
46
|
-
});
|
|
47
|
-
return res;
|
|
22
|
+
async function switchHttpServiceAuth(options) {
|
|
23
|
+
const { envId, enable } = options;
|
|
24
|
+
const value = enable ? 'true' : 'false';
|
|
25
|
+
const res = await tcbService.request('ModifyCloudBaseGWPrivilege', {
|
|
26
|
+
ServiceId: envId,
|
|
27
|
+
EnableService: enable,
|
|
28
|
+
Options: [
|
|
29
|
+
{
|
|
30
|
+
Key: 'authswitch',
|
|
31
|
+
Value: value
|
|
32
|
+
}
|
|
33
|
+
]
|
|
48
34
|
});
|
|
35
|
+
return res;
|
|
49
36
|
}
|
|
50
37
|
exports.switchHttpServiceAuth = switchHttpServiceAuth;
|
|
51
|
-
function getHttpServicePrivilege(options) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
ServiceId: envId
|
|
56
|
-
});
|
|
38
|
+
async function getHttpServicePrivilege(options) {
|
|
39
|
+
const { envId } = options;
|
|
40
|
+
return tcbService.request('DescribeCloudBaseGWPrivilege', {
|
|
41
|
+
ServiceId: envId
|
|
57
42
|
});
|
|
58
43
|
}
|
|
59
44
|
exports.getHttpServicePrivilege = getHttpServicePrivilege;
|
|
60
|
-
function createGateway(options) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
EnableUnion: true
|
|
69
|
-
});
|
|
70
|
-
return res;
|
|
45
|
+
async function createGateway(options) {
|
|
46
|
+
const { envId, path, name } = options;
|
|
47
|
+
const res = await tcbService.request('CreateCloudBaseGWAPI', {
|
|
48
|
+
Type: 1,
|
|
49
|
+
Path: path,
|
|
50
|
+
Name: name,
|
|
51
|
+
ServiceId: envId,
|
|
52
|
+
EnableUnion: true
|
|
71
53
|
});
|
|
54
|
+
return res;
|
|
72
55
|
}
|
|
73
56
|
exports.createGateway = createGateway;
|
|
74
|
-
function queryGateway(options) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
EnableUnion: true
|
|
84
|
-
});
|
|
85
|
-
return res;
|
|
57
|
+
async function queryGateway(options) {
|
|
58
|
+
const { envId, domain, path, gatewayId, name } = options;
|
|
59
|
+
const res = await tcbService.request('DescribeCloudBaseGWAPI', {
|
|
60
|
+
ServiceId: envId,
|
|
61
|
+
Domain: domain,
|
|
62
|
+
Path: path,
|
|
63
|
+
APIId: gatewayId,
|
|
64
|
+
Name: name,
|
|
65
|
+
EnableUnion: true
|
|
86
66
|
});
|
|
67
|
+
return res;
|
|
87
68
|
}
|
|
88
69
|
exports.queryGateway = queryGateway;
|
|
89
|
-
function deleteGateway(options) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
Name: name
|
|
98
|
-
});
|
|
99
|
-
return res;
|
|
70
|
+
async function deleteGateway(options) {
|
|
71
|
+
const { envId, path, name, gatewayId } = options;
|
|
72
|
+
const res = await tcbService.request('DeleteCloudBaseGWAPI', {
|
|
73
|
+
ServiceId: envId,
|
|
74
|
+
Path: path,
|
|
75
|
+
APIId: gatewayId,
|
|
76
|
+
Type: 1,
|
|
77
|
+
Name: name
|
|
100
78
|
});
|
|
79
|
+
return res;
|
|
101
80
|
}
|
|
102
81
|
exports.deleteGateway = deleteGateway;
|
|
103
|
-
function bindGatewayDomain(options) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
Domain: domain
|
|
109
|
-
});
|
|
110
|
-
return res;
|
|
82
|
+
async function bindGatewayDomain(options) {
|
|
83
|
+
const { envId, domain } = options;
|
|
84
|
+
const res = await tcbService.request('BindCloudBaseAccessDomain', {
|
|
85
|
+
ServiceId: envId,
|
|
86
|
+
Domain: domain
|
|
111
87
|
});
|
|
88
|
+
return res;
|
|
112
89
|
}
|
|
113
90
|
exports.bindGatewayDomain = bindGatewayDomain;
|
|
114
|
-
function queryGatewayDomain(options) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
EnableUnion: true
|
|
121
|
-
});
|
|
122
|
-
return res;
|
|
91
|
+
async function queryGatewayDomain(options) {
|
|
92
|
+
const { envId, domain } = options;
|
|
93
|
+
const res = await tcbService.request('DescribeCloudBaseGWService', {
|
|
94
|
+
ServiceId: envId,
|
|
95
|
+
Domain: domain,
|
|
96
|
+
EnableUnion: true
|
|
123
97
|
});
|
|
98
|
+
return res;
|
|
124
99
|
}
|
|
125
100
|
exports.queryGatewayDomain = queryGatewayDomain;
|
|
126
|
-
function unbindGatewayDomain(options) {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
Domain: domain
|
|
132
|
-
});
|
|
133
|
-
return res;
|
|
101
|
+
async function unbindGatewayDomain(options) {
|
|
102
|
+
const { envId, domain } = options;
|
|
103
|
+
const res = await tcbService.request('DeleteCloudBaseGWDomain', {
|
|
104
|
+
ServiceId: envId,
|
|
105
|
+
Domain: domain
|
|
134
106
|
});
|
|
107
|
+
return res;
|
|
135
108
|
}
|
|
136
109
|
exports.unbindGatewayDomain = unbindGatewayDomain;
|