@base44-preview/cli 0.0.38-pr.379.d03b1ca → 0.0.38-pr.380.ba23c83

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
@@ -233911,6 +233911,21 @@ var DeployFunctionsResponseSchema = exports_external.object({
233911
233911
  skipped: exports_external.array(exports_external.string()).optional().nullable(),
233912
233912
  errors: exports_external.array(exports_external.object({ name: exports_external.string(), message: exports_external.string() })).nullable()
233913
233913
  });
233914
+ var FunctionAutomationInfoSchema = exports_external.object({
233915
+ name: exports_external.string(),
233916
+ type: exports_external.string(),
233917
+ is_active: exports_external.boolean()
233918
+ });
233919
+ var FunctionInfoSchema = exports_external.object({
233920
+ name: exports_external.string(),
233921
+ deployment_id: exports_external.string(),
233922
+ entry: exports_external.string(),
233923
+ files: exports_external.array(FunctionFileSchema),
233924
+ automations: exports_external.array(FunctionAutomationInfoSchema)
233925
+ });
233926
+ var ListFunctionsResponseSchema = exports_external.object({
233927
+ functions: exports_external.array(FunctionInfoSchema)
233928
+ });
233914
233929
  var LogLevelSchema = exports_external.enum(["info", "warning", "error", "debug"]);
233915
233930
  var FunctionLogEntrySchema = exports_external.object({
233916
233931
  time: exports_external.string(),
@@ -233948,6 +233963,20 @@ async function deployFunctions(functions) {
233948
233963
  }
233949
233964
  return result.data;
233950
233965
  }
233966
+ async function listDeployedFunctions() {
233967
+ const appClient = getAppClient();
233968
+ let response;
233969
+ try {
233970
+ response = await appClient.get("backend-functions", { timeout: 30000 });
233971
+ } catch (error48) {
233972
+ throw await ApiError.fromHttpError(error48, "listing deployed functions");
233973
+ }
233974
+ const result = ListFunctionsResponseSchema.safeParse(await response.json());
233975
+ if (!result.success) {
233976
+ throw new SchemaValidationError("Invalid response from server", result.error);
233977
+ }
233978
+ return result.data;
233979
+ }
233951
233980
  function buildLogsQueryString(filters) {
233952
233981
  const params = new URLSearchParams;
233953
233982
  if (filters.since) {
@@ -243125,10 +243154,36 @@ async function deployFunctionsAction() {
243125
243154
  }
243126
243155
  return { outroMessage: "Functions deployed to Base44" };
243127
243156
  }
243128
- function getFunctionsDeployCommand(context) {
243129
- return new Command("functions").description("Manage project functions").addCommand(new Command("deploy").description("Deploy local functions to Base44").action(async () => {
243157
+ function getDeployCommand(context) {
243158
+ return new Command("deploy").description("Deploy local functions to Base44").action(async () => {
243130
243159
  await runCommand(deployFunctionsAction, { requireAuth: true }, context);
243131
- }));
243160
+ });
243161
+ }
243162
+
243163
+ // src/cli/commands/functions/list.ts
243164
+ async function listFunctionsAction() {
243165
+ const { functions } = await listDeployedFunctions();
243166
+ if (functions.length === 0) {
243167
+ return { outroMessage: "No functions on remote" };
243168
+ }
243169
+ for (const fn of functions) {
243170
+ const autoCount = fn.automations.length;
243171
+ const autoLabel = autoCount > 0 ? theme.styles.dim(` (${autoCount} automation${autoCount > 1 ? "s" : ""})`) : "";
243172
+ R2.message(` ${fn.name}${autoLabel}`);
243173
+ }
243174
+ return {
243175
+ outroMessage: `${functions.length} function${functions.length !== 1 ? "s" : ""} on remote`
243176
+ };
243177
+ }
243178
+ function getListCommand(context) {
243179
+ return new Command("list").description("List all deployed functions").action(async () => {
243180
+ await runCommand(listFunctionsAction, { requireAuth: true }, context);
243181
+ });
243182
+ }
243183
+
243184
+ // src/cli/commands/functions/index.ts
243185
+ function getFunctionsCommand(context) {
243186
+ return new Command("functions").description("Manage backend functions").addCommand(getDeployCommand(context)).addCommand(getListCommand(context));
243132
243187
  }
243133
243188
 
243134
243189
  // src/cli/commands/project/create.ts
@@ -243370,7 +243425,7 @@ ${summaryLines.join(`
243370
243425
  }
243371
243426
  return { outroMessage: "App deployed successfully" };
243372
243427
  }
243373
- function getDeployCommand(context) {
243428
+ function getDeployCommand2(context) {
243374
243429
  return new Command("deploy").description("Deploy all project resources (entities, functions, agents, connectors, and site)").option("-y, --yes", "Skip confirmation prompt").action(async (options) => {
243375
243430
  await runCommand(() => deployAction({
243376
243431
  ...options,
@@ -244603,19 +244658,13 @@ function createEntityRoutes(db2, logger, remoteProxy, broadcast) {
244603
244658
  // src/cli/dev/dev-server/routes/integrations.ts
244604
244659
  var import_express3 = __toESM(require_express(), 1);
244605
244660
  var import_multer = __toESM(require_multer(), 1);
244606
- import { createHash, randomUUID as randomUUID4 } from "node:crypto";
244661
+ import { randomUUID as randomUUID4 } from "node:crypto";
244607
244662
  import fs28 from "node:fs";
244608
244663
  import path18 from "node:path";
244609
- function createFileToken(fileUri) {
244610
- return createHash("sha256").update(fileUri).digest("hex");
244611
- }
244612
244664
  function createIntegrationRoutes(mediaFilesDir, baseUrl, remoteProxy, logger) {
244613
244665
  const router = import_express3.Router({ mergeParams: true });
244614
244666
  const parseBody = import_express3.json();
244615
- const privateFilesDir = path18.join(mediaFilesDir, "private");
244616
244667
  fs28.mkdirSync(mediaFilesDir, { recursive: true });
244617
- fs28.mkdirSync(privateFilesDir, { recursive: true });
244618
- const MAX_FILE_SIZE = 50 * 1024 * 1024;
244619
244668
  const storage = import_multer.default.diskStorage({
244620
244669
  destination: mediaFilesDir,
244621
244670
  filename: (_req, file2, cb2) => {
@@ -244623,18 +244672,8 @@ function createIntegrationRoutes(mediaFilesDir, baseUrl, remoteProxy, logger) {
244623
244672
  cb2(null, `${randomUUID4()}${ext}`);
244624
244673
  }
244625
244674
  });
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
- });
244675
+ const MAX_FILE_SIZE = 50 * 1024 * 1024;
244633
244676
  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
- });
244638
244677
  router.post("/Core/UploadFile", upload.single("file"), (req, res) => {
244639
244678
  if (!req.file) {
244640
244679
  res.status(400).json({ error: "No file uploaded" });
@@ -244643,15 +244682,13 @@ function createIntegrationRoutes(mediaFilesDir, baseUrl, remoteProxy, logger) {
244643
244682
  const file_url = `${baseUrl}/media/${req.file.filename}`;
244644
244683
  res.json({ file_url });
244645
244684
  });
244646
- router.post("/Core/UploadPrivateFile", privateUpload.single("file"), (req, res) => {
244685
+ router.post("/Core/UploadPrivateFile", upload.single("file"), (req, res) => {
244647
244686
  if (!req.file) {
244648
244687
  res.status(400).json({ error: "No file uploaded" });
244649
244688
  return;
244650
244689
  }
244651
244690
  const file_uri = req.file.filename;
244652
- const token2 = createFileToken(file_uri);
244653
- const signed_url = `${baseUrl}/media/private/${file_uri}?token=${token2}`;
244654
- res.json({ file_uri, signed_url });
244691
+ res.json({ file_uri });
244655
244692
  });
244656
244693
  router.post("/Core/CreateFileSignedUrl", parseBody, (req, res) => {
244657
244694
  const { file_uri } = req.body;
@@ -244659,8 +244696,8 @@ function createIntegrationRoutes(mediaFilesDir, baseUrl, remoteProxy, logger) {
244659
244696
  res.status(400).json({ error: "file_uri is required" });
244660
244697
  return;
244661
244698
  }
244662
- const token2 = createFileToken(file_uri);
244663
- const signed_url = `${baseUrl}/media/private/${file_uri}?token=${token2}`;
244699
+ const signature = randomUUID4();
244700
+ const signed_url = `${baseUrl}/media/${file_uri}?signature=${signature}`;
244664
244701
  res.json({ signed_url });
244665
244702
  });
244666
244703
  router.post("/Core/:endpointName", (req, res, next) => {
@@ -246429,24 +246466,6 @@ async function createDevServer(options8) {
246429
246466
  const entityRoutes = createEntityRoutes(db2, devLogger, remoteProxy, (...args) => emitEntityEvent(...args));
246430
246467
  app.use("/api/apps/:appId/entities", entityRoutes);
246431
246468
  const { path: mediaFilesDir } = await $dir();
246432
- app.use("/media/private/:fileUri", (req, res, next) => {
246433
- const { fileUri } = req.params;
246434
- const token2 = req.query.token;
246435
- if (!token2) {
246436
- res.status(401).json({ error: "Missing token" });
246437
- return;
246438
- }
246439
- const expectedToken = createFileToken(fileUri);
246440
- if (token2 !== expectedToken) {
246441
- res.status(400).json({
246442
- error: "InvalidJWT",
246443
- message: "signature verification failed",
246444
- statusCode: "400"
246445
- });
246446
- return;
246447
- }
246448
- next();
246449
- });
246450
246469
  app.use("/media", import_express4.default.static(mediaFilesDir));
246451
246470
  const integrationRoutes = createIntegrationRoutes(mediaFilesDir, baseUrl, remoteProxy, devLogger);
246452
246471
  app.use("/api/apps/:appId/integration-endpoints", integrationRoutes);
@@ -246644,13 +246663,13 @@ function createProgram(context) {
246644
246663
  program2.addCommand(getLogoutCommand(context));
246645
246664
  program2.addCommand(getCreateCommand(context));
246646
246665
  program2.addCommand(getDashboardCommand(context));
246647
- program2.addCommand(getDeployCommand(context));
246666
+ program2.addCommand(getDeployCommand2(context));
246648
246667
  program2.addCommand(getLinkCommand(context));
246649
246668
  program2.addCommand(getEjectCommand(context));
246650
246669
  program2.addCommand(getEntitiesPushCommand(context));
246651
246670
  program2.addCommand(getAgentsCommand(context));
246652
246671
  program2.addCommand(getConnectorsCommand(context));
246653
- program2.addCommand(getFunctionsDeployCommand(context));
246672
+ program2.addCommand(getFunctionsCommand(context));
246654
246673
  program2.addCommand(getSecretsCommand(context));
246655
246674
  program2.addCommand(getSiteCommand(context));
246656
246675
  program2.addCommand(getTypesCommand(context));
@@ -250891,4 +250910,4 @@ export {
250891
250910
  CLIExitError
250892
250911
  };
250893
250912
 
250894
- //# debugId=364C3B73C55ABA7664756E2164756E21
250913
+ //# debugId=153E33F56F0F0F1C64756E2164756E21