@base44-preview/cli 0.0.41-pr.394.460ed4c → 0.0.41-pr.394.51fe1f5

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
@@ -247899,7 +247899,16 @@ async function getAllFunctionNames() {
247899
247899
  const { functions } = await readProjectConfig();
247900
247900
  return functions.map((fn) => fn.name);
247901
247901
  }
247902
+ function validateLimit(limit) {
247903
+ if (limit === undefined)
247904
+ return;
247905
+ const n2 = Number.parseInt(limit, 10);
247906
+ if (Number.isNaN(n2) || n2 < 1 || n2 > 1000) {
247907
+ throw new InvalidInputError(`Invalid limit: "${limit}". Must be a number between 1 and 1000.`);
247908
+ }
247909
+ }
247902
247910
  async function logsAction(options) {
247911
+ validateLimit(options.limit);
247903
247912
  const specifiedFunctions = parseFunctionNames(options.function);
247904
247913
  const allProjectFunctions = await getAllFunctionNames();
247905
247914
  const functionNames = specifiedFunctions.length > 0 ? specifiedFunctions : allProjectFunctions;
@@ -247916,13 +247925,7 @@ async function logsAction(options) {
247916
247925
  return { outroMessage: "Fetched logs", stdout: logsOutput };
247917
247926
  }
247918
247927
  function getLogsCommand(context) {
247919
- 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).addOption(new Option("--level <level>", "Filter by log level").choices([...LogLevelSchema.options]).hideHelp()).option("-n, --limit <n>", "Results per page (1-1000, default: 50)", (v) => {
247920
- const n2 = Number.parseInt(v, 10);
247921
- if (Number.isNaN(n2) || n2 < 1 || n2 > 1000) {
247922
- throw new InvalidInputError(`Invalid limit: "${v}". Must be a number between 1 and 1000.`);
247923
- }
247924
- return v;
247925
- }).addOption(new Option("--order <order>", "Sort order").choices(["asc", "desc"])).action(async (options) => {
247928
+ 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).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"])).action(async (options) => {
247926
247929
  await runCommand(() => logsAction(options), { requireAuth: true }, context);
247927
247930
  });
247928
247931
  }
@@ -247988,11 +247991,9 @@ function parseEntries(entries) {
247988
247991
  }
247989
247992
  return secrets;
247990
247993
  }
247991
- function validateInput(command) {
247992
- const entries = command.args;
247993
- const { envFile } = command.opts();
247994
+ function validateInput(entries, options) {
247994
247995
  const hasEntries = entries.length > 0;
247995
- const hasEnvFile = Boolean(envFile);
247996
+ const hasEnvFile = Boolean(options.envFile);
247996
247997
  if (!hasEntries && !hasEnvFile) {
247997
247998
  throw new InvalidInputError("Provide KEY=VALUE pairs or use --env-file. Example: base44 secrets set KEY1=VALUE1 KEY2=VALUE2");
247998
247999
  }
@@ -248001,6 +248002,7 @@ function validateInput(command) {
248001
248002
  }
248002
248003
  }
248003
248004
  async function setSecretsAction(entries, options) {
248005
+ validateInput(entries, options);
248004
248006
  let secrets;
248005
248007
  if (options.envFile) {
248006
248008
  secrets = await parseEnvFile(resolve3(options.envFile));
@@ -248023,7 +248025,7 @@ async function setSecretsAction(entries, options) {
248023
248025
  };
248024
248026
  }
248025
248027
  function getSecretsSetCommand(context) {
248026
- return new Command("set").description("Set one or more secrets (KEY=VALUE format)").argument("[entries...]", "KEY=VALUE pairs (e.g. KEY1=VALUE1 KEY2=VALUE2)").option("--env-file <path>", "Path to .env file").hook("preAction", validateInput).action(async (entries, options) => {
248028
+ return new Command("set").description("Set one or more secrets (KEY=VALUE format)").argument("[entries...]", "KEY=VALUE pairs (e.g. KEY1=VALUE1 KEY2=VALUE2)").option("--env-file <path>", "Path to .env file").action(async (entries, options) => {
248027
248029
  await runCommand(() => setSecretsAction(entries, options), { requireAuth: true }, context);
248028
248030
  });
248029
248031
  }
@@ -248884,13 +248886,19 @@ function createEntityRoutes(db2, logger, remoteProxy, broadcast) {
248884
248886
  // src/cli/dev/dev-server/routes/integrations.ts
248885
248887
  var import_express3 = __toESM(require_express(), 1);
248886
248888
  var import_multer = __toESM(require_multer(), 1);
248887
- import { randomUUID as randomUUID4 } from "node:crypto";
248889
+ import { createHash, randomUUID as randomUUID4 } from "node:crypto";
248888
248890
  import fs28 from "node:fs";
248889
248891
  import path18 from "node:path";
248892
+ function createFileToken(fileUri) {
248893
+ return createHash("sha256").update(fileUri).digest("hex");
248894
+ }
248890
248895
  function createIntegrationRoutes(mediaFilesDir, baseUrl, remoteProxy, logger) {
248891
248896
  const router = import_express3.Router({ mergeParams: true });
248892
248897
  const parseBody = import_express3.json();
248898
+ const privateFilesDir = path18.join(mediaFilesDir, "private");
248893
248899
  fs28.mkdirSync(mediaFilesDir, { recursive: true });
248900
+ fs28.mkdirSync(privateFilesDir, { recursive: true });
248901
+ const MAX_FILE_SIZE = 50 * 1024 * 1024;
248894
248902
  const storage = import_multer.default.diskStorage({
248895
248903
  destination: mediaFilesDir,
248896
248904
  filename: (_req, file2, cb2) => {
@@ -248898,8 +248906,18 @@ function createIntegrationRoutes(mediaFilesDir, baseUrl, remoteProxy, logger) {
248898
248906
  cb2(null, `${randomUUID4()}${ext}`);
248899
248907
  }
248900
248908
  });
248901
- const MAX_FILE_SIZE = 50 * 1024 * 1024;
248909
+ const privateStorage = import_multer.default.diskStorage({
248910
+ destination: privateFilesDir,
248911
+ filename: (_req, file2, cb2) => {
248912
+ const ext = path18.extname(file2.originalname);
248913
+ cb2(null, `${randomUUID4()}${ext}`);
248914
+ }
248915
+ });
248902
248916
  const upload = import_multer.default({ storage, limits: { fileSize: MAX_FILE_SIZE } });
248917
+ const privateUpload = import_multer.default({
248918
+ storage: privateStorage,
248919
+ limits: { fileSize: MAX_FILE_SIZE }
248920
+ });
248903
248921
  router.post("/Core/UploadFile", upload.single("file"), (req, res) => {
248904
248922
  if (!req.file) {
248905
248923
  res.status(400).json({ error: "No file uploaded" });
@@ -248908,7 +248926,7 @@ function createIntegrationRoutes(mediaFilesDir, baseUrl, remoteProxy, logger) {
248908
248926
  const file_url = `${baseUrl}/media/${req.file.filename}`;
248909
248927
  res.json({ file_url });
248910
248928
  });
248911
- router.post("/Core/UploadPrivateFile", upload.single("file"), (req, res) => {
248929
+ router.post("/Core/UploadPrivateFile", privateUpload.single("file"), (req, res) => {
248912
248930
  if (!req.file) {
248913
248931
  res.status(400).json({ error: "No file uploaded" });
248914
248932
  return;
@@ -248922,8 +248940,8 @@ function createIntegrationRoutes(mediaFilesDir, baseUrl, remoteProxy, logger) {
248922
248940
  res.status(400).json({ error: "file_uri is required" });
248923
248941
  return;
248924
248942
  }
248925
- const signature = randomUUID4();
248926
- const signed_url = `${baseUrl}/media/${file_uri}?signature=${signature}`;
248943
+ const token2 = createFileToken(file_uri);
248944
+ const signed_url = `${baseUrl}/media/private/${file_uri}?token=${token2}`;
248927
248945
  res.json({ signed_url });
248928
248946
  });
248929
248947
  router.post("/Core/:endpointName", (req, res, next) => {
@@ -250692,6 +250710,24 @@ async function createDevServer(options8) {
250692
250710
  const entityRoutes = createEntityRoutes(db2, devLogger, remoteProxy, (...args) => emitEntityEvent(...args));
250693
250711
  app.use("/api/apps/:appId/entities", entityRoutes);
250694
250712
  const { path: mediaFilesDir } = await $dir();
250713
+ app.use("/media/private/:fileUri", (req, res, next) => {
250714
+ const { fileUri } = req.params;
250715
+ const token2 = req.query.token;
250716
+ if (!token2) {
250717
+ res.status(401).json({ error: "Missing token" });
250718
+ return;
250719
+ }
250720
+ const expectedToken = createFileToken(fileUri);
250721
+ if (token2 !== expectedToken) {
250722
+ res.status(400).json({
250723
+ error: "InvalidJWT",
250724
+ message: "signature verification failed",
250725
+ statusCode: "400"
250726
+ });
250727
+ return;
250728
+ }
250729
+ next();
250730
+ });
250695
250731
  app.use("/media", import_express4.default.static(mediaFilesDir));
250696
250732
  const integrationRoutes = createIntegrationRoutes(mediaFilesDir, baseUrl, remoteProxy, devLogger);
250697
250733
  app.use("/api/apps/:appId/integration-endpoints", integrationRoutes);
@@ -255142,4 +255178,4 @@ export {
255142
255178
  CLIExitError
255143
255179
  };
255144
255180
 
255145
- //# debugId=329D9AC43EA2056364756E2164756E21
255181
+ //# debugId=6FAE1342B3B86B2E64756E2164756E21