@vibecodeapp/cloud-studio 0.2.4 → 0.2.6
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/client/index.html
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
mq.addEventListener('change', update);
|
|
16
16
|
})();
|
|
17
17
|
</script>
|
|
18
|
-
<script type="module" crossorigin src="/assets/index-
|
|
18
|
+
<script type="module" crossorigin src="/assets/index-BkzxCr1P.js"></script>
|
|
19
19
|
<link rel="stylesheet" crossorigin href="/assets/index-cxhFZ8pR.css">
|
|
20
20
|
</head>
|
|
21
21
|
<body>
|
package/dist/server/index.js
CHANGED
|
@@ -2403,15 +2403,40 @@ async function loadPrismaClient() {
|
|
|
2403
2403
|
}
|
|
2404
2404
|
throw new PrismaNotConfiguredError(errors);
|
|
2405
2405
|
}
|
|
2406
|
+
var IDLE_DISCONNECT_MS = 0;
|
|
2407
|
+
var sharedClient = null;
|
|
2408
|
+
var activeRequests = 0;
|
|
2409
|
+
var idleTimer = null;
|
|
2410
|
+
var disconnecting = null;
|
|
2406
2411
|
async function withPrisma(fn) {
|
|
2407
2412
|
const ClientConstructor = await loadPrismaClient();
|
|
2408
|
-
|
|
2413
|
+
if (disconnecting)
|
|
2414
|
+
await disconnecting;
|
|
2415
|
+
sharedClient ??= new ClientConstructor({ log: ["error"] });
|
|
2416
|
+
if (idleTimer) {
|
|
2417
|
+
clearTimeout(idleTimer);
|
|
2418
|
+
idleTimer = null;
|
|
2419
|
+
}
|
|
2420
|
+
activeRequests++;
|
|
2409
2421
|
try {
|
|
2410
|
-
return await fn(
|
|
2422
|
+
return await fn(sharedClient);
|
|
2411
2423
|
} finally {
|
|
2412
|
-
|
|
2424
|
+
if (--activeRequests === 0) {
|
|
2425
|
+
idleTimer = setTimeout(disconnectIdleClient, IDLE_DISCONNECT_MS);
|
|
2426
|
+
idleTimer.unref();
|
|
2427
|
+
}
|
|
2413
2428
|
}
|
|
2414
2429
|
}
|
|
2430
|
+
function disconnectIdleClient() {
|
|
2431
|
+
idleTimer = null;
|
|
2432
|
+
if (!sharedClient || activeRequests > 0)
|
|
2433
|
+
return;
|
|
2434
|
+
disconnecting = sharedClient.$disconnect().catch((error) => {
|
|
2435
|
+
console.error("Failed to disconnect idle Prisma client:", error);
|
|
2436
|
+
}).finally(() => {
|
|
2437
|
+
disconnecting = null;
|
|
2438
|
+
});
|
|
2439
|
+
}
|
|
2415
2440
|
async function getDatabaseSchema() {
|
|
2416
2441
|
await loadPrismaClient();
|
|
2417
2442
|
if (!cachedSchema) {
|
|
@@ -2498,6 +2523,25 @@ schemaRoutes.get("/", async (c) => {
|
|
|
2498
2523
|
return handlePrismaError(error, c);
|
|
2499
2524
|
}
|
|
2500
2525
|
});
|
|
2526
|
+
schemaRoutes.get("/counts", async (c) => {
|
|
2527
|
+
try {
|
|
2528
|
+
const schema = await getDatabaseSchema();
|
|
2529
|
+
const counts = {};
|
|
2530
|
+
await withPrisma(async (prisma) => {
|
|
2531
|
+
for (const model of schema.models) {
|
|
2532
|
+
const delegate = prisma[model.name.charAt(0).toLowerCase() + model.name.slice(1)];
|
|
2533
|
+
counts[model.name] = await delegate.count();
|
|
2534
|
+
}
|
|
2535
|
+
});
|
|
2536
|
+
const response = {
|
|
2537
|
+
success: true,
|
|
2538
|
+
data: { counts }
|
|
2539
|
+
};
|
|
2540
|
+
return c.json(response);
|
|
2541
|
+
} catch (error) {
|
|
2542
|
+
return handlePrismaError(error, c);
|
|
2543
|
+
}
|
|
2544
|
+
});
|
|
2501
2545
|
|
|
2502
2546
|
// server/lib/fieldValidator.ts
|
|
2503
2547
|
async function filterEditableFields(tableName, data) {
|
|
@@ -6582,9 +6626,14 @@ var NEVER = INVALID;
|
|
|
6582
6626
|
|
|
6583
6627
|
// server/routes/tables.ts
|
|
6584
6628
|
var tableRoutes = new Hono2();
|
|
6629
|
+
var MAX_LIMIT = 500;
|
|
6630
|
+
function parseCount(val, fallback, max = Number.MAX_SAFE_INTEGER) {
|
|
6631
|
+
const n = parseInt(val ?? "", 10);
|
|
6632
|
+
return Number.isNaN(n) ? fallback : Math.min(Math.max(n, 0), max);
|
|
6633
|
+
}
|
|
6585
6634
|
var listQuerySchema = external_exports.object({
|
|
6586
|
-
offset: external_exports.string().optional().transform((val) =>
|
|
6587
|
-
limit: external_exports.string().optional().transform((val) =>
|
|
6635
|
+
offset: external_exports.string().optional().transform((val) => parseCount(val, 0)),
|
|
6636
|
+
limit: external_exports.string().optional().transform((val) => parseCount(val, 50, MAX_LIMIT)),
|
|
6588
6637
|
orderBy: external_exports.string().optional(),
|
|
6589
6638
|
orderDir: external_exports.enum(["asc", "desc"]).optional().default("asc"),
|
|
6590
6639
|
filters: external_exports.string().optional()
|