diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..8aa51dd8 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,13 @@ +# Prerequisites + +- Have `npm` installed and in PATH +- Have `git` installed and in PATH + +# 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` +- 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 ../..` 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 { 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/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(); 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 { 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. *