Skip to content

Commit 2ad6a6a

Browse files
committed
mention ignored configs
1 parent f19d5d4 commit 2ad6a6a

File tree

2 files changed

+11
-42
lines changed

2 files changed

+11
-42
lines changed

src/client.ts

+3-42
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { TransactionMode, rawSQLStatement, libsqlConfig, rawSQLArgs, rawSQL, ResultSet, clientInterface } from "./commons.js";
22
import { libsqlBatchWithoutTransaction, libsqlBatch, libsqlExecute, libsqlExecuteMultiple, libsqlMigrate } from "./functions.js";
33
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";
55
import type { libsqlBatchReqStepExecCond } from "libsql-stateless";
66

77
export function createClient(conf: libsqlConfig) {
@@ -12,58 +12,20 @@ export function createClient(conf: libsqlConfig) {
1212
export class libsqlClient implements clientInterface {
1313
private readonly conf: libsqlConfig;
1414
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-
*/
2215
public protocol: string;
2316

2417
constructor(conf: libsqlConfig) {
2518
if (!conf.disableCriticalChecks) {
2619
checkHttpUrl(conf.url);
2720
ensure_fetch(conf);
21+
checkRedundantConfig(conf);
2822
}
2923

3024
this.conf = conf;
3125
this.closed = false;
3226
this.protocol = "http";
3327
}
3428

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-
*/
6729
public async execute(stmt: rawSQL, args?: rawSQLArgs, want_rows?: boolean): Promise<ResultSet>;
6830
public async execute(stmt: rawSQLStatement): Promise<ResultSet>;
6931
public async execute(stmt_or_sql: rawSQL|rawSQLStatement, or_args?: rawSQLArgs, or_want_rows?: boolean) {
@@ -128,8 +90,7 @@ export class libsqlClient implements clientInterface {
12890
return await libsqlMigrate(this.conf, stmts);
12991
}
13092

131-
// @ts-ignore
132-
public async transaction(mode?: TransactionMode): Promise<any> {
93+
public async transaction(_mode?: TransactionMode): Promise<any> {
13394
throw new MisuseError("'libsql-stateless' is stateless and does not support interactive transactions. Use this.batch() instead.");
13495
}
13596

src/globcon/mod.ts

+8
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,12 @@ export function checkHttpUrl(url: string) {
4040
'This is a HTTP client and only supports "https:" and "http:" URLs. For modern libsql DBs simply changing "libsql://" to "https://" should resolve this.',
4141
"URL_SCHEME_NOT_SUPPORTED",
4242
);
43+
}
44+
45+
export function checkRedundantConfig(conf: libsqlConfig) {
46+
if (conf.encryptionKey) conserror("'encryptionKey' config unsupported.");
47+
if (conf.syncUrl) conserror("'syncUrl' config unsupported because 'url' is the remote url. (embedded replicas unsupported)");
48+
if (conf.syncInterval) conserror("'syncInterval' config unsupported because nothing to sync. (embedded replicas unsupported)");
49+
if (conf.tls) conserror("'tls' config unsupported. Change url scheme to 'http' for no tls and 'https' for tls.");
50+
if (conf.concurrency) conserror("'concurrency' config unsupported. You may use a custom fetch to specify concurrency.");
4351
}

0 commit comments

Comments
 (0)