Skip to content

Commit d84a4a4

Browse files
authored
Merge pull request #261 from DaBigBlob/main
move overloads of execute to @libsql/core/api (because its part of the public API) && add CONTRIBUTING.md
2 parents 839d48e + 1bebef6 commit d84a4a4

File tree

8 files changed

+24
-32
lines changed

8 files changed

+24
-32
lines changed

CONTRIBUTING.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Prerequisites
2+
3+
- Have `npm` installed and in PATH
4+
- Have `git` installed and in PATH
5+
6+
# Setting up the repository for contribution
7+
8+
- Clone this repository: `git clone https://github.com/tursodatabase/libsql-client-ts`
9+
- Change the current working directory to the cloned repository: `cd libsql-client-ts`
10+
- Install dependencies: `npm i`
11+
- Change the current working directory to `libsql-core`'s workspace: `cd packages/libsql-core`
12+
- Built the core package: `npm run build`
13+
- Go back to the root directory to start making changes: `cd ../..`

packages/libsql-client-wasm/src/wasm.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,6 @@ export class Sqlite3Client implements Client {
123123
this.protocol = "file";
124124
}
125125

126-
async execute(stmt: InStatement): Promise<ResultSet>;
127-
async execute(sql: string, args?: InArgs): Promise<ResultSet>;
128-
129126
async execute(
130127
stmtOrSql: InStatement | string,
131128
args?: InArgs,
@@ -171,9 +168,7 @@ export class Sqlite3Client implements Client {
171168
}
172169
}
173170

174-
async migrate(
175-
stmts: Array<InStatement>,
176-
): Promise<Array<ResultSet>> {
171+
async migrate(stmts: Array<InStatement>): Promise<Array<ResultSet>> {
177172
this.#checkNotClosed();
178173
const db = this.#getDb();
179174
try {

packages/libsql-client/src/__tests__/client.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ describe("batch()", () => {
814814
);
815815

816816
const n = 100;
817-
const promises = [];
817+
const promises = [] as Array<any>;
818818
for (let i = 0; i < n; ++i) {
819819
const ii = i;
820820
promises.push(
@@ -885,7 +885,7 @@ describe("batch()", () => {
885885
test(
886886
"batch with a lot of different statements",
887887
withClient(async (c) => {
888-
const stmts = [];
888+
const stmts = [] as Array<any>;
889889
for (let i = 0; i < 1000; ++i) {
890890
stmts.push(`SELECT ${i}`);
891891
}
@@ -902,7 +902,7 @@ describe("batch()", () => {
902902
const n = 20;
903903
const m = 200;
904904

905-
const stmts = [];
905+
const stmts = [] as Array<any>;
906906
for (let i = 0; i < n; ++i) {
907907
for (let j = 0; j < m; ++j) {
908908
stmts.push({ sql: `SELECT ?, ${j}`, args: [i] });

packages/libsql-client/src/hrana.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ export async function executeHranaBatch(
255255
disableForeignKeys: boolean = false,
256256
): Promise<Array<ResultSet>> {
257257
if (disableForeignKeys) {
258-
batch.step().run("PRAGMA foreign_keys=off")
258+
batch.step().run("PRAGMA foreign_keys=off");
259259
}
260260
const beginStep = batch.step();
261261
const beginPromise = beginStep.run(transactionModeToBegin(mode));
@@ -287,7 +287,7 @@ export async function executeHranaBatch(
287287
.condition(hrana.BatchCond.not(hrana.BatchCond.ok(commitStep)));
288288
rollbackStep.run("ROLLBACK").catch((_) => undefined);
289289
if (disableForeignKeys) {
290-
batch.step().run("PRAGMA foreign_keys=on")
290+
batch.step().run("PRAGMA foreign_keys=on");
291291
}
292292

293293
await batch.execute();

packages/libsql-client/src/http.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,6 @@ export class HttpClient implements Client {
9696
return this.#promiseLimitFunction(fn);
9797
}
9898

99-
async execute(stmt: InStatement): Promise<ResultSet>;
100-
async execute(sql: string, args?: InArgs): Promise<ResultSet>;
101-
10299
async execute(
103100
stmtOrSql: InStatement | string,
104101
args?: InArgs,
@@ -180,9 +177,7 @@ export class HttpClient implements Client {
180177
});
181178
}
182179

183-
async migrate(
184-
stmts: Array<InStatement>,
185-
): Promise<Array<ResultSet>> {
180+
async migrate(stmts: Array<InStatement>): Promise<Array<ResultSet>> {
186181
return this.limit<Array<ResultSet>>(async () => {
187182
try {
188183
const hranaStmts = stmts.map(stmtToHrana);

packages/libsql-client/src/sqlite3.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,6 @@ export class Sqlite3Client implements Client {
119119
this.protocol = "file";
120120
}
121121

122-
async execute(stmt: InStatement): Promise<ResultSet>;
123-
async execute(sql: string, args?: InArgs): Promise<ResultSet>;
124-
125122
async execute(
126123
stmtOrSql: InStatement | string,
127124
args?: InArgs,
@@ -167,9 +164,7 @@ export class Sqlite3Client implements Client {
167164
}
168165
}
169166

170-
async migrate(
171-
stmts: Array<InStatement>,
172-
): Promise<Array<ResultSet>> {
167+
async migrate(stmts: Array<InStatement>): Promise<Array<ResultSet>> {
173168
this.#checkNotClosed();
174169
const db = this.#getDb();
175170
try {

packages/libsql-client/src/ws.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,6 @@ export class WsClient implements Client {
154154
return this.#promiseLimitFunction(fn);
155155
}
156156

157-
async execute(stmt: InStatement): Promise<ResultSet>;
158-
async execute(sql: string, args?: InArgs): Promise<ResultSet>;
159-
160157
async execute(
161158
stmtOrSql: InStatement | string,
162159
args?: InArgs,
@@ -226,9 +223,7 @@ export class WsClient implements Client {
226223
});
227224
}
228225

229-
async migrate(
230-
stmts: Array<InStatement>,
231-
): Promise<Array<ResultSet>> {
226+
async migrate(stmts: Array<InStatement>): Promise<Array<ResultSet>> {
232227
return this.limit<Array<ResultSet>>(async () => {
233228
const streamState = await this.#openStream();
234229
try {

packages/libsql-core/src/api.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ export interface Client {
8787
* ```
8888
*/
8989
execute(stmt: InStatement): Promise<ResultSet>;
90+
execute(sql: string, args?: InArgs): Promise<ResultSet>;
9091

9192
/** Execute a batch of SQL statements in a transaction.
9293
*
@@ -155,9 +156,7 @@ export interface Client {
155156
* ]);
156157
* ```
157158
*/
158-
migrate(
159-
stmts: Array<InStatement>,
160-
): Promise<Array<ResultSet>>;
159+
migrate(stmts: Array<InStatement>): Promise<Array<ResultSet>>;
161160

162161
/** Start an interactive transaction.
163162
*

0 commit comments

Comments
 (0)