@base44-preview/cli 0.3.1-pr.694.b9f40b5 → 0.3.1-pr.695.503ca43

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
@@ -228514,21 +228514,6 @@ class DependencyNotFoundError extends UserError {
228514
228514
  });
228515
228515
  }
228516
228516
  }
228517
-
228518
- class AppNotPublishedError extends UserError {
228519
- code = "APP_NOT_PUBLISHED";
228520
- constructor(message = "This app has not been published yet, so it has no site URL", options) {
228521
- super(message, {
228522
- hints: options?.hints ?? [
228523
- {
228524
- message: "Publish the app in the Base44 builder, or deploy its site with 'base44 deploy'",
228525
- command: "base44 deploy"
228526
- }
228527
- ],
228528
- cause: options?.cause
228529
- });
228530
- }
228531
- }
228532
228517
  var MAX_RESPONSE_TEXT_CHARS = 500;
228533
228518
  async function readResponseText(response) {
228534
228519
  try {
@@ -266143,18 +266128,10 @@ function getSiteInstallCommand() {
266143
266128
  }
266144
266129
 
266145
266130
  // src/cli/commands/site/open.ts
266146
- var isAppNotPublished = (error) => error instanceof ApiError && error.statusCode === 404;
266147
- async function getPublishedSiteUrl() {
266148
- try {
266149
- return await getSiteUrl();
266150
- } catch (error) {
266151
- throw isAppNotPublished(error) ? new AppNotPublishedError : error;
266152
- }
266153
- }
266154
266131
  async function openAction({
266155
266132
  isNonInteractive
266156
266133
  }) {
266157
- const siteUrl = await getPublishedSiteUrl();
266134
+ const siteUrl = await getSiteUrl();
266158
266135
  if (!isNonInteractive) {
266159
266136
  await open_default(siteUrl);
266160
266137
  }
@@ -270561,6 +270538,19 @@ async function createDevServer(options) {
270561
270538
  return { port, server, shutdown };
270562
270539
  }
270563
270540
 
270541
+ // src/core/project/app-base-url.ts
270542
+ var appPreviewUrl = (appId) => `https://preview--${appId}.base44.app`;
270543
+ var isAppNotPublished = (error) => error instanceof ApiError && error.statusCode === 404;
270544
+ async function resolveAppBaseUrl(appId) {
270545
+ try {
270546
+ return await getSiteUrl();
270547
+ } catch (error) {
270548
+ if (isAppNotPublished(error))
270549
+ return appPreviewUrl(appId);
270550
+ throw error;
270551
+ }
270552
+ }
270553
+
270564
270554
  // src/cli/commands/dev.ts
270565
270555
  function localServerUrl(port) {
270566
270556
  return `http://localhost:${port}`;
@@ -270599,7 +270589,7 @@ async function remoteDevAction(app) {
270599
270589
  if (!site) {
270600
270590
  throw new ConfigInvalidError("base44 dev --remote serves the frontend against the production backend, but this project has no site.serveCommand in base44/config.jsonc.");
270601
270591
  }
270602
- const appBaseUrl = await getSiteUrl();
270592
+ const appBaseUrl = await resolveAppBaseUrl(app.id);
270603
270593
  const runner = createServeCommandRunner({
270604
270594
  ...site,
270605
270595
  appId: app.id,
@@ -270728,7 +270718,7 @@ async function runScript(options) {
270728
270718
  cleanupFns.push(tempScript.cleanup);
270729
270719
  writeFileSync3(tempScript.path, code, "utf-8");
270730
270720
  const scriptPath = `file://${tempScript.path}`;
270731
- const [appUserToken, appBaseUrl] = local ? [local.token, local.serverUrl] : await Promise.all([getAppUserToken(), getSiteUrl()]);
270721
+ const [appUserToken, appBaseUrl] = local ? [local.token, local.serverUrl] : await Promise.all([getAppUserToken(), resolveAppBaseUrl(appId)]);
270732
270722
  const tempWrapper = await $file({ postfix: ".ts" });
270733
270723
  cleanupFns.push(tempWrapper.cleanup);
270734
270724
  writeFileSync3(tempWrapper.path, wrapperSource(sdkVersion), "utf-8");
@@ -275065,4 +275055,4 @@ export {
275065
275055
  runCLI
275066
275056
  };
275067
275057
 
275068
- //# debugId=11789D5167933FD664756E2164756E21
275058
+ //# debugId=5897AB86D8A0BE5164756E2164756E21