@base44-preview/cli 0.0.38-pr.378.bb7fa12 → 0.0.38-pr.379.c10177b

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
@@ -233897,12 +233897,11 @@ var AutomationSchema = exports_external.union([
233897
233897
  EntityAutomationSchema
233898
233898
  ]);
233899
233899
  var FunctionConfigSchema = exports_external.object({
233900
- name: FunctionNameSchema.optional(),
233900
+ name: FunctionNameSchema,
233901
233901
  entry: exports_external.string().min(1, "Entry point cannot be empty"),
233902
233902
  automations: exports_external.array(AutomationSchema).optional()
233903
233903
  });
233904
233904
  var BackendFunctionSchema = FunctionConfigSchema.extend({
233905
- name: FunctionNameSchema,
233906
233905
  entryPath: exports_external.string().min(1, "Entry path cannot be empty"),
233907
233906
  filePaths: exports_external.array(exports_external.string()).min(1, "Function must have at least one file")
233908
233907
  });
@@ -233995,10 +233994,9 @@ async function readFunctionConfig(configPath) {
233995
233994
  }
233996
233995
  return result.data;
233997
233996
  }
233998
- async function readFunction(configPath, functionsDir) {
233997
+ async function readFunction(configPath) {
233999
233998
  const config5 = await readFunctionConfig(configPath);
234000
233999
  const functionDir = dirname4(configPath);
234001
- const name2 = config5.name ?? relative(functionsDir, functionDir).split(/[/\\]/).join("/");
234002
234000
  const entryPath = join5(functionDir, config5.entry);
234003
234001
  if (!await pathExists(entryPath)) {
234004
234002
  throw new InvalidInputError(`Function entry file not found: ${entryPath} (referenced in ${configPath})`, {
@@ -234009,7 +234007,7 @@ async function readFunction(configPath, functionsDir) {
234009
234007
  cwd: functionDir,
234010
234008
  absolute: true
234011
234009
  });
234012
- const functionData = { ...config5, name: name2, entryPath, filePaths };
234010
+ const functionData = { ...config5, entryPath, filePaths };
234013
234011
  return functionData;
234014
234012
  }
234015
234013
  async function readAllFunctions(functionsDir) {
@@ -234027,7 +234025,7 @@ async function readAllFunctions(functionsDir) {
234027
234025
  });
234028
234026
  const configFilesDirs = new Set(configFiles.map((f) => dirname4(f)));
234029
234027
  const entryFilesWithoutConfig = entryFiles.filter((entryFile) => !configFilesDirs.has(dirname4(entryFile)));
234030
- const functionsFromConfig = await Promise.all(configFiles.map((configPath) => readFunction(configPath, functionsDir)));
234028
+ const functionsFromConfig = await Promise.all(configFiles.map((configPath) => readFunction(configPath)));
234031
234029
  const functionsWithoutConfig = await Promise.all(entryFilesWithoutConfig.map(async (entryFile) => {
234032
234030
  const functionDir = dirname4(entryFile);
234033
234031
  const filePaths = await globby("**/*.{js,ts,json}", {
@@ -244605,13 +244603,19 @@ function createEntityRoutes(db2, logger, remoteProxy, broadcast) {
244605
244603
  // src/cli/dev/dev-server/routes/integrations.ts
244606
244604
  var import_express3 = __toESM(require_express(), 1);
244607
244605
  var import_multer = __toESM(require_multer(), 1);
244608
- import { randomUUID as randomUUID4 } from "node:crypto";
244606
+ import { createHash, randomUUID as randomUUID4 } from "node:crypto";
244609
244607
  import fs28 from "node:fs";
244610
244608
  import path18 from "node:path";
244609
+ function createFileToken(fileUri) {
244610
+ return createHash("sha256").update(fileUri).digest("hex");
244611
+ }
244611
244612
  function createIntegrationRoutes(mediaFilesDir, baseUrl, remoteProxy, logger) {
244612
244613
  const router = import_express3.Router({ mergeParams: true });
244613
244614
  const parseBody = import_express3.json();
244615
+ const privateFilesDir = path18.join(mediaFilesDir, "private");
244614
244616
  fs28.mkdirSync(mediaFilesDir, { recursive: true });
244617
+ fs28.mkdirSync(privateFilesDir, { recursive: true });
244618
+ const MAX_FILE_SIZE = 50 * 1024 * 1024;
244615
244619
  const storage = import_multer.default.diskStorage({
244616
244620
  destination: mediaFilesDir,
244617
244621
  filename: (_req, file2, cb2) => {
@@ -244619,8 +244623,18 @@ function createIntegrationRoutes(mediaFilesDir, baseUrl, remoteProxy, logger) {
244619
244623
  cb2(null, `${randomUUID4()}${ext}`);
244620
244624
  }
244621
244625
  });
244622
- const MAX_FILE_SIZE = 50 * 1024 * 1024;
244626
+ const privateStorage = import_multer.default.diskStorage({
244627
+ destination: privateFilesDir,
244628
+ filename: (_req, file2, cb2) => {
244629
+ const ext = path18.extname(file2.originalname);
244630
+ cb2(null, `${randomUUID4()}${ext}`);
244631
+ }
244632
+ });
244623
244633
  const upload = import_multer.default({ storage, limits: { fileSize: MAX_FILE_SIZE } });
244634
+ const privateUpload = import_multer.default({
244635
+ storage: privateStorage,
244636
+ limits: { fileSize: MAX_FILE_SIZE }
244637
+ });
244624
244638
  router.post("/Core/UploadFile", upload.single("file"), (req, res) => {
244625
244639
  if (!req.file) {
244626
244640
  res.status(400).json({ error: "No file uploaded" });
@@ -244629,7 +244643,7 @@ function createIntegrationRoutes(mediaFilesDir, baseUrl, remoteProxy, logger) {
244629
244643
  const file_url = `${baseUrl}/media/${req.file.filename}`;
244630
244644
  res.json({ file_url });
244631
244645
  });
244632
- router.post("/Core/UploadPrivateFile", upload.single("file"), (req, res) => {
244646
+ router.post("/Core/UploadPrivateFile", privateUpload.single("file"), (req, res) => {
244633
244647
  if (!req.file) {
244634
244648
  res.status(400).json({ error: "No file uploaded" });
244635
244649
  return;
@@ -244643,8 +244657,8 @@ function createIntegrationRoutes(mediaFilesDir, baseUrl, remoteProxy, logger) {
244643
244657
  res.status(400).json({ error: "file_uri is required" });
244644
244658
  return;
244645
244659
  }
244646
- const signature = randomUUID4();
244647
- const signed_url = `${baseUrl}/media/${file_uri}?signature=${signature}`;
244660
+ const token2 = createFileToken(file_uri);
244661
+ const signed_url = `${baseUrl}/media/private/${file_uri}?token=${token2}`;
244648
244662
  res.json({ signed_url });
244649
244663
  });
244650
244664
  router.post("/Core/:endpointName", (req, res, next) => {
@@ -246413,6 +246427,24 @@ async function createDevServer(options8) {
246413
246427
  const entityRoutes = createEntityRoutes(db2, devLogger, remoteProxy, (...args) => emitEntityEvent(...args));
246414
246428
  app.use("/api/apps/:appId/entities", entityRoutes);
246415
246429
  const { path: mediaFilesDir } = await $dir();
246430
+ app.use("/media/private/:fileUri", (req, res, next) => {
246431
+ const { fileUri } = req.params;
246432
+ const token2 = req.query.token;
246433
+ if (!token2) {
246434
+ res.status(401).json({ error: "Missing token" });
246435
+ return;
246436
+ }
246437
+ const expectedToken = createFileToken(fileUri);
246438
+ if (token2 !== expectedToken) {
246439
+ res.status(400).json({
246440
+ error: "InvalidJWT",
246441
+ message: "signature verification failed",
246442
+ statusCode: "400"
246443
+ });
246444
+ return;
246445
+ }
246446
+ next();
246447
+ });
246416
246448
  app.use("/media", import_express4.default.static(mediaFilesDir));
246417
246449
  const integrationRoutes = createIntegrationRoutes(mediaFilesDir, baseUrl, remoteProxy, devLogger);
246418
246450
  app.use("/api/apps/:appId/integration-endpoints", integrationRoutes);
@@ -250857,4 +250889,4 @@ export {
250857
250889
  CLIExitError
250858
250890
  };
250859
250891
 
250860
- //# debugId=46902C4097C5377B64756E2164756E21
250892
+ //# debugId=53B967AC62FD12E864756E2164756E21