@base44-preview/cli 0.0.45-pr.406.7acd6ec → 0.0.45-pr.406.ed52e60
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 +65 -63
- package/dist/cli/index.js.map +8 -8
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -179494,19 +179494,19 @@ var require_base64id = __commonJS((exports, module) => {
|
|
|
179494
179494
|
/*!
|
|
179495
179495
|
* base64id v0.1.0
|
|
179496
179496
|
*/
|
|
179497
|
-
var
|
|
179497
|
+
var crypto2 = __require("crypto");
|
|
179498
179498
|
var Base64Id = function() {};
|
|
179499
179499
|
Base64Id.prototype.getRandomBytes = function(bytes) {
|
|
179500
179500
|
var BUFFER_SIZE = 4096;
|
|
179501
179501
|
var self2 = this;
|
|
179502
179502
|
bytes = bytes || 12;
|
|
179503
179503
|
if (bytes > BUFFER_SIZE) {
|
|
179504
|
-
return
|
|
179504
|
+
return crypto2.randomBytes(bytes);
|
|
179505
179505
|
}
|
|
179506
179506
|
var bytesInBuffer = parseInt(BUFFER_SIZE / bytes);
|
|
179507
179507
|
var threshold = parseInt(bytesInBuffer * 0.85);
|
|
179508
179508
|
if (!threshold) {
|
|
179509
|
-
return
|
|
179509
|
+
return crypto2.randomBytes(bytes);
|
|
179510
179510
|
}
|
|
179511
179511
|
if (this.bytesBufferIndex == null) {
|
|
179512
179512
|
this.bytesBufferIndex = -1;
|
|
@@ -179518,14 +179518,14 @@ var require_base64id = __commonJS((exports, module) => {
|
|
|
179518
179518
|
if (this.bytesBufferIndex == -1 || this.bytesBufferIndex > threshold) {
|
|
179519
179519
|
if (!this.isGeneratingBytes) {
|
|
179520
179520
|
this.isGeneratingBytes = true;
|
|
179521
|
-
|
|
179521
|
+
crypto2.randomBytes(BUFFER_SIZE, function(err, bytes2) {
|
|
179522
179522
|
self2.bytesBuffer = bytes2;
|
|
179523
179523
|
self2.bytesBufferIndex = 0;
|
|
179524
179524
|
self2.isGeneratingBytes = false;
|
|
179525
179525
|
});
|
|
179526
179526
|
}
|
|
179527
179527
|
if (this.bytesBufferIndex == -1) {
|
|
179528
|
-
return
|
|
179528
|
+
return crypto2.randomBytes(bytes);
|
|
179529
179529
|
}
|
|
179530
179530
|
}
|
|
179531
179531
|
var result = this.bytesBuffer.slice(bytes * this.bytesBufferIndex, bytes * (this.bytesBufferIndex + 1));
|
|
@@ -179539,7 +179539,7 @@ var require_base64id = __commonJS((exports, module) => {
|
|
|
179539
179539
|
}
|
|
179540
179540
|
this.sequenceNumber = this.sequenceNumber + 1 | 0;
|
|
179541
179541
|
rand.writeInt32BE(this.sequenceNumber, 11);
|
|
179542
|
-
if (
|
|
179542
|
+
if (crypto2.randomBytes) {
|
|
179543
179543
|
this.getRandomBytes(12).copy(rand);
|
|
179544
179544
|
} else {
|
|
179545
179545
|
[0, 4, 8].forEach(function(i5) {
|
|
@@ -249177,6 +249177,36 @@ function createFunctionRouter(manager, logger) {
|
|
|
249177
249177
|
// src/cli/dev/dev-server/db/database.ts
|
|
249178
249178
|
var import_nedb = __toESM(require_nedb(), 1);
|
|
249179
249179
|
|
|
249180
|
+
// ../../node_modules/nanoid/index.js
|
|
249181
|
+
import { webcrypto as crypto } from "node:crypto";
|
|
249182
|
+
|
|
249183
|
+
// ../../node_modules/nanoid/url-alphabet/index.js
|
|
249184
|
+
var urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
249185
|
+
|
|
249186
|
+
// ../../node_modules/nanoid/index.js
|
|
249187
|
+
var POOL_SIZE_MULTIPLIER = 128;
|
|
249188
|
+
var pool;
|
|
249189
|
+
var poolOffset;
|
|
249190
|
+
function fillPool(bytes) {
|
|
249191
|
+
if (!pool || pool.length < bytes) {
|
|
249192
|
+
pool = Buffer.allocUnsafe(bytes * POOL_SIZE_MULTIPLIER);
|
|
249193
|
+
crypto.getRandomValues(pool);
|
|
249194
|
+
poolOffset = 0;
|
|
249195
|
+
} else if (poolOffset + bytes > pool.length) {
|
|
249196
|
+
crypto.getRandomValues(pool);
|
|
249197
|
+
poolOffset = 0;
|
|
249198
|
+
}
|
|
249199
|
+
poolOffset += bytes;
|
|
249200
|
+
}
|
|
249201
|
+
function nanoid3(size = 21) {
|
|
249202
|
+
fillPool(size |= 0);
|
|
249203
|
+
let id2 = "";
|
|
249204
|
+
for (let i5 = poolOffset - size;i5 < poolOffset; i5++) {
|
|
249205
|
+
id2 += urlAlphabet[pool[i5] & 63];
|
|
249206
|
+
}
|
|
249207
|
+
return id2;
|
|
249208
|
+
}
|
|
249209
|
+
|
|
249180
249210
|
// src/cli/dev/dev-server/db/validator.ts
|
|
249181
249211
|
var fieldTypes = [
|
|
249182
249212
|
"string",
|
|
@@ -249329,11 +249359,25 @@ class Database {
|
|
|
249329
249359
|
collections = new Map;
|
|
249330
249360
|
schemas = new Map;
|
|
249331
249361
|
validator = new Validator;
|
|
249332
|
-
load(entities) {
|
|
249333
|
-
|
|
249362
|
+
async load(entities) {
|
|
249363
|
+
const userDataStore = new import_nedb.default;
|
|
249364
|
+
this.collections.set(USER_COLLECTION, userDataStore);
|
|
249365
|
+
const userInfo = await readAuth();
|
|
249366
|
+
const now = new Date().toISOString().replace("Z", "000");
|
|
249367
|
+
await userDataStore.insertAsync({
|
|
249368
|
+
id: nanoid3(),
|
|
249369
|
+
email: userInfo.email,
|
|
249370
|
+
full_name: userInfo.name,
|
|
249371
|
+
is_service: false,
|
|
249372
|
+
is_verified: true,
|
|
249373
|
+
disabled: null,
|
|
249374
|
+
role: "admin",
|
|
249375
|
+
collaborator_role: "editor",
|
|
249376
|
+
created_date: now,
|
|
249377
|
+
updated_date: now
|
|
249378
|
+
});
|
|
249334
249379
|
for (const entity2 of entities) {
|
|
249335
249380
|
const entityName = this.normalizeName(entity2.name);
|
|
249336
|
-
this.collections.set(entityName, new import_nedb.default);
|
|
249337
249381
|
const clonedEntity = structuredClone(entity2);
|
|
249338
249382
|
if (entityName === USER_COLLECTION) {
|
|
249339
249383
|
["full_name", "email"].forEach((predefinedField) => {
|
|
@@ -249344,6 +249388,8 @@ class Database {
|
|
|
249344
249388
|
clonedEntity.properties.full_name = { type: "string" };
|
|
249345
249389
|
clonedEntity.properties.email = { type: "string" };
|
|
249346
249390
|
clonedEntity.properties.role = { type: "string" };
|
|
249391
|
+
} else {
|
|
249392
|
+
this.collections.set(entityName, new import_nedb.default);
|
|
249347
249393
|
}
|
|
249348
249394
|
this.schemas.set(entityName, clonedEntity);
|
|
249349
249395
|
}
|
|
@@ -249433,36 +249479,6 @@ function broadcastEntityEvent(io6, appId, entityName, event) {
|
|
|
249433
249479
|
// src/cli/dev/dev-server/routes/entities/entities-router.ts
|
|
249434
249480
|
var import_express3 = __toESM(require_express(), 1);
|
|
249435
249481
|
|
|
249436
|
-
// ../../node_modules/nanoid/index.js
|
|
249437
|
-
import { webcrypto as crypto } from "node:crypto";
|
|
249438
|
-
|
|
249439
|
-
// ../../node_modules/nanoid/url-alphabet/index.js
|
|
249440
|
-
var urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
249441
|
-
|
|
249442
|
-
// ../../node_modules/nanoid/index.js
|
|
249443
|
-
var POOL_SIZE_MULTIPLIER = 128;
|
|
249444
|
-
var pool;
|
|
249445
|
-
var poolOffset;
|
|
249446
|
-
function fillPool(bytes) {
|
|
249447
|
-
if (!pool || pool.length < bytes) {
|
|
249448
|
-
pool = Buffer.allocUnsafe(bytes * POOL_SIZE_MULTIPLIER);
|
|
249449
|
-
crypto.getRandomValues(pool);
|
|
249450
|
-
poolOffset = 0;
|
|
249451
|
-
} else if (poolOffset + bytes > pool.length) {
|
|
249452
|
-
crypto.getRandomValues(pool);
|
|
249453
|
-
poolOffset = 0;
|
|
249454
|
-
}
|
|
249455
|
-
poolOffset += bytes;
|
|
249456
|
-
}
|
|
249457
|
-
function nanoid3(size = 21) {
|
|
249458
|
-
fillPool(size |= 0);
|
|
249459
|
-
let id2 = "";
|
|
249460
|
-
for (let i5 = poolOffset - size;i5 < poolOffset; i5++) {
|
|
249461
|
-
id2 += urlAlphabet[pool[i5] & 63];
|
|
249462
|
-
}
|
|
249463
|
-
return id2;
|
|
249464
|
-
}
|
|
249465
|
-
|
|
249466
249482
|
// src/cli/dev/dev-server/routes/entities/entities-user-router.ts
|
|
249467
249483
|
var import_express2 = __toESM(require_express(), 1);
|
|
249468
249484
|
|
|
@@ -249477,29 +249493,15 @@ function stripInternalFields(doc2) {
|
|
|
249477
249493
|
|
|
249478
249494
|
// src/cli/dev/dev-server/routes/entities/entities-user-router.ts
|
|
249479
249495
|
async function createUserRouter(db2) {
|
|
249480
|
-
const userInfo = await readAuth();
|
|
249481
|
-
const meEntity = await db2.getCollection("User")?.findOneAsync({ email: userInfo.email });
|
|
249482
|
-
let idMe = meEntity?.id;
|
|
249483
|
-
if (!idMe) {
|
|
249484
|
-
const now = new Date().toISOString().replace("Z", "000");
|
|
249485
|
-
idMe = nanoid3();
|
|
249486
|
-
await db2.getCollection("User")?.insertAsync({
|
|
249487
|
-
id: idMe,
|
|
249488
|
-
email: userInfo.email,
|
|
249489
|
-
full_name: userInfo.name,
|
|
249490
|
-
is_service: false,
|
|
249491
|
-
is_verified: true,
|
|
249492
|
-
disabled: null,
|
|
249493
|
-
role: "admin",
|
|
249494
|
-
collaborator_role: "editor",
|
|
249495
|
-
created_date: now,
|
|
249496
|
-
updated_date: now
|
|
249497
|
-
});
|
|
249498
|
-
}
|
|
249499
249496
|
const router = import_express2.Router({ mergeParams: true });
|
|
249500
249497
|
router.get("/:id", async (req, res) => {
|
|
249501
|
-
|
|
249502
|
-
|
|
249498
|
+
let result;
|
|
249499
|
+
if (req.params.id === "me") {
|
|
249500
|
+
const userInfo = await readAuth();
|
|
249501
|
+
result = await db2.getCollection("User")?.findOneAsync({ email: userInfo.email });
|
|
249502
|
+
} else {
|
|
249503
|
+
result = await db2.getCollection("User")?.findOneAsync({ id: req.params.id });
|
|
249504
|
+
}
|
|
249503
249505
|
if (!result) {
|
|
249504
249506
|
res.status(404).json({ error: `User with id "${req.params.id}" not found` });
|
|
249505
249507
|
return;
|
|
@@ -251573,7 +251575,7 @@ async function createDevServer(options8) {
|
|
|
251573
251575
|
R2.info(`Loaded functions: ${functionManager.getFunctionNames().join(", ")}`);
|
|
251574
251576
|
}
|
|
251575
251577
|
const db2 = new Database;
|
|
251576
|
-
db2.load(entities);
|
|
251578
|
+
await db2.load(entities);
|
|
251577
251579
|
if (db2.getCollectionNames().length > 0) {
|
|
251578
251580
|
R2.info(`Loaded entities: ${db2.getCollectionNames().join(", ")}`);
|
|
251579
251581
|
}
|
|
@@ -251648,7 +251650,7 @@ async function createDevServer(options8) {
|
|
|
251648
251650
|
if (previousEntityCount > 0) {
|
|
251649
251651
|
devLogger.log("Entities directory changed, clearing data...");
|
|
251650
251652
|
}
|
|
251651
|
-
db2.load(entities2);
|
|
251653
|
+
await db2.load(entities2);
|
|
251652
251654
|
if (db2.getCollectionNames().length > 0) {
|
|
251653
251655
|
devLogger.log(`Loaded entities: ${db2.getCollectionNames().join(", ")}`);
|
|
251654
251656
|
}
|
|
@@ -256050,4 +256052,4 @@ export {
|
|
|
256050
256052
|
CLIExitError
|
|
256051
256053
|
};
|
|
256052
256054
|
|
|
256053
|
-
//# debugId=
|
|
256055
|
+
//# debugId=1D8798AB57E4532E64756E2164756E21
|