rqlite-js
rqlite-js copied to clipboard
TypeScript, Deno-first implementation
Just curious if there might be interest in a TypeScript sourced, Deno-first implementation?
Part of the reasoning is it would be possible to significantly reduce external dependencies and resources for the main project source, and be able to relatively easily convert to JS and Node capable implementations.
Part of this would be using fetch-api, which is in recent node releases, deno and browser. Deno first would be mainly for the explicit reference to paths with the extension, which are easier to strip for JS target builds for Node/Browser. Should make it possible to bring in via import directive of async function in node and browsers.
It would leave some legacy support behind, but likely be slightly more cohesive for forward use. Could possibly displace the current JS library, with a breaking version bump.
I am always interested in new libraries for interacting with rqlite. If you want to create such a library, go for it. I can create a new repo in the rqlite org, to which you can have commit rights.
Hi, love your work.
I am playing around with deno using the "rqlite-js" (latest npm as of writing). I thought I would re-write the integration-tests of rqlite-js.
import { Agent as HttpAgent } from "https://deno.land/[email protected]/node/http.ts";
import { Agent as HttpsAgent } from "https://deno.land/[email protected]/node/https.ts";
import rqlite from 'npm:rqlite-js';
const httpAgent = new HttpAgent({ keepAlive: true })
const httpsAgent = new HttpsAgent({ keepAlive: true })
[...]
Deno.test("data api client", async (test) => {
const dataApiClient = new DataApiClient(HOST, { httpAgent, httpsAgent });
[...]
await test.step("select one row", async () => {
const sql = 'SELECT name FROM foo WHERE name="fiona"'
const dataResults = await dataApiClient.execute(sql);
assert(dataResults.getFirstError()===undefined)
const dataResult = dataResults.get(0);
assertExists(dataResult)
console.log(dataResult)
assertEquals(dataResult.get('name'), 'fiona')
})
[...]
I see a lot of not implemented: ClientRequest.setTimeout
from Deno's implementation. And it seems to kind of work. SQL get executed successfully.
But, when querying, I receive only empty results (see above). The assertEqual
to get the "name" fails. The console.log
shows
DataResult { time: 0, lastInsertId: 1, rowsAffected: 1, results: [], data: {} }
I will look into this myself.
deno 1.28.0 (release, x86_64-pc-windows-msvc)
v8 10.9.194.1
typescript 4.8.3
@cons0l3 it shouldn't be too hard to port over the current code base to TypeScript. The code is already transpiled with babel I wrote JSDocs with types for all of the documentation. Adding TypeScript running on NodeJS and fixing any type errors might be an easier first step to get working then try it out on Deno.
@justinmorant porting it over to TypeScript maybe doable. I have started porting rqlite-js to a reqlite-ts, but there are a lot of details, that did not work easily without chaning the API. Currently the rqlite-ts is not running. My goal is to make a rqlite-deno with a minimum of external dependencies. That implies removal of e.g. axios and replacing with deno itnernal "fetch"-API, ... At the end a rqlite-deno module would be somewhat a rewrite. I have to familiarize myself the the rqlited-API and maybe even simplify the features of rqlite-js.
When/If I have progress, I will come back to you.
In case anyone is looking for something similar I created a TypeScript wrapper around rqlite for my purposes: https://github.com/Tjstretchalot/tsrqdb
Has a lot of the features requested here (built for typing, minimal dependencies, use of the fetch api). Also has explain() support and configurable logging; if chalk is installed, the logging is colored by default.
Thanks @Tjstretchalot -- I added your work to the Clients page: https://rqlite.io/docs/api/client-libraries/