libsql-stateless
Advanced tools
Comparing version 2.8.3 to 2.8.4-alpha.0
@@ -1,2 +0,152 @@ | ||
export * from './functions.js'; | ||
export * from './types.js'; | ||
type libsqlResult<T, E> = { | ||
isOk: true; | ||
val: T; | ||
} | { | ||
isOk: false; | ||
err: E; | ||
}; | ||
type libsqlConfig = { | ||
db_url: string; | ||
authToken?: string; | ||
}; | ||
type libsqlError = { | ||
kind: "LIBSQL_SERVER_ERROR"; | ||
server_message: string | null; | ||
http_status_code: number; | ||
} | { | ||
kind: "LIBSQL_RESPONSE_ERROR"; | ||
data: libsqlStreamResErrData; | ||
}; | ||
type libsqlPipelineReq = { | ||
baton: string | null; | ||
requests: Array<libsqlCloseStreamReq | libsqlExecuteStreamReq | libsqlBatchStreamReq>; | ||
}; | ||
type libsqlPipelineRes = { | ||
baton: string | null; | ||
base_url: string | null; | ||
results: Array<libsqlStreamResOk | libsqlStreamResErr>; | ||
}; | ||
type libsqlCloseStreamReq = { | ||
type: "close"; | ||
}; | ||
type libsqlExecuteStreamReq = { | ||
type: "execute"; | ||
stmt: libsqlSQLStatement; | ||
}; | ||
type libsqlBatchStreamReq = { | ||
type: "batch"; | ||
batch: { | ||
steps: Array<libsqlBatchReqStep>; | ||
}; | ||
}; | ||
type libsqlStreamResOk = { | ||
type: "ok"; | ||
response: libsqlCloseStreamResOk | libsqlExecuteStreamResOk | libsqlBatchStreamResOk; | ||
}; | ||
type libsqlStreamResErr = { | ||
type: "error"; | ||
error: libsqlStreamResErrData; | ||
}; | ||
type libsqlSQLStatement = { | ||
sql: string; | ||
args?: Array<libsqlSQLValue>; | ||
named_args?: Array<{ | ||
name: string; | ||
value: libsqlSQLValue; | ||
}>; | ||
want_rows?: boolean; | ||
}; | ||
type libsqlBatchReqStep = { | ||
condition?: libsqlBatchReqStepExecCond | null; | ||
stmt: libsqlSQLStatement; | ||
}; | ||
type libsqlCloseStreamResOk = { | ||
type: "close"; | ||
}; | ||
type libsqlExecuteStreamResOk = { | ||
type: "execute"; | ||
result: libsqlStatementResOkData; | ||
}; | ||
type libsqlBatchStreamResOk = { | ||
type: "batch"; | ||
result: libsqlBatchStreamResOkData; | ||
}; | ||
type libsqlStreamResErrData = { | ||
message: string; | ||
code?: string | null; | ||
}; | ||
type libsqlSQLValue = { | ||
type: "null"; | ||
} | { | ||
type: "integer"; | ||
value: string; | ||
} | { | ||
type: "float"; | ||
value: number; | ||
} | { | ||
type: "text"; | ||
value: string; | ||
} | { | ||
type: "blob"; | ||
base64: string; | ||
}; | ||
type libsqlBatchReqStepExecCond = { | ||
type: "ok"; | ||
step: number; | ||
} | //uint32: 0-based index in the steps array | ||
{ | ||
type: "error"; | ||
step: number; | ||
} | //uint32: 0-based index in the steps array | ||
{ | ||
type: "not"; | ||
cond: libsqlBatchReqStepExecCond; | ||
} | { | ||
type: "and"; | ||
conds: Array<libsqlBatchReqStepExecCond>; | ||
} | { | ||
type: "or"; | ||
conds: Array<libsqlBatchReqStepExecCond>; | ||
} | { | ||
type: "is_autocommit"; | ||
}; | ||
type libsqlStatementResOkData = { | ||
cols: Array<libsqlSQLColumnElm>; | ||
rows: Array<Array<libsqlSQLValue>>; | ||
affected_row_count: number; | ||
last_insert_rowid: string | null; | ||
rows_read: number; | ||
rows_written: number; | ||
query_duration_ms: number; | ||
}; | ||
type libsqlBatchStreamResOkData = { | ||
step_results: Array<libsqlStatementResOkData | null>; | ||
step_errors: Array<libsqlStreamResErrData | null>; | ||
}; | ||
type libsqlSQLColumnElm = { | ||
name: string | null; | ||
decltype: string | null; | ||
}; | ||
/** | ||
* @async | ||
* @description Executes exactly one (1) SQL statements. | ||
* @param {libsqlConfig} conf libsql's config for DB connection: {@link libsqlConfig} | ||
* @param {libsqlSQLStatement} stmt libsql's raw API sql statement: {@link libsqlSQLStatement} | ||
*/ | ||
declare function libsqlExecute(conf: libsqlConfig, stmt: libsqlSQLStatement): Promise<libsqlResult<libsqlStatementResOkData, libsqlError>>; | ||
/** | ||
* @async | ||
* @description Executes many SQL statements. Can be used to perform implicit transactions. | ||
* @param {libsqlConfig} conf libsql's config for DB connection: {@link libsqlConfig} | ||
* @param {Array<BatchReqSteps>} batch_steps array of libsql's raw API sql batch steps: {@link BatchReqSteps} | ||
*/ | ||
declare function libsqlBatch(conf: libsqlConfig, batch_steps: Array<libsqlBatchReqStep>): Promise<libsqlResult<libsqlBatchStreamResOkData, libsqlError>>; | ||
/** | ||
* @async | ||
* @description Check if the server supports this library | ||
* @param {Config} conf libsql's config for DB connection: {@link libsqlConfig} | ||
*/ | ||
declare function libsqlServerCompatCheck(conf: libsqlConfig): Promise<libsqlResult<null, null>>; | ||
export { libsqlBatch, type libsqlBatchReqStep, type libsqlBatchReqStepExecCond, type libsqlBatchStreamReq, type libsqlBatchStreamResOk, type libsqlBatchStreamResOkData, type libsqlCloseStreamReq, type libsqlCloseStreamResOk, type libsqlConfig, type libsqlError, libsqlExecute, type libsqlExecuteStreamReq, type libsqlExecuteStreamResOk, type libsqlPipelineReq, type libsqlPipelineRes, type libsqlResult, type libsqlSQLColumnElm, type libsqlSQLStatement, type libsqlSQLValue, libsqlServerCompatCheck, type libsqlStatementResOkData, type libsqlStreamResErr, type libsqlStreamResErrData, type libsqlStreamResOk }; |
@@ -1,2 +0,3 @@ | ||
export * from './functions.js'; | ||
export * from './types.js'; | ||
async function r(e){let s=await fetch(`${e.conf.db_url}/v3/pipeline`,{method:"POST",headers:e.conf.authToken?{Authorization:"Bearer "+e.conf.authToken}:void 0,body:JSON.stringify(e.req_json)});return s.ok&&s.headers.get("content-type")==="application/json"?{isOk:!0,val:await s.json()}:{isOk:!1,err:{kind:"LIBSQL_SERVER_ERROR",server_message:await(async()=>{try{return await s.text()}catch{return null}})(),http_status_code:s.status}}}async function i(e,s){let l=await r({conf:e,req_json:{baton:null,requests:[{type:"execute",stmt:s},{type:"close"}]}});if(l.isOk){let t=l.val.results[0];return t.type=="ok"&&t.response.type=="execute"?{isOk:!0,val:t.response.result}:{isOk:!1,err:{kind:"LIBSQL_RESPONSE_ERROR",data:t.error}}}else return l}async function n(e,s){let l=await r({conf:e,req_json:{baton:null,requests:[{type:"batch",batch:{steps:s}},{type:"close"}]}});if(l.isOk){let t=l.val.results[0];return t.type=="ok"&&t.response.type=="batch"?{isOk:!0,val:t.response.result}:{isOk:!1,err:{kind:"LIBSQL_RESPONSE_ERROR",data:t.error}}}else return l}async function a(e){return (await fetch(`${e.db_url}/v3`,{method:"GET"})).ok?{isOk:!0,val:null}:{isOk:!1,err:null}} | ||
export { n as libsqlBatch, i as libsqlExecute, a as libsqlServerCompatCheck }; |
{ | ||
"name": "libsql-stateless", | ||
"version": "2.8.3", | ||
"version": "2.8.4-alpha.0", | ||
"description": "thin libSQL stateless http driver for TypeScript and JavaScript", | ||
"homepage": "https://github.com/DaBigBlob/libsql-stateless#readme", | ||
@@ -13,21 +14,42 @@ "repository": { | ||
}, | ||
"author": { | ||
"name": "LocalBox Crox", | ||
"email": "localboxcrox@gmail.com" | ||
}, | ||
"license": "MIT", | ||
"type": "module", | ||
"main": "./dist/main.js", | ||
"devDependencies": { | ||
"typescript": "^5.0.0" | ||
}, | ||
"types": "./dist/main.d.ts", | ||
"files": [ | ||
"./dist/*", | ||
"./LICENSE", | ||
"./package.json", | ||
"./README.md" | ||
], | ||
"exports": { | ||
".": { | ||
"types": "./dist/main.d.ts", | ||
"import": "./dist/main.js", | ||
"require": "./dist/main.js" | ||
"import": { | ||
"default": "./dist/main.js", | ||
"types": "./dist/main.d.ts" | ||
}, | ||
"require": { | ||
"default": "./dist/main.js", | ||
"types": "./dist/main.d.cts" | ||
} | ||
} | ||
}, | ||
"author": { | ||
"name": "LocalBox Crox", | ||
"email": "localboxcrox@gmail.com" | ||
"devDependencies": { | ||
"tsup": "^8.0.2", | ||
"typescript": "^5.0.0" | ||
}, | ||
"description": "thin libSQL stateless http driver for TypeScript and JavaScript", | ||
"files": [ | ||
"./dist/**" | ||
], | ||
"scripts": { | ||
"prepublishOnly": "npm run build", | ||
"prebuild": "rm -rf ./dist", | ||
"build": "tsup", | ||
"typecheck": "tsc --noEmit", | ||
"test": "bun run _tests/test2.ts", | ||
"perf": "bun run _tests/perf.ts", | ||
"clean": "npm run prebuild", | ||
"prod": "npm publish && npm run clean" | ||
}, | ||
"keywords": [ | ||
@@ -47,17 +69,3 @@ "libsql", | ||
"edge" | ||
], | ||
"license": "MIT", | ||
"scripts": { | ||
"prepublishOnly": "npm run build", | ||
"prebuild": "rm -rf ./dist", | ||
"build": "tsc -p tsconfig.json", | ||
"typecheck": "tsc --noEmit", | ||
"test": "bun run _tests/test2.ts", | ||
"perf": "bun run _tests/perf.ts", | ||
"clean": "npm run prebuild", | ||
"build:clean": "npm run clean && npm run build", | ||
"prod": "npm publish && npm run clean" | ||
}, | ||
"type": "module", | ||
"types": "./dist/main.d.ts" | ||
] | ||
} |
@@ -8,3 +8,3 @@ # libsql-stateless | ||
- ✅ **Has no premature optimizations.** | ||
- ✅ **Is extremely light:** 2KB (minified)/ 899B (minified+gzipped) | ||
- ✅ **Is extremely light:** 1.4kB (minified)/ 658B (minified+gzipped) | ||
- ✅ Unlike `@libsql/client/web`, **every function performs complete execution in exactly 1 roundtrip.** | ||
@@ -11,0 +11,0 @@ - ✅ **Is built for:** Quick stateless query execution. (Mainly for serverless and edge functions.) |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
16793
2
7
167
1
5