get-db9 0.4.0 → 0.5.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/dist/{client-fUeI7kwU.d.cts → client-UKXFQNll.d.cts} +62 -17
- package/dist/{client-fUeI7kwU.d.ts → client-UKXFQNll.d.ts} +62 -17
- package/dist/client.cjs +314 -157
- 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 +314 -157
- package/dist/client.js.map +1 -1
- package/dist/index.cjs +318 -158
- 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 +318 -158
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
|
@@ -4,6 +4,9 @@ interface HttpClientOptions {
|
|
|
4
4
|
baseUrl: string;
|
|
5
5
|
fetch?: FetchFn;
|
|
6
6
|
headers?: Record<string, string>;
|
|
7
|
+
timeout?: number;
|
|
8
|
+
maxRetries?: number;
|
|
9
|
+
retryDelay?: number;
|
|
7
10
|
}
|
|
8
11
|
interface HttpClient {
|
|
9
12
|
get<T>(path: string, params?: Record<string, string | undefined>): Promise<T>;
|
|
@@ -12,6 +15,8 @@ interface HttpClient {
|
|
|
12
15
|
del<T>(path: string): Promise<T>;
|
|
13
16
|
getRaw(path: string, params?: Record<string, string | undefined>): Promise<Response>;
|
|
14
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>;
|
|
15
20
|
}
|
|
16
21
|
|
|
17
22
|
/** Credential fields stored in `~/.db9/credentials` (TOML). */
|
|
@@ -49,22 +54,19 @@ declare class MemoryCredentialStore implements CredentialStore {
|
|
|
49
54
|
/** Returns a FileCredentialStore with the default path (`~/.db9/credentials`). */
|
|
50
55
|
declare function defaultCredentialStore(): CredentialStore;
|
|
51
56
|
|
|
52
|
-
/** A file or directory entry from fs9 readdir API */
|
|
53
|
-
interface
|
|
57
|
+
/** A file or directory entry from fs9 readdir/stat API */
|
|
58
|
+
interface Fs9FileEntry {
|
|
54
59
|
path: string;
|
|
55
|
-
type: 'file' | 'dir';
|
|
56
|
-
size: number;
|
|
57
|
-
mode: number;
|
|
58
|
-
mtime: string;
|
|
59
|
-
}
|
|
60
|
-
/** Response from fs9 stat API */
|
|
61
|
-
interface Fs9StatResponse {
|
|
62
|
-
path: string;
|
|
63
|
-
is_dir: boolean;
|
|
64
|
-
is_file: boolean;
|
|
65
60
|
size: number;
|
|
61
|
+
file_type: 'regular' | 'directory' | 'symlink';
|
|
66
62
|
mode: number;
|
|
63
|
+
uid: number;
|
|
64
|
+
gid: number;
|
|
65
|
+
atime: number;
|
|
67
66
|
mtime: number;
|
|
67
|
+
ctime: number;
|
|
68
|
+
etag: string;
|
|
69
|
+
symlink_target?: string;
|
|
68
70
|
}
|
|
69
71
|
/** Options for fs9 list operation */
|
|
70
72
|
interface Fs9ListOptions {
|
|
@@ -91,12 +93,19 @@ interface ColumnInfo {
|
|
|
91
93
|
name: string;
|
|
92
94
|
type: string;
|
|
93
95
|
}
|
|
96
|
+
interface SqlErrorDetail {
|
|
97
|
+
message: string;
|
|
98
|
+
code?: string;
|
|
99
|
+
position?: number;
|
|
100
|
+
hint?: string;
|
|
101
|
+
detail?: string;
|
|
102
|
+
}
|
|
94
103
|
interface SqlResult {
|
|
95
104
|
columns: ColumnInfo[];
|
|
96
105
|
rows: unknown[][];
|
|
97
106
|
row_count: number;
|
|
98
107
|
command: string;
|
|
99
|
-
error?: string;
|
|
108
|
+
error?: string | SqlErrorDetail;
|
|
100
109
|
}
|
|
101
110
|
interface CreateTenantRequest {
|
|
102
111
|
admin_user?: string;
|
|
@@ -291,6 +300,10 @@ interface CreateUserRequest {
|
|
|
291
300
|
username: string;
|
|
292
301
|
password: string;
|
|
293
302
|
}
|
|
303
|
+
interface CreateTokenRequest {
|
|
304
|
+
name?: string;
|
|
305
|
+
expires_in_days?: number;
|
|
306
|
+
}
|
|
294
307
|
interface CustomerResponse {
|
|
295
308
|
id: string;
|
|
296
309
|
email: string;
|
|
@@ -343,6 +356,13 @@ interface TokenResponse {
|
|
|
343
356
|
created_at: string;
|
|
344
357
|
expires_at?: string;
|
|
345
358
|
}
|
|
359
|
+
interface CreateTokenResponse {
|
|
360
|
+
id: string;
|
|
361
|
+
name: string;
|
|
362
|
+
token: string;
|
|
363
|
+
expires_at?: string;
|
|
364
|
+
created_at: string;
|
|
365
|
+
}
|
|
346
366
|
interface DumpResponse {
|
|
347
367
|
sql: string;
|
|
348
368
|
object_count: number;
|
|
@@ -376,6 +396,21 @@ interface MigrationMetadata {
|
|
|
376
396
|
applied_at: string;
|
|
377
397
|
sql_preview: string;
|
|
378
398
|
}
|
|
399
|
+
interface Fs9EventEntry {
|
|
400
|
+
id: string;
|
|
401
|
+
type: string;
|
|
402
|
+
path: string;
|
|
403
|
+
timestamp: string;
|
|
404
|
+
user_id?: string;
|
|
405
|
+
size?: number;
|
|
406
|
+
metadata?: Record<string, unknown>;
|
|
407
|
+
}
|
|
408
|
+
interface Fs9EventOptions {
|
|
409
|
+
limit?: number;
|
|
410
|
+
offset?: number;
|
|
411
|
+
path?: string;
|
|
412
|
+
type?: string;
|
|
413
|
+
}
|
|
379
414
|
type TenantState = 'CREATING' | 'ACTIVE' | 'DISABLING' | 'DISABLED' | 'CREATE_FAILED';
|
|
380
415
|
|
|
381
416
|
interface Db9ClientOptions {
|
|
@@ -383,6 +418,9 @@ interface Db9ClientOptions {
|
|
|
383
418
|
token?: string;
|
|
384
419
|
fetch?: FetchFn;
|
|
385
420
|
credentialStore?: CredentialStore;
|
|
421
|
+
timeout?: number;
|
|
422
|
+
maxRetries?: number;
|
|
423
|
+
retryDelay?: number;
|
|
386
424
|
}
|
|
387
425
|
declare function createDb9Client(options?: Db9ClientOptions): {
|
|
388
426
|
auth: {
|
|
@@ -393,10 +431,12 @@ declare function createDb9Client(options?: Db9ClientOptions): {
|
|
|
393
431
|
me: () => Promise<CustomerResponse>;
|
|
394
432
|
getAnonymousSecret: () => Promise<AnonymousSecretResponse>;
|
|
395
433
|
claim: (req: ClaimRequest) => Promise<ClaimResponse>;
|
|
434
|
+
ensureAnonymousSecret: () => Promise<void>;
|
|
396
435
|
};
|
|
397
436
|
tokens: {
|
|
398
437
|
list: () => Promise<TokenResponse[]>;
|
|
399
438
|
revoke: (tokenId: string) => Promise<MessageResponse>;
|
|
439
|
+
create: (req: CreateTokenRequest) => Promise<CreateTokenResponse>;
|
|
400
440
|
};
|
|
401
441
|
databases: {
|
|
402
442
|
create: (req: CreateDatabaseRequest) => Promise<DatabaseResponse>;
|
|
@@ -419,12 +459,17 @@ declare function createDb9Client(options?: Db9ClientOptions): {
|
|
|
419
459
|
};
|
|
420
460
|
};
|
|
421
461
|
fs: {
|
|
422
|
-
list: (dbId: string, path: string, options?: Fs9ListOptions) => Promise<
|
|
462
|
+
list: (dbId: string, path: string, options?: Fs9ListOptions) => Promise<Fs9FileEntry[]>;
|
|
423
463
|
read: (dbId: string, path: string) => Promise<string>;
|
|
424
|
-
|
|
425
|
-
|
|
464
|
+
readBinary: (dbId: string, path: string) => Promise<ArrayBuffer>;
|
|
465
|
+
write: (dbId: string, path: string, content: string | ArrayBuffer | Uint8Array | Blob) => Promise<void>;
|
|
466
|
+
stat: (dbId: string, path: string) => Promise<Fs9FileEntry>;
|
|
467
|
+
exists: (dbId: string, path: string) => Promise<boolean>;
|
|
468
|
+
mkdir: (dbId: string, path: string) => Promise<void>;
|
|
469
|
+
remove: (dbId: string, path: string) => Promise<void>;
|
|
470
|
+
events: (dbId: string, options?: Fs9EventOptions) => Promise<Fs9EventEntry[]>;
|
|
426
471
|
};
|
|
427
472
|
};
|
|
428
473
|
type Db9Client = ReturnType<typeof createDb9Client>;
|
|
429
474
|
|
|
430
|
-
export { type
|
|
475
|
+
export { type RegisterRequest 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 DumpRequest as H, type DumpResponse as I, type Endpoint as J, FileCredentialStore as K, type Fs9EventEntry as L, type Fs9EventOptions as M, type HealthResponse as N, type HttpClient as O, type HttpClientOptions as P, type ListTenantsParams as Q, type LoginRequest as R, type LoginResponse as S, MemoryCredentialStore as T, type MessageResponse as U, type MigrationApplyRequest as V, type MigrationApplyResponse as W, type MigrationMetadata as X, type ObservabilitySummary as Y, type PasswordResetResponse as Z, type QuerySample as _, type AnonymousRefreshRequest as a, type SchemaResponse as a0, type SqlErrorDetail as a1, type SqlExecuteRequest as a2, type SqlQueryRequest as a3, type SqlQueryResponse as a4, type SqlResult as a5, type TableMetadata as a6, type TenantConnectRequest as a7, type TenantConnectResponse as a8, type TenantListResponse as a9, type TenantObservabilityResponse as aa, type TenantResponse as ab, type TenantState as ac, type TenantUpdateRequest as ad, type TokenResponse as ae, type UserCreateResponse as af, type UserResponse as ag, type ViewMetadata as ah, createDb9Client as ai, defaultCredentialStore as aj, 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 };
|
|
@@ -4,6 +4,9 @@ interface HttpClientOptions {
|
|
|
4
4
|
baseUrl: string;
|
|
5
5
|
fetch?: FetchFn;
|
|
6
6
|
headers?: Record<string, string>;
|
|
7
|
+
timeout?: number;
|
|
8
|
+
maxRetries?: number;
|
|
9
|
+
retryDelay?: number;
|
|
7
10
|
}
|
|
8
11
|
interface HttpClient {
|
|
9
12
|
get<T>(path: string, params?: Record<string, string | undefined>): Promise<T>;
|
|
@@ -12,6 +15,8 @@ interface HttpClient {
|
|
|
12
15
|
del<T>(path: string): Promise<T>;
|
|
13
16
|
getRaw(path: string, params?: Record<string, string | undefined>): Promise<Response>;
|
|
14
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>;
|
|
15
20
|
}
|
|
16
21
|
|
|
17
22
|
/** Credential fields stored in `~/.db9/credentials` (TOML). */
|
|
@@ -49,22 +54,19 @@ declare class MemoryCredentialStore implements CredentialStore {
|
|
|
49
54
|
/** Returns a FileCredentialStore with the default path (`~/.db9/credentials`). */
|
|
50
55
|
declare function defaultCredentialStore(): CredentialStore;
|
|
51
56
|
|
|
52
|
-
/** A file or directory entry from fs9 readdir API */
|
|
53
|
-
interface
|
|
57
|
+
/** A file or directory entry from fs9 readdir/stat API */
|
|
58
|
+
interface Fs9FileEntry {
|
|
54
59
|
path: string;
|
|
55
|
-
type: 'file' | 'dir';
|
|
56
|
-
size: number;
|
|
57
|
-
mode: number;
|
|
58
|
-
mtime: string;
|
|
59
|
-
}
|
|
60
|
-
/** Response from fs9 stat API */
|
|
61
|
-
interface Fs9StatResponse {
|
|
62
|
-
path: string;
|
|
63
|
-
is_dir: boolean;
|
|
64
|
-
is_file: boolean;
|
|
65
60
|
size: number;
|
|
61
|
+
file_type: 'regular' | 'directory' | 'symlink';
|
|
66
62
|
mode: number;
|
|
63
|
+
uid: number;
|
|
64
|
+
gid: number;
|
|
65
|
+
atime: number;
|
|
67
66
|
mtime: number;
|
|
67
|
+
ctime: number;
|
|
68
|
+
etag: string;
|
|
69
|
+
symlink_target?: string;
|
|
68
70
|
}
|
|
69
71
|
/** Options for fs9 list operation */
|
|
70
72
|
interface Fs9ListOptions {
|
|
@@ -91,12 +93,19 @@ interface ColumnInfo {
|
|
|
91
93
|
name: string;
|
|
92
94
|
type: string;
|
|
93
95
|
}
|
|
96
|
+
interface SqlErrorDetail {
|
|
97
|
+
message: string;
|
|
98
|
+
code?: string;
|
|
99
|
+
position?: number;
|
|
100
|
+
hint?: string;
|
|
101
|
+
detail?: string;
|
|
102
|
+
}
|
|
94
103
|
interface SqlResult {
|
|
95
104
|
columns: ColumnInfo[];
|
|
96
105
|
rows: unknown[][];
|
|
97
106
|
row_count: number;
|
|
98
107
|
command: string;
|
|
99
|
-
error?: string;
|
|
108
|
+
error?: string | SqlErrorDetail;
|
|
100
109
|
}
|
|
101
110
|
interface CreateTenantRequest {
|
|
102
111
|
admin_user?: string;
|
|
@@ -291,6 +300,10 @@ interface CreateUserRequest {
|
|
|
291
300
|
username: string;
|
|
292
301
|
password: string;
|
|
293
302
|
}
|
|
303
|
+
interface CreateTokenRequest {
|
|
304
|
+
name?: string;
|
|
305
|
+
expires_in_days?: number;
|
|
306
|
+
}
|
|
294
307
|
interface CustomerResponse {
|
|
295
308
|
id: string;
|
|
296
309
|
email: string;
|
|
@@ -343,6 +356,13 @@ interface TokenResponse {
|
|
|
343
356
|
created_at: string;
|
|
344
357
|
expires_at?: string;
|
|
345
358
|
}
|
|
359
|
+
interface CreateTokenResponse {
|
|
360
|
+
id: string;
|
|
361
|
+
name: string;
|
|
362
|
+
token: string;
|
|
363
|
+
expires_at?: string;
|
|
364
|
+
created_at: string;
|
|
365
|
+
}
|
|
346
366
|
interface DumpResponse {
|
|
347
367
|
sql: string;
|
|
348
368
|
object_count: number;
|
|
@@ -376,6 +396,21 @@ interface MigrationMetadata {
|
|
|
376
396
|
applied_at: string;
|
|
377
397
|
sql_preview: string;
|
|
378
398
|
}
|
|
399
|
+
interface Fs9EventEntry {
|
|
400
|
+
id: string;
|
|
401
|
+
type: string;
|
|
402
|
+
path: string;
|
|
403
|
+
timestamp: string;
|
|
404
|
+
user_id?: string;
|
|
405
|
+
size?: number;
|
|
406
|
+
metadata?: Record<string, unknown>;
|
|
407
|
+
}
|
|
408
|
+
interface Fs9EventOptions {
|
|
409
|
+
limit?: number;
|
|
410
|
+
offset?: number;
|
|
411
|
+
path?: string;
|
|
412
|
+
type?: string;
|
|
413
|
+
}
|
|
379
414
|
type TenantState = 'CREATING' | 'ACTIVE' | 'DISABLING' | 'DISABLED' | 'CREATE_FAILED';
|
|
380
415
|
|
|
381
416
|
interface Db9ClientOptions {
|
|
@@ -383,6 +418,9 @@ interface Db9ClientOptions {
|
|
|
383
418
|
token?: string;
|
|
384
419
|
fetch?: FetchFn;
|
|
385
420
|
credentialStore?: CredentialStore;
|
|
421
|
+
timeout?: number;
|
|
422
|
+
maxRetries?: number;
|
|
423
|
+
retryDelay?: number;
|
|
386
424
|
}
|
|
387
425
|
declare function createDb9Client(options?: Db9ClientOptions): {
|
|
388
426
|
auth: {
|
|
@@ -393,10 +431,12 @@ declare function createDb9Client(options?: Db9ClientOptions): {
|
|
|
393
431
|
me: () => Promise<CustomerResponse>;
|
|
394
432
|
getAnonymousSecret: () => Promise<AnonymousSecretResponse>;
|
|
395
433
|
claim: (req: ClaimRequest) => Promise<ClaimResponse>;
|
|
434
|
+
ensureAnonymousSecret: () => Promise<void>;
|
|
396
435
|
};
|
|
397
436
|
tokens: {
|
|
398
437
|
list: () => Promise<TokenResponse[]>;
|
|
399
438
|
revoke: (tokenId: string) => Promise<MessageResponse>;
|
|
439
|
+
create: (req: CreateTokenRequest) => Promise<CreateTokenResponse>;
|
|
400
440
|
};
|
|
401
441
|
databases: {
|
|
402
442
|
create: (req: CreateDatabaseRequest) => Promise<DatabaseResponse>;
|
|
@@ -419,12 +459,17 @@ declare function createDb9Client(options?: Db9ClientOptions): {
|
|
|
419
459
|
};
|
|
420
460
|
};
|
|
421
461
|
fs: {
|
|
422
|
-
list: (dbId: string, path: string, options?: Fs9ListOptions) => Promise<
|
|
462
|
+
list: (dbId: string, path: string, options?: Fs9ListOptions) => Promise<Fs9FileEntry[]>;
|
|
423
463
|
read: (dbId: string, path: string) => Promise<string>;
|
|
424
|
-
|
|
425
|
-
|
|
464
|
+
readBinary: (dbId: string, path: string) => Promise<ArrayBuffer>;
|
|
465
|
+
write: (dbId: string, path: string, content: string | ArrayBuffer | Uint8Array | Blob) => Promise<void>;
|
|
466
|
+
stat: (dbId: string, path: string) => Promise<Fs9FileEntry>;
|
|
467
|
+
exists: (dbId: string, path: string) => Promise<boolean>;
|
|
468
|
+
mkdir: (dbId: string, path: string) => Promise<void>;
|
|
469
|
+
remove: (dbId: string, path: string) => Promise<void>;
|
|
470
|
+
events: (dbId: string, options?: Fs9EventOptions) => Promise<Fs9EventEntry[]>;
|
|
426
471
|
};
|
|
427
472
|
};
|
|
428
473
|
type Db9Client = ReturnType<typeof createDb9Client>;
|
|
429
474
|
|
|
430
|
-
export { type
|
|
475
|
+
export { type RegisterRequest 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 DumpRequest as H, type DumpResponse as I, type Endpoint as J, FileCredentialStore as K, type Fs9EventEntry as L, type Fs9EventOptions as M, type HealthResponse as N, type HttpClient as O, type HttpClientOptions as P, type ListTenantsParams as Q, type LoginRequest as R, type LoginResponse as S, MemoryCredentialStore as T, type MessageResponse as U, type MigrationApplyRequest as V, type MigrationApplyResponse as W, type MigrationMetadata as X, type ObservabilitySummary as Y, type PasswordResetResponse as Z, type QuerySample as _, type AnonymousRefreshRequest as a, type SchemaResponse as a0, type SqlErrorDetail as a1, type SqlExecuteRequest as a2, type SqlQueryRequest as a3, type SqlQueryResponse as a4, type SqlResult as a5, type TableMetadata as a6, type TenantConnectRequest as a7, type TenantConnectResponse as a8, type TenantListResponse as a9, type TenantObservabilityResponse as aa, type TenantResponse as ab, type TenantState as ac, type TenantUpdateRequest as ad, type TokenResponse as ae, type UserCreateResponse as af, type UserResponse as ag, type ViewMetadata as ah, createDb9Client as ai, defaultCredentialStore as aj, 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 };
|