libsql-stateless-easy
Advanced tools
Comparing version 1.6.1 to 1.6.2-alpha.1
@@ -1,5 +0,301 @@ | ||
export * from './builders.js'; | ||
export * from './parsers.js'; | ||
export * from './functions.js'; | ||
export * from './client.js'; | ||
export * from './errors.js'; | ||
import { libsqlConfig as libsqlConfig$1, libsqlSQLValue, libsqlSQLStatement, libsqlBatchReqStepExecCond, libsqlBatchReqStep, libsqlStatementResOkData, libsqlBatchStreamResOkData, libsqlStreamResErrData } from 'libsql-stateless'; | ||
type rawValue = null | bigint | number | string | ArrayBuffer; | ||
type intMode = "bigint" | "number" | "string"; | ||
type rawSQLStatement = string | { | ||
sql: string; | ||
args: Array<rawValue> | Record<string, rawValue>; | ||
want_rows?: boolean; | ||
}; | ||
interface libsqlConfig extends libsqlConfig$1 { | ||
/** How to convert SQLite integers to JavaScript values: | ||
* | ||
* - `"number"` (default): returns SQLite integers as JavaScript `number`-s (double precision floats). | ||
* `number` cannot precisely represent integers larger than 2^53-1 in absolute value, so attempting to read | ||
* larger integers will throw a `RangeError`. | ||
* - `"bigint"`: returns SQLite integers as JavaScript `bigint`-s (arbitrary precision integers). Bigints can | ||
* precisely represent all SQLite integers. | ||
* - `"string"`: returns SQLite integers as strings. | ||
*/ | ||
intMode?: intMode; | ||
/** Custom `fetch` function to use for the HTTP client. | ||
* | ||
* By default, the HTTP client uses `fetch` from the `@libsql/isomorphic-fetch` package, but you can pass | ||
* your own function here. The argument to this function will be `Request` from | ||
* `@libsql/isomorphic-fetch`, and it must return a promise that resolves to an object that is compatible | ||
* with the Web `Response`. | ||
*/ | ||
fetch?: Function; | ||
} | ||
/** Row returned from an SQL statement. | ||
* | ||
* The row object can be used as an `Array` or as an object: | ||
* | ||
* ```javascript | ||
* const rs = await client.execute("SELECT name, title FROM books"); | ||
* for (const row in rs.rows) { | ||
* // Get the value from column `name` | ||
* console.log(row.name); | ||
* // Get the value from second column (`title`) | ||
* console.log(row[1]); | ||
* } | ||
* ``` | ||
*/ | ||
interface Row { | ||
/** Number of columns in this row. | ||
* | ||
* All rows in one {@link ResultSet} have the same number and names of columns. | ||
*/ | ||
length: number; | ||
/** Columns can be accessed like an array by numeric indexes. */ | ||
[index: number]: rawValue; | ||
/** Columns can be accessed like an object by column names. */ | ||
[name: string]: rawValue; | ||
} | ||
/** Result of executing an SQL statement. | ||
* | ||
* ```javascript | ||
* const rs = await client.execute("SELECT name, title FROM books"); | ||
* console.log(`Found ${rs.rows.length} books`); | ||
* for (const row in rs.rows) { | ||
* console.log(`Book ${row[0]} by ${row[1]}`); | ||
* } | ||
* | ||
* const rs = await client.execute("DELETE FROM books WHERE author = 'Jane Austen'"); | ||
* console.log(`Deleted ${rs.rowsAffected} books`); | ||
* ``` | ||
*/ | ||
interface ResultSet { | ||
/** Names of columns. | ||
* | ||
* Names of columns can be defined using the `AS` keyword in SQL: | ||
* | ||
* ```sql | ||
* SELECT author AS author, COUNT(*) AS count FROM books GROUP BY author | ||
* ``` | ||
*/ | ||
columns: Array<string>; | ||
/** Types of columns. | ||
* | ||
* The types are currently shown for types declared in a SQL table. For | ||
* column types of function calls, for example, an empty string is | ||
* returned. | ||
*/ | ||
columnTypes: Array<string>; | ||
/** Rows produced by the statement. */ | ||
rows: Array<Row>; | ||
/** Number of rows that were affected by an UPDATE, INSERT or DELETE operation. | ||
* | ||
* This value is not specified for other SQL statements. | ||
*/ | ||
rowsAffected: number; | ||
/** ROWID of the last inserted row. | ||
* | ||
* This value is not specified if the SQL statement was not an INSERT or if the table was not a ROWID | ||
* table. | ||
*/ | ||
lastInsertRowid: bigint | undefined; | ||
/** Converts the result set to JSON. | ||
* | ||
* This is used automatically by `JSON.stringify()`, but you can also call it explicitly. | ||
*/ | ||
toJSON(): any; | ||
/** Rows read during processing query. | ||
* Might not be available on older server versions. | ||
*/ | ||
rowsRead: number; | ||
/** Rows written during processing query. | ||
* Might not be available on older server versions. | ||
*/ | ||
rowsWritten: number; | ||
/** Wall time of work done by server. | ||
* Might not be available on older server versions. | ||
*/ | ||
queryDurationMS: number; | ||
} | ||
/** Transaction mode. | ||
* | ||
* The client supports multiple modes for transactions: | ||
* | ||
* - `"write"` is a read-write transaction, started with `BEGIN IMMEDIATE`. This transaction mode supports | ||
* both read statements (`SELECT`) and write statements (`INSERT`, `UPDATE`, `CREATE TABLE`, etc). The libSQL | ||
* server cannot process multiple write transactions concurrently, so if there is another write transaction | ||
* already started, our transaction will wait in a queue before it can begin. | ||
* | ||
* - `"read"` is a read-only transaction, started with `BEGIN TRANSACTION READONLY` (a libSQL extension). This | ||
* transaction mode supports only reads (`SELECT`) and will not accept write statements. The libSQL server can | ||
* handle multiple read transactions at the same time, so we don't need to wait for other transactions to | ||
* complete. A read-only transaction can also be executed on a local replica, so it provides lower latency. | ||
* | ||
* - `"deferred"` is a transaction started with `BEGIN DEFERRED`, which starts as a read transaction, but the | ||
* first write statement will try to upgrade it to a write transaction. However, this upgrade may fail if | ||
* there already is a write transaction executing on the server, so you should be ready to handle these | ||
* failures. | ||
* | ||
* If your transaction includes only read statements, `"read"` is always preferred over `"deferred"` or | ||
* `"write"`, because `"read"` transactions can be executed more efficiently and don't block other | ||
* transactions. | ||
* | ||
* If your transaction includes both read and write statements, you should be using the `"write"` mode most of | ||
* the time. Use the `"deferred"` mode only if you prefer to fail the write transaction instead of waiting for | ||
* the previous write transactions to complete. | ||
*/ | ||
type TransactionMode = "write" | "read" | "deferred"; | ||
declare function libsqlValueBuilder(value: rawValue): libsqlSQLValue; | ||
declare function libsqlStatementBuilder(s: rawSQLStatement): libsqlSQLStatement; | ||
declare const libsqlBatchReqStepExecCondBuilder: { | ||
ok: (step: number) => libsqlBatchReqStepExecCond; | ||
error: (step: number) => libsqlBatchReqStepExecCond; | ||
not: (cond: libsqlBatchReqStepExecCond) => libsqlBatchReqStepExecCond; | ||
and: (conds: Array<libsqlBatchReqStepExecCond>) => libsqlBatchReqStepExecCond; | ||
or: (conds: Array<libsqlBatchReqStepExecCond>) => libsqlBatchReqStepExecCond; | ||
is_autocommit: () => libsqlBatchReqStepExecCond; | ||
}; | ||
declare function libsqlBatchReqStepsBuilder(batch_queries: Array<rawSQLStatement>, batch_conditions: Array<libsqlBatchReqStepExecCond | undefined | null>): Array<libsqlBatchReqStep>; | ||
declare function libsqlTransactionBeginStatement(mode: TransactionMode): libsqlBatchReqStep; | ||
declare function libsqlTransactionEndStatements(last_step_before_this: number): Array<libsqlBatchReqStep>; | ||
declare function libsqlTransactionBatchReqStepsBuilder(queries: Array<rawSQLStatement>, mode: TransactionMode): Array<libsqlBatchReqStep>; | ||
declare function libsqlValueParser(value: libsqlSQLValue, intMode?: intMode): rawValue; | ||
declare function libsqlStatementResParser(res: libsqlStatementResOkData, intMode?: intMode): ResultSet; | ||
declare function libsqlBatchStreamResParser(res: libsqlBatchStreamResOkData, intMode?: intMode): Array<ResultSet | null>; | ||
declare function libsqlTransactionBatchStreamResParser(res: libsqlBatchStreamResOkData, intMode?: intMode): Array<ResultSet>; | ||
declare function libsqlExecute(conf: libsqlConfig, stmt: rawSQLStatement): Promise<ResultSet>; | ||
declare function libsqlBatch(conf: libsqlConfig, steps: Array<rawSQLStatement>, step_conditions: Array<libsqlBatchReqStepExecCond | null | undefined>): Promise<Array<ResultSet | null>>; | ||
declare function libsqlServerCompatCheck(conf: libsqlConfig): Promise<boolean>; | ||
declare function libsqlBatchTransaction(conf: libsqlConfig, steps: Array<rawSQLStatement>, mode?: TransactionMode): Promise<Array<ResultSet>>; | ||
declare function libsqlExecuteMultiple(conf: libsqlConfig, sql: string): Promise<undefined>; | ||
declare class libsqlClient { | ||
private readonly conf; | ||
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; | ||
constructor(conf: libsqlConfig); | ||
/** Execute a single SQL statement. | ||
* | ||
* Every statement executed with this method is executed in its own logical database connection. If you | ||
* want to execute a group of statements in a transaction, use the {@link batch} method. | ||
* | ||
* ```javascript | ||
* // execute a statement without arguments | ||
* const rs = await client.execute("SELECT * FROM books"); | ||
* | ||
* // execute a statement with positional arguments | ||
* const rs = await client.execute({ | ||
* sql: "SELECT * FROM books WHERE author = ?", | ||
* args: ["Jane Austen"], | ||
* }); | ||
* | ||
* // execute a statement with named arguments | ||
* const rs = await client.execute({ | ||
* sql: "SELECT * FROM books WHERE published_at > $year", | ||
* args: {year: 1719}, | ||
* }); | ||
* ``` | ||
*/ | ||
execute(stmt: rawSQLStatement): Promise<ResultSet>; | ||
/** Execute a batch of SQL statements in a transaction. | ||
* | ||
* The batch is executed in its own logical database connection and the statements are wrapped in a | ||
* transaction. This ensures that the batch is applied atomically: either all or no changes are applied. | ||
* | ||
* The `mode` parameter selects the transaction mode for the batch; please see {@link TransactionMode} for | ||
* details. The default transaction mode is `"deferred"`. | ||
* | ||
* If any of the statements in the batch fails with an error, the batch is aborted, the transaction is | ||
* rolled back and the returned promise is rejected. | ||
* | ||
* This method provides non-interactive transactions. | ||
* | ||
* ```javascript | ||
* const rss = await client.batch([ | ||
* // batch statement without arguments | ||
* "DELETE FROM books WHERE name LIKE '%Crusoe'", | ||
* | ||
* // batch statement with positional arguments | ||
* { | ||
* sql: "INSERT INTO books (name, author, published_at) VALUES (?, ?, ?)", | ||
* args: ["First Impressions", "Jane Austen", 1813], | ||
* }, | ||
* | ||
* // batch statement with named arguments | ||
* { | ||
* sql: "UPDATE books SET name = $new WHERE name = $old", | ||
* args: {old: "First Impressions", new: "Pride and Prejudice"}, | ||
* }, | ||
* ], "write"); | ||
* ``` | ||
*/ | ||
batch(steps: Array<rawSQLStatement>, mode?: TransactionMode): Promise<ResultSet[]>; | ||
transaction(mode?: TransactionMode): Promise<any>; | ||
/** Execute a sequence of SQL statements separated by semicolons. | ||
* | ||
* NOTE: libsql-stateless-easy implements this function using `batch` under the hood instead of the `serial` endpoint. | ||
* | ||
* The statements are executed sequentially on a new logical database connection. If a statement fails, | ||
* further statements are not executed and this method throws an error. All results from the statements | ||
* are ignored. | ||
* | ||
* We do not wrap the statements in a transaction, but the SQL can contain explicit transaction-control | ||
* statements such as `BEGIN` and `COMMIT`. | ||
* | ||
* This method is intended to be used with existing SQL scripts, such as migrations or small database | ||
* dumps. If you want to execute a sequence of statements programmatically, please use {@link batch} | ||
* instead. | ||
* | ||
* ```javascript | ||
* await client.executeMultiple(` | ||
* CREATE TABLE books (id INTEGER PRIMARY KEY, title TEXT NOT NULL, author_id INTEGER NOT NULL); | ||
* CREATE TABLE authors (id INTEGER PRIMARY KEY, name TEXT NOT NULL); | ||
* `); | ||
* ``` | ||
*/ | ||
executeMultiple(sql: string): Promise<undefined>; | ||
sync(): Promise<void>; | ||
close(): void; | ||
serverOk(): Promise<boolean>; | ||
} | ||
declare function createClient(conf: { | ||
url: string; | ||
authToken?: string; | ||
intMode?: intMode; | ||
}): libsqlClient; | ||
/** Error thrown by the client. */ | ||
declare class LibsqlError extends Error { | ||
/** Machine-readable error code. */ | ||
code: string; | ||
/** Raw numeric error code */ | ||
rawCode?: number; | ||
constructor(message: string, code: string, cause?: Error); | ||
} | ||
/** Error thrown when the server violates the protocol. */ | ||
declare class ProtoError extends LibsqlError { | ||
constructor(message: string); | ||
} | ||
/** Error thrown when the server returns an error response. */ | ||
declare class ResponseError extends LibsqlError { | ||
constructor(message: string, protoError: libsqlStreamResErrData); | ||
} | ||
/** Error thrown when the HTTP server returns an error response. */ | ||
declare class HttpServerError extends LibsqlError { | ||
constructor(message: string, status: number); | ||
} | ||
/** Error thrown when an internal client error happens. */ | ||
declare class InternalError extends LibsqlError { | ||
constructor(message: string); | ||
} | ||
/** Error thrown when the API is misused. */ | ||
declare class MisuseError extends LibsqlError { | ||
constructor(message: string); | ||
} | ||
export { HttpServerError, InternalError, LibsqlError, MisuseError, ProtoError, ResponseError, createClient, libsqlBatch, libsqlBatchReqStepExecCondBuilder, libsqlBatchReqStepsBuilder, libsqlBatchStreamResParser, libsqlBatchTransaction, libsqlExecute, libsqlExecuteMultiple, libsqlServerCompatCheck, libsqlStatementBuilder, libsqlStatementResParser, libsqlTransactionBatchReqStepsBuilder, libsqlTransactionBatchStreamResParser, libsqlTransactionBeginStatement, libsqlTransactionEndStatements, libsqlValueBuilder, libsqlValueParser }; |
@@ -1,5 +0,5 @@ | ||
export * from './builders.js'; | ||
export * from './parsers.js'; | ||
export * from './functions.js'; | ||
export * from './client.js'; | ||
export * from './errors.js'; | ||
import { libsqlExecute, libsqlBatch, libsqlServerCompatCheck } from 'libsql-stateless'; | ||
var tt=Object.defineProperty;var et=(t,e,r)=>e in t?tt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var l=(t,e,r)=>(et(t,typeof e!="symbol"?e+"":e,r),r);var d=typeof Buffer=="function",A=typeof btoa=="function",C=typeof atob=="function",L=t=>atob(t),O=t=>btoa(t),T=t=>Buffer.from(t).toString("base64"),U=t=>Buffer.from(t,"binary").toString("base64"),k=t=>Buffer.from(t,"base64"),M=t=>Buffer.from(t,"base64").toString("binary");var rt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",m=Array.prototype.slice.call(rt),b=(t=>{let e={};return t.forEach((r,s)=>e[r]=s),e})(m),st=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,nt=t=>{let e,r,s,n,o="",a=t.length%3;for(let u=0;u<t.length;){if((r=t.charCodeAt(u++))>255||(s=t.charCodeAt(u++))>255||(n=t.charCodeAt(u++))>255)throw new TypeError("invalid character found");e=r<<16|s<<8|n,o+=m[e>>18&63]+m[e>>12&63]+m[e>>6&63]+m[e&63];}return a?o.slice(0,a-3)+"===".substring(a):o},ot=A?t=>O(t):d?t=>U(t):nt,at=t=>t.replace(/=/g,"").replace(/[+\/]/g,e=>e=="+"?"-":"_"),v=d?t=>T(t):t=>{let r=[];for(let s=0,n=t.length;s<n;s+=4096){let o=[];t.subarray(s,s+4096).forEach(a=>o.push(a.valueOf())),r.push(h.apply(null,o));}return ot(r.join(""))},h=String.fromCharCode.bind(String),N=(t,e=!1)=>e?at(v(t)):v(t),P=t=>t.replace(/[^A-Za-z0-9\+\/]/g,""),it=t=>{if(t=t.replace(/\s+/g,""),!st.test(t))throw new TypeError("malformed base64.");t+="==".slice(2-(t.length&3));let e,r="",s,n;for(let o=0;o<t.length;)e=b[t.charAt(o++)]<<18|b[t.charAt(o++)]<<12|(s=b[t.charAt(o++)])<<6|(n=b[t.charAt(o++)]),r+=s===64?h(e>>16&255):n===64?h(e>>16&255,e>>8&255):h(e>>16&255,e>>8&255,e&255);return r},lt=C?t=>L(P(t)):d?t=>M(t):it,I=typeof Uint8Array.from=="function"?Uint8Array.from.bind(Uint8Array):t=>new Uint8Array(Array.prototype.slice.call(t,0)),ct=d?t=>I(k(t)):t=>I(lt(t).split("").map(e=>e.charCodeAt(0))),ut=t=>P(t.replace(/[-_]/g,e=>e=="-"?"+":"/")),Q=t=>ct(ut(t));var i=class extends Error{constructor(r,s,n){super(`${s}: ${r}`,{cause:n});l(this,"code");l(this,"rawCode");this.code=s,this.rawCode=void 0,this.name="LibsqlError";}},q=class extends i{constructor(e){super(e,"HRANA_PROTO_ERROR",new class extends Error{constructor(){super(e),this.name="ProtoError";}});}},c=class extends i{constructor(e,r){super(e,r.code||"UNKNOWN",new class extends Error{constructor(){super(e);l(this,"proto");this.name="ResponseError",this.proto=r,this.stack=void 0;}});}},p=class extends i{constructor(e,r){super(e,"SERVER_ERROR",new class extends Error{constructor(){super(e);l(this,"status");this.status=r,this.name="HttpServerError";}});}},f=class extends i{constructor(e){super(e,"INTERNAL_ERROR",new class extends Error{constructor(){super(e),this.name="InternalError";}});}},y=class extends i{constructor(e){super(e,"UNKNOWN",new class extends Error{constructor(){super(e),this.name="MisuseError";}});}};function V(t){if(t===null)return {type:"null"};if(typeof t=="bigint")return {type:"integer",value:""+t};if(typeof t=="number")return {type:"float",value:t};if(typeof t=="string")return {type:"text",value:t};if(t instanceof Uint8Array)return {type:"blob",base64:N(t)};throw new f("Invalid type of input. Cannot build request to server.")}function S(t){if(typeof t!="string"){if(Object.prototype.toString.call(t.args)==="[object Array]")return {sql:t.sql,args:t.args.map(e=>V(e)),want_rows:t.want_rows};{let e=[],r=t.args;for(let s in r)e.push({name:s,value:V(r[s])});return {sql:t.sql,named_args:e,want_rows:t.want_rows}}}return {sql:t}}var w={ok:t=>({type:"ok",step:t}),error:t=>({type:"error",step:t}),not:t=>({type:"not",cond:t}),and:t=>({type:"and",conds:t}),or:t=>({type:"or",conds:t}),is_autocommit:()=>({type:"is_autocommit"})};function D(t,e){return t.map((r,s)=>({stmt:S(r),condition:e[s]||void 0}))}function pt(t){if(t==="write")return {stmt:{sql:"BEGIN IMMEDIATE"}};if(t==="read")return {stmt:{sql:"BEGIN TRANSACTION READONLY"}};if(t==="deferred")return {stmt:{sql:"BEGIN DEFERRED"}};throw RangeError('Unknown transaction mode, supported values are "write", "read" and "deferred"')}function ft(t){return [{stmt:{sql:"COMMIT"},condition:{type:"ok",step:t}},{stmt:{sql:"ROLLBACK"},condition:{type:"not",cond:{type:"ok",step:t+1}}}]}function j(t,e){let r=t.map((s,n)=>({stmt:S(s),condition:w.ok(n)}));return [pt(e)].concat(r).concat(ft(r.length))}function dt(t,e="number"){switch(e){case"number":return +t;case"string":return t;case"bigint":return BigInt(t);default:throw new y('Invalid value for "intMode".')}}function mt(t,e){switch(t.type){case"null":return null;case"integer":return dt(t.value,e);case"float":return Number(t.value);case"text":return t.value;case"blob":return Q(t.base64);default:throw new q("Invalid data type from server. Cannot parse.")}}function g(t,e){let r=[];for(let n=0;n<t.rows.length;n++){let o={};Object.defineProperty(o,"length",{value:t.rows[n].length});for(let a=0;a<t.rows[n].length;a++){let u=mt(t.rows[n][a],e);Object.defineProperty(o,a,{value:u});let R=t.cols[a].name;R!==void 0&&!Object.hasOwn(o,R)&&Object.defineProperty(o,R,{value:u,enumerable:!0});}r.push(o);}let s={rows:r,columns:t.cols.map(n=>n.name||""),columnTypes:t.cols.map(n=>n.decltype||""),rowsAffected:t.affected_row_count,lastInsertRowid:t.last_insert_rowid?BigInt(t.last_insert_rowid):void 0,rowsRead:t.rows_read,rowsWritten:t.rows_written,queryDurationMS:t.query_duration_ms};return {...s,toJSON:()=>s}}function _(t,e){return t.step_results.map((r,s)=>{var n;if(r)return g(r,e);if(t.step_errors[s])throw new c(((n=t.step_errors[s])==null?void 0:n.message)||"",t.step_errors[s]);return null})}function H(t,e){let r=_(t,e);return r.slice(1,r.length-2).filter(s=>s!==null)}async function F(t,e){let r=await libsqlExecute(t,S(e));if(r.isOk)return g(r.val,t.intMode);throw r.err.kind==="LIBSQL_SERVER_ERROR"?new p(r.err.server_message||"Server encountered error.",r.err.http_status_code):new c(r.err.data.message,r.err.data)}async function Pt(t,e,r){let s=await libsqlBatch(t,D(e,r));if(s.isOk)return _(s.val,t.intMode);throw s.err.kind==="LIBSQL_SERVER_ERROR"?new p(s.err.server_message||"Server encountered error.",s.err.http_status_code):new c(s.err.data.message,s.err.data)}async function G(t){return !!(await libsqlServerCompatCheck(t)).isOk}async function W(t,e,r="deferred"){let s=await libsqlBatch(t,j(e,r));if(s.isOk)return H(s.val,t.intMode);throw s.err.kind==="LIBSQL_SERVER_ERROR"?new p(s.err.server_message||"Server encountered error.",s.err.http_status_code):new c(s.err.data.message,s.err.data)}async function z(t,e){let r=e.split(";").filter(n=>n.trim()!=="").map((n,o)=>({stmt:{sql:n},condition:w.ok(o-1)}));r[0].condition=void 0;let s=await libsqlBatch(t,r);if(!s.isOk)throw s.err.kind==="LIBSQL_SERVER_ERROR"?new p(s.err.server_message||"Server encountered error.",s.err.http_status_code):new c(s.err.data.message,s.err.data)}var Z=typeof fetch=="function";var K=typeof URL=="function",J=t=>console.error(t),$=t=>new URL(t);function Y(t){if(!Z){if(t){globalThis.fetch=t;return}throw new i("No global fetch. Please provide one.","NO_GLOBAL_FETCH")}}function B(t){return J(t)}function X(t){if((()=>{if(K)try{return !!$(t)}catch(r){throw new i(r.message,"ERR_INVALID_URL",r)}else return !!(t.startsWith("https://")||t.startsWith("http://"))})())throw new i('This is a HTTP client and only supports "https:" and "http:" URLs.',"URL_SCHEME_NOT_SUPPORTED")}var E=class{constructor(e){l(this,"conf");l(this,"closed");l(this,"protocol");X(e.db_url),Y(e.fetch),this.conf=e,this.closed=!1,this.protocol="http";}async execute(e){return await F(this.conf,e)}async batch(e,r){return await W(this.conf,e,r)}async transaction(e){throw new f("'libsql-stateless' is stateless and does not support interactive transactions. Use this.batch() instead.")}async executeMultiple(e){return await z(this.conf,e)}async sync(){B("'libsql-stateless' is remote only so nothing to sync.");}close(){B("'libsql-stateless' is stateless therefore no connection to close.");}async serverOk(){return await G(this.conf)}};function zt(t){return new E({db_url:t.url,authToken:t.authToken,intMode:t.intMode})} | ||
export { p as HttpServerError, f as InternalError, i as LibsqlError, y as MisuseError, q as ProtoError, c as ResponseError, zt as createClient, Pt as libsqlBatch, w as libsqlBatchReqStepExecCondBuilder, D as libsqlBatchReqStepsBuilder, _ as libsqlBatchStreamResParser, W as libsqlBatchTransaction, F as libsqlExecute, z as libsqlExecuteMultiple, G as libsqlServerCompatCheck, S as libsqlStatementBuilder, g as libsqlStatementResParser, j as libsqlTransactionBatchReqStepsBuilder, H as libsqlTransactionBatchStreamResParser, pt as libsqlTransactionBeginStatement, ft as libsqlTransactionEndStatements, V as libsqlValueBuilder, mt as libsqlValueParser }; |
{ | ||
"name": "libsql-stateless-easy", | ||
"version": "1.6.1", | ||
"version": "1.6.2-alpha.1", | ||
"description": "thin libSQL stateless http driver for TypeScript and JavaScript but easy", | ||
"homepage": "https://github.com/DaBigBlob/libsql-stateless-easy#readme", | ||
@@ -11,8 +12,18 @@ "repository": { | ||
"url": "https://github.com/DaBigBlob/libsql-stateless-easy/issues", | ||
"email": "localboxcrox@gmail.com" | ||
"email": "libsqlstateless@hman.io" | ||
}, | ||
"main": "dist/main.js", | ||
"devDependencies": { | ||
"typescript": "^5.0.0" | ||
"author": { | ||
"name": "LocalBox Crox", | ||
"email": "libsqlstateless@hman.io" | ||
}, | ||
"license": "MIT", | ||
"type": "module", | ||
"main": "./dist/main.js", | ||
"types": "./dist/main.d.ts", | ||
"files": [ | ||
"./dist/*", | ||
"./LICENSE", | ||
"./package.json", | ||
"./README.md" | ||
], | ||
"exports": { | ||
@@ -22,13 +33,19 @@ ".": { | ||
"import": "./dist/main.js", | ||
"require": "./dist/main.js" | ||
"require": "./dist/main.cjs" | ||
} | ||
}, | ||
"author": { | ||
"name": "LocalBox Crox", | ||
"email": "localboxcrox@gmail.com" | ||
"devDependencies": { | ||
"tsup": "^8.0.2", | ||
"typescript": "^5.0.0" | ||
}, | ||
"description": "this makes using libsql-stateless easy", | ||
"files": [ | ||
"dist/**" | ||
], | ||
"scripts": { | ||
"prepublishOnly": "npm run build", | ||
"prebuild": "rm -rf ./dist", | ||
"build": "tsup && rm ./dist/main.d.cts", | ||
"typecheck": "tsc --noEmit", | ||
"test": "bun run _tests/test4.ts", | ||
"perf": "bun run _tests/perf.ts", | ||
"clean": "npm run prebuild", | ||
"prod": "npm publish && npm run clean" | ||
}, | ||
"keywords": [ | ||
@@ -49,19 +66,5 @@ "libsql", | ||
], | ||
"license": "MIT", | ||
"scripts": { | ||
"prepublishOnly": "npm run build", | ||
"prebuild": "rm -rf ./dist", | ||
"build": "tsc -p tsconfig.json", | ||
"typecheck": "tsc --noEmit", | ||
"test": "bun run _tests/test4.ts", | ||
"perf": "bun run _tests/perf.ts", | ||
"clean": "npm run prebuild", | ||
"prod": "npm publish && npm run clean" | ||
}, | ||
"type": "module", | ||
"types": "dist/main.d.ts", | ||
"dependencies": { | ||
"js-base64": "^3.7.5", | ||
"libsql-stateless": "^2.8.3" | ||
"libsql-stateless": "^2.8.4-alpha.2" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
38783
1
2
6
382
2
3
- Removedjs-base64@^3.7.5
- Removedjs-base64@3.7.7(transitive)