drizzle-orm-libsql-sync 0.0.0 → 0.0.1
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/driver.d.mts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { n as LibsqlSyncRunResult } from "./session-
|
|
1
|
+
import { n as LibsqlSyncRunResult } from "./session-DiU-8bTt.mjs";
|
|
2
2
|
import { Database } from "libsql";
|
|
3
3
|
import { AnyRelations, DrizzleConfig, EmptyRelations, entityKind } from "drizzle-orm";
|
|
4
|
-
import {
|
|
4
|
+
import { SQLiteAsyncDatabase } from "drizzle-orm/sqlite-core";
|
|
5
5
|
|
|
6
6
|
//#region src/driver.d.ts
|
|
7
7
|
/** Config-object form accepted by the call sites. */
|
|
8
8
|
type LibsqlSyncDrizzleConfig<TSchema extends Record<string, unknown>, TRelations extends AnyRelations> = DrizzleConfig<TSchema, TRelations> & {
|
|
9
9
|
client: Database;
|
|
10
10
|
};
|
|
11
|
-
declare class LibsqlSyncDatabase<TSchema extends Record<string, unknown> = Record<string, never>, TRelations extends AnyRelations = EmptyRelations> extends
|
|
11
|
+
declare class LibsqlSyncDatabase<TSchema extends Record<string, unknown> = Record<string, never>, TRelations extends AnyRelations = EmptyRelations> extends SQLiteAsyncDatabase<"sync", LibsqlSyncRunResult, TRelations> {
|
|
12
12
|
static readonly [entityKind]: string;
|
|
13
13
|
$client: Database;
|
|
14
14
|
}
|
package/dist/driver.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { LibsqlSyncSession } from "./session.mjs";
|
|
|
3
3
|
import LibsqlDatabaseCtor from "libsql";
|
|
4
4
|
import { DefaultLogger, entityKind } from "drizzle-orm";
|
|
5
5
|
import * as V1 from "drizzle-orm/_relations";
|
|
6
|
-
import {
|
|
6
|
+
import { SQLiteAsyncDatabase, SQLiteDialect } from "drizzle-orm/sqlite-core";
|
|
7
7
|
//#region src/driver.ts
|
|
8
8
|
function isAnyObject(value) {
|
|
9
9
|
return typeof value === "object" && value !== null;
|
|
@@ -14,12 +14,12 @@ function isRelationsConfig(value) {
|
|
|
14
14
|
function isExtractedSchemaTables(value) {
|
|
15
15
|
return isAnyObject(value);
|
|
16
16
|
}
|
|
17
|
-
var LibsqlSyncDatabase = class extends
|
|
17
|
+
var LibsqlSyncDatabase = class extends SQLiteAsyncDatabase {
|
|
18
18
|
static [entityKind] = "LibsqlSyncDatabase";
|
|
19
19
|
};
|
|
20
20
|
function construct(client, drizzleConfig = {}) {
|
|
21
21
|
const sqliteClient = toDrizzleSyncSQLiteClient(client);
|
|
22
|
-
const dialect = new
|
|
22
|
+
const dialect = new SQLiteDialect();
|
|
23
23
|
let logger;
|
|
24
24
|
if (drizzleConfig.logger === true) logger = new DefaultLogger();
|
|
25
25
|
else if (drizzleConfig.logger !== false) logger = drizzleConfig.logger;
|
|
@@ -35,7 +35,7 @@ function construct(client, drizzleConfig = {}) {
|
|
|
35
35
|
}
|
|
36
36
|
const relations = drizzleConfig.relations ?? {};
|
|
37
37
|
if (!isRelationsConfig(relations)) throw new TypeError("Invalid drizzle relations config");
|
|
38
|
-
const db = new LibsqlSyncDatabase("sync", dialect, new LibsqlSyncSession(sqliteClient, dialect, relations, schema, { logger }), relations
|
|
38
|
+
const db = new LibsqlSyncDatabase("sync", dialect, new LibsqlSyncSession(sqliteClient, dialect, relations, schema, { logger }), relations);
|
|
39
39
|
db.$client = sqliteClient;
|
|
40
40
|
return db;
|
|
41
41
|
}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { i as toDrizzleSyncSQLiteClient, n as DrizzleSyncSQLiteClient, r as isDrizzleSyncSQLiteClient, t as DrizzleSyncSQLiteBindValue } from "./client-xqwnbWL8.mjs";
|
|
2
|
-
import { a as LibsqlSyncTransaction, i as LibsqlSyncSessionOptions, n as LibsqlSyncRunResult, r as LibsqlSyncSession, t as LibsqlSyncPreparedQuery } from "./session-
|
|
2
|
+
import { a as LibsqlSyncTransaction, i as LibsqlSyncSessionOptions, n as LibsqlSyncRunResult, r as LibsqlSyncSession, t as LibsqlSyncPreparedQuery } from "./session-DiU-8bTt.mjs";
|
|
3
3
|
import { LibsqlSyncDatabase, LibsqlSyncDrizzleConfig, drizzle } from "./driver.mjs";
|
|
4
4
|
export { type DrizzleSyncSQLiteBindValue, type DrizzleSyncSQLiteClient, LibsqlSyncDatabase, LibsqlSyncDrizzleConfig, LibsqlSyncPreparedQuery, LibsqlSyncRunResult, LibsqlSyncSession, LibsqlSyncSessionOptions, LibsqlSyncTransaction, drizzle, isDrizzleSyncSQLiteClient, toDrizzleSyncSQLiteClient };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { n as DrizzleSyncSQLiteClient } from "./client-xqwnbWL8.mjs";
|
|
2
2
|
import { AnyRelations, DrizzleTypeError, Logger, Query, RelationalQueryMapperConfig, entityKind } from "drizzle-orm";
|
|
3
3
|
import * as V1 from "drizzle-orm/_relations";
|
|
4
|
-
import { PreparedQueryConfig,
|
|
4
|
+
import { PreparedQueryConfig, SQLiteAsyncPreparedQuery, SQLiteAsyncSession, SQLiteAsyncTransaction, SQLiteDialect, SQLiteExecuteMethod, SQLiteTransactionConfig, SelectedFieldsOrdered } from "drizzle-orm/sqlite-core";
|
|
5
5
|
import { WithCacheConfig } from "drizzle-orm/cache/core/types";
|
|
6
6
|
|
|
7
7
|
//#region src/session.d.ts
|
|
@@ -14,26 +14,24 @@ interface LibsqlSyncRunResult {
|
|
|
14
14
|
lastInsertRowid: number | bigint;
|
|
15
15
|
}
|
|
16
16
|
type PreparedQueryConfig$1 = Omit<PreparedQueryConfig, "statement" | "run">;
|
|
17
|
-
declare class LibsqlSyncSession<TFullSchema extends Record<string, unknown>, TRelations extends AnyRelations, TSchema extends V1.TablesRelationalConfig> extends
|
|
17
|
+
declare class LibsqlSyncSession<TFullSchema extends Record<string, unknown>, TRelations extends AnyRelations, TSchema extends V1.TablesRelationalConfig> extends SQLiteAsyncSession<"sync", LibsqlSyncRunResult, TRelations> {
|
|
18
18
|
private client;
|
|
19
|
-
private relations;
|
|
20
|
-
private schema;
|
|
21
19
|
private options;
|
|
22
20
|
static readonly [entityKind]: string;
|
|
23
21
|
private logger;
|
|
24
|
-
constructor(client: DrizzleSyncSQLiteClient, dialect:
|
|
25
|
-
prepareQuery<T extends Omit<PreparedQueryConfig$1, "run">>(query: Query,
|
|
22
|
+
constructor(client: DrizzleSyncSQLiteClient, dialect: SQLiteDialect, relations: TRelations, schema: V1.RelationalSchemaConfig<TSchema> | undefined, options?: LibsqlSyncSessionOptions);
|
|
23
|
+
prepareQuery<T extends Omit<PreparedQueryConfig$1, "run">>(query: Query, _mode: "arrays" | "objects" | "raw", _prepare: boolean, executeMethod?: SQLiteExecuteMethod, customResultMapper?: (rows: unknown[][], mapColumnValue?: (value: unknown) => unknown) => unknown, queryMetadata?: {
|
|
26
24
|
tables: string[];
|
|
27
25
|
type: "select" | "update" | "delete" | "insert";
|
|
28
26
|
}, _cacheConfig?: WithCacheConfig): LibsqlSyncPreparedQuery<T>;
|
|
29
27
|
prepareRelationalQuery<T extends Omit<PreparedQueryConfig$1, "run">>(query: Query, fields: SelectedFieldsOrdered | undefined, executeMethod: SQLiteExecuteMethod, customResultMapper: (rows: Record<string, unknown>[], mapColumnValue?: (value: unknown) => unknown) => unknown, config: RelationalQueryMapperConfig): LibsqlSyncPreparedQuery<T, true>;
|
|
30
28
|
transaction<T>(transaction: (tx: LibsqlSyncTransaction<TFullSchema, TRelations, TSchema>) => T, config?: SQLiteTransactionConfig): T;
|
|
31
29
|
}
|
|
32
|
-
declare class LibsqlSyncTransaction<TFullSchema extends Record<string, unknown>, TRelations extends AnyRelations, TSchema extends V1.TablesRelationalConfig> extends
|
|
30
|
+
declare class LibsqlSyncTransaction<TFullSchema extends Record<string, unknown>, TRelations extends AnyRelations, TSchema extends V1.TablesRelationalConfig> extends SQLiteAsyncTransaction<"sync", LibsqlSyncRunResult, TRelations> {
|
|
33
31
|
static readonly [entityKind]: string;
|
|
34
32
|
transaction<T>(transaction: (tx: LibsqlSyncTransaction<TFullSchema, TRelations, TSchema>) => T extends Promise<any> ? DrizzleTypeError<"Sync drivers can't use async functions in transactions!"> : T): T;
|
|
35
33
|
}
|
|
36
|
-
declare class LibsqlSyncPreparedQuery<T extends PreparedQueryConfig$1 = PreparedQueryConfig$1, TIsRqbV2 extends boolean = false> extends
|
|
34
|
+
declare class LibsqlSyncPreparedQuery<T extends PreparedQueryConfig$1 = PreparedQueryConfig$1, TIsRqbV2 extends boolean = false> extends SQLiteAsyncPreparedQuery<{
|
|
37
35
|
all: T["all"];
|
|
38
36
|
execute: T["execute"];
|
|
39
37
|
get: T["get"];
|
|
@@ -42,7 +40,7 @@ declare class LibsqlSyncPreparedQuery<T extends PreparedQueryConfig$1 = Prepared
|
|
|
42
40
|
values: T["values"];
|
|
43
41
|
}> {
|
|
44
42
|
private client;
|
|
45
|
-
|
|
43
|
+
protected logger: Logger;
|
|
46
44
|
private fields;
|
|
47
45
|
private useJitMappers;
|
|
48
46
|
private customResultMapper?;
|
package/dist/session.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as LibsqlSyncTransaction, i as LibsqlSyncSessionOptions, n as LibsqlSyncRunResult, r as LibsqlSyncSession, t as LibsqlSyncPreparedQuery } from "./session-
|
|
1
|
+
import { a as LibsqlSyncTransaction, i as LibsqlSyncSessionOptions, n as LibsqlSyncRunResult, r as LibsqlSyncSession, t as LibsqlSyncPreparedQuery } from "./session-DiU-8bTt.mjs";
|
|
2
2
|
export { LibsqlSyncPreparedQuery, LibsqlSyncRunResult, LibsqlSyncSession, LibsqlSyncSessionOptions, LibsqlSyncTransaction };
|
package/dist/session.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "./client.mjs";
|
|
2
2
|
import * as drizzleRuntime from "drizzle-orm";
|
|
3
3
|
import { NoopLogger, entityKind, fillPlaceholders, is, makeJitQueryMapper, makeJitRqbMapper, sql } from "drizzle-orm";
|
|
4
|
-
import {
|
|
4
|
+
import { SQLiteAsyncPreparedQuery, SQLiteAsyncSession, SQLiteAsyncTransaction } from "drizzle-orm/sqlite-core";
|
|
5
5
|
//#region src/session.ts
|
|
6
6
|
function isAnyObject(value) {
|
|
7
7
|
return typeof value === "object" && value !== null;
|
|
@@ -79,29 +79,25 @@ function getRelationalQueryMapperConfig(config) {
|
|
|
79
79
|
if (config === void 0) throw new TypeError("Expected relational query mapper config to be defined");
|
|
80
80
|
return config;
|
|
81
81
|
}
|
|
82
|
-
var LibsqlSyncSession = class extends
|
|
82
|
+
var LibsqlSyncSession = class extends SQLiteAsyncSession {
|
|
83
83
|
client;
|
|
84
|
-
relations;
|
|
85
|
-
schema;
|
|
86
84
|
options;
|
|
87
85
|
static [entityKind] = "LibsqlSyncSession";
|
|
88
86
|
logger;
|
|
89
87
|
constructor(client, dialect, relations, schema, options = {}) {
|
|
90
|
-
super(dialect);
|
|
88
|
+
super(dialect, "sync");
|
|
91
89
|
this.client = client;
|
|
92
|
-
this.relations = relations;
|
|
93
|
-
this.schema = schema;
|
|
94
90
|
this.options = options;
|
|
95
91
|
this.logger = options.logger ?? new NoopLogger();
|
|
96
92
|
}
|
|
97
|
-
prepareQuery(query,
|
|
98
|
-
return new LibsqlSyncPreparedQuery(this.client, query, this.logger, queryMetadata,
|
|
93
|
+
prepareQuery(query, _mode, _prepare, executeMethod, customResultMapper, queryMetadata, _cacheConfig) {
|
|
94
|
+
return new LibsqlSyncPreparedQuery(this.client, query, this.logger, queryMetadata, void 0, executeMethod ?? "all", this.options.useJitMappers, customResultMapper);
|
|
99
95
|
}
|
|
100
96
|
prepareRelationalQuery(query, fields, executeMethod, customResultMapper, config) {
|
|
101
|
-
return new LibsqlSyncPreparedQuery(this.client, query, this.logger, void 0,
|
|
97
|
+
return new LibsqlSyncPreparedQuery(this.client, query, this.logger, void 0, void 0, executeMethod ?? "all", this.options.useJitMappers, customResultMapper, true, config);
|
|
102
98
|
}
|
|
103
99
|
transaction(transaction, config = {}) {
|
|
104
|
-
const tx = new LibsqlSyncTransaction("sync", getSQLiteSyncDialect(this), this, this
|
|
100
|
+
const tx = new LibsqlSyncTransaction("sync", getSQLiteSyncDialect(this), this, Reflect.get(this, "relations"));
|
|
105
101
|
this.run(sql.raw(`begin${config.behavior ? " " + config.behavior : ""}`));
|
|
106
102
|
try {
|
|
107
103
|
const result = transaction(tx);
|
|
@@ -113,14 +109,14 @@ var LibsqlSyncSession = class extends SQLiteSession {
|
|
|
113
109
|
}
|
|
114
110
|
}
|
|
115
111
|
};
|
|
116
|
-
var LibsqlSyncTransaction = class LibsqlSyncTransaction extends
|
|
112
|
+
var LibsqlSyncTransaction = class LibsqlSyncTransaction extends SQLiteAsyncTransaction {
|
|
117
113
|
static [entityKind] = "LibsqlSyncTransaction";
|
|
118
114
|
transaction(transaction) {
|
|
119
115
|
const dialect = getSQLiteSyncDialect(this);
|
|
120
116
|
const sessionValue = Reflect.get(this, "session");
|
|
121
117
|
if (!isLibsqlSyncSessionFor(sessionValue)) throw new TypeError("Expected LibsqlSyncSession");
|
|
122
|
-
const savepointName = `sp${this
|
|
123
|
-
const tx = new LibsqlSyncTransaction("sync", dialect, sessionValue, this
|
|
118
|
+
const savepointName = `sp${Reflect.get(this, "nestedIndex")}`;
|
|
119
|
+
const tx = new LibsqlSyncTransaction("sync", dialect, sessionValue, Reflect.get(this, "relations"), Reflect.get(this, "nestedIndex") + 1);
|
|
124
120
|
sessionValue.run(sql.raw(`savepoint ${savepointName}`));
|
|
125
121
|
try {
|
|
126
122
|
const result = transaction(tx);
|
|
@@ -132,7 +128,7 @@ var LibsqlSyncTransaction = class LibsqlSyncTransaction extends SQLiteTransactio
|
|
|
132
128
|
}
|
|
133
129
|
}
|
|
134
130
|
};
|
|
135
|
-
var LibsqlSyncPreparedQuery = class extends
|
|
131
|
+
var LibsqlSyncPreparedQuery = class extends SQLiteAsyncPreparedQuery {
|
|
136
132
|
client;
|
|
137
133
|
logger;
|
|
138
134
|
fields;
|
|
@@ -144,7 +140,20 @@ var LibsqlSyncPreparedQuery = class extends SQLitePreparedQuery {
|
|
|
144
140
|
jitRowMapper;
|
|
145
141
|
jitRqbMapper;
|
|
146
142
|
constructor(client, query, logger, queryMetadata, fields, executeMethod, useJitMappers, customResultMapper, isRqbV2Query, rqbConfig) {
|
|
147
|
-
super("sync", executeMethod
|
|
143
|
+
super("sync", executeMethod ?? "all", {
|
|
144
|
+
all: () => {
|
|
145
|
+
throw new Error("LibsqlSyncPreparedQuery overrides all()");
|
|
146
|
+
},
|
|
147
|
+
get: () => {
|
|
148
|
+
throw new Error("LibsqlSyncPreparedQuery overrides get()");
|
|
149
|
+
},
|
|
150
|
+
run: () => {
|
|
151
|
+
throw new Error("LibsqlSyncPreparedQuery overrides run()");
|
|
152
|
+
},
|
|
153
|
+
values: () => {
|
|
154
|
+
throw new Error("LibsqlSyncPreparedQuery overrides values()");
|
|
155
|
+
}
|
|
156
|
+
}, query, void 0, "objects", logger, void 0, queryMetadata, void 0);
|
|
148
157
|
this.client = client;
|
|
149
158
|
this.logger = logger;
|
|
150
159
|
this.fields = fields;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "drizzle-orm-libsql-sync",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.1",
|
|
4
4
|
"description": "A synchronous Drizzle ORM driver for libsql, backed by the libsql Database (prepare/exec) and drizzle v1 modern relations.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"drizzle",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@types/node": "^25.6.2",
|
|
49
49
|
"@typescript/native-preview": "7.0.0-dev.20260509.2",
|
|
50
50
|
"bumpp": "^11.1.0",
|
|
51
|
-
"drizzle-orm": "1.0.0-rc.4
|
|
51
|
+
"drizzle-orm": "1.0.0-rc.4",
|
|
52
52
|
"libsql": "^0.5.29",
|
|
53
53
|
"typescript": "^6.0.3",
|
|
54
54
|
"vite": "npm:@voidzero-dev/vite-plus-core@latest",
|