@base44-preview/cli 0.0.47-pr.429.feb5c42 → 0.0.47-pr.435.27294cb

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.
@@ -9,6 +9,7 @@
9
9
  * - BASE44_APP_ID: App identifier from .app.jsonc
10
10
  * - BASE44_ACCESS_TOKEN: User's access token
11
11
  * - BASE44_APP_BASE_URL: App's published URL / subdomain (used for function calls)
12
+ * - BASE44_ADMIN: When "true", adds X-Bypass-RLS header for admin access
12
13
  */
13
14
 
14
15
  export {};
@@ -17,6 +18,8 @@ const scriptPath = Deno.env.get("SCRIPT_PATH");
17
18
  const appId = Deno.env.get("BASE44_APP_ID");
18
19
  const accessToken = Deno.env.get("BASE44_ACCESS_TOKEN");
19
20
  const appBaseUrl = Deno.env.get("BASE44_APP_BASE_URL");
21
+ const isAdmin = Deno.env.get("BASE44_ADMIN") === "true";
22
+ const dataEnv = Deno.env.get("BASE44_DATA_ENV");
20
23
 
21
24
  if (!scriptPath) {
22
25
  console.error("SCRIPT_PATH environment variable is required");
@@ -35,10 +38,15 @@ if (!appBaseUrl) {
35
38
 
36
39
  import { createClient } from "npm:@base44/sdk";
37
40
 
41
+ const customHeaders: Record<string, string> = {};
42
+ if (isAdmin) customHeaders["X-Bypass-RLS"] = "true";
43
+ if (dataEnv) customHeaders["X-Data-Env"] = dataEnv;
44
+
38
45
  const base44 = createClient({
39
46
  appId,
40
47
  token: accessToken,
41
48
  serverUrl: appBaseUrl,
49
+ headers: customHeaders,
42
50
  });
43
51
 
44
52
  (globalThis as any).base44 = base44;
package/dist/cli/index.js CHANGED
@@ -251703,7 +251703,7 @@ function getDevCommand() {
251703
251703
  import { spawn as spawn3 } from "node:child_process";
251704
251704
  import { copyFileSync, writeFileSync as writeFileSync2 } from "node:fs";
251705
251705
  async function runScript(options8) {
251706
- const { appId, code: code2 } = options8;
251706
+ const { appId, code: code2, admin, dataEnv } = options8;
251707
251707
  verifyDenoInstalled("to run scripts with exec");
251708
251708
  const cleanupFns = [];
251709
251709
  const tempScript = await $file({ postfix: ".ts" });
@@ -251725,7 +251725,9 @@ async function runScript(options8) {
251725
251725
  SCRIPT_PATH: scriptPath,
251726
251726
  BASE44_APP_ID: appId,
251727
251727
  BASE44_ACCESS_TOKEN: appUserToken,
251728
- BASE44_APP_BASE_URL: appBaseUrl
251728
+ BASE44_APP_BASE_URL: appBaseUrl,
251729
+ ...admin ? { BASE44_ADMIN: "true" } : {},
251730
+ ...dataEnv ? { BASE44_DATA_ENV: dataEnv } : {}
251729
251731
  },
251730
251732
  stdio: "inherit"
251731
251733
  });
@@ -251752,7 +251754,7 @@ function readStdin() {
251752
251754
  process.stdin.on("error", reject);
251753
251755
  });
251754
251756
  }
251755
- async function execAction(isNonInteractive) {
251757
+ async function execAction(options8, isNonInteractive) {
251756
251758
  const noInputError = new InvalidInputError("No input provided. Pipe a script to stdin.", {
251757
251759
  hints: [
251758
251760
  { message: "File: cat ./script.ts | base44 exec" },
@@ -251768,21 +251770,29 @@ async function execAction(isNonInteractive) {
251768
251770
  if (!code2.trim()) {
251769
251771
  throw noInputError;
251770
251772
  }
251771
- const { exitCode } = await runScript({ appId: getAppConfig().id, code: code2 });
251773
+ const { exitCode } = await runScript({
251774
+ appId: getAppConfig().id,
251775
+ code: code2,
251776
+ admin: options8.admin,
251777
+ dataEnv: options8.env
251778
+ });
251772
251779
  if (exitCode !== 0) {
251773
251780
  process.exitCode = exitCode;
251774
251781
  }
251775
251782
  return {};
251776
251783
  }
251777
251784
  function getExecCommand() {
251778
- return new Base44Command("exec").description("Run a script with the Base44 SDK pre-authenticated as the current user").addHelpText("after", `
251785
+ return new Base44Command("exec").description("Run a script with the Base44 SDK pre-authenticated as the current user").option("--admin", "Run with admin privileges (bypass RLS). Requires app owner/editor role.").option("--env <environment>", "Data environment to use (dev, share, or production). Defaults to production.").addHelpText("after", `
251779
251786
  Examples:
251780
251787
  Run a script file:
251781
251788
  $ cat ./script.ts | base44 exec
251782
251789
 
251783
251790
  Inline script:
251784
- $ echo "const users = await base44.entities.User.list()" | base44 exec`).action(async (_options, command2) => {
251785
- return await execAction(command2.isNonInteractive);
251791
+ $ echo "const users = await base44.entities.User.list()" | base44 exec
251792
+
251793
+ Run with admin privileges (bypass RLS):
251794
+ $ echo "const all = await base44.entities.Task.list()" | base44 exec --admin`).action(async (options8, command2) => {
251795
+ return await execAction(options8, command2.isNonInteractive);
251786
251796
  });
251787
251797
  }
251788
251798
 
@@ -256160,4 +256170,4 @@ export {
256160
256170
  CLIExitError
256161
256171
  };
256162
256172
 
256163
- //# debugId=03E220E345F1F26964756E2164756E21
256173
+ //# debugId=FB42CE5EE321E72364756E2164756E21