@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/commands/utils.js
CHANGED
|
@@ -1,24 +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
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
-
var t = {};
|
|
13
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
-
t[p] = s[p];
|
|
15
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
-
t[p[i]] = s[p[i]];
|
|
19
|
-
}
|
|
20
|
-
return t;
|
|
21
|
-
};
|
|
22
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
4
|
};
|
|
@@ -35,60 +15,54 @@ const env_1 = require("../env");
|
|
|
35
15
|
const utils_1 = require("../utils");
|
|
36
16
|
const constants_1 = require("./constants");
|
|
37
17
|
const i18n_1 = require("../i18n");
|
|
38
|
-
function selectEnv(options = {}) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
loading.stop();
|
|
45
|
-
});
|
|
46
|
-
const choices = (0, lodash_1.sortBy)(data, ['Alias']).map((item) => {
|
|
47
|
-
return {
|
|
48
|
-
name: `${item.Alias || item.EnvId} (${item.EnvId}) ${item.Status === constants_1.EnvStatus.NORMAL ? (0, i18n_1.t)('正常') : (0, i18n_1.t)('不可用')}`,
|
|
49
|
-
value: item.EnvId
|
|
50
|
-
};
|
|
51
|
-
});
|
|
52
|
-
const questions = [
|
|
53
|
-
{
|
|
54
|
-
type: 'list',
|
|
55
|
-
name: 'env',
|
|
56
|
-
message: (0, i18n_1.t)('请选择环境'),
|
|
57
|
-
choices: choices
|
|
58
|
-
}
|
|
59
|
-
];
|
|
60
|
-
const answers = yield inquirer_1.default.prompt(questions);
|
|
61
|
-
return answers['env'];
|
|
18
|
+
async function selectEnv(options = {}) {
|
|
19
|
+
const loading = (0, utils_1.loadingFactory)();
|
|
20
|
+
const { source = [] } = options;
|
|
21
|
+
loading.start((0, i18n_1.t)('获取环境列表中...'));
|
|
22
|
+
let data = await (0, env_1.listEnvs)({ source }).finally(() => {
|
|
23
|
+
loading.stop();
|
|
62
24
|
});
|
|
63
|
-
|
|
64
|
-
exports.selectEnv = selectEnv;
|
|
65
|
-
function getPackageJsonName(pkgPath) {
|
|
66
|
-
var _a;
|
|
67
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
-
const pkg = yield (0, fs_1.safeReadJSON)(pkgPath);
|
|
69
|
-
const parts = ((_a = pkg.name) === null || _a === void 0 ? void 0 : _a.split('/')) || [];
|
|
70
|
-
const pkgName = parts.length > 1 ? parts[parts.length - 1] : parts[0];
|
|
25
|
+
const choices = (0, lodash_1.sortBy)(data, ['Alias']).map((item) => {
|
|
71
26
|
return {
|
|
72
|
-
|
|
73
|
-
|
|
27
|
+
name: `${item.Alias || item.EnvId} (${item.EnvId}) ${item.Status === constants_1.EnvStatus.NORMAL ? (0, i18n_1.t)('正常') : (0, i18n_1.t)('不可用')}`,
|
|
28
|
+
value: item.EnvId
|
|
74
29
|
};
|
|
75
30
|
});
|
|
31
|
+
const questions = [
|
|
32
|
+
{
|
|
33
|
+
type: 'list',
|
|
34
|
+
name: 'env',
|
|
35
|
+
message: (0, i18n_1.t)('请选择环境'),
|
|
36
|
+
choices: choices
|
|
37
|
+
}
|
|
38
|
+
];
|
|
39
|
+
const answers = await inquirer_1.default.prompt(questions);
|
|
40
|
+
return answers['env'];
|
|
41
|
+
}
|
|
42
|
+
exports.selectEnv = selectEnv;
|
|
43
|
+
async function getPackageJsonName(pkgPath) {
|
|
44
|
+
var _a;
|
|
45
|
+
const pkg = await (0, fs_1.safeReadJSON)(pkgPath);
|
|
46
|
+
const parts = ((_a = pkg.name) === null || _a === void 0 ? void 0 : _a.split('/')) || [];
|
|
47
|
+
const pkgName = parts.length > 1 ? parts[parts.length - 1] : parts[0];
|
|
48
|
+
return {
|
|
49
|
+
fullName: pkg.name,
|
|
50
|
+
shortName: pkgName
|
|
51
|
+
};
|
|
76
52
|
}
|
|
77
53
|
exports.getPackageJsonName = getPackageJsonName;
|
|
78
|
-
function isDirectoryEmptyOrNotExists(dirPath) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
if (!exists) {
|
|
83
|
-
return true;
|
|
84
|
-
}
|
|
85
|
-
const files = yield (0, fs_extra_1.readdir)(dirPath);
|
|
86
|
-
return files.length === 0;
|
|
87
|
-
}
|
|
88
|
-
catch (error) {
|
|
54
|
+
async function isDirectoryEmptyOrNotExists(dirPath) {
|
|
55
|
+
try {
|
|
56
|
+
const exists = await (0, fs_extra_1.pathExists)(dirPath);
|
|
57
|
+
if (!exists) {
|
|
89
58
|
return true;
|
|
90
59
|
}
|
|
91
|
-
|
|
60
|
+
const files = await (0, fs_extra_1.readdir)(dirPath);
|
|
61
|
+
return files.length === 0;
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
92
66
|
}
|
|
93
67
|
exports.isDirectoryEmptyOrNotExists = isDirectoryEmptyOrNotExists;
|
|
94
68
|
function trackCallback(message, log) {
|
|
@@ -100,98 +74,94 @@ function trackCallback(message, log) {
|
|
|
100
74
|
}
|
|
101
75
|
}
|
|
102
76
|
exports.trackCallback = trackCallback;
|
|
103
|
-
function getCredential(ctx, options) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
return credential;
|
|
115
|
-
});
|
|
77
|
+
async function getCredential(ctx, options) {
|
|
78
|
+
let credential;
|
|
79
|
+
if (ctx.hasPrivateSettings) {
|
|
80
|
+
process.env.IS_PRIVATE = 'true';
|
|
81
|
+
const privateSettings = (0, utils_1.getPrivateSettings)(ctx.config, options.cmd);
|
|
82
|
+
credential = privateSettings === null || privateSettings === void 0 ? void 0 : privateSettings.credential;
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
credential = await utils_1.authSupevisor.getLoginState();
|
|
86
|
+
}
|
|
87
|
+
return credential;
|
|
116
88
|
}
|
|
117
89
|
exports.getCredential = getCredential;
|
|
118
|
-
function fetchAccessToken(params) {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
return result === null || result === void 0 ? void 0 : result.access_token;
|
|
122
|
-
});
|
|
90
|
+
async function fetchAccessToken(params) {
|
|
91
|
+
const result = await rawFetchAccessToken(params);
|
|
92
|
+
return result === null || result === void 0 ? void 0 : result.access_token;
|
|
123
93
|
}
|
|
124
94
|
exports.fetchAccessToken = fetchAccessToken;
|
|
125
|
-
function rawFetchAccessToken(params) {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
}
|
|
155
|
-
|
|
95
|
+
async function rawFetchAccessToken(params) {
|
|
96
|
+
const { envId, secretId, secretKey, token } = params;
|
|
97
|
+
const domain = `${envId}.${utils_1.EDomain.Gateway}`;
|
|
98
|
+
const url = `https://${domain}/auth/v1/token/clientCredential`;
|
|
99
|
+
const method = 'POST';
|
|
100
|
+
const body = {
|
|
101
|
+
grant_type: 'client_credentials'
|
|
102
|
+
};
|
|
103
|
+
const now = Date.now();
|
|
104
|
+
const requiredHeaders = {
|
|
105
|
+
Host: domain,
|
|
106
|
+
'Content-Type': 'application/json'
|
|
107
|
+
};
|
|
108
|
+
const { authorization, timestamp } = (0, signature_nodejs_1.sign)({
|
|
109
|
+
secretId,
|
|
110
|
+
secretKey,
|
|
111
|
+
method,
|
|
112
|
+
url,
|
|
113
|
+
params: body,
|
|
114
|
+
headers: requiredHeaders,
|
|
115
|
+
timestamp: Math.floor(now / 1000) - 1,
|
|
116
|
+
withSignedParams: false,
|
|
117
|
+
isCloudApi: true
|
|
118
|
+
});
|
|
119
|
+
const tokenResponse = await (0, node_fetch_1.default)(url, {
|
|
120
|
+
method,
|
|
121
|
+
headers: {
|
|
122
|
+
...requiredHeaders,
|
|
123
|
+
Authorization: `${authorization}, Timestamp=${timestamp}, Token=${token}`
|
|
124
|
+
},
|
|
125
|
+
body: JSON.stringify(body)
|
|
156
126
|
});
|
|
127
|
+
return tokenResponse.json();
|
|
157
128
|
}
|
|
158
129
|
exports.rawFetchAccessToken = rawFetchAccessToken;
|
|
159
|
-
function upsertCloudbaserc(projectPath, inputData) {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
const mergedConfig = (0, lodash_1.merge)(existingConfig, inputData);
|
|
177
|
-
yield (0, fs_extra_1.writeJson)(configPath, mergedConfig, { spaces: 2 });
|
|
178
|
-
}
|
|
179
|
-
catch (error) {
|
|
180
|
-
throw new Error((0, i18n_1.t)('更新 cloudbaserc.json 失败: {{error}}', {
|
|
181
|
-
error: error instanceof Error ? error.message : String(error)
|
|
182
|
-
}));
|
|
130
|
+
async function upsertCloudbaserc(projectPath, inputData) {
|
|
131
|
+
const { envId, ...rest } = inputData;
|
|
132
|
+
const configPath = path_1.default.resolve(projectPath, 'cloudbaserc.json');
|
|
133
|
+
const defaultConfig = {
|
|
134
|
+
version: '2.0',
|
|
135
|
+
envId: envId || '{{envId}}',
|
|
136
|
+
$schema: 'https://framework-1258016615.tcloudbaseapp.com/schema/latest.json'
|
|
137
|
+
};
|
|
138
|
+
try {
|
|
139
|
+
const fileExists = await (0, fs_extra_1.pathExists)(configPath);
|
|
140
|
+
if (!fileExists) {
|
|
141
|
+
const initialConfig = {
|
|
142
|
+
...defaultConfig,
|
|
143
|
+
...rest
|
|
144
|
+
};
|
|
145
|
+
await (0, fs_extra_1.writeJson)(configPath, initialConfig, { spaces: 2 });
|
|
146
|
+
return;
|
|
183
147
|
}
|
|
184
|
-
|
|
148
|
+
const existingConfig = await (0, fs_extra_1.readJson)(configPath);
|
|
149
|
+
const mergedConfig = (0, lodash_1.merge)(existingConfig, inputData);
|
|
150
|
+
await (0, fs_extra_1.writeJson)(configPath, mergedConfig, { spaces: 2 });
|
|
151
|
+
}
|
|
152
|
+
catch (error) {
|
|
153
|
+
throw new Error((0, i18n_1.t)('更新 cloudbaserc.json 失败: {{error}}', {
|
|
154
|
+
error: error instanceof Error ? error.message : String(error)
|
|
155
|
+
}));
|
|
156
|
+
}
|
|
185
157
|
}
|
|
186
158
|
exports.upsertCloudbaserc = upsertCloudbaserc;
|
|
187
|
-
function getCloudbaserc(projectPath) {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
}
|
|
195
|
-
});
|
|
159
|
+
async function getCloudbaserc(projectPath) {
|
|
160
|
+
try {
|
|
161
|
+
return await (0, utils_1.getCloudBaseConfig)(path_1.default.resolve(projectPath, 'cloudbaserc.json'));
|
|
162
|
+
}
|
|
163
|
+
catch (e) {
|
|
164
|
+
return {};
|
|
165
|
+
}
|
|
196
166
|
}
|
|
197
167
|
exports.getCloudbaserc = getCloudbaserc;
|
package/lib/db/index.js
CHANGED
|
@@ -1,85 +1,66 @@
|
|
|
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.publishModel = exports.getModel = exports.updateModel = exports.createModel = exports.listModels = void 0;
|
|
13
4
|
const net_1 = require("../utils/net");
|
|
14
5
|
const lowCodeService = new net_1.CloudApiService('lowcode', {}, '2021-01-08');
|
|
15
|
-
function listModels(options = {}) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
QueryDataSourceRelationList: true
|
|
26
|
-
});
|
|
27
|
-
const rows = datasourceList.Data.Rows;
|
|
28
|
-
return rows;
|
|
6
|
+
async function listModels(options = {}) {
|
|
7
|
+
const { envId } = options;
|
|
8
|
+
const datasourceList = await lowCodeService.request('DescribeDataSourceList', {
|
|
9
|
+
EnvId: envId,
|
|
10
|
+
PageIndex: 1,
|
|
11
|
+
PageSize: 1000,
|
|
12
|
+
DataSourceNames: options.name,
|
|
13
|
+
QuerySystemModel: true,
|
|
14
|
+
QueryConnector: 0,
|
|
15
|
+
QueryDataSourceRelationList: true
|
|
29
16
|
});
|
|
17
|
+
const rows = datasourceList.Data.Rows;
|
|
18
|
+
return rows;
|
|
30
19
|
}
|
|
31
20
|
exports.listModels = listModels;
|
|
32
|
-
function createModel({ envId, name, title, schema }) {
|
|
33
|
-
return
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
})).Data);
|
|
42
|
-
});
|
|
21
|
+
async function createModel({ envId, name, title, schema }) {
|
|
22
|
+
return ((await lowCodeService.request('CreateDataSourceDetail', {
|
|
23
|
+
EnvId: envId,
|
|
24
|
+
Title: title,
|
|
25
|
+
Name: name,
|
|
26
|
+
Type: 'database',
|
|
27
|
+
TableNameRule: "only_name",
|
|
28
|
+
Schema: JSON.stringify(schema)
|
|
29
|
+
})).Data);
|
|
43
30
|
}
|
|
44
31
|
exports.createModel = createModel;
|
|
45
|
-
function updateModel({ envId, id, title, schema }) {
|
|
46
|
-
return
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
})).Data);
|
|
53
|
-
});
|
|
32
|
+
async function updateModel({ envId, id, title, schema }) {
|
|
33
|
+
return ((await lowCodeService.request('ModifyDataSource', {
|
|
34
|
+
Id: id,
|
|
35
|
+
EnvId: envId,
|
|
36
|
+
Title: title,
|
|
37
|
+
Schema: JSON.stringify(schema)
|
|
38
|
+
})).Data);
|
|
54
39
|
}
|
|
55
40
|
exports.updateModel = updateModel;
|
|
56
|
-
function getModel(options) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
41
|
+
async function getModel(options) {
|
|
42
|
+
const { envId, name } = options;
|
|
43
|
+
try {
|
|
44
|
+
return (await lowCodeService.request('DescribeDataSource', {
|
|
45
|
+
EnvId: envId,
|
|
46
|
+
Name: name
|
|
47
|
+
})).Data;
|
|
48
|
+
}
|
|
49
|
+
catch (e) {
|
|
50
|
+
if (e.original.Code === 'ResourceNotFound') {
|
|
51
|
+
return null;
|
|
64
52
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
throw e;
|
|
71
|
-
}
|
|
53
|
+
else {
|
|
54
|
+
throw e;
|
|
72
55
|
}
|
|
73
|
-
}
|
|
56
|
+
}
|
|
74
57
|
}
|
|
75
58
|
exports.getModel = getModel;
|
|
76
|
-
function publishModel(options) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
})).Data;
|
|
83
|
-
});
|
|
59
|
+
async function publishModel(options) {
|
|
60
|
+
const { envId, ids } = options;
|
|
61
|
+
return (await lowCodeService.request('BatchPublishDataSources', {
|
|
62
|
+
EnvId: envId,
|
|
63
|
+
DataSourceIds: ids
|
|
64
|
+
})).Data;
|
|
84
65
|
}
|
|
85
66
|
exports.publishModel = publishModel;
|
|
@@ -1,29 +1,18 @@
|
|
|
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.CaptureError = void 0;
|
|
13
4
|
const CaptureError = () => (target, key, descriptor) => {
|
|
14
5
|
const rawFunc = descriptor.value;
|
|
15
|
-
descriptor.value = function (...args) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
});
|
|
6
|
+
descriptor.value = async function (...args) {
|
|
7
|
+
try {
|
|
8
|
+
const res = await rawFunc.apply(this, args);
|
|
9
|
+
return res;
|
|
10
|
+
}
|
|
11
|
+
catch (e) {
|
|
12
|
+
const errMsg = (e === null || e === void 0 ? void 0 : e.message) ||
|
|
13
|
+
(typeof (e === null || e === void 0 ? void 0 : e.toString) === 'function' ? e.toString() : '') ||
|
|
14
|
+
'Unknown Error';
|
|
15
|
+
}
|
|
27
16
|
};
|
|
28
17
|
return descriptor;
|
|
29
18
|
};
|
package/lib/decorators/guard.js
CHANGED
|
@@ -1,34 +1,23 @@
|
|
|
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.AuthGuard = void 0;
|
|
13
4
|
const utils_1 = require("../utils");
|
|
14
5
|
const AuthGuard = (options = {}) => (target, key, descriptor) => {
|
|
15
6
|
const { tips, ensureConfig = true } = options;
|
|
16
7
|
const rawFunc = descriptor.value;
|
|
17
|
-
descriptor.value = function (...args) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
8
|
+
descriptor.value = async function (...args) {
|
|
9
|
+
const credential = target === null || target === void 0 ? void 0 : target.credential;
|
|
10
|
+
const loginState = await utils_1.authSupevisor.getLoginState();
|
|
11
|
+
if (!credential && !loginState) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
if (ensureConfig) {
|
|
15
|
+
const config = await (0, utils_1.getCloudBaseConfig)();
|
|
16
|
+
if (!(config === null || config === void 0 ? void 0 : config.envId)) {
|
|
22
17
|
return;
|
|
23
18
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (!(config === null || config === void 0 ? void 0 : config.envId)) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return rawFunc.apply(this, args);
|
|
31
|
-
});
|
|
19
|
+
}
|
|
20
|
+
return rawFunc.apply(this, args);
|
|
32
21
|
};
|
|
33
22
|
return descriptor;
|
|
34
23
|
};
|
|
@@ -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.InjectParams = void 0;
|
|
13
4
|
const constants_1 = require("./constants");
|
|
@@ -16,40 +7,38 @@ function InjectParams() {
|
|
|
16
7
|
const rawFunc = descriptor.value;
|
|
17
8
|
const paramMetadata = Reflect.getMetadata(constants_1.PARAM_METADATA, target[key]);
|
|
18
9
|
if (paramMetadata) {
|
|
19
|
-
descriptor.value = function (...args) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
args[index] = injectValue;
|
|
47
|
-
}
|
|
10
|
+
descriptor.value = async function (...args) {
|
|
11
|
+
const ctx = args[0] || {};
|
|
12
|
+
for (const paramKey in paramMetadata) {
|
|
13
|
+
if (Object.prototype.hasOwnProperty.call(paramMetadata, paramKey)) {
|
|
14
|
+
const { getter, index } = paramMetadata[paramKey];
|
|
15
|
+
switch (paramKey) {
|
|
16
|
+
case constants_1.ParamTypes.CmdContext:
|
|
17
|
+
args[index] = ctx;
|
|
18
|
+
break;
|
|
19
|
+
case constants_1.ParamTypes.Config:
|
|
20
|
+
args[index] = ctx.config;
|
|
21
|
+
break;
|
|
22
|
+
case constants_1.ParamTypes.ArgsParams:
|
|
23
|
+
args[index] = ctx.params;
|
|
24
|
+
break;
|
|
25
|
+
case constants_1.ParamTypes.ArgsOptions:
|
|
26
|
+
args[index] = ctx.options;
|
|
27
|
+
break;
|
|
28
|
+
case constants_1.ParamTypes.EnvId:
|
|
29
|
+
args[index] = ctx.envId;
|
|
30
|
+
break;
|
|
31
|
+
case constants_1.ParamTypes.IsPrivateEnv:
|
|
32
|
+
args[index] = ctx.hasPrivateSettings;
|
|
33
|
+
break;
|
|
34
|
+
default: {
|
|
35
|
+
const injectValue = await getter(target);
|
|
36
|
+
args[index] = injectValue;
|
|
48
37
|
}
|
|
49
38
|
}
|
|
50
39
|
}
|
|
51
|
-
|
|
52
|
-
|
|
40
|
+
}
|
|
41
|
+
return rawFunc.apply(this, args);
|
|
53
42
|
};
|
|
54
43
|
}
|
|
55
44
|
return descriptor;
|
|
@@ -6,10 +6,13 @@ const createParamDecorator = (paramtype, getter) => {
|
|
|
6
6
|
return () => {
|
|
7
7
|
return (target, key, index) => {
|
|
8
8
|
const data = Reflect.getMetadata(constants_1.PARAM_METADATA, target[key]) || {};
|
|
9
|
-
Reflect.defineMetadata(constants_1.PARAM_METADATA,
|
|
9
|
+
Reflect.defineMetadata(constants_1.PARAM_METADATA, {
|
|
10
|
+
...data,
|
|
11
|
+
[paramtype]: {
|
|
10
12
|
index,
|
|
11
13
|
getter
|
|
12
|
-
}
|
|
14
|
+
}
|
|
15
|
+
}, target[key]);
|
|
13
16
|
};
|
|
14
17
|
};
|
|
15
18
|
};
|