@llmops/core 0.6.7 → 0.6.8

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.
@@ -1,4 +1,4 @@
1
- const require_db = require('./db-i0OOYxJm.cjs');
1
+ const require_db = require('./db-DsEVRoua.cjs');
2
2
  let kysely = require("kysely");
3
3
 
4
4
  //#region src/db/bun-sqlite-dialect.ts
package/dist/db/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
- const require_db = require('../db-i0OOYxJm.cjs');
2
- const require_neon_dialect = require('../neon-dialect-oh8u9vRy.cjs');
1
+ const require_db = require('../db-DsEVRoua.cjs');
2
+ const require_neon_dialect = require('../neon-dialect-Dn80Acj9.cjs');
3
3
 
4
4
  exports.SCHEMA_METADATA = require_db.SCHEMA_METADATA;
5
5
  exports.configVariantsSchema = require_db.configVariantsSchema;
package/dist/db/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { A as schemas, C as llmRequestsSchema, D as playgroundsSchema, E as playgroundRunsSchema, F as variantVersionsSchema, I as variantsSchema, L as workspaceSettingsSchema, M as spansSchema, N as targetingRulesSchema, O as providerConfigsSchema, P as tracesSchema, S as guardrailConfigsSchema, T as playgroundResultsSchema, _ as datasetVersionRecordsSchema, a as matchType, b as environmentSecretsSchema, d as validatePartialTableData, f as validateTableData, g as datasetRecordsSchema, h as configsSchema, i as getMigrations, j as spanEventsSchema, k as providerGuardrailOverridesSchema, l as parsePartialTableData, m as configVariantsSchema, n as createDatabaseFromConnection, o as runAutoMigrations, p as SCHEMA_METADATA, r as detectDatabaseType, t as createDatabase, u as parseTableData, v as datasetVersionsSchema, w as playgroundColumnSchema, x as environmentsSchema, y as datasetsSchema } from "../db-Cd1KR24Y.mjs";
1
+ import { A as schemas, C as llmRequestsSchema, D as playgroundsSchema, E as playgroundRunsSchema, F as variantVersionsSchema, I as variantsSchema, L as workspaceSettingsSchema, M as spansSchema, N as targetingRulesSchema, O as providerConfigsSchema, P as tracesSchema, S as guardrailConfigsSchema, T as playgroundResultsSchema, _ as datasetVersionRecordsSchema, a as matchType, b as environmentSecretsSchema, d as validatePartialTableData, f as validateTableData, g as datasetRecordsSchema, h as configsSchema, i as getMigrations, j as spanEventsSchema, k as providerGuardrailOverridesSchema, l as parsePartialTableData, m as configVariantsSchema, n as createDatabaseFromConnection, o as runAutoMigrations, p as SCHEMA_METADATA, r as detectDatabaseType, t as createDatabase, u as parseTableData, v as datasetVersionsSchema, w as playgroundColumnSchema, x as environmentsSchema, y as datasetsSchema } from "../db-H8SfNI38.mjs";
2
2
  import { n as executeWithSchema, t as createNeonDialect } from "../neon-dialect-DySGBYUi.mjs";
3
3
 
4
4
  export { SCHEMA_METADATA, configVariantsSchema, configsSchema, createDatabase, createDatabaseFromConnection, createNeonDialect, datasetRecordsSchema, datasetVersionRecordsSchema, datasetVersionsSchema, datasetsSchema, detectDatabaseType, environmentSecretsSchema, environmentsSchema, executeWithSchema, getMigrations, guardrailConfigsSchema, llmRequestsSchema, matchType, parsePartialTableData, parseTableData, playgroundColumnSchema, playgroundResultsSchema, playgroundRunsSchema, playgroundsSchema, providerConfigsSchema, providerGuardrailOverridesSchema, runAutoMigrations, schemas, spanEventsSchema, spansSchema, targetingRulesSchema, tracesSchema, validatePartialTableData, validateTableData, variantVersionsSchema, variantsSchema, workspaceSettingsSchema };
@@ -39,7 +39,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
39
39
 
40
40
  //#endregion
41
41
  let kysely = require("kysely");
42
- let better_auth_db = require("better-auth/db");
43
42
  let pino = require("pino");
44
43
  pino = __toESM(pino);
45
44
 
@@ -14545,10 +14544,29 @@ async function getMigrations(db, dbType, options) {
14545
14544
  } catch (error$47) {
14546
14545
  logger.warn({ error: error$47 }, "Failed to set search_path for Better Auth migrations");
14547
14546
  }
14548
- const { toBeAdded: authChangesToBeAdded, toBeCreated: authChangesToBeCreated, runMigrations: runAuthMigrations } = await (0, better_auth_db.getMigrations)(getAuthClientOptions({ database: {
14547
+ let getAuthMigrations;
14548
+ try {
14549
+ ({getMigrations: getAuthMigrations} = await import("better-auth/db"));
14550
+ } catch (error$47) {
14551
+ logger.warn({ error: error$47 }, "Failed to import better-auth/db; skipping auth migrations");
14552
+ return {
14553
+ toBeCreated,
14554
+ toBeAdded,
14555
+ runMigrations: async () => {
14556
+ for (const migration of migrations) await migration.execute();
14557
+ },
14558
+ compileMigrations: async () => {
14559
+ return migrations.map((m) => m.compile().sql).join(";\n\n") + ";";
14560
+ },
14561
+ migrations,
14562
+ needsMigration: toBeCreated.length > 0 || toBeAdded.length > 0
14563
+ };
14564
+ }
14565
+ const authOptions = getAuthClientOptions({ database: {
14549
14566
  db,
14550
14567
  type: dbType === "neon" ? "postgres" : dbType
14551
- } }));
14568
+ } });
14569
+ const { toBeAdded: authChangesToBeAdded, toBeCreated: authChangesToBeCreated, runMigrations: runAuthMigrations } = await getAuthMigrations(authOptions);
14552
14570
  async function runMigrations() {
14553
14571
  for (const migration of migrations) await migration.execute();
14554
14572
  await runAuthMigrations();
@@ -14695,12 +14713,12 @@ async function createDatabaseFromConnection(rawConnection, options) {
14695
14713
  case "sqlite":
14696
14714
  if ("aggregate" in rawConnection && !("createSession" in rawConnection)) dialect = new kysely.SqliteDialect({ database: rawConnection });
14697
14715
  else if ("fileControl" in rawConnection) {
14698
- const { BunSqliteDialect } = await Promise.resolve().then(() => require("./bun-sqlite-dialect-BUnuGpx1.cjs"));
14716
+ const { BunSqliteDialect } = await Promise.resolve().then(() => require("./bun-sqlite-dialect-CweOAhRE.cjs"));
14699
14717
  dialect = new BunSqliteDialect({ database: rawConnection });
14700
14718
  } else if ("createSession" in rawConnection && typeof window === "undefined") try {
14701
14719
  const { DatabaseSync } = await import("node:sqlite");
14702
14720
  if (rawConnection instanceof DatabaseSync) {
14703
- const { NodeSqliteDialect } = await Promise.resolve().then(() => require("./node-sqlite-dialect-CbwETvHG.cjs"));
14721
+ const { NodeSqliteDialect } = await Promise.resolve().then(() => require("./node-sqlite-dialect-DyFzt-h5.cjs"));
14704
14722
  dialect = new NodeSqliteDialect({ database: rawConnection });
14705
14723
  }
14706
14724
  } catch {}
@@ -14718,7 +14736,7 @@ async function createDatabaseFromConnection(rawConnection, options) {
14718
14736
  break;
14719
14737
  case "neon": {
14720
14738
  if (typeof rawConnection === "function") {
14721
- const { createNeonDialect: createNeonDialect$1 } = await Promise.resolve().then(() => require("./neon-dialect-DavGzunb.cjs"));
14739
+ const { createNeonDialect: createNeonDialect$1 } = await Promise.resolve().then(() => require("./neon-dialect-Bk6Cncio.cjs"));
14722
14740
  dialect = createNeonDialect$1(rawConnection);
14723
14741
  break;
14724
14742
  }
@@ -14726,7 +14744,7 @@ async function createDatabaseFromConnection(rawConnection, options) {
14726
14744
  if (!connectionString) throw new Error("Neon connection string is required. Pass it directly as the database option or set one of: NEON_CONNECTION_STRING, NEON_PG_URL, DATABASE_URL, POSTGRES_URL");
14727
14745
  const { neon } = await import("@neondatabase/serverless");
14728
14746
  const sql$1 = neon(connectionString);
14729
- const { createNeonDialect } = await Promise.resolve().then(() => require("./neon-dialect-DavGzunb.cjs"));
14747
+ const { createNeonDialect } = await Promise.resolve().then(() => require("./neon-dialect-Bk6Cncio.cjs"));
14730
14748
  dialect = createNeonDialect(sql$1);
14731
14749
  break;
14732
14750
  }
@@ -1,5 +1,4 @@
1
1
  import { CompiledQuery, Kysely, MssqlDialect, MysqlDialect, PostgresDialect, SqliteDialect, sql } from "kysely";
2
- import { getMigrations } from "better-auth/db";
3
2
  import pino from "pino";
4
3
 
5
4
  //#region rolldown:runtime
@@ -14369,7 +14368,7 @@ async function ensurePostgresSchemaExists(db, schema) {
14369
14368
  logger.warn({ error: error$47 }, "Failed to ensure PostgreSQL schema exists");
14370
14369
  }
14371
14370
  }
14372
- async function getMigrations$1(db, dbType, options) {
14371
+ async function getMigrations(db, dbType, options) {
14373
14372
  let currentSchema = "public";
14374
14373
  if (dbType === "postgres" || dbType === "neon") {
14375
14374
  if (options?.schema) {
@@ -14521,10 +14520,29 @@ async function getMigrations$1(db, dbType, options) {
14521
14520
  } catch (error$47) {
14522
14521
  logger.warn({ error: error$47 }, "Failed to set search_path for Better Auth migrations");
14523
14522
  }
14524
- const { toBeAdded: authChangesToBeAdded, toBeCreated: authChangesToBeCreated, runMigrations: runAuthMigrations } = await getMigrations(getAuthClientOptions({ database: {
14523
+ let getAuthMigrations;
14524
+ try {
14525
+ ({getMigrations: getAuthMigrations} = await import("better-auth/db"));
14526
+ } catch (error$47) {
14527
+ logger.warn({ error: error$47 }, "Failed to import better-auth/db; skipping auth migrations");
14528
+ return {
14529
+ toBeCreated,
14530
+ toBeAdded,
14531
+ runMigrations: async () => {
14532
+ for (const migration of migrations) await migration.execute();
14533
+ },
14534
+ compileMigrations: async () => {
14535
+ return migrations.map((m) => m.compile().sql).join(";\n\n") + ";";
14536
+ },
14537
+ migrations,
14538
+ needsMigration: toBeCreated.length > 0 || toBeAdded.length > 0
14539
+ };
14540
+ }
14541
+ const authOptions = getAuthClientOptions({ database: {
14525
14542
  db,
14526
14543
  type: dbType === "neon" ? "postgres" : dbType
14527
- } }));
14544
+ } });
14545
+ const { toBeAdded: authChangesToBeAdded, toBeCreated: authChangesToBeCreated, runMigrations: runAuthMigrations } = await getAuthMigrations(authOptions);
14528
14546
  async function runMigrations() {
14529
14547
  for (const migration of migrations) await migration.execute();
14530
14548
  await runAuthMigrations();
@@ -14593,7 +14611,7 @@ async function runAutoMigrations(db, dbType, options) {
14593
14611
  } catch (error$47) {
14594
14612
  logger.debug(`Constraint fixup skipped or failed: ${error$47}`);
14595
14613
  }
14596
- const { toBeCreated, toBeAdded, runMigrations, needsMigration } = await getMigrations$1(db, dbType, options);
14614
+ const { toBeCreated, toBeAdded, runMigrations, needsMigration } = await getMigrations(db, dbType, options);
14597
14615
  if (!needsMigration) {
14598
14616
  logger.debug("Auto-migration: No migrations needed");
14599
14617
  return {
@@ -14714,4 +14732,4 @@ async function createDatabaseFromConnection(rawConnection, options) {
14714
14732
  }
14715
14733
 
14716
14734
  //#endregion
14717
- export { schemas as A, any as B, llmRequestsSchema as C, playgroundsSchema as D, playgroundRunsSchema as E, variantVersionsSchema as F, object as G, boolean$1 as H, variantsSchema as I, union as J, record as K, workspaceSettingsSchema as L, spansSchema as M, targetingRulesSchema as N, providerConfigsSchema as O, tracesSchema as P, zod_default as R, guardrailConfigsSchema as S, playgroundResultsSchema as T, literal as U, array as V, number$1 as W, unknown as Y, datasetVersionRecordsSchema as _, matchType as a, environmentSecretsSchema as b, logger as c, validatePartialTableData as d, validateTableData as f, datasetRecordsSchema as g, configsSchema as h, getMigrations$1 as i, spanEventsSchema as j, providerGuardrailOverridesSchema as k, parsePartialTableData as l, configVariantsSchema as m, createDatabaseFromConnection as n, runAutoMigrations as o, SCHEMA_METADATA as p, string$1 as q, detectDatabaseType as r, getAuthClientOptions as s, createDatabase as t, parseTableData as u, datasetVersionsSchema as v, playgroundColumnSchema as w, environmentsSchema as x, datasetsSchema as y, _enum as z };
14735
+ export { schemas as A, any as B, llmRequestsSchema as C, playgroundsSchema as D, playgroundRunsSchema as E, variantVersionsSchema as F, object as G, boolean$1 as H, variantsSchema as I, union as J, record as K, workspaceSettingsSchema as L, spansSchema as M, targetingRulesSchema as N, providerConfigsSchema as O, tracesSchema as P, zod_default as R, guardrailConfigsSchema as S, playgroundResultsSchema as T, literal as U, array as V, number$1 as W, unknown as Y, datasetVersionRecordsSchema as _, matchType as a, environmentSecretsSchema as b, logger as c, validatePartialTableData as d, validateTableData as f, datasetRecordsSchema as g, configsSchema as h, getMigrations as i, spanEventsSchema as j, providerGuardrailOverridesSchema as k, parsePartialTableData as l, configVariantsSchema as m, createDatabaseFromConnection as n, runAutoMigrations as o, SCHEMA_METADATA as p, string$1 as q, detectDatabaseType as r, getAuthClientOptions as s, createDatabase as t, parseTableData as u, datasetVersionsSchema as v, playgroundColumnSchema as w, environmentsSchema as x, datasetsSchema as y, _enum as z };
package/dist/index.cjs CHANGED
@@ -1,10 +1,8 @@
1
- const require_db = require('./db-i0OOYxJm.cjs');
2
- const require_neon_dialect = require('./neon-dialect-oh8u9vRy.cjs');
1
+ const require_db = require('./db-DsEVRoua.cjs');
2
+ const require_neon_dialect = require('./neon-dialect-Dn80Acj9.cjs');
3
3
  let __llmops_gateway = require("@llmops/gateway");
4
4
  __llmops_gateway = require_db.__toESM(__llmops_gateway);
5
5
  let kysely = require("kysely");
6
- let node_fs_promises = require("node:fs/promises");
7
- node_fs_promises = require_db.__toESM(node_fs_promises);
8
6
  let node_path = require("node:path");
9
7
  node_path = require_db.__toESM(node_path);
10
8
  let __better_auth_utils_random = require("@better-auth/utils/random");
@@ -643,7 +641,7 @@ const llmopsConfigBaseSchema = require_db.object({
643
641
  const llmopsConfigSchema = llmopsConfigBaseSchema.transform((config) => ({
644
642
  ...config,
645
643
  providers: mergeWithDefaultProviders(config.providers)
646
- })).refine((config) => config.database !== void 0 || config.providers && config.providers.length > 0, "Either database or providers must be configured. Set a database connection, configure providers explicitly, or set API key environment variables (e.g., OPENAI_API_KEY).");
644
+ }));
647
645
  function validateLLMOpsConfig(config) {
648
646
  const result = llmopsConfigSchema.safeParse(config ?? {});
649
647
  if (!result.success) {
@@ -864,14 +862,16 @@ var FileCacheBackend = class {
864
862
  if (!this.loaded) await this.loadPromise;
865
863
  }
866
864
  async ensureDataDir() {
865
+ const { mkdir } = await import("node:fs/promises");
867
866
  const dir = node_path.dirname(this.cacheFile);
868
867
  try {
869
- await node_fs_promises.mkdir(dir, { recursive: true });
868
+ await mkdir(dir, { recursive: true });
870
869
  } catch {}
871
870
  }
872
871
  async loadCache() {
873
872
  try {
874
- const content = await node_fs_promises.readFile(this.cacheFile, "utf-8");
873
+ const { readFile } = await import("node:fs/promises");
874
+ const content = await readFile(this.cacheFile, "utf-8");
875
875
  this.data = JSON.parse(content);
876
876
  this.updateStats();
877
877
  this.loaded = true;
@@ -883,7 +883,8 @@ var FileCacheBackend = class {
883
883
  async saveCache() {
884
884
  try {
885
885
  await this.ensureDataDir();
886
- await node_fs_promises.writeFile(this.cacheFile, JSON.stringify(this.data, null, 2));
886
+ const { writeFile } = await import("node:fs/promises");
887
+ await writeFile(this.cacheFile, JSON.stringify(this.data, null, 2));
887
888
  } catch {}
888
889
  }
889
890
  scheduleSave() {
package/dist/index.mjs CHANGED
@@ -1,8 +1,7 @@
1
- import { A as schemas, B as any, C as llmRequestsSchema, D as playgroundsSchema, E as playgroundRunsSchema, F as variantVersionsSchema, G as object, H as boolean, I as variantsSchema, J as union, K as record, L as workspaceSettingsSchema, M as spansSchema, N as targetingRulesSchema, O as providerConfigsSchema, P as tracesSchema, R as zod_default, S as guardrailConfigsSchema, T as playgroundResultsSchema, U as literal, V as array, W as number, Y as unknown, _ as datasetVersionRecordsSchema, a as matchType, b as environmentSecretsSchema, c as logger, d as validatePartialTableData, f as validateTableData, g as datasetRecordsSchema, h as configsSchema, i as getMigrations, j as spanEventsSchema, k as providerGuardrailOverridesSchema, l as parsePartialTableData, m as configVariantsSchema, n as createDatabaseFromConnection, o as runAutoMigrations, p as SCHEMA_METADATA, q as string, r as detectDatabaseType, s as getAuthClientOptions, t as createDatabase, u as parseTableData, v as datasetVersionsSchema, w as playgroundColumnSchema, x as environmentsSchema, y as datasetsSchema, z as _enum } from "./db-Cd1KR24Y.mjs";
1
+ import { A as schemas, B as any, C as llmRequestsSchema, D as playgroundsSchema, E as playgroundRunsSchema, F as variantVersionsSchema, G as object, H as boolean, I as variantsSchema, J as union, K as record, L as workspaceSettingsSchema, M as spansSchema, N as targetingRulesSchema, O as providerConfigsSchema, P as tracesSchema, R as zod_default, S as guardrailConfigsSchema, T as playgroundResultsSchema, U as literal, V as array, W as number, Y as unknown, _ as datasetVersionRecordsSchema, a as matchType, b as environmentSecretsSchema, c as logger, d as validatePartialTableData, f as validateTableData, g as datasetRecordsSchema, h as configsSchema, i as getMigrations, j as spanEventsSchema, k as providerGuardrailOverridesSchema, l as parsePartialTableData, m as configVariantsSchema, n as createDatabaseFromConnection, o as runAutoMigrations, p as SCHEMA_METADATA, q as string, r as detectDatabaseType, s as getAuthClientOptions, t as createDatabase, u as parseTableData, v as datasetVersionsSchema, w as playgroundColumnSchema, x as environmentsSchema, y as datasetsSchema, z as _enum } from "./db-H8SfNI38.mjs";
2
2
  import { n as executeWithSchema, t as createNeonDialect } from "./neon-dialect-DySGBYUi.mjs";
3
3
  import gateway from "@llmops/gateway";
4
4
  import { sql } from "kysely";
5
- import * as fs from "node:fs/promises";
6
5
  import * as path from "node:path";
7
6
  import { createRandomStringGenerator } from "@better-auth/utils/random";
8
7
  import { createHash, randomBytes, randomUUID } from "node:crypto";
@@ -639,7 +638,7 @@ const llmopsConfigBaseSchema = object({
639
638
  const llmopsConfigSchema = llmopsConfigBaseSchema.transform((config) => ({
640
639
  ...config,
641
640
  providers: mergeWithDefaultProviders(config.providers)
642
- })).refine((config) => config.database !== void 0 || config.providers && config.providers.length > 0, "Either database or providers must be configured. Set a database connection, configure providers explicitly, or set API key environment variables (e.g., OPENAI_API_KEY).");
641
+ }));
643
642
  function validateLLMOpsConfig(config) {
644
643
  const result = llmopsConfigSchema.safeParse(config ?? {});
645
644
  if (!result.success) {
@@ -860,14 +859,16 @@ var FileCacheBackend = class {
860
859
  if (!this.loaded) await this.loadPromise;
861
860
  }
862
861
  async ensureDataDir() {
862
+ const { mkdir } = await import("node:fs/promises");
863
863
  const dir = path.dirname(this.cacheFile);
864
864
  try {
865
- await fs.mkdir(dir, { recursive: true });
865
+ await mkdir(dir, { recursive: true });
866
866
  } catch {}
867
867
  }
868
868
  async loadCache() {
869
869
  try {
870
- const content = await fs.readFile(this.cacheFile, "utf-8");
870
+ const { readFile } = await import("node:fs/promises");
871
+ const content = await readFile(this.cacheFile, "utf-8");
871
872
  this.data = JSON.parse(content);
872
873
  this.updateStats();
873
874
  this.loaded = true;
@@ -879,7 +880,8 @@ var FileCacheBackend = class {
879
880
  async saveCache() {
880
881
  try {
881
882
  await this.ensureDataDir();
882
- await fs.writeFile(this.cacheFile, JSON.stringify(this.data, null, 2));
883
+ const { writeFile } = await import("node:fs/promises");
884
+ await writeFile(this.cacheFile, JSON.stringify(this.data, null, 2));
883
885
  } catch {}
884
886
  }
885
887
  scheduleSave() {
@@ -1,3 +1,3 @@
1
- const require_neon_dialect = require('./neon-dialect-oh8u9vRy.cjs');
1
+ const require_neon_dialect = require('./neon-dialect-Dn80Acj9.cjs');
2
2
 
3
3
  exports.createNeonDialect = require_neon_dialect.createNeonDialect;
@@ -1,4 +1,4 @@
1
- const require_db = require('./db-i0OOYxJm.cjs');
1
+ const require_db = require('./db-DsEVRoua.cjs');
2
2
  let kysely_neon = require("kysely-neon");
3
3
  require("@neondatabase/serverless");
4
4
 
@@ -1,4 +1,4 @@
1
- const require_db = require('./db-i0OOYxJm.cjs');
1
+ const require_db = require('./db-DsEVRoua.cjs');
2
2
  let kysely = require("kysely");
3
3
 
4
4
  //#region src/db/node-sqlite-dialect.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@llmops/core",
3
- "version": "0.6.7",
3
+ "version": "0.6.8",
4
4
  "description": "Core LLMOps functionality and utilities",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -55,7 +55,7 @@
55
55
  "kysely": "^0.28.8",
56
56
  "kysely-neon": "^2.0.2",
57
57
  "pino": "^10.1.0",
58
- "@llmops/gateway": "^0.6.7"
58
+ "@llmops/gateway": "^0.6.8"
59
59
  },
60
60
  "devDependencies": {
61
61
  "@types/json-logic-js": "^2.0.8",