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.4.0-pre.7 to 0.4.0-pre.8

24

lib-cjs/hrana.js

@@ -28,4 +28,4 @@ "use strict";

const hrana = __importStar(require("@libsql/hrana-client"));
const api_js_1 = require("./api.js");
const util_js_1 = require("./util.js");
const api_1 = require("@libsql/core/api");
const util_1 = require("@libsql/core/util");
class HranaTransaction {

@@ -49,3 +49,3 @@ #mode;

if (stream.closed) {
throw new api_js_1.LibsqlError("Cannot execute statements because the transaction is closed", "TRANSACTION_CLOSED");
throw new api_1.LibsqlError("Cannot execute statements because the transaction is closed", "TRANSACTION_CLOSED");
}

@@ -61,3 +61,3 @@ try {

const beginStep = batch.step();
const beginPromise = beginStep.run((0, util_js_1.transactionModeToBegin)(this.#mode));
const beginPromise = beginStep.run((0, util_1.transactionModeToBegin)(this.#mode));
// Execute the `hranaStmts` only if the BEGIN succeeded, to make sure that we don't execute it

@@ -126,3 +126,3 @@ // outside of a transaction.

if (rows === undefined) {
throw new api_js_1.LibsqlError("Statement in a transaction was not executed, " +
throw new api_1.LibsqlError("Statement in a transaction was not executed, " +
"probably because the transaction has been rolled back", "TRANSACTION_CLOSED");

@@ -141,3 +141,3 @@ }

if (stream.closed) {
throw new api_js_1.LibsqlError("Cannot execute statements because the transaction is closed", "TRANSACTION_CLOSED");
throw new api_1.LibsqlError("Cannot execute statements because the transaction is closed", "TRANSACTION_CLOSED");
}

@@ -147,3 +147,3 @@ try {

// If the transaction hasn't started yet, start it now
this.#started = stream.run((0, util_js_1.transactionModeToBegin)(this.#mode))
this.#started = stream.run((0, util_1.transactionModeToBegin)(this.#mode))
.then(() => undefined);

@@ -204,3 +204,3 @@ try {

if (stream.closed) {
throw new api_js_1.LibsqlError("Cannot commit the transaction because it is already closed", "TRANSACTION_CLOSED");
throw new api_1.LibsqlError("Cannot commit the transaction because it is already closed", "TRANSACTION_CLOSED");
}

@@ -230,3 +230,3 @@ if (this.#started !== undefined) {

const beginStep = batch.step();
const beginPromise = beginStep.run((0, util_js_1.transactionModeToBegin)(mode));
const beginPromise = beginStep.run((0, util_1.transactionModeToBegin)(mode));
let lastStep = beginStep;

@@ -258,3 +258,3 @@ const stmtPromises = hranaStmts.map((hranaStmt) => {

if (hranaRows === undefined) {
throw new api_js_1.LibsqlError("Statement in a batch was not executed, probably because the transaction has been rolled back", "TRANSACTION_CLOSED");
throw new api_1.LibsqlError("Statement in a batch was not executed, probably because the transaction has been rolled back", "TRANSACTION_CLOSED");
}

@@ -290,3 +290,3 @@ resultSets.push(resultSetFromHrana(hranaRows));

? hranaRows.lastInsertRowid : undefined;
return new util_js_1.ResultSetImpl(columns, columnTypes, rows, rowsAffected, lastInsertRowid);
return new util_1.ResultSetImpl(columns, columnTypes, rows, rowsAffected, lastInsertRowid);
}

@@ -297,3 +297,3 @@ exports.resultSetFromHrana = resultSetFromHrana;

const code = mapHranaErrorCode(e);
return new api_js_1.LibsqlError(e.message, code, undefined, e);
return new api_1.LibsqlError(e.message, code, undefined, e);
}

@@ -300,0 +300,0 @@ return e;

@@ -31,11 +31,11 @@ "use strict";

const hrana = __importStar(require("@libsql/hrana-client"));
const api_js_1 = require("./api.js");
const config_js_1 = require("./config.js");
const api_1 = require("@libsql/core/api");
const config_1 = require("@libsql/core/config");
const hrana_js_1 = require("./hrana.js");
const sql_cache_js_1 = require("./sql_cache.js");
const uri_js_1 = require("./uri.js");
const util_js_1 = require("./util.js");
__exportStar(require("./api.js"), exports);
const uri_1 = require("@libsql/core/uri");
const util_1 = require("@libsql/core/util");
__exportStar(require("@libsql/core/api"), exports);
function createClient(config) {
return _createClient((0, config_js_1.expandConfig)(config, true));
return _createClient((0, config_1.expandConfig)(config, true));
}

@@ -46,12 +46,12 @@ exports.createClient = createClient;

if (config.scheme !== "https" && config.scheme !== "http") {
throw new api_js_1.LibsqlError('The HTTP client supports only "libsql:", "https:" and "http:" URLs, ' +
`got ${JSON.stringify(config.scheme + ":")}. For more information, please read ${util_js_1.supportedUrlLink}`, "URL_SCHEME_NOT_SUPPORTED");
throw new api_1.LibsqlError('The HTTP client supports only "libsql:", "https:" and "http:" URLs, ' +
`got ${JSON.stringify(config.scheme + ":")}. For more information, please read ${util_1.supportedUrlLink}`, "URL_SCHEME_NOT_SUPPORTED");
}
if (config.scheme === "http" && config.tls) {
throw new api_js_1.LibsqlError(`A "http:" URL cannot opt into TLS by using ?tls=1`, "URL_INVALID");
throw new api_1.LibsqlError(`A "http:" URL cannot opt into TLS by using ?tls=1`, "URL_INVALID");
}
else if (config.scheme === "https" && !config.tls) {
throw new api_js_1.LibsqlError(`A "https:" URL cannot opt out of TLS by using ?tls=0`, "URL_INVALID");
throw new api_1.LibsqlError(`A "https:" URL cannot opt out of TLS by using ?tls=0`, "URL_INVALID");
}
const url = (0, uri_js_1.encodeBaseUrl)(config.scheme, config.authority, config.path);
const url = (0, uri_1.encodeBaseUrl)(config.scheme, config.authority, config.path);
return new HttpClient(url, config.authToken, config.intMode, config.fetch);

@@ -146,3 +146,3 @@ }

sync() {
throw new api_js_1.LibsqlError("sync not supported in http mode", "SYNC_NOT_SUPPORTED");
throw new api_1.LibsqlError("sync not supported in http mode", "SYNC_NOT_SUPPORTED");
}

@@ -149,0 +149,0 @@ close() {

@@ -18,7 +18,7 @@ "use strict";

exports.createClient = void 0;
const config_js_1 = require("./config.js");
const config_1 = require("@libsql/core/config");
const sqlite3_js_1 = require("./sqlite3.js");
const ws_js_1 = require("./ws.js");
const http_js_1 = require("./http.js");
__exportStar(require("./api.js"), exports);
__exportStar(require("@libsql/core/api"), exports);
/** Creates a {@link Client} object.

@@ -29,3 +29,3 @@ *

function createClient(config) {
return _createClient((0, config_js_1.expandConfig)(config, true));
return _createClient((0, config_1.expandConfig)(config, true));
}

@@ -32,0 +32,0 @@ exports.createClient = createClient;

@@ -23,8 +23,8 @@ "use strict";

const node_buffer_1 = require("node:buffer");
const api_js_1 = require("./api.js");
const config_js_1 = require("./config.js");
const util_js_1 = require("./util.js");
__exportStar(require("./api.js"), exports);
const api_1 = require("@libsql/core/api");
const config_1 = require("@libsql/core/config");
const util_1 = require("@libsql/core/util");
__exportStar(require("@libsql/core/api"), exports);
function createClient(config) {
return _createClient((0, config_js_1.expandConfig)(config, true));
return _createClient((0, config_1.expandConfig)(config, true));
}

@@ -35,4 +35,4 @@ exports.createClient = createClient;

if (config.scheme !== "file") {
throw new api_js_1.LibsqlError(`URL scheme ${JSON.stringify(config.scheme + ":")} is not supported by the local sqlite3 client. ` +
`For more information, please read ${util_js_1.supportedUrlLink}`, "URL_SCHEME_NOT_SUPPORTED");
throw new api_1.LibsqlError(`URL scheme ${JSON.stringify(config.scheme + ":")} is not supported by the local sqlite3 client. ` +
`For more information, please read ${util_1.supportedUrlLink}`, "URL_SCHEME_NOT_SUPPORTED");
}

@@ -43,12 +43,12 @@ const authority = config.authority;

if (host !== "" && host !== "localhost") {
throw new api_js_1.LibsqlError(`Invalid host in file URL: ${JSON.stringify(authority.host)}. ` +
throw new api_1.LibsqlError(`Invalid host in file URL: ${JSON.stringify(authority.host)}. ` +
'A "file:" URL with an absolute path should start with one slash ("file:/absolute/path.db") ' +
'or with three slashes ("file:///absolute/path.db"). ' +
`For more information, please read ${util_js_1.supportedUrlLink}`, "URL_INVALID");
`For more information, please read ${util_1.supportedUrlLink}`, "URL_INVALID");
}
if (authority.port !== undefined) {
throw new api_js_1.LibsqlError("File URL cannot have a port", "URL_INVALID");
throw new api_1.LibsqlError("File URL cannot have a port", "URL_INVALID");
}
if (authority.userinfo !== undefined) {
throw new api_js_1.LibsqlError("File URL cannot have username and password", "URL_INVALID");
throw new api_1.LibsqlError("File URL cannot have username and password", "URL_INVALID");
}

@@ -90,6 +90,6 @@ }

try {
executeStmt(db, (0, util_js_1.transactionModeToBegin)(mode), this.#intMode);
executeStmt(db, (0, util_1.transactionModeToBegin)(mode), this.#intMode);
const resultSets = stmts.map((stmt) => {
if (!db.inTransaction) {
throw new api_js_1.LibsqlError("The transaction has been rolled back", "TRANSACTION_CLOSED");
throw new api_1.LibsqlError("The transaction has been rolled back", "TRANSACTION_CLOSED");
}

@@ -109,3 +109,3 @@ return executeStmt(db, stmt, this.#intMode);

const db = this.#getDb();
executeStmt(db, (0, util_js_1.transactionModeToBegin)(mode), this.#intMode);
executeStmt(db, (0, util_1.transactionModeToBegin)(mode), this.#intMode);
this.#db = null; // A new connection will be lazily created on next use

@@ -138,3 +138,3 @@ return new Sqlite3Transaction(db, this.#intMode);

if (this.closed) {
throw new api_js_1.LibsqlError("The client is closed", "CLIENT_CLOSED");
throw new api_1.LibsqlError("The client is closed", "CLIENT_CLOSED");
}

@@ -194,3 +194,3 @@ }

if (this.closed) {
throw new api_js_1.LibsqlError("The transaction is closed", "TRANSACTION_CLOSED");
throw new api_1.LibsqlError("The transaction is closed", "TRANSACTION_CLOSED");
}

@@ -241,3 +241,3 @@ }

const lastInsertRowid = undefined;
return new util_js_1.ResultSetImpl(columns, columnTypes, rows, rowsAffected, lastInsertRowid);
return new util_1.ResultSetImpl(columns, columnTypes, rows, rowsAffected, lastInsertRowid);
}

@@ -248,3 +248,3 @@ else {

const lastInsertRowid = BigInt(info.lastInsertRowid);
return new util_js_1.ResultSetImpl([], [], [], rowsAffected, lastInsertRowid);
return new util_1.ResultSetImpl([], [], [], rowsAffected, lastInsertRowid);
}

@@ -343,5 +343,5 @@ }

if (e instanceof libsql_1.default.SqliteError) {
return new api_js_1.LibsqlError(e.message, e.code, e.rawCode, e);
return new api_1.LibsqlError(e.message, e.code, e.rawCode, e);
}
return e;
}

@@ -18,10 +18,10 @@ "use strict";

exports._createClient = exports.createClient = void 0;
const api_js_1 = require("./api.js");
const config_js_1 = require("./config.js");
const util_js_1 = require("./util.js");
const api_1 = require("@libsql/core/api");
const config_1 = require("@libsql/core/config");
const util_1 = require("@libsql/core/util");
const ws_js_1 = require("./ws.js");
const http_js_1 = require("./http.js");
__exportStar(require("./api.js"), exports);
__exportStar(require("@libsql/core/api"), exports);
function createClient(config) {
return _createClient((0, config_js_1.expandConfig)(config, true));
return _createClient((0, config_1.expandConfig)(config, true));
}

@@ -38,6 +38,6 @@ exports.createClient = createClient;

else {
throw new api_js_1.LibsqlError('The client that uses Web standard APIs supports only "libsql:", "wss:", "ws:", "https:" and "http:" URLs, ' +
`got ${JSON.stringify(config.scheme + ":")}. For more information, please read ${util_js_1.supportedUrlLink}`, "URL_SCHEME_NOT_SUPPORTED");
throw new api_1.LibsqlError('The client that uses Web standard APIs supports only "libsql:", "wss:", "ws:", "https:" and "http:" URLs, ' +
`got ${JSON.stringify(config.scheme + ":")}. For more information, please read ${util_1.supportedUrlLink}`, "URL_SCHEME_NOT_SUPPORTED");
}
}
exports._createClient = _createClient;

@@ -31,11 +31,11 @@ "use strict";

const hrana = __importStar(require("@libsql/hrana-client"));
const api_js_1 = require("./api.js");
const config_js_1 = require("./config.js");
const api_1 = require("@libsql/core/api");
const config_1 = require("@libsql/core/config");
const hrana_js_1 = require("./hrana.js");
const sql_cache_js_1 = require("./sql_cache.js");
const uri_js_1 = require("./uri.js");
const util_js_1 = require("./util.js");
__exportStar(require("./api.js"), exports);
const uri_1 = require("@libsql/core/uri");
const util_1 = require("@libsql/core/util");
__exportStar(require("@libsql/core/api"), exports);
function createClient(config) {
return _createClient((0, config_js_1.expandConfig)(config, false));
return _createClient((0, config_1.expandConfig)(config, false));
}

@@ -46,12 +46,12 @@ exports.createClient = createClient;

if (config.scheme !== "wss" && config.scheme !== "ws") {
throw new api_js_1.LibsqlError('The WebSocket client supports only "libsql:", "wss:" and "ws:" URLs, ' +
`got ${JSON.stringify(config.scheme + ":")}. For more information, please read ${util_js_1.supportedUrlLink}`, "URL_SCHEME_NOT_SUPPORTED");
throw new api_1.LibsqlError('The WebSocket client supports only "libsql:", "wss:" and "ws:" URLs, ' +
`got ${JSON.stringify(config.scheme + ":")}. For more information, please read ${util_1.supportedUrlLink}`, "URL_SCHEME_NOT_SUPPORTED");
}
if (config.scheme === "ws" && config.tls) {
throw new api_js_1.LibsqlError(`A "ws:" URL cannot opt into TLS by using ?tls=1`, "URL_INVALID");
throw new api_1.LibsqlError(`A "ws:" URL cannot opt into TLS by using ?tls=1`, "URL_INVALID");
}
else if (config.scheme === "wss" && !config.tls) {
throw new api_js_1.LibsqlError(`A "wss:" URL cannot opt out of TLS by using ?tls=0`, "URL_INVALID");
throw new api_1.LibsqlError(`A "wss:" URL cannot opt out of TLS by using ?tls=0`, "URL_INVALID");
}
const url = (0, uri_js_1.encodeBaseUrl)(config.scheme, config.authority, config.path);
const url = (0, uri_1.encodeBaseUrl)(config.scheme, config.authority, config.path);
let client;

@@ -64,6 +64,6 @@ try {

const suggestedScheme = config.scheme === "wss" ? "https" : "http";
const suggestedUrl = (0, uri_js_1.encodeBaseUrl)(suggestedScheme, config.authority, config.path);
throw new api_js_1.LibsqlError("This environment does not support WebSockets, please switch to the HTTP client by using " +
const suggestedUrl = (0, uri_1.encodeBaseUrl)(suggestedScheme, config.authority, config.path);
throw new api_1.LibsqlError("This environment does not support WebSockets, please switch to the HTTP client by using " +
`a "${suggestedScheme}:" URL (${JSON.stringify(suggestedUrl)}). ` +
`For more information, please read ${util_js_1.supportedUrlLink}`, "WEBSOCKETS_NOT_SUPPORTED");
`For more information, please read ${util_1.supportedUrlLink}`, "WEBSOCKETS_NOT_SUPPORTED");
}

@@ -169,3 +169,3 @@ throw (0, hrana_js_1.mapHranaError)(e);

if (this.closed) {
throw new api_js_1.LibsqlError("The client is closed", "CLIENT_CLOSED");
throw new api_1.LibsqlError("The client is closed", "CLIENT_CLOSED");
}

@@ -172,0 +172,0 @@ const now = new Date();

import * as hrana from "@libsql/hrana-client";
import type { InStatement, ResultSet, Transaction, TransactionMode } from "./api.js";
import type { InStatement, ResultSet, Transaction, TransactionMode } from "@libsql/core/api";
import type { SqlCache } from "./sql_cache.js";

@@ -4,0 +4,0 @@ export declare abstract class HranaTransaction implements Transaction {

import * as hrana from "@libsql/hrana-client";
import { LibsqlError } from "./api.js";
import { transactionModeToBegin, ResultSetImpl } from "./util.js";
import { LibsqlError } from "@libsql/core/api";
import { transactionModeToBegin, ResultSetImpl } from "@libsql/core/util";
export class HranaTransaction {

@@ -5,0 +5,0 @@ #mode;

/// <reference types="node" />
import * as hrana from "@libsql/hrana-client";
import type { Config, Client } from "./api.js";
import type { InStatement, ResultSet, Transaction, IntMode } from "./api.js";
import { TransactionMode } from "./api.js";
import type { ExpandedConfig } from "./config.js";
import type { Config, Client } from "@libsql/core/api";
import type { InStatement, ResultSet, Transaction, IntMode } from "@libsql/core/api";
import { TransactionMode } from "@libsql/core/api";
import type { ExpandedConfig } from "@libsql/core/config";
import { HranaTransaction } from "./hrana.js";
import { SqlCache } from "./sql_cache.js";
export * from "./api.js";
export * from "@libsql/core/api";
export declare function createClient(config: Config): Client;

@@ -11,0 +11,0 @@ /** @private */

import * as hrana from "@libsql/hrana-client";
import { LibsqlError } from "./api.js";
import { expandConfig } from "./config.js";
import { LibsqlError } from "@libsql/core/api";
import { expandConfig } from "@libsql/core/config";
import { HranaTransaction, executeHranaBatch, stmtToHrana, resultSetFromHrana, mapHranaError, } from "./hrana.js";
import { SqlCache } from "./sql_cache.js";
import { encodeBaseUrl } from "./uri.js";
import { supportedUrlLink } from "./util.js";
export * from "./api.js";
import { encodeBaseUrl } from "@libsql/core/uri";
import { supportedUrlLink } from "@libsql/core/util";
export * from "@libsql/core/api";
export function createClient(config) {

@@ -10,0 +10,0 @@ return _createClient(expandConfig(config, true));

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

import type { Config, Client } from "./api.js";
export * from "./api.js";
import type { Config, Client } from "@libsql/core/api";
export * from "@libsql/core/api";
/** Creates a {@link Client} object.

@@ -4,0 +4,0 @@ *

@@ -1,6 +0,6 @@

import { expandConfig } from "./config.js";
import { expandConfig } from "@libsql/core/config";
import { _createClient as _createSqlite3Client } from "./sqlite3.js";
import { _createClient as _createWsClient } from "./ws.js";
import { _createClient as _createHttpClient } from "./http.js";
export * from "./api.js";
export * from "@libsql/core/api";
/** Creates a {@link Client} object.

@@ -7,0 +7,0 @@ *

import Database from "libsql";
import type { Config, IntMode, Client, Transaction, TransactionMode, ResultSet, InStatement } from "./api.js";
import type { ExpandedConfig } from "./config.js";
export * from "./api.js";
import type { Config, IntMode, Client, Transaction, TransactionMode, ResultSet, InStatement } from "@libsql/core/api";
import type { ExpandedConfig } from "@libsql/core/config";
export * from "@libsql/core/api";
export declare function createClient(config: Config): Client;

@@ -6,0 +6,0 @@ /** @private */

import Database from "libsql";
import { Buffer } from "node:buffer";
import { LibsqlError } from "./api.js";
import { expandConfig } from "./config.js";
import { supportedUrlLink, transactionModeToBegin, ResultSetImpl } from "./util.js";
export * from "./api.js";
import { LibsqlError } from "@libsql/core/api";
import { expandConfig } from "@libsql/core/config";
import { supportedUrlLink, transactionModeToBegin, ResultSetImpl } from "@libsql/core/util";
export * from "@libsql/core/api";
export function createClient(config) {

@@ -8,0 +8,0 @@ return _createClient(expandConfig(config, true));

@@ -1,6 +0,6 @@

import type { Config, Client } from "./api.js";
import type { ExpandedConfig } from "./config.js";
export * from "./api.js";
import type { Config, Client } from "@libsql/core/api";
import type { ExpandedConfig } from "@libsql/core/config";
export * from "@libsql/core/api";
export declare function createClient(config: Config): Client;
/** @private */
export declare function _createClient(config: ExpandedConfig): Client;

@@ -1,7 +0,7 @@

import { LibsqlError } from "./api.js";
import { expandConfig } from "./config.js";
import { supportedUrlLink } from "./util.js";
import { LibsqlError } from "@libsql/core/api";
import { expandConfig } from "@libsql/core/config";
import { supportedUrlLink } from "@libsql/core/util";
import { _createClient as _createWsClient } from "./ws.js";
import { _createClient as _createHttpClient } from "./http.js";
export * from "./api.js";
export * from "@libsql/core/api";
export function createClient(config) {

@@ -8,0 +8,0 @@ return _createClient(expandConfig(config, true));

/// <reference types="node" />
import * as hrana from "@libsql/hrana-client";
import type { Config, IntMode, Client, Transaction, ResultSet, InStatement } from "./api.js";
import { TransactionMode } from "./api.js";
import type { ExpandedConfig } from "./config.js";
import type { Config, IntMode, Client, Transaction, ResultSet, InStatement } from "@libsql/core/api";
import { TransactionMode } from "@libsql/core/api";
import type { ExpandedConfig } from "@libsql/core/config";
import { HranaTransaction } from "./hrana.js";
import { SqlCache } from "./sql_cache.js";
export * from "./api.js";
export * from "@libsql/core/api";
export declare function createClient(config: Config): WsClient;

@@ -10,0 +10,0 @@ /** @private */

import * as hrana from "@libsql/hrana-client";
import { LibsqlError } from "./api.js";
import { expandConfig } from "./config.js";
import { LibsqlError } from "@libsql/core/api";
import { expandConfig } from "@libsql/core/config";
import { HranaTransaction, executeHranaBatch, stmtToHrana, resultSetFromHrana, mapHranaError, } from "./hrana.js";
import { SqlCache } from "./sql_cache.js";
import { encodeBaseUrl } from "./uri.js";
import { supportedUrlLink } from "./util.js";
export * from "./api.js";
import { encodeBaseUrl } from "@libsql/core/uri";
import { supportedUrlLink } from "@libsql/core/util";
export * from "@libsql/core/api";
export function createClient(config) {

@@ -10,0 +10,0 @@ return _createClient(expandConfig(config, false));

{
"name": "@libsql/client",
"version": "0.4.0-pre.7",
"version": "0.4.0-pre.8",
"keywords": [

@@ -102,2 +102,3 @@ "libsql",

"dependencies": {
"@libsql/core": "^0.4.0-pre.7",
"@libsql/hrana-client": "^0.5.5",

@@ -104,0 +105,0 @@ "js-base64": "^3.7.5",

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