@base44-preview/cli 0.0.41-pr.394.ff9a1f1 → 0.0.41-pr.395.72f56e6
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 +171 -14
- package/dist/cli/index.js.map +9 -8
- package/package.json +2 -1
package/dist/cli/index.js
CHANGED
|
@@ -161575,7 +161575,7 @@ var require_is_promise = __commonJS((exports, module) => {
|
|
|
161575
161575
|
}
|
|
161576
161576
|
});
|
|
161577
161577
|
|
|
161578
|
-
// ../../node_modules/path-to-regexp/dist/index.js
|
|
161578
|
+
// ../../node_modules/router/node_modules/path-to-regexp/dist/index.js
|
|
161579
161579
|
var require_dist = __commonJS((exports) => {
|
|
161580
161580
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
161581
161581
|
exports.PathError = exports.TokenData = undefined;
|
|
@@ -238469,6 +238469,7 @@ var package_default = {
|
|
|
238469
238469
|
json5: "^2.2.3",
|
|
238470
238470
|
ky: "^1.14.2",
|
|
238471
238471
|
lodash: "^4.17.23",
|
|
238472
|
+
msw: "^2.12.10",
|
|
238472
238473
|
multer: "^2.0.0",
|
|
238473
238474
|
nanoid: "^5.1.6",
|
|
238474
238475
|
open: "^11.0.0",
|
|
@@ -247919,7 +247920,7 @@ function getLogsCommand(context) {
|
|
|
247919
247920
|
return new Command("logs").description("Fetch function logs for this app").option("--function <names>", "Filter by function name(s), comma-separated. If omitted, fetches logs for all project functions").option("--since <datetime>", "Show logs from this time (ISO format)", normalizeDatetime).option("--until <datetime>", "Show logs until this time (ISO format)", normalizeDatetime).addOption(new Option("--level <level>", "Filter by log level").choices([...LogLevelSchema.options]).hideHelp()).option("-n, --limit <n>", "Results per page (1-1000, default: 50)", (v) => {
|
|
247920
247921
|
const n2 = Number.parseInt(v, 10);
|
|
247921
247922
|
if (Number.isNaN(n2) || n2 < 1 || n2 > 1000) {
|
|
247922
|
-
throw new
|
|
247923
|
+
throw new InvalidInputError(`Invalid limit: "${v}". Must be a number between 1 and 1000.`);
|
|
247923
247924
|
}
|
|
247924
247925
|
return v;
|
|
247925
247926
|
}).addOption(new Option("--order <order>", "Sort order").choices(["asc", "desc"])).action(async (options) => {
|
|
@@ -247994,10 +247995,10 @@ function validateInput(command) {
|
|
|
247994
247995
|
const hasEntries = entries.length > 0;
|
|
247995
247996
|
const hasEnvFile = Boolean(envFile);
|
|
247996
247997
|
if (!hasEntries && !hasEnvFile) {
|
|
247997
|
-
|
|
247998
|
+
throw new InvalidInputError("Provide KEY=VALUE pairs or use --env-file. Example: base44 secrets set KEY1=VALUE1 KEY2=VALUE2");
|
|
247998
247999
|
}
|
|
247999
248000
|
if (hasEntries && hasEnvFile) {
|
|
248000
|
-
|
|
248001
|
+
throw new InvalidInputError("Provide KEY=VALUE pairs or --env-file, but not both.");
|
|
248001
248002
|
}
|
|
248002
248003
|
}
|
|
248003
248004
|
async function setSecretsAction(entries, options) {
|
|
@@ -248580,14 +248581,130 @@ function createFunctionRouter(manager, logger) {
|
|
|
248580
248581
|
return router;
|
|
248581
248582
|
}
|
|
248582
248583
|
|
|
248583
|
-
// src/cli/dev/dev-server/database.ts
|
|
248584
|
+
// src/cli/dev/dev-server/db/database.ts
|
|
248584
248585
|
var import_nedb = __toESM(require_nedb(), 1);
|
|
248585
248586
|
|
|
248587
|
+
// src/cli/dev/dev-server/db/validator.ts
|
|
248588
|
+
var fieldTypes = [
|
|
248589
|
+
"string",
|
|
248590
|
+
"integer",
|
|
248591
|
+
"number",
|
|
248592
|
+
"boolean",
|
|
248593
|
+
"array",
|
|
248594
|
+
"object"
|
|
248595
|
+
];
|
|
248596
|
+
|
|
248597
|
+
class Validator {
|
|
248598
|
+
filterFields(record2, entitySchema) {
|
|
248599
|
+
const filteredRecord = {};
|
|
248600
|
+
for (const [key2, value] of Object.entries(record2)) {
|
|
248601
|
+
if (entitySchema.properties[key2]) {
|
|
248602
|
+
filteredRecord[key2] = value;
|
|
248603
|
+
}
|
|
248604
|
+
}
|
|
248605
|
+
return filteredRecord;
|
|
248606
|
+
}
|
|
248607
|
+
applyDefaults(record2, entitySchema) {
|
|
248608
|
+
const result = {};
|
|
248609
|
+
for (const [key2, property] of Object.entries(entitySchema.properties)) {
|
|
248610
|
+
if (property?.default) {
|
|
248611
|
+
result[key2] = property.default;
|
|
248612
|
+
}
|
|
248613
|
+
}
|
|
248614
|
+
return {
|
|
248615
|
+
...result,
|
|
248616
|
+
...record2
|
|
248617
|
+
};
|
|
248618
|
+
}
|
|
248619
|
+
validate(record2, entitySchema, partial2 = false) {
|
|
248620
|
+
if (!partial2) {
|
|
248621
|
+
const requiredFieldsResponse = this.validateRequiredFields(record2, entitySchema);
|
|
248622
|
+
if (requiredFieldsResponse.hasError) {
|
|
248623
|
+
return requiredFieldsResponse;
|
|
248624
|
+
}
|
|
248625
|
+
}
|
|
248626
|
+
const fieldTypesResponse = this.validateFieldTypes(record2, entitySchema);
|
|
248627
|
+
if (fieldTypesResponse.hasError) {
|
|
248628
|
+
return fieldTypesResponse;
|
|
248629
|
+
}
|
|
248630
|
+
return {
|
|
248631
|
+
hasError: false
|
|
248632
|
+
};
|
|
248633
|
+
}
|
|
248634
|
+
createValidationError(message) {
|
|
248635
|
+
return {
|
|
248636
|
+
error_type: "ValidationError",
|
|
248637
|
+
message,
|
|
248638
|
+
request_id: null,
|
|
248639
|
+
traceback: ""
|
|
248640
|
+
};
|
|
248641
|
+
}
|
|
248642
|
+
validateFieldTypes(record2, entitySchema) {
|
|
248643
|
+
for (const [key2, value] of Object.entries(record2)) {
|
|
248644
|
+
const property = entitySchema.properties[key2];
|
|
248645
|
+
const propertyType = property?.type;
|
|
248646
|
+
if (!fieldTypes.includes(propertyType)) {
|
|
248647
|
+
return {
|
|
248648
|
+
hasError: true,
|
|
248649
|
+
error: this.createValidationError(`Error in field ${key2}: Input should be a valid ${propertyType}`)
|
|
248650
|
+
};
|
|
248651
|
+
}
|
|
248652
|
+
switch (propertyType) {
|
|
248653
|
+
case "array":
|
|
248654
|
+
if (!Array.isArray(value)) {
|
|
248655
|
+
return {
|
|
248656
|
+
hasError: true,
|
|
248657
|
+
error: this.createValidationError(`Error in field ${key2}: Input should be a valid array`)
|
|
248658
|
+
};
|
|
248659
|
+
}
|
|
248660
|
+
break;
|
|
248661
|
+
case "integer":
|
|
248662
|
+
if (!Number.isInteger(value)) {
|
|
248663
|
+
return {
|
|
248664
|
+
hasError: true,
|
|
248665
|
+
error: this.createValidationError(`Error in field ${key2}: Input should be a valid integer`)
|
|
248666
|
+
};
|
|
248667
|
+
}
|
|
248668
|
+
break;
|
|
248669
|
+
default:
|
|
248670
|
+
if (typeof value !== propertyType) {
|
|
248671
|
+
return {
|
|
248672
|
+
hasError: true,
|
|
248673
|
+
error: this.createValidationError(`Error in field ${key2}: Input should be a valid ${propertyType}`)
|
|
248674
|
+
};
|
|
248675
|
+
}
|
|
248676
|
+
}
|
|
248677
|
+
}
|
|
248678
|
+
return {
|
|
248679
|
+
hasError: false
|
|
248680
|
+
};
|
|
248681
|
+
}
|
|
248682
|
+
validateRequiredFields(record2, entitySchema) {
|
|
248683
|
+
if (entitySchema.required && entitySchema.required.length > 0) {
|
|
248684
|
+
for (const required2 of entitySchema.required) {
|
|
248685
|
+
if (!record2[required2]) {
|
|
248686
|
+
return {
|
|
248687
|
+
hasError: true,
|
|
248688
|
+
error: this.createValidationError(`Error in field ${required2}: Field required`)
|
|
248689
|
+
};
|
|
248690
|
+
}
|
|
248691
|
+
}
|
|
248692
|
+
}
|
|
248693
|
+
return {
|
|
248694
|
+
hasError: false
|
|
248695
|
+
};
|
|
248696
|
+
}
|
|
248697
|
+
}
|
|
248698
|
+
|
|
248699
|
+
// src/cli/dev/dev-server/db/database.ts
|
|
248586
248700
|
class Database {
|
|
248587
248701
|
collections = new Map;
|
|
248702
|
+
schemas = new Map;
|
|
248703
|
+
validator = new Validator;
|
|
248588
248704
|
load(entities) {
|
|
248589
248705
|
for (const entity2 of entities) {
|
|
248590
248706
|
this.collections.set(entity2.name, new import_nedb.default);
|
|
248707
|
+
this.schemas.set(entity2.name, entity2);
|
|
248591
248708
|
}
|
|
248592
248709
|
}
|
|
248593
248710
|
getCollection(name2) {
|
|
@@ -248601,6 +248718,25 @@ class Database {
|
|
|
248601
248718
|
collection.remove({}, { multi: true });
|
|
248602
248719
|
}
|
|
248603
248720
|
this.collections.clear();
|
|
248721
|
+
this.schemas.clear();
|
|
248722
|
+
}
|
|
248723
|
+
validate(entityName, record2, partial2 = false) {
|
|
248724
|
+
const schema9 = this.schemas.get(entityName);
|
|
248725
|
+
if (!schema9) {
|
|
248726
|
+
throw new Error(`Entity "${entityName}" not found`);
|
|
248727
|
+
}
|
|
248728
|
+
return this.validator.validate(record2, schema9, partial2);
|
|
248729
|
+
}
|
|
248730
|
+
prepareRecord(entityName, record2, partial2 = false) {
|
|
248731
|
+
const schema9 = this.schemas.get(entityName);
|
|
248732
|
+
if (!schema9) {
|
|
248733
|
+
throw new Error(`Entity "${entityName}" not found`);
|
|
248734
|
+
}
|
|
248735
|
+
const filteredRecord = this.validator.filterFields(record2, schema9);
|
|
248736
|
+
if (partial2) {
|
|
248737
|
+
return filteredRecord;
|
|
248738
|
+
}
|
|
248739
|
+
return this.validator.applyDefaults(filteredRecord, schema9);
|
|
248604
248740
|
}
|
|
248605
248741
|
}
|
|
248606
248742
|
|
|
@@ -248792,8 +248928,14 @@ function createEntityRoutes(db2, logger, remoteProxy, broadcast) {
|
|
|
248792
248928
|
try {
|
|
248793
248929
|
const now = new Date().toISOString();
|
|
248794
248930
|
const { _id, ...body } = req.body;
|
|
248931
|
+
const filteredBody = db2.prepareRecord(entityName, body);
|
|
248932
|
+
const validation = db2.validate(entityName, filteredBody);
|
|
248933
|
+
if (validation.hasError) {
|
|
248934
|
+
res.status(422).json(validation.error);
|
|
248935
|
+
return;
|
|
248936
|
+
}
|
|
248795
248937
|
const record2 = {
|
|
248796
|
-
...
|
|
248938
|
+
...filteredBody,
|
|
248797
248939
|
id: nanoid3(),
|
|
248798
248940
|
created_date: now,
|
|
248799
248941
|
updated_date: now
|
|
@@ -248814,12 +248956,21 @@ function createEntityRoutes(db2, logger, remoteProxy, broadcast) {
|
|
|
248814
248956
|
}
|
|
248815
248957
|
try {
|
|
248816
248958
|
const now = new Date().toISOString();
|
|
248817
|
-
const records =
|
|
248818
|
-
|
|
248819
|
-
|
|
248820
|
-
|
|
248821
|
-
|
|
248822
|
-
|
|
248959
|
+
const records = [];
|
|
248960
|
+
for (const record2 of req.body) {
|
|
248961
|
+
const filteredRecord = db2.prepareRecord(entityName, record2);
|
|
248962
|
+
const validation = db2.validate(entityName, record2);
|
|
248963
|
+
if (validation.hasError) {
|
|
248964
|
+
res.status(422).json(validation.error);
|
|
248965
|
+
return;
|
|
248966
|
+
}
|
|
248967
|
+
records.push({
|
|
248968
|
+
...filteredRecord,
|
|
248969
|
+
id: nanoid3(),
|
|
248970
|
+
created_date: now,
|
|
248971
|
+
updated_date: now
|
|
248972
|
+
});
|
|
248973
|
+
}
|
|
248823
248974
|
const inserted = stripInternalFields(await collection.insertAsync(records));
|
|
248824
248975
|
emit(appId, entityName, "create", inserted);
|
|
248825
248976
|
res.status(201).json(inserted);
|
|
@@ -248832,8 +248983,14 @@ function createEntityRoutes(db2, logger, remoteProxy, broadcast) {
|
|
|
248832
248983
|
const { appId, entityName, id: id2 } = req.params;
|
|
248833
248984
|
const { id: _id, created_date: _created_date, ...body } = req.body;
|
|
248834
248985
|
try {
|
|
248986
|
+
const filteredBody = db2.prepareRecord(entityName, body, true);
|
|
248987
|
+
const validation = db2.validate(entityName, filteredBody, true);
|
|
248988
|
+
if (validation.hasError) {
|
|
248989
|
+
res.status(422).json(validation.error);
|
|
248990
|
+
return;
|
|
248991
|
+
}
|
|
248835
248992
|
const updateData = {
|
|
248836
|
-
...
|
|
248993
|
+
...filteredBody,
|
|
248837
248994
|
updated_date: new Date().toISOString()
|
|
248838
248995
|
};
|
|
248839
248996
|
const result = await collection.updateAsync({ id: id2 }, { $set: updateData }, { returnUpdatedDocs: true });
|
|
@@ -255142,4 +255299,4 @@ export {
|
|
|
255142
255299
|
CLIExitError
|
|
255143
255300
|
};
|
|
255144
255301
|
|
|
255145
|
-
//# debugId=
|
|
255302
|
+
//# debugId=789ED61B2490152E64756E2164756E21
|