diff --git a/get_official_api b/get_official_api new file mode 100755 index 0000000..e7efbe0 --- /dev/null +++ b/get_official_api @@ -0,0 +1,5 @@ +#!/bin/sh + +UNIXMILI=$(node -e "console.log(Date.now())") + +curl -s "https://raw.githubusercontent.com/tursodatabase/libsql-client-ts/main/packages/libsql-core/src/api.ts" > "./src/api-${UNIXMILI}.ts" \ No newline at end of file diff --git a/package.json b/package.json index c2f299d..e72c348 100644 --- a/package.json +++ b/package.json @@ -63,6 +63,6 @@ "edge" ], "dependencies": { - "libsql-stateless": "^2.9.0" + "libsql-stateless": "^2.9.1" } } diff --git a/src/functions.ts b/src/functions.ts index 5dca28b..24f9e69 100644 --- a/src/functions.ts +++ b/src/functions.ts @@ -2,7 +2,6 @@ import { libsqlExecute as LIBlibsqlExecute, libsqlBatch as LIBlibsqlBatch, libsqlServerCompatCheck as LIBlibsqlServerCompatCheck, - type libsqlConfig as LIBlibsqlConfig, type libsqlBatchReqStepExecCond, type libsqlBatchReqStep, type libsqlError as LIBlibsqlError @@ -12,14 +11,6 @@ import { libsqlBatchReqStepExecCondBuilder, libsqlBatchReqStepsBuilder, libsqlSt import { libsqlBatchStreamResParser, libsqlStatementResParser, libsqlTransactionBatchStreamResParser } from "./parsers.js"; import { HttpServerError, ResponseError } from "./errors.js"; -function confTranslate(conf: libsqlConfig): LIBlibsqlConfig { - return { - db_url: conf.url, - authToken: conf.authToken, - fetch: conf.fetch - } -} - function errorTranslate(err: LIBlibsqlError) { if (err.kind==="LIBSQL_SERVER_ERROR") return new HttpServerError( @@ -34,7 +25,7 @@ function errorTranslate(err: LIBlibsqlError) { } export async function libsqlExecute(conf: libsqlConfig, stmt_or_sql: rawSQL|rawSQLStatement, or_args?: rawSQLArgs, or_want_rows?: boolean): Promise { - const res = await LIBlibsqlExecute(confTranslate(conf), libsqlStatementBuilder(stmt_or_sql, or_args, or_want_rows)); + const res = await LIBlibsqlExecute(conf, libsqlStatementBuilder(stmt_or_sql, or_args, or_want_rows)); if (res.isOk) return libsqlStatementResParser(res.val, conf.intMode); else throw errorTranslate(res.err); @@ -45,16 +36,14 @@ export async function libsqlBatch( steps: Array, step_conditions: Array ): Promise> { - const res = await LIBlibsqlBatch(confTranslate(conf), libsqlBatchReqStepsBuilder(steps, step_conditions)); + const res = await LIBlibsqlBatch(conf, libsqlBatchReqStepsBuilder(steps, step_conditions)); if (res.isOk) return libsqlBatchStreamResParser(res.val, conf.intMode); else throw errorTranslate(res.err); } export async function libsqlServerCompatCheck(conf: libsqlConfig) { - return (await LIBlibsqlServerCompatCheck( - confTranslate(conf) - )).isOk; + return (await LIBlibsqlServerCompatCheck(conf)).isOk; } export async function libsqlBatchTransaction( @@ -62,7 +51,7 @@ export async function libsqlBatchTransaction( steps: Array, mode: TransactionMode="deferred" ): Promise> { - const res = await LIBlibsqlBatch(confTranslate(conf), libsqlTransactionBatchReqStepsBuilder(steps, mode)); + const res = await LIBlibsqlBatch(conf, libsqlTransactionBatchReqStepsBuilder(steps, mode)); if (res.isOk) return libsqlTransactionBatchStreamResParser(res.val, conf.intMode); else throw errorTranslate(res.err); @@ -75,6 +64,6 @@ export async function libsqlExecuteMultiple(conf: libsqlConfig, sql: string): Pr }}); sqlArr[0].condition = undefined; //elm 0's ok index is set to -1; removing that - const res = await LIBlibsqlBatch(confTranslate(conf), sqlArr); + const res = await LIBlibsqlBatch(conf, sqlArr); if (!res.isOk) throw errorTranslate(res.err); }