@base44-preview/cli 0.0.38-pr.379.d03b1ca → 0.0.38-pr.381.74c3c3d

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
@@ -233948,6 +233948,14 @@ async function deployFunctions(functions) {
233948
233948
  }
233949
233949
  return result.data;
233950
233950
  }
233951
+ async function deleteSingleFunction(name2) {
233952
+ const appClient = getAppClient();
233953
+ try {
233954
+ await appClient.delete(`backend-functions/${encodeURIComponent(name2)}`, { timeout: 60000 });
233955
+ } catch (error48) {
233956
+ throw await ApiError.fromHttpError(error48, `deleting function "${name2}"`);
233957
+ }
233958
+ }
233951
233959
  function buildLogsQueryString(filters) {
233952
233960
  const params = new URLSearchParams;
233953
233961
  if (filters.since) {
@@ -243093,6 +243101,63 @@ function getEntitiesPushCommand(context) {
243093
243101
  }));
243094
243102
  }
243095
243103
 
243104
+ // src/cli/utils/parseNames.ts
243105
+ function parseNames(args) {
243106
+ return args.flatMap((arg) => arg.split(",")).map((n2) => n2.trim()).filter(Boolean);
243107
+ }
243108
+
243109
+ // src/cli/commands/functions/delete.ts
243110
+ async function deleteFunctionsAction(names) {
243111
+ let deleted = 0;
243112
+ let notFound = 0;
243113
+ let errors4 = 0;
243114
+ let completed = 0;
243115
+ const total = names.length;
243116
+ for (const name2 of names) {
243117
+ R2.step(theme.styles.dim(`[${completed + 1}/${total}] Deleting ${name2}...`));
243118
+ try {
243119
+ await deleteSingleFunction(name2);
243120
+ R2.success(`${name2.padEnd(25)} deleted`);
243121
+ deleted++;
243122
+ } catch (error48) {
243123
+ if (error48 instanceof ApiError && error48.statusCode === 404) {
243124
+ R2.warn(`${name2.padEnd(25)} not found`);
243125
+ notFound++;
243126
+ } else {
243127
+ R2.error(`${name2.padEnd(25)} error: ${error48 instanceof Error ? error48.message : String(error48)}`);
243128
+ errors4++;
243129
+ }
243130
+ }
243131
+ completed++;
243132
+ }
243133
+ if (names.length === 1) {
243134
+ if (deleted)
243135
+ return { outroMessage: `Function "${names[0]}" deleted` };
243136
+ if (notFound)
243137
+ return { outroMessage: `Function "${names[0]}" not found` };
243138
+ return { outroMessage: `Failed to delete "${names[0]}"` };
243139
+ }
243140
+ const parts = [];
243141
+ if (deleted > 0)
243142
+ parts.push(`${deleted}/${total} deleted`);
243143
+ if (notFound > 0)
243144
+ parts.push(`${notFound} not found`);
243145
+ if (errors4 > 0)
243146
+ parts.push(`${errors4} error${errors4 !== 1 ? "s" : ""}`);
243147
+ return { outroMessage: parts.join(", ") };
243148
+ }
243149
+ function getDeleteCommand(context) {
243150
+ return new Command("delete").description("Delete deployed functions").argument("<names...>", "Function names to delete").action(async (rawNames) => {
243151
+ await runCommand(() => {
243152
+ const names = parseNames(rawNames);
243153
+ if (names.length === 0) {
243154
+ throw new InvalidInputError("At least one function name is required");
243155
+ }
243156
+ return deleteFunctionsAction(names);
243157
+ }, { requireAuth: true }, context);
243158
+ });
243159
+ }
243160
+
243096
243161
  // src/cli/commands/functions/deploy.ts
243097
243162
  async function deployFunctionsAction() {
243098
243163
  const { functions } = await readProjectConfig();
@@ -243125,10 +243190,15 @@ async function deployFunctionsAction() {
243125
243190
  }
243126
243191
  return { outroMessage: "Functions deployed to Base44" };
243127
243192
  }
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 () => {
243193
+ function getDeployCommand(context) {
243194
+ return new Command("deploy").description("Deploy local functions to Base44").action(async () => {
243130
243195
  await runCommand(deployFunctionsAction, { requireAuth: true }, context);
243131
- }));
243196
+ });
243197
+ }
243198
+
243199
+ // src/cli/commands/functions/index.ts
243200
+ function getFunctionsCommand(context) {
243201
+ return new Command("functions").description("Manage backend functions").addCommand(getDeployCommand(context)).addCommand(getDeleteCommand(context));
243132
243202
  }
243133
243203
 
243134
243204
  // src/cli/commands/project/create.ts
@@ -243370,7 +243440,7 @@ ${summaryLines.join(`
243370
243440
  }
243371
243441
  return { outroMessage: "App deployed successfully" };
243372
243442
  }
243373
- function getDeployCommand(context) {
243443
+ function getDeployCommand2(context) {
243374
243444
  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
243445
  await runCommand(() => deployAction({
243376
243446
  ...options,
@@ -244603,19 +244673,13 @@ function createEntityRoutes(db2, logger, remoteProxy, broadcast) {
244603
244673
  // src/cli/dev/dev-server/routes/integrations.ts
244604
244674
  var import_express3 = __toESM(require_express(), 1);
244605
244675
  var import_multer = __toESM(require_multer(), 1);
244606
- import { createHash, randomUUID as randomUUID4 } from "node:crypto";
244676
+ import { randomUUID as randomUUID4 } from "node:crypto";
244607
244677
  import fs28 from "node:fs";
244608
244678
  import path18 from "node:path";
244609
- function createFileToken(fileUri) {
244610
- return createHash("sha256").update(fileUri).digest("hex");
244611
- }
244612
244679
  function createIntegrationRoutes(mediaFilesDir, baseUrl, remoteProxy, logger) {
244613
244680
  const router = import_express3.Router({ mergeParams: true });
244614
244681
  const parseBody = import_express3.json();
244615
- const privateFilesDir = path18.join(mediaFilesDir, "private");
244616
244682
  fs28.mkdirSync(mediaFilesDir, { recursive: true });
244617
- fs28.mkdirSync(privateFilesDir, { recursive: true });
244618
- const MAX_FILE_SIZE = 50 * 1024 * 1024;
244619
244683
  const storage = import_multer.default.diskStorage({
244620
244684
  destination: mediaFilesDir,
244621
244685
  filename: (_req, file2, cb2) => {
@@ -244623,18 +244687,8 @@ function createIntegrationRoutes(mediaFilesDir, baseUrl, remoteProxy, logger) {
244623
244687
  cb2(null, `${randomUUID4()}${ext}`);
244624
244688
  }
244625
244689
  });
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
- });
244690
+ const MAX_FILE_SIZE = 50 * 1024 * 1024;
244633
244691
  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
244692
  router.post("/Core/UploadFile", upload.single("file"), (req, res) => {
244639
244693
  if (!req.file) {
244640
244694
  res.status(400).json({ error: "No file uploaded" });
@@ -244643,15 +244697,13 @@ function createIntegrationRoutes(mediaFilesDir, baseUrl, remoteProxy, logger) {
244643
244697
  const file_url = `${baseUrl}/media/${req.file.filename}`;
244644
244698
  res.json({ file_url });
244645
244699
  });
244646
- router.post("/Core/UploadPrivateFile", privateUpload.single("file"), (req, res) => {
244700
+ router.post("/Core/UploadPrivateFile", upload.single("file"), (req, res) => {
244647
244701
  if (!req.file) {
244648
244702
  res.status(400).json({ error: "No file uploaded" });
244649
244703
  return;
244650
244704
  }
244651
244705
  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 });
244706
+ res.json({ file_uri });
244655
244707
  });
244656
244708
  router.post("/Core/CreateFileSignedUrl", parseBody, (req, res) => {
244657
244709
  const { file_uri } = req.body;
@@ -244659,8 +244711,8 @@ function createIntegrationRoutes(mediaFilesDir, baseUrl, remoteProxy, logger) {
244659
244711
  res.status(400).json({ error: "file_uri is required" });
244660
244712
  return;
244661
244713
  }
244662
- const token2 = createFileToken(file_uri);
244663
- const signed_url = `${baseUrl}/media/private/${file_uri}?token=${token2}`;
244714
+ const signature = randomUUID4();
244715
+ const signed_url = `${baseUrl}/media/${file_uri}?signature=${signature}`;
244664
244716
  res.json({ signed_url });
244665
244717
  });
244666
244718
  router.post("/Core/:endpointName", (req, res, next) => {
@@ -246429,24 +246481,6 @@ async function createDevServer(options8) {
246429
246481
  const entityRoutes = createEntityRoutes(db2, devLogger, remoteProxy, (...args) => emitEntityEvent(...args));
246430
246482
  app.use("/api/apps/:appId/entities", entityRoutes);
246431
246483
  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
246484
  app.use("/media", import_express4.default.static(mediaFilesDir));
246451
246485
  const integrationRoutes = createIntegrationRoutes(mediaFilesDir, baseUrl, remoteProxy, devLogger);
246452
246486
  app.use("/api/apps/:appId/integration-endpoints", integrationRoutes);
@@ -246644,13 +246678,13 @@ function createProgram(context) {
246644
246678
  program2.addCommand(getLogoutCommand(context));
246645
246679
  program2.addCommand(getCreateCommand(context));
246646
246680
  program2.addCommand(getDashboardCommand(context));
246647
- program2.addCommand(getDeployCommand(context));
246681
+ program2.addCommand(getDeployCommand2(context));
246648
246682
  program2.addCommand(getLinkCommand(context));
246649
246683
  program2.addCommand(getEjectCommand(context));
246650
246684
  program2.addCommand(getEntitiesPushCommand(context));
246651
246685
  program2.addCommand(getAgentsCommand(context));
246652
246686
  program2.addCommand(getConnectorsCommand(context));
246653
- program2.addCommand(getFunctionsDeployCommand(context));
246687
+ program2.addCommand(getFunctionsCommand(context));
246654
246688
  program2.addCommand(getSecretsCommand(context));
246655
246689
  program2.addCommand(getSiteCommand(context));
246656
246690
  program2.addCommand(getTypesCommand(context));
@@ -250891,4 +250925,4 @@ export {
250891
250925
  CLIExitError
250892
250926
  };
250893
250927
 
250894
- //# debugId=364C3B73C55ABA7664756E2164756E21
250928
+ //# debugId=82EE38A292EE010964756E2164756E21