@base44-preview/cli 0.1.22-pr.644.52a9e2d → 0.1.22-pr.644.9e3658d

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.
@@ -12,10 +12,8 @@
12
12
  * - BASE44_PRIVILEGED: When "true", adds the X-Bypass-RLS header (bypass RLS)
13
13
  * - BASE44_DATA_ENV: When set, adds the X-Data-Env header (target data environment)
14
14
  * - BASE44_SERVICE_TOKEN: When set, passed as `serviceToken` (enables `base44.asServiceRole`)
15
- * - BASE44_EXTRA_HEADERS: When set, a JSON object of extra headers on every SDK request
16
15
  *
17
- * BASE44_SERVICE_TOKEN and BASE44_EXTRA_HEADERS are removed from the environment
18
- * before the user script runs.
16
+ * BASE44_SERVICE_TOKEN is removed from the environment before the user script runs.
19
17
  */
20
18
 
21
19
  export {};
@@ -27,9 +25,7 @@ const appBaseUrl = Deno.env.get("BASE44_APP_BASE_URL");
27
25
  const isPrivileged = Deno.env.get("BASE44_PRIVILEGED") === "true";
28
26
  const dataEnv = Deno.env.get("BASE44_DATA_ENV");
29
27
  const serviceToken = Deno.env.get("BASE44_SERVICE_TOKEN");
30
- const extraHeaders = Deno.env.get("BASE44_EXTRA_HEADERS");
31
28
  Deno.env.delete("BASE44_SERVICE_TOKEN");
32
- Deno.env.delete("BASE44_EXTRA_HEADERS");
33
29
 
34
30
  if (!scriptPath) {
35
31
  console.error("SCRIPT_PATH environment variable is required");
@@ -48,9 +44,7 @@ if (!appBaseUrl) {
48
44
 
49
45
  import { createClient } from "npm:@base44/sdk";
50
46
 
51
- const customHeaders: Record<string, string> = extraHeaders
52
- ? JSON.parse(extraHeaders)
53
- : {};
47
+ const customHeaders: Record<string, string> = {};
54
48
  if (isPrivileged) customHeaders["X-Bypass-RLS"] = "true";
55
49
  if (dataEnv) customHeaders["X-Data-Env"] = dataEnv;
56
50
 
package/dist/cli/index.js CHANGED
@@ -256168,39 +256168,19 @@ function getDevCommand() {
256168
256168
  var ACCESS_TOKEN_VAR = "BASE44_EXEC_ACCESS_TOKEN";
256169
256169
  var SERVER_URL_VAR = "BASE44_EXEC_SERVER_URL";
256170
256170
  var SERVICE_TOKEN_VAR = "BASE44_EXEC_SERVICE_TOKEN";
256171
- var HEADERS_VAR = "BASE44_EXEC_HEADERS";
256172
256171
  var EXEC_ENV_VARS = [
256173
256172
  ACCESS_TOKEN_VAR,
256174
256173
  SERVER_URL_VAR,
256175
- SERVICE_TOKEN_VAR,
256176
- HEADERS_VAR
256174
+ SERVICE_TOKEN_VAR
256177
256175
  ];
256176
+ var PRIVILEGED_ENV_VAR = "BASE44_EXEC_PRIVILEGED";
256177
+ var DATA_ENV_ENV_VAR = "BASE44_EXEC_DATA_ENV";
256178
256178
  function read3(env, name) {
256179
256179
  return env[name]?.trim() || undefined;
256180
256180
  }
256181
256181
  function hasExecEnvTarget(env = process.env) {
256182
256182
  return EXEC_ENV_VARS.some((name) => read3(env, name) !== undefined);
256183
256183
  }
256184
- var HeadersSchema = record(string2(), string2());
256185
- function parseHeaders(raw) {
256186
- let parsed;
256187
- try {
256188
- parsed = JSON.parse(raw);
256189
- } catch {
256190
- throw new InvalidInputError(`${HEADERS_VAR} is not valid JSON.`, {
256191
- hints: [{ message: `Set ${HEADERS_VAR} to e.g. '{"X-Header":"value"}'` }]
256192
- });
256193
- }
256194
- const result = HeadersSchema.safeParse(parsed);
256195
- if (!result.success) {
256196
- throw new InvalidInputError(`${HEADERS_VAR} must be a JSON object of string header values.`, {
256197
- hints: [
256198
- { message: `Set ${HEADERS_VAR} to e.g. '{"X-Header":"value"}'` }
256199
- ]
256200
- });
256201
- }
256202
- return result.data;
256203
- }
256204
256184
  function readExecEnvTarget(env = process.env) {
256205
256185
  if (!hasExecEnvTarget(env)) {
256206
256186
  return;
@@ -256212,7 +256192,7 @@ function readExecEnvTarget(env = process.env) {
256212
256192
  throw new InvalidInputError(`${missing} is not set. ${ACCESS_TOKEN_VAR} and ${SERVER_URL_VAR} must be set together.`, {
256213
256193
  hints: [
256214
256194
  {
256215
- message: `Set both ${ACCESS_TOKEN_VAR} and ${SERVER_URL_VAR}, or unset all BASE44_EXEC_* variables to use your login`
256195
+ message: `Set both ${ACCESS_TOKEN_VAR} and ${SERVER_URL_VAR}, or unset all of them to use your login`
256216
256196
  }
256217
256197
  ]
256218
256198
  });
@@ -256221,34 +256201,26 @@ function readExecEnvTarget(env = process.env) {
256221
256201
  throw new InvalidInputError(`${SERVER_URL_VAR} is not a valid URL.`);
256222
256202
  }
256223
256203
  const serviceToken = read3(env, SERVICE_TOKEN_VAR);
256224
- const rawHeaders = read3(env, HEADERS_VAR);
256225
- return {
256226
- token,
256227
- serverUrl,
256228
- ...serviceToken ? { serviceToken } : {},
256229
- ...rawHeaders ? { headers: parseHeaders(rawHeaders) } : {}
256230
- };
256204
+ return { token, serverUrl, ...serviceToken ? { serviceToken } : {} };
256231
256205
  }
256232
256206
  // src/core/exec/run-script.ts
256233
256207
  import { spawn as spawn4 } from "node:child_process";
256234
256208
  import { copyFileSync, writeFileSync as writeFileSync3 } from "node:fs";
256235
256209
  var SERVICE_TOKEN_ENV = "BASE44_SERVICE_TOKEN";
256236
- var EXTRA_HEADERS_ENV = "BASE44_EXTRA_HEADERS";
256237
- function wrapperOnlyEnv(serviceToken, headers) {
256238
- return {
256239
- ...serviceToken ? { [SERVICE_TOKEN_ENV]: serviceToken } : {},
256240
- ...headers ? { [EXTRA_HEADERS_ENV]: JSON.stringify(headers) } : {}
256241
- };
256242
- }
256243
256210
  function inheritedEnv() {
256244
256211
  const env = { ...process.env };
256245
- for (const name of [...EXEC_ENV_VARS, SERVICE_TOKEN_ENV, EXTRA_HEADERS_ENV]) {
256212
+ for (const name of [
256213
+ ...EXEC_ENV_VARS,
256214
+ PRIVILEGED_ENV_VAR,
256215
+ DATA_ENV_ENV_VAR,
256216
+ SERVICE_TOKEN_ENV
256217
+ ]) {
256246
256218
  delete env[name];
256247
256219
  }
256248
256220
  return env;
256249
256221
  }
256250
256222
  async function runScript(options) {
256251
- const { appId, code, local, privileged, dataEnv, serviceToken, headers } = options;
256223
+ const { appId, code, local, privileged, dataEnv, serviceToken } = options;
256252
256224
  verifyDenoInstalled("to run scripts with exec");
256253
256225
  const cleanupFns = [];
256254
256226
  const tempScript = await $file({ postfix: ".ts" });
@@ -256261,10 +256233,10 @@ async function runScript(options) {
256261
256233
  copyFileSync(getExecWrapperPath(), tempWrapper.path);
256262
256234
  try {
256263
256235
  const exitCode = await new Promise((resolvePromise) => {
256264
- const child = spawn4("deno", ["run", "--allow-all", "--node-modules-dir=auto", tempWrapper.path], {
256236
+ const child = spawn4("deno", ["run", "--allow-all", "--node-modules-dir=none", tempWrapper.path], {
256265
256237
  env: {
256266
256238
  ...inheritedEnv(),
256267
- ...wrapperOnlyEnv(serviceToken, headers),
256239
+ ...serviceToken ? { [SERVICE_TOKEN_ENV]: serviceToken } : {},
256268
256240
  SCRIPT_PATH: scriptPath,
256269
256241
  BASE44_APP_ID: appId,
256270
256242
  BASE44_ACCESS_TOKEN: appUserToken,
@@ -256345,8 +256317,7 @@ async function execAction({ app, isNonInteractive }, options) {
256345
256317
  local,
256346
256318
  privileged: options.privileged,
256347
256319
  dataEnv: options.dataEnv,
256348
- serviceToken: envTarget?.serviceToken,
256349
- headers: envTarget?.headers
256320
+ serviceToken: envTarget?.serviceToken
256350
256321
  });
256351
256322
  if (exitCode !== 0) {
256352
256323
  process.exitCode = exitCode;
@@ -256354,7 +256325,7 @@ async function execAction({ app, isNonInteractive }, options) {
256354
256325
  return {};
256355
256326
  }
256356
256327
  function getExecCommand() {
256357
- return new Base44Command("exec", { requireAuth: () => !hasExecEnvTarget() }).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", `
256328
+ return new Base44Command("exec", { requireAuth: () => !hasExecEnvTarget() }).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})`).addOption(new Option2("--privileged", "Run with admin privileges (bypass RLS). Requires app owner/editor role.").env(PRIVILEGED_ENV_VAR)).addOption(new Option2("--data-env <environment>", "Data environment to run against (e.g. dev, prod)").env(DATA_ENV_ENV_VAR)).addHelpText("after", `
256358
256329
  Examples:
256359
256330
  Run a script file:
256360
256331
  $ cat ./script.ts | base44 exec
@@ -256372,7 +256343,8 @@ Environment (for sandboxes and agents; no login or linked project needed):
256372
256343
  BASE44_EXEC_ACCESS_TOKEN App-user token for the SDK (requires BASE44_EXEC_SERVER_URL)
256373
256344
  BASE44_EXEC_SERVER_URL SDK server URL (requires BASE44_EXEC_ACCESS_TOKEN)
256374
256345
  BASE44_EXEC_SERVICE_TOKEN Optional service token, enables base44.asServiceRole
256375
- BASE44_EXEC_HEADERS Optional JSON object of extra request headers
256346
+ BASE44_EXEC_PRIVILEGED Same as --privileged (set to any value to enable)
256347
+ BASE44_EXEC_DATA_ENV Same as --data-env
256376
256348
  The app id comes from --app-id or BASE44_APP_ID.`).action(execAction);
256377
256349
  }
256378
256350
 
@@ -260585,4 +260557,4 @@ export {
260585
260557
  runCLI
260586
260558
  };
260587
260559
 
260588
- //# debugId=FD7BADBA9A7011E864756E2164756E21
260560
+ //# debugId=CE7CD756BAAA547D64756E2164756E21