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.7.0 to 0.8.0-pre.1

41

lib-cjs/http.js

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

const util_1 = require("@libsql/core/util");
const migrations_js_1 = require("./migrations.js");
const promise_limit_1 = __importDefault(require("promise-limit"));

@@ -71,5 +70,3 @@ __exportStar(require("@libsql/core/api"), exports);

protocol;
#url;
#authToken;
#isSchemaDatabase;
#promiseLimitFunction;

@@ -81,22 +78,21 @@ /** @private */

this.protocol = "http";
this.#url = url;
this.#authToken = authToken;
this.#promiseLimitFunction = (0, promise_limit_1.default)(concurrency);
}
getIsSchemaDatabase() {
if (this.#isSchemaDatabase === undefined) {
this.#isSchemaDatabase = (0, migrations_js_1.getIsSchemaDatabase)({
authToken: this.#authToken,
baseUrl: this.#url.origin,
});
}
return this.#isSchemaDatabase;
}
async limit(fn) {
return this.#promiseLimitFunction(fn);
}
async execute(stmt) {
async execute(stmtOrSql, args) {
let stmt;
if (typeof stmtOrSql === 'string') {
stmt = {
sql: stmtOrSql,
args: args || []
};
}
else {
stmt = stmtOrSql;
}
return this.limit(async () => {
try {
const isSchemaDatabasePromise = this.getIsSchemaDatabase();
const hranaStmt = (0, hrana_js_1.stmtToHrana)(stmt);

@@ -114,9 +110,2 @@ // Pipeline all operations, so `hrana.HttpClient` can open the stream, execute the statement and

const rowsResult = await rowsPromise;
const isSchemaDatabase = await isSchemaDatabasePromise;
if (isSchemaDatabase) {
await (0, migrations_js_1.waitForLastMigrationJobToFinish)({
authToken: this.#authToken,
baseUrl: this.#url.origin,
});
}
return (0, hrana_js_1.resultSetFromHrana)(rowsResult);

@@ -132,3 +121,2 @@ }

try {
const isSchemaDatabasePromise = this.getIsSchemaDatabase();
const hranaStmts = stmts.map(hrana_js_1.stmtToHrana);

@@ -156,9 +144,2 @@ const version = await this.#client.getVersion();

const results = await resultsPromise;
const isSchemaDatabase = await isSchemaDatabasePromise;
if (isSchemaDatabase) {
await (0, migrations_js_1.waitForLastMigrationJobToFinish)({
authToken: this.#authToken,
baseUrl: this.#url.origin,
});
}
return results;

@@ -165,0 +146,0 @@ }

@@ -53,3 +53,4 @@ "use strict";

}
const path = config.path;
// note: we must always prepend file scheme in order for SQLite3 to recognize :memory: connection query parameters
const path = `${config.scheme}:${config.path}`;
const options = {

@@ -82,3 +83,13 @@ authToken: config.authToken,

}
async execute(stmt) {
async execute(stmtOrSql, args) {
let stmt;
if (typeof stmtOrSql === 'string') {
stmt = {
sql: stmtOrSql,
args: args || []
};
}
else {
stmt = stmtOrSql;
}
this.#checkNotClosed();

@@ -157,3 +168,13 @@ return executeStmt(this.#getDb(), stmt, this.#intMode);

}
async execute(stmt) {
async execute(stmtOrSql, args) {
let stmt;
if (typeof stmtOrSql === 'string') {
stmt = {
sql: stmtOrSql,
args: args || []
};
}
else {
stmt = stmtOrSql;
}
this.#checkNotClosed();

@@ -160,0 +181,0 @@ return executeStmt(this.#database, stmt, this.#intMode);

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

const util_1 = require("@libsql/core/util");
const migrations_js_1 = require("./migrations.js");
const promise_limit_1 = __importDefault(require("promise-limit"));

@@ -107,19 +106,19 @@ __exportStar(require("@libsql/core/api"), exports);

}
getIsSchemaDatabase() {
if (this.#isSchemaDatabase === undefined) {
this.#isSchemaDatabase = (0, migrations_js_1.getIsSchemaDatabase)({
authToken: this.#authToken,
baseUrl: this.#url.origin,
});
}
return this.#isSchemaDatabase;
}
async limit(fn) {
return this.#promiseLimitFunction(fn);
}
async execute(stmt) {
async execute(stmtOrSql, args) {
let stmt;
if (typeof stmtOrSql === 'string') {
stmt = {
sql: stmtOrSql,
args: args || []
};
}
else {
stmt = stmtOrSql;
}
return this.limit(async () => {
const streamState = await this.#openStream();
try {
const isSchemaDatabasePromise = this.getIsSchemaDatabase();
const hranaStmt = (0, hrana_js_1.stmtToHrana)(stmt);

@@ -132,9 +131,2 @@ // Schedule all operations synchronously, so they will be pipelined and executed in a single

const hranaRowsResult = await hranaRowsPromise;
const isSchemaDatabase = await isSchemaDatabasePromise;
if (isSchemaDatabase) {
await (0, migrations_js_1.waitForLastMigrationJobToFinish)({
authToken: this.#authToken,
baseUrl: this.#url.origin,
});
}
return (0, hrana_js_1.resultSetFromHrana)(hranaRowsResult);

@@ -154,3 +146,2 @@ }

try {
const isSchemaDatabasePromise = this.getIsSchemaDatabase();
const hranaStmts = stmts.map(hrana_js_1.stmtToHrana);

@@ -164,9 +155,2 @@ const version = await streamState.conn.client.getVersion();

const results = await resultsPromise;
const isSchemaDatabase = await isSchemaDatabasePromise;
if (isSchemaDatabase) {
await (0, migrations_js_1.waitForLastMigrationJobToFinish)({
authToken: this.#authToken,
baseUrl: this.#url.origin,
});
}
return results;

@@ -173,0 +157,0 @@ }

/// <reference types="node" />
import * as hrana from "@libsql/hrana-client";
import type { Config, Client } from "@libsql/core/api";
import type { InStatement, ResultSet, Transaction, IntMode } from "@libsql/core/api";
import type { InStatement, ResultSet, Transaction, IntMode, InArgs } from "@libsql/core/api";
import { TransactionMode } from "@libsql/core/api";

@@ -18,5 +18,5 @@ import type { ExpandedConfig } from "@libsql/core/config";

constructor(url: URL, authToken: string | undefined, intMode: IntMode, customFetch: Function | undefined, concurrency: number);
getIsSchemaDatabase(): Promise<boolean>;
private limit;
execute(stmt: InStatement): Promise<ResultSet>;
execute(sql: string, args?: InArgs): Promise<ResultSet>;
batch(stmts: Array<InStatement>, mode?: TransactionMode): Promise<Array<ResultSet>>;

@@ -23,0 +23,0 @@ transaction(mode?: TransactionMode): Promise<HttpTransaction>;

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

import { supportedUrlLink } from "@libsql/core/util";
import { getIsSchemaDatabase, waitForLastMigrationJobToFinish, } from "./migrations.js";
import promiseLimit from "promise-limit";

@@ -37,5 +36,3 @@ export * from "@libsql/core/api";

protocol;
#url;
#authToken;
#isSchemaDatabase;
#promiseLimitFunction;

@@ -47,22 +44,21 @@ /** @private */

this.protocol = "http";
this.#url = url;
this.#authToken = authToken;
this.#promiseLimitFunction = promiseLimit(concurrency);
}
getIsSchemaDatabase() {
if (this.#isSchemaDatabase === undefined) {
this.#isSchemaDatabase = getIsSchemaDatabase({
authToken: this.#authToken,
baseUrl: this.#url.origin,
});
}
return this.#isSchemaDatabase;
}
async limit(fn) {
return this.#promiseLimitFunction(fn);
}
async execute(stmt) {
async execute(stmtOrSql, args) {
let stmt;
if (typeof stmtOrSql === 'string') {
stmt = {
sql: stmtOrSql,
args: args || []
};
}
else {
stmt = stmtOrSql;
}
return this.limit(async () => {
try {
const isSchemaDatabasePromise = this.getIsSchemaDatabase();
const hranaStmt = stmtToHrana(stmt);

@@ -80,9 +76,2 @@ // Pipeline all operations, so `hrana.HttpClient` can open the stream, execute the statement and

const rowsResult = await rowsPromise;
const isSchemaDatabase = await isSchemaDatabasePromise;
if (isSchemaDatabase) {
await waitForLastMigrationJobToFinish({
authToken: this.#authToken,
baseUrl: this.#url.origin,
});
}
return resultSetFromHrana(rowsResult);

@@ -98,3 +87,2 @@ }

try {
const isSchemaDatabasePromise = this.getIsSchemaDatabase();
const hranaStmts = stmts.map(stmtToHrana);

@@ -122,9 +110,2 @@ const version = await this.#client.getVersion();

const results = await resultsPromise;
const isSchemaDatabase = await isSchemaDatabasePromise;
if (isSchemaDatabase) {
await waitForLastMigrationJobToFinish({
authToken: this.#authToken,
baseUrl: this.#url.origin,
});
}
return results;

@@ -131,0 +112,0 @@ }

import Database from "libsql";
import type { Config, IntMode, Client, Transaction, TransactionMode, ResultSet, InStatement } from "@libsql/core/api";
import type { Config, IntMode, Client, Transaction, TransactionMode, ResultSet, InStatement, InArgs } from "@libsql/core/api";
import type { ExpandedConfig } from "@libsql/core/config";

@@ -15,2 +15,3 @@ export * from "@libsql/core/api";

execute(stmt: InStatement): Promise<ResultSet>;
execute(sql: string, args?: InArgs): Promise<ResultSet>;
batch(stmts: Array<InStatement>, mode?: TransactionMode): Promise<Array<ResultSet>>;

@@ -27,2 +28,3 @@ transaction(mode?: TransactionMode): Promise<Transaction>;

execute(stmt: InStatement): Promise<ResultSet>;
execute(sql: string, args?: InArgs): Promise<ResultSet>;
batch(stmts: Array<InStatement>): Promise<Array<ResultSet>>;

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

@@ -32,3 +32,4 @@ import Database from "libsql";

}
const path = config.path;
// note: we must always prepend file scheme in order for SQLite3 to recognize :memory: connection query parameters
const path = `${config.scheme}:${config.path}`;
const options = {

@@ -60,3 +61,13 @@ authToken: config.authToken,

}
async execute(stmt) {
async execute(stmtOrSql, args) {
let stmt;
if (typeof stmtOrSql === 'string') {
stmt = {
sql: stmtOrSql,
args: args || []
};
}
else {
stmt = stmtOrSql;
}
this.#checkNotClosed();

@@ -134,3 +145,13 @@ return executeStmt(this.#getDb(), stmt, this.#intMode);

}
async execute(stmt) {
async execute(stmtOrSql, args) {
let stmt;
if (typeof stmtOrSql === 'string') {
stmt = {
sql: stmtOrSql,
args: args || []
};
}
else {
stmt = stmtOrSql;
}
this.#checkNotClosed();

@@ -137,0 +158,0 @@ return executeStmt(this.#database, stmt, this.#intMode);

/// <reference types="node" />
import * as hrana from "@libsql/hrana-client";
import type { Config, IntMode, Client, Transaction, ResultSet, InStatement } from "@libsql/core/api";
import type { Config, IntMode, Client, Transaction, ResultSet, InStatement, InArgs } from "@libsql/core/api";
import { TransactionMode } from "@libsql/core/api";

@@ -29,5 +29,5 @@ import type { ExpandedConfig } from "@libsql/core/config";

constructor(client: hrana.WsClient, url: URL, authToken: string | undefined, intMode: IntMode, concurrency: number | undefined);
getIsSchemaDatabase(): Promise<boolean>;
private limit;
execute(stmt: InStatement): Promise<ResultSet>;
execute(sql: string, args?: InArgs): Promise<ResultSet>;
batch(stmts: Array<InStatement>, mode?: TransactionMode): Promise<Array<ResultSet>>;

@@ -34,0 +34,0 @@ transaction(mode?: TransactionMode): Promise<WsTransaction>;

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

import { supportedUrlLink } from "@libsql/core/util";
import { getIsSchemaDatabase, waitForLastMigrationJobToFinish, } from "./migrations.js";
import promiseLimit from "promise-limit";

@@ -73,19 +72,19 @@ export * from "@libsql/core/api";

}
getIsSchemaDatabase() {
if (this.#isSchemaDatabase === undefined) {
this.#isSchemaDatabase = getIsSchemaDatabase({
authToken: this.#authToken,
baseUrl: this.#url.origin,
});
}
return this.#isSchemaDatabase;
}
async limit(fn) {
return this.#promiseLimitFunction(fn);
}
async execute(stmt) {
async execute(stmtOrSql, args) {
let stmt;
if (typeof stmtOrSql === 'string') {
stmt = {
sql: stmtOrSql,
args: args || []
};
}
else {
stmt = stmtOrSql;
}
return this.limit(async () => {
const streamState = await this.#openStream();
try {
const isSchemaDatabasePromise = this.getIsSchemaDatabase();
const hranaStmt = stmtToHrana(stmt);

@@ -98,9 +97,2 @@ // Schedule all operations synchronously, so they will be pipelined and executed in a single

const hranaRowsResult = await hranaRowsPromise;
const isSchemaDatabase = await isSchemaDatabasePromise;
if (isSchemaDatabase) {
await waitForLastMigrationJobToFinish({
authToken: this.#authToken,
baseUrl: this.#url.origin,
});
}
return resultSetFromHrana(hranaRowsResult);

@@ -120,3 +112,2 @@ }

try {
const isSchemaDatabasePromise = this.getIsSchemaDatabase();
const hranaStmts = stmts.map(stmtToHrana);

@@ -130,9 +121,2 @@ const version = await streamState.conn.client.getVersion();

const results = await resultsPromise;
const isSchemaDatabase = await isSchemaDatabasePromise;
if (isSchemaDatabase) {
await waitForLastMigrationJobToFinish({
authToken: this.#authToken,
baseUrl: this.#url.origin,
});
}
return results;

@@ -139,0 +123,0 @@ }

{
"name": "@libsql/client",
"version": "0.7.0",
"version": "0.8.0-pre.1",
"keywords": [

@@ -105,4 +105,4 @@ "libsql",

"dependencies": {
"@libsql/core": "^0.7.0",
"@libsql/hrana-client": "^0.6.0",
"@libsql/core": "^0.8.0-pre.1",
"@libsql/hrana-client": "^0.6.2",
"js-base64": "^3.7.5",

@@ -109,0 +109,0 @@ "libsql": "^0.3.10",

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