@base44-preview/cli 0.0.32-pr.265.de49ace → 0.0.32-pr.267.071c9b9

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.
package/dist/cli/index.js CHANGED
@@ -18485,7 +18485,7 @@ var require_lodash2 = __commonJS((exports, module) => {
18485
18485
  result2[value] = [key];
18486
18486
  }
18487
18487
  }, getIteratee);
18488
- var invoke2 = baseRest(baseInvoke);
18488
+ var invoke = baseRest(baseInvoke);
18489
18489
  function keys(object2) {
18490
18490
  return isArrayLike(object2) ? arrayLikeKeys(object2) : baseKeys(object2);
18491
18491
  }
@@ -19340,7 +19340,7 @@ __p += '`;
19340
19340
  lodash.includes = includes;
19341
19341
  lodash.indexOf = indexOf;
19342
19342
  lodash.inRange = inRange;
19343
- lodash.invoke = invoke2;
19343
+ lodash.invoke = invoke;
19344
19344
  lodash.isArguments = isArguments;
19345
19345
  lodash.isArray = isArray;
19346
19346
  lodash.isArrayBuffer = isArrayBuffer2;
@@ -186073,103 +186073,6 @@ async function pushFunctions(functions) {
186073
186073
  const functionsWithCode = await Promise.all(functions.map(loadFunctionCode));
186074
186074
  return deployFunctions(functionsWithCode);
186075
186075
  }
186076
- // src/core/site/schema.ts
186077
- var DeployResponseSchema = exports_external.object({
186078
- app_url: exports_external.url()
186079
- }).transform((data) => ({
186080
- appUrl: data.app_url
186081
- }));
186082
- var PublishedUrlResponseSchema = exports_external.object({
186083
- url: exports_external.string()
186084
- });
186085
-
186086
- // src/core/site/api.ts
186087
- async function uploadSite(archivePath) {
186088
- const archiveBuffer = await readFile(archivePath);
186089
- const blob = new Blob([archiveBuffer], { type: "application/gzip" });
186090
- const formData = new FormData;
186091
- formData.append("file", blob, "dist.tar.gz");
186092
- const appClient = getAppClient();
186093
- let response;
186094
- try {
186095
- response = await appClient.post("deploy-dist", {
186096
- body: formData,
186097
- timeout: 180000
186098
- });
186099
- } catch (error48) {
186100
- throw await ApiError.fromHttpError(error48, "deploying site");
186101
- }
186102
- const result = DeployResponseSchema.safeParse(await response.json());
186103
- if (!result.success) {
186104
- throw new SchemaValidationError("There was an issue deploying your site", result.error);
186105
- }
186106
- return result.data;
186107
- }
186108
- async function getSiteUrl(projectId) {
186109
- const id = projectId ?? getAppConfig().id;
186110
- let response;
186111
- try {
186112
- response = await base44Client.get(`api/apps/platform/${id}/published-url`);
186113
- } catch (error48) {
186114
- throw await ApiError.fromHttpError(error48, "fetching site URL");
186115
- }
186116
- const result = PublishedUrlResponseSchema.safeParse(await response.json());
186117
- if (!result.success) {
186118
- throw new SchemaValidationError("Invalid response from server", result.error);
186119
- }
186120
- return result.data.url;
186121
- }
186122
-
186123
- // src/core/resources/function/invoke.ts
186124
- var METHODS_WITH_BODY = new Set(["POST", "PUT", "PATCH"]);
186125
- async function invokeFunction(functionName, data, options) {
186126
- const { id } = getAppConfig();
186127
- const method = options?.method?.toUpperCase() ?? "POST";
186128
- const siteUrl = await getSiteUrl();
186129
- const url2 = `${siteUrl.replace(/\/+$/, "")}/api/functions/${functionName}`;
186130
- const auth = await readAuth();
186131
- let token = auth.accessToken;
186132
- if (isTokenExpired(auth)) {
186133
- const refreshed = await refreshAndSaveTokens();
186134
- if (refreshed) {
186135
- token = refreshed;
186136
- }
186137
- }
186138
- const requestHeaders = {
186139
- Authorization: `Bearer ${token}`,
186140
- "X-App-Id": id,
186141
- "User-Agent": "Base44 CLI",
186142
- ...options?.headers
186143
- };
186144
- const startTime = Date.now();
186145
- let response;
186146
- try {
186147
- response = await distribution_default(url2, {
186148
- method,
186149
- ...METHODS_WITH_BODY.has(method) ? { json: data } : {},
186150
- headers: requestHeaders,
186151
- timeout: options?.timeout ?? 300000
186152
- });
186153
- } catch (error48) {
186154
- throw await ApiError.fromHttpError(error48, "invoking function");
186155
- }
186156
- const durationMs = Date.now() - startTime;
186157
- const responseHeaders = {};
186158
- response.headers.forEach((value, key) => {
186159
- responseHeaders[key] = value;
186160
- });
186161
- const body = await response.json();
186162
- return {
186163
- body,
186164
- status: response.status,
186165
- statusText: response.statusText,
186166
- headers: responseHeaders,
186167
- url: url2,
186168
- method,
186169
- requestHeaders,
186170
- durationMs
186171
- };
186172
- }
186173
186076
  // src/core/resources/function/resource.ts
186174
186077
  var functionResource = {
186175
186078
  readAll: readAllFunctions,
@@ -186385,6 +186288,53 @@ async function createProjectFilesForExistingProject(options) {
186385
186288
  }
186386
186289
  // src/core/project/deploy.ts
186387
186290
  import { resolve } from "node:path";
186291
+
186292
+ // src/core/site/schema.ts
186293
+ var DeployResponseSchema = exports_external.object({
186294
+ app_url: exports_external.url()
186295
+ }).transform((data) => ({
186296
+ appUrl: data.app_url
186297
+ }));
186298
+ var PublishedUrlResponseSchema = exports_external.object({
186299
+ url: exports_external.string()
186300
+ });
186301
+
186302
+ // src/core/site/api.ts
186303
+ async function uploadSite(archivePath) {
186304
+ const archiveBuffer = await readFile(archivePath);
186305
+ const blob = new Blob([archiveBuffer], { type: "application/gzip" });
186306
+ const formData = new FormData;
186307
+ formData.append("file", blob, "dist.tar.gz");
186308
+ const appClient = getAppClient();
186309
+ let response;
186310
+ try {
186311
+ response = await appClient.post("deploy-dist", {
186312
+ body: formData,
186313
+ timeout: 180000
186314
+ });
186315
+ } catch (error48) {
186316
+ throw await ApiError.fromHttpError(error48, "deploying site");
186317
+ }
186318
+ const result = DeployResponseSchema.safeParse(await response.json());
186319
+ if (!result.success) {
186320
+ throw new SchemaValidationError("There was an issue deploying your site", result.error);
186321
+ }
186322
+ return result.data;
186323
+ }
186324
+ async function getSiteUrl(projectId) {
186325
+ const id = projectId ?? getAppConfig().id;
186326
+ let response;
186327
+ try {
186328
+ response = await base44Client.get(`api/apps/platform/${id}/published-url`);
186329
+ } catch (error48) {
186330
+ throw await ApiError.fromHttpError(error48, "fetching site URL");
186331
+ }
186332
+ const result = PublishedUrlResponseSchema.safeParse(await response.json());
186333
+ if (!result.success) {
186334
+ throw new SchemaValidationError("Invalid response from server", result.error);
186335
+ }
186336
+ return result.data.url;
186337
+ }
186388
186338
  // src/core/site/config.ts
186389
186339
  async function getSiteFilePaths(outputDir) {
186390
186340
  return await globby("**/*", {
@@ -195037,80 +194987,6 @@ function getEntitiesPushCommand(context) {
195037
194987
  }));
195038
194988
  }
195039
194989
 
195040
- // src/cli/commands/functions/invoke.ts
195041
- function collectHeader(value, previous) {
195042
- const idx = value.indexOf(":");
195043
- if (idx === -1) {
195044
- throw new Error(`Invalid header (expected "Name: Value"): ${value}`);
195045
- }
195046
- const name2 = value.slice(0, idx).trim();
195047
- const headerValue = value.slice(idx + 1).trim();
195048
- return { ...previous, [name2]: headerValue };
195049
- }
195050
- function parseJsonArg(value) {
195051
- try {
195052
- const parsed = JSON.parse(value);
195053
- if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
195054
- throw new Error("Data must be a JSON object");
195055
- }
195056
- return parsed;
195057
- } catch (e2) {
195058
- throw new Error(`Invalid JSON data: ${e2 instanceof Error ? e2.message : String(e2)}`);
195059
- }
195060
- }
195061
- async function invokeFunctionAction(functionName, options) {
195062
- const data = options.data ? parseJsonArg(options.data) : {};
195063
- const method = options.method?.toUpperCase() ?? "POST";
195064
- const timeout2 = options.timeout ? parseInt(options.timeout, 10) * 1000 : undefined;
195065
- if (!options.verbose) {
195066
- R2.info(`Invoking function ${theme.styles.bold(functionName)} (${method})`);
195067
- }
195068
- const result = await runTask("Running function", async () => {
195069
- return await invokeFunction(functionName, data, {
195070
- timeout: timeout2,
195071
- method,
195072
- headers: options.header
195073
- });
195074
- }, {
195075
- successMessage: options.verbose ? undefined : "Function executed successfully",
195076
- errorMessage: "Function execution failed"
195077
- });
195078
- if (options.verbose) {
195079
- R2.info(theme.styles.dim("* Request:"));
195080
- R2.info(theme.styles.dim(`> ${result.method} ${result.url}`));
195081
- for (const [key, value] of Object.entries(result.requestHeaders)) {
195082
- const displayValue = key === "Authorization" ? "Bearer [REDACTED]" : value;
195083
- R2.info(theme.styles.dim(`> ${key}: ${displayValue}`));
195084
- }
195085
- if (Object.keys(data).length > 0) {
195086
- R2.info(theme.styles.dim(">"));
195087
- R2.info(theme.styles.dim(`> ${JSON.stringify(data)}`));
195088
- }
195089
- R2.info(theme.styles.dim("*"));
195090
- R2.info(theme.styles.dim("* Response:"));
195091
- R2.info(theme.styles.dim(`< HTTP ${result.status} ${result.statusText} (${result.durationMs}ms)`));
195092
- for (const [key, value] of Object.entries(result.headers)) {
195093
- R2.info(theme.styles.dim(`< ${key}: ${value}`));
195094
- }
195095
- R2.info(theme.styles.dim("<"));
195096
- }
195097
- const output = typeof result.body === "string" ? result.body : JSON.stringify(result.body, null, 2);
195098
- if (options.verbose) {
195099
- R2.info(output);
195100
- } else {
195101
- R2.info(`Response:
195102
- ${output}`);
195103
- }
195104
- return {
195105
- outroMessage: options.verbose ? undefined : `Function ${theme.styles.bold(functionName)} completed`
195106
- };
195107
- }
195108
- function getFunctionsInvokeCommand(context) {
195109
- return new Command("invoke").description("Invoke a deployed backend function").argument("<function-name>", "Name of the function to invoke").option("-X, --method <verb>", "HTTP method (default: POST)").option("-H, --header <header>", "Custom header (Name: Value), repeatable", collectHeader, {}).option("-d, --data <json>", "JSON data to send to the function").option("-t, --timeout <seconds>", "Timeout in seconds (default: 300)").option("-v, --verbose", "Verbose output (show request/response headers, status, timing)").action(async (functionName, options) => {
195110
- await runCommand(() => invokeFunctionAction(functionName, options), { requireAuth: true }, context);
195111
- });
195112
- }
195113
-
195114
194990
  // src/cli/commands/functions/deploy.ts
195115
194991
  async function deployFunctionsAction() {
195116
194992
  const { functions } = await readProjectConfig();
@@ -195148,7 +195024,7 @@ ${errorMessages}`, {
195148
195024
  function getFunctionsDeployCommand(context) {
195149
195025
  return new Command("functions").description("Manage project functions").addCommand(new Command("deploy").description("Deploy local functions to Base44").action(async () => {
195150
195026
  await runCommand(deployFunctionsAction, { requireAuth: true }, context);
195151
- })).addCommand(getFunctionsInvokeCommand(context));
195027
+ }));
195152
195028
  }
195153
195029
 
195154
195030
  // src/cli/commands/project/create.ts
@@ -200287,4 +200163,4 @@ export {
200287
200163
  CLIExitError
200288
200164
  };
200289
200165
 
200290
- //# debugId=229682012D05F2D664756E2164756E21
200166
+ //# debugId=8FF06F66318A4ACC64756E2164756E21