Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@libsql/client

Package Overview
Dependencies
Maintainers
3
Versions
93
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@libsql/client - npm Package Compare versions

Comparing version 0.2.2 to 0.3.0

5

lib-cjs/http.js

@@ -61,2 +61,3 @@ "use strict";

#client;
protocol;
/** @private */

@@ -66,2 +67,3 @@ constructor(url, authToken, intMode) {

this.#client.intMode = intMode;
this.protocol = "http";
}

@@ -87,4 +89,3 @@ async execute(stmt) {

}
async batch(arg1, arg2 = undefined) {
const { mode, stmts } = (0, util_js_1.extractBatchArgs)(arg1, arg2);
async batch(stmts, mode = "deferred") {
try {

@@ -91,0 +92,0 @@ const hranaStmts = stmts.map(hrana_js_1.stmtToHrana);

@@ -70,2 +70,3 @@ "use strict";

closed;
protocol;
/** @private */

@@ -77,2 +78,3 @@ constructor(path, options, intMode) {

this.closed = false;
this.protocol = "file";
}

@@ -89,4 +91,3 @@ async execute(stmt) {

}
async batch(arg1, arg2 = undefined) {
const { mode, stmts } = (0, util_js_1.extractBatchArgs)(arg1, arg2);
async batch(stmts, mode = "deferred") {
this.#checkNotClosed();

@@ -93,0 +94,0 @@ const db = new better_sqlite3_1.default(this.#path, this.#options);

17

lib-cjs/util.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.extractBatchArgs = exports.transactionModeToBegin = exports.supportedUrlLink = void 0;
exports.transactionModeToBegin = exports.supportedUrlLink = void 0;
exports.supportedUrlLink = "https://github.com/libsql/libsql-client-ts#supported-urls";

@@ -20,16 +20,1 @@ function transactionModeToBegin(mode) {

exports.transactionModeToBegin = transactionModeToBegin;
function extractBatchArgs(arg1, arg2) {
if (arg2 === undefined) {
return {
mode: "write",
stmts: arg1,
};
}
else {
return {
mode: arg1,
stmts: arg2,
};
}
}
exports.extractBatchArgs = extractBatchArgs;

@@ -84,2 +84,3 @@ "use strict";

closed;
protocol;
/** @private */

@@ -93,2 +94,3 @@ constructor(client, url, authToken, intMode) {

this.closed = false;
this.protocol = "ws";
}

@@ -113,4 +115,3 @@ async execute(stmt) {

}
async batch(arg1, arg2 = undefined) {
const { mode, stmts } = (0, util_js_1.extractBatchArgs)(arg1, arg2);
async batch(stmts, mode = "deferred") {
const streamState = await this.#openStream();

@@ -117,0 +118,0 @@ try {

@@ -66,3 +66,3 @@ /** Configuration object for {@link createClient}. */

* The `mode` parameter selects the transaction mode for the batch; please see {@link TransactionMode} for
* details.
* details. The default transaction mode is `"deferred"`.
*

@@ -76,3 +76,3 @@ * If any of the statements in the batch fails with an error, the batch is aborted, the transaction is

* ```javascript
* const rss = await client.batch("write", [
* const rss = await client.batch([
* // batch statement without arguments

@@ -92,14 +92,6 @@ * "DELETE FROM books WHERE name LIKE '%Crusoe'",

* },
* ]);
* ], "write");
* ```
*/
batch(mode: TransactionMode, stmts: Array<InStatement>): Promise<Array<ResultSet>>;
/** Execute a batch of SQL statement in the `"write"` transaction mode.
*
* Please see {@link batch} for details.
*
* @deprecated Please specify the `mode` explicitly. The default `"write"` will be removed in the next
* major release.
*/
batch(stmts: Array<InStatement>): Promise<Array<ResultSet>>;
batch(stmts: Array<InStatement>, mode?: TransactionMode): Promise<Array<ResultSet>>;
/** Start an interactive transaction.

@@ -112,3 +104,3 @@ *

* The `mode` parameter selects the transaction mode for the interactive transaction; please see {@link
* TransactionMode} for details.
* TransactionMode} for details. The default transaction mode is `"deferred"`.
*

@@ -120,3 +112,3 @@ * You **must** make sure that the returned {@link Transaction} object is closed, by calling {@link

* ```javascript
* const transaction = client.transaction();
* const transaction = client.transaction("write");
* try {

@@ -141,3 +133,3 @@ * // do some operations with the transaction here

*/
transaction(mode: TransactionMode): Promise<Transaction>;
transaction(mode?: TransactionMode): Promise<Transaction>;
/** Start an interactive transaction in `"write"` mode.

@@ -184,2 +176,9 @@ *

closed: boolean;
/** Which protocol does the client use?
*
* - `"http"` if the client connects over HTTP
* - `"ws"` if the client connects over WebSockets
* - `"file"` if the client works with a local file
*/
protocol: string;
}

@@ -198,3 +197,3 @@ /** Interactive transaction.

* ```javascript
* const transaction = client.transaction();
* const transaction = client.transaction("write");
* try {

@@ -299,3 +298,4 @@ * // do some operations with the transaction here

* If your transaction includes only read statements, `"read"` is always preferred over `"deferred"` or
* `"write"`, because `"read"` transactions can be executed on a replica and don't block other transactions.
* `"write"`, because `"read"` transactions can be executed more efficiently and don't block other
* transactions.
*

@@ -302,0 +302,0 @@ * If your transaction includes both read and write statements, you should be using the `"write"` mode most of

@@ -15,7 +15,7 @@ /// <reference types="node" />

#private;
protocol: "http";
/** @private */
constructor(url: URL, authToken: string | undefined, intMode: IntMode);
execute(stmt: InStatement): Promise<ResultSet>;
batch(mode: TransactionMode, stmts: Array<InStatement>): Promise<Array<ResultSet>>;
batch(stmts: Array<InStatement>): Promise<Array<ResultSet>>;
batch(stmts: Array<InStatement>, mode?: TransactionMode): Promise<Array<ResultSet>>;
transaction(mode?: TransactionMode): Promise<HttpTransaction>;

@@ -22,0 +22,0 @@ executeMultiple(sql: string): Promise<void>;

@@ -7,3 +7,3 @@ import * as hrana from "@libsql/hrana-client";

import { encodeBaseUrl } from "./uri.js";
import { supportedUrlLink, extractBatchArgs } from "./util.js";
import { supportedUrlLink } from "./util.js";
export * from "./api.js";

@@ -31,2 +31,3 @@ export function createClient(config) {

#client;
protocol;
/** @private */

@@ -36,2 +37,3 @@ constructor(url, authToken, intMode) {

this.#client.intMode = intMode;
this.protocol = "http";
}

@@ -57,4 +59,3 @@ async execute(stmt) {

}
async batch(arg1, arg2 = undefined) {
const { mode, stmts } = extractBatchArgs(arg1, arg2);
async batch(stmts, mode = "deferred") {
try {

@@ -61,0 +62,0 @@ const hranaStmts = stmts.map(stmtToHrana);

@@ -11,7 +11,7 @@ import Database from "better-sqlite3";

closed: boolean;
protocol: "file";
/** @private */
constructor(path: string, options: Database.Options, intMode: IntMode);
execute(stmt: InStatement): Promise<ResultSet>;
batch(mode: TransactionMode, stmts: Array<InStatement>): Promise<Array<ResultSet>>;
batch(stmts: Array<InStatement>): Promise<Array<ResultSet>>;
batch(stmts: Array<InStatement>, mode?: TransactionMode): Promise<Array<ResultSet>>;
transaction(mode?: TransactionMode): Promise<Transaction>;

@@ -18,0 +18,0 @@ executeMultiple(sql: string): Promise<void>;

@@ -5,3 +5,3 @@ import Database from "better-sqlite3";

import { expandConfig } from "./config.js";
import { supportedUrlLink, transactionModeToBegin, extractBatchArgs } from "./util.js";
import { supportedUrlLink, transactionModeToBegin } from "./util.js";
export * from "./api.js";

@@ -49,2 +49,3 @@ export function createClient(config) {

closed;
protocol;
/** @private */

@@ -56,2 +57,3 @@ constructor(path, options, intMode) {

this.closed = false;
this.protocol = "file";
}

@@ -68,4 +70,3 @@ async execute(stmt) {

}
async batch(arg1, arg2 = undefined) {
const { mode, stmts } = extractBatchArgs(arg1, arg2);
async batch(stmts, mode = "deferred") {
this.#checkNotClosed();

@@ -72,0 +73,0 @@ const db = new Database(this.#path, this.#options);

@@ -1,8 +0,3 @@

import { TransactionMode, InStatement } from "./api.js";
import { TransactionMode } from "./api.js";
export declare const supportedUrlLink = "https://github.com/libsql/libsql-client-ts#supported-urls";
export declare function transactionModeToBegin(mode: TransactionMode): string;
export type BatchArgs = {
mode: TransactionMode;
stmts: Array<InStatement>;
};
export declare function extractBatchArgs(arg1: unknown, arg2: unknown): BatchArgs;

@@ -16,15 +16,1 @@ export const supportedUrlLink = "https://github.com/libsql/libsql-client-ts#supported-urls";

}
export function extractBatchArgs(arg1, arg2) {
if (arg2 === undefined) {
return {
mode: "write",
stmts: arg1,
};
}
else {
return {
mode: arg1,
stmts: arg2,
};
}
}

@@ -26,7 +26,7 @@ /// <reference types="node" />

closed: boolean;
protocol: "ws";
/** @private */
constructor(client: hrana.WsClient, url: URL, authToken: string | undefined, intMode: IntMode);
execute(stmt: InStatement): Promise<ResultSet>;
batch(mode: TransactionMode, stmts: Array<InStatement>): Promise<Array<ResultSet>>;
batch(stmts: Array<InStatement>): Promise<Array<ResultSet>>;
batch(stmts: Array<InStatement>, mode?: TransactionMode): Promise<Array<ResultSet>>;
transaction(mode?: TransactionMode): Promise<WsTransaction>;

@@ -33,0 +33,0 @@ executeMultiple(sql: string): Promise<void>;

@@ -7,3 +7,3 @@ import * as hrana from "@libsql/hrana-client";

import { encodeBaseUrl } from "./uri.js";
import { supportedUrlLink, extractBatchArgs } from "./util.js";
import { supportedUrlLink } from "./util.js";
export * from "./api.js";

@@ -54,2 +54,3 @@ export function createClient(config) {

closed;
protocol;
/** @private */

@@ -63,2 +64,3 @@ constructor(client, url, authToken, intMode) {

this.closed = false;
this.protocol = "ws";
}

@@ -83,4 +85,3 @@ async execute(stmt) {

}
async batch(arg1, arg2 = undefined) {
const { mode, stmts } = extractBatchArgs(arg1, arg2);
async batch(stmts, mode = "deferred") {
const streamState = await this.#openStream();

@@ -87,0 +88,0 @@ try {

{
"name": "@libsql/client",
"version": "0.2.2",
"version": "0.3.0",
"keywords": [

@@ -5,0 +5,0 @@ "libsql",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc