cross-sqlite-client 0.1.0 → 0.2.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.
@@ -1,45 +0,0 @@
1
- //#region src/core/types.d.ts
2
- interface DbClient {
3
- select<T>(sql: string, params?: unknown[]): Promise<T[]>;
4
- execute(sql: string, params?: unknown[]): Promise<{
5
- lastInsertId?: number;
6
- rowsAffected?: number;
7
- }>;
8
- close(): Promise<void>;
9
- }
10
- interface DbAdapterConfig {
11
- /** 数据库文件名/标识,如 "my-app"(不含扩展名) */
12
- name: string;
13
- }
14
- interface DbAdapter {
15
- initialize(config: DbAdapterConfig): Promise<DbClient>;
16
- /**
17
- * 该适配器的每次 execute()/select() 调用是否保证落在同一条物理连接上。
18
- * web/memory 适配器是单一持久连接,为 true;Tauri 适配器底层是
19
- * sqlx::Pool<Sqlite> 连接池,不同调用可能拿到不同物理连接,为 false。
20
- * 决定了自定义 MigrationExecutor 里手写的 BEGIN/COMMIT 是否安全。
21
- */
22
- singleConnection: boolean;
23
- }
24
- interface Migration {
25
- version: number;
26
- statements: string[];
27
- }
28
- type MigrationExecutor = (db: Pick<DbClient, "execute" | "select">, migration: Migration,
29
- /** 记录 schema_version 的回调;executor 决定何时调用(比如放进自己的事务里) */
30
- recordVersion: () => Promise<void>) => Promise<void>;
31
- interface MigrationOptions {
32
- /** schema 版本表名,默认 "schema_version" */
33
- tableName?: string;
34
- /** 自定义事务包裹策略;仅能用于 adapter.singleConnection === true 的适配器 */
35
- executor?: MigrationExecutor;
36
- }
37
- interface CreateDbClientOptions {
38
- name: string;
39
- /** 必须显式传入实例,库不提供 'auto'/'web'/'tauri' 字符串快捷方式 */
40
- adapter: DbAdapter;
41
- migrations?: Migration[];
42
- migrationOptions?: MigrationOptions;
43
- }
44
- //#endregion
45
- export { Migration as a, DbClient as i, DbAdapter as n, MigrationExecutor as o, DbAdapterConfig as r, MigrationOptions as s, CreateDbClientOptions as t };