@supabase/lite 0.6.2-next.3 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/STATUS.md +1 -1
- package/dist/cli/index.js +107 -107
- package/dist/cli/lib.js +36 -36
- package/dist/db/libsql/index.d.ts +30 -0
- package/dist/db/libsql/index.js +12 -0
- package/package.json +10 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Config, Client } from '@libsql/client';
|
|
2
|
+
import { Kysely } from 'kysely';
|
|
3
|
+
import { ISqliteConnectionConfig, SqliteConnection, TransactionOptions } from '@supabase/lite';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Connection config: Lite's SQLite options plus every libsql client option
|
|
7
|
+
* (`authToken`, `syncUrl`, `encryptionKey`, `intMode`, `tls`, ...). `url` comes
|
|
8
|
+
* from `ISqliteConnectionConfig` and is normalized before reaching libsql.
|
|
9
|
+
*/
|
|
10
|
+
interface ILibsqlConnectionConfig extends ISqliteConnectionConfig, Omit<Config, "url"> {
|
|
11
|
+
/**
|
|
12
|
+
* Pass an already-constructed libsql `Client` for full control. When set,
|
|
13
|
+
* `url` and the other libsql options are ignored.
|
|
14
|
+
*/
|
|
15
|
+
client?: Client;
|
|
16
|
+
}
|
|
17
|
+
declare class LibsqlConnection<DB = any> extends SqliteConnection<Client, DB, ILibsqlConnectionConfig> {
|
|
18
|
+
kysely: Kysely<DB>;
|
|
19
|
+
driver: Client;
|
|
20
|
+
constructor(config?: ILibsqlConnectionConfig);
|
|
21
|
+
exec<T = {
|
|
22
|
+
rows: unknown[];
|
|
23
|
+
} | void>(query: string, ...parameters: readonly unknown[]): Promise<T>;
|
|
24
|
+
transaction(statements: string[], opts?: TransactionOptions): Promise<void>;
|
|
25
|
+
close(): Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
declare function createLibsqlConnection(config?: ILibsqlConnectionConfig): LibsqlConnection<any>;
|
|
28
|
+
declare function libsql(config?: ILibsqlConnectionConfig): LibsqlConnection<any>;
|
|
29
|
+
|
|
30
|
+
export { type ILibsqlConnectionConfig, LibsqlConnection, createLibsqlConnection, libsql };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import c from'node:fs';import a from'node:path';import {createClient}from'@libsql/client';import {Kysely}from'kysely';import {GenericSqliteDialect}from'kysely-generic-sqlite';import {SqliteConnection}from'@supabase/lite';try {
|
|
2
|
+
/**
|
|
3
|
+
* Adding this to avoid warnings from node:sqlite being experimental
|
|
4
|
+
*/
|
|
5
|
+
const { emitWarning } = process;
|
|
6
|
+
process.emitWarning = (warning, ...args) => {
|
|
7
|
+
if (warning.includes("SQLite is an experimental feature")) return;
|
|
8
|
+
return emitWarning(warning, ...args);
|
|
9
|
+
};
|
|
10
|
+
} catch {}
|
|
11
|
+
function u(e){if(!e||e===":memory:"||e==="file::memory:")return ":memory:";if(/^(libsql|https?|wss?):/.test(e))return e;let t=e.startsWith("file://")?e.slice(7):e.startsWith("file:")?e.slice(5):e;return !t||t===":memory:"?":memory:":`file:${a.isAbsolute(t)?t:a.resolve(process.cwd(),t)}`}function l(e){return e.rows.map(t=>Object.fromEntries(e.columns.map((n,i)=>[n,t[i]])))}function y(e,t){return {db:e,query:async(n,i,r=[])=>{let s=await e.execute({sql:i,args:t(r)});return {rows:l(s),insertId:s.lastInsertRowid!==void 0?BigInt(s.lastInsertRowid):void 0,numAffectedRows:BigInt(s.rowsAffected)}},close:()=>e.close()}}var o=class extends SqliteConnection{kysely;driver;constructor(t={}){if(super(t),t.client)this.driver=t.client;else {let i=u(t.url);if(i.startsWith("file:")){let r=a.dirname(i.slice(5));c.existsSync(r)||c.mkdirSync(r,{recursive:true});}this.driver=createClient({...t,url:i});}let n=new GenericSqliteDialect(()=>y(this.driver,i=>this.prepareBindParams(i)),async i=>{await this.driver.execute("pragma foreign_keys = on");});this.kysely=new Kysely({dialect:n,plugins:this.withSqlitePlugins()});}async exec(t,...n){let i=t.trimStart().toUpperCase(),r=this.prepareBindParams(n);if(i.startsWith("SELECT")||i.startsWith("WITH")){let s=await this.driver.execute({sql:t,args:r});return {rows:l(s)}}r.length>0?await this.driver.execute({sql:t,args:r}):await this.driver.executeMultiple(t);}async transaction(t,n){n?.intent==="migration"&&await this.driver.execute("PRAGMA foreign_keys=OFF;");try{await this.driver.batch(t,"write");}finally{n?.intent==="migration"&&(await this.driver.execute("PRAGMA foreign_keys=ON;"),await this.clearSchemaCache());}}async close(){this.driver.close();}};function C(e={}){return new o(e)}function w(e={}){return new o(e)}
|
|
12
|
+
export{o as LibsqlConnection,C as createLibsqlConnection,w as libsql};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@supabase/lite",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Lightweight TypeScript-native Supabase implementation on SQLite (alpha). PostgREST + GoTrue compatible — use @supabase/supabase-js as-is.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -51,6 +51,10 @@
|
|
|
51
51
|
"types": "./dist/db/postgres/pglite/PgliteConnection.d.ts",
|
|
52
52
|
"import": "./dist/db/postgres/pglite/PgliteConnection.js"
|
|
53
53
|
},
|
|
54
|
+
"./libsql": {
|
|
55
|
+
"types": "./dist/db/libsql/index.d.ts",
|
|
56
|
+
"import": "./dist/db/libsql/index.js"
|
|
57
|
+
},
|
|
54
58
|
"./vite": {
|
|
55
59
|
"types": "./dist/vite/index.d.ts",
|
|
56
60
|
"import": "./dist/vite/index.js"
|
|
@@ -150,11 +154,15 @@
|
|
|
150
154
|
"uuid": "^13.0.0"
|
|
151
155
|
},
|
|
152
156
|
"peerDependencies": {
|
|
157
|
+
"@libsql/client": "^0.17.4",
|
|
153
158
|
"@supabase/supabase-js": ">=2.90.0",
|
|
154
159
|
"postgres": "^3.4.8",
|
|
155
160
|
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0"
|
|
156
161
|
},
|
|
157
162
|
"peerDependenciesMeta": {
|
|
163
|
+
"@libsql/client": {
|
|
164
|
+
"optional": true
|
|
165
|
+
},
|
|
158
166
|
"vite": {
|
|
159
167
|
"optional": true
|
|
160
168
|
},
|
|
@@ -164,6 +172,7 @@
|
|
|
164
172
|
},
|
|
165
173
|
"devDependencies": {
|
|
166
174
|
"@clack/prompts": "^1.1.0",
|
|
175
|
+
"@libsql/client": "^0.17.4",
|
|
167
176
|
"@cloudflare/vitest-pool-workers": "^0.9.0",
|
|
168
177
|
"@cloudflare/workers-types": "^4.20260301.1",
|
|
169
178
|
"@hono/vite-dev-server": "^0.25.0",
|