@base44-preview/cli 0.0.50-pr.475.feeb89c → 0.0.50-pr.477.43f5b00

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
@@ -219926,8 +219926,7 @@ var theme = {
219926
219926
  bold: source_default.bold,
219927
219927
  dim: source_default.dim,
219928
219928
  error: source_default.red,
219929
- warn: source_default.yellow,
219930
- info: source_default.cyan
219929
+ warn: source_default.yellow
219931
219930
  },
219932
219931
  format: {
219933
219932
  errorContext(ctx) {
@@ -243244,7 +243243,6 @@ var package_default = {
243244
243243
  typescript: "^5.7.2",
243245
243244
  vitest: "^4.0.16",
243246
243245
  yaml: "^2.8.2",
243247
- qs: "^6.12.3",
243248
243246
  zod: "^4.3.5"
243249
243247
  },
243250
243248
  engines: {
@@ -252757,12 +252755,9 @@ function getTypesCommand() {
252757
252755
  return new Command("types").description("Manage TypeScript type generation").addCommand(getTypesGenerateCommand());
252758
252756
  }
252759
252757
 
252760
- // src/cli/commands/dev.ts
252761
- import process21 from "node:process";
252762
-
252763
252758
  // src/cli/dev/dev-server/main.ts
252764
252759
  var import_cors = __toESM(require_lib4(), 1);
252765
- var import_express6 = __toESM(require_express(), 1);
252760
+ var import_express5 = __toESM(require_express(), 1);
252766
252761
  import { dirname as dirname16, join as join23 } from "node:path";
252767
252762
 
252768
252763
  // ../../node_modules/get-port/index.js
@@ -253322,7 +253317,6 @@ class Validator {
253322
253317
 
253323
253318
  // src/cli/dev/dev-server/db/database.ts
253324
253319
  var USER_COLLECTION = "user";
253325
- var PRIVATE_COLLECTION_PREFIX = "$";
253326
253320
 
253327
253321
  class Database {
253328
253322
  collections = new Map;
@@ -253344,7 +253338,6 @@ class Database {
253344
253338
  this.schemas.set(USER_COLLECTION, this.buildUserSchema(userEntity));
253345
253339
  const collection = new import_nedb.default;
253346
253340
  this.collections.set(USER_COLLECTION, collection);
253347
- this.collections.set(PRIVATE_COLLECTION_PREFIX + USER_COLLECTION, new import_nedb.default);
253348
253341
  const userInfo = await readAuth();
253349
253342
  const now = getNowISOTimestamp();
253350
253343
  await collection.insertAsync({
@@ -253386,9 +253379,7 @@ class Database {
253386
253379
  return this.collections.get(this.normalizeName(name2));
253387
253380
  }
253388
253381
  getCollectionNames() {
253389
- return Array.from(this.collections.keys()).filter((name2) => {
253390
- return !name2.startsWith(PRIVATE_COLLECTION_PREFIX);
253391
- });
253382
+ return Array.from(this.collections.keys());
253392
253383
  }
253393
253384
  dropAll() {
253394
253385
  for (const collection of this.collections.values()) {
@@ -253452,205 +253443,15 @@ function broadcastEntityEvent(io6, appId, entityName, event) {
253452
253443
  });
253453
253444
  }
253454
253445
 
253455
- // src/cli/dev/dev-server/routes/auth-router.ts
253456
- var import_express2 = __toESM(require_express(), 1);
253457
- var import_jsonwebtoken = __toESM(require_jsonwebtoken(), 1);
253458
- import { randomInt } from "node:crypto";
253459
- var LOCAL_DEV_SECRET = "LOCAL_DEV_SECRET";
253460
- var generateCode = () => {
253461
- return randomInt(1e5, 1e6).toString();
253462
- };
253463
- var createJwtToken = (email3) => {
253464
- return import_jsonwebtoken.default.sign({ sub: email3 }, LOCAL_DEV_SECRET, {
253465
- expiresIn: "360d"
253466
- });
253467
- };
253468
- function createAuthRouter(db2, logger2) {
253469
- const router = import_express2.Router({ mergeParams: true });
253470
- const userRegistrPendingMap = new Map;
253471
- const parseBody = import_express2.json();
253472
- router.post("/login", parseBody, async (req, res) => {
253473
- const { email: email3, password } = req.body;
253474
- const result = await db2.getCollection(USER_COLLECTION)?.findOneAsync({ email: email3 });
253475
- if (result) {
253476
- const registeredUserData = userRegistrPendingMap.get(email3);
253477
- if (result.role === "admin" || registeredUserData?.password === password) {
253478
- res.json({
253479
- access_token: createJwtToken(email3),
253480
- success: true,
253481
- user: {}
253482
- });
253483
- } else {
253484
- res.status(400).json({
253485
- detail: "Invalid email or password",
253486
- error_type: "HTTPException",
253487
- message: "Invalid email or password",
253488
- request_id: null,
253489
- traceback: ""
253490
- });
253491
- }
253492
- return;
253493
- }
253494
- res.status(401).json({ error: "Unauthorized" });
253495
- });
253496
- router.post("/register", parseBody, async (req, res) => {
253497
- const { email: email3, password } = req.body;
253498
- if ((password || "").length < 8) {
253499
- res.status(400).json({
253500
- detail: "Password must be at least 8 characters long",
253501
- error_type: "HTTPException",
253502
- message: "Password must be at least 8 characters long",
253503
- request_id: null,
253504
- traceback: ""
253505
- });
253506
- return;
253507
- }
253508
- const result = await db2.getCollection(USER_COLLECTION)?.findOneAsync({ email: email3 });
253509
- if (result) {
253510
- res.status(400).json({
253511
- detail: "A user with this email already exists",
253512
- error_type: "HTTPException",
253513
- message: "A user with this email already exists",
253514
- request_id: null,
253515
- traceback: ""
253516
- });
253517
- return;
253518
- }
253519
- const otpCode = generateCode();
253520
- const id2 = nanoid3();
253521
- userRegistrPendingMap.set(email3, {
253522
- id: id2,
253523
- email: email3,
253524
- otpCode,
253525
- password,
253526
- createdAt: +Date.now()
253527
- });
253528
- logger2.log(theme.styles.info(`
253529
- In order to complete registration use this verification code: ${otpCode}
253530
- `));
253531
- res.json({
253532
- id: id2,
253533
- message: "Registration successful. Please check your email for the verification code.",
253534
- otp_expires_in_minutes: 10
253535
- });
253536
- });
253537
- router.post("/verify-otp", parseBody, async (req, res) => {
253538
- const { email: email3, otp_code } = req.body;
253539
- const userData = userRegistrPendingMap.get(email3);
253540
- if (userData && userData.otpCode === otp_code) {
253541
- if (+Date.now() - userData.createdAt < 10 * 60 * 1000) {
253542
- userData.otpCode = undefined;
253543
- const collection = db2.getCollection(USER_COLLECTION);
253544
- const now = getNowISOTimestamp();
253545
- const nameFromEmailMatch = /^([^@]+)/.exec(email3);
253546
- const fullName = nameFromEmailMatch ? nameFromEmailMatch[1] : email3;
253547
- await collection?.insertAsync({
253548
- id: userData.id,
253549
- email: email3,
253550
- full_name: fullName,
253551
- is_service: false,
253552
- is_verified: true,
253553
- disabled: null,
253554
- role: "user",
253555
- collaborator_role: "editor",
253556
- created_date: now,
253557
- updated_date: now
253558
- });
253559
- res.json({
253560
- id: userData.id,
253561
- access_token: createJwtToken(email3),
253562
- message: "Email verified successfully. You are now logged in.",
253563
- success: true
253564
- });
253565
- } else {
253566
- res.status(400).json({
253567
- detail: "Verification code has expired",
253568
- error_type: "HTTPException",
253569
- message: "Verification code has expired",
253570
- request_id: null,
253571
- traceback: ""
253572
- });
253573
- }
253574
- } else {
253575
- const appId = req.params.appId;
253576
- res.status(500).json({
253577
- detail: `{'email': '${email3}', 'app_id': '${appId}}'} -> Object not found`,
253578
- error_type: "ObjectNotFoundError",
253579
- message: `{'email': '${email3}', 'app_id': '${appId}}'} -> Object not found`,
253580
- request_id: null,
253581
- traceback: ""
253582
- });
253583
- }
253584
- });
253585
- return router;
253586
- }
253587
-
253588
253446
  // src/cli/dev/dev-server/routes/entities/entities-router.ts
253589
- var import_express4 = __toESM(require_express(), 1);
253590
-
253591
- // src/cli/dev/dev-server/db/entity-queries.ts
253592
- function parseSort(sort) {
253593
- if (!sort) {
253594
- return;
253595
- }
253596
- if (sort.startsWith("-")) {
253597
- return { [sort.slice(1)]: -1 };
253598
- }
253599
- return { [sort]: 1 };
253600
- }
253601
- function parseFields(fields) {
253602
- if (!fields) {
253603
- return;
253604
- }
253605
- const projection = {};
253606
- for (const field of fields.split(",")) {
253607
- const trimmed = field.trim();
253608
- if (trimmed) {
253609
- projection[trimmed] = 1;
253610
- }
253611
- }
253612
- return Object.keys(projection).length > 0 ? projection : undefined;
253613
- }
253614
- var queryEntity = async (collection, reqQuery) => {
253615
- const { sort, limit, skip: skip2, fields, q: q13 } = reqQuery;
253616
- let query = {};
253617
- if (q13 && typeof q13 === "string") {
253618
- try {
253619
- query = JSON.parse(q13);
253620
- } catch {
253621
- throw new InvalidInputError("Invalid query parameter 'q'");
253622
- }
253623
- }
253624
- let cursor3 = collection.findAsync(query);
253625
- const sortObj = parseSort(sort);
253626
- if (sortObj) {
253627
- cursor3 = cursor3.sort(sortObj);
253628
- }
253629
- if (skip2) {
253630
- const skipNum = Number.parseInt(skip2, 10);
253631
- if (!Number.isNaN(skipNum)) {
253632
- cursor3 = cursor3.skip(skipNum);
253633
- }
253634
- }
253635
- if (limit) {
253636
- const limitNum = Number.parseInt(limit, 10);
253637
- if (!Number.isNaN(limitNum)) {
253638
- cursor3 = cursor3.limit(limitNum);
253639
- }
253640
- }
253641
- const projection = parseFields(fields);
253642
- if (projection) {
253643
- cursor3 = cursor3.projection(projection);
253644
- }
253645
- return cursor3;
253646
- };
253447
+ var import_express3 = __toESM(require_express(), 1);
253647
253448
 
253648
253449
  // src/cli/dev/dev-server/routes/entities/entities-user-router.ts
253649
- var import_express3 = __toESM(require_express(), 1);
253650
- var import_jsonwebtoken2 = __toESM(require_jsonwebtoken(), 1);
253450
+ var import_express2 = __toESM(require_express(), 1);
253451
+ var import_jsonwebtoken = __toESM(require_jsonwebtoken(), 1);
253651
253452
  function createUserRouter(db2, logger2) {
253652
- const router = import_express3.Router({ mergeParams: true });
253653
- const parseBody = import_express3.json();
253453
+ const router = import_express2.Router({ mergeParams: true });
253454
+ const parseBody = import_express2.json();
253654
253455
  function withAuth(handler) {
253655
253456
  return async (req, res) => {
253656
253457
  const auth2 = req.headers.authorization;
@@ -253659,7 +253460,7 @@ function createUserRouter(db2, logger2) {
253659
253460
  return;
253660
253461
  }
253661
253462
  try {
253662
- const { payload } = import_jsonwebtoken2.default.decode(auth2.replace("Bearer ", ""), { complete: true }) ?? {};
253463
+ const { payload } = import_jsonwebtoken.default.decode(auth2.replace("Bearer ", ""), { complete: true }) ?? {};
253663
253464
  const result = await db2.getCollection(USER_COLLECTION)?.findOneAsync({ email: payload?.sub });
253664
253465
  if (!result) {
253665
253466
  res.status(404).json({ error: "Unable to read data for the current user" });
@@ -253692,28 +253493,6 @@ function createUserRouter(db2, logger2) {
253692
253493
  ...req.body
253693
253494
  });
253694
253495
  }));
253695
- router.get("/", withAuth(async (req, res, currentUser) => {
253696
- const collection = db2.getCollection(USER_COLLECTION);
253697
- if (!collection) {
253698
- res.status(404).json({ error: `Entity "${USER_COLLECTION}" not found` });
253699
- return;
253700
- }
253701
- try {
253702
- if (currentUser.role === "admin") {
253703
- const result = await queryEntity(collection, req.query);
253704
- res.json(stripInternalFields(result));
253705
- } else {
253706
- res.json([stripInternalFields(currentUser)]);
253707
- }
253708
- } catch (error48) {
253709
- if (error48 instanceof InvalidInputError) {
253710
- res.status(400).json({ error: error48.message });
253711
- } else {
253712
- logger2.error(`Error in GET /${USER_COLLECTION}:`, error48);
253713
- res.status(500).json({ error: "Internal server error" });
253714
- }
253715
- }
253716
- }));
253717
253496
  router.post("/bulk", async (_req, res) => {
253718
253497
  res.json({});
253719
253498
  });
@@ -253763,9 +253542,31 @@ function createUserRouter(db2, logger2) {
253763
253542
  }
253764
253543
 
253765
253544
  // src/cli/dev/dev-server/routes/entities/entities-router.ts
253545
+ function parseSort(sort) {
253546
+ if (!sort) {
253547
+ return;
253548
+ }
253549
+ if (sort.startsWith("-")) {
253550
+ return { [sort.slice(1)]: -1 };
253551
+ }
253552
+ return { [sort]: 1 };
253553
+ }
253554
+ function parseFields(fields) {
253555
+ if (!fields) {
253556
+ return;
253557
+ }
253558
+ const projection = {};
253559
+ for (const field of fields.split(",")) {
253560
+ const trimmed = field.trim();
253561
+ if (trimmed) {
253562
+ projection[trimmed] = 1;
253563
+ }
253564
+ }
253565
+ return Object.keys(projection).length > 0 ? projection : undefined;
253566
+ }
253766
253567
  async function createEntityRoutes(db2, logger2, broadcast) {
253767
- const router = import_express4.Router({ mergeParams: true });
253768
- const parseBody = import_express4.json();
253568
+ const router = import_express3.Router({ mergeParams: true });
253569
+ const parseBody = import_express3.json();
253769
253570
  function withCollection(handler) {
253770
253571
  return async (req, res) => {
253771
253572
  const collection = db2.getCollection(req.params.entityName);
@@ -253810,14 +253611,42 @@ async function createEntityRoutes(db2, logger2, broadcast) {
253810
253611
  router.get("/:entityName", withCollection(async (req, res, collection) => {
253811
253612
  const { entityName } = req.params;
253812
253613
  try {
253813
- res.json(stripInternalFields(await queryEntity(collection, req.query)));
253814
- } catch (error48) {
253815
- if (error48 instanceof InvalidInputError) {
253816
- res.status(400).json({ error: error48.message });
253817
- } else {
253818
- logger2.error(`Error in GET /${entityName}:`, error48);
253819
- res.status(500).json({ error: "Internal server error" });
253614
+ const { sort, limit, skip: skip2, fields, q: q13 } = req.query;
253615
+ let query = {};
253616
+ if (q13 && typeof q13 === "string") {
253617
+ try {
253618
+ query = JSON.parse(q13);
253619
+ } catch {
253620
+ res.status(400).json({ error: "Invalid query parameter 'q'" });
253621
+ return;
253622
+ }
253623
+ }
253624
+ let cursor3 = collection.findAsync(query);
253625
+ const sortObj = parseSort(sort);
253626
+ if (sortObj) {
253627
+ cursor3 = cursor3.sort(sortObj);
253628
+ }
253629
+ if (skip2) {
253630
+ const skipNum = Number.parseInt(skip2, 10);
253631
+ if (!Number.isNaN(skipNum)) {
253632
+ cursor3 = cursor3.skip(skipNum);
253633
+ }
253634
+ }
253635
+ if (limit) {
253636
+ const limitNum = Number.parseInt(limit, 10);
253637
+ if (!Number.isNaN(limitNum)) {
253638
+ cursor3 = cursor3.limit(limitNum);
253639
+ }
253820
253640
  }
253641
+ const projection = parseFields(fields);
253642
+ if (projection) {
253643
+ cursor3 = cursor3.projection(projection);
253644
+ }
253645
+ const docs = await cursor3;
253646
+ res.json(stripInternalFields(docs));
253647
+ } catch (error48) {
253648
+ logger2.error(`Error in GET /${entityName}:`, error48);
253649
+ res.status(500).json({ error: "Internal server error" });
253821
253650
  }
253822
253651
  }));
253823
253652
  router.post("/:entityName", parseBody, withCollection(async (req, res, collection) => {
@@ -253936,7 +253765,7 @@ async function createEntityRoutes(db2, logger2, broadcast) {
253936
253765
  }
253937
253766
 
253938
253767
  // src/cli/dev/dev-server/routes/integrations.ts
253939
- var import_express5 = __toESM(require_express(), 1);
253768
+ var import_express4 = __toESM(require_express(), 1);
253940
253769
  var import_multer = __toESM(require_multer(), 1);
253941
253770
  import { createHash, randomUUID as randomUUID4 } from "node:crypto";
253942
253771
  import fs28 from "node:fs";
@@ -253945,8 +253774,8 @@ function createFileToken(fileUri) {
253945
253774
  return createHash("sha256").update(fileUri).digest("hex");
253946
253775
  }
253947
253776
  function createIntegrationRoutes(mediaFilesDir, baseUrl, remoteProxy, logger2) {
253948
- const router = import_express5.Router({ mergeParams: true });
253949
- const parseBody = import_express5.json();
253777
+ const router = import_express4.Router({ mergeParams: true });
253778
+ const parseBody = import_express4.json();
253950
253779
  const privateFilesDir = path18.join(mediaFilesDir, "private");
253951
253780
  fs28.mkdirSync(mediaFilesDir, { recursive: true });
253952
253781
  fs28.mkdirSync(privateFilesDir, { recursive: true });
@@ -254016,7 +253845,7 @@ function createIntegrationRoutes(mediaFilesDir, baseUrl, remoteProxy, logger2) {
254016
253845
  return router;
254017
253846
  }
254018
253847
  function createCustomIntegrationRoutes(remoteProxy, logger2) {
254019
- const router = import_express5.Router({ mergeParams: true });
253848
+ const router = import_express4.Router({ mergeParams: true });
254020
253849
  router.post("/:slug/:operationId", (req, res, next) => {
254021
253850
  logger2.warn(`"${req.originalUrl}" is not supported in local development, passing call to production`);
254022
253851
  req.url = req.originalUrl;
@@ -255729,7 +255558,7 @@ async function createDevServer(options8) {
255729
255558
  const port = userPort ?? await getPorts({ port: DEFAULT_PORT });
255730
255559
  const baseUrl = `http://localhost:${port}`;
255731
255560
  const { functions, entities, project: project2 } = await options8.loadResources();
255732
- const app = import_express6.default();
255561
+ const app = import_express5.default();
255733
255562
  const remoteProxy = import_http_proxy_middleware2.createProxyMiddleware({
255734
255563
  target: BASE44_APP_URL,
255735
255564
  changeOrigin: true
@@ -255761,8 +255590,6 @@ async function createDevServer(options8) {
255761
255590
  let emitEntityEvent = () => {};
255762
255591
  const entityRoutes = await createEntityRoutes(db2, devLogger, (...args) => emitEntityEvent(...args));
255763
255592
  app.use("/api/apps/:appId/entities", entityRoutes);
255764
- const authRouter = createAuthRouter(db2, devLogger);
255765
- app.use("/api/apps/:appId/auth", authRouter);
255766
255593
  const { path: mediaFilesDir } = await $dir();
255767
255594
  app.use("/media/private/:fileUri", (req, res, next) => {
255768
255595
  const { fileUri } = req.params;
@@ -255782,15 +255609,13 @@ async function createDevServer(options8) {
255782
255609
  }
255783
255610
  next();
255784
255611
  });
255785
- app.use("/media", import_express6.default.static(mediaFilesDir));
255612
+ app.use("/media", import_express5.default.static(mediaFilesDir));
255786
255613
  const integrationRoutes = createIntegrationRoutes(mediaFilesDir, baseUrl, remoteProxy, devLogger);
255787
255614
  app.use("/api/apps/:appId/integration-endpoints", integrationRoutes);
255788
255615
  const customIntegrationRoutes = createCustomIntegrationRoutes(remoteProxy, devLogger);
255789
255616
  app.use("/api/apps/:appId/integrations/custom", customIntegrationRoutes);
255790
255617
  app.use((req, res, next) => {
255791
- if (!req.originalUrl.endsWith("analytics/track/batch")) {
255792
- devLogger.warn(`"${req.originalUrl}" is not supported in local development, passing call to production`);
255793
- }
255618
+ devLogger.warn(`"${req.originalUrl}" is not supported in local development, passing call to production`);
255794
255619
  remoteProxy(req, res, next);
255795
255620
  });
255796
255621
  const server = await new Promise((resolve8, reject) => {
@@ -255861,7 +255686,6 @@ async function devAction({ log }, options8) {
255861
255686
  const { port: resolvedPort } = await createDevServer({
255862
255687
  log,
255863
255688
  port,
255864
- cwd: process21.cwd(),
255865
255689
  denoWrapperPath: getDenoWrapperPath(),
255866
255690
  loadResources: async () => {
255867
255691
  const { functions, entities, project: project2 } = await readProjectConfig();
@@ -260369,4 +260193,4 @@ export {
260369
260193
  CLIExitError
260370
260194
  };
260371
260195
 
260372
- //# debugId=F5DEA59E4A91DAEE64756E2164756E21
260196
+ //# debugId=CBBBAC71F12A75D664756E2164756E21