get-db9 0.4.1 → 0.6.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 +244 -2
- package/dist/client-B3NUYqOc.d.cts +643 -0
- package/dist/client-B3NUYqOc.d.ts +643 -0
- package/dist/client.cjs +567 -190
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.js +567 -190
- package/dist/client.js.map +1 -1
- package/dist/index.cjs +575 -191
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +573 -191
- package/dist/index.js.map +1 -1
- package/package.json +8 -5
- package/dist/client-CXv2ZlbR.d.cts +0 -429
- package/dist/client-CXv2ZlbR.d.ts +0 -429
|
@@ -0,0 +1,643 @@
|
|
|
1
|
+
type FetchFn = typeof globalThis.fetch;
|
|
2
|
+
type BodyInit = string | Blob | ArrayBuffer | FormData | URLSearchParams | ReadableStream<Uint8Array>;
|
|
3
|
+
interface HttpClientOptions {
|
|
4
|
+
baseUrl: string;
|
|
5
|
+
fetch?: FetchFn;
|
|
6
|
+
headers?: Record<string, string>;
|
|
7
|
+
timeout?: number;
|
|
8
|
+
maxRetries?: number;
|
|
9
|
+
retryDelay?: number;
|
|
10
|
+
}
|
|
11
|
+
interface HttpClient {
|
|
12
|
+
get<T>(path: string, params?: Record<string, string | undefined>): Promise<T>;
|
|
13
|
+
post<T>(path: string, body?: unknown): Promise<T>;
|
|
14
|
+
put<T>(path: string, body?: unknown): Promise<T>;
|
|
15
|
+
del<T>(path: string): Promise<T>;
|
|
16
|
+
getRaw(path: string, params?: Record<string, string | undefined>): Promise<Response>;
|
|
17
|
+
putRaw(path: string, body: BodyInit, headers?: Record<string, string>): Promise<Response>;
|
|
18
|
+
postRaw(path: string, body?: BodyInit, headers?: Record<string, string>): Promise<Response>;
|
|
19
|
+
delRaw(path: string, params?: Record<string, string | undefined>): Promise<Response>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Credential fields stored in `~/.db9/credentials` (TOML). */
|
|
23
|
+
interface Credentials {
|
|
24
|
+
token: string;
|
|
25
|
+
is_anonymous?: boolean;
|
|
26
|
+
anonymous_id?: string;
|
|
27
|
+
anonymous_secret?: string;
|
|
28
|
+
}
|
|
29
|
+
/** Async credential persistence abstraction. */
|
|
30
|
+
interface CredentialStore {
|
|
31
|
+
load(): Promise<Credentials | null>;
|
|
32
|
+
save(credentials: Credentials): Promise<void>;
|
|
33
|
+
clear(): Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
declare class FileCredentialStore implements CredentialStore {
|
|
36
|
+
private readonly customPath;
|
|
37
|
+
/**
|
|
38
|
+
* @param path — Override the credential file location.
|
|
39
|
+
* Defaults to `~/.db9/credentials` (resolved lazily).
|
|
40
|
+
*/
|
|
41
|
+
constructor(path?: string);
|
|
42
|
+
/** Resolve the credential file path (lazy to avoid top-level `os` import). */
|
|
43
|
+
private resolvePath;
|
|
44
|
+
load(): Promise<Credentials | null>;
|
|
45
|
+
save(credentials: Credentials): Promise<void>;
|
|
46
|
+
clear(): Promise<void>;
|
|
47
|
+
}
|
|
48
|
+
declare class MemoryCredentialStore implements CredentialStore {
|
|
49
|
+
private credentials;
|
|
50
|
+
load(): Promise<Credentials | null>;
|
|
51
|
+
save(credentials: Credentials): Promise<void>;
|
|
52
|
+
clear(): Promise<void>;
|
|
53
|
+
}
|
|
54
|
+
/** Returns a FileCredentialStore with the default path (`~/.db9/credentials`). */
|
|
55
|
+
declare function defaultCredentialStore(): CredentialStore;
|
|
56
|
+
|
|
57
|
+
/** File or directory metadata returned by `stat` and `readdir`. */
|
|
58
|
+
interface FileInfo {
|
|
59
|
+
path: string;
|
|
60
|
+
type: 'file' | 'dir';
|
|
61
|
+
size: number;
|
|
62
|
+
mode: number;
|
|
63
|
+
mtime: string;
|
|
64
|
+
}
|
|
65
|
+
/** Options for listing directory contents. */
|
|
66
|
+
interface FsListOptions {
|
|
67
|
+
recursive?: boolean;
|
|
68
|
+
}
|
|
69
|
+
/** Options for removing files/directories. */
|
|
70
|
+
interface FsRemoveOptions {
|
|
71
|
+
recursive?: boolean;
|
|
72
|
+
}
|
|
73
|
+
/** Base shape for all WS requests. */
|
|
74
|
+
interface FsWsRequest {
|
|
75
|
+
id: string;
|
|
76
|
+
op: string;
|
|
77
|
+
[key: string]: unknown;
|
|
78
|
+
}
|
|
79
|
+
/** Successful WS response. */
|
|
80
|
+
interface FsWsResponse {
|
|
81
|
+
id: string;
|
|
82
|
+
ok: boolean;
|
|
83
|
+
data?: unknown;
|
|
84
|
+
error?: FsWsError;
|
|
85
|
+
}
|
|
86
|
+
/** Error detail from a failed WS response. */
|
|
87
|
+
interface FsWsError {
|
|
88
|
+
code: string;
|
|
89
|
+
message: string;
|
|
90
|
+
}
|
|
91
|
+
/** Auth response data. */
|
|
92
|
+
interface FsAuthInfo {
|
|
93
|
+
user: string;
|
|
94
|
+
tenant: string;
|
|
95
|
+
keyspace: string;
|
|
96
|
+
}
|
|
97
|
+
/** Options for connecting to the fs9 WebSocket server. */
|
|
98
|
+
interface FsConnectOptions {
|
|
99
|
+
/** WebSocket URL (e.g. `wss://host:5480`). */
|
|
100
|
+
wsUrl: string;
|
|
101
|
+
/** Username in `{tenant_id}.{admin_user}` format. */
|
|
102
|
+
username: string;
|
|
103
|
+
/** Admin password. */
|
|
104
|
+
password: string;
|
|
105
|
+
}
|
|
106
|
+
/** @deprecated Use `FileInfo` instead. */
|
|
107
|
+
type Fs9FileEntry = FileInfo;
|
|
108
|
+
/** @deprecated Use `FsListOptions` instead. */
|
|
109
|
+
type Fs9ListOptions = FsListOptions;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* WebSocket client for the fs9 filesystem protocol.
|
|
113
|
+
*
|
|
114
|
+
* Mirrors db9-cli/src/fssh/client.rs — each public method maps to a single
|
|
115
|
+
* request–response round-trip over a JSON text WebSocket.
|
|
116
|
+
*
|
|
117
|
+
* The client is environment-agnostic: pass any W3C-compatible WebSocket
|
|
118
|
+
* constructor (native `WebSocket` in browsers/Deno/Bun/Node 21+, or the
|
|
119
|
+
* `ws` npm package for Node 18–20).
|
|
120
|
+
*/
|
|
121
|
+
|
|
122
|
+
/** Minimal W3C WebSocket interface we depend on. */
|
|
123
|
+
interface WebSocketLike {
|
|
124
|
+
readonly readyState: number;
|
|
125
|
+
send(data: string): void;
|
|
126
|
+
close(code?: number, reason?: string): void;
|
|
127
|
+
onopen: ((ev: unknown) => void) | null;
|
|
128
|
+
onclose: ((ev: unknown) => void) | null;
|
|
129
|
+
onerror: ((ev: unknown) => void) | null;
|
|
130
|
+
onmessage: ((ev: {
|
|
131
|
+
data: unknown;
|
|
132
|
+
}) => void) | null;
|
|
133
|
+
}
|
|
134
|
+
/** Constructor for a W3C-compatible WebSocket. */
|
|
135
|
+
type WebSocketConstructor = new (url: string) => WebSocketLike;
|
|
136
|
+
/** Error from an fs9 WebSocket operation. */
|
|
137
|
+
declare class FsError extends Error {
|
|
138
|
+
readonly code: string;
|
|
139
|
+
constructor(code: string, message: string);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Async WebSocket client for fs9 file operations.
|
|
143
|
+
*
|
|
144
|
+
* Usage:
|
|
145
|
+
* ```ts
|
|
146
|
+
* const client = await FsClient.connect('wss://host:5480', WebSocket);
|
|
147
|
+
* await client.authenticate('tenant.admin', 'password');
|
|
148
|
+
* const entries = await client.readdir('/');
|
|
149
|
+
* await client.close();
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
declare class FsClient {
|
|
153
|
+
private ws;
|
|
154
|
+
private pending;
|
|
155
|
+
private closed;
|
|
156
|
+
private constructor();
|
|
157
|
+
/**
|
|
158
|
+
* Connect to an fs9 WebSocket server.
|
|
159
|
+
*
|
|
160
|
+
* @param url WebSocket URL, e.g. `wss://host:5480`
|
|
161
|
+
* @param WS WebSocket constructor (native or from `ws` package)
|
|
162
|
+
*/
|
|
163
|
+
static connect(url: string, WS: WebSocketConstructor): Promise<FsClient>;
|
|
164
|
+
/** Authenticate with the server. Must be called first after connect. */
|
|
165
|
+
authenticate(username: string, password: string): Promise<FsAuthInfo>;
|
|
166
|
+
/** Get file or directory metadata. */
|
|
167
|
+
stat(path: string): Promise<FileInfo>;
|
|
168
|
+
/** List directory contents. */
|
|
169
|
+
readdir(path: string): Promise<FileInfo[]>;
|
|
170
|
+
/** Create a directory. Always recursive (mkdir -p). */
|
|
171
|
+
mkdir(path: string, recursive?: boolean): Promise<void>;
|
|
172
|
+
/** Read an entire file, returning raw bytes. */
|
|
173
|
+
readFile(path: string): Promise<Uint8Array>;
|
|
174
|
+
/** Write (overwrite) a file. Returns bytes written. */
|
|
175
|
+
writeFile(path: string, data: Uint8Array | ArrayBuffer | string): Promise<number>;
|
|
176
|
+
/** Append to a file. Returns bytes written. */
|
|
177
|
+
appendFile(path: string, data: Uint8Array | ArrayBuffer | string): Promise<number>;
|
|
178
|
+
/** Remove a file (non-recursive) or directory (recursive). */
|
|
179
|
+
rm(path: string, recursive?: boolean): Promise<void>;
|
|
180
|
+
/** Rename (move) a file or directory. */
|
|
181
|
+
rename(oldPath: string, newPath: string): Promise<void>;
|
|
182
|
+
/** Gracefully close the WebSocket connection. */
|
|
183
|
+
close(): Promise<void>;
|
|
184
|
+
private sendAndRecv;
|
|
185
|
+
private expectOk;
|
|
186
|
+
private errorMessage;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
interface Endpoint {
|
|
190
|
+
host: string;
|
|
191
|
+
port: number;
|
|
192
|
+
type: string;
|
|
193
|
+
region?: string;
|
|
194
|
+
priority: number;
|
|
195
|
+
description?: string;
|
|
196
|
+
enabled: boolean;
|
|
197
|
+
}
|
|
198
|
+
interface MessageResponse {
|
|
199
|
+
message: string;
|
|
200
|
+
}
|
|
201
|
+
interface HealthResponse {
|
|
202
|
+
status: string;
|
|
203
|
+
pd_healthy: boolean;
|
|
204
|
+
}
|
|
205
|
+
interface ColumnInfo {
|
|
206
|
+
name: string;
|
|
207
|
+
type: string;
|
|
208
|
+
}
|
|
209
|
+
interface SqlErrorDetail {
|
|
210
|
+
message: string;
|
|
211
|
+
code?: string;
|
|
212
|
+
position?: number;
|
|
213
|
+
hint?: string;
|
|
214
|
+
detail?: string;
|
|
215
|
+
}
|
|
216
|
+
interface SqlResult {
|
|
217
|
+
columns: ColumnInfo[];
|
|
218
|
+
rows: unknown[][];
|
|
219
|
+
row_count: number;
|
|
220
|
+
command: string;
|
|
221
|
+
error?: string | SqlErrorDetail;
|
|
222
|
+
}
|
|
223
|
+
interface CreateTenantRequest {
|
|
224
|
+
admin_user?: string;
|
|
225
|
+
admin_password?: string;
|
|
226
|
+
}
|
|
227
|
+
interface TenantConnectRequest {
|
|
228
|
+
admin_user: string;
|
|
229
|
+
admin_password: string;
|
|
230
|
+
}
|
|
231
|
+
interface TenantUpdateRequest {
|
|
232
|
+
notes?: string;
|
|
233
|
+
tags?: string[];
|
|
234
|
+
}
|
|
235
|
+
interface AdminCreateUserRequest {
|
|
236
|
+
username: string;
|
|
237
|
+
password?: string;
|
|
238
|
+
superuser?: boolean;
|
|
239
|
+
}
|
|
240
|
+
interface SqlQueryRequest {
|
|
241
|
+
sql: string;
|
|
242
|
+
}
|
|
243
|
+
interface ListTenantsParams {
|
|
244
|
+
page?: number;
|
|
245
|
+
size?: number;
|
|
246
|
+
state?: string;
|
|
247
|
+
q?: string;
|
|
248
|
+
cursor?: string;
|
|
249
|
+
tag?: string;
|
|
250
|
+
}
|
|
251
|
+
interface BatchCreateRequest {
|
|
252
|
+
count: number;
|
|
253
|
+
admin_user?: string;
|
|
254
|
+
admin_password?: string;
|
|
255
|
+
}
|
|
256
|
+
interface BatchDeleteRequest {
|
|
257
|
+
ids: string[];
|
|
258
|
+
}
|
|
259
|
+
interface BatchUpdateRequest {
|
|
260
|
+
ids: string[];
|
|
261
|
+
notes?: string;
|
|
262
|
+
tags?: string[];
|
|
263
|
+
}
|
|
264
|
+
interface AuditLogParams {
|
|
265
|
+
tenant_id?: string;
|
|
266
|
+
operation_type?: string;
|
|
267
|
+
resource_type?: string;
|
|
268
|
+
success?: boolean;
|
|
269
|
+
limit?: number;
|
|
270
|
+
offset?: number;
|
|
271
|
+
}
|
|
272
|
+
interface TenantResponse {
|
|
273
|
+
id: string;
|
|
274
|
+
state: string;
|
|
275
|
+
created_at?: string;
|
|
276
|
+
created_by?: string;
|
|
277
|
+
notes?: string;
|
|
278
|
+
tags?: string[];
|
|
279
|
+
updated_at?: string;
|
|
280
|
+
state_reason?: string;
|
|
281
|
+
endpoints?: Endpoint[];
|
|
282
|
+
}
|
|
283
|
+
interface TenantListResponse {
|
|
284
|
+
items: TenantResponse[];
|
|
285
|
+
total: number;
|
|
286
|
+
page: number;
|
|
287
|
+
size: number;
|
|
288
|
+
next_cursor?: string;
|
|
289
|
+
}
|
|
290
|
+
interface CreateTenantResponse {
|
|
291
|
+
id: string;
|
|
292
|
+
admin_user: string;
|
|
293
|
+
admin_password: string;
|
|
294
|
+
connection_string: string;
|
|
295
|
+
created_at: string;
|
|
296
|
+
}
|
|
297
|
+
interface TenantConnectResponse {
|
|
298
|
+
session_id: string;
|
|
299
|
+
expires_at: string;
|
|
300
|
+
}
|
|
301
|
+
interface BatchCreateResponse {
|
|
302
|
+
created: CreateTenantResponse[];
|
|
303
|
+
failed: BatchItemError[];
|
|
304
|
+
total_requested: number;
|
|
305
|
+
total_created: number;
|
|
306
|
+
}
|
|
307
|
+
interface BatchDeleteResponse {
|
|
308
|
+
deleted: string[];
|
|
309
|
+
failed: BatchItemError[];
|
|
310
|
+
}
|
|
311
|
+
interface BatchUpdateResponse {
|
|
312
|
+
updated: string[];
|
|
313
|
+
failed: BatchItemError[];
|
|
314
|
+
}
|
|
315
|
+
interface BatchItemError {
|
|
316
|
+
id: string;
|
|
317
|
+
error: string;
|
|
318
|
+
}
|
|
319
|
+
interface UserResponse {
|
|
320
|
+
name: string;
|
|
321
|
+
is_superuser: boolean;
|
|
322
|
+
can_login: boolean;
|
|
323
|
+
can_create_db: boolean;
|
|
324
|
+
can_create_role: boolean;
|
|
325
|
+
}
|
|
326
|
+
interface UserCreateResponse {
|
|
327
|
+
username: string;
|
|
328
|
+
password: string;
|
|
329
|
+
connection: string;
|
|
330
|
+
}
|
|
331
|
+
interface PasswordResetResponse {
|
|
332
|
+
username: string;
|
|
333
|
+
password: string;
|
|
334
|
+
}
|
|
335
|
+
interface SqlQueryResponse {
|
|
336
|
+
success: boolean;
|
|
337
|
+
result?: string;
|
|
338
|
+
error?: string;
|
|
339
|
+
}
|
|
340
|
+
interface AuditLogResponse {
|
|
341
|
+
id: string;
|
|
342
|
+
timestamp: string;
|
|
343
|
+
operation_type: string;
|
|
344
|
+
resource_type: string;
|
|
345
|
+
resource_name: string;
|
|
346
|
+
tenant_id?: string;
|
|
347
|
+
operator?: string;
|
|
348
|
+
success: boolean;
|
|
349
|
+
error_message?: string;
|
|
350
|
+
extra_metadata?: unknown;
|
|
351
|
+
}
|
|
352
|
+
interface ObservabilitySummary {
|
|
353
|
+
window_seconds: number;
|
|
354
|
+
statement_count: number;
|
|
355
|
+
txn_commit_count: number;
|
|
356
|
+
error_count: number;
|
|
357
|
+
qps: number;
|
|
358
|
+
tps: number;
|
|
359
|
+
latency_avg_ms: number;
|
|
360
|
+
latency_p99_ms: number;
|
|
361
|
+
active_connections: number;
|
|
362
|
+
}
|
|
363
|
+
interface QuerySample {
|
|
364
|
+
query: string;
|
|
365
|
+
sample_count: number;
|
|
366
|
+
error_count: number;
|
|
367
|
+
latency_avg_ms: number;
|
|
368
|
+
latency_p99_ms: number;
|
|
369
|
+
latency_max_ms: number;
|
|
370
|
+
last_seen_ms_ago: number;
|
|
371
|
+
}
|
|
372
|
+
interface TenantObservabilityResponse {
|
|
373
|
+
summary: ObservabilitySummary;
|
|
374
|
+
samples: QuerySample[];
|
|
375
|
+
}
|
|
376
|
+
interface RegisterRequest {
|
|
377
|
+
email: string;
|
|
378
|
+
password: string;
|
|
379
|
+
}
|
|
380
|
+
interface LoginRequest {
|
|
381
|
+
email: string;
|
|
382
|
+
password: string;
|
|
383
|
+
}
|
|
384
|
+
interface CreateDatabaseRequest {
|
|
385
|
+
name: string;
|
|
386
|
+
region?: string;
|
|
387
|
+
admin_password?: string;
|
|
388
|
+
}
|
|
389
|
+
interface SqlExecuteRequest {
|
|
390
|
+
query?: string;
|
|
391
|
+
file_content?: string;
|
|
392
|
+
}
|
|
393
|
+
interface DumpRequest {
|
|
394
|
+
ddl_only?: boolean;
|
|
395
|
+
}
|
|
396
|
+
interface MigrationApplyRequest {
|
|
397
|
+
name: string;
|
|
398
|
+
sql: string;
|
|
399
|
+
checksum: string;
|
|
400
|
+
}
|
|
401
|
+
interface BranchRequest {
|
|
402
|
+
name: string;
|
|
403
|
+
}
|
|
404
|
+
interface ClaimRequest {
|
|
405
|
+
email: string;
|
|
406
|
+
password: string;
|
|
407
|
+
}
|
|
408
|
+
interface AnonymousRefreshRequest {
|
|
409
|
+
anonymous_id: string;
|
|
410
|
+
anonymous_secret: string;
|
|
411
|
+
}
|
|
412
|
+
interface CreateUserRequest {
|
|
413
|
+
username: string;
|
|
414
|
+
password: string;
|
|
415
|
+
}
|
|
416
|
+
interface CreateTokenRequest {
|
|
417
|
+
name?: string;
|
|
418
|
+
expires_in_days?: number;
|
|
419
|
+
}
|
|
420
|
+
interface CustomerResponse {
|
|
421
|
+
id: string;
|
|
422
|
+
email: string;
|
|
423
|
+
created_at: string;
|
|
424
|
+
status: string;
|
|
425
|
+
}
|
|
426
|
+
interface LoginResponse {
|
|
427
|
+
token: string;
|
|
428
|
+
expires_at: string;
|
|
429
|
+
}
|
|
430
|
+
interface AnonymousRegisterResponse {
|
|
431
|
+
token: string;
|
|
432
|
+
expires_at: string;
|
|
433
|
+
is_anonymous: boolean;
|
|
434
|
+
anonymous_id: string;
|
|
435
|
+
anonymous_secret: string;
|
|
436
|
+
}
|
|
437
|
+
interface AnonymousRefreshResponse {
|
|
438
|
+
token: string;
|
|
439
|
+
expires_at: string;
|
|
440
|
+
}
|
|
441
|
+
interface AnonymousSecretResponse {
|
|
442
|
+
anonymous_id: string;
|
|
443
|
+
anonymous_secret: string;
|
|
444
|
+
}
|
|
445
|
+
interface ClaimResponse {
|
|
446
|
+
id: string;
|
|
447
|
+
email: string;
|
|
448
|
+
claimed: boolean;
|
|
449
|
+
}
|
|
450
|
+
interface DatabaseResponse {
|
|
451
|
+
id: string;
|
|
452
|
+
name: string;
|
|
453
|
+
state: string;
|
|
454
|
+
region?: string;
|
|
455
|
+
endpoints?: Endpoint[];
|
|
456
|
+
admin_user?: string;
|
|
457
|
+
admin_password?: string;
|
|
458
|
+
created_at: string;
|
|
459
|
+
connection_string?: string;
|
|
460
|
+
}
|
|
461
|
+
interface CustomerPasswordResetResponse {
|
|
462
|
+
admin_user: string;
|
|
463
|
+
admin_password: string;
|
|
464
|
+
connection_string: string;
|
|
465
|
+
}
|
|
466
|
+
interface TokenResponse {
|
|
467
|
+
id: string;
|
|
468
|
+
name: string;
|
|
469
|
+
created_at: string;
|
|
470
|
+
expires_at?: string;
|
|
471
|
+
}
|
|
472
|
+
interface CreateTokenResponse {
|
|
473
|
+
id: string;
|
|
474
|
+
name: string;
|
|
475
|
+
token: string;
|
|
476
|
+
expires_at?: string;
|
|
477
|
+
created_at: string;
|
|
478
|
+
}
|
|
479
|
+
interface DumpResponse {
|
|
480
|
+
sql: string;
|
|
481
|
+
object_count: number;
|
|
482
|
+
}
|
|
483
|
+
interface SchemaResponse {
|
|
484
|
+
tables: TableMetadata[];
|
|
485
|
+
views: ViewMetadata[];
|
|
486
|
+
}
|
|
487
|
+
interface TableMetadata {
|
|
488
|
+
name: string;
|
|
489
|
+
schema: string;
|
|
490
|
+
columns: ColumnMetadata[];
|
|
491
|
+
}
|
|
492
|
+
interface ColumnMetadata {
|
|
493
|
+
name: string;
|
|
494
|
+
type: string;
|
|
495
|
+
nullable: boolean;
|
|
496
|
+
default_value?: string;
|
|
497
|
+
}
|
|
498
|
+
interface ViewMetadata {
|
|
499
|
+
name: string;
|
|
500
|
+
schema: string;
|
|
501
|
+
}
|
|
502
|
+
interface MigrationApplyResponse {
|
|
503
|
+
status: string;
|
|
504
|
+
name: string;
|
|
505
|
+
}
|
|
506
|
+
interface MigrationMetadata {
|
|
507
|
+
name: string;
|
|
508
|
+
checksum: string;
|
|
509
|
+
applied_at: string;
|
|
510
|
+
sql_preview: string;
|
|
511
|
+
}
|
|
512
|
+
/** @deprecated Fs9 events are not available in the WebSocket protocol. */
|
|
513
|
+
interface Fs9EventEntry {
|
|
514
|
+
id: string;
|
|
515
|
+
type: string;
|
|
516
|
+
path: string;
|
|
517
|
+
timestamp: string;
|
|
518
|
+
user_id?: string;
|
|
519
|
+
size?: number;
|
|
520
|
+
metadata?: Record<string, unknown>;
|
|
521
|
+
}
|
|
522
|
+
/** @deprecated Fs9 events are not available in the WebSocket protocol. */
|
|
523
|
+
interface Fs9EventOptions {
|
|
524
|
+
limit?: number;
|
|
525
|
+
offset?: number;
|
|
526
|
+
path?: string;
|
|
527
|
+
type?: string;
|
|
528
|
+
}
|
|
529
|
+
interface DeviceCodeResponse {
|
|
530
|
+
device_code: string;
|
|
531
|
+
user_code: string;
|
|
532
|
+
verification_uri: string;
|
|
533
|
+
expires_in: number;
|
|
534
|
+
interval: number;
|
|
535
|
+
}
|
|
536
|
+
interface DeviceTokenRequest {
|
|
537
|
+
device_code: string;
|
|
538
|
+
}
|
|
539
|
+
interface DeviceTokenResponse {
|
|
540
|
+
token: string;
|
|
541
|
+
expires_at: string;
|
|
542
|
+
}
|
|
543
|
+
interface DeviceTokenErrorResponse {
|
|
544
|
+
error: 'authorization_pending' | 'expired_token' | 'access_denied';
|
|
545
|
+
}
|
|
546
|
+
interface DeviceVerifyRequest {
|
|
547
|
+
user_code: string;
|
|
548
|
+
email: string;
|
|
549
|
+
password: string;
|
|
550
|
+
}
|
|
551
|
+
type TenantState = 'CREATING' | 'ACTIVE' | 'DISABLING' | 'DISABLED' | 'CREATE_FAILED';
|
|
552
|
+
|
|
553
|
+
interface Db9ClientOptions {
|
|
554
|
+
baseUrl?: string;
|
|
555
|
+
token?: string;
|
|
556
|
+
fetch?: FetchFn;
|
|
557
|
+
credentialStore?: CredentialStore;
|
|
558
|
+
timeout?: number;
|
|
559
|
+
maxRetries?: number;
|
|
560
|
+
retryDelay?: number;
|
|
561
|
+
/** WebSocket constructor for fs operations (native WebSocket, or `ws` package for Node 18–20). */
|
|
562
|
+
WebSocket?: WebSocketConstructor;
|
|
563
|
+
/** WebSocket port for fs9 server (default: 5480). */
|
|
564
|
+
wsPort?: number;
|
|
565
|
+
}
|
|
566
|
+
declare function createDb9Client(options?: Db9ClientOptions): {
|
|
567
|
+
auth: {
|
|
568
|
+
register: (req: RegisterRequest) => Promise<CustomerResponse>;
|
|
569
|
+
login: (req: LoginRequest) => Promise<LoginResponse>;
|
|
570
|
+
anonymousRegister: () => Promise<AnonymousRegisterResponse>;
|
|
571
|
+
anonymousRefresh: (req: AnonymousRefreshRequest) => Promise<AnonymousRefreshResponse>;
|
|
572
|
+
me: () => Promise<CustomerResponse>;
|
|
573
|
+
getAnonymousSecret: () => Promise<AnonymousSecretResponse>;
|
|
574
|
+
claim: (req: ClaimRequest) => Promise<ClaimResponse>;
|
|
575
|
+
ensureAnonymousSecret: () => Promise<void>;
|
|
576
|
+
};
|
|
577
|
+
tokens: {
|
|
578
|
+
list: () => Promise<TokenResponse[]>;
|
|
579
|
+
revoke: (tokenId: string) => Promise<MessageResponse>;
|
|
580
|
+
create: (req: CreateTokenRequest) => Promise<CreateTokenResponse>;
|
|
581
|
+
};
|
|
582
|
+
databases: {
|
|
583
|
+
create: (req: CreateDatabaseRequest) => Promise<DatabaseResponse>;
|
|
584
|
+
list: () => Promise<DatabaseResponse[]>;
|
|
585
|
+
get: (databaseId: string) => Promise<DatabaseResponse>;
|
|
586
|
+
delete: (databaseId: string) => Promise<MessageResponse>;
|
|
587
|
+
resetPassword: (databaseId: string) => Promise<CustomerPasswordResetResponse>;
|
|
588
|
+
credentials: (databaseId: string) => Promise<CustomerPasswordResetResponse>;
|
|
589
|
+
observability: (databaseId: string) => Promise<TenantObservabilityResponse>;
|
|
590
|
+
sql: (databaseId: string, query: string) => Promise<SqlResult>;
|
|
591
|
+
sqlFile: (databaseId: string, fileContent: string) => Promise<SqlResult>;
|
|
592
|
+
schema: (databaseId: string) => Promise<SchemaResponse>;
|
|
593
|
+
dump: (databaseId: string, req?: DumpRequest) => Promise<DumpResponse>;
|
|
594
|
+
applyMigration: (databaseId: string, req: MigrationApplyRequest) => Promise<MigrationApplyResponse>;
|
|
595
|
+
listMigrations: (databaseId: string) => Promise<MigrationMetadata[]>;
|
|
596
|
+
branch: (databaseId: string, req: BranchRequest) => Promise<DatabaseResponse>;
|
|
597
|
+
users: {
|
|
598
|
+
list: (databaseId: string) => Promise<UserResponse[]>;
|
|
599
|
+
create: (databaseId: string, req: CreateUserRequest) => Promise<MessageResponse>;
|
|
600
|
+
delete: (databaseId: string, username: string) => Promise<MessageResponse>;
|
|
601
|
+
};
|
|
602
|
+
};
|
|
603
|
+
fs: {
|
|
604
|
+
/**
|
|
605
|
+
* Open a persistent WebSocket connection for multiple fs operations.
|
|
606
|
+
* Caller is responsible for calling `client.close()` when done.
|
|
607
|
+
*/
|
|
608
|
+
connect: (dbId: string) => Promise<FsClient>;
|
|
609
|
+
/** List directory contents. */
|
|
610
|
+
list: (dbId: string, path: string) => Promise<FileInfo[]>;
|
|
611
|
+
/** Read a file as text (UTF-8). */
|
|
612
|
+
read: (dbId: string, path: string) => Promise<string>;
|
|
613
|
+
/** Read a file as raw bytes. */
|
|
614
|
+
readBinary: (dbId: string, path: string) => Promise<Uint8Array>;
|
|
615
|
+
/** Write (overwrite) a file. Accepts string, ArrayBuffer, or Uint8Array. */
|
|
616
|
+
write: (dbId: string, path: string, content: string | ArrayBuffer | Uint8Array) => Promise<void>;
|
|
617
|
+
/** Append to a file. Returns bytes written. */
|
|
618
|
+
append: (dbId: string, path: string, content: string | ArrayBuffer | Uint8Array) => Promise<number>;
|
|
619
|
+
/** Get file or directory metadata. */
|
|
620
|
+
stat: (dbId: string, path: string) => Promise<FileInfo>;
|
|
621
|
+
/** Check if a file or directory exists. */
|
|
622
|
+
exists: (dbId: string, path: string) => Promise<boolean>;
|
|
623
|
+
/** Create a directory (recursive by default). */
|
|
624
|
+
mkdir: (dbId: string, path: string) => Promise<void>;
|
|
625
|
+
/** Remove a file or directory. */
|
|
626
|
+
remove: (dbId: string, path: string, opts?: {
|
|
627
|
+
recursive?: boolean;
|
|
628
|
+
}) => Promise<void>;
|
|
629
|
+
/** Rename (move) a file or directory. */
|
|
630
|
+
rename: (dbId: string, oldPath: string, newPath: string) => Promise<void>;
|
|
631
|
+
};
|
|
632
|
+
deviceAuth: {
|
|
633
|
+
/** Start device code flow. Returns codes for user to authorize. */
|
|
634
|
+
createDeviceCode: () => Promise<DeviceCodeResponse>;
|
|
635
|
+
/** Poll for device token after user authorizes. Returns token or error status. */
|
|
636
|
+
pollDeviceToken: (req: DeviceTokenRequest) => Promise<DeviceTokenResponse | DeviceTokenErrorResponse>;
|
|
637
|
+
/** Submit device verification with user credentials. */
|
|
638
|
+
verifyDevice: (req: DeviceVerifyRequest) => Promise<MessageResponse>;
|
|
639
|
+
};
|
|
640
|
+
};
|
|
641
|
+
type Db9Client = ReturnType<typeof createDb9Client>;
|
|
642
|
+
|
|
643
|
+
export { type FsWsError as $, type AdminCreateUserRequest as A, type BatchCreateRequest as B, type CredentialStore as C, type DatabaseResponse as D, type Db9Client as E, type FetchFn as F, type Db9ClientOptions as G, type DeviceCodeResponse as H, type DeviceTokenErrorResponse as I, type DeviceTokenRequest as J, type DeviceTokenResponse as K, type DeviceVerifyRequest as L, type DumpRequest as M, type DumpResponse as N, type Endpoint as O, FileCredentialStore as P, type FileInfo as Q, type Fs9EventEntry as R, type Fs9EventOptions as S, type Fs9FileEntry as T, type Fs9ListOptions as U, type FsAuthInfo as V, FsClient as W, type FsConnectOptions as X, FsError as Y, type FsListOptions as Z, type FsRemoveOptions as _, type AnonymousRefreshRequest as a, type FsWsRequest as a0, type FsWsResponse as a1, type HealthResponse as a2, type HttpClient as a3, type HttpClientOptions as a4, type ListTenantsParams as a5, type LoginRequest as a6, type LoginResponse as a7, MemoryCredentialStore as a8, type MessageResponse as a9, type WebSocketLike as aA, createDb9Client as aB, defaultCredentialStore as aC, type MigrationApplyRequest as aa, type MigrationApplyResponse as ab, type MigrationMetadata as ac, type ObservabilitySummary as ad, type PasswordResetResponse as ae, type QuerySample as af, type RegisterRequest as ag, type SchemaResponse as ah, type SqlErrorDetail as ai, type SqlExecuteRequest as aj, type SqlQueryRequest as ak, type SqlQueryResponse as al, type SqlResult as am, type TableMetadata as an, type TenantConnectRequest as ao, type TenantConnectResponse as ap, type TenantListResponse as aq, type TenantObservabilityResponse as ar, type TenantResponse as as, type TenantState as at, type TenantUpdateRequest as au, type TokenResponse as av, type UserCreateResponse as aw, type UserResponse as ax, type ViewMetadata as ay, type WebSocketConstructor as az, type AnonymousRefreshResponse as b, type AnonymousRegisterResponse as c, type AnonymousSecretResponse as d, type AuditLogParams as e, type AuditLogResponse as f, type BatchCreateResponse as g, type BatchDeleteRequest as h, type BatchDeleteResponse as i, type BatchItemError as j, type BatchUpdateRequest as k, type BatchUpdateResponse as l, type BranchRequest as m, type ClaimRequest as n, type ClaimResponse as o, type ColumnInfo as p, type ColumnMetadata as q, type CreateDatabaseRequest as r, type CreateTenantRequest as s, type CreateTenantResponse as t, type CreateTokenRequest as u, type CreateTokenResponse as v, type CreateUserRequest as w, type Credentials as x, type CustomerPasswordResetResponse as y, type CustomerResponse as z };
|