@vectorx/cloud-toolkit 0.5.1 → 1.0.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/agent.kit.js CHANGED
@@ -20,7 +20,6 @@ exports.cleanup = cleanup;
20
20
  const child_process_1 = require("child_process");
21
21
  const fs_1 = __importDefault(require("fs"));
22
22
  const path_1 = __importDefault(require("path"));
23
- const agent_simulator_1 = require("@vectorx/agent-simulator");
24
23
  const archiver_1 = __importDefault(require("archiver"));
25
24
  const semver_1 = __importDefault(require("semver"));
26
25
  const container_1 = require("./container");
@@ -34,7 +33,7 @@ function validatePort(port, name = "端口") {
34
33
  }
35
34
  }
36
35
  function startRcbFramework(workDir_1, port_1, watch_1) {
37
- return __awaiter(this, arguments, void 0, function* (workDir, port, watch, nodePath = "node", options) {
36
+ return __awaiter(this, arguments, void 0, function* (workDir, port, watch, nodePath = "node", options, onLog) {
38
37
  return new Promise((resolve, reject) => {
39
38
  const args = [
40
39
  ...(watch ? ["--watch"] : []),
@@ -47,10 +46,29 @@ function startRcbFramework(workDir_1, port_1, watch_1) {
47
46
  "localhost,127.0.0.1",
48
47
  "--config",
49
48
  "agent-cloudbase-functions.json",
49
+ ...((options === null || options === void 0 ? void 0 : options.mode) ? ["--mode", options.mode] : []),
50
50
  ...((options === null || options === void 0 ? void 0 : options.enableRedLangfuse) ? ["--enableRedLangfuse"] : []),
51
51
  ];
52
52
  try {
53
- const packagePath = require.resolve("@vectorx/functions-framework/package.json");
53
+ let packagePath;
54
+ try {
55
+ packagePath = require.resolve("@vectorx/functions-framework/package.json", { paths: [workDir] });
56
+ }
57
+ catch (err) {
58
+ const msg = (err === null || err === void 0 ? void 0 : err.message) || String(err);
59
+ const isMissing = (err === null || err === void 0 ? void 0 : err.code) === "MODULE_NOT_FOUND" &&
60
+ (msg.includes("@vectorx/functions-framework") || msg.includes("functions-framework"));
61
+ if (!isMissing) {
62
+ throw err;
63
+ }
64
+ throw new Error([
65
+ "未检测到可选依赖 @vectorx/functions-framework,无法启动 rcb-ff 服务。",
66
+ "请在你的项目根目录安装(推荐):",
67
+ " pnpm add @vectorx/functions-framework",
68
+ "或在 monorepo 根目录安装:",
69
+ " pnpm add -w @vectorx/functions-framework",
70
+ ].join("\n"));
71
+ }
54
72
  const packageDir = path_1.default.dirname(packagePath);
55
73
  const rcbFfPath = path_1.default.join(packageDir, "bin/rcb-ff.js");
56
74
  console.log("开始启动 rcb-ff 服务...");
@@ -61,12 +79,32 @@ function startRcbFramework(workDir_1, port_1, watch_1) {
61
79
  cwd: workDir,
62
80
  });
63
81
  rcbProcess.stdout.on("data", (data) => {
64
- const output = data.toString();
65
- console.log(output.trim());
82
+ const logMessage = data.toString();
83
+ process.stdout.write(logMessage);
84
+ if (onLog) {
85
+ const lines = logMessage.split(/\r?\n/).filter((line) => line.trim().length > 0);
86
+ lines.forEach((line) => {
87
+ onLog({
88
+ level: "info",
89
+ message: line,
90
+ timestamp: new Date().toISOString(),
91
+ });
92
+ });
93
+ }
66
94
  });
67
95
  rcbProcess.stderr.on("data", (data) => {
68
- const error = data.toString();
69
- console.error(error.trim());
96
+ const logMessage = data.toString();
97
+ process.stderr.write(logMessage);
98
+ if (onLog) {
99
+ const lines = logMessage.split(/\r?\n/).filter((line) => line.trim().length > 0);
100
+ lines.forEach((line) => {
101
+ onLog({
102
+ level: "error",
103
+ message: line,
104
+ timestamp: new Date().toISOString(),
105
+ });
106
+ });
107
+ }
70
108
  });
71
109
  rcbProcess.on("message", (message) => {
72
110
  if ((message.type === "message" && message.data.type === "start-up") ||
@@ -96,7 +134,8 @@ function startRcbFramework(workDir_1, port_1, watch_1) {
96
134
  }
97
135
  function startDev(options) {
98
136
  return __awaiter(this, void 0, void 0, function* () {
99
- const { workDir = process.cwd(), port: specifiedPort, simulatorPort: specifiedSimulatorPort, watch = false, enableRedLangfuse = false, } = options;
137
+ var _a;
138
+ const { workDir = process.cwd(), port: specifiedPort, simulatorPort: specifiedSimulatorPort, watch = false, enableRedLangfuse = false, mode = "agent", } = options;
100
139
  if (!fs_1.default.existsSync(workDir)) {
101
140
  throw new Error(`目录不存在: ${workDir}`);
102
141
  }
@@ -127,8 +166,30 @@ function startDev(options) {
127
166
  else {
128
167
  simulatorPort = yield (0, port_finder_1.findAvailablePort)(port + 1);
129
168
  }
130
- yield startRcbFramework(workDir, port, watch, undefined, { enableRedLangfuse });
131
- const simulator = new agent_simulator_1.AgentSimulator({
169
+ yield startRcbFramework(workDir, port, watch, undefined, { enableRedLangfuse, mode });
170
+ let AgentSimulator = (_a = options === null || options === void 0 ? void 0 : options.deps) === null || _a === void 0 ? void 0 : _a.AgentSimulator;
171
+ if (!AgentSimulator) {
172
+ try {
173
+ const mod = require("@vectorx/agent-simulator");
174
+ AgentSimulator = ((mod === null || mod === void 0 ? void 0 : mod.AgentSimulator) || (mod === null || mod === void 0 ? void 0 : mod.default) || mod);
175
+ }
176
+ catch (err) {
177
+ const msg = (err === null || err === void 0 ? void 0 : err.message) || String(err);
178
+ const isMissing = (err === null || err === void 0 ? void 0 : err.code) === "MODULE_NOT_FOUND" &&
179
+ (msg.includes("@vectorx/agent-simulator") || msg.includes("agent-simulator"));
180
+ if (!isMissing)
181
+ throw err;
182
+ throw new Error([
183
+ "未检测到可选依赖 @vectorx/agent-simulator,无法启动本地模拟器。",
184
+ "如在 CLI 中使用,请升级/使用最新的 rcb(CLI 会自动注入该依赖)。",
185
+ "如需在当前项目手动启用该能力,请安装:",
186
+ " pnpm add @vectorx/agent-simulator",
187
+ "或在 monorepo 根目录安装:",
188
+ " pnpm add -w @vectorx/agent-simulator",
189
+ ].join("\n"));
190
+ }
191
+ }
192
+ const simulator = new AgentSimulator({
132
193
  port: simulatorPort,
133
194
  agentServerUrl: `http://localhost:${port}/v1/aiagent/agents/demo-agent`,
134
195
  open: false,
@@ -172,45 +233,13 @@ function build(options) {
172
233
  reject(err);
173
234
  });
174
235
  archive.pipe(output);
175
- const filesToAdd = [];
176
- const collectFiles = (dir, basePath = "") => {
177
- const files = fs_1.default.readdirSync(dir);
178
- for (const file of files) {
179
- const fullPath = path_1.default.join(dir, file);
180
- const relativePath = path_1.default.join(basePath, file);
181
- const stat = fs_1.default.statSync(fullPath);
182
- const excludePatterns = [/^\.git/, /^dist/, /\.zip$/, /\.DS_Store$/];
183
- if (excludePatterns.some((pattern) => pattern.test(relativePath))) {
184
- continue;
185
- }
186
- if (stat.isDirectory()) {
187
- collectFiles(fullPath, relativePath);
188
- }
189
- else {
190
- const isExecutable = relativePath.startsWith("bin/") ||
191
- relativePath.includes("/bin/") ||
192
- (() => {
193
- try {
194
- const content = fs_1.default.readFileSync(fullPath, "utf8");
195
- return content.startsWith("#!/");
196
- }
197
- catch (_a) {
198
- return false;
199
- }
200
- })();
201
- filesToAdd.push({ fullPath, relativePath, isExecutable });
202
- }
236
+ archive.directory(workDir, false, (data) => {
237
+ const excludePatterns = [/^\.git/, /^dist/, /\.zip$/, /\.DS_Store$/];
238
+ if (excludePatterns.some((pattern) => pattern.test(data.name))) {
239
+ return false;
203
240
  }
204
- };
205
- collectFiles(workDir);
206
- for (const { fullPath, relativePath, isExecutable } of filesToAdd) {
207
- if (isExecutable) {
208
- archive.file(fullPath, { name: relativePath, mode: 0o755 });
209
- }
210
- else {
211
- archive.file(fullPath, { name: relativePath });
212
- }
213
- }
241
+ return data;
242
+ });
214
243
  archive.finalize();
215
244
  });
216
245
  const size = fs_1.default.statSync(outputPath).size;
@@ -1,13 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getBaseUrl = getBaseUrl;
4
- const apiUrls = {
5
- sit: "http://miniapp-tailiang.sl.sit.xiaohongshu.com",
6
- development: "https://miniapp.beta.xiaohongshu.com",
7
- production: "https://miniapp.xiaohongshu.com",
8
- };
9
- const env = process.env.AGENT_BUILD_ENV || "production";
10
- const baseUrl = apiUrls[env] || apiUrls.development;
4
+ const endpoints_1 = require("@vectorx/endpoints");
11
5
  function getBaseUrl() {
12
- return baseUrl;
6
+ console.log("resolveUrl", (0, endpoints_1.resolveUrl)("@vectorx/cloud-toolkit", "baseUrl"));
7
+ return (0, endpoints_1.resolveUrl)("@vectorx/cloud-toolkit", "baseUrl");
13
8
  }
@@ -3,9 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.container = void 0;
4
4
  const inversify_1 = require("inversify");
5
5
  const auth_service_1 = require("../services/auth-service");
6
+ const cloud_env_service_1 = require("../services/cloud-env-service");
7
+ const fun_service_1 = require("../services/fun-service");
6
8
  const upload_service_1 = require("../services/upload-service");
7
9
  const identifiers_1 = require("./identifiers");
8
10
  const container = new inversify_1.Container();
9
11
  exports.container = container;
10
12
  container.bind(identifiers_1.SERVICE_IDENTIFIERS.AuthService).to(auth_service_1.AuthService).inSingletonScope();
11
13
  container.bind(identifiers_1.SERVICE_IDENTIFIERS.UploadService).to(upload_service_1.UploadService).inSingletonScope();
14
+ container.bind(identifiers_1.SERVICE_IDENTIFIERS.CloudEnvService).to(cloud_env_service_1.CloudEnvService).inSingletonScope();
15
+ container.bind(identifiers_1.SERVICE_IDENTIFIERS.FunService).to(fun_service_1.FunService).inSingletonScope();
@@ -4,4 +4,6 @@ exports.SERVICE_IDENTIFIERS = void 0;
4
4
  exports.SERVICE_IDENTIFIERS = {
5
5
  AuthService: Symbol.for("AuthService"),
6
6
  UploadService: Symbol.for("UploadService"),
7
+ CloudEnvService: Symbol.for("CloudEnvService"),
8
+ FunService: Symbol.for("FunService"),
7
9
  };
@@ -26,6 +26,12 @@ class ServiceProvider {
26
26
  static getUploadService() {
27
27
  return container_1.container.get(identifiers_1.SERVICE_IDENTIFIERS.UploadService);
28
28
  }
29
+ static getCloudEnvService() {
30
+ return container_1.container.get(identifiers_1.SERVICE_IDENTIFIERS.CloudEnvService);
31
+ }
32
+ static getFunService() {
33
+ return container_1.container.get(identifiers_1.SERVICE_IDENTIFIERS.FunService);
34
+ }
29
35
  }
30
36
  exports.ServiceProvider = ServiceProvider;
31
37
  __exportStar(require("./types"), exports);
package/lib/env.kit.js ADDED
@@ -0,0 +1,40 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.getCloudEnvironments = getCloudEnvironments;
13
+ exports.getCloudEnvironment = getCloudEnvironment;
14
+ exports.createCloudEnvironment = createCloudEnvironment;
15
+ exports.updateCloudEnvironment = updateCloudEnvironment;
16
+ const container_1 = require("./container");
17
+ function getCloudEnvironments(cloudEnvId) {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ const envService = container_1.ServiceProvider.getCloudEnvService();
20
+ return envService.getCloudEnvironments(cloudEnvId);
21
+ });
22
+ }
23
+ function getCloudEnvironment(cloudEnvId) {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ const envService = container_1.ServiceProvider.getCloudEnvService();
26
+ return envService.getCloudEnvironment(cloudEnvId);
27
+ });
28
+ }
29
+ function createCloudEnvironment(payload) {
30
+ return __awaiter(this, void 0, void 0, function* () {
31
+ const envService = container_1.ServiceProvider.getCloudEnvService();
32
+ return envService.createCloudEnvironment(payload);
33
+ });
34
+ }
35
+ function updateCloudEnvironment(payload) {
36
+ return __awaiter(this, void 0, void 0, function* () {
37
+ const envService = container_1.ServiceProvider.getCloudEnvService();
38
+ return envService.updateCloudEnvironment(payload);
39
+ });
40
+ }
package/lib/fun.kit.js ADDED
@@ -0,0 +1,34 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.startFunDev = startFunDev;
13
+ exports.deployFun = deployFun;
14
+ exports.getPublishHistory = getPublishHistory;
15
+ const container_1 = require("./container");
16
+ function startFunDev() {
17
+ return __awaiter(this, arguments, void 0, function* (options = {}) {
18
+ const funService = container_1.ServiceProvider.getFunService();
19
+ return funService.startFunDev(options);
20
+ });
21
+ }
22
+ function deployFun(options) {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ const funService = container_1.ServiceProvider.getFunService();
25
+ const result = yield funService.deploy(options);
26
+ return result;
27
+ });
28
+ }
29
+ function getPublishHistory(options) {
30
+ return __awaiter(this, void 0, void 0, function* () {
31
+ const funService = container_1.ServiceProvider.getFunService();
32
+ return funService.getPublishHistory(options);
33
+ });
34
+ }
package/lib/index.js CHANGED
@@ -16,6 +16,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.Uploader = void 0;
18
18
  __exportStar(require("./agent.kit"), exports);
19
+ __exportStar(require("./fun.kit"), exports);
20
+ __exportStar(require("./env.kit"), exports);
19
21
  var cos_uploader_1 = require("./utils/cos-uploader");
20
22
  Object.defineProperty(exports, "Uploader", { enumerable: true, get: function () { return cos_uploader_1.Uploader; } });
21
23
  __exportStar(require("./container"), exports);
@@ -28,3 +30,5 @@ __exportStar(require("./utils/tracker"), exports);
28
30
  __exportStar(require("./utils/port-finder"), exports);
29
31
  __exportStar(require("./utils/open-browser"), exports);
30
32
  __exportStar(require("./utils/output"), exports);
33
+ __exportStar(require("./utils/table"), exports);
34
+ __exportStar(require("./utils/fun-project-validator"), exports);
@@ -104,6 +104,7 @@ let AuthService = class AuthService {
104
104
  return loginInfo;
105
105
  }
106
106
  catch (error) {
107
+ yield this.clearLoginInfo();
107
108
  return null;
108
109
  }
109
110
  });
@@ -124,7 +125,7 @@ let AuthService = class AuthService {
124
125
  return response.data;
125
126
  }
126
127
  catch (error) {
127
- throw new Error("检查登录信息失败");
128
+ throw new Error("检查登录失败信息");
128
129
  }
129
130
  });
130
131
  }
@@ -0,0 +1,166 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
12
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
13
+ return new (P || (P = Promise))(function (resolve, reject) {
14
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
15
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
16
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
17
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
18
+ });
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.CloudEnvService = void 0;
22
+ const inversify_1 = require("inversify");
23
+ const config_1 = require("../config");
24
+ const container_1 = require("../container");
25
+ const env_helper_1 = require("../utils/env-helper");
26
+ const logger_1 = require("../utils/logger");
27
+ const request_1 = require("../utils/request");
28
+ let CloudEnvService = class CloudEnvService {
29
+ constructor() {
30
+ this.authService = container_1.container.get(container_1.SERVICE_IDENTIFIERS.AuthService);
31
+ }
32
+ getCloudEnvironments(cloudEnvId) {
33
+ return __awaiter(this, void 0, void 0, function* () {
34
+ var _a, _b;
35
+ try {
36
+ let query = {};
37
+ if (!env_helper_1.isIDE) {
38
+ const loginInfo = yield this.authService.getLoginInfo();
39
+ if (!loginInfo) {
40
+ throw new Error("未登录,请先执行登录命令");
41
+ }
42
+ query = {
43
+ secret_id: loginInfo.secret_id,
44
+ cli_token: loginInfo.cli_token,
45
+ };
46
+ }
47
+ const httpResponse = yield request_1.request.fetch({
48
+ method: "POST",
49
+ url: `${(0, config_1.getBaseUrl)()}/api/eros/mp/red/code/cloud_env/query`,
50
+ headers: {
51
+ "Content-Type": "application/json",
52
+ },
53
+ data: {
54
+ query,
55
+ body: {
56
+ cloud_env_id: cloudEnvId !== null && cloudEnvId !== void 0 ? cloudEnvId : "",
57
+ },
58
+ },
59
+ });
60
+ const data = request_1.request.handleCode(request_1.request.handleHttpStatus(httpResponse));
61
+ return ((_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.env_list) || ((_b = data === null || data === void 0 ? void 0 : data.data) === null || _b === void 0 ? void 0 : _b.envs) || [];
62
+ }
63
+ catch (error) {
64
+ const msg = (error === null || error === void 0 ? void 0 : error.message) || String(error);
65
+ logger_1.logger.error(`云环境列表接口调用失败: ${msg}`);
66
+ throw error;
67
+ }
68
+ });
69
+ }
70
+ getCloudEnvironment(cloudEnvId) {
71
+ return __awaiter(this, void 0, void 0, function* () {
72
+ if (!cloudEnvId) {
73
+ return null;
74
+ }
75
+ const envs = yield this.getCloudEnvironments(cloudEnvId);
76
+ if (!envs || envs.length === 0) {
77
+ return null;
78
+ }
79
+ const exact = envs.find((env) => env.cloud_env_id === cloudEnvId);
80
+ return exact || envs[0] || null;
81
+ });
82
+ }
83
+ createCloudEnvironment(payload) {
84
+ return __awaiter(this, void 0, void 0, function* () {
85
+ var _a, _b;
86
+ if (!(payload === null || payload === void 0 ? void 0 : payload.cloud_env_name)) {
87
+ throw new Error("cloud_env_name 为必填字段");
88
+ }
89
+ let query = {};
90
+ if (!env_helper_1.isIDE) {
91
+ const loginInfo = yield this.authService.getLoginInfo();
92
+ if (!loginInfo) {
93
+ throw new Error("未登录,请先执行登录命令");
94
+ }
95
+ query = {
96
+ secret_id: loginInfo.secret_id,
97
+ cli_token: loginInfo.cli_token,
98
+ };
99
+ }
100
+ const httpResponse = yield request_1.request.fetch({
101
+ method: "POST",
102
+ url: `${(0, config_1.getBaseUrl)()}/api/eros/mp/red/code/cloud_env/create`,
103
+ headers: {
104
+ "Content-Type": "application/json",
105
+ },
106
+ data: {
107
+ query,
108
+ body: {
109
+ cloud_env_name: payload.cloud_env_name,
110
+ description: (_a = payload.description) !== null && _a !== void 0 ? _a : "",
111
+ },
112
+ },
113
+ });
114
+ const res = request_1.request.handleCode(request_1.request.handleHttpStatus(httpResponse));
115
+ return ((_b = res.data) === null || _b === void 0 ? void 0 : _b.env_info) || res.data;
116
+ });
117
+ }
118
+ updateCloudEnvironment(payload) {
119
+ return __awaiter(this, void 0, void 0, function* () {
120
+ var _a, _b;
121
+ if (!(payload === null || payload === void 0 ? void 0 : payload.cloud_env_id)) {
122
+ throw new Error("cloud_env_id 为必填字段");
123
+ }
124
+ let query = {};
125
+ if (!env_helper_1.isIDE) {
126
+ const loginInfo = yield this.authService.getLoginInfo();
127
+ if (!loginInfo) {
128
+ throw new Error("未登录,请先执行登录命令");
129
+ }
130
+ query = {
131
+ secret_id: loginInfo.secret_id,
132
+ cli_token: loginInfo.cli_token,
133
+ };
134
+ }
135
+ const httpResponse = yield request_1.request.fetch({
136
+ method: "POST",
137
+ url: `${(0, config_1.getBaseUrl)()}/api/eros/mp/red/code/cloud_env/update`,
138
+ headers: {
139
+ "Content-Type": "application/json",
140
+ },
141
+ data: {
142
+ query,
143
+ body: {
144
+ cloud_env_id: payload.cloud_env_id,
145
+ env_variables: payload.env_variables,
146
+ },
147
+ },
148
+ });
149
+ if ((httpResponse === null || httpResponse === void 0 ? void 0 : httpResponse.status) === 401) {
150
+ const msg = ((_a = httpResponse === null || httpResponse === void 0 ? void 0 : httpResponse.data) === null || _a === void 0 ? void 0 : _a.msg) || "请先登录";
151
+ throw new Error(msg);
152
+ }
153
+ const res = request_1.request.handleCode(request_1.request.handleHttpStatus(httpResponse));
154
+ if ((res === null || res === void 0 ? void 0 : res.success) === false) {
155
+ const msg = (res === null || res === void 0 ? void 0 : res.msg) || (res === null || res === void 0 ? void 0 : res.message) || "更新云环境配置失败";
156
+ throw new Error(msg);
157
+ }
158
+ return ((_b = res.data) === null || _b === void 0 ? void 0 : _b.env_info) || res.data;
159
+ });
160
+ }
161
+ };
162
+ exports.CloudEnvService = CloudEnvService;
163
+ exports.CloudEnvService = CloudEnvService = __decorate([
164
+ (0, inversify_1.injectable)(),
165
+ __metadata("design:paramtypes", [])
166
+ ], CloudEnvService);