@base44-preview/cli 0.1.5-pr.569.0f0eefe → 0.1.5-pr.570.3e2e87e
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,8 @@
|
|
|
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_PRIVILEGED: When "true", adds the X-Bypass-RLS header (bypass RLS)
|
|
13
|
+
* - BASE44_DATA_ENV: When set, adds the X-Data-Env header (target data environment)
|
|
12
14
|
*/
|
|
13
15
|
|
|
14
16
|
export {};
|
|
@@ -17,6 +19,8 @@ const scriptPath = Deno.env.get("SCRIPT_PATH");
|
|
|
17
19
|
const appId = Deno.env.get("BASE44_APP_ID");
|
|
18
20
|
const accessToken = Deno.env.get("BASE44_ACCESS_TOKEN");
|
|
19
21
|
const appBaseUrl = Deno.env.get("BASE44_APP_BASE_URL");
|
|
22
|
+
const isPrivileged = Deno.env.get("BASE44_PRIVILEGED") === "true";
|
|
23
|
+
const dataEnv = Deno.env.get("BASE44_DATA_ENV");
|
|
20
24
|
|
|
21
25
|
if (!scriptPath) {
|
|
22
26
|
console.error("SCRIPT_PATH environment variable is required");
|
|
@@ -35,10 +39,15 @@ if (!appBaseUrl) {
|
|
|
35
39
|
|
|
36
40
|
import { createClient } from "npm:@base44/sdk";
|
|
37
41
|
|
|
42
|
+
const customHeaders: Record<string, string> = {};
|
|
43
|
+
if (isPrivileged) customHeaders["X-Bypass-RLS"] = "true";
|
|
44
|
+
if (dataEnv) customHeaders["X-Data-Env"] = dataEnv;
|
|
45
|
+
|
|
38
46
|
const base44 = createClient({
|
|
39
47
|
appId,
|
|
40
48
|
token: accessToken,
|
|
41
49
|
serverUrl: appBaseUrl,
|
|
50
|
+
headers: customHeaders,
|
|
42
51
|
});
|
|
43
52
|
|
|
44
53
|
(globalThis as any).base44 = base44;
|
package/dist/cli/index.js
CHANGED
|
@@ -258458,7 +258458,7 @@ function getDevCommand() {
|
|
|
258458
258458
|
import { spawn as spawn4 } from "node:child_process";
|
|
258459
258459
|
import { copyFileSync, writeFileSync as writeFileSync2 } from "node:fs";
|
|
258460
258460
|
async function runScript(options8) {
|
|
258461
|
-
const { appId, code: code2, local } = options8;
|
|
258461
|
+
const { appId, code: code2, local, privileged, dataEnv } = options8;
|
|
258462
258462
|
verifyDenoInstalled("to run scripts with exec");
|
|
258463
258463
|
const cleanupFns = [];
|
|
258464
258464
|
const tempScript = await $file({ postfix: ".ts" });
|
|
@@ -258477,7 +258477,9 @@ async function runScript(options8) {
|
|
|
258477
258477
|
SCRIPT_PATH: scriptPath,
|
|
258478
258478
|
BASE44_APP_ID: appId,
|
|
258479
258479
|
BASE44_ACCESS_TOKEN: appUserToken,
|
|
258480
|
-
BASE44_APP_BASE_URL: appBaseUrl
|
|
258480
|
+
BASE44_APP_BASE_URL: appBaseUrl,
|
|
258481
|
+
...privileged ? { BASE44_PRIVILEGED: "true" } : {},
|
|
258482
|
+
...dataEnv ? { BASE44_DATA_ENV: dataEnv } : {}
|
|
258481
258483
|
},
|
|
258482
258484
|
stdio: "inherit"
|
|
258483
258485
|
});
|
|
@@ -258542,14 +258544,20 @@ async function execAction({ app, isNonInteractive }, options8) {
|
|
|
258542
258544
|
throw noInputError;
|
|
258543
258545
|
}
|
|
258544
258546
|
const local = options8.local ? await resolveLocalTarget(options8.port !== undefined ? parsePort(options8.port) : DEFAULT_DEV_SERVER_PORT) : undefined;
|
|
258545
|
-
const { exitCode } = await runScript({
|
|
258547
|
+
const { exitCode } = await runScript({
|
|
258548
|
+
appId: app.id,
|
|
258549
|
+
code: code2,
|
|
258550
|
+
local,
|
|
258551
|
+
privileged: options8.privileged,
|
|
258552
|
+
dataEnv: options8.dataEnv
|
|
258553
|
+
});
|
|
258546
258554
|
if (exitCode !== 0) {
|
|
258547
258555
|
process.exitCode = exitCode;
|
|
258548
258556
|
}
|
|
258549
258557
|
return {};
|
|
258550
258558
|
}
|
|
258551
258559
|
function getExecCommand() {
|
|
258552
|
-
return new Base44Command("exec").description("Run a script with the Base44 SDK pre-authenticated as the current user").option("--local", "Run against the local `base44 dev` server instead of the deployed app").option("--port <number>", `Port the local dev server is on (with --local; defaults to ${DEFAULT_DEV_SERVER_PORT})`).addHelpText("after", `
|
|
258560
|
+
return new Base44Command("exec").description("Run a script with the Base44 SDK pre-authenticated as the current user").option("--local", "Run against the local `base44 dev` server instead of the deployed app").option("--port <number>", `Port the local dev server is on (with --local; defaults to ${DEFAULT_DEV_SERVER_PORT})`).option("--privileged", "Run with admin privileges (bypass RLS). Requires app owner/editor role.").option("--data-env <environment>", "Data environment to run against (e.g. dev, prod)").addHelpText("after", `
|
|
258553
258561
|
Examples:
|
|
258554
258562
|
Run a script file:
|
|
258555
258563
|
$ cat ./script.ts | base44 exec
|
|
@@ -258558,7 +258566,10 @@ Examples:
|
|
|
258558
258566
|
$ echo "const users = await base44.entities.User.list()" | base44 exec
|
|
258559
258567
|
|
|
258560
258568
|
Against the local dev server (base44 dev must be running):
|
|
258561
|
-
$ echo "await base44.entities.Task.create({ title: 'seed' })" | base44 exec --local
|
|
258569
|
+
$ echo "await base44.entities.Task.create({ title: 'seed' })" | base44 exec --local
|
|
258570
|
+
|
|
258571
|
+
With privileged access (bypass RLS):
|
|
258572
|
+
$ echo "const all = await base44.entities.Task.list()" | base44 exec --privileged`).action(execAction);
|
|
258562
258573
|
}
|
|
258563
258574
|
|
|
258564
258575
|
// src/cli/commands/project/eject.ts
|
|
@@ -262952,4 +262963,4 @@ export {
|
|
|
262952
262963
|
CLIExitError
|
|
262953
262964
|
};
|
|
262954
262965
|
|
|
262955
|
-
//# debugId=
|
|
262966
|
+
//# debugId=6F90C592BC20AEC764756E2164756E21
|