@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.
Files changed (205) hide show
  1. package/lib/auth/login.js +51 -65
  2. package/lib/auth/logout.js +3 -14
  3. package/lib/commands/account/login.js +136 -149
  4. package/lib/commands/account/logout.js +3 -14
  5. package/lib/commands/ag/base.js +203 -0
  6. package/lib/commands/ag/create.js +301 -0
  7. package/lib/commands/ag/debug/index.html +699 -0
  8. package/lib/commands/ag/delete.js +200 -0
  9. package/lib/commands/ag/deploy.js +185 -0
  10. package/lib/commands/ag/detail.js +113 -0
  11. package/lib/commands/ag/index.js +22 -0
  12. package/lib/commands/ag/list.js +155 -0
  13. package/lib/commands/ag/run.js +644 -0
  14. package/lib/commands/ai/index.js +76 -95
  15. package/lib/commands/cloudfunction/base.js +182 -203
  16. package/lib/commands/cloudrun/base.js +578 -603
  17. package/lib/commands/common.js +48 -63
  18. package/lib/commands/config/delete.js +16 -27
  19. package/lib/commands/config/get.js +13 -24
  20. package/lib/commands/config/list.js +16 -27
  21. package/lib/commands/config/set.js +33 -44
  22. package/lib/commands/db/base.js +221 -240
  23. package/lib/commands/env/base.js +36 -49
  24. package/lib/commands/env/domain.js +79 -94
  25. package/lib/commands/env/login.js +120 -135
  26. package/lib/commands/framework/index.js +32 -49
  27. package/lib/commands/fun/base.js +223 -244
  28. package/lib/commands/functions/alias/getRoute.js +33 -44
  29. package/lib/commands/functions/alias/setRoute.js +36 -47
  30. package/lib/commands/functions/code-download.js +43 -54
  31. package/lib/commands/functions/code-update.js +23 -34
  32. package/lib/commands/functions/concurrency/delete.js +11 -22
  33. package/lib/commands/functions/concurrency/list.js +20 -31
  34. package/lib/commands/functions/concurrency/set.js +13 -24
  35. package/lib/commands/functions/config-update.js +30 -41
  36. package/lib/commands/functions/copy.js +12 -23
  37. package/lib/commands/functions/delete.js +30 -41
  38. package/lib/commands/functions/deploy.js +184 -202
  39. package/lib/commands/functions/detail.js +23 -34
  40. package/lib/commands/functions/invoke.js +69 -75
  41. package/lib/commands/functions/layer/bind.js +102 -105
  42. package/lib/commands/functions/layer/create.js +29 -35
  43. package/lib/commands/functions/layer/delete.js +42 -48
  44. package/lib/commands/functions/layer/download.js +52 -58
  45. package/lib/commands/functions/layer/list.js +44 -50
  46. package/lib/commands/functions/layer/sort.js +39 -45
  47. package/lib/commands/functions/list.js +25 -36
  48. package/lib/commands/functions/log.js +65 -73
  49. package/lib/commands/functions/run.js +118 -116
  50. package/lib/commands/functions/trigger-create.js +32 -43
  51. package/lib/commands/functions/trigger-delete.js +50 -61
  52. package/lib/commands/functions/version/list.js +29 -40
  53. package/lib/commands/functions/version/publish.js +11 -22
  54. package/lib/commands/gateway/create.js +50 -61
  55. package/lib/commands/gateway/delete.js +38 -49
  56. package/lib/commands/gateway/domain.js +65 -80
  57. package/lib/commands/gateway/list.js +31 -42
  58. package/lib/commands/gateway/switch.js +48 -61
  59. package/lib/commands/helpers/init.js +226 -249
  60. package/lib/commands/helpers/new.js +35 -46
  61. package/lib/commands/helpers/open.js +22 -33
  62. package/lib/commands/hosting/hosting.js +157 -178
  63. package/lib/commands/index.js +1 -0
  64. package/lib/commands/lowcode/app.js +114 -144
  65. package/lib/commands/lowcode/comps.js +136 -127
  66. package/lib/commands/lowcode/utils.js +11 -22
  67. package/lib/commands/pull/pull.js +33 -46
  68. package/lib/commands/run/delete.js +35 -46
  69. package/lib/commands/run/image/delete.js +32 -39
  70. package/lib/commands/run/image/download.js +26 -33
  71. package/lib/commands/run/image/list.js +41 -48
  72. package/lib/commands/run/image/upload.js +26 -33
  73. package/lib/commands/run/list.js +32 -43
  74. package/lib/commands/run/service/config.js +17 -28
  75. package/lib/commands/run/service/deploy.js +15 -26
  76. package/lib/commands/run/service/list.js +48 -59
  77. package/lib/commands/run/service/update.js +7 -18
  78. package/lib/commands/run/standalonegateway/create.js +35 -42
  79. package/lib/commands/run/standalonegateway/destroy.js +23 -30
  80. package/lib/commands/run/standalonegateway/list.js +19 -26
  81. package/lib/commands/run/standalonegateway/package.js +31 -38
  82. package/lib/commands/run/standalonegateway/turn.js +27 -34
  83. package/lib/commands/run/version/create.js +198 -205
  84. package/lib/commands/run/version/delete.js +31 -38
  85. package/lib/commands/run/version/list.js +42 -49
  86. package/lib/commands/run/version/modify.js +27 -34
  87. package/lib/commands/run/version/update.js +201 -208
  88. package/lib/commands/runf/base.js +216 -237
  89. package/lib/commands/self-update.js +59 -72
  90. package/lib/commands/smart.js +66 -79
  91. package/lib/commands/storage/storage.js +192 -219
  92. package/lib/commands/third/thirdAttach.js +16 -27
  93. package/lib/commands/utils.js +119 -149
  94. package/lib/db/index.js +48 -67
  95. package/lib/decorators/captureError.js +10 -21
  96. package/lib/decorators/guard.js +11 -22
  97. package/lib/decorators/injectParams.js +29 -40
  98. package/lib/decorators/params/common.js +5 -2
  99. package/lib/decorators/params/index.js +3 -12
  100. package/lib/env/domain.js +13 -28
  101. package/lib/env/index.js +25 -44
  102. package/lib/env/login.js +30 -45
  103. package/lib/function/alias.js +31 -44
  104. package/lib/function/base.js +187 -215
  105. package/lib/function/code.js +8 -19
  106. package/lib/function/concurrency.js +43 -58
  107. package/lib/function/create.js +43 -53
  108. package/lib/function/delete.js +22 -35
  109. package/lib/function/layer/attach.js +33 -46
  110. package/lib/function/layer/create.js +34 -45
  111. package/lib/function/layer/delete.js +5 -16
  112. package/lib/function/layer/download.js +11 -22
  113. package/lib/function/layer/list.js +12 -25
  114. package/lib/function/layer/sort.js +6 -17
  115. package/lib/function/trigger.js +65 -82
  116. package/lib/function/update.js +24 -32
  117. package/lib/function/version.js +29 -42
  118. package/lib/function/vpc.js +12 -25
  119. package/lib/gateway/index.js +77 -104
  120. package/lib/hosting.js +157 -188
  121. package/lib/run/delete.js +3 -12
  122. package/lib/run/image/build.js +6 -15
  123. package/lib/run/image/delete.js +3 -12
  124. package/lib/run/image/info.js +3 -12
  125. package/lib/run/image/list.js +6 -15
  126. package/lib/run/list.js +19 -30
  127. package/lib/run/repo.js +6 -15
  128. package/lib/run/service/common.js +160 -173
  129. package/lib/run/service/config.js +44 -57
  130. package/lib/run/service/deployPackage.js +33 -44
  131. package/lib/run/service/list.js +8 -14
  132. package/lib/run/service/showLogs.js +69 -90
  133. package/lib/run/service/update.js +50 -63
  134. package/lib/run/standalonegateway/create.js +3 -12
  135. package/lib/run/standalonegateway/destroy.js +3 -12
  136. package/lib/run/standalonegateway/list.js +3 -12
  137. package/lib/run/standalonegateway/package/list.js +3 -12
  138. package/lib/run/standalonegateway/turn/off.js +3 -12
  139. package/lib/run/standalonegateway/turn/on.js +3 -12
  140. package/lib/run/version/create.js +41 -31
  141. package/lib/run/version/delete.js +3 -12
  142. package/lib/run/version/list.js +3 -12
  143. package/lib/run/version/modify.js +3 -12
  144. package/lib/run/version/repo.js +6 -15
  145. package/lib/run/version/update.js +37 -26
  146. package/lib/storage.js +62 -93
  147. package/lib/third/index.js +6 -17
  148. package/lib/utils/ai/banner.js +49 -60
  149. package/lib/utils/ai/claudeWindows.js +2 -2
  150. package/lib/utils/ai/config.js +169 -206
  151. package/lib/utils/ai/ensureFiles.js +6 -17
  152. package/lib/utils/ai/env.js +16 -27
  153. package/lib/utils/ai/envLocalManager.js +35 -52
  154. package/lib/utils/ai/router.js +927 -1005
  155. package/lib/utils/ai/setup.js +527 -563
  156. package/lib/utils/auth.js +3 -14
  157. package/lib/utils/checkTcbrEnv.js +20 -31
  158. package/lib/utils/cli-table.js +6 -1
  159. package/lib/utils/config.js +4 -13
  160. package/lib/utils/dts.js +98 -113
  161. package/lib/utils/env.js +154 -175
  162. package/lib/utils/function-packer.js +29 -42
  163. package/lib/utils/log.js +10 -21
  164. package/lib/utils/mcp-config-modifier.js +105 -120
  165. package/lib/utils/net/cloud-api-request.js +15 -23
  166. package/lib/utils/net/credential.js +26 -39
  167. package/lib/utils/net/http-request.js +63 -80
  168. package/lib/utils/net/manager-service.js +22 -35
  169. package/lib/utils/notice.js +16 -27
  170. package/lib/utils/output/loading.js +3 -12
  171. package/lib/utils/parallel.js +32 -43
  172. package/lib/utils/platform/mac.js +4 -15
  173. package/lib/utils/platform/port.js +4 -15
  174. package/lib/utils/prompt/select.js +6 -15
  175. package/lib/utils/report.js +28 -33
  176. package/lib/utils/reporter/agree.js +11 -22
  177. package/lib/utils/reporter/download.js +17 -28
  178. package/lib/utils/reporter/usage.js +12 -23
  179. package/lib/utils/store/auth.js +17 -30
  180. package/lib/utils/store/config.js +11 -25
  181. package/lib/utils/store/db.js +17 -36
  182. package/lib/utils/tcbrApi/callTcbrApi.js +19 -28
  183. package/lib/utils/template-manager.js +215 -242
  184. package/lib/utils/template.js +81 -96
  185. package/lib/utils/tools/common.js +45 -56
  186. package/lib/utils/tools/time.js +5 -16
  187. package/lib/utils/url.js +10 -4
  188. package/package.json +2 -2
  189. package/specs/ag-command/design.md +421 -0
  190. package/specs/ag-command/doc.md +204 -0
  191. package/specs/ag-command/requirements.md +173 -0
  192. package/specs/ag-command/summary.md +174 -0
  193. package/specs/ag-command/tasks.md +197 -0
  194. package/specs/ag-command/usage-guide.md +420 -0
  195. package/tsconfig.json +1 -1
  196. package/types/commands/ag/base.d.ts +44 -0
  197. package/types/commands/ag/create.d.ts +25 -0
  198. package/types/commands/ag/delete.d.ts +32 -0
  199. package/types/commands/ag/deploy.d.ts +31 -0
  200. package/types/commands/ag/detail.d.ts +28 -0
  201. package/types/commands/ag/index.d.ts +6 -0
  202. package/types/commands/ag/list.d.ts +35 -0
  203. package/types/commands/ag/run.d.ts +52 -0
  204. package/types/commands/cloudrun/base.d.ts +10 -0
  205. package/types/commands/index.d.ts +1 -0
@@ -34,26 +34,6 @@ var __metadata = (this && this.__metadata) || function (k, v) {
34
34
  var __param = (this && this.__param) || function (paramIndex, decorator) {
35
35
  return function (target, key) { decorator(target, key, paramIndex); }
36
36
  };
37
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
38
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
39
- return new (P || (P = Promise))(function (resolve, reject) {
40
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
41
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
42
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
43
- step((generator = generator.apply(thisArg, _arguments || [])).next());
44
- });
45
- };
46
- var __rest = (this && this.__rest) || function (s, e) {
47
- var t = {};
48
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
49
- t[p] = s[p];
50
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
51
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
52
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
53
- t[p[i]] = s[p[i]];
54
- }
55
- return t;
56
- };
57
37
  var __importDefault = (this && this.__importDefault) || function (mod) {
58
38
  return (mod && mod.__esModule) ? mod : { "default": mod };
59
39
  };
@@ -99,18 +79,16 @@ let LowCodeWatch = class LowCodeWatch extends common_1.Command {
99
79
  requiredEnvId: false
100
80
  };
101
81
  }
102
- execute(ctx, options) {
103
- return __awaiter(this, void 0, void 0, function* () {
104
- const config = (0, utils_1.getCmdConfig)(ctx.config, this.options);
105
- const mergesOptions = (0, utils_1.getMergedOptions)(config, options);
106
- Promise.resolve().then(() => __importStar(require('@cloudbase/lowcode-cli'))).then((res) => __awaiter(this, void 0, void 0, function* () {
107
- yield res.watchApp({
108
- watchPort: 8288,
109
- wxDevtoolPath: options === null || options === void 0 ? void 0 : options.wxDevtoolPath,
110
- forceInstall: options === null || options === void 0 ? void 0 : options.forceInstall,
111
- projectPath: options === null || options === void 0 ? void 0 : options.path
112
- });
113
- }));
82
+ async execute(ctx, options) {
83
+ const config = (0, utils_1.getCmdConfig)(ctx.config, this.options);
84
+ const mergesOptions = (0, utils_1.getMergedOptions)(config, options);
85
+ Promise.resolve().then(() => __importStar(require('@cloudbase/lowcode-cli'))).then(async (res) => {
86
+ await res.watchApp({
87
+ watchPort: 8288,
88
+ wxDevtoolPath: options === null || options === void 0 ? void 0 : options.wxDevtoolPath,
89
+ forceInstall: options === null || options === void 0 ? void 0 : options.forceInstall,
90
+ projectPath: options === null || options === void 0 ? void 0 : options.path
91
+ });
114
92
  });
115
93
  }
116
94
  };
@@ -147,17 +125,15 @@ let LowCodeBuildApp = class LowCodeBuildApp extends common_1.Command {
147
125
  requiredEnvId: false
148
126
  };
149
127
  }
150
- execute(ctx, log, options) {
151
- return __awaiter(this, void 0, void 0, function* () {
152
- const config = (0, utils_1.getCmdConfig)(ctx.config, this.options);
153
- const mergesOptions = (0, utils_1.getMergedOptions)(config, options);
154
- yield lowcodeCli.buildApp({
155
- envId: ctx.envId || ctx.config.envId,
156
- projectPath: process.cwd(),
157
- logger: log,
158
- privateSettings: (0, utils_2.getPrivateSettings)(ctx.config, this.options.cmd)
159
- }, mergesOptions);
160
- });
128
+ async execute(ctx, log, options) {
129
+ const config = (0, utils_1.getCmdConfig)(ctx.config, this.options);
130
+ const mergesOptions = (0, utils_1.getMergedOptions)(config, options);
131
+ await lowcodeCli.buildApp({
132
+ envId: ctx.envId || ctx.config.envId,
133
+ projectPath: process.cwd(),
134
+ logger: log,
135
+ privateSettings: (0, utils_2.getPrivateSettings)(ctx.config, this.options.cmd)
136
+ }, mergesOptions);
161
137
  }
162
138
  };
163
139
  __decorate([
@@ -192,17 +168,15 @@ let LowCodePreviewApp = class LowCodePreviewApp extends common_1.Command {
192
168
  requiredEnvId: false
193
169
  };
194
170
  }
195
- execute(ctx, log, options) {
196
- return __awaiter(this, void 0, void 0, function* () {
197
- const config = (0, utils_1.getCmdConfig)(ctx.config, this.options);
198
- const mergesOptions = (0, utils_1.getMergedOptions)(config, options);
199
- yield lowcodeCli.previewApp({
200
- envId: ctx.envId || ctx.config.envId,
201
- projectPath: process.cwd(),
202
- logger: log,
203
- privateSettings: (0, utils_2.getPrivateSettings)(ctx.config, this.options.cmd)
204
- }, mergesOptions);
205
- });
171
+ async execute(ctx, log, options) {
172
+ const config = (0, utils_1.getCmdConfig)(ctx.config, this.options);
173
+ const mergesOptions = (0, utils_1.getMergedOptions)(config, options);
174
+ await lowcodeCli.previewApp({
175
+ envId: ctx.envId || ctx.config.envId,
176
+ projectPath: process.cwd(),
177
+ logger: log,
178
+ privateSettings: (0, utils_2.getPrivateSettings)(ctx.config, this.options.cmd)
179
+ }, mergesOptions);
206
180
  }
207
181
  };
208
182
  __decorate([
@@ -241,17 +215,15 @@ let LowCodeBuildAppConfig = class LowCodeBuildAppConfig extends common_1.Command
241
215
  requiredEnvId: false
242
216
  };
243
217
  }
244
- execute(ctx, log, options) {
245
- return __awaiter(this, void 0, void 0, function* () {
246
- const config = (0, utils_1.getCmdConfig)(ctx.config, this.options);
247
- const mergesOptions = (0, utils_1.getMergedOptions)(config, options);
248
- yield lowcodeCli.buildAppConfig({
249
- envId: ctx.envId || ctx.config.envId,
250
- projectPath: process.cwd(),
251
- logger: log,
252
- privateSettings: (0, utils_2.getPrivateSettings)(ctx.config, this.options.cmd)
253
- }, mergesOptions);
254
- });
218
+ async execute(ctx, log, options) {
219
+ const config = (0, utils_1.getCmdConfig)(ctx.config, this.options);
220
+ const mergesOptions = (0, utils_1.getMergedOptions)(config, options);
221
+ await lowcodeCli.buildAppConfig({
222
+ envId: ctx.envId || ctx.config.envId,
223
+ projectPath: process.cwd(),
224
+ logger: log,
225
+ privateSettings: (0, utils_2.getPrivateSettings)(ctx.config, this.options.cmd)
226
+ }, mergesOptions);
255
227
  }
256
228
  };
257
229
  __decorate([
@@ -286,25 +258,27 @@ let LowCodeDeployApp = class LowCodeDeployApp extends common_1.Command {
286
258
  requiredEnvId: false
287
259
  };
288
260
  }
289
- execute(ctx, log, options) {
290
- return __awaiter(this, void 0, void 0, function* () {
291
- let credential;
292
- const privateSettings = (0, utils_2.getPrivateSettings)(ctx.config, this.options.cmd);
293
- const config = (0, utils_1.getCmdConfig)(ctx.config, this.options);
294
- const _a = (0, utils_1.getMergedOptions)(config, options), { src } = _a, restMergedOptions = __rest(_a, ["src"]);
295
- if (ctx.hasPrivateSettings) {
296
- process.env.IS_PRIVATE = 'true';
297
- credential = privateSettings.credential;
298
- }
299
- else {
300
- credential = yield utils_2.authSupevisor.getLoginState();
301
- }
302
- yield lowcodeCli.deployApp({
303
- envId: ctx.envId || ctx.config.envId,
304
- projectPath: process.cwd(),
305
- logger: log,
306
- privateSettings
307
- }, Object.assign(Object.assign({ credential }, restMergedOptions), { projectPath: src || restMergedOptions.projectPath }));
261
+ async execute(ctx, log, options) {
262
+ let credential;
263
+ const privateSettings = (0, utils_2.getPrivateSettings)(ctx.config, this.options.cmd);
264
+ const config = (0, utils_1.getCmdConfig)(ctx.config, this.options);
265
+ const { src, ...restMergedOptions } = (0, utils_1.getMergedOptions)(config, options);
266
+ if (ctx.hasPrivateSettings) {
267
+ process.env.IS_PRIVATE = 'true';
268
+ credential = privateSettings.credential;
269
+ }
270
+ else {
271
+ credential = await utils_2.authSupevisor.getLoginState();
272
+ }
273
+ await lowcodeCli.deployApp({
274
+ envId: ctx.envId || ctx.config.envId,
275
+ projectPath: process.cwd(),
276
+ logger: log,
277
+ privateSettings
278
+ }, {
279
+ credential,
280
+ ...restMergedOptions,
281
+ projectPath: src || restMergedOptions.projectPath
308
282
  });
309
283
  }
310
284
  };
@@ -336,46 +310,44 @@ let ModelTypeSync = class ModelTypeSync extends common_1.Command {
336
310
  autoRunLogin: true
337
311
  };
338
312
  }
339
- execute(ctx, log, options) {
340
- return __awaiter(this, void 0, void 0, function* () {
341
- log.info('同步中...');
342
- if (!(yield fs_extra_1.default.pathExists('cloudbaserc.json'))) {
343
- yield fs_extra_1.default.writeFile('cloudbaserc.json', JSON.stringify({
344
- version: '2.0',
345
- envId: ctx.envId
346
- }, null, 2), 'utf8');
347
- }
348
- if (!(yield fs_extra_1.default.pathExists('tsconfig.json'))) {
349
- yield fs_extra_1.default.writeFile('tsconfig.json', JSON.stringify({
350
- compilerOptions: {
351
- allowJs: true
352
- }
353
- }, null, 2), 'utf8');
354
- }
355
- else {
356
- const config = yield fs_extra_1.default.readJson('tsconfig.json', 'utf8');
357
- (0, lodash_1.set)(config, 'compilerOptions.allowJs', true);
358
- yield fs_extra_1.default.writeFile('tsconfig.json', JSON.stringify(config, null, 2), 'utf8');
359
- }
360
- const cloudService = yield getCloudServiceInstance(ctx);
361
- const datasourceList = yield cloudService.lowcode.request('DescribeDataSourceList', {
362
- EnvId: ctx.envId,
363
- PageIndex: 1,
364
- PageSize: 1000,
365
- QuerySystemModel: true,
366
- QueryConnector: 0
367
- });
368
- const rows = datasourceList.Data.Rows;
369
- const dataModelList = rows.map((item) => ({
370
- name: item.Name,
371
- schema: JSON.parse(item.Schema),
372
- title: item.Title
373
- }));
374
- const dts = yield (0, dts_1.generateDataModelDTS)(dataModelList);
375
- const dtsFileName = 'cloud-models.d.ts';
376
- yield fs_extra_1.default.writeFile(dtsFileName, dts);
377
- log.success('同步数据模型类型定义文件成功。文件名称:' + dtsFileName);
313
+ async execute(ctx, log, options) {
314
+ log.info('同步中...');
315
+ if (!(await fs_extra_1.default.pathExists('cloudbaserc.json'))) {
316
+ await fs_extra_1.default.writeFile('cloudbaserc.json', JSON.stringify({
317
+ version: '2.0',
318
+ envId: ctx.envId
319
+ }, null, 2), 'utf8');
320
+ }
321
+ if (!(await fs_extra_1.default.pathExists('tsconfig.json'))) {
322
+ await fs_extra_1.default.writeFile('tsconfig.json', JSON.stringify({
323
+ compilerOptions: {
324
+ allowJs: true
325
+ }
326
+ }, null, 2), 'utf8');
327
+ }
328
+ else {
329
+ const config = await fs_extra_1.default.readJson('tsconfig.json', 'utf8');
330
+ (0, lodash_1.set)(config, 'compilerOptions.allowJs', true);
331
+ await fs_extra_1.default.writeFile('tsconfig.json', JSON.stringify(config, null, 2), 'utf8');
332
+ }
333
+ const cloudService = await getCloudServiceInstance(ctx);
334
+ const datasourceList = await cloudService.lowcode.request('DescribeDataSourceList', {
335
+ EnvId: ctx.envId,
336
+ PageIndex: 1,
337
+ PageSize: 1000,
338
+ QuerySystemModel: true,
339
+ QueryConnector: 0
378
340
  });
341
+ const rows = datasourceList.Data.Rows;
342
+ const dataModelList = rows.map((item) => ({
343
+ name: item.Name,
344
+ schema: JSON.parse(item.Schema),
345
+ title: item.Title
346
+ }));
347
+ const dts = await (0, dts_1.generateDataModelDTS)(dataModelList);
348
+ const dtsFileName = 'cloud-models.d.ts';
349
+ await fs_extra_1.default.writeFile(dtsFileName, dts);
350
+ log.success('同步数据模型类型定义文件成功。文件名称:' + dtsFileName);
379
351
  }
380
352
  };
381
353
  __decorate([
@@ -391,25 +363,23 @@ ModelTypeSync = __decorate([
391
363
  (0, common_1.ICommand)({ supportPrivate: true })
392
364
  ], ModelTypeSync);
393
365
  exports.ModelTypeSync = ModelTypeSync;
394
- function getCloudServiceInstance(ctx) {
395
- return __awaiter(this, void 0, void 0, function* () {
396
- let credential;
397
- if (ctx.hasPrivateSettings) {
398
- process.env.IS_PRIVATE = 'true';
399
- const privateSettings = (0, utils_2.getPrivateSettings)(ctx.config, this.options.cmd);
400
- credential = privateSettings.credential;
401
- }
402
- else {
403
- credential = yield utils_2.authSupevisor.getLoginState();
404
- }
405
- return {
406
- lowcode: cloud_api_1.CloudApiService.getInstance({
407
- service: 'lowcode',
408
- proxy: (0, toolbox_1.getProxy)(),
409
- credential,
410
- version: '2021-01-08'
411
- }),
412
- tcb: cloud_api_1.CloudApiService.getInstance({ service: 'tcb', proxy: (0, toolbox_1.getProxy)(), credential })
413
- };
414
- });
366
+ async function getCloudServiceInstance(ctx) {
367
+ let credential;
368
+ if (ctx.hasPrivateSettings) {
369
+ process.env.IS_PRIVATE = 'true';
370
+ const privateSettings = (0, utils_2.getPrivateSettings)(ctx.config, this.options.cmd);
371
+ credential = privateSettings.credential;
372
+ }
373
+ else {
374
+ credential = await utils_2.authSupevisor.getLoginState();
375
+ }
376
+ return {
377
+ lowcode: cloud_api_1.CloudApiService.getInstance({
378
+ service: 'lowcode',
379
+ proxy: (0, toolbox_1.getProxy)(),
380
+ credential,
381
+ version: '2021-01-08'
382
+ }),
383
+ tcb: cloud_api_1.CloudApiService.getInstance({ service: 'tcb', proxy: (0, toolbox_1.getProxy)(), credential })
384
+ };
415
385
  }
@@ -34,15 +34,6 @@ var __metadata = (this && this.__metadata) || function (k, v) {
34
34
  var __param = (this && this.__param) || function (paramIndex, decorator) {
35
35
  return function (target, key) { decorator(target, key, paramIndex); }
36
36
  };
37
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
38
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
39
- return new (P || (P = Promise))(function (resolve, reject) {
40
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
41
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
42
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
43
- step((generator = generator.apply(thisArg, _arguments || [])).next());
44
- });
45
- };
46
37
  Object.defineProperty(exports, "__esModule", { value: true });
47
38
  exports.LowCodePublishVersionComps = exports.LowCodePublishComps = exports.LowCodeDebugComps = exports.LowCodeBuildComps = exports.LowCodeCreateComps = void 0;
48
39
  const common_1 = require("../common");
@@ -76,58 +67,56 @@ let LowCodeCreateComps = class LowCodeCreateComps extends common_1.Command {
76
67
  requiredEnvId: false
77
68
  };
78
69
  }
79
- execute(opts, params, isPrivateEnv, config, log) {
80
- return __awaiter(this, void 0, void 0, function* () {
81
- const mergesOptions = (0, utils_2.getMergedOptions)((0, utils_2.getCmdConfig)(config, this.options), opts);
82
- if (mergesOptions.skipValidate) {
83
- if (!(params === null || params === void 0 ? void 0 : params[0])) {
84
- throw new error_1.CloudBaseError('skip validate 需要指定组件库名 eg: `tcb lowcode create mydemo`');
85
- }
86
- yield lowcodeCli.bootstrap(params === null || params === void 0 ? void 0 : params[0], log);
87
- return;
88
- }
89
- const privateSettings = (0, utils_1.getPrivateSettings)(config, this.options.cmd);
90
- if (process.env.CLOUDBASE_LOWCODE_CLOUDAPI_URL === undefined) {
91
- process.env.CLOUDBASE_LOWCODE_CLOUDAPI_URL =
92
- 'https://lcap.cloud.tencent.com/api/v1/cliapi';
70
+ async execute(opts, params, isPrivateEnv, config, log) {
71
+ const mergesOptions = (0, utils_2.getMergedOptions)((0, utils_2.getCmdConfig)(config, this.options), opts);
72
+ if (mergesOptions.skipValidate) {
73
+ if (!(params === null || params === void 0 ? void 0 : params[0])) {
74
+ throw new error_1.CloudBaseError('skip validate 需要指定组件库名 eg: `tcb lowcode create mydemo`');
93
75
  }
94
- let cloudService;
95
- if (isPrivateEnv) {
96
- cloudService = cloud_api_1.CloudApiService.getInstance({
97
- service: 'lowcode',
98
- credential: privateSettings.credential
99
- });
76
+ await lowcodeCli.bootstrap(params === null || params === void 0 ? void 0 : params[0], log);
77
+ return;
78
+ }
79
+ const privateSettings = (0, utils_1.getPrivateSettings)(config, this.options.cmd);
80
+ if (process.env.CLOUDBASE_LOWCODE_CLOUDAPI_URL === undefined) {
81
+ process.env.CLOUDBASE_LOWCODE_CLOUDAPI_URL =
82
+ 'https://lcap.cloud.tencent.com/api/v1/cliapi';
83
+ }
84
+ let cloudService;
85
+ if (isPrivateEnv) {
86
+ cloudService = cloud_api_1.CloudApiService.getInstance({
87
+ service: 'lowcode',
88
+ credential: privateSettings.credential
89
+ });
90
+ }
91
+ else {
92
+ cloudService = utils_1.CloudApiService.getInstance('lowcode');
93
+ }
94
+ const res = await cloudService.request('ListUserCompositeGroups', isPrivateEnv
95
+ ? {
96
+ privateUin: privateSettings.privateUin
100
97
  }
101
- else {
102
- cloudService = utils_1.CloudApiService.getInstance('lowcode');
103
- }
104
- const res = yield cloudService.request('ListUserCompositeGroups', isPrivateEnv
105
- ? {
106
- privateUin: privateSettings.privateUin
107
- }
108
- : undefined);
109
- const comps = res === null || res === void 0 ? void 0 : res.data;
110
- if (!(comps === null || comps === void 0 ? void 0 : comps.count)) {
111
- throw new error_1.CloudBaseError('没有可关联的云端组件库,请到低码控制台新建组件库!');
98
+ : undefined);
99
+ const comps = res === null || res === void 0 ? void 0 : res.data;
100
+ if (!(comps === null || comps === void 0 ? void 0 : comps.count)) {
101
+ throw new error_1.CloudBaseError('没有可关联的云端组件库,请到低码控制台新建组件库!');
102
+ }
103
+ let compsName = params === null || params === void 0 ? void 0 : params[0];
104
+ if (!compsName) {
105
+ const { selectCompsName } = await (0, enquirer_1.prompt)({
106
+ type: 'select',
107
+ name: 'selectCompsName',
108
+ message: '关联云端组件库:',
109
+ choices: comps.rows.map((row) => row.groupName)
110
+ });
111
+ compsName = selectCompsName;
112
+ }
113
+ else {
114
+ const comp = comps.rows.find((row) => row.groupName === compsName);
115
+ if (!comp) {
116
+ throw new error_1.CloudBaseError(`云端不存在组件库 ${compsName},请在微搭控制台-应用菜单中,打开任意一个应用的编辑器,点击素材-组件库管理模块,并创建组件库`);
112
117
  }
113
- let compsName = params === null || params === void 0 ? void 0 : params[0];
114
- if (!compsName) {
115
- const { selectCompsName } = yield (0, enquirer_1.prompt)({
116
- type: 'select',
117
- name: 'selectCompsName',
118
- message: '关联云端组件库:',
119
- choices: comps.rows.map((row) => row.groupName)
120
- });
121
- compsName = selectCompsName;
122
- }
123
- else {
124
- const comp = comps.rows.find((row) => row.groupName === compsName);
125
- if (!comp) {
126
- throw new error_1.CloudBaseError(`云端不存在组件库 ${compsName},请在微搭控制台-应用菜单中,打开任意一个应用的编辑器,点击素材-组件库管理模块,并创建组件库`);
127
- }
128
- }
129
- yield lowcodeCli.bootstrap(compsName, log);
130
- });
118
+ }
119
+ await lowcodeCli.bootstrap(compsName, log);
131
120
  }
132
121
  };
133
122
  __decorate([
@@ -162,15 +151,19 @@ let LowCodeBuildComps = class LowCodeBuildComps extends common_1.Command {
162
151
  requiredEnvId: false
163
152
  };
164
153
  }
165
- execute(ctx, log) {
166
- return __awaiter(this, void 0, void 0, function* () {
167
- const config = ctx.config.lowcodeCustomComponents;
168
- if (config) {
169
- yield lowcodeCli.graceBuildComps(Object.assign(Object.assign({}, config), { context: config.context || process.cwd(), logger: log, privateSettings: (0, utils_1.getPrivateSettings)(ctx.config, this.options.cmd), envId: ctx.envId || ctx.config.envId }));
170
- return;
171
- }
172
- throw new error_1.CloudBaseError('请参考文档填写 cloudbaserc 配置: https://docs.cloudbase.net/lowcode/custom-components/config/config-comps');
173
- });
154
+ async execute(ctx, log) {
155
+ const config = ctx.config.lowcodeCustomComponents;
156
+ if (config) {
157
+ await lowcodeCli.graceBuildComps({
158
+ ...config,
159
+ context: config.context || process.cwd(),
160
+ logger: log,
161
+ privateSettings: (0, utils_1.getPrivateSettings)(ctx.config, this.options.cmd),
162
+ envId: ctx.envId || ctx.config.envId,
163
+ });
164
+ return;
165
+ }
166
+ throw new error_1.CloudBaseError('请参考文档填写 cloudbaserc 配置: https://docs.cloudbase.net/lowcode/custom-components/config/config-comps');
174
167
  }
175
168
  };
176
169
  __decorate([
@@ -210,19 +203,25 @@ let LowCodeDebugComps = class LowCodeDebugComps extends common_1.Command {
210
203
  requiredEnvId: false
211
204
  };
212
205
  }
213
- execute(ctx, options, log) {
206
+ async execute(ctx, options, log) {
214
207
  var _a;
215
- return __awaiter(this, void 0, void 0, function* () {
216
- const config = ctx.config.lowcodeCustomComponents;
217
- const privateSettings = (0, utils_1.getPrivateSettings)(ctx.config, this.options.cmd);
218
- if (config) {
219
- const cmdConfig = (0, utils_2.getCmdConfig)(ctx.config, this.options);
220
- const mergesOptions = (0, utils_2.getMergedOptions)(cmdConfig, options);
221
- yield lowcodeCli.graceDebugComps(Object.assign(Object.assign({}, config), { context: config.context || process.cwd(), debugPort: (mergesOptions === null || mergesOptions === void 0 ? void 0 : mergesOptions.debugPort) || 8388, logger: log, wxDevtoolPath: mergesOptions === null || mergesOptions === void 0 ? void 0 : mergesOptions.wxDevtoolPath, debugBaseUrl: (_a = privateSettings === null || privateSettings === void 0 ? void 0 : privateSettings.endpoints) === null || _a === void 0 ? void 0 : _a.editor, envId: ctx.envId || ctx.config.envId }));
222
- return;
223
- }
224
- throw new error_1.CloudBaseError('请参考文档填写 cloudbaserc 配置: https://docs.cloudbase.net/lowcode/custom-components/config/config-comps');
225
- });
208
+ const config = ctx.config.lowcodeCustomComponents;
209
+ const privateSettings = (0, utils_1.getPrivateSettings)(ctx.config, this.options.cmd);
210
+ if (config) {
211
+ const cmdConfig = (0, utils_2.getCmdConfig)(ctx.config, this.options);
212
+ const mergesOptions = (0, utils_2.getMergedOptions)(cmdConfig, options);
213
+ await lowcodeCli.graceDebugComps({
214
+ ...config,
215
+ context: config.context || process.cwd(),
216
+ debugPort: (mergesOptions === null || mergesOptions === void 0 ? void 0 : mergesOptions.debugPort) || 8388,
217
+ logger: log,
218
+ wxDevtoolPath: mergesOptions === null || mergesOptions === void 0 ? void 0 : mergesOptions.wxDevtoolPath,
219
+ debugBaseUrl: (_a = privateSettings === null || privateSettings === void 0 ? void 0 : privateSettings.endpoints) === null || _a === void 0 ? void 0 : _a.editor,
220
+ envId: ctx.envId || ctx.config.envId,
221
+ });
222
+ return;
223
+ }
224
+ throw new error_1.CloudBaseError('请参考文档填写 cloudbaserc 配置: https://docs.cloudbase.net/lowcode/custom-components/config/config-comps');
226
225
  }
227
226
  };
228
227
  __decorate([
@@ -260,17 +259,22 @@ let LowCodePublishComps = class LowCodePublishComps extends common_1.Command {
260
259
  requiredEnvId: false
261
260
  };
262
261
  }
263
- execute(ctx, log, options) {
264
- return __awaiter(this, void 0, void 0, function* () {
265
- const config = ctx.config.lowcodeCustomComponents;
266
- if (config) {
267
- const mergesOptions = (0, utils_2.getMergedOptions)((0, utils_2.getCmdConfig)(ctx.config, this.options), options);
268
- yield lowcodeCli.gracePublishComps(Object.assign(Object.assign({}, config), { context: config.context || process.cwd(), logger: log, privateSettings: (0, utils_1.getPrivateSettings)(ctx.config, this.options.cmd), isAdmin: Boolean(mergesOptions.admin), envId: ctx.envId || ctx.config.envId }));
269
- log.success('组件库 - 已同步到云端,请到低码控制台发布该组件库!');
270
- return;
271
- }
272
- throw new error_1.CloudBaseError('请参考文档填写 cloudbaserc 配置: https://docs.cloudbase.net/lowcode/custom-components/config/config-comps');
273
- });
262
+ async execute(ctx, log, options) {
263
+ const config = ctx.config.lowcodeCustomComponents;
264
+ if (config) {
265
+ const mergesOptions = (0, utils_2.getMergedOptions)((0, utils_2.getCmdConfig)(ctx.config, this.options), options);
266
+ await lowcodeCli.gracePublishComps({
267
+ ...config,
268
+ context: config.context || process.cwd(),
269
+ logger: log,
270
+ privateSettings: (0, utils_1.getPrivateSettings)(ctx.config, this.options.cmd),
271
+ isAdmin: Boolean(mergesOptions.admin),
272
+ envId: ctx.envId || ctx.config.envId,
273
+ });
274
+ log.success('组件库 - 已同步到云端,请到低码控制台发布该组件库!');
275
+ return;
276
+ }
277
+ throw new error_1.CloudBaseError('请参考文档填写 cloudbaserc 配置: https://docs.cloudbase.net/lowcode/custom-components/config/config-comps');
274
278
  }
275
279
  };
276
280
  __decorate([
@@ -314,46 +318,51 @@ let LowCodePublishVersionComps = class LowCodePublishVersionComps extends common
314
318
  requiredEnvId: false
315
319
  };
316
320
  }
317
- execute(ctx, options, log) {
318
- return __awaiter(this, void 0, void 0, function* () {
319
- const { tag, comment, admin } = (0, utils_2.getMergedOptions)((0, utils_2.getCmdConfig)(ctx.config, this.options), options) || {};
320
- if (!comment) {
321
- throw new error_1.CloudBaseError('请使用 --comment 填写版本注释');
322
- }
323
- if (!tag) {
324
- throw new error_1.CloudBaseError('请使用 --tag 填写符合semver的版本号');
325
- }
326
- if (!semver.valid(tag)) {
327
- log.error('组件库版本不符合semver标准');
328
- return;
329
- }
330
- const config = ctx.config.lowcodeCustomComponents;
331
- if (!config) {
332
- throw new error_1.CloudBaseError('组件库 - 请添加组件库配置到cloudbaserc.json 以使用该命令');
333
- }
334
- const res = yield lowcodeCli.publishVersion(Object.assign(Object.assign({}, config), { context: config.context || process.cwd(), logger: log, isAdmin: options.admin, privateSettings: (0, utils_1.getPrivateSettings)(ctx.config, this.options.cmd), envId: ctx.envId || ctx.config.envId }), comment, tag);
335
- if (res.data.code === 200) {
336
- log.success('组件库 - 已发布新版本!');
337
- return;
338
- }
339
- if (res.data.code === 100) {
340
- log.error('组件库 - 无待发布版本');
341
- return;
342
- }
343
- if (res.data.code === 201) {
344
- log.error('组件库 - comment 重复, 请使用有意义的comment');
345
- return;
321
+ async execute(ctx, options, log) {
322
+ const { tag, comment, admin } = (0, utils_2.getMergedOptions)((0, utils_2.getCmdConfig)(ctx.config, this.options), options) || {};
323
+ if (!comment) {
324
+ throw new error_1.CloudBaseError('请使用 --comment 填写版本注释');
325
+ }
326
+ if (!tag) {
327
+ throw new error_1.CloudBaseError('请使用 --tag 填写符合semver的版本号');
328
+ }
329
+ if (!semver.valid(tag)) {
330
+ log.error('组件库版本不符合semver标准');
331
+ return;
332
+ }
333
+ const config = ctx.config.lowcodeCustomComponents;
334
+ if (!config) {
335
+ throw new error_1.CloudBaseError('组件库 - 请添加组件库配置到cloudbaserc.json 以使用该命令');
336
+ }
337
+ const res = await lowcodeCli.publishVersion({
338
+ ...config,
339
+ context: config.context || process.cwd(),
340
+ logger: log,
341
+ isAdmin: options.admin,
342
+ privateSettings: (0, utils_1.getPrivateSettings)(ctx.config, this.options.cmd),
343
+ envId: ctx.envId || ctx.config.envId,
344
+ }, comment, tag);
345
+ if (res.data.code === 200) {
346
+ log.success('组件库 - 已发布新版本!');
347
+ return;
348
+ }
349
+ if (res.data.code === 100) {
350
+ log.error('组件库 - 无待发布版本');
351
+ return;
352
+ }
353
+ if (res.data.code === 201) {
354
+ log.error('组件库 - comment 重复, 请使用有意义的comment');
355
+ return;
356
+ }
357
+ else {
358
+ if (res.data.msg) {
359
+ log.error(`组件库 - ${res.data.msg} RequestId: ${res.requestId}`);
346
360
  }
347
361
  else {
348
- if (res.data.msg) {
349
- log.error(`组件库 - ${res.data.msg} RequestId: ${res.requestId}`);
350
- }
351
- else {
352
- log.error('组件库 - 未知错误');
353
- }
354
- return;
362
+ log.error('组件库 - 未知错误');
355
363
  }
356
- });
364
+ return;
365
+ }
357
366
  }
358
367
  };
359
368
  __decorate([