Skip to content

move overloads of execute to @libsql/core/api (because its part of the public API) && add CONTRIBUTING.md #261

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Sep 25, 2024
Merged
13 changes: 13 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -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 ../..`
7 changes: 1 addition & 6 deletions packages/libsql-client-wasm/src/wasm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,6 @@ export class Sqlite3Client implements Client {
this.protocol = "file";
}

async execute(stmt: InStatement): Promise<ResultSet>;
async execute(sql: string, args?: InArgs): Promise<ResultSet>;

async execute(
stmtOrSql: InStatement | string,
args?: InArgs,
Expand Down Expand Up @@ -171,9 +168,7 @@ export class Sqlite3Client implements Client {
}
}

async migrate(
stmts: Array<InStatement>,
): Promise<Array<ResultSet>> {
async migrate(stmts: Array<InStatement>): Promise<Array<ResultSet>> {
this.#checkNotClosed();
const db = this.#getDb();
try {
Expand Down
6 changes: 3 additions & 3 deletions packages/libsql-client/src/__tests__/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ describe("batch()", () => {
);

const n = 100;
const promises = [];
const promises = [] as Array<any>;
for (let i = 0; i < n; ++i) {
const ii = i;
promises.push(
Expand Down Expand Up @@ -885,7 +885,7 @@ describe("batch()", () => {
test(
"batch with a lot of different statements",
withClient(async (c) => {
const stmts = [];
const stmts = [] as Array<any>;
for (let i = 0; i < 1000; ++i) {
stmts.push(`SELECT ${i}`);
}
Expand All @@ -902,7 +902,7 @@ describe("batch()", () => {
const n = 20;
const m = 200;

const stmts = [];
const stmts = [] as Array<any>;
for (let i = 0; i < n; ++i) {
for (let j = 0; j < m; ++j) {
stmts.push({ sql: `SELECT ?, ${j}`, args: [i] });
Expand Down
4 changes: 2 additions & 2 deletions packages/libsql-client/src/hrana.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ export async function executeHranaBatch(
disableForeignKeys: boolean = false,
): Promise<Array<ResultSet>> {
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));
Expand Down Expand Up @@ -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();
Expand Down
7 changes: 1 addition & 6 deletions packages/libsql-client/src/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@ export class HttpClient implements Client {
return this.#promiseLimitFunction(fn);
}

async execute(stmt: InStatement): Promise<ResultSet>;
async execute(sql: string, args?: InArgs): Promise<ResultSet>;

async execute(
stmtOrSql: InStatement | string,
args?: InArgs,
Expand Down Expand Up @@ -180,9 +177,7 @@ export class HttpClient implements Client {
});
}

async migrate(
stmts: Array<InStatement>,
): Promise<Array<ResultSet>> {
async migrate(stmts: Array<InStatement>): Promise<Array<ResultSet>> {
return this.limit<Array<ResultSet>>(async () => {
try {
const hranaStmts = stmts.map(stmtToHrana);
Expand Down
7 changes: 1 addition & 6 deletions packages/libsql-client/src/sqlite3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,6 @@ export class Sqlite3Client implements Client {
this.protocol = "file";
}

async execute(stmt: InStatement): Promise<ResultSet>;
async execute(sql: string, args?: InArgs): Promise<ResultSet>;

async execute(
stmtOrSql: InStatement | string,
args?: InArgs,
Expand Down Expand Up @@ -167,9 +164,7 @@ export class Sqlite3Client implements Client {
}
}

async migrate(
stmts: Array<InStatement>,
): Promise<Array<ResultSet>> {
async migrate(stmts: Array<InStatement>): Promise<Array<ResultSet>> {
this.#checkNotClosed();
const db = this.#getDb();
try {
Expand Down
7 changes: 1 addition & 6 deletions packages/libsql-client/src/ws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,6 @@ export class WsClient implements Client {
return this.#promiseLimitFunction(fn);
}

async execute(stmt: InStatement): Promise<ResultSet>;
async execute(sql: string, args?: InArgs): Promise<ResultSet>;

async execute(
stmtOrSql: InStatement | string,
args?: InArgs,
Expand Down Expand Up @@ -226,9 +223,7 @@ export class WsClient implements Client {
});
}

async migrate(
stmts: Array<InStatement>,
): Promise<Array<ResultSet>> {
async migrate(stmts: Array<InStatement>): Promise<Array<ResultSet>> {
return this.limit<Array<ResultSet>>(async () => {
const streamState = await this.#openStream();
try {
Expand Down
5 changes: 2 additions & 3 deletions packages/libsql-core/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export interface Client {
* ```
*/
execute(stmt: InStatement): Promise<ResultSet>;
execute(sql: string, args?: InArgs): Promise<ResultSet>;

/** Execute a batch of SQL statements in a transaction.
*
Expand Down Expand Up @@ -155,9 +156,7 @@ export interface Client {
* ]);
* ```
*/
migrate(
stmts: Array<InStatement>,
): Promise<Array<ResultSet>>;
migrate(stmts: Array<InStatement>): Promise<Array<ResultSet>>;

/** Start an interactive transaction.
*
Expand Down
Loading