@base44-preview/cli 0.0.43-pr.395.eec7338 → 0.0.44-pr.382.6bffbd1

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 join10(array2, separator) {
16462
+ function join11(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 pull2 = baseRest(pullAll);
16484
+ var pull3 = 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 = pull2;
18249
+ lodash.pull = pull3;
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 = join10;
18394
+ lodash.join = join11;
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" ? join13(replacement, currentDoc.split(`
27506
+ return mapDoc(doc2, (currentDoc) => typeof currentDoc === "string" ? join15(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 join13(separator, docs) {
27586
+ function join15(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: join13,
28297
+ join: join15,
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" ? join15(replacement, currentDoc.split(`
133211
+ return mapDoc2(doc2, (currentDoc) => typeof currentDoc === "string" ? join17(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 join15(separator, docs) {
133297
+ function join17(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: join15,
133962
+ join: join17,
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 dirname11 = path18.dirname;
160402
+ var dirname12 = path18.dirname;
160403
160403
  var basename4 = path18.basename;
160404
160404
  var extname2 = path18.extname;
160405
- var join16 = path18.join;
160405
+ var join18 = 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 = dirname11(loc);
160441
+ var dir = dirname12(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 = join16(dir, file2);
160467
+ var path19 = join18(dir, file2);
160468
160468
  var stat2 = tryStat(path19);
160469
160469
  if (stat2 && stat2.isFile()) {
160470
160470
  return path19;
160471
160471
  }
160472
- path19 = join16(dir, basename4(file2, ext), "index" + ext);
160472
+ path19 = join18(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 join16 = path18.join;
164167
+ var join18 = 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(join16(root2, path19));
164339
+ path19 = normalize(join18(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 = join16(path19, self2._index[i5]);
164479
+ var p4 = join18(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 join16(s5) {
211074
+ value: function join18(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 dirname15, join as join19 } from "node:path";
214785
+ import { dirname as dirname16, join as join21 } 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 join10 } from "node:path";
214805
+ import { dirname as dirname7, join as join11 } 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 join6 } from "node:path";
237301
+ import { dirname as dirname5, join as join7 } 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(),
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) {
@@ -238404,6 +238434,66 @@ async function pushFunctions(functions) {
238404
238434
  const functionsWithCode = await Promise.all(functions.map(loadFunctionCode));
238405
238435
  return deployFunctions(functionsWithCode);
238406
238436
  }
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
+ }
238407
238497
  // src/core/resources/function/resource.ts
238408
238498
  var functionResource = {
238409
238499
  readAll: readAllFunctions,
@@ -238448,10 +238538,10 @@ async function readProjectConfig(projectRoot) {
238448
238538
  const project = result.data;
238449
238539
  const configDir = dirname5(configPath);
238450
238540
  const [entities, functions, agents, connectors] = await Promise.all([
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))
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))
238455
238545
  ]);
238456
238546
  return {
238457
238547
  project: { ...project, root, configPath },
@@ -238548,16 +238638,16 @@ async function readAppConfig(projectRoot) {
238548
238638
  // src/core/project/template.ts
238549
238639
  var import_ejs = __toESM(require_ejs(), 1);
238550
238640
  var import_front_matter = __toESM(require_front_matter(), 1);
238551
- import { dirname as dirname6, join as join8 } from "node:path";
238641
+ import { dirname as dirname6, join as join9 } from "node:path";
238552
238642
 
238553
238643
  // src/core/assets.ts
238554
238644
  import { cpSync, existsSync } from "node:fs";
238555
238645
  import { homedir as homedir2 } from "node:os";
238556
- import { join as join7 } from "node:path";
238646
+ import { join as join8 } from "node:path";
238557
238647
  // package.json
238558
238648
  var package_default = {
238559
238649
  name: "base44",
238560
- version: "0.0.43",
238650
+ version: "0.0.44",
238561
238651
  description: "Base44 CLI - Unified interface for managing Base44 applications",
238562
238652
  type: "module",
238563
238653
  bin: {
@@ -238646,15 +238736,15 @@ var package_default = {
238646
238736
  };
238647
238737
 
238648
238738
  // src/core/assets.ts
238649
- var ASSETS_DIR = join7(homedir2(), ".base44", "assets", package_default.version);
238739
+ var ASSETS_DIR = join8(homedir2(), ".base44", "assets", package_default.version);
238650
238740
  function getTemplatesDir() {
238651
- return join7(ASSETS_DIR, "templates");
238741
+ return join8(ASSETS_DIR, "templates");
238652
238742
  }
238653
238743
  function getTemplatesIndexPath() {
238654
- return join7(ASSETS_DIR, "templates", "templates.json");
238744
+ return join8(ASSETS_DIR, "templates", "templates.json");
238655
238745
  }
238656
238746
  function getDenoWrapperPath() {
238657
- return join7(ASSETS_DIR, "deno-runtime", "main.js");
238747
+ return join8(ASSETS_DIR, "deno-runtime", "main.js");
238658
238748
  }
238659
238749
  function ensureNpmAssets(sourceDir) {
238660
238750
  if (existsSync(ASSETS_DIR))
@@ -238675,23 +238765,23 @@ async function listTemplates() {
238675
238765
  return result.data.templates;
238676
238766
  }
238677
238767
  async function renderTemplate(template, destPath, data) {
238678
- const templateDir = join8(getTemplatesDir(), template.path);
238768
+ const templateDir = join9(getTemplatesDir(), template.path);
238679
238769
  const files = await globby("**/*", {
238680
238770
  cwd: templateDir,
238681
238771
  dot: true,
238682
238772
  onlyFiles: true
238683
238773
  });
238684
238774
  for (const file2 of files) {
238685
- const srcPath = join8(templateDir, file2);
238775
+ const srcPath = join9(templateDir, file2);
238686
238776
  try {
238687
238777
  if (file2.endsWith(".ejs")) {
238688
238778
  const rendered = await import_ejs.default.renderFile(srcPath, data);
238689
238779
  const { attributes, body } = import_front_matter.default(rendered);
238690
- const destFile = attributes.outputFileName ? join8(dirname6(file2), attributes.outputFileName) : file2.replace(/\.ejs$/, "");
238691
- const destFilePath = join8(destPath, destFile);
238780
+ const destFile = attributes.outputFileName ? join9(dirname6(file2), attributes.outputFileName) : file2.replace(/\.ejs$/, "");
238781
+ const destFilePath = join9(destPath, destFile);
238692
238782
  await writeFile(destFilePath, body);
238693
238783
  } else {
238694
- const destFilePath = join8(destPath, file2);
238784
+ const destFilePath = join9(destPath, file2);
238695
238785
  await copyFile(srcPath, destFilePath);
238696
238786
  }
238697
238787
  } catch (error48) {
@@ -238790,7 +238880,7 @@ async function getSiteFilePaths(outputDir) {
238790
238880
  // src/core/site/deploy.ts
238791
238881
  import { randomUUID } from "node:crypto";
238792
238882
  import { tmpdir } from "node:os";
238793
- import { join as join9 } from "node:path";
238883
+ import { join as join10 } from "node:path";
238794
238884
  async function deploySite(siteOutputDir) {
238795
238885
  if (!await pathExists(siteOutputDir)) {
238796
238886
  throw new InvalidInputError(`Output directory does not exist: ${siteOutputDir}. Make sure to build your project first.`, {
@@ -238807,7 +238897,7 @@ async function deploySite(siteOutputDir) {
238807
238897
  ]
238808
238898
  });
238809
238899
  }
238810
- const archivePath = join9(tmpdir(), `base44-site-${randomUUID()}.tar.gz`);
238900
+ const archivePath = join10(tmpdir(), `base44-site-${randomUUID()}.tar.gz`);
238811
238901
  try {
238812
238902
  await createArchive(siteOutputDir, archivePath);
238813
238903
  return await uploadSite(archivePath);
@@ -246563,7 +246653,7 @@ function formatYaml(data, options = {}) {
246563
246653
  async function pullAgentsAction() {
246564
246654
  const { project: project2 } = await readProjectConfig();
246565
246655
  const configDir = dirname7(project2.configPath);
246566
- const agentsDir = join10(configDir, project2.agentsDir);
246656
+ const agentsDir = join11(configDir, project2.agentsDir);
246567
246657
  const remoteAgents = await runTask("Fetching agents from Base44", async () => {
246568
246658
  return await fetchAgents();
246569
246659
  }, {
@@ -246685,11 +246775,11 @@ function getConnectorsListAvailableCommand(context) {
246685
246775
  }
246686
246776
 
246687
246777
  // src/cli/commands/connectors/pull.ts
246688
- import { dirname as dirname8, join as join11 } from "node:path";
246778
+ import { dirname as dirname8, join as join12 } from "node:path";
246689
246779
  async function pullConnectorsAction() {
246690
246780
  const { project: project2 } = await readProjectConfig();
246691
246781
  const configDir = dirname8(project2.configPath);
246692
- const connectorsDir = join11(configDir, project2.connectorsDir);
246782
+ const connectorsDir = join12(configDir, project2.connectorsDir);
246693
246783
  const remoteConnectors = await runTask("Fetching connectors from Base44", async () => {
246694
246784
  return await pullAllConnectors();
246695
246785
  }, {
@@ -247590,14 +247680,84 @@ async function deployFunctionsAction() {
247590
247680
  }
247591
247681
  return { outroMessage: "Functions deployed to Base44" };
247592
247682
  }
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 () => {
247683
+ function getDeployCommand(context) {
247684
+ return new Command("deploy").description("Deploy local functions to Base44").action(async () => {
247595
247685
  await runCommand(deployFunctionsAction, { requireAuth: true }, context);
247596
- }));
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));
247597
247757
  }
247598
247758
 
247599
247759
  // src/cli/commands/project/create.ts
247600
- import { basename as basename3, join as join12, resolve as resolve2 } from "node:path";
247760
+ import { basename as basename3, join as join14, resolve as resolve2 } from "node:path";
247601
247761
  var import_kebabCase = __toESM(require_kebabCase(), 1);
247602
247762
  var DEFAULT_TEMPLATE_ID = "backend-only";
247603
247763
  async function getTemplateById(templateId) {
@@ -247733,7 +247893,7 @@ async function executeCreate({
247733
247893
  updateMessage("Building project...");
247734
247894
  await execa({ cwd: resolvedPath, shell: true })`${buildCommand}`;
247735
247895
  updateMessage("Deploying site...");
247736
- return await deploySite(join12(resolvedPath, outputDirectory));
247896
+ return await deploySite(join14(resolvedPath, outputDirectory));
247737
247897
  }, {
247738
247898
  successMessage: theme.colors.base44Orange("Site deployed successfully"),
247739
247899
  errorMessage: "Failed to deploy site"
@@ -247831,7 +247991,7 @@ ${summaryLines.join(`
247831
247991
  }
247832
247992
  return { outroMessage: "App deployed successfully" };
247833
247993
  }
247834
- function getDeployCommand(context) {
247994
+ function getDeployCommand2(context) {
247835
247995
  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
247996
  await runCommand(() => deployAction({
247837
247997
  ...options,
@@ -248376,10 +248536,10 @@ function toPascalCase(name2) {
248376
248536
  return name2.split(/[-_\s]+/).map((w8) => w8.charAt(0).toUpperCase() + w8.slice(1)).join("");
248377
248537
  }
248378
248538
  // src/core/types/update-project.ts
248379
- import { join as join15 } from "node:path";
248539
+ import { join as join17 } from "node:path";
248380
248540
  var TYPES_INCLUDE_PATH = `${PROJECT_SUBDIR}/${TYPES_OUTPUT_SUBDIR}/*.d.ts`;
248381
248541
  async function updateProjectConfig(projectRoot) {
248382
- const tsconfigPath = join15(projectRoot, "tsconfig.json");
248542
+ const tsconfigPath = join17(projectRoot, "tsconfig.json");
248383
248543
  if (!await pathExists(tsconfigPath)) {
248384
248544
  return false;
248385
248545
  }
@@ -248422,7 +248582,7 @@ function getTypesCommand(context) {
248422
248582
  }
248423
248583
 
248424
248584
  // src/cli/dev/dev-server/main.ts
248425
- import { dirname as dirname13, join as join18 } from "node:path";
248585
+ import { dirname as dirname14, join as join20 } from "node:path";
248426
248586
  var import_cors = __toESM(require_lib4(), 1);
248427
248587
  var import_express4 = __toESM(require_express(), 1);
248428
248588
 
@@ -248779,130 +248939,14 @@ function createFunctionRouter(manager, logger) {
248779
248939
  return router;
248780
248940
  }
248781
248941
 
248782
- // src/cli/dev/dev-server/db/database.ts
248942
+ // src/cli/dev/dev-server/database.ts
248783
248943
  var import_nedb = __toESM(require_nedb(), 1);
248784
248944
 
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
248945
  class Database {
248899
248946
  collections = new Map;
248900
- schemas = new Map;
248901
- validator = new Validator;
248902
248947
  load(entities) {
248903
248948
  for (const entity2 of entities) {
248904
248949
  this.collections.set(entity2.name, new import_nedb.default);
248905
- this.schemas.set(entity2.name, entity2);
248906
248950
  }
248907
248951
  }
248908
248952
  getCollection(name2) {
@@ -248916,25 +248960,6 @@ class Database {
248916
248960
  collection.remove({}, { multi: true });
248917
248961
  }
248918
248962
  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
248963
  }
248939
248964
  }
248940
248965
 
@@ -249126,14 +249151,8 @@ function createEntityRoutes(db2, logger, remoteProxy, broadcast) {
249126
249151
  try {
249127
249152
  const now = new Date().toISOString();
249128
249153
  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
249154
  const record2 = {
249136
- ...filteredBody,
249155
+ ...body,
249137
249156
  id: nanoid3(),
249138
249157
  created_date: now,
249139
249158
  updated_date: now
@@ -249154,21 +249173,12 @@ function createEntityRoutes(db2, logger, remoteProxy, broadcast) {
249154
249173
  }
249155
249174
  try {
249156
249175
  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
- }
249176
+ const records = req.body.map((item) => ({
249177
+ ...item,
249178
+ id: nanoid3(),
249179
+ created_date: now,
249180
+ updated_date: now
249181
+ }));
249172
249182
  const inserted = stripInternalFields(await collection.insertAsync(records));
249173
249183
  emit(appId, entityName, "create", inserted);
249174
249184
  res.status(201).json(inserted);
@@ -249181,14 +249191,8 @@ function createEntityRoutes(db2, logger, remoteProxy, broadcast) {
249181
249191
  const { appId, entityName, id: id2 } = req.params;
249182
249192
  const { id: _id, created_date: _created_date, ...body } = req.body;
249183
249193
  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
249194
  const updateData = {
249191
- ...filteredBody,
249195
+ ...body,
249192
249196
  updated_date: new Date().toISOString()
249193
249197
  };
249194
249198
  const result = await collection.updateAsync({ id: id2 }, { $set: updateData }, { returnUpdatedDocs: true });
@@ -250058,9 +250062,9 @@ class NodeFsHandler {
250058
250062
  if (this.fsw.closed) {
250059
250063
  return;
250060
250064
  }
250061
- const dirname12 = sp2.dirname(file2);
250065
+ const dirname13 = sp2.dirname(file2);
250062
250066
  const basename5 = sp2.basename(file2);
250063
- const parent = this.fsw._getWatchedDir(dirname12);
250067
+ const parent = this.fsw._getWatchedDir(dirname13);
250064
250068
  let prevStats = stats;
250065
250069
  if (parent.has(basename5))
250066
250070
  return;
@@ -250087,7 +250091,7 @@ class NodeFsHandler {
250087
250091
  prevStats = newStats2;
250088
250092
  }
250089
250093
  } catch (error48) {
250090
- this.fsw._remove(dirname12, basename5);
250094
+ this.fsw._remove(dirname13, basename5);
250091
250095
  }
250092
250096
  } else if (parent.has(basename5)) {
250093
250097
  const at13 = newStats.atimeMs;
@@ -251108,8 +251112,8 @@ async function createDevServer(options8) {
251108
251112
  broadcastEntityEvent(io6, appId, entityName, event);
251109
251113
  };
251110
251114
  const base44ConfigWatcher = new WatchBase44({
251111
- functions: join18(dirname13(project2.configPath), project2.functionsDir),
251112
- entities: join18(dirname13(project2.configPath), project2.entitiesDir)
251115
+ functions: join20(dirname14(project2.configPath), project2.functionsDir),
251116
+ entities: join20(dirname14(project2.configPath), project2.entitiesDir)
251113
251117
  }, devLogger);
251114
251118
  base44ConfigWatcher.on("change", async (name2) => {
251115
251119
  try {
@@ -251279,13 +251283,13 @@ function createProgram(context) {
251279
251283
  program2.addCommand(getLogoutCommand(context));
251280
251284
  program2.addCommand(getCreateCommand(context));
251281
251285
  program2.addCommand(getDashboardCommand(context));
251282
- program2.addCommand(getDeployCommand(context));
251286
+ program2.addCommand(getDeployCommand2(context));
251283
251287
  program2.addCommand(getLinkCommand(context));
251284
251288
  program2.addCommand(getEjectCommand(context));
251285
251289
  program2.addCommand(getEntitiesPushCommand(context));
251286
251290
  program2.addCommand(getAgentsCommand(context));
251287
251291
  program2.addCommand(getConnectorsCommand(context));
251288
- program2.addCommand(getFunctionsDeployCommand(context));
251292
+ program2.addCommand(getFunctionsCommand(context));
251289
251293
  program2.addCommand(getSecretsCommand(context));
251290
251294
  program2.addCommand(getSiteCommand(context));
251291
251295
  program2.addCommand(getTypesCommand(context));
@@ -251299,7 +251303,7 @@ var import_detect_agent = __toESM(require_dist5(), 1);
251299
251303
  import { release, type } from "node:os";
251300
251304
 
251301
251305
  // ../../node_modules/posthog-node/dist/extensions/error-tracking/modifiers/module.node.mjs
251302
- import { dirname as dirname14, posix, sep } from "path";
251306
+ import { dirname as dirname15, posix, sep } from "path";
251303
251307
  function createModulerModifier() {
251304
251308
  const getModuleFromFileName = createGetModuleFromFilename();
251305
251309
  return async (frames) => {
@@ -251308,7 +251312,7 @@ function createModulerModifier() {
251308
251312
  return frames;
251309
251313
  };
251310
251314
  }
251311
- function createGetModuleFromFilename(basePath = process.argv[1] ? dirname14(process.argv[1]) : process.cwd(), isWindows5 = sep === "\\") {
251315
+ function createGetModuleFromFilename(basePath = process.argv[1] ? dirname15(process.argv[1]) : process.cwd(), isWindows5 = sep === "\\") {
251312
251316
  const normalizedBase = isWindows5 ? normalizeWindowsPath2(basePath) : basePath;
251313
251317
  return (filename) => {
251314
251318
  if (!filename)
@@ -255497,9 +255501,9 @@ function addCommandInfoToErrorReporter(program2, errorReporter) {
255497
255501
  });
255498
255502
  }
255499
255503
  // src/cli/index.ts
255500
- var __dirname4 = dirname15(fileURLToPath6(import.meta.url));
255504
+ var __dirname4 = dirname16(fileURLToPath6(import.meta.url));
255501
255505
  async function runCLI() {
255502
- ensureNpmAssets(join19(__dirname4, "../assets"));
255506
+ ensureNpmAssets(join21(__dirname4, "../assets"));
255503
255507
  const errorReporter = new ErrorReporter;
255504
255508
  errorReporter.registerProcessErrorHandlers();
255505
255509
  const isNonInteractive = !process.stdin.isTTY || !process.stdout.isTTY;
@@ -255531,4 +255535,4 @@ export {
255531
255535
  CLIExitError
255532
255536
  };
255533
255537
 
255534
- //# debugId=E1E29CEB4EDF231E64756E2164756E21
255538
+ //# debugId=177D5D3CB71DE0D564756E2164756E21