@base44-preview/cli 0.0.32-pr.265.a0aeeff → 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,23 +186135,40 @@ async function invokeFunction(functionName, data, options) {
186135
186135
  token = refreshed;
186136
186136
  }
186137
186137
  }
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();
186138
186145
  let response;
186139
186146
  try {
186140
186147
  response = await distribution_default(url2, {
186141
186148
  method,
186142
186149
  ...METHODS_WITH_BODY.has(method) ? { json: data } : {},
186143
- headers: {
186144
- Authorization: `Bearer ${token}`,
186145
- "X-App-Id": id,
186146
- "User-Agent": "Base44 CLI",
186147
- ...options?.headers
186148
- },
186150
+ headers: requestHeaders,
186149
186151
  timeout: options?.timeout ?? 300000
186150
186152
  });
186151
186153
  } catch (error48) {
186152
186154
  throw await ApiError.fromHttpError(error48, "invoking function");
186153
186155
  }
186154
- return response.json();
186156
+ const durationMs = Date.now() - startTime;
186157
+ const responseHeaders = {};
186158
+ response.headers.forEach((value, key) => {
186159
+ responseHeaders[key] = value;
186160
+ });
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
+ };
186155
186172
  }
186156
186173
  // src/core/resources/function/resource.ts
186157
186174
  var functionResource = {
@@ -195045,7 +195062,9 @@ async function invokeFunctionAction(functionName, options) {
195045
195062
  const data = options.data ? parseJsonArg(options.data) : {};
195046
195063
  const method = options.method?.toUpperCase() ?? "POST";
195047
195064
  const timeout2 = options.timeout ? parseInt(options.timeout, 10) * 1000 : undefined;
195048
- R2.info(`Invoking function ${theme.styles.bold(functionName)} (${method})`);
195065
+ if (!options.verbose) {
195066
+ R2.info(`Invoking function ${theme.styles.bold(functionName)} (${method})`);
195067
+ }
195049
195068
  const result = await runTask("Running function", async () => {
195050
195069
  return await invokeFunction(functionName, data, {
195051
195070
  timeout: timeout2,
@@ -195053,18 +195072,41 @@ async function invokeFunctionAction(functionName, options) {
195053
195072
  headers: options.header
195054
195073
  });
195055
195074
  }, {
195056
- successMessage: "Function executed successfully",
195075
+ successMessage: options.verbose ? undefined : "Function executed successfully",
195057
195076
  errorMessage: "Function execution failed"
195058
195077
  });
195059
- const output = typeof result === "string" ? result : JSON.stringify(result, null, 2);
195060
- 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:
195061
195102
  ${output}`);
195103
+ }
195062
195104
  return {
195063
- outroMessage: `Function ${theme.styles.bold(functionName)} completed`
195105
+ outroMessage: options.verbose ? undefined : `Function ${theme.styles.bold(functionName)} completed`
195064
195106
  };
195065
195107
  }
195066
195108
  function getFunctionsInvokeCommand(context) {
195067
- 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) => {
195068
195110
  await runCommand(() => invokeFunctionAction(functionName, options), { requireAuth: true }, context);
195069
195111
  });
195070
195112
  }
@@ -200245,4 +200287,4 @@ export {
200245
200287
  CLIExitError
200246
200288
  };
200247
200289
 
200248
- //# debugId=4D1B0191CACD8D7D64756E2164756E21
200290
+ //# debugId=229682012D05F2D664756E2164756E21