@base44-preview/cli 0.0.30-pr.223.517d2cd → 0.0.30-pr.225.d99f29e
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 +243 -12
- package/dist/cli/index.js.map +8 -7
- package/package.json +1 -1
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
|
|
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 =
|
|
136904
|
+
exports.validateOptions = validateOptions3;
|
|
136905
136905
|
});
|
|
136906
136906
|
|
|
136907
136907
|
// node_modules/json-schema-to-typescript/dist/src/index.js
|
|
@@ -154019,8 +154019,32 @@ var DeployFunctionsResponseSchema = exports_external.object({
|
|
|
154019
154019
|
skipped: exports_external.array(exports_external.string()).optional().nullable(),
|
|
154020
154020
|
errors: exports_external.array(exports_external.object({ name: exports_external.string(), message: exports_external.string() })).nullable()
|
|
154021
154021
|
});
|
|
154022
|
+
var LogLevelSchema = exports_external.enum(["log", "info", "warn", "error", "debug"]);
|
|
154023
|
+
var FunctionLogEntrySchema = exports_external.object({
|
|
154024
|
+
time: exports_external.string(),
|
|
154025
|
+
level: LogLevelSchema,
|
|
154026
|
+
message: exports_external.string()
|
|
154027
|
+
});
|
|
154028
|
+
var FunctionLogsResponseSchema = exports_external.array(FunctionLogEntrySchema);
|
|
154022
154029
|
|
|
154023
154030
|
// src/core/resources/function/api.ts
|
|
154031
|
+
class FunctionNotFoundError extends ApiError {
|
|
154032
|
+
constructor(functionName, cause) {
|
|
154033
|
+
super(`Function "${functionName}" was not found in this app`, {
|
|
154034
|
+
statusCode: 404,
|
|
154035
|
+
cause,
|
|
154036
|
+
hints: [
|
|
154037
|
+
{
|
|
154038
|
+
message: "Make sure the function name is correct and has been deployed",
|
|
154039
|
+
command: "base44 functions deploy"
|
|
154040
|
+
},
|
|
154041
|
+
{
|
|
154042
|
+
message: "List project functions by checking the base44/functions/ directory"
|
|
154043
|
+
}
|
|
154044
|
+
]
|
|
154045
|
+
});
|
|
154046
|
+
}
|
|
154047
|
+
}
|
|
154024
154048
|
function toDeployPayloadItem(fn) {
|
|
154025
154049
|
return {
|
|
154026
154050
|
name: fn.name,
|
|
@@ -154049,6 +154073,55 @@ async function deployFunctions(functions) {
|
|
|
154049
154073
|
}
|
|
154050
154074
|
return result.data;
|
|
154051
154075
|
}
|
|
154076
|
+
function buildLogsQueryString(filters) {
|
|
154077
|
+
const params = new URLSearchParams;
|
|
154078
|
+
if (filters.since) {
|
|
154079
|
+
params.set("since", filters.since);
|
|
154080
|
+
}
|
|
154081
|
+
if (filters.until) {
|
|
154082
|
+
params.set("until", filters.until);
|
|
154083
|
+
}
|
|
154084
|
+
if (filters.level) {
|
|
154085
|
+
params.set("level", filters.level);
|
|
154086
|
+
}
|
|
154087
|
+
if (filters.limit !== undefined) {
|
|
154088
|
+
params.set("limit", String(filters.limit));
|
|
154089
|
+
}
|
|
154090
|
+
if (filters.order) {
|
|
154091
|
+
params.set("order", filters.order);
|
|
154092
|
+
}
|
|
154093
|
+
const queryString = params.toString();
|
|
154094
|
+
return queryString ? `?${queryString}` : "";
|
|
154095
|
+
}
|
|
154096
|
+
async function fetchFunctionLogs(functionName, filters = {}) {
|
|
154097
|
+
const appClient = getAppClient();
|
|
154098
|
+
const queryString = buildLogsQueryString(filters);
|
|
154099
|
+
let response;
|
|
154100
|
+
try {
|
|
154101
|
+
response = await appClient.get(`functions-mgmt/${functionName}/logs${queryString}`);
|
|
154102
|
+
} catch (error48) {
|
|
154103
|
+
if (error48 instanceof HTTPError) {
|
|
154104
|
+
if (error48.response.status === 404) {
|
|
154105
|
+
throw new FunctionNotFoundError(functionName, error48);
|
|
154106
|
+
}
|
|
154107
|
+
try {
|
|
154108
|
+
const body = await error48.response.clone().json();
|
|
154109
|
+
if (body.error_type === "KeyError") {
|
|
154110
|
+
throw new FunctionNotFoundError(functionName, error48);
|
|
154111
|
+
}
|
|
154112
|
+
} catch (parseError) {
|
|
154113
|
+
if (parseError instanceof ApiError)
|
|
154114
|
+
throw parseError;
|
|
154115
|
+
}
|
|
154116
|
+
}
|
|
154117
|
+
throw await ApiError.fromHttpError(error48, `fetching function logs: '${functionName}'`);
|
|
154118
|
+
}
|
|
154119
|
+
const result = FunctionLogsResponseSchema.safeParse(await response.json());
|
|
154120
|
+
if (!result.success) {
|
|
154121
|
+
throw new SchemaValidationError("Invalid function logs response from server", result.error);
|
|
154122
|
+
}
|
|
154123
|
+
return result.data;
|
|
154124
|
+
}
|
|
154052
154125
|
// src/core/resources/function/config.ts
|
|
154053
154126
|
import { dirname as dirname3, join as join3 } from "node:path";
|
|
154054
154127
|
async function readFunctionConfig(configPath) {
|
|
@@ -168812,14 +168885,18 @@ async function printUpgradeNotificationIfAvailable() {
|
|
|
168812
168885
|
|
|
168813
168886
|
// src/cli/utils/runCommand.ts
|
|
168814
168887
|
async function runCommand(commandFn, options, context) {
|
|
168815
|
-
|
|
168816
|
-
|
|
168817
|
-
|
|
168818
|
-
|
|
168819
|
-
|
|
168820
|
-
|
|
168888
|
+
const skipIntro = options?.skipIntro === true;
|
|
168889
|
+
const skipOutro = options?.skipOutro === true;
|
|
168890
|
+
if (!skipIntro) {
|
|
168891
|
+
console.log();
|
|
168892
|
+
if (options?.fullBanner) {
|
|
168893
|
+
await printBanner();
|
|
168894
|
+
Ie("");
|
|
168895
|
+
} else {
|
|
168896
|
+
Ie(theme.colors.base44OrangeBackground(" Base 44 "));
|
|
168897
|
+
}
|
|
168898
|
+
await printUpgradeNotificationIfAvailable();
|
|
168821
168899
|
}
|
|
168822
|
-
await printUpgradeNotificationIfAvailable();
|
|
168823
168900
|
try {
|
|
168824
168901
|
if (options?.requireAuth) {
|
|
168825
168902
|
const loggedIn = await isLoggedIn();
|
|
@@ -168839,7 +168916,9 @@ async function runCommand(commandFn, options, context) {
|
|
|
168839
168916
|
context.errorReporter.setContext({ appId: appConfig.id });
|
|
168840
168917
|
}
|
|
168841
168918
|
const { outroMessage } = await commandFn();
|
|
168842
|
-
|
|
168919
|
+
if (!skipOutro) {
|
|
168920
|
+
Se(outroMessage || "");
|
|
168921
|
+
}
|
|
168843
168922
|
} catch (error48) {
|
|
168844
168923
|
const errorMessage = error48 instanceof Error ? error48.message : String(error48);
|
|
168845
168924
|
M2.error(errorMessage);
|
|
@@ -168853,7 +168932,12 @@ async function runCommand(commandFn, options, context) {
|
|
|
168853
168932
|
}
|
|
168854
168933
|
}
|
|
168855
168934
|
const errorContext = context.errorReporter.getErrorContext();
|
|
168856
|
-
|
|
168935
|
+
if (!skipOutro) {
|
|
168936
|
+
Se(theme.format.errorContext(errorContext));
|
|
168937
|
+
} else {
|
|
168938
|
+
process.stderr.write(`${theme.format.errorContext(errorContext)}
|
|
168939
|
+
`);
|
|
168940
|
+
}
|
|
168857
168941
|
throw error48;
|
|
168858
168942
|
}
|
|
168859
168943
|
}
|
|
@@ -169669,6 +169753,152 @@ function getFunctionsDeployCommand(context) {
|
|
|
169669
169753
|
}));
|
|
169670
169754
|
}
|
|
169671
169755
|
|
|
169756
|
+
// src/cli/commands/logs/index.ts
|
|
169757
|
+
var VALID_LEVELS = ["log", "info", "warn", "error", "debug"];
|
|
169758
|
+
function parseFunctionFilters(options) {
|
|
169759
|
+
const filters = {};
|
|
169760
|
+
if (options.since) {
|
|
169761
|
+
filters.since = options.since;
|
|
169762
|
+
}
|
|
169763
|
+
if (options.until) {
|
|
169764
|
+
filters.until = options.until;
|
|
169765
|
+
}
|
|
169766
|
+
if (options.level) {
|
|
169767
|
+
filters.level = options.level;
|
|
169768
|
+
}
|
|
169769
|
+
if (options.limit) {
|
|
169770
|
+
filters.limit = Number.parseInt(options.limit, 10);
|
|
169771
|
+
}
|
|
169772
|
+
if (options.order) {
|
|
169773
|
+
filters.order = options.order.toLowerCase();
|
|
169774
|
+
}
|
|
169775
|
+
return filters;
|
|
169776
|
+
}
|
|
169777
|
+
function parseFunctionNames(option) {
|
|
169778
|
+
if (!option)
|
|
169779
|
+
return [];
|
|
169780
|
+
return option.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
169781
|
+
}
|
|
169782
|
+
function normalizeDatetime(value) {
|
|
169783
|
+
if (/Z|[+-]\d{2}:\d{2}$/.test(value))
|
|
169784
|
+
return value;
|
|
169785
|
+
return `${value}Z`;
|
|
169786
|
+
}
|
|
169787
|
+
function validateOptions2(options) {
|
|
169788
|
+
if (options.level && !VALID_LEVELS.includes(options.level)) {
|
|
169789
|
+
throw new InvalidInputError(`Invalid level: "${options.level}". Must be one of: ${VALID_LEVELS.join(", ")}.`);
|
|
169790
|
+
}
|
|
169791
|
+
if (options.limit) {
|
|
169792
|
+
const limit = Number.parseInt(options.limit, 10);
|
|
169793
|
+
if (Number.isNaN(limit) || limit < 1 || limit > 1000) {
|
|
169794
|
+
throw new InvalidInputError(`Invalid limit: "${options.limit}". Must be a number between 1 and 1000.`);
|
|
169795
|
+
}
|
|
169796
|
+
}
|
|
169797
|
+
if (options.order) {
|
|
169798
|
+
const order = options.order.toUpperCase();
|
|
169799
|
+
if (order !== "ASC" && order !== "DESC") {
|
|
169800
|
+
throw new InvalidInputError(`Invalid order: "${options.order}". Must be "ASC" or "DESC".`);
|
|
169801
|
+
}
|
|
169802
|
+
}
|
|
169803
|
+
}
|
|
169804
|
+
function formatEntry(entry) {
|
|
169805
|
+
const time3 = entry.time.substring(0, 19).replace("T", " ");
|
|
169806
|
+
const level = entry.level.toUpperCase().padEnd(5);
|
|
169807
|
+
const message = entry.message.trim();
|
|
169808
|
+
return `${time3} ${level} ${message}
|
|
169809
|
+
`;
|
|
169810
|
+
}
|
|
169811
|
+
function displayLogs(entries) {
|
|
169812
|
+
if (entries.length === 0) {
|
|
169813
|
+
process.stdout.write(`No logs found matching the filters.
|
|
169814
|
+
`);
|
|
169815
|
+
return;
|
|
169816
|
+
}
|
|
169817
|
+
process.stdout.write(`Showing ${entries.length} function log entries
|
|
169818
|
+
|
|
169819
|
+
`);
|
|
169820
|
+
for (const entry of entries) {
|
|
169821
|
+
process.stdout.write(formatEntry(entry));
|
|
169822
|
+
}
|
|
169823
|
+
}
|
|
169824
|
+
function normalizeLogEntry(entry, functionName) {
|
|
169825
|
+
return {
|
|
169826
|
+
time: entry.time,
|
|
169827
|
+
level: entry.level,
|
|
169828
|
+
message: `[${functionName}] ${entry.message}`,
|
|
169829
|
+
source: functionName
|
|
169830
|
+
};
|
|
169831
|
+
}
|
|
169832
|
+
async function fetchLogsForFunctions(functionNames, options, availableFunctionNames) {
|
|
169833
|
+
const filters = parseFunctionFilters(options);
|
|
169834
|
+
const allEntries = [];
|
|
169835
|
+
for (const functionName of functionNames) {
|
|
169836
|
+
let logs;
|
|
169837
|
+
try {
|
|
169838
|
+
logs = await fetchFunctionLogs(functionName, filters);
|
|
169839
|
+
} catch (error48) {
|
|
169840
|
+
if (error48 instanceof FunctionNotFoundError && availableFunctionNames.length > 0) {
|
|
169841
|
+
const available = availableFunctionNames.join(", ");
|
|
169842
|
+
throw new InvalidInputError(`Function "${functionName}" was not found in this app`, {
|
|
169843
|
+
hints: [
|
|
169844
|
+
{
|
|
169845
|
+
message: `Available functions in this project: ${available}`
|
|
169846
|
+
},
|
|
169847
|
+
{
|
|
169848
|
+
message: "Make sure the function has been deployed before fetching logs",
|
|
169849
|
+
command: "base44 functions deploy"
|
|
169850
|
+
}
|
|
169851
|
+
]
|
|
169852
|
+
});
|
|
169853
|
+
}
|
|
169854
|
+
throw error48;
|
|
169855
|
+
}
|
|
169856
|
+
const entries = logs.map((entry) => normalizeLogEntry(entry, functionName));
|
|
169857
|
+
allEntries.push(...entries);
|
|
169858
|
+
}
|
|
169859
|
+
if (functionNames.length > 1) {
|
|
169860
|
+
const order = options.order?.toUpperCase() === "ASC" ? 1 : -1;
|
|
169861
|
+
allEntries.sort((a2, b3) => order * a2.time.localeCompare(b3.time));
|
|
169862
|
+
}
|
|
169863
|
+
return allEntries;
|
|
169864
|
+
}
|
|
169865
|
+
async function getAllFunctionNames() {
|
|
169866
|
+
const { functions } = await readProjectConfig();
|
|
169867
|
+
return functions.map((fn) => fn.name);
|
|
169868
|
+
}
|
|
169869
|
+
async function logsAction(options) {
|
|
169870
|
+
if (options.since)
|
|
169871
|
+
options.since = normalizeDatetime(options.since);
|
|
169872
|
+
if (options.until)
|
|
169873
|
+
options.until = normalizeDatetime(options.until);
|
|
169874
|
+
validateOptions2(options);
|
|
169875
|
+
const specifiedFunctions = parseFunctionNames(options.function);
|
|
169876
|
+
const allProjectFunctions = await getAllFunctionNames();
|
|
169877
|
+
const functionNames = specifiedFunctions.length > 0 ? specifiedFunctions : allProjectFunctions;
|
|
169878
|
+
if (functionNames.length === 0) {
|
|
169879
|
+
process.stdout.write(`No functions found in this project.
|
|
169880
|
+
`);
|
|
169881
|
+
return {};
|
|
169882
|
+
}
|
|
169883
|
+
let entries = await fetchLogsForFunctions(functionNames, options, allProjectFunctions);
|
|
169884
|
+
const limit = options.limit ? Number.parseInt(options.limit, 10) : undefined;
|
|
169885
|
+
if (limit !== undefined && entries.length > limit) {
|
|
169886
|
+
entries = entries.slice(0, limit);
|
|
169887
|
+
}
|
|
169888
|
+
if (options.json) {
|
|
169889
|
+
process.stdout.write(`${JSON.stringify(entries, null, 2)}
|
|
169890
|
+
`);
|
|
169891
|
+
} else {
|
|
169892
|
+
displayLogs(entries);
|
|
169893
|
+
}
|
|
169894
|
+
return {};
|
|
169895
|
+
}
|
|
169896
|
+
function getLogsCommand(context) {
|
|
169897
|
+
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) => {
|
|
169898
|
+
await runCommand(() => logsAction(options), { requireAuth: true, skipIntro: true, skipOutro: true }, context);
|
|
169899
|
+
});
|
|
169900
|
+
}
|
|
169901
|
+
|
|
169672
169902
|
// src/cli/commands/project/create.ts
|
|
169673
169903
|
import { basename as basename3, join as join9, resolve as resolve2 } from "node:path";
|
|
169674
169904
|
var import_lodash = __toESM(require_lodash(), 1);
|
|
@@ -170251,6 +170481,7 @@ function createProgram(context) {
|
|
|
170251
170481
|
program2.addCommand(getFunctionsDeployCommand(context));
|
|
170252
170482
|
program2.addCommand(getSiteCommand(context));
|
|
170253
170483
|
program2.addCommand(getTypesCommand(context), { hidden: true });
|
|
170484
|
+
program2.addCommand(getLogsCommand(context));
|
|
170254
170485
|
return program2;
|
|
170255
170486
|
}
|
|
170256
170487
|
|
|
@@ -174517,4 +174748,4 @@ export {
|
|
|
174517
174748
|
CLIExitError
|
|
174518
174749
|
};
|
|
174519
174750
|
|
|
174520
|
-
//# debugId=
|
|
174751
|
+
//# debugId=9E4AB83C2BF609E364756E2164756E21
|