@base44-preview/cli 0.0.33-pr.225.299669a → 0.0.33-pr.225.3509af6
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 +132 -181
- package/dist/cli/index.js.map +9 -9
- 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 validateOptions2({ 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 = validateOptions2;
|
|
136905
136905
|
});
|
|
136906
136906
|
|
|
136907
136907
|
// node_modules/json-schema-to-typescript/dist/src/index.js
|
|
@@ -178557,9 +178557,10 @@ class ApiError extends SystemError {
|
|
|
178557
178557
|
} catch {
|
|
178558
178558
|
message = error48.message;
|
|
178559
178559
|
}
|
|
178560
|
+
const statusCode = ApiError.normalizeStatusCode(error48.response.status, responseBody);
|
|
178560
178561
|
const requestBody = error48.options.context?.__requestBody;
|
|
178561
178562
|
return new ApiError(`Error ${context}: ${message}`, {
|
|
178562
|
-
statusCode
|
|
178563
|
+
statusCode,
|
|
178563
178564
|
requestUrl: error48.request.url,
|
|
178564
178565
|
requestMethod: error48.request.method,
|
|
178565
178566
|
requestBody,
|
|
@@ -178616,6 +178617,12 @@ class ApiError extends SystemError {
|
|
|
178616
178617
|
return;
|
|
178617
178618
|
return REASON_HINTS[reason];
|
|
178618
178619
|
}
|
|
178620
|
+
static normalizeStatusCode(statusCode, responseBody) {
|
|
178621
|
+
if (responseBody?.error_type === "KeyError") {
|
|
178622
|
+
return 404;
|
|
178623
|
+
}
|
|
178624
|
+
return statusCode;
|
|
178625
|
+
}
|
|
178619
178626
|
}
|
|
178620
178627
|
|
|
178621
178628
|
class FileNotFoundError extends SystemError {
|
|
@@ -178642,24 +178649,6 @@ class FileReadError extends SystemError {
|
|
|
178642
178649
|
}
|
|
178643
178650
|
}
|
|
178644
178651
|
|
|
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
|
-
|
|
178663
178652
|
class InternalError extends SystemError {
|
|
178664
178653
|
code = "INTERNAL_ERROR";
|
|
178665
178654
|
constructor(message, options) {
|
|
@@ -186084,30 +186073,17 @@ function buildLogsQueryString(filters) {
|
|
|
186084
186073
|
if (filters.order) {
|
|
186085
186074
|
params.set("order", filters.order);
|
|
186086
186075
|
}
|
|
186087
|
-
|
|
186088
|
-
return queryString ? `?${queryString}` : "";
|
|
186076
|
+
return params;
|
|
186089
186077
|
}
|
|
186090
186078
|
async function fetchFunctionLogs(functionName, filters = {}) {
|
|
186091
186079
|
const appClient = getAppClient();
|
|
186092
|
-
const
|
|
186080
|
+
const searchParams = buildLogsQueryString(filters);
|
|
186093
186081
|
let response;
|
|
186094
186082
|
try {
|
|
186095
|
-
response = await appClient.get(`functions-mgmt/${functionName}/logs
|
|
186083
|
+
response = await appClient.get(`functions-mgmt/${functionName}/logs`, {
|
|
186084
|
+
searchParams
|
|
186085
|
+
});
|
|
186096
186086
|
} 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
|
-
}
|
|
186111
186087
|
throw await ApiError.fromHttpError(error48, `fetching function logs: '${functionName}'`);
|
|
186112
186088
|
}
|
|
186113
186089
|
const result = FunctionLogsResponseSchema.safeParse(await response.json());
|
|
@@ -195133,147 +195109,6 @@ function getFunctionsDeployCommand(context) {
|
|
|
195133
195109
|
}));
|
|
195134
195110
|
}
|
|
195135
195111
|
|
|
195136
|
-
// src/cli/commands/logs/index.ts
|
|
195137
|
-
var VALID_LEVELS = ["log", "info", "warn", "error", "debug"];
|
|
195138
|
-
function parseFunctionFilters(options) {
|
|
195139
|
-
const filters = {};
|
|
195140
|
-
if (options.since) {
|
|
195141
|
-
filters.since = options.since;
|
|
195142
|
-
}
|
|
195143
|
-
if (options.until) {
|
|
195144
|
-
filters.until = options.until;
|
|
195145
|
-
}
|
|
195146
|
-
if (options.level) {
|
|
195147
|
-
filters.level = options.level;
|
|
195148
|
-
}
|
|
195149
|
-
if (options.limit) {
|
|
195150
|
-
filters.limit = Number.parseInt(options.limit, 10);
|
|
195151
|
-
}
|
|
195152
|
-
if (options.order) {
|
|
195153
|
-
filters.order = options.order.toLowerCase();
|
|
195154
|
-
}
|
|
195155
|
-
return filters;
|
|
195156
|
-
}
|
|
195157
|
-
function parseFunctionNames(option) {
|
|
195158
|
-
if (!option)
|
|
195159
|
-
return [];
|
|
195160
|
-
return option.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
195161
|
-
}
|
|
195162
|
-
function normalizeDatetime(value) {
|
|
195163
|
-
if (/Z$|[+-]\d{2}:\d{2}$/.test(value))
|
|
195164
|
-
return value;
|
|
195165
|
-
return `${value}Z`;
|
|
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
|
-
}
|
|
195184
|
-
function formatEntry(entry) {
|
|
195185
|
-
const time3 = entry.time.substring(0, 19).replace("T", " ");
|
|
195186
|
-
const level = entry.level.toUpperCase().padEnd(5);
|
|
195187
|
-
const message = entry.message.trim();
|
|
195188
|
-
return `${time3} ${level} ${message}
|
|
195189
|
-
`;
|
|
195190
|
-
}
|
|
195191
|
-
function formatLogs(entries) {
|
|
195192
|
-
if (entries.length === 0) {
|
|
195193
|
-
return `No logs found matching the filters.
|
|
195194
|
-
`;
|
|
195195
|
-
}
|
|
195196
|
-
let output = `Showing ${entries.length} function log entries
|
|
195197
|
-
|
|
195198
|
-
`;
|
|
195199
|
-
for (const entry of entries) {
|
|
195200
|
-
output += formatEntry(entry);
|
|
195201
|
-
}
|
|
195202
|
-
return output;
|
|
195203
|
-
}
|
|
195204
|
-
function normalizeLogEntry(entry, functionName) {
|
|
195205
|
-
return {
|
|
195206
|
-
time: entry.time,
|
|
195207
|
-
level: entry.level,
|
|
195208
|
-
message: `[${functionName}] ${entry.message}`,
|
|
195209
|
-
source: functionName
|
|
195210
|
-
};
|
|
195211
|
-
}
|
|
195212
|
-
async function fetchLogsForFunctions(functionNames, options, availableFunctionNames) {
|
|
195213
|
-
const filters = parseFunctionFilters(options);
|
|
195214
|
-
const allEntries = [];
|
|
195215
|
-
for (const functionName of functionNames) {
|
|
195216
|
-
let logs;
|
|
195217
|
-
try {
|
|
195218
|
-
logs = await fetchFunctionLogs(functionName, filters);
|
|
195219
|
-
} catch (error48) {
|
|
195220
|
-
if (error48 instanceof FunctionNotFoundError && availableFunctionNames.length > 0) {
|
|
195221
|
-
const available = availableFunctionNames.join(", ");
|
|
195222
|
-
throw new InvalidInputError(`Function "${functionName}" was not found in this app`, {
|
|
195223
|
-
hints: [
|
|
195224
|
-
{
|
|
195225
|
-
message: `Available functions in this project: ${available}`
|
|
195226
|
-
},
|
|
195227
|
-
{
|
|
195228
|
-
message: "Make sure the function has been deployed before fetching logs",
|
|
195229
|
-
command: "base44 functions deploy"
|
|
195230
|
-
}
|
|
195231
|
-
]
|
|
195232
|
-
});
|
|
195233
|
-
}
|
|
195234
|
-
throw error48;
|
|
195235
|
-
}
|
|
195236
|
-
const entries = logs.map((entry) => normalizeLogEntry(entry, functionName));
|
|
195237
|
-
allEntries.push(...entries);
|
|
195238
|
-
}
|
|
195239
|
-
if (functionNames.length > 1) {
|
|
195240
|
-
const order = options.order?.toUpperCase() === "ASC" ? 1 : -1;
|
|
195241
|
-
allEntries.sort((a2, b) => order * a2.time.localeCompare(b.time));
|
|
195242
|
-
}
|
|
195243
|
-
return allEntries;
|
|
195244
|
-
}
|
|
195245
|
-
async function getAllFunctionNames() {
|
|
195246
|
-
const { functions } = await readProjectConfig();
|
|
195247
|
-
return functions.map((fn) => fn.name);
|
|
195248
|
-
}
|
|
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);
|
|
195255
|
-
const specifiedFunctions = parseFunctionNames(options.function);
|
|
195256
|
-
const allProjectFunctions = await getAllFunctionNames();
|
|
195257
|
-
const functionNames = specifiedFunctions.length > 0 ? specifiedFunctions : allProjectFunctions;
|
|
195258
|
-
if (functionNames.length === 0) {
|
|
195259
|
-
return { stdout: `No functions found in this project.
|
|
195260
|
-
` };
|
|
195261
|
-
}
|
|
195262
|
-
let entries = await fetchLogsForFunctions(functionNames, options, allProjectFunctions);
|
|
195263
|
-
const limit = options.limit ? Number.parseInt(options.limit, 10) : undefined;
|
|
195264
|
-
if (limit !== undefined && entries.length > limit) {
|
|
195265
|
-
entries = entries.slice(0, limit);
|
|
195266
|
-
}
|
|
195267
|
-
const stdout = options.json ? `${JSON.stringify(entries, null, 2)}
|
|
195268
|
-
` : formatLogs(entries);
|
|
195269
|
-
return { stdout };
|
|
195270
|
-
}
|
|
195271
|
-
function getLogsCommand(context) {
|
|
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) => {
|
|
195273
|
-
await runCommand(() => logsAction(options), { requireAuth: true }, context);
|
|
195274
|
-
});
|
|
195275
|
-
}
|
|
195276
|
-
|
|
195277
195112
|
// src/cli/commands/project/create.ts
|
|
195278
195113
|
import { basename as basename3, join as join11, resolve as resolve2 } from "node:path";
|
|
195279
195114
|
var import_lodash = __toESM(require_lodash(), 1);
|
|
@@ -195668,6 +195503,122 @@ function getLinkCommand(context) {
|
|
|
195668
195503
|
});
|
|
195669
195504
|
}
|
|
195670
195505
|
|
|
195506
|
+
// src/cli/commands/project/logs.ts
|
|
195507
|
+
function parseFunctionFilters(options) {
|
|
195508
|
+
const filters = {};
|
|
195509
|
+
if (options.since) {
|
|
195510
|
+
filters.since = options.since;
|
|
195511
|
+
}
|
|
195512
|
+
if (options.until) {
|
|
195513
|
+
filters.until = options.until;
|
|
195514
|
+
}
|
|
195515
|
+
if (options.limit) {
|
|
195516
|
+
filters.limit = Number.parseInt(options.limit, 10);
|
|
195517
|
+
}
|
|
195518
|
+
if (options.order) {
|
|
195519
|
+
filters.order = options.order.toLowerCase();
|
|
195520
|
+
}
|
|
195521
|
+
return filters;
|
|
195522
|
+
}
|
|
195523
|
+
function parseFunctionNames(option) {
|
|
195524
|
+
if (!option)
|
|
195525
|
+
return [];
|
|
195526
|
+
return option.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
195527
|
+
}
|
|
195528
|
+
function normalizeDatetime(value) {
|
|
195529
|
+
if (/Z$|[+-]\d{2}:\d{2}$/.test(value))
|
|
195530
|
+
return value;
|
|
195531
|
+
return `${value}Z`;
|
|
195532
|
+
}
|
|
195533
|
+
function formatEntry(entry) {
|
|
195534
|
+
const time3 = entry.time.substring(0, 19).replace("T", " ");
|
|
195535
|
+
const level = entry.level.toUpperCase().padEnd(5);
|
|
195536
|
+
const message = entry.message.trim();
|
|
195537
|
+
return `${time3} ${level} ${message}`;
|
|
195538
|
+
}
|
|
195539
|
+
function formatLogs(entries) {
|
|
195540
|
+
if (entries.length === 0) {
|
|
195541
|
+
return `No logs found matching the filters.
|
|
195542
|
+
`;
|
|
195543
|
+
}
|
|
195544
|
+
const header2 = `Showing ${entries.length} function log entries
|
|
195545
|
+
`;
|
|
195546
|
+
return [header2, ...entries.map(formatEntry)].join(`
|
|
195547
|
+
`);
|
|
195548
|
+
}
|
|
195549
|
+
function normalizeLogEntry(entry, functionName) {
|
|
195550
|
+
return {
|
|
195551
|
+
time: entry.time,
|
|
195552
|
+
level: entry.level,
|
|
195553
|
+
message: `[${functionName}] ${entry.message}`,
|
|
195554
|
+
source: functionName
|
|
195555
|
+
};
|
|
195556
|
+
}
|
|
195557
|
+
async function fetchLogsForFunctions(functionNames, options, availableFunctionNames) {
|
|
195558
|
+
const filters = parseFunctionFilters(options);
|
|
195559
|
+
const allEntries = [];
|
|
195560
|
+
for (const functionName of functionNames) {
|
|
195561
|
+
let logs;
|
|
195562
|
+
try {
|
|
195563
|
+
logs = await fetchFunctionLogs(functionName, filters);
|
|
195564
|
+
} catch (error48) {
|
|
195565
|
+
if (error48 instanceof ApiError && error48.statusCode === 404 && availableFunctionNames.length > 0) {
|
|
195566
|
+
const available = availableFunctionNames.join(", ");
|
|
195567
|
+
throw new InvalidInputError(`Function "${functionName}" was not found in this app`, {
|
|
195568
|
+
hints: [
|
|
195569
|
+
{
|
|
195570
|
+
message: `Available functions in this project: ${available}`
|
|
195571
|
+
},
|
|
195572
|
+
{
|
|
195573
|
+
message: "Make sure the function has been deployed before fetching logs",
|
|
195574
|
+
command: "base44 functions deploy"
|
|
195575
|
+
}
|
|
195576
|
+
]
|
|
195577
|
+
});
|
|
195578
|
+
}
|
|
195579
|
+
throw error48;
|
|
195580
|
+
}
|
|
195581
|
+
const entries = logs.map((entry) => normalizeLogEntry(entry, functionName));
|
|
195582
|
+
allEntries.push(...entries);
|
|
195583
|
+
}
|
|
195584
|
+
if (functionNames.length > 1) {
|
|
195585
|
+
const order = options.order?.toUpperCase() === "ASC" ? 1 : -1;
|
|
195586
|
+
allEntries.sort((a2, b) => order * a2.time.localeCompare(b.time));
|
|
195587
|
+
}
|
|
195588
|
+
return allEntries;
|
|
195589
|
+
}
|
|
195590
|
+
async function getAllFunctionNames() {
|
|
195591
|
+
const { functions } = await readProjectConfig();
|
|
195592
|
+
return functions.map((fn) => fn.name);
|
|
195593
|
+
}
|
|
195594
|
+
async function logsAction(options) {
|
|
195595
|
+
const specifiedFunctions = parseFunctionNames(options.function);
|
|
195596
|
+
const allProjectFunctions = await getAllFunctionNames();
|
|
195597
|
+
const functionNames = specifiedFunctions.length > 0 ? specifiedFunctions : allProjectFunctions;
|
|
195598
|
+
if (functionNames.length === 0) {
|
|
195599
|
+
return { outroMessage: "No functions found in this project." };
|
|
195600
|
+
}
|
|
195601
|
+
let entries = await fetchLogsForFunctions(functionNames, options, allProjectFunctions);
|
|
195602
|
+
const limit = options.limit ? Number.parseInt(options.limit, 10) : undefined;
|
|
195603
|
+
if (limit !== undefined && entries.length > limit) {
|
|
195604
|
+
entries = entries.slice(0, limit);
|
|
195605
|
+
}
|
|
195606
|
+
const logsOutput = options.json ? `${JSON.stringify(entries, null, 2)}
|
|
195607
|
+
` : formatLogs(entries);
|
|
195608
|
+
return { outroMessage: "Fetched logs", stdout: logsOutput };
|
|
195609
|
+
}
|
|
195610
|
+
function getLogsCommand(context) {
|
|
195611
|
+
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) => {
|
|
195612
|
+
const n2 = Number.parseInt(v, 10);
|
|
195613
|
+
if (Number.isNaN(n2) || n2 < 1 || n2 > 1000) {
|
|
195614
|
+
throw new InvalidInputError(`Invalid limit: "${v}". Must be a number between 1 and 1000.`);
|
|
195615
|
+
}
|
|
195616
|
+
return v;
|
|
195617
|
+
}).addOption(new Option("--order <order>", "Sort order").choices(["asc", "desc"])).option("--json", "Output raw JSON").action(async (options) => {
|
|
195618
|
+
await runCommand(() => logsAction(options), { requireAuth: true }, context);
|
|
195619
|
+
});
|
|
195620
|
+
}
|
|
195621
|
+
|
|
195671
195622
|
// src/cli/commands/site/deploy.ts
|
|
195672
195623
|
import { resolve as resolve3 } from "node:path";
|
|
195673
195624
|
async function deployAction2(options) {
|
|
@@ -200654,4 +200605,4 @@ export {
|
|
|
200654
200605
|
CLIExitError
|
|
200655
200606
|
};
|
|
200656
200607
|
|
|
200657
|
-
//# debugId=
|
|
200608
|
+
//# debugId=4A72726F99984B0D64756E2164756E21
|