@llmops/core 0.1.0-beta.11 → 0.1.0-beta.12
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/bun-sqlite-dialect-D0Q9d80w.cjs +156 -0
- package/dist/db/index.cjs +18 -0
- package/dist/db/index.d.cts +2 -0
- package/dist/db-CUPUfhtT.cjs +12941 -0
- package/dist/index-B-ZIrOBc.d.cts +826 -0
- package/dist/index.cjs +1385 -0
- package/dist/index.d.cts +2064 -0
- package/dist/node-sqlite-dialect-_Xn99gdW.cjs +156 -0
- package/package.json +23 -5
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
const require_db = require('./db-CUPUfhtT.cjs');
|
|
2
|
+
let kysely = require("kysely");
|
|
3
|
+
|
|
4
|
+
//#region src/db/bun-sqlite-dialect.ts
|
|
5
|
+
var BunSqliteAdapter = class {
|
|
6
|
+
get supportsCreateIfNotExists() {
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
9
|
+
get supportsTransactionalDdl() {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
get supportsReturning() {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
async acquireMigrationLock() {}
|
|
16
|
+
async releaseMigrationLock() {}
|
|
17
|
+
get supportsOutput() {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
var BunSqliteDriver = class {
|
|
22
|
+
#config;
|
|
23
|
+
#connectionMutex = new ConnectionMutex();
|
|
24
|
+
#db;
|
|
25
|
+
#connection;
|
|
26
|
+
constructor(config) {
|
|
27
|
+
this.#config = { ...config };
|
|
28
|
+
}
|
|
29
|
+
async init() {
|
|
30
|
+
this.#db = this.#config.database;
|
|
31
|
+
this.#connection = new BunSqliteConnection(this.#db);
|
|
32
|
+
if (this.#config.onCreateConnection) await this.#config.onCreateConnection(this.#connection);
|
|
33
|
+
}
|
|
34
|
+
async acquireConnection() {
|
|
35
|
+
await this.#connectionMutex.lock();
|
|
36
|
+
return this.#connection;
|
|
37
|
+
}
|
|
38
|
+
async beginTransaction(connection) {
|
|
39
|
+
await connection.executeQuery(kysely.CompiledQuery.raw("begin"));
|
|
40
|
+
}
|
|
41
|
+
async commitTransaction(connection) {
|
|
42
|
+
await connection.executeQuery(kysely.CompiledQuery.raw("commit"));
|
|
43
|
+
}
|
|
44
|
+
async rollbackTransaction(connection) {
|
|
45
|
+
await connection.executeQuery(kysely.CompiledQuery.raw("rollback"));
|
|
46
|
+
}
|
|
47
|
+
async releaseConnection() {
|
|
48
|
+
this.#connectionMutex.unlock();
|
|
49
|
+
}
|
|
50
|
+
async destroy() {
|
|
51
|
+
this.#db?.close();
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
var BunSqliteConnection = class {
|
|
55
|
+
#db;
|
|
56
|
+
constructor(db) {
|
|
57
|
+
this.#db = db;
|
|
58
|
+
}
|
|
59
|
+
executeQuery(compiledQuery) {
|
|
60
|
+
const { sql: sql$1, parameters } = compiledQuery;
|
|
61
|
+
const stmt = this.#db.prepare(sql$1);
|
|
62
|
+
return Promise.resolve({ rows: stmt.all(parameters) });
|
|
63
|
+
}
|
|
64
|
+
async *streamQuery() {
|
|
65
|
+
throw new Error("Streaming query is not supported by SQLite driver.");
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
var ConnectionMutex = class {
|
|
69
|
+
#promise;
|
|
70
|
+
#resolve;
|
|
71
|
+
async lock() {
|
|
72
|
+
while (this.#promise) await this.#promise;
|
|
73
|
+
this.#promise = new Promise((resolve) => {
|
|
74
|
+
this.#resolve = resolve;
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
unlock() {
|
|
78
|
+
const resolve = this.#resolve;
|
|
79
|
+
this.#promise = void 0;
|
|
80
|
+
this.#resolve = void 0;
|
|
81
|
+
resolve?.();
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
var BunSqliteIntrospector = class {
|
|
85
|
+
#db;
|
|
86
|
+
constructor(db) {
|
|
87
|
+
this.#db = db;
|
|
88
|
+
}
|
|
89
|
+
async getSchemas() {
|
|
90
|
+
return [];
|
|
91
|
+
}
|
|
92
|
+
async getTables(options = { withInternalKyselyTables: false }) {
|
|
93
|
+
let query = this.#db.selectFrom("sqlite_schema").where("type", "=", "table").where("name", "not like", "sqlite_%").select("name").$castTo();
|
|
94
|
+
if (!options.withInternalKyselyTables) query = query.where("name", "!=", kysely.DEFAULT_MIGRATION_TABLE).where("name", "!=", kysely.DEFAULT_MIGRATION_LOCK_TABLE);
|
|
95
|
+
const tables = await query.execute();
|
|
96
|
+
return Promise.all(tables.map(({ name }) => this.#getTableMetadata(name)));
|
|
97
|
+
}
|
|
98
|
+
async getMetadata(options) {
|
|
99
|
+
return { tables: await this.getTables(options) };
|
|
100
|
+
}
|
|
101
|
+
async #getTableMetadata(table) {
|
|
102
|
+
const db = this.#db;
|
|
103
|
+
const autoIncrementCol = (await db.selectFrom("sqlite_master").where("name", "=", table).select("sql").$castTo().execute())[0]?.sql?.split(/[\(\),]/)?.find((it) => it.toLowerCase().includes("autoincrement"))?.split(/\s+/)?.[0]?.replace(/["`]/g, "");
|
|
104
|
+
return {
|
|
105
|
+
name: table,
|
|
106
|
+
columns: (await db.selectFrom(kysely.sql`pragma_table_info(${table})`.as("table_info")).select([
|
|
107
|
+
"name",
|
|
108
|
+
"type",
|
|
109
|
+
"notnull",
|
|
110
|
+
"dflt_value"
|
|
111
|
+
]).execute()).map((col) => ({
|
|
112
|
+
name: col.name,
|
|
113
|
+
dataType: col.type,
|
|
114
|
+
isNullable: !col.notnull,
|
|
115
|
+
isAutoIncrementing: col.name === autoIncrementCol,
|
|
116
|
+
hasDefaultValue: col.dflt_value != null
|
|
117
|
+
})),
|
|
118
|
+
isView: true
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
var BunSqliteQueryCompiler = class extends kysely.DefaultQueryCompiler {
|
|
123
|
+
getCurrentParameterPlaceholder() {
|
|
124
|
+
return "?";
|
|
125
|
+
}
|
|
126
|
+
getLeftIdentifierWrapper() {
|
|
127
|
+
return "\"";
|
|
128
|
+
}
|
|
129
|
+
getRightIdentifierWrapper() {
|
|
130
|
+
return "\"";
|
|
131
|
+
}
|
|
132
|
+
getAutoIncrement() {
|
|
133
|
+
return "autoincrement";
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
var BunSqliteDialect = class {
|
|
137
|
+
#config;
|
|
138
|
+
constructor(config) {
|
|
139
|
+
this.#config = { ...config };
|
|
140
|
+
}
|
|
141
|
+
createDriver() {
|
|
142
|
+
return new BunSqliteDriver(this.#config);
|
|
143
|
+
}
|
|
144
|
+
createQueryCompiler() {
|
|
145
|
+
return new BunSqliteQueryCompiler();
|
|
146
|
+
}
|
|
147
|
+
createAdapter() {
|
|
148
|
+
return new BunSqliteAdapter();
|
|
149
|
+
}
|
|
150
|
+
createIntrospector(db) {
|
|
151
|
+
return new BunSqliteIntrospector(db);
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
//#endregion
|
|
156
|
+
exports.BunSqliteDialect = BunSqliteDialect;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const require_db = require('../db-CUPUfhtT.cjs');
|
|
2
|
+
|
|
3
|
+
exports.SCHEMA_METADATA = require_db.SCHEMA_METADATA;
|
|
4
|
+
exports.configVariantsSchema = require_db.configVariantsSchema;
|
|
5
|
+
exports.configsSchema = require_db.configsSchema;
|
|
6
|
+
exports.createDatabase = require_db.createDatabase;
|
|
7
|
+
exports.createDatabaseFromConnection = require_db.createDatabaseFromConnection;
|
|
8
|
+
exports.detectDatabaseType = require_db.detectDatabaseType;
|
|
9
|
+
exports.environmentSecretsSchema = require_db.environmentSecretsSchema;
|
|
10
|
+
exports.environmentsSchema = require_db.environmentsSchema;
|
|
11
|
+
exports.parsePartialTableData = require_db.parsePartialTableData;
|
|
12
|
+
exports.parseTableData = require_db.parseTableData;
|
|
13
|
+
exports.schemas = require_db.schemas;
|
|
14
|
+
exports.targetingRulesSchema = require_db.targetingRulesSchema;
|
|
15
|
+
exports.validatePartialTableData = require_db.validatePartialTableData;
|
|
16
|
+
exports.validateTableData = require_db.validateTableData;
|
|
17
|
+
exports.variantVersionsSchema = require_db.variantVersionsSchema;
|
|
18
|
+
exports.variantsSchema = require_db.variantsSchema;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { A as configVariantsSchema, C as TargetingRule, D as VariantVersion, E as Variant, F as targetingRulesSchema, I as variantVersionsSchema, L as variantsSchema, M as environmentSecretsSchema, N as environmentsSchema, O as VariantVersionsTable, P as schemas, S as TableName, T as Updateable, _ as EnvironmentSecretsTable, a as detectDatabaseType, b as SCHEMA_METADATA, c as validatePartialTableData, d as ConfigVariant, f as ConfigVariantsTable, g as EnvironmentSecret, h as Environment, i as createDatabaseFromConnection, j as configsSchema, k as VariantsTable, l as validateTableData, m as Database, n as DatabaseType, o as parsePartialTableData, p as ConfigsTable, r as createDatabase, s as parseTableData, t as DatabaseConnection, u as Config, v as EnvironmentsTable, w as TargetingRulesTable, x as Selectable, y as Insertable } from "../index-B-ZIrOBc.cjs";
|
|
2
|
+
export { Config, ConfigVariant, ConfigVariantsTable, ConfigsTable, Database, DatabaseConnection, DatabaseType, Environment, EnvironmentSecret, EnvironmentSecretsTable, EnvironmentsTable, Insertable, SCHEMA_METADATA, Selectable, TableName, TargetingRule, TargetingRulesTable, Updateable, Variant, VariantVersion, VariantVersionsTable, VariantsTable, configVariantsSchema, configsSchema, createDatabase, createDatabaseFromConnection, detectDatabaseType, environmentSecretsSchema, environmentsSchema, parsePartialTableData, parseTableData, schemas, targetingRulesSchema, validatePartialTableData, validateTableData, variantVersionsSchema, variantsSchema };
|