@base44-preview/cli 0.0.50-pr.481.773d5d4 → 0.0.50-pr.482.7d46c5c
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 +137 -502
- package/dist/cli/index.js.map +11 -14
- package/package.json +1 -1
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) {
|
|
@@ -235042,8 +235041,8 @@ var TOKEN_REFRESH_BUFFER_MS = 60 * 1000;
|
|
|
235042
235041
|
var refreshPromise = null;
|
|
235043
235042
|
async function readAuth() {
|
|
235044
235043
|
try {
|
|
235045
|
-
const
|
|
235046
|
-
const result = AuthDataSchema.safeParse(
|
|
235044
|
+
const parsed = await readJsonFile(getAuthFilePath());
|
|
235045
|
+
const result = AuthDataSchema.safeParse(parsed);
|
|
235047
235046
|
if (!result.success) {
|
|
235048
235047
|
throw new SchemaValidationError("Invalid authentication data", result.error, getAuthFilePath());
|
|
235049
235048
|
}
|
|
@@ -242595,11 +242594,51 @@ var EntityAutomationSchema = AutomationBaseSchema.extend({
|
|
|
242595
242594
|
entity_name: exports_external.string().min(1, "Entity name cannot be empty"),
|
|
242596
242595
|
event_types: exports_external.array(exports_external.enum(["create", "update", "delete"])).min(1, "At least one event type is required")
|
|
242597
242596
|
});
|
|
242597
|
+
var KnownConditionOperators = [
|
|
242598
|
+
"equals",
|
|
242599
|
+
"not_equals",
|
|
242600
|
+
"gt",
|
|
242601
|
+
"gte",
|
|
242602
|
+
"lt",
|
|
242603
|
+
"lte",
|
|
242604
|
+
"contains",
|
|
242605
|
+
"not_contains",
|
|
242606
|
+
"starts_with",
|
|
242607
|
+
"ends_with",
|
|
242608
|
+
"in_list",
|
|
242609
|
+
"not_in_list",
|
|
242610
|
+
"exists",
|
|
242611
|
+
"not_exists",
|
|
242612
|
+
"is_empty",
|
|
242613
|
+
"is_not_empty"
|
|
242614
|
+
];
|
|
242615
|
+
var ConditionOperatorSchema = exports_external.union([
|
|
242616
|
+
exports_external.enum(KnownConditionOperators),
|
|
242617
|
+
exports_external.string().min(1)
|
|
242618
|
+
]);
|
|
242619
|
+
var TriggerConditionSchema = exports_external.object({
|
|
242620
|
+
field: exports_external.string().min(1),
|
|
242621
|
+
operator: ConditionOperatorSchema,
|
|
242622
|
+
value: exports_external.unknown().nullable().optional()
|
|
242623
|
+
});
|
|
242624
|
+
var TriggerLogicSchema = exports_external.enum(["and", "or"]);
|
|
242625
|
+
var TriggerConditionGroupSchema = exports_external.lazy(() => exports_external.object({
|
|
242626
|
+
logic: TriggerLogicSchema.optional(),
|
|
242627
|
+
conditions: exports_external.array(exports_external.union([TriggerConditionSchema, TriggerConditionGroupSchema])).min(1)
|
|
242628
|
+
}));
|
|
242629
|
+
var ConnectorAutomationSchema = AutomationBaseSchema.extend({
|
|
242630
|
+
type: exports_external.literal("connector"),
|
|
242631
|
+
integration_type: IntegrationTypeSchema,
|
|
242632
|
+
events: exports_external.array(exports_external.string()),
|
|
242633
|
+
resource_id: exports_external.string().nullable().optional(),
|
|
242634
|
+
trigger_conditions: TriggerConditionGroupSchema.nullable().optional()
|
|
242635
|
+
});
|
|
242598
242636
|
var AutomationSchema = exports_external.union([
|
|
242599
242637
|
ScheduledOneTimeSchema,
|
|
242600
242638
|
ScheduledCronSchema,
|
|
242601
242639
|
ScheduledSimpleSchema,
|
|
242602
|
-
EntityAutomationSchema
|
|
242640
|
+
EntityAutomationSchema,
|
|
242641
|
+
ConnectorAutomationSchema
|
|
242603
242642
|
]);
|
|
242604
242643
|
var FunctionConfigSchema = exports_external.object({
|
|
242605
242644
|
name: FunctionNameSchema,
|
|
@@ -243211,12 +243250,10 @@ var package_default = {
|
|
|
243211
243250
|
"@types/ejs": "^3.1.5",
|
|
243212
243251
|
"@types/express": "^5.0.6",
|
|
243213
243252
|
"@types/json-schema": "^7.0.15",
|
|
243214
|
-
"@types/jsonwebtoken": "^9.0.10",
|
|
243215
243253
|
"@types/lodash": "^4.17.24",
|
|
243216
243254
|
"@types/multer": "^2.0.0",
|
|
243217
243255
|
"@types/node": "^22.10.5",
|
|
243218
243256
|
"@vercel/detect-agent": "^1.1.0",
|
|
243219
|
-
outdent: "^0.8.0",
|
|
243220
243257
|
chalk: "^5.6.2",
|
|
243221
243258
|
chokidar: "^5.0.0",
|
|
243222
243259
|
commander: "^12.1.0",
|
|
@@ -243231,7 +243268,6 @@ var package_default = {
|
|
|
243231
243268
|
globby: "^16.1.0",
|
|
243232
243269
|
"http-proxy-middleware": "^3.0.5",
|
|
243233
243270
|
"json-schema-to-typescript": "^15.0.4",
|
|
243234
|
-
jsonwebtoken: "^9.0.3",
|
|
243235
243271
|
json5: "^2.2.3",
|
|
243236
243272
|
ky: "^1.14.2",
|
|
243237
243273
|
lodash: "^4.17.23",
|
|
@@ -243247,7 +243283,6 @@ var package_default = {
|
|
|
243247
243283
|
typescript: "^5.7.2",
|
|
243248
243284
|
vitest: "^4.0.16",
|
|
243249
243285
|
yaml: "^2.8.2",
|
|
243250
|
-
qs: "^6.12.3",
|
|
243251
243286
|
zod: "^4.3.5"
|
|
243252
243287
|
},
|
|
243253
243288
|
engines: {
|
|
@@ -252760,12 +252795,9 @@ function getTypesCommand() {
|
|
|
252760
252795
|
return new Command("types").description("Manage TypeScript type generation").addCommand(getTypesGenerateCommand());
|
|
252761
252796
|
}
|
|
252762
252797
|
|
|
252763
|
-
// src/cli/commands/dev.ts
|
|
252764
|
-
import process21 from "node:process";
|
|
252765
|
-
|
|
252766
252798
|
// src/cli/dev/dev-server/main.ts
|
|
252767
252799
|
var import_cors = __toESM(require_lib4(), 1);
|
|
252768
|
-
var
|
|
252800
|
+
var import_express5 = __toESM(require_express(), 1);
|
|
252769
252801
|
import { dirname as dirname16, join as join23 } from "node:path";
|
|
252770
252802
|
|
|
252771
252803
|
// ../../node_modules/get-port/index.js
|
|
@@ -253329,9 +253361,7 @@ class Validator {
|
|
|
253329
253361
|
}
|
|
253330
253362
|
|
|
253331
253363
|
// src/cli/dev/dev-server/db/database.ts
|
|
253332
|
-
var PRIVATE_COLLECTION_PREFIX = "$";
|
|
253333
253364
|
var USER_COLLECTION = "user";
|
|
253334
|
-
var PRIVATE_USER_COLLECTION = PRIVATE_COLLECTION_PREFIX + USER_COLLECTION;
|
|
253335
253365
|
|
|
253336
253366
|
class Database {
|
|
253337
253367
|
collections = new Map;
|
|
@@ -253353,7 +253383,6 @@ class Database {
|
|
|
253353
253383
|
this.schemas.set(USER_COLLECTION, this.buildUserSchema(userEntity));
|
|
253354
253384
|
const collection = new import_nedb.default;
|
|
253355
253385
|
this.collections.set(USER_COLLECTION, collection);
|
|
253356
|
-
this.collections.set(PRIVATE_USER_COLLECTION, new import_nedb.default);
|
|
253357
253386
|
const userInfo = await readAuth();
|
|
253358
253387
|
const now = getNowISOTimestamp();
|
|
253359
253388
|
await collection.insertAsync({
|
|
@@ -253394,13 +253423,8 @@ class Database {
|
|
|
253394
253423
|
getCollection(name2) {
|
|
253395
253424
|
return this.collections.get(this.normalizeName(name2));
|
|
253396
253425
|
}
|
|
253397
|
-
getSchema(entityName) {
|
|
253398
|
-
return this.schemas.get(this.normalizeName(entityName));
|
|
253399
|
-
}
|
|
253400
253426
|
getCollectionNames() {
|
|
253401
|
-
return Array.from(this.collections.keys())
|
|
253402
|
-
return !name2.startsWith(PRIVATE_COLLECTION_PREFIX);
|
|
253403
|
-
});
|
|
253427
|
+
return Array.from(this.collections.keys());
|
|
253404
253428
|
}
|
|
253405
253429
|
dropAll() {
|
|
253406
253430
|
for (const collection of this.collections.values()) {
|
|
@@ -253464,339 +253488,15 @@ function broadcastEntityEvent(io6, appId, entityName, event) {
|
|
|
253464
253488
|
});
|
|
253465
253489
|
}
|
|
253466
253490
|
|
|
253467
|
-
// src/cli/dev/dev-server/routes/auth-router.ts
|
|
253468
|
-
var import_express2 = __toESM(require_express(), 1);
|
|
253469
|
-
var import_jsonwebtoken = __toESM(require_jsonwebtoken(), 1);
|
|
253470
|
-
import { randomInt } from "node:crypto";
|
|
253471
|
-
var LOCAL_DEV_SECRET = "LOCAL_DEV_SECRET";
|
|
253472
|
-
var generateCode = () => {
|
|
253473
|
-
return randomInt(1e5, 1e6).toString();
|
|
253474
|
-
};
|
|
253475
|
-
var createJwtToken = (email3) => {
|
|
253476
|
-
return import_jsonwebtoken.default.sign({ sub: email3 }, LOCAL_DEV_SECRET, {
|
|
253477
|
-
expiresIn: "360d"
|
|
253478
|
-
});
|
|
253479
|
-
};
|
|
253480
|
-
var LoginBody = object({ email: email2(), password: string2() });
|
|
253481
|
-
var VerifyOtpBody = object({ email: email2(), otp_code: string2() });
|
|
253482
|
-
function createAuthRouter(db2, logger2) {
|
|
253483
|
-
const router = import_express2.Router({ mergeParams: true });
|
|
253484
|
-
const parseBody = import_express2.json();
|
|
253485
|
-
router.post("/login", parseBody, async (req, res) => {
|
|
253486
|
-
const { email: email3, password } = LoginBody.parse(req.body);
|
|
253487
|
-
const result = await db2.getCollection(USER_COLLECTION)?.findOneAsync({ email: email3 });
|
|
253488
|
-
if (result) {
|
|
253489
|
-
const privateUserData = await db2.getCollection(PRIVATE_USER_COLLECTION)?.findOneAsync({ email: email3 });
|
|
253490
|
-
if (result.role === "admin" || privateUserData?.password === password) {
|
|
253491
|
-
res.json({
|
|
253492
|
-
access_token: createJwtToken(email3),
|
|
253493
|
-
success: true,
|
|
253494
|
-
user: {}
|
|
253495
|
-
});
|
|
253496
|
-
} else {
|
|
253497
|
-
res.status(400).json({
|
|
253498
|
-
detail: "Invalid email or password",
|
|
253499
|
-
error_type: "HTTPException",
|
|
253500
|
-
message: "Invalid email or password",
|
|
253501
|
-
request_id: null,
|
|
253502
|
-
traceback: ""
|
|
253503
|
-
});
|
|
253504
|
-
}
|
|
253505
|
-
return;
|
|
253506
|
-
}
|
|
253507
|
-
res.status(401).json({ error: "Unauthorized" });
|
|
253508
|
-
});
|
|
253509
|
-
router.post("/register", parseBody, async (req, res) => {
|
|
253510
|
-
const { email: email3, password } = LoginBody.parse(req.body);
|
|
253511
|
-
if ((password || "").length < 8) {
|
|
253512
|
-
res.status(400).json({
|
|
253513
|
-
detail: "Password must be at least 8 characters long",
|
|
253514
|
-
error_type: "HTTPException",
|
|
253515
|
-
message: "Password must be at least 8 characters long",
|
|
253516
|
-
request_id: null,
|
|
253517
|
-
traceback: ""
|
|
253518
|
-
});
|
|
253519
|
-
return;
|
|
253520
|
-
}
|
|
253521
|
-
const result = await db2.getCollection(USER_COLLECTION)?.findOneAsync({ email: email3 });
|
|
253522
|
-
if (result) {
|
|
253523
|
-
res.status(400).json({
|
|
253524
|
-
detail: "A user with this email already exists",
|
|
253525
|
-
error_type: "HTTPException",
|
|
253526
|
-
message: "A user with this email already exists",
|
|
253527
|
-
request_id: null,
|
|
253528
|
-
traceback: ""
|
|
253529
|
-
});
|
|
253530
|
-
return;
|
|
253531
|
-
}
|
|
253532
|
-
const privateUserCollection = db2.getCollection(PRIVATE_USER_COLLECTION);
|
|
253533
|
-
const privateUserData = await privateUserCollection?.findOneAsync({
|
|
253534
|
-
email: email3
|
|
253535
|
-
});
|
|
253536
|
-
const otpCode = generateCode();
|
|
253537
|
-
const id2 = privateUserData ? privateUserData.id : nanoid3();
|
|
253538
|
-
if (!privateUserData) {
|
|
253539
|
-
await privateUserCollection?.insertAsync({
|
|
253540
|
-
id: id2,
|
|
253541
|
-
email: email3,
|
|
253542
|
-
otpCode,
|
|
253543
|
-
password,
|
|
253544
|
-
createdAt: Date.now()
|
|
253545
|
-
});
|
|
253546
|
-
} else {
|
|
253547
|
-
await privateUserCollection?.updateAsync({
|
|
253548
|
-
email: email3
|
|
253549
|
-
}, {
|
|
253550
|
-
$set: {
|
|
253551
|
-
otpCode,
|
|
253552
|
-
createdAt: Date.now()
|
|
253553
|
-
}
|
|
253554
|
-
});
|
|
253555
|
-
}
|
|
253556
|
-
logger2.log(theme.styles.info(`
|
|
253557
|
-
In order to complete registration use this verification code: ${otpCode}
|
|
253558
|
-
`));
|
|
253559
|
-
res.json({
|
|
253560
|
-
id: id2,
|
|
253561
|
-
message: "Registration successful. Please check your email for the verification code.",
|
|
253562
|
-
otp_expires_in_minutes: 10
|
|
253563
|
-
});
|
|
253564
|
-
});
|
|
253565
|
-
router.post("/verify-otp", parseBody, async (req, res) => {
|
|
253566
|
-
const { email: email3, otp_code } = VerifyOtpBody.parse(req.body);
|
|
253567
|
-
const privateUserCollection = db2.getCollection(PRIVATE_USER_COLLECTION);
|
|
253568
|
-
const privateUserData = await privateUserCollection?.findOneAsync({
|
|
253569
|
-
email: email3
|
|
253570
|
-
});
|
|
253571
|
-
if (privateUserData && privateUserData.otpCode === otp_code) {
|
|
253572
|
-
if (+Date.now() - privateUserData.createdAt < 10 * 60 * 1000) {
|
|
253573
|
-
await privateUserCollection?.updateAsync({
|
|
253574
|
-
email: email3
|
|
253575
|
-
}, {
|
|
253576
|
-
$unset: { otpCode: true }
|
|
253577
|
-
});
|
|
253578
|
-
const collection = db2.getCollection(USER_COLLECTION);
|
|
253579
|
-
const now = getNowISOTimestamp();
|
|
253580
|
-
const nameFromEmailMatch = /^([^@]+)/.exec(email3);
|
|
253581
|
-
const fullName = nameFromEmailMatch ? nameFromEmailMatch[1] : email3;
|
|
253582
|
-
await collection?.insertAsync({
|
|
253583
|
-
id: privateUserData.id,
|
|
253584
|
-
email: email3,
|
|
253585
|
-
full_name: fullName,
|
|
253586
|
-
is_service: false,
|
|
253587
|
-
is_verified: true,
|
|
253588
|
-
disabled: null,
|
|
253589
|
-
role: "user",
|
|
253590
|
-
collaborator_role: "editor",
|
|
253591
|
-
created_date: now,
|
|
253592
|
-
updated_date: now
|
|
253593
|
-
});
|
|
253594
|
-
res.json({
|
|
253595
|
-
id: privateUserData.id,
|
|
253596
|
-
access_token: createJwtToken(email3),
|
|
253597
|
-
message: "Email verified successfully. You are now logged in.",
|
|
253598
|
-
success: true
|
|
253599
|
-
});
|
|
253600
|
-
} else {
|
|
253601
|
-
res.status(400).json({
|
|
253602
|
-
detail: "Verification code has expired",
|
|
253603
|
-
error_type: "HTTPException",
|
|
253604
|
-
message: "Verification code has expired",
|
|
253605
|
-
request_id: null,
|
|
253606
|
-
traceback: ""
|
|
253607
|
-
});
|
|
253608
|
-
}
|
|
253609
|
-
} else {
|
|
253610
|
-
const appId = req.params.appId;
|
|
253611
|
-
res.status(500).json({
|
|
253612
|
-
detail: `{'email': '${email3}', 'app_id': '${appId}}'} -> Object not found`,
|
|
253613
|
-
error_type: "ObjectNotFoundError",
|
|
253614
|
-
message: `{'email': '${email3}', 'app_id': '${appId}}'} -> Object not found`,
|
|
253615
|
-
request_id: null,
|
|
253616
|
-
traceback: ""
|
|
253617
|
-
});
|
|
253618
|
-
}
|
|
253619
|
-
});
|
|
253620
|
-
return router;
|
|
253621
|
-
}
|
|
253622
|
-
|
|
253623
253491
|
// src/cli/dev/dev-server/routes/entities/entities-router.ts
|
|
253624
|
-
var
|
|
253625
|
-
var import_jsonwebtoken3 = __toESM(require_jsonwebtoken(), 1);
|
|
253626
|
-
|
|
253627
|
-
// src/cli/dev/dev-server/db/rls.ts
|
|
253628
|
-
function resolveTemplate(value, user) {
|
|
253629
|
-
return value.replace(/\{\{user\.([\w.]+)\}\}/g, (_match, path18) => {
|
|
253630
|
-
if (path18.startsWith("data.")) {
|
|
253631
|
-
return String(user[path18.slice(5)] ?? "");
|
|
253632
|
-
}
|
|
253633
|
-
return String(user[path18] ?? "");
|
|
253634
|
-
});
|
|
253635
|
-
}
|
|
253636
|
-
function getRecordField(key2, record2) {
|
|
253637
|
-
if (key2.startsWith("data.")) {
|
|
253638
|
-
return record2[key2.slice(5)];
|
|
253639
|
-
}
|
|
253640
|
-
return record2[key2];
|
|
253641
|
-
}
|
|
253642
|
-
function evaluateOperator(recordValue, operator) {
|
|
253643
|
-
for (const [op2, opValue] of Object.entries(operator)) {
|
|
253644
|
-
switch (op2) {
|
|
253645
|
-
case "$in":
|
|
253646
|
-
if (!Array.isArray(opValue) || !opValue.includes(recordValue))
|
|
253647
|
-
return false;
|
|
253648
|
-
break;
|
|
253649
|
-
case "$nin":
|
|
253650
|
-
if (Array.isArray(opValue) && opValue.includes(recordValue))
|
|
253651
|
-
return false;
|
|
253652
|
-
break;
|
|
253653
|
-
case "$ne":
|
|
253654
|
-
if (recordValue === opValue)
|
|
253655
|
-
return false;
|
|
253656
|
-
break;
|
|
253657
|
-
case "$all":
|
|
253658
|
-
if (!Array.isArray(recordValue) || !Array.isArray(opValue))
|
|
253659
|
-
return false;
|
|
253660
|
-
if (!opValue.every((v10) => recordValue.includes(v10)))
|
|
253661
|
-
return false;
|
|
253662
|
-
break;
|
|
253663
|
-
}
|
|
253664
|
-
}
|
|
253665
|
-
return true;
|
|
253666
|
-
}
|
|
253667
|
-
function evaluateUserCondition(condition, user) {
|
|
253668
|
-
for (const [key2, expected] of Object.entries(condition)) {
|
|
253669
|
-
const userValue = key2.startsWith("data.") ? user[key2.slice(5)] : user[key2];
|
|
253670
|
-
if (typeof expected === "object" && expected !== null) {
|
|
253671
|
-
if (!evaluateOperator(userValue, expected))
|
|
253672
|
-
return false;
|
|
253673
|
-
} else {
|
|
253674
|
-
if (userValue !== expected)
|
|
253675
|
-
return false;
|
|
253676
|
-
}
|
|
253677
|
-
}
|
|
253678
|
-
return true;
|
|
253679
|
-
}
|
|
253680
|
-
function evaluateCondition(condition, record2, user) {
|
|
253681
|
-
for (const [key2, value] of Object.entries(condition)) {
|
|
253682
|
-
if (key2 === "user_condition") {
|
|
253683
|
-
if (!evaluateUserCondition(value, user))
|
|
253684
|
-
return false;
|
|
253685
|
-
continue;
|
|
253686
|
-
}
|
|
253687
|
-
if (key2 === "$or") {
|
|
253688
|
-
const conditions = value;
|
|
253689
|
-
if (!conditions.some((c8) => evaluateCondition(c8, record2, user)))
|
|
253690
|
-
return false;
|
|
253691
|
-
continue;
|
|
253692
|
-
}
|
|
253693
|
-
if (key2 === "$and") {
|
|
253694
|
-
const conditions = value;
|
|
253695
|
-
if (!conditions.every((c8) => evaluateCondition(c8, record2, user)))
|
|
253696
|
-
return false;
|
|
253697
|
-
continue;
|
|
253698
|
-
}
|
|
253699
|
-
if (key2 === "$nor") {
|
|
253700
|
-
const conditions = value;
|
|
253701
|
-
if (conditions.some((c8) => evaluateCondition(c8, record2, user)))
|
|
253702
|
-
return false;
|
|
253703
|
-
continue;
|
|
253704
|
-
}
|
|
253705
|
-
const recordValue = getRecordField(key2, record2);
|
|
253706
|
-
const resolvedValue = typeof value === "string" ? resolveTemplate(value, user) : value;
|
|
253707
|
-
if (typeof resolvedValue === "object" && resolvedValue !== null) {
|
|
253708
|
-
if (!evaluateOperator(recordValue, resolvedValue))
|
|
253709
|
-
return false;
|
|
253710
|
-
} else {
|
|
253711
|
-
if (recordValue !== resolvedValue)
|
|
253712
|
-
return false;
|
|
253713
|
-
}
|
|
253714
|
-
}
|
|
253715
|
-
return true;
|
|
253716
|
-
}
|
|
253717
|
-
function checkRLS(rule, record2, user) {
|
|
253718
|
-
if (rule === undefined)
|
|
253719
|
-
return true;
|
|
253720
|
-
if (typeof rule === "boolean")
|
|
253721
|
-
return rule;
|
|
253722
|
-
if (!user)
|
|
253723
|
-
return false;
|
|
253724
|
-
return evaluateCondition(rule, record2, user);
|
|
253725
|
-
}
|
|
253726
|
-
function applyFLS(record2, schema10, user, operation) {
|
|
253727
|
-
const result = {};
|
|
253728
|
-
for (const [key2, value] of Object.entries(record2)) {
|
|
253729
|
-
const rule = schema10.properties[key2]?.rls?.[operation];
|
|
253730
|
-
if (!rule || checkRLS(rule, record2, user)) {
|
|
253731
|
-
result[key2] = value;
|
|
253732
|
-
}
|
|
253733
|
-
}
|
|
253734
|
-
return result;
|
|
253735
|
-
}
|
|
253736
|
-
|
|
253737
|
-
// src/cli/dev/dev-server/db/entity-queries.ts
|
|
253738
|
-
function parseSort(sort) {
|
|
253739
|
-
if (!sort) {
|
|
253740
|
-
return;
|
|
253741
|
-
}
|
|
253742
|
-
if (sort.startsWith("-")) {
|
|
253743
|
-
return { [sort.slice(1)]: -1 };
|
|
253744
|
-
}
|
|
253745
|
-
return { [sort]: 1 };
|
|
253746
|
-
}
|
|
253747
|
-
function parseFields(fields) {
|
|
253748
|
-
if (!fields) {
|
|
253749
|
-
return;
|
|
253750
|
-
}
|
|
253751
|
-
const projection = {};
|
|
253752
|
-
for (const field of fields.split(",")) {
|
|
253753
|
-
const trimmed = field.trim();
|
|
253754
|
-
if (trimmed) {
|
|
253755
|
-
projection[trimmed] = 1;
|
|
253756
|
-
}
|
|
253757
|
-
}
|
|
253758
|
-
return Object.keys(projection).length > 0 ? projection : undefined;
|
|
253759
|
-
}
|
|
253760
|
-
var queryEntity = async (collection, reqQuery) => {
|
|
253761
|
-
const { sort, limit, skip: skip2, fields, q: q13 } = reqQuery;
|
|
253762
|
-
let query = {};
|
|
253763
|
-
if (q13 && typeof q13 === "string") {
|
|
253764
|
-
try {
|
|
253765
|
-
query = JSON.parse(q13);
|
|
253766
|
-
} catch {
|
|
253767
|
-
throw new InvalidInputError("Invalid query parameter 'q'");
|
|
253768
|
-
}
|
|
253769
|
-
}
|
|
253770
|
-
let cursor3 = collection.findAsync(query);
|
|
253771
|
-
const sortObj = parseSort(sort);
|
|
253772
|
-
if (sortObj) {
|
|
253773
|
-
cursor3 = cursor3.sort(sortObj);
|
|
253774
|
-
}
|
|
253775
|
-
if (skip2) {
|
|
253776
|
-
const skipNum = Number.parseInt(skip2, 10);
|
|
253777
|
-
if (!Number.isNaN(skipNum)) {
|
|
253778
|
-
cursor3 = cursor3.skip(skipNum);
|
|
253779
|
-
}
|
|
253780
|
-
}
|
|
253781
|
-
if (limit) {
|
|
253782
|
-
const limitNum = Number.parseInt(limit, 10);
|
|
253783
|
-
if (!Number.isNaN(limitNum)) {
|
|
253784
|
-
cursor3 = cursor3.limit(limitNum);
|
|
253785
|
-
}
|
|
253786
|
-
}
|
|
253787
|
-
const projection = parseFields(fields);
|
|
253788
|
-
if (projection) {
|
|
253789
|
-
cursor3 = cursor3.projection(projection);
|
|
253790
|
-
}
|
|
253791
|
-
return cursor3;
|
|
253792
|
-
};
|
|
253492
|
+
var import_express3 = __toESM(require_express(), 1);
|
|
253793
253493
|
|
|
253794
253494
|
// src/cli/dev/dev-server/routes/entities/entities-user-router.ts
|
|
253795
|
-
var
|
|
253796
|
-
var
|
|
253495
|
+
var import_express2 = __toESM(require_express(), 1);
|
|
253496
|
+
var import_jsonwebtoken = __toESM(require_jsonwebtoken(), 1);
|
|
253797
253497
|
function createUserRouter(db2, logger2) {
|
|
253798
|
-
const router =
|
|
253799
|
-
const parseBody =
|
|
253498
|
+
const router = import_express2.Router({ mergeParams: true });
|
|
253499
|
+
const parseBody = import_express2.json();
|
|
253800
253500
|
function withAuth(handler) {
|
|
253801
253501
|
return async (req, res) => {
|
|
253802
253502
|
const auth2 = req.headers.authorization;
|
|
@@ -253805,13 +253505,13 @@ function createUserRouter(db2, logger2) {
|
|
|
253805
253505
|
return;
|
|
253806
253506
|
}
|
|
253807
253507
|
try {
|
|
253808
|
-
const { payload } =
|
|
253809
|
-
const
|
|
253810
|
-
if (!
|
|
253508
|
+
const { payload } = import_jsonwebtoken.default.decode(auth2.replace("Bearer ", ""), { complete: true }) ?? {};
|
|
253509
|
+
const result = await db2.getCollection(USER_COLLECTION)?.findOneAsync({ email: payload?.sub });
|
|
253510
|
+
if (!result) {
|
|
253811
253511
|
res.status(404).json({ error: "Unable to read data for the current user" });
|
|
253812
253512
|
return;
|
|
253813
253513
|
}
|
|
253814
|
-
await handler(req, res,
|
|
253514
|
+
await handler(req, res, result);
|
|
253815
253515
|
} catch {
|
|
253816
253516
|
res.status(401).json({ error: "Unauthorized" });
|
|
253817
253517
|
}
|
|
@@ -253838,28 +253538,6 @@ function createUserRouter(db2, logger2) {
|
|
|
253838
253538
|
...req.body
|
|
253839
253539
|
});
|
|
253840
253540
|
}));
|
|
253841
|
-
router.get("/", withAuth(async (req, res, currentUser) => {
|
|
253842
|
-
const collection = db2.getCollection(USER_COLLECTION);
|
|
253843
|
-
if (!collection) {
|
|
253844
|
-
res.status(404).json({ error: `Entity "${USER_COLLECTION}" not found` });
|
|
253845
|
-
return;
|
|
253846
|
-
}
|
|
253847
|
-
try {
|
|
253848
|
-
if (currentUser.role === "admin") {
|
|
253849
|
-
const result = await queryEntity(collection, req.query);
|
|
253850
|
-
res.json(stripInternalFields(result));
|
|
253851
|
-
} else {
|
|
253852
|
-
res.json([stripInternalFields(currentUser)]);
|
|
253853
|
-
}
|
|
253854
|
-
} catch (error48) {
|
|
253855
|
-
if (error48 instanceof InvalidInputError) {
|
|
253856
|
-
res.status(400).json({ error: error48.message });
|
|
253857
|
-
} else {
|
|
253858
|
-
logger2.error(`Error in GET /${USER_COLLECTION}:`, error48);
|
|
253859
|
-
res.status(500).json({ error: "Internal server error" });
|
|
253860
|
-
}
|
|
253861
|
-
}
|
|
253862
|
-
}));
|
|
253863
253541
|
router.post("/bulk", async (_req, res) => {
|
|
253864
253542
|
res.json({});
|
|
253865
253543
|
});
|
|
@@ -253909,9 +253587,31 @@ function createUserRouter(db2, logger2) {
|
|
|
253909
253587
|
}
|
|
253910
253588
|
|
|
253911
253589
|
// src/cli/dev/dev-server/routes/entities/entities-router.ts
|
|
253590
|
+
function parseSort(sort) {
|
|
253591
|
+
if (!sort) {
|
|
253592
|
+
return;
|
|
253593
|
+
}
|
|
253594
|
+
if (sort.startsWith("-")) {
|
|
253595
|
+
return { [sort.slice(1)]: -1 };
|
|
253596
|
+
}
|
|
253597
|
+
return { [sort]: 1 };
|
|
253598
|
+
}
|
|
253599
|
+
function parseFields(fields) {
|
|
253600
|
+
if (!fields) {
|
|
253601
|
+
return;
|
|
253602
|
+
}
|
|
253603
|
+
const projection = {};
|
|
253604
|
+
for (const field of fields.split(",")) {
|
|
253605
|
+
const trimmed = field.trim();
|
|
253606
|
+
if (trimmed) {
|
|
253607
|
+
projection[trimmed] = 1;
|
|
253608
|
+
}
|
|
253609
|
+
}
|
|
253610
|
+
return Object.keys(projection).length > 0 ? projection : undefined;
|
|
253611
|
+
}
|
|
253912
253612
|
async function createEntityRoutes(db2, logger2, broadcast) {
|
|
253913
|
-
const router =
|
|
253914
|
-
const parseBody =
|
|
253613
|
+
const router = import_express3.Router({ mergeParams: true });
|
|
253614
|
+
const parseBody = import_express3.json();
|
|
253915
253615
|
function withCollection(handler) {
|
|
253916
253616
|
return async (req, res) => {
|
|
253917
253617
|
const collection = db2.getCollection(req.params.entityName);
|
|
@@ -253919,13 +253619,7 @@ async function createEntityRoutes(db2, logger2, broadcast) {
|
|
|
253919
253619
|
res.status(404).json({ error: `Entity "${req.params.entityName}" not found` });
|
|
253920
253620
|
return;
|
|
253921
253621
|
}
|
|
253922
|
-
|
|
253923
|
-
try {
|
|
253924
|
-
const auth2 = req.headers.authorization || "";
|
|
253925
|
-
const { payload } = import_jsonwebtoken3.default.decode(auth2.replace("Bearer ", ""), { complete: true }) ?? {};
|
|
253926
|
-
currentUser = await db2.getCollection(USER_COLLECTION)?.findOneAsync({ email: payload?.sub });
|
|
253927
|
-
} catch {}
|
|
253928
|
-
await handler(req, res, collection, currentUser);
|
|
253622
|
+
await handler(req, res, collection);
|
|
253929
253623
|
};
|
|
253930
253624
|
}
|
|
253931
253625
|
function emit(appId, entityName, type, data) {
|
|
@@ -253945,7 +253639,7 @@ async function createEntityRoutes(db2, logger2, broadcast) {
|
|
|
253945
253639
|
}
|
|
253946
253640
|
const userRouter = createUserRouter(db2, logger2);
|
|
253947
253641
|
router.use("/User", userRouter);
|
|
253948
|
-
router.get("/:entityName/:id", withCollection(async (req, res, collection
|
|
253642
|
+
router.get("/:entityName/:id", withCollection(async (req, res, collection) => {
|
|
253949
253643
|
const { entityName, id: id2 } = req.params;
|
|
253950
253644
|
try {
|
|
253951
253645
|
const doc2 = await collection.findOneAsync({ id: id2 });
|
|
@@ -253953,70 +253647,63 @@ async function createEntityRoutes(db2, logger2, broadcast) {
|
|
|
253953
253647
|
res.status(404).json({ error: `Record with id "${id2}" not found` });
|
|
253954
253648
|
return;
|
|
253955
253649
|
}
|
|
253956
|
-
|
|
253957
|
-
if (!checkRLS(schema10?.rls?.read, doc2, currentUser)) {
|
|
253958
|
-
res.status(403).json({ error: "Permission denied" });
|
|
253959
|
-
return;
|
|
253960
|
-
}
|
|
253961
|
-
let result = stripInternalFields(doc2);
|
|
253962
|
-
if (schema10) {
|
|
253963
|
-
result = applyFLS(result, schema10, currentUser, "read");
|
|
253964
|
-
}
|
|
253965
|
-
res.json(result);
|
|
253650
|
+
res.json(stripInternalFields(doc2));
|
|
253966
253651
|
} catch (error48) {
|
|
253967
253652
|
logger2.error(`Error in GET /${entityName}/${id2}:`, error48);
|
|
253968
253653
|
res.status(500).json({ error: "Internal server error" });
|
|
253969
253654
|
}
|
|
253970
253655
|
}));
|
|
253971
|
-
router.get("/:entityName", withCollection(async (req, res, collection
|
|
253656
|
+
router.get("/:entityName", withCollection(async (req, res, collection) => {
|
|
253972
253657
|
const { entityName } = req.params;
|
|
253973
253658
|
try {
|
|
253974
|
-
const
|
|
253975
|
-
|
|
253976
|
-
|
|
253977
|
-
|
|
253659
|
+
const { sort, limit, skip: skip2, fields, q: q13 } = req.query;
|
|
253660
|
+
let query = {};
|
|
253661
|
+
if (q13 && typeof q13 === "string") {
|
|
253662
|
+
try {
|
|
253663
|
+
query = JSON.parse(q13);
|
|
253664
|
+
} catch {
|
|
253665
|
+
res.status(400).json({ error: "Invalid query parameter 'q'" });
|
|
253666
|
+
return;
|
|
253667
|
+
}
|
|
253978
253668
|
}
|
|
253979
|
-
let
|
|
253980
|
-
|
|
253981
|
-
|
|
253669
|
+
let cursor3 = collection.findAsync(query);
|
|
253670
|
+
const sortObj = parseSort(sort);
|
|
253671
|
+
if (sortObj) {
|
|
253672
|
+
cursor3 = cursor3.sort(sortObj);
|
|
253982
253673
|
}
|
|
253983
|
-
if (
|
|
253984
|
-
|
|
253674
|
+
if (skip2) {
|
|
253675
|
+
const skipNum = Number.parseInt(skip2, 10);
|
|
253676
|
+
if (!Number.isNaN(skipNum)) {
|
|
253677
|
+
cursor3 = cursor3.skip(skipNum);
|
|
253678
|
+
}
|
|
253985
253679
|
}
|
|
253986
|
-
|
|
253987
|
-
|
|
253988
|
-
|
|
253989
|
-
|
|
253990
|
-
|
|
253991
|
-
|
|
253992
|
-
|
|
253680
|
+
if (limit) {
|
|
253681
|
+
const limitNum = Number.parseInt(limit, 10);
|
|
253682
|
+
if (!Number.isNaN(limitNum)) {
|
|
253683
|
+
cursor3 = cursor3.limit(limitNum);
|
|
253684
|
+
}
|
|
253685
|
+
}
|
|
253686
|
+
const projection = parseFields(fields);
|
|
253687
|
+
if (projection) {
|
|
253688
|
+
cursor3 = cursor3.projection(projection);
|
|
253993
253689
|
}
|
|
253690
|
+
const docs = await cursor3;
|
|
253691
|
+
res.json(stripInternalFields(docs));
|
|
253692
|
+
} catch (error48) {
|
|
253693
|
+
logger2.error(`Error in GET /${entityName}:`, error48);
|
|
253694
|
+
res.status(500).json({ error: "Internal server error" });
|
|
253994
253695
|
}
|
|
253995
253696
|
}));
|
|
253996
|
-
router.post("/:entityName", parseBody, withCollection(async (req, res, collection
|
|
253697
|
+
router.post("/:entityName", parseBody, withCollection(async (req, res, collection) => {
|
|
253997
253698
|
const { appId, entityName } = req.params;
|
|
253998
253699
|
try {
|
|
253999
253700
|
const now = new Date().toISOString();
|
|
254000
253701
|
const { _id, ...body } = req.body;
|
|
254001
|
-
const
|
|
254002
|
-
if (!checkRLS(schema10?.rls?.create, {
|
|
254003
|
-
...body,
|
|
254004
|
-
created_by: currentUser?.email,
|
|
254005
|
-
created_by_id: currentUser?.id
|
|
254006
|
-
}, currentUser)) {
|
|
254007
|
-
res.status(403).json({ error: "Permission denied" });
|
|
254008
|
-
return;
|
|
254009
|
-
}
|
|
254010
|
-
let filteredBody = db2.prepareRecord(entityName, body);
|
|
254011
|
-
if (schema10) {
|
|
254012
|
-
filteredBody = applyFLS(filteredBody, schema10, currentUser, "write");
|
|
254013
|
-
}
|
|
253702
|
+
const filteredBody = db2.prepareRecord(entityName, body);
|
|
254014
253703
|
db2.validate(entityName, filteredBody);
|
|
254015
253704
|
const record2 = {
|
|
254016
253705
|
...filteredBody,
|
|
254017
253706
|
id: nanoid3(),
|
|
254018
|
-
created_by: currentUser?.email,
|
|
254019
|
-
created_by_id: currentUser?.id,
|
|
254020
253707
|
created_date: now,
|
|
254021
253708
|
updated_date: now
|
|
254022
253709
|
};
|
|
@@ -254032,7 +253719,7 @@ async function createEntityRoutes(db2, logger2, broadcast) {
|
|
|
254032
253719
|
res.status(500).json({ error: "Internal server error" });
|
|
254033
253720
|
}
|
|
254034
253721
|
}));
|
|
254035
|
-
router.post("/:entityName/bulk", parseBody, withCollection(async (req, res, collection
|
|
253722
|
+
router.post("/:entityName/bulk", parseBody, withCollection(async (req, res, collection) => {
|
|
254036
253723
|
const { appId, entityName } = req.params;
|
|
254037
253724
|
if (!Array.isArray(req.body)) {
|
|
254038
253725
|
res.status(400).json({ error: "Request body must be an array" });
|
|
@@ -254040,27 +253727,13 @@ async function createEntityRoutes(db2, logger2, broadcast) {
|
|
|
254040
253727
|
}
|
|
254041
253728
|
try {
|
|
254042
253729
|
const now = new Date().toISOString();
|
|
254043
|
-
const schema10 = db2.getSchema(entityName);
|
|
254044
253730
|
const records = [];
|
|
254045
253731
|
for (const record2 of req.body) {
|
|
254046
|
-
|
|
254047
|
-
...record2,
|
|
254048
|
-
created_by: currentUser?.email,
|
|
254049
|
-
created_by_id: currentUser?.id
|
|
254050
|
-
}, currentUser)) {
|
|
254051
|
-
res.status(403).json({ error: "Permission denied" });
|
|
254052
|
-
return;
|
|
254053
|
-
}
|
|
254054
|
-
let filteredRecord = db2.prepareRecord(entityName, record2);
|
|
254055
|
-
if (schema10) {
|
|
254056
|
-
filteredRecord = applyFLS(filteredRecord, schema10, currentUser, "write");
|
|
254057
|
-
}
|
|
253732
|
+
const filteredRecord = db2.prepareRecord(entityName, record2);
|
|
254058
253733
|
db2.validate(entityName, filteredRecord);
|
|
254059
253734
|
records.push({
|
|
254060
253735
|
...filteredRecord,
|
|
254061
253736
|
id: nanoid3(),
|
|
254062
|
-
created_by: currentUser?.email,
|
|
254063
|
-
created_by_id: currentUser?.id,
|
|
254064
253737
|
created_date: now,
|
|
254065
253738
|
updated_date: now
|
|
254066
253739
|
});
|
|
@@ -254077,26 +253750,11 @@ async function createEntityRoutes(db2, logger2, broadcast) {
|
|
|
254077
253750
|
res.status(500).json({ error: "Internal server error" });
|
|
254078
253751
|
}
|
|
254079
253752
|
}));
|
|
254080
|
-
router.put("/:entityName/:id", parseBody, withCollection(async (req, res, collection
|
|
253753
|
+
router.put("/:entityName/:id", parseBody, withCollection(async (req, res, collection) => {
|
|
254081
253754
|
const { appId, entityName, id: id2 } = req.params;
|
|
254082
253755
|
const { id: _id, created_date: _created_date, ...body } = req.body;
|
|
254083
253756
|
try {
|
|
254084
|
-
const
|
|
254085
|
-
if (schema10?.rls?.update !== undefined) {
|
|
254086
|
-
const existing = await collection.findOneAsync({ id: id2 });
|
|
254087
|
-
if (!existing) {
|
|
254088
|
-
res.status(404).json({ error: `Record with id "${id2}" not found` });
|
|
254089
|
-
return;
|
|
254090
|
-
}
|
|
254091
|
-
if (!checkRLS(schema10.rls.update, existing, currentUser)) {
|
|
254092
|
-
res.status(403).json({ error: "Permission denied" });
|
|
254093
|
-
return;
|
|
254094
|
-
}
|
|
254095
|
-
}
|
|
254096
|
-
let filteredBody = db2.prepareRecord(entityName, body, true);
|
|
254097
|
-
if (schema10) {
|
|
254098
|
-
filteredBody = applyFLS(filteredBody, schema10, currentUser, "write");
|
|
254099
|
-
}
|
|
253757
|
+
const filteredBody = db2.prepareRecord(entityName, body, true);
|
|
254100
253758
|
db2.validate(entityName, filteredBody, true);
|
|
254101
253759
|
const updateData = {
|
|
254102
253760
|
...filteredBody,
|
|
@@ -254119,48 +253777,30 @@ async function createEntityRoutes(db2, logger2, broadcast) {
|
|
|
254119
253777
|
res.status(500).json({ error: "Internal server error" });
|
|
254120
253778
|
}
|
|
254121
253779
|
}));
|
|
254122
|
-
router.delete("/:entityName/:id", withCollection(async (req, res, collection
|
|
253780
|
+
router.delete("/:entityName/:id", withCollection(async (req, res, collection) => {
|
|
254123
253781
|
const { appId, entityName, id: id2 } = req.params;
|
|
254124
253782
|
try {
|
|
254125
253783
|
const doc2 = await collection.findOneAsync({ id: id2 });
|
|
254126
|
-
|
|
253784
|
+
const numRemoved = await collection.removeAsync({ id: id2 }, { multi: false });
|
|
253785
|
+
if (numRemoved === 0) {
|
|
254127
253786
|
res.status(404).json({ error: `Record with id "${id2}" not found` });
|
|
254128
253787
|
return;
|
|
254129
253788
|
}
|
|
254130
|
-
|
|
254131
|
-
|
|
254132
|
-
res.status(403).json({ error: "Permission denied" });
|
|
254133
|
-
return;
|
|
253789
|
+
if (doc2) {
|
|
253790
|
+
emit(appId, entityName, "delete", stripInternalFields(doc2));
|
|
254134
253791
|
}
|
|
254135
|
-
await collection.removeAsync({ id: id2 }, { multi: false });
|
|
254136
|
-
emit(appId, entityName, "delete", stripInternalFields(doc2));
|
|
254137
253792
|
res.json({ success: true });
|
|
254138
253793
|
} catch (error48) {
|
|
254139
253794
|
logger2.error(`Error in DELETE /${entityName}/${id2}:`, error48);
|
|
254140
253795
|
res.status(500).json({ error: "Internal server error" });
|
|
254141
253796
|
}
|
|
254142
253797
|
}));
|
|
254143
|
-
router.delete("/:entityName", parseBody, withCollection(async (req, res, collection
|
|
253798
|
+
router.delete("/:entityName", parseBody, withCollection(async (req, res, collection) => {
|
|
254144
253799
|
const { entityName } = req.params;
|
|
254145
253800
|
try {
|
|
254146
253801
|
const query = req.body || {};
|
|
254147
|
-
const
|
|
254148
|
-
|
|
254149
|
-
if (rlsDelete !== undefined && rlsDelete !== true) {
|
|
254150
|
-
if (rlsDelete === false) {
|
|
254151
|
-
res.status(403).json({ error: "Permission denied" });
|
|
254152
|
-
return;
|
|
254153
|
-
}
|
|
254154
|
-
const docs = await collection.findAsync(query);
|
|
254155
|
-
const allowedIds = docs.filter((doc2) => checkRLS(rlsDelete, doc2, currentUser)).map((doc2) => doc2.id);
|
|
254156
|
-
const numRemoved = await collection.removeAsync({ id: { $in: allowedIds } }, { multi: true });
|
|
254157
|
-
res.json({ success: true, deleted: numRemoved });
|
|
254158
|
-
} else {
|
|
254159
|
-
const numRemoved = await collection.removeAsync(query, {
|
|
254160
|
-
multi: true
|
|
254161
|
-
});
|
|
254162
|
-
res.json({ success: true, deleted: numRemoved });
|
|
254163
|
-
}
|
|
253802
|
+
const numRemoved = await collection.removeAsync(query, { multi: true });
|
|
253803
|
+
res.json({ success: true, deleted: numRemoved });
|
|
254164
253804
|
} catch (error48) {
|
|
254165
253805
|
logger2.error(`Error in DELETE /${entityName}:`, error48);
|
|
254166
253806
|
res.status(500).json({ error: "Internal server error" });
|
|
@@ -254170,7 +253810,7 @@ async function createEntityRoutes(db2, logger2, broadcast) {
|
|
|
254170
253810
|
}
|
|
254171
253811
|
|
|
254172
253812
|
// src/cli/dev/dev-server/routes/integrations.ts
|
|
254173
|
-
var
|
|
253813
|
+
var import_express4 = __toESM(require_express(), 1);
|
|
254174
253814
|
var import_multer = __toESM(require_multer(), 1);
|
|
254175
253815
|
import { createHash, randomUUID as randomUUID4 } from "node:crypto";
|
|
254176
253816
|
import fs28 from "node:fs";
|
|
@@ -254179,8 +253819,8 @@ function createFileToken(fileUri) {
|
|
|
254179
253819
|
return createHash("sha256").update(fileUri).digest("hex");
|
|
254180
253820
|
}
|
|
254181
253821
|
function createIntegrationRoutes(mediaFilesDir, baseUrl, remoteProxy, logger2) {
|
|
254182
|
-
const router =
|
|
254183
|
-
const parseBody =
|
|
253822
|
+
const router = import_express4.Router({ mergeParams: true });
|
|
253823
|
+
const parseBody = import_express4.json();
|
|
254184
253824
|
const privateFilesDir = path18.join(mediaFilesDir, "private");
|
|
254185
253825
|
fs28.mkdirSync(mediaFilesDir, { recursive: true });
|
|
254186
253826
|
fs28.mkdirSync(privateFilesDir, { recursive: true });
|
|
@@ -254250,7 +253890,7 @@ function createIntegrationRoutes(mediaFilesDir, baseUrl, remoteProxy, logger2) {
|
|
|
254250
253890
|
return router;
|
|
254251
253891
|
}
|
|
254252
253892
|
function createCustomIntegrationRoutes(remoteProxy, logger2) {
|
|
254253
|
-
const router =
|
|
253893
|
+
const router = import_express4.Router({ mergeParams: true });
|
|
254254
253894
|
router.post("/:slug/:operationId", (req, res, next) => {
|
|
254255
253895
|
logger2.warn(`"${req.originalUrl}" is not supported in local development, passing call to production`);
|
|
254256
253896
|
req.url = req.originalUrl;
|
|
@@ -255963,7 +255603,7 @@ async function createDevServer(options8) {
|
|
|
255963
255603
|
const port = userPort ?? await getPorts({ port: DEFAULT_PORT });
|
|
255964
255604
|
const baseUrl = `http://localhost:${port}`;
|
|
255965
255605
|
const { functions, entities, project: project2 } = await options8.loadResources();
|
|
255966
|
-
const app =
|
|
255606
|
+
const app = import_express5.default();
|
|
255967
255607
|
const remoteProxy = import_http_proxy_middleware2.createProxyMiddleware({
|
|
255968
255608
|
target: BASE44_APP_URL,
|
|
255969
255609
|
changeOrigin: true
|
|
@@ -255995,8 +255635,6 @@ async function createDevServer(options8) {
|
|
|
255995
255635
|
let emitEntityEvent = () => {};
|
|
255996
255636
|
const entityRoutes = await createEntityRoutes(db2, devLogger, (...args) => emitEntityEvent(...args));
|
|
255997
255637
|
app.use("/api/apps/:appId/entities", entityRoutes);
|
|
255998
|
-
const authRouter = createAuthRouter(db2, devLogger);
|
|
255999
|
-
app.use("/api/apps/:appId/auth", authRouter);
|
|
256000
255638
|
const { path: mediaFilesDir } = await $dir();
|
|
256001
255639
|
app.use("/media/private/:fileUri", (req, res, next) => {
|
|
256002
255640
|
const { fileUri } = req.params;
|
|
@@ -256016,15 +255654,13 @@ async function createDevServer(options8) {
|
|
|
256016
255654
|
}
|
|
256017
255655
|
next();
|
|
256018
255656
|
});
|
|
256019
|
-
app.use("/media",
|
|
255657
|
+
app.use("/media", import_express5.default.static(mediaFilesDir));
|
|
256020
255658
|
const integrationRoutes = createIntegrationRoutes(mediaFilesDir, baseUrl, remoteProxy, devLogger);
|
|
256021
255659
|
app.use("/api/apps/:appId/integration-endpoints", integrationRoutes);
|
|
256022
255660
|
const customIntegrationRoutes = createCustomIntegrationRoutes(remoteProxy, devLogger);
|
|
256023
255661
|
app.use("/api/apps/:appId/integrations/custom", customIntegrationRoutes);
|
|
256024
255662
|
app.use((req, res, next) => {
|
|
256025
|
-
|
|
256026
|
-
devLogger.warn(`"${req.originalUrl}" is not supported in local development, passing call to production`);
|
|
256027
|
-
}
|
|
255663
|
+
devLogger.warn(`"${req.originalUrl}" is not supported in local development, passing call to production`);
|
|
256028
255664
|
remoteProxy(req, res, next);
|
|
256029
255665
|
});
|
|
256030
255666
|
const server = await new Promise((resolve8, reject) => {
|
|
@@ -256095,7 +255731,6 @@ async function devAction({ log }, options8) {
|
|
|
256095
255731
|
const { port: resolvedPort } = await createDevServer({
|
|
256096
255732
|
log,
|
|
256097
255733
|
port,
|
|
256098
|
-
cwd: process21.cwd(),
|
|
256099
255734
|
denoWrapperPath: getDenoWrapperPath(),
|
|
256100
255735
|
loadResources: async () => {
|
|
256101
255736
|
const { functions, entities, project: project2 } = await readProjectConfig();
|
|
@@ -260603,4 +260238,4 @@ export {
|
|
|
260603
260238
|
CLIExitError
|
|
260604
260239
|
};
|
|
260605
260240
|
|
|
260606
|
-
//# debugId=
|
|
260241
|
+
//# debugId=4CE71B78B25F696A64756E2164756E21
|