Socket
Socket
Sign inDemoInstall

libsql-stateless

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

libsql-stateless - npm Package Compare versions

Comparing version 2.4.4 to 2.5.0

lib-cjs/functions.js

99

lib-cjs/main.js
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.libsqlServerCompatCheck = exports.libsqlBatch = exports.libsqlExecute = void 0;
const hrana_js_1 = require("./hrana.js");
//## functions
async function libsqlExecute(conf, stmt) {
const res = await (0, hrana_js_1.hranaFetch)({
...conf,
req_json: {
"baton": null,
"requests": [
{
"type": "execute",
"stmt": stmt,
},
{
"type": "close",
}
],
}
});
if (res.isOk) {
const resu = res.val.results[0]; //this because [0] is where we executed the statement
if (resu.type == "ok" &&
resu.response.type == "execute")
return { isOk: true, val: resu.response.result };
else
return { isOk: false, err: resu.error };
}
else
return { isOk: false, err: { message: res.err.error } };
}
exports.libsqlExecute = libsqlExecute;
async function libsqlBatch(conf, batch_steps) {
const res = await (0, hrana_js_1.hranaFetch)({
...conf,
req_json: {
"baton": null,
"requests": [
{
"type": "batch",
"batch": {
"steps": batch_steps,
},
},
{
"type": "close",
}
]
}
});
if (res.isOk) {
const resu = res.val.results[0]; //this because [0] is where we executed the statement
if (resu.type == "ok" &&
resu.response.type == "batch")
return { isOk: true, val: (resu.response.result) };
else
return { isOk: false, err: resu.error };
}
else
return { isOk: false, err: { message: res.err.error } };
}
exports.libsqlBatch = libsqlBatch;
async function libsqlServerCompatCheck(db_url) {
if ((await fetch(`${db_url}/v3`, {
method: 'GET'
})).ok)
return { isOk: true, val: null };
else
return { isOk: false, err: null };
}
exports.libsqlServerCompatCheck = libsqlServerCompatCheck;
exports.libsqlType = void 0;
__exportStar(require("./functions"), exports);
exports.libsqlType = __importStar(require("./types"));

@@ -1,72 +0,2 @@

import { Result } from "./hrana.js";
export type libsql_conf = {
db_url: string;
authToken?: string;
};
export type libsql_value = {
"type": "null";
} | {
"type": "integer";
"value": string;
} | {
"type": "float";
"value": number;
} | {
"type": "text";
"value": string;
} | {
"type": "blob";
"base64": string;
};
export type libsql_column = {
"name": string | null;
"decltype": string | null;
};
export type libsql_statement = {
"sql": string;
"args"?: Array<libsql_value>;
"named_args"?: Array<{
"name": string;
"value": libsql_value;
}>;
"want_rows"?: boolean;
};
export type libsql_statement_result = {
"cols": Array<libsql_column>;
"rows": Array<Array<libsql_value>>;
"affected_row_count": number;
"last_insert_rowid": string | null;
};
export type libsql_error = {
"message": string;
"code"?: string | null;
};
export type libsql_batch_execution_condition = {
"type": "ok";
"step": number;
} | {
"type": "error";
"step": number;
} | {
"type": "not";
"cond": libsql_batch_execution_condition;
} | {
"type": "and";
"conds": Array<libsql_batch_execution_condition>;
} | {
"type": "or";
"conds": Array<libsql_batch_execution_condition>;
} | {
"type": "is_autocommit";
};
export type libsql_batch_step = {
"condition"?: libsql_batch_execution_condition | null;
"stmt": libsql_statement;
};
export type libsql_batch_statement_result = {
"step_results": Array<libsql_statement_result | null>;
"step_errors": Array<libsql_error | null>;
};
export declare function libsqlExecute(conf: libsql_conf, stmt: libsql_statement): Promise<Result<libsql_statement_result, libsql_error>>;
export declare function libsqlBatch(conf: libsql_conf, batch_steps: Array<libsql_batch_step>): Promise<Result<libsql_batch_statement_result, libsql_error>>;
export declare function libsqlServerCompatCheck(db_url: string): Promise<Result<null, null>>;
export * from './functions';
export * as libsqlType from './types';

@@ -1,66 +0,2 @@

import { hranaFetch } from "./hrana.js";
//## functions
export async function libsqlExecute(conf, stmt) {
const res = await hranaFetch({
...conf,
req_json: {
"baton": null,
"requests": [
{
"type": "execute",
"stmt": stmt,
},
{
"type": "close",
}
],
}
});
if (res.isOk) {
const resu = res.val.results[0]; //this because [0] is where we executed the statement
if (resu.type == "ok" &&
resu.response.type == "execute")
return { isOk: true, val: resu.response.result };
else
return { isOk: false, err: resu.error };
}
else
return { isOk: false, err: { message: res.err.error } };
}
export async function libsqlBatch(conf, batch_steps) {
const res = await hranaFetch({
...conf,
req_json: {
"baton": null,
"requests": [
{
"type": "batch",
"batch": {
"steps": batch_steps,
},
},
{
"type": "close",
}
]
}
});
if (res.isOk) {
const resu = res.val.results[0]; //this because [0] is where we executed the statement
if (resu.type == "ok" &&
resu.response.type == "batch")
return { isOk: true, val: (resu.response.result) };
else
return { isOk: false, err: resu.error };
}
else
return { isOk: false, err: { message: res.err.error } };
}
export async function libsqlServerCompatCheck(db_url) {
if ((await fetch(`${db_url}/v3`, {
method: 'GET'
})).ok)
return { isOk: true, val: null };
else
return { isOk: false, err: null };
}
export * from './functions';
export * as libsqlType from './types';
{
"name": "libsql-stateless",
"version": "2.4.4",
"version": "2.5.0",
"homepage": "https://github.com/DaBigBlob/libsql-stateless#readme",

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

@@ -17,3 +17,5 @@ # libsql-stateless

```
⚠️ **WARNING: The Docs are out of date. Give me a few days.**
## The Result Type

@@ -20,0 +22,0 @@ Every function in this library returns a `Result<T, R>` type.

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