@llmops/app 0.1.0-beta.7 → 0.1.0

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.
@@ -0,0 +1,30 @@
1
+ import * as hono_types1 from "hono/types";
2
+ import * as hono_hono_base0 from "hono/hono-base";
3
+ import { LLMOpsConfig, ValidatedLLMOpsConfig, createDataLayer } from "@llmops/core";
4
+ import { Hono } from "hono";
5
+
6
+ //#region src/server/types.d.ts
7
+ interface LLMProvider {
8
+ key: string;
9
+ name: string;
10
+ imageURI: string;
11
+ }
12
+ declare module 'hono' {
13
+ interface ContextVariableMap {
14
+ llmopsConfig: ValidatedLLMOpsConfig;
15
+ llmProviders: LLMProvider[];
16
+ db: Awaited<ReturnType<typeof createDataLayer>>;
17
+ }
18
+ }
19
+ //#endregion
20
+ //#region src/server/index.d.ts
21
+ declare const app: Hono<hono_types1.BlankEnv, hono_types1.BlankSchema, "/">;
22
+ //#endregion
23
+ //#region src/index.d.ts
24
+ declare const createApp: (config: LLMOpsConfig) => {
25
+ app: hono_hono_base0.HonoBase<{}, {
26
+ "*": {};
27
+ } | hono_types1.MergeSchemaPath<hono_types1.BlankSchema, "/">, string>;
28
+ };
29
+ //#endregion
30
+ export { createApp, app as default };
package/dist/index.mjs CHANGED
@@ -13622,6 +13622,55 @@ const createSeedMiddleware = () => {
13622
13622
  };
13623
13623
  };
13624
13624
 
13625
+ //#endregion
13626
+ //#region src/server/middlewares/migration.ts
13627
+ /**
13628
+ * Creates a middleware that handles auto-migration based on config
13629
+ *
13630
+ * This middleware runs once on application startup and handles:
13631
+ * - autoMigrate: true - Always run migrations
13632
+ * - autoMigrate: false - Never run migrations (default)
13633
+ * - autoMigrate: 'development' - Only run when NODE_ENV is 'development'
13634
+ *
13635
+ * IMPORTANT: This middleware should run BEFORE the seed middleware
13636
+ * but AFTER the database middleware creates the connection.
13637
+ */
13638
+ const createMigrationMiddleware = (config$1) => {
13639
+ let migrationComplete = false;
13640
+ let migrationPromise = null;
13641
+ return async (c, next) => {
13642
+ const autoMigrate = config$1.autoMigrate ?? false;
13643
+ if (migrationComplete || autoMigrate === false) {
13644
+ await next();
13645
+ return;
13646
+ }
13647
+ if (!migrationPromise) migrationPromise = (async () => {
13648
+ try {
13649
+ const { detectDatabaseType, runAutoMigrations, createDatabaseFromConnection: createDatabaseFromConnection$1 } = await import("@llmops/core/db");
13650
+ const rawConnection = config$1.database;
13651
+ const dbType = detectDatabaseType(rawConnection);
13652
+ if (!dbType) {
13653
+ console.warn("[Migration] Could not detect database type, skipping auto-migration");
13654
+ return;
13655
+ }
13656
+ const db = await createDatabaseFromConnection$1(rawConnection);
13657
+ if (!db) {
13658
+ console.warn("[Migration] Could not create database connection, skipping auto-migration");
13659
+ return;
13660
+ }
13661
+ const result = await runAutoMigrations(db, dbType, autoMigrate);
13662
+ if (result.ran) console.log(`[Migration] Auto-migration completed: ${result.tables.length} table(s) created, ${result.fields.length} field(s) added`);
13663
+ } catch (error$45) {
13664
+ console.error("[Migration] Auto-migration failed:", error$45);
13665
+ } finally {
13666
+ migrationComplete = true;
13667
+ }
13668
+ })();
13669
+ await migrationPromise;
13670
+ await next();
13671
+ };
13672
+ };
13673
+
13625
13674
  //#endregion
13626
13675
  //#region src/index.ts
13627
13676
  const MODELS_DEV_LOGOS = "https://models.dev/logos";
@@ -13665,7 +13714,7 @@ const createLLMProvidersMiddleware = (config$1) => {
13665
13714
  };
13666
13715
  const createApp = (config$1) => {
13667
13716
  const validatedConfig = validateLLMOpsConfig(config$1);
13668
- return { app: new Hono().use("*", createEnvValidatorMiddleware()).use("*", setConfigMiddleware(validatedConfig)).use("*", createDatabaseMiddleware(validatedConfig)).use("*", createSeedMiddleware()).use("*", createLLMProvidersMiddleware(validatedConfig)).route("/", server_default).basePath(validatedConfig.basePath) };
13717
+ return { app: new Hono().use("*", createEnvValidatorMiddleware()).use("*", setConfigMiddleware(validatedConfig)).use("*", createMigrationMiddleware(validatedConfig)).use("*", createDatabaseMiddleware(validatedConfig)).use("*", createSeedMiddleware()).use("*", createLLMProvidersMiddleware(validatedConfig)).route("/", server_default).basePath(validatedConfig.basePath) };
13669
13718
  };
13670
13719
  var src_default = server_default;
13671
13720
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@llmops/app",
3
- "version": "0.1.0-beta.7",
3
+ "version": "0.1.0",
4
4
  "description": "LLMOps application with server and client",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -17,11 +17,20 @@
17
17
  "files": [
18
18
  "dist"
19
19
  ],
20
- "main": "./dist/index.mjs",
20
+ "main": "./dist/index.cjs",
21
21
  "module": "./dist/index.mjs",
22
22
  "types": "./dist/index.d.mts",
23
23
  "exports": {
24
- ".": "./dist/index.mjs",
24
+ ".": {
25
+ "import": {
26
+ "types": "./dist/index.d.mts",
27
+ "default": "./dist/index.mjs"
28
+ },
29
+ "require": {
30
+ "types": "./dist/index.d.cts",
31
+ "default": "./dist/index.cjs"
32
+ }
33
+ },
25
34
  "./package.json": "./package.json"
26
35
  },
27
36
  "publishConfig": {
@@ -55,8 +64,8 @@
55
64
  "motion": "^12.23.25",
56
65
  "react-aria-components": "^1.13.0",
57
66
  "react-hook-form": "^7.68.0",
58
- "@llmops/core": "0.1.0-beta.7",
59
- "@llmops/gateway": "0.1.0-beta.7"
67
+ "@llmops/gateway": "^0.1.0",
68
+ "@llmops/core": "^0.1.0"
60
69
  },
61
70
  "peerDependencies": {
62
71
  "react": "^19.2.1",