@base44-preview/cli 0.1.22-pr.644.52a9e2d → 0.1.22-pr.644.73e28ed

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
@@ -247411,8 +247411,7 @@ class Base44Command extends Command2 {
247411
247411
  if (branch !== undefined && !branch.trim()) {
247412
247412
  throw new InvalidInputError("--branch must not be empty.");
247413
247413
  }
247414
- const { requireAuth } = this._commandOptions;
247415
- if (typeof requireAuth === "function" ? requireAuth() : requireAuth) {
247414
+ if (this._commandOptions.requireAuth) {
247416
247415
  await ensureAuth(this.context);
247417
247416
  }
247418
247417
  if (this._commandOptions.requireAppContext) {
@@ -256168,39 +256167,19 @@ function getDevCommand() {
256168
256167
  var ACCESS_TOKEN_VAR = "BASE44_EXEC_ACCESS_TOKEN";
256169
256168
  var SERVER_URL_VAR = "BASE44_EXEC_SERVER_URL";
256170
256169
  var SERVICE_TOKEN_VAR = "BASE44_EXEC_SERVICE_TOKEN";
256171
- var HEADERS_VAR = "BASE44_EXEC_HEADERS";
256172
256170
  var EXEC_ENV_VARS = [
256173
256171
  ACCESS_TOKEN_VAR,
256174
256172
  SERVER_URL_VAR,
256175
- SERVICE_TOKEN_VAR,
256176
- HEADERS_VAR
256173
+ SERVICE_TOKEN_VAR
256177
256174
  ];
256175
+ var PRIVILEGED_ENV_VAR = "BASE44_PRIVILEGED";
256176
+ var DATA_ENV_ENV_VAR = "BASE44_DATA_ENV";
256178
256177
  function read3(env, name) {
256179
256178
  return env[name]?.trim() || undefined;
256180
256179
  }
256181
256180
  function hasExecEnvTarget(env = process.env) {
256182
256181
  return EXEC_ENV_VARS.some((name) => read3(env, name) !== undefined);
256183
256182
  }
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
256183
  function readExecEnvTarget(env = process.env) {
256205
256184
  if (!hasExecEnvTarget(env)) {
256206
256185
  return;
@@ -256212,7 +256191,7 @@ function readExecEnvTarget(env = process.env) {
256212
256191
  throw new InvalidInputError(`${missing} is not set. ${ACCESS_TOKEN_VAR} and ${SERVER_URL_VAR} must be set together.`, {
256213
256192
  hints: [
256214
256193
  {
256215
- message: `Set both ${ACCESS_TOKEN_VAR} and ${SERVER_URL_VAR}, or unset all BASE44_EXEC_* variables to use your login`
256194
+ message: `Set both ${ACCESS_TOKEN_VAR} and ${SERVER_URL_VAR}, or unset all of them to use your login`
256216
256195
  }
256217
256196
  ]
256218
256197
  });
@@ -256221,34 +256200,26 @@ function readExecEnvTarget(env = process.env) {
256221
256200
  throw new InvalidInputError(`${SERVER_URL_VAR} is not a valid URL.`);
256222
256201
  }
256223
256202
  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
- };
256203
+ return { token, serverUrl, ...serviceToken ? { serviceToken } : {} };
256231
256204
  }
256232
256205
  // src/core/exec/run-script.ts
256233
256206
  import { spawn as spawn4 } from "node:child_process";
256234
256207
  import { copyFileSync, writeFileSync as writeFileSync3 } from "node:fs";
256235
256208
  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
256209
  function inheritedEnv() {
256244
256210
  const env = { ...process.env };
256245
- for (const name of [...EXEC_ENV_VARS, SERVICE_TOKEN_ENV, EXTRA_HEADERS_ENV]) {
256211
+ for (const name of [
256212
+ ...EXEC_ENV_VARS,
256213
+ PRIVILEGED_ENV_VAR,
256214
+ DATA_ENV_ENV_VAR,
256215
+ SERVICE_TOKEN_ENV
256216
+ ]) {
256246
256217
  delete env[name];
256247
256218
  }
256248
256219
  return env;
256249
256220
  }
256250
256221
  async function runScript(options) {
256251
- const { appId, code, local, privileged, dataEnv, serviceToken, headers } = options;
256222
+ const { appId, code, local, privileged, dataEnv, serviceToken } = options;
256252
256223
  verifyDenoInstalled("to run scripts with exec");
256253
256224
  const cleanupFns = [];
256254
256225
  const tempScript = await $file({ postfix: ".ts" });
@@ -256261,10 +256232,10 @@ async function runScript(options) {
256261
256232
  copyFileSync(getExecWrapperPath(), tempWrapper.path);
256262
256233
  try {
256263
256234
  const exitCode = await new Promise((resolvePromise) => {
256264
- const child = spawn4("deno", ["run", "--allow-all", "--node-modules-dir=auto", tempWrapper.path], {
256235
+ const child = spawn4("deno", ["run", "--allow-all", "--node-modules-dir=none", tempWrapper.path], {
256265
256236
  env: {
256266
256237
  ...inheritedEnv(),
256267
- ...wrapperOnlyEnv(serviceToken, headers),
256238
+ ...serviceToken ? { [SERVICE_TOKEN_ENV]: serviceToken } : {},
256268
256239
  SCRIPT_PATH: scriptPath,
256269
256240
  BASE44_APP_ID: appId,
256270
256241
  BASE44_ACCESS_TOKEN: appUserToken,
@@ -256345,8 +256316,7 @@ async function execAction({ app, isNonInteractive }, options) {
256345
256316
  local,
256346
256317
  privileged: options.privileged,
256347
256318
  dataEnv: options.dataEnv,
256348
- serviceToken: envTarget?.serviceToken,
256349
- headers: envTarget?.headers
256319
+ serviceToken: envTarget?.serviceToken
256350
256320
  });
256351
256321
  if (exitCode !== 0) {
256352
256322
  process.exitCode = exitCode;
@@ -256354,7 +256324,7 @@ async function execAction({ app, isNonInteractive }, options) {
256354
256324
  return {};
256355
256325
  }
256356
256326
  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", `
256327
+ 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
256328
  Examples:
256359
256329
  Run a script file:
256360
256330
  $ cat ./script.ts | base44 exec
@@ -256366,14 +256336,7 @@ Examples:
256366
256336
  $ echo "await base44.entities.Task.create({ title: 'seed' })" | base44 exec --local
256367
256337
 
256368
256338
  With privileged access (bypass RLS):
256369
- $ echo "const all = await base44.entities.Task.list()" | base44 exec --privileged
256370
-
256371
- Environment (for sandboxes and agents; no login or linked project needed):
256372
- BASE44_EXEC_ACCESS_TOKEN App-user token for the SDK (requires BASE44_EXEC_SERVER_URL)
256373
- BASE44_EXEC_SERVER_URL SDK server URL (requires BASE44_EXEC_ACCESS_TOKEN)
256374
- BASE44_EXEC_SERVICE_TOKEN Optional service token, enables base44.asServiceRole
256375
- BASE44_EXEC_HEADERS Optional JSON object of extra request headers
256376
- The app id comes from --app-id or BASE44_APP_ID.`).action(execAction);
256339
+ $ echo "const all = await base44.entities.Task.list()" | base44 exec --privileged`).action(execAction);
256377
256340
  }
256378
256341
 
256379
256342
  // src/cli/commands/project/eject.ts
@@ -260585,4 +260548,4 @@ export {
260585
260548
  runCLI
260586
260549
  };
260587
260550
 
260588
- //# debugId=FD7BADBA9A7011E864756E2164756E21
260551
+ //# debugId=CBF218C6D6FED80864756E2164756E21