@base44-preview/cli 0.3.1-pr.692.8cd7d7b → 0.3.1-pr.693.36e994c

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.
@@ -8,7 +8,7 @@
8
8
  * - SCRIPT_PATH: Absolute path (or file:// URL) to the user's script
9
9
  * - BASE44_APP_ID: App identifier from .app.jsonc
10
10
  * - BASE44_ACCESS_TOKEN: User's access token
11
- * - BASE44_APP_BASE_URL: App's published URL / subdomain (used for function calls)
11
+ * - BASE44_APP_BASE_URL: App's published URL, or its preview URL before the first publish (function calls need an app host)
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`)
package/dist/cli/index.js CHANGED
@@ -270697,6 +270697,17 @@ function inheritedEnv() {
270697
270697
  }
270698
270698
  return env;
270699
270699
  }
270700
+ var appPreviewUrl = (appId) => `https://preview--${appId}.base44.app`;
270701
+ async function resolveAppBaseUrl(appId) {
270702
+ try {
270703
+ return await getSiteUrl();
270704
+ } catch (error) {
270705
+ if (error instanceof ApiError && error.statusCode === 404) {
270706
+ return appPreviewUrl(appId);
270707
+ }
270708
+ throw error;
270709
+ }
270710
+ }
270700
270711
  async function runScript(options) {
270701
270712
  const { appId, code, local, privileged, dataEnv, serviceToken, sdkVersion } = options;
270702
270713
  verifyDenoInstalled("to run scripts with exec");
@@ -270705,7 +270716,7 @@ async function runScript(options) {
270705
270716
  cleanupFns.push(tempScript.cleanup);
270706
270717
  writeFileSync3(tempScript.path, code, "utf-8");
270707
270718
  const scriptPath = `file://${tempScript.path}`;
270708
- const [appUserToken, appBaseUrl] = local ? [local.token, local.serverUrl] : await Promise.all([getAppUserToken(), getSiteUrl()]);
270719
+ const [appUserToken, appBaseUrl] = local ? [local.token, local.serverUrl] : await Promise.all([getAppUserToken(), resolveAppBaseUrl(appId)]);
270709
270720
  const tempWrapper = await $file({ postfix: ".ts" });
270710
270721
  cleanupFns.push(tempWrapper.cleanup);
270711
270722
  writeFileSync3(tempWrapper.path, wrapperSource(sdkVersion), "utf-8");
@@ -275042,4 +275053,4 @@ export {
275042
275053
  runCLI
275043
275054
  };
275044
275055
 
275045
- //# debugId=B638BBD3E1A945A364756E2164756E21
275056
+ //# debugId=8867935948E85B0C64756E2164756E21