1
1
import type { TransactionMode , rawSQLStatement , libsqlConfig , rawSQLArgs , rawSQL , ResultSet , clientInterface } from "./commons.js" ;
2
2
import { libsqlBatchWithoutTransaction , libsqlBatch , libsqlExecute , libsqlExecuteMultiple , libsqlMigrate } from "./functions.js" ;
3
3
import { MisuseError } from "./errors.js" ;
4
- import { checkHttpUrl , conserror , ensure_fetch } from "./globcon/mod.js" ;
4
+ import { checkHttpUrl , checkRedundantConfig , conserror , ensure_fetch } from "./globcon/mod.js" ;
5
5
import type { libsqlBatchReqStepExecCond } from "libsql-stateless" ;
6
6
7
7
export function createClient ( conf : libsqlConfig ) {
@@ -12,58 +12,20 @@ export function createClient(conf: libsqlConfig) {
12
12
export class libsqlClient implements clientInterface {
13
13
private readonly conf : libsqlConfig ;
14
14
public closed : boolean ;
15
-
16
- /** Which protocol does the client use?
17
- *
18
- * - `"http"` if the client connects over HTTP
19
- * - `"ws"` if the client connects over WebSockets
20
- * - `"file"` if the client works with a local file
21
- */
22
15
public protocol : string ;
23
16
24
17
constructor ( conf : libsqlConfig ) {
25
18
if ( ! conf . disableCriticalChecks ) {
26
19
checkHttpUrl ( conf . url ) ;
27
20
ensure_fetch ( conf ) ;
21
+ checkRedundantConfig ( conf ) ;
28
22
}
29
23
30
24
this . conf = conf ;
31
25
this . closed = false ;
32
26
this . protocol = "http" ;
33
27
}
34
28
35
- /** Execute a single SQL statement.
36
- *
37
- * Every statement executed with this method is executed in its own logical database connection. If you
38
- * want to execute a group of statements in a transaction, use the {@link batch} method.
39
- *
40
- * ```javascript
41
- * // execute a statement without arguments
42
- * const rs = await client.execute("SELECT * FROM books");
43
- *
44
- * // execute a statement with positional arguments
45
- * const rs = await client.execute(
46
- * "SELECT * FROM books WHERE author = ?",
47
- * ["Jane Austen"],
48
- * );
49
- * // for backward compatibality
50
- * const rs = await client.execute({
51
- * sql: "SELECT * FROM books WHERE author = ?",
52
- * args: ["Jane Austen"],
53
- * });
54
- *
55
- * // execute a statement with named arguments
56
- * const rs = await client.execute(
57
- * "SELECT * FROM books WHERE published_at > $year",
58
- * {year: 1719},
59
- * );
60
- * // for backward compatibality
61
- * const rs = await client.execute({
62
- * sql: "SELECT * FROM books WHERE published_at > $year",
63
- * args: {year: 1719},
64
- * });
65
- * ```
66
- */
67
29
public async execute ( stmt : rawSQL , args ?: rawSQLArgs , want_rows ?: boolean ) : Promise < ResultSet > ;
68
30
public async execute ( stmt : rawSQLStatement ) : Promise < ResultSet > ;
69
31
public async execute ( stmt_or_sql : rawSQL | rawSQLStatement , or_args ?: rawSQLArgs , or_want_rows ?: boolean ) {
@@ -128,8 +90,7 @@ export class libsqlClient implements clientInterface {
128
90
return await libsqlMigrate ( this . conf , stmts ) ;
129
91
}
130
92
131
- // @ts -ignore
132
- public async transaction ( mode ?: TransactionMode ) : Promise < any > {
93
+ public async transaction ( _mode ?: TransactionMode ) : Promise < any > {
133
94
throw new MisuseError ( "'libsql-stateless' is stateless and does not support interactive transactions. Use this.batch() instead." ) ;
134
95
}
135
96
0 commit comments