@yydb/sqlite 0.0.0 â 0.0.1
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 +6 -3
- package/package.json +41 -5
- package/src/index.ts +69 -0
- package/src/node.ts +7 -0
- package/src/wasm.ts +7 -0
package/README.md
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# ðŠķ `@yydb/sqlite`
|
|
2
|
+
|
|
3
|
+
SQLite for **SQL Studio**. Conditional exports isolate WASM vs file backends:
|
|
4
|
+
|
|
5
|
+
- `@yydb/sqlite/wasm` â browser
|
|
6
|
+
- `@yydb/sqlite/node` â server file database
|
package/package.json
CHANGED
|
@@ -1,10 +1,46 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yydb/sqlite",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "SQL Studio
|
|
5
|
-
"
|
|
6
|
-
"
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "SQLite driver for SQL Studio / sql-studio-orm â 0.0.1 Developer Preview",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MPL-2.0",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"main": "./src/index.ts",
|
|
9
|
+
"types": "./src/index.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./src/index.ts",
|
|
13
|
+
"import": "./src/index.ts",
|
|
14
|
+
"default": "./src/index.ts"
|
|
15
|
+
},
|
|
16
|
+
"./wasm": {
|
|
17
|
+
"types": "./src/wasm.ts",
|
|
18
|
+
"import": "./src/wasm.ts",
|
|
19
|
+
"default": "./src/wasm.ts"
|
|
20
|
+
},
|
|
21
|
+
"./node": {
|
|
22
|
+
"types": "./src/node.ts",
|
|
23
|
+
"import": "./src/node.ts",
|
|
24
|
+
"node": "./src/node.ts",
|
|
25
|
+
"default": "./src/node.ts"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
7
28
|
"files": [
|
|
29
|
+
"src",
|
|
8
30
|
"README.md"
|
|
9
|
-
]
|
|
31
|
+
],
|
|
32
|
+
"scripts": {
|
|
33
|
+
"typecheck": "tsc --noEmit -p tsconfig.json"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@yydb/sql-studio-orm": "0.0.1",
|
|
37
|
+
"@yydb/sql-studio-protocol": "0.0.1"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"typescript": "^5.9.2"
|
|
41
|
+
},
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public",
|
|
44
|
+
"tag": "dev"
|
|
45
|
+
}
|
|
10
46
|
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@yydb/sqlite` â SQLite SqlDriver + Studio registration.
|
|
3
|
+
* Use `./wasm` or `./node` for concrete backends.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type {
|
|
7
|
+
CompiledQuery,
|
|
8
|
+
ExecuteOptions,
|
|
9
|
+
QueryChunk,
|
|
10
|
+
QueryResult,
|
|
11
|
+
SqlConnection,
|
|
12
|
+
SqlDriver,
|
|
13
|
+
SqlTransaction,
|
|
14
|
+
StreamOptions,
|
|
15
|
+
TransactionOptions,
|
|
16
|
+
} from "@yydb/sql-studio-orm";
|
|
17
|
+
import type { StudioDriverRegistration } from "@yydb/sql-studio-protocol";
|
|
18
|
+
|
|
19
|
+
export const DRIVER_ID = "sqlite" as const;
|
|
20
|
+
|
|
21
|
+
export type SqliteDriverOptions = {
|
|
22
|
+
path: string;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type SqliteStudioOptions = SqliteDriverOptions & {
|
|
26
|
+
id: string;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
class NotImplementedConnection implements SqlConnection {
|
|
30
|
+
async execute<R>(_query: CompiledQuery, _options?: ExecuteOptions): Promise<QueryResult<R>> {
|
|
31
|
+
throw new Error("@yydb/sqlite: execute not implemented yet");
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
stream<R>(_query: CompiledQuery, _options?: StreamOptions): AsyncIterable<QueryChunk<R>> {
|
|
35
|
+
throw new Error("@yydb/sqlite: stream not implemented yet");
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async begin(_options?: TransactionOptions): Promise<SqlTransaction> {
|
|
39
|
+
throw new Error("@yydb/sqlite: transactions not implemented yet");
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
class SqliteDriver implements SqlDriver {
|
|
44
|
+
readonly dialect = "sqlite" as const;
|
|
45
|
+
readonly path: string;
|
|
46
|
+
|
|
47
|
+
constructor(options: SqliteDriverOptions) {
|
|
48
|
+
this.path = options.path;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async acquire(): Promise<SqlConnection> {
|
|
52
|
+
return new NotImplementedConnection();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async destroy(): Promise<void> {}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function sqlite(options: SqliteDriverOptions): SqlDriver;
|
|
59
|
+
export function sqlite(options: SqliteStudioOptions): StudioDriverRegistration;
|
|
60
|
+
export function sqlite(options: SqliteDriverOptions | SqliteStudioOptions): SqlDriver | StudioDriverRegistration {
|
|
61
|
+
if ("id" in options && options.id) {
|
|
62
|
+
return {
|
|
63
|
+
id: options.id,
|
|
64
|
+
kind: "sqlite",
|
|
65
|
+
driver: new SqliteDriver(options),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
return new SqliteDriver(options);
|
|
69
|
+
}
|
package/src/node.ts
ADDED