@base44-preview/cli 0.0.33-pr.225.220b697 → 0.0.33-pr.225.299669a

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
@@ -136896,12 +136896,12 @@ var require_linker = __commonJS((exports) => {
136896
136896
  var require_optionValidator = __commonJS((exports) => {
136897
136897
  Object.defineProperty(exports, "__esModule", { value: true });
136898
136898
  exports.validateOptions = undefined;
136899
- function validateOptions2({ maxItems }) {
136899
+ function validateOptions3({ maxItems }) {
136900
136900
  if (maxItems !== undefined && maxItems < -1) {
136901
136901
  throw RangeError(`Expected options.maxItems to be >= -1, but was given ${maxItems}.`);
136902
136902
  }
136903
136903
  }
136904
- exports.validateOptions = validateOptions2;
136904
+ exports.validateOptions = validateOptions3;
136905
136905
  });
136906
136906
 
136907
136907
  // node_modules/json-schema-to-typescript/dist/src/index.js
@@ -178557,10 +178557,9 @@ class ApiError extends SystemError {
178557
178557
  } catch {
178558
178558
  message = error48.message;
178559
178559
  }
178560
- const statusCode = ApiError.normalizeStatusCode(error48.response.status, responseBody);
178561
178560
  const requestBody = error48.options.context?.__requestBody;
178562
178561
  return new ApiError(`Error ${context}: ${message}`, {
178563
- statusCode,
178562
+ statusCode: error48.response.status,
178564
178563
  requestUrl: error48.request.url,
178565
178564
  requestMethod: error48.request.method,
178566
178565
  requestBody,
@@ -178617,12 +178616,6 @@ class ApiError extends SystemError {
178617
178616
  return;
178618
178617
  return REASON_HINTS[reason];
178619
178618
  }
178620
- static normalizeStatusCode(statusCode, responseBody) {
178621
- if (responseBody?.error_type === "KeyError") {
178622
- return 404;
178623
- }
178624
- return statusCode;
178625
- }
178626
178619
  }
178627
178620
 
178628
178621
  class FileNotFoundError extends SystemError {
@@ -178649,6 +178642,24 @@ class FileReadError extends SystemError {
178649
178642
  }
178650
178643
  }
178651
178644
 
178645
+ class FunctionNotFoundError extends ApiError {
178646
+ constructor(functionName, cause) {
178647
+ super(`Function "${functionName}" was not found in this app`, {
178648
+ statusCode: 404,
178649
+ cause,
178650
+ hints: [
178651
+ {
178652
+ message: "Make sure the function name is correct and has been deployed",
178653
+ command: "base44 functions deploy"
178654
+ },
178655
+ {
178656
+ message: "List project functions by checking the base44/functions/ directory"
178657
+ }
178658
+ ]
178659
+ });
178660
+ }
178661
+ }
178662
+
178652
178663
  class InternalError extends SystemError {
178653
178664
  code = "INTERNAL_ERROR";
178654
178665
  constructor(message, options) {
@@ -186073,17 +186084,30 @@ function buildLogsQueryString(filters) {
186073
186084
  if (filters.order) {
186074
186085
  params.set("order", filters.order);
186075
186086
  }
186076
- return params;
186087
+ const queryString = params.toString();
186088
+ return queryString ? `?${queryString}` : "";
186077
186089
  }
186078
186090
  async function fetchFunctionLogs(functionName, filters = {}) {
186079
186091
  const appClient = getAppClient();
186080
- const searchParams = buildLogsQueryString(filters);
186092
+ const queryString = buildLogsQueryString(filters);
186081
186093
  let response;
186082
186094
  try {
186083
- response = await appClient.get(`functions-mgmt/${functionName}/logs`, {
186084
- searchParams
186085
- });
186095
+ response = await appClient.get(`functions-mgmt/${functionName}/logs${queryString}`);
186086
186096
  } catch (error48) {
186097
+ if (error48 instanceof HTTPError) {
186098
+ if (error48.response.status === 404) {
186099
+ throw new FunctionNotFoundError(functionName, error48);
186100
+ }
186101
+ try {
186102
+ const body = await error48.response.clone().json();
186103
+ if (body.error_type === "KeyError") {
186104
+ throw new FunctionNotFoundError(functionName, error48);
186105
+ }
186106
+ } catch (parseError) {
186107
+ if (parseError instanceof ApiError)
186108
+ throw parseError;
186109
+ }
186110
+ }
186087
186111
  throw await ApiError.fromHttpError(error48, `fetching function logs: '${functionName}'`);
186088
186112
  }
186089
186113
  const result = FunctionLogsResponseSchema.safeParse(await response.json());
@@ -195109,7 +195133,8 @@ function getFunctionsDeployCommand(context) {
195109
195133
  }));
195110
195134
  }
195111
195135
 
195112
- // src/cli/commands/project/logs.ts
195136
+ // src/cli/commands/logs/index.ts
195137
+ var VALID_LEVELS = ["log", "info", "warn", "error", "debug"];
195113
195138
  function parseFunctionFilters(options) {
195114
195139
  const filters = {};
195115
195140
  if (options.since) {
@@ -195118,6 +195143,9 @@ function parseFunctionFilters(options) {
195118
195143
  if (options.until) {
195119
195144
  filters.until = options.until;
195120
195145
  }
195146
+ if (options.level) {
195147
+ filters.level = options.level;
195148
+ }
195121
195149
  if (options.limit) {
195122
195150
  filters.limit = Number.parseInt(options.limit, 10);
195123
195151
  }
@@ -195136,21 +195164,42 @@ function normalizeDatetime(value) {
195136
195164
  return value;
195137
195165
  return `${value}Z`;
195138
195166
  }
195167
+ function validateOptions2(options) {
195168
+ if (options.level && !VALID_LEVELS.includes(options.level)) {
195169
+ throw new InvalidInputError(`Invalid level: "${options.level}". Must be one of: ${VALID_LEVELS.join(", ")}.`);
195170
+ }
195171
+ if (options.limit) {
195172
+ const limit = Number.parseInt(options.limit, 10);
195173
+ if (Number.isNaN(limit) || limit < 1 || limit > 1000) {
195174
+ throw new InvalidInputError(`Invalid limit: "${options.limit}". Must be a number between 1 and 1000.`);
195175
+ }
195176
+ }
195177
+ if (options.order) {
195178
+ const order = options.order.toUpperCase();
195179
+ if (order !== "ASC" && order !== "DESC") {
195180
+ throw new InvalidInputError(`Invalid order: "${options.order}". Must be "ASC" or "DESC".`);
195181
+ }
195182
+ }
195183
+ }
195139
195184
  function formatEntry(entry) {
195140
195185
  const time3 = entry.time.substring(0, 19).replace("T", " ");
195141
195186
  const level = entry.level.toUpperCase().padEnd(5);
195142
195187
  const message = entry.message.trim();
195143
- return `${time3} ${level} ${message}`;
195188
+ return `${time3} ${level} ${message}
195189
+ `;
195144
195190
  }
195145
195191
  function formatLogs(entries) {
195146
195192
  if (entries.length === 0) {
195147
195193
  return `No logs found matching the filters.
195148
195194
  `;
195149
195195
  }
195150
- const header2 = `Showing ${entries.length} function log entries
195196
+ let output = `Showing ${entries.length} function log entries
195197
+
195151
195198
  `;
195152
- return [header2, ...entries.map(formatEntry)].join(`
195153
- `);
195199
+ for (const entry of entries) {
195200
+ output += formatEntry(entry);
195201
+ }
195202
+ return output;
195154
195203
  }
195155
195204
  function normalizeLogEntry(entry, functionName) {
195156
195205
  return {
@@ -195168,7 +195217,7 @@ async function fetchLogsForFunctions(functionNames, options, availableFunctionNa
195168
195217
  try {
195169
195218
  logs = await fetchFunctionLogs(functionName, filters);
195170
195219
  } catch (error48) {
195171
- if (error48 instanceof ApiError && error48.statusCode === 404 && availableFunctionNames.length > 0) {
195220
+ if (error48 instanceof FunctionNotFoundError && availableFunctionNames.length > 0) {
195172
195221
  const available = availableFunctionNames.join(", ");
195173
195222
  throw new InvalidInputError(`Function "${functionName}" was not found in this app`, {
195174
195223
  hints: [
@@ -195198,29 +195247,29 @@ async function getAllFunctionNames() {
195198
195247
  return functions.map((fn) => fn.name);
195199
195248
  }
195200
195249
  async function logsAction(options) {
195250
+ if (options.since)
195251
+ options.since = normalizeDatetime(options.since);
195252
+ if (options.until)
195253
+ options.until = normalizeDatetime(options.until);
195254
+ validateOptions2(options);
195201
195255
  const specifiedFunctions = parseFunctionNames(options.function);
195202
195256
  const allProjectFunctions = await getAllFunctionNames();
195203
195257
  const functionNames = specifiedFunctions.length > 0 ? specifiedFunctions : allProjectFunctions;
195204
195258
  if (functionNames.length === 0) {
195205
- return { outroMessage: "No functions found in this project." };
195259
+ return { stdout: `No functions found in this project.
195260
+ ` };
195206
195261
  }
195207
195262
  let entries = await fetchLogsForFunctions(functionNames, options, allProjectFunctions);
195208
195263
  const limit = options.limit ? Number.parseInt(options.limit, 10) : undefined;
195209
195264
  if (limit !== undefined && entries.length > limit) {
195210
195265
  entries = entries.slice(0, limit);
195211
195266
  }
195212
- const logsOutput = options.json ? `${JSON.stringify(entries, null, 2)}
195267
+ const stdout = options.json ? `${JSON.stringify(entries, null, 2)}
195213
195268
  ` : formatLogs(entries);
195214
- return { outroMessage: "Fetched logs", stdout: logsOutput };
195269
+ return { stdout };
195215
195270
  }
195216
195271
  function getLogsCommand(context) {
195217
- return new Command("logs").description("Fetch function logs for this app").option("--function <names>", "Filter by function name(s), comma-separated. If omitted, fetches logs for all project functions").option("--since <datetime>", "Show logs from this time (ISO format)", normalizeDatetime).option("--until <datetime>", "Show logs until this time (ISO format)", normalizeDatetime).option("-n, --limit <n>", "Results per page (1-1000, default: 50)", (v) => {
195218
- const n2 = Number.parseInt(v, 10);
195219
- if (Number.isNaN(n2) || n2 < 1 || n2 > 1000) {
195220
- throw new InvalidInputError(`Invalid limit: "${v}". Must be a number between 1 and 1000.`);
195221
- }
195222
- return v;
195223
- }).addOption(new Option("--order <order>", "Sort order").choices(["asc", "desc"])).option("--json", "Output raw JSON").action(async (options) => {
195272
+ return new Command("logs").description("Fetch function logs for this app").option("--function <names>", "Filter by function name(s), comma-separated. If omitted, fetches logs for all project functions").option("--since <datetime>", "Show logs from this time (ISO format)").option("--until <datetime>", "Show logs until this time (ISO format)").option("--level <level>", "Filter by log level: log, info, warn, error, debug").option("-n, --limit <n>", "Results per page (1-1000, default: 50)").option("--order <order>", "Sort order: ASC|DESC (default: DESC)").option("--json", "Output raw JSON").action(async (options) => {
195224
195273
  await runCommand(() => logsAction(options), { requireAuth: true }, context);
195225
195274
  });
195226
195275
  }
@@ -200605,4 +200654,4 @@ export {
200605
200654
  CLIExitError
200606
200655
  };
200607
200656
 
200608
- //# debugId=BDC2926C94F34D8D64756E2164756E21
200657
+ //# debugId=00151F47FED4FE2F64756E2164756E21