@solidrt/flux-types 0.0.5 → 0.0.7
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/index.d.ts +54 -18
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
declare global {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
let Flux: {
|
|
3
|
+
on(event: string, callback: (data: any) => void): () => void
|
|
4
|
+
once(event: string, callback: (data: any) => void): () => void
|
|
5
5
|
}
|
|
6
|
+
}
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
declare module "flux:fs" {
|
|
9
|
+
type DirEntry = {
|
|
10
|
+
name: string
|
|
11
|
+
type: "file" | "directory" | "symlink" | "other"
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
type
|
|
14
|
+
type FileStat = {
|
|
14
15
|
size: number
|
|
15
16
|
type: string
|
|
16
17
|
mtime?: number
|
|
@@ -22,20 +23,55 @@ declare global {
|
|
|
22
23
|
bytes(): Promise<Uint8Array>
|
|
23
24
|
json(): Promise<any>
|
|
24
25
|
exists(): Promise<boolean>
|
|
25
|
-
stat(): Promise<
|
|
26
|
+
stat(): Promise<FileStat>
|
|
27
|
+
write(data: string | Uint8Array): Promise<void>
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
type FluxDir = {
|
|
31
|
+
path: string
|
|
32
|
+
entries(): Promise<DirEntry[]>
|
|
33
|
+
exists(): Promise<boolean>
|
|
26
34
|
}
|
|
27
35
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
36
|
+
export function file(path: string): FluxFile
|
|
37
|
+
export function dir(path: string): FluxDir
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
declare module "flux:sqlite" {
|
|
41
|
+
// Values accepted as bound parameters. booleans bind as 0/1.
|
|
42
|
+
type SqlParam = null | boolean | number | string | Uint8Array
|
|
43
|
+
// Values returned in result rows. BLOB comes back as Uint8Array.
|
|
44
|
+
type SqlValue = null | number | string | Uint8Array
|
|
45
|
+
type Row = Record<string, SqlValue>
|
|
46
|
+
|
|
47
|
+
// The outcome of a write.
|
|
48
|
+
type RunResult = { changes: number; lastInsertRowid: number }
|
|
49
|
+
|
|
50
|
+
// A reusable prepared statement. Created with db.query(sql); its executions
|
|
51
|
+
// reuse the compiled statement (cached on the connection).
|
|
52
|
+
export class Statement {
|
|
53
|
+
all(params?: SqlParam[]): Promise<Row[]>
|
|
54
|
+
get(params?: SqlParam[]): Promise<Row | undefined>
|
|
55
|
+
run(params?: SqlParam[]): Promise<RunResult>
|
|
31
56
|
}
|
|
32
57
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
58
|
+
// Open mode: "ro" (default, read-only, must exist), "rw" (read-write, must
|
|
59
|
+
// exist), "rw+" (read-write, create if missing).
|
|
60
|
+
type OpenMode = "ro" | "rw" | "rw+"
|
|
61
|
+
|
|
62
|
+
export class Database {
|
|
63
|
+
static connect(path: string, mode?: OpenMode): Promise<Database>
|
|
64
|
+
// Create a reusable prepared statement (synchronous; compiles on first run).
|
|
65
|
+
query(sql: string): Statement
|
|
66
|
+
// One-shot write; uses plain prepare (no caching).
|
|
67
|
+
run(sql: string, params?: SqlParam[]): Promise<RunResult>
|
|
68
|
+
// Run a multi-statement script (no params), e.g. schema setup / migrations.
|
|
69
|
+
exec(sql: string): Promise<void>
|
|
70
|
+
// Run a batch of [sql, params] statements in one transaction (BEGIN/COMMIT,
|
|
71
|
+
// ROLLBACK on any error). Resolves to one result per statement. Statements
|
|
72
|
+
// must be writes/DDL. Cannot branch on intermediate results.
|
|
73
|
+
transaction(statements: [string, SqlParam[]?][]): Promise<RunResult[]>
|
|
74
|
+
close(): Promise<void>
|
|
39
75
|
}
|
|
40
76
|
}
|
|
41
77
|
|