@base44-preview/cli 0.0.50-pr.481.10960f2 → 0.0.50-pr.481.7634acb
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 +33 -48
- package/dist/cli/index.js.map +5 -5
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -253946,10 +253946,7 @@ function evaluateOperator(recordValue, operator) {
|
|
|
253946
253946
|
}
|
|
253947
253947
|
break;
|
|
253948
253948
|
case "$nin":
|
|
253949
|
-
if (!Array.isArray(opValue)) {
|
|
253950
|
-
return false;
|
|
253951
|
-
}
|
|
253952
|
-
if (Array.isArray(opValue) && opValue.includes(recordValue)) {
|
|
253949
|
+
if (!Array.isArray(opValue) || opValue.includes(recordValue)) {
|
|
253953
253950
|
return false;
|
|
253954
253951
|
}
|
|
253955
253952
|
break;
|
|
@@ -253965,6 +253962,8 @@ function evaluateOperator(recordValue, operator) {
|
|
|
253965
253962
|
return false;
|
|
253966
253963
|
}
|
|
253967
253964
|
break;
|
|
253965
|
+
default:
|
|
253966
|
+
return false;
|
|
253968
253967
|
}
|
|
253969
253968
|
}
|
|
253970
253969
|
return true;
|
|
@@ -254219,9 +254218,15 @@ async function createEntityRoutes(db2, logger2, broadcast) {
|
|
|
254219
254218
|
const parseBody = import_express4.json();
|
|
254220
254219
|
function withCollection(handler) {
|
|
254221
254220
|
return async (req, res) => {
|
|
254222
|
-
const
|
|
254221
|
+
const { entityName } = req.params;
|
|
254222
|
+
const collection = db2.getCollection(entityName);
|
|
254223
254223
|
if (!collection) {
|
|
254224
|
-
res.status(404).json({ error: `Entity "${
|
|
254224
|
+
res.status(404).json({ error: `Entity "${entityName}" not found` });
|
|
254225
|
+
return;
|
|
254226
|
+
}
|
|
254227
|
+
const schema10 = db2.getSchema(entityName);
|
|
254228
|
+
if (!schema10) {
|
|
254229
|
+
res.status(404).json({ error: `Schema for "${entityName}" not found` });
|
|
254225
254230
|
return;
|
|
254226
254231
|
}
|
|
254227
254232
|
let currentUser;
|
|
@@ -254230,7 +254235,7 @@ async function createEntityRoutes(db2, logger2, broadcast) {
|
|
|
254230
254235
|
const { payload } = import_jsonwebtoken3.default.decode(auth2.replace("Bearer ", ""), { complete: true }) ?? {};
|
|
254231
254236
|
currentUser = await db2.getCollection(USER_COLLECTION)?.findOneAsync({ email: payload?.sub });
|
|
254232
254237
|
} catch {}
|
|
254233
|
-
await handler(req, res, collection, currentUser);
|
|
254238
|
+
await handler(req, res, collection, schema10, currentUser);
|
|
254234
254239
|
};
|
|
254235
254240
|
}
|
|
254236
254241
|
function emit(appId, entityName, type, data) {
|
|
@@ -254250,7 +254255,7 @@ async function createEntityRoutes(db2, logger2, broadcast) {
|
|
|
254250
254255
|
}
|
|
254251
254256
|
const userRouter = createUserRouter(db2, logger2);
|
|
254252
254257
|
router.use("/User", userRouter);
|
|
254253
|
-
router.get("/:entityName/:id", withCollection(async (req, res, collection, currentUser) => {
|
|
254258
|
+
router.get("/:entityName/:id", withCollection(async (req, res, collection, schema10, currentUser) => {
|
|
254254
254259
|
const { entityName, id: id2 } = req.params;
|
|
254255
254260
|
try {
|
|
254256
254261
|
const doc2 = await collection.findOneAsync({ id: id2 });
|
|
@@ -254258,38 +254263,27 @@ async function createEntityRoutes(db2, logger2, broadcast) {
|
|
|
254258
254263
|
res.status(404).json({ error: `Record with id "${id2}" not found` });
|
|
254259
254264
|
return;
|
|
254260
254265
|
}
|
|
254261
|
-
|
|
254262
|
-
if (!checkRLS(schema10?.rls?.read, doc2, currentUser)) {
|
|
254266
|
+
if (!checkRLS(schema10.rls?.read, doc2, currentUser)) {
|
|
254263
254267
|
res.status(404).json({
|
|
254264
254268
|
message: `Entity ${entityName} with ID ${id2} not found`
|
|
254265
254269
|
});
|
|
254266
254270
|
return;
|
|
254267
254271
|
}
|
|
254268
|
-
|
|
254269
|
-
if (schema10) {
|
|
254270
|
-
result = applyFLS(result, schema10, currentUser, "read");
|
|
254271
|
-
}
|
|
254272
|
+
const result = applyFLS(stripInternalFields(doc2), schema10, currentUser, "read");
|
|
254272
254273
|
res.json(result);
|
|
254273
254274
|
} catch (error48) {
|
|
254274
254275
|
logger2.error(`Error in GET /${entityName}/${id2}:`, error48);
|
|
254275
254276
|
res.status(500).json({ error: "Internal server error" });
|
|
254276
254277
|
}
|
|
254277
254278
|
}));
|
|
254278
|
-
router.get("/:entityName", withCollection(async (req, res, collection, currentUser) => {
|
|
254279
|
+
router.get("/:entityName", withCollection(async (req, res, collection, schema10, currentUser) => {
|
|
254279
254280
|
const { entityName } = req.params;
|
|
254280
254281
|
try {
|
|
254281
|
-
const schema10 = db2.getSchema(entityName);
|
|
254282
|
-
if (schema10?.rls?.read === false) {
|
|
254283
|
-
res.json([]);
|
|
254284
|
-
return;
|
|
254285
|
-
}
|
|
254286
254282
|
let results = stripInternalFields(await queryEntity(collection, req.query));
|
|
254287
|
-
if (schema10
|
|
254283
|
+
if (schema10.rls?.read && schema10.rls.read !== true) {
|
|
254288
254284
|
results = results.filter((doc2) => checkRLS(schema10.rls.read, doc2, currentUser));
|
|
254289
254285
|
}
|
|
254290
|
-
|
|
254291
|
-
results = results.map((doc2) => applyFLS(doc2, schema10, currentUser, "read"));
|
|
254292
|
-
}
|
|
254286
|
+
results = results.map((doc2) => applyFLS(doc2, schema10, currentUser, "read"));
|
|
254293
254287
|
res.json(results);
|
|
254294
254288
|
} catch (error48) {
|
|
254295
254289
|
if (error48 instanceof InvalidInputError) {
|
|
@@ -254300,12 +254294,11 @@ async function createEntityRoutes(db2, logger2, broadcast) {
|
|
|
254300
254294
|
}
|
|
254301
254295
|
}
|
|
254302
254296
|
}));
|
|
254303
|
-
router.post("/:entityName", parseBody, withCollection(async (req, res, collection, currentUser) => {
|
|
254297
|
+
router.post("/:entityName", parseBody, withCollection(async (req, res, collection, schema10, currentUser) => {
|
|
254304
254298
|
const { appId, entityName } = req.params;
|
|
254305
254299
|
try {
|
|
254306
254300
|
const now = new Date().toISOString();
|
|
254307
254301
|
const { _id, ...body } = req.body;
|
|
254308
|
-
const schema10 = db2.getSchema(entityName);
|
|
254309
254302
|
if (!checkRLS(schema10?.rls?.create, {
|
|
254310
254303
|
...body,
|
|
254311
254304
|
created_by: currentUser?.email,
|
|
@@ -254314,10 +254307,7 @@ async function createEntityRoutes(db2, logger2, broadcast) {
|
|
|
254314
254307
|
res.status(403).json({ error: "Permission denied" });
|
|
254315
254308
|
return;
|
|
254316
254309
|
}
|
|
254317
|
-
|
|
254318
|
-
if (schema10) {
|
|
254319
|
-
filteredBody = applyFLS(filteredBody, schema10, currentUser, "write");
|
|
254320
|
-
}
|
|
254310
|
+
const filteredBody = applyFLS(db2.prepareRecord(entityName, body), schema10, currentUser, "write");
|
|
254321
254311
|
db2.validate(entityName, filteredBody);
|
|
254322
254312
|
const record2 = {
|
|
254323
254313
|
...filteredBody,
|
|
@@ -254327,7 +254317,7 @@ async function createEntityRoutes(db2, logger2, broadcast) {
|
|
|
254327
254317
|
created_date: now,
|
|
254328
254318
|
updated_date: now
|
|
254329
254319
|
};
|
|
254330
|
-
const inserted = stripInternalFields(await collection.insertAsync(record2));
|
|
254320
|
+
const inserted = applyFLS(stripInternalFields(await collection.insertAsync(record2)), schema10, currentUser, "read");
|
|
254331
254321
|
emit(appId, entityName, "create", inserted);
|
|
254332
254322
|
res.status(201).json(inserted);
|
|
254333
254323
|
} catch (error48) {
|
|
@@ -254339,7 +254329,7 @@ async function createEntityRoutes(db2, logger2, broadcast) {
|
|
|
254339
254329
|
res.status(500).json({ error: "Internal server error" });
|
|
254340
254330
|
}
|
|
254341
254331
|
}));
|
|
254342
|
-
router.post("/:entityName/bulk", parseBody, withCollection(async (req, res, collection, currentUser) => {
|
|
254332
|
+
router.post("/:entityName/bulk", parseBody, withCollection(async (req, res, collection, schema10, currentUser) => {
|
|
254343
254333
|
const { appId, entityName } = req.params;
|
|
254344
254334
|
if (!Array.isArray(req.body)) {
|
|
254345
254335
|
res.status(400).json({ error: "Request body must be an array" });
|
|
@@ -254347,7 +254337,6 @@ async function createEntityRoutes(db2, logger2, broadcast) {
|
|
|
254347
254337
|
}
|
|
254348
254338
|
try {
|
|
254349
254339
|
const now = new Date().toISOString();
|
|
254350
|
-
const schema10 = db2.getSchema(entityName);
|
|
254351
254340
|
const records = [];
|
|
254352
254341
|
for (const record2 of req.body) {
|
|
254353
254342
|
if (!checkRLS(schema10?.rls?.create, {
|
|
@@ -254384,12 +254373,11 @@ async function createEntityRoutes(db2, logger2, broadcast) {
|
|
|
254384
254373
|
res.status(500).json({ error: "Internal server error" });
|
|
254385
254374
|
}
|
|
254386
254375
|
}));
|
|
254387
|
-
router.put("/:entityName/:id", parseBody, withCollection(async (req, res, collection, currentUser) => {
|
|
254376
|
+
router.put("/:entityName/:id", parseBody, withCollection(async (req, res, collection, schema10, currentUser) => {
|
|
254388
254377
|
const { appId, entityName, id: id2 } = req.params;
|
|
254389
254378
|
const { id: _id, created_date: _created_date, ...body } = req.body;
|
|
254390
254379
|
try {
|
|
254391
|
-
|
|
254392
|
-
if (schema10?.rls?.update !== undefined) {
|
|
254380
|
+
if (schema10.rls?.update !== undefined) {
|
|
254393
254381
|
const existing = await collection.findOneAsync({ id: id2 });
|
|
254394
254382
|
if (!existing) {
|
|
254395
254383
|
res.status(404).json({ error: `Record with id "${id2}" not found` });
|
|
@@ -254402,10 +254390,7 @@ async function createEntityRoutes(db2, logger2, broadcast) {
|
|
|
254402
254390
|
return;
|
|
254403
254391
|
}
|
|
254404
254392
|
}
|
|
254405
|
-
|
|
254406
|
-
if (schema10) {
|
|
254407
|
-
filteredBody = applyFLS(filteredBody, schema10, currentUser, "write");
|
|
254408
|
-
}
|
|
254393
|
+
const filteredBody = applyFLS(db2.prepareRecord(entityName, body, true), schema10, currentUser, "write");
|
|
254409
254394
|
db2.validate(entityName, filteredBody, true);
|
|
254410
254395
|
const updateData = {
|
|
254411
254396
|
...filteredBody,
|
|
@@ -254416,7 +254401,7 @@ async function createEntityRoutes(db2, logger2, broadcast) {
|
|
|
254416
254401
|
res.status(404).json({ error: `Record with id "${id2}" not found` });
|
|
254417
254402
|
return;
|
|
254418
254403
|
}
|
|
254419
|
-
const updated = stripInternalFields(result.affectedDocuments);
|
|
254404
|
+
const updated = applyFLS(stripInternalFields(result.affectedDocuments), schema10, currentUser, "read");
|
|
254420
254405
|
emit(appId, entityName, "update", updated);
|
|
254421
254406
|
res.json(updated);
|
|
254422
254407
|
} catch (error48) {
|
|
@@ -254428,7 +254413,7 @@ async function createEntityRoutes(db2, logger2, broadcast) {
|
|
|
254428
254413
|
res.status(500).json({ error: "Internal server error" });
|
|
254429
254414
|
}
|
|
254430
254415
|
}));
|
|
254431
|
-
router.delete("/:entityName/:id", withCollection(async (req, res, collection, currentUser) => {
|
|
254416
|
+
router.delete("/:entityName/:id", withCollection(async (req, res, collection, schema10, currentUser) => {
|
|
254432
254417
|
const { appId, entityName, id: id2 } = req.params;
|
|
254433
254418
|
try {
|
|
254434
254419
|
const doc2 = await collection.findOneAsync({ id: id2 });
|
|
@@ -254436,8 +254421,7 @@ async function createEntityRoutes(db2, logger2, broadcast) {
|
|
|
254436
254421
|
res.status(404).json({ error: `Record with id "${id2}" not found` });
|
|
254437
254422
|
return;
|
|
254438
254423
|
}
|
|
254439
|
-
|
|
254440
|
-
if (!checkRLS(schema10?.rls?.delete, doc2, currentUser)) {
|
|
254424
|
+
if (!checkRLS(schema10.rls?.delete, doc2, currentUser)) {
|
|
254441
254425
|
res.status(404).json({
|
|
254442
254426
|
message: `Entity ${entityName} with ID ${id2} not found`
|
|
254443
254427
|
});
|
|
@@ -254451,11 +254435,10 @@ async function createEntityRoutes(db2, logger2, broadcast) {
|
|
|
254451
254435
|
res.status(500).json({ error: "Internal server error" });
|
|
254452
254436
|
}
|
|
254453
254437
|
}));
|
|
254454
|
-
router.delete("/:entityName", parseBody, withCollection(async (req, res, collection, currentUser) => {
|
|
254438
|
+
router.delete("/:entityName", parseBody, withCollection(async (req, res, collection, schema10, currentUser) => {
|
|
254455
254439
|
const { entityName } = req.params;
|
|
254456
254440
|
try {
|
|
254457
254441
|
const query = req.body || {};
|
|
254458
|
-
const schema10 = db2.getSchema(entityName);
|
|
254459
254442
|
const rlsDelete = schema10?.rls?.delete;
|
|
254460
254443
|
if (rlsDelete !== undefined && rlsDelete !== true) {
|
|
254461
254444
|
if (rlsDelete === false) {
|
|
@@ -256271,7 +256254,9 @@ var DEFAULT_PORT = 4400;
|
|
|
256271
256254
|
var BASE44_APP_URL = "https://base44.app";
|
|
256272
256255
|
async function createDevServer(options8) {
|
|
256273
256256
|
const { port: userPort } = options8;
|
|
256274
|
-
const port = userPort ?? await getPorts({
|
|
256257
|
+
const port = userPort ?? await getPorts({
|
|
256258
|
+
port: process.env.IS_TEST === "true" ? undefined : DEFAULT_PORT
|
|
256259
|
+
});
|
|
256275
256260
|
const baseUrl = `http://localhost:${port}`;
|
|
256276
256261
|
const { functions, entities, project: project2 } = await options8.loadResources();
|
|
256277
256262
|
const app = import_express6.default();
|
|
@@ -260883,4 +260868,4 @@ export {
|
|
|
260883
260868
|
CLIExitError
|
|
260884
260869
|
};
|
|
260885
260870
|
|
|
260886
|
-
//# debugId=
|
|
260871
|
+
//# debugId=731CCB72EF64A04D64756E2164756E21
|