@base44-preview/cli 0.0.32-pr.264.aa4c901 → 0.0.32-pr.265.1f0294b
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/README.md +9 -7
- package/dist/cli/index.js +175 -56
- package/dist/cli/index.js.map +10 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -44,21 +44,23 @@ The CLI will guide you through project setup. For step-by-step tutorials, see th
|
|
|
44
44
|
| Command | Description |
|
|
45
45
|
| ------- | ----------- |
|
|
46
46
|
| [`create`](https://docs.base44.com/developers/references/cli/commands/create) | Create a new Base44 project from a template |
|
|
47
|
-
| [`deploy`](https://docs.base44.com/developers/references/cli/commands/deploy) | Deploy resources and site
|
|
48
|
-
| [`link`](https://docs.base44.com/developers/references/cli/commands/link) | Link a local project to a project
|
|
47
|
+
| [`deploy`](https://docs.base44.com/developers/references/cli/commands/deploy) | Deploy all project resources (entities, functions, agents, connectors, and site) |
|
|
48
|
+
| [`link`](https://docs.base44.com/developers/references/cli/commands/link) | Link a local project to a Base44 project |
|
|
49
|
+
| [`eject`](https://docs.base44.com/developers/references/cli/commands/eject) | Download the code for an existing Base44 project |
|
|
49
50
|
| [`dashboard open`](https://docs.base44.com/developers/references/cli/commands/dashboard) | Open the app dashboard in your browser |
|
|
50
51
|
| [`login`](https://docs.base44.com/developers/references/cli/commands/login) | Authenticate with Base44 |
|
|
51
|
-
| [`logout`](https://docs.base44.com/developers/references/cli/commands/logout) |
|
|
52
|
-
| [`whoami`](https://docs.base44.com/developers/references/cli/commands/whoami) | Display
|
|
52
|
+
| [`logout`](https://docs.base44.com/developers/references/cli/commands/logout) | Logout from current device |
|
|
53
|
+
| [`whoami`](https://docs.base44.com/developers/references/cli/commands/whoami) | Display current authenticated user |
|
|
53
54
|
| [`agents pull`](https://docs.base44.com/developers/references/cli/commands/agents-pull) | Pull agents from Base44 to local files |
|
|
54
55
|
| [`agents push`](https://docs.base44.com/developers/references/cli/commands/agents-push) | Push local agents to Base44 |
|
|
56
|
+
| [`connectors pull`](https://docs.base44.com/developers/references/cli/commands/connectors-pull) | Pull connectors from Base44 to local files |
|
|
57
|
+
| [`connectors push`](https://docs.base44.com/developers/references/cli/commands/connectors-push) | Push local connectors to Base44 |
|
|
55
58
|
| [`entities push`](https://docs.base44.com/developers/references/cli/commands/entities-push) | Push local entity schemas to Base44 |
|
|
56
59
|
| [`functions deploy`](https://docs.base44.com/developers/references/cli/commands/functions-deploy) | Deploy local functions to Base44 |
|
|
60
|
+
| [`functions invoke`](https://docs.base44.com/developers/references/cli/commands/functions-invoke) | Invoke a deployed backend function |
|
|
57
61
|
| [`site deploy`](https://docs.base44.com/developers/references/cli/commands/site-deploy) | Deploy built site files to Base44 hosting |
|
|
58
62
|
| [`site open`](https://docs.base44.com/developers/references/cli/commands/site-open) | Open the published site in your browser |
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
<!--| [`eject`](https://docs.base44.com/developers/references/cli/commands/eject) | Create a Base44 backend project from an existing Base44 app | -->
|
|
63
|
+
| [`types generate`](https://docs.base44.com/developers/references/cli/commands/types-generate) | Generate TypeScript types from project resources |
|
|
62
64
|
|
|
63
65
|
## AI agent skills
|
|
64
66
|
|
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,103 @@ 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 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
|
+
}
|
|
186078
186173
|
// src/core/resources/function/resource.ts
|
|
186079
186174
|
var functionResource = {
|
|
186080
186175
|
readAll: readAllFunctions,
|
|
@@ -186290,53 +186385,6 @@ async function createProjectFilesForExistingProject(options) {
|
|
|
186290
186385
|
}
|
|
186291
186386
|
// src/core/project/deploy.ts
|
|
186292
186387
|
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
186388
|
// src/core/site/config.ts
|
|
186341
186389
|
async function getSiteFilePaths(outputDir) {
|
|
186342
186390
|
return await globby("**/*", {
|
|
@@ -194989,6 +195037,80 @@ function getEntitiesPushCommand(context) {
|
|
|
194989
195037
|
}));
|
|
194990
195038
|
}
|
|
194991
195039
|
|
|
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
|
+
|
|
194992
195114
|
// src/cli/commands/functions/deploy.ts
|
|
194993
195115
|
async function deployFunctionsAction() {
|
|
194994
195116
|
const { functions } = await readProjectConfig();
|
|
@@ -195026,7 +195148,7 @@ ${errorMessages}`, {
|
|
|
195026
195148
|
function getFunctionsDeployCommand(context) {
|
|
195027
195149
|
return new Command("functions").description("Manage project functions").addCommand(new Command("deploy").description("Deploy local functions to Base44").action(async () => {
|
|
195028
195150
|
await runCommand(deployFunctionsAction, { requireAuth: true }, context);
|
|
195029
|
-
}));
|
|
195151
|
+
})).addCommand(getFunctionsInvokeCommand(context));
|
|
195030
195152
|
}
|
|
195031
195153
|
|
|
195032
195154
|
// src/cli/commands/project/create.ts
|
|
@@ -200039,9 +200161,6 @@ class ErrorReporter {
|
|
|
200039
200161
|
};
|
|
200040
200162
|
}).catch(() => {});
|
|
200041
200163
|
}
|
|
200042
|
-
getSessionId() {
|
|
200043
|
-
return this.sessionId;
|
|
200044
|
-
}
|
|
200045
200164
|
setContext(context) {
|
|
200046
200165
|
Object.assign(this.context, context);
|
|
200047
200166
|
}
|
|
@@ -200168,4 +200287,4 @@ export {
|
|
|
200168
200287
|
CLIExitError
|
|
200169
200288
|
};
|
|
200170
200289
|
|
|
200171
|
-
//# debugId=
|
|
200290
|
+
//# debugId=229682012D05F2D664756E2164756E21
|