@base44-preview/cli 0.0.44-pr.382.6bffbd1 → 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 CHANGED
@@ -16459,7 +16459,7 @@ var require_lodash = __commonJS((exports, module) => {
16459
16459
  }
16460
16460
  return mapped.length && mapped[0] === arrays[0] ? baseIntersection(mapped, undefined2, comparator) : [];
16461
16461
  });
16462
- function join11(array2, separator) {
16462
+ function join10(array2, separator) {
16463
16463
  return array2 == null ? "" : nativeJoin.call(array2, separator);
16464
16464
  }
16465
16465
  function last(array2) {
@@ -16481,7 +16481,7 @@ var require_lodash = __commonJS((exports, module) => {
16481
16481
  function nth(array2, n2) {
16482
16482
  return array2 && array2.length ? baseNth(array2, toInteger(n2)) : undefined2;
16483
16483
  }
16484
- var pull3 = baseRest(pullAll);
16484
+ var pull2 = baseRest(pullAll);
16485
16485
  function pullAll(array2, values2) {
16486
16486
  return array2 && array2.length && values2 && values2.length ? basePullAll(array2, values2) : array2;
16487
16487
  }
@@ -18246,7 +18246,7 @@ __p += '`;
18246
18246
  lodash.pickBy = pickBy;
18247
18247
  lodash.property = property;
18248
18248
  lodash.propertyOf = propertyOf;
18249
- lodash.pull = pull3;
18249
+ lodash.pull = pull2;
18250
18250
  lodash.pullAll = pullAll;
18251
18251
  lodash.pullAllBy = pullAllBy;
18252
18252
  lodash.pullAllWith = pullAllWith;
@@ -18391,7 +18391,7 @@ __p += '`;
18391
18391
  lodash.isUndefined = isUndefined;
18392
18392
  lodash.isWeakMap = isWeakMap;
18393
18393
  lodash.isWeakSet = isWeakSet;
18394
- lodash.join = join11;
18394
+ lodash.join = join10;
18395
18395
  lodash.kebabCase = kebabCase;
18396
18396
  lodash.last = last;
18397
18397
  lodash.lastIndexOf = lastIndexOf;
@@ -27503,7 +27503,7 @@ function cleanDoc(doc2) {
27503
27503
  return mapDoc(doc2, (currentDoc) => cleanDocFn(currentDoc));
27504
27504
  }
27505
27505
  function replaceEndOfLine(doc2, replacement = literalline) {
27506
- return mapDoc(doc2, (currentDoc) => typeof currentDoc === "string" ? join15(replacement, currentDoc.split(`
27506
+ return mapDoc(doc2, (currentDoc) => typeof currentDoc === "string" ? join13(replacement, currentDoc.split(`
27507
27507
  `)) : currentDoc);
27508
27508
  }
27509
27509
  function canBreakFn(doc2) {
@@ -27583,7 +27583,7 @@ function indentIfBreak(contents, options) {
27583
27583
  negate: options.negate
27584
27584
  };
27585
27585
  }
27586
- function join15(separator, docs) {
27586
+ function join13(separator, docs) {
27587
27587
  assertDoc(separator);
27588
27588
  assertDocArray(docs);
27589
27589
  const parts = [];
@@ -28294,7 +28294,7 @@ var init_doc = __esm(() => {
28294
28294
  MODE_FLAT = Symbol("MODE_FLAT");
28295
28295
  DOC_FILL_PRINTED_LENGTH = Symbol("DOC_FILL_PRINTED_LENGTH");
28296
28296
  builders = {
28297
- join: join15,
28297
+ join: join13,
28298
28298
  line,
28299
28299
  softline,
28300
28300
  hardline,
@@ -133208,7 +133208,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`;
133208
133208
  return mapDoc2(doc2, (currentDoc) => cleanDocFn2(currentDoc));
133209
133209
  }
133210
133210
  function replaceEndOfLine2(doc2, replacement = literalline2) {
133211
- return mapDoc2(doc2, (currentDoc) => typeof currentDoc === "string" ? join17(replacement, currentDoc.split(`
133211
+ return mapDoc2(doc2, (currentDoc) => typeof currentDoc === "string" ? join15(replacement, currentDoc.split(`
133212
133212
  `)) : currentDoc);
133213
133213
  }
133214
133214
  function canBreakFn2(doc2) {
@@ -133294,7 +133294,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`;
133294
133294
  negate: options8.negate
133295
133295
  };
133296
133296
  }
133297
- function join17(separator, docs) {
133297
+ function join15(separator, docs) {
133298
133298
  assertDoc2(separator);
133299
133299
  assertDocArray2(docs);
133300
133300
  const parts = [];
@@ -133959,7 +133959,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`;
133959
133959
  }
133960
133960
  }
133961
133961
  var builders2 = {
133962
- join: join17,
133962
+ join: join15,
133963
133963
  line: line3,
133964
133964
  softline: softline2,
133965
133965
  hardline: hardline4,
@@ -160399,10 +160399,10 @@ var require_view = __commonJS((exports, module) => {
160399
160399
  var debug = require_src4()("express:view");
160400
160400
  var path18 = __require("node:path");
160401
160401
  var fs28 = __require("node:fs");
160402
- var dirname12 = path18.dirname;
160402
+ var dirname11 = path18.dirname;
160403
160403
  var basename4 = path18.basename;
160404
160404
  var extname2 = path18.extname;
160405
- var join18 = path18.join;
160405
+ var join16 = path18.join;
160406
160406
  var resolve6 = path18.resolve;
160407
160407
  module.exports = View;
160408
160408
  function View(name2, options8) {
@@ -160438,7 +160438,7 @@ var require_view = __commonJS((exports, module) => {
160438
160438
  for (var i5 = 0;i5 < roots.length && !path19; i5++) {
160439
160439
  var root2 = roots[i5];
160440
160440
  var loc = resolve6(root2, name2);
160441
- var dir = dirname12(loc);
160441
+ var dir = dirname11(loc);
160442
160442
  var file2 = basename4(loc);
160443
160443
  path19 = this.resolve(dir, file2);
160444
160444
  }
@@ -160464,12 +160464,12 @@ var require_view = __commonJS((exports, module) => {
160464
160464
  };
160465
160465
  View.prototype.resolve = function resolve7(dir, file2) {
160466
160466
  var ext = this.ext;
160467
- var path19 = join18(dir, file2);
160467
+ var path19 = join16(dir, file2);
160468
160468
  var stat2 = tryStat(path19);
160469
160469
  if (stat2 && stat2.isFile()) {
160470
160470
  return path19;
160471
160471
  }
160472
- path19 = join18(dir, basename4(file2, ext), "index" + ext);
160472
+ path19 = join16(dir, basename4(file2, ext), "index" + ext);
160473
160473
  stat2 = tryStat(path19);
160474
160474
  if (stat2 && stat2.isFile()) {
160475
160475
  return path19;
@@ -164164,7 +164164,7 @@ var require_send = __commonJS((exports, module) => {
164164
164164
  var Stream2 = __require("stream");
164165
164165
  var util2 = __require("util");
164166
164166
  var extname2 = path18.extname;
164167
- var join18 = path18.join;
164167
+ var join16 = path18.join;
164168
164168
  var normalize = path18.normalize;
164169
164169
  var resolve6 = path18.resolve;
164170
164170
  var sep = path18.sep;
@@ -164336,7 +164336,7 @@ var require_send = __commonJS((exports, module) => {
164336
164336
  return res;
164337
164337
  }
164338
164338
  parts = path19.split(sep);
164339
- path19 = normalize(join18(root2, path19));
164339
+ path19 = normalize(join16(root2, path19));
164340
164340
  } else {
164341
164341
  if (UP_PATH_REGEXP.test(path19)) {
164342
164342
  debug('malicious path "%s"', path19);
@@ -164476,7 +164476,7 @@ var require_send = __commonJS((exports, module) => {
164476
164476
  return self2.onStatError(err);
164477
164477
  return self2.error(404);
164478
164478
  }
164479
- var p4 = join18(path19, self2._index[i5]);
164479
+ var p4 = join16(path19, self2._index[i5]);
164480
164480
  debug('stat "%s"', p4);
164481
164481
  fs28.stat(p4, function(err2, stat2) {
164482
164482
  if (err2)
@@ -211071,7 +211071,7 @@ var require_buffer_list = __commonJS((exports, module) => {
211071
211071
  }
211072
211072
  }, {
211073
211073
  key: "join",
211074
- value: function join18(s5) {
211074
+ value: function join16(s5) {
211075
211075
  if (this.length === 0)
211076
211076
  return "";
211077
211077
  var p4 = this.head;
@@ -214782,7 +214782,7 @@ var require_dist5 = __commonJS((exports, module) => {
214782
214782
  });
214783
214783
 
214784
214784
  // src/cli/index.ts
214785
- import { dirname as dirname16, join as join21 } from "node:path";
214785
+ import { dirname as dirname15, join as join19 } from "node:path";
214786
214786
  import { fileURLToPath as fileURLToPath6 } from "node:url";
214787
214787
 
214788
214788
  // ../../node_modules/commander/esm.mjs
@@ -214802,7 +214802,7 @@ var {
214802
214802
  } = import__.default;
214803
214803
 
214804
214804
  // src/cli/commands/agents/pull.ts
214805
- import { dirname as dirname7, join as join11 } from "node:path";
214805
+ import { dirname as dirname7, join as join10 } from "node:path";
214806
214806
 
214807
214807
  // ../../node_modules/@clack/core/dist/index.mjs
214808
214808
  var import_picocolors = __toESM(require_picocolors(), 1);
@@ -237298,7 +237298,7 @@ var generateGlobTasks = normalizeArguments(generateTasks);
237298
237298
  var generateGlobTasksSync = normalizeArgumentsSync(generateTasksSync);
237299
237299
 
237300
237300
  // src/core/project/config.ts
237301
- import { dirname as dirname5, join as join7 } from "node:path";
237301
+ import { dirname as dirname5, join as join6 } from "node:path";
237302
237302
 
237303
237303
  // src/core/resources/agent/schema.ts
237304
237304
  var EntityOperationSchema = exports_external.enum(["create", "update", "delete", "read"]);
@@ -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().optional(),
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) {
@@ -238434,66 +238404,6 @@ async function pushFunctions(functions) {
238434
238404
  const functionsWithCode = await Promise.all(functions.map(loadFunctionCode));
238435
238405
  return deployFunctions(functionsWithCode);
238436
238406
  }
238437
- // src/core/resources/function/pull.ts
238438
- import { join as join6 } from "node:path";
238439
- import { isDeepStrictEqual as isDeepStrictEqual3 } from "node:util";
238440
- async function writeFunctions(functionsDir, functions) {
238441
- const written = [];
238442
- const skipped = [];
238443
- for (const fn of functions) {
238444
- const functionDir = join6(functionsDir, fn.name);
238445
- const configPath = join6(functionDir, "function.jsonc");
238446
- if (await isFunctionUnchanged(functionDir, fn)) {
238447
- skipped.push(fn.name);
238448
- continue;
238449
- }
238450
- const config5 = {
238451
- name: fn.name,
238452
- entry: fn.entry
238453
- };
238454
- if (fn.automations.length > 0) {
238455
- config5.automations = fn.automations;
238456
- }
238457
- await writeJsonFile(configPath, config5);
238458
- for (const file2 of fn.files) {
238459
- await writeFile(join6(functionDir, file2.path), file2.content);
238460
- }
238461
- written.push(fn.name);
238462
- }
238463
- return { written, skipped };
238464
- }
238465
- async function isFunctionUnchanged(functionDir, fn) {
238466
- if (!await pathExists(functionDir)) {
238467
- return false;
238468
- }
238469
- const configPath = join6(functionDir, "function.jsonc");
238470
- try {
238471
- const localConfig = await readJsonFile(configPath);
238472
- if (localConfig.entry !== fn.entry) {
238473
- return false;
238474
- }
238475
- if (!isDeepStrictEqual3(localConfig.automations ?? [], fn.automations)) {
238476
- return false;
238477
- }
238478
- } catch {
238479
- return false;
238480
- }
238481
- for (const file2 of fn.files) {
238482
- const filePath = join6(functionDir, file2.path);
238483
- if (!await pathExists(filePath)) {
238484
- return false;
238485
- }
238486
- try {
238487
- const localContent = await readTextFile(filePath);
238488
- if (localContent !== file2.content) {
238489
- return false;
238490
- }
238491
- } catch {
238492
- return false;
238493
- }
238494
- }
238495
- return true;
238496
- }
238497
238407
  // src/core/resources/function/resource.ts
238498
238408
  var functionResource = {
238499
238409
  readAll: readAllFunctions,
@@ -238538,10 +238448,10 @@ async function readProjectConfig(projectRoot) {
238538
238448
  const project = result.data;
238539
238449
  const configDir = dirname5(configPath);
238540
238450
  const [entities, functions, agents, connectors] = await Promise.all([
238541
- entityResource.readAll(join7(configDir, project.entitiesDir)),
238542
- functionResource.readAll(join7(configDir, project.functionsDir)),
238543
- agentResource.readAll(join7(configDir, project.agentsDir)),
238544
- connectorResource.readAll(join7(configDir, project.connectorsDir))
238451
+ entityResource.readAll(join6(configDir, project.entitiesDir)),
238452
+ functionResource.readAll(join6(configDir, project.functionsDir)),
238453
+ agentResource.readAll(join6(configDir, project.agentsDir)),
238454
+ connectorResource.readAll(join6(configDir, project.connectorsDir))
238545
238455
  ]);
238546
238456
  return {
238547
238457
  project: { ...project, root, configPath },
@@ -238638,12 +238548,12 @@ async function readAppConfig(projectRoot) {
238638
238548
  // src/core/project/template.ts
238639
238549
  var import_ejs = __toESM(require_ejs(), 1);
238640
238550
  var import_front_matter = __toESM(require_front_matter(), 1);
238641
- import { dirname as dirname6, join as join9 } from "node:path";
238551
+ import { dirname as dirname6, join as join8 } from "node:path";
238642
238552
 
238643
238553
  // src/core/assets.ts
238644
238554
  import { cpSync, existsSync } from "node:fs";
238645
238555
  import { homedir as homedir2 } from "node:os";
238646
- import { join as join8 } from "node:path";
238556
+ import { join as join7 } from "node:path";
238647
238557
  // package.json
238648
238558
  var package_default = {
238649
238559
  name: "base44",
@@ -238736,15 +238646,15 @@ var package_default = {
238736
238646
  };
238737
238647
 
238738
238648
  // src/core/assets.ts
238739
- var ASSETS_DIR = join8(homedir2(), ".base44", "assets", package_default.version);
238649
+ var ASSETS_DIR = join7(homedir2(), ".base44", "assets", package_default.version);
238740
238650
  function getTemplatesDir() {
238741
- return join8(ASSETS_DIR, "templates");
238651
+ return join7(ASSETS_DIR, "templates");
238742
238652
  }
238743
238653
  function getTemplatesIndexPath() {
238744
- return join8(ASSETS_DIR, "templates", "templates.json");
238654
+ return join7(ASSETS_DIR, "templates", "templates.json");
238745
238655
  }
238746
238656
  function getDenoWrapperPath() {
238747
- return join8(ASSETS_DIR, "deno-runtime", "main.js");
238657
+ return join7(ASSETS_DIR, "deno-runtime", "main.js");
238748
238658
  }
238749
238659
  function ensureNpmAssets(sourceDir) {
238750
238660
  if (existsSync(ASSETS_DIR))
@@ -238765,23 +238675,23 @@ async function listTemplates() {
238765
238675
  return result.data.templates;
238766
238676
  }
238767
238677
  async function renderTemplate(template, destPath, data) {
238768
- const templateDir = join9(getTemplatesDir(), template.path);
238678
+ const templateDir = join8(getTemplatesDir(), template.path);
238769
238679
  const files = await globby("**/*", {
238770
238680
  cwd: templateDir,
238771
238681
  dot: true,
238772
238682
  onlyFiles: true
238773
238683
  });
238774
238684
  for (const file2 of files) {
238775
- const srcPath = join9(templateDir, file2);
238685
+ const srcPath = join8(templateDir, file2);
238776
238686
  try {
238777
238687
  if (file2.endsWith(".ejs")) {
238778
238688
  const rendered = await import_ejs.default.renderFile(srcPath, data);
238779
238689
  const { attributes, body } = import_front_matter.default(rendered);
238780
- const destFile = attributes.outputFileName ? join9(dirname6(file2), attributes.outputFileName) : file2.replace(/\.ejs$/, "");
238781
- const destFilePath = join9(destPath, destFile);
238690
+ const destFile = attributes.outputFileName ? join8(dirname6(file2), attributes.outputFileName) : file2.replace(/\.ejs$/, "");
238691
+ const destFilePath = join8(destPath, destFile);
238782
238692
  await writeFile(destFilePath, body);
238783
238693
  } else {
238784
- const destFilePath = join9(destPath, file2);
238694
+ const destFilePath = join8(destPath, file2);
238785
238695
  await copyFile(srcPath, destFilePath);
238786
238696
  }
238787
238697
  } catch (error48) {
@@ -238880,7 +238790,7 @@ async function getSiteFilePaths(outputDir) {
238880
238790
  // src/core/site/deploy.ts
238881
238791
  import { randomUUID } from "node:crypto";
238882
238792
  import { tmpdir } from "node:os";
238883
- import { join as join10 } from "node:path";
238793
+ import { join as join9 } from "node:path";
238884
238794
  async function deploySite(siteOutputDir) {
238885
238795
  if (!await pathExists(siteOutputDir)) {
238886
238796
  throw new InvalidInputError(`Output directory does not exist: ${siteOutputDir}. Make sure to build your project first.`, {
@@ -238897,7 +238807,7 @@ async function deploySite(siteOutputDir) {
238897
238807
  ]
238898
238808
  });
238899
238809
  }
238900
- const archivePath = join10(tmpdir(), `base44-site-${randomUUID()}.tar.gz`);
238810
+ const archivePath = join9(tmpdir(), `base44-site-${randomUUID()}.tar.gz`);
238901
238811
  try {
238902
238812
  await createArchive(siteOutputDir, archivePath);
238903
238813
  return await uploadSite(archivePath);
@@ -246653,7 +246563,7 @@ function formatYaml(data, options = {}) {
246653
246563
  async function pullAgentsAction() {
246654
246564
  const { project: project2 } = await readProjectConfig();
246655
246565
  const configDir = dirname7(project2.configPath);
246656
- const agentsDir = join11(configDir, project2.agentsDir);
246566
+ const agentsDir = join10(configDir, project2.agentsDir);
246657
246567
  const remoteAgents = await runTask("Fetching agents from Base44", async () => {
246658
246568
  return await fetchAgents();
246659
246569
  }, {
@@ -246775,11 +246685,11 @@ function getConnectorsListAvailableCommand(context) {
246775
246685
  }
246776
246686
 
246777
246687
  // src/cli/commands/connectors/pull.ts
246778
- import { dirname as dirname8, join as join12 } from "node:path";
246688
+ import { dirname as dirname8, join as join11 } from "node:path";
246779
246689
  async function pullConnectorsAction() {
246780
246690
  const { project: project2 } = await readProjectConfig();
246781
246691
  const configDir = dirname8(project2.configPath);
246782
- const connectorsDir = join12(configDir, project2.connectorsDir);
246692
+ const connectorsDir = join11(configDir, project2.connectorsDir);
246783
246693
  const remoteConnectors = await runTask("Fetching connectors from Base44", async () => {
246784
246694
  return await pullAllConnectors();
246785
246695
  }, {
@@ -247680,84 +247590,14 @@ async function deployFunctionsAction() {
247680
247590
  }
247681
247591
  return { outroMessage: "Functions deployed to Base44" };
247682
247592
  }
247683
- function getDeployCommand(context) {
247684
- 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 () => {
247685
247595
  await runCommand(deployFunctionsAction, { requireAuth: true }, context);
247686
- });
247687
- }
247688
-
247689
- // src/cli/commands/functions/list.ts
247690
- async function listFunctionsAction() {
247691
- const { functions } = await runTask("Fetching functions...", async () => listDeployedFunctions());
247692
- if (functions.length === 0) {
247693
- return { outroMessage: "No functions on remote" };
247694
- }
247695
- for (const fn of functions) {
247696
- const automationCount = fn.automations.length;
247697
- const automationLabel = automationCount > 0 ? theme.styles.dim(` (${automationCount} automation${automationCount > 1 ? "s" : ""})`) : "";
247698
- R2.message(` ${fn.name}${automationLabel}`);
247699
- }
247700
- return {
247701
- outroMessage: `${functions.length} function${functions.length !== 1 ? "s" : ""} on remote`
247702
- };
247703
- }
247704
- function getListCommand(context) {
247705
- return new Command("list").description("List all deployed functions").action(async () => {
247706
- await runCommand(listFunctionsAction, { requireAuth: true }, context);
247707
- });
247708
- }
247709
-
247710
- // src/cli/commands/functions/pull.ts
247711
- import { dirname as dirname9, join as join13 } from "node:path";
247712
- async function pullFunctionsAction(name2) {
247713
- const { project: project2 } = await readProjectConfig();
247714
- const configDir = dirname9(project2.configPath);
247715
- const functionsDir = join13(configDir, project2.functionsDir);
247716
- const remoteFunctions = await runTask("Fetching functions from Base44", async () => {
247717
- const { functions } = await listDeployedFunctions();
247718
- return functions;
247719
- }, {
247720
- successMessage: "Functions fetched successfully",
247721
- errorMessage: "Failed to fetch functions"
247722
- });
247723
- const toPull = name2 ? remoteFunctions.filter((f) => f.name === name2) : remoteFunctions;
247724
- if (name2 && toPull.length === 0) {
247725
- return {
247726
- outroMessage: `Function "${name2}" not found on remote`
247727
- };
247728
- }
247729
- if (toPull.length === 0) {
247730
- return { outroMessage: "No functions found on remote" };
247731
- }
247732
- const { written, skipped } = await runTask("Writing function files", async () => {
247733
- return await writeFunctions(functionsDir, toPull);
247734
- }, {
247735
- successMessage: "Function files written successfully",
247736
- errorMessage: "Failed to write function files"
247737
- });
247738
- for (const name3 of written) {
247739
- R2.success(`${name3.padEnd(25)} written`);
247740
- }
247741
- for (const name3 of skipped) {
247742
- R2.info(`${name3.padEnd(25)} unchanged`);
247743
- }
247744
- return {
247745
- outroMessage: `Pulled ${toPull.length} function${toPull.length !== 1 ? "s" : ""} to ${functionsDir}`
247746
- };
247747
- }
247748
- function getPullCommand(context) {
247749
- return new Command("pull").description("Pull deployed functions from Base44").argument("[name]", "Pull a single function by name").action(async (name2) => {
247750
- await runCommand(() => pullFunctionsAction(name2), { requireAuth: true }, context);
247751
- });
247752
- }
247753
-
247754
- // src/cli/commands/functions/index.ts
247755
- function getFunctionsCommand(context) {
247756
- return new Command("functions").description("Manage backend functions").addCommand(getDeployCommand(context)).addCommand(getListCommand(context)).addCommand(getPullCommand(context));
247596
+ }));
247757
247597
  }
247758
247598
 
247759
247599
  // src/cli/commands/project/create.ts
247760
- import { basename as basename3, join as join14, resolve as resolve2 } from "node:path";
247600
+ import { basename as basename3, join as join12, resolve as resolve2 } from "node:path";
247761
247601
  var import_kebabCase = __toESM(require_kebabCase(), 1);
247762
247602
  var DEFAULT_TEMPLATE_ID = "backend-only";
247763
247603
  async function getTemplateById(templateId) {
@@ -247893,7 +247733,7 @@ async function executeCreate({
247893
247733
  updateMessage("Building project...");
247894
247734
  await execa({ cwd: resolvedPath, shell: true })`${buildCommand}`;
247895
247735
  updateMessage("Deploying site...");
247896
- return await deploySite(join14(resolvedPath, outputDirectory));
247736
+ return await deploySite(join12(resolvedPath, outputDirectory));
247897
247737
  }, {
247898
247738
  successMessage: theme.colors.base44Orange("Site deployed successfully"),
247899
247739
  errorMessage: "Failed to deploy site"
@@ -247991,7 +247831,7 @@ ${summaryLines.join(`
247991
247831
  }
247992
247832
  return { outroMessage: "App deployed successfully" };
247993
247833
  }
247994
- function getDeployCommand2(context) {
247834
+ function getDeployCommand(context) {
247995
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) => {
247996
247836
  await runCommand(() => deployAction({
247997
247837
  ...options,
@@ -248536,10 +248376,10 @@ function toPascalCase(name2) {
248536
248376
  return name2.split(/[-_\s]+/).map((w8) => w8.charAt(0).toUpperCase() + w8.slice(1)).join("");
248537
248377
  }
248538
248378
  // src/core/types/update-project.ts
248539
- import { join as join17 } from "node:path";
248379
+ import { join as join15 } from "node:path";
248540
248380
  var TYPES_INCLUDE_PATH = `${PROJECT_SUBDIR}/${TYPES_OUTPUT_SUBDIR}/*.d.ts`;
248541
248381
  async function updateProjectConfig(projectRoot) {
248542
- const tsconfigPath = join17(projectRoot, "tsconfig.json");
248382
+ const tsconfigPath = join15(projectRoot, "tsconfig.json");
248543
248383
  if (!await pathExists(tsconfigPath)) {
248544
248384
  return false;
248545
248385
  }
@@ -248582,7 +248422,7 @@ function getTypesCommand(context) {
248582
248422
  }
248583
248423
 
248584
248424
  // src/cli/dev/dev-server/main.ts
248585
- import { dirname as dirname14, join as join20 } from "node:path";
248425
+ import { dirname as dirname13, join as join18 } from "node:path";
248586
248426
  var import_cors = __toESM(require_lib4(), 1);
248587
248427
  var import_express4 = __toESM(require_express(), 1);
248588
248428
 
@@ -248939,14 +248779,163 @@ function createFunctionRouter(manager, logger) {
248939
248779
  return router;
248940
248780
  }
248941
248781
 
248942
- // src/cli/dev/dev-server/database.ts
248782
+ // src/cli/dev/dev-server/db/database.ts
248943
248783
  var import_nedb = __toESM(require_nedb(), 1);
248944
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
248945
248931
  class Database {
248946
248932
  collections = new Map;
248933
+ schemas = new Map;
248934
+ validator = new Validator;
248947
248935
  load(entities) {
248948
248936
  for (const entity2 of entities) {
248949
248937
  this.collections.set(entity2.name, new import_nedb.default);
248938
+ this.schemas.set(entity2.name, entity2);
248950
248939
  }
248951
248940
  }
248952
248941
  getCollection(name2) {
@@ -248960,6 +248949,25 @@ class Database {
248960
248949
  collection.remove({}, { multi: true });
248961
248950
  }
248962
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);
248963
248971
  }
248964
248972
  }
248965
248973
 
@@ -249151,8 +249159,14 @@ function createEntityRoutes(db2, logger, remoteProxy, broadcast) {
249151
249159
  try {
249152
249160
  const now = new Date().toISOString();
249153
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
+ }
249154
249168
  const record2 = {
249155
- ...body,
249169
+ ...filteredBody,
249156
249170
  id: nanoid3(),
249157
249171
  created_date: now,
249158
249172
  updated_date: now
@@ -249173,12 +249187,21 @@ function createEntityRoutes(db2, logger, remoteProxy, broadcast) {
249173
249187
  }
249174
249188
  try {
249175
249189
  const now = new Date().toISOString();
249176
- const records = req.body.map((item) => ({
249177
- ...item,
249178
- id: nanoid3(),
249179
- created_date: now,
249180
- updated_date: now
249181
- }));
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
+ }
249182
249205
  const inserted = stripInternalFields(await collection.insertAsync(records));
249183
249206
  emit(appId, entityName, "create", inserted);
249184
249207
  res.status(201).json(inserted);
@@ -249191,8 +249214,14 @@ function createEntityRoutes(db2, logger, remoteProxy, broadcast) {
249191
249214
  const { appId, entityName, id: id2 } = req.params;
249192
249215
  const { id: _id, created_date: _created_date, ...body } = req.body;
249193
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
+ }
249194
249223
  const updateData = {
249195
- ...body,
249224
+ ...filteredBody,
249196
249225
  updated_date: new Date().toISOString()
249197
249226
  };
249198
249227
  const result = await collection.updateAsync({ id: id2 }, { $set: updateData }, { returnUpdatedDocs: true });
@@ -250062,9 +250091,9 @@ class NodeFsHandler {
250062
250091
  if (this.fsw.closed) {
250063
250092
  return;
250064
250093
  }
250065
- const dirname13 = sp2.dirname(file2);
250094
+ const dirname12 = sp2.dirname(file2);
250066
250095
  const basename5 = sp2.basename(file2);
250067
- const parent = this.fsw._getWatchedDir(dirname13);
250096
+ const parent = this.fsw._getWatchedDir(dirname12);
250068
250097
  let prevStats = stats;
250069
250098
  if (parent.has(basename5))
250070
250099
  return;
@@ -250091,7 +250120,7 @@ class NodeFsHandler {
250091
250120
  prevStats = newStats2;
250092
250121
  }
250093
250122
  } catch (error48) {
250094
- this.fsw._remove(dirname13, basename5);
250123
+ this.fsw._remove(dirname12, basename5);
250095
250124
  }
250096
250125
  } else if (parent.has(basename5)) {
250097
250126
  const at13 = newStats.atimeMs;
@@ -251112,8 +251141,8 @@ async function createDevServer(options8) {
251112
251141
  broadcastEntityEvent(io6, appId, entityName, event);
251113
251142
  };
251114
251143
  const base44ConfigWatcher = new WatchBase44({
251115
- functions: join20(dirname14(project2.configPath), project2.functionsDir),
251116
- entities: join20(dirname14(project2.configPath), project2.entitiesDir)
251144
+ functions: join18(dirname13(project2.configPath), project2.functionsDir),
251145
+ entities: join18(dirname13(project2.configPath), project2.entitiesDir)
251117
251146
  }, devLogger);
251118
251147
  base44ConfigWatcher.on("change", async (name2) => {
251119
251148
  try {
@@ -251283,13 +251312,13 @@ function createProgram(context) {
251283
251312
  program2.addCommand(getLogoutCommand(context));
251284
251313
  program2.addCommand(getCreateCommand(context));
251285
251314
  program2.addCommand(getDashboardCommand(context));
251286
- program2.addCommand(getDeployCommand2(context));
251315
+ program2.addCommand(getDeployCommand(context));
251287
251316
  program2.addCommand(getLinkCommand(context));
251288
251317
  program2.addCommand(getEjectCommand(context));
251289
251318
  program2.addCommand(getEntitiesPushCommand(context));
251290
251319
  program2.addCommand(getAgentsCommand(context));
251291
251320
  program2.addCommand(getConnectorsCommand(context));
251292
- program2.addCommand(getFunctionsCommand(context));
251321
+ program2.addCommand(getFunctionsDeployCommand(context));
251293
251322
  program2.addCommand(getSecretsCommand(context));
251294
251323
  program2.addCommand(getSiteCommand(context));
251295
251324
  program2.addCommand(getTypesCommand(context));
@@ -251303,7 +251332,7 @@ var import_detect_agent = __toESM(require_dist5(), 1);
251303
251332
  import { release, type } from "node:os";
251304
251333
 
251305
251334
  // ../../node_modules/posthog-node/dist/extensions/error-tracking/modifiers/module.node.mjs
251306
- import { dirname as dirname15, posix, sep } from "path";
251335
+ import { dirname as dirname14, posix, sep } from "path";
251307
251336
  function createModulerModifier() {
251308
251337
  const getModuleFromFileName = createGetModuleFromFilename();
251309
251338
  return async (frames) => {
@@ -251312,7 +251341,7 @@ function createModulerModifier() {
251312
251341
  return frames;
251313
251342
  };
251314
251343
  }
251315
- function createGetModuleFromFilename(basePath = process.argv[1] ? dirname15(process.argv[1]) : process.cwd(), isWindows5 = sep === "\\") {
251344
+ function createGetModuleFromFilename(basePath = process.argv[1] ? dirname14(process.argv[1]) : process.cwd(), isWindows5 = sep === "\\") {
251316
251345
  const normalizedBase = isWindows5 ? normalizeWindowsPath2(basePath) : basePath;
251317
251346
  return (filename) => {
251318
251347
  if (!filename)
@@ -255501,9 +255530,9 @@ function addCommandInfoToErrorReporter(program2, errorReporter) {
255501
255530
  });
255502
255531
  }
255503
255532
  // src/cli/index.ts
255504
- var __dirname4 = dirname16(fileURLToPath6(import.meta.url));
255533
+ var __dirname4 = dirname15(fileURLToPath6(import.meta.url));
255505
255534
  async function runCLI() {
255506
- ensureNpmAssets(join21(__dirname4, "../assets"));
255535
+ ensureNpmAssets(join19(__dirname4, "../assets"));
255507
255536
  const errorReporter = new ErrorReporter;
255508
255537
  errorReporter.registerProcessErrorHandlers();
255509
255538
  const isNonInteractive = !process.stdin.isTTY || !process.stdout.isTTY;
@@ -255535,4 +255564,4 @@ export {
255535
255564
  CLIExitError
255536
255565
  };
255537
255566
 
255538
- //# debugId=177D5D3CB71DE0D564756E2164756E21
255567
+ //# debugId=40892139B6B5F92764756E2164756E21