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.
@@ -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
- write: (dbId: string, path: string, content: string) => Promise<void>;
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 SqlQueryResponse as $, type AdminCreateUserRequest as A, type BatchCreateRequest as B, type CredentialStore as C, type DatabaseResponse as D, type DumpRequest as E, type FetchFn as F, type DumpResponse as G, type Endpoint as H, FileCredentialStore as I, type HealthResponse as J, type HttpClient as K, type HttpClientOptions as L, type ListTenantsParams as M, type LoginRequest as N, type LoginResponse as O, MemoryCredentialStore as P, type MessageResponse as Q, type MigrationApplyRequest as R, type MigrationApplyResponse as S, type MigrationMetadata as T, type ObservabilitySummary as U, type PasswordResetResponse as V, type QuerySample as W, type RegisterRequest as X, type SchemaResponse as Y, type SqlExecuteRequest as Z, type SqlQueryRequest as _, type AnonymousRefreshRequest as a, type SqlResult as a0, type TableMetadata as a1, type TenantConnectRequest as a2, type TenantConnectResponse as a3, type TenantListResponse as a4, type TenantObservabilityResponse as a5, type TenantResponse as a6, type TenantState as a7, type TenantUpdateRequest as a8, type TokenResponse as a9, type UserCreateResponse as aa, type UserResponse as ab, type ViewMetadata as ac, createDb9Client as ad, defaultCredentialStore as ae, 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 CreateUserRequest as u, type Credentials as v, type CustomerPasswordResetResponse as w, type CustomerResponse as x, type Db9Client as y, type Db9ClientOptions as z };
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
- write: (dbId: string, path: string, content: string) => Promise<void>;
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 SqlQueryResponse as $, type AdminCreateUserRequest as A, type BatchCreateRequest as B, type CredentialStore as C, type DatabaseResponse as D, type DumpRequest as E, type FetchFn as F, type DumpResponse as G, type Endpoint as H, FileCredentialStore as I, type HealthResponse as J, type HttpClient as K, type HttpClientOptions as L, type ListTenantsParams as M, type LoginRequest as N, type LoginResponse as O, MemoryCredentialStore as P, type MessageResponse as Q, type MigrationApplyRequest as R, type MigrationApplyResponse as S, type MigrationMetadata as T, type ObservabilitySummary as U, type PasswordResetResponse as V, type QuerySample as W, type RegisterRequest as X, type SchemaResponse as Y, type SqlExecuteRequest as Z, type SqlQueryRequest as _, type AnonymousRefreshRequest as a, type SqlResult as a0, type TableMetadata as a1, type TenantConnectRequest as a2, type TenantConnectResponse as a3, type TenantListResponse as a4, type TenantObservabilityResponse as a5, type TenantResponse as a6, type TenantState as a7, type TenantUpdateRequest as a8, type TokenResponse as a9, type UserCreateResponse as aa, type UserResponse as ab, type ViewMetadata as ac, createDb9Client as ad, defaultCredentialStore as ae, 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 CreateUserRequest as u, type Credentials as v, type CustomerPasswordResetResponse as w, type CustomerResponse as x, type Db9Client as y, type Db9ClientOptions as z };
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 };