From 6de91a2e927bb04eb5d05ef3fa0535299191d73c Mon Sep 17 00:00:00 2001 From: Person Date: Wed, 11 Sep 2024 15:53:29 -0400 Subject: [PATCH 01/11] move overloads of execute to @libsql/core/api (because its part of the public API) --- packages/libsql-client-wasm/src/wasm.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/packages/libsql-client-wasm/src/wasm.ts b/packages/libsql-client-wasm/src/wasm.ts index abab3f20..d140546c 100644 --- a/packages/libsql-client-wasm/src/wasm.ts +++ b/packages/libsql-client-wasm/src/wasm.ts @@ -123,9 +123,6 @@ export class Sqlite3Client implements Client { this.protocol = "file"; } - async execute(stmt: InStatement): Promise; - async execute(sql: string, args?: InArgs): Promise; - async execute( stmtOrSql: InStatement | string, args?: InArgs, @@ -171,9 +168,7 @@ export class Sqlite3Client implements Client { } } - async migrate( - stmts: Array, - ): Promise> { + async migrate(stmts: Array): Promise> { this.#checkNotClosed(); const db = this.#getDb(); try { From b40f7eaa68eb10e32b3613b077ae15e58b24348f Mon Sep 17 00:00:00 2001 From: Person Date: Wed, 11 Sep 2024 15:53:59 -0400 Subject: [PATCH 02/11] move overloads of execute to @libsql/core/api (because its part of the public API) --- packages/libsql-client/src/__tests__/client.test.ts | 6 +++--- packages/libsql-client/src/http.ts | 7 +------ packages/libsql-client/src/sqlite3.ts | 7 +------ packages/libsql-client/src/ws.ts | 7 +------ 4 files changed, 6 insertions(+), 21 deletions(-) diff --git a/packages/libsql-client/src/__tests__/client.test.ts b/packages/libsql-client/src/__tests__/client.test.ts index 0e6bcfc5..eaa5a87b 100644 --- a/packages/libsql-client/src/__tests__/client.test.ts +++ b/packages/libsql-client/src/__tests__/client.test.ts @@ -814,7 +814,7 @@ describe("batch()", () => { ); const n = 100; - const promises = []; + const promises = [] as Array; for (let i = 0; i < n; ++i) { const ii = i; promises.push( @@ -885,7 +885,7 @@ describe("batch()", () => { test( "batch with a lot of different statements", withClient(async (c) => { - const stmts = []; + const stmts = [] as Array; for (let i = 0; i < 1000; ++i) { stmts.push(`SELECT ${i}`); } @@ -902,7 +902,7 @@ describe("batch()", () => { const n = 20; const m = 200; - const stmts = []; + const stmts = [] as Array; for (let i = 0; i < n; ++i) { for (let j = 0; j < m; ++j) { stmts.push({ sql: `SELECT ?, ${j}`, args: [i] }); diff --git a/packages/libsql-client/src/http.ts b/packages/libsql-client/src/http.ts index fac092f5..a540e46c 100644 --- a/packages/libsql-client/src/http.ts +++ b/packages/libsql-client/src/http.ts @@ -96,9 +96,6 @@ export class HttpClient implements Client { return this.#promiseLimitFunction(fn); } - async execute(stmt: InStatement): Promise; - async execute(sql: string, args?: InArgs): Promise; - async execute( stmtOrSql: InStatement | string, args?: InArgs, @@ -180,9 +177,7 @@ export class HttpClient implements Client { }); } - async migrate( - stmts: Array, - ): Promise> { + async migrate(stmts: Array): Promise> { return this.limit>(async () => { try { const hranaStmts = stmts.map(stmtToHrana); diff --git a/packages/libsql-client/src/sqlite3.ts b/packages/libsql-client/src/sqlite3.ts index 2ac9790e..864ad694 100644 --- a/packages/libsql-client/src/sqlite3.ts +++ b/packages/libsql-client/src/sqlite3.ts @@ -119,9 +119,6 @@ export class Sqlite3Client implements Client { this.protocol = "file"; } - async execute(stmt: InStatement): Promise; - async execute(sql: string, args?: InArgs): Promise; - async execute( stmtOrSql: InStatement | string, args?: InArgs, @@ -167,9 +164,7 @@ export class Sqlite3Client implements Client { } } - async migrate( - stmts: Array, - ): Promise> { + async migrate(stmts: Array): Promise> { this.#checkNotClosed(); const db = this.#getDb(); try { diff --git a/packages/libsql-client/src/ws.ts b/packages/libsql-client/src/ws.ts index eda69bef..c27e9cf1 100644 --- a/packages/libsql-client/src/ws.ts +++ b/packages/libsql-client/src/ws.ts @@ -154,9 +154,6 @@ export class WsClient implements Client { return this.#promiseLimitFunction(fn); } - async execute(stmt: InStatement): Promise; - async execute(sql: string, args?: InArgs): Promise; - async execute( stmtOrSql: InStatement | string, args?: InArgs, @@ -226,9 +223,7 @@ export class WsClient implements Client { }); } - async migrate( - stmts: Array, - ): Promise> { + async migrate(stmts: Array): Promise> { return this.limit>(async () => { const streamState = await this.#openStream(); try { From af2d811c636e9ff17ee849fe97623529acc46112 Mon Sep 17 00:00:00 2001 From: Person Date: Wed, 11 Sep 2024 15:54:06 -0400 Subject: [PATCH 03/11] move overloads of execute to @libsql/core/api (because its part of the public API) --- packages/libsql-core/src/api.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/libsql-core/src/api.ts b/packages/libsql-core/src/api.ts index 0d4cdb64..304bd8ca 100644 --- a/packages/libsql-core/src/api.ts +++ b/packages/libsql-core/src/api.ts @@ -87,6 +87,7 @@ export interface Client { * ``` */ execute(stmt: InStatement): Promise; + execute(sql: string, args?: InArgs): Promise; /** Execute a batch of SQL statements in a transaction. * @@ -155,9 +156,7 @@ export interface Client { * ]); * ``` */ - migrate( - stmts: Array, - ): Promise>; + migrate(stmts: Array): Promise>; /** Start an interactive transaction. * From 48b25f653fe1508cf3cefc80d2a615f2ce3697d6 Mon Sep 17 00:00:00 2001 From: Person Date: Wed, 11 Sep 2024 16:03:49 -0400 Subject: [PATCH 04/11] add CONTRIBUTING.md --- CONTRIBUTING.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..d49585fe --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,12 @@ + +# Perquisites +- have `npm` installed and in path +- have `git` installed and in path + +# Setting up the repo for contributing +- clone this repo (`git clone libsql-client-ts` on *nix) +- change the current working directory to the cloned repo (`cd libsql-client-ts` on *nix) +- `npm i` +- change the current working directory to `libsql-core`'s workspace (`cd packages/libsql-core` on *nix) +- build it (`npm run build` on *nix) +- finally change back to base directory and start experimenting! (`cd ../..` on *nix) \ No newline at end of file From 12e308660f74b06ba5042e511dae1afb63cf273a Mon Sep 17 00:00:00 2001 From: Person Date: Thu, 12 Sep 2024 22:18:00 -0400 Subject: [PATCH 05/11] fix: spelling mistake --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d49585fe..41837202 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,5 +1,5 @@ -# Perquisites +# Prerequisites - have `npm` installed and in path - have `git` installed and in path From 3473a53d3de77fa5d491270f09cd9e785d122f42 Mon Sep 17 00:00:00 2001 From: Person Date: Thu, 12 Sep 2024 22:20:22 -0400 Subject: [PATCH 06/11] fix: linting: npx prettier --write . --- CONTRIBUTING.md | 19 ++++++++++--------- packages/libsql-client/src/hrana.ts | 4 ++-- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 41837202..ca8b763c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,12 +1,13 @@ - # Prerequisites -- have `npm` installed and in path -- have `git` installed and in path + +- have `npm` installed and in path +- have `git` installed and in path # Setting up the repo for contributing -- clone this repo (`git clone libsql-client-ts` on *nix) -- change the current working directory to the cloned repo (`cd libsql-client-ts` on *nix) -- `npm i` -- change the current working directory to `libsql-core`'s workspace (`cd packages/libsql-core` on *nix) -- build it (`npm run build` on *nix) -- finally change back to base directory and start experimenting! (`cd ../..` on *nix) \ No newline at end of file + +- clone this repo (`git clone libsql-client-ts` on \*nix) +- change the current working directory to the cloned repo (`cd libsql-client-ts` on \*nix) +- `npm i` +- change the current working directory to `libsql-core`'s workspace (`cd packages/libsql-core` on \*nix) +- build it (`npm run build` on \*nix) +- finally change back to base directory and start experimenting! (`cd ../..` on \*nix) diff --git a/packages/libsql-client/src/hrana.ts b/packages/libsql-client/src/hrana.ts index 81b179f7..62a51e08 100644 --- a/packages/libsql-client/src/hrana.ts +++ b/packages/libsql-client/src/hrana.ts @@ -255,7 +255,7 @@ export async function executeHranaBatch( disableForeignKeys: boolean = false, ): Promise> { if (disableForeignKeys) { - batch.step().run("PRAGMA foreign_keys=off") + batch.step().run("PRAGMA foreign_keys=off"); } const beginStep = batch.step(); const beginPromise = beginStep.run(transactionModeToBegin(mode)); @@ -287,7 +287,7 @@ export async function executeHranaBatch( .condition(hrana.BatchCond.not(hrana.BatchCond.ok(commitStep))); rollbackStep.run("ROLLBACK").catch((_) => undefined); if (disableForeignKeys) { - batch.step().run("PRAGMA foreign_keys=on") + batch.step().run("PRAGMA foreign_keys=on"); } await batch.execute(); From e0560a4db23905b847a35248c3ee6256558c119d Mon Sep 17 00:00:00 2001 From: localbox <73036332+DaBigBlob@users.noreply.github.com> Date: Wed, 25 Sep 2024 05:49:17 -0400 Subject: [PATCH 07/11] update CONTRIBUTING.md Co-authored-by: alcpereira <48070464+alcpereira@users.noreply.github.com> --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ca8b763c..bda545a9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,7 +1,7 @@ # Prerequisites -- have `npm` installed and in path -- have `git` installed and in path +- have `npm` installed and in PATH +- have `git` installed and in PATH # Setting up the repo for contributing From 92ea842b4b3bce8b971ce9957f8c53c6492a41af Mon Sep 17 00:00:00 2001 From: Person Date: Wed, 25 Sep 2024 07:54:58 -0400 Subject: [PATCH 08/11] better instructions for contribution --- CONTRIBUTING.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bda545a9..72e45a33 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,13 +1,13 @@ # Prerequisites -- have `npm` installed and in PATH -- have `git` installed and in PATH +- Have `npm` installed and in PATH +- Have `git` installed and in PATH # Setting up the repo for contributing -- clone this repo (`git clone libsql-client-ts` on \*nix) -- change the current working directory to the cloned repo (`cd libsql-client-ts` on \*nix) -- `npm i` -- change the current working directory to `libsql-core`'s workspace (`cd packages/libsql-core` on \*nix) -- build it (`npm run build` on \*nix) -- finally change back to base directory and start experimenting! (`cd ../..` on \*nix) +- Clone this repository: `git clone https://github.com/tursodatabase/libsql-client-ts` +- Change the current working directory to the cloned repository: `cd libsql-client-ts` +- Install dependencies: `npm i` +- Change the current working directory to `libsql-core`'s workspace: `cd packages/libsql-core` +- Built the core package: `npm run build` +- Go back to the root directory to start making changes: `cd ../..` From d8d16b483d62fdfd17d33faaf3b26eb3c8d1b8f2 Mon Sep 17 00:00:00 2001 From: Person Date: Wed, 25 Sep 2024 07:55:57 -0400 Subject: [PATCH 09/11] better instructions for contribution --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 72e45a33..64f0e855 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,7 +1,7 @@ # Prerequisites -- Have `npm` installed and in PATH -- Have `git` installed and in PATH +- Have `npm` installed and in PATH +- Have `git` installed and in PATH # Setting up the repo for contributing From 5e7759333cccb555d98d6666d51cfd4302813cea Mon Sep 17 00:00:00 2001 From: Person Date: Wed, 25 Sep 2024 08:01:07 -0400 Subject: [PATCH 10/11] prettier's antics --- CONTRIBUTING.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 64f0e855..7fbe88cf 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,13 +1,13 @@ # Prerequisites -- Have `npm` installed and in PATH -- Have `git` installed and in PATH +- Have `npm` installed and in PATH +- Have `git` installed and in PATH # Setting up the repo for contributing -- Clone this repository: `git clone https://github.com/tursodatabase/libsql-client-ts` -- Change the current working directory to the cloned repository: `cd libsql-client-ts` -- Install dependencies: `npm i` -- Change the current working directory to `libsql-core`'s workspace: `cd packages/libsql-core` -- Built the core package: `npm run build` -- Go back to the root directory to start making changes: `cd ../..` +- Clone this repository: `git clone https://github.com/tursodatabase/libsql-client-ts` +- Change the current working directory to the cloned repository: `cd libsql-client-ts` +- Install dependencies: `npm i` +- Change the current working directory to `libsql-core`'s workspace: `cd packages/libsql-core` +- Built the core package: `npm run build` +- Go back to the root directory to start making changes: `cd ../..` From 1bebef604f5b4b3895a8c6f9df69c477d23dbd9b Mon Sep 17 00:00:00 2001 From: Person Date: Wed, 25 Sep 2024 08:02:08 -0400 Subject: [PATCH 11/11] better instructions for contribution --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7fbe88cf..8aa51dd8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -3,7 +3,7 @@ - Have `npm` installed and in PATH - Have `git` installed and in PATH -# Setting up the repo for contributing +# Setting up the repository for contribution - Clone this repository: `git clone https://github.com/tursodatabase/libsql-client-ts` - Change the current working directory to the cloned repository: `cd libsql-client-ts`