@base44-preview/cli 0.0.43-pr.395.eec7338 → 0.0.44-pr.380.71fe077

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
@@ -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().optional(),
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,6 +238236,22 @@ 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
+ });
238239
238255
  var LogLevelSchema = exports_external.enum(["info", "warning", "error", "debug"]);
238240
238256
  var FunctionLogEntrySchema = exports_external.object({
238241
238257
  time: exports_external.string(),
@@ -238309,6 +238325,20 @@ async function fetchFunctionLogs(functionName, filters = {}) {
238309
238325
  }
238310
238326
  return result.data;
238311
238327
  }
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
+ }
238312
238342
  // src/core/resources/function/config.ts
238313
238343
  import { basename as basename2, dirname as dirname3, join as join5, relative } from "node:path";
238314
238344
  async function readFunctionConfig(configPath) {
@@ -238557,7 +238587,7 @@ import { join as join7 } from "node:path";
238557
238587
  // package.json
238558
238588
  var package_default = {
238559
238589
  name: "base44",
238560
- version: "0.0.43",
238590
+ version: "0.0.44",
238561
238591
  description: "Base44 CLI - Unified interface for managing Base44 applications",
238562
238592
  type: "module",
238563
238593
  bin: {
@@ -247590,10 +247620,36 @@ async function deployFunctionsAction() {
247590
247620
  }
247591
247621
  return { outroMessage: "Functions deployed to Base44" };
247592
247622
  }
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 () => {
247623
+ function getDeployCommand(context) {
247624
+ return new Command("deploy").description("Deploy local functions to Base44").action(async () => {
247595
247625
  await runCommand(deployFunctionsAction, { requireAuth: true }, context);
247596
- }));
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));
247597
247653
  }
247598
247654
 
247599
247655
  // src/cli/commands/project/create.ts
@@ -247831,7 +247887,7 @@ ${summaryLines.join(`
247831
247887
  }
247832
247888
  return { outroMessage: "App deployed successfully" };
247833
247889
  }
247834
- function getDeployCommand(context) {
247890
+ function getDeployCommand2(context) {
247835
247891
  return new Command("deploy").description("Deploy all project resources (entities, functions, agents, connectors, and site)").option("-y, --yes", "Skip confirmation prompt").action(async (options) => {
247836
247892
  await runCommand(() => deployAction({
247837
247893
  ...options,
@@ -248779,130 +248835,14 @@ function createFunctionRouter(manager, logger) {
248779
248835
  return router;
248780
248836
  }
248781
248837
 
248782
- // src/cli/dev/dev-server/db/database.ts
248838
+ // src/cli/dev/dev-server/database.ts
248783
248839
  var import_nedb = __toESM(require_nedb(), 1);
248784
248840
 
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 propertyType = property?.type;
248844
- if (!fieldTypes.includes(propertyType)) {
248845
- return {
248846
- hasError: true,
248847
- error: this.createValidationError(`Error in field ${key2}: Input should be a valid ${propertyType}`)
248848
- };
248849
- }
248850
- switch (propertyType) {
248851
- case "array":
248852
- if (!Array.isArray(value)) {
248853
- return {
248854
- hasError: true,
248855
- error: this.createValidationError(`Error in field ${key2}: Input should be a valid array`)
248856
- };
248857
- }
248858
- break;
248859
- case "integer":
248860
- if (!Number.isInteger(value)) {
248861
- return {
248862
- hasError: true,
248863
- error: this.createValidationError(`Error in field ${key2}: Input should be a valid integer`)
248864
- };
248865
- }
248866
- break;
248867
- default:
248868
- if (typeof value !== propertyType) {
248869
- return {
248870
- hasError: true,
248871
- error: this.createValidationError(`Error in field ${key2}: Input should be a valid ${propertyType}`)
248872
- };
248873
- }
248874
- }
248875
- }
248876
- return {
248877
- hasError: false
248878
- };
248879
- }
248880
- validateRequiredFields(record2, entitySchema) {
248881
- if (entitySchema.required && entitySchema.required.length > 0) {
248882
- for (const required2 of entitySchema.required) {
248883
- if (record2[required2] == null) {
248884
- return {
248885
- hasError: true,
248886
- error: this.createValidationError(`Error in field ${required2}: Field required`)
248887
- };
248888
- }
248889
- }
248890
- }
248891
- return {
248892
- hasError: false
248893
- };
248894
- }
248895
- }
248896
-
248897
- // src/cli/dev/dev-server/db/database.ts
248898
248841
  class Database {
248899
248842
  collections = new Map;
248900
- schemas = new Map;
248901
- validator = new Validator;
248902
248843
  load(entities) {
248903
248844
  for (const entity2 of entities) {
248904
248845
  this.collections.set(entity2.name, new import_nedb.default);
248905
- this.schemas.set(entity2.name, entity2);
248906
248846
  }
248907
248847
  }
248908
248848
  getCollection(name2) {
@@ -248916,25 +248856,6 @@ class Database {
248916
248856
  collection.remove({}, { multi: true });
248917
248857
  }
248918
248858
  this.collections.clear();
248919
- this.schemas.clear();
248920
- }
248921
- validate(entityName, record2, partial2 = false) {
248922
- const schema9 = this.schemas.get(entityName);
248923
- if (!schema9) {
248924
- throw new Error(`Entity "${entityName}" not found`);
248925
- }
248926
- return this.validator.validate(record2, schema9, partial2);
248927
- }
248928
- prepareRecord(entityName, record2, partial2 = false) {
248929
- const schema9 = this.schemas.get(entityName);
248930
- if (!schema9) {
248931
- throw new Error(`Entity "${entityName}" not found`);
248932
- }
248933
- const filteredRecord = this.validator.filterFields(record2, schema9);
248934
- if (partial2) {
248935
- return filteredRecord;
248936
- }
248937
- return this.validator.applyDefaults(filteredRecord, schema9);
248938
248859
  }
248939
248860
  }
248940
248861
 
@@ -249126,14 +249047,8 @@ function createEntityRoutes(db2, logger, remoteProxy, broadcast) {
249126
249047
  try {
249127
249048
  const now = new Date().toISOString();
249128
249049
  const { _id, ...body } = req.body;
249129
- const filteredBody = db2.prepareRecord(entityName, body);
249130
- const validation = db2.validate(entityName, filteredBody);
249131
- if (validation.hasError) {
249132
- res.status(422).json(validation.error);
249133
- return;
249134
- }
249135
249050
  const record2 = {
249136
- ...filteredBody,
249051
+ ...body,
249137
249052
  id: nanoid3(),
249138
249053
  created_date: now,
249139
249054
  updated_date: now
@@ -249154,21 +249069,12 @@ function createEntityRoutes(db2, logger, remoteProxy, broadcast) {
249154
249069
  }
249155
249070
  try {
249156
249071
  const now = new Date().toISOString();
249157
- const records = [];
249158
- for (const record2 of req.body) {
249159
- const filteredRecord = db2.prepareRecord(entityName, record2);
249160
- const validation = db2.validate(entityName, filteredRecord);
249161
- if (validation.hasError) {
249162
- res.status(422).json(validation.error);
249163
- return;
249164
- }
249165
- records.push({
249166
- ...filteredRecord,
249167
- id: nanoid3(),
249168
- created_date: now,
249169
- updated_date: now
249170
- });
249171
- }
249072
+ const records = req.body.map((item) => ({
249073
+ ...item,
249074
+ id: nanoid3(),
249075
+ created_date: now,
249076
+ updated_date: now
249077
+ }));
249172
249078
  const inserted = stripInternalFields(await collection.insertAsync(records));
249173
249079
  emit(appId, entityName, "create", inserted);
249174
249080
  res.status(201).json(inserted);
@@ -249181,14 +249087,8 @@ function createEntityRoutes(db2, logger, remoteProxy, broadcast) {
249181
249087
  const { appId, entityName, id: id2 } = req.params;
249182
249088
  const { id: _id, created_date: _created_date, ...body } = req.body;
249183
249089
  try {
249184
- const filteredBody = db2.prepareRecord(entityName, body, true);
249185
- const validation = db2.validate(entityName, filteredBody, true);
249186
- if (validation.hasError) {
249187
- res.status(422).json(validation.error);
249188
- return;
249189
- }
249190
249090
  const updateData = {
249191
- ...filteredBody,
249091
+ ...body,
249192
249092
  updated_date: new Date().toISOString()
249193
249093
  };
249194
249094
  const result = await collection.updateAsync({ id: id2 }, { $set: updateData }, { returnUpdatedDocs: true });
@@ -251279,13 +251179,13 @@ function createProgram(context) {
251279
251179
  program2.addCommand(getLogoutCommand(context));
251280
251180
  program2.addCommand(getCreateCommand(context));
251281
251181
  program2.addCommand(getDashboardCommand(context));
251282
- program2.addCommand(getDeployCommand(context));
251182
+ program2.addCommand(getDeployCommand2(context));
251283
251183
  program2.addCommand(getLinkCommand(context));
251284
251184
  program2.addCommand(getEjectCommand(context));
251285
251185
  program2.addCommand(getEntitiesPushCommand(context));
251286
251186
  program2.addCommand(getAgentsCommand(context));
251287
251187
  program2.addCommand(getConnectorsCommand(context));
251288
- program2.addCommand(getFunctionsDeployCommand(context));
251188
+ program2.addCommand(getFunctionsCommand(context));
251289
251189
  program2.addCommand(getSecretsCommand(context));
251290
251190
  program2.addCommand(getSiteCommand(context));
251291
251191
  program2.addCommand(getTypesCommand(context));
@@ -255531,4 +255431,4 @@ export {
255531
255431
  CLIExitError
255532
255432
  };
255533
255433
 
255534
- //# debugId=E1E29CEB4EDF231E64756E2164756E21
255434
+ //# debugId=FD4A53B035AEBB5D64756E2164756E21