@llmops/app 0.4.8-beta.4 → 0.4.8-beta.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/index.cjs +34 -2
- package/dist/index.mjs +34 -2
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -18406,6 +18406,11 @@ const createSeedMiddleware = () => {
|
|
|
18406
18406
|
* This middleware runs once on application startup and automatically
|
|
18407
18407
|
* runs database migrations if needed.
|
|
18408
18408
|
*
|
|
18409
|
+
* For Neon databases, it uses the idempotent SQL schema approach which
|
|
18410
|
+
* works better with stateless HTTP connections.
|
|
18411
|
+
*
|
|
18412
|
+
* For other databases, it uses the Kysely-based migration system.
|
|
18413
|
+
*
|
|
18409
18414
|
* IMPORTANT: This middleware should run BEFORE the seed middleware
|
|
18410
18415
|
* but AFTER the database middleware creates the connection.
|
|
18411
18416
|
*/
|
|
@@ -18419,14 +18424,19 @@ const createMigrationMiddleware = (config$1) => {
|
|
|
18419
18424
|
}
|
|
18420
18425
|
if (!migrationPromise) migrationPromise = (async () => {
|
|
18421
18426
|
try {
|
|
18422
|
-
const { detectDatabaseType: detectDatabaseType$1
|
|
18427
|
+
const { detectDatabaseType: detectDatabaseType$1 } = await import("@llmops/core/db");
|
|
18423
18428
|
const rawConnection = config$1.database;
|
|
18424
18429
|
const dbType = detectDatabaseType$1(rawConnection);
|
|
18430
|
+
const schema = config$1.schema ?? "llmops";
|
|
18425
18431
|
if (!dbType) {
|
|
18426
18432
|
console.warn("[Migration] Could not detect database type, skipping auto-migration");
|
|
18427
18433
|
return;
|
|
18428
18434
|
}
|
|
18429
|
-
|
|
18435
|
+
if (dbType === "neon") {
|
|
18436
|
+
await runNeonSchemaMigration(rawConnection, schema);
|
|
18437
|
+
return;
|
|
18438
|
+
}
|
|
18439
|
+
const { runAutoMigrations, createDatabaseFromConnection: createDatabaseFromConnection$1 } = await import("@llmops/core/db");
|
|
18430
18440
|
const db = await createDatabaseFromConnection$1(rawConnection, { schema });
|
|
18431
18441
|
if (!db) {
|
|
18432
18442
|
console.warn("[Migration] Could not create database connection, skipping auto-migration");
|
|
@@ -18447,6 +18457,28 @@ const createMigrationMiddleware = (config$1) => {
|
|
|
18447
18457
|
await next();
|
|
18448
18458
|
};
|
|
18449
18459
|
};
|
|
18460
|
+
/**
|
|
18461
|
+
* Run schema migration for Neon using idempotent SQL
|
|
18462
|
+
*
|
|
18463
|
+
* This approach works better with Neon's stateless HTTP connections
|
|
18464
|
+
* because it doesn't rely on Kysely's introspection.
|
|
18465
|
+
*/
|
|
18466
|
+
async function runNeonSchemaMigration(rawConnection, schema) {
|
|
18467
|
+
const { runSchemaSQL, createNeonSqlFunction } = await import("@llmops/core/db");
|
|
18468
|
+
const sql = await createNeonSqlFunction(rawConnection);
|
|
18469
|
+
if (!sql) {
|
|
18470
|
+
console.warn("[Migration] Could not create Neon SQL function, skipping schema migration");
|
|
18471
|
+
return;
|
|
18472
|
+
}
|
|
18473
|
+
console.log(`[Migration] Running idempotent schema migration for Neon (schema: ${schema})`);
|
|
18474
|
+
try {
|
|
18475
|
+
await runSchemaSQL(sql, schema);
|
|
18476
|
+
console.log("[Migration] Schema migration completed successfully");
|
|
18477
|
+
} catch (error$47) {
|
|
18478
|
+
console.error("[Migration] Schema migration failed:", error$47);
|
|
18479
|
+
throw error$47;
|
|
18480
|
+
}
|
|
18481
|
+
}
|
|
18450
18482
|
|
|
18451
18483
|
//#endregion
|
|
18452
18484
|
//#region src/server/middlewares/auth.ts
|
package/dist/index.mjs
CHANGED
|
@@ -18378,6 +18378,11 @@ const createSeedMiddleware = () => {
|
|
|
18378
18378
|
* This middleware runs once on application startup and automatically
|
|
18379
18379
|
* runs database migrations if needed.
|
|
18380
18380
|
*
|
|
18381
|
+
* For Neon databases, it uses the idempotent SQL schema approach which
|
|
18382
|
+
* works better with stateless HTTP connections.
|
|
18383
|
+
*
|
|
18384
|
+
* For other databases, it uses the Kysely-based migration system.
|
|
18385
|
+
*
|
|
18381
18386
|
* IMPORTANT: This middleware should run BEFORE the seed middleware
|
|
18382
18387
|
* but AFTER the database middleware creates the connection.
|
|
18383
18388
|
*/
|
|
@@ -18391,14 +18396,19 @@ const createMigrationMiddleware = (config$1) => {
|
|
|
18391
18396
|
}
|
|
18392
18397
|
if (!migrationPromise) migrationPromise = (async () => {
|
|
18393
18398
|
try {
|
|
18394
|
-
const { detectDatabaseType: detectDatabaseType$1
|
|
18399
|
+
const { detectDatabaseType: detectDatabaseType$1 } = await import("@llmops/core/db");
|
|
18395
18400
|
const rawConnection = config$1.database;
|
|
18396
18401
|
const dbType = detectDatabaseType$1(rawConnection);
|
|
18402
|
+
const schema = config$1.schema ?? "llmops";
|
|
18397
18403
|
if (!dbType) {
|
|
18398
18404
|
console.warn("[Migration] Could not detect database type, skipping auto-migration");
|
|
18399
18405
|
return;
|
|
18400
18406
|
}
|
|
18401
|
-
|
|
18407
|
+
if (dbType === "neon") {
|
|
18408
|
+
await runNeonSchemaMigration(rawConnection, schema);
|
|
18409
|
+
return;
|
|
18410
|
+
}
|
|
18411
|
+
const { runAutoMigrations, createDatabaseFromConnection: createDatabaseFromConnection$1 } = await import("@llmops/core/db");
|
|
18402
18412
|
const db = await createDatabaseFromConnection$1(rawConnection, { schema });
|
|
18403
18413
|
if (!db) {
|
|
18404
18414
|
console.warn("[Migration] Could not create database connection, skipping auto-migration");
|
|
@@ -18419,6 +18429,28 @@ const createMigrationMiddleware = (config$1) => {
|
|
|
18419
18429
|
await next();
|
|
18420
18430
|
};
|
|
18421
18431
|
};
|
|
18432
|
+
/**
|
|
18433
|
+
* Run schema migration for Neon using idempotent SQL
|
|
18434
|
+
*
|
|
18435
|
+
* This approach works better with Neon's stateless HTTP connections
|
|
18436
|
+
* because it doesn't rely on Kysely's introspection.
|
|
18437
|
+
*/
|
|
18438
|
+
async function runNeonSchemaMigration(rawConnection, schema) {
|
|
18439
|
+
const { runSchemaSQL, createNeonSqlFunction } = await import("@llmops/core/db");
|
|
18440
|
+
const sql = await createNeonSqlFunction(rawConnection);
|
|
18441
|
+
if (!sql) {
|
|
18442
|
+
console.warn("[Migration] Could not create Neon SQL function, skipping schema migration");
|
|
18443
|
+
return;
|
|
18444
|
+
}
|
|
18445
|
+
console.log(`[Migration] Running idempotent schema migration for Neon (schema: ${schema})`);
|
|
18446
|
+
try {
|
|
18447
|
+
await runSchemaSQL(sql, schema);
|
|
18448
|
+
console.log("[Migration] Schema migration completed successfully");
|
|
18449
|
+
} catch (error$47) {
|
|
18450
|
+
console.error("[Migration] Schema migration failed:", error$47);
|
|
18451
|
+
throw error$47;
|
|
18452
|
+
}
|
|
18453
|
+
}
|
|
18422
18454
|
|
|
18423
18455
|
//#endregion
|
|
18424
18456
|
//#region src/server/middlewares/auth.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@llmops/app",
|
|
3
|
-
"version": "0.4.8-beta.
|
|
3
|
+
"version": "0.4.8-beta.6",
|
|
4
4
|
"description": "LLMOps application with server and client",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -76,8 +76,8 @@
|
|
|
76
76
|
"react-hook-form": "^7.68.0",
|
|
77
77
|
"recharts": "^3.6.0",
|
|
78
78
|
"uuid": "^13.0.0",
|
|
79
|
-
"@llmops/
|
|
80
|
-
"@llmops/
|
|
79
|
+
"@llmops/core": "^0.4.8-beta.6",
|
|
80
|
+
"@llmops/gateway": "^0.4.8-beta.6"
|
|
81
81
|
},
|
|
82
82
|
"peerDependencies": {
|
|
83
83
|
"react": "^19.2.1",
|