@base44-preview/cli 0.0.32-pr.265.bdeb701 → 0.0.32-pr.265.de49ace

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/dist/cli/index.js CHANGED
@@ -186135,18 +186135,40 @@ async function invokeFunction(functionName, data, options) {
186135
186135
  token = refreshed;
186136
186136
  }
186137
186137
  }
186138
- const response = await distribution_default(url2, {
186139
- method,
186140
- ...METHODS_WITH_BODY.has(method) ? { json: data } : {},
186141
- headers: {
186142
- Authorization: `Bearer ${token}`,
186143
- "X-App-Id": id,
186144
- "User-Agent": "Base44 CLI",
186145
- ...options?.headers
186146
- },
186147
- timeout: options?.timeout ?? 300000
186138
+ const requestHeaders = {
186139
+ Authorization: `Bearer ${token}`,
186140
+ "X-App-Id": id,
186141
+ "User-Agent": "Base44 CLI",
186142
+ ...options?.headers
186143
+ };
186144
+ const startTime = Date.now();
186145
+ let response;
186146
+ try {
186147
+ response = await distribution_default(url2, {
186148
+ method,
186149
+ ...METHODS_WITH_BODY.has(method) ? { json: data } : {},
186150
+ headers: requestHeaders,
186151
+ timeout: options?.timeout ?? 300000
186152
+ });
186153
+ } catch (error48) {
186154
+ throw await ApiError.fromHttpError(error48, "invoking function");
186155
+ }
186156
+ const durationMs = Date.now() - startTime;
186157
+ const responseHeaders = {};
186158
+ response.headers.forEach((value, key) => {
186159
+ responseHeaders[key] = value;
186148
186160
  });
186149
- return response.json();
186161
+ const body = await response.json();
186162
+ return {
186163
+ body,
186164
+ status: response.status,
186165
+ statusText: response.statusText,
186166
+ headers: responseHeaders,
186167
+ url: url2,
186168
+ method,
186169
+ requestHeaders,
186170
+ durationMs
186171
+ };
186150
186172
  }
186151
186173
  // src/core/resources/function/resource.ts
186152
186174
  var functionResource = {
@@ -195040,7 +195062,9 @@ async function invokeFunctionAction(functionName, options) {
195040
195062
  const data = options.data ? parseJsonArg(options.data) : {};
195041
195063
  const method = options.method?.toUpperCase() ?? "POST";
195042
195064
  const timeout2 = options.timeout ? parseInt(options.timeout, 10) * 1000 : undefined;
195043
- R2.info(`Invoking function ${theme.styles.bold(functionName)} (${method})`);
195065
+ if (!options.verbose) {
195066
+ R2.info(`Invoking function ${theme.styles.bold(functionName)} (${method})`);
195067
+ }
195044
195068
  const result = await runTask("Running function", async () => {
195045
195069
  return await invokeFunction(functionName, data, {
195046
195070
  timeout: timeout2,
@@ -195048,18 +195072,41 @@ async function invokeFunctionAction(functionName, options) {
195048
195072
  headers: options.header
195049
195073
  });
195050
195074
  }, {
195051
- successMessage: "Function executed successfully",
195075
+ successMessage: options.verbose ? undefined : "Function executed successfully",
195052
195076
  errorMessage: "Function execution failed"
195053
195077
  });
195054
- const output = typeof result === "string" ? result : JSON.stringify(result, null, 2);
195055
- R2.info(`Response:
195078
+ if (options.verbose) {
195079
+ R2.info(theme.styles.dim("* Request:"));
195080
+ R2.info(theme.styles.dim(`> ${result.method} ${result.url}`));
195081
+ for (const [key, value] of Object.entries(result.requestHeaders)) {
195082
+ const displayValue = key === "Authorization" ? "Bearer [REDACTED]" : value;
195083
+ R2.info(theme.styles.dim(`> ${key}: ${displayValue}`));
195084
+ }
195085
+ if (Object.keys(data).length > 0) {
195086
+ R2.info(theme.styles.dim(">"));
195087
+ R2.info(theme.styles.dim(`> ${JSON.stringify(data)}`));
195088
+ }
195089
+ R2.info(theme.styles.dim("*"));
195090
+ R2.info(theme.styles.dim("* Response:"));
195091
+ R2.info(theme.styles.dim(`< HTTP ${result.status} ${result.statusText} (${result.durationMs}ms)`));
195092
+ for (const [key, value] of Object.entries(result.headers)) {
195093
+ R2.info(theme.styles.dim(`< ${key}: ${value}`));
195094
+ }
195095
+ R2.info(theme.styles.dim("<"));
195096
+ }
195097
+ const output = typeof result.body === "string" ? result.body : JSON.stringify(result.body, null, 2);
195098
+ if (options.verbose) {
195099
+ R2.info(output);
195100
+ } else {
195101
+ R2.info(`Response:
195056
195102
  ${output}`);
195103
+ }
195057
195104
  return {
195058
- outroMessage: `Function ${theme.styles.bold(functionName)} completed`
195105
+ outroMessage: options.verbose ? undefined : `Function ${theme.styles.bold(functionName)} completed`
195059
195106
  };
195060
195107
  }
195061
195108
  function getFunctionsInvokeCommand(context) {
195062
- return new Command("invoke").description("Invoke a deployed backend function").argument("<function-name>", "Name of the function to invoke").option("-X, --method <verb>", "HTTP method (default: POST)").option("-H, --header <header>", "Custom header (Name: Value), repeatable", collectHeader, {}).option("-d, --data <json>", "JSON data to send to the function").option("-t, --timeout <seconds>", "Timeout in seconds (default: 300)").action(async (functionName, options) => {
195109
+ return new Command("invoke").description("Invoke a deployed backend function").argument("<function-name>", "Name of the function to invoke").option("-X, --method <verb>", "HTTP method (default: POST)").option("-H, --header <header>", "Custom header (Name: Value), repeatable", collectHeader, {}).option("-d, --data <json>", "JSON data to send to the function").option("-t, --timeout <seconds>", "Timeout in seconds (default: 300)").option("-v, --verbose", "Verbose output (show request/response headers, status, timing)").action(async (functionName, options) => {
195063
195110
  await runCommand(() => invokeFunctionAction(functionName, options), { requireAuth: true }, context);
195064
195111
  });
195065
195112
  }
@@ -200240,4 +200287,4 @@ export {
200240
200287
  CLIExitError
200241
200288
  };
200242
200289
 
200243
- //# debugId=B2CE23710B195DBD64756E2164756E21
200290
+ //# debugId=229682012D05F2D664756E2164756E21