@base44-preview/cli 0.0.32-pr.264.aa4c901 → 0.0.32-pr.265.44aca22
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 +128 -56
- package/dist/cli/index.js.map +10 -8
- package/package.json +1 -1
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
|
|
18488
|
+
var invoke2 = 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 =
|
|
19343
|
+
lodash.invoke = invoke2;
|
|
19344
19344
|
lodash.isArguments = isArguments;
|
|
19345
19345
|
lodash.isArray = isArray;
|
|
19346
19346
|
lodash.isArrayBuffer = isArrayBuffer2;
|
|
@@ -178631,7 +178631,6 @@ class FileReadError extends SystemError {
|
|
|
178631
178631
|
}
|
|
178632
178632
|
class TypeGenerationError extends SystemError {
|
|
178633
178633
|
code = "TYPE_GENERATION_ERROR";
|
|
178634
|
-
entityName;
|
|
178635
178634
|
constructor(message, entityName, cause) {
|
|
178636
178635
|
super(message, {
|
|
178637
178636
|
hints: [
|
|
@@ -178641,7 +178640,6 @@ class TypeGenerationError extends SystemError {
|
|
|
178641
178640
|
],
|
|
178642
178641
|
cause: cause instanceof Error ? cause : undefined
|
|
178643
178642
|
});
|
|
178644
|
-
this.entityName = entityName;
|
|
178645
178643
|
}
|
|
178646
178644
|
}
|
|
178647
178645
|
function isCLIError(error48) {
|
|
@@ -186075,6 +186073,81 @@ async function pushFunctions(functions) {
|
|
|
186075
186073
|
const functionsWithCode = await Promise.all(functions.map(loadFunctionCode));
|
|
186076
186074
|
return deployFunctions(functionsWithCode);
|
|
186077
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 response = await distribution_default(url2, {
|
|
186139
|
+
method,
|
|
186140
|
+
...METHODS_WITH_BODY.has(method) ? { json: data } : {},
|
|
186141
|
+
headers: {
|
|
186142
|
+
Authorization: `Bearer ${token}`,
|
|
186143
|
+
"X-App-Id": id,
|
|
186144
|
+
"User-Agent": "Base44 CLI",
|
|
186145
|
+
...options?.headers
|
|
186146
|
+
},
|
|
186147
|
+
timeout: options?.timeout ?? 300000
|
|
186148
|
+
});
|
|
186149
|
+
return response.json();
|
|
186150
|
+
}
|
|
186078
186151
|
// src/core/resources/function/resource.ts
|
|
186079
186152
|
var functionResource = {
|
|
186080
186153
|
readAll: readAllFunctions,
|
|
@@ -186290,53 +186363,6 @@ async function createProjectFilesForExistingProject(options) {
|
|
|
186290
186363
|
}
|
|
186291
186364
|
// src/core/project/deploy.ts
|
|
186292
186365
|
import { resolve } from "node:path";
|
|
186293
|
-
|
|
186294
|
-
// src/core/site/schema.ts
|
|
186295
|
-
var DeployResponseSchema = exports_external.object({
|
|
186296
|
-
app_url: exports_external.url()
|
|
186297
|
-
}).transform((data) => ({
|
|
186298
|
-
appUrl: data.app_url
|
|
186299
|
-
}));
|
|
186300
|
-
var PublishedUrlResponseSchema = exports_external.object({
|
|
186301
|
-
url: exports_external.string()
|
|
186302
|
-
});
|
|
186303
|
-
|
|
186304
|
-
// src/core/site/api.ts
|
|
186305
|
-
async function uploadSite(archivePath) {
|
|
186306
|
-
const archiveBuffer = await readFile(archivePath);
|
|
186307
|
-
const blob = new Blob([archiveBuffer], { type: "application/gzip" });
|
|
186308
|
-
const formData = new FormData;
|
|
186309
|
-
formData.append("file", blob, "dist.tar.gz");
|
|
186310
|
-
const appClient = getAppClient();
|
|
186311
|
-
let response;
|
|
186312
|
-
try {
|
|
186313
|
-
response = await appClient.post("deploy-dist", {
|
|
186314
|
-
body: formData,
|
|
186315
|
-
timeout: 180000
|
|
186316
|
-
});
|
|
186317
|
-
} catch (error48) {
|
|
186318
|
-
throw await ApiError.fromHttpError(error48, "deploying site");
|
|
186319
|
-
}
|
|
186320
|
-
const result = DeployResponseSchema.safeParse(await response.json());
|
|
186321
|
-
if (!result.success) {
|
|
186322
|
-
throw new SchemaValidationError("There was an issue deploying your site", result.error);
|
|
186323
|
-
}
|
|
186324
|
-
return result.data;
|
|
186325
|
-
}
|
|
186326
|
-
async function getSiteUrl(projectId) {
|
|
186327
|
-
const id = projectId ?? getAppConfig().id;
|
|
186328
|
-
let response;
|
|
186329
|
-
try {
|
|
186330
|
-
response = await base44Client.get(`api/apps/platform/${id}/published-url`);
|
|
186331
|
-
} catch (error48) {
|
|
186332
|
-
throw await ApiError.fromHttpError(error48, "fetching site URL");
|
|
186333
|
-
}
|
|
186334
|
-
const result = PublishedUrlResponseSchema.safeParse(await response.json());
|
|
186335
|
-
if (!result.success) {
|
|
186336
|
-
throw new SchemaValidationError("Invalid response from server", result.error);
|
|
186337
|
-
}
|
|
186338
|
-
return result.data.url;
|
|
186339
|
-
}
|
|
186340
186366
|
// src/core/site/config.ts
|
|
186341
186367
|
async function getSiteFilePaths(outputDir) {
|
|
186342
186368
|
return await globby("**/*", {
|
|
@@ -194989,6 +195015,55 @@ function getEntitiesPushCommand(context) {
|
|
|
194989
195015
|
}));
|
|
194990
195016
|
}
|
|
194991
195017
|
|
|
195018
|
+
// src/cli/commands/functions/invoke.ts
|
|
195019
|
+
function collectHeader(value, previous) {
|
|
195020
|
+
const idx = value.indexOf(":");
|
|
195021
|
+
if (idx === -1) {
|
|
195022
|
+
throw new Error(`Invalid header (expected "Name: Value"): ${value}`);
|
|
195023
|
+
}
|
|
195024
|
+
const name2 = value.slice(0, idx).trim();
|
|
195025
|
+
const headerValue = value.slice(idx + 1).trim();
|
|
195026
|
+
return { ...previous, [name2]: headerValue };
|
|
195027
|
+
}
|
|
195028
|
+
function parseJsonArg(value) {
|
|
195029
|
+
try {
|
|
195030
|
+
const parsed = JSON.parse(value);
|
|
195031
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
195032
|
+
throw new Error("Data must be a JSON object");
|
|
195033
|
+
}
|
|
195034
|
+
return parsed;
|
|
195035
|
+
} catch (e2) {
|
|
195036
|
+
throw new Error(`Invalid JSON data: ${e2 instanceof Error ? e2.message : String(e2)}`);
|
|
195037
|
+
}
|
|
195038
|
+
}
|
|
195039
|
+
async function invokeFunctionAction(functionName, options) {
|
|
195040
|
+
const data = options.data ? parseJsonArg(options.data) : {};
|
|
195041
|
+
const method = options.method?.toUpperCase() ?? "POST";
|
|
195042
|
+
const timeout2 = options.timeout ? parseInt(options.timeout, 10) * 1000 : undefined;
|
|
195043
|
+
R2.info(`Invoking function ${theme.styles.bold(functionName)} (${method})`);
|
|
195044
|
+
const result = await runTask("Running function", async () => {
|
|
195045
|
+
return await invokeFunction(functionName, data, {
|
|
195046
|
+
timeout: timeout2,
|
|
195047
|
+
method,
|
|
195048
|
+
headers: options.header
|
|
195049
|
+
});
|
|
195050
|
+
}, {
|
|
195051
|
+
successMessage: "Function executed successfully",
|
|
195052
|
+
errorMessage: "Function execution failed"
|
|
195053
|
+
});
|
|
195054
|
+
const output = typeof result === "string" ? result : JSON.stringify(result, null, 2);
|
|
195055
|
+
R2.info(`Response:
|
|
195056
|
+
${output}`);
|
|
195057
|
+
return {
|
|
195058
|
+
outroMessage: `Function ${theme.styles.bold(functionName)} completed`
|
|
195059
|
+
};
|
|
195060
|
+
}
|
|
195061
|
+
function getFunctionsInvokeCommand(context) {
|
|
195062
|
+
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)").action(async (functionName, options) => {
|
|
195063
|
+
await runCommand(() => invokeFunctionAction(functionName, options), { requireAuth: true }, context);
|
|
195064
|
+
});
|
|
195065
|
+
}
|
|
195066
|
+
|
|
194992
195067
|
// src/cli/commands/functions/deploy.ts
|
|
194993
195068
|
async function deployFunctionsAction() {
|
|
194994
195069
|
const { functions } = await readProjectConfig();
|
|
@@ -195026,7 +195101,7 @@ ${errorMessages}`, {
|
|
|
195026
195101
|
function getFunctionsDeployCommand(context) {
|
|
195027
195102
|
return new Command("functions").description("Manage project functions").addCommand(new Command("deploy").description("Deploy local functions to Base44").action(async () => {
|
|
195028
195103
|
await runCommand(deployFunctionsAction, { requireAuth: true }, context);
|
|
195029
|
-
}));
|
|
195104
|
+
})).addCommand(getFunctionsInvokeCommand(context));
|
|
195030
195105
|
}
|
|
195031
195106
|
|
|
195032
195107
|
// src/cli/commands/project/create.ts
|
|
@@ -200039,9 +200114,6 @@ class ErrorReporter {
|
|
|
200039
200114
|
};
|
|
200040
200115
|
}).catch(() => {});
|
|
200041
200116
|
}
|
|
200042
|
-
getSessionId() {
|
|
200043
|
-
return this.sessionId;
|
|
200044
|
-
}
|
|
200045
200117
|
setContext(context) {
|
|
200046
200118
|
Object.assign(this.context, context);
|
|
200047
200119
|
}
|
|
@@ -200168,4 +200240,4 @@ export {
|
|
|
200168
200240
|
CLIExitError
|
|
200169
200241
|
};
|
|
200170
200242
|
|
|
200171
|
-
//# debugId=
|
|
200243
|
+
//# debugId=B2CE23710B195DBD64756E2164756E21
|