@base44-preview/cli 0.0.35-pr.279.ea914f7 → 0.0.35-pr.279.eaf0d5c

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
@@ -226152,6 +226152,9 @@ class Database {
226152
226152
  getCollection(name2) {
226153
226153
  return this.collections.get(name2);
226154
226154
  }
226155
+ getCollectionNames() {
226156
+ return Array.from(this.collections.keys());
226157
+ }
226155
226158
  }
226156
226159
 
226157
226160
  // node_modules/socket.io/wrapper.mjs
@@ -226243,6 +226246,9 @@ function parseFields(fields) {
226243
226246
  return Object.keys(projection).length > 0 ? projection : undefined;
226244
226247
  }
226245
226248
  function stripInternalFields(doc2) {
226249
+ if (Array.isArray(doc2)) {
226250
+ return doc2.map((d5) => stripInternalFields(d5));
226251
+ }
226246
226252
  const { _id, ...rest } = doc2;
226247
226253
  return rest;
226248
226254
  }
@@ -226264,7 +226270,7 @@ function createEntityRoutes(db2, logger, remoteProxy, broadcast) {
226264
226270
  }
226265
226271
  broadcast(appId, entityName, createData(data));
226266
226272
  }
226267
- router.get("/User/me", (req, res, next) => {
226273
+ router.get("/User/:id", (req, res, next) => {
226268
226274
  req.url = req.originalUrl;
226269
226275
  remoteProxy(req, res, next);
226270
226276
  });
@@ -226311,13 +226317,13 @@ function createEntityRoutes(db2, logger, remoteProxy, broadcast) {
226311
226317
  cursor3 = cursor3.sort(sortObj);
226312
226318
  }
226313
226319
  if (skip2) {
226314
- const skipNum = parseInt(skip2, 10);
226320
+ const skipNum = Number.parseInt(skip2, 10);
226315
226321
  if (!Number.isNaN(skipNum)) {
226316
226322
  cursor3 = cursor3.skip(skipNum);
226317
226323
  }
226318
226324
  }
226319
226325
  if (limit) {
226320
- const limitNum = parseInt(limit, 10);
226326
+ const limitNum = Number.parseInt(limit, 10);
226321
226327
  if (!Number.isNaN(limitNum)) {
226322
226328
  cursor3 = cursor3.limit(limitNum);
226323
226329
  }
@@ -226327,7 +226333,7 @@ function createEntityRoutes(db2, logger, remoteProxy, broadcast) {
226327
226333
  cursor3 = cursor3.projection(projection);
226328
226334
  }
226329
226335
  const docs = await cursor3;
226330
- res.json(docs.map(stripInternalFields));
226336
+ res.json(stripInternalFields(docs));
226331
226337
  } catch (error48) {
226332
226338
  logger.error(`Error in GET /${entityName}:`, error48);
226333
226339
  res.status(500).json({ error: "Internal server error" });
@@ -226349,9 +226355,9 @@ function createEntityRoutes(db2, logger, remoteProxy, broadcast) {
226349
226355
  created_date: now,
226350
226356
  updated_date: now
226351
226357
  };
226352
- const inserted = await collection.insertAsync(record2);
226358
+ const inserted = stripInternalFields(await collection.insertAsync(record2));
226353
226359
  emit(appId, entityName, "create", inserted);
226354
- res.status(201).json(stripInternalFields(inserted));
226360
+ res.status(201).json(inserted);
226355
226361
  } catch (error48) {
226356
226362
  logger.error(`Error in POST /${entityName}:`, error48);
226357
226363
  res.status(500).json({ error: "Internal server error" });
@@ -226376,7 +226382,7 @@ function createEntityRoutes(db2, logger, remoteProxy, broadcast) {
226376
226382
  created_date: now,
226377
226383
  updated_date: now
226378
226384
  }));
226379
- const inserted = (await collection.insertAsync(records)).map(stripInternalFields);
226385
+ const inserted = stripInternalFields(await collection.insertAsync(records));
226380
226386
  emit(appId, entityName, "create", inserted);
226381
226387
  res.status(201).json(inserted);
226382
226388
  } catch (error48) {
@@ -226391,7 +226397,7 @@ function createEntityRoutes(db2, logger, remoteProxy, broadcast) {
226391
226397
  res.status(404).json({ error: `Entity "${entityName}" not found` });
226392
226398
  return;
226393
226399
  }
226394
- const { id: _id, created_date, ...body } = req.body;
226400
+ const { id: _id, created_date: _created_date, ...body } = req.body;
226395
226401
  try {
226396
226402
  const updateData = {
226397
226403
  ...body,
@@ -226402,7 +226408,7 @@ function createEntityRoutes(db2, logger, remoteProxy, broadcast) {
226402
226408
  res.status(404).json({ error: `Record with id "${id2}" not found` });
226403
226409
  return;
226404
226410
  }
226405
- const updated = Array.isArray(result.affectedDocuments) ? result.affectedDocuments.map(stripInternalFields) : stripInternalFields(result.affectedDocuments);
226411
+ const updated = stripInternalFields(result.affectedDocuments);
226406
226412
  emit(appId, entityName, "update", updated);
226407
226413
  res.json(updated);
226408
226414
  } catch (error48) {
@@ -226425,16 +226431,16 @@ function createEntityRoutes(db2, logger, remoteProxy, broadcast) {
226425
226431
  return;
226426
226432
  }
226427
226433
  if (doc2) {
226428
- emit(appId, entityName, "delete", doc2);
226434
+ emit(appId, entityName, "delete", stripInternalFields(doc2));
226429
226435
  }
226430
- res.json({ deleted: numRemoved });
226436
+ res.json({ success: true });
226431
226437
  } catch (error48) {
226432
226438
  logger.error(`Error in DELETE /${entityName}/${id2}:`, error48);
226433
226439
  res.status(500).json({ error: "Internal server error" });
226434
226440
  }
226435
226441
  });
226436
226442
  router.delete("/:entityName", parseBody, async (req, res) => {
226437
- const { appId, entityName } = req.params;
226443
+ const { entityName } = req.params;
226438
226444
  const collection = db2.getCollection(entityName);
226439
226445
  if (!collection) {
226440
226446
  res.status(404).json({ error: `Entity "${entityName}" not found` });
@@ -226442,12 +226448,8 @@ function createEntityRoutes(db2, logger, remoteProxy, broadcast) {
226442
226448
  }
226443
226449
  try {
226444
226450
  const query = req.body || {};
226445
- const docs = await collection.findAsync(query);
226446
226451
  const numRemoved = await collection.removeAsync(query, { multi: true });
226447
- for (const doc2 of docs) {
226448
- emit(appId, entityName, "delete", doc2);
226449
- }
226450
- res.json({ deleted: numRemoved });
226452
+ res.json({ success: true, deleted: numRemoved });
226451
226453
  } catch (error48) {
226452
226454
  logger.error(`Error in DELETE /${entityName}:`, error48);
226453
226455
  res.status(500).json({ error: "Internal server error" });
@@ -226488,6 +226490,9 @@ async function createDevServer(options8) {
226488
226490
  app.use("/api/apps/:appId/functions", functionRoutes);
226489
226491
  }
226490
226492
  const db2 = new Database(entities);
226493
+ if (db2.getCollectionNames().length > 0) {
226494
+ R2.info(`Loaded entities: ${db2.getCollectionNames().join(", ")}`);
226495
+ }
226491
226496
  let emitEntityEvent = () => {};
226492
226497
  const entityRoutes = createEntityRoutes(db2, devLogger, remoteProxy, (...args) => emitEntityEvent(...args));
226493
226498
  app.use("/api/apps/:appId/entities", entityRoutes);
@@ -230896,4 +230901,4 @@ export {
230896
230901
  CLIExitError
230897
230902
  };
230898
230903
 
230899
- //# debugId=95AD1B0C74FD653A64756E2164756E21
230904
+ //# debugId=A3CA6D4CCBA3DDBE64756E2164756E21