@llmops/core 1.0.0-beta.3 → 1.0.0-beta.4
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 +13788 -1499
- package/dist/index.d.cts +86 -1060
- package/dist/index.d.mts +86 -1060
- package/dist/index.mjs +13556 -1246
- package/package.json +2 -17
- package/dist/bun-sqlite-dialect-CHpTFgAo.mjs +0 -155
- package/dist/bun-sqlite-dialect-CVUG5QUU.cjs +0 -156
- package/dist/db/index.cjs +0 -40
- package/dist/db/index.d.cts +0 -2
- package/dist/db/index.d.mts +0 -2
- package/dist/db/index.mjs +0 -4
- package/dist/db-CZ8KtpL-.mjs +0 -14325
- package/dist/db-DZv0NtMm.cjs +0 -14640
- package/dist/index-BlFAMkmT.d.mts +0 -2711
- package/dist/index-DjIHdwhi.d.cts +0 -2711
- package/dist/neon-dialect-BOnuygPe.cjs +0 -3
- package/dist/neon-dialect-ByrFa9iy.cjs +0 -42
- package/dist/neon-dialect-DySGBYUi.mjs +0 -30
- package/dist/neon-dialect-Hmo08nUq.mjs +0 -3
- package/dist/node-sqlite-dialect-B5oKhOm1.mjs +0 -155
- package/dist/node-sqlite-dialect-fwmW40Ar.cjs +0 -156
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
const require_db = require('./db-DZv0NtMm.cjs');
|
|
2
|
-
let kysely_neon = require("kysely-neon");
|
|
3
|
-
require("@neondatabase/serverless");
|
|
4
|
-
|
|
5
|
-
//#region src/db/neon-dialect.ts
|
|
6
|
-
/**
|
|
7
|
-
* Create a Neon serverless dialect for Kysely
|
|
8
|
-
*
|
|
9
|
-
* @param neonInstance - Neon database query function
|
|
10
|
-
* @returns Kysely dialect configured for Neon serverless
|
|
11
|
-
*/
|
|
12
|
-
function createNeonDialect(neonInstance) {
|
|
13
|
-
return new kysely_neon.NeonDialect({ neon: neonInstance });
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Execute a query with search_path set for Neon serverless
|
|
17
|
-
*
|
|
18
|
-
* @param neonInstance - Neon database query function
|
|
19
|
-
* @param query - SQL query to execute
|
|
20
|
-
* @param schema - Schema to set (optional)
|
|
21
|
-
* @returns Query result
|
|
22
|
-
*/
|
|
23
|
-
async function executeWithSchema(neonInstance, query, schema) {
|
|
24
|
-
if (schema && schema !== "public") try {
|
|
25
|
-
await neonInstance`SET search_path TO ${schema}`;
|
|
26
|
-
} catch (error) {}
|
|
27
|
-
return neonInstance(query);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
//#endregion
|
|
31
|
-
Object.defineProperty(exports, 'createNeonDialect', {
|
|
32
|
-
enumerable: true,
|
|
33
|
-
get: function () {
|
|
34
|
-
return createNeonDialect;
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
Object.defineProperty(exports, 'executeWithSchema', {
|
|
38
|
-
enumerable: true,
|
|
39
|
-
get: function () {
|
|
40
|
-
return executeWithSchema;
|
|
41
|
-
}
|
|
42
|
-
});
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { NeonDialect } from "kysely-neon";
|
|
2
|
-
import "@neondatabase/serverless";
|
|
3
|
-
|
|
4
|
-
//#region src/db/neon-dialect.ts
|
|
5
|
-
/**
|
|
6
|
-
* Create a Neon serverless dialect for Kysely
|
|
7
|
-
*
|
|
8
|
-
* @param neonInstance - Neon database query function
|
|
9
|
-
* @returns Kysely dialect configured for Neon serverless
|
|
10
|
-
*/
|
|
11
|
-
function createNeonDialect(neonInstance) {
|
|
12
|
-
return new NeonDialect({ neon: neonInstance });
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Execute a query with search_path set for Neon serverless
|
|
16
|
-
*
|
|
17
|
-
* @param neonInstance - Neon database query function
|
|
18
|
-
* @param query - SQL query to execute
|
|
19
|
-
* @param schema - Schema to set (optional)
|
|
20
|
-
* @returns Query result
|
|
21
|
-
*/
|
|
22
|
-
async function executeWithSchema(neonInstance, query, schema) {
|
|
23
|
-
if (schema && schema !== "public") try {
|
|
24
|
-
await neonInstance`SET search_path TO ${schema}`;
|
|
25
|
-
} catch (error) {}
|
|
26
|
-
return neonInstance(query);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
//#endregion
|
|
30
|
-
export { executeWithSchema as n, createNeonDialect as t };
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import { CompiledQuery, DEFAULT_MIGRATION_LOCK_TABLE, DEFAULT_MIGRATION_TABLE, DefaultQueryCompiler, sql } from "kysely";
|
|
2
|
-
|
|
3
|
-
//#region src/db/node-sqlite-dialect.ts
|
|
4
|
-
var NodeSqliteAdapter = class {
|
|
5
|
-
get supportsCreateIfNotExists() {
|
|
6
|
-
return true;
|
|
7
|
-
}
|
|
8
|
-
get supportsTransactionalDdl() {
|
|
9
|
-
return false;
|
|
10
|
-
}
|
|
11
|
-
get supportsReturning() {
|
|
12
|
-
return true;
|
|
13
|
-
}
|
|
14
|
-
async acquireMigrationLock() {}
|
|
15
|
-
async releaseMigrationLock() {}
|
|
16
|
-
get supportsOutput() {
|
|
17
|
-
return true;
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
var NodeSqliteDriver = class {
|
|
21
|
-
#config;
|
|
22
|
-
#connectionMutex = new ConnectionMutex();
|
|
23
|
-
#db;
|
|
24
|
-
#connection;
|
|
25
|
-
constructor(config) {
|
|
26
|
-
this.#config = { ...config };
|
|
27
|
-
}
|
|
28
|
-
async init() {
|
|
29
|
-
this.#db = this.#config.database;
|
|
30
|
-
this.#connection = new NodeSqliteConnection(this.#db);
|
|
31
|
-
if (this.#config.onCreateConnection) await this.#config.onCreateConnection(this.#connection);
|
|
32
|
-
}
|
|
33
|
-
async acquireConnection() {
|
|
34
|
-
await this.#connectionMutex.lock();
|
|
35
|
-
return this.#connection;
|
|
36
|
-
}
|
|
37
|
-
async beginTransaction(connection) {
|
|
38
|
-
await connection.executeQuery(CompiledQuery.raw("begin"));
|
|
39
|
-
}
|
|
40
|
-
async commitTransaction(connection) {
|
|
41
|
-
await connection.executeQuery(CompiledQuery.raw("commit"));
|
|
42
|
-
}
|
|
43
|
-
async rollbackTransaction(connection) {
|
|
44
|
-
await connection.executeQuery(CompiledQuery.raw("rollback"));
|
|
45
|
-
}
|
|
46
|
-
async releaseConnection() {
|
|
47
|
-
this.#connectionMutex.unlock();
|
|
48
|
-
}
|
|
49
|
-
async destroy() {
|
|
50
|
-
this.#db?.close();
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
var NodeSqliteConnection = class {
|
|
54
|
-
#db;
|
|
55
|
-
constructor(db) {
|
|
56
|
-
this.#db = db;
|
|
57
|
-
}
|
|
58
|
-
executeQuery(compiledQuery) {
|
|
59
|
-
const { sql: sql$1, parameters } = compiledQuery;
|
|
60
|
-
const rows = this.#db.prepare(sql$1).all(...parameters);
|
|
61
|
-
return Promise.resolve({ rows });
|
|
62
|
-
}
|
|
63
|
-
async *streamQuery() {
|
|
64
|
-
throw new Error("Streaming query is not supported by SQLite driver.");
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
var ConnectionMutex = class {
|
|
68
|
-
#promise;
|
|
69
|
-
#resolve;
|
|
70
|
-
async lock() {
|
|
71
|
-
while (this.#promise) await this.#promise;
|
|
72
|
-
this.#promise = new Promise((resolve) => {
|
|
73
|
-
this.#resolve = resolve;
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
unlock() {
|
|
77
|
-
const resolve = this.#resolve;
|
|
78
|
-
this.#promise = void 0;
|
|
79
|
-
this.#resolve = void 0;
|
|
80
|
-
resolve?.();
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
var NodeSqliteIntrospector = class {
|
|
84
|
-
#db;
|
|
85
|
-
constructor(db) {
|
|
86
|
-
this.#db = db;
|
|
87
|
-
}
|
|
88
|
-
async getSchemas() {
|
|
89
|
-
return [];
|
|
90
|
-
}
|
|
91
|
-
async getTables(options = { withInternalKyselyTables: false }) {
|
|
92
|
-
let query = this.#db.selectFrom("sqlite_schema").where("type", "=", "table").where("name", "not like", "sqlite_%").select("name").$castTo();
|
|
93
|
-
if (!options.withInternalKyselyTables) query = query.where("name", "!=", DEFAULT_MIGRATION_TABLE).where("name", "!=", DEFAULT_MIGRATION_LOCK_TABLE);
|
|
94
|
-
const tables = await query.execute();
|
|
95
|
-
return Promise.all(tables.map(({ name }) => this.#getTableMetadata(name)));
|
|
96
|
-
}
|
|
97
|
-
async getMetadata(options) {
|
|
98
|
-
return { tables: await this.getTables(options) };
|
|
99
|
-
}
|
|
100
|
-
async #getTableMetadata(table) {
|
|
101
|
-
const db = this.#db;
|
|
102
|
-
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, "");
|
|
103
|
-
return {
|
|
104
|
-
name: table,
|
|
105
|
-
columns: (await db.selectFrom(sql`pragma_table_info(${table})`.as("table_info")).select([
|
|
106
|
-
"name",
|
|
107
|
-
"type",
|
|
108
|
-
"notnull",
|
|
109
|
-
"dflt_value"
|
|
110
|
-
]).execute()).map((col) => ({
|
|
111
|
-
name: col.name,
|
|
112
|
-
dataType: col.type,
|
|
113
|
-
isNullable: !col.notnull,
|
|
114
|
-
isAutoIncrementing: col.name === autoIncrementCol,
|
|
115
|
-
hasDefaultValue: col.dflt_value != null
|
|
116
|
-
})),
|
|
117
|
-
isView: true
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
var NodeSqliteQueryCompiler = class extends DefaultQueryCompiler {
|
|
122
|
-
getCurrentParameterPlaceholder() {
|
|
123
|
-
return "?";
|
|
124
|
-
}
|
|
125
|
-
getLeftIdentifierWrapper() {
|
|
126
|
-
return "\"";
|
|
127
|
-
}
|
|
128
|
-
getRightIdentifierWrapper() {
|
|
129
|
-
return "\"";
|
|
130
|
-
}
|
|
131
|
-
getAutoIncrement() {
|
|
132
|
-
return "autoincrement";
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
var NodeSqliteDialect = class {
|
|
136
|
-
#config;
|
|
137
|
-
constructor(config) {
|
|
138
|
-
this.#config = { ...config };
|
|
139
|
-
}
|
|
140
|
-
createDriver() {
|
|
141
|
-
return new NodeSqliteDriver(this.#config);
|
|
142
|
-
}
|
|
143
|
-
createQueryCompiler() {
|
|
144
|
-
return new NodeSqliteQueryCompiler();
|
|
145
|
-
}
|
|
146
|
-
createAdapter() {
|
|
147
|
-
return new NodeSqliteAdapter();
|
|
148
|
-
}
|
|
149
|
-
createIntrospector(db) {
|
|
150
|
-
return new NodeSqliteIntrospector(db);
|
|
151
|
-
}
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
//#endregion
|
|
155
|
-
export { NodeSqliteDialect };
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
const require_db = require('./db-DZv0NtMm.cjs');
|
|
2
|
-
let kysely = require("kysely");
|
|
3
|
-
|
|
4
|
-
//#region src/db/node-sqlite-dialect.ts
|
|
5
|
-
var NodeSqliteAdapter = 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 NodeSqliteDriver = 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 NodeSqliteConnection(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 NodeSqliteConnection = class {
|
|
55
|
-
#db;
|
|
56
|
-
constructor(db) {
|
|
57
|
-
this.#db = db;
|
|
58
|
-
}
|
|
59
|
-
executeQuery(compiledQuery) {
|
|
60
|
-
const { sql: sql$1, parameters } = compiledQuery;
|
|
61
|
-
const rows = this.#db.prepare(sql$1).all(...parameters);
|
|
62
|
-
return Promise.resolve({ rows });
|
|
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 NodeSqliteIntrospector = 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 NodeSqliteQueryCompiler = 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 NodeSqliteDialect = class {
|
|
137
|
-
#config;
|
|
138
|
-
constructor(config) {
|
|
139
|
-
this.#config = { ...config };
|
|
140
|
-
}
|
|
141
|
-
createDriver() {
|
|
142
|
-
return new NodeSqliteDriver(this.#config);
|
|
143
|
-
}
|
|
144
|
-
createQueryCompiler() {
|
|
145
|
-
return new NodeSqliteQueryCompiler();
|
|
146
|
-
}
|
|
147
|
-
createAdapter() {
|
|
148
|
-
return new NodeSqliteAdapter();
|
|
149
|
-
}
|
|
150
|
-
createIntrospector(db) {
|
|
151
|
-
return new NodeSqliteIntrospector(db);
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
//#endregion
|
|
156
|
-
exports.NodeSqliteDialect = NodeSqliteDialect;
|