@base44-preview/cli 0.0.41-pr.379.099a4e6 → 0.0.41-pr.381.83d161e

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
@@ -231169,6 +231169,16 @@ async function deployFunctions(functions) {
231169
231169
  }
231170
231170
  return result.data;
231171
231171
  }
231172
+ async function deleteSingleFunction(name2) {
231173
+ const appClient = getAppClient();
231174
+ try {
231175
+ await appClient.delete(`backend-functions/${encodeURIComponent(name2)}`, {
231176
+ timeout: 60000
231177
+ });
231178
+ } catch (error48) {
231179
+ throw await ApiError.fromHttpError(error48, `deleting function "${name2}"`);
231180
+ }
231181
+ }
231172
231182
  function buildLogsQueryString(filters) {
231173
231183
  const params = new URLSearchParams;
231174
231184
  if (filters.since) {
@@ -240337,6 +240347,63 @@ function getEntitiesPushCommand(context) {
240337
240347
  }));
240338
240348
  }
240339
240349
 
240350
+ // src/cli/utils/parseNames.ts
240351
+ function parseNames(args) {
240352
+ return args.flatMap((arg) => arg.split(",")).map((n2) => n2.trim()).filter(Boolean);
240353
+ }
240354
+
240355
+ // src/cli/commands/functions/delete.ts
240356
+ async function deleteFunctionsAction(names) {
240357
+ let deleted = 0;
240358
+ let notFound = 0;
240359
+ let errors4 = 0;
240360
+ let completed = 0;
240361
+ const total = names.length;
240362
+ for (const name2 of names) {
240363
+ R2.step(theme.styles.dim(`[${completed + 1}/${total}] Deleting ${name2}...`));
240364
+ try {
240365
+ await deleteSingleFunction(name2);
240366
+ R2.success(`${name2.padEnd(25)} deleted`);
240367
+ deleted++;
240368
+ } catch (error48) {
240369
+ if (error48 instanceof ApiError && error48.statusCode === 404) {
240370
+ R2.warn(`${name2.padEnd(25)} not found`);
240371
+ notFound++;
240372
+ } else {
240373
+ R2.error(`${name2.padEnd(25)} error: ${error48 instanceof Error ? error48.message : String(error48)}`);
240374
+ errors4++;
240375
+ }
240376
+ }
240377
+ completed++;
240378
+ }
240379
+ if (names.length === 1) {
240380
+ if (deleted)
240381
+ return { outroMessage: `Function "${names[0]}" deleted` };
240382
+ if (notFound)
240383
+ return { outroMessage: `Function "${names[0]}" not found` };
240384
+ return { outroMessage: `Failed to delete "${names[0]}"` };
240385
+ }
240386
+ const parts = [];
240387
+ if (deleted > 0)
240388
+ parts.push(`${deleted}/${total} deleted`);
240389
+ if (notFound > 0)
240390
+ parts.push(`${notFound} not found`);
240391
+ if (errors4 > 0)
240392
+ parts.push(`${errors4} error${errors4 !== 1 ? "s" : ""}`);
240393
+ return { outroMessage: parts.join(", ") };
240394
+ }
240395
+ function getDeleteCommand(context) {
240396
+ return new Command("delete").description("Delete deployed functions").argument("<names...>", "Function names to delete").action(async (rawNames) => {
240397
+ await runCommand(() => {
240398
+ const names = parseNames(rawNames);
240399
+ if (names.length === 0) {
240400
+ throw new InvalidInputError("At least one function name is required");
240401
+ }
240402
+ return deleteFunctionsAction(names);
240403
+ }, { requireAuth: true }, context);
240404
+ });
240405
+ }
240406
+
240340
240407
  // src/cli/commands/functions/deploy.ts
240341
240408
  async function deployFunctionsAction() {
240342
240409
  const { functions } = await readProjectConfig();
@@ -240369,10 +240436,15 @@ async function deployFunctionsAction() {
240369
240436
  }
240370
240437
  return { outroMessage: "Functions deployed to Base44" };
240371
240438
  }
240372
- function getFunctionsDeployCommand(context) {
240373
- return new Command("functions").description("Manage project functions").addCommand(new Command("deploy").description("Deploy local functions to Base44").action(async () => {
240439
+ function getDeployCommand(context) {
240440
+ return new Command("deploy").description("Deploy local functions to Base44").action(async () => {
240374
240441
  await runCommand(deployFunctionsAction, { requireAuth: true }, context);
240375
- }));
240442
+ });
240443
+ }
240444
+
240445
+ // src/cli/commands/functions/index.ts
240446
+ function getFunctionsCommand(context) {
240447
+ return new Command("functions").description("Manage backend functions").addCommand(getDeployCommand(context)).addCommand(getDeleteCommand(context));
240376
240448
  }
240377
240449
 
240378
240450
  // src/cli/commands/project/create.ts
@@ -240614,7 +240686,7 @@ ${summaryLines.join(`
240614
240686
  }
240615
240687
  return { outroMessage: "App deployed successfully" };
240616
240688
  }
240617
- function getDeployCommand(context) {
240689
+ function getDeployCommand2(context) {
240618
240690
  return new Command("deploy").description("Deploy all project resources (entities, functions, agents, connectors, and site)").option("-y, --yes", "Skip confirmation prompt").action(async (options) => {
240619
240691
  await runCommand(() => deployAction({
240620
240692
  ...options,
@@ -241845,19 +241917,13 @@ function createEntityRoutes(db2, logger, remoteProxy, broadcast) {
241845
241917
  // src/cli/dev/dev-server/routes/integrations.ts
241846
241918
  var import_express3 = __toESM(require_express(), 1);
241847
241919
  var import_multer = __toESM(require_multer(), 1);
241848
- import { createHash, randomUUID as randomUUID4 } from "node:crypto";
241920
+ import { randomUUID as randomUUID4 } from "node:crypto";
241849
241921
  import fs28 from "node:fs";
241850
241922
  import path18 from "node:path";
241851
- function createFileToken(fileUri) {
241852
- return createHash("sha256").update(fileUri).digest("hex");
241853
- }
241854
241923
  function createIntegrationRoutes(mediaFilesDir, baseUrl, remoteProxy, logger) {
241855
241924
  const router = import_express3.Router({ mergeParams: true });
241856
241925
  const parseBody = import_express3.json();
241857
- const privateFilesDir = path18.join(mediaFilesDir, "private");
241858
241926
  fs28.mkdirSync(mediaFilesDir, { recursive: true });
241859
- fs28.mkdirSync(privateFilesDir, { recursive: true });
241860
- const MAX_FILE_SIZE = 50 * 1024 * 1024;
241861
241927
  const storage = import_multer.default.diskStorage({
241862
241928
  destination: mediaFilesDir,
241863
241929
  filename: (_req, file2, cb2) => {
@@ -241865,18 +241931,8 @@ function createIntegrationRoutes(mediaFilesDir, baseUrl, remoteProxy, logger) {
241865
241931
  cb2(null, `${randomUUID4()}${ext}`);
241866
241932
  }
241867
241933
  });
241868
- const privateStorage = import_multer.default.diskStorage({
241869
- destination: privateFilesDir,
241870
- filename: (_req, file2, cb2) => {
241871
- const ext = path18.extname(file2.originalname);
241872
- cb2(null, `${randomUUID4()}${ext}`);
241873
- }
241874
- });
241934
+ const MAX_FILE_SIZE = 50 * 1024 * 1024;
241875
241935
  const upload = import_multer.default({ storage, limits: { fileSize: MAX_FILE_SIZE } });
241876
- const privateUpload = import_multer.default({
241877
- storage: privateStorage,
241878
- limits: { fileSize: MAX_FILE_SIZE }
241879
- });
241880
241936
  router.post("/Core/UploadFile", upload.single("file"), (req, res) => {
241881
241937
  if (!req.file) {
241882
241938
  res.status(400).json({ error: "No file uploaded" });
@@ -241885,7 +241941,7 @@ function createIntegrationRoutes(mediaFilesDir, baseUrl, remoteProxy, logger) {
241885
241941
  const file_url = `${baseUrl}/media/${req.file.filename}`;
241886
241942
  res.json({ file_url });
241887
241943
  });
241888
- router.post("/Core/UploadPrivateFile", privateUpload.single("file"), (req, res) => {
241944
+ router.post("/Core/UploadPrivateFile", upload.single("file"), (req, res) => {
241889
241945
  if (!req.file) {
241890
241946
  res.status(400).json({ error: "No file uploaded" });
241891
241947
  return;
@@ -241899,8 +241955,8 @@ function createIntegrationRoutes(mediaFilesDir, baseUrl, remoteProxy, logger) {
241899
241955
  res.status(400).json({ error: "file_uri is required" });
241900
241956
  return;
241901
241957
  }
241902
- const token2 = createFileToken(file_uri);
241903
- const signed_url = `${baseUrl}/media/private/${file_uri}?token=${token2}`;
241958
+ const signature = randomUUID4();
241959
+ const signed_url = `${baseUrl}/media/${file_uri}?signature=${signature}`;
241904
241960
  res.json({ signed_url });
241905
241961
  });
241906
241962
  router.post("/Core/:endpointName", (req, res, next) => {
@@ -243669,24 +243725,6 @@ async function createDevServer(options8) {
243669
243725
  const entityRoutes = createEntityRoutes(db2, devLogger, remoteProxy, (...args) => emitEntityEvent(...args));
243670
243726
  app.use("/api/apps/:appId/entities", entityRoutes);
243671
243727
  const { path: mediaFilesDir } = await $dir();
243672
- app.use("/media/private/:fileUri", (req, res, next) => {
243673
- const { fileUri } = req.params;
243674
- const token2 = req.query.token;
243675
- if (!token2) {
243676
- res.status(401).json({ error: "Missing token" });
243677
- return;
243678
- }
243679
- const expectedToken = createFileToken(fileUri);
243680
- if (token2 !== expectedToken) {
243681
- res.status(400).json({
243682
- error: "InvalidJWT",
243683
- message: "signature verification failed",
243684
- statusCode: "400"
243685
- });
243686
- return;
243687
- }
243688
- next();
243689
- });
243690
243728
  app.use("/media", import_express4.default.static(mediaFilesDir));
243691
243729
  const integrationRoutes = createIntegrationRoutes(mediaFilesDir, baseUrl, remoteProxy, devLogger);
243692
243730
  app.use("/api/apps/:appId/integration-endpoints", integrationRoutes);
@@ -243885,13 +243923,13 @@ function createProgram(context) {
243885
243923
  program2.addCommand(getLogoutCommand(context));
243886
243924
  program2.addCommand(getCreateCommand(context));
243887
243925
  program2.addCommand(getDashboardCommand(context));
243888
- program2.addCommand(getDeployCommand(context));
243926
+ program2.addCommand(getDeployCommand2(context));
243889
243927
  program2.addCommand(getLinkCommand(context));
243890
243928
  program2.addCommand(getEjectCommand(context));
243891
243929
  program2.addCommand(getEntitiesPushCommand(context));
243892
243930
  program2.addCommand(getAgentsCommand(context));
243893
243931
  program2.addCommand(getConnectorsCommand(context));
243894
- program2.addCommand(getFunctionsDeployCommand(context));
243932
+ program2.addCommand(getFunctionsCommand(context));
243895
243933
  program2.addCommand(getSecretsCommand(context));
243896
243934
  program2.addCommand(getSiteCommand(context));
243897
243935
  program2.addCommand(getTypesCommand(context));
@@ -248137,4 +248175,4 @@ export {
248137
248175
  CLIExitError
248138
248176
  };
248139
248177
 
248140
- //# debugId=E2A1C79322A8941664756E2164756E21
248178
+ //# debugId=76EF0E044F070BC564756E2164756E21