Socket
Socket
Sign inDemoInstall

libsql-stateless-easy

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.4.7 to 1.4.8

30

lib-cjs/builders.js

@@ -25,9 +25,5 @@ "use strict";

if (Object.prototype.toString.call(s.args) === '[object Array]') {
let p_args = [];
const _args = s.args;
for (let i = 0; i < _args.length; i++)
p_args.push(libsqlValueBuilder(_args[i]));
return {
sql: s.sql,
args: p_args,
args: s.args.map(r => libsqlValueBuilder(r)),
want_rows: s.want_rows

@@ -92,9 +88,8 @@ };

function libsqlBatchReqStepsBuilder(batch_queries, batch_conditions) {
let p_stmts = [];
for (let i = 0; i < batch_queries.length; i++)
p_stmts.push({
stmt: libsqlStatementBuilder(batch_queries[i]),
condition: (batch_conditions) ? (batch_conditions[i] || undefined) : undefined
});
return p_stmts;
return batch_queries.map((q, i) => {
return {
stmt: libsqlStatementBuilder(q),
condition: batch_conditions[i] || undefined
};
});
}

@@ -128,5 +123,14 @@ exports.libsqlBatchReqStepsBuilder = libsqlBatchReqStepsBuilder;

function libsqlTransactionBatchReqStepsBuilder(queries, mode) {
const main_steps = libsqlBatchReqStepsBuilder(queries);
const main_steps = queries.map((q, i) => {
return {
stmt: libsqlStatementBuilder(q),
condition: exports.libsqlBatchReqStepExecCondBuilder.and([
exports.libsqlBatchReqStepExecCondBuilder.ok(i),
exports.libsqlBatchReqStepExecCondBuilder.not(exports.libsqlBatchReqStepExecCondBuilder.is_autocommit())
])
};
});
main_steps[0].condition = undefined; //elm 1's ok index is set to 0 (transaction begin); removing that
return [libsqlTransactionBeginStatement(mode)].concat(main_steps).concat(libsqlTransactionEndStatements(main_steps.length));
}
exports.libsqlTransactionBatchReqStepsBuilder = libsqlTransactionBatchReqStepsBuilder;

@@ -9,6 +9,12 @@ "use strict";

closed;
/** 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;
constructor(conf) {
this.conf = conf;
this.closed = true;
this.closed = false;
this.protocol = "http";

@@ -109,8 +115,2 @@ }

}
/** 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
*/
close() {

@@ -117,0 +117,0 @@ throw new errors_js_1.InternalError("'libsql-stateless' is stateless therefore no connection to close.");

@@ -69,6 +69,9 @@ "use strict";

CheckHttpUrl(conf.db_url);
const sqlArr = sql.split(";").filter(s => s.trim() !== "").map(s => { return { stmt: { sql: s }, condition: builders_js_1.libsqlBatchReqStepExecCondBuilder.ok(0) }; });
for (let i = 1; i < sqlArr.length; i++)
sqlArr[i].condition = builders_js_1.libsqlBatchReqStepExecCondBuilder.ok(i - 1);
sqlArr[0].condition = undefined;
const sqlArr = sql.split(";").filter(s => s.trim() !== "").map((s, i) => {
return {
stmt: { sql: s },
condition: builders_js_1.libsqlBatchReqStepExecCondBuilder.ok(i - 1)
};
});
sqlArr[0].condition = undefined; //elm 0's ok index is set to -1; removing that
const res = await (0, libsql_stateless_1.libsqlBatch)(conf, sqlArr);

@@ -75,0 +78,0 @@ if (!res.isOk) {

@@ -71,12 +71,10 @@ "use strict";

function libsqlBatchStreamResParser(res) {
let batchResults = [];
for (let j = 0; j < res.step_results.length; j++) {
if (res.step_results[j])
batchResults.push(libsqlStatementResParser(res.step_results[j]));
else if (res.step_errors[j])
throw new errors_js_1.ResponseError(res.step_errors[j]?.message, res.step_errors[j]);
return res.step_results.map((r, i) => {
if (r)
return libsqlStatementResParser(r);
else if (res.step_errors[i])
throw new errors_js_1.ResponseError(res.step_errors[i]?.message || "", res.step_errors[i]);
else
batchResults.push(null);
}
return batchResults;
return null;
});
}

@@ -83,0 +81,0 @@ exports.libsqlBatchStreamResParser = libsqlBatchStreamResParser;

@@ -13,5 +13,5 @@ import { TransactionMode, rawSQLStatement, rawValue } from './types.js';

};
export declare function libsqlBatchReqStepsBuilder(batch_queries: Array<rawSQLStatement>, batch_conditions?: Array<libsqlBatchReqStepExecCond | undefined | null>): Array<libsqlBatchReqStep>;
export declare function libsqlBatchReqStepsBuilder(batch_queries: Array<rawSQLStatement>, batch_conditions: Array<libsqlBatchReqStepExecCond | undefined | null>): Array<libsqlBatchReqStep>;
export declare function libsqlTransactionBeginStatement(mode: TransactionMode): libsqlBatchReqStep;
export declare function libsqlTransactionEndStatements(last_step_before_this: number): Array<libsqlBatchReqStep>;
export declare function libsqlTransactionBatchReqStepsBuilder(queries: Array<rawSQLStatement>, mode: TransactionMode): Array<libsqlBatchReqStep>;

@@ -21,9 +21,5 @@ import { Base64 } from 'js-base64';

if (Object.prototype.toString.call(s.args) === '[object Array]') {
let p_args = [];
const _args = s.args;
for (let i = 0; i < _args.length; i++)
p_args.push(libsqlValueBuilder(_args[i]));
return {
sql: s.sql,
args: p_args,
args: s.args.map(r => libsqlValueBuilder(r)),
want_rows: s.want_rows

@@ -87,9 +83,8 @@ };

export function libsqlBatchReqStepsBuilder(batch_queries, batch_conditions) {
let p_stmts = [];
for (let i = 0; i < batch_queries.length; i++)
p_stmts.push({
stmt: libsqlStatementBuilder(batch_queries[i]),
condition: (batch_conditions) ? (batch_conditions[i] || undefined) : undefined
});
return p_stmts;
return batch_queries.map((q, i) => {
return {
stmt: libsqlStatementBuilder(q),
condition: batch_conditions[i] || undefined
};
});
}

@@ -120,4 +115,13 @@ //========================================================

export function libsqlTransactionBatchReqStepsBuilder(queries, mode) {
const main_steps = libsqlBatchReqStepsBuilder(queries);
const main_steps = queries.map((q, i) => {
return {
stmt: libsqlStatementBuilder(q),
condition: libsqlBatchReqStepExecCondBuilder.and([
libsqlBatchReqStepExecCondBuilder.ok(i),
libsqlBatchReqStepExecCondBuilder.not(libsqlBatchReqStepExecCondBuilder.is_autocommit())
])
};
});
main_steps[0].condition = undefined; //elm 1's ok index is set to 0 (transaction begin); removing that
return [libsqlTransactionBeginStatement(mode)].concat(main_steps).concat(libsqlTransactionEndStatements(main_steps.length));
}

@@ -7,2 +7,8 @@ import { libsqlBatchReqStepExecCond, libsqlConfig } from "libsql-stateless";

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;

@@ -66,3 +72,3 @@ constructor(conf: libsqlConfig);

batch(steps: Array<rawSQLStatement>, mode?: TransactionMode): Promise<import("./types.js").ResultSet[]>;
batchPrimitive(steps: Array<rawSQLStatement>, step_conditions?: Array<libsqlBatchReqStepExecCond | null | undefined>): Promise<(import("./types.js").ResultSet | null)[]>;
batchPrimitive(steps: Array<rawSQLStatement>, step_conditions: Array<libsqlBatchReqStepExecCond | null | undefined>): Promise<(import("./types.js").ResultSet | null)[]>;
transaction(mode?: TransactionMode): Promise<____Transaction>;

@@ -91,8 +97,2 @@ /** Execute a sequence of SQL statements separated by semicolons.

sync(): Promise<void>;
/** 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
*/
close(): void;

@@ -99,0 +99,0 @@ serverOk(): Promise<boolean>;

@@ -6,6 +6,12 @@ import { libsqlBatch, libsqlBatchTransaction, libsqlExecute, libsqlExecuteMultiple, libsqlServerCompatCheck } from "./functions.js";

closed;
/** 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;
constructor(conf) {
this.conf = conf;
this.closed = true;
this.closed = false;
this.protocol = "http";

@@ -106,8 +112,2 @@ }

}
/** 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
*/
close() {

@@ -114,0 +114,0 @@ throw new InternalError("'libsql-stateless' is stateless therefore no connection to close.");

import { libsqlConfig, libsqlBatchReqStepExecCond } from "libsql-stateless";
import { ResultSet, TransactionMode, rawSQLStatement } from "./types.js";
export declare function libsqlExecute(conf: libsqlConfig, stmt: rawSQLStatement): Promise<ResultSet>;
export declare function libsqlBatch(conf: libsqlConfig, steps: Array<rawSQLStatement>, step_conditions?: Array<libsqlBatchReqStepExecCond | null | undefined>): Promise<Array<ResultSet | null>>;
export declare function libsqlBatch(conf: libsqlConfig, steps: Array<rawSQLStatement>, step_conditions: Array<libsqlBatchReqStepExecCond | null | undefined>): Promise<Array<ResultSet | null>>;
export declare function libsqlServerCompatCheck(conf: libsqlConfig): Promise<boolean>;
export declare function libsqlBatchTransaction(conf: libsqlConfig, steps: Array<rawSQLStatement>, mode?: TransactionMode): Promise<Array<ResultSet>>;
export declare function libsqlExecuteMultiple(conf: libsqlConfig, sql: string): Promise<void>;

@@ -62,6 +62,9 @@ import { libsqlExecute as LIBlibsqlExecute, libsqlBatch as LIBlibsqlBatch, libsqlServerCompatCheck as LIBlibsqlServerCompatCheck } from "libsql-stateless";

CheckHttpUrl(conf.db_url);
const sqlArr = sql.split(";").filter(s => s.trim() !== "").map(s => { return { stmt: { sql: s }, condition: libsqlBatchReqStepExecCondBuilder.ok(0) }; });
for (let i = 1; i < sqlArr.length; i++)
sqlArr[i].condition = libsqlBatchReqStepExecCondBuilder.ok(i - 1);
sqlArr[0].condition = undefined;
const sqlArr = sql.split(";").filter(s => s.trim() !== "").map((s, i) => {
return {
stmt: { sql: s },
condition: libsqlBatchReqStepExecCondBuilder.ok(i - 1)
};
});
sqlArr[0].condition = undefined; //elm 0's ok index is set to -1; removing that
const res = await LIBlibsqlBatch(conf, sqlArr);

@@ -68,0 +71,0 @@ if (!res.isOk) {

@@ -66,12 +66,10 @@ import { Base64 } from "js-base64";

export function libsqlBatchStreamResParser(res) {
let batchResults = [];
for (let j = 0; j < res.step_results.length; j++) {
if (res.step_results[j])
batchResults.push(libsqlStatementResParser(res.step_results[j]));
else if (res.step_errors[j])
throw new ResponseError(res.step_errors[j]?.message, res.step_errors[j]);
return res.step_results.map((r, i) => {
if (r)
return libsqlStatementResParser(r);
else if (res.step_errors[i])
throw new ResponseError(res.step_errors[i]?.message || "", res.step_errors[i]);
else
batchResults.push(null);
}
return batchResults;
return null;
});
}

@@ -78,0 +76,0 @@ //========================================================

{
"name": "libsql-stateless-easy",
"version": "1.4.7",
"version": "1.4.8",
"homepage": "https://github.com/DaBigBlob/libsql-stateless-easy#readme",

@@ -5,0 +5,0 @@ "repository": {

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc