get-db9 0.4.1 → 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-CXv2ZlbR.d.cts → client-UKXFQNll.d.cts} +49 -3
- package/dist/{client-CXv2ZlbR.d.ts → client-UKXFQNll.d.ts} +49 -3
- package/dist/client.cjs +309 -176
- 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 +309 -176
- package/dist/client.js.map +1 -1
- package/dist/index.cjs +313 -177
- 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 +313 -177
- 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). */
|
|
@@ -88,12 +93,19 @@ interface ColumnInfo {
|
|
|
88
93
|
name: string;
|
|
89
94
|
type: string;
|
|
90
95
|
}
|
|
96
|
+
interface SqlErrorDetail {
|
|
97
|
+
message: string;
|
|
98
|
+
code?: string;
|
|
99
|
+
position?: number;
|
|
100
|
+
hint?: string;
|
|
101
|
+
detail?: string;
|
|
102
|
+
}
|
|
91
103
|
interface SqlResult {
|
|
92
104
|
columns: ColumnInfo[];
|
|
93
105
|
rows: unknown[][];
|
|
94
106
|
row_count: number;
|
|
95
107
|
command: string;
|
|
96
|
-
error?: string;
|
|
108
|
+
error?: string | SqlErrorDetail;
|
|
97
109
|
}
|
|
98
110
|
interface CreateTenantRequest {
|
|
99
111
|
admin_user?: string;
|
|
@@ -288,6 +300,10 @@ interface CreateUserRequest {
|
|
|
288
300
|
username: string;
|
|
289
301
|
password: string;
|
|
290
302
|
}
|
|
303
|
+
interface CreateTokenRequest {
|
|
304
|
+
name?: string;
|
|
305
|
+
expires_in_days?: number;
|
|
306
|
+
}
|
|
291
307
|
interface CustomerResponse {
|
|
292
308
|
id: string;
|
|
293
309
|
email: string;
|
|
@@ -340,6 +356,13 @@ interface TokenResponse {
|
|
|
340
356
|
created_at: string;
|
|
341
357
|
expires_at?: string;
|
|
342
358
|
}
|
|
359
|
+
interface CreateTokenResponse {
|
|
360
|
+
id: string;
|
|
361
|
+
name: string;
|
|
362
|
+
token: string;
|
|
363
|
+
expires_at?: string;
|
|
364
|
+
created_at: string;
|
|
365
|
+
}
|
|
343
366
|
interface DumpResponse {
|
|
344
367
|
sql: string;
|
|
345
368
|
object_count: number;
|
|
@@ -373,6 +396,21 @@ interface MigrationMetadata {
|
|
|
373
396
|
applied_at: string;
|
|
374
397
|
sql_preview: string;
|
|
375
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
|
+
}
|
|
376
414
|
type TenantState = 'CREATING' | 'ACTIVE' | 'DISABLING' | 'DISABLED' | 'CREATE_FAILED';
|
|
377
415
|
|
|
378
416
|
interface Db9ClientOptions {
|
|
@@ -380,6 +418,9 @@ interface Db9ClientOptions {
|
|
|
380
418
|
token?: string;
|
|
381
419
|
fetch?: FetchFn;
|
|
382
420
|
credentialStore?: CredentialStore;
|
|
421
|
+
timeout?: number;
|
|
422
|
+
maxRetries?: number;
|
|
423
|
+
retryDelay?: number;
|
|
383
424
|
}
|
|
384
425
|
declare function createDb9Client(options?: Db9ClientOptions): {
|
|
385
426
|
auth: {
|
|
@@ -390,10 +431,12 @@ declare function createDb9Client(options?: Db9ClientOptions): {
|
|
|
390
431
|
me: () => Promise<CustomerResponse>;
|
|
391
432
|
getAnonymousSecret: () => Promise<AnonymousSecretResponse>;
|
|
392
433
|
claim: (req: ClaimRequest) => Promise<ClaimResponse>;
|
|
434
|
+
ensureAnonymousSecret: () => Promise<void>;
|
|
393
435
|
};
|
|
394
436
|
tokens: {
|
|
395
437
|
list: () => Promise<TokenResponse[]>;
|
|
396
438
|
revoke: (tokenId: string) => Promise<MessageResponse>;
|
|
439
|
+
create: (req: CreateTokenRequest) => Promise<CreateTokenResponse>;
|
|
397
440
|
};
|
|
398
441
|
databases: {
|
|
399
442
|
create: (req: CreateDatabaseRequest) => Promise<DatabaseResponse>;
|
|
@@ -418,12 +461,15 @@ declare function createDb9Client(options?: Db9ClientOptions): {
|
|
|
418
461
|
fs: {
|
|
419
462
|
list: (dbId: string, path: string, options?: Fs9ListOptions) => Promise<Fs9FileEntry[]>;
|
|
420
463
|
read: (dbId: string, path: string) => Promise<string>;
|
|
421
|
-
|
|
464
|
+
readBinary: (dbId: string, path: string) => Promise<ArrayBuffer>;
|
|
465
|
+
write: (dbId: string, path: string, content: string | ArrayBuffer | Uint8Array | Blob) => Promise<void>;
|
|
422
466
|
stat: (dbId: string, path: string) => Promise<Fs9FileEntry>;
|
|
467
|
+
exists: (dbId: string, path: string) => Promise<boolean>;
|
|
423
468
|
mkdir: (dbId: string, path: string) => Promise<void>;
|
|
424
469
|
remove: (dbId: string, path: string) => Promise<void>;
|
|
470
|
+
events: (dbId: string, options?: Fs9EventOptions) => Promise<Fs9EventEntry[]>;
|
|
425
471
|
};
|
|
426
472
|
};
|
|
427
473
|
type Db9Client = ReturnType<typeof createDb9Client>;
|
|
428
474
|
|
|
429
|
-
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). */
|
|
@@ -88,12 +93,19 @@ interface ColumnInfo {
|
|
|
88
93
|
name: string;
|
|
89
94
|
type: string;
|
|
90
95
|
}
|
|
96
|
+
interface SqlErrorDetail {
|
|
97
|
+
message: string;
|
|
98
|
+
code?: string;
|
|
99
|
+
position?: number;
|
|
100
|
+
hint?: string;
|
|
101
|
+
detail?: string;
|
|
102
|
+
}
|
|
91
103
|
interface SqlResult {
|
|
92
104
|
columns: ColumnInfo[];
|
|
93
105
|
rows: unknown[][];
|
|
94
106
|
row_count: number;
|
|
95
107
|
command: string;
|
|
96
|
-
error?: string;
|
|
108
|
+
error?: string | SqlErrorDetail;
|
|
97
109
|
}
|
|
98
110
|
interface CreateTenantRequest {
|
|
99
111
|
admin_user?: string;
|
|
@@ -288,6 +300,10 @@ interface CreateUserRequest {
|
|
|
288
300
|
username: string;
|
|
289
301
|
password: string;
|
|
290
302
|
}
|
|
303
|
+
interface CreateTokenRequest {
|
|
304
|
+
name?: string;
|
|
305
|
+
expires_in_days?: number;
|
|
306
|
+
}
|
|
291
307
|
interface CustomerResponse {
|
|
292
308
|
id: string;
|
|
293
309
|
email: string;
|
|
@@ -340,6 +356,13 @@ interface TokenResponse {
|
|
|
340
356
|
created_at: string;
|
|
341
357
|
expires_at?: string;
|
|
342
358
|
}
|
|
359
|
+
interface CreateTokenResponse {
|
|
360
|
+
id: string;
|
|
361
|
+
name: string;
|
|
362
|
+
token: string;
|
|
363
|
+
expires_at?: string;
|
|
364
|
+
created_at: string;
|
|
365
|
+
}
|
|
343
366
|
interface DumpResponse {
|
|
344
367
|
sql: string;
|
|
345
368
|
object_count: number;
|
|
@@ -373,6 +396,21 @@ interface MigrationMetadata {
|
|
|
373
396
|
applied_at: string;
|
|
374
397
|
sql_preview: string;
|
|
375
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
|
+
}
|
|
376
414
|
type TenantState = 'CREATING' | 'ACTIVE' | 'DISABLING' | 'DISABLED' | 'CREATE_FAILED';
|
|
377
415
|
|
|
378
416
|
interface Db9ClientOptions {
|
|
@@ -380,6 +418,9 @@ interface Db9ClientOptions {
|
|
|
380
418
|
token?: string;
|
|
381
419
|
fetch?: FetchFn;
|
|
382
420
|
credentialStore?: CredentialStore;
|
|
421
|
+
timeout?: number;
|
|
422
|
+
maxRetries?: number;
|
|
423
|
+
retryDelay?: number;
|
|
383
424
|
}
|
|
384
425
|
declare function createDb9Client(options?: Db9ClientOptions): {
|
|
385
426
|
auth: {
|
|
@@ -390,10 +431,12 @@ declare function createDb9Client(options?: Db9ClientOptions): {
|
|
|
390
431
|
me: () => Promise<CustomerResponse>;
|
|
391
432
|
getAnonymousSecret: () => Promise<AnonymousSecretResponse>;
|
|
392
433
|
claim: (req: ClaimRequest) => Promise<ClaimResponse>;
|
|
434
|
+
ensureAnonymousSecret: () => Promise<void>;
|
|
393
435
|
};
|
|
394
436
|
tokens: {
|
|
395
437
|
list: () => Promise<TokenResponse[]>;
|
|
396
438
|
revoke: (tokenId: string) => Promise<MessageResponse>;
|
|
439
|
+
create: (req: CreateTokenRequest) => Promise<CreateTokenResponse>;
|
|
397
440
|
};
|
|
398
441
|
databases: {
|
|
399
442
|
create: (req: CreateDatabaseRequest) => Promise<DatabaseResponse>;
|
|
@@ -418,12 +461,15 @@ declare function createDb9Client(options?: Db9ClientOptions): {
|
|
|
418
461
|
fs: {
|
|
419
462
|
list: (dbId: string, path: string, options?: Fs9ListOptions) => Promise<Fs9FileEntry[]>;
|
|
420
463
|
read: (dbId: string, path: string) => Promise<string>;
|
|
421
|
-
|
|
464
|
+
readBinary: (dbId: string, path: string) => Promise<ArrayBuffer>;
|
|
465
|
+
write: (dbId: string, path: string, content: string | ArrayBuffer | Uint8Array | Blob) => Promise<void>;
|
|
422
466
|
stat: (dbId: string, path: string) => Promise<Fs9FileEntry>;
|
|
467
|
+
exists: (dbId: string, path: string) => Promise<boolean>;
|
|
423
468
|
mkdir: (dbId: string, path: string) => Promise<void>;
|
|
424
469
|
remove: (dbId: string, path: string) => Promise<void>;
|
|
470
|
+
events: (dbId: string, options?: Fs9EventOptions) => Promise<Fs9EventEntry[]>;
|
|
425
471
|
};
|
|
426
472
|
};
|
|
427
473
|
type Db9Client = ReturnType<typeof createDb9Client>;
|
|
428
474
|
|
|
429
|
-
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 };
|