-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.d.ts
More file actions
208 lines (173 loc) · 6.03 KB
/
Copy pathindex.d.ts
File metadata and controls
208 lines (173 loc) · 6.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
/**
* @dolthub/doltlite — Node.js bindings for DoltLite
*
* `DatabaseSync` and `StatementSync` are intentionally compatible with the
* Node.js built-in `node:sqlite` module so existing consumers can switch by
* changing their import. Dolt-specific methods are added under `dolt*` names.
*/
/**
* Absolute path to the platform's `doltlite` CLI binary bundled in this
* package. Use it to spawn the shell (interactive or with a script piped
* via stdio). Throws if the binary isn't bundled for the current
* platform/arch.
*/
export function binPath(): string
export interface ColumnInfo {
name: string | null
column: string | null
table: string | null
database: string | null
type: string | null
}
export interface RunResult {
changes: number
lastInsertRowid: number
}
export interface MergeResult {
fast_forward: number
conflicts: number
}
export interface DoltCommit {
commit_hash: string
committer: string
committer_email: string
message: string
date: string
parents: string
}
export interface DoltBranchInfo {
name: string
hash: string
latest_committer: string
latest_committer_email: string
latest_commit_date: string
latest_commit_message: string
}
export interface DoltStatusEntry {
table_name: string
staged: number
status: string
}
export interface DoltDiffRow {
from_commit: string
from_commit_date: string
to_commit: string
to_commit_date: string
diff_type: "added" | "removed" | "modified"
[column: string]: unknown
}
export interface DoltTagInfo {
tag_name: string
tag_hash: string
tagger: string
tagger_email: string
date: string
message: string
}
export interface DatabaseSyncOptions {
/** Open the database immediately (default: true). */
open?: boolean
/** Open in read-only mode (default: false). */
readOnly?: boolean
}
export class StatementSync {
/** Execute the statement and return change metadata. */
run(...params: unknown[]): RunResult
/** Return the first result row, or undefined. */
get(...params: unknown[]): Record<string, unknown> | unknown[] | undefined
/** Return all result rows. */
all(...params: unknown[]): Array<Record<string, unknown> | unknown[]>
/** Return an iterator over result rows. */
iterate(...params: unknown[]): IterableIterator<Record<string, unknown> | unknown[]>
/** Return column metadata for the statement. */
columns(): ColumnInfo[]
/** Return result rows as arrays instead of objects. */
setReturnArrays(enabled: boolean): void
/** Return integer columns as BigInt values. */
setReadBigInts(enabled: boolean): void
/** Allow bare object keys for named parameters. */
setAllowBareNamedParameters(enabled: boolean): void
/** Ignore unknown named parameter keys. */
setAllowUnknownNamedParameters(enabled: boolean): void
/** The SQL source text of the statement. */
readonly sourceSQL: string
/** The SQL text with bound parameters expanded. */
readonly expandedSQL: string
}
export class DatabaseSync {
constructor(path: string, options?: DatabaseSyncOptions)
// ── node:sqlite-compatible API ──────────────────────────────────────────
/** Execute one or more SQL statements (no result returned). */
exec(sql: string): void
/** Compile a SQL statement for repeated execution. */
prepare(sql: string): StatementSync
/** Close the database connection. */
close(): void
/** (Re-)open the database at the given path. */
open(path: string): void
/** Return the filesystem path of the database, or null for :memory:. */
location(): string | null
/** Register a user-defined scalar SQL function. */
createFunction(name: string, fn: (...args: unknown[]) => unknown): void
/** True if the database connection is open. */
readonly isOpen: boolean
/** True if a transaction is currently active. */
readonly inTransaction: boolean
// ── Dolt version-control API ────────────────────────────────────────────
/**
* Stage all modified tables and create a commit.
* Returns the new commit hash.
*/
doltCommit(message: string): string
/**
* Create a new branch, optionally from a specific source branch.
*/
doltBranch(name: string, fromBranch?: string): void
/** Check out an existing branch. */
doltCheckout(branch: string): void
/**
* Merge a branch into HEAD.
* Returns `{fast_forward, conflicts}`.
*/
doltMerge(branch: string): MergeResult
/** Reset HEAD. Pass `"--hard"` for a hard reset. */
doltReset(flag?: "--hard"): void
/** Return the working-set status (staged/unstaged changes). */
doltStatus(): DoltStatusEntry[]
/** Return commit history, newest first. */
doltLog(options?: { limit?: number }): DoltCommit[]
/** Return all branches. */
doltBranches(): DoltBranchInfo[]
/** Return the name of the currently active branch. */
doltActiveBranch(): string
/**
* Stage a table (or all tables if no argument) for the next commit.
*/
doltAdd(table?: string): void
/**
* Return row-level diff between two refs for a given table.
*/
doltDiff(fromRef: string, toRef: string, table: string): DoltDiffRow[]
/** Return the content hash of the database at a ref (default: HEAD). */
doltHashOf(ref?: string): string
/** Return the DoltLite version string. */
doltVersion(): string
/** Create a tag at HEAD. */
doltTag(name: string): void
/** Return all tags. */
doltTags(): DoltTagInfo[]
/**
* Return the full history of rows in a table across all commits.
* Equivalent to `SELECT * FROM dolt_history_<table>`.
*/
doltHistoryOf(table: string): Record<string, unknown>[]
/**
* Return blame information for a table — which commit last modified each row.
* Equivalent to `SELECT * FROM dolt_blame_<table>`.
*/
doltBlameOf(table: string): Record<string, unknown>[]
/** Cherry-pick a commit onto HEAD. */
doltCherryPick(commitHash: string): void
/** Revert a commit (default: HEAD). */
doltRevert(ref?: string): void
}