diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ec2218e1..b605bded 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -407,6 +407,9 @@ importers: eslint-plugin-jest: specifier: ^27.6.3 version: 27.9.0(@typescript-eslint/eslint-plugin@6.21.0)(eslint@8.57.0)(jest@29.7.0)(typescript@5.4.5) + libsql-stateless-easy: + specifier: ^1.6.2 + version: 1.6.6 lucia: specifier: ^3.1.1 version: 3.1.1 @@ -10282,6 +10285,16 @@ packages: isomorphic.js: 0.2.5 dev: false + /libsql-stateless-easy@1.6.6: + resolution: {integrity: sha512-GorX2qXMfMjzq2+JCTMaoBb/+kwVLtfh//AqCExc9WdB13joAi5QxxxaxsViwK6uPtPhMrYttC8uqljFtdbLpQ==} + dependencies: + libsql-stateless: 2.8.4 + dev: false + + /libsql-stateless@2.8.4: + resolution: {integrity: sha512-LD2mMLefkTsfVWDpBzaFMYY6ZC6GEXrdNRRKEG/Y8tXGpds1JCqEvUpYhziVae884bbsEG/zeiKTLogoD5dM+g==} + dev: false + /libsql@0.3.12: resolution: {integrity: sha512-to30hj8O3DjS97wpbKN6ERZ8k66MN1IaOfFLR6oHqd25GMiPJ/ZX0VaZ7w+TsPmxcFS3p71qArj/hiedCyvXCg==} cpu: [x64, arm64, wasm32] diff --git a/studio/package.json b/studio/package.json index b7f74ee3..446073e5 100644 --- a/studio/package.json +++ b/studio/package.json @@ -1,6 +1,6 @@ { "name": "@libsqlstudio/studio", - "version": "0.3.1", + "version": "0.4.0", "private": false, "scripts": { "dev": "next dev --turbo", @@ -73,6 +73,7 @@ "dotenv": "^16.4.5", "drizzle-orm": "^0.30.1", "eslint-plugin-jest": "^27.6.3", + "libsql-stateless-easy": "^1.6.2", "lucia": "^3.1.1", "lucide-react": "^0.309.0", "magic-bytes.js": "^1.10.0", diff --git a/studio/src/drivers/turso-driver.tsx b/studio/src/drivers/turso-driver.tsx index 66da7652..9c9e9d81 100644 --- a/studio/src/drivers/turso-driver.tsx +++ b/studio/src/drivers/turso-driver.tsx @@ -4,6 +4,7 @@ import { InStatement, ResultSet, } from "@libsql/client/web"; +import { createClient as createClientStateless } from "libsql-stateless-easy"; import { SqliteLikeBaseDriver, DatabaseHeader, @@ -64,11 +65,23 @@ export default class TursoDriver extends SqliteLikeBaseDriver { this.authToken = authToken; this.bigInt = bigInt; - this.client = createClient({ - url: this.endpoint, - authToken: this.authToken, - intMode: bigInt ? "bigint" : "number", - }); + if ( + url.startsWith("libsql://") || + url.startsWith("http://") || + url.startsWith("https://") + ) { + this.client = createClientStateless({ + url: this.endpoint.replace(/^libsql:\/\//, "https://"), + authToken: this.authToken, + intMode: bigInt ? "bigint" : "number", + }); + } else { + this.client = createClient({ + url: this.endpoint, + authToken: this.authToken, + intMode: bigInt ? "bigint" : "number", + }); + } } supportBigInt(): boolean {