@base44-preview/cli 0.0.50-pr.471.f3b3ba8 → 0.0.50-pr.475.1c343ca
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 +277 -106
- package/dist/cli/index.js.map +12 -10
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -219926,7 +219926,8 @@ 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
|
|
219929
|
+
warn: source_default.yellow,
|
|
219930
|
+
info: source_default.cyan
|
|
219930
219931
|
},
|
|
219931
219932
|
format: {
|
|
219932
219933
|
errorContext(ctx) {
|
|
@@ -242594,40 +242595,11 @@ var EntityAutomationSchema = AutomationBaseSchema.extend({
|
|
|
242594
242595
|
entity_name: exports_external.string().min(1, "Entity name cannot be empty"),
|
|
242595
242596
|
event_types: exports_external.array(exports_external.enum(["create", "update", "delete"])).min(1, "At least one event type is required")
|
|
242596
242597
|
});
|
|
242597
|
-
var TriggerConditionSchema = exports_external.object({
|
|
242598
|
-
field: exports_external.string().min(1),
|
|
242599
|
-
operator: exports_external.string().min(1),
|
|
242600
|
-
value: exports_external.unknown().nullable().optional()
|
|
242601
|
-
});
|
|
242602
|
-
var TriggerLogicSchema = exports_external.enum(["and", "or"]);
|
|
242603
|
-
var TriggerConditionGroupSchema = exports_external.lazy(() => exports_external.object({
|
|
242604
|
-
logic: TriggerLogicSchema.optional(),
|
|
242605
|
-
conditions: exports_external.array(exports_external.union([TriggerConditionSchema, TriggerConditionGroupSchema])).min(1)
|
|
242606
|
-
}).strict());
|
|
242607
|
-
var EmptyTriggerConditionsSchema = exports_external.union([
|
|
242608
|
-
exports_external.object({}).strict(),
|
|
242609
|
-
exports_external.object({
|
|
242610
|
-
logic: TriggerLogicSchema.optional(),
|
|
242611
|
-
conditions: exports_external.array(exports_external.unknown()).length(0)
|
|
242612
|
-
}).strict()
|
|
242613
|
-
]);
|
|
242614
|
-
var TriggerConditionsSchema = exports_external.union([
|
|
242615
|
-
EmptyTriggerConditionsSchema,
|
|
242616
|
-
TriggerConditionGroupSchema
|
|
242617
|
-
]);
|
|
242618
|
-
var ConnectorAutomationSchema = AutomationBaseSchema.extend({
|
|
242619
|
-
type: exports_external.literal("connector"),
|
|
242620
|
-
integration_type: exports_external.string().min(1, "Integration type cannot be empty"),
|
|
242621
|
-
events: exports_external.array(exports_external.string()),
|
|
242622
|
-
resource_id: exports_external.string().nullable().optional(),
|
|
242623
|
-
trigger_conditions: TriggerConditionsSchema.nullable().optional()
|
|
242624
|
-
});
|
|
242625
242598
|
var AutomationSchema = exports_external.union([
|
|
242626
242599
|
ScheduledOneTimeSchema,
|
|
242627
242600
|
ScheduledCronSchema,
|
|
242628
242601
|
ScheduledSimpleSchema,
|
|
242629
|
-
EntityAutomationSchema
|
|
242630
|
-
ConnectorAutomationSchema
|
|
242602
|
+
EntityAutomationSchema
|
|
242631
242603
|
]);
|
|
242632
242604
|
var FunctionConfigSchema = exports_external.object({
|
|
242633
242605
|
name: FunctionNameSchema,
|
|
@@ -243272,6 +243244,7 @@ var package_default = {
|
|
|
243272
243244
|
typescript: "^5.7.2",
|
|
243273
243245
|
vitest: "^4.0.16",
|
|
243274
243246
|
yaml: "^2.8.2",
|
|
243247
|
+
qs: "^6.12.3",
|
|
243275
243248
|
zod: "^4.3.5"
|
|
243276
243249
|
},
|
|
243277
243250
|
engines: {
|
|
@@ -252784,9 +252757,12 @@ function getTypesCommand() {
|
|
|
252784
252757
|
return new Command("types").description("Manage TypeScript type generation").addCommand(getTypesGenerateCommand());
|
|
252785
252758
|
}
|
|
252786
252759
|
|
|
252760
|
+
// src/cli/commands/dev.ts
|
|
252761
|
+
import process21 from "node:process";
|
|
252762
|
+
|
|
252787
252763
|
// src/cli/dev/dev-server/main.ts
|
|
252788
252764
|
var import_cors = __toESM(require_lib4(), 1);
|
|
252789
|
-
var
|
|
252765
|
+
var import_express6 = __toESM(require_express(), 1);
|
|
252790
252766
|
import { dirname as dirname16, join as join23 } from "node:path";
|
|
252791
252767
|
|
|
252792
252768
|
// ../../node_modules/get-port/index.js
|
|
@@ -253345,7 +253321,9 @@ class Validator {
|
|
|
253345
253321
|
}
|
|
253346
253322
|
|
|
253347
253323
|
// src/cli/dev/dev-server/db/database.ts
|
|
253324
|
+
var PRIVATE_COLLECTION_PREFIX = "$";
|
|
253348
253325
|
var USER_COLLECTION = "user";
|
|
253326
|
+
var PRIVATE_USER_COLLECTION = PRIVATE_COLLECTION_PREFIX + USER_COLLECTION;
|
|
253349
253327
|
|
|
253350
253328
|
class Database {
|
|
253351
253329
|
collections = new Map;
|
|
@@ -253367,6 +253345,7 @@ class Database {
|
|
|
253367
253345
|
this.schemas.set(USER_COLLECTION, this.buildUserSchema(userEntity));
|
|
253368
253346
|
const collection = new import_nedb.default;
|
|
253369
253347
|
this.collections.set(USER_COLLECTION, collection);
|
|
253348
|
+
this.collections.set(PRIVATE_USER_COLLECTION, new import_nedb.default);
|
|
253370
253349
|
const userInfo = await readAuth();
|
|
253371
253350
|
const now = getNowISOTimestamp();
|
|
253372
253351
|
await collection.insertAsync({
|
|
@@ -253408,7 +253387,9 @@ class Database {
|
|
|
253408
253387
|
return this.collections.get(this.normalizeName(name2));
|
|
253409
253388
|
}
|
|
253410
253389
|
getCollectionNames() {
|
|
253411
|
-
return Array.from(this.collections.keys())
|
|
253390
|
+
return Array.from(this.collections.keys()).filter((name2) => {
|
|
253391
|
+
return !name2.startsWith(PRIVATE_COLLECTION_PREFIX);
|
|
253392
|
+
});
|
|
253412
253393
|
}
|
|
253413
253394
|
dropAll() {
|
|
253414
253395
|
for (const collection of this.collections.values()) {
|
|
@@ -253472,15 +253453,228 @@ function broadcastEntityEvent(io6, appId, entityName, event) {
|
|
|
253472
253453
|
});
|
|
253473
253454
|
}
|
|
253474
253455
|
|
|
253475
|
-
// src/cli/dev/dev-server/routes/
|
|
253476
|
-
var import_express3 = __toESM(require_express(), 1);
|
|
253477
|
-
|
|
253478
|
-
// src/cli/dev/dev-server/routes/entities/entities-user-router.ts
|
|
253456
|
+
// src/cli/dev/dev-server/routes/auth-router.ts
|
|
253479
253457
|
var import_express2 = __toESM(require_express(), 1);
|
|
253480
253458
|
var import_jsonwebtoken = __toESM(require_jsonwebtoken(), 1);
|
|
253481
|
-
|
|
253459
|
+
import { randomInt } from "node:crypto";
|
|
253460
|
+
var LOCAL_DEV_SECRET = "LOCAL_DEV_SECRET";
|
|
253461
|
+
var generateCode = () => {
|
|
253462
|
+
return randomInt(1e5, 1e6).toString();
|
|
253463
|
+
};
|
|
253464
|
+
var createJwtToken = (email3) => {
|
|
253465
|
+
return import_jsonwebtoken.default.sign({ sub: email3 }, LOCAL_DEV_SECRET, {
|
|
253466
|
+
expiresIn: "360d"
|
|
253467
|
+
});
|
|
253468
|
+
};
|
|
253469
|
+
var LoginBody = object({ email: email2(), password: string2() });
|
|
253470
|
+
var VerifyOtpBody = object({ email: email2(), otp_code: string2() });
|
|
253471
|
+
function createAuthRouter(db2, logger2) {
|
|
253482
253472
|
const router = import_express2.Router({ mergeParams: true });
|
|
253483
253473
|
const parseBody = import_express2.json();
|
|
253474
|
+
router.post("/login", parseBody, async (req, res) => {
|
|
253475
|
+
const { email: email3, password } = LoginBody.parse(req.body);
|
|
253476
|
+
const result = await db2.getCollection(USER_COLLECTION)?.findOneAsync({ email: email3 });
|
|
253477
|
+
if (result) {
|
|
253478
|
+
const privateUserData = await db2.getCollection(PRIVATE_USER_COLLECTION)?.findOneAsync({ email: email3 });
|
|
253479
|
+
if (result.role === "admin" || privateUserData?.password === password) {
|
|
253480
|
+
res.json({
|
|
253481
|
+
access_token: createJwtToken(email3),
|
|
253482
|
+
success: true,
|
|
253483
|
+
user: {}
|
|
253484
|
+
});
|
|
253485
|
+
} else {
|
|
253486
|
+
res.status(400).json({
|
|
253487
|
+
detail: "Invalid email or password",
|
|
253488
|
+
error_type: "HTTPException",
|
|
253489
|
+
message: "Invalid email or password",
|
|
253490
|
+
request_id: null,
|
|
253491
|
+
traceback: ""
|
|
253492
|
+
});
|
|
253493
|
+
}
|
|
253494
|
+
return;
|
|
253495
|
+
}
|
|
253496
|
+
res.status(401).json({ error: "Unauthorized" });
|
|
253497
|
+
});
|
|
253498
|
+
router.post("/register", parseBody, async (req, res) => {
|
|
253499
|
+
const { email: email3, password } = LoginBody.parse(req.body);
|
|
253500
|
+
if ((password || "").length < 8) {
|
|
253501
|
+
res.status(400).json({
|
|
253502
|
+
detail: "Password must be at least 8 characters long",
|
|
253503
|
+
error_type: "HTTPException",
|
|
253504
|
+
message: "Password must be at least 8 characters long",
|
|
253505
|
+
request_id: null,
|
|
253506
|
+
traceback: ""
|
|
253507
|
+
});
|
|
253508
|
+
return;
|
|
253509
|
+
}
|
|
253510
|
+
const result = await db2.getCollection(USER_COLLECTION)?.findOneAsync({ email: email3 });
|
|
253511
|
+
if (result) {
|
|
253512
|
+
res.status(400).json({
|
|
253513
|
+
detail: "A user with this email already exists",
|
|
253514
|
+
error_type: "HTTPException",
|
|
253515
|
+
message: "A user with this email already exists",
|
|
253516
|
+
request_id: null,
|
|
253517
|
+
traceback: ""
|
|
253518
|
+
});
|
|
253519
|
+
return;
|
|
253520
|
+
}
|
|
253521
|
+
const privateUserCollection = db2.getCollection(PRIVATE_USER_COLLECTION);
|
|
253522
|
+
const privateUserData = await privateUserCollection?.findOneAsync({
|
|
253523
|
+
email: email3
|
|
253524
|
+
});
|
|
253525
|
+
const otpCode = generateCode();
|
|
253526
|
+
const id2 = privateUserData ? privateUserData.id : nanoid3();
|
|
253527
|
+
if (!privateUserData) {
|
|
253528
|
+
await privateUserCollection?.insertAsync({
|
|
253529
|
+
id: id2,
|
|
253530
|
+
email: email3,
|
|
253531
|
+
otpCode,
|
|
253532
|
+
password,
|
|
253533
|
+
createdAt: Date.now()
|
|
253534
|
+
});
|
|
253535
|
+
} else {
|
|
253536
|
+
await privateUserCollection?.updateAsync({
|
|
253537
|
+
email: email3
|
|
253538
|
+
}, {
|
|
253539
|
+
$set: {
|
|
253540
|
+
otpCode,
|
|
253541
|
+
createdAt: Date.now()
|
|
253542
|
+
}
|
|
253543
|
+
});
|
|
253544
|
+
}
|
|
253545
|
+
logger2.log(theme.styles.info(`
|
|
253546
|
+
In order to complete registration use this verification code: ${otpCode}
|
|
253547
|
+
`));
|
|
253548
|
+
res.json({
|
|
253549
|
+
id: id2,
|
|
253550
|
+
message: "Registration successful. Please check your email for the verification code.",
|
|
253551
|
+
otp_expires_in_minutes: 10
|
|
253552
|
+
});
|
|
253553
|
+
});
|
|
253554
|
+
router.post("/verify-otp", parseBody, async (req, res) => {
|
|
253555
|
+
const { email: email3, otp_code } = VerifyOtpBody.parse(req.body);
|
|
253556
|
+
const privateUserCollection = db2.getCollection(PRIVATE_USER_COLLECTION);
|
|
253557
|
+
const privateUserData = await privateUserCollection?.findOneAsync({
|
|
253558
|
+
email: email3
|
|
253559
|
+
});
|
|
253560
|
+
if (privateUserData && privateUserData.otpCode === otp_code) {
|
|
253561
|
+
if (+Date.now() - privateUserData.createdAt < 10 * 60 * 1000) {
|
|
253562
|
+
await privateUserCollection?.updateAsync({
|
|
253563
|
+
email: email3
|
|
253564
|
+
}, {
|
|
253565
|
+
$unset: { otpCode: true }
|
|
253566
|
+
});
|
|
253567
|
+
const collection = db2.getCollection(USER_COLLECTION);
|
|
253568
|
+
const now = getNowISOTimestamp();
|
|
253569
|
+
const nameFromEmailMatch = /^([^@]+)/.exec(email3);
|
|
253570
|
+
const fullName = nameFromEmailMatch ? nameFromEmailMatch[1] : email3;
|
|
253571
|
+
await collection?.insertAsync({
|
|
253572
|
+
id: privateUserData.id,
|
|
253573
|
+
email: email3,
|
|
253574
|
+
full_name: fullName,
|
|
253575
|
+
is_service: false,
|
|
253576
|
+
is_verified: true,
|
|
253577
|
+
disabled: null,
|
|
253578
|
+
role: "user",
|
|
253579
|
+
collaborator_role: "editor",
|
|
253580
|
+
created_date: now,
|
|
253581
|
+
updated_date: now
|
|
253582
|
+
});
|
|
253583
|
+
res.json({
|
|
253584
|
+
id: privateUserData.id,
|
|
253585
|
+
access_token: createJwtToken(email3),
|
|
253586
|
+
message: "Email verified successfully. You are now logged in.",
|
|
253587
|
+
success: true
|
|
253588
|
+
});
|
|
253589
|
+
} else {
|
|
253590
|
+
res.status(400).json({
|
|
253591
|
+
detail: "Verification code has expired",
|
|
253592
|
+
error_type: "HTTPException",
|
|
253593
|
+
message: "Verification code has expired",
|
|
253594
|
+
request_id: null,
|
|
253595
|
+
traceback: ""
|
|
253596
|
+
});
|
|
253597
|
+
}
|
|
253598
|
+
} else {
|
|
253599
|
+
const appId = req.params.appId;
|
|
253600
|
+
res.status(500).json({
|
|
253601
|
+
detail: `{'email': '${email3}', 'app_id': '${appId}}'} -> Object not found`,
|
|
253602
|
+
error_type: "ObjectNotFoundError",
|
|
253603
|
+
message: `{'email': '${email3}', 'app_id': '${appId}}'} -> Object not found`,
|
|
253604
|
+
request_id: null,
|
|
253605
|
+
traceback: ""
|
|
253606
|
+
});
|
|
253607
|
+
}
|
|
253608
|
+
});
|
|
253609
|
+
return router;
|
|
253610
|
+
}
|
|
253611
|
+
|
|
253612
|
+
// src/cli/dev/dev-server/routes/entities/entities-router.ts
|
|
253613
|
+
var import_express4 = __toESM(require_express(), 1);
|
|
253614
|
+
|
|
253615
|
+
// src/cli/dev/dev-server/db/entity-queries.ts
|
|
253616
|
+
function parseSort(sort) {
|
|
253617
|
+
if (!sort) {
|
|
253618
|
+
return;
|
|
253619
|
+
}
|
|
253620
|
+
if (sort.startsWith("-")) {
|
|
253621
|
+
return { [sort.slice(1)]: -1 };
|
|
253622
|
+
}
|
|
253623
|
+
return { [sort]: 1 };
|
|
253624
|
+
}
|
|
253625
|
+
function parseFields(fields) {
|
|
253626
|
+
if (!fields) {
|
|
253627
|
+
return;
|
|
253628
|
+
}
|
|
253629
|
+
const projection = {};
|
|
253630
|
+
for (const field of fields.split(",")) {
|
|
253631
|
+
const trimmed = field.trim();
|
|
253632
|
+
if (trimmed) {
|
|
253633
|
+
projection[trimmed] = 1;
|
|
253634
|
+
}
|
|
253635
|
+
}
|
|
253636
|
+
return Object.keys(projection).length > 0 ? projection : undefined;
|
|
253637
|
+
}
|
|
253638
|
+
var queryEntity = async (collection, reqQuery) => {
|
|
253639
|
+
const { sort, limit, skip: skip2, fields, q: q13 } = reqQuery;
|
|
253640
|
+
let query = {};
|
|
253641
|
+
if (q13 && typeof q13 === "string") {
|
|
253642
|
+
try {
|
|
253643
|
+
query = JSON.parse(q13);
|
|
253644
|
+
} catch {
|
|
253645
|
+
throw new InvalidInputError("Invalid query parameter 'q'");
|
|
253646
|
+
}
|
|
253647
|
+
}
|
|
253648
|
+
let cursor3 = collection.findAsync(query);
|
|
253649
|
+
const sortObj = parseSort(sort);
|
|
253650
|
+
if (sortObj) {
|
|
253651
|
+
cursor3 = cursor3.sort(sortObj);
|
|
253652
|
+
}
|
|
253653
|
+
if (skip2) {
|
|
253654
|
+
const skipNum = Number.parseInt(skip2, 10);
|
|
253655
|
+
if (!Number.isNaN(skipNum)) {
|
|
253656
|
+
cursor3 = cursor3.skip(skipNum);
|
|
253657
|
+
}
|
|
253658
|
+
}
|
|
253659
|
+
if (limit) {
|
|
253660
|
+
const limitNum = Number.parseInt(limit, 10);
|
|
253661
|
+
if (!Number.isNaN(limitNum)) {
|
|
253662
|
+
cursor3 = cursor3.limit(limitNum);
|
|
253663
|
+
}
|
|
253664
|
+
}
|
|
253665
|
+
const projection = parseFields(fields);
|
|
253666
|
+
if (projection) {
|
|
253667
|
+
cursor3 = cursor3.projection(projection);
|
|
253668
|
+
}
|
|
253669
|
+
return cursor3;
|
|
253670
|
+
};
|
|
253671
|
+
|
|
253672
|
+
// src/cli/dev/dev-server/routes/entities/entities-user-router.ts
|
|
253673
|
+
var import_express3 = __toESM(require_express(), 1);
|
|
253674
|
+
var import_jsonwebtoken2 = __toESM(require_jsonwebtoken(), 1);
|
|
253675
|
+
function createUserRouter(db2, logger2) {
|
|
253676
|
+
const router = import_express3.Router({ mergeParams: true });
|
|
253677
|
+
const parseBody = import_express3.json();
|
|
253484
253678
|
function withAuth(handler) {
|
|
253485
253679
|
return async (req, res) => {
|
|
253486
253680
|
const auth2 = req.headers.authorization;
|
|
@@ -253489,7 +253683,7 @@ function createUserRouter(db2, logger2) {
|
|
|
253489
253683
|
return;
|
|
253490
253684
|
}
|
|
253491
253685
|
try {
|
|
253492
|
-
const { payload } =
|
|
253686
|
+
const { payload } = import_jsonwebtoken2.default.decode(auth2.replace("Bearer ", ""), { complete: true }) ?? {};
|
|
253493
253687
|
const result = await db2.getCollection(USER_COLLECTION)?.findOneAsync({ email: payload?.sub });
|
|
253494
253688
|
if (!result) {
|
|
253495
253689
|
res.status(404).json({ error: "Unable to read data for the current user" });
|
|
@@ -253522,6 +253716,28 @@ function createUserRouter(db2, logger2) {
|
|
|
253522
253716
|
...req.body
|
|
253523
253717
|
});
|
|
253524
253718
|
}));
|
|
253719
|
+
router.get("/", withAuth(async (req, res, currentUser) => {
|
|
253720
|
+
const collection = db2.getCollection(USER_COLLECTION);
|
|
253721
|
+
if (!collection) {
|
|
253722
|
+
res.status(404).json({ error: `Entity "${USER_COLLECTION}" not found` });
|
|
253723
|
+
return;
|
|
253724
|
+
}
|
|
253725
|
+
try {
|
|
253726
|
+
if (currentUser.role === "admin") {
|
|
253727
|
+
const result = await queryEntity(collection, req.query);
|
|
253728
|
+
res.json(stripInternalFields(result));
|
|
253729
|
+
} else {
|
|
253730
|
+
res.json([stripInternalFields(currentUser)]);
|
|
253731
|
+
}
|
|
253732
|
+
} catch (error48) {
|
|
253733
|
+
if (error48 instanceof InvalidInputError) {
|
|
253734
|
+
res.status(400).json({ error: error48.message });
|
|
253735
|
+
} else {
|
|
253736
|
+
logger2.error(`Error in GET /${USER_COLLECTION}:`, error48);
|
|
253737
|
+
res.status(500).json({ error: "Internal server error" });
|
|
253738
|
+
}
|
|
253739
|
+
}
|
|
253740
|
+
}));
|
|
253525
253741
|
router.post("/bulk", async (_req, res) => {
|
|
253526
253742
|
res.json({});
|
|
253527
253743
|
});
|
|
@@ -253571,31 +253787,9 @@ function createUserRouter(db2, logger2) {
|
|
|
253571
253787
|
}
|
|
253572
253788
|
|
|
253573
253789
|
// src/cli/dev/dev-server/routes/entities/entities-router.ts
|
|
253574
|
-
function parseSort(sort) {
|
|
253575
|
-
if (!sort) {
|
|
253576
|
-
return;
|
|
253577
|
-
}
|
|
253578
|
-
if (sort.startsWith("-")) {
|
|
253579
|
-
return { [sort.slice(1)]: -1 };
|
|
253580
|
-
}
|
|
253581
|
-
return { [sort]: 1 };
|
|
253582
|
-
}
|
|
253583
|
-
function parseFields(fields) {
|
|
253584
|
-
if (!fields) {
|
|
253585
|
-
return;
|
|
253586
|
-
}
|
|
253587
|
-
const projection = {};
|
|
253588
|
-
for (const field of fields.split(",")) {
|
|
253589
|
-
const trimmed = field.trim();
|
|
253590
|
-
if (trimmed) {
|
|
253591
|
-
projection[trimmed] = 1;
|
|
253592
|
-
}
|
|
253593
|
-
}
|
|
253594
|
-
return Object.keys(projection).length > 0 ? projection : undefined;
|
|
253595
|
-
}
|
|
253596
253790
|
async function createEntityRoutes(db2, logger2, broadcast) {
|
|
253597
|
-
const router =
|
|
253598
|
-
const parseBody =
|
|
253791
|
+
const router = import_express4.Router({ mergeParams: true });
|
|
253792
|
+
const parseBody = import_express4.json();
|
|
253599
253793
|
function withCollection(handler) {
|
|
253600
253794
|
return async (req, res) => {
|
|
253601
253795
|
const collection = db2.getCollection(req.params.entityName);
|
|
@@ -253640,42 +253834,14 @@ async function createEntityRoutes(db2, logger2, broadcast) {
|
|
|
253640
253834
|
router.get("/:entityName", withCollection(async (req, res, collection) => {
|
|
253641
253835
|
const { entityName } = req.params;
|
|
253642
253836
|
try {
|
|
253643
|
-
|
|
253644
|
-
let query = {};
|
|
253645
|
-
if (q13 && typeof q13 === "string") {
|
|
253646
|
-
try {
|
|
253647
|
-
query = JSON.parse(q13);
|
|
253648
|
-
} catch {
|
|
253649
|
-
res.status(400).json({ error: "Invalid query parameter 'q'" });
|
|
253650
|
-
return;
|
|
253651
|
-
}
|
|
253652
|
-
}
|
|
253653
|
-
let cursor3 = collection.findAsync(query);
|
|
253654
|
-
const sortObj = parseSort(sort);
|
|
253655
|
-
if (sortObj) {
|
|
253656
|
-
cursor3 = cursor3.sort(sortObj);
|
|
253657
|
-
}
|
|
253658
|
-
if (skip2) {
|
|
253659
|
-
const skipNum = Number.parseInt(skip2, 10);
|
|
253660
|
-
if (!Number.isNaN(skipNum)) {
|
|
253661
|
-
cursor3 = cursor3.skip(skipNum);
|
|
253662
|
-
}
|
|
253663
|
-
}
|
|
253664
|
-
if (limit) {
|
|
253665
|
-
const limitNum = Number.parseInt(limit, 10);
|
|
253666
|
-
if (!Number.isNaN(limitNum)) {
|
|
253667
|
-
cursor3 = cursor3.limit(limitNum);
|
|
253668
|
-
}
|
|
253669
|
-
}
|
|
253670
|
-
const projection = parseFields(fields);
|
|
253671
|
-
if (projection) {
|
|
253672
|
-
cursor3 = cursor3.projection(projection);
|
|
253673
|
-
}
|
|
253674
|
-
const docs = await cursor3;
|
|
253675
|
-
res.json(stripInternalFields(docs));
|
|
253837
|
+
res.json(stripInternalFields(await queryEntity(collection, req.query)));
|
|
253676
253838
|
} catch (error48) {
|
|
253677
|
-
|
|
253678
|
-
|
|
253839
|
+
if (error48 instanceof InvalidInputError) {
|
|
253840
|
+
res.status(400).json({ error: error48.message });
|
|
253841
|
+
} else {
|
|
253842
|
+
logger2.error(`Error in GET /${entityName}:`, error48);
|
|
253843
|
+
res.status(500).json({ error: "Internal server error" });
|
|
253844
|
+
}
|
|
253679
253845
|
}
|
|
253680
253846
|
}));
|
|
253681
253847
|
router.post("/:entityName", parseBody, withCollection(async (req, res, collection) => {
|
|
@@ -253794,7 +253960,7 @@ async function createEntityRoutes(db2, logger2, broadcast) {
|
|
|
253794
253960
|
}
|
|
253795
253961
|
|
|
253796
253962
|
// src/cli/dev/dev-server/routes/integrations.ts
|
|
253797
|
-
var
|
|
253963
|
+
var import_express5 = __toESM(require_express(), 1);
|
|
253798
253964
|
var import_multer = __toESM(require_multer(), 1);
|
|
253799
253965
|
import { createHash, randomUUID as randomUUID4 } from "node:crypto";
|
|
253800
253966
|
import fs28 from "node:fs";
|
|
@@ -253803,8 +253969,8 @@ function createFileToken(fileUri) {
|
|
|
253803
253969
|
return createHash("sha256").update(fileUri).digest("hex");
|
|
253804
253970
|
}
|
|
253805
253971
|
function createIntegrationRoutes(mediaFilesDir, baseUrl, remoteProxy, logger2) {
|
|
253806
|
-
const router =
|
|
253807
|
-
const parseBody =
|
|
253972
|
+
const router = import_express5.Router({ mergeParams: true });
|
|
253973
|
+
const parseBody = import_express5.json();
|
|
253808
253974
|
const privateFilesDir = path18.join(mediaFilesDir, "private");
|
|
253809
253975
|
fs28.mkdirSync(mediaFilesDir, { recursive: true });
|
|
253810
253976
|
fs28.mkdirSync(privateFilesDir, { recursive: true });
|
|
@@ -253874,7 +254040,7 @@ function createIntegrationRoutes(mediaFilesDir, baseUrl, remoteProxy, logger2) {
|
|
|
253874
254040
|
return router;
|
|
253875
254041
|
}
|
|
253876
254042
|
function createCustomIntegrationRoutes(remoteProxy, logger2) {
|
|
253877
|
-
const router =
|
|
254043
|
+
const router = import_express5.Router({ mergeParams: true });
|
|
253878
254044
|
router.post("/:slug/:operationId", (req, res, next) => {
|
|
253879
254045
|
logger2.warn(`"${req.originalUrl}" is not supported in local development, passing call to production`);
|
|
253880
254046
|
req.url = req.originalUrl;
|
|
@@ -255587,7 +255753,7 @@ async function createDevServer(options8) {
|
|
|
255587
255753
|
const port = userPort ?? await getPorts({ port: DEFAULT_PORT });
|
|
255588
255754
|
const baseUrl = `http://localhost:${port}`;
|
|
255589
255755
|
const { functions, entities, project: project2 } = await options8.loadResources();
|
|
255590
|
-
const app =
|
|
255756
|
+
const app = import_express6.default();
|
|
255591
255757
|
const remoteProxy = import_http_proxy_middleware2.createProxyMiddleware({
|
|
255592
255758
|
target: BASE44_APP_URL,
|
|
255593
255759
|
changeOrigin: true
|
|
@@ -255619,6 +255785,8 @@ async function createDevServer(options8) {
|
|
|
255619
255785
|
let emitEntityEvent = () => {};
|
|
255620
255786
|
const entityRoutes = await createEntityRoutes(db2, devLogger, (...args) => emitEntityEvent(...args));
|
|
255621
255787
|
app.use("/api/apps/:appId/entities", entityRoutes);
|
|
255788
|
+
const authRouter = createAuthRouter(db2, devLogger);
|
|
255789
|
+
app.use("/api/apps/:appId/auth", authRouter);
|
|
255622
255790
|
const { path: mediaFilesDir } = await $dir();
|
|
255623
255791
|
app.use("/media/private/:fileUri", (req, res, next) => {
|
|
255624
255792
|
const { fileUri } = req.params;
|
|
@@ -255638,13 +255806,15 @@ async function createDevServer(options8) {
|
|
|
255638
255806
|
}
|
|
255639
255807
|
next();
|
|
255640
255808
|
});
|
|
255641
|
-
app.use("/media",
|
|
255809
|
+
app.use("/media", import_express6.default.static(mediaFilesDir));
|
|
255642
255810
|
const integrationRoutes = createIntegrationRoutes(mediaFilesDir, baseUrl, remoteProxy, devLogger);
|
|
255643
255811
|
app.use("/api/apps/:appId/integration-endpoints", integrationRoutes);
|
|
255644
255812
|
const customIntegrationRoutes = createCustomIntegrationRoutes(remoteProxy, devLogger);
|
|
255645
255813
|
app.use("/api/apps/:appId/integrations/custom", customIntegrationRoutes);
|
|
255646
255814
|
app.use((req, res, next) => {
|
|
255647
|
-
|
|
255815
|
+
if (!req.originalUrl.endsWith("analytics/track/batch")) {
|
|
255816
|
+
devLogger.warn(`"${req.originalUrl}" is not supported in local development, passing call to production`);
|
|
255817
|
+
}
|
|
255648
255818
|
remoteProxy(req, res, next);
|
|
255649
255819
|
});
|
|
255650
255820
|
const server = await new Promise((resolve8, reject) => {
|
|
@@ -255715,6 +255885,7 @@ async function devAction({ log }, options8) {
|
|
|
255715
255885
|
const { port: resolvedPort } = await createDevServer({
|
|
255716
255886
|
log,
|
|
255717
255887
|
port,
|
|
255888
|
+
cwd: process21.cwd(),
|
|
255718
255889
|
denoWrapperPath: getDenoWrapperPath(),
|
|
255719
255890
|
loadResources: async () => {
|
|
255720
255891
|
const { functions, entities, project: project2 } = await readProjectConfig();
|
|
@@ -260222,4 +260393,4 @@ export {
|
|
|
260222
260393
|
CLIExitError
|
|
260223
260394
|
};
|
|
260224
260395
|
|
|
260225
|
-
//# debugId=
|
|
260396
|
+
//# debugId=87279C94ABAC181364756E2164756E21
|