@base44-preview/cli 0.0.56-pr.551.d02ef77 → 0.0.56-pr.552.590deb5
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 +45 -46
- package/dist/cli/index.js.map +6 -6
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -243426,7 +243426,7 @@ var ListFunctionsResponseSchema = exports_external.object({
|
|
|
243426
243426
|
var LogLevelSchema = exports_external.enum(["info", "warning", "error", "debug"]);
|
|
243427
243427
|
var FunctionLogEntrySchema = exports_external.object({
|
|
243428
243428
|
time: exports_external.string(),
|
|
243429
|
-
level: LogLevelSchema,
|
|
243429
|
+
level: exports_external.preprocess((v) => v === "warn" ? "warning" : !v || v === "log" ? "info" : v, LogLevelSchema),
|
|
243430
243430
|
message: exports_external.string()
|
|
243431
243431
|
});
|
|
243432
243432
|
var FunctionLogsResponseSchema = exports_external.array(FunctionLogEntrySchema);
|
|
@@ -243487,9 +243487,6 @@ function buildLogsQueryString(filters) {
|
|
|
243487
243487
|
if (filters.order) {
|
|
243488
243488
|
params.set("order", filters.order);
|
|
243489
243489
|
}
|
|
243490
|
-
if (filters.env) {
|
|
243491
|
-
params.set("env", filters.env);
|
|
243492
|
-
}
|
|
243493
243490
|
return params;
|
|
243494
243491
|
}
|
|
243495
243492
|
async function fetchFunctionLogs(functionName, filters = {}) {
|
|
@@ -251109,9 +251106,12 @@ class Base44Command extends Command {
|
|
|
251109
251106
|
}
|
|
251110
251107
|
return this._context;
|
|
251111
251108
|
}
|
|
251109
|
+
isRawOutputMode() {
|
|
251110
|
+
return this.opts().format === "json";
|
|
251111
|
+
}
|
|
251112
251112
|
action(fn) {
|
|
251113
251113
|
return super.action(async (...args) => {
|
|
251114
|
-
const quiet = this.context.isNonInteractive;
|
|
251114
|
+
const quiet = this.context.isNonInteractive || this.isRawOutputMode();
|
|
251115
251115
|
if (!quiet) {
|
|
251116
251116
|
await showCommandStart(this._commandOptions.fullBanner);
|
|
251117
251117
|
}
|
|
@@ -253499,9 +253499,6 @@ function parseFunctionFilters(options) {
|
|
|
253499
253499
|
if (options.order) {
|
|
253500
253500
|
filters.order = options.order.toLowerCase();
|
|
253501
253501
|
}
|
|
253502
|
-
if (options.env) {
|
|
253503
|
-
filters.env = options.env;
|
|
253504
|
-
}
|
|
253505
253502
|
return filters;
|
|
253506
253503
|
}
|
|
253507
253504
|
function parseFunctionNames(option) {
|
|
@@ -253510,6 +253507,11 @@ function parseFunctionNames(option) {
|
|
|
253510
253507
|
return option.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
253511
253508
|
}
|
|
253512
253509
|
function normalizeDatetime(value) {
|
|
253510
|
+
const rel = value.match(/^(\d+)(m|h|d)$/);
|
|
253511
|
+
if (rel) {
|
|
253512
|
+
const ms = rel[2] === "m" ? Number(rel[1]) * 60000 : rel[2] === "h" ? Number(rel[1]) * 3600000 : Number(rel[1]) * 86400000;
|
|
253513
|
+
return new Date(Date.now() - ms).toISOString();
|
|
253514
|
+
}
|
|
253513
253515
|
if (/Z$|[+-]\d{2}:\d{2}$/.test(value))
|
|
253514
253516
|
return value;
|
|
253515
253517
|
return `${value}Z`;
|
|
@@ -253538,44 +253540,37 @@ function normalizeLogEntry(entry, functionName) {
|
|
|
253538
253540
|
source: functionName
|
|
253539
253541
|
};
|
|
253540
253542
|
}
|
|
253541
|
-
async function fetchLogsForFunction(functionName, filters, availableFunctionNames) {
|
|
253542
|
-
try {
|
|
253543
|
-
return await fetchFunctionLogs(functionName, filters);
|
|
253544
|
-
} catch (error48) {
|
|
253545
|
-
if (error48 instanceof ApiError && error48.statusCode === 404 && availableFunctionNames.length > 0) {
|
|
253546
|
-
const available = availableFunctionNames.join(", ");
|
|
253547
|
-
throw new InvalidInputError(`Function "${functionName}" was not found in this app`, {
|
|
253548
|
-
hints: [
|
|
253549
|
-
{ message: `Available functions in this project: ${available}` },
|
|
253550
|
-
{
|
|
253551
|
-
message: "Make sure the function has been deployed before fetching logs",
|
|
253552
|
-
command: "base44 functions deploy"
|
|
253553
|
-
}
|
|
253554
|
-
]
|
|
253555
|
-
});
|
|
253556
|
-
}
|
|
253557
|
-
throw error48;
|
|
253558
|
-
}
|
|
253559
|
-
}
|
|
253560
253543
|
async function fetchLogsForFunctions(functionNames, options, availableFunctionNames) {
|
|
253561
|
-
const
|
|
253562
|
-
const envs = env3 === "all" ? ["preview", "prod"] : [env3];
|
|
253544
|
+
const filters = parseFunctionFilters(options);
|
|
253563
253545
|
const allEntries = [];
|
|
253564
253546
|
for (const functionName of functionNames) {
|
|
253565
|
-
|
|
253566
|
-
|
|
253567
|
-
|
|
253547
|
+
let logs;
|
|
253548
|
+
try {
|
|
253549
|
+
logs = await fetchFunctionLogs(functionName, filters);
|
|
253550
|
+
} catch (error48) {
|
|
253551
|
+
if (error48 instanceof ApiError && error48.statusCode === 404 && availableFunctionNames.length > 0) {
|
|
253552
|
+
const available = availableFunctionNames.join(", ");
|
|
253553
|
+
throw new InvalidInputError(`Function "${functionName}" was not found in this app`, {
|
|
253554
|
+
hints: [
|
|
253555
|
+
{
|
|
253556
|
+
message: `Available functions in this project: ${available}`
|
|
253557
|
+
},
|
|
253558
|
+
{
|
|
253559
|
+
message: "Make sure the function has been deployed before fetching logs",
|
|
253560
|
+
command: "base44 functions deploy"
|
|
253561
|
+
}
|
|
253562
|
+
]
|
|
253563
|
+
});
|
|
253564
|
+
}
|
|
253565
|
+
throw error48;
|
|
253566
|
+
}
|
|
253567
|
+
allEntries.push(...logs.map((entry) => normalizeLogEntry(entry, functionName)));
|
|
253568
253568
|
}
|
|
253569
|
-
|
|
253570
|
-
|
|
253571
|
-
|
|
253572
|
-
|
|
253573
|
-
|
|
253574
|
-
if (seen.has(key))
|
|
253575
|
-
return false;
|
|
253576
|
-
seen.add(key);
|
|
253577
|
-
return true;
|
|
253578
|
-
});
|
|
253569
|
+
if (functionNames.length > 1) {
|
|
253570
|
+
const order = options.order?.toUpperCase() === "ASC" ? 1 : -1;
|
|
253571
|
+
allEntries.sort((a2, b) => order * a2.time.localeCompare(b.time));
|
|
253572
|
+
}
|
|
253573
|
+
return allEntries;
|
|
253579
253574
|
}
|
|
253580
253575
|
async function getProjectFunctionNames(projectRoot) {
|
|
253581
253576
|
const { functions } = await readProjectConfig(projectRoot);
|
|
@@ -253609,12 +253604,16 @@ async function logsAction(ctx, options) {
|
|
|
253609
253604
|
if (limit !== undefined && entries.length > limit) {
|
|
253610
253605
|
entries = entries.slice(0, limit);
|
|
253611
253606
|
}
|
|
253612
|
-
const logsOutput = options.json ? `${JSON.stringify(entries, null, 2)}
|
|
253607
|
+
const logsOutput = options.format === "json" ? `${JSON.stringify(entries, null, 2)}
|
|
253613
253608
|
` : formatLogs(entries);
|
|
253614
|
-
|
|
253609
|
+
const shouldOutputOutroMessage = options.format !== "json";
|
|
253610
|
+
return {
|
|
253611
|
+
outroMessage: shouldOutputOutroMessage ? "Fetched logs" : undefined,
|
|
253612
|
+
stdout: logsOutput
|
|
253613
|
+
};
|
|
253615
253614
|
}
|
|
253616
253615
|
function getLogsCommand() {
|
|
253617
|
-
return new Base44Command("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).addOption(new Option("--level <level>", "Filter by log level").choices([...LogLevelSchema.options]).hideHelp()).option("-n, --limit <n>", "Results per page (1-1000, default: 50)").addOption(new Option("--order <order>", "Sort order").choices(["asc", "desc"])).addOption(new Option("--
|
|
253616
|
+
return new Base44Command("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).addOption(new Option("--level <level>", "Filter by log level").choices([...LogLevelSchema.options]).hideHelp()).option("-n, --limit <n>", "Results per page (1-1000, default: 50)").addOption(new Option("--order <order>", "Sort order").choices(["asc", "desc"])).addOption(new Option("--format <format>", "Output format").choices(["text", "json"]).default("text")).action(logsAction);
|
|
253618
253617
|
}
|
|
253619
253618
|
|
|
253620
253619
|
// src/cli/commands/project/scaffold.ts
|
|
@@ -261990,4 +261989,4 @@ export {
|
|
|
261990
261989
|
CLIExitError
|
|
261991
261990
|
};
|
|
261992
261991
|
|
|
261993
|
-
//# debugId=
|
|
261992
|
+
//# debugId=56490DCED052362F64756E2164756E21
|