@base44-preview/cli 0.0.44-pr.380.71fe077 → 0.0.44-pr.395.7152e38
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 +206 -73
- package/dist/cli/index.js.map +12 -13
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -238081,7 +238081,7 @@ var FieldRLSSchema = exports_external.looseObject({
|
|
|
238081
238081
|
delete: RLSRuleSchema.optional()
|
|
238082
238082
|
});
|
|
238083
238083
|
var PropertyDefinitionSchema = exports_external.looseObject({
|
|
238084
|
-
type: exports_external.string()
|
|
238084
|
+
type: exports_external.string(),
|
|
238085
238085
|
title: exports_external.string().optional(),
|
|
238086
238086
|
description: exports_external.string().optional(),
|
|
238087
238087
|
minLength: exports_external.number().int().min(0).optional(),
|
|
@@ -238236,22 +238236,6 @@ var DeployFunctionsResponseSchema = exports_external.object({
|
|
|
238236
238236
|
skipped: exports_external.array(exports_external.string()).optional().nullable(),
|
|
238237
238237
|
errors: exports_external.array(exports_external.object({ name: exports_external.string(), message: exports_external.string() })).nullable()
|
|
238238
238238
|
});
|
|
238239
|
-
var FunctionInfoSchema = exports_external.object({
|
|
238240
|
-
name: exports_external.string(),
|
|
238241
|
-
deployment_id: exports_external.string(),
|
|
238242
|
-
entry: exports_external.string(),
|
|
238243
|
-
files: exports_external.array(FunctionFileSchema),
|
|
238244
|
-
automations: exports_external.array(AutomationSchema)
|
|
238245
|
-
}).transform((data) => ({
|
|
238246
|
-
name: data.name,
|
|
238247
|
-
deploymentId: data.deployment_id,
|
|
238248
|
-
entry: data.entry,
|
|
238249
|
-
files: data.files,
|
|
238250
|
-
automations: data.automations
|
|
238251
|
-
}));
|
|
238252
|
-
var ListFunctionsResponseSchema = exports_external.object({
|
|
238253
|
-
functions: exports_external.array(FunctionInfoSchema)
|
|
238254
|
-
});
|
|
238255
238239
|
var LogLevelSchema = exports_external.enum(["info", "warning", "error", "debug"]);
|
|
238256
238240
|
var FunctionLogEntrySchema = exports_external.object({
|
|
238257
238241
|
time: exports_external.string(),
|
|
@@ -238325,20 +238309,6 @@ async function fetchFunctionLogs(functionName, filters = {}) {
|
|
|
238325
238309
|
}
|
|
238326
238310
|
return result.data;
|
|
238327
238311
|
}
|
|
238328
|
-
async function listDeployedFunctions() {
|
|
238329
|
-
const appClient = getAppClient();
|
|
238330
|
-
let response;
|
|
238331
|
-
try {
|
|
238332
|
-
response = await appClient.get("backend-functions", { timeout: 30000 });
|
|
238333
|
-
} catch (error48) {
|
|
238334
|
-
throw await ApiError.fromHttpError(error48, "listing deployed functions");
|
|
238335
|
-
}
|
|
238336
|
-
const result = ListFunctionsResponseSchema.safeParse(await response.json());
|
|
238337
|
-
if (!result.success) {
|
|
238338
|
-
throw new SchemaValidationError("Invalid response from server", result.error);
|
|
238339
|
-
}
|
|
238340
|
-
return result.data;
|
|
238341
|
-
}
|
|
238342
238312
|
// src/core/resources/function/config.ts
|
|
238343
238313
|
import { basename as basename2, dirname as dirname3, join as join5, relative } from "node:path";
|
|
238344
238314
|
async function readFunctionConfig(configPath) {
|
|
@@ -247620,36 +247590,10 @@ async function deployFunctionsAction() {
|
|
|
247620
247590
|
}
|
|
247621
247591
|
return { outroMessage: "Functions deployed to Base44" };
|
|
247622
247592
|
}
|
|
247623
|
-
function
|
|
247624
|
-
return new Command("deploy").description("Deploy local functions to Base44").action(async () => {
|
|
247593
|
+
function getFunctionsDeployCommand(context) {
|
|
247594
|
+
return new Command("functions").description("Manage project functions").addCommand(new Command("deploy").description("Deploy local functions to Base44").action(async () => {
|
|
247625
247595
|
await runCommand(deployFunctionsAction, { requireAuth: true }, context);
|
|
247626
|
-
});
|
|
247627
|
-
}
|
|
247628
|
-
|
|
247629
|
-
// src/cli/commands/functions/list.ts
|
|
247630
|
-
async function listFunctionsAction() {
|
|
247631
|
-
const { functions } = await runTask("Fetching functions...", async () => listDeployedFunctions());
|
|
247632
|
-
if (functions.length === 0) {
|
|
247633
|
-
return { outroMessage: "No functions on remote" };
|
|
247634
|
-
}
|
|
247635
|
-
for (const fn of functions) {
|
|
247636
|
-
const automationCount = fn.automations.length;
|
|
247637
|
-
const automationLabel = automationCount > 0 ? theme.styles.dim(` (${automationCount} automation${automationCount > 1 ? "s" : ""})`) : "";
|
|
247638
|
-
R2.message(` ${fn.name}${automationLabel}`);
|
|
247639
|
-
}
|
|
247640
|
-
return {
|
|
247641
|
-
outroMessage: `${functions.length} function${functions.length !== 1 ? "s" : ""} on remote`
|
|
247642
|
-
};
|
|
247643
|
-
}
|
|
247644
|
-
function getListCommand(context) {
|
|
247645
|
-
return new Command("list").description("List all deployed functions").action(async () => {
|
|
247646
|
-
await runCommand(listFunctionsAction, { requireAuth: true }, context);
|
|
247647
|
-
});
|
|
247648
|
-
}
|
|
247649
|
-
|
|
247650
|
-
// src/cli/commands/functions/index.ts
|
|
247651
|
-
function getFunctionsCommand(context) {
|
|
247652
|
-
return new Command("functions").description("Manage backend functions").addCommand(getDeployCommand(context)).addCommand(getListCommand(context));
|
|
247596
|
+
}));
|
|
247653
247597
|
}
|
|
247654
247598
|
|
|
247655
247599
|
// src/cli/commands/project/create.ts
|
|
@@ -247887,7 +247831,7 @@ ${summaryLines.join(`
|
|
|
247887
247831
|
}
|
|
247888
247832
|
return { outroMessage: "App deployed successfully" };
|
|
247889
247833
|
}
|
|
247890
|
-
function
|
|
247834
|
+
function getDeployCommand(context) {
|
|
247891
247835
|
return new Command("deploy").description("Deploy all project resources (entities, functions, agents, connectors, and site)").option("-y, --yes", "Skip confirmation prompt").action(async (options) => {
|
|
247892
247836
|
await runCommand(() => deployAction({
|
|
247893
247837
|
...options,
|
|
@@ -248835,14 +248779,163 @@ function createFunctionRouter(manager, logger) {
|
|
|
248835
248779
|
return router;
|
|
248836
248780
|
}
|
|
248837
248781
|
|
|
248838
|
-
// src/cli/dev/dev-server/database.ts
|
|
248782
|
+
// src/cli/dev/dev-server/db/database.ts
|
|
248839
248783
|
var import_nedb = __toESM(require_nedb(), 1);
|
|
248840
248784
|
|
|
248785
|
+
// src/cli/dev/dev-server/db/validator.ts
|
|
248786
|
+
var fieldTypes = [
|
|
248787
|
+
"string",
|
|
248788
|
+
"integer",
|
|
248789
|
+
"number",
|
|
248790
|
+
"boolean",
|
|
248791
|
+
"array",
|
|
248792
|
+
"object"
|
|
248793
|
+
];
|
|
248794
|
+
|
|
248795
|
+
class Validator {
|
|
248796
|
+
filterFields(record2, entitySchema) {
|
|
248797
|
+
const filteredRecord = {};
|
|
248798
|
+
for (const [key2, value] of Object.entries(record2)) {
|
|
248799
|
+
if (entitySchema.properties[key2]) {
|
|
248800
|
+
filteredRecord[key2] = value;
|
|
248801
|
+
}
|
|
248802
|
+
}
|
|
248803
|
+
return filteredRecord;
|
|
248804
|
+
}
|
|
248805
|
+
applyDefaults(record2, entitySchema) {
|
|
248806
|
+
const result = {};
|
|
248807
|
+
for (const [key2, property] of Object.entries(entitySchema.properties)) {
|
|
248808
|
+
if (property.default !== undefined) {
|
|
248809
|
+
result[key2] = property.default;
|
|
248810
|
+
}
|
|
248811
|
+
}
|
|
248812
|
+
return {
|
|
248813
|
+
...result,
|
|
248814
|
+
...record2
|
|
248815
|
+
};
|
|
248816
|
+
}
|
|
248817
|
+
validate(record2, entitySchema, partial2 = false) {
|
|
248818
|
+
if (!partial2) {
|
|
248819
|
+
const requiredFieldsResponse = this.validateRequiredFields(record2, entitySchema);
|
|
248820
|
+
if (requiredFieldsResponse.hasError) {
|
|
248821
|
+
return requiredFieldsResponse;
|
|
248822
|
+
}
|
|
248823
|
+
}
|
|
248824
|
+
const fieldTypesResponse = this.validateFieldTypes(record2, entitySchema);
|
|
248825
|
+
if (fieldTypesResponse.hasError) {
|
|
248826
|
+
return fieldTypesResponse;
|
|
248827
|
+
}
|
|
248828
|
+
return {
|
|
248829
|
+
hasError: false
|
|
248830
|
+
};
|
|
248831
|
+
}
|
|
248832
|
+
createValidationError(message) {
|
|
248833
|
+
return {
|
|
248834
|
+
error_type: "ValidationError",
|
|
248835
|
+
message,
|
|
248836
|
+
request_id: null,
|
|
248837
|
+
traceback: ""
|
|
248838
|
+
};
|
|
248839
|
+
}
|
|
248840
|
+
validateFieldTypes(record2, entitySchema) {
|
|
248841
|
+
for (const [key2, value] of Object.entries(record2)) {
|
|
248842
|
+
const property = entitySchema.properties[key2];
|
|
248843
|
+
const result = this.validateValue(value, property, key2);
|
|
248844
|
+
if (result.hasError)
|
|
248845
|
+
return result;
|
|
248846
|
+
}
|
|
248847
|
+
return {
|
|
248848
|
+
hasError: false
|
|
248849
|
+
};
|
|
248850
|
+
}
|
|
248851
|
+
validateValue(value, property, fieldPath) {
|
|
248852
|
+
if (!property) {
|
|
248853
|
+
return { hasError: false };
|
|
248854
|
+
}
|
|
248855
|
+
const propertyType = property.type;
|
|
248856
|
+
if (!fieldTypes.includes(propertyType)) {
|
|
248857
|
+
return {
|
|
248858
|
+
hasError: true,
|
|
248859
|
+
error: this.createValidationError(`Error in field ${fieldPath}: Input should be a valid ${propertyType}`)
|
|
248860
|
+
};
|
|
248861
|
+
}
|
|
248862
|
+
switch (propertyType) {
|
|
248863
|
+
case "array":
|
|
248864
|
+
if (!Array.isArray(value)) {
|
|
248865
|
+
return {
|
|
248866
|
+
hasError: true,
|
|
248867
|
+
error: this.createValidationError(`Error in field ${fieldPath}: Input should be a valid array`)
|
|
248868
|
+
};
|
|
248869
|
+
}
|
|
248870
|
+
if (property.items) {
|
|
248871
|
+
for (let i5 = 0;i5 < value.length; i5++) {
|
|
248872
|
+
const itemResult = this.validateValue(value[i5], property.items, `${fieldPath}[${i5}]`);
|
|
248873
|
+
if (itemResult.hasError)
|
|
248874
|
+
return itemResult;
|
|
248875
|
+
}
|
|
248876
|
+
}
|
|
248877
|
+
break;
|
|
248878
|
+
case "object":
|
|
248879
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
248880
|
+
return {
|
|
248881
|
+
hasError: true,
|
|
248882
|
+
error: this.createValidationError(`Error in field ${fieldPath}: Input should be a valid object`)
|
|
248883
|
+
};
|
|
248884
|
+
}
|
|
248885
|
+
if (property.properties) {
|
|
248886
|
+
for (const [subKey, subValue] of Object.entries(value)) {
|
|
248887
|
+
if (property.properties[subKey]) {
|
|
248888
|
+
const subResult = this.validateValue(subValue, property.properties[subKey], `${fieldPath}.${subKey}`);
|
|
248889
|
+
if (subResult.hasError)
|
|
248890
|
+
return subResult;
|
|
248891
|
+
}
|
|
248892
|
+
}
|
|
248893
|
+
}
|
|
248894
|
+
break;
|
|
248895
|
+
case "integer":
|
|
248896
|
+
if (!Number.isInteger(value)) {
|
|
248897
|
+
return {
|
|
248898
|
+
hasError: true,
|
|
248899
|
+
error: this.createValidationError(`Error in field ${fieldPath}: Input should be a valid integer`)
|
|
248900
|
+
};
|
|
248901
|
+
}
|
|
248902
|
+
break;
|
|
248903
|
+
default:
|
|
248904
|
+
if (typeof value !== propertyType) {
|
|
248905
|
+
return {
|
|
248906
|
+
hasError: true,
|
|
248907
|
+
error: this.createValidationError(`Error in field ${fieldPath}: Input should be a valid ${propertyType}`)
|
|
248908
|
+
};
|
|
248909
|
+
}
|
|
248910
|
+
}
|
|
248911
|
+
return { hasError: false };
|
|
248912
|
+
}
|
|
248913
|
+
validateRequiredFields(record2, entitySchema) {
|
|
248914
|
+
if (entitySchema.required && entitySchema.required.length > 0) {
|
|
248915
|
+
for (const required2 of entitySchema.required) {
|
|
248916
|
+
if (record2[required2] == null) {
|
|
248917
|
+
return {
|
|
248918
|
+
hasError: true,
|
|
248919
|
+
error: this.createValidationError(`Error in field ${required2}: Field required`)
|
|
248920
|
+
};
|
|
248921
|
+
}
|
|
248922
|
+
}
|
|
248923
|
+
}
|
|
248924
|
+
return {
|
|
248925
|
+
hasError: false
|
|
248926
|
+
};
|
|
248927
|
+
}
|
|
248928
|
+
}
|
|
248929
|
+
|
|
248930
|
+
// src/cli/dev/dev-server/db/database.ts
|
|
248841
248931
|
class Database {
|
|
248842
248932
|
collections = new Map;
|
|
248933
|
+
schemas = new Map;
|
|
248934
|
+
validator = new Validator;
|
|
248843
248935
|
load(entities) {
|
|
248844
248936
|
for (const entity2 of entities) {
|
|
248845
248937
|
this.collections.set(entity2.name, new import_nedb.default);
|
|
248938
|
+
this.schemas.set(entity2.name, entity2);
|
|
248846
248939
|
}
|
|
248847
248940
|
}
|
|
248848
248941
|
getCollection(name2) {
|
|
@@ -248856,6 +248949,25 @@ class Database {
|
|
|
248856
248949
|
collection.remove({}, { multi: true });
|
|
248857
248950
|
}
|
|
248858
248951
|
this.collections.clear();
|
|
248952
|
+
this.schemas.clear();
|
|
248953
|
+
}
|
|
248954
|
+
validate(entityName, record2, partial2 = false) {
|
|
248955
|
+
const schema9 = this.schemas.get(entityName);
|
|
248956
|
+
if (!schema9) {
|
|
248957
|
+
throw new Error(`Entity "${entityName}" not found`);
|
|
248958
|
+
}
|
|
248959
|
+
return this.validator.validate(record2, schema9, partial2);
|
|
248960
|
+
}
|
|
248961
|
+
prepareRecord(entityName, record2, partial2 = false) {
|
|
248962
|
+
const schema9 = this.schemas.get(entityName);
|
|
248963
|
+
if (!schema9) {
|
|
248964
|
+
throw new Error(`Entity "${entityName}" not found`);
|
|
248965
|
+
}
|
|
248966
|
+
const filteredRecord = this.validator.filterFields(record2, schema9);
|
|
248967
|
+
if (partial2) {
|
|
248968
|
+
return filteredRecord;
|
|
248969
|
+
}
|
|
248970
|
+
return this.validator.applyDefaults(filteredRecord, schema9);
|
|
248859
248971
|
}
|
|
248860
248972
|
}
|
|
248861
248973
|
|
|
@@ -249047,8 +249159,14 @@ function createEntityRoutes(db2, logger, remoteProxy, broadcast) {
|
|
|
249047
249159
|
try {
|
|
249048
249160
|
const now = new Date().toISOString();
|
|
249049
249161
|
const { _id, ...body } = req.body;
|
|
249162
|
+
const filteredBody = db2.prepareRecord(entityName, body);
|
|
249163
|
+
const validation = db2.validate(entityName, filteredBody);
|
|
249164
|
+
if (validation.hasError) {
|
|
249165
|
+
res.status(422).json(validation.error);
|
|
249166
|
+
return;
|
|
249167
|
+
}
|
|
249050
249168
|
const record2 = {
|
|
249051
|
-
...
|
|
249169
|
+
...filteredBody,
|
|
249052
249170
|
id: nanoid3(),
|
|
249053
249171
|
created_date: now,
|
|
249054
249172
|
updated_date: now
|
|
@@ -249069,12 +249187,21 @@ function createEntityRoutes(db2, logger, remoteProxy, broadcast) {
|
|
|
249069
249187
|
}
|
|
249070
249188
|
try {
|
|
249071
249189
|
const now = new Date().toISOString();
|
|
249072
|
-
const records =
|
|
249073
|
-
|
|
249074
|
-
|
|
249075
|
-
|
|
249076
|
-
|
|
249077
|
-
|
|
249190
|
+
const records = [];
|
|
249191
|
+
for (const record2 of req.body) {
|
|
249192
|
+
const filteredRecord = db2.prepareRecord(entityName, record2);
|
|
249193
|
+
const validation = db2.validate(entityName, filteredRecord);
|
|
249194
|
+
if (validation.hasError) {
|
|
249195
|
+
res.status(422).json(validation.error);
|
|
249196
|
+
return;
|
|
249197
|
+
}
|
|
249198
|
+
records.push({
|
|
249199
|
+
...filteredRecord,
|
|
249200
|
+
id: nanoid3(),
|
|
249201
|
+
created_date: now,
|
|
249202
|
+
updated_date: now
|
|
249203
|
+
});
|
|
249204
|
+
}
|
|
249078
249205
|
const inserted = stripInternalFields(await collection.insertAsync(records));
|
|
249079
249206
|
emit(appId, entityName, "create", inserted);
|
|
249080
249207
|
res.status(201).json(inserted);
|
|
@@ -249087,8 +249214,14 @@ function createEntityRoutes(db2, logger, remoteProxy, broadcast) {
|
|
|
249087
249214
|
const { appId, entityName, id: id2 } = req.params;
|
|
249088
249215
|
const { id: _id, created_date: _created_date, ...body } = req.body;
|
|
249089
249216
|
try {
|
|
249217
|
+
const filteredBody = db2.prepareRecord(entityName, body, true);
|
|
249218
|
+
const validation = db2.validate(entityName, filteredBody, true);
|
|
249219
|
+
if (validation.hasError) {
|
|
249220
|
+
res.status(422).json(validation.error);
|
|
249221
|
+
return;
|
|
249222
|
+
}
|
|
249090
249223
|
const updateData = {
|
|
249091
|
-
...
|
|
249224
|
+
...filteredBody,
|
|
249092
249225
|
updated_date: new Date().toISOString()
|
|
249093
249226
|
};
|
|
249094
249227
|
const result = await collection.updateAsync({ id: id2 }, { $set: updateData }, { returnUpdatedDocs: true });
|
|
@@ -251179,13 +251312,13 @@ function createProgram(context) {
|
|
|
251179
251312
|
program2.addCommand(getLogoutCommand(context));
|
|
251180
251313
|
program2.addCommand(getCreateCommand(context));
|
|
251181
251314
|
program2.addCommand(getDashboardCommand(context));
|
|
251182
|
-
program2.addCommand(
|
|
251315
|
+
program2.addCommand(getDeployCommand(context));
|
|
251183
251316
|
program2.addCommand(getLinkCommand(context));
|
|
251184
251317
|
program2.addCommand(getEjectCommand(context));
|
|
251185
251318
|
program2.addCommand(getEntitiesPushCommand(context));
|
|
251186
251319
|
program2.addCommand(getAgentsCommand(context));
|
|
251187
251320
|
program2.addCommand(getConnectorsCommand(context));
|
|
251188
|
-
program2.addCommand(
|
|
251321
|
+
program2.addCommand(getFunctionsDeployCommand(context));
|
|
251189
251322
|
program2.addCommand(getSecretsCommand(context));
|
|
251190
251323
|
program2.addCommand(getSiteCommand(context));
|
|
251191
251324
|
program2.addCommand(getTypesCommand(context));
|
|
@@ -255431,4 +255564,4 @@ export {
|
|
|
255431
255564
|
CLIExitError
|
|
255432
255565
|
};
|
|
255433
255566
|
|
|
255434
|
-
//# debugId=
|
|
255567
|
+
//# debugId=40892139B6B5F92764756E2164756E21
|