@libsql/client
Advanced tools
+25
-4
@@ -69,2 +69,6 @@ "use strict"; | ||
| protocol; | ||
| #url; | ||
| #intMode; | ||
| #customFetch; | ||
| #concurrency; | ||
| #authToken; | ||
@@ -74,7 +78,11 @@ #promiseLimitFunction; | ||
| constructor(url, authToken, intMode, customFetch, concurrency) { | ||
| this.#client = hrana.openHttp(url, authToken, customFetch); | ||
| this.#client.intMode = intMode; | ||
| this.#url = url; | ||
| this.#authToken = authToken; | ||
| this.#intMode = intMode; | ||
| this.#customFetch = customFetch; | ||
| this.#concurrency = concurrency; | ||
| this.#client = hrana.openHttp(this.#url, this.#authToken, this.#customFetch); | ||
| this.#client.intMode = this.#intMode; | ||
| this.protocol = "http"; | ||
| this.#authToken = authToken; | ||
| this.#promiseLimitFunction = (0, promise_limit_1.default)(concurrency); | ||
| this.#promiseLimitFunction = (0, promise_limit_1.default)(this.#concurrency); | ||
| } | ||
@@ -218,2 +226,15 @@ async limit(fn) { | ||
| } | ||
| async reconnect() { | ||
| try { | ||
| if (!this.closed) { | ||
| // Abort in-flight ops and free resources | ||
| this.#client.close(); | ||
| } | ||
| } | ||
| finally { | ||
| // Recreate the underlying hrana client | ||
| this.#client = hrana.openHttp(this.#url, this.#authToken, this.#customFetch); | ||
| this.#client.intMode = this.#intMode; | ||
| } | ||
| } | ||
| get closed() { | ||
@@ -220,0 +241,0 @@ return this.#client.closed; |
+12
-0
@@ -176,2 +176,13 @@ "use strict"; | ||
| } | ||
| async reconnect() { | ||
| try { | ||
| if (!this.closed && this.#db !== null) { | ||
| this.#db.close(); | ||
| } | ||
| } | ||
| finally { | ||
| this.#db = new libsql_1.default(this.#path, this.#options); | ||
| this.closed = false; | ||
| } | ||
| } | ||
| close() { | ||
@@ -181,2 +192,3 @@ this.closed = true; | ||
| this.#db.close(); | ||
| this.#db = null; | ||
| } | ||
@@ -183,0 +195,0 @@ } |
+35
-0
@@ -319,2 +319,29 @@ "use strict"; | ||
| } | ||
| async reconnect() { | ||
| try { | ||
| for (const st of Array.from(this.#connState.streamStates)) { | ||
| try { | ||
| st.stream.close(); | ||
| } | ||
| catch { } | ||
| } | ||
| this.#connState.client.close(); | ||
| } | ||
| catch { } | ||
| if (this.#futureConnState) { | ||
| try { | ||
| this.#futureConnState.client.close(); | ||
| } | ||
| catch { } | ||
| this.#futureConnState = undefined; | ||
| } | ||
| const next = this.#openConn(); | ||
| const version = await next.client.getVersion(); | ||
| next.useSqlCache = version >= 2; | ||
| if (next.useSqlCache) { | ||
| next.sqlCache.capacity = sqlCacheCapacity; | ||
| } | ||
| this.#connState = next; | ||
| this.closed = false; | ||
| } | ||
| _closeStream(streamState) { | ||
@@ -334,2 +361,10 @@ streamState.stream.close(); | ||
| this.closed = true; | ||
| if (this.#futureConnState) { | ||
| try { | ||
| this.#futureConnState.client.close(); | ||
| } | ||
| catch { } | ||
| this.#futureConnState = undefined; | ||
| } | ||
| this.closed = true; | ||
| } | ||
@@ -336,0 +371,0 @@ } |
@@ -26,2 +26,3 @@ /// <reference types="node" /> | ||
| close(): void; | ||
| reconnect(): Promise<void>; | ||
| get closed(): boolean; | ||
@@ -28,0 +29,0 @@ } |
+25
-4
@@ -35,2 +35,6 @@ import * as hrana from "@libsql/hrana-client"; | ||
| protocol; | ||
| #url; | ||
| #intMode; | ||
| #customFetch; | ||
| #concurrency; | ||
| #authToken; | ||
@@ -40,7 +44,11 @@ #promiseLimitFunction; | ||
| constructor(url, authToken, intMode, customFetch, concurrency) { | ||
| this.#client = hrana.openHttp(url, authToken, customFetch); | ||
| this.#client.intMode = intMode; | ||
| this.#url = url; | ||
| this.#authToken = authToken; | ||
| this.#intMode = intMode; | ||
| this.#customFetch = customFetch; | ||
| this.#concurrency = concurrency; | ||
| this.#client = hrana.openHttp(this.#url, this.#authToken, this.#customFetch); | ||
| this.#client.intMode = this.#intMode; | ||
| this.protocol = "http"; | ||
| this.#authToken = authToken; | ||
| this.#promiseLimitFunction = promiseLimit(concurrency); | ||
| this.#promiseLimitFunction = promiseLimit(this.#concurrency); | ||
| } | ||
@@ -184,2 +192,15 @@ async limit(fn) { | ||
| } | ||
| async reconnect() { | ||
| try { | ||
| if (!this.closed) { | ||
| // Abort in-flight ops and free resources | ||
| this.#client.close(); | ||
| } | ||
| } | ||
| finally { | ||
| // Recreate the underlying hrana client | ||
| this.#client = hrana.openHttp(this.#url, this.#authToken, this.#customFetch); | ||
| this.#client.intMode = this.#intMode; | ||
| } | ||
| } | ||
| get closed() { | ||
@@ -186,0 +207,0 @@ return this.#client.closed; |
@@ -20,2 +20,3 @@ import Database from "libsql"; | ||
| sync(): Promise<Replicated>; | ||
| reconnect(): Promise<void>; | ||
| close(): void; | ||
@@ -22,0 +23,0 @@ } |
+12
-0
@@ -154,2 +154,13 @@ import Database from "libsql"; | ||
| } | ||
| async reconnect() { | ||
| try { | ||
| if (!this.closed && this.#db !== null) { | ||
| this.#db.close(); | ||
| } | ||
| } | ||
| finally { | ||
| this.#db = new Database(this.#path, this.#options); | ||
| this.closed = false; | ||
| } | ||
| } | ||
| close() { | ||
@@ -159,2 +170,3 @@ this.closed = true; | ||
| this.#db.close(); | ||
| this.#db = null; | ||
| } | ||
@@ -161,0 +173,0 @@ } |
+1
-0
@@ -36,2 +36,3 @@ /// <reference types="node" /> | ||
| sync(): Promise<Replicated>; | ||
| reconnect(): Promise<void>; | ||
| _closeStream(streamState: StreamState): void; | ||
@@ -38,0 +39,0 @@ close(): void; |
+35
-0
@@ -285,2 +285,29 @@ import * as hrana from "@libsql/hrana-client"; | ||
| } | ||
| async reconnect() { | ||
| try { | ||
| for (const st of Array.from(this.#connState.streamStates)) { | ||
| try { | ||
| st.stream.close(); | ||
| } | ||
| catch { } | ||
| } | ||
| this.#connState.client.close(); | ||
| } | ||
| catch { } | ||
| if (this.#futureConnState) { | ||
| try { | ||
| this.#futureConnState.client.close(); | ||
| } | ||
| catch { } | ||
| this.#futureConnState = undefined; | ||
| } | ||
| const next = this.#openConn(); | ||
| const version = await next.client.getVersion(); | ||
| next.useSqlCache = version >= 2; | ||
| if (next.useSqlCache) { | ||
| next.sqlCache.capacity = sqlCacheCapacity; | ||
| } | ||
| this.#connState = next; | ||
| this.closed = false; | ||
| } | ||
| _closeStream(streamState) { | ||
@@ -300,2 +327,10 @@ streamState.stream.close(); | ||
| this.closed = true; | ||
| if (this.#futureConnState) { | ||
| try { | ||
| this.#futureConnState.client.close(); | ||
| } | ||
| catch { } | ||
| this.#futureConnState = undefined; | ||
| } | ||
| this.closed = true; | ||
| } | ||
@@ -302,0 +337,0 @@ } |
+2
-2
| { | ||
| "name": "@libsql/client", | ||
| "version": "0.15.10", | ||
| "version": "0.15.11", | ||
| "keywords": [ | ||
@@ -106,3 +106,3 @@ "libsql", | ||
| "dependencies": { | ||
| "@libsql/core": "^0.15.10", | ||
| "@libsql/core": "^0.15.11", | ||
| "@libsql/hrana-client": "^0.7.0", | ||
@@ -109,0 +109,0 @@ "js-base64": "^3.7.5", |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
130443
3.23%3187
4.56%Updated